# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1265062630 -7200 # Node ID f3d95d9c00abeb5e24982736e480bba6e3b1078d Revision: 201003 Kit: 201005 diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/bwins/fmradioactiveidleengine200u.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/bwins/fmradioactiveidleengine200u.def Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,19 @@ +EXPORTS + ?FrequencyDecimalCount@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSFrequencyDecimalCount@@XZ @ 1 NONAME ; enum TFMRadioPSFrequencyDecimalCount CFMRadioActiveIdleEngine::FrequencyDecimalCount(void) const + ?SetMuteState@CFMRadioActiveIdleEngine@@QBEXW4TFMRadioPSRadioMuteState@@@Z @ 2 NONAME ; void CFMRadioActiveIdleEngine::SetMuteState(enum TFMRadioPSRadioMuteState) const + ?Channel@CFMRadioActiveIdleEngine@@QBEHXZ @ 3 NONAME ; int CFMRadioActiveIdleEngine::Channel(void) const + ??1CFMRadioActiveIdleEngine@@UAE@XZ @ 4 NONAME ; CFMRadioActiveIdleEngine::~CFMRadioActiveIdleEngine(void) + ?Cancel@CFMRadioActiveIdleEngine@@QAEXXZ @ 5 NONAME ; void CFMRadioActiveIdleEngine::Cancel(void) + ?ApplicationRunningState@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSApplicationRunningState@@XZ @ 6 NONAME ; enum TFMRadioPSApplicationRunningState CFMRadioActiveIdleEngine::ApplicationRunningState(void) const + ?AdjustRadioVolume@CFMRadioActiveIdleEngine@@QBEXW4TFMRadioPSAdjustVolume@@@Z @ 7 NONAME ; void CFMRadioActiveIdleEngine::AdjustRadioVolume(enum TFMRadioPSAdjustVolume) const + ?MuteState@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSRadioMuteState@@XZ @ 8 NONAME ; enum TFMRadioPSRadioMuteState CFMRadioActiveIdleEngine::MuteState(void) const + ?ChannelName@CFMRadioActiveIdleEngine@@QBEABVTDesC16@@XZ @ 9 NONAME ; class TDesC16 const & CFMRadioActiveIdleEngine::ChannelName(void) const + ?TuningState@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSTuningState@@XZ @ 10 NONAME ; enum TFMRadioPSTuningState CFMRadioActiveIdleEngine::TuningState(void) const + ?NewL@CFMRadioActiveIdleEngine@@SAPAV1@AAVMFMRadioActiveIdleEngineNotifyHandler@@@Z @ 11 NONAME ; class CFMRadioActiveIdleEngine * CFMRadioActiveIdleEngine::NewL(class MFMRadioActiveIdleEngineNotifyHandler &) + ?PowerState@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSRadioPowerState@@XZ @ 12 NONAME ; enum TFMRadioPSRadioPowerState CFMRadioActiveIdleEngine::PowerState(void) const + ?AntennaStatus@CFMRadioActiveIdleEngine@@QBE?AW4TFMRadioPSHeadsetStatus@@XZ @ 13 NONAME ; enum TFMRadioPSHeadsetStatus CFMRadioActiveIdleEngine::AntennaStatus(void) const + ?Frequency@CFMRadioActiveIdleEngine@@QBEHXZ @ 14 NONAME ; int CFMRadioActiveIdleEngine::Frequency(void) const + ?RDSProgramService@CFMRadioActiveIdleEngine@@QBEABVTDesC16@@XZ @ 15 NONAME ; class TDesC16 const & CFMRadioActiveIdleEngine::RDSProgramService(void) const + ?RadioVolume@CFMRadioActiveIdleEngine@@QBEHXZ @ 16 NONAME ; int CFMRadioActiveIdleEngine::RadioVolume(void) const + ?ActivateL@CFMRadioActiveIdleEngine@@QAEXXZ @ 17 NONAME ; void CFMRadioActiveIdleEngine::ActivateL(void) + diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/eabi/fmradioactiveidleengine200u.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/eabi/fmradioactiveidleengine200u.def Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,23 @@ +EXPORTS + _ZN24CFMRadioActiveIdleEngine4NewLER37MFMRadioActiveIdleEngineNotifyHandler @ 1 NONAME + _ZN24CFMRadioActiveIdleEngine6CancelEv @ 2 NONAME + _ZN24CFMRadioActiveIdleEngine9ActivateLEv @ 3 NONAME + _ZN24CFMRadioActiveIdleEngineD0Ev @ 4 NONAME + _ZN24CFMRadioActiveIdleEngineD1Ev @ 5 NONAME + _ZN24CFMRadioActiveIdleEngineD2Ev @ 6 NONAME + _ZNK24CFMRadioActiveIdleEngine10PowerStateEv @ 7 NONAME + _ZNK24CFMRadioActiveIdleEngine11ChannelNameEv @ 8 NONAME + _ZNK24CFMRadioActiveIdleEngine11RadioVolumeEv @ 9 NONAME + _ZNK24CFMRadioActiveIdleEngine11TuningStateEv @ 10 NONAME + _ZNK24CFMRadioActiveIdleEngine12SetMuteStateE24TFMRadioPSRadioMuteState @ 11 NONAME + _ZNK24CFMRadioActiveIdleEngine13AntennaStatusEv @ 12 NONAME + _ZNK24CFMRadioActiveIdleEngine17AdjustRadioVolumeE22TFMRadioPSAdjustVolume @ 13 NONAME + _ZNK24CFMRadioActiveIdleEngine17RDSProgramServiceEv @ 14 NONAME + _ZNK24CFMRadioActiveIdleEngine21FrequencyDecimalCountEv @ 15 NONAME + _ZNK24CFMRadioActiveIdleEngine23ApplicationRunningStateEv @ 16 NONAME + _ZNK24CFMRadioActiveIdleEngine7ChannelEv @ 17 NONAME + _ZNK24CFMRadioActiveIdleEngine9FrequencyEv @ 18 NONAME + _ZNK24CFMRadioActiveIdleEngine9MuteStateEv @ 19 NONAME + _ZTI24CFMRadioPropertyObserver @ 20 NONAME ; ## + _ZTV24CFMRadioPropertyObserver @ 21 NONAME ; ## + diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/group/bld.inf Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,33 @@ +/* +* 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: Build configuration for FMRadio active idle engine +* +*/ + +#include + +// Platforms the component needs to be built on +// + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES +fmradioactiveidleengine.mmp + + + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/group/fmradioactiveidleengine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/group/fmradioactiveidleengine.mmp Tue Feb 02 00:17:10 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: Project definition file for project FMRadio active idle engine +* +*/ + + +// To get the APP_LAYER_SYSTEMINCLUDE-definition +#include +#include "../../inc/fmradioactiveidle.hrh" + +TARGET fmradioactiveidleengine200.dll +TARGETTYPE DLL +UID 0x1000006C AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_FMRADIOPLUGIN +VERSION 20.0 + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +PAGED + +SOURCEPATH ../src +SOURCE fmradioactiveidleengine.cpp + +SOURCEPATH ../../fmradioengine/src +SOURCE fmradiopropertyobserver.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../fmradioengine/inc + +// Default system include paths for application layer modules. +APP_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +DEBUGLIBRARY flogger.lib \ No newline at end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/inc/fmradioactiveidleengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/inc/fmradioactiveidleengine.h Tue Feb 02 00:17:10 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: Engine component for FMRadio Active Idle plugin. +* +*/ + + +#ifndef __FMRADIOACTIVEIDLEENGINE_H__ +#define __FMRADIOACTIVEIDLEENGINE_H__ + +#include +#include + +#include "fmradiopropertyobserver.h" + +class MFMRadioActiveIdleEngineNotifyHandler; + + +/** +* Engine component for FMRadio Active Idle plugin. +* +* This class is responsible for listening to relevant P&S keys and notifying the UI code whenever the listened keys change. +* The actual listening is done by multiple CFMRadioPropertyObserver objects. +* +* @lib fmradioactiveidleengine200.lib +* +*/ +NONSHARABLE_CLASS(CFMRadioActiveIdleEngine) : public CBase, public MFMRadioPropertyChangeObserver + { + public: + + /** + * Static constructor. + * @param aObserver The observer to be notified of the changes in the keys. + * @return The newly created CFMRadioActiveIdleEngine object. + */ + IMPORT_C static CFMRadioActiveIdleEngine* NewL( MFMRadioActiveIdleEngineNotifyHandler& aObserver ); + + /** + * Destructor. + */ + IMPORT_C ~CFMRadioActiveIdleEngine(); + + /** + * Activates subscription to P&S keys if not already active. + * Must be called after CFMRadioActiveIdleEngine::NewL, or after Cancel. + */ + IMPORT_C void ActivateL(); + + /** + * Stops subscribing to P&S keys. + */ + IMPORT_C void Cancel(); + + /** + * Returns the current volume level of the radio. + * @return The current volume level of the radio. + */ + IMPORT_C TInt RadioVolume() const; + + /** + * Sets the radio volume. + * @param aVolume The radio volume to set. + */ + IMPORT_C void AdjustRadioVolume( TFMRadioPSAdjustVolume aVolume ) const; + + /** + * Returns the current tuning state. + * @return The current tuning state. + */ + IMPORT_C TFMRadioPSTuningState TuningState() const; + + /** + * Returns the current frequency. + * @return The current frequency. + */ + IMPORT_C TInt Frequency() const; + + /** + * Returns the current channel ID. + * @return The current channel ID. + */ + IMPORT_C TInt Channel() const; + + /** + * Returns the current channel name. + * @return The current channel name. + */ + IMPORT_C const TDesC& ChannelName() const; + + /** + * Returns the current mute state. + * @return The current mute state. + */ + IMPORT_C TFMRadioPSRadioMuteState MuteState() const; + + /** + * Sets the mute state. + * @param aMuteState The mute state to set. + */ + IMPORT_C void SetMuteState( TFMRadioPSRadioMuteState aMuteState ) const; + + /** + * Returns the antenna's current connectivity status. + * @return The antenna's current connectivity status. + */ + IMPORT_C TFMRadioPSHeadsetStatus AntennaStatus() const; + + /** + * Returns the current frequency decimal count. + * @return The current frequency decimal count. + */ + IMPORT_C TFMRadioPSFrequencyDecimalCount FrequencyDecimalCount() const; + + /** + * Returns FM Radio application's running state. + * @return Application's running state. + */ + IMPORT_C TFMRadioPSApplicationRunningState ApplicationRunningState() const; + + /** + * Returns the radio's power state. + * @return The power state. + */ + IMPORT_C TFMRadioPSRadioPowerState PowerState() const; + + /** + * Returns the RDS Program Service information. + * @return RDS Program Service. + */ + IMPORT_C const TDesC& RDSProgramService() const; + + protected: + + // from base class MFMRadioPropertyChangeObserver + void HandlePropertyChangeL( const TUid& aCategory, TUint aKey, TInt aValue ); + void HandlePropertyChangeL( const TUid& aCategory, TUint aKey, const TDesC8& aValue ); + void HandlePropertyChangeL( const TUid& aCategory, TUint aKey, const TDesC& aValue ); + void HandlePropertyChangeErrorL( const TUid& aCategory, TUint aKey, TInt aError ); + + private: + + /** + * Constructor. + * @param aObserver The observer to be notified of the changes in the keys. + */ + CFMRadioActiveIdleEngine( MFMRadioActiveIdleEngineNotifyHandler& aObserver ); + + /** + * Second-phase constructor. + */ + void ConstructL(); + + protected: + + /** The observer to be notified of the changes in the listened keys. */ + MFMRadioActiveIdleEngineNotifyHandler& iObserver; + /** Array of status observers. */ + RPointerArray iPropertyObserverArray; + + private: + + }; + +#endif //__FMRADIOACTIVEIDLEENGINE_H__ diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/inc/fmradioactiveidleenginenotifyhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/inc/fmradioactiveidleenginenotifyhandler.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,115 @@ +/* +* 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: Observer interface for active idle engine +* +*/ + + +#ifndef __FMRADIOACTIVEIDLEENGINENOTIFYHANDLER_H__ +#define __FMRADIOACTIVEIDLEENGINENOTIFYHANDLER_H__ + +#include + +/** +* Observer interface for active idle engine. +* The observer is notified about the changes in relevant keys through this interface. +*/ +NONSHARABLE_CLASS(MFMRadioActiveIdleEngineNotifyHandler) + { + public: + + /** + * Invoked when the radio volume has changed. + * @param aVolume The new radio volume. + */ + virtual void HandleRadioVolumeChangeL( TInt aVolume ) = 0; + + /** + * Invoked when tuning has taken more than one second, or tuning was previously on, but now completed. + * @param aTuningState The new tuning state. + */ + virtual void HandleTuningStateChangeL( TFMRadioPSTuningState aTuningState ) = 0; + + /** + * Invoked when a new channel has been tuned into. + * @param aIndex The index of the channel. + */ + virtual void HandleChannelChangeL( TInt aIndex ) = 0; + + /** + * Invoked when a channel has been modifed. + * @param aIndex The index of the channel that was modified. + */ + virtual void HandleChannelModifyL( TInt aIndex ) = 0; + + /** + * Invoked when the frequency has changed. + * @param aFrequency The new frequency. + */ + virtual void HandleFrequencyChangeL( TInt aFrequency ) = 0; + + /** + * Invoked when the muting state has changed. + * @param aMuteState The new mute state. + */ + virtual void HandleMuteStateChangeL( TFMRadioPSRadioMuteState aMuteState ) = 0; + + /** + * Invoked when the application's running state has changed. + * @param aRunningState The new running state. + */ + virtual void HandleApplicationRunningStateChangeL( TFMRadioPSApplicationRunningState aRunningState ) = 0; + + /** + * Invoked when the used decimal count is changed. + * @param aDecimalCount The new decimal count. + */ + virtual void HandleFrequencyDecimalCountChangeL( TFMRadioPSFrequencyDecimalCount aDecimalCount ) = 0; + + /** + * Invoked when the antenna's connectivity status is changed. + * @param aAntennaStatus Antenna's new connectivity status. + */ + virtual void HandleAntennaStatusChangeL( TFMRadioPSHeadsetStatus aAntennaStatus ) = 0; + + /** + * Invoked when radio's power state changes. + * @param aPowerState The new power state. + */ + virtual void HandlePowerStateChangeL( TFMRadioPSRadioPowerState aPowerState ) = 0; + + /** + * Invoked when RDS Program Service information changes. + * @param aProgramService New Program Service info. + */ + virtual void HandleRDSProgramServiceChangeL( const TDesC& aProgramService ) = 0; + + /** + * Invoked when RDS Text information changes. + * @param aRdsText New Program Service info. + */ + virtual void HandleRDSRadioTextChangeL( const TDesC& aRdsText ) = 0; + + /** + * Invoked when Channel name changes. + * @param aName New channel name. + */ + virtual void HandleChannelNameChangeL( const TDesC& aName ) = 0; + + virtual void HandlePresetListCountChangeL( TInt aPresetCount ) = 0; + virtual void HandlePresetListFocusChangeL( TInt aPresetFocus ) = 0; + }; + +#endif // __FMRADIOACTIVEIDLEENGINENOTIFYHANDLER_H__ + diff -r 000000000000 -r f3d95d9c00ab fmradio/activeidleengine/src/fmradioactiveidleengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/activeidleengine/src/fmradioactiveidleengine.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,386 @@ +/* +* 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: FMRadio active idle engine +* +*/ + + +#include + +#include "fmradioactiveidleengine.h" +#include "fmradioactiveidleenginenotifyhandler.h" + + +/** +* Listing of the subscribed P&S values. +* Changing the order of this enumeration requires changes to CFMRadioActiveIdleEngine::ConstructL as well. +*/ + +enum TFMRadioActiveIdleStatusObserverArray + { + //EFMRadioActiveIdleRadioVolumeObserver, /**< Index of the radio volume observer. */ + EFMRadioActiveIdleTuningStateObserver, /**< Index of the tuning state observer. */ + EFMRadioActiveIdleFrequencyObserver, /**< Index of the current frequency observer. */ + EFMRadioActiveIdleChannelChangeObserver, /**< Index of the current channel observer. */ + EFMRadioActiveIdleChannelModifyObserver, /**< Index of the channel modified observer. */ + EFMRadioActiveIdleMuteStateObserver, /**< Index of the muting state observer. */ + EFMRadioActiveIdleApplicationObserver, /**< Index of the FM Radio application observer used to observer whether the application is running or not. */ + EFMRadioActiveIdleHeadsetStatusObserver, /**< Index of the antenna status observer. */ + EFMRadioActiveIdleDecimalCountObserver, /**< Index of the frequency decimal count observer. */ + EFMRadioActiveIdlePowerStateObserver, /**< Index of the power state observer. */ + EFMRadioActiveIdleRDSProgramServiceObserver, /**< Index of the RDS Program Service observer. */ + EFMRadioPSDataRDSRadioText, + EFMRadioPSDataChannelName, + EFMRadioActiveIdlePresetListCountObserver, /**< Index of the active preset list count observer */ + EFMRadioActiveIdlePresetListFocusObserver /**< Index of the active preset list focus observer */ + }; + +// ==================== LOCAL FUNCTIONS ==================== + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------- +// Constructor. +// --------------------------------------------------------------------------- +// +CFMRadioActiveIdleEngine::CFMRadioActiveIdleEngine( MFMRadioActiveIdleEngineNotifyHandler& aObserver ) + : iObserver( aObserver ) + { + } + +// --------------------------------------------------------------------------- +// Second-phase constructor. +// --------------------------------------------------------------------------- +// +void CFMRadioActiveIdleEngine::ConstructL() + { + //User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioEnginePSUid, KFMRadioPSDataVolume, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataTuningState, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataFrequency, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataChannel, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataChannelDataChanged, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataRadioMuteState, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataApplicationRunning, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataHeadsetStatus, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataFrequencyDecimalCount, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataRadioPowerState, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataRDSProgramService, CFMRadioPropertyObserver::EFMRadioPropertyText ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataRDSRadioText, CFMRadioPropertyObserver::EFMRadioPropertyText ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioPSDataChannelName, CFMRadioPropertyObserver::EFMRadioPropertyText ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioActiveIdlePresetListCount, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + User::LeaveIfError( iPropertyObserverArray.Append( CFMRadioPropertyObserver::NewL( *this, KFMRadioPSUid, KFMRadioActiveIdlePresetListFocus, CFMRadioPropertyObserver::EFMRadioPropertyInt ) ) ); + } + +// --------------------------------------------------------------------------- +// Makes all pubsub objects to subscribe. +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioActiveIdleEngine::ActivateL() + { + for ( TInt i = 0; i < iPropertyObserverArray.Count(); i++ ) + { + iPropertyObserverArray[i]->ActivateL(); + } + } + +// --------------------------------------------------------------------------- +// Cancels all pubsub objects. +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioActiveIdleEngine::Cancel() + { + for ( TInt i = 0; i < iPropertyObserverArray.Count(); i++ ) + { + iPropertyObserverArray[i]->Cancel(); + } + } + +// --------------------------------------------------------------------------- +// Static constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CFMRadioActiveIdleEngine* CFMRadioActiveIdleEngine::NewL( MFMRadioActiveIdleEngineNotifyHandler& aObserver ) + { + CFMRadioActiveIdleEngine* self = new ( ELeave ) CFMRadioActiveIdleEngine( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CFMRadioActiveIdleEngine::~CFMRadioActiveIdleEngine() + { + iPropertyObserverArray.ResetAndDestroy(); + iPropertyObserverArray.Close(); + /* + if ( iServ ) + { + iServ->Close(); + } + delete iServ; + */ + } + +// --------------------------------------------------------------------------- +// Invoked when a listened integer P&S key is changed. +// --------------------------------------------------------------------------- +// +void CFMRadioActiveIdleEngine::HandlePropertyChangeL( const TUid& aCategory, TUint aKey, TInt aValue ) + { + if ( aCategory == KFMRadioPSUid ) + { + switch ( aKey ) + {/* + case KFMRadioPSDataVolume: + iObserver.HandleRadioVolumeChangeL( aValue ); + break;*/ + + case KFMRadioPSDataTuningState: + iObserver.HandleTuningStateChangeL( static_cast( aValue ) ); + break; + + case KFMRadioPSDataFrequency: + iObserver.HandleFrequencyChangeL( aValue ); + break; + + case KFMRadioPSDataChannel: + // Sync the cache values for channel name and index + iPropertyObserverArray[EFMRadioPSDataChannelName]->ValueDes( ETrue ); + iObserver.HandleChannelChangeL( aValue ); + break; + + case KFMRadioPSDataChannelDataChanged: + iPropertyObserverArray[EFMRadioPSDataChannelName]->ValueDes( ETrue ); + iObserver.HandleChannelModifyL( aValue ); + break; + + case KFMRadioPSDataRadioMuteState: + iObserver.HandleMuteStateChangeL( static_cast( aValue ) ); + break; + + case KFMRadioPSDataApplicationRunning: + iObserver.HandleApplicationRunningStateChangeL( static_cast( aValue ) ); + break; + + case KFMRadioPSDataHeadsetStatus: + iObserver.HandleAntennaStatusChangeL( static_cast( aValue ) ); + break; + + case KFMRadioPSDataFrequencyDecimalCount: + iObserver.HandleFrequencyDecimalCountChangeL( static_cast( aValue ) ); + break; + + case KFMRadioPSDataRadioPowerState: + iObserver.HandlePowerStateChangeL( static_cast( aValue ) ); + break; + + case KFMRadioActiveIdlePresetListCount: + iObserver.HandlePresetListCountChangeL( aValue ); + break; + + case KFMRadioActiveIdlePresetListFocus: + //iObserver.HandlePresetListFocusChangeL( aValue ); + break; + + default: + break; + } + } + } + +// --------------------------------------------------------------------------- +// Invoked when a listened byte array P&S key is changed. +// --------------------------------------------------------------------------- +// +//void CFMRadioActiveIdleEngine::HandlePropertyChangeL( const TUid& /*aCategory*/, TUint /*aKey*/, const TDesC8& /*aValue*/ ) +// { +// } + +// --------------------------------------------------------------------------- +// Invoked when a listened text P&S key is changed. +// --------------------------------------------------------------------------- +// + +void CFMRadioActiveIdleEngine::HandlePropertyChangeL( const TUid& aCategory, TUint aKey, const TDesC& aValue ) + { + if ( aCategory == KFMRadioPSUid ) + { + switch ( aKey ) + { + case KFMRadioPSDataRDSProgramService: + iObserver.HandleRDSProgramServiceChangeL( aValue ); + break; + case KFMRadioPSDataRDSRadioText: + iObserver.HandleRDSRadioTextChangeL( aValue ); + break; + case KFMRadioPSDataChannelName: + // Sync the cache valuse for channel name and index + iPropertyObserverArray[EFMRadioActiveIdleChannelChangeObserver]->ValueInt( ETrue ); + iObserver.HandleChannelNameChangeL( aValue ); + break; + default: + break; + } + } + + } +// --------------------------------------------------------------------------- +// Invoked when a listened text P&S key is changed. +// --------------------------------------------------------------------------- +// +void CFMRadioActiveIdleEngine::HandlePropertyChangeL( const TUid&, TUint, const TDesC8&) + { + } + +// --------------------------------------------------------------------------- +// Invoked when an error has occured while fetching the new value of any listened P&S key. +// --------------------------------------------------------------------------- +// +void CFMRadioActiveIdleEngine::HandlePropertyChangeErrorL( const TUid& /*aCategory*/, TUint /*aKey*/, TInt aError ) + { + if (aError < 0) + { + // If any error should pass to this method, handle it like 'application shutdown'. + // This situation will realize whenever the application is killed, by accident/by system/by an app crash + // or due to change to offline mode. + HandlePropertyChangeL(KFMRadioPSUid, KFMRadioPSDataApplicationRunning, EFMRadioPSApplicationClosing); + } + } + +// --------------------------------------------------------------------------- +// Returns the current radio volume. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CFMRadioActiveIdleEngine::RadioVolume() const + { + //return iPropertyObserverArray[EFMRadioActiveIdleRadioVolumeObserver]->ValueInt(); + return 0; + } + +// --------------------------------------------------------------------------- +// Sets the radio volume. +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioActiveIdleEngine::AdjustRadioVolume( TFMRadioPSAdjustVolume aVolume ) const + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlAdjustVolume, aVolume ); + } + + +// --------------------------------------------------------------------------- +// Returns the current tuning state. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSTuningState CFMRadioActiveIdleEngine::TuningState() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdleTuningStateObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Returns the current frequency. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CFMRadioActiveIdleEngine::Frequency() const + { + return iPropertyObserverArray[EFMRadioActiveIdleFrequencyObserver]->ValueInt(); + } + +// --------------------------------------------------------------------------- +// Returns the currently active channel ID. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CFMRadioActiveIdleEngine::Channel() const + { + return iPropertyObserverArray[EFMRadioActiveIdleChannelChangeObserver]->ValueInt(); + } + +// --------------------------------------------------------------------------- +// Returns the currently active channel name. +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioActiveIdleEngine::ChannelName() const + { + return iPropertyObserverArray[EFMRadioPSDataChannelName]->ValueDes(); + } + +// --------------------------------------------------------------------------- +// Returns the current mute state. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSRadioMuteState CFMRadioActiveIdleEngine::MuteState() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdleMuteStateObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Sets the mute state. +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioActiveIdleEngine::SetMuteState( TFMRadioPSRadioMuteState aMuteState ) const + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlSetRadioMuteState, aMuteState ); + } + +// --------------------------------------------------------------------------- +// Returns the current antenna connectivity status. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSHeadsetStatus CFMRadioActiveIdleEngine::AntennaStatus() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdleHeadsetStatusObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Returns the current frequency decimal count. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSFrequencyDecimalCount CFMRadioActiveIdleEngine::FrequencyDecimalCount() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdleDecimalCountObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Returns FM Radio application's running state. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSApplicationRunningState CFMRadioActiveIdleEngine::ApplicationRunningState() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdleApplicationObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Returns the radio's power state. +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioPSRadioPowerState CFMRadioActiveIdleEngine::PowerState() const + { + return static_cast( iPropertyObserverArray[EFMRadioActiveIdlePowerStateObserver]->ValueInt() ); + } + +// --------------------------------------------------------------------------- +// Returns RDS Program Service information. +// --------------------------------------------------------------------------- +// + +EXPORT_C const TDesC& CFMRadioActiveIdleEngine::RDSProgramService() const + { + return iPropertyObserverArray[EFMRadioActiveIdleRDSProgramServiceObserver]->ValueDes(); + } + +// ================= OTHER EXPORTED FUNCTIONS ============== + diff -r 000000000000 -r f3d95d9c00ab fmradio/conf/fmradio.confml Binary file fmradio/conf/fmradio.confml has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/conf/fmradio_2001b25e.crml Binary file fmradio/conf/fmradio_2001b25e.crml has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/aif/fmradioaif.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/aif/fmradioaif.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies 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 file for creating the aif file for FMRadio. +* +*/ + +#include +#include + +RESOURCE AIF_DATA + { + app_uid=0x10207A89; + num_icons=2; + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/data/fmradio.rh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/data/fmradio.rh Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,56 @@ +/* +* 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: Resource headers for project FMRadio +* +*/ + + +#ifndef FMRADIO_RH +#define FMRADIO_RH + +#include + +// --------------------------------------------------------------------------- +// Frequency editor struct +// --------------------------------------------------------------------------- +// +STRUCT FMRADIO_FREQUENCY_EDITOR + { + BYTE flags = 0; + } + +// --------------------------------------------------------------------------- +// Struct for defining a fadable icon +// --------------------------------------------------------------------------- +// +STRUCT FMRADIO_FADABLE_ICON + { + LTEXT bmpfile; + LONG bitmap; + LONG mask; + WORD fadetime = 1000; // fading time in milliseconds, defaults to one second + BYTE invisible_percentage = 0; // Percentage how much the icon is shown when it is faded out + } + +// --------------------------------------------------------------------------- +// Struct for defining a bitmap animation composed of fadable icons. +// --------------------------------------------------------------------------- +// +STRUCT FMRADIO_BITMAP_ANIMATION + { + LONG frameInterval; // Interval between frames. + STRUCT frames[]; // Bitmap animation frames of type FMRADIO_FADABLE_ICON. + } + +#endif // FMRADIO_RH diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/data/fmradio.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/data/fmradio.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1655 @@ +/* +* 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: FM Radio resource definitions +* +* +*/ + + +// RESOURCE IDENTIFIER +// +NAME FMRD // 4 letter ID + +// INCLUDES +// +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "fmradio.rh" +#include "fmradio.hrh" + +#include + +#define KFMRadioBitmapFile APP_BITMAP_DIR "\\fmradio.mif" + +// RESOURCE DEFINITIONS +// +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="FM Radio"; } + + +RESOURCE EIK_APP_INFO + { + menubar = r_fmradio_main_menu; // Resource defining the menu. + status_pane = r_fmradio_status_pane; + } + +// For scalable AIF +RESOURCE LOCALISABLE_APP_INFO r_fmradio_localisable_app_info + { + short_caption = qtn_fmradio_app_menu_list; + caption_and_icon = CAPTION_AND_ICON_INFO + { + caption = qtn_fmradio_app_menu_grid; +#ifdef __SCALABLE_ICONS + number_of_icons = 1; + icon_file = APP_BITMAP_DIR"\\FMRadio_aif.mif"; +#else + number_of_icons = 2; + icon_file = APP_BITMAP_DIR"\\FMRadio_aif.mbm"; +#endif + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_setting_frequency_editor +// Editor for setting frequency of a channel. +// --------------------------------------------------------------------------- +// +RESOURCE FMRADIO_FREQUENCY_EDITOR r_fmradio_setting_frequency_editor + { + } + +// --------------------------------------------------------------------------- +// r_fmradio_manual_tuning_query +// Manual tuning query resources +// --------------------------------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_manual_tuning_query + { + flags = EGeneralQueryFlags | EEikDialogFlagDontEatUpDownEvents; + buttons = r_fmradio_softkeys_save_cancel__save; + items = + { + DLG_LINE + { + type = EFMRadioCtFrequencyQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = ETimeLayout; + control = FMRADIO_FREQUENCY_EDITOR + { + }; + }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_channel_list_icon_array +// --------------------------------------------------------------------------- +// +RESOURCE AKN_ICON_ARRAY r_fmradio_channel_list_icon_array + { + type = EAknIconArraySimple; + bmpfile = KFMRadioBitmapFile; + icons = + { + AKN_ICON + { + iconId = EMbmFmradioQgn_indi_radio_playing; + maskId = EMbmFmradioQgn_indi_radio_playing_mask; + }, + AKN_ICON + { + iconId = EMbmFmradioQgn_indi_marked_add; + maskId = EMbmFmradioQgn_indi_marked_add_mask; + } + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_main_view_toolbar +// --------------------------------------------------------------------------- +// +RESOURCE AVKON_TOOLBAR r_fmradio_main_view_toolbar + { + flags = KAknToolbarTransparent|KAknToolbarWithoutCba|KAknToolbarFixed; + items = + { + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdTuneDown; + control = AVKON_BUTTON + { + flags = KAknButtonReportOnLongPress; + states = + { + AVKON_BUTTON_STATE + { + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_previous; + bmpmask = EMbmFmradioQgn_indi_tb_radio_previous_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtToolbarExtension; + id = EFMRadioToolbarButtonCmdExtensionList; + control = AVKON_TOOLBAR_EXTENSION + { + helptxt = qtn_fmradio_tooltip_extension; + items = + { + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdRename; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_rename; + helptxt = qtn_fmradio_tooltip_rename; + bmpfile = KFMRadioBitmapFile; + bmpmask = EMbmFmradioQgn_indi_tb_rename; + bmpid = EMbmFmradioQgn_indi_tb_rename_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdSaveChannel; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_save; + helptxt = qtn_fmradio_tooltip_save; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_station_save; + bmpmask = EMbmFmradioQgn_indi_tb_radio_station_save_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdErase; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_delete; + helptxt = qtn_fmradio_tooltip_delete; + bmpfile = KFMRadioBitmapFile; + bmpmask = EMbmFmradioQgn_indi_cam4_tb_delete_mask; + bmpid = EMbmFmradioQgn_indi_cam4_tb_delete; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdOperatorMusicStore; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + bmpfile = KFMRadioBitmapFile; + bmpmask = EMbmFmradioQgn_indi_radio_tb_mshop; + bmpid = EMbmFmradioQgn_indi_radio_tb_mshop_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdToggleIhf; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_activate_loudspeaker; + helptxt = qtn_fmradio_tooltip_activate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_on; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_on_mask; + }, + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_deactivate_loudspeaker; + helptxt = qtn_fmradio_tooltip_deactivate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_off; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_off_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EMPXPbvCmdInternetGoToWeb; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_station_web; + helptxt = qtn_fmradio_tooltip_web; + bmpfile = KFMRadioBitmapFile; + bmpmask = EMbmFmradioQgn_indi_radio_tb_gotoweb; + bmpid = EMbmFmradioQgn_indi_radio_tb_gotoweb_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdChannelList; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_list_view; + helptxt = qtn_fmradio_tooltip_stations; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_radio_tb_list; + bmpmask = EMbmFmradioQgn_indi_radio_tb_list_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdNokiaMusicStore; + control = AVKON_BUTTON + { + flags = KAknButtonRequestExitOnButtonUpEvent; + states = + { + AVKON_BUTTON_STATE + { + txt = qtn_tbextension_ovi_music; + helptxt = qtn_fmradio_tooltip_nokia_music_store; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_menu_music; + bmpmask = EMbmFmradioQgn_menu_music_mask; + } + }; + }; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdTuneUp; + control = AVKON_BUTTON + { + flags = KAknButtonReportOnLongPress; + states = + { + AVKON_BUTTON_STATE + { + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_next; + bmpmask = EMbmFmradioQgn_indi_tb_radio_next_mask; + } + }; + }; + } + }; + } + +//---------------------------------------------------- +// +// r_fmradio_status_pane +// +//---------------------------------------------------- +// +RESOURCE STATUS_PANE_APP_MODEL r_fmradio_status_pane + { + layout = R_AVKON_STATUS_PANE_LAYOUT_USUAL; + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_qtn_fmradio_title; + } + }; + } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_title +//---------------------------------------------------- +// +RESOURCE TITLE_PANE r_qtn_fmradio_title + { + txt = qtn_fmradio_title; + } + +// ============================ Application views ============================ +// +RESOURCE CBA r_fmradio_softkeys_select_exit__select + { + buttons= + { + CBA_BUTTON { id = EAknSoftkeySelect; txt = text_softkey_select; }, + CBA_BUTTON { id = EAknSoftkeyExit; txt = text_softkey_exit; }, + CBA_BUTTON { id = EAknSoftkeySelect; txt = text_softkey_select; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_softkeys_drop_done +// Description : Reorder functionality softkeys +//---------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_drop_done + { + buttons= + { + CBA_BUTTON { id = EFMRadioCmdDrop; txt = qtn_fmradio_softkey_drop; }, + CBA_BUTTON { id = EFMRadioCmdDone; txt = text_softkey_done; } + }; + } +//---------------------------------------------------- +// Resource : r_fmradio_softkeys_drop_cancel +// Description : Reorder functionality softkeys +//---------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_drop_cancel + { + buttons= + { + CBA_BUTTON { id = EFMRadioCmdDrop; txt = qtn_fmradio_softkey_drop; }, + CBA_BUTTON { id = EAknSoftkeyCancel; txt = text_softkey_cancel; } + }; + } +//---------------------------------------------------- +// Resource : r_fmradio_softkeys_drop_done +// Description : Reorder functionality softkeys +//---------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_grab_cancel + { + buttons= + { + CBA_BUTTON { id = EFMRadioCmdGrap; txt = qtn_fmradio_softkey_grab; }, + CBA_BUTTON { id = EAknSoftkeyCancel; txt = text_softkey_cancel; } + }; + } +//---------------------------------------------------- +// Resource : r_fmradio_softkeys_grap_done +// Description : Move functionality softkeys +//---------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_grap_done + { + buttons= + { + CBA_BUTTON { id = EFMRadioCmdGrap; txt = qtn_fmradio_softkey_grab; }, + CBA_BUTTON { id = EFMRadioCmdDone; txt = text_softkey_done; } + }; + } +//---------------------------------------------------- +// Resource : r_fmradio_softkeys_save_cancel__save +// Description : softkeys for manual tuning dialog +//---------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_save_cancel__save + { + buttons= + { + CBA_BUTTON { id = EAknSoftkeySave; txt = text_softkey_save; }, + CBA_BUTTON { id = EAknSoftkeyCancel; txt = text_softkey_cancel; }, + CBA_BUTTON { id = EAknSoftkeySave; txt = text_softkey_save; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_main_view +// Description : Application main view. (View ID=1) +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_fmradio_main_view + { + menubar = r_fmradio_main_menu; + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + toolbar = r_fmradio_main_view_toolbar; + } + +// --------------------------------------------------------- +// r_fmradio_main_view_tuning_state_softkeys +// --------------------------------------------------------- +// +RESOURCE CBA r_fmradio_main_view_tuning_state_softkeys + { + buttons = + { + CBA_BUTTON { txt = text_softkey_empty; }, + CBA_BUTTON { id = EFMRadioCmdStopTuning; txt = text_softkey_stop; } + }; + } + +// --------------------------------------------------------- +// r_fmradio_softkeys_exit +// --------------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_exit + { + buttons = + { + CBA_BUTTON { txt = text_softkey_empty; }, + CBA_BUTTON { id = EAknSoftkeyExit; txt = text_softkey_exit; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_ch_list_view +// Description : Stations view. (View ID=2) +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_fmradio_ch_list_view + { + menubar = r_fmradio_channel_list_menu; + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + toolbar = r_fmradio_channel_list_toolbar; + } + +// ================================ View titles ============================== +// + +// --------------------------------------------------------------------------- +// r_fmradio_stations_view_title +// Title of stations view. +// --------------------------------------------------------------------------- +// +RESOURCE TBUF r_fmradio_stations_view_title { buf = qtn_fmradio_stations_title; } + +// --------------------------------------------------------------------------- +// r_fmradio_search_stations_view_title +// Title of scan local stations view. +// --------------------------------------------------------------------------- +// +RESOURCE TBUF r_fmradio_search_stations_view_title { buf = qtn_fmradio_search_stations_title; } + + +// ================================ Menu titles ============================== +// + +//---------------------------------------------------- +// Resource : r_fmradio_main_menu +// Description : Title for the Main menu. +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_fmradio_main_menu + { + titles= + { + MENU_TITLE { menu_pane = r_fmradio_main_options_menu; txt = ""; } + }; + } + + +//---------------------------------------------------- +// Resource : r_fmradio_channel_list_menu +// Description : Title for the channel list menu. +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_fmradio_channel_list_menu + { + titles= + { + MENU_TITLE { menu_pane = r_fmradio_ch_list_options_menu; txt = ""; } + }; + } + + +// ================================ Menu items =============================== +// + +//---------------------------------------------------- +// Resource : r_fmradio_main_options_menu +// Description : Main options menu items v2. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_main_options_menu + { + items= + { + MENU_ITEM { command = EMPXPbvCmdInternetGoToWeb; txt = qtn_fmradio_options_web_address; }, + MENU_ITEM { command = EFMRadioCmdChannelList; txt = qtn_fmradio_options_stations; }, + MENU_ITEM { command = EFMRadioCmdSaveChannel; txt = qtn_fmradio_options_save; }, + MENU_ITEM { command = EFMRadioCmdErase; txt = qtn_fmradio_options_delete; }, + MENU_ITEM { command = EFMRadioCmdRename; txt = qtn_fmradio_options_rename; }, + MENU_ITEM { command = EFMRadioCmdActivateIhf; txt = qtn_fmradio_options_activate; }, + MENU_ITEM { command = EFMRadioCmdDeactivateIhf; txt = qtn_fmradio_options_deactivate; }, + MENU_ITEM { command = EFMRadioCmdOpenAFSubmenu; txt = qtn_fmradio_options_alternative_freq; cascade = r_fmradio_options_af_sub_menu; }, + MENU_ITEM { command = EAknCmdHelp; txt = qtn_options_help; }, + MENU_ITEM { command = EAknCmdExit; txt = qtn_options_exit; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_options_af_sub_menu +// Description : Sub options menu for alternative frequency. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_options_af_sub_menu + { + items = + { + MENU_ITEM + { + command = EFMRadioCmdEnableRdsAfSearch; + txt = qtn_fmradio_options_on; + flags = EEikMenuItemRadioStart; + }, + MENU_ITEM + { + command = EFMRadioCmdDisableRdsAfSearch; + txt = qtn_fmradio_options_off; + flags = EEikMenuItemRadioEnd; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_ch_list_options_menu +// Description : Channel list options menu items. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_ch_list_options_menu + { + items= + { + MENU_ITEM { command = EFMRadioCmdRename; txt = qtn_fmradio_options_rename; flags = EEikMenuItemSpecific; }, + MENU_ITEM { command = EFMRadioCmdErase; txt = qtn_fmradio_options_delete; flags = EEikMenuItemSpecific; }, + MENU_ITEM { command = EFMRadioCmdMove; txt = qtn_fmradio_move; flags = EEikMenuItemSpecific; }, + MENU_ITEM { command = EFMRadioCmdScanLocalStations; txt = qtn_fmradio_options_search_stations; }, + MENU_ITEM { command = EFMRadioCmdTuneManually; txt = qtn_fmradio_options_tune_manually; }, + MENU_ITEM { command = EFMRadioCmdActivateIhf; txt = qtn_fmradio_options_activate; }, + MENU_ITEM { command = EFMRadioCmdDeactivateIhf; txt = qtn_fmradio_options_deactivate; }, + MENU_ITEM { command = EAknCmdHelp; txt = qtn_options_help; }, + MENU_ITEM { command = EAknCmdExit; txt = qtn_options_exit; } + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_channel_list_toolbar +// --------------------------------------------------------------------------- +// +RESOURCE AVKON_TOOLBAR r_fmradio_channel_list_toolbar + { + flags = KAknToolbarTransparent|KAknToolbarWithoutCba|KAknToolbarFixed; + items = + { + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdTuneManually; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_tune_manually; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_radio_tb_manualtune; + bmpmask = EMbmFmradioQgn_indi_radio_tb_manualtune_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioCmdScanLocalStations; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_search_stations; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_scan; + bmpmask = EMbmFmradioQgn_indi_tb_radio_scan_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdToggleIhf; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_activate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_on; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_on_mask; + }, + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_deactivate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_off; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_off_mask; + } + }; + }; + } + }; + } + +// ============================= Data queries ============================== +// + +RESOURCE AVKON_LIST_QUERY r_fmradio_listquery_save_all_replace_append + { + softkeys=R_AVKON_SOFTKEYS_SELECT_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control = AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + heading = qtn_fmradio_list_query_save_all; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_fmradio_listquery_save_all_replace_append_items; + }; + }; + } + }; + } + + +RESOURCE ARRAY r_fmradio_listquery_save_all_replace_append_items + { + items = + { + LBUF {txt = qtn_fmradio_list_query_replace_all; }, + LBUF {txt = qtn_fmradio_list_query_append; } + }; + } + +RESOURCE AVKON_LIST_QUERY r_fmradio_listquery_save_all_replace_append_list_almost_full + { + softkeys=R_AVKON_SOFTKEYS_SELECT_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control = AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + heading = qtn_fmradio_list_query_list_full; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_fmradio_listquery_save_all_replace_append_items_list_almost_full; + }; + }; + } + }; + } + +RESOURCE ARRAY r_fmradio_listquery_save_all_replace_append_items_list_almost_full + { + items = + { + LBUF {txt = qtn_fmradio_list_query_all_fits; }, + LBUF {txt = qtn_fmradio_list_query_replace_all; } + }; + } + +RESOURCE DIALOG r_fmradio_rename_query +{ + flags=EGeneralQueryFlags; + buttons=R_AVKON_SOFTKEYS_OK_CANCEL; + items= + { + DLG_LINE + { + type=EAknCtQuery; + id=EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = EDataLayout; + label = qtn_fmradio_query_rename; + control = EDWIN + { + flags= EEikEdwinNoHorizScrolling | EEikEdwinResizable; + maxlength=20; + width=16; + lines=1; + max_view_height_in_lines=1; // (5 or less lines are permitted) + base_line_delta=21; + }; + }; + } + }; +} + +RESOURCE AVKON_LIST_QUERY r_fmradio_select_region_query + { + flags = EGeneralQueryFlags | EEikDialogFlagWait; + softkeys = r_fmradio_softkeys_select_exit__select; + + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control = AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + }; + heading = qtn_fmradio_popup_head_select_reg; + }; + } + }; + } + +// ========================= Confirmation queries ========================== +// + +//---------------------------------------------------- +// Resource : r_fmradio_activate_in_offline_query +// Description : A dialog shown when starting FM Radio +// and off-line mode is active. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_activate_in_offline_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_fmradio_query_offline_activate; + }; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_continue_in_offline_query +// Description : A dialog shown when coming to +// foreground and off-line mode has been +// activated in background. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_continue_in_offline_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_fmradio_query_offline_use; + }; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_save_ch_confirmation_query +// Description : Confirmation query used when user +// tries to save a channel to a reserved +// channel slot. User is asked to +// confirm is the intention to replace +// the existing channel in that channel +// slot. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_save_ch_confirmation_query +{ + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + }; + } + }; +} + +//---------------------------------------------------- +// Resource : r_fmradio_erase_ch_confirmation_query +// Description : Confirmation query used when user +// tries to delete a channel from a +// channel slot. User is asked to +// confirm is the intention to really +// delete the existing channel in that +// channel slot or was it just an +// accidental menu selection... +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_erase_ch_confirmation_query +{ + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + }; + } + }; +} + +RESOURCE DIALOG r_fmradio_connect_headset_note + { + flags = EAknDialogGenericQueryFlags; + buttons = r_fmradio_softkeys_exit; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EConfirmationLayout; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_note_radio_jackmini; + bmpmask = EMbmFmradioQgn_note_radio_jackmini_mask; + }; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_query_save_current +// Description : query for saving channel that has not been saved +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_query_save_current + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_fmradio_query_save_current; + }; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_replace_existing_channels_query +// Description : Shown when starting channel list is full +// and user presses save all in scan stations. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_replace_existing_channels_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_fmradio_query_replace_all; + }; + } + }; + } +// ============================== Notes =================================== + +//---------------------------------------------------- +// Resource : r_fmradio_rtplus_firsttime_note +// Description : A wait note used while seek is +// in progress. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_rtplus_firsttime_note + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + }; + } + }; + } + +// ======================== Dynamic menu strings =========================== +// + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_options_activate +// Description : String for a menu item when IHF- +// speaker is inactive. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_options_activate { buf = qtn_fmradio_options_activate; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_options_deactivate +// Description : String for a menu item when IHF- +// speaker is active. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_options_deactivate { buf = qtn_fmradio_options_deactivate; } + +//---------------------------------------------------- +// Resource : r_fmradio_options_music_store +// Description : Options menu item for music store. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_options_music_store + { + items = + { + MENU_ITEM + { + command = EFMRadioMusicStore; + txt = qtn_fmradio_options_music_store; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_options_music_store_with_sub_menu +// Description : Sub options menu for music store. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_options_music_store_with_sub_menu + { + items = + { + MENU_ITEM + { + command = EFMRadioMusicStore; + txt = qtn_fmradio_options_music_store_submenu; + cascade = r_fmradio_options_music_store_sub_menu; + } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_options_music_store_sub_menu +// Description : Sub options menu for music store. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_options_music_store_sub_menu + { + items = + { + MENU_ITEM + { + command = EFMRadioMusicStoreOperator; + txt = ""; // Operator Music Store + }, + MENU_ITEM + { + command = EFMRadioMusicStoreNokiaMusicShop; + txt = qtn_fmradio_options_nokia_music_store; + } + }; + } + + +// ====================== Strings from fmradio.loc ========================= +// + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_query_offline_use +// Description : Prompt text for text query dialog. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_query_offline_use { buf = qtn_fmradio_query_offline_use; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_mem_location_freq +// Description : Text including channel index and +// frequency. Used in main view. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_mem_location_freq { buf = qtn_fmradio_mem_location_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_mem_location_name +// Description : Text including channel index and +// channel name. Used in main view. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_mem_location_name { buf = qtn_fmradio_mem_location_name; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_freq +// Description : Text to display frequency of current station +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_freq { buf= qtn_fmradio_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_media_idle_freq +// Description : Text to display frequency in media idle +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_media_idle_freq { buf= qtn_fmradio_media_idle_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_rds +// Description : Text to rds indicator +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_rds { buf = qtn_fmradio_rds; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_af +// Description : Text to af indicator +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_af { buf = qtn_fmradio_af; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_rtplus_indicator_text +// Description : Text to af indicator +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_rtplus_indicator_text { buf = qtn_fmradio_rtplus; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_rtplus_firsttime +// Description : Text to a note which is shown when RT+ +// interactions become available for the first time. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_rtplus_firsttime { buf = qtn_fmradio_query_rtplus_enabled; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_query_delete +// Description : Used in confirmation query when user +// is asked to confirm deleting a +// channel from the channel list. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_query_delete { buf = qtn_fmradio_query_delete; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_query_delete_mhz +// Description : Used in confirmation query when user +// is asked to confirm deleting a +// channel from the channel list. Used +// for frequency if the channel name +// is not set +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_query_delete_mhz { buf = qtn_fmradio_query_delete_mhz; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_tuning +// Description : A label used while +// tuning is in progress. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_tuning { buf = qtn_fmradio_scanning; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_use_long_tap +// Description : Text for the information note that +// will be shown when the channels haven't been saved +// and tryed to change channel. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_use_long_tap { buf = qtn_fmradio_use_long_tap; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_list_query_list_full +// Description : If the amount of added stations is about to exceed +// the limit, a List query is displayed with a prompt +// text Station list full: +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_list_query_list_full { buf = qtn_fmradio_list_query_list_full; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_error_con_headset +// Description : Text for the error note about +// a missing headset. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_error_con_headset { buf = qtn_fmradio_error_con_headset; } + +//text for the frequence range note. User has selected range manually +RESOURCE TBUF128 r_qtn_fmradio_conf_freq_band_set_manual { buf = qtn_fmradio_conf_freq_band_set_manual; } +RESOURCE TBUF128 r_qtn_fmradio_conf_freq_band_set_autom { buf = qtn_fmradio_conf_freq_band_set_autom; } +RESOURCE TBUF128 r_qtn_fmradio_manual_tune_freq { buf = qtn_fmradio_query_frequency; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_stations_saved +// Description : Text "%N stations saved to the stations list." used in Scan Local Stations list. +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_stations_saved { buf = qtn_fmradio_saving_done; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_list_no_stations_found +// Description : Text "No stations found. Please try again." +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_list_no_stations_found { buf = qtn_fmradio_list_no_stations_found; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_no_stations_found +// Description : Text "No stations found." +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_no_stations_found { buf = qtn_fmradio_no_stations_found; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_msk_listen +// Description : String for the listen text +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_msk_listen { buf = qtn_fmradio_msk_listen; } + +RESOURCE TBUF r_qtn_fmradio_none { buf = ""; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_list_no_stations +// Description : String for empty stations list +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_list_no_stations { buf = qtn_fmradio_list_no_stations; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_note_fmtx_unable_to_start +// Description : FM transmitter is active during radio launch +// text : "FM Radio cannot be started when FM transmitter is on." +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_note_fmtx_unable_to_start { buf = qtn_fmradio_note_fmtx_unable_to_start; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_note_fmtx_close_application +// Description : +// text : "FM Radio cannot be used when the FM transmitter is on. FM Radio is closed." +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_note_fmtx_close_application { buf = qtn_fmradio_note_fmtx_close_application; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_saving_done_one +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_saving_done_one { buf = qtn_fmradio_saving_done_one; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_saving_done_one_no_name +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_saving_done_one_no_name { buf = qtn_fmradio_saving_done_one_no_name; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_double1_freq +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_double1_freq { buf = qtn_fmradio_double1_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_double2_freq +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_double2_freq { buf = qtn_fmradio_double2_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_single_freq +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_single_freq { buf = qtn_fmradio_single_freq; } + +//---------------------------------------------------- +// Resource : r_qtn_fmradio_single_freq_name +//---------------------------------------------------- +// +RESOURCE TBUF r_qtn_fmradio_single_freq_name { buf = qtn_fmradio_single_freq_name; } + +// ============================ Application views ============================ + +// --------------------------------------------------------------------------- +// r_fmradio_softkeys_empty_stop +// --------------------------------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_empty_stop + { + buttons= + { + CBA_BUTTON { txt = text_softkey_empty; }, + CBA_BUTTON { id = EAknSoftkeyCancel; txt = text_softkey_stop; } + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_softkeys_empty_cancel +// --------------------------------------------------------------------------- +// +RESOURCE CBA r_fmradio_softkeys_empty_cancel + { + buttons= + { + CBA_BUTTON { txt = text_softkey_empty; }, + CBA_BUTTON { id = EAknSoftkeyCancel; txt = text_softkey_cancel; } + }; + } + +// Search Stations view + +//---------------------------------------------------- +// Resource : r_fmradio_search_stations__view +// Description : Search Stations view. (View ID=4) +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_fmradio_search_stations_view + { + menubar = r_fmradio_search_stations_menu; + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + toolbar = r_fmradio_search_stations_toolbar; + } + +//---------------------------------------------------- +// Resource : r_fmradio_search_stations_menu +// Description : Search Stations menu. +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_fmradio_search_stations_menu + { + titles= + { + MENU_TITLE { menu_pane = r_fmradio_search_stations_options_menu; txt = ""; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_search_stations_options_menu +// Description : Search Stations options menu items. +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_fmradio_search_stations_options_menu + { + items= + { + MENU_ITEM { command = EFMRadioCmdSaveChannel; txt = qtn_fmradio_options_save; flags = EEikMenuItemSpecific; }, + MENU_ITEM { command = EFMRadioCmdSaveAllChannels; txt = qtn_fmradio_options_save_all; }, + MENU_ITEM { command = EFMRadioCmdScanLocalStationsScan; txt = qtn_fmradio_options_search_stations; }, + MENU_ITEM { command = EFMRadioCmdActivateIhf; txt = qtn_fmradio_options_activate; }, + MENU_ITEM { command = EFMRadioCmdDeactivateIhf; txt = qtn_fmradio_options_deactivate; }, + MENU_ITEM { command = EAknCmdHelp; txt = qtn_options_help; }, + MENU_ITEM { command = EAknCmdExit; txt = qtn_options_exit; } + }; + } + +// --------------------------------------------------------------------------- +// r_fmradio_search_stations_toolbar +// --------------------------------------------------------------------------- +// +RESOURCE AVKON_TOOLBAR r_fmradio_search_stations_toolbar + { + flags = KAknToolbarTransparent|KAknToolbarWithoutCba|KAknToolbarFixed; + items = + { + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdSaveAll; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_save_all; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_station_save_all; + bmpmask = EMbmFmradioQgn_indi_tb_radio_station_save_all_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdScan; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_search_stations; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_radio_scan; + bmpmask = EMbmFmradioQgn_indi_tb_radio_scan_mask; + } + }; + }; + }, + TBAR_CTRL + { + type = EAknCtButton; + id = EFMRadioToolbarButtonCmdToggleIhf; + control = AVKON_BUTTON + { + states = + { + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_activate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_on; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_on_mask; + }, + AVKON_BUTTON_STATE + { + helptxt = qtn_fmradio_tooltip_deactivate_loudspeaker; + bmpfile = KFMRadioBitmapFile; + bmpid = EMbmFmradioQgn_indi_tb_ihf_off; + bmpmask = EMbmFmradioQgn_indi_tb_ihf_off_mask; + } + }; + }; + } + }; + } + +// ======================== Notes for the Scan Local Stations View ==================== + +//---------------------------------------------------- +// Resource : r_fmradio_search_stations_wait_note +// Description : A wait note used while station scanning is in progress. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_search_stations_wait_note + { + flags = EAknWaitNoteFlags; + buttons = r_fmradio_softkeys_empty_stop; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EGeneralNote; + control = AVKON_NOTE + { + layout = EWaitLayout; + singular_label = qtn_fmradio_wait_note_scanning; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } + +// ----------------------------------------------------------------------------- +// +// r_radio_cui_fill_stations_ctx_menubar +// Menu bar used by channel list view context sensitive menu. +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_BAR r_fmradio_scan_stations_ctx_menubar + { + titles = + { + MENU_TITLE + { + menu_pane = r_fmradio_scan_stations_ctx_menu; + } + }; + } + +RESOURCE MENU_PANE r_fmradio_scan_stations_ctx_menu + { + items = + { + MENU_ITEM { command = EFMRadioCmdSaveChannel; txt = qtn_fmradio_options_save; } + }; + } + +// ----------------------------------------------------------------------------- +// +// r_radio_cui_fill_stations_ctx_menubar +// Menu bar used by channel list view context sensitive menu. +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_BAR r_fmradio_scan_stations_ctx_menubar_save + { + titles = + { + MENU_TITLE + { + menu_pane = r_fmradio_scan_stations_ctx_menu_save; + } + }; + } + +RESOURCE MENU_PANE r_fmradio_scan_stations_ctx_menu_save + { + items = + { + MENU_ITEM { command = EFMRadioCmdSaveChannel; txt = qtn_fmradio_options_save; } + }; + } + +//---------------------------------------------------- +// Resource : r_fmradio_search_stations_wait_note +// Description : A wait note used while station scanning is in progress. +//---------------------------------------------------- +// +RESOURCE DIALOG r_fmradio_search_stations_wait_cancel_note + { + flags = EAknWaitNoteFlags; + buttons = r_fmradio_softkeys_empty_cancel; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EGeneralNote; + control = AVKON_NOTE + { + layout = EWaitLayout; + singular_label = qtn_fmradio_wait_note_scanning; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } +// --------------------------------------------------------------------------- +// r_fmradio_wait_anim_tuning +// Tuning animation. +// --------------------------------------------------------------------------- +// +RESOURCE FMRADIO_BITMAP_ANIMATION r_fmradio_wait_anim_tuning + { + frameInterval = 20; + frames = + { + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_01; + mask = EMbmFmradioQgn_graf_ring_wait_01_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_02; + mask = EMbmFmradioQgn_graf_ring_wait_02_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_03; + mask = EMbmFmradioQgn_graf_ring_wait_03_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_04; + mask = EMbmFmradioQgn_graf_ring_wait_04_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_05; + mask = EMbmFmradioQgn_graf_ring_wait_05_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_06; + mask = EMbmFmradioQgn_graf_ring_wait_06_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_07; + mask = EMbmFmradioQgn_graf_ring_wait_07_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_08; + mask = EMbmFmradioQgn_graf_ring_wait_08_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_09; + mask = EMbmFmradioQgn_graf_ring_wait_09_mask; + }, + FMRADIO_FADABLE_ICON + { + bmpfile = KFMRadioBitmapFile; + bitmap = EMbmFmradioQgn_graf_ring_wait_10; + mask = EMbmFmradioQgn_graf_ring_wait_10_mask; + } + }; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/data/fmradio_caption.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/data/fmradio_caption.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: FM Radio UI +* +*/ + +#include +#include + +RESOURCE CAPTION_DATA + { + caption = qtn_fmradio_app_menu_list; + shortcaption = qtn_fmradio_app_menu_grid; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/data/fmradio_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/data/fmradio_reg.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,35 @@ +/* +* 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: FMRadio +* +*/ + + +#include +#include +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0x10207A89 // MyApp UID + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "fmradio"; + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; + + localisable_resource_file = APP_RESOURCE_DIR"\\fmradio"; + localisable_resource_id = R_FMRADIO_LOCALISABLE_APP_INFO; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/group/bld.inf Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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 the information required for building the +* FMRadio application. +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +// stub sis +../../sis/fmradio_default/stub.sis /epoc32/data/z/system/install/fmradio_stub.sis +../inc/fmradiocommandlineparams.h APP_LAYER_PLATFORM_EXPORT_PATH(fmradiocommandlineparams.h) +../inc/fmradiouids.h APP_LAYER_PLATFORM_EXPORT_PATH(fmradiouids.h) + +// iby file +../rom/fmradio.iby CORE_APP_LAYER_IBY_EXPORT_PATH(fmradio.iby) +../rom/fmradioresources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(fmradioresources.iby) + +PRJ_EXTENSIONS + +START EXTENSION s60/mifconv +OPTION TARGETFILE fmradio.mif +OPTION HEADERFILE fmradio.mbg +OPTION SOURCEDIR ../aif +OPTION SOURCEFILE iconlist.txt +END + +START EXTENSION s60/mifconv +OPTION TARGETFILE fmradio_aif.mif +OPTION SOURCES -c8,8 qgn_menu_radio +END + +PRJ_MMPFILES + +fmradio.mmp diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/group/fmradio.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/group/fmradio.mmp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,117 @@ +/* +* 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: Project definition file for project FMRadio +* +*/ + + + +#include +#include + +#include +TARGET fmradio.exe +TARGETTYPE exe +epocstacksize 0x10000 + +UID 0x100039CE 0x10207A89 + +VENDORID VID_DEFAULT +CAPABILITY CAP_APPLICATION MultimediaDD ReadUserData + +PAGED + +START RESOURCE ../data/fmradio.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +LANGUAGE_IDS +END //RESOURCE + +START RESOURCE ../data/fmradio_reg.rss +DEPENDS fmradio.rsg +TARGETPATH /private/10003a3f/import/apps +END + +SOURCEPATH ../src + +SOURCE fmradioalfbitmapanimation.cpp +SOURCE fmradioalfindicator.cpp +SOURCE fmradioalfmediaidle.cpp +SOURCE fmradioalfvisualizer.cpp +SOURCE fmradioapp.cpp +SOURCE fmradioappui.cpp +SOURCE fmradiobacksteppingservicewrapper.cpp +SOURCE fmradiochannellistview.cpp +SOURCE fmradiochannellistcontainer.cpp +SOURCE fmradiocontroleventobserverimpl.cpp +SOURCE fmradiodocument.cpp +SOURCE fmradiomaincontainer.cpp +SOURCE fmradiomainview.cpp +SOURCE fmradiosvkevents.cpp +SOURCE fmradioglobalconfirmationquery.cpp +SOURCE fmradioscanlocalstationsview.cpp +SOURCE fmradioscanlocalstationscontainer.cpp +SOURCE fmradiofrequencyeditor.cpp +SOURCE fmradiofrequencynumber.cpp +SOURCE fmradiofrequencyquerycontrol.cpp +SOURCE fmradiofrequencyquerydialog.cpp +SOURCE fmradioalfrdsviewer.cpp +SOURCE fmradiomusicstorehandler.cpp +SOURCE fmradiopreset.cpp +SOURCE fmradioidlecontroller.cpp +SOURCE fmradiologo.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../fmradioengine/inc +USERINCLUDE ../../help/inc + +APP_LAYER_SYSTEMINCLUDE + +LIBRARY aknnotify.lib +LIBRARY alfclient.lib +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY eikdlg.lib +LIBRARY ws32.lib +LIBRARY eikcoctl.lib +LIBRARY avkon.lib +LIBRARY efsrv.lib +LIBRARY featmgr.lib +LIBRARY bafl.lib +LIBRARY commonengine.lib +LIBRARY aknskins.lib +LIBRARY egul.lib +LIBRARY eikctl.lib +LIBRARY fmradioengine.lib +LIBRARY hlplch.lib +LIBRARY cdlengine.lib +LIBRARY apgrfx.lib +LIBRARY remconcoreapi.lib +LIBRARY remconinterfacebase.lib +LIBRARY remconextensionapi.lib +LIBRARY gdi.lib +LIBRARY numberconversion.lib +LIBRARY aknlayout2.lib +LIBRARY aknlayout2scalable.lib +LIBRARY hwrmlightclient.lib +LIBRARY iaupdateapi.lib +LIBRARY liwservicehandler.lib +LIBRARY centralrepository.lib +LIBRARY ecom.lib +LIBRARY gesturehelper.lib + +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/group/iconlist.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/group/iconlist.txt Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,38 @@ +-c24,8 qgn_indi_radio_default.svg +-c8,8 qgn_indi_tb_radio_previous.svg +-c8,8 qgn_indi_tb_radio_next.svg +-c8,8 qgn_indi_tb_radio_scan.svg +-c8,8 qgn_indi_tb_radio_station_save.svg +-c8,8 qgn_indi_tb_radio_station_save_all.svg +-c8,8 qgn_indi_radio_playing.svg +-c24,8 qgn_menu_radio.svg +-c8,8 qgn_graf_ring_wait_01.svg +-c8,8 qgn_graf_ring_wait_02.svg +-c8,8 qgn_graf_ring_wait_03.svg +-c8,8 qgn_graf_ring_wait_04.svg +-c8,8 qgn_graf_ring_wait_05.svg +-c8,8 qgn_graf_ring_wait_06.svg +-c8,8 qgn_graf_ring_wait_07.svg +-c8,8 qgn_graf_ring_wait_08.svg +-c8,8 qgn_graf_ring_wait_09.svg +-c8,8 qgn_graf_ring_wait_10.svg +-c8,8 qgn_prop_msk_menu.svg +-c8,8 qgn_prop_image_tb_prev.svg +-c8,8 qgn_prop_image_tb_next.svg +-c8,8 qgn_prop_image_tb_prev_dimmed.svg +-c8,8 qgn_prop_image_tb_next_dimmed.svg +-c8,8 qgn_indi_music_widget_tb_radio_sound.svg +-c8,8 qgn_indi_music_widget_tb_radio_sound_dimmed.svg +-c8,8 qgn_indi_music_widget_tb_radio_sound_muted.svg +-c8,8 qgn_indi_music_widget_tb_radio_sound_muted_dimmed.svg +-c8,8 qgn_indi_radio_tb_list.svg +-c8,8 qgn_indi_tb_rename.svg +-c8,8 qgn_indi_cam4_tb_delete.svg +-c8,8 qgn_indi_marked_add.svg +-c8,8 qgn_indi_tb_ihf_on.svg +-c8,8 qgn_indi_tb_ihf_off.svg +-c8,8 qgn_indi_radio_tb_manualtune.svg +-c8,8 qgn_indi_radio_tb_mshop.svg +-c8,8 qgn_indi_radio_tb_gotoweb.svg +-c8,8 qgn_note_radio_jackmini.svg +-c8,8 qgn_menu_music.svg diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/debug.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,114 @@ +/* +* 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: Central place for nice debug-type macros & functions +* +* +*/ + + +#ifndef FMRADIO_DEBUG_H +#define FMRADIO_DEBUG_H + +#ifdef _DEBUG + +#ifdef __WINS__ +#define __CLOGGING__ +// File logging for WIS +//#define __FLOGGING__ + +#else + +// Logging with RDebug for target HW +#define __CLOGGING__ +//#define __FLOGGING__ + +#endif //__WINS__ + +#endif + +#if defined ( __FLOGGING__ ) + +_LIT(KLogFile,"FMRadioLog.txt"); +_LIT(KLogDir,"FMRadio"); + +#include +#include + +#define FLOG(a) {FPrint(a);} + +#define FLOGHEX(value, len) {RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len);} + +#define FDEBUGVAR(a) a +#define FTRACE(a) {a;} + +#define FDEBUGVAR(a) a + +// 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 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 FLOGHEX(a) + +#define FDEBUGVAR(a) a +#define FTRACE(a) {a;} + +#define FDEBUGVAR(a) a + +// Declare the FPrint function + +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); +} + + +#else // No loggings --> reduced code size +#define FLOG(a) +#define FLOGHEX(a) +#define FDEBUGVAR(a) +#define FTRACE(a) +#define FDEBUGVAR(a) + +#endif //_DEBUG + +#endif // FMRADIO_DEBUG_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradio.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradio.hrh Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies 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 constants of FMRadio. +* The file can be included in C++ or resource file. +* +*/ + + +#ifndef FMRADIO_HRH +#define FMRADIO_HRH + +enum TFMRadioViewCBAButtons // CBA button ID's + { + EIdCBAStop = 550 + }; + +enum TFMRadioCommandIds // Menu command ID's + { + // Main menu commands + EFMRadioCmdChannelList = 600, + EFMRadioCmdSeekUp, + EFMRadioCmdSeekDown, + EFMRadioCmdScanLocalStations, + EFMRadioCmdSaveChannel, + EFMRadioCmdSettings, + EFMRadioCmdOpenAFSubmenu, + + //RT+ + EMPXPbvCmdInternet, + EMPXPbvCmdInternetGoogle, + EMPXPbvCmdInternetWikipedia, + EMPXPbvCmdInternetAmg, + EMPXPbvCmdInternetNokiaMusicStore, + EMPXPbvCmdInternetMusicPortl, + EMPXPbvCmdInternetGoToWeb, + + // Channel list menu commands + EFMRadioCmdErase, + EFMRadioCmdRename, + EFMRadioCmdListenCh, + + // Manual tuning menu commands + EFMRadioCmdTuneManually, + EFMRadioCmdClose, + + // Scan local stations menu commands + EFMRadioCmdSaveAllChannels, + EFMRadioCmdScanLocalStationsScan, + + // Used in both menus + EFMRadioCmdActivateIhf, + EFMRadioCmdDeactivateIhf, + EFMRadioCmdHelp, + EFMRadioCmdExitApp, + + // Move commands + EFMRadioCmdMove, + EFMRadioCmdDone, + EFMRadioCmdDrop, + EFMRadioCmdGrap, + + + // General commands + EFMRadioCmdNextChannel, + EFMRadioCmdPrevChannel, + EFMRadioCmdRecord, + EFMRadioCmdStop,//620 + EFMRadioCmdUpdateVolume, + EFMRadioCmdStopTuning, + EFMRadioCmdScanLocalStationsViewActive, + EFMRadioCmdChannelListViewActive, + EFMRadioCmdMainViewActive, + EFMRadioCmdMuteOn, + EFMRadioCmdMuteOff, + EFMRadioCmdMute, + EFMRadioCmdEnableRdsAfSearch, + EFMRadioCmdDisableRdsAfSearch, + + //toolbar + EFMRadioToolbarButtonCmdTuneDown, + EFMRadioToolbarButtonCmdTuneUp, + EFMRadioToolbarButtonCmdExtensionList, + EFMRadioToolbarButtonCmdAutoSeekDown, + EFMRadioToolbarButtonCmdAutoSeekUp, + EFMRadioToolbarButtonCmdSaveAll, + EFMRadioToolbarButtonCmdScan, + EFMRadioToolbarButtonCmdToggleIhf, + EFMRadioToolbarButtonCmdNokiaMusicStore, + EFMRadioToolbarButtonCmdOperatorMusicStore, + EFMRadioChannelListToolbarButtonCmdSearchStations, + + //rocker + EFMRadioRockerButtonKeyLeft, + EFMRadioRockerButtonKeyLeftLong, + EFMRadioRockerButtonKeyRight, + EFMRadioRockerButtonKeyRightLong, + EFMRadioRockerButtonKeyUp, + EFMRadioRockerButtonKeyDown + }; + +enum TFMRadioNoteDialog + { + EHeadsetErrorNote = 750, + EChNotFoundInformationNote + }; + +enum TFMRadioStationChangeType + { + EFMRadioStationChangeNone = 950, + EFMRadioStationChangeNext, + EFMRadioStationChangePrevious, + EFMRadioStationChangeScanUp, + EFMRadioStationChangeScanDown + }; + +enum + { + EFMRadioFrequencyEditor = 0x2000, + EFMRadioCtFrequencyQuery + }; + +enum TFMRadioCancelScanType + { + EFMRadioCancelScanDefault = 0, + EFMRadioCancelScanBySoftkey, + EFMRadioCancelScanByHeadsetDisconnect + }; + +enum TFMRadioMusicStoreCommandIds + { + EFMRadioMusicStore = 40567, + EFMRadioMusicStoreGoogle, + EFMRadioMusicStoreWikipedia, + EFMRadioMusicStoreAmg, + EFMRadioMusicStoreNokiaMusicShop, + EFMRadioMusicStoreMusicPortl, + EFMRadioMusicStoreOperator + }; + +#endif // FMRADIO_HRH diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfbitmapanimation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfbitmapanimation.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,155 @@ +/* +* 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: Tuning animation for RadioGaGa +* +*/ + + +#ifndef CMFRADIOALFBITMAPANIMATION_H +#define CMFRADIOALFBITMAPANIMATION_H + + +// INCLUDES + +#include + + +// FORWARD DECLARATIONS + +class CAlfImageVisual; +class CAlfAnchorLayout; + + +// CONSTANTS + + +/** + * Alf control to show tuning animation + */ +class CFMRadioAlfBitmapAnimation : public CAlfControl + { + + public: + /** + * Two-phased constructor. + * @param aEnv Alf environment + */ + static CFMRadioAlfBitmapAnimation* NewL( CAlfEnv& aEnv ); + /** + * Destructor. + */ + virtual ~CFMRadioAlfBitmapAnimation(); + + public: // from base class + /** + * From CAlfControl, takes care of alfred event handling. + */ + TBool OfferEventL( const TAlfEvent& aEvent ); + + public: // New functions + /** + * Shows the indicator with the defined opacity value. + * @param aShowWithFading ETrue if the indicator will be shown with fading; EFalse otherwise. + * @see SetOpacityInVisibleState() + */ + void Show( TBool aShowWithFading ); + /** + * Hides the indicator with the defined opacity value. + * @param aHideWithFading ETrue if the indicator will be hidden with fading; EFalse otherwise. + * @see SetOpacityInHiddenState() + */ + void Hide( TBool aHideWithFading ); + /** + * Sets the indicator rectangle + * @param aRect Rectangle to the indicator + */ + void SetRect( const TRect& aRect ); + /** + * Starts bitmap animation after delay and + * fades it in while animation is running + */ + void StartBmpAnimation(); + /** + * Stops bitmap animation after delay and + * fades it out while animation is running + */ + void StopBmpAnimation(); + + private: + // Custom events for the bitmap animation. + enum TBmpAnimationCustomEvent + { + EBmpAnimationStart, + EBmpAnimationContinue, + EBmpAnimationStop + }; + + enum TBmpAnimationRunningState + { + EBmpAnimationStopped, + EBmpAnimationStartup, + EBmpAnimationRunning + }; + + void StartAnimation(); + + CFMRadioAlfBitmapAnimation(); + + void ConstructL( CAlfEnv& aEnv ); + + void CreateImageAnimationVisualL(); + + void CreateBitmapAnimationArrayL(); + + void ContinueBmpAnimation(); + + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + + private: // data + + // Visual containing current frame + CAlfImageVisual* iAnimationImageVisual; + // Animation frame array + RArray iFrames; + // Interval to change frames + TInt iFrameInterval; + // mbm file for bitmaps + HBufC* iBitmapFileName; + /** Anchor layout for Bmpanimation */ + CAlfAnchorLayout* iBmpAnimationAnchor; + TInt iCurrentFrameIndex; + /** Bmpanimation opacity in visible state */ + TReal iOpacityInVisibleState; + /** Bmpanimation opacity in hidden state */ + TReal iOpacityInHiddenState; + /** Bmpanimation rectangle */ + TRect iRect; + /** Animation state */ + TBmpAnimationRunningState iAnimationState; + + + }; + + +#endif // CMFRADIOALFBITMAPANIMATION_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfindicator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfindicator.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,188 @@ +/* +* 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: Definition of the class CFMRadioAlfIndicator. +* +*/ + + +#ifndef ALF_INDICATOR_H +#define ALF_INDICATOR_H + +// INCLUDES + +#include +#include +#include + +// FORWARD DECLARATIONS + +class CAlfTextVisual; + +// CLASS DEFINITION + +/** +* Text indicator control class +* +* Provides means to show and fade in/out a specific text inside the supplied "layout". +* +*/ +class CFMRadioAlfIndicator : public CAlfControl + { +public: // Constructors and destructor + + /** + * Epoc two-phased constructor. + * @param aEnv Reference to the HitchCock environment instance. + * @return Pointer to this Indicator component. + */ + static CFMRadioAlfIndicator* NewL( CAlfEnv& aEnv ); + /** + * Destructor + */ + virtual ~CFMRadioAlfIndicator(); +public: // Functions from base classes + /** + * From CAlfControl, takes care of alfred event handling. + * @param aEvent + */ + TBool OfferEventL( const TAlfEvent& aEvent ); +public: // New functions + /** + * Shows the indicator with the defined opacity value. + * @param aShowWithFading ETrue if the indicator will be shown with fading; EFalse otherwise. + * @see SetOpacityInVisibleState() + */ + void Show( TBool aShowWithFading ); + /** + * Hides the indicator with the defined opacity value. + * @param aHideWithFading ETrue if the indicator will be hidden with fading; EFalse otherwise. + * @see SetOpacityInHiddenState() + */ + void Hide( TBool aHideWithFading ); + /** + * Sets the indicator opacity in visible state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInVisibleState( const TReal aOpacity ); + /** + * Sets the indicator opacity in hidden state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInHiddenState( const TReal aOpacity ); + /** + * Sets the indicator text. + * @param aText The indicator text to be shown + */ + void SetTextL( const TDesC& aText ); + /** + * Changes indicator text color + * @param aTextColor Color of the indicator text + */ + void SetTextColor( const TRgb& aTextColor ); + /** + * Sets the indicator rectangle + * @param aRect Rectangle to the indicator + */ + void SetRect( const TRect& aRect ); +private: + /** + * C++ default constructor + */ + CFMRadioAlfIndicator( ); + /** + * EPOC second phase constructor. + * @param aEnv Reference to the Hitchcock environment instance. + */ + void ConstructL( CAlfEnv& aEnv ); +private: // New functions + /** + * Sets the fading animation to the CAlfVisual object. + * @param aVisual a pointer to the visual object + * @param aFadingTime Time duration after the visual object has been faded. Fading duration in milliseconds. + * @param aOpacity Target opacity value + */ + void Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ) const; + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + /** + * Sets absolute rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TSize& aSize ); + /** + * Sets relative rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealPoint& aBottomRightPosition ); + /** + * Sets relative rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealSize& aSize ); + /** + * Creates the needed drawing layers and visual objects + * for the indicator. + */ + void AddIndicatorLayerL(); + /** + * Creates the text style for the indicator + */ + void SetTextStyleL(); + +private: // Data + + /** Anchor layout for indicator */ + CAlfAnchorLayout* iIndicatorTextAnchor; + /** Visual object of the indicator. Not owned. */ + CAlfTextVisual* iText; + /** Text color of the indicator text */ + TRgb iTextColor; + /** Text style id of the indicator text */ + TInt iTextStyleId; + /** Indicator opacity in visible state */ + TReal iOpacityInVisibleState; + /** Indicator opacity in hidden state */ + TReal iOpacityInHiddenState; + /** Indicator rectangle */ + TRect iRect; + }; + +#endif //ALF_INDICATOR_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfmediaidle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfmediaidle.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,422 @@ +/* +* 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: Definition of the class CFMRadioAlfMediaIdle. +* +*/ + + +#ifndef FMRADIOALFMEDIAIDLE_H_ +#define FMRADIOALFMEDIAIDLE_H_ + +// INCLUDES + +#include +#include +#include + +#include "fmradioidlecontrolinterface.h" + +// FORWARD DECLARATIONS + +class CAlfGradientBrush; +class CAlfEnv; +class CAlfVisual; + +// CONSTANTS + +// CLASS DEFINITIONS + +/** +* CFMRadioAlfMediaIdle class +* +* Class launches animated information in the defined subregion of the display. +*/ +NONSHARABLE_CLASS(CFMRadioAlfMediaIdle) : public CAlfControl, + public MFMRadioIdleControlInterface + { +public: // Constructors and destructor + + /** Display orientations. */ + enum TOrientation + { + EPortrait = 0x4A, + ELandscape, + EOrientationNone + }; + + /** + * Epoc two-phased constructor. + * @param aEnv Reference to Alfred environment instance. + * @return Pointer to this media idle component. + */ + static CFMRadioAlfMediaIdle* NewL( CAlfEnv& aEnv ); + /** + * Destructor + */ + virtual ~CFMRadioAlfMediaIdle(); +public: // Functions from base classes + /** + * From CAlfControl, takes care of alfred event handling. + */ + TBool OfferEventL( const TAlfEvent& aEvent ); + +public: // New functions + + /** Media idle modes. */ + enum TMediaIdleMode + { + EOnlyBackgroundText = 0xB0, + EBackgroundTextAndMediaIdleItems + }; + + /** + * Adds media idle item text to be used in the media idle + * @param aMediaIdleItemText Text of the media idle item + */ + void AddMediaIdleContentL( const TDesC& aMediaIdleItemText ); + /** + * Removes all media idle item texts + */ + void ResetMediaIdleContent(); + /** + * Returns number of media idle content items + * @return content count + */ + TInt MediaIdleContentCount() const; + /** + * Sets the mode request for mode change. The mode + * will be changed as soon as possible. + * @param aRequestedMode Requested mode + */ + void SetModeChangeRequestL( TMediaIdleMode aRequestedMode ); + /** + * Retrieves the media idle mode + */ + CFMRadioAlfMediaIdle::TMediaIdleMode Mode(); + /** + * Sets primary color for the media idle + * @param aColor The color that is used as primary color of media idle + */ + void SetPrimaryColor( const TRgb& aColor ); + /** + * Sets secondary color for the media idle + * @param aColor The color that is used as secondary color of media idle + */ + void SetSecondaryColor( const TRgb& aColor ); + + /** + * Return orientation of the display + */ + CFMRadioAlfMediaIdle::TOrientation Orientation(); + /** + * Set orientation of the display + * @param aOrientation The display orientation + */ + void SetOrientation( TOrientation aOrientation ); + /** + * Calculates display layout + */ + void UpdateLayout(); + /** + * Adds PS name to the media idle item array + */ + void AddPsNameToMediaIdleL( const TDesC& aPsName ); + +private: + /** + * C++ default constructor + */ + CFMRadioAlfMediaIdle( ); + /** + * EPOC second phase constructor. + * @param aEnv Reference to the Hitchcock environment instance. + */ + void ConstructL( CAlfEnv& aEnv ); + +private: // New functions + + /** Scroll directions for the media idle item. */ + enum TMediaIdleItemScrollDirection + { + EScrollLeftToRight = 0xA0, + EScrollRightToLeft, + EScrollNone + }; + + /** States of media idle. */ + enum TMediaIdleState + { + ERunning = 0xA0, + EStopped + }; + + /** Custom events for the media idle. */ + enum TMediaIdleCustomEvent + { + EMediaIdleItemTransformationEnd = 0x5B, + EMediaIdleBackgroundTextScrollEnd, + EMediaIdleFadeOutAnimationEnd, + EMediaIdleChangeMode, + EMediaIdleEventNone + }; + + /** + * Launches media idle immediately. + */ + void StartMediaIdleL(); + /** + * Creates media idle with passed number of the media idle items + * @param aNumberOfMediaIdleItems Number of the media idle items + */ + void AddMediaIdleL( const TInt aNumberOfMediaIdleItems ); + /** + * Creates the media idle item to the passed media idle view port. + * @param aMediaIdle The view port of the media idle + * @param aMediaIdleItemText Text of the media idle item + * @param aMediaIdleItemHasBackground TBool to indicate background visibility + * @param aBackgroundColor The background color of the media idle item + * @param aBackgroundOpacity The background opacity of the media idle item + */ + CAlfTextVisual* AddMediaIdleItemL( CAlfLayout* aMediaIdle, + const TDesC& aMediaIdleItemText, + TBool aMediaIdleItemHasBackground = EFalse, + const TRgb& aBackgroundColor = KRgbWhite, + const TReal aBackgroundOpacity = 0.5f ); + /** + * Initializes the media idle items + * @param aNumberOfMediaIdleItems Number of the media idle items + */ + void InitializeMediaIdleItemsL( const TInt aNumberOfMediaIdleItems ); + /** + * Sets defined animation to the created media idle items + */ + void AnimateMediaIdleItems(); + /** + * Retrieves text from randomly chousen media idle item + */ + HBufC* GetRandomMediaIdleContentL(); + /** + * Sets color, opacity and scaling settings to the media idle item + * @param aMediaIdleItem The media idle item + * @param aMediaIdleItemText Text of the media idle item + * @param aTextStyleId Text style for text of the media idle item + */ + void SetMediaIdleItemSettingsL( CAlfTextVisual* aMediaIdleItem, const TDesC& aMediaIdleItemText, const TInt aTextStyleId ); + /** + * Sets translating animations to the media idle item + * @param aMediaIdleItem The media idle item + */ + void SetMediaIdleItemAnimation( CAlfTextVisual* aMediaIdleItem ); + /** + * Sets the media idle mode + */ + void SetMode( TMediaIdleMode aMode ); + /** + * Sets image to display + * @param aBitmapFileName Full path to image file + * @param aAbsoluteRect Rect of the image + * @param aBorders + * @param aParentLayout + */ + void SetImageByAbsoluteRectL( const TDesC& aBitmapFileName, + const TRect& aAbsoluteRect, + TBool aBorders, + CAlfLayout* aParentLayout = 0 ); + /** + * Fades in media idle + * @param aNow If ETrue shows media idle immediately otherwise + * fades with defined fading duration + */ + void MediaIdleFadeIn( TBool aNow = EFalse ); + /** + * Fades out media idle + * @param aNow If ETrue hides media idle immediately otherwise + * fades with defined fading duration + */ + void MediaIdleFadeOut( TBool aNow = EFalse ); + /** + * Sets and starts scrolling animation to CAlfTextVisual. + * The visual object is scrolled from current position to + * right side of the display + * @param aVisual a pointer to the visual object + */ + void ScrollToRight( CAlfTextVisual* aVisual ) const; + /** + * Sets and starts scrolling animation to CAlfTextVisual. + * The visual object is scrolled from current position to + * left side of the display + * @param aVisual a pointer to the visual object + */ + void ScrollToLeft( CAlfTextVisual* aVisual ) const; + /** + * @param aVisual a pointer to the visual object + * @param aTransitionTime Duration for reaching the target. + * @param aEventAfterScrollingEnd custom even that will be sent when transition time is end + */ + void SetScrollingToBackgroundText( CAlfTextVisual* aVisual, + TInt aTransitionTime, + TMediaIdleCustomEvent aEventAfterScrollingEnd = EMediaIdleEventNone ) ; + /** + * Sets fade-in animation to the CAlfVisual. + * @param aVisual a pointer to the visual object + * @param aFadingTime Time duration after the visual object has been faded in. + * Fading duration in milliseconds + * @param aOpacity Target opacity value + */ + void FadeIn( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity = 1.0f ) const; + /** + * Sets fade-out animation to the CAlfVisual. + * @param aVisual a pointer to the visual object + * @param aFadingTime Time duration after the visual object has been faded out. + * Fading duration in milliseconds + * @param aOpacity Target opacity value + */ + void FadeOut( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity = 0.0f ) const; + /** + * Translates the visual object with passed arguments + * @param aTextVisual a pointer to the visual object + * @param aX Translation value in the horizontal direction + * @param aY Translation value in the vertical direction + */ + void Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ); + /** + * Removes all transformations of the visual object such as the scaling and translating. + * @param aTextVisual a pointer to the visual object + */ + void LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ); + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + /** + * Sets absolute rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TSize& aSize ); + /** + * Sets relative rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealPoint& aBottomRightPosition ); + /** + * Sets relative rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealSize& aSize ); + + + + /* + * Transformation end event received + */ + void HandleMediaIdleItemTransformationEndEventL( const TAlfEvent& aEvent ); + + /** + * Background text scroll end event received + */ + void HandleBackgroundTextScrollEndEventL( const TAlfEvent& aEvent ); + + /** + ** Create fonts for media idle; based on a list of relative font sizes + */ + void CreateFontsL(); + + /** + * Create a background idle text visual + */ + void CreateBackgroundTextL(); + /** + * Stops media idle + */ + void StopAndFadeOutMediaIdle(); + + // from MFMRadioIdleControlInterface + void Show(); + + /** + * from MFMRadioIdleControlInterface + */ + void Hide(); + + /** + * from MFMRadioIdleControlInterface + */ + void Deactivate(); + +private: // Data + /** Status flag for knowing should the fonts be recreated or not */ + TOrientation iFontsOrientation; + /** Display orientation */ + TOrientation iOrientation; + + /** Layout for media idle */ + TAknLayoutRect iMediaIdleLayout; + /** Text style id of the media idle background text */ + TInt iMediaIdleItemBackgroundTextStyleId; + /** States of media idle */ + TMediaIdleState iMediaIdleState; + /** Keeps track of the current media idle mode */ + TMediaIdleMode iMediaIdleMode; + /** Keeps track of the requested mode */ + TMediaIdleMode iMediaIdleRequestedMode; + /** Counts the items that have finished their transformations for mode change */ + TInt iItemsTransformationEndEventCounter; + + /** Color to be used for the media idle items */ + TRgb iMediaIdlePrimaryColor; + /** Color to be used for the media idle items */ + TRgb iMediaIdleSecondaryColor; + /** Scroll direction for the media idle item */ + TMediaIdleItemScrollDirection iScrollDirection; + + /** Array for the strings of the media idle items */ + CDesCArrayFlat* iMediaIdleItemArray; + /** Array for the text styles of the media idle items */ + RArray iTextStyleIdArray; + /** Scroll direction for the media idle background text */ + TMediaIdleItemScrollDirection iBackgroundTextScrollDirection; + /** Indicates whether the instance is fully constructed */ + TBool iIsConstructed; + /** the latest PS name added to the media idle item array. Owned */ + HBufC* iPsName; + /** The last size for font creation */ + TInt iFontReferenceHeight; + }; + +#endif /*FMRADIOALFMEDIAIDLE_H_*/ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfrdsviewer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfrdsviewer.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,234 @@ +/* +* 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: Definition of the class CFMRadioAlfRDSViewer. +* +*/ + + +#ifndef ALF_RDS_VIEWR_H +#define ALF_RDS_VIEWR_H + +// INCLUDES + +#include +#include + +#include "fmradioidlecontrolinterface.h" +// FORWARD DECLARATIONS + +class CAlfTextVisual; +class MFMRadioAlfRdsViewObserver; +// CLASS DEFINITION + +/** +* Text indicator control class +* +* Provides means to show and fade in/out a specific text inside the supplied "layout". +* +*/ +class CFMRadioAlfRDSViewer : public CAlfControl, + public MFMRadioIdleControlInterface + { +public: // Constructors and destructor + + /** + * Epoc two-phased constructor. + * @param aEnv Reference to the HitchCock environment instance. + * @return Pointer to this Indicator component. + */ + static CFMRadioAlfRDSViewer* NewL( CAlfEnv& aEnv ); + /** + * Destructor + */ + virtual ~CFMRadioAlfRDSViewer(); +public: // Functions from base classes + /** + * From CAlfControl, takes care of alfred event handling. + * @param aEvent + */ + TBool OfferEventL( const TAlfEvent& aEvent ); +public: // New functions + /** + * Resets the RDS viewer and + * cancels alf events. + */ + void Reset(); + /** + * Sets the indicator opacity in visible state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInVisibleState( const TReal aOpacity ); + /** + * Sets the indicator opacity in hidden state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInHiddenState( const TReal aOpacity ); + /** + * Sets the indicator text. + * @param aText The indicator text to be shown + */ + TBool SetTextL( const TDesC& aText ); + /** + * Changes indicator text color + * @param aTextColor Color of the indicator text + */ + void SetTextColor( const TRgb& aTextColor ); + /** + * Sets the indicator rectangle + * @param aRect Rectangle to the indicator + */ + void SetRect( const TRect& aRect ); + /** + * Get RDS text area visibility + * @return visibility status + */ + TBool IsShowingRdsTextArea() const; + /** + * Sets the Observer + * @param aObserver The object to observe the control + */ + + void SetObserver( MFMRadioAlfRdsViewObserver* aObserver ); + /** + * Removes the observer + */ + void RemoveObserver( MFMRadioAlfRdsViewObserver* aObserver ); + + /** + * Check if the same rds text has been displayed + * for the predefined time period + * @return timer status + */ + TBool IsRdsTextVisibilityTimerCompleted(); +private: + /** + * C++ default constructor + */ + CFMRadioAlfRDSViewer(); + /** + * EPOC second phase constructor. + * @param aEnv Reference to the Hitchcock environment instance. + */ + void ConstructL( CAlfEnv& aEnv ); + /** + * from MFMRadioIdleControlInterface + */ + void Show(); + /** + * from MFMRadioIdleControlInterface + */ + void Hide(); + + /** + * from MFMRadioIdleControlInterface + */ + void Deactivate(); + +private: // New functions + /** + * Sets the fading animation to the CAlfVisual object. + * @param aVisual a pointer to the visual object + * @param aFadingTime Time duration after the visual object has been faded. Fading duration in milliseconds. + * @param aOpacity Target opacity value + */ + void Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ) const; + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + /** + * Sets absolute rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TSize& aSize ); + /** + * Sets relative rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealPoint& aBottomRightPosition ); + /** + * Sets relative rect of the anchor by top left and size of the rect. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aSize Size of the rect + */ + void SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealSize& aSize ); + /** + * Creates the needed drawing layers and visual objects + * for the indicator. + */ + void AddIndicatorLayerL(); + /** + * Creates the text style for the indicator + */ + void SetTextStyleL(); + +private: + + enum TFadeCustomEvent + { + EFadeInCompleted, + EOldTextFadeEffectCompleted, + ERDSDisplayTimerCompleted + }; + +private:// Data + /** Anchor layout for indicator */ + CAlfAnchorLayout* iIndicatorTextAnchor; + /** Visual object of the indicator. Not owned. */ + CAlfTextVisual* iText; + /** Text color of the indicator text */ + TRgb iTextColor; + /** Text style id of the indicator text */ + TInt iTextStyleId; + /** Indicator opacity in visible state */ + TReal iOpacityInVisibleState; + /** Indicator opacity in hidden state */ + TReal iOpacityInHiddenState; + /** Indicator rectangle */ + TRect iRect; + /** flag for RDS text area visibility */ + TBool iIsRdsTextVisible; + /** local copy of latest RT */ + RBuf iRadioText; + /** Array of observers. */ + RPointerArray iObservers; + // flag for rds text timer + TBool iRdsTextVisibilityTimerCompleted; + }; + +#endif //ALF_RDS_VIEWR_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfrdsviewobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfrdsviewobserver.h Tue Feb 02 00:17:10 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: Declares an interface for observing rds text events +* +*/ + +#ifndef FMRADIOALFRDSVIEWOBSERVER_H_ +#define FMRADIOALFRDSVIEWOBSERVER_H_ + +/* + * Interface for notifying rds text events. + */ +class MFMRadioAlfRdsViewObserver + { + public: + /* + * Called when the same rds text has been + * displayed for predifined time period + */ + virtual void NotifyRdsTextTimerCompletion() = 0; + }; +#endif /* FMRADIOALFRDSVIEWOBSERVER_H_ */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioalfvisualizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioalfvisualizer.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,429 @@ +/* +* 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: Definition of the class CFMRadioAlfVisualizer. +* +*/ + + +#ifndef FMRADIOALFVISUALIZER_H +#define FMRADIOALFVISUALIZER_H + +// INCLUDES + +#include +#include +#include +#include +#include + +#include "fmradiodefines.h" +#include "fmradio.hrh" + +// CONSTANTS + +/** Scroll directions of the visual objects. */ +enum TScrollDirection + { + EScrollLeftToRight = 0xA0, + EScrollRightToLeft, + EScrollNone + }; + +/** Possible display styles. */ +enum TFMRadioDisplayStyle + { + EFMRadioDisplaySingleLine = 0, /**< Single line display. */ + EFMRadioDisplayDoubleLine, /**< Double line display. */ + EFMRadioDisplayTuning, /**< Tuning display. */ + EFMRadioDisplayNoDisplay /**< No display used. */ + }; + +/** Display orientations. */ +enum TDisplayOrientation + { + EPortrait = 0x4A, + ELandscape, + EOrientationNone + }; + +// FORWARD DECLARATIONS + +class CAlfTextVisual; +class CAlfViewportLayout; +class CAlfGradientBrush; +class CFMRadioAlfBitmapAnimation; +class CFMRadioAppUi; + +using namespace GestureHelper; +// CLASS DEFINITION + +/** +* CFMRadioAlfVisualizer class +* +* Visualizes informations of the FMRadio to the display by Hitchcock UI Toolkit +*/ +NONSHARABLE_CLASS(CFMRadioAlfVisualizer) : public CGestureControl, public MGestureObserver + { +public: // Constructors and destructor + + /** + * Epoc two-phased constructor. + * @param aEnv Reference to the HitchCock environment instance. + * @return Pointer to this Visualizer component. + */ + static CFMRadioAlfVisualizer* NewL( CAlfEnv& aEnv ); + /** + * Destructor + */ + virtual ~CFMRadioAlfVisualizer(); +public: // Functions from base classes + /** + * From CGestureControl/CAlfControl, takes care of alfred event handling. + * @param aEvent + */ + TBool OfferEventL( const TAlfEvent& aEvent ); + + /** + * From CGestureControl, takes care of gesture event handling. + * @param aEvent + */ + void HandleGestureL( const MGestureEvent& aEvent ); +public: // New functions + /** + * Changes station to next with scrolling and fading station's + * information (name, frequency, etc.). + * @param aChangeType The change type + * @param aFirstLine The text shown in the first line + * @param aSecondLine The text shown in the second line, or NULL + */ + void ChangeStationL( TFMRadioStationChangeType aChangeType, + const TDesC& aFirstLine, + const TDesC* aSecondLine = NULL ); + /** + * Scrolls out the current station information lines by + * hiding actual visuals and scrolling out the created temporary information lines. + * @param aChangeType Station change type + */ + void ScrollOutCurrentStationInformationL( TFMRadioStationChangeType aChangeType ); + /** + * Resets the station information and sets static text to the third line + * @param aInfoText an information text to show + * @param aChangeType The change type + */ + void SetStaticInfoTextL( TFMRadioStationChangeType aChangeType, const TDesC& aInfoText ); + /** + * Change text color of the text visuals + * @param aTextColor Color of the visual texts + */ + void SetStationInformationTextColor( const TRgb& aTextColor ); + /** + * Sets the display style in use. + * @param aDisplayStyle Display style to use. + */ + void SetDisplayStyle( TFMRadioDisplayStyle aDisplayStyle ); + /** + * Returns the display style. + * @return Display style. + */ + TFMRadioDisplayStyle DisplayStyle() const; + /** + * Calculates display layout + */ + void UpdateLayout(); + /** + * Return orientation of the display + */ + TDisplayOrientation Orientation(); + /** + * Set orientation of the display + * @param aOrientation Orientation of the display + */ + void SetOrientation( TDisplayOrientation aOrientation ); + /** + * Set mirrored layout state + * @param aIsMirrored state + */ + void SetMirrored( const TBool aIsMirrored ); + /** + * @return Mirrored layout state + */ + TBool IsMirrored() const; + + /** + * Starts tuning animation after delay + */ + void StartTuningAnimation(); + + /** + * Stops tuning animation by fading it away + */ + void StopTuningAnimation(); +private: + /** + * C++ default constructor + */ + CFMRadioAlfVisualizer( ); + /** + * EPOC second phase constructor. + * @param aEnv Reference to the Hitchcock environment instance. + */ + void ConstructL( CAlfEnv& aEnv ); +private: // New functions + + /** The visuals of the station information display. */ + enum TStationInformationVisual + { + EFirstLineTextVisual = 0x1, /**< Text visual of the first line. */ + ESecondLineTextVisual = 0x2, /**< Text visual of the second line. */ + ETuningTextVisual = 0x4, /* Tuning text visual. */ + EAllVisuals = EFirstLineTextVisual | + ESecondLineTextVisual | + ETuningTextVisual + }; + + /** + * Specifies the axis that is currently used in the station info drag + */ + enum TFMRadioDragAxis + { + EFMRadioDragAxisNone = 0, + EFMRadioDragAxisX, + EFMRadioDragAxisY + }; + + /** + * Sets text to the defined station information visual. + * @param aVisual The text visual object for showing + * @param aText Text + */ + void SetVisualTextL( TStationInformationVisual aVisual, const TDesC& aText ); + /** + * Shows the defined station information visual. + * @param aVisual The text visual object for showing + * @param aFade ETrue if fade effect it to be used, EFalse otherwise. + */ + void ShowVisual( TStationInformationVisual aVisual, TBool aFade ); + /** + * Hides the defined station information visual. + * @param aVisual The text visual object for hiding + */ + void HideVisual( TStationInformationVisual aVisual ); + /** + * Sets and starts scrolling and fading animations to CAlfTextVisual. + * The visual object is scrolled from right side of the display to + * original position of the visual object. + * @param aVisual a pointer to the visual object + */ + void ScrollRightToLeftWithFadeIn( CAlfVisual& aVisual ) const; + /** + * Sets and starts scrolling and fading animations to CAlfTextVisual. + * The visual object is scrolled from left side of the display to + * original position of the visual object. + * @param aVisual a pointer to the visual object + */ + void ScrollLeftToRightWithFadeIn( CAlfVisual& aVisual ) const; + /** + * Sets and starts scrolling and fading animations to CAlfTextVisual. + * The visual object is scrolled from top of the display to + * original position of the visual object. + * @param aVisual a pointer to the visual object + */ + void ScrollInFromTop( CAlfVisual& aVisual ) const; + /** + * Sets and starts scrolling and fading animations to CAlfTextVisual. + * The visual object is scrolled from bottom of the display to + * original position of the visual object. + * @param aVisual a pointer to the visual object + */ + void ScrollInFromBottom( CAlfVisual& aVisual ) const; + /** + * Moves the visual back to it's original position + * @param aVisual The visual to be moved + */ + void RevertVisual( CAlfVisual& aVisual ); + /** + * Sets and starts scrolling animation to CAlfVisual. + * The visual object is scrolled from current position to + * right side of the display + * @param aVisual a reference to the visual object + * @param aTime Time duration after the visual object has been scrolled to the target. + * Scrolling duration in milliseconds. + */ + void ScrollToRight( CAlfVisual& aVisual, TInt aTime ) const; + /** + * Sets and starts scrolling animation to CAlfVisual. + * The visual object is scrolled from current position to + * left side of the display + * @param aVisual a reference to the visual object + * @param aTime Time duration after the visual object has been scrolled to the target. + * Scrolling duration in milliseconds. + */ + void ScrollToLeft( CAlfVisual& aVisual, TInt aTime ) const; + /** + * Sets and starts scrolling animation to CAlfVisual. + * The visual object is scrolled from current position above the the display + * @param aVisual a reference to the visual object + * @param aTime Time duration after the visual object has been scrolled to the target. + * Scrolling duration in milliseconds. + */ + void ScrollUp( CAlfVisual& aVisual, TInt aTime ) const; + /** + * Sets and starts scrolling animation to CAlfVisual. + * The visual object is scrolled from current position below the the display + * @param aVisual a reference to the visual object + * @param aTime Time duration after the visual object has been scrolled to the target. + * Scrolling duration in milliseconds. + */ + void ScrollDown( CAlfVisual& aVisual, TInt aTime ) const; + /** + * Sets fade-in animation to the CAlfVisual. + * @param aVisual a reference to the visual object + * @param aFadingTime Time duration after the visual object has been faded in. + * Fading duration in milliseconds + * @param aOpacity Target opacity value + */ + void FadeIn( CAlfVisual& aVisual, TInt aFadingTime, TReal aOpacity = 1.0f ) const; + /** + * Sets fade-out animation to the CAlfVisual. + * @param aVisual a reference to the visual object + * @param aFadingTime Time duration after the visual object has been faded out. + * Fading duration in milliseconds + * @param aOpacity Target opacity value + */ + void FadeOut( CAlfVisual& aVisual, TInt aFadingTime, TReal aOpacity = 0.0f ) const; + /** + * Translates the visual object with passed arguments + * @param aTextVisual a pointer to the visual object + * @param aX Translation value in the horizontal direction + * @param aY Translation value in the vertical direction + */ + void Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ); + /** + * Removes all transformations of the visual object such as the scaling and translating. + * @param aTextVisual a pointer to the visual object + */ + void LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ); + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + + /** + * Creates the needed drawing layers and visual objects + * for visualiazing the station information. + */ + void AddInformationLayersL(); + /** + * Creates the text styles to be used by station information visualiazing + */ + void CreateTextStylesForStationInformationL(); + /** + * Creates copy of current station information + */ + void CreateTemporaryStationInformationVisualsL(); + /** + * Animates temporary station infoout of the display + * @param aChangeType Change type + */ + void AnimateTemporaryStationInformationVisuals( TFMRadioStationChangeType aChangeType ); + /** + * Triggers the command to view handling + */ + void TriggerCommandL(); + /** + * Static call back for the long key press timer. + * @param aSelf Pointer to self. + * @return KErrNone + */ + static TInt StaticLongPressCallBack( TAny* aSelf ); +private: // Data + + /** Layout for the station information */ + TAknLayoutRect iStationInformationLayout; + /** Layout for the transparent background layer of the station information */ + TAknLayoutRect iTransparentBackgroundLayout; + + /** Layout for the first line. */ + TAknLayoutText iFirstLineLayout; + /** Layout for the second line */ + TAknLayoutText iSecondLineLayout; + /** Layout for the tuning text. */ + TAknLayoutText iTuningTextLayout; + /** Layout for the tuning animation. */ + TAknLayoutRect iTuningAnimationLayout; + + /** Visual object of the first line. Not owned. */ + CAlfTextVisual* iFirstLineVisualText; + /** Visual object of the second line. Not owned. */ + CAlfTextVisual* iSecondLineVisualText; + /** Visual text for tuning text. Not owned */ + CAlfTextVisual* iTuningVisualText; + + /** The layout for the station info visuals */ + CAlfAnchorLayout* iStationInformationAnchorLayout; + /** The layout for temporary station info fade out effect */ + CAlfAnchorLayout* iStationInformationTempAnchorLayout; + + /** Text color of the station information visuals */ + TRgb iStationInformationTextColor; + + /** Text style id of the first line */ + TInt iFirstLineTextStyleId; + /** Text style id of the second line */ + TInt iSecondLineTextStyleId; + /** Text style id of the tuning text line */ + TInt iTuningTextStyleId; + + /** Display style */ + TFMRadioDisplayStyle iDisplayStyle; + /** Display orientation */ + TDisplayOrientation iOrientation; + /** Scroll direction */ + TScrollDirection iScrollDirection; + // Bitmap Animation + CFMRadioAlfBitmapAnimation* iBmpAnimation; + // Flag to indicate mirrored layout usage + TBool iMirrored; + // visual size for bitmap animation positioning + TSize iTuningTextVisualSize; + // counts rt text (3rd line) scrollout -events for rt-timeout. + TInt iScrollOutCounter; + // Pointer to CFMRadioAppUi. Not owned + CFMRadioAppUi* iAppUi; + // key event + TInt iKeyScanCode; + /** + * If the long key event was detected or not. If it was, the subsequent key up should be ignored + */ + TBool iLongKeyTriggered; + /** + * Long key press timer. Owned. + */ + CPeriodic* iLongPressTimer; + // The position of the visual before the dragging started + TAlfTimedPoint iDragStartPosition; + // Status for determinging whether or not to revert the visual back to it's original position + TBool iRevertGestureDrag; + // The axis for the currently ongoing stroke + TFMRadioDragAxis iDragAxis; + }; + +#endif //FMRADIOALFVISUALIZER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioapp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioapp.h Tue Feb 02 00:17:10 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: Main application class definitions. +* +*/ + +/*! \mainpage +* +* @section intro Introduction +* +* @subsection abstract Abstract +* +* Application provides FM radio functionality for +* finding, saving and playing radio stations. +* +* @subsection architecture Basic architecture +* +* FMRadio constructs from the following program modules: +* application UI, application engine, plugin extensions and interfaces to external components. +** +* @subsection containedcomponents Contained Components/Executables +* +* - fmradio.exe / UI application +* - fmradioengine.dll / Application engine +* - fmradioactiveidleengine200.dll / Active idle engine. Notify observers about P&S changes +* - fmradioactionhandler.dll / Action handler plugin. Handles P&S commands +* - fmradiomcpplugin100.dll / Content publisher plugin. Publishes radio data to other components +* +* @subsection providedapis Provided APIs +* +* - FM Radio command line parameters. +* - Publish & Subscribe interface. +* +* @section usecases Use cases +* +* \image html fmradio_use_case.png "Use cases" +* + +* +*/ + +#ifndef FMRADIOAPP_H +#define FMRADIOAPP_H + +// INCLUDES +#include + +// CONSTANTS + +// CLASS DECLARATION + +/** +* CFMRadioApp application class. +* This class is a part of the standard application framework. The application +* gets instantiated by this class. Provides a factory method for +* instantiating the document object. +* +* @since 2.6 +*/ +class CFMRadioApp : public CAknApplication + { + + private: + /** + * From CApaApplication, creates CFMRadioDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + /** + * From CApaApplication, returns application's UID (KUidFMRadio). + * @return The value of KUidFMRadio. + */ + TUid AppDllUid() const; + }; + +#endif + +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioappui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioappui.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,805 @@ +/* +* 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: Definition of class FMRadioAppUi. Provides command +* and callback interfaces to control the engine and the +* application views. +* +*/ + + +#ifndef FMRADIOAPPUI_H +#define FMRADIOAPPUI_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioenginestatechangecallback.h" +#include "fmradioengine.h" +#include "fmradiodefines.h" +#include "fmradiosvkevents.h" +#include "fmradioglobalconfirmationquery.h" +#include "mchannellisthandler.h" + + +// FORWARD DECLARATIONS +class CAknQueryDialog; +class CFMRadioBackSteppingServiceWrapper; +class CFMRadioDocument; +class CFMRadioMainContainer; +class CFMRadioScanLocalStationsView; +class CFMRadioChannelListView; +class CFMRadioMainView; +class CEikMenuPane; +class MFMRadioLayoutChangeObserver; +class CAlfEnv; +class CAknVolumePopup; +class CAknInformationNote; +class CAknGlobalNote; +class CIAUpdate; +class CIAUpdateParameters; +class CFMRadioControlEventObserverImpl; +class CRepository; +// CLASS DECLARATION + +/** +* Interface to tell when dialog was terminated +* +* @since 2.6 +*/ +class MInformationNoteInterface + { + public: + + /** + * tells when dialog was terminated + */ + virtual void DialogTerminated() = 0; + + }; + + +/** +* Information note for headset key events. Enabling functionality to disable new dialog creation +* when dialog is active +* +* @since 2.6 +*/ +class CFMInformationNote: public CAknInformationNote + { + public: + + /** + * default constructor. + */ + CFMInformationNote( MInformationNoteInterface& aObserver); + + /** + * Destructor. + */ + virtual ~CFMInformationNote(); + + private: + + // Dialog event observer + MInformationNoteInterface& iDialogObserver; + + }; + + + +/** +* Instantiates the application views. It also acts as the default command handler for the +* application. Part of the standard application framework. +* +* @since 2.6 +*/ + +class CFMRadioAppUi : public CAknViewAppUi, + public MFMRadioSvkEventsObserver, + public MCoeControlObserver, + private MRadioEngineStateChangeCallback, + private MFMRadioGlobalConfirmationQueryObserver, + private MInformationNoteInterface, + public MChannelListHandler, + public MIAUpdateObserver + + { + public: + // Volume, seek, tune and channel changing directions + enum TFMRadioDirections + { + EDirectionUp, + EDirectionNone, + EDirectionDown + }; + + public: // Constructors and destructor + /** + * EPOC default constructor. + */ + void ConstructL(); + /** + * Destructor. + */ + virtual ~CFMRadioAppUi(); + + /** + * Utility method to select the right layout resource according to + * mirroring and orientation + * + * @param aNormalPortraitRes Normal portrait resource id + * @param aMirroredPortraitRes Mirrored portrait resource id + * @param aNormalLandscapeRes Normal landscape resource id + * @param aMirroredLandscapeRes Mirrored landscape resource id + * @return one of the resource id's passed to this method + */ + TInt ChooseLayoutResource( const TInt aNormalPortraitRes, + const TInt aMirroredPortraitRes, + const TInt aNormalLandscapeRes, + const TInt aMirroredLandscapeRes ) const; + public: // Functions from base classes + + /** + * From CEikAppUi, takes care of command handling. + * @since 2.6 + * @param aCommand command to be handled + */ + void HandleCommandL( TInt aCommand ); + + /** + * Notification interface from RadioEngine. Used to inform + * us when requests have completed. + * @since 2.6 + * @param aEventCode code corresponding to the event being propogated + * @param aErrorCode error code of the event being propogated + */ + void HandleRadioEngineCallBack( MRadioEngineStateChangeCallback::TFMRadioNotifyEvent aEventCode, TInt aErrorCode ); + public: // new functions + /** + * Returns a pointer to the radio engine + * + * @return Radio engine + */ + CRadioEngine* RadioEngine(); + + /** + * Returns a reference to Back Stepping wrapper + * + * @return Reference to Back Stepping wrapper + */ + CFMRadioBackSteppingServiceWrapper& BackSteppingWrapper() const; + + /** + * Returns a pointer to FMRadio's document, cannot be null. + * + * @return A pointer to a CFMRadioDocument object. + */ + CFMRadioDocument* Document() const; + /** + * Checks if current screen orientation is landscape + * + * @return ETrue if orientation is landscape, otherwise EFalse + */ + TBool IsLandscapeOrientation() const; + + /** + * Handles offline mode at startup. + */ + void HandleOfflineModeAtStartUpL(); + + /** + * Handles start up foreground event. + */ + void HandleStartupForegroundEventL(); + /** + * Nunber of channels stored in presets. + * @return number of channels in presets + */ + TInt NumberOfChannelsStored() const; + /** + * Returns the UID of the currently active local view. KNullUid if none + * active (construction/destruction). + * @return UID of the currently active local view, KNullUid if none + * active. + */ + TUid ActiveView() const; + /** + * Return startup scanning wizard status. + * @return running status + */ + TBool IsStartupWizardRunning() const; + /** + * Set startup scanning wizard status. + * @param aRunningState running state + */ + void SetStartupWizardRunning( const TBool aRunningState ); + /** + * Tune to the specified frequency + * @since 2.6 + * @param aFrequency the frequency to be tuned + */ + void TuneL(TInt aFrequency); + /** + * @return mirrored layout state + */ + TBool IsLayoutMirrored() const; + /** + * Show currently active volume popup control + */ + void ShowVolumePopupL(); + + /** + * From MChannelListHandler + * Updates channels array in appui + * @param aOperation tells which operation is made to array + * @param aIndex tells affecting index + * @param aMovedToNewIndex optional during move operation + */ + void UpdateChannelsL( TMoveoperations aOperation, + TInt aIndex, + TInt aMovedToNewIndex ); + + /** + * From MChannelListHandler + * Add a new channel to list of channels + * @param aChannelName Name of the channel to be saved + * @param aChannelFreq Channel frequency + */ + void AddChannelToListL( const TDesC& aChannelName, TInt aChannelFreq ); + + /** + * From MChannelListHandler + * Accessory method to channels array + */ + CArrayFixFlat* Channels(); + + void AutoTuneInMainView ( TBool aTune ); + /** + * status of the startup wizard state + * @return wizard status + */ + TBool IsStartupWizardHandled() const; + /** + * Return the index of the first channel that matches the + * frequency specified. + * @since 2.6 + * @param aFrequency The frequency to match against + * @return the index of the channel whose frequency matched. + * -1 if no frequency matched. + */ + TInt MatchingChannelL( TInt aFrequency ); + + /** + * Erase a channel + * @param aIndex index to delete + * @return ETrue if user accepted delete, otherwise EFalse + */ + TBool EraseChannelL( TInt aIndex ); + + /* + * Returns a pointer to the currently active volume popup control + * @return active volume popup + */ + CAknVolumePopup* ActiveVolumePopup() const; + + protected: + /** + * From CEikAppUi HandleWsEventL + */ + void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination); + + /** + * From base class CCoeAppUi + */ + void HandleForegroundEventL( TBool aForeground ); + + private: // Functions from base classes + + /** + * Handles a change to the application's resources + * @param aType The type of changed resource + */ + void HandleResourceChangeL( TInt aType ); + /** + * Updates the landscape data. This is done separately + * and not in IsLandscapeOrientation method as + * IsLandscapeOrientation MUST NOT do a window server flush + */ + void UpdateLandscapeInformation(); + private: // new functions + + /** + * All leaving function calls are made here, so that nothing is left on the stack if the ConstructL leaves + * The reason for this behaviour is that the UI framework doesn't handle leaves from the AppUi correctly. + */ + void SecondaryConstructL(); + /** + * Perform object cleanup. This would normally be performed in the destructor, but since it can also be + * called from SecondaryConstructL it was moved into a seperate function. + */ + void Cleanup(); + /** + * Handles callback from engine + * @since 3.0 + */ + void HandleInitializedCallbackL(); + /** + * Updates radio volume level by one step at time. + * @since 2.6 + * @param aDirection Parameter is interpreted as + * following: 1 = increase volume, 0 = no change, + * -1 = decrease volume. + */ + void UpdateVolume( CFMRadioAppUi::TFMRadioDirections aDirection ); + /** + * Perform automatic tuning to the next available audible frequency + * @since 2.6 + */ + void ScanUpL(); + /** + * Perform automatic tuning to the last available audible frequency + * @since 2.6 + */ + void ScanDownL(); + /** + * Save currently tuned frequency to the currently selected channel + * @since 2.6 + * @param aIndex the index of the slot to save the channel to. + */ + void SaveChannelL( TInt aIndex ); + /** + * Tune the radio hardware to the frequency saved at the specified channel + * @since 2.6 + * @param aIndex index of channel to tune to + */ + void PlayChannel( TInt aIndex ); + /** + * Set the audio output of the radio, and update the UI + * @since 2.6 + * @param aAudioOutput the audio output (headset or IHF) + */ + void SetAudioOutput( CRadioEngine::TFMRadioAudioOutput aAudioOutput ); + /** + * Cancel outstanding seek request + * @since 2.6 + */ + void CancelSeek(); + /** + * Shutdown the application. + * @since 2.6 + */ + void ExitApplication(); + /** + * Rename the currently selected channel + * @since 2.6 + */ + void RenameCurrentChannelL(); + /** + * Display confirmation dialog for channel deletion + * @param aIndex the index of the channel to delete + */ + TBool ConfirmChannelListDeleteL( TInt aIndex ); + /** + * Saves channel to be last item in channels list + * @since 2.6 + */ + void SaveChannelToLastIntoListL(); + /** + * Displays an error note with the text contained in the passed in reference + * @since 2.6 + * @param aErrorNote id of the text to display in the error note + */ + void DisplayErrorNoteL( TInt aErrorNote ); + + /** + * Displays an information note with the text contained in the passed in reference + * @since 2.6 + * @param aInfoNote id of the text to display in the error note + */ + void DisplayInformationNoteL( TInt aInfoNote ); + + /** + * Return the numeric key value corresponding to the key code + * @since 2.6 + * @param aCode the Symbian key code + * @return the numeric key value + */ + TInt NumericKeyValue( TUint aCode ); + /** + * Turn the fm radio hardware on + * @since 2.6 + */ + void TurnRadioOn(); + /** + * Processes "seek operation completed" callback + * @since 2.6 + */ + void HandleStopSeekCallback(); + /** + * Processes "set mute state" callback + * @since 2.6 + */ + void HandleSetMuteStateCallback(); + /** + * Processes "volume changed" callback + * @since 2.6 + */ + void HandleVolumeChangedCallback(); + /** + * Processes "set audio output completed" callback + * @since 2.6 + */ + void HandleAudioOutputSetCallback(); + /** + * Processes "headset reconnected" callback + * @since 2.6 + */ + void HandleHeadsetReconnectedCallback(); + /** + * Processes "headset disconnected" callback + * @since 2.6 + */ + void HandleHeadsetDisconnectedCallback(); + /** + * Processes "flightmode disabled" callback + * @since 2.6 + */ + void HandleFlightmodeDisabledCallback(); + /** + * Processes "volume update failed" callback + * @since 2.6 + */ + void HandleVolumeUpdateFailedCallback(); + /** + * Handles mute keypress from main view + * + */ + void HandleMuteCommand(); + /** + * Processes "manual tune failed" callback + * @since 2.6 + */ + void HandleManualTuneFailedCallback(); + /** + * Processes audio resource not available + * @since 3.0 + */ + void HandleAudioResourceNotAvailableL(TInt aErrorCode); + + /** + * Processes audio resource available + * @since 3.0 + */ + void HandleAudioResourceAvailableL(); + + /** + * Processes FM Transmitter on. + * @since 3.2 + */ + void HandleFMTransmitterOnCallbackL(); + + /** + * Processes Frequency range changed. + * @since 3.2 + */ + void HandleFreqRangeChangedCallback(); + + /** + * Processes Frequency range changed. + * @since 3.2 + */ + void HandleFlightModeEnabledCallbackL(); + + /** + * Handle flight mode disabled. + * @since 3.2 + */ + void HandleFlightModeDisabledCallback(); + + /** + * Processes Frequency range changed. + * @since 3.2 + */ + void HandleTunerReadyCallback(); + + /** + * Get region automatically from network or manually by user choice if network + * is not available + */ + TFMRadioRegionSetting HandleRegionsAtStartUpL(); + + /** + * Request tuner control from engine + */ + void RequestTunerControl() const; + + /** + * Is offline profile activated when radio audio was disabled. + * @return ETrue, if offline profile activated when radio + * audio was disabled. EFalse otherwise. + */ + TBool IsOfflineProfileActivatedWhenRadioAudioDisabled() const; + + /** + * Sets the toolbar visibility. + * @param aVisible + */ + void ShowToolbar( TBool aVisible ); + + /** + * Determine if scan all local stations view should be started + * in wizard mode + */ + void HandleStartupWizardL(); + + /** + * Start local stations scan + */ + void StartLocalStationsSeekL(); + + /** + * Tries to start radio again if the situation allows it + */ + void TryToResumeAudioL(); + /** + * Fade and show exit on all views + */ + void FadeViewsAndShowExit( TBool aState ); + + /* + * Show connect headset query with only exit softkey + */ + void ShowConnectHeadsetDialogL(); + + /* + * Get help context based on active view + * @return array containing help context for active view + */ + CArrayFix* GetCurrentHelpContextL() const; + + /** + * A call back function for processing start up foreground event. + * + * @param aSelfPtr Pointer to self. + * @return Always 0. + */ + static TInt StaticStartupForegroundCallback( TAny* aSelfPtr ); + + private: + + /** + * Called when volume level should be changed. + * Set volume control visible. + * @param aVolumeChange: +1 change volume up + * -1 change volume down + */ + void FMRadioSvkChangeVolumeL( TInt aVolumeChange ); + + /** + * Called when volume was changed last time 2 seconds ago or + * timer was started 2 seconds ago. The remove control timer + * is started when ChangeVolumeL() is called + * or when started through CMmsSvkEvents::StartRemoveTimerL() + */ + void FMRadioSvkRemoveVolumeL( ); + + void FMRadioHeadsetEvent(TAccessoryEvent aEvent); + + /** + * From MFMRadioGlobalConfirmationQueryObserver + * + * @see MFMRadioGlobalConfirmationQueryObserver::GlobalConfirmationQueryDismissedL(TInt aSoftKey) + */ + void GlobalConfirmationQueryDismissedL( TInt aSoftKey ); + + /** + *From MCoeControlObserver. To handle the volume events. + */ + void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); + + /** + * From MInformationNoteInterface. To handle dialog terminated events. + */ + void DialogTerminated(); + + /** + * Gets the Channels array + */ + void GetChannelsArrayL(); + /** + * Check available IAD updates + */ + void HandleIADUpdateCheckL(); + // from base class MIAUpdateObserver + void CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates ); + void UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResultDetails ); + void UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ); + + /** + * Processes the tail of the command + * @param aTail The tail to be processed + */ + void ProcessCommandTailL( const TDesC8& aTail ); + + // from base class CEikAppUi + MCoeMessageObserver::TMessageResponse HandleMessageL( + TUint32 aClientHandleOfTargetWindowGroup, + TUid aMessageUid, + const TDesC8& aMessageParameters ); + + TBool ProcessCommandParametersL( TApaCommand aCommand, + TFileName& aDocumentName, + const TDesC8& aTail ); + + /** + * Check if Active Idle app is on foreground. + * + * @return ETrue if idle app is in the foreground, EFalse otherwise. + */ + TBool IsIdleAppForeground(); + + /** + * Check if Active Idle is enabled. + * + * @return ETrue if active idle is in the enabled, EFalse otherwise. + */ + TBool IsActiveIdleEnabled(); + + /** + * Handles the possibly pending view activation + */ + void HandlePendingViewActivationL(); + + private: + + enum TInterfaceState + { + EFMRadioStateOff = 0, // Radio off + EFMRadioStateOffForPhoneCall, // Radio off because a phone call + EFMRadioStateOffBeforePhoneCall,// Radio was off + phone call going on -> no resume + EFMRadioStateOn, + EFMRadioStateRecording, + EFMRadioStateBusyRadioOn, + EFMRadioStateBusyRadioOff, + EFMRadioStateBusyScanUp, + EFMRadioStateBusyScanDown, + EFMRadioStateBusySeek, + EFMRadioStateBusyMute, + EFMRadioStateBusyVolume, + EFMRadioStateBusyManualTune, + EFMRadioStateBusyScanLocalStations, + EFMRadioStateExiting + }; + + /** + * State to indicate the mute status + */ + enum TFMMuteStatus + { + EFMUninitialized = 0, // Uninitialized value + EFMUnmuted, // Unmute state + EFMMuted // Mute state + }; + + // System's volume indicator + CAknVolumePopup* iIhfVolumePopupControl; + CAknVolumePopup* iHeadsetVolumePopupControl; + CAknVolumePopup* iActiveVolumePopupControl; + + CRadioEngine* iRadioEngine; + TInt iCurrentRadioState; + CFMRadioScanLocalStationsView* iScanLocalStationsView; + CFMRadioChannelListView* iChannelListView; + CFMRadioMainView* iMainView; + //all the possible radio UI states + TInt iFMRadioVariationFlags; + CFMRadioSvkEvents* iSvkEvents; + TBool iAlreadyClean; + MFMRadioLayoutChangeObserver* iLayoutChangeObserver; + CFMRadioControlEventObserverImpl* iControlEventObserver; + /** + * Is audio resources available + */ + TBool iAudioResourceAvailable; + + /** + * Was audio lost "permanently" due to another music playing application? + */ + TBool iAudioLost; + + /** + * Global offline query. Owned + */ + CFMRadioGlobalConfirmationQuery* iGlobalOfflineQuery; + + /** + * Local activate offline query. Owned + */ + CAknQueryDialog* iLocalActivateOfflineQuery; + + /** + * Local continue offline query. Owned + */ + CAknQueryDialog* iLocalContinueOfflineQuery; + + /** + * Is offline profile activated when radio audio was disabled. + */ + TBool iOfflineProfileActivatedWhenRadioAudioDisabled; + + /** + * Is the local "continue in offline" query visible. + */ + TBool iShowingLocalOfflineContinueQuery; + + /** + * Is the local or global offline query activated. + */ + TBool iOfflineQueryDialogActivated; + + /** + * Is the start up of application ongoing. + */ + TBool iStartUp; + + /** + * Is the screen orientation landscape + */ + TBool iLandscape; + CAlfEnv* iAlfEnv; // Owned + // flag to indicate wizard handling + TBool iStartupWizardHandled; + // flag for startup wizard status + TBool iStartupWizardRunning; + // connect headset query + CAknQueryDialog* iConnectHeadsetQuery; + // flag to indicate if automatic tune is activated from startup wizard + TBool iTuneFromWizardActivated; + // akn information note ptr to check that dialog has dismissed from display + TBool iInfoNoteOn; + // global note for headset status when radio is background + CAknGlobalNote* iConnectHeadsetGlobalNote; + // flag for previous mute status + TFMMuteStatus iMuteStatusBeforeRadioInit; + // Channels list + CArrayFixFlat* iChannels; + // IAD client object. Owned. + CIAUpdate* iUpdate; + // Parameters for IAD update. Owned. + CIAUpdateParameters* iParameters; + TBool iAutoTune; + TBool iAutoTuneUnmute; + // The backstepping wrapper. Owned. + CFMRadioBackSteppingServiceWrapper* iBsWrapper; + // Is feature manager initialized, used for uninitializing feature manager + TBool iFeatureManagerInitialized; + // own, for active idle setting + CRepository* iSettingsRepository; + // Callback for processing start up foreground event. + CAsyncCallBack* iStartupForegroundCallback; + // The view id of the view that is to be activated when possible + TUid iPendingViewId; + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiobacksteppingservicewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiobacksteppingservicewrapper.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,126 @@ +/* +* 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 the class CFMRadioBackSteppingServiceWrapper +* +*/ + +#ifndef CFMRADIOBACKSTEPPINGSERVICEWRAPPER_H +#define CFMRADIOBACKSTEPPINGSERVICEWRAPPER_H + +#include +#include +#include + +class MLiwInterface; +class CLiwGenericParamList; +class CLiwServiceHandler; + +/** + * Back Stepping (BS) Service wrapper. + */ +class CFMRadioBackSteppingServiceWrapper : public CBase, public MCoeViewActivationObserver + { + +public: + + /** + * Static constructor. + * The object can be registered as view activation observer + * or view activations can be notified explicitly by HandleViewActivationEventL. + * + * @param aUid Application UID. + */ + static CFMRadioBackSteppingServiceWrapper* NewL( TUid aUid ); + + /** + * Destructor. + */ + ~CFMRadioBackSteppingServiceWrapper(); + + /** + * Forwards view activation event to BS Service. + * + * @param aViewId View id of the view where back is called. + * @param aEnter Indicates if it is entry or exit activation. + */ + void HandleViewActivationEventL( const TVwsViewId aViewId, TBool aEnter ); + + /** + * Forwards back command to BS Service. + * + * @param aViewId View id of the view where back is called. + * @return Returns Etrue if BS Service consumed the command, otherwise returns EFalse. + */ + TBool HandleBackCommandL( const TVwsViewId aViewId ); + +private: + + /** + * C++ default constructor. + */ + CFMRadioBackSteppingServiceWrapper(); + + /** + * 2nd phase constructor + * + * @param aUid Application UID. + */ + void ConstructL( TUid aUid ); + + /** + * Initializes BS Service. + * + * @param aUid Application UID. + */ + void InitializeL( TUid aUid ); + + /** + * Handles the result of a LIW command + * + * @return Returns ETrue if LIW command executed, otherwise returns EFalse. + */ + TBool HandleResultL(); + + // from base class MCoeViewActivationObserver + void HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, + const TVwsViewId& aViewIdToBeDeactivated ); + +private: // data + + /** + * AIW Service Handler. + * Owned. + */ + CLiwServiceHandler* iServiceHandler; + + /** + * BS Service interface returned by LIW. + * Owned. + */ + MLiwInterface* iBsInterface; + + /** + * In param list. + * Not owned. + */ + CLiwGenericParamList* iInParamList; + + /** + * Out param list. + * Not owned. + */ + CLiwGenericParamList* iOutParamList; + }; + +#endif // CFMRADIOBACKSTEPPINGSERVICEWRAPPER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiochannellistcontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiochannellistcontainer.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,235 @@ +/* +* 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: definition of the class CFMRadioRecordingContainer +* +*/ + + +#ifndef FMRADIOCHANNELLISTCONTAINER_H +#define FMRADIOCHANNELLISTCONTAINER_H + +// INCLUDES +#include +#include + +#include "fmradiodefines.h" +#include "fmradioengine.h" +#include "mchannellisthandler.h" + +// FORWARD DECLARATIONS +class CAknWaitDialog; +class CFMRadioChannelListView; +// CLASS DECLARATION + +/** +* Creates and owns the UI components related to the Channel List view. +* @since 2.6 +*/ +class CFMRadioChannelListContainer : public CCoeControl, + public MEikListBoxObserver + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioChannelListContainer + * @since 2.6 + * @param aRect Frame rectangle for container + * @param aRadioEngine Radio engine + * @param aObserver Handler for channel list + */ + static CFMRadioChannelListContainer* NewL( const TRect& aRect, + CRadioEngine& aRadioEngine, + MChannelListHandler& aObserver); + /** + * Destructor. + */ + virtual ~CFMRadioChannelListContainer(); + public: // New functions + /** + * Returns the index of the selected channel item from the channel list. + * @since 2.6 + * @return the index of the currently selected channel + */ + TInt CurrentlySelectedChannel() const; + /** + * Update the content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex index of the channel to update + * @param aChannelName the new name of the channel + * @param aChannelFrequency the new frequency of the channel + */ + void UpdateChannelListContentL( TInt aIndex, const TDesC& aChannelName, TInt aChannelFrequency ); + /** + * RemoveChannel from channel list + * @since 2.6 + * @param aIndex the index of the channel to update + */ + void RemoveChannelL( TInt aIndex ); + /** + * AddChannel from channel list + * @since 2.6 + * @param aChannelName the new name of the channel + * @param aChannelFrequency the new frequency of the channel + * @param aNowPlaying ETrue if channel is tuned + */ + void AddChannelL( const TDesC& aChannelName, TInt aChannelFrequency, TBool aNowPlaying ); + /** + * Update the content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex index of the last selected channel + */ + void UpdateLastListenedChannel( TInt aIndex ); + /** + * Adds icon to a list item + * @param aIndex new icon index + * @param aIconIndex icon index in list icon array + */ + void UpdateItemIconL( TInt aIndex, TInt aIconIndex ); + /** + * Hide all icons from the list + */ + void HideIconsL(); + /** + * Fades the entire window and controls in the window owned by this container control. + * @since 2.6 + * @param aFaded flag to indicate whether we should fade or unfade + */ + void SetFaded( TBool aFaded ); + /** + * From CCoeControl + */ + void HandleResourceChange(TInt aType); + /** + * MoveMode handled -> All Done + */ + void MoveDoneL(); + /** + * ReIndexAll items in constainer list + */ + void ReIndexAllL(); + /** + * Handle movable item drop + */ + void HandleDropL(); + /** + * Move selected item in list up + */ + void MoveUpL(); + /** + * Move selected item in list down + */ + void MoveDownL(); + /** + * Activate move action -> when grab is selected + */ + void ActivateMoveL(); + /** + * Move action canceled, return list to previous state + */ + TBool MoveCanceledL(); + /** + * Current Move action state. + */ + TBool MoveAction(); + /** + * Touch pad move event handling + */ + void TouchMoveEventL( TInt aIndex ); + + private: // Functions from base classes + /** + * Called by framework when the view size is changed + * @since 2.6 + */ + void SizeChanged(); + /** + * Return the number of controls in the window owned by this container + * @since 2.6 + * @return number of controls + */ + TInt CountComponentControls() const; + /** + * Return the control corresponding to the specified index + * @since 2.6 + * @param aIndex the index of the control to retrieve + * @return the control corresponding to the specified index + */ + CCoeControl* ComponentControl( TInt aIndex ) const; + /** + * Redraw the window owned by this container + * @since 2.6 + * @param aRect the size of the window to redraw + */ + void Draw( const TRect& aRect ) const; + /** + * From MEikListBoxObserver, for listbox event handling. + * @since 2.6 + * @param aListBox The originating list box. + * @param aEventType A code for the event. + */ + void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); + /** + * Allow the channel list to process key events + * @since 2.6 + * @param aKeyEvent The key event. + * @param aType The type of key event. + */ + TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); + /** + * Required for help. + * @since 2.7 + * @param aContext the help context to be used. + */ + void GetHelpContext(TCoeHelpContext& aContext) const; + + void FocusChanged(TDrawNow aDrawNow); + /* + * from CCoeControl + */ + void HandlePointerEventL( const TPointerEvent& aPointerEvent ); + + private: // new functions + // Default constructor + CFMRadioChannelListContainer( CRadioEngine& aRadioEngine, MChannelListHandler& aObserver ); + /** + * EPOC default constructor. + * @since 2.6 + * @param aRect Frame rectangle for container. + */ + void ConstructL( const TRect& aRect); + /** + * Create the channel list (initially all spots are set as empty) + * @since 2.6 + */ + void InitializeChannelListL(); + private: //data + // The channel list listbox + CAknDoubleNumberStyleListBox* iChannelList; + // Array of channel list items + CDesCArray* iChannelItemArray; + // Index of the most recently listened channel to keep the listbox up-to-date. + TInt iLastChIndex; + RPointerArray iControls; + TBool iFadeStatus; + CRadioEngine& iRadioEngine; + TBool iMoveAction; + TInt iMoveIndex; + TInt iTouchMoveIndex; + MChannelListHandler& iObserver; + // not owned + CFMRadioChannelListView* iChannelView; + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiochannellistview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiochannellistview.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,305 @@ +/* +* 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: definition of the class CFMRadioChannelListView +* +*/ + + +#ifndef FMRADIOCHANNELLISTVIEW_H +#define FMRADIOCHANNELLISTVIEW_H + +// INCLUDES +#include +#include + +#include "fmradiochannellistcontainer.h" +#include "mfmradiolayoutchangeobserver.h" +#include "fmradiordsobserver.h" +#include "mchannellisthandler.h" + + +// FORWARD DECLARATIONS +class CFMRadioChannelListViewContainer; +class CRadioEngine; + +// CLASS DECLARATION + +/** +* CFMRadioChannelListView view class. +* @since 2.6 +*/ +class CFMRadioChannelListView : public CAknView, + public MCoeControlObserver, + public MFMRadioLayoutChangeObserver, + public MFMRadioRdsObserver, + public MAknToolbarObserver + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioChannelListView + * @since 2.6 + * @param aRadioEngine pointer to a radio engine object + * @param aObserver Handler for channel list + */ + static CFMRadioChannelListView* NewL( CRadioEngine* aRadioEngine, + MChannelListHandler& aObserver ); + + /** + * CFMRadioChannelListView. + * @since 2.6 + */ + CFMRadioChannelListView::CFMRadioChannelListView( MChannelListHandler& aObserver ) ; + + /** + * Destructor. + * @since 2.6 + */ + virtual ~CFMRadioChannelListView(); + public: // New functions + /** + * Return the unique identifier corresponding to this view + * @since 2.6 + * @return the unique identifier corresponding to this view + */ + TUid Id() const; + /** + * Keep track of the last selected channel + * @since 2.6 + * @param aIndex the index of the last listened to channel + */ + void SetLastListenedChannel( TInt aIndex ); + /** + * Keep track of the current selected channel + * @param aChannelIndex the index of the current channel + */ + void SetNowPlayingChannel ( TInt aChannelIndex ); + /** + * Returns the index of the playing channel item from the + * channel list. + * @return the currently playing channel + */ + TInt CurrentlyPlayingChannel(); + /** + * Returns the index of the selected channel item from the + * channel list. If the container is active get the info from + * it, because it may have more up-to-date info. + * @since 2.6 + * @return the currently selected channel + */ + TInt CurrentlySelectedChannel(); + /** + * Make a request to the channel container to update the + * content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex the index of the channel to update + * @param aChannelName the new name of the channel + * @param aChannelFrequency the new frequency + */ + void UpdateChannelListContentL( TInt aIndex, const TDesC& aChannelName, TInt aChannelFrequency ); + /** + * Return true/false to indicate whether the channel specified is in play + * @param aChannelIndex the index of the channel to check + * @return true/false to indicate whether the channel is currently being played + */ + TBool ChannelInPlay( TInt aChannelIndex ) const; + /** + * Retrieve the index of the next channel that has been set. + * @since 2.6 + * @return the index of the next "in use" channel + */ + TInt NextChannel(); + /** + * Retrieve the index of the previous channel that has been set. + * @since 2.6 + * @return the index of the previous "in use" channel + */ + TInt PreviousChannel(); + /** + * Initialize the channels with the values currently saved in + * the radio engine + * @since 2.6 + */ + void InitializeChannelsL(); + /** + * Fade the view and all controls associated with it. Change + * the soft keys so that "Exit" is displayed + * @since 2.6 + * @param aFaded indicates whether the view should fade/unfade. + */ + void FadeAndShowExit( TBool aFaded ); + /** + * Update display when focus regained + * @since 3.0 + */ + void UpdateDisplayForFocusGained(); + /** + * from MFMRadioLayoutChangeObserver + * This method gets called by the AppUI when a dynamic layout change + * event occurs. + * @param aType layout change type + */ + void LayoutChangedL( TInt aType ); + /** + * Set empty channel list item + * when preset is deleted from fmradiopresetutility + * @param aIndex list index to delete + */ + void SetEmptyChannelListItemL( const TInt aIndex ) const; + + /** + * From MAknToolbarObserver + * Handle commands from toolbar. + * @param aCommandId The command id + */ + void OfferToolbarEventL( TInt aCommandId ); + + /** + * Sets toolbar visibility + * @param aVisible + * @return none + */ + void ShowToolbar( TBool aVisible ); + + /** + * From base class MFMRadioRdsObserver + */ + void RdsDataProgrammeService( const TDesC& aProgramService ); + void RdsDataPsNameIsStatic( TBool aStatic ); + void RdsDataRadioText( const TDesC& aRadioText ); + void RdsDataRadioTextPlus( const TInt /*aRTPlusClass*/, const TDesC& /*aRadioText*/ ){}; + void RdsAfSearchBegin(); + void RdsAfSearchEnd( TUint32 aFrequency, TInt aError ); + void RdsAfSearchStateChange( TBool aEnabled ); + void RdsAvailable( TBool aAvailable ); + /** + * Procedures for finishing a move of channel on the list + * @param none + * @return none + */ + void MoveActionDoneL(); + + /** + * Cancel the moving + */ + void CancelMoveL(); + + /** + * Dim relevant buttons when the list is empty + */ + void UpdateToolbar() const; + + /* + * Updates view when seek event is ended + */ + void StopSeekL(); + + private: // Functions from base classes + /** + * Activate the channel list view + * @since 2.6 + */ + void DoActivateL( const TVwsViewId& aPrevViewId,TUid aCustomMessageId, const TDesC8& aCustomMessage ); + /** + * Deactivate the channel list view + * @since 2.6 + */ + void DoDeactivate(); + /** + * Interprets view's menu,softkey and other commands and acts + * accordingly by calling the appropriate command handler + * function for further action. + * @since 2.6 + * @param aCommand the command to process + */ + void HandleCommandL( TInt aCommand ); + /** + * From MCoeControlObserver, control event observing. In this case, + * the user selection from the list is reported by container class + * and observed here. + * @since 2.6 + * @param aControl the control that caused the event + * @param aEventType the type of event that was triggered + */ + void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType ); + /** + * Sets the state of menu items dynamically according to the + * state of application data. + * @since 2.6 + * @param aResourceId Resource ID identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + */ + void DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ); + + /** + * SetMiddleSoftKeyLabelL, sets the MSK label + * + */ + void SetMiddleSoftKeyLabelL (TInt aResourceId, TInt aCommandId); + + /** + * UpdateMiddleSoftKeyL, updates the MSK + * + */ + void UpdateMiddleSoftKeyL(); + private: // new functions + /** + * EPOC default constructor. + * @since 2.6 + * @param aRadioEngine pointer to a radio engine object + */ + void ConstructL( CRadioEngine* aRadioEngine ); + + /** + * Prepare toolbar for FMRadio command buttons + */ + void PrepareToolbar(); + /* + * Set view title text + * @param aResourceId resource Id containing the title text + */ + void SetTitleL( TInt aResourceId ); + /** + * Procedures for beginning a move of channel on the list + * @param none + * @return none + */ + void MoveCurrentItemIndexL(); + + private: // Data + CFMRadioChannelListContainer* iContainer; + CRadioEngine* iRadioEngine; + TInt iChIndex; + TInt iNowPlayingIndex; + TInt iCurrentMSKCommandId; //owned + TBool iFaded; + MChannelListHandler& iObserver; + + CAknQueryDialog* iManualQueryDialog; + + TBool iMoveMode; + + /** + * Boolean for knowing if any moves have been made + */ + TBool iFirstMoveDone; + + /** + * Toolbar for controlling the application. + */ + CAknToolbar* iToolbar; + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiocommandlineparams.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiocommandlineparams.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,58 @@ +/* +* 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: This file contains definitions for +* FM Radio command line parameters +* +*/ + + +#ifndef FMRADIOCOMMANDLINEPARAMS_H +#define FMRADIOCOMMANDLINEPARAMS_H + +#include + +/** + * The needed ID's are defined in fmradiouids.h + * Only one of the following commands can be currently given at a time + */ + +/** + * FM Radio application UID + */ +const TUid KFMRadioCommandUid = {0x10207A89}; + +/** + * Starts FM Radio to specified view or activates it if some other view is already active + * Supports only Main view and Channel List View + * Example: "-v 1", use the ID's defined in fmradiouids.h + */ +_LIT8( KFMRadioCommandActivateView, "-v" ); + +/** + * Starts FM Radio to specified frequency or just tunes if application is already running. + * No effect if the frequency is outside current frequency range. Example: "-f 87500000" + * @param frequency The frequency to be activated in hertz + */ +_LIT8( KFMRadioCommandFrequency, "-f" ); + +/** + * Starts FM Radio to specified station index or just tunes if application is already running. + * No effect if the index is out of boundaries. Example: "-i 0" + * @param index The index to be activated + */ +_LIT8( KFMRadioCommandStationIndex, "-i" ); + +#endif // FMRADIOCOMMANDLINEPARAMS_H + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiocontroleventobserverimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiocontroleventobserverimpl.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,74 @@ +/* +* 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 class CFMRadioControlEventObserverImpl. +* Provides the implementation for the control event observer. +* +*/ + +#ifndef FMRADIOCONTROLEVENTOBSERVERIMPL_H_ +#define FMRADIOCONTROLEVENTOBSERVERIMPL_H_ + +#include + +#include "fmradiopropertyobserver.h" +#include "fmradioaudioutils.hrh" +#include "fmradiocontroleventobserver.h" + +class MFMRadioControlEventObserver; +class CFMRadioAppUi; + +class CFMRadioControlEventObserverImpl : public CBase, public MFMRadioControlEventObserver + { + public: + /** + * Static constructor. + */ + static CFMRadioControlEventObserverImpl* NewL( CFMRadioAppUi& aAppUi ); + + /** + * Destructor. + */ + ~CFMRadioControlEventObserverImpl(); + + void StepToChannelL( TFMRadioTuneDirection aDirection ); + void SetChannelL( TInt aChannelId ); + void SeekL( TFMRadioTuneDirection aDirection ); + void StepToFrequencyL( TFMRadioTuneDirection aDirection ); + void SetFrequencyL( TUint32 aFreq ); + void AdjustVolumeL( TFMRadioVolumeSetDirection aDirection ); + void MuteL( TBool aMute ); + void PlayL( TBool aDownPressed ); + void PauseL(TBool aDownPressed ); + void PausePlayL( TBool aDownPressed ); + void StopL( TBool aDownPressed ); + void ForwardL( TBool aDownPressed ); + void FastForwardL( TBool aDownPressed ); + void BackwardL( TBool aDownPressed ); + void RewindL( TBool aDownPressed ); + void ChannelUpL( TBool aDownPressed ); + void ChannelDownL( TBool aDownPressed ); + void VolumeUpL( TBool aDownPressed ); + void VolumeDownL( TBool aDownPressed ); + void ChangeViewL(TUid aViewId, TBool aForceChange); + void SetAudioOutputDestinationL(TFMRadioOutputDestination aDestination); + void AnswerEndCallL(); + + private: //Methods + CFMRadioControlEventObserverImpl(CFMRadioAppUi& aAppUi); + void ConstructL(); + + private: + CFMRadioAppUi& iAppUi; + }; +#endif /*FMRADIOCONTROLEVENTOBSERVERIMPL_H_*/ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiodefines.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiodefines.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,188 @@ +/* +* 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: This file contains common constant defines used within the +* scope of the application. +* +*/ + + +#ifndef FMRADIODEFINES_H +#define FMRADIODEFINES_H + +#include +#include +#include +#include + +#include "fmradioengine.h" + +const TInt KHzConversionFactor = 1000000; + +// Tuning step, frequency range high and low limits +const TReal KFrequencyTuningStep = 0.05; + +const TInt KFrequencyMaxDecimalPlaces = 2; +const TInt KFrequencyMaxLength = 6; + +// Minimum and maximum volume levels +const TInt KMinimumVolume = 1; +const TInt KMaximumVolume = 10; + +// Handy string buffer size declarations +const TInt KBufLen16 = 0x10; + +const TInt KDefaultRegionArrayGranularity = 3; + +// Channel list item amount +const TInt KMinNumberOfChannelListItems = 0; +const TInt KMaxNumberOfChannelListItems = 99; + +// Channel list channel item string length +const TInt KLengthOfChannelItemString = 100; + +// Channel list channel index string length +const TInt KLengthOfChIndexStringChList = 5; + +// Channel list channel name string length +const TInt KLengthOfChannelNameString = 80; + +// Channel list channel item icon index string length +const TInt KLengthOfChannelItemIconIndexString = 3; + +// Time after pressing delayed key 1 or 2 +const TInt KKeyDelayTimeInMicroseconds = 2000000; // 2 seconds + +const TInt KFMRadioProgressUpdateDelayInMicroseconds = 5000; //every .05 seconds. +const TInt KProgressBarMaxValue = 100; +const TInt KProgressBarIntervalChange = 10; + +//Decimal notation +const TInt KBaseTen = 10; + +// Asterisk key code +const TInt EStdKeyNkpAsteriskInDevice = 0x2A; + +// Current mode of the channel list view +enum TFMRadioChannelListViewMode + { + ENormalListMode, + ESaveChannelMode + }; + +//const TInt KNumberOfButtonsToDisplay = 5; + +// Channel list channel index string formatter +_LIT(KChIndexFormatChList, "%d"); +_LIT(KChIndexFormatChMenu, "%d "); +// Channel list channel item icon index string formatter +_LIT(KChIconIndexFormatChList, "%d"); + +// bitmap file for the button panel +_LIT( KFMRadioBmpFile, "fmradio.mif" ); + +// Keyboard number key codes +enum TKeyboardKeys +{ + EKeyboardKey0 = 0x30, + EKeyboardKey1 = 0x31, + EKeyboardKey2 = 0x32, + EKeyboardKey3 = 0x33, + EKeyboardKey4 = 0x34, + EKeyboardKey5 = 0x35, + EKeyboardKey6 = 0x36, + EKeyboardKey7 = 0x37, + EKeyboardKey8 = 0x38, + EKeyboardKey9 = 0x39 +}; + +// CONSTANTS FOR ALFRED ENVIRONMENT + +// Main view visual controls group id +const TInt KFMRadioVisualControlsGroupId = 1; +const TInt KFMRadioVisualizerGestureControlGroupId = 2; //Do not use for any other purpose +const TInt KFMRadioMediaIdleId = 312; +const TInt KFMRadioVisualControlId = 211; +const TInt KFMRadioRdsIndicatorId = 313; +const TInt KFMRadioRdsAfIndicatorId = 314; +const TInt KFMRadioRdsViewer = 316; +const TInt KFMRadioRdsInteractionIndicatorId = 317; +const TInt KFMRadioLogoId = 318; +const TReal KFMRadioIndicatorOpacityInHiddenState = 0.2f; +const TReal KFMRadioRdsViewerOpacityHidden = 0.0f; +const TReal KFMRadioRdsViewerOpacityShow = 0.4f; + + +// Main view transparent layer bottom margin +const TReal KInfoBgLayerBottomMarginAsNormalizedValue = -0.12f; +// Main view transparent layer top margin +const TReal KInfoBgLayerTopMarginAsNormalizedValue = 0.5f; +// Media Idle content item amount +const TInt KFMRadioMaxNumberOfMediaIdleContentItem = 10; + +// Time delay in milliseconds when main view toolbar buttons report long key press event +const TInt KLongPressDelayValueInMicroseconds = 500; +// How many times user is asked to scan local frequencies at application startup +const TInt KMaxStartupTimesToAskSaveWizard = 2; + +// Toolbar center (=mute) button state indexes +const TInt KMuteStateIndex = 1; +const TInt KUnMuteStateIndex = 0; + +/** +* Local Variation Flags for FM Radio +* For values, see FMRadioVariant.hrh. +* Integer value. +**/ +//_LIT( KFMRadioFeatures, "FMRadioFeatures" ); + +/** +* Upper frequency bound for FM Radio band +* Possible Values are: +* 0 ... 115000 +* 108000 default value +* Integer value. +**/ +_LIT( KFMRadioFrequencyRangeUpperLimit, "FMRadioFrequencyRangeUpperLimit" ); + +/** +* Lower frequency bound for FM Radio band +* Possible Values are: +* 0 ... 115000 +* 87500 default value +* Integer value. +**/ +_LIT( KFMRadioFrequencyRangeLowerLimit, "FMRadioFrequencyRangeLowerLimit" ); + +/** + * Direction change mark for strings with numerals in mirrored layout + */ +_LIT( KRightToLeftMark, "\x200F" ); +_LIT( KLeftToRightMark, "\x200E" ); + +/** + * Volume settings for radio + */ +const TInt KFMRadioMaxVolumeLevel = 20; +const TInt KFMRadioMinVolumeLevel = 0; +const TInt KFMRadioVolumeStepSize = 1; + +// Channel list icon index in the icon array +const TInt KNowPlayingIconIndexChList = 0; +const TInt KMoveIconIndexChList = 1; + +#endif + + + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiodocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiodocument.h Tue Feb 02 00:17:10 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: Definitaion of the CFMRadioDocument class, which +* handles application data serialization. Owns the Ui +* (controller) and the engine (model) +* +*/ + + +#ifndef FMRADIODOCUMENT_H +#define FMRADIODOCUMENT_H + +// INCLUDES +#include + +// CONSTANTS + +// FORWARD DECLARATIONS +class CEikAppUi; + +// CLASS DECLARATION + +/** +* Part of the standard application framework. Declares the document class +* for this application. +* @since 2.6 +*/ +class CFMRadioDocument : public CAknDocument + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * @since 2.6 + */ + static CFMRadioDocument* NewL( CEikApplication& aApp ); + /** + * Destructor. + * @since 2.6 + */ + virtual ~CFMRadioDocument(); + private: // New functions + /** + * EPOC default constructor. + * @since 2.6 + */ + CFMRadioDocument( CEikApplication& aApp ); + private: // Functions from base classes + /** + * From CEikDocument, create CFMRadioAppUi "App UI" object. + * @since 2.6 + */ + CEikAppUi* CreateAppUiL(); + }; + +#endif + +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiofrequencyeditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiofrequencyeditor.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,285 @@ +/* +* 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: Header file for CFMRadioFrequencyEditor +* +*/ + + +#ifndef CFMRADIOFREQUENCYEDITOR_H +#define CFMRADIOFREQUENCYEDITOR_H + +#include + +struct SEikControlInfo; + +/** + * Custom editor for editing radio frequencies. + */ +class CFMRadioFrequencyEditor : public CEikMfne + { + +public: // Methods + + /** + * C++ default constructor. + */ + CFMRadioFrequencyEditor(); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(const TUint32 aFlags = 0); + + /** + * Destructor. + */ + ~CFMRadioFrequencyEditor(); + + /** + * This editor is constructed by the system using this static method. + */ + static SEikControlInfo StaticCreateCustomEditor(TInt aIdentifier); + + /** + * Sets the frequency of this editor. + * + * @param aFreq New frequency. + */ + void SetFrequency(const TUint32 aFreq); + + /** + * Returns the frequency of this editor. + * + * @return Frequency of this editor. + */ + TUint32 Frequency() const; + + /** + * Sets minimum and maximum frequencies of this editor. + * + * @param aMinimumFrequency Minimum frequency. + * @param aMaximumFrequency Maximum frequency. + */ + void SetMinimumAndMaximum(const TUint32 aMinimumFrequency, + const TUint32 aMaximumFrequency); + + /** + * Gets minimum and maximum frequencies of this editor. + * + * @param aMinimumFrequency Contains the minimum frequency when returned. + * @param aMaximumFrequency Contains the maximum frequency when returned. + */ + void GetMinimumAndMaximum(TUint32& aMinimumFrequency, + TUint32& aMaximumFrequency) const; + + /** + * Returns validity of this editor. + * @return ETrue, if the values of the fields of this editor are valid. + * EFalse otherwise. + */ + TBool IsValid() const; + + /** + * Returns the report state of this editor. + * @return ETrue, if the editor is valid to report of a state change. + * EFalse otherwise. + */ + TBool IsValidToReport() const; + + /** + * Fills decimal field with zero decimal, if field is left in middle of + * typing. + */ + void FillDecimalField(); + + /** + * Handle possible editor leave. + * + * @return ETrue, if editor can be left. + */ + TBool CanLeaveEditorL(); + + // from base class CCoeControl + /** + * From CCoeControl + * @see CCoeControl::ConstructFromResourceL + */ + void ConstructFromResourceL( TResourceReader& aResourceReader ); + + // from base class CEikMfne + /** + * From CEikMfne OfferKeyEventL. + * @see CEikMfne::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) + */ + TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); + /** + * From CEikMfne HandlePointerEventL. + * @see CEikMfne::HandlePointerEventL(const TPointerEvent& aPointerEvent) + */ + void HandlePointerEventL(const TPointerEvent& aPointerEvent); + + /** + * Updates minimum and maximum values of the fields. + */ + void UpdateMinimumAndMaximum(); + + /** + * Increments the current field. + */ + void IncrementCurrentField(); + + /** + * Decrements the current field. + */ + void DecrementCurrentField(); + + void SetEditorReportState( TBool aReport ); + + /** + * Redraws editor and reports of state change. + * + * @param aForceDrawNow forces immediate draw + */ + void DrawAndReportL( TBool aForceDrawNow ); + + /* + * Set editor frame rect + * @param aRect editor frame rect + */ + void SetEditorFrameRect( const TRect& aRect ); + +protected: // Methods + + // from base class CCoeControl + /** + * From CCoeControl + * + * @see CCoeControl::FocusChanged( TDrawNow aDrawNow ) + */ + void FocusChanged( TDrawNow aDrawNow ); + +private: //Methods + + /** + * Increments the integer field. + */ + void IncrementIntField(); + + /** + * Decrements the integer field. + */ + void DecrementIntField(); + + /** + * Increments the decimal field. + */ + void IncrementDecField(); + + /** + * Decrements the decimal field. + */ + void DecrementDecField(); + + /** + * Validates the values of the both fields. + * Calls ValidateIntField and ValidateDecField, + * but doesn't return anything. + */ + void ValidateFields(); + + /** + * Validates the integer field. If field was changed, returns ETrue. + */ + TBool ValidateIntField(); + + /** + * Validates the decimal field. If field was changed, returns ETrue. + */ + TBool ValidateDecField(); + + + + + +private: // Data + /** + * Minimum frequency got from RadioSettings. + */ + TUint32 iMinFreq; + + /** + * Maximum frequency got from RadioSettings. + */ + TUint32 iMaxFreq; + + /** + * Step frequency got from RadioSettings. + */ + TUint32 iStepFreq; + + /** + * Current minimum value of integer field. + */ + TInt iMinIntValue; + + /** + * Current maximum value of integer field. + */ + TInt iMaxIntValue; + + /** + * Current minimum value of decimal field. + */ + TInt iMinDecValue; + + /** + * Current maximum value of decimal field. + */ + TInt iMaxDecValue; + + /** + * The field at the beginning of keypress. + */ + TInt iPreviousField; + + /** + * ETrue, when user is in the middle of typing numbers in decimal + * field. + */ + TBool iTypedInDecField; + + /** + * Editor is valid to report it's state (after internal validations). + */ + TBool iValidToReport; + + /** + * Decimal field divider that is based on decimal count. + */ + TUint32 iDecDiv; + /** + * flag to set editor report state + */ + TBool iReportEditorState; + + TInt iIncrements; + + /* + * Editor frame rect + */ + TRect iEditorFrameRect; + + }; + +#endif // CFMRADIOFREQUENCYEDITOR_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiofrequencynumber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiofrequencynumber.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,214 @@ +/* +* 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: Header file for CFMRadioFrequencyNumber +* +*/ + + +#ifndef CFMRADIOFREQUENCYNUMBER_H +#define CFMRADIOFREQUENCYNUMBER_H + +#include + +/** Flags */ +enum + { + EFillWithLeadingZeros =0x1, + EPreserveOldWidthBeforeEditing =0x2, + ERepresentsYear =0x4, + EPublicallySettableFlags =EFillWithLeadingZeros|EPreserveOldWidthBeforeEditing|ERepresentsYear, + EIsBeingEditedWithCursor =0x8, + EIsUninitialised =0x10 + }; + +/** + * Custom field for frequency number. + */ +class CFMRadioFrequencyNumber : public CEikMfneField + { + +public: // Methods + + /** + * Static constructor. + */ + static CFMRadioFrequencyNumber* NewL( + const CFont& aFont, + TInt aMinimumValue, + TInt aMaximumValue, + TInt aInitialValue, + TUint32 aFlags ); + + /** + * Destructor. + */ + ~CFMRadioFrequencyNumber(); + + /** + * Sets new value in this number field. + * + * @param aValue New value + * @param aFont Current font + */ + void SetValue( TInt aValue, const CFont& aFont ); + + /** + * Gets the value in this number field. + * + * @return Value + */ + TInt Value() const; + + /** + * Sets digit type of this number field. + * + * @param aDigitType New digit type + * @param aFont Current font + */ + void SetDigitType( TDigitType aDigitType, const CFont& aFont ); + + /** + * Gets digit type of this number field. + * + * @return aDigitType Digit type + */ + TDigitType DigitType() const; + + // from base class CEikMfneField + /** + * From CEikMfneField + * + * @see CEikMfneField::IsValid() + */ + TBool IsValid() const; + + /** + * From CEikMfneField + * + * @see CEikMfneField::IsEditable. + */ + TBool IsEditable() const; + + /** + * From CEikMfneField + * + * @see CEikMfneField::HighlightType. + */ + THighlightType HighlightType() const; + + /** + * From CEikMfneField + * CEikMfneField::HandleKey( + * const CFont& aFont, + * const TKeyEvent& aKeyEvent, + * TBool aInterpretLeftAndRightAsEarEvents, + * TBool& aDataAltered, + * TInt& aHighlightIncrement + */ + void HandleKey( + const CFont& aFont, + const TKeyEvent& aKeyEvent, + TBool aInterpretLeftAndRightAsEarEvents, + TBool& aDataAltered, + TInt& aHighlightIncrement ); + + /** + * From CEikMfneField + * + * @see CEikMfneField::HandleDeHighlight( + * const CFont& aFont, + * CEikonEnv& aEikonEnv, + * TBool& aDataAltered, + * TBool& aError ) + */ + void HandleDeHighlight( + const CFont& aFont, + CEikonEnv& aEikonEnv, + TBool& aDataAltered, + TBool& aError); + +protected: // Methods + +private: //Methods + + /** + * C++ default constructor. + */ + CFMRadioFrequencyNumber( + TInt aMinimumValue, + TInt aMaximumValue, + TUint32 aFlags ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( const CFont& aFont, TInt aInitialValue ); + + /** + * Gets maximum width of this field in pixels. + */ + TInt MaximumWidthInPixels( + const CFont& aFont, + TBool aShrinkToMinimumSize ); + + /** + * Gets input capabilities of this field. + */ + TCoeInputCapabilities InputCapabilities() const; + + /** + * Get textual representation of the value in this field. + */ + const TDesC& Text() const; + + /** + * Gets numerical representation of the value in this field. + */ + TInt ValueFromText() const; + +private: // Data + /** + * Minimum value of this field. + */ + TInt iMinimumValue; + + /** + * Maximum value of this field. + */ + TInt iMaximumValue; + + /** + * Maximum number of digits value in this field. + */ + TInt iMaxDigits; + + /** + * Flags of this field. + */ + TUint32 iFlags; + + /** + * Holds the value of this field. + */ + HBufC* iText; + + /** + * Digit type of this field. + */ + TDigitType iDigitType; + + }; + +#endif // CFMRADIOFREQUENCYNUMBER_H + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiofrequencyquerycontrol.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiofrequencyquerycontrol.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,400 @@ +/* +* 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: Header file for CFMRadioFrequencyQueryControl +* +*/ + + +#ifndef FMRADIOFREQUENCYQUERYCONTROL_H +#define FMRADIOFREQUENCYQUERYCONTROL_H + +#include +#include +#include + +// CONSTANTS + +const TInt KFMRadioFrequencyQueryDialogCustomAdditionHeight = 110; + +class CFMRadioFrequencyEditor; +class CAknsFrameBackgroundControlContext; + +/** + * Custom query control for frequency query dialog. + */ +class CFMRadioFrequencyQueryControl : public CAknQueryControl + { + +public: // Methods + + /** + * C++ default constructor. + */ + CFMRadioFrequencyQueryControl(); + + /** + * Destructor. + */ + ~CFMRadioFrequencyQueryControl(); + + /** + * This control is constructed by the system using this static method. + */ + static SEikControlInfo StaticCreateCustomControl( TInt aIdentifier ); + + /** + * Gets the frequency from the control + * + * @return Frequency + */ + TUint32 Frequency() const; + + /** + * Sets the frequency to the control + * + * @param aFreq Frequency + */ + void SetFrequency(const TUint32 aFreq); + + /** + * Handle possible editor leave. + * + * @return ETrue, if editor can be left. + */ + TBool CanLeaveEditorL(); + + // from base class CAknQueryControl + /** + * From CAknQueryControl + * + * @see CAknQueryControl::ControlByLayoutOrNull( TInt aLayout ) + */ + CCoeControl* ControlByLayoutOrNull( TInt aLayout ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::EditorContentIsValidL() const + */ + TBool EditorContentIsValidL() const; + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::SetAndUseFlags( TBitFlags16 aFlags ) + */ + void SetAndUseFlags( TBitFlags16 aFlags ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::WindowLayout( TAknWindowLineLayout& aLayout ) + * const + */ + void WindowLayout( TAknWindowLineLayout& aLayout ) const; + + + // from base class CCoeControl + /** + * From CCoeControl + * + * @see CCoeControl::PrepareForFocusLossL() + */ + void PrepareForFocusLossL(); + + /** + * From CCoeControl + * + * @see CCoeControl::FocusChanged( TDrawNow aDrawNow ) + */ + void FocusChanged( TDrawNow aDrawNow ); + + /** + * From CCoeControl + * + * @see CCoeControl::CountComponentControls() const + */ + TInt CountComponentControls() const; + + /** + * From CCoeControl + * + * @see CCoeControl::ComponentControl( TInt aIndex ) const + */ + CCoeControl* ComponentControl( TInt aIndex ) const; + + /** + * Is public so that callbacks may utilize this. + * Sets repeat intervals. + * + * @param aAccelerated ETrue=accelerated speed, EFalse=default values + */ + void SetAcceleratedLongPress(TBool aAccelerated); + + /** + * From CCoeControl + * + * @see CCoeControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) + * */ + TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); + + // from base class MCoeControlObserver + /** + * From MCoeControlObserver + * + * @see MCoeControlObserver::HandleControlEventL( + * CCoeControl* aControl, + * TCoeEvent aEventType ) + */ + void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); + + class CFMRadioManualTuningEditorIndicator : public CAknIndicatorContainer, public MAknEditingStateIndicator + { + public: + + static CFMRadioManualTuningEditorIndicator* NewL(CCoeControl* aControl); + + ~CFMRadioManualTuningEditorIndicator(); + + /** + * From MAknEditingStateIndicator + */ + void SetState(TAknEditingState aState); + + /** + * From MAknEditingStateIndicator + */ + CAknIndicatorContainer* IndicatorContainer(); + + /** + * Sets the information about the query flags. + */ + void SetFlags(TBitFlags16 aFlags); + + private: + + CFMRadioManualTuningEditorIndicator(); + + void ConstructL(CCoeControl* aControl); + + // from base class CAknIndicatorContainer + /** + * From CAknIndicatorContainer + * + * @see CAknIndicatorContainer::Reserved_1() + */ + void Reserved_1(); + + private: + /** + * Flags + */ + TBitFlags16 iBitFlags; + + }; + + public: + /** + * Manage indexes into LAF tables + */ + class TIndex + { + public: + TIndex(TInt aNumberOfPromptLines); + + public: + TInt PromptLine() const; + + public: + TInt DQPWindowTextsLine2(TInt aLineNum) const; + TInt PNWindow() const; + TInt PQDWindow(TInt aLineNum) const; + TInt PQCWindow() const; + + private: + + + private: + TInt iNumberOfPromptLines; + }; + +protected: // Methods + + // from base class + /** + * From CAknQueryControl + * + * @see CAknQueryControl::ConstructQueryL( TResourceReader& aRes ) + */ + void ConstructQueryL( TResourceReader& aRes ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutEditor( const TLayoutMethod& aLayoutM ) + */ + void LayoutEditor( const TLayoutMethod& aLayoutM ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutPrompt( const TLayoutMethod& aLayoutM ) + */ + void LayoutPrompt( const TLayoutMethod& aLayoutM ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutImageOrAnim( + * const TLayoutMethod& aLayoutM ) + */ + void LayoutImageOrAnim( const TLayoutMethod& aLayoutM ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutEditorFrame( + * const TLayoutMethod& aLayoutM ) + */ + void LayoutEditorFrame( const TLayoutMethod& aLayoutM ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutEditorIndicator( + * const TLayoutMethod& aLayoutM ) + */ + void LayoutEditorIndicator( const TLayoutMethod& aLayoutM ); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::LayoutRect() + */ + TRect LayoutRect(); + + /** + * From CAknQueryControl + * + * @see CAknQueryControl::SetLineWidthsL(); + */ + void SetLineWidthsL(); + + /** + * From CCoeControl + * + * @see CCoeControl::Draw( const TRect& aRect ) const + */ + void Draw( const TRect& aRect ) const; + + /** + * Draw editor frame and shadows + */ + void DrawFrequencyEditorFrame(CWindowGc& aGc,TRect& aRect) const; + + /** + * From CCoeControl + * + * @see CCoeControl::SizeChanged() + */ + void SizeChanged(); + + /** + * From MObjectProvider + * + * @see MObjectProvider::MopSupplyObject( TTypeUid aId ) + */ + TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); + + /** + * From CCoeControl. + * @see CCoeControl::HandlePointerEventL() + */ + void HandlePointerEventL( const TPointerEvent& aPointerEvent ); + +private: // Methods + + /** + * Starts timer to accelerate long press repeat interval + */ + void StartKeypress(); + + /** + * Instructs frequency editor component to update the appropriate field + * if it is possible (user is not typing numbers). Update is either + * incrementing or decrementing depending on state of iChangeDirectionIncrease. + * If it is ETrue, the desired action is to increment the value. + */ + void DoIncrementOrDecrement(); + + /** + * Callback for iLongPressAccelerationTimer + * Speeds up repeated key event interval. + * See CPeriodic::Start() + * + * @param aAny pointer to self + * + * @return ignored + */ + static TInt LongPressAccelerateCallBack( TAny* aAny ); + + /** + * Callback for iLongPressTimer + * Called repeatedly to act as long keypress repeat event. + * See CPeriodic::Start() + * + * @return ignored + */ + static TInt LongPressTimerCallBack( TAny* aAny ); + +private: // Data + + /** + * Prompt + */ + CEikLabel* iMyPrompt; + + /** + * Editor indicator + */ + CFMRadioManualTuningEditorIndicator* iMyEditorIndicator; + + /** + * Editor + */ + CFMRadioFrequencyEditor* iFreqEditor; + + /** + * A control context that provides a layout background generated from a frame item + */ + CAknsFrameBackgroundControlContext* iEditorContext; + /** + * Accelerates manual tuning speed after two seconds + */ + CPeriodic* iLongPressAccelerationTimer; + + CPeriodic* iLongPressTimer; + + /** + * State of current keypress. Value is valid only between EEventKeyDown + * and EEventKeyUp. + * ETrue == increment, EFalse == decrement + */ + TBool iChangeDirectionIncrease; + + TBool iKeyPressReported; + + }; + +#endif // FMRADIOFREQUENCYQUERYCONTROL_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiofrequencyquerydialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiofrequencyquerydialog.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,109 @@ +/* +* 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: Header file for CFMRadioFrequencyQueryDialog +* +*/ + + +#ifndef FMRADIOFREQUENCYQUERYDIALOG_H +#define FMRADIOFREQUENCYQUERYDIALOG_H + +#include + +/** + * Custom query dialog for frequency. + */ +class CFMRadioFrequencyQueryDialog : public CAknQueryDialog + { + +public: // Methods + + /** + * Static constructor. + */ + static CFMRadioFrequencyQueryDialog* NewL( TUint32& aFreq, + const TTone& aTone = ENoTone ); + + /** + * Destructor. + */ + ~CFMRadioFrequencyQueryDialog(); + + /** + * Returns the frequency currently set in this dialog. + * + * @return ?description + */ + TUint32 Frequency() const; + + // from base class MAknQueryControlObserver + /** + * From MAknQueryControlObserver + * + * @see MAknQueryControlObserver::HandleQueryEditorStateEventL + */ + TBool HandleQueryEditorStateEventL( + CAknQueryControl* aQueryControl, + TQueryControlEvent aEventType, + TQueryValidationStatus aStatus ); + +protected: // Methods + + // from base class CAknQueryDialog + /** + * From CAknQueryDialog + * + * @see CAknQueryDialog::QueryControl() const + */ + CAknQueryControl* QueryControl() const; + + /** + * From CAknQueryDialog + * + * @see CAknQueryDialog::UpdateLeftSoftKeyL() + */ + void UpdateLeftSoftKeyL(); + + /** + * From CAknQueryDialog OkToExitL + */ + TBool OkToExitL(TInt aButtonId); + + // from base class CEikDialog + /** + * From CEikDialog + * + * @see CEikDialog::PreLayoutDynInitL() + */ + void PreLayoutDynInitL(); + +private: //Methods + + /** + * C++ default constructor. + */ + CFMRadioFrequencyQueryDialog( TUint32& aFreq, const TTone& aTone = ENoTone ); + + +private: + + /** + * Current frequency + */ + TUint32& iFreq; + + }; + +#endif // FMRADIOFREQUENCYQUERYDIALOG_H + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioglobalconfirmationquery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioglobalconfirmationquery.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,112 @@ +/* +* 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: Header file of CFMRadioGlobalConfirmationQuery +* +*/ + + +#ifndef C_CFMRADIOGLOBALCONFIRMATIONQUERY_H +#define C_CFMRADIOGLOBALCONFIRMATIONQUERY_H + +#include + +class CAknGlobalConfirmationQuery; + +/** +* Observer for global confirmation query event. +*/ +class MFMRadioGlobalConfirmationQueryObserver + { + public: + + /** + * Callback function that is called when global confirmation + * query is dismissed. + * + * @param aSoftKey The softkey used to dismiss the query. + */ + virtual void GlobalConfirmationQueryDismissedL(TInt aSoftKey) = 0; + }; + + +/** + * FM Radio global confirmation query. + * + * Must be deleted after used once. + */ +class CFMRadioGlobalConfirmationQuery : public CActive + { + +public: + + /** + * Static constructor. + */ + static CFMRadioGlobalConfirmationQuery* NewL(MFMRadioGlobalConfirmationQueryObserver* aObserver = NULL); + + /** + * Static constructor. + */ + static CFMRadioGlobalConfirmationQuery* NewLC(MFMRadioGlobalConfirmationQueryObserver* aObserver = NULL); + + /** + * Destructor. + */ + virtual ~CFMRadioGlobalConfirmationQuery(); + + /** + * Shows the query. + * + * @param aText Query text. + * @param aSoftkeys Query softkeys. + * @param aAnimation Query animation. + */ + void ShowQueryL(const TDesC& aText, TInt aSoftkeys, TInt aAnimation); + +// From base class CActive +protected: + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + +private: + /** + * C++ default constructor. + */ + CFMRadioGlobalConfirmationQuery(MFMRadioGlobalConfirmationQueryObserver* aObserver = NULL); + + /** + * 2nd phase constructor. + */ + void ConstructL(); + +private: // data + + /** + * Pointer to avkon global confirmation query. Owned! + */ + CAknGlobalConfirmationQuery* iAknGlobalConfirmationQuery; + + /** + * Text of global confirmation query. Owned! + */ + HBufC* iText; + + /** + * Observer for global confirmation query. Not owned! + */ + MFMRadioGlobalConfirmationQueryObserver* iObserver; + }; + +#endif // C_CFMRADIOGLOBALCONFIRMATIONQUERY_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioidlecontrolinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioidlecontrolinterface.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,46 @@ +/* +* 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 an interface for handling the media idle components +* +*/ + +#ifndef FMRADIOIDLECONTROLINTERFACE_H_ +#define FMRADIOIDLECONTROLINTERFACE_H_ + +/* + * Interface for handling the media idle components. + * Media idle visuals are controlled solely through this interface. + */ +class MFMRadioIdleControlInterface + { + public: + /* + * Show the component with fade in + */ + virtual void Show() = 0; + + /* + * Hide the component with fade out + */ + virtual void Hide() = 0; + + /* + * Deactivates control. Used for example + * foreground and background events. + */ + virtual void Deactivate() = 0; + }; + + +#endif /* FMRADIOIDLECONTROLINTERFACE_H_ */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioidlecontroller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioidlecontroller.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,88 @@ +/* +* 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: fmradio idle area controller +* +*/ + +#ifndef CMRADIOIDLECONTROLLER_H +#define CMRADIOIDLECONTROLLER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MFMRadioIdleControlInterface; +// CONSTANTS + +/** + * fmradio idle area controller + */ +class CFMRadioIdleController : public CBase + { + + public: + /** + * Two-phased constructor. + */ + static CFMRadioIdleController* NewL(); + + /** + * Destructor. + */ + virtual ~CFMRadioIdleController(); + + public: // New functions + /** + * Adds new item to control. + * @aControl control to add + */ + void AddControlItem( const MFMRadioIdleControlInterface& aControl ); + + /** + * Shows a control and hides all other controls + * @param aControl control to show + */ + void ShowControl( const MFMRadioIdleControlInterface& aControl ); + + /** + * Deactivates all controlled items + */ + void DeactivateControls(); + + /** + * Hide all controlled items + */ + void HideAllControls(); + + private: + /** + * C++ default constructor. + */ + CFMRadioIdleController(); + + /** + * EPOC default constructor. + */ + void ConstructL(); + + + private: // data + // array of controlled items + RPointerArray iControlArray; + + + }; + + +#endif // CMRADIOIDLECONTROLLER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiologo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiologo.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,185 @@ +/* +* 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: Definition of the class CFMRadioLogo. +* +*/ + + +#ifndef FMRADIOALFLOGO_H +#define FMRADIOALFLOGO_H + +// INCLUDES + +#include + +#include "fmradioidlecontrolinterface.h" +// FORWARD DECLARATIONS + +class CAlfImageVisual; +class MFMRadioLogoObserver; +class CAlfAnchorLayout; + +// CLASS DEFINITION + +/** +* Class for handling the radio icon +* +*/ +class CFMRadioLogo : public CAlfControl, + public MFMRadioIdleControlInterface + { + public: // Constructors and destructor + /** + * Epoc two-phased constructor. + * @param aEnv Reference to the Alf environment instance. + * @return Pointer to this Indicator component. + */ + static CFMRadioLogo* NewL( CAlfEnv& aEnv ); + + /** + * Destructor + */ + virtual ~CFMRadioLogo(); + + public: // New functions + /** + * Sets the indicator opacity in visible state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInVisibleState( const TReal aOpacity ); + + /** + * Sets the indicator opacity in hidden state. + * @param aOpacity The indicator opacity + */ + void SetOpacityInHiddenState( const TReal aOpacity ); + + /** + * Sets the indicator rectangle + * @param aRect Rectangle to the indicator + */ + void SetRect( const TRect& aRect ); + + /** + * Sets the Observer + * @param aObserver The object to observe the control + */ + void SetObserver( MFMRadioLogoObserver* aObserver ); + + /** + * Removes the observer + */ + void RemoveObserver( MFMRadioLogoObserver* aObserver ); + + /** + * Switch to landscape image. + * @param aShow. ETrue for landscape, EFalse for portrait + */ + void SwitchToLandscapeImage( TBool aShow ); + + private: + /** + * C++ default constructor + */ + CFMRadioLogo (); + + /** + * EPOC second phase constructor. + * @param aEnv Reference to the Hitchcock environment instance. + */ + void ConstructL( CAlfEnv& aEnv ); + + private: // Functions from base classes + /** + * from MFMRadioIdleControlInterface + */ + void Show(); + + /** + * from MFMRadioIdleControlInterface + */ + void Hide(); + + /** + * from MFMRadioIdleControlInterface + */ + void Deactivate(); + + /** + * from CAlfControl + */ + TBool OfferEventL( const TAlfEvent& aEvent ); + + private: // New functions + /** + * Sets the fading animation to the CAlfVisual object. + * @param aVisual a pointer to the visual object + * @param aFadingTime Time duration after the visual object has been faded. Fading duration in milliseconds. + * @param aOpacity Target opacity value + */ + void Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ); + + /** + * Sets absolute rect of the anchor by top left and bottom right points. + * @param aAnchor Anchor layout for setting placement + * @param aOrdinal Index of visual element + * @param aTopLeftPosition Top left point of the rect + * @param aBottomRightPosition Bottom right point of the rect + */ + void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ); + /** + * Creates the needed drawing layers and visual objects + * for the logo. + */ + void CreateImageVisualsL(); + + private: + /** + * Alf custom events for the logo fade effects. + * Logo stays visible couple of seconds after the + * fade in event. + */ + enum TFadeCustomEvent + { + EFadeInCompleted, // Fade in completed. + ELogoDisplayTimerCompleted // Visibility time ended. + }; + + private:// Data + /** Anchor layout for the logo. Not owned */ + CAlfAnchorLayout* iLogoAnchor; + /** logo opacity in visible state */ + TReal iOpacityInVisibleState; + /** logo opacity in hidden state */ + TReal iOpacityInHiddenState; + /** logo rectangle */ + TRect iRect; + /** Array of observers. */ + RPointerArray iObservers; + // visual containing the default radio icon. Not owned + CAlfImageVisual* iImageVisual; + // default radio icon in portrait mode + TAlfImage iPortraitImage; + // default radio icon in landscape mode + TAlfImage iLandscapeImage; + /** File name for the background bitmap. Owned. */ + HBufC* iBackgroundBitmapFileName; + // flag for visibility status + TBool iIsVisible; + }; + +#endif //FMRADIOALFLOGO_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiologoobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiologoobserver.h Tue Feb 02 00:17:10 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: Declares an interface for observing radio logo event +* +*/ + +#ifndef FMRADIOALFLOGOOBSERVER_H_ +#define FMRADIOALFLOGOOBSERVER_H_ + +/* + * Interface for observing radio logo event + */ +class MFMRadioLogoObserver + { + public: + /* + * Logo visibility time has ended + */ + virtual void LogoDisplayTimeCompleted() = 0; + }; +#endif /* FMRADIOALFLOGOOBSERVER_H_ */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiomaincontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiomaincontainer.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,290 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Definition of the class CFMRadioMainContainer. +* +*/ + + +#ifndef FMRADIOMAINCONTAINER_H +#define FMRADIOMAINCONTAINER_H + +// INCLUDES + +#include +#include +#include +#include + +#include "fmradio.hrh" +#include "fmradioappui.h" + +// FORWARD DECLARATIONS + +class CRadioEngine; +class CFMRadioAlfVisualizer; +class CFMRadioAlfMediaIdle; +class CFMRadioAlfIndicator; +class CFMRadioAlfRDSViewer; +class CFMRadioIdleController; +class CFMRadioLogo; +// CLASS DECLARATION +/** +* Interface to tell when timeout event occured +* +* @since 2.6 +*/ +class MFMRadioTimer + { + public: + + virtual void TimerTimeOut( TInt aErrorStatus ) = 0; + + }; + +/** +* Active object to handle timer timeout events +* +* @since 2.6 +*/ +class CFMRadioTimer : public CActive + { + public: + /** + * Constructor + * @param aTimerObserver observer for active object + */ + CFMRadioTimer( MFMRadioTimer* aTimerObserver ); + /** + * Destructor + */ + ~CFMRadioTimer(); + /** + * ActiveObject RunL, which calls observer interface when completes + */ + void RunL(); + /** + * ActiveObject DoCancel, which calls observer interface when completes + */ + void DoCancel(); + /** + * Activated active object + */ + void Activate(); + + private: + // Active object observer + MFMRadioTimer* iTimerObserver; + + }; + + +/** +* Creates and owns the UI controls related to the main view. +* +*/ +class CFMRadioMainContainer : public CBase, + public MHWRMLightObserver, + public MFMRadioTimer + + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioMainContainer + * @since 2.6 + * @param aRect Frame rectangle for container. + * @param aAlfEnv A reference to the alfred environment + * @param aRadioEngine A pointer to the radio engine + */ + static CFMRadioMainContainer* NewL( const TRect& aRect, + CAlfEnv& aAlfEnv, + CRadioEngine& aRadioEngine ); + /** + * Destructor. + * @since 2.6 + */ + virtual ~CFMRadioMainContainer(); + + public: // New functions + /** + * Display the channel information + * @since 2.6 + * @param aChannelNumber the channel number to display + * @param aStationName the station name to display + * @param aChangeType Station change type for the animation + * @param aFrequency of the channel + */ + void DisplayChannelInfoL( TInt aChannelNumber, + const TDesC& aStationName, + TFMRadioStationChangeType aChangeType, + TInt aFrequency ); + + /** + * Formats the frequency number and returns it as a descriptor. + * Ownership of the returned string is transfered. + * @param aFrequency The frequency to be formatted + * @param aResourceId The resource to be used for formatting the string + * @return The formatted frequency + */ + HBufC* FormattedFrequencyStringL( TInt aFrequency, TInt aResourceId ); + + /** + * Dims or undims RDS information + * @param aShow ETrue if RDS marquee is to be shown, EFalse otherwise. + * @param aFade ETrue if fade effect it to be used, EFalse otherwise. + * @param aShowAfMarquee ETrue if AF marquee is also to be shown, EFalse otherwise. + * This only has effect if aShow is ETrue. + */ + void ShowRdsInfo( TBool aShow, TBool aFade, TBool aShowAfMarquee = EFalse); + + /** + * Sets RT+ interaction indicator visible or invisible. + * + * The indicator is "MusicStore" or "+" depending on KRadioRTPlusSupportLevel cenrep value. + * When it is off, only music store interaction is supported and the indicator is set likewise. + * + * @param aVisible sets the visibility + * @param aFadeEffect to use transition fade effect or not + */ + void ShowRTPlusInteractionIndicator( TBool aVisible, TBool aFadeEffect); + + /** + * Fades the entire window and controls in the window owned by this container control. + * @since 2.6 + * @param aFaded true/false to indicate whether the view should fade/unfade + */ + void SetFaded( TBool aFaded ); + /** + * Handles resource changes + * @param aType Resource change type + */ + void HandleResourceChange(TInt aType); + /** + * Sets rectangle of the alfred display + * @param aRect Display rectangle + * @return none + */ + void SetRect( const TRect& aRect ); + /** + * Returns a pointer to the station information visualizer + * @return VisualControl + */ + CFMRadioAlfVisualizer* VisualControl(); + /** + * Returns a reference to the Media Idle + * @return Media Idle + */ + CFMRadioAlfMediaIdle& MediaIdle(); + + /** + * Updates RDS text to display + * @return Media Idle + */ + void SetRdsRadioTextL( const TDesC& aRadioText ); + /** + * From MHWRMLightObserver + * Lights status has been changed + */ + void LightStatusChanged(TInt aTarget, + CHWRMLight::TLightStatus aStatus); + /** + * From MFMTimer To handle timer timeout events. + */ + void TimerTimeOut( TInt aErrorStatus ); + + /** + * Returns a reference to the RDS Viewer + * @return RDS Viewer + */ + CFMRadioAlfRDSViewer& RdsViewer() const; + /** + * Returns a reference to the idle controller + * @return idle controller + */ + CFMRadioIdleController& IdleController() const; + /** + * Returns a reference to the logo visual + * @return logo visual + */ + CFMRadioLogo& Logo() const; + + private: // New functions + /** + * Called when the view size is changed + */ + void SizeChanged(); + /** + * Required for help. + * @since 2.7 + * @param aContext the help context to be used. + */ + void GetHelpContext(TCoeHelpContext& aContext) const; + /** + * C++ default constructor + * @param aAlfEnv A reference to the alfred environment + * @param aRadioEngine A pointer to the radio engine + */ + CFMRadioMainContainer( CAlfEnv& aAlfEnv, CRadioEngine& aRadioEngine ); + /** + * EPOC default constructor + * @since 2.7 + * @param aRect Frame rectangle for container. + */ + void ConstructL( const TRect& aRect ); + /** + * Handles updating main area text colors using current skin + * @since 3.0 + */ + void UpdateTextColorFromSkin(); + + private: //data + + TBool iFadeStatus; + TRect iMainPaneRect; + + /** Visualizer for the radio information. Not owned. */ + CFMRadioAlfVisualizer* iVisualControl; + /** Media Idle. Not owned. */ + CFMRadioAlfMediaIdle* iMediaIdle; + /** RDS indicator. Not owned. */ + CFMRadioAlfIndicator* iRdsIndicator; + /** RDS AF indicator. Not owned. */ + CFMRadioAlfIndicator* iRdsAfIndicator; + /** RDS viewer. Not owned. */ + CFMRadioAlfRDSViewer* iRdsViewer; + /** RDS interaction (music store, web link etc.) indicator. Not owned. */ + CFMRadioAlfIndicator* iRdsInteractionIndicator; + /** A reference to the alfred environment. */ + CAlfEnv& iAlfEnv; + /** A reference to the radio engine */ + CRadioEngine& iRadioEngine; + /** A pointer to the control environment */ + CCoeEnv* iCoeEnv; + /**Light event informer*/ + CHWRMLight* iLight; + /**timer for light dimmed handler*/ + RTimer timer; + /**Active object to handle lights dimmed timer */ + CFMRadioTimer* iTimer; + /**Frame counter */ + TInt iLightsOffCounter; + // Media idle controller. Owned + CFMRadioIdleController* iIdleController; + // Alf image visual for the default radio icon. Not Owned + CFMRadioLogo* iRadioLogo; + + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiomainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiomainview.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,320 @@ +/* +* 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: Definition of the class CFMRadioMainView. +* +*/ + + +#ifndef FMRADIOMAINVIEW_H +#define FMRADIOMAINVIEW_H + +// INCLUDES +#include +#include +#include + +#include "mfmradiolayoutchangeobserver.h" +#include "fmradiordsobserver.h" +#include "fmradio.hrh" +#include "mchannellisthandler.h" +#include "fmradioalfrdsviewobserver.h" +#include "fmradiologoobserver.h" + +// FORWARD DECLARATIONS +class CFMRadioMainContainer; +class CRadioEngine; +class CFMRadioMusicStoreHandler; + +// CLASS DECLARATION + +/** +* CFMRadioMainView view class. +* +* @since 2.6 +*/ +class CFMRadioMainView : public CAknView, + public MFMRadioLayoutChangeObserver, + public MFMRadioRdsObserver, + public MAknToolbarObserver, + public MFMRadioAlfRdsViewObserver, + public MFMRadioLogoObserver + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioMainView + * @since 2.6 + * @param aRadioEngine pointer to the radio engine object + * @param aAlfEnv alfred environment reference + * @param aObserver channel list handler + */ + static CFMRadioMainView* NewL( + CRadioEngine* aRadioEngine, + CAlfEnv& aAlfEnv, + MChannelListHandler& aObserver ); + /** + * Destructor. + * @since 2.6 + */ + virtual ~CFMRadioMainView(); + public: // New functions + /** + * Return the unique identifier corresponding to this view + * @since 2.6 + * @return unique view identifier + */ + TUid Id() const; + /** + * Fade the view and all controls associated with it. Change + * the soft keys so that "Exit" is displayed + * @since 2.6 + * @param aFaded flag whether to fade or unfade + */ + void FadeAndShowExit( TBool aFaded ); + /** + * Update display when focus is regained + * @since 3.0 + */ + void UpdateDisplayForFocusGained(); + /** + * Tells the window owning container to display seek note + * and updates softkeys + * @since 2.6 + */ + void SeekL(); + /** + * Seek operation has completed. Update the view to reflect + * this fact. + * @since 2.6 + */ + void StopSeekL(); + /** + * Inform the window owning container that it should display + * the frequency and name of the channel specified + * @since 2.6 + * @param aChannelIndex The index of the channel to display + */ + void DisplayChannelL( TInt aChannelIndex ); + /** + * from MFMRadioLayoutChangeObserver + * This method gets called by the AppUI when a dynamic layout change + * event occurs. + */ + void LayoutChangedL( TInt aType ); + + /** + * Sets the type for forthcoming station change + * @param aChangeType The change type + */ + void SetStationChangeType( TFMRadioStationChangeType aChangeType ); + + /* + * called before channel is about to change + * */ + void PrepareViewForChannelChange(); + + /** + * Sets toolbar visibility + * @param aVisible + * @return none + */ + void ShowToolbar( TBool aVisible ); + + /** + * From base class MFMRadioRdsObserver + */ + void RdsDataProgrammeService( const TDesC& aProgramService ); + void RdsDataPsNameIsStatic( TBool aStatic ); + void RdsDataRadioText( const TDesC& aRadioText ); + void RdsDataRadioTextPlus( const TInt aRadioTextPlusClass, const TDesC& aRadioText ); + void RdsAfSearchBegin(); + void RdsAfSearchEnd( TUint32 aFrequency, TInt aError ); + void RdsAfSearchStateChange( TBool aEnabled ); + void RdsAvailable( TBool aAvailable ); + + /* + * Requests the right idle component to be started + */ + void DetermineActiveMediaIdleComponent(); + + /* + * Shows default radio logo + */ + void ShowDefaultLogo(); + + private: // New functions + /** + * EPOC default constructor. + * @since 2.6 + */ + void ConstructL(); + /** + * constructor. + * @since 2.6 + * @param aRadioEngine pointer to the radio engine object + * @param aAlfEnv alf environment + * @param aObserver + */ + CFMRadioMainView( CRadioEngine* aRadioEngine, CAlfEnv& aAlfEnv, MChannelListHandler& aObserver ); + /** + * Shows a tutorial dialog when user sees RT+ interaction indicator + * for the very first time. + */ + void ShowRTPlusFirstTimeDialogL(); + /** + * Determines if RT+ interaction indicator should be shown, based on if + * data is available in iSongName, iArtistName and iWebUrl. + * + * @return ETrue if there is valid data for RT+ interactions + */ + TBool IsRTPlusInterActionIndicatorNeeded(); + /** + * StaticRdsSignalTimerCallback Callback for iRdsSignalTimer + */ + static TInt StaticRdsSignalTimerCallback( TAny* aSelfPtr ); + /** + * Prepare toolbar for FMRadio command buttons + */ + void PrepareToolbar(); + /** + * Set the current dimmed state of the toolbar + * @param aState the new toolbar dimmed state + */ + void SetToolbarDimmedState( TBool aState ); + + /** + * Checks if the rds feed has a web link + */ + TBool IsWebLinkAvailable(); + + /** + * Updates speaker button state in the toolbar + * extension list + */ + void UpdateToolbarSpeakerButtonStatus(); + + private: // Functions from base classes + /** + * All commands are handled by the AppUi + * @since 2.6 + * @param aCommand key code of the command to handle + */ + void HandleCommandL( TInt aCommand ); + /** + * From base class CAknView + */ + void HandleForegroundEventL( TBool aForeground ); + /** + * Activate the main view + * @since 2.6 + */ + void DoActivateL( const TVwsViewId& aPrevViewId,TUid aCustomMessageId, const TDesC8& aCustomMessage ); + /** + * Deactivate the main view + * @since 2.6 + */ + void DoDeactivate(); + /** + * From MEikMenuObserver, for changing menu items dynamically. + * + * @param aResourceId Resource ID identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + */ + void DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ); + /** + * from MAknToolbarObserver + */ + void OfferToolbarEventL( TInt aCommandId ); + + /** + * from MAknToolbarObserver + */ + void DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar ); + + /** + * Launch WebBrowser or Music shop based on given command Id. + * @param aCommandId The command id + */ + void LaunchBrowserL(TInt aCommandId); + /** + * Handle RDS programme service change. + * @param aProgramService New programme service + */ + void RdsDataProgrammeServiceL( const TDesC& aProgramService ); + /** + * Handles the notification about type of PS name + * @param aStatic + */ + void HandleStaticProgrammeServiceL( TBool aStatic ); + /** + * PrepareViewForChannelChangeL. + */ + void PrepareViewForChannelChangeL(); + /** + * Show save query if the current channel is not saved + */ + void HandleSaveChannelQueryL(); + /** + * from MEikMenuObserver + */ + void SetEmphasis( CCoeControl* aMenuControl, TBool aEmphasis ); + + // from MFMRadioLogoObserver + void LogoDisplayTimeCompleted(); + + // from MFMRadioAlfRdsViewObserver + void NotifyRdsTextTimerCompletion(); + + private: // Data + // pointer to the container of the main view + CFMRadioMainContainer* iContainer; + // A pointer to the radio engine object + CRadioEngine* iRadioEngine; + // flag to keep track of whether the radio is currently seeking + TBool iSeeking; + + /** + * Station change direction used for station information animation + */ + TFMRadioStationChangeType iChangeDirection; + + /** + * Is the start up of application ongoing. + */ + TBool iStartUp; + TBool iFaded; + /** + * Timer for hiding the RDS signal icon after a delay + */ + CPeriodic* iRdsSignalTimer; + + /** + * Toolbar for controlling the application. + */ + CAknToolbar* iToolbar; + + /** + * observer for list event from main list + */ + MChannelListHandler& iObserver; + /** + * Takes care of Music store integration. + */ + CFMRadioMusicStoreHandler* iMusicStoreHandler; + // flag for options menu status + TBool iOptionsMenuOpen; + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiomusicstorehandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiomusicstorehandler.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,277 @@ +/* +* 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: Handles music store integration. +* +*/ + + +#ifndef FMRADIOMUSICSTOREHANDLER_H +#define FMRADIOMUSICSTOREHANDLER_H + +#include + +class CEikMenuPane; +class CRepository; + +/** + * Handler for Music Store. + * + * Takes care of Nokia music store and operator specific music store. + * + * Provides also a interface to open a web page. + */ +class CFMRadioMusicStoreHandler : public CBase + { +private: + /** + * Used for tracking the visibility state. + */ + enum TFMRadioMusicStoreState + { + EFMRadioMusicStoreUninitialized, + EFMRadioMusicStoreEnabled, + EFMRadioMusicStoreDisabled, + EFMRadioMusicStoreForceEnabled + }; + + /** + * Distinguishes between different implementation types of music store. + */ + enum TFMRadioOperatorAppType + { + EFMRadioAppNotAvailable, + EFMRadioNativeApp, + EFMRadioJavaApp, + EFMRadioWebsite + }; + +public: + /** + * Two-phase constructor of CMusicStoreHandler. + * + * @param aResourceId Menu pane where the music store item/items + * will be added. + */ + static CFMRadioMusicStoreHandler* NewL( TInt aResourceId ); + + /** + * Destructor + */ + ~CFMRadioMusicStoreHandler(); + + /** + * Checks wether given command id is for music store functionality. + * + * @param aCommandId command id to check + * @returns ETrue for music store command ids + */ + TBool IsMusicStoreCommandId( TInt aCommandId ); + + /** + * This is called when dynamically initializing menu (ie, from DynInitMenuPaneL). + * + * @param aResourceId Resource id for currently processed menu part + * @param aMenuPane Menu pane which is being handled + * @returns ETrue, if menu pane was handled by this method + */ + TBool InitializeMenuL( TInt aResourceId, CEikMenuPane* aMenuPane ); + + /** + * The value given will be used as a guideline to wether to show or hide the item. + * If music shop feature is not supported and this is called with ETrue it will + * not show the item unless forced state is used. + * + * @param aEnable Whether enable or disable the item + * @param aForce Whether the state is forced, by default it is not + */ + void EnableMusicStore( TBool aEnable, TBool aForce = EFalse ); + + /** + * Launches Music store based on command id. + * + * @param aCommandId Command id for menu item + * @param aArtist Artist of the single + * @param aAlbum Album of the single + * @param aTitle Name of the single + */ + void LaunchMusicStoreL( TInt aCommandId, + const TDesC& aTitle, + const TDesC& aArtist, + const TDesC& aAlbum ); + + /** + * Launches web page based on given string. + * + * @param aWebpage Web site to be launched + */ + void LaunchWebPageL( const TDesC& aWebpage ); + + /** + * Is Nokia Music shop available + * @returns ETrue if available + */ + TBool NokiaMusicStoreAvailable(); + + /** + * Is Operator music store available + * @returns ETrue if available + */ + TBool OperatorMusicStoreAvailable(); + + /** + * Check if the music store functionality has been enabled + * @return state + */ + TBool IsMusicStoreEnabled(); + + /** + * returns name of the operator music store + * @return name + */ + const TDesC& OperatorMusicStoreName() const; + +private: + /** + * Default C++ constuctor + * + * @param aResourceId Menu pane where the music store item/items + * will be added. + */ + CFMRadioMusicStoreHandler( TInt aResourceId ); + + /** + * Second-phase constructor + */ + void ConstructL(); + + /** + * Finds out the type of operator specific music store. + * + * @param aRepository Cenrep from which information is sought. + * @returns Application type if available, otherwise EFMRadioAppNotAvailable + */ + TFMRadioOperatorAppType CheckOperatorMusicStoreTypeL( CRepository& aRepository ); + + /** + * Called for application type specific initialization. + * + * @param aRepository Cenrep from which information is sought. + * @param aAppType Type of implementation to be initialized. + */ + void InitializeParametersL( CRepository& aRepository, TFMRadioOperatorAppType aAppType ); + + /** + * Called when native music store needs initializing. + * + * @param aMusicstoreUid P&S UID for initializing music shop + */ + void InitializeMusicStore( TUid aMusicstoreUid ); + + /** + * Returns the count of active music stores. + * + * @returns Active music store count + */ + TInt MusicStoreCount(); + + /** + * Creates the search string for Nokia Music Shop application + * + * @param aArtistName Artist of the single + * @param aAlbumName Album of the single + * @param aSongName Name of the single + * @returns search string and pushes it to cleanup stack. + */ + HBufC* NokiaMusicShopSearchLC( const TDesC& aSongName, + const TDesC& aArtistName, + const TDesC& aAlbumName ); + + /** + * Handles calling appropriate operator music store implementation + * + * @param aSearchString string used for searching + */ + void LaunchOperatorMusicStoreL( const TDesC& aSearchString ); + + /** + * Launches Nokia Music shop application + * + * @param aMusicshopUid UID of the music shop + * @param aSearchString string used for searching + */ + void LaunchMusicShopL( TUid aMusicshopUid, const TDesC& aSearchString ); + + /** + * Converts binary data from cenrep to Uint32 presentation + * @param aBuf binary data from cenrep + * @return resolved Uint32 number + */ + TUint32 Uint32Presentation( const TDesC8& aBuf ); + + /** + * Checks if the application with the given uid is installed to the system + * @param aAppUid Application uid + * @return true if app is found + */ + TBool IsAppInstalledL( const TUid& aAppUid ); + +private: // members + /** + * Resource id to which music store option will be bound. + */ + TInt iResourceId; + + /** + * This is used for with isMenuInitialized so that it is not needed + * to go through all items in case we don't find the music store item. + */ + TInt iFirstKnownResourceId; + + /** + * Saves the state of Music store item + */ + TFMRadioMusicStoreState iState; + + /** + * Nokia Music store UID + */ + TUint32 iMusicStoreUID; + + /** + * Display name for operator music store + */ + RBuf iOperatorMusicStoreName; + + /** + * UID for Operator music store (native app.) + */ + TUint32 iOperatorStoreNativeUID; + + /** + * Website where Operator music store can be found + */ + RBuf iOperatorStoreWebsite; + + /** + * Control environment. + */ + CCoeEnv* iCoeEnv; + + /** + * flag for music store application availability + */ + TBool iMusicStoreAppInstalled; + }; + +#endif /*FMRADIOMUSICSTOREHANDLER_H*/ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiopreset.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiopreset.h Tue Feb 02 00:17:10 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: fmradio preset station information +* +*/ + +#ifndef CMFRADIOPRESET_H +#define CMFRADIOPRESET_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS + +// CONSTANTS + +/** + * fmradio preset station information + */ +class CFMRadioPreset : public CBase + { + + public: + /** + * Two-phased constructor. + */ + static CFMRadioPreset* NewL(); + /** + * Destructor. + */ + virtual ~CFMRadioPreset(); + + public: // New functions + /* + * Set name for the preset + * @param aName new name for the preset + */ + void SetPresetNameL( const TDesC& aName ); + /* + * Returns preset name + * @return name + */ + TDesC& PresetName(); + /* + * Set of the preset valid + * @param aValid ETrue is the name is set valid + */ + void SetPresetNameValid( TBool aValid ); + /* + * Returns the validity of the preset name + * @return ETrue if the name is valid, otherwise EFalse + */ + TBool PresetNameValid(); + /* + * Set frequency for the preset + * @param aFrequency frequency to set + */ + void SetPresetFrequency( TInt aFrequency ); + /* + * Returns preset frequency + * @return frequency + */ + TInt PresetFrequency(); + + private: + /** + * C++ default constructor. + */ + CFMRadioPreset(); + /** + * EPOC default constructor. + */ + void ConstructL(); + + private: // data + // station name + RBuf iStationName; + // station frequency + TInt iStationFrequency; + // Validity of the station name + TBool iNameIsValid; + }; + + +#endif // CMFRADIOPRESET_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioscanlocalstationscontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioscanlocalstationscontainer.h Tue Feb 02 00:17:10 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: definition of the class CFMRadioScanLocalStationsContainer +* +*/ + + +#ifndef FMRADIOSCANLOCALSTATIONSCONTAINER_H +#define FMRADIOSCANLOCALSTATIONSCONTAINER_H + +// INCLUDES +#include +#include + +#include "fmradiodefines.h" +#include "fmradio.hrh" +#include "fmradioengine.h" +// FORWARD DECLARATIONS +class CAknWaitDialog; + +// CLASS DECLARATION + +/** +* Creates and owns the UI components related to the Scan Local Stations View. +* @since 2.6 +*/ +class CFMRadioScanLocalStationsContainer : public CCoeControl, + public MEikListBoxObserver + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioScanLocalStationsContainer + * @since 2.6 + * @param aRect Frame rectangle for container. + * @param aRadioEngine Radio engine reference + */ + static CFMRadioScanLocalStationsContainer* NewL( const TRect& aRect, CRadioEngine& aRadioEngine ); + /** + * Destructor. + */ + virtual ~CFMRadioScanLocalStationsContainer(); + public: // New functions + /** + * Returns the index of the selected channel item from the channel list. + * @since 2.6 + * @return the index of the currently selected channel + */ + TInt CurrentlySelectedChannel() const; + /** + * Update the content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex index of the channel to update + * @param aInfoText Info text to be shown instead of the frequency value + * @param aChannelFrequency the new frequency of the channel + * @param aNowPlaying indicates if 'Now playing' icon needs to be shown + * @param aInfoTextPlacement ETrue if info text is displayed after frequency string; EFalse otherwise. + */ + void UpdateChannelListContentL( TInt aIndex, const TDesC& aInfoText, TInt aChannelFrequency, TBool aNowPlaying, TBool aInfoTextPlacement = EFalse ); + void RemoveChannelListContentL( TInt aIndex ); + /** + * Update the content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex index of the last selected channel + */ + void UpdateLastListenedChannel( TInt aIndex ); + /** + * Displays 'Now Playing' icon for given index. + * @param aNewIndex Index of channel to get the icon + * @param aOldIndex Index of channel to loose the icon + */ + void UpdateNowPlayingIconL( TInt aNewIndex, TInt aOldIndex = KErrNotFound ); + /** + * Hide 'Now Playing' icon from given index + * @param aIndex Index of channel to hide the icon + * @param aDraw flag for updating list after icon removal + */ + void HideNowPlayingIconL( TInt aIndex, TBool aDraw ); + /** + * Fades the entire window and controls in the window owned by this container control. + * @since 2.6 + * @param aFaded flag to indicate whether we should fade or unfade + */ + void SetFaded( TBool aFaded ); + /** + * From CCoeControl + */ + void HandleResourceChange(TInt aType); + /** + * Resets channel list + */ + void ResetChannelListL(); + /** + * Create the channel list (initially all spots are set as empty) + * @since 2.6 + */ + void InitializeChannelListL(); + + void SetStationListEmptyTextL( const TDesC& aText ); + + /* + * Adds frequency to the scanned channels list. Used while + * scanning is ongoing + * @param aIndex channel index + * @param aChannelFrequency frequency to add + */ + void InsertScannedChannelToListL( TInt aIndex, TInt aChannelFrequency ); + + private: // Functions from base classes + /** + * Called by framework when the view size is changed + * @since 2.6 + */ + void SizeChanged(); + /** + * Return the number of controls in the window owned by this container + * @since 2.6 + * @return number of controls + */ + TInt CountComponentControls() const; + /** + * Return the control corresponding to the specified index + * @since 2.6 + * @param aIndex the index of the control to retrieve + * @return the control corresponding to the specified index + */ + CCoeControl* ComponentControl( TInt aIndex ) const; + /** + * Redraw the window owned by this container + * @since 2.6 + * @param aRect the size of the window to redraw + */ + void Draw( const TRect& aRect ) const; + /** + * From MEikListBoxObserver, for listbox event handling. + * @since 2.6 + * @param aListBox The originating list box. + * @param aEventType A code for the event. + */ + void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); + /** + * Allow the channel list to process key events + * @since 2.6 + * @param aKeyEvent The key event. + * @param aType The type of key event. + */ + TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); + /** + * Required for help. + * @since 2.7 + * @param aContext the help context to be used. + */ + void GetHelpContext(TCoeHelpContext& aContext) const; + + void FocusChanged(TDrawNow aDrawNow); + /* + * from CCoeControl + */ + void HandlePointerEventL( const TPointerEvent& aPointerEvent ); + + private: // new functions + // Default constructor + CFMRadioScanLocalStationsContainer( CRadioEngine& aRadioEngine ); + /** + * EPOC two phased constructor + * @since 2.6 + * @param aRect Frame rectangle for container. + */ + void ConstructL( const TRect& aRect); + + private: //data + + // The channel list listbox + CAknSingleNumberStyleListBox* iChannelList; + // Array of channel list items + CDesCArray* iChannelItemArray; + + // Index of the most recently listened channel to keep the listbox up-to-date. + TInt iLastChIndex; + RPointerArray iControls; + TBool iFadeStatus; + CAknsBasicBackgroundControlContext* iBackground; + MAknsSkinInstance* iSkin; + CRadioEngine& iRadioEngine; //not own + + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradioscanlocalstationsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradioscanlocalstationsview.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,371 @@ +/* +* 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: definition of the class CFMRadioScanLocalStationsView +* +*/ + + +#ifndef FMRADIOSCANLOCALSTATIONSVIEW_H +#define FMRADIOSCANLOCALSTATIONSVIEW_H + +// INCLUDES +#include +#include +#include + +#include "fmradioscanlocalstationscontainer.h" +#include "mfmradiolayoutchangeobserver.h" +#include "fmradiordsobserver.h" +#include "mchannellisthandler.h" +#include "fmradiosvkevents.h" + +// FORWARD DECLARATIONS +class CFMRadioScanLocalStationsContainer; +class CRadioEngine; +class CAknWaitDialog; +class CFMRadioPreset; + + +// CLASS DECLARATION + +/** +* CFMRadioScanLocalStationsView view class. +* @since 2.6 +*/ +class CFMRadioScanLocalStationsView : public CAknView, + public MCoeControlObserver, + public MFMRadioLayoutChangeObserver, + public MProgressDialogCallback, + public MFMRadioRdsObserver, + public MAknToolbarObserver + { + public: // Constructors and destructor + /** + * Two-phase constructor of CFMRadioScanLocalStationsView + * @since 2.6 + * @param aRadioEngine pointer to a radio engine object + * @param aObserver channel list observer + */ + static CFMRadioScanLocalStationsView* NewL( CRadioEngine& aRadioEngine, + MChannelListHandler& aObserver ); + /** + * Destructor. + * @since 2.6 + */ + virtual ~CFMRadioScanLocalStationsView(); + public: // New functions + /** + * Return the unique identifier corresponding to this view + * @since 2.6 + * @return the unique identifier corresponding to this view + */ + TUid Id() const; + /** + * Keep track of the last selected channel + * @since 2.6 + * @param aIndex the index of the last listened to channel + */ + void SetLastListenedChannel( TInt aIndex ); + /** + * Keep track of the current selected channel + * @param aChannelIndex the index of the current channel + */ + void SetNowPlayingChannelL ( TInt aChannelIndex ); + /** + * Returns the index of the playing channel item from the + * channel list. + * @return the currently playing channel + */ + TInt CurrentlyPlayingChannel(); + /** + * Returns the index of the selected channel item from the + * channel list. If the container is active get the info from + * it, because it may have more up-to-date info. + * @since 2.6 + * @return the currently selected channel + */ + TInt CurrentlySelectedChannel(); + /** + * Make a request to the channel container to update the + * content of the channel at aIndex with the values specified + * @since 2.6 + * @param aIndex the index of the channel to update + * @param aChannelFrequency the new frequency + */ + void UpdateChannelListContentL( TInt aIndex, TInt aChannelFrequency ); + /** + * Return true/false to indicate whether the channel specified is in use + * @since 2.6 + * @param aIndex the index of the channel to check + * @return true/false to indicate whether the channel is currently being used + */ + TBool ChannelInUse( const TInt aIndex ) const; + /** + * Return true/false to indicate whether the channel specified is in play + * @param aChannelIndex the index of the channel to check + * @return true/false to indicate whether the channel is currently being played + */ + TBool ChannelInPlay( TInt aChannelIndex ) const; + /** + * Retrieve the index of the next channel that has been set. + * @since 2.6 + * @return the index of the next "in use" channel + */ + TInt NextChannel(); + /** + * Retrieve the index of the previous channel that has been set. + * @since 2.6 + * @return the index of the previous "in use" channel + */ + TInt PreviousChannel(); + /** + * Fade the view and all controls associated with it. Change + * the soft keys so that "Exit" is displayed + * @since 2.6 + * @param aFaded true/false to indicate whether the view should fade/unfade. + */ + void FadeAndShowExit( TBool aFaded ); + /** + * Update display when focus regained + * @since 3.0 + */ + void UpdateDisplayForFocusGained(); + /** + * Display a wait note while the channel fill is occuring. + * @since 2.6 * + */ + void DisplayScanningInProgressNoteL(); + /** + * Remove and destroy the scanning note. + * @since 2.6 + */ + void RemoveScanningInProgressNoteL(); + /** + * from MFMRadioLayoutChangeObserver + * This method gets called by the AppUI when a dynamic layout change + * event occurs. + */ + void LayoutChangedL( TInt aType ); + + /** + * Invoked by AppUi when a new radio station is found. + */ + void StopSeekL(); + /** + * Restores the radio after scanning + */ + void RestoreRadio( TBool aTuneInitialFrequency = ETrue ); + /** + * Called when a new scan is activated. + */ + void ResetListAndStartScanL(); + /** + * Saves all the scanned channels into Radio Engine's presets. + */ + void SaveAllChannelsL(); + /** + * Sets toolbar visibility + * @param aVisible + * @return none + */ + void ShowToolbar( TBool aVisible ); + + // from base class MFMRadioRdsObserver + void RdsDataProgrammeService( const TDesC& aProgramService ); + void RdsDataPsNameIsStatic( TBool aStatic ); + void RdsDataRadioText( const TDesC& aRadioText ); + void RdsDataRadioTextPlus( const TInt /*aRTPlusClass*/, const TDesC& /*aRadioText*/ ){}; + void RdsAfSearchBegin(); + void RdsAfSearchEnd( TUint32 aFrequency, TInt aError ); + void RdsAfSearchStateChange( TBool aEnabled ); + void RdsAvailable( TBool aAvailable ); + + //for canceling the wizard + void SetScanCanceled( TFMRadioCancelScanType aType ); + TFMRadioCancelScanType CancelType(); + /** + * Dim or undim save and saveall buttons. + */ + void UpdateToolbar(); + + /* + * Handle view specific remote control events + * @param aEvent accessory event + */ + void HandleScanListRemConEventL( TAccessoryEvent aEvent ); + + private: // Functions from base classes + /** + * Activate the channel list view + * @since 2.6 + */ + void DoActivateL( const TVwsViewId& aPrevViewId,TUid aCustomMessageId, const TDesC8& aCustomMessage ); + /** + * Deactivate the channel list view + * @since 2.6 + */ + void DoDeactivate(); + /** + * Interprets view's menu,softkey and other commands and acts + * accordingly by calling the appropriate command handler + * function for further action. + * @since 2.6 + * @param aCommand the command to process + */ + void HandleCommandL( TInt aCommand ); + /** + * From MCoeControlObserver, control event observing. In this case, + * the user selection from the list is reported by container class + * and observed here. + * @since 2.6 + * @param aControl the control that caused the event + * @param aEventType the type of event that was triggered + */ + void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType ); + /** + * Sets the state of menu items dynamically according to the + * state of application data. + * @since 2.6 + * @param aResourceId Resource ID identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + */ + void DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ); + + /** + * SetMiddleSoftKeyLabelL, sets the MSK label + * from resource + */ + void SetMiddleSoftKeyLabelL( const TInt aResourceId, const TInt aCommandId ); + /** + * SetMiddleSoftKeyIconL, sets the MSK icon + * + */ + void SetMiddleSoftKeyIconL(); + /** + * Called when user cancels waiting note or process finishes + */ + void DialogDismissedL( TInt aButtonId ); + /** + * from MAknToolbarObserver + * Handle commands from toolbar. + * @param aCommandId The command id + */ + void OfferToolbarEventL( TInt aCommandId ); + /** + * SetContextMenu, to set MSK context + */ + void SetContextMenu( TInt aMenuTitleResourceId ); + private: // new functions + + /** modes for channel saving */ + enum TSavingMode + { + EAppend = 0x1, + EReplace + }; + /** + * C++ default constructor + */ + CFMRadioScanLocalStationsView( CRadioEngine& aRadioEngine, MChannelListHandler& aObserver ); + /** + * EPOC default constructor. + * @since 2.6 + */ + void ConstructL(); + /** + * Save scanned channels to presets + */ + void SaveFoundChannelsToPresetsL( TSavingMode aSavingMode ); + /** + * Add found channel to the frequency list + */ + void AddTunedFrequencyToListL(); + /** + * Tune to the selected channel + */ + void PlayCurrentlySelectedChannelL(); + + /** + * Show aResQuery confimation query with aResText. + * aResText and aResQuery must be real resource ids. + * Returns users response, 0 if user denied. + */ + TInt ShowConfirmationQueryL(TInt aResText, TInt aResQuery); + /** + * Prepare toolbar for FMRadio command buttons + */ + void PrepareToolbar(); + /** + * Set the current dimmed state of the toolbar + * + * @param aState the new toolbar dimmed state + */ + void SetToolbarDimmedState( const TBool aState ); + /** + * check if the frequency is already found + * @param aFrequency frequency to check + * @return list index or KErrNotFound if the frequency is not in the list + */ + TInt FrequencyIndex( TInt aFrequency ); + /** + * Handle single channel save + */ + void HandleOneChannelSaveL(); + /* + * Activates main view. Doesn't bring radio to + * foreground if the app is in the background + */ + void ActivateMainViewL(); + + /* + * Resolves index number for the given frequency. + * Frequencies are sorted from smallest to largest. + * @param aFrequency frequency to add + */ + TInt SortedFrequencyListIndex( TInt aFrequency ); + + private: // Data + CFMRadioScanLocalStationsContainer* iContainer; + TInt iChIndex; + TInt iNowPlayingIndex; + TBool iScanAndSaveActivated; + TInt iCurrentMSKCommandId; //owned + TBool iFaded; + TBool iScanCancelled; + CRadioEngine& iRadioEngine; + TInt iLowerFrequencyBound; + TInt iUpperFrequencyBound; + + TBool iScanningNoteIsVisible; + // array for the scanned channels + RPointerArray iScannedChannels; + + TInt iInitialTunedFrequency; + // A wait used when channel fill in progress + CAknWaitDialog* iScanningNote; + TBool iTuneRequested; + /** + * Toolbar for controlling the application. + */ + CAknToolbar* iToolbar; + /** + * channel list handler observer + */ + MChannelListHandler& iObserver; + TFMRadioCancelScanType iCancelType; + }; + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiosvkevents.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiosvkevents.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,201 @@ +/* +* 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: +* Class which implements handling Side Volume Key events (SVK). +* This class implements methods of MRemConCoreApiTargetObserver +* +* +*/ + + +#ifndef FMRADIOSVKEVENTS_H +#define FMRADIOSVKEVENTS_H + +// INCLUDES +#include +#include +#include + +#include "fmradio.hrh" + +// FORWARD DECLARATIONS + +// CONSTANTS + +enum TAccessoryEvent + { + EForward = 1, + ERewind, + EPausePlay, + EStop + }; + +// CLASS DECLARATION +class CRemConCallHandlingTarget; +class CRemConCoreApiTarget; +class CRemConInterfaceSelector; +class CRemConCoreApiTarget; + + +class MFMRadioSvkEventsObserver + { + + public: + + + + public: + /** + * Called when volume level should be changed. + * @param aVolumeChange: +1 change volume up + * -1 change volume down + */ + virtual void FMRadioSvkChangeVolumeL( TInt aVolumeChange ) = 0; + + /** + * Called when volume was changed last time 2 seconds ago or + * timer was started 2 seconds ago. The remove control timer + * is started when ChangeVolumeL() is called + * or when started through CFMRadioSvkEvents::StartRemoveTimerL() + */ + virtual void FMRadioSvkRemoveVolumeL( ) = 0; + + /** + * Called when accessory key is pressed. + * @param aEvent The headset event generated. + */ + virtual void FMRadioHeadsetEvent(TAccessoryEvent aEvent) = 0; + + }; + + +class CFMRadioSvkEvents : public CBase, + public MRemConCoreApiTargetObserver, + public MRemConCallHandlingTargetObserver + { + public: // Constructors and destructor + /** + * Symbian constructor + * @param aObserver observer to implement callback functions + */ + + static CFMRadioSvkEvents* NewL( MFMRadioSvkEventsObserver& aObserver ); + + /** + * Starts remove timer. Cancels running remove timer. + * If SVK event occurs, the timer is cancelled and restarted. + */ + void StartRemoveTimerL( ); + + /** + * Cancels remove timer. + * If SVK event occurs, the timer is restarted. + */ + void CancelRemoveTimer( ); + + /** + * Destructor. + */ + virtual ~CFMRadioSvkEvents(); + + + public: // From MRemConCallHandlingTargetObserver + + void AnswerCall(); + + void AnswerEndCall(); + + void DialCall( const TDesC8& aTelNumber ); + + void EndCall(); + + void GenerateDTMF( const TChar aChar ); + + void LastNumberRedial(); + + void MultipartyCalling( const TDesC8& aData ); + + void SpeedDial( const TInt aIndex ); + + void VoiceDial( const TBool aActivate ); + + protected: // New functions + /** + * Default constructor. + */ + CFMRadioSvkEvents( MFMRadioSvkEventsObserver& aObserver ); + + /** + * EPOC constructor. + */ + void ConstructL(); + + // From MRemConCoreApiTargetObserver + void MrccatoCommand(TRemConCoreApiOperationId aOperationId, + TRemConCoreApiButtonAction aButtonAct); + + + private: + + /** + * Calls respective observer function + */ + void DoChangeVolume( ); + + /** + * Calls respective observer function + */ + void RemoveControlL( ); + + + /** + * ChangeVolume is the callback function called from change volume timer. + */ + static TInt ChangeVolume(TAny* aThis); + + /** + * RemoveControl is the callback function called from remove control timer. + */ + static TInt RemoveControl(TAny* aThis); + + /** + * TuneChannel can be used to tune up/down + */ + void TuneChannel( TFMRadioCommandIds aDirection ); + + /** + * Takes care of remcon volume keys + * @param aButtonAct the button event + * @param aDirection volume up or down + */ + void HandleVolumeButtons( TRemConCoreApiButtonAction aButtonAct, TInt aDirection ); + + + private: + MFMRadioSvkEventsObserver& iObserver; + CRemConInterfaceSelector* iInterfaceSelector; + CRemConCoreApiTarget* iCoreTarget; + CRemConCallHandlingTarget* iCallTarget; + CPeriodic* iVolumeTimer; + CPeriodic* iRemoveTimer; + + /// indicates size of volume level change + TInt iChange; + TBool iTargetOpen; + }; + + +#endif + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/fmradiouids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/fmradiouids.h Tue Feb 02 00:17:10 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: FMRadio identifiers +* +*/ +#ifndef FMRADIOUIDS_H +#define FMRADIOUIDS_H + +#include + +// FMRadio Application UID +#define KUidFMRadioApplication 0x10207A89 + +// FM Radio View id's +const TUid KFMRadioMainViewId = {0x01}; +const TUid KFMRadioChannelListViewId = {0x02}; +const TUid KFMRadioScanLocalStationsViewId = {0x03}; + +#endif // FMRADIOUIDS_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/mchannellisthandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/mchannellisthandler.h Tue Feb 02 00:17:10 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: Callback definitions to channel main list update +* +* +*/ + +#ifndef MCHANNELLISTHANDLER_H + +#define MCHANNELLISTHANDLER_H + +/** +* Operations to main list +* @since 2.6 +*/ +enum TMoveoperations + { + EMoveChannels, + EDeleteChannel, + EAddChannelToList, + EStoreAllToRepository, + EStoreIndexToRepository, + ERemoveAllFromRepository + }; + +/** +* Holder for the channel information and channel frequency +* @since 2.6 +*/ +struct TChannelInformation + { + TBuf<32> iChannelInformation; + TInt iChannelFrequency; + }; + +/** +* Interface to update channel list +* +* @since 2.6 +*/ +class MChannelListHandler + { + public: + + + virtual void UpdateChannelsL( TMoveoperations aOperation, + TInt aIndex, + TInt aMovedToNewIndex ) = NULL; + + virtual void AddChannelToListL( const TDesC& aChannelName, TInt aChannelFreq ) = 0; + + virtual CArrayFixFlat* Channels() = 0; + + }; + +#endif // MCHANNELLISTHANDLER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/inc/mfmradiolayoutchangeobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/inc/mfmradiolayoutchangeobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,42 @@ +/* +* 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 an interface for observing +* +*/ + + + +#ifndef MFMRADIOLAYOUTCHANGEOBSERVER_H +#define MFMRADIOLAYOUTCHANGEOBSERVER_H + +// INCLUDES +#include + +// CLASS DECLARATION + +/** +* Notifies layot change. +* +* @lib VoiceRecorderUtils.dll +* @since 2.0 +*/ +class MFMRadioLayoutChangeObserver + { + public: + virtual void LayoutChangedL( TInt aType ) = 0; + }; + +#endif // MFMRADIOLAYOUTCHANGEOBSERVER_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/rom/fmradio.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/rom/fmradio.iby Tue Feb 02 00:17:10 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: Image description file for project FM Radio +* +*/ + + +#ifndef __FMRADIO_IBY__ +#define __FMRADIO_IBY__ + +#include + +#ifdef __S60_FM_RADIO_APPLICATION + +S60_APP_EXE(fmradio) +S60_APP_AIF_ICONS(fmradio) +data=DATAZ_\PRIVATE\10003A3F\IMPORT\APPS\fmradio_reg.rsc private\10003a3f\import\apps\fmradio_reg.rsc + +data=ZSYSTEM\install\fmradio_stub.sis system\install\fmradio_stub.sis + +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,fmradio) + +// Active Idle Engine +file=ABI_DIR\BUILD_DIR\fmradioactiveidleengine200.dll SHARED_LIB_DIR\fmradioactiveidleengine200.dll + +#ifdef FF_HOMESCREEN_COMMON_IDLEFW +ECOM_PLUGIN(fmradiomcpplugin100.dll, 2001f497.rsc) +ECOM_PLUGIN(fmradioactionhandler.dll, 2001f498.rsc) +#endif // FF_HOMESCREEN_COMMON_IDLEFW + +#endif // __S60_FM_RADIO_APPLICATION + +#endif // __FMRADIO_IBY__ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/rom/fmradioresources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/rom/fmradioresources.iby Tue Feb 02 00:17:10 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: The iby file contains files that must be included in image +* +*/ + + +#ifndef __FMRADIORESOURCES_IBY__ +#define __FMRADIORESOURCES_IBY__ + +#include +#ifdef __S60_FM_RADIO_APPLICATION + +data=DATAZ_\APP_RESOURCE_DIR\fmradio.rsc APP_RESOURCE_DIR\fmradio.rsc +data=DATAZ_\RESOURCE_FILES_DIR\fmradioengine.rsc RESOURCE_FILES_DIR\fmradioengine.rsc + +#ifdef FF_HOMESCREEN_COMMON_IDLEFW +data=DATAZ_\RESOURCE_FILES_DIR\fmradiomcpplugin.rsc RESOURCE_FILES_DIR\fmradiomcpplugin.rsc +#endif // FF_HOMESCREEN_COMMON_IDLEFW + +#endif // __S60_FM_RADIO_APPLICATION + +#endif //__FMRADIORESOURCES_IBY__ + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioalfbitmapanimation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioalfbitmapanimation.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,369 @@ +/* +* 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: Tuning animation for fmradio +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioalfbitmapanimation.h" +#include "fmradiodefines.h" + +// CONSTANTS +//const TInt KBmpAnimationDelay = 90; +const TInt KBmpAnimationStartupDelay = 500; +const TInt KBmpAnimationFadeInDefaultDurationTime = 200; +const TInt KBmpAnimationFadeOutDefaultDurationTime = 200; +const TInt KbmpAnimationStopDelay = 210; + +const TReal KDefaultOpacityInVisibleState = 1.0f; +const TReal KDefaultOpacityInHiddenState = 0.0f; + +_LIT8( KBmpAnimationAnchorTag, "BitmapAnimationAnchorTag" ); +// values from fmradio LAF document +const TInt KLAFVarietyTuningAnimationPortrait = 7; + +// ======== MEMBER FUNCTIONS ======== + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::CFMRadioAlfBitmapAnimation +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioAlfBitmapAnimation::CFMRadioAlfBitmapAnimation() : + iOpacityInVisibleState( KDefaultOpacityInVisibleState ), + iOpacityInHiddenState( KDefaultOpacityInHiddenState ), + iAnimationState( EBmpAnimationStopped ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::ConstructL( CAlfEnv& aEnv ) + { + CAlfControl::ConstructL( aEnv ); + CreateBitmapAnimationArrayL(); + CreateImageAnimationVisualL(); + } + + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::NewL +// Two-phase constructor of CFMRadioAlfBitmapAnimation +// --------------------------------------------------------------------------- +// +CFMRadioAlfBitmapAnimation* CFMRadioAlfBitmapAnimation::NewL( CAlfEnv& aEnv ) + { + CFMRadioAlfBitmapAnimation* self = new ( ELeave ) CFMRadioAlfBitmapAnimation; + CleanupStack::PushL( self ); + self->ConstructL( aEnv ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::~CFMRadioAlfBitmapAnimation +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAlfBitmapAnimation::~CFMRadioAlfBitmapAnimation() + { + iFrames.Reset(); + iFrames.Close(); + delete iBitmapFileName; + } + + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// ---------------------------------------------------------------------------- +// +TBool CFMRadioAlfBitmapAnimation::OfferEventL( const TAlfEvent& aEvent ) + { + TBool eventHandled = EFalse; + + if ( aEvent.IsCustomEvent() ) + { + switch( aEvent.CustomParameter() ) + { + case EBmpAnimationStart: + { + eventHandled = ETrue; + iAnimationState = EBmpAnimationRunning; + StartAnimation(); + break; + } + case EBmpAnimationContinue: + { + eventHandled = ETrue; + ContinueBmpAnimation(); + break; + } + case EBmpAnimationStop: + { + eventHandled = ETrue; + Env().CancelCustomCommands( this ); + iAnimationState = EBmpAnimationStopped; + break; + } + default: + { + break; + } + } + } + return eventHandled; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::CreateImageAnimationVisualL +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::CreateImageAnimationVisualL() + { + + //CAlfAnchorLayout* imageAnchorLayout = CAlfAnchorLayout::AddNewL( *this ); + //imageAnchorLayout->SetTagL( KBitmapAnimationAnchorTag ); + // Create an anchor for the indicator layout + iBmpAnimationAnchor = CAlfAnchorLayout::AddNewL( *this ); + iBmpAnimationAnchor->SetTagL( KBmpAnimationAnchorTag ); + + iAnimationImageVisual = CAlfImageVisual::AddNewL( *this, iBmpAnimationAnchor ); + iAnimationImageVisual->SetImage( iFrames[0] ); + + TAlfTimedValue opacity; + opacity.SetTarget( iOpacityInHiddenState, 0 ); + + iAnimationImageVisual->SetOpacity( opacity ); + } + + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::CreateBitmapAnimationArrayL +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::CreateBitmapAnimationArrayL() + { + CCoeEnv* coeEnv = CCoeEnv::Static(); + + TResourceReader resourceReader; + coeEnv->CreateResourceReaderLC( resourceReader, R_FMRADIO_WAIT_ANIM_TUNING ); + + iFrameInterval = resourceReader.ReadInt32(); + TInt bitmapCount = resourceReader.ReadInt16(); + + TFindFile finder( coeEnv->FsSession() ); + TInt err = finder.FindByDir( KFMRadioBmpFile, KDC_APP_BITMAP_DIR ); + if ( err == KErrNone ) + { + iBitmapFileName = finder.File().AllocL(); + } + + // read bitmap size from layout data + TRect tempRect; + TAknLayoutRect bitmapLayout; + bitmapLayout.LayoutRect( + tempRect, + AknLayoutScalable_Apps::area_fmrd2_info_pane_g1( KLAFVarietyTuningAnimationPortrait ) ); + + + for ( TInt i = 0; i < bitmapCount; i++ ) + { + TFileName bmpFile = resourceReader.ReadTPtrC(); + TInt bitmapId = resourceReader.ReadInt32(); + TInt bitmapMaskId = resourceReader.ReadInt32(); + TInt xx = resourceReader.ReadInt16(); + TInt xxx = resourceReader.ReadInt8(); + + TAlfImage alfImage( KAknsIIDNone, + bitmapLayout.Rect().Size(), + EAspectRatioPreserved, + iBitmapFileName, + bitmapId, + bitmapMaskId ); + + iFrames.Append( alfImage ); + } + CleanupStack::PopAndDestroy(); //resourceReader + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::StartBmpAnimation +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::StartAnimation() + { + iCurrentFrameIndex = 0; + iAnimationImageVisual->SetImage( iFrames[iCurrentFrameIndex] ); + + Show( ETrue ); + + Env().Send( TAlfCustomEventCommand( EBmpAnimationContinue, this ), iFrameInterval ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::ContinueBmpAnimation +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::ContinueBmpAnimation() + { + iCurrentFrameIndex++; + + if ( iCurrentFrameIndex == 9 ) + { + iCurrentFrameIndex = 0; + } + iAnimationImageVisual->SetImage( iFrames[iCurrentFrameIndex] ); + Env().Send( TAlfCustomEventCommand( EBmpAnimationContinue, this ), iFrameInterval ); + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::Show +// Shows the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::Show( TBool aShowWithFading ) + { + TAlfTimedValue opacity; + + if ( aShowWithFading ) + { + opacity.SetTarget( iOpacityInVisibleState, KBmpAnimationFadeInDefaultDurationTime ); + + iAnimationImageVisual->SetOpacity( opacity ); + } + else + { + opacity.SetValueNow( iOpacityInVisibleState ); + iAnimationImageVisual->SetOpacity( opacity ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::Hide +// Hides the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::Hide( TBool aHideWithFading ) + { + TAlfTimedValue opacity; + + if ( aHideWithFading ) + { + opacity.SetTarget( iOpacityInHiddenState, KBmpAnimationFadeOutDefaultDurationTime ); + + iAnimationImageVisual->SetOpacity( opacity ); + } + else + { + opacity.SetValueNow( iOpacityInHiddenState ); + iAnimationImageVisual->SetOpacity( opacity ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::StopBmpAnimation +// --------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::StopBmpAnimation() + { + if ( iAnimationState == EBmpAnimationStartup ) + { + Env().CancelCustomCommands( this, EBmpAnimationStart ); + iAnimationState = EBmpAnimationStopped; + } + else if ( iAnimationState == EBmpAnimationRunning ) + { + Hide( ETrue ); + + Env().Send( TAlfCustomEventCommand( EBmpAnimationStop, this ), KbmpAnimationStopDelay ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::SetRect +// Sets the Bmpanimation rectangle. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::SetRect( const TRect& aRect ) + { + iRect = aRect; + if ( iBmpAnimationAnchor ) + { + SetAbsoluteCornerAnchors( iBmpAnimationAnchor, 0, iRect.iTl, iRect.iBr ); + iBmpAnimationAnchor->UpdateChildrenLayout(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfBitmapAnimation::StartBmpAnimation +// --------------------------------------------------------------------------- +// +void CFMRadioAlfBitmapAnimation::StartBmpAnimation() + { + if ( iAnimationState == EBmpAnimationRunning ) + { + Env().CancelCustomCommands( this ); + Hide( EFalse ); // hide without fade + } + else if ( iAnimationState == EBmpAnimationStartup ) + { + Env().CancelCustomCommands( this, EBmpAnimationStart ); + } + iAnimationState = EBmpAnimationStartup; + Env().Send( TAlfCustomEventCommand( EBmpAnimationStart, this ), KBmpAnimationStartupDelay ); + } + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioalfindicator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioalfindicator.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,333 @@ +/* +* 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: Implementation of the class CFMRadioAlfIndicator +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include + +#include "fmradioalfindicator.h" + +// CONSTANTS + +const TInt KIndicatorFadeInDefaultDurationTime = 500; +const TInt KIndicatorFadeOutDefaultDurationTime = 500; +const TReal KDefaultOpacityInVisibleState = 1.0f; +const TReal KDefaultOpacityInHiddenState = 0.0f; + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::NewL +// Two-phase constructor of CFMRadioAlfIndicator +// --------------------------------------------------------------------------- +// +CFMRadioAlfIndicator* CFMRadioAlfIndicator::NewL( CAlfEnv& aEnv ) + { + CFMRadioAlfIndicator* self = new (ELeave) CFMRadioAlfIndicator( ); + CleanupStack::PushL(self); + self->ConstructL( aEnv ); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfIndicator::CFMRadioAlfIndicator +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioAlfIndicator::CFMRadioAlfIndicator( ) +: iTextStyleId( KErrNotFound ), + iOpacityInVisibleState( KDefaultOpacityInVisibleState ), + iOpacityInHiddenState( KDefaultOpacityInHiddenState ) + { + //No implementation needed + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfIndicator::ConstructL +// Symbian 2nd phase constructor can leave. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::ConstructL( CAlfEnv& aEnv ) + { + CAlfControl::ConstructL( aEnv ); + AddIndicatorLayerL(); + Hide( EFalse ); + } + +// --------------------------------------------------------------------------- +// ~CFMRadioAlfIndicator::~CFMRadioAlfIndicator +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAlfIndicator::~CFMRadioAlfIndicator() + { + if( iTextStyleId != KErrNotFound ) + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + manager.DeleteTextStyle( iTextStyleId ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// --------------------------------------------------------------------------- +// +TBool CFMRadioAlfIndicator::OfferEventL( const TAlfEvent& /*aEvent*/ ) + { + return EFalse; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetRect +// Sets the indicator rectangle. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetRect( const TRect& aRect ) + { + iRect = aRect; + TRAP_IGNORE( SetTextStyleL() ); + if( iIndicatorTextAnchor ) + { + SetAbsoluteCornerAnchors( iIndicatorTextAnchor, 0, iRect.iTl, iRect.iBr ); + iIndicatorTextAnchor->UpdateChildrenLayout(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::AddIndicatorLayerL +// Creates the needed drawing layers and visual objects +// for the indicator. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::AddIndicatorLayerL() + { + // Create an anchor for the indicator layout + iIndicatorTextAnchor = CAlfAnchorLayout::AddNewL( *this ); + + // Create visual object for the indicator + iText = CAlfTextVisual::AddNewL( *this, iIndicatorTextAnchor ); + iText->SetColor( iTextColor ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetTextStyleL +// Creates the text style for indicator +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetTextStyleL() + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + if ( iTextStyleId == KErrNotFound ) + { + iTextStyleId = manager.CreatePlatformTextStyleL( + EAknLogicalFontSecondaryFont, + EAlfTextStyleNormal ); + } + iText->SetTextStyle( iTextStyleId ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetTextColor +// Changes indicator text color. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetTextColor( const TRgb& aTextColor ) + { + iTextColor = aTextColor; + if( iText ) + { + iText->SetColor( aTextColor ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::SetTextL +// Sets the indicator text. +// --------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetTextL( const TDesC& aText ) + { + iText->SetTextL( aText ); + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::Show +// Shows the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfIndicator::Show( TBool aShowWithFading ) + { + if( aShowWithFading ) + { + Fade( iText, KIndicatorFadeInDefaultDurationTime, iOpacityInVisibleState ); + } + else + { + Fade( iText, 0, iOpacityInVisibleState ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfIndicator::Hide +// Hides the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfIndicator::Hide( TBool aHideWithFading ) + { + if( aHideWithFading ) + { + Fade( iText, KIndicatorFadeOutDefaultDurationTime, iOpacityInHiddenState ); + } + else + { + Fade( iText, 0, iOpacityInHiddenState ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetOpacityInVisibleState +// Sets the indicator opacity in visible state. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetOpacityInVisibleState( const TReal aOpacity ) + { + iOpacityInVisibleState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetOpacityInHiddenState +// Sets the indicator opacity in hidden state. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetOpacityInHiddenState( const TReal aOpacity ) + { + iOpacityInHiddenState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TSize& aSize ) + { + if( aAnchor ) + { + // set top left corner position + aAnchor->SetAnchor( EAlfAnchorTopLeft, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX, aTopLeftPosition.iY ) ); + // .. and set the bottom right corner also to fix the size + aAnchor->SetAnchor( EAlfAnchorBottomRight, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX + aSize.iWidth, aTopLeftPosition.iY + aSize.iHeight ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealPoint& aBottomRightPosition ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aBottomRightPosition ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealSize& aSize ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition + TAlfRealPoint( aSize.iWidth, aSize.iHeight ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::Fade +// Sets the fading animation to the CAlfVisual object. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfIndicator::Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ) const + { + TAlfTimedValue opacity; + opacity.SetTarget( aOpacity, aFadingTime ); // and smooth target + aVisual->SetOpacity( opacity ); + } + +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioalfmediaidle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioalfmediaidle.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1274 @@ +/* +* 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: Implementation of the class CFMRadioAlfMediaIdle +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioalfmediaidle.h" +#include "fmradioappui.h" +#include "debug.h" + +// CONSTANTS + + +_LIT8( KMediaIdleAnchorTag, "mediaIdleAnchor" ); +_LIT8( KMediaIdleViewportTag, "mediaIdleViewport" ); +_LIT8( KMediaIdleFlowLayoutTag, "mediaIdleFlowLayout" ); +_LIT8( KMediaIdleBackgroundTextTag, "mediaIdleBackgroundText" ); +_LIT8( KMediaIdleItemTag, "mediaIdleItem" ); + +const TInt KNumberOfTextStyles = 4; +const TReal KRelativeFontSizeArray[KNumberOfTextStyles] = {0.12f, 0.17f, 0.25f, 0.33f}; +const TReal KRelativeSizeOfMediaIdleBackgroundFont = 0.7f; + +const TInt KMediaIdleFadeOutDurationTime = 500; +const TInt KMediaIdleFadeInDurationTime = 500; + +const TInt KMediaIdleBackgroundTextScrollInterval = 12000; +const TReal KMediaIdleBackgroundTextOpacity = 0.2f; +const TInt KMediaIdleBackgroundTextSideToSideTransitionDurationTime = 25000; + +//const TInt KMediaIdleModeChangeInterval = 20000; + +const TInt KMaxNumberOfMediaIdleItems = 5; +const TInt KMaxMediaIdleItemScrollDurationTime = 35000; +const TInt KMinMediaIdleItemScrollDurationTime = 25000; +const TInt KMinMediaIdleItemHideDurationTime = 5000; +const TInt KModeChangingFactor = 3; + +const TReal KMaxOpacity = 0.3f; +const TReal KMinOpacity = 0.1f; + +const TRgb KMediaIdleItemDefaultColor(0, 0, 0); +const TRgb KMediaIdleItemBackgroundColor(255, 255, 255); +const TReal KMediaIdleItemBackgroundOpacity = 0.4f; + +const TInt KMediaIdleItemArrayGranularity = 4; + +const TInt KLAFVarietyRadioIdlePortrait = 0; +const TInt KLAFVarietyRadioIdleLandscape = 1; + + +// ============================ MEMBER FUNCTIONS =============================== + + +// ============================ LOCAL FUNCTIONS =============================== + +namespace LocalFunctions { + +// --------------------------------------------------------------------------- +// fullyVerticallyVisibleRect +// Check does the given rect fit vertically into a CAlfLayout area +// --------------------------------------------------------------------------- +// +static TBool fullyVerticallyVisibleRect( const CAlfLayout& aLayout, const TAlfRealRect & aRect ) + { + TBool ret = ETrue; + TInt layoutHeight = aLayout.Size().IntTarget().iY; + TInt bottomY = aRect.BottomLeft().iY; + TInt topY = aRect.TopRight().iY; + + if ( bottomY >= layoutHeight || topY < 0 ) ret = EFalse; + + return ret; + } +// --------------------------------------------------------------------------- +// updateItemVisibility +// Hide (or unhide) an visual depending is it going to be not fully visible or not +// --------------------------------------------------------------------------- +// +static void updateItemVisibility( const CAlfLayout& aLayout, TInt index ) + { + CAlfVisual& visual = aLayout.Visual( index ); + if ( !LocalFunctions::fullyVerticallyVisibleRect( aLayout, visual.DisplayRectTarget() ) ) + { + visual.SetOpacity( TAlfTimedValue( 0.0f, KMinMediaIdleItemHideDurationTime ) ); + } + } +} + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::NewL +// Two-phase constructor of CFMRadioAlfMediaIdle +// --------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle* CFMRadioAlfMediaIdle::NewL( CAlfEnv& aEnv ) + { + CFMRadioAlfMediaIdle* self = new (ELeave) CFMRadioAlfMediaIdle( ); + CleanupStack::PushL(self); + self->ConstructL( aEnv ); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::CFMRadioAlfMediaIdle +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle::CFMRadioAlfMediaIdle() +: iFontsOrientation( EOrientationNone ), + iOrientation( EOrientationNone ), + iMediaIdleItemBackgroundTextStyleId( KErrNotFound ), + iMediaIdleState( EStopped ), + iMediaIdleMode( EBackgroundTextAndMediaIdleItems ), + iMediaIdleRequestedMode( EBackgroundTextAndMediaIdleItems ), + iMediaIdlePrimaryColor( KRgbBlue ), + iMediaIdleSecondaryColor( KRgbBlue ), + iPsName( NULL ) + { + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::ConstructL +// Symbian 2nd phase constructor can leave. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::ConstructL( CAlfEnv& aEnv ) + { + CAlfControl::ConstructL( aEnv ); + UpdateLayout(); + iIsConstructed = ETrue; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::CreateFontsL +// Create fonts that are based on a list of relative sizes +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::CreateFontsL() + { + TInt layoutHeight = 20; + + if ( iMediaIdleLayout.Rect().Height() != 0 ) + { + layoutHeight = iMediaIdleLayout.Rect().Height(); + } + + if( iFontsOrientation != iOrientation || + iFontReferenceHeight != layoutHeight ) + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + for( TInt i=0; i < iTextStyleIdArray.Count(); i++ ) + { + manager.DeleteTextStyle( iTextStyleIdArray[i] ); + iTextStyleIdArray.Reset(); + } + if( iMediaIdleItemBackgroundTextStyleId != KErrNotFound ) + { + manager.DeleteTextStyle( iMediaIdleItemBackgroundTextStyleId ); + iMediaIdleItemBackgroundTextStyleId = KErrNotFound; + } + + // Create largest font for the background text of media idle + iMediaIdleItemBackgroundTextStyleId = manager.CreatePlatformTextStyleL(); + CAlfTextStyle* mediaIdleItemStyle = manager.TextStyle( iMediaIdleItemBackgroundTextStyleId ); + mediaIdleItemStyle->SetTextSizeInPixels( KRelativeSizeOfMediaIdleBackgroundFont * layoutHeight, ETrue ); + // Create text styles for other media idle items + for( TInt i = 0; i < KNumberOfTextStyles; i++ ) + { + TInt mediaIdleItemTextStyleId = manager.CreatePlatformTextStyleL(); + CAlfTextStyle* mediaIdleItemStyle = manager.TextStyle( mediaIdleItemTextStyleId ); + mediaIdleItemStyle->SetTextSizeInPixels( KRelativeFontSizeArray[i] * layoutHeight, ETrue ); + iTextStyleIdArray.Append( mediaIdleItemTextStyleId ); + } + iFontsOrientation = iOrientation; + iFontReferenceHeight = layoutHeight; + } + } + +// --------------------------------------------------------------------------- +// ~CFMRadioAlfMediaIdle::~CFMRadioAlfMediaIdle +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle::~CFMRadioAlfMediaIdle() + { + Env().CancelCustomCommands( this ); + if( iMediaIdleItemArray ) + { + if( iMediaIdleItemArray->Count() > 0 ) + { + iMediaIdleItemArray->Reset(); + } + delete iMediaIdleItemArray; + } + CAlfTextStyleManager& manager = Env().TextStyleManager(); + for( TInt i=0; i < iTextStyleIdArray.Count(); i++ ) + { + manager.DeleteTextStyle( iTextStyleIdArray[i] ); + } + iTextStyleIdArray.Close(); + if ( iMediaIdleItemBackgroundTextStyleId != KErrNotFound ) + { + manager.DeleteTextStyle( iMediaIdleItemBackgroundTextStyleId ); + } + delete iPsName; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::AddMediaIdleL +// Creates the media idle with passed number of media idle items +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::AddMediaIdleL( const TInt aNumberOfMediaIdleItems ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::AddMediaIdleL(%d)"), aNumberOfMediaIdleItems ) ); + + CAlfAnchorLayout* mediaIdleAnchor = static_cast ( FindTag( KMediaIdleAnchorTag ) ); + if ( !mediaIdleAnchor ) + { + mediaIdleAnchor = CAlfAnchorLayout::AddNewL( *this ); + } + mediaIdleAnchor->SetTagL( KMediaIdleAnchorTag ); + + CAlfViewportLayout* mediaIdleViewport = static_cast ( FindTag( KMediaIdleViewportTag ) ); + if( !mediaIdleViewport ) + { + mediaIdleViewport = CAlfViewportLayout::AddNewL( *this, mediaIdleAnchor ); + mediaIdleViewport->SetTagL( KMediaIdleViewportTag ); + mediaIdleViewport->SetViewportPos( TAlfRealPoint( .0f, .0f ), 0 ); + mediaIdleViewport->SetViewportSize( TAlfRealSize( 1.0f, 1.0f ), 0 ); + } + MediaIdleFadeOut( ETrue ); + + // Create the flow layout for the other media idle items + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( FindTag( KMediaIdleFlowLayoutTag ) ); + if( !mediaIdleFlowLayout ) + { + mediaIdleFlowLayout = CAlfFlowLayout::AddNewL( *this, mediaIdleViewport ); + mediaIdleFlowLayout->SetTagL( KMediaIdleFlowLayoutTag ); + mediaIdleFlowLayout->SetFlowDirection( CAlfFlowLayout::EFlowVertical ); + mediaIdleFlowLayout->SetMode( CAlfFlowLayout::EModeCenterPerpendicular ); + } + + InitializeMediaIdleItemsL( aNumberOfMediaIdleItems ); + UpdateLayout(); + AnimateMediaIdleItems(); + MediaIdleFadeIn(); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::CreateBackgroundTextL +// Creates backgrounf text for media idle content +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::CreateBackgroundTextL() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::CreateBackgroundTextL()") ) ); + + CAlfViewportLayout* mediaIdleViewport = static_cast ( FindTag( KMediaIdleViewportTag ) ); + // Create and animate the background text of the media idle + HBufC* itemText = GetRandomMediaIdleContentL(); + CleanupStack::PushL( itemText ); + CAlfTextVisual* backgroundText = static_cast ( mediaIdleViewport->FindTag( KMediaIdleBackgroundTextTag ) ); + if( !backgroundText && itemText ) + { + backgroundText = AddMediaIdleItemL( mediaIdleViewport, *itemText, EFalse, KMediaIdleItemBackgroundColor, KMediaIdleItemBackgroundOpacity ); + backgroundText->SetTagL( KMediaIdleBackgroundTextTag ); + SetMediaIdleItemSettingsL( backgroundText, *itemText, iMediaIdleItemBackgroundTextStyleId ); + backgroundText->SetOpacity( TAlfTimedValue( KMediaIdleBackgroundTextOpacity ) ); + backgroundText->EnableBrushesL(); + backgroundText->EnableShadow( EFalse ); + SetScrollingToBackgroundText( backgroundText, + KMediaIdleBackgroundTextSideToSideTransitionDurationTime, + EMediaIdleBackgroundTextScrollEnd ); + } + else if( itemText ) + { + SetMediaIdleItemSettingsL( backgroundText, *itemText, iMediaIdleItemBackgroundTextStyleId ); + backgroundText->SetOpacity( TAlfTimedValue( KMediaIdleBackgroundTextOpacity ) ); + SetScrollingToBackgroundText( backgroundText, KMediaIdleBackgroundTextSideToSideTransitionDurationTime, EMediaIdleBackgroundTextScrollEnd ); + } + CleanupStack::PopAndDestroy( itemText ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::InitializeMediaIdleItemsL +// Initializes the media idle items +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::InitializeMediaIdleItemsL( const TInt aNumberOfMediaIdleItems ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::InitializeMediaIdleItemsL(%d)"), aNumberOfMediaIdleItems ) ); + + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( FindTag( KMediaIdleFlowLayoutTag ) ); + if( mediaIdleFlowLayout ) + { + CreateFontsL(); + CreateBackgroundTextL(); + // Create the media idle items + for( TInt i = 0, fontStyleIdIx = 0; i < aNumberOfMediaIdleItems; i++, fontStyleIdIx++ ) + { + HBufC* itemText = GetRandomMediaIdleContentL(); + const TPtrC& text = itemText ? itemText->Des() : KNullDesC(); + + CleanupStack::PushL( itemText ); + TInt randFontStyleIx = AlfUtil::RandomInt( 0, iTextStyleIdArray.Count() - 1 ); + CAlfTextVisual* mediaIdleItem = NULL; + if( mediaIdleFlowLayout->Count() < aNumberOfMediaIdleItems ) + { + mediaIdleItem = AddMediaIdleItemL( mediaIdleFlowLayout, text, EFalse, KMediaIdleItemBackgroundColor, KMediaIdleItemBackgroundOpacity ); + } + else + { + mediaIdleItem = static_cast ( &mediaIdleFlowLayout->Visual( i ) ); + mediaIdleItem->SetOpacity( TAlfTimedValue( .0f ) ); + mediaIdleItem->EnableTransformationL( ETrue ); + mediaIdleItem->Transformation().LoadIdentity(); + } + SetMediaIdleItemSettingsL( mediaIdleItem, text, iTextStyleIdArray[ randFontStyleIx ] ); + CleanupStack::PopAndDestroy( itemText ); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::AnimateMediaIdleItems +// Sets defined animation to the created media idle items +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::AnimateMediaIdleItems() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::AnimateMediaIdleItems()") ) ); + + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( FindTag( KMediaIdleFlowLayoutTag ) ); + if( mediaIdleFlowLayout ) + { + for( TInt i = 0; i < mediaIdleFlowLayout->Count(); i++ ) + { + CAlfTextVisual* mediaIdleItem = static_cast ( &mediaIdleFlowLayout->Visual( i ) ); + if( mediaIdleItem ) + { + SetMediaIdleItemAnimation( mediaIdleItem ); + } + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::AddMediaIdleItemL +// Creates the media idle item to the passed media idle view port. +// ---------------------------------------------------------------------------- +// +CAlfTextVisual* CFMRadioAlfMediaIdle::AddMediaIdleItemL( CAlfLayout* aMediaIdle, + const TDesC& aMediaIdleItemText, + TBool aMediaIdleItemHasBackground, + const TRgb& aBackgroundColor, + const TReal aBackgroundOpacity ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::AddMediaIdleItemL('%S')"), &aMediaIdleItemText ) ); + + CAlfTextVisual* mediaIdleItem = CAlfTextVisual::AddNewL( *this, aMediaIdle ); + mediaIdleItem->EnableBrushesL(); + mediaIdleItem->SetTextL( aMediaIdleItemText ); + mediaIdleItem->SetTagL( KMediaIdleItemTag ); + mediaIdleItem->EnableShadow( EFalse ); + mediaIdleItem->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + // mediaIdleItem->SetFlag( EAlfVisualFlagManualLayout ); + mediaIdleItem->SetSize( mediaIdleItem->TextExtents() ); + + if ( aMediaIdleItemHasBackground ) + { + CAlfGradientBrush* gradientBrush = CAlfGradientBrush::NewLC( Env() ); + gradientBrush->SetColor( aBackgroundColor, aBackgroundOpacity ); + mediaIdleItem->Brushes()->AppendL( gradientBrush, EAlfHasOwnership ); + CleanupStack::Pop( gradientBrush ); + } + return mediaIdleItem; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetMediaIdleItemSettings +// Sets color, opacity and scaling settings to the media idle item +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetMediaIdleItemSettingsL( CAlfTextVisual* aMediaIdleItem, const TDesC& aMediaIdleItemText, const TInt aTextStyleId ) + { + // Set text of the media idle item + aMediaIdleItem->SetTextL( aMediaIdleItemText ); + aMediaIdleItem->SetOpacity( TAlfTimedValue( .0f ) ); + aMediaIdleItem->EnableTransformationL( ETrue ); + CAlfTransformation* mediaIdleItemTransformation = &( aMediaIdleItem->Transformation() ); + mediaIdleItemTransformation->LoadIdentity(); + + // Select text color of the media idle item + TInt randomColorSelector = AlfUtil::RandomInt( 0, 1 ); + if ( randomColorSelector ) + { + // Set text color of the media idle item + aMediaIdleItem->SetColor( iMediaIdlePrimaryColor ); + } + else + { + // Set text color of the media idle item + aMediaIdleItem->SetColor( iMediaIdleSecondaryColor ); + } + + // Set text style of the media idle item + aMediaIdleItem->SetTextStyle( aTextStyleId ); + + TSize itemSize( 0, 0 ); + if ( aMediaIdleItem->TextExtents() != itemSize ) + { + aMediaIdleItem->SetSize( aMediaIdleItem->TextExtents() ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetMediaIdleItemAnimation +// Sets translating animations to the media idle item +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetMediaIdleItemAnimation( CAlfTextVisual* aMediaIdleItem ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::SetMediaIdleItemAnimation()") ) ); + + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( aMediaIdleItem->Layout() ); + TInt mediaIdleItemCount = mediaIdleFlowLayout->Count(); + TInt mediaIdleItemIndex = mediaIdleFlowLayout->FindVisual( aMediaIdleItem ); + + TInt mediaIdleItemWidth = aMediaIdleItem->DisplayRect().Width(); + TInt mediaIdleWidth = mediaIdleFlowLayout->Size().IntTarget().iX; + + TInt randomTranslateDuration = AlfUtil::RandomInt( KMinMediaIdleItemScrollDurationTime, KMaxMediaIdleItemScrollDurationTime ); + TInt scrollDirection = AlfUtil::RandomInt( 0, 1 ); + TAlfTimedValue targetPositionX; + if( scrollDirection ) + { + targetPositionX.SetValueNow( -mediaIdleWidth/2 - mediaIdleItemWidth/2 ); + targetPositionX.SetTarget( mediaIdleWidth/2 + mediaIdleItemWidth/2, randomTranslateDuration ); + } + else + { + targetPositionX.SetValueNow( mediaIdleWidth/2 + mediaIdleItemWidth/2 ); + targetPositionX.SetTarget( -mediaIdleWidth/2 - mediaIdleItemWidth/2, randomTranslateDuration ); + } + + Translate( aMediaIdleItem, targetPositionX, TAlfTimedValue(0)); // targetPositionY ); + + if( mediaIdleItemIndex >= 0 ) + { + Env().Send( TAlfCustomEventCommand( EMediaIdleItemTransformationEnd, + this, + mediaIdleItemIndex ), + randomTranslateDuration ); + } + // Set text opacity of the media idle item + if( !LocalFunctions::fullyVerticallyVisibleRect( *mediaIdleFlowLayout, aMediaIdleItem->DisplayRect() ) ) + { + aMediaIdleItem->SetOpacity( TAlfTimedValue( 0.0f ) ); + } + else + { + TReal randomOpacity = AlfUtil::RandomReal( KMinOpacity, KMaxOpacity ); + aMediaIdleItem->SetOpacity( TAlfTimedValue( randomOpacity ) ); + } + + mediaIdleFlowLayout->UpdateChildrenLayout( KMinMediaIdleItemScrollDurationTime ); + + // Checking all items, should they fade or not; must be done after UpdateChildrenLayout + for (TInt i=0; i ( FindTag( KMediaIdleViewportTag ) ); + if ( mediaIdle ) + { + if( aNow ) + { + FadeIn( mediaIdle, 0 ); + } + else + { + FadeIn( mediaIdle, KMediaIdleFadeInDurationTime ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::MediaIdleFadeOut +// Fades out media idle +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::MediaIdleFadeOut( TBool aNow ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::MediaIdleFadeOut(%d)"), aNow ) ); + + CAlfViewportLayout* mediaIdle = static_cast ( FindTag( KMediaIdleViewportTag ) ); + if ( mediaIdle ) + { + if( aNow ) + { + FadeOut( mediaIdle, 0 ); + } + else + { + FadeOut( mediaIdle, KMediaIdleFadeOutDurationTime ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::StartMediaIdleL +// Launches media idle. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::StartMediaIdleL() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::StartMediaIdleL()") ) ); + + if ( iMediaIdleState == EStopped ) + { + Env().CancelCustomCommands( this ); + iMediaIdleState = ERunning; + AddMediaIdleL( KMaxNumberOfMediaIdleItems ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::AddMediaIdleContentL +// Adds media idle item text to be used in the media idle +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::AddMediaIdleContentL( const TDesC& aMediaIdleItemText ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::AddMediaIdleContentL('%S')"), &aMediaIdleItemText ) ); + + if( !iMediaIdleItemArray ) + { + // Array for media idle items + iMediaIdleItemArray = new( ELeave ) CDesCArrayFlat( KMediaIdleItemArrayGranularity ); + iMediaIdleItemArray->AppendL( aMediaIdleItemText ); + } + else + { + TInt searchResultIndex = 0; + if ( iMediaIdleItemArray->Find( aMediaIdleItemText, searchResultIndex ) ) + { + // text wasn't added earlier + iMediaIdleItemArray->AppendL( aMediaIdleItemText ); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::GetRandomMediaIdleContentL +// Retrieves text from randomly chousen media idle item +// ---------------------------------------------------------------------------- +// +HBufC* CFMRadioAlfMediaIdle::GetRandomMediaIdleContentL() + { + if( !iMediaIdleItemArray ) + { + return NULL; + } + TInt count = iMediaIdleItemArray->MdcaCount(); + if( count > 0 ) + { + TInt mediaIdleItemIndex; + mediaIdleItemIndex = AlfUtil::RandomInt( 0, count - 1 ); + TPtrC itemContent( iMediaIdleItemArray->MdcaPoint( mediaIdleItemIndex ) ); + return itemContent.AllocL(); + } + else + { + return NULL; + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::ResetMediaIdleContent +// Removes all media idle item texts +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::ResetMediaIdleContent() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::ResetMediaIdleContent()") ) ); + + delete iPsName; + iPsName = NULL; + if( iMediaIdleItemArray ) + { + if( iMediaIdleItemArray->Count() > 0 ) + { + iMediaIdleItemArray->Reset(); + iMediaIdleItemArray->Compress(); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::MediaIdleContentCount +// Returns number of media idle content items +// ---------------------------------------------------------------------------- +// +TInt CFMRadioAlfMediaIdle::MediaIdleContentCount() const + { + if( iMediaIdleItemArray ) + { + return iMediaIdleItemArray->Count(); + } + else + { + return 0; + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetPrimaryColor +// Sets primary color for the media idle +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetPrimaryColor( const TRgb& aColor ) + { + iMediaIdlePrimaryColor = aColor; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetSecondaryColor +// Sets secondary color for the media idle +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetSecondaryColor( const TRgb& aColor ) + { + iMediaIdleSecondaryColor = aColor; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Translate +// Translates the visual object with passed arguments +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ) + { + if( aTextVisual ) + { + TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); + if( err == KErrNone ) + { + CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); + TAlfTimedValue x(aX); + x.SetStyle( EAlfTimedValueStyleLinear ); + + TAlfTimedValue y(aY); + y.SetStyle( EAlfTimedValueStyleLinear ); + + visualTransformation->Translate( x, y ); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::LoadTextVisualIdentity +// Removes all transformations of the visual object such as the scaling and translating. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ) + { + if( aTextVisual ) + { + TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); + if( err == KErrNone ) + { + CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); + visualTransformation->LoadIdentity(); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::UpdateLayout +// Calculates display layout +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::UpdateLayout() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::UpdateLayout()") ) ); + + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + TRect displayRect( mainPaneRect.Size() ); + + TInt lafVarietyMediaIdle = 0; + + // Adjust positions of the visual elements + if ( iOrientation == EPortrait || iOrientation == EOrientationNone ) + { + lafVarietyMediaIdle = KLAFVarietyRadioIdlePortrait; + } + else if ( iOrientation == ELandscape ) + { + lafVarietyMediaIdle = KLAFVarietyRadioIdleLandscape; + } + + iMediaIdleLayout.LayoutRect( displayRect, + AknLayoutScalable_Apps::area_fmrd2_visual_pane( lafVarietyMediaIdle ).LayoutLine() ); + + if ( iIsConstructed ) + { + CAlfVisual* thirdVisual = FindTag( KMediaIdleAnchorTag ); + if ( thirdVisual ) + { + CAlfAnchorLayout* mediaIdleAnchor = static_cast( thirdVisual ); + SetAbsoluteCornerAnchors( mediaIdleAnchor, 0, iMediaIdleLayout.Rect().iTl, iMediaIdleLayout.Rect().iBr ); + mediaIdleAnchor->UpdateChildrenLayout(); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetModeChangeRequest +// Sets request for mode change +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetModeChangeRequestL( TMediaIdleMode aRequestedMode ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::SetModeChangeRequestL(%d)"), aRequestedMode ) ); + + iMediaIdleRequestedMode = aRequestedMode; + if( iMediaIdleRequestedMode == EBackgroundTextAndMediaIdleItems && + Mode() == EOnlyBackgroundText ) + { + InitializeMediaIdleItemsL( KMaxNumberOfMediaIdleItems ); + AnimateMediaIdleItems(); + SetMode( EBackgroundTextAndMediaIdleItems ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetMode +// Sets the media idle mode +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetMode( TMediaIdleMode aMode ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::SetMode(%d)"), aMode ) ); + + iMediaIdleMode = aMode; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Mode +// Retrieves the media idle mode +// ---------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle::TMediaIdleMode CFMRadioAlfMediaIdle::Mode() + { + return iMediaIdleMode; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Orientation +// Return orientation of the display +// ---------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle::TOrientation CFMRadioAlfMediaIdle::Orientation() + { + return iOrientation; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Orientation +// Set orientation of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetOrientation( TOrientation aOrientation ) + { + iOrientation = aOrientation; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// ---------------------------------------------------------------------------- +// +TBool CFMRadioAlfMediaIdle::OfferEventL( const TAlfEvent& aEvent ) + { + TBool isHandled = EFalse; + if( aEvent.IsCustomEvent() ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::OfferEventL(aEvent.CustomParameter()=%d)"), aEvent.CustomParameter() ) ); + + switch( aEvent.CustomParameter() ) + { + case EMediaIdleItemTransformationEnd: + { + HandleMediaIdleItemTransformationEndEventL( aEvent ); + isHandled = ETrue; + } + break; + case EMediaIdleBackgroundTextScrollEnd: + { + HandleBackgroundTextScrollEndEventL( aEvent ); + isHandled = ETrue; + } + break; + case EMediaIdleChangeMode: + { + if( Mode() == EBackgroundTextAndMediaIdleItems ) + { + SetModeChangeRequestL( EOnlyBackgroundText ); + } + else + { + SetModeChangeRequestL( EBackgroundTextAndMediaIdleItems ); + } + isHandled = ETrue; + } + break; + default: + break; + } + } + return isHandled; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::HandleMediaIdleItemTransformationEndEventL +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::HandleMediaIdleItemTransformationEndEventL( const TAlfEvent& aEvent ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::HandleMediaIdleItemTransformationEndEventL()") ) ); + + iItemsTransformationEndEventCounter++; + if ( iMediaIdleRequestedMode == EOnlyBackgroundText || Mode() == EOnlyBackgroundText ) + { + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( FindTag( KMediaIdleFlowLayoutTag ) ); + if ( mediaIdleFlowLayout ) + { + TInt mediaIdleItemIndex = aEvent.CustomEventData(); + CAlfTextVisual* mediaIdleItem = static_cast ( &mediaIdleFlowLayout->Visual( mediaIdleItemIndex ) ); + if ( mediaIdleItem ) + { + mediaIdleItem->SetOpacity( TAlfTimedValue( .0f ) ); + } + + if( iItemsTransformationEndEventCounter == mediaIdleFlowLayout->Count() ) + { + SetMode( EOnlyBackgroundText ); + iItemsTransformationEndEventCounter = 0; + Env().Send( TAlfCustomEventCommand( EMediaIdleBackgroundTextScrollEnd, this ), 0 ); + } + } + } + else + { + CAlfFlowLayout* mediaIdleFlowLayout = static_cast ( FindTag( KMediaIdleFlowLayoutTag ) ); + if ( mediaIdleFlowLayout ) + { + HBufC* itemText = GetRandomMediaIdleContentL(); + if( itemText ) + { + CleanupStack::PushL( itemText ); + TInt mediaIdleItemIndex = aEvent.CustomEventData(); + CAlfTextVisual* mediaIdleItem = static_cast ( &mediaIdleFlowLayout->Visual( mediaIdleItemIndex ) ); + if ( mediaIdleItem && iTextStyleIdArray.Count() > 0 ) + { + // First hide the media idle item + mediaIdleItem->SetOpacity( TAlfTimedValue( .0f ) ); + mediaIdleItem->EnableTransformationL( ETrue ); + mediaIdleItem->Transformation().LoadIdentity(); + + TInt randFontStyleIx = AlfUtil::RandomInt( 0, iTextStyleIdArray.Count() - 1 ); + SetMediaIdleItemSettingsL( mediaIdleItem, *itemText, iTextStyleIdArray[ randFontStyleIx ] ); + SetMediaIdleItemAnimation( mediaIdleItem ); + + if ( iMediaIdleRequestedMode != EOnlyBackgroundText ) + { + if( iItemsTransformationEndEventCounter == mediaIdleFlowLayout->Count() ) + { + Env().Send( TAlfCustomEventCommand( EMediaIdleChangeMode, this ), + KMaxMediaIdleItemScrollDurationTime * KModeChangingFactor ); + iItemsTransformationEndEventCounter = 0; + } + } + } + CleanupStack::PopAndDestroy( itemText ); + } + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::HandleBackgroundTextScrollEndEventL +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::HandleBackgroundTextScrollEndEventL( const TAlfEvent& /*aEvent*/ ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::HandleBackgroundTextScrollEndEventL()") ) ); + + CAlfViewportLayout* mediaIdleViewport = static_cast ( FindTag( KMediaIdleViewportTag ) ); + if( mediaIdleViewport ) + { + CAlfTextVisual* backgroundText = static_cast ( mediaIdleViewport->FindTag( KMediaIdleBackgroundTextTag ) ); + if( backgroundText ) + { + backgroundText->SetOpacity( TAlfTimedValue( .0f ) ); + + if ( iMediaIdleRequestedMode == EOnlyBackgroundText && Mode() == EBackgroundTextAndMediaIdleItems ) + { + } + else + { + if( iMediaIdleRequestedMode == EOnlyBackgroundText && + Mode() == EOnlyBackgroundText ) + { + Env().CancelCustomCommands( this ); + Env().Send( TAlfCustomEventCommand( EMediaIdleChangeMode, this ), + KMediaIdleBackgroundTextSideToSideTransitionDurationTime ); + } + backgroundText->EnableTransformationL( ETrue ); + backgroundText->Transformation().LoadIdentity(); + HBufC* itemText = GetRandomMediaIdleContentL(); + if( itemText ) + { + CleanupStack::PushL( itemText ); + SetMediaIdleItemSettingsL( backgroundText, *itemText, iMediaIdleItemBackgroundTextStyleId ); + CleanupStack::PopAndDestroy( itemText ); + } + backgroundText->SetOpacity( TAlfTimedValue( KMediaIdleBackgroundTextOpacity ) ); + SetScrollingToBackgroundText( backgroundText, + KMediaIdleBackgroundTextSideToSideTransitionDurationTime, + EMediaIdleBackgroundTextScrollEnd ); + } + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, TInt aOrdinal, const TPoint& aTopLeftPosition, const TSize& aSize ) + { + if( aAnchor ) + { + // set top left corner position + aAnchor->SetAnchor( EAlfAnchorTopLeft, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX, aTopLeftPosition.iY ) ); + // .. and set the bottom right corner also to fix the size + aAnchor->SetAnchor( EAlfAnchorBottomRight, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX + aSize.iWidth, aTopLeftPosition.iY + aSize.iHeight ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, TInt aOrdinal, const TAlfRealPoint& aTopLeftPosition, const TAlfRealPoint& aBottomRightPosition ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aBottomRightPosition ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, TInt aOrdinal, const TAlfRealPoint& aTopLeftPosition, const TAlfRealSize& aSize ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition + TAlfRealPoint( aSize.iWidth, aSize.iHeight ) ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::SetScrollingToBackgroundText +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::SetScrollingToBackgroundText( CAlfTextVisual* aVisual, TInt aTransitionTime, TMediaIdleCustomEvent aEventAfterScrollingEnd ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::SetScrollingToBackgroundText(aTransitionTime=%d)"), aTransitionTime ) ); + + CAlfViewportLayout* mediaIdle = static_cast ( aVisual->Layout() ); + TInt mediaIdleItemWidth = aVisual->DisplayRect().Width(); + TInt mediaIdleItemHeight = aVisual->DisplayRect().Height(); + TInt mediaIdleWidth = mediaIdle->Size().IntTarget().iX; + + TAlfTimedValue targetPositionX; + if( iBackgroundTextScrollDirection == EScrollRightToLeft ) + { + targetPositionX.SetValueNow( -mediaIdleItemWidth ); + targetPositionX.SetTarget( mediaIdleWidth, aTransitionTime ); + iBackgroundTextScrollDirection = EScrollLeftToRight; + } + else + { + targetPositionX.SetValueNow( mediaIdleWidth ); + targetPositionX.SetTarget( -mediaIdleItemWidth, aTransitionTime ); + iBackgroundTextScrollDirection = EScrollRightToLeft; + } + Translate( aVisual, targetPositionX, TAlfTimedValue( -30 ) ); + Env().Send( TAlfCustomEventCommand( aEventAfterScrollingEnd, this ), + aTransitionTime + KMediaIdleBackgroundTextScrollInterval ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::ScrollToLeft +// Sets and starts scrolling animation to CAlfTextVisual. +// The visual object is scrolled from current position to +// left side of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::ScrollToLeft( CAlfTextVisual* aVisual ) const + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::ScrollToLeft(0x%x)"), aVisual ) ); + + if( aVisual ) + { + TInt visualWidth = aVisual->DisplayRect().Width(); + TInt textWidth = aVisual->TextExtents().iWidth; + TInt scrollValue = visualWidth; + if( textWidth > visualWidth ) + { + scrollValue += textWidth - visualWidth; + } + TAlfTimedPoint timedPosition = aVisual->Pos(); + TAlfRealPoint positionZero( 0, timedPosition.iY.ValueNow() ); + TAlfRealPoint positionLeft( - ( scrollValue ), timedPosition.iY.ValueNow() ); + aVisual->SetPos( positionZero ); + aVisual->SetPos( positionLeft, 1000 ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::ScrollToRight +// Sets and starts scrolling animation to CAlfTextVisual. +// The visual object is scrolled from current position to +// right side of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::ScrollToRight( CAlfTextVisual* aVisual ) const + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::ScrollToRight(0x%x)"), aVisual ) ); + + TInt visualWidth = aVisual->DisplayRect().Width(); + TInt textWidth = aVisual->TextExtents().iWidth; + TInt scrollValue = visualWidth; + if( textWidth > visualWidth ) + { + scrollValue += textWidth - visualWidth; + } + TAlfTimedPoint timedPosition = aVisual->Pos(); + TAlfRealPoint positionZero( 0, timedPosition.iY.ValueNow() ); + TAlfRealPoint positionRight( scrollValue, timedPosition.iY.ValueNow() ); + aVisual->SetPos( positionZero ); + aVisual->SetPos( positionRight, 1000 ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::FadeIn +// Sets fade-in animation to the CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::FadeIn( CAlfVisual* aVisual, TInt aTime, TReal aOpacity ) const + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::FadeIn(aVisual=0x%x, aTime=%d)"), aVisual, aTime ) ); + + TAlfTimedValue opacity; + opacity.SetValueNow( 0.0f ); // immediate change + opacity.SetTarget( aOpacity, aTime ); // and smooth target + aVisual->SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::FadeOut +// Sets fade-out animation to the CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::FadeOut( CAlfVisual* aVisual, TInt aTime, TReal aOpacity ) const + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::FadeOut(aVisual=0x%x, aTime=%d)"), aVisual, aTime ) ); + TAlfTimedValue opacity; + opacity.SetTarget( aOpacity, aTime ); + aVisual->SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::AddPsNameToMediaIdleL +// Adds PS name to the media idle item array +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::AddPsNameToMediaIdleL( const TDesC& aPsName ) + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::AddPsNameToMediaIdleL('%S')"), &aPsName ) ); + + if ( !iMediaIdleItemArray ) + { + // Array for media idle items + iMediaIdleItemArray = new ( ELeave ) CDesCArrayFlat( KMediaIdleItemArrayGranularity ); + iPsName = aPsName.AllocL(); + iMediaIdleItemArray->AppendL( *iPsName ); + return; + } + else if ( !iPsName ) + { + // PS name is added for the first time or media idle item array is reseted + if ( iMediaIdleItemArray->Count() < KFMRadioMaxNumberOfMediaIdleContentItem ) + { + iPsName = aPsName.AllocL(); + iMediaIdleItemArray->AppendL( *iPsName ); + } + return; + } + + TInt returnValue; + TInt searchResultIndex; + + returnValue = iMediaIdleItemArray->Find( *iPsName, searchResultIndex ); + + if ( returnValue == 0 ) + { + // if old PS name is found, replace it with new name + iMediaIdleItemArray->InsertL( searchResultIndex, aPsName ); + iMediaIdleItemArray->Delete( searchResultIndex + 1 ); + } + + delete iPsName; + iPsName = NULL; + iPsName = aPsName.AllocL(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::StopAndFadeOutMediaIdle +// stops media idle and clears out animation and background image +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::StopAndFadeOutMediaIdle() + { + FTRACE( FPrint( _L("CFMRadioAlfMediaIdle::StopAndFadeOutMediaIdle() - iMediaIdleState was %d"), iMediaIdleState ) ); + + if ( iMediaIdleState != EStopped ) + { + Env().CancelCustomCommands( this ); + iMediaIdleState = EStopped; + MediaIdleFadeOut(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Show +// from MFMRadioIdleControlInterface +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::Show() + { + TRAP_IGNORE( StartMediaIdleL() ) + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Hide +// from MFMRadioIdleControlInterface +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::Hide() + { + StopAndFadeOutMediaIdle(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::Deactivate +// from MFMRadioIdleControlInterface +// --------------------------------------------------------------------------- +// +void CFMRadioAlfMediaIdle::Deactivate() + { + StopAndFadeOutMediaIdle(); + } +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioalfrdsviewer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioalfrdsviewer.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,500 @@ +/* +* 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: Implementation of the class CFMRadioAlfIndicator +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include + +// brushes +#include +#include +#include +#include + +#include "debug.h" +#include "fmradioalfrdsviewer.h" +#include "fmradioalfrdsviewobserver.h" +// CONSTANTS + +const TInt KIndicatorFadeInDefaultDurationTime = 500; +const TInt KIndicatorFadeOutDefaultDurationTime = 500; +const TInt KRDSDisplayPeriod = 60000; //milliseconds = 1 min. +const TReal KDefaultOpacityInVisibleState = 1.0f; +const TReal KDefaultOpacityInHiddenState = 0.0f; +const TReal KRelativeFontSize = 0.10; + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CFMRadioAlfIndicator::NewL +// Two-phase constructor of CFMRadioAlfIndicator +// --------------------------------------------------------------------------- +// +CFMRadioAlfRDSViewer* CFMRadioAlfRDSViewer::NewL( CAlfEnv& aEnv ) + { + CFMRadioAlfRDSViewer* self = new (ELeave) CFMRadioAlfRDSViewer( ); + CleanupStack::PushL(self); + self->ConstructL( aEnv ); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::CFMRadioAlfRDSViewer +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioAlfRDSViewer::CFMRadioAlfRDSViewer() +: iTextStyleId( KErrNotFound ), + iOpacityInVisibleState( KDefaultOpacityInVisibleState ), + iOpacityInHiddenState( KDefaultOpacityInHiddenState ), + iIsRdsTextVisible( EFalse ), + iRdsTextVisibilityTimerCompleted( ETrue ) + { + //No implementation needed + } + + +// ---------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetObserver +// Sets observer +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetObserver( MFMRadioAlfRdsViewObserver* aObserver ) + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::SetObserver" ) ) ); + TInt index = iObservers.FindInAddressOrder( aObserver ); + if ( index == KErrNotFound ) + { + iObservers.InsertInAddressOrder( aObserver ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::RemoveObserver +// Removes observer +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::RemoveObserver( MFMRadioAlfRdsViewObserver* aObserver ) + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::RemoveObserver" ) ) ); + TInt index = iObservers.FindInAddressOrder( aObserver ); + + if ( index >= 0 ) + { + iObservers.Remove( index ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::ConstructL +// Symbian 2nd phase constructor can leave. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::ConstructL( CAlfEnv& aEnv ) + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::ConstructL" ) ) ); + CAlfControl::ConstructL( aEnv ); + AddIndicatorLayerL(); + Hide(); + } + +// --------------------------------------------------------------------------- +// ~CFMRadioAlfRDSViewer::~CFMRadioAlfRDSViewer +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAlfRDSViewer::~CFMRadioAlfRDSViewer() + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::Destructor" ) ) ); + Env().CancelCustomCommands( this ); + if( iTextStyleId != KErrNotFound ) + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + manager.DeleteTextStyle( iTextStyleId ); + } + iRadioText.Close(); + iObservers.Close(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// --------------------------------------------------------------------------- +// +TBool CFMRadioAlfRDSViewer::OfferEventL( const TAlfEvent& aEvent ) + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::OfferEventL" ) ) ); + TBool eventHandled = EFalse; + + if ( aEvent.IsCustomEvent() ) + { + switch( aEvent.CustomParameter() ) + { + case EFadeInCompleted: + { + eventHandled = ETrue; + Env().Send( TAlfCustomEventCommand( ERDSDisplayTimerCompleted, this ), KRDSDisplayPeriod ); + break; + } + case EOldTextFadeEffectCompleted: + { + eventHandled = ETrue; + iText->SetTextL( iRadioText ); + // fade in the new radio text + Fade( iText, KIndicatorFadeInDefaultDurationTime, iOpacityInVisibleState ); + Env().Send( TAlfCustomEventCommand( EFadeInCompleted, this ), KIndicatorFadeOutDefaultDurationTime ); + break; + } + case ERDSDisplayTimerCompleted: + { + eventHandled = ETrue; + iRdsTextVisibilityTimerCompleted = ETrue; + iIsRdsTextVisible = EFalse; + Fade( iText, KIndicatorFadeOutDefaultDurationTime, iOpacityInHiddenState ); + for ( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->NotifyRdsTextTimerCompletion(); + } + break; + } + default: + { + break; + } + } + } + return eventHandled; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetRect +// Sets the indicator rectangle. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetRect( const TRect& aRect ) + { + iRect = aRect; + TRAP_IGNORE( SetTextStyleL() ); + if( iIndicatorTextAnchor ) + { + SetAbsoluteCornerAnchors( iIndicatorTextAnchor, 0, iRect.iTl, iRect.iBr ); + iIndicatorTextAnchor->UpdateChildrenLayout(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::AddIndicatorLayerL +// Creates the needed drawing layers and visual objects +// for the indicator. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::AddIndicatorLayerL() + { + // Create an anchor for the indicator layout + iIndicatorTextAnchor = CAlfAnchorLayout::AddNewL( *this ); + + // Create visual object for the indicator + iText = CAlfTextVisual::AddNewL( *this, iIndicatorTextAnchor ); + iText->SetColor( iTextColor ); + iText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + iText->SetWrapping( CAlfTextVisual::ELineWrapBreak ); + iText->SetClipping( ETrue ); + + // shadow enablers + //iText->EnableDropShadowL( ETrue ); + //iText->EnableShadow( ETrue ); + + iText->EnableBrushesL(); + + /*CAlfGradientBrush* gradientBrush = CAlfGradientBrush::NewLC( Env() ); + gradientBrush->SetColor( KRgbBlack, 0.7f ); + iText->Brushes()->AppendL( gradientBrush, EAlfHasOwnership ); + CleanupStack::Pop( gradientBrush ); + */ + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetTextStyleL +// Creates the text style for indicator +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetTextStyleL() + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + CAlfTextStyle* textStyle = NULL; + if( iTextStyleId == KErrNotFound ) + { + iTextStyleId = manager.CreatePlatformTextStyleL( EAlfTextStyleNormal ); + } + + textStyle = manager.TextStyle( iTextStyleId ); + // 5 lines + textStyle->SetTextSizeInPixels( ( iRect.Height()*KRelativeFontSize ), ETrue ); + //textStyle->SetTextPaneHeightInPixels(iRect.Height(), ETrue ); + iText->SetTextStyle( iTextStyleId ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetTextColor +// Changes indicator text color. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetTextColor( const TRgb& aTextColor ) + { + iTextColor = aTextColor; + if( iText ) + { + iText->SetColor( aTextColor ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetTextL +// Sets the indicator text. +// --------------------------------------------------------- +// +TBool CFMRadioAlfRDSViewer::SetTextL( const TDesC& aText ) + { + TBool result = EFalse; + if ( aText.Length() > 0 ) + { + if ( iRadioText.Compare( aText ) != 0 ) + { + iRdsTextVisibilityTimerCompleted = EFalse; + Env().CancelCustomCommands( this, ERDSDisplayTimerCompleted ); + + iRadioText.Close(); + iRadioText.Create( aText ); + + if ( !iIsRdsTextVisible ) + { + iText->SetTextL( aText ); + } + else + { + // fade out the old radio text + Fade( iText, KIndicatorFadeOutDefaultDurationTime, iOpacityInHiddenState ); + Env().Send( TAlfCustomEventCommand( EOldTextFadeEffectCompleted, this ), KIndicatorFadeOutDefaultDurationTime ); + } + result = ETrue; + } + } + return result; + } + +// --------------------------------------------------------- +// CFMRadioAlfRDSViewer::Show +// Shows the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::Show() + { + if ( !iIsRdsTextVisible ) + { + iIsRdsTextVisible = ETrue; + Fade( iText, KIndicatorFadeInDefaultDurationTime, iOpacityInVisibleState ); + Env().Send( TAlfCustomEventCommand( EFadeInCompleted, this ), KIndicatorFadeOutDefaultDurationTime ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfRDSViewer::Hide +// Hides the indicator with the defined opacity value. +// --------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::Hide() + { + if ( iIsRdsTextVisible ) + { + // cancel timer event + Env().CancelCustomCommands( this, ERDSDisplayTimerCompleted ); + iIsRdsTextVisible = EFalse; + Fade( iText, KIndicatorFadeOutDefaultDurationTime, iOpacityInHiddenState ); + } + } + +// --------------------------------------------------------- +// CFMRadioAlfRDSViewer::Reset +// Cancel events and flush radio text cache +// --------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::Reset() + { + FTRACE( FPrint( _L( "CFMRadioAlfRDSViewer::Reset" ) ) ); + iRdsTextVisibilityTimerCompleted = ETrue; + iRadioText.Close(); + Env().CancelCustomCommands( this ); + } +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetOpacityInVisibleState +// Sets the indicator opacity in visible state. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetOpacityInVisibleState( const TReal aOpacity ) + { + iOpacityInVisibleState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetOpacityInHiddenState +// Sets the indicator opacity in hidden state. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetOpacityInHiddenState( const TReal aOpacity ) + { + iOpacityInHiddenState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TSize& aSize ) + { + if( aAnchor ) + { + // set top left corner position + aAnchor->SetAnchor( EAlfAnchorTopLeft, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX, aTopLeftPosition.iY ) ); + // .. and set the bottom right corner also to fix the size + aAnchor->SetAnchor( EAlfAnchorBottomRight, aOrdinal, + EAlfAnchorOriginLeft, + EAlfAnchorOriginTop, + EAlfAnchorMetricAbsolute, + EAlfAnchorMetricAbsolute, + TAlfTimedPoint( aTopLeftPosition.iX + aSize.iWidth, aTopLeftPosition.iY + aSize.iHeight ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealPoint& aBottomRightPosition ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aBottomRightPosition ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::SetRelativeCornerAnchors +// Sets relative rect of the anchor by top left point and size of the rect +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::SetRelativeCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TAlfRealPoint& aTopLeftPosition, + const TAlfRealSize& aSize ) + { + if( aAnchor ) + { + aAnchor->SetRelativeAnchorRect( aOrdinal, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition, + EAlfAnchorOriginLeft, EAlfAnchorOriginTop, aTopLeftPosition + TAlfRealPoint( aSize.iWidth, aSize.iHeight ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::Fade +// Sets the fading animation to the CAlfVisual object. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ) const + { + TAlfTimedValue opacity; + opacity.SetTarget( aOpacity, aFadingTime ); // and smooth target + aVisual->SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::IsShowingRdsTextArea +// --------------------------------------------------------------------------- +// +TBool CFMRadioAlfRDSViewer::IsShowingRdsTextArea() const + { + return iIsRdsTextVisible; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::Deactivate +// from MFMRadioIdleControlInterface +// --------------------------------------------------------------------------- +// +void CFMRadioAlfRDSViewer::Deactivate() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfRDSViewer::IsRdsTextVisibilityTimerCompleted +// --------------------------------------------------------------------------- +// +TBool CFMRadioAlfRDSViewer::IsRdsTextVisibilityTimerCompleted() + { + return iRdsTextVisibilityTimerCompleted; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioalfvisualizer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioalfvisualizer.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1181 @@ +/* +* 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: Implementation of the class CFMRadioAlfVisualizer +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioalfvisualizer.h" +#include "fmradioappui.h" +#include "fmradioalfbitmapanimation.h" +#include "fmradio.hrh" +#include "debug.h" + +using namespace GestureHelper; + +// CONSTANTS +const TInt KFMRadioStationInformationFadeDurationTime = 200; +const TInt KFMRadioStationInformationScrollDurationTime = 300; +// The delay, in microseconds, after which long keypress is activated. Taken from S60 UI style guide +const TInt KFMRadioRockerLongPressDelay = 600000; + +// values from fmradio LAF document +const TInt KLAFVarietyTuningAnimationPortrait = 7; +const TInt KLAFVarietyTuningAnimationLandscape = 7; +const TInt KLAFVarietyTuningTextPortrait = 7; +const TInt KLAFVarietyTuningTextLandscape = 7; +const TInt KLAFVarietyInfoPaneFirstLinePortrait = 0; +const TInt KLAFVarietyInfoPaneFirstLineLandscape = 1; +const TInt KLAFVarietyInfoPaneSecondLinePortrait = 0; +const TInt KLAFVarietyInfoPaneSecondLineLandscape = 1; +const TInt KLAFVarietyStationInfoPanePortrait = 0; +const TInt KLAFVarietyStationInfoPaneLandscape = 1; + + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::NewL +// Two-phase constructor of CFMRadioAlfVisualizer +// --------------------------------------------------------------------------- +// +CFMRadioAlfVisualizer* CFMRadioAlfVisualizer::NewL( CAlfEnv& aEnv ) + { + CFMRadioAlfVisualizer* self = new (ELeave) CFMRadioAlfVisualizer( ); + CleanupStack::PushL(self); + self->ConstructL( aEnv ); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::CFMRadioAlfVisualizer +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioAlfVisualizer::CFMRadioAlfVisualizer( ) +: iOrientation ( EOrientationNone ) + { + //No implementation needed + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ConstructL +// Symbian 2nd phase constructor can leave. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ConstructL( CAlfEnv& aEnv ) + { + CGestureControl::ConstructL( *this, aEnv, aEnv.PrimaryDisplay(), KFMRadioVisualizerGestureControlGroupId ); + + CCoeEnv* coeEnv = CCoeEnv::Static(); + iAppUi = static_cast( coeEnv->AppUi() ); + + SetDisplayStyle( EFMRadioDisplayNoDisplay ); + AddInformationLayersL(); + + iBmpAnimation = CFMRadioAlfBitmapAnimation::NewL( aEnv ); + CAlfControlGroup& group = aEnv.ControlGroup( KFMRadioVisualControlsGroupId ); + group.AppendL( iBmpAnimation ); + + UpdateLayout(); + + if ( AknLayoutUtils::PenEnabled() ) + { + iLongPressTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + } + } + +// --------------------------------------------------------------------------- +// ~CFMRadioAlfVisualizer::~CFMRadioAlfVisualizer +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAlfVisualizer::~CFMRadioAlfVisualizer() + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + manager.DeleteTextStyle( iFirstLineTextStyleId ); + manager.DeleteTextStyle( iSecondLineTextStyleId ); + manager.DeleteTextStyle( iTuningTextStyleId ); + + delete iLongPressTimer; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::UpdateLayout +// Calculates display layout +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::UpdateLayout() + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + TRect displayRect( mainPaneRect.Size() ); + + TInt lafVarietyAnimation = 0; + TInt lafVarietyTuningText = 0; + TInt lafVarietyStationInfoPane = 0; + TInt lafVarietyFirstLineText = 0; + TInt lafVarietySecondLineText = 0; + + TFMRadioDisplayStyle displayStyle = DisplayStyle(); + + // Adjust positions of the visual elements + if ( iOrientation == EPortrait || iOrientation == EOrientationNone ) + { + lafVarietyAnimation = KLAFVarietyTuningAnimationPortrait; + lafVarietyTuningText = KLAFVarietyTuningTextPortrait; + lafVarietyStationInfoPane = KLAFVarietyStationInfoPanePortrait; + lafVarietyFirstLineText = KLAFVarietyInfoPaneFirstLinePortrait; + lafVarietySecondLineText = KLAFVarietyInfoPaneSecondLinePortrait; + } + else if ( iOrientation == ELandscape ) + { + lafVarietyAnimation = KLAFVarietyTuningAnimationLandscape; + lafVarietyTuningText = KLAFVarietyTuningTextLandscape; + lafVarietyStationInfoPane = KLAFVarietyStationInfoPaneLandscape; + lafVarietyFirstLineText = KLAFVarietyInfoPaneFirstLineLandscape; + lafVarietySecondLineText = KLAFVarietyInfoPaneSecondLineLandscape; + } + + iStationInformationLayout.LayoutRect( displayRect, + AknLayoutScalable_Apps::area_fmrd2_info_pane( lafVarietyStationInfoPane ).LayoutLine() ); + + if ( EFMRadioDisplayDoubleLine == displayStyle ) + { + iFirstLineLayout.LayoutText( iStationInformationLayout.Rect(), + AknLayoutScalable_Apps::area_fmrd2_info_pane_t1( lafVarietyFirstLineText ).LayoutLine() ); + } + else // use bigger area for first line because it is the only visible line + { + iFirstLineLayout.LayoutText( iStationInformationLayout.Rect(), + AknLayoutScalable_Apps::area_fmrd2_info_pane_t3( lafVarietyFirstLineText ).LayoutLine() ); + } + + iSecondLineLayout.LayoutText( iStationInformationLayout.Rect(), + AknLayoutScalable_Apps::area_fmrd2_info_pane_t2( lafVarietySecondLineText ).LayoutLine() ); + + iTuningTextLayout.LayoutText( iStationInformationLayout.Rect(), + AknLayoutScalable_Apps::area_fmrd2_info_pane_t4( lafVarietyTuningText ).LayoutLine() ); + + iTuningAnimationLayout.LayoutRect( iStationInformationLayout.Rect(), + AknLayoutScalable_Apps::area_fmrd2_info_pane_g1( lafVarietyAnimation ) ); + + CAlfTextStyleManager& manager = Env().TextStyleManager(); + CAlfTextStyle* style = NULL; + style = manager.TextStyle( iFirstLineTextStyleId ); + if ( style->TextSizeInPixels() != iFirstLineLayout.TextRect().Height() ) + { // Update text size according to height of layout in LS & PT modes + style->SetTextSizeInPixels( iFirstLineLayout.TextRect().Height(), ETrue ); + iFirstLineVisualText->SetTextStyle( iFirstLineTextStyleId ); + } + + style = manager.TextStyle( iSecondLineTextStyleId ); + if ( style->TextSizeInPixels() != iSecondLineLayout.TextRect().Height() ) + { // Update text size according to height of layout in LS & PT modes + style->SetTextSizeInPixels( iSecondLineLayout.TextRect().Height(), ETrue ); + iSecondLineVisualText->SetTextStyle( iSecondLineTextStyleId ); + } + + style = manager.TextStyle( iTuningTextStyleId ); + if ( style->TextSizeInPixels() != iTuningTextLayout.TextRect().Height() ) + { // Update text size according to height of layout in LS & PT modes + style->SetTextSizeInPixels( iTuningTextLayout.TextRect().Height(), ETrue ); + iTuningVisualText->SetTextStyle( iTuningTextStyleId ); + } + + SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 0, iFirstLineLayout.TextRect().iTl, iFirstLineLayout.TextRect().iBr ); + SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 1, iSecondLineLayout.TextRect().iTl, iSecondLineLayout.TextRect().iBr ); + SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 2, iTuningTextLayout.TextRect().iTl, iTuningTextLayout.TextRect().iBr ); + iStationInformationAnchorLayout->UpdateChildrenLayout(); + iBmpAnimation->SetRect( iTuningAnimationLayout.Rect() ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::Orientation +// Return orientation of the display +// ---------------------------------------------------------------------------- +// +TDisplayOrientation CFMRadioAlfVisualizer::Orientation() + { + return iOrientation; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::Orientation +// Set orientation of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetOrientation( TDisplayOrientation aOrientation ) + { + iOrientation = aOrientation; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::SetMirrored +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetMirrored( const TBool aIsMirrored ) + { + iMirrored = aIsMirrored; + } + + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::IsMirroredL +// --------------------------------------------------------------------------- +// +TBool CFMRadioAlfVisualizer::IsMirrored() const + { + return iMirrored; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::AddInformationLayersL +// Creates the needed drawing layers and visual objects +// for visualiazing the station information. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::AddInformationLayersL() + { + CreateTextStylesForStationInformationL(); + // Create an anchor for layout of texts + iStationInformationAnchorLayout = CAlfAnchorLayout::AddNewL( *this ); + + // Create anchor to be used when preset channel is changed + iStationInformationTempAnchorLayout = CAlfAnchorLayout::AddNewL( *this ); + iStationInformationTempAnchorLayout->SetOpacity( TAlfTimedValue( 0.0 ) ); + + for ( TInt i = 0; i < 3; i++ ) + { + CAlfTextVisual* tempTextVisual = CAlfTextVisual::AddNewL( *this, iStationInformationTempAnchorLayout ); + tempTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); + tempTextVisual->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + } + + // Create visual object for the station name + iFirstLineVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); + iFirstLineVisualText->SetTextStyle( iFirstLineTextStyleId ); + iFirstLineVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); + iFirstLineVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + // Create visual object for frequency information + iSecondLineVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); + iSecondLineVisualText->SetTextStyle( iSecondLineTextStyleId ); + iSecondLineVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); + iSecondLineVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + // Visual for tuning text + iTuningVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); + iTuningVisualText->SetTextStyle( iTuningTextStyleId ); + iTuningVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); + iTuningVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::CreateTextStylesForStationInformationL +// Creates the text styles to be used by station information visualiazing +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::CreateTextStylesForStationInformationL() + { + CAlfTextStyleManager& manager = Env().TextStyleManager(); + + iFirstLineTextStyleId = manager.CreatePlatformTextStyleL( + EAknLogicalFontPrimaryFont, + EAlfTextStyleNormal ); + + iSecondLineTextStyleId = manager.CreatePlatformTextStyleL( + EAknLogicalFontSecondaryFont, + EAlfTextStyleNormal ); + + iTuningTextStyleId = manager.CreatePlatformTextStyleL( + EAknLogicalFontSecondaryFont, + EAlfTextStyleNormal ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::SetVisualText +// Sets text to the defined station information visual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetVisualTextL( TStationInformationVisual aVisual, const TDesC& aText ) + { + if( aVisual & EFirstLineTextVisual ) + { + iFirstLineVisualText->SetTextL( aText ); + iFirstLineVisualText->SetSize( iFirstLineVisualText->TextExtents() ); + } + if( aVisual & ESecondLineTextVisual ) + { + iSecondLineVisualText->SetTextL( aText ); + iSecondLineVisualText->SetSize( iSecondLineVisualText->TextExtents() ); + } + if ( aVisual & ETuningTextVisual ) + { + iTuningVisualText->SetTextL( aText ); + iTuningVisualText->SetSize( iTuningVisualText->TextExtents() ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ShowVisual +// Shows the defined station information visual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ShowVisual( TStationInformationVisual aVisual, TBool aFade ) + { + if ( aVisual & EFirstLineTextVisual ) + { + if ( aFade ) + { + FadeIn( *iFirstLineVisualText, KFMRadioStationInformationFadeDurationTime ); + } + else + { + FadeIn( *iFirstLineVisualText, 0 ); + } + } + if ( aVisual & ESecondLineTextVisual ) + { + if ( aFade ) + { + FadeIn( *iSecondLineVisualText, KFMRadioStationInformationFadeDurationTime ); + } + else + { + FadeIn( *iSecondLineVisualText, 0 ); + } + } + if ( aVisual & ETuningTextVisual ) + { + if ( aFade ) + { + FadeIn( *iTuningVisualText, KFMRadioStationInformationFadeDurationTime ); + } + else + { + FadeIn( *iTuningVisualText, 0 ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::HideVisual +// Hides the defined station information visual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::HideVisual( TStationInformationVisual aVisual ) + { + if ( aVisual & EFirstLineTextVisual ) + { + FadeOut( *iFirstLineVisualText, 0 ); + } + if ( aVisual & ESecondLineTextVisual ) + { + FadeOut( *iSecondLineVisualText, 0 ); + } + if ( aVisual & ETuningTextVisual ) + { + FadeOut( *iTuningVisualText, 0 ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::SetStationInformationTextColor +// Change text color of the text visuals. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetStationInformationTextColor( const TRgb& aTextColor ) + { + iStationInformationTextColor = aTextColor; + iFirstLineVisualText->SetColor( aTextColor ); + iSecondLineVisualText->SetColor( aTextColor ); + iTuningVisualText->SetColor( aTextColor ); + }; + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollOutCurrentStationInformationL +// Scrolls out the current station information lines by hiding actual visuals and scrolling out +// the created temporary information lines +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollOutCurrentStationInformationL( TFMRadioStationChangeType aChangeType ) + { + // Don't start any effects if the current station info is already disappeared + if ( iStationInformationAnchorLayout->Opacity().Target() != 0 ) + { + // Hide the actual station information visuals + CreateTemporaryStationInformationVisualsL(); + AnimateTemporaryStationInformationVisuals( aChangeType ); + // Hide the original and set it to origin by default + HideVisual( EAllVisuals ); + FadeOut( *iStationInformationAnchorLayout, 0 ); + iStationInformationAnchorLayout->SetPos( TAlfRealPoint() ); + // Flush manually + Env().BatchBufferHandler().FlushBatchBuffer(); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::CreateTemporaryStationInformationVisualsL +// Creates copy of current station information +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::CreateTemporaryStationInformationVisualsL() + { + // update layout and attributes for child visuals + for ( TInt i = 0, count = iStationInformationAnchorLayout->Count(); i < count; i++ ) + { + TPoint childPosition; + TSize childSize; + + iStationInformationAnchorLayout->ChildPos( i , childPosition ); + iStationInformationAnchorLayout->ChildSize( i , childSize ); + TAlfRealRect childRect( TRect( childPosition, childSize ) ); + + CAlfTextVisual* textVisual = static_cast( &iStationInformationAnchorLayout->Visual( i ) ); + CAlfTextVisual* tempTextVisual = static_cast( &iStationInformationTempAnchorLayout->Visual( i ) ); + + tempTextVisual->SetTextL( textVisual->Text() ); + tempTextVisual->SetTextStyle( textVisual->TextStyle() ); + tempTextVisual->SetColor( iStationInformationTextColor ); + tempTextVisual->SetOpacity( textVisual->Opacity() ); + + SetAbsoluteCornerAnchors( iStationInformationTempAnchorLayout, i, childRect.iTl, childRect.iBr ); + } + iStationInformationTempAnchorLayout->UpdateChildrenLayout(); + + // Flush manually + Env().BatchBufferHandler().FlushBatchBuffer(); + + iStationInformationTempAnchorLayout->SetOpacity( iStationInformationAnchorLayout->Opacity() ); + iStationInformationTempAnchorLayout->SetPos( iStationInformationAnchorLayout->Pos() ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::AnimateTemporaryStationInformationVisuals +// Animates temporary station infoout of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::AnimateTemporaryStationInformationVisuals( TFMRadioStationChangeType aChangeType ) + { + FadeOut( *iStationInformationTempAnchorLayout, KFMRadioStationInformationFadeDurationTime ); + switch ( aChangeType ) + { + // Swipe visuals in the opposite direction to give the right impression + case EFMRadioStationChangePrevious: + { + ScrollToRight( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); + break; + } + case EFMRadioStationChangeNext: + { + ScrollToLeft( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); + break; + } + case EFMRadioStationChangeScanUp: + { + ScrollUp( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); + break; + } + case EFMRadioStationChangeScanDown: + { + ScrollDown( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); + break; + } + default: + break; + }; + } + +// --------------------------------------------------------------------------- +// From class MGestureObserver. +// Called when user makes gestures. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::HandleGestureL( const MGestureEvent& aEvent ) + { + TGestureCode eventCode( aEvent.Code( MGestureEvent::EAxisBoth ) ); + FTRACE( FPrint( _L("CFMRadioAlfVisualizer::HandleGestureL(eventCode=%d)"), eventCode ) ); + + CFMRadioAppUi* appUi = static_cast( CCoeEnv::Static()->AppUi() ); + // handle gestures only if there is no call ongoing + if ( !appUi->RadioEngine()->IsInCall() ) + { + switch ( eventCode ) + { + case EGestureTap: + { + CAknVolumePopup* volPopup = appUi->ActiveVolumePopup(); + if ( volPopup ) + { + if ( volPopup->IsVisible() ) + { + volPopup->CloseVolumePopup(); + } + else + { + volPopup->ShowVolumePopupL(); + } + } + break; + } + case EGestureSwipeLeft: + { + if ( iDragAxis == EFMRadioDragAxisX ) + { + if ( appUi->NumberOfChannelsStored() ) + { + iRevertGestureDrag = EFalse; + } + appUi->HandleCommandL( EFMRadioCmdNextChannel ); + } + break; + } + case EGestureSwipeRight: + { + if ( iDragAxis == EFMRadioDragAxisX ) + { + if ( appUi->NumberOfChannelsStored() ) + { + iRevertGestureDrag = EFalse; + } + appUi->HandleCommandL( EFMRadioCmdPrevChannel ); + } + break; + } + case EGestureSwipeUp: + { + if ( iDragAxis == EFMRadioDragAxisY ) + { + iRevertGestureDrag = EFalse; + appUi->HandleCommandL( EFMRadioCmdSeekUp ); + } + break; + } + case EGestureSwipeDown: + { + if ( iDragAxis == EFMRadioDragAxisY ) + { + iRevertGestureDrag = EFalse; + appUi->HandleCommandL( EFMRadioCmdSeekDown ); + } + break; + } + case EGestureStart: + { + iDragAxis = EFMRadioDragAxisNone; + iRevertGestureDrag = ETrue; + iDragStartPosition = iStationInformationAnchorLayout->Pos(); + break; + } + case EGestureDrag: + { + TPoint delta = aEvent.CurrentPos() - aEvent.StartPos(); + + // Determine the dragging axis + if ( iDragAxis == EFMRadioDragAxisNone ) + { + TInt absX = Abs( delta.iX ); + TInt absY = Abs( delta.iY ); + if ( absX > absY ) + { + iDragAxis = EFMRadioDragAxisX; + } + else if ( absY > absX ) + { + iDragAxis = EFMRadioDragAxisY; + } + else + { + //X and Y are equal, can't determine the axis + } + } + + + if ( iRevertGestureDrag && iDragAxis != EFMRadioDragAxisNone ) // gesture is ongoing, ok to move visual + { + TAlfRealPoint newPosition; + newPosition.iX = iDragStartPosition.iX.ValueNow(); + newPosition.iY = iDragStartPosition.iY.ValueNow(); + + if ( iDragAxis == EFMRadioDragAxisX ) + { + newPosition.iX += delta.iX; + } + else + { + newPosition.iY += delta.iY; + } + iStationInformationAnchorLayout->SetPos( newPosition ); + } + break; + } + case EGestureUnknown: + case EGestureReleased: + { + if ( iRevertGestureDrag ) + { + RevertVisual( *iStationInformationAnchorLayout ); + } + break; + } + case EGestureHoldLeft: + case EGestureHoldRight: + case EGestureHoldUp: + case EGestureHoldDown: + { + // gesture "timed out" + if ( iRevertGestureDrag ) + { + // change revert status so that the following + // EGestureDrag event doesn't change visual position + // anymore + iRevertGestureDrag = EFalse; + RevertVisual( *iStationInformationAnchorLayout ); + } + break; + } + default: + { + break; + } + } + } + else + { + FTRACE(FPrint(_L("CFMRadioAlfVisualizer::HandleGestureL() call ongoing -> gestures ignored"))); + } + } +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// ---------------------------------------------------------------------------- +// +TBool CFMRadioAlfVisualizer::OfferEventL( const TAlfEvent& aEvent ) + { + if ( aEvent.IsKeyEvent() && AknLayoutUtils::PenEnabled() ) + { + const TKeyEvent& kEvent = aEvent.KeyEvent(); + if ( kEvent.iScanCode == EStdKeyRightArrow || + kEvent.iScanCode == EStdKeyLeftArrow || + kEvent.iScanCode == EStdKeyUpArrow || + kEvent.iScanCode == EStdKeyDownArrow ) + { + iKeyScanCode = kEvent.iScanCode; + + if ( aEvent.Code() == EEventKeyUp ) + { + iLongPressTimer->Cancel(); + if ( !iLongKeyTriggered ) + { + TriggerCommandL(); + } + } + else if ( aEvent.Code() == EEventKeyDown ) + { + iLongKeyTriggered = EFalse; + // Start the long key press timer + iLongPressTimer->Cancel(); + iLongPressTimer->Start( KFMRadioRockerLongPressDelay, + 0, + TCallBack( CFMRadioAlfVisualizer::StaticLongPressCallBack, this ) ); + } + return ETrue; + } + } + if ( aEvent.IsPointerEvent() ) + { + CGestureControl::OfferEventL( aEvent ); + } + return EFalse; + } + +// --------------------------------------------------------------------------- +// Sets the display style in use. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetDisplayStyle( TFMRadioDisplayStyle aDisplayStyle ) + { + iDisplayStyle = aDisplayStyle; + } + +// --------------------------------------------------------------------------- +// Returns the display style. +// --------------------------------------------------------------------------- +// +TFMRadioDisplayStyle CFMRadioAlfVisualizer::DisplayStyle() const + { + return iDisplayStyle; + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollRightToLeftWithFadeIn +// Sets and starts scrolling and fading animations to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollRightToLeftWithFadeIn( CAlfVisual& aVisual ) const + { + TInt visualWidthInDisplayCoord = aVisual.DisplayRect().Width(); + + TAlfTimedPoint targetPoint; + targetPoint.iX.SetValueNow( visualWidthInDisplayCoord ); + targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + aVisual.SetPos( targetPoint ); + + FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollLeftToRightWithFadeIn +// Sets and starts scrolling and fading animations to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollLeftToRightWithFadeIn( CAlfVisual& aVisual ) const + { + TInt visualWidthInDisplayCoord = aVisual.DisplayRect().Width(); + TAlfTimedPoint targetPoint; + targetPoint.iX.SetValueNow( - visualWidthInDisplayCoord ); + targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + aVisual.SetPos( targetPoint ); + + FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollInFromTop +// Sets and starts scrolling and fading animations to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollInFromTop( CAlfVisual& aVisual ) const + { + TRect displayArea = Env().PrimaryDisplay().VisibleArea(); + TAlfTimedPoint targetPoint; + targetPoint.iY.SetValueNow( -displayArea.Height() ); + targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + aVisual.SetPos( targetPoint ); + + FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollInFromBottom +// Sets and starts scrolling and fading animations to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollInFromBottom( CAlfVisual& aVisual ) const + { + TRect displayArea = Env().PrimaryDisplay().VisibleArea(); + TAlfTimedPoint targetPoint; + targetPoint.iY.SetValueNow( displayArea.Height() ); + targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + aVisual.SetPos( targetPoint ); + + FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::RevertVisual +// Reverts the visual to the origin +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::RevertVisual( CAlfVisual& aVisual ) + { + TAlfTimedPoint targetPoint; + targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); + aVisual.SetPos( targetPoint ); + TAlfTimedValue opacity; + opacity.SetTarget( 1.0f, KFMRadioStationInformationFadeDurationTime ); + aVisual.SetOpacity( opacity ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollToLeft +// Sets and starts scrolling animation to CAlfVisual. +// The visual object is scrolled from current position to +// left side of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollToLeft( CAlfVisual& aVisual, TInt aTime ) const + { + TInt visualWidth = aVisual.DisplayRect().Width(); + TAlfTimedPoint timedPosition = aVisual.Pos(); + TAlfRealPoint positionLeft( - ( visualWidth ), timedPosition.iY.ValueNow() ); + aVisual.SetPos( positionLeft, aTime ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollToRight +// Sets and starts scrolling animation to CAlfVisual. +// The visual object is scrolled from current position to +// right side of the display +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollToRight( CAlfVisual& aVisual, TInt aTime ) const + { + TRect displayArea = Env().PrimaryDisplay().VisibleArea(); + TAlfTimedPoint timedPosition = aVisual.Pos(); + TAlfRealPoint positionRight( displayArea.Width(), timedPosition.iY.ValueNow() ); + + aVisual.SetPos( positionRight, aTime ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollUp +// Sets and starts scrolling animation to CAlfVisual. +// The visual object is scrolled up +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollUp( CAlfVisual& aVisual, TInt aTime ) const + { + TInt visualHeight = aVisual.DisplayRect().Height(); + TAlfTimedPoint timedPosition = aVisual.Pos(); + TAlfRealPoint positionUp( timedPosition.iX.ValueNow(), -visualHeight ); + aVisual.SetPos( positionUp, aTime ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ScrollDown +// Sets and starts scrolling animation to CAlfVisual. +// The visual object is scrolled down +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ScrollDown( CAlfVisual& aVisual, TInt aTime ) const + { + TRect displayArea = Env().PrimaryDisplay().VisibleArea(); + TAlfTimedPoint timedPosition = aVisual.Pos(); + TAlfRealPoint positionDown( timedPosition.iX.ValueNow(), displayArea.Height() ); + aVisual.SetPos( positionDown, aTime ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::FadeIn +// Sets fading in animation to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::FadeIn( CAlfVisual& aVisual, TInt aTime, TReal aOpacity ) const + { + TAlfTimedValue opacity; + opacity.SetValueNow( 0.0f ); // immediate change + opacity.SetTarget( aOpacity, aTime ); // and smooth target + aVisual.SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::FadeOut +// Sets fading out animation to CAlfVisual. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::FadeOut( CAlfVisual& aVisual, TInt aTime, TReal aOpacity ) const + { + TAlfTimedValue opacity; + opacity.SetTarget( aOpacity, aTime ); + aVisual.SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::ChangeStationL +// Changes station to next with scrolling and fading station's +// information (name, frequency, etc.). +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::ChangeStationL( TFMRadioStationChangeType aChangeType, + const TDesC& aFirstLine, + const TDesC* aSecondLine ) + { + const TDesC& secondLine = aSecondLine ? *aSecondLine : KNullDesC; + TBool firstLineFade = iFirstLineVisualText->Text() != aFirstLine; + TBool secondLineFade = iSecondLineVisualText->Text() != secondLine; + + if ( aChangeType != EFMRadioStationChangeNone || firstLineFade || secondLineFade ) + { + Env().CancelCommands( iFirstLineVisualText ); + Env().CancelCommands( iSecondLineVisualText ); + + if ( secondLine.Length() ) + { + SetDisplayStyle( EFMRadioDisplayDoubleLine ); + } + else + { + SetDisplayStyle( EFMRadioDisplaySingleLine ); + } + + FadeOut( *iTuningVisualText, 0 ); + LoadTextVisualIdentity( iFirstLineVisualText ); + LoadTextVisualIdentity( iSecondLineVisualText ); + iFirstLineVisualText->SetTextL( aFirstLine ); + iSecondLineVisualText->SetTextL( secondLine ); + UpdateLayout(); + + // Set the horizontal animation + switch ( aChangeType ) + { + case EFMRadioStationChangePrevious: + { + // Direction of the animation is left to right + ShowVisual( EFirstLineTextVisual, 0 ); + ShowVisual( ESecondLineTextVisual, 0 ); + ScrollLeftToRightWithFadeIn( *iStationInformationAnchorLayout ); + } + break; + case EFMRadioStationChangeNext: + { + // Direction of the animation is right to left + ShowVisual( EFirstLineTextVisual, 0 ); + ShowVisual( ESecondLineTextVisual, 0 ); + ScrollRightToLeftWithFadeIn( *iStationInformationAnchorLayout ); + } + break; + case EFMRadioStationChangeScanUp: + { + ShowVisual( EFirstLineTextVisual, 0 ); + ShowVisual( ESecondLineTextVisual, 0 ); + ScrollInFromBottom( *iStationInformationAnchorLayout ); + } + break; + case EFMRadioStationChangeScanDown: + { + ShowVisual( EFirstLineTextVisual, 0 ); + ShowVisual( ESecondLineTextVisual, 0 ); + ScrollInFromTop( *iStationInformationAnchorLayout ); + } + break; + case EFMRadioStationChangeNone: + { + ShowVisual( EFirstLineTextVisual, firstLineFade ); + ShowVisual( ESecondLineTextVisual, secondLineFade ); + } + break; + default: + break; + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::SetStaticInfoTextL +// Resets the station information and sets static text to the third line. +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::SetStaticInfoTextL( TFMRadioStationChangeType aChangeType, const TDesC& aInfoText ) + { + ScrollOutCurrentStationInformationL( aChangeType ); + SetVisualTextL( ETuningTextVisual, aInfoText ); + UpdateLayout(); + ShowVisual( ETuningTextVisual, ETrue ); + // Make the new station info visible + FadeIn( *iStationInformationAnchorLayout, 0 ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::Translate +// Translates the visual object with passed arguments +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ) + { + if( aTextVisual ) + { + TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); + if( err == KErrNone ) + { + CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); + TAlfTimedValue x(aX); + x.SetStyle( EAlfTimedValueStyleLinear ); + + TAlfTimedValue y(aY); + y.SetStyle( EAlfTimedValueStyleLinear ); + + visualTransformation->Translate( x, y ); + } + } + } + +// --------------------------------------------------------------------------- +// Triggers the command to view handling +// --------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::TriggerCommandL() + { + TVwsViewId viewId( KNullUid, KNullUid ); + CAknViewAppUi* appUi = static_cast( CCoeEnv::Static()->AppUi() ); + TInt err = appUi->GetActiveViewId( viewId ); + RProcess process; + TSecureId id = process.SecureId(); + + if ( !err && viewId.iAppUid.iUid == id.iId ) + { + CAknView* view = appUi->View( viewId.iViewUid ); + if ( view ) + { + // command to be generated + TInt commandId = 0; + + switch ( iKeyScanCode ) + { + case EStdKeyLeftArrow: + { + if ( iLongKeyTriggered ) + { + commandId = EFMRadioRockerButtonKeyLeftLong; + break; + } + else + { + commandId = EFMRadioRockerButtonKeyLeft; + } + break; + } + case EStdKeyRightArrow: + { + if ( iLongKeyTriggered ) + { + commandId = EFMRadioRockerButtonKeyRightLong; + } + else + { + commandId = EFMRadioRockerButtonKeyRight; + } + break; + } + case EStdKeyUpArrow: + { + commandId = EFMRadioRockerButtonKeyUp; + break; + } + case EStdKeyDownArrow: + { + commandId = EFMRadioRockerButtonKeyDown; + break; + } + } + // send command to view + view->ProcessCommandL( commandId ); + } + } + } + +// --------------------------------------------------------------------------- +// Callback that is invoked when a long key press has occurred. +// --------------------------------------------------------------------------- +// +TInt CFMRadioAlfVisualizer::StaticLongPressCallBack( TAny* aSelf ) + { + CFMRadioAlfVisualizer* self = static_cast( aSelf ); + if ( self ) + { + self->iLongPressTimer->Cancel(); + self->iLongKeyTriggered = ETrue; + + TRAP_IGNORE( self->TriggerCommandL() ) + } + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::LoadTextVisualIdentity +// Removes all transformations of the visual object such as the scaling and translating. +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ) + { + if( aTextVisual ) + { + TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); + if( err == KErrNone ) + { + CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); + visualTransformation->LoadIdentity(); + } + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::StartTuningAnimation +// Starts tuning animation after delay +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::StartTuningAnimation() + { + iBmpAnimation->StartBmpAnimation(); + } + +// ---------------------------------------------------------------------------- +// CFMRadioAlfVisualizer::StopTuningAnimation +// Stops tuning animation by fading it away +// ---------------------------------------------------------------------------- +// +void CFMRadioAlfVisualizer::StopTuningAnimation() + { + iBmpAnimation->StopBmpAnimation(); + } + +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioapp.cpp Tue Feb 02 00:17:10 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: Main application class implementation. +* +*/ + + +// INCLUDE FILES +#include + +#include "fmradioapp.h" +#include "fmradiodocument.h" +#include "debug.h" +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CFMRadioApp::AppDllUid() +// Returns application UID +// --------------------------------------------------------- +// +TUid CFMRadioApp::AppDllUid() const + { + return TUid::Uid( KUidFMRadioApplication ); + } + + +// --------------------------------------------------------- +// CFMRadioApp::CreateDocumentL() +// Creates CFMRadioDocument object +// --------------------------------------------------------- +// +CApaDocument* CFMRadioApp::CreateDocumentL() + { + return CFMRadioDocument::NewL( *this ); + } + +// ================= OTHER EXPORTED FUNCTIONS ============== + + +#include + +LOCAL_C CApaApplication* NewApplication() + { + return new CFMRadioApp; + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + + +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioappui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioappui.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,2802 @@ +/* +* 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: FM Radio App UI implementation +* +*/ + +// INCLUDE FILES + +#include +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE +#include +#include "radio.hlp.hrh" +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiobacksteppingservicewrapper.h" +#include "fmradiodocument.h" +#include "fmradioengine.h" +#include "fmradiovariant.hrh" +#include "fmradiomainview.h" +#include "fmradiochannellistview.h" +#include "fmradiocontroleventobserverimpl.h" +#include "fmradioscanlocalstationsview.h" +#include "fmradio.hrh" +#include "fmradioengine.hrh" +#include "fmradioappui.h" +#include "fmradiordsreceiver.h" +#include "fmradioapp.h" +#include "fmradiopubsub.h" +#include "debug.h" + +// Application Uid for Active Idle app +#ifdef __ACTIVE_IDLE +const TUid KFMRadioUidIdleApp = { 0x101FD64C }; +#else +const TUid KFMRadioUidIdleApp = KPSUidActiveIdle2; // use this one instead because the "aisystemuids.hrh" is not export +#endif +// CONSTANTS + +const TInt KMaxAlfredFrameRate = 25; + +// --------------------------------------------------------------------------------- +// CFMInformationNote::CFMInformationNote +// --------------------------------------------------------------------------------- +CFMInformationNote::CFMInformationNote( MInformationNoteInterface& aObserver ) : + CAknInformationNote ( EFalse ), + iDialogObserver( aObserver ) + { + + } + + +// --------------------------------------------------------------------------------- +// CFMInformationNote::~CFMInformationNote +// --------------------------------------------------------------------------------- +// +CFMInformationNote::~CFMInformationNote() + { + iDialogObserver.DialogTerminated(); + } + + + +// ================= MEMBER FUNCTIONS ======================= +// +// --------------------------------------------------------------------------------- +// CFMRadioAppUi::ConstructL +// 2nd phase constructor. Instanciates all member objects +// --------------------------------------------------------------------------------- +// +void CFMRadioAppUi::ConstructL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ConstructL()") ) ); + + iPendingViewId = TUid::Null(); + iStartUp = ETrue; + iStartupWizardHandled = EFalse; + iStartupWizardRunning = EFalse; + iTuneFromWizardActivated = EFalse; + iInfoNoteOn = EFalse; + iAutoTune = EFalse; + iAutoTuneUnmute = EFalse; + + BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); + FeatureManager::InitializeLibL(); + iFeatureManagerInitialized = ETrue; + + iChannels = new( ELeave ) CArrayFixFlat( 1 ); + + // initialise local variation key with all features disabled. + iFMRadioVariationFlags = 0; + iAudioResourceAvailable = ETrue; + iAlreadyClean = EFalse; + + iRadioEngine = CRadioEngine::NewL( *this ); // Construct a radio engine object + + // Fill channels array from engine + GetChannelsArrayL(); + + if ( iRadioEngine->IsInCall() ) + { + iCurrentRadioState = EFMRadioStateOffForPhoneCall; + } + + iBsWrapper = CFMRadioBackSteppingServiceWrapper::NewL( TUid::Uid( KUidFMRadioApplication ) ); + AddViewActivationObserverL( iBsWrapper ); + + iMainView = CFMRadioMainView::NewL( iRadioEngine, *iAlfEnv, *this ); + AddViewL( iMainView ); // transfer ownership to CAknViewAppUi + iChannelListView = CFMRadioChannelListView::NewL( iRadioEngine, *this ); + AddViewL( iChannelListView ); // transfer ownership to CAknViewAppUi + iScanLocalStationsView = CFMRadioScanLocalStationsView::NewL( *iRadioEngine, *this ); + AddViewL( iScanLocalStationsView ); // transfer ownership to CAknViewAppUi + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::SecondaryConstructL() +// All leaving function calls are made here, so that nothing is left on the stack if the ConstructL leaves +// The reason for this behaviour is that the UI framework doesn't handle leaves from the AppUi correctly. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::SecondaryConstructL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::SecondaryConstructL()") ) ); + + iLayoutChangeObserver = iMainView; + + iRadioEngine->PubSubL().PublishPresetCountL( iChannels->Count() ); + + // Create vertical volume popup for speaker and headset + iIhfVolumePopupControl = CAknVolumePopup::NewL( NULL, ETrue ); + iIhfVolumePopupControl->SetRange( KFMRadioMinVolumeLevel, KFMRadioMaxVolumeLevel ); + iIhfVolumePopupControl->SetStepSize( KFMRadioVolumeStepSize ); + // Set observer for control events + iIhfVolumePopupControl->SetObserver( this ); + + iHeadsetVolumePopupControl = CAknVolumePopup::NewL( NULL, ETrue ); + iHeadsetVolumePopupControl->SetRange( KFMRadioMinVolumeLevel, KFMRadioMaxVolumeLevel ); + iHeadsetVolumePopupControl->SetStepSize( KFMRadioVolumeStepSize ); + iHeadsetVolumePopupControl->SetObserver( this ); + + iActiveVolumePopupControl = iHeadsetVolumePopupControl; //initialize it to Headset + + // Create and set our observer for control events. + iControlEventObserver = CFMRadioControlEventObserverImpl::NewL( *this ); + iRadioEngine->PubSubL().SetControlEventObserver( iControlEventObserver ); + + // For monitoring side volume key events + iSvkEvents = CFMRadioSvkEvents::NewL(*this); + + iRadioEngine->PubSubL().PublishApplicationRunningStateL( EFMRadioPSApplicationRunning ); + + UpdateLandscapeInformation(); + + // Create alfred environment + iAlfEnv = CAlfEnv::NewL(); + iAlfEnv->SetMaxFrameRate( KMaxAlfredFrameRate ); + + // Create alfred display + TRect rect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); + if( !IsLandscapeOrientation() ) + { + TRect toolBarRect = iMainView->Toolbar()->Rect(); + rect.SetHeight( rect.Height() - toolBarRect.Height() ); + } + iAlfEnv->NewDisplayL( rect, CAlfEnv::ENewDisplayAsCoeControl ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleTunerReadyCallback +// Tuner is initialized and ready. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleTunerReadyCallback() + { + iRadioEngine->InitializeRadio(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::~CFMRadioAppUi +// Destructor +// Frees reserved resources +// --------------------------------------------------------------------------- +// +CFMRadioAppUi::~CFMRadioAppUi() + { + if ( iRadioEngine ) + { + TRAP_IGNORE( + iRadioEngine->PubSubL().PublishApplicationRunningStateL( EFMRadioPSApplicationClosing ) ) + } + + FTRACE( FPrint( _L("CFMRadioAppUi::~CFMRadioAppUi()") ) ); + if ( iAlreadyClean == EFalse ) + { + Cleanup(); + } + + if ( iFeatureManagerInitialized ) + { + FeatureManager::UnInitializeLib(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::Cleanup() +// Perform object cleanup. This would normally be performed in the destructor, +// but since it can also be called from SecondaryConstructL it was moved into +// a seperate function. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::Cleanup() + { + FTRACE( FPrint( _L("CFMRadioAppUi::Cleanup()") ) ); + + delete iIhfVolumePopupControl; + iIhfVolumePopupControl = NULL; + delete iHeadsetVolumePopupControl; + iHeadsetVolumePopupControl = NULL; + + if (iRadioEngine) + { + delete iRadioEngine; + iRadioEngine = NULL; + } + if (iSvkEvents) + { + delete iSvkEvents; + } + + if (iGlobalOfflineQuery) + { + delete iGlobalOfflineQuery; + } + + if (iLocalActivateOfflineQuery) + { + delete iLocalActivateOfflineQuery; + } + + if (iLocalContinueOfflineQuery) + { + delete iLocalContinueOfflineQuery; + } + + delete iControlEventObserver; + delete iAlfEnv; + + iAlreadyClean = ETrue; + + if ( iConnectHeadsetGlobalNote ) + { + delete iConnectHeadsetGlobalNote; + iConnectHeadsetGlobalNote = NULL; + } + + if ( iConnectHeadsetQuery ) + { + delete iConnectHeadsetQuery; + iConnectHeadsetQuery = NULL; + } + if ( iChannels ) + { + iChannels->Reset(); + delete iChannels; + iChannels = NULL; + } + if ( iUpdate ) + { + delete iUpdate; + iUpdate = NULL; + } + if ( iParameters ) + { + delete iParameters; + iParameters = NULL; + } + if ( iSettingsRepository ) + { + delete iSettingsRepository; + iSettingsRepository = NULL; + } + if ( iBsWrapper ) + { + RemoveViewActivationObserver( iBsWrapper ); + } + delete iBsWrapper; + iBsWrapper = NULL; + + delete iStartupForegroundCallback; + iStartupForegroundCallback = NULL; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleCommandL +// Interprets view's menu-,softkey and other commands and acts +// accordingly by calling the appropriate command handler +// function for further action. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleCommandL( TInt aCommand ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleCommandL state=%d command=%d "), iCurrentRadioState, aCommand) ); + if ( iCurrentRadioState == EFMRadioStateOn ) + { + switch ( aCommand ) + { + case EFMRadioCmdChannelList: + ActivateLocalViewL( iChannelListView->Id() ); + break; + case EFMRadioCmdSeekUp: + ScanUpL(); + break; + case EFMRadioCmdSeekDown: + ScanDownL(); + break; + case EFMRadioCmdSaveChannel: + SaveChannelToLastIntoListL(); + break; + case EFMRadioCmdScanLocalStations: + ActivateLocalViewL(iScanLocalStationsView->Id()); + break; + case EFMRadioCmdScanLocalStationsScan: + // continue scanning + StartLocalStationsSeekL(); + break; + case EFMRadioCmdListenCh: + + if ( iChannels->Count() > 0 ) + { + PlayChannel( iChannelListView->CurrentlySelectedChannel() ); + } + break; + case EFMRadioCmdRename: + RenameCurrentChannelL(); + break; + case EFMRadioCmdActivateIhf: + SetAudioOutput( CRadioEngine::EFMRadioOutputIHF ); + break; + case EFMRadioCmdDeactivateIhf: + SetAudioOutput( CRadioEngine::EFMRadioOutputHeadset ); + break; + case EFMRadioCmdEnableRdsAfSearch: + iRadioEngine->SetRdsAfSearchEnable( ETrue ); + break; + case EFMRadioCmdDisableRdsAfSearch: + iRadioEngine->SetRdsAfSearchEnable( EFalse ); + break; + case EFMRadioCmdUpdateVolume: + UpdateVolume( EDirectionNone ); + break; + case EFMRadioCmdNextChannel: + { + TInt channelCount = iChannels->Count(); + if ( channelCount >= 1 ) + { + iMainView->SetStationChangeType( EFMRadioStationChangeNext ); + PlayChannel( iChannelListView->NextChannel() ); + } + else + { + if ( AknLayoutUtils::PenEnabled() ) + { + DisplayInformationNoteL( R_QTN_FMRADIO_USE_LONG_TAP ); + } + } + break; + } + case EFMRadioCmdPrevChannel: + { + TInt channelCount = iChannels->Count(); + if ( channelCount >= 1 ) + { + iMainView->SetStationChangeType( EFMRadioStationChangePrevious ); + PlayChannel( iChannelListView->PreviousChannel() ); + } + else + { + if ( AknLayoutUtils::PenEnabled() ) + { + DisplayInformationNoteL( R_QTN_FMRADIO_USE_LONG_TAP ); + } + } + break; + } + case EFMRadioCmdMuteOn: + iRadioEngine->SetMuteOn( ETrue ); + break; + case EFMRadioCmdMuteOff: + iRadioEngine->SetMuteOn( EFalse ); + break; + case EFMRadioCmdMute: + HandleMuteCommand(); + break; + case EAknCmdHelp: + case EFMRadioCmdHelp: + { +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE + if ( ActiveView() == KFMRadioMainViewId ) + { + HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), GetCurrentHelpContextL() ); + } + else + { + CArrayFix* buf = CCoeAppUi::AppHelpContextL(); + HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), buf ); + } +#endif + } + break; + case EFMRadioCmdScanLocalStationsViewActive: + iLayoutChangeObserver = iScanLocalStationsView; + break; + case EFMRadioCmdChannelListViewActive: + iLayoutChangeObserver = iChannelListView; + break; + case EFMRadioCmdMainViewActive: + iLayoutChangeObserver = iMainView; + if ( iAutoTune && + ( iScanLocalStationsView->CancelType() == EFMRadioCancelScanBySoftkey || + iScanLocalStationsView->CancelType() == EFMRadioCancelScanDefault)) + { + ScanUpL(); + iAutoTune = EFalse; + iAutoTuneUnmute = ETrue; + } + break; + + default: + break; + } + } + else if( iCurrentRadioState == EFMRadioStateBusyScanUp || + iCurrentRadioState == EFMRadioStateBusyScanDown || + iCurrentRadioState == EFMRadioStateBusySeek || + iCurrentRadioState == EFMRadioStateBusyScanLocalStations ) + { + switch ( aCommand ) + { + case EFMRadioCmdStopTuning: + case EAknSoftkeyCancel: + CancelSeek(); + break; + default: + break; + } + } + switch ( aCommand ) + { + case EAknSoftkeyExit: + case EEikCmdExit: + case EAknCmdExit: + Exit(); + break; + default: + break; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ActiveView +// --------------------------------------------------------------------------- +// +TUid CFMRadioAppUi::ActiveView() const + { + return iView ? iView->Id() : KNullUid; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::RadioEngine +// --------------------------------------------------------------------------- +// +CRadioEngine* CFMRadioAppUi::RadioEngine() + { + return iRadioEngine; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::Document +// --------------------------------------------------------------------------- +// +CFMRadioDocument* CFMRadioAppUi::Document() const + { + return static_cast( CEikAppUi::Document() ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::BackSteppingWrapper +// --------------------------------------------------------------------------- +// +CFMRadioBackSteppingServiceWrapper& CFMRadioAppUi::BackSteppingWrapper() const + { + return *iBsWrapper; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::TurnRadioOn +// Turn the fm radio hardware on +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::TurnRadioOn() + { + FTRACE(FPrint(_L("CFMRadioAppUi::TurnRadioOn()"))); + if ( !iRadioEngine->IsRadioOn() ) + { + // Force the mute state only if it wasn't already forced + if ( iMuteStatusBeforeRadioInit == EFMUninitialized ) + { + if ( iRadioEngine->IsMuteOn() ) + { + FTRACE(FPrint(_L("CFMRadioAppUi::iMuteStatusBeforeRadioInit = ETrue;()"))); + iMuteStatusBeforeRadioInit = EFMMuted; + } + else + { + FTRACE(FPrint(_L("CFMRadioAppUi::iMuteStatusBeforeRadioInit = EFalse;()"))); + iMuteStatusBeforeRadioInit = EFMUnmuted; + } + } + iCurrentRadioState = EFMRadioStateBusyRadioOn; + // use mute here so we have no audio until tune event + iRadioEngine->SetMuteOn( ETrue ); + iRadioEngine->RadioOn(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::PlayChannel +// Tune the radio hardware to the frequency saved at the specified channel +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::PlayChannel( TInt aIndex ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::PlayChannel(%d)"), aIndex ) ); + if ( aIndex >= KMinNumberOfChannelListItems && + aIndex < KMaxNumberOfChannelListItems ) + { + // Activate the channel by index + TRAP_IGNORE( iRadioEngine->TunePresetL( aIndex ) ) + iMainView->PrepareViewForChannelChange(); + + // Update channel list + iChannelListView->SetNowPlayingChannel( aIndex ); + iChannelListView->SetLastListenedChannel( aIndex ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::EraseCurrentChannelL +// Delete channel from the channel list +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::EraseChannelL( TInt aIndex ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::EraseCurrentChannelL()") ) ); + + TBool accepted = ConfirmChannelListDeleteL( aIndex ); + + if ( accepted ) + { + UpdateChannelsL( EDeleteChannel, aIndex, 0 ); + UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + } + return accepted; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::RenameCurrentChannelL +// Rename the currently selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::RenameCurrentChannelL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::RenameCurrentChannelL()") ) ); + + TInt channelIndex = KErrNotFound; + if ( ActiveView() == KFMRadioChannelListViewId ) + { + channelIndex = iChannelListView->CurrentlySelectedChannel(); + } + else + { + channelIndex = iRadioEngine->GetPresetIndex(); + } + // Display the text query + CRadioEngine::TStationName channelName = iChannels->At(channelIndex).iChannelInformation; + + CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog( channelName, CAknQueryDialog::ENoTone ); + + if ( dlg->ExecuteLD( R_FMRADIO_RENAME_QUERY ) ) + { + FTRACE(FPrint(_L("CFMRadioAppUi::RenameCurrentChannelL()"))); + + iChannels->At(channelIndex).iChannelInformation = channelName; + + + iChannelListView->UpdateChannelListContentL( channelIndex, + iChannels->At(channelIndex).iChannelInformation, + iChannels->At(channelIndex).iChannelFrequency ); + + UpdateChannelsL( EStoreIndexToRepository, channelIndex, 0 ); + + iMainView->SetStationChangeType( EFMRadioStationChangeNone ); + // A channel can also be renamed from the main view + iMainView->DisplayChannelL( channelIndex ); + // show default logo for a while + // so that animation is stopped and it has the right channel name + // after restart + iMainView->ShowDefaultLogo(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::SaveChannelToLastIntoListL +// Display listbox menu to allow user to specify a channel +// to save currently tuned frequency to. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::SaveChannelToLastIntoListL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::SaveChannelToLastIntoListL()") ) ); + SaveChannelL( iChannels->Count() + 1 ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::SaveChannel +// Save currently tuned frequency to the currently selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::SaveChannelL( TInt aIndex ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::SaveChannelL(%d)"), aIndex ) ); + + TBool continueWithSave = ETrue; + // check if channel list is full + if ( aIndex == KMaxNumberOfChannelListItems + 1 ) + { + CAknQueryDialog* query = CAknQueryDialog::NewL(); + if ( query->ExecuteLD( R_FMRADIO_REPLACE_EXISTING_CHANNELS_QUERY ) ) + { + UpdateChannelsL( ERemoveAllFromRepository, 0, 0 ); + } + else + { + continueWithSave = EFalse; + } + } + + if ( continueWithSave ) + { + CFMRadioRdsReceiverBase::TFMRadioProgrammeSeviceType type = + iRadioEngine->RdsReceiver().ProgrammeServiceNameType(); + const TDesC& channelName = type == CFMRadioRdsReceiverBase::EFMRadioPSNameStatic ? + iRadioEngine->RdsReceiver().ProgrammeService() : KNullDesC; + + AddChannelToListL( channelName, iRadioEngine->GetTunedFrequency() ); + UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + + iMainView->SetStationChangeType( EFMRadioStationChangeNone ); + PlayChannel( iChannels->Count() - 1 ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ConfirmChannelListDeleteL +// Display confirmation dialog for channel deletion +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::ConfirmChannelListDeleteL( TInt aIndex ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::ConfirmChannelListActionL( %d )"), aIndex ) ); + TInt accepted = EFalse; // Operation accepted or discarded + TInt stringResourceId = 0; // Resource id of the prompt text + TInt queryResourceId = R_FMRADIO_ERASE_CH_CONFIRMATION_QUERY; // Resource id of the used query dialog + + RBuf channelData; + channelData.CleanupClosePushL(); + + if ( iChannels->At( aIndex ).iChannelInformation.Length() ) + { + stringResourceId = R_QTN_FMRADIO_QUERY_DELETE; + channelData.CreateL( iChannels->At( aIndex ).iChannelInformation ); + } + else + { + stringResourceId = R_QTN_FMRADIO_QUERY_DELETE_MHZ; + TInt maxDecimalPlaces = iRadioEngine->DecimalCount(); + TInt channelfreq = iChannels->At( aIndex ).iChannelFrequency; + TReal realFrequency = static_cast( channelfreq / static_cast( KHzConversionFactor )); + + channelData.CreateL( KFrequencyMaxLength ); + + TRealFormat format( KFrequencyMaxLength, maxDecimalPlaces ); + channelData.Num( realFrequency, format ); + AknTextUtils::LanguageSpecificNumberConversion( channelData ); + } + + // Excecute a confirmation query with string and query resource id + HBufC* prompt = StringLoader::LoadLC( stringResourceId, channelData, iCoeEnv ); + CAknQueryDialog* queryDlg = CAknQueryDialog::NewL(); + accepted = queryDlg->ExecuteLD( queryResourceId, *prompt ); + CleanupStack::PopAndDestroy( prompt ); + CleanupStack::PopAndDestroy( &channelData ); + return accepted; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ScanUpL +// +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ScanUpL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ScanUpL()") ) ); + // Frequency is always 0 when asking engine for automatical tuning. Frequency + // parameter is then ignored by engine when automatical tuning (seek) is requested. + iCurrentRadioState = EFMRadioStateBusyScanUp; + + if ( iMainView->IsForeground() ) + { + iMainView->SetStationChangeType( EFMRadioStationChangeScanUp ); + iMainView->SeekL(); // Show seek wait note + } + iRadioEngine->ScanUp(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ScanDownL +// +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ScanDownL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ScanDownL()") ) ); + // Frequency is always 0 when asking engine for automatical tuning. Frequency + // parameter is then ignored by engine when automatical tuning (seek) is requested. + iCurrentRadioState = EFMRadioStateBusyScanDown; + + if ( iMainView->IsForeground() ) + { + iMainView->SetStationChangeType( EFMRadioStationChangeScanDown ); + iMainView->SeekL(); // Show seek wait note + } + iRadioEngine->ScanDown(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::TuneL +// +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::TuneL( TInt aFrequency ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::TuneL(%d)"), aFrequency ) ); + // Frequency is always 0 when asking engine for automatical tuning. Frequency + // parameter is then ignored by engine when automatical tuning (seek) is requested. + iCurrentRadioState = EFMRadioStateBusySeek; + + if (iMainView->IsForeground()) + { + iMainView->SeekL(); // Show seek wait note + } + + iRadioEngine->Tune(aFrequency); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::UpdateVolume +// Update the radio volume +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::UpdateVolume( CFMRadioAppUi::TFMRadioDirections aDirection ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::UpdateVolume(%d)"), UpdateVolume ) ); + + if ( !iRadioEngine->IsInCall() ) + { + TInt volumeControlLevel = iRadioEngine->GetVolume(); + + TInt newVol = 0; + if ( aDirection == EDirectionDown ) + { + TRAP_IGNORE( ShowVolumePopupL(); ) + newVol = volumeControlLevel - 1; + + if ( newVol > KFMRadioMinVolumeLevel ) + { + iRadioEngine->SetVolume( newVol ); + } + else + { + iRadioEngine->SetMuteOn( ETrue ); + iRadioEngine->SetVolume( newVol ); + iActiveVolumePopupControl->SetValue( KFMRadioMinVolumeLevel ); + } + } + else if ( aDirection == EDirectionUp ) + { + TRAP_IGNORE( ShowVolumePopupL(); ) + if ( iRadioEngine->IsMuteOn() ) + { + iRadioEngine->SetMuteOn( EFalse ); + } + newVol = volumeControlLevel + 1; + + if ( newVol <= KFMRadioMaxVolumeLevel ) + { + iRadioEngine->SetVolume( newVol ); + } + else + { + iActiveVolumePopupControl->SetValue( KFMRadioMaxVolumeLevel ); + } + } + else if ( aDirection == EDirectionNone ) + { + //we just wish to update the UI's volume control + HandleVolumeChangedCallback(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::SetAudioOutput +// Set the audio output of the radio. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::SetAudioOutput( + CRadioEngine::TFMRadioAudioOutput aAudioOutput ) + { + iRadioEngine->SetAudioOutput( aAudioOutput ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::CancelSeek +// Cancel outstanding seek request. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::CancelSeek() + { + FTRACE( FPrint( _L("CFMRadioAppUi::CancelSeek()") ) ); + if( iCurrentRadioState == EFMRadioStateBusyScanUp || + iCurrentRadioState == EFMRadioStateBusyScanDown ) + { + iRadioEngine->CancelScan(); // Seek request to engine + } + HandleStopSeekCallback(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::DisplayErrorNoteL +// Displays an error note with the text contained in the passed in reference +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::DisplayErrorNoteL( TInt aErrorNote ) + { + // Show headset missing note + CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote( ETrue ); + HBufC* noteText = StringLoader::LoadLC( aErrorNote, iCoeEnv ); + errorNote->ExecuteLD( *noteText ); + CleanupStack::PopAndDestroy( noteText ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::DisplayInformationNoteL +// Displays an information note +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::DisplayInformationNoteL( TInt aInfoNote ) + { + if ( !iInfoNoteOn ) + { + CFMInformationNote* infonote = new ( ELeave ) CFMInformationNote( *this ); + HBufC* noteText = StringLoader::LoadLC( aInfoNote, iCoeEnv ); + iInfoNoteOn = ETrue; + infonote->ExecuteLD( *noteText ); + CleanupStack::PopAndDestroy( noteText ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ExitApplication +// Shutdown the application. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ExitApplication() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ExitApplication() - Start") ) ); + //this method is called twice. First will trigger the RadioOff command + if ( iCurrentRadioState == EFMRadioStateOff || + iCurrentRadioState == EFMRadioStateOffForPhoneCall || + iCurrentRadioState == EFMRadioStateOffBeforePhoneCall ) + { + //once we receive a radio off complete event we finish shutting down. + FTRACE( FPrint( _L("CFMRadioAppUi::ExitApplication() - calling exit") ) ); + Exit(); + } + else + { + if ( iCurrentRadioState != EFMRadioStateExiting ) + { + iCurrentRadioState = EFMRadioStateExiting; + FTRACE( FPrint( _L("CFMRadioAppUi::ExitApplication() - turning off, and starting timer") ) ); + iRadioEngine->RadioOff(); // Shutdown radio + } + } + } + +// --------------------------------------------------------------------------- +// From class CCoeAppUi +// CFMRadioAppUi::HandleForegroundEventL +// Application has gone to foreground/background. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleForegroundEventL( TBool aForeground ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleForegroundEventL(%d)"), aForeground ) ); + CAknViewAppUi::HandleForegroundEventL( aForeground ); + + if ( aForeground ) + { + if ( iStartUp ) + { + iStartUp = EFalse; + // Rest of startup processing may show a waiting dialog. It cannot be + // done while processing a foreground event. So a call back is used. + iStartupForegroundCallback = new( ELeave ) CAsyncCallBack( + TCallBack( StaticStartupForegroundCallback, this ), CActive::EPriorityStandard ); + iStartupForegroundCallback->CallBack(); + } + else + { + // Restores all resources that were released with a call to Release(). + // After this the Hitchcock user interface should be in the same state + // in terms of resources as it was prior to the Release() call. + //iAlfEnv->RestoreL(); + + // Check if offline profile is activated after/when playing e.g. music player. + // In that case we didn't show the offline query as global, so we need + // to show it now. + if ( IsOfflineProfileActivatedWhenRadioAudioDisabled() ) + { + // Do not re-show the offline query if user hasn't yet answered to it. + if ( !iShowingLocalOfflineContinueQuery ) + { + iRadioEngine->RadioOff(); + TInt res(0); + iShowingLocalOfflineContinueQuery = ETrue; + + iOfflineQueryDialogActivated = ETrue; + + if ( !iLocalContinueOfflineQuery ) + { + iLocalContinueOfflineQuery = CAknQueryDialog::NewL(); + } + + res = iLocalContinueOfflineQuery->ExecuteLD( R_FMRADIO_CONTINUE_IN_OFFLINE_QUERY ); + + iLocalContinueOfflineQuery = NULL; + iOfflineQueryDialogActivated = EFalse; + iShowingLocalOfflineContinueQuery = EFalse; + + if ( res ) + { + iOfflineProfileActivatedWhenRadioAudioDisabled = EFalse; + iRadioEngine->RadioOn(); + HandlePendingViewActivationL(); + } + else + { + Exit(); + } + } + } + TryToResumeAudioL(); + } + } + else + { + // Releases as many resources of the Hitchcock as possible. + //iAlfEnv->Release( ETrue ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleRadioEngineCallBack +// Notification from Radio Engine informing the UI when requests have +// completed or certain events have occured that needs to be handled. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleRadioEngineCallBack( + MRadioEngineStateChangeCallback::TFMRadioNotifyEvent aEventCode, + TInt aErrorCode ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleRadioEngineCallBack - event %d error code: %d"), aEventCode, aErrorCode ) ); + TInt err = KErrNone; + if ( aErrorCode == KErrNone ) + { + switch ( aEventCode ) + { + case EFMRadioEventTunerReady: + HandleTunerReadyCallback(); + break; + case EFMRadioEventRadioOn: + iCurrentRadioState = EFMRadioStateOn; + TRAPD( err, HandleStartupWizardL() ); + iStartupWizardHandled = ETrue;//FirstRadioInitCall = EFalse; + if ( iAutoTune && + iScanLocalStationsView->CancelType() == EFMRadioCancelScanByHeadsetDisconnect) + { + TRAP_IGNORE( ScanUpL() ); + iAutoTune = EFalse; + iAutoTuneUnmute = ETrue; + } + else if( !IsStartupWizardRunning() || err != KErrNone ) + { + //we use method because the behaviour we require is the same. + if ( !iTuneFromWizardActivated && iMuteStatusBeforeRadioInit != EFMUninitialized ) + { + TBool mute = EFalse; + if ( iMuteStatusBeforeRadioInit == EFMMuted ) + { + mute = ETrue; + } + iRadioEngine->SetMuteOn( mute ); + iMuteStatusBeforeRadioInit = EFMUninitialized; + } + HandleStopSeekCallback(); + } + break; + case EFMRadioEventRadioOff: + iCurrentRadioState = EFMRadioStateOff; + + if ( !iOfflineQueryDialogActivated ) + { + ExitApplication(); + } + + break; + case EFMRadioEventFMRadioInitialized: + TRAP( err, HandleInitializedCallbackL() ); + break; + case EFMRadioEventTune: + if ( iTuneFromWizardActivated ) + { + iTuneFromWizardActivated = EFalse; + iRadioEngine->SetMuteOn( EFalse ); + iMuteStatusBeforeRadioInit = EFMUninitialized; + } + if( iAutoTuneUnmute ) + { + iRadioEngine->SetMuteOn( EFalse ); + iAutoTuneUnmute = EFalse; + } + if ( IsStartupWizardHandled() ) + { + HandleStopSeekCallback(); + } + break; + case EFMRadioEventSetMuteState: + HandleSetMuteStateCallback(); + break; + case EFMRadioEventVolumeUpdated: + HandleVolumeChangedCallback(); + break; + case EFMRadioEventSetAudioOutput: + HandleAudioOutputSetCallback(); + break; + case EFMRadioEventButtonPressed: + iMainView->SetStationChangeType( EFMRadioStationChangeNext ); + PlayChannel( iChannelListView->NextChannel() ); + break; + case EFMRadioEventHeadsetDisconnected: + HandleHeadsetDisconnectedCallback(); + break; + case EFMRadioEventHeadsetReconnected: + HandleHeadsetReconnectedCallback(); + break; + case EFMRadioEventAudioResourceLost: + iAudioLost = ETrue; + TRAP( err, HandleAudioResourceNotAvailableL(aErrorCode) ); + break; + case EFMRadioEventAudioResourcePaused: + TRAP( err, HandleAudioResourceNotAvailableL(aErrorCode) ); + break; + case EFMRadioEventAudioResourceAvailable: + TRAP( err, HandleAudioResourceAvailableL() ); + break; + case EFMRadioEventCallStarted: + if ( iCurrentRadioState != EFMRadioStateOff && + iCurrentRadioState != EFMRadioStateOffBeforePhoneCall ) + { + iCurrentRadioState = EFMRadioStateOffForPhoneCall; + } + else + { + iCurrentRadioState = EFMRadioStateOffBeforePhoneCall; + } + FadeViewsAndShowExit( ETrue ); + break; + case EFMRadioEventCallEnded: + FadeViewsAndShowExit( EFalse ); + if ( iAudioLost ) + { + TRAP_IGNORE( TryToResumeAudioL() ); + iCurrentRadioState = EFMRadioStateOff; + } + else if ( iCurrentRadioState == EFMRadioStateOffForPhoneCall ) + { + TurnRadioOn(); + } + else + { + // Do nothing. + } + break; + case EFMRadioEventStandbyMode: + ExitApplication(); + break; + case EFMRadioEventFlightModeEnabled: + TRAP( err, HandleFlightModeEnabledCallbackL() ); + break; + case EFMRadioEventFlightModeDisabled: + HandleFlightModeDisabledCallback(); + break; + case EFMRadioEventFMTransmitterOn: + TRAP_IGNORE( HandleFMTransmitterOnCallbackL() ); + break; + case EFMRadioEventFreqRangeChanged: + HandleFreqRangeChangedCallback(); + break; + case EFMRadioEventScanLocalStationsCanceled: + { + HandleStopSeekCallback(); + SetStartupWizardRunning( EFalse ); + break; + } + default: + break; + } + } + else + { + switch ( aEventCode ) + { + case EFMRadioEventAudioResourceLost: + iAudioLost = ETrue; + TRAP( err, HandleAudioResourceNotAvailableL( aErrorCode ) ); + break; + case EFMRadioEventAudioResourcePaused: + TRAP( err, HandleAudioResourceNotAvailableL( aErrorCode ) ); + break; + case EFMRadioEventTune: + if ( iTuneFromWizardActivated ) + { + iTuneFromWizardActivated = EFalse; + iRadioEngine->SetMuteOn( EFalse ); + iMuteStatusBeforeRadioInit = EFMUninitialized; + } + + if ( aErrorCode == KFmRadioErrAntennaNotConnected ) + { + iScanLocalStationsView->SetScanCanceled(EFMRadioCancelScanByHeadsetDisconnect); + } + + HandleStopSeekCallback(); + break; + case EFMRadioEventCallStarted: + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleRadioEngineCallBack() error -> EFMRadioEventCallStarted ") ) ); + if ( iCurrentRadioState != EFMRadioStateOff && + iCurrentRadioState != EFMRadioStateOffBeforePhoneCall ) + { + iCurrentRadioState = EFMRadioStateOffForPhoneCall; + } + else + { + iCurrentRadioState = EFMRadioStateOffBeforePhoneCall; + } + FadeViewsAndShowExit( ETrue ); + break; + } + default: + FTRACE( FPrint( _L("CFMRadioAppUi::HandleRadioEngineCallBack() failed to process event.") ) ); + break; + } + } + + FTRACE( FPrint( _L("END CFMRadioAppUi::HandleRadioEngineCallBack()") ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleVolumeChangedCallback +// Processes "volume changed" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleVolumeChangedCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleVolumeChangedCallback() Start") ) ); + if ( !iRadioEngine->IsMuteOn() ) + { + TInt newVolume = iRadioEngine->GetVolume(); // current volume + FTRACE( FPrint( _L("CFMRadioAppUi::HandleVolumeChangedCallback() - volume now %d "), newVolume ) ); + iActiveVolumePopupControl->SetValue( newVolume ); + } + else + { + iActiveVolumePopupControl->SetValue( KFMRadioMinVolumeLevel ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleInitializedCallbackL +// The initialization of the radio is completed, the radio can be turned on if +// not in call. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleInitializedCallbackL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleInitializedCallbackL() Start") ) ); + if( iCurrentRadioState != EFMRadioStateOffForPhoneCall && + iCurrentRadioState != EFMRadioStateOffBeforePhoneCall ) + { + TurnRadioOn(); + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + iActiveVolumePopupControl = iIhfVolumePopupControl; + } + else + { + iActiveVolumePopupControl = iHeadsetVolumePopupControl; + } + HandleVolumeChangedCallback(); + } + } +// --------------------------------------------------------------------------- +// CFMRadioAppUi::FadeViewsAndShowExit +// fade and show exit for all views +// --------------------------------------------------------------------------- +// + +void CFMRadioAppUi::FadeViewsAndShowExit( TBool aState ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::FadeViewsAndShowExit( Tbool %d )"), aState ) ); + iMainView->FadeAndShowExit( aState ); + iChannelListView->FadeAndShowExit( aState ); + iScanLocalStationsView->FadeAndShowExit( aState ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleAudioResourceAvailableL +// When audio resource is available, we would resume the radio. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleAudioResourceAvailableL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleAudioResourceAvailableL") ) ); + + iAudioResourceAvailable = ETrue; + + if ( !IsOfflineProfileActivatedWhenRadioAudioDisabled() && + !( iGlobalOfflineQuery && iGlobalOfflineQuery->IsActive() ) ) + { + if ( ( ( iFMRadioVariationFlags & KFMRadioInternalAntennaSupported) || + iRadioEngine->IsHeadsetConnected() ) && !iAudioLost && !iRadioEngine->IsInCall() ) + { + TurnRadioOn(); + } + else if ( iAudioLost && + iRadioEngine->IsHeadsetConnected() ) + { + TryToResumeAudioL(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleAudioResourceNotAvailableL +// Handles the cases when the radio is interrupted due to: +// 1. Call setup/in progress +// 2. Higher priority audio +// --------------------------------------------------------------------------- + +void CFMRadioAppUi::HandleAudioResourceNotAvailableL( TInt FDEBUGVAR(aError) ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleAudioResourceNotAvailableL() error code: %d"), + aError ) ); + + SetStartupWizardRunning( EFalse ); + iAudioResourceAvailable = EFalse; + + if ( iCurrentRadioState != EFMRadioStateOffForPhoneCall && + iCurrentRadioState != EFMRadioStateOffBeforePhoneCall ) + { + iCurrentRadioState = EFMRadioStateOff; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleHeadsetDisconnectedCallback +// Take actions when the headset is disconnected. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleHeadsetDisconnectedCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleHeadsetDisconnectedCallback" ) ) ); + + if ( iFMRadioVariationFlags & KFMRadioInternalAntennaSupported ) + { + SetAudioOutput( CRadioEngine::EFMRadioOutputIHF ); + } + else + { + // radio is already turned off, and if it was tuning it was canceled + iCurrentRadioState = EFMRadioStateOff; + TRAP_IGNORE( ShowConnectHeadsetDialogL() ); + } + + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleHeadsetReconnectedCallback +// Take actions when the headset is reconnected. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleHeadsetReconnectedCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleHeadsetReconnectedCallback()") ) ); + if ( iConnectHeadsetQuery ) + { + delete iConnectHeadsetQuery; + iConnectHeadsetQuery = NULL; + } + + //compare bitmask to see if feature supported + if ( !(iFMRadioVariationFlags & KFMRadioInternalAntennaSupported) && + iCurrentRadioState != EFMRadioStateOffForPhoneCall && + iCurrentRadioState != EFMRadioStateOffBeforePhoneCall ) + { + // active offline query controls radio on/off + if ( iAudioLost ) + { + TRAP_IGNORE( TryToResumeAudioL() ); + } + else if ( ( iGlobalOfflineQuery && !iGlobalOfflineQuery->IsActive() ) || + !iGlobalOfflineQuery ) + { + iRadioEngine->InitializeRadio(); + } + HandleVolumeChangedCallback(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleManualTuneFailedCallback +// Processes "manual tune failed" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleManualTuneFailedCallback() + { + HandleStopSeekCallback(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleVolumeUpdateFailedCallback +// Processes "volume update failed" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleVolumeUpdateFailedCallback() + { + HandleVolumeChangedCallback(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleMuteCallback +// Processes "radio volume muted" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleSetMuteStateCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleSetMuteStateCallback()")) ); + HandleVolumeChangedCallback(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleStopSeekCallback +// Processes "seek operation completed" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleStopSeekCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleStopSeekCallback() state %d "), iCurrentRadioState) ); + + if ( iCurrentRadioState == EFMRadioStateBusyManualTune || + iCurrentRadioState == EFMRadioStateBusyScanUp || + iCurrentRadioState == EFMRadioStateBusyScanDown || + iCurrentRadioState == EFMRadioStateBusySeek || + iCurrentRadioState == EFMRadioStateBusyScanLocalStations ) + { + iCurrentRadioState = EFMRadioStateOn; // Update state + } + + const TUid activeViewTuid = ActiveView(); + + if ( activeViewTuid == KFMRadioMainViewId ) + { + TRAP_IGNORE( iMainView->StopSeekL() ) + } + else if ( activeViewTuid == KFMRadioChannelListViewId ) + { + TRAP_IGNORE( iChannelListView->StopSeekL() ) + } + else if ( activeViewTuid == KFMRadioScanLocalStationsViewId ) + { + TRAP_IGNORE( iScanLocalStationsView->StopSeekL() ) + } + else + { + // nop + } + + FTRACE( FPrint( _L("end CFMRadioAppUi::HandleStopSeekCallback") ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleAudioOutputSetCallback +// Processes "set audio output completed" callback +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleAudioOutputSetCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleAudioOutputSetCallback()")) ); + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + iActiveVolumePopupControl = iIhfVolumePopupControl; + } + else + { + iActiveVolumePopupControl = iHeadsetVolumePopupControl; + } + + // restore volume for current output + TInt volumeLevel = iRadioEngine->GetVolume(); + iRadioEngine->SetVolume( volumeLevel ); + + if ( iCurrentRadioState != EFMRadioStateBusyScanLocalStations ) + { + iRadioEngine->SetMuteOn( EFalse ); + } + + TUid view = ActiveView(); + + if ( view == KFMRadioScanLocalStationsViewId ) + { + iScanLocalStationsView->UpdateToolbar(); + } + else if ( view == KFMRadioChannelListViewId ) + { + iChannelListView->UpdateToolbar(); + } + else if ( view == KFMRadioMainViewId ) + { + CAknView* mainView = View( KFMRadioMainViewId ); + if ( mainView ) + { + // force update for toolbar extension view + mainView->Toolbar()->ToolbarExtension()->SetShown( EFalse ); + } + } + else + { + // NOP + } + + // So the views can dynamically change the option menu + StopDisplayingMenuBar(); // force update for menu bar + // Force UI update + HandleVolumeChangedCallback(); + } + +// -------------------------------------------------------------------------------- +// CFMRadioAppUi::HandleWsEventL +// -------------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleWsEventL - event %d "), aEvent.Type() ) ); + switch ( aEvent.Type() ) + { + case EEventFocusLost: + // being sent to background, so if tuning cancel first then handle event + if( iCurrentRadioState == EFMRadioStateBusyScanUp || + iCurrentRadioState == EFMRadioStateBusyScanDown ) + { + iRadioEngine->CancelScan(); + HandleStopSeekCallback(); + } + CAknViewAppUi::HandleWsEventL(aEvent, aDestination); + break; + case EEventFocusGained: + // override default behavior of unfading the ui + // can be taken out when auto resume is implemented + CAknViewAppUi::HandleWsEventL(aEvent, aDestination); + if (iMainView) + { + iMainView->UpdateDisplayForFocusGained(); + } + if (iChannelListView) + { + iChannelListView->UpdateDisplayForFocusGained(); + } + if (iScanLocalStationsView) + { + iScanLocalStationsView->UpdateDisplayForFocusGained(); + } + break; + default: + CAknViewAppUi::HandleWsEventL(aEvent, aDestination); + break; + } + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioAppUi::FMRadioSvkChangeVolumeL +// Handles the change in the Volume that is needed as per the Side Volume Key +// events. +// ---------------------------------------------------------------------------------------------------- +// +void CFMRadioAppUi::FMRadioSvkChangeVolumeL( TInt aVolumeChange ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::FMRadioSvkRemoveVolumeL() aVolumeChange : %d"), aVolumeChange ) ); + + TBool headsetConnected = iRadioEngine->IsHeadsetConnected(); + + if ( iCurrentRadioState != EFMRadioStateBusyScanLocalStations && IsStartupWizardHandled() && + headsetConnected ) + { + if ( aVolumeChange > 0 ) // up direction + { + UpdateVolume( EDirectionUp ); + } + else // down direction + { + UpdateVolume( EDirectionDown ); + } + } + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioAppUi::FMRadioSvkRemoveVolumeL +// Handles the remove Volume option that is needed depending on the duration of the +// Side Volume Key press +// ---------------------------------------------------------------------------------------------------- +// +void CFMRadioAppUi::FMRadioSvkRemoveVolumeL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::FMRadioSvkRemoveVolumeL( )") ) ); + } + + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioAppUi::FMRadioHeadsetEvent +// Handles the Headset button pressed +// ---------------------------------------------------------------------------------------------------- + +void CFMRadioAppUi::FMRadioHeadsetEvent( TAccessoryEvent aEvent ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::FMRadioHeadsetEvent event: %d "), aEvent ) ); + switch ( aEvent ) + { + case EForward: + { + if ( ActiveView() == KFMRadioScanLocalStationsViewId && + iCurrentRadioState != EFMRadioStateBusyScanLocalStations ) + { + // change channels in scan local stations view + TRAP_IGNORE( iScanLocalStationsView->HandleScanListRemConEventL( aEvent ) ) + } + else + { + TRAP_IGNORE( HandleCommandL( EFMRadioCmdNextChannel ) ) + } + break; + } + case ERewind: + { + if ( ActiveView() == KFMRadioScanLocalStationsViewId && + iCurrentRadioState != EFMRadioStateBusyScanLocalStations ) + { + TRAP_IGNORE( iScanLocalStationsView->HandleScanListRemConEventL( aEvent ) ) + } + else + { + TRAP_IGNORE( HandleCommandL( EFMRadioCmdPrevChannel ) ) + } + break; + } + case EStop: + { + if ( iCurrentRadioState != EFMRadioStateBusyScanLocalStations && IsStartupWizardHandled() ) + { + iRadioEngine->SetMuteOn( ETrue ); + } + break; + } + case EPausePlay: + { + if ( iCurrentRadioState != EFMRadioStateBusyScanLocalStations && IsStartupWizardHandled() ) + { + HandleMuteCommand(); + } + break; + } + default: + break; + } + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioAppUi::HandleResourceChangeL +// ---------------------------------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleResourceChangeL( TInt aType ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleResourceChangeL type: %d "), aType ) ); + CAknViewAppUi::HandleResourceChangeL( aType ); + + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + UpdateLandscapeInformation(); + iLayoutChangeObserver->LayoutChangedL( aType ); + } + else if ( aType == KAknsMessageSkinChange ) + { + iLayoutChangeObserver->LayoutChangedL( aType ); + } + } + +// ---------------------------------------------------------------------------------------------------- +// Handles MCoeControl events +// ---------------------------------------------------------------------------------------------------- +void CFMRadioAppUi::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleControlEventL - aEventID = %d"), aEventType) ); + if ( (aEventType == EEventStateChanged) && + ( aControl == iActiveVolumePopupControl ) ) + { + TInt volumeControlLevel = iActiveVolumePopupControl->Value(); + // Set mute + if ( volumeControlLevel == KFMRadioMinVolumeLevel ) + { + // Mute status could change from toolbar, svk or pointer event + if ( !iRadioEngine->IsMuteOn() ) + { + iRadioEngine->SetMuteOn( ETrue ); + } + } + else + { + iRadioEngine->SetMuteOn( EFalse ); + } + + // Make sure volume level is in range + if ( volumeControlLevel < KFMRadioMinVolumeLevel ) + { + volumeControlLevel = KFMRadioMinVolumeLevel; + } + else if ( volumeControlLevel > KFMRadioMaxVolumeLevel ) + { + volumeControlLevel = KFMRadioMaxVolumeLevel; + } + + // Set volume. If volume is muted we dont want to set it to iRadioEngine + if ( !iRadioEngine->IsMuteOn() ) + { + iRadioEngine->SetVolume( volumeControlLevel ); + } + } + } + +// ---------------------------------------------------------------------------------------------------- +// DialogTerminated +// ---------------------------------------------------------------------------------------------------- +void CFMRadioAppUi::DialogTerminated() + { + iInfoNoteOn = EFalse; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::UpdateLandscapeInformation +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::UpdateLandscapeInformation() + { + TSize screenSize; + + AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EScreen, screenSize ); + + // Is it portrait or landscape, compare height and width, since we can't + // be sure if EGraphicsOrientationNormal is portrait or landscape + if ( screenSize.iHeight < screenSize.iWidth ) + { + iLandscape = ETrue; + } + else + { + iLandscape = EFalse; + } + } +// --------------------------------------------------------------------------- +// CFMRadioAppUi::UpdateChannelsL +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::UpdateChannelsL( TMoveoperations aOperation, + TInt aIndex, TInt aMovedToNewIndex ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::UpdateChannelsL(%d, %d, %d)"), aOperation, aIndex, aMovedToNewIndex ) ); + TChannelInformation channelinfo; + + // Move channel operation moves channel from aIndex to aMovedToNewIndex value + if ( EMoveChannels == aOperation ) + { + channelinfo = iChannels->At( aIndex ); + iChannels->Delete( aIndex ); + iChannels->InsertL( aMovedToNewIndex, channelinfo ); + } + // Delete channel deletes channel from list + else if( EDeleteChannel == aOperation ) + { + iChannels->Delete( aIndex ); + + for ( TInt index = 0; index < iChannels->Count(); index++ ) + { + iRadioEngine->SetPresetNameFrequencyL( + index, + iChannels->At( index ).iChannelInformation, + iChannels->At( index ).iChannelFrequency ); + } + + CRadioEngine::TStationName emptyStationName; + // Remove last + iRadioEngine->SetPresetNameFrequencyL( iChannels->Count(), emptyStationName, KErrNotFound ); + } + // Store all channels to repository + else if ( EStoreAllToRepository == aOperation ) + { + for ( TInt index = 0; index < iChannels->Count(); index++ ) + { + iRadioEngine->SetPresetNameFrequencyL( + index, + iChannels->At( index ).iChannelInformation, + iChannels->At( index ).iChannelFrequency ); + } + } + // Store specified index to repository and same index + else if (EStoreIndexToRepository== aOperation ) + { + iRadioEngine->SetPresetNameFrequencyL( + aIndex, + iChannels->At( aIndex ).iChannelInformation, + iChannels->At( aIndex ).iChannelFrequency ); + + } + else if ( ERemoveAllFromRepository == aOperation ) + { + CRadioEngine::TStationName emptyStationName; + + for ( TInt i = 0; i < iChannels->Count(); i++ ) + { + iRadioEngine->SetPresetNameFrequencyL( i, emptyStationName, KErrNotFound ); + } + iChannels->Reset(); + } + + iRadioEngine->PubSubL().PublishPresetCountL( iChannels->Count() ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::AddChannelToListL +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::AddChannelToListL( const TDesC& aChannelName, TInt aChannelFreq ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::AddChannelToListL(%S, %d)"), &aChannelName, aChannelFreq ) ); + TChannelInformation channelinfo; + channelinfo.iChannelInformation = aChannelName; + channelinfo.iChannelFrequency = aChannelFreq; + iChannels->AppendL( channelinfo ); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::IsLandscapeOrientation +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsLandscapeOrientation() const + { + return iLandscape; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ChooseLayoutResource +// --------------------------------------------------------------------------- +// +TInt CFMRadioAppUi::ChooseLayoutResource( TInt aNormalPortraitRes, + TInt aMirroredPortraitRes, TInt aNormalLandscapeRes, + TInt aMirroredLandscapeRes ) const + { + TInt resId = 0; + + if ( IsLandscapeOrientation() ) + { + if ( AknLayoutUtils::LayoutMirrored() ) + { + resId = aMirroredLandscapeRes; + } + else + { + resId = aNormalLandscapeRes; + } + } + else + { + if ( AknLayoutUtils::LayoutMirrored() ) + { + resId = aMirroredPortraitRes; + } + else + { + resId = aNormalPortraitRes; + } + } + return resId; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::IsLayoutMirrored +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsLayoutMirrored() const + { + return AknLayoutUtils::LayoutMirrored(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleFlightModeEnabledCallbackL +// Displays continue offline query. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleFlightModeEnabledCallbackL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleFlightModeEnabledCallbackL" ) ) ); + + // If off-line profile is activated when no other app + // (that would disable auto resume) is playing (or has played) + // audio, a global confirmation query is displayed. + if ( iAudioResourceAvailable ) + { + iRadioEngine->RadioOff(); + + if ( !iGlobalOfflineQuery ) + { + iGlobalOfflineQuery = CFMRadioGlobalConfirmationQuery::NewL( this ); + } + + HBufC* text = StringLoader::LoadLC( R_QTN_FMRADIO_QUERY_OFFLINE_USE, iCoeEnv ); + + iOfflineQueryDialogActivated = ETrue; + iGlobalOfflineQuery->ShowQueryL( *text, R_AVKON_SOFTKEYS_YES_NO, R_QGN_NOTE_QUERY_ANIM ); + + CleanupStack::PopAndDestroy( text ); + } + + // Do the next when offline query wasn't already on the screen. + // That could happen when user changes profiles without + // answering to the query. + else if (!iGlobalOfflineQuery || !iGlobalOfflineQuery->IsActive()) + { + iOfflineProfileActivatedWhenRadioAudioDisabled = ETrue; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleFlightModeDisabledCallback +// Close query dialog. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleFlightModeDisabledCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleFlightModeDisabledCallback" ) ) ); + iOfflineProfileActivatedWhenRadioAudioDisabled = EFalse; + + // Close continue offline query + if ( iLocalContinueOfflineQuery && iLocalContinueOfflineQuery->IsVisible() ) + { + TRAP_IGNORE( iLocalContinueOfflineQuery->DismissQueryL() ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::StaticStartupForegroundCallback +// takes care of some delayed initialisation +// --------------------------------------------------------------------------- +// +TInt CFMRadioAppUi::StaticStartupForegroundCallback( TAny* aSelfPtr ) + { + CFMRadioAppUi* self = reinterpret_cast( aSelfPtr ); + if ( self ) + { + delete self->iStartupForegroundCallback; + self->iStartupForegroundCallback = NULL; + + TRAPD( err, self->HandleStartupForegroundEventL() ) + if ( err ) + { + // Shutdown the application + CEikonEnv* eikonEnv = CEikonEnv::Static(); + TApaTask task( eikonEnv->WsSession() ); + task.SetWgId( eikonEnv->RootWin().Identifier() ); + task.EndTask(); + } + } + + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleStartupForegroundEventL +// Note that leaving from this fuction will cause exit of +// FM Radio (on purpose)! +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleStartupForegroundEventL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleStartupForegroundEventL" ) ) ); + HandleOfflineModeAtStartUpL(); + TFMRadioRegionSetting region = HandleRegionsAtStartUpL(); + iRadioEngine->SetRegionIdL( region ); + HandlePendingViewActivationL(); + RequestTunerControl(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleOfflineModeAtStartUpL +// Handles offline mode at startup. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleOfflineModeAtStartUpL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleOfflineModeAtStartUpL" ) ) ); + if ( iRadioEngine->IsOfflineProfileL() ) + { + iOfflineQueryDialogActivated = ETrue; + + if ( AknLayoutUtils::PenEnabled() ) + { + // We must hide toolbar, otherwise query dialog softkeys doesn't work + ShowToolbar( EFalse ); + } + + iLocalActivateOfflineQuery = CAknQueryDialog::NewL(); + TInt result = iLocalActivateOfflineQuery->ExecuteLD( R_FMRADIO_ACTIVATE_IN_OFFLINE_QUERY ); + iLocalActivateOfflineQuery = NULL; + + iOfflineQueryDialogActivated = EFalse; + + if ( result ) + { + if ( AknLayoutUtils::PenEnabled() ) + { + ShowToolbar( ETrue ); + } + } + else + { + Exit(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ShowToolbar +// Sets toolbar visibility. This function is used to hide toolbar component +// while query dialog is shown. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ShowToolbar( TBool aVisible ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::ShowToolbar(%d)"), aVisible ) ); + if ( iLayoutChangeObserver == iMainView ) + { + iMainView->ShowToolbar( aVisible ); + } + else if ( iLayoutChangeObserver == iScanLocalStationsView ) + { + iScanLocalStationsView->ShowToolbar( aVisible ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::IsOfflineProfileActivatedWhenRadioAudioDisabled +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsOfflineProfileActivatedWhenRadioAudioDisabled() const + { + return iOfflineProfileActivatedWhenRadioAudioDisabled; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleFMTransmitterOnCallback +// Displays note about transmitter being activated and +// fade the UI. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleFMTransmitterOnCallbackL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleFMTransmitterOnCallbackL()") ) ); + iCurrentRadioState = EFMRadioStateOff; + if ( IsStartupWizardHandled() ) + { + // Wizard is allready handled so this callback is not coming + // in startup phase + HBufC* closeAppText = StringLoader::LoadLC( R_QTN_FMRADIO_NOTE_FMTX_CLOSE_APPLICATION, iCoeEnv ); + + CAknGlobalNote* fmTransmitterGlobalNote = CAknGlobalNote::NewLC(); + fmTransmitterGlobalNote->ShowNoteL( EAknGlobalInformationNote, *closeAppText ); + CleanupStack::PopAndDestroy( fmTransmitterGlobalNote ); + + CleanupStack::PopAndDestroy( closeAppText ); + } + else + { + HBufC* unableToStartText = StringLoader::LoadLC( R_QTN_FMRADIO_NOTE_FMTX_UNABLE_TO_START, iCoeEnv ); + + CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); + note->ExecuteLD( *unableToStartText ); + + CleanupStack::PopAndDestroy( unableToStartText ); + } + // check if we have any dialogs open and close them manually + if ( IsDisplayingDialog() ) + { + TKeyEvent key; + key.iRepeats = 0; + key.iCode = EKeyEscape; + key.iModifiers = 0; + + iCoeEnv->SimulateKeyEventL( key, EEventKey ); + // in case there is still dialog on the screen + if ( IsDisplayingDialog() ) + { + iCoeEnv->SimulateKeyEventL( key, EEventKey ); + } + } + // Shutdown the application + TApaTask task( iCoeEnv->WsSession() ); + task.SetWgId( iCoeEnv->RootWin().Identifier() ); + task.EndTask(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleFreqRangeChangedCallback +// Frequency range changed. +// Current handling is to exit the application since +// the UI specification doesn't specify how this should +// be handled. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleFreqRangeChangedCallback() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleFreqRangeChangedCallback()") ) ); + iCurrentRadioState = EFMRadioStateOff; + Exit(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleMuteCommand +// Handles mute keypress from main view +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleMuteCommand() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleMuteCommand" ) ) ); + if ( iRadioEngine->IsMuteOn() ) + { + iRadioEngine->SetMuteOn( EFalse ); + } + else + { + iRadioEngine->SetMuteOn( ETrue ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleRegionsAtStartUpL +// get region automatically from network or manually by user choice if network +// is not available +// --------------------------------------------------------------------------- +// +TFMRadioRegionSetting CFMRadioAppUi::HandleRegionsAtStartUpL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleRegionsAtStartUpL()")) ); + TFMRadioRegionSetting region = iRadioEngine->GetRegionL(); + + if ( region == EFMRadioRegionNone ) + { + ShowToolbar( EFalse ); + TInt index = 0; + + CDesCArraySeg* regionList = new( ELeave ) CDesCArraySeg( KDefaultRegionArrayGranularity ); + CleanupStack::PushL( regionList ); + + iRadioEngine->FillListWithRegionDataL( *regionList ); + + CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &index ); + + dlg->PrepareLC( R_FMRADIO_SELECT_REGION_QUERY ); + CTextListBoxModel* model = + static_cast( dlg->ListControl() )->listbox()->Model(); + model->SetItemTextArray( regionList ); + model->SetOwnershipType( ELbmDoesNotOwnItemArray ); // Array won't be deleted here + + TInt ret = dlg->RunLD(); + CleanupStack::PopAndDestroy( regionList ); + + if ( ret != EAknSoftkeyExit ) + { + // We should have a proper region selected by user + region = iRadioEngine->RegionIdAtIndex( index ); + } + + if ( region == EFMRadioRegionNone ) + { + Exit(); // This will eventually exit FMRadio. + } + else + { + HBufC* bandSetText = StringLoader::LoadLC( R_QTN_FMRADIO_CONF_FREQ_BAND_SET_MANUAL, iCoeEnv ); + CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue ); + note->ExecuteLD( *bandSetText ); + CleanupStack::PopAndDestroy( bandSetText ); + if ( AknLayoutUtils::PenEnabled() ) + { + ShowToolbar( ETrue ); + } + } + } + else + { + // Region is known + if ( region != iRadioEngine->RegionId() ) + { + TInt previousRegion = iRadioEngine->RegionId(); + + if ( previousRegion != EFMRadioRegionNone ) + { + // Show note only if the region has changed from a concrete + // one to another concrete one. EFMRadioRegionNone is not + // a concrete one (first startup case) -- don't show note. + HBufC* bandSetText = StringLoader::LoadLC( R_QTN_FMRADIO_CONF_FREQ_BAND_SET_AUTOM, iCoeEnv ); + CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); + note->ExecuteLD( *bandSetText ); + CleanupStack::PopAndDestroy( bandSetText ); + } + } + } + + return region; + } + +// --------------------------------------------------------------------------- +// From class MFMRadioGlobalConfirmationQueryObserver. Callback function +// that is called when global confirmation query is dismissed. +// CFMRadioAppUi::GlobalConfirmationQueryDismissedL +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::GlobalConfirmationQueryDismissedL(TInt aSoftKey) + { + FTRACE( FPrint( _L("CFMRadioAppUi::GlobalConfirmationQueryDismissedL()")) ); + iOfflineQueryDialogActivated = EFalse; + + if ( aSoftKey == EAknSoftkeyYes ) + { + iOfflineProfileActivatedWhenRadioAudioDisabled = EFalse; + iRadioEngine->RadioOn(); + HandlePendingViewActivationL(); + } + else + { + // Shutdown the application + TApaTask task( iCoeEnv->WsSession() ); + task.SetWgId( iCoeEnv->RootWin().Identifier() ); + task.EndTask(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::RequestTunerControl +// request tuner control from engine +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::RequestTunerControl() const + { + FTRACE( FPrint( _L("CFMRadioAppUi::RequestTunerControl()")) ); + iRadioEngine->RequestTunerControl(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::NumberOfChannelsStored +// return number of channels saved to the presets +// --------------------------------------------------------------------------- +// +TInt CFMRadioAppUi::NumberOfChannelsStored() const + { + FTRACE( FPrint( _L("CFMRadioAppUi::NumberOfChannelsStored()")) ); + return iChannels->Count(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleStartupWizard +// Determine if "Scan all channels" in scan local stations view should be started. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleStartupWizardL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleStartupWizardL()")) ); + if ( !IsStartupWizardHandled() ) + { + // Call to iRadioEngine->UpdatedStartupCount() + // increases startup count by one and returns amount of app startups. + TInt startupCount = iRadioEngine->UpdatedStartupCount(); + if ( startupCount <= KMaxStartupTimesToAskSaveWizard && + NumberOfChannelsStored() == 0 ) + { + SetStartupWizardRunning( ETrue ); + ActivateLocalViewL( iScanLocalStationsView->Id() ); + } + else // check IAD update here + { + HandleIADUpdateCheckL(); + } + } + } + +// -------------------------------------------------------------------------- +// CFMRadioAppUi::IsStartupWizardRunning +// Return startup scanning wizard status. +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsStartupWizardRunning() const + { + return iStartupWizardRunning; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::SetStartupWizardRunning +// Set startup scanning wizard status. +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::SetStartupWizardRunning( const TBool aRunningState ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::SetStartupWizardRunning() - state = %d"), aRunningState) ); + iStartupWizardRunning = aRunningState; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::StartLocalStationsSeekL +// Start local stations scan +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::StartLocalStationsSeekL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::StartLocalStationsSeekL()")) ); + iCurrentRadioState = EFMRadioStateBusyScanLocalStations; + iRadioEngine->ScanUp(); + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::TryToResumeAudioL +// Show Audio Preempted query +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::TryToResumeAudioL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::TryToResumeAudioL" ) ) ); + TFMRadioRegionSetting region = iRadioEngine->GetRegionL(); + if ( iAudioLost && + IsForeground() && + !iOfflineQueryDialogActivated && + region != EFMRadioRegionNone ) + { + iAudioLost = EFalse; + iRadioEngine->InitializeRadio(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ShowConnectHeadsetDialogL +// Show connect headset query with only exit softkey +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ShowConnectHeadsetDialogL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ShowConnectHeadsetDialogL" ) ) ); + if ( !iConnectHeadsetQuery && !iConnectHeadsetGlobalNote ) + { + HBufC* noteTxt = StringLoader::LoadLC( R_QTN_FMRADIO_ERROR_CON_HEADSET, iCoeEnv ); + + // if radio is in background, show also global note + if ( !IsForeground() ) + { + iConnectHeadsetGlobalNote = CAknGlobalNote::NewL(); + iConnectHeadsetGlobalNote->ShowNoteL( EAknGlobalInformationNote, *noteTxt ); + delete iConnectHeadsetGlobalNote; + iConnectHeadsetGlobalNote = NULL; + } + + iConnectHeadsetQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); + TInt ret = iConnectHeadsetQuery->ExecuteLD( R_FMRADIO_CONNECT_HEADSET_NOTE, *noteTxt ); + + CleanupStack::PopAndDestroy( noteTxt ); + + if ( iConnectHeadsetQuery ) + { + iConnectHeadsetQuery = NULL; + if ( ret == EAknSoftkeyExit ) + { + TApaTask task( iCoeEnv->WsSession() ); + task.SetWgId( iCoeEnv->RootWin().Identifier() ); + task.EndTask(); + } + else + { + HandlePendingViewActivationL(); + } + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ShowVolumePopupL +// Show currently active volume popup +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ShowVolumePopupL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::ShowVolumePopupL" ) ) ); + if ( !iRadioEngine->IsInCall() ) + { + if ( iActiveVolumePopupControl ) + { + if ( IsForeground() || ( IsActiveIdleEnabled() && IsIdleAppForeground() ) ) + { + iActiveVolumePopupControl->ShowVolumePopupL(); + } + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::GetCurrentHelpContext +// get help context based on currently active view +// --------------------------------------------------------------------------- +// +CArrayFix* CFMRadioAppUi::GetCurrentHelpContextL() const + { + FTRACE( FPrint( _L("CFMRadioAppUi::GetCurrentHelpContextL" ) ) ); +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE + // currently main container and manual tuning container are derived from CBase + // so lets create help array manually for them + CArrayFixFlat* helpArray = new( ELeave ) + CArrayFixFlat( 1 ); + CleanupStack::PushL( helpArray ); + helpArray->AppendL( TCoeHelpContext( TUid::Uid( KUidFMRadioApplication ), KFMRADIO_HLP_MAIN ) ); + CleanupStack::Pop( helpArray ); + return helpArray; +#else + return AppHelpContextL(); +#endif +} + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::GetChannelsArrayL +// Get channels array list from radio engine +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::GetChannelsArrayL() + { + FTRACE( FPrint( _L("CFMRadioChannelListView::GetChannelsArrayL Start") ) ); + + // Note: KMaxNumberOfChannelListItems can be setted to any supported max value + for ( TInt index = 0; index < KMaxNumberOfChannelListItems; index++ ) + { + TChannelInformation channelinfo; + + iRadioEngine->GetPresetNameAndFrequencyL( index, + channelinfo.iChannelInformation, + channelinfo.iChannelFrequency ); + + if ( channelinfo.iChannelFrequency != KErrNotFound ) + { + FTRACE( FPrint( _L("CFMRadioChannelListView::ChannelInUse inside if") ) ); + iChannels->AppendL( channelinfo ); + } + } + } + +// --------------------------------------------------------------------------- +// From class CEikAppUi. +// Handles window server messages. +// --------------------------------------------------------------------------- +// +MCoeMessageObserver::TMessageResponse CFMRadioAppUi::HandleMessageL( + TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid, + const TDesC8& aMessageParameters ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio-- CFMRadioAppUi::HandleMessageL" ))); + + TMessageResponse resp = CAknViewAppUi::HandleMessageL( + aClientHandleOfTargetWindowGroup, aMessageUid, aMessageParameters ); + + if ( resp == EMessageNotHandled && aMessageUid == TUid::Uid( KUidFMRadioApplication ) ) + { + ProcessCommandTailL( aMessageParameters ); + resp = EMessageHandled; + } + + return resp; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ProcessCommandParametersL +// Processes the shell commands +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::ProcessCommandParametersL( TApaCommand aCommand, + TFileName& aDocumentName, + const TDesC8& aTail ) + { + FTRACE(FPrint(_L("CFMRadioAppUi::ProcessCommandParametersL(%d, %S)" ), aCommand, &aTail )); + SecondaryConstructL(); + + TBool ret = CAknViewAppUi::ProcessCommandParametersL( aCommand, aDocumentName, aTail ); + ProcessCommandTailL( aTail ); + + return ret; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::ProcessCommandParametersL +// Processes the command tail in any situation +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::ProcessCommandTailL( const TDesC8& aTail ) + { + TLex8 tailLex( aTail ); + if ( tailLex.Peek() != 0 ) + { + TPtrC8 command = tailLex.NextToken(); + if ( command == KFMRadioCommandFrequency ) + { + // tune to frequency + TLex8 frequencyLex( tailLex.NextToken() ); + TInt32 frequency = 0; + TInt min = 0; + TInt max = 0; + iRadioEngine->GetFrequencyBandRange( min, max ); + TInt ret = frequencyLex.BoundedVal( frequency, max ); + if ( ret == KErrNone && frequency >= min ) + { + iRadioEngine->CancelScan(); + TuneL( frequency ); + } + } + else if ( command == KFMRadioCommandStationIndex ) + { + // tune to station index + TLex8 indexLex( tailLex.NextToken() ); + TInt32 index = 0; + TInt ret = indexLex.BoundedVal( index, iChannels->Count() - 1 ); + if ( ret == KErrNone && index >= 0 ) + { + iRadioEngine->CancelScan(); + PlayChannel( index ); + } + } + else if( command == KFMRadioCommandActivateView ) + { + TLex8 viewIdLex( tailLex.NextToken() ); + TInt viewId = 0; + TInt ret = viewIdLex.Val( viewId ); + if ( ret == KErrNone ) + { + TUid uid = TUid::Uid( viewId ); + CAknView* view = View( uid ); + // Currently this API supports only activating main view or channel list view + if ( view && ( uid == KFMRadioMainViewId || uid == KFMRadioChannelListViewId ) ) + { + if ( iStartUp ) + { + SetDefaultViewL( *view ); + } + else + { + TFMRadioRegionSetting region = iRadioEngine->GetRegionL(); + + if ( iOfflineQueryDialogActivated || + iConnectHeadsetQuery || + region == EFMRadioRegionNone ) + { + iPendingViewId = view->Id(); + } + else + { + iChannelListView->CancelMoveL(); + ActivateLocalViewL( view->Id() ); + } + TApaTask task( iCoeEnv->WsSession() ); + task.SetWgId( iCoeEnv->RootWin().Identifier() ); + task.BringToForeground(); + } + } + } + } + else + { + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::Channels +// Returns channels array +// --------------------------------------------------------------------------- +// +CArrayFixFlat* CFMRadioAppUi::Channels() + { + return iChannels; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::HandleIADUpdateCheckL +// Initialize software update check using IAD api +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::HandleIADUpdateCheckL() + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleIADUpdateCheckL") ) ); + if ( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::HandleIADUpdateCheckL - KFeatureIdIAUpdate supported") ) ); + TRAPD( err, iUpdate = CIAUpdate::NewL( *this ) ) + if ( err && err != KErrNotSupported ) + { + User::Leave( err ); + } + if ( !err ) + { + iParameters = CIAUpdateParameters::NewL(); + // Use SIS package UID + iParameters->SetUid( TUid::Uid( KUidFMRadioApplication ) ); + iUpdate->CheckUpdates( *iParameters ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::CheckUpdatesComplete +// from base class MIAUpdateObserver +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::CheckUpdatesComplete(%d, %d)"), aErrorCode, aAvailableUpdates ) ); + if ( aErrorCode == KErrNone ) + { + if ( aAvailableUpdates > 0 ) + { + // There were some updates available. Let's ask if the user wants to update them. + iUpdate->UpdateQuery(); + } + else + { + // No updates available. CIAUpdate object could be deleted already now, since we are not + // going to call anything else from the API. This will also close down the IAUpdate server. + delete iUpdate; + iUpdate = NULL; + delete iParameters; + iParameters = NULL; + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::UpdateComplete +// from base class MIAUpdateObserver +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::UpdateComplete( TInt FDEBUGVAR( aErrorCode ), CIAUpdateResult* aResultDetails ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::UpdateComplete(%d)"), aErrorCode ) ); + // The update process that the user started from IAUpdate UI is now completed. + // If the client application itself was updated in the update process, this callback + // is never called, since the client is not running anymore. + + delete aResultDetails; // Ownership was transferred, so this must be deleted by the client + + // We do not need the client-server session anymore, let's delete the object to close the session + delete iUpdate; + iUpdate = NULL; + delete iParameters; + iParameters = NULL; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::UpdateQueryComplete +// from base class MIAUpdateObserver +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::UpdateQueryComplete(%d, %d)"), aErrorCode, aUpdateNow ) ); + if ( aErrorCode == KErrNone ) + { + if ( aUpdateNow ) + { + // User choosed to update now, so let's launch the IAUpdate UI. + iUpdate->ShowUpdates( *iParameters ); + } + else + { + // The answer was 'Later'. CIAUpdate object could be deleted already now, since we are not + // going to call anything else from the API. This will also close down the IAUpdate server. + delete iUpdate; + iUpdate = NULL; + delete iParameters; + iParameters = NULL; + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::AutoTuneInMainView +// Set autotune true, if scan is interrupted +// --------------------------------------------------------------------------- +// +void CFMRadioAppUi::AutoTuneInMainView ( TBool aTune ) + { + FTRACE( FPrint( _L("CFMRadioAppUi::AutoTuneInMainView()"))); + iAutoTune = aTune; + } + +// --------------------------------------------------------------------------- +// CFMRadioAppUi::IsStartupWizardHandled +// --------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsStartupWizardHandled() const + { + return iStartupWizardHandled; + } + +// ----------------------------------------------------------------------------- +// Check if Active Idle app is on foreground +// ----------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsIdleAppForeground() + { + FTRACE( FPrint( _L( "CFMRadioAppUi::IsIdleAppForeground" ) ) ); + TBool isIdleActive( EFalse ); + // Gets the window group id of the app in foreground + RWsSession& wsSession = iCoeEnv->Static()->WsSession(); + TInt windowGroupId = wsSession.GetFocusWindowGroup(); + if ( windowGroupId >= 0 ) + { + TRAP_IGNORE( + { + CApaWindowGroupName* wgName = CApaWindowGroupName::NewL( + wsSession, windowGroupId ); + + isIdleActive = ( wgName->AppUid() == KFMRadioUidIdleApp ); + delete wgName; + } ); + } + + return isIdleActive; + } + +// ----------------------------------------------------------------------------- +// Check if Active Idle is enabled +// ----------------------------------------------------------------------------- +// +TBool CFMRadioAppUi::IsActiveIdleEnabled() + { + FTRACE( FPrint( _L( "CFMRadioAppUi::IsActiveIdleEnabled" ) ) ); + TBool res( EFalse ); + +#ifdef __ACTIVE_IDLE + if (! FeatureManager::FeatureSupported( KFeatureIdActiveIdle ) ) + return EFalse; +#endif + if ( !iSettingsRepository ) + { + TRAP_IGNORE( + { + iSettingsRepository = CRepository::NewL( + KCRUidPersonalizationSettings ); + } ); + } + + if ( iSettingsRepository ) + { + TInt value( 0 ); + TInt err( iSettingsRepository->Get( KSettingsActiveIdleState, value ) ); + if ( !err && value ) + { + res = ETrue; + } + } + return res; + } + +// --------------------------------------------------------- +// CFMRadioAppUi::MatchingChannel +// Return the index of the first channel that matches the +// frequency specified. +// --------------------------------------------------------- +// +TInt CFMRadioAppUi::MatchingChannelL( TInt aFrequency ) + { + TInt channelIndex = KErrNotFound; + TInt numberOfChannels = iChannels->Count(); + + for ( TInt i = 0; i < numberOfChannels; i++ ) + { + TInt presetFrequency = iChannels->At( i ).iChannelFrequency; + + if ( aFrequency == presetFrequency ) + { + channelIndex = i; + break; + } + } + FTRACE(FPrint(_L("CFMRadioAppUi::MatchingChannel i[%d] aFrequency[%d]"), channelIndex, aFrequency)); + return channelIndex; + } + +// --------------------------------------------------------- +// CFMRadioAppUi::HandlePendingViewActivationL +// Activates the view that is pending +// --------------------------------------------------------- +// +void CFMRadioAppUi::HandlePendingViewActivationL() + { + if ( iPendingViewId != TUid::Null() ) + { + ActivateLocalViewL( iPendingViewId ); + iPendingViewId == TUid::Null(); + } + } + +// --------------------------------------------------------- +// CFMRadioAppUi::ActiveVolumePopup +// --------------------------------------------------------- +// +CAknVolumePopup* CFMRadioAppUi::ActiveVolumePopup() const + { + return iActiveVolumePopupControl; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiobacksteppingservicewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiobacksteppingservicewrapper.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,275 @@ +/* +* 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 the Back Stepping Service wrapper +* +*/ + +#include +#include +#include + +#include "fmradiobacksteppingservicewrapper.h" + +_LIT8( KFMRadioBackSteppingPrefix, "FMRADIOBS" ); + +// BS Service implementation UID +//const TInt KBSServiceImplUid( 0x2000F840 ); + +// BS Service and Interface ID +_LIT8( KFMRadioBSServiceID, "Service.BackStepping" ); +_LIT8( KFMRadioBSInterface, "IBackStepping" ); + +// BS commands +_LIT8( KFMRadioBSCmdInitialize, "Initialize" ); +_LIT8( KFMRadioBSCmdForwardActivationEvent, "ForwardActivationEvent" ); +_LIT8( KFMRadioBSCmdHandleBackCommand, "HandleBackCommand" ); + +// BS in param names +_LIT8( KFMRadioBSInParamAppUid, "AppUid" ); +_LIT8( KFMRadioBSInParamState, "State" ); +_LIT8( KFMRadioBSInParamEnter, "Enter" ); + +// BS out param names +_LIT8( KFMRadioBSOutParamStatusInfo, "StatusInfo" ); + +// ======== MEMBER FUNCTIONS ================================================= + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::NewL +// --------------------------------------------------------------------------- +// +CFMRadioBackSteppingServiceWrapper* CFMRadioBackSteppingServiceWrapper::NewL( TUid aUid ) + { + CFMRadioBackSteppingServiceWrapper* self = new( ELeave ) CFMRadioBackSteppingServiceWrapper; + CleanupStack::PushL( self ); + self->ConstructL( aUid ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::CFMRadioBackSteppingServiceWrapper +// --------------------------------------------------------------------------- +// +CFMRadioBackSteppingServiceWrapper::CFMRadioBackSteppingServiceWrapper() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioBackSteppingServiceWrapper::ConstructL( TUid aUid ) + { + // Create Service Handler and keep as long as access to BS Service needed. + iServiceHandler = CLiwServiceHandler::NewL(); + // For convenience keep pointers to Service Handler param lists. + iInParamList = &iServiceHandler->InParamListL(); + iOutParamList = &iServiceHandler->OutParamListL(); + + // Create AIW criteria. + RCriteriaArray criteriaArray; + CleanupResetAndDestroyPushL( criteriaArray ); + CLiwCriteriaItem* criterion = CLiwCriteriaItem::NewLC( + KLiwCmdAsStr, + KFMRadioBSInterface, + KFMRadioBSServiceID ); + criterion->SetServiceClass( TUid::Uid( KLiwClassBase ) ); + criteriaArray.AppendL( criterion ); + CleanupStack::Pop( criterion ); + + // Attach AIW criteria. + iServiceHandler->AttachL( criteriaArray ); + // Get BS Service interface. + iServiceHandler->ExecuteServiceCmdL( *criterion, *iInParamList, *iOutParamList ); + CleanupStack::PopAndDestroy( &criteriaArray ); + + // Check if BS interface can be found from output params. + TInt pos( 0 ); + iOutParamList->FindFirst( pos, KFMRadioBSInterface ); + if( KErrNotFound != pos ) + { + // Extract BS interface from output params. + iBsInterface = ( *iOutParamList )[pos].Value().AsInterface(); + } + + // Initialize BS Service. + InitializeL( aUid ); + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::~CFMRadioBackSteppingServiceWrapper +// --------------------------------------------------------------------------- +// +CFMRadioBackSteppingServiceWrapper::~CFMRadioBackSteppingServiceWrapper() + { + if ( iBsInterface ) + { + iBsInterface->Close(); + } + if ( iServiceHandler ) + { + delete iServiceHandler; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::HandleViewActivationEventL +// --------------------------------------------------------------------------- +// +void CFMRadioBackSteppingServiceWrapper::HandleViewActivationEventL( const TVwsViewId aViewId, + TBool aEnter ) + { + if ( iBsInterface ) + { + // Make Service Handler param lists. + iInParamList->Reset(); + iOutParamList->Reset(); + + RBuf8 buffer; + CleanupClosePushL( buffer ); + buffer.CreateL( KFMRadioBackSteppingPrefix().Length() + KDefaultRealWidth ); + buffer.Copy( KFMRadioBackSteppingPrefix ); + // Convert 32-bit signed integer (TInt32) view uid to TInt. + TInt64 viewUid = static_cast< TInt64 >( aViewId.iViewUid.iUid ); + buffer.AppendNum( viewUid ); + + TLiwGenericParam state( KFMRadioBSInParamState, TLiwVariant( buffer ) ); + iInParamList->AppendL( state ); + TLiwGenericParam enter( KFMRadioBSInParamEnter, TLiwVariant( aEnter ) ); + iInParamList->AppendL( enter ); + + // Execute view activation event. + iBsInterface->ExecuteCmdL( KFMRadioBSCmdForwardActivationEvent, *iInParamList, *iOutParamList ); + CleanupStack::PopAndDestroy(); + + // Check if BS Service consumed the event. + HandleResultL(); + + iInParamList->Reset(); + iOutParamList->Reset(); + } + } + + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::HandleBackCommandL +// --------------------------------------------------------------------------- +// +TBool CFMRadioBackSteppingServiceWrapper::HandleBackCommandL( const TVwsViewId aViewId ) + { + TBool retVal = EFalse; + if ( iBsInterface ) + { + // Make Service Handler param lists. + iInParamList->Reset(); + iOutParamList->Reset(); + + // Create message for back stepping wrapper to handle back command event. + RBuf8 buffer; + CleanupClosePushL( buffer ); + buffer.CreateL( KFMRadioBackSteppingPrefix().Length() + KDefaultRealWidth ); + buffer.Copy( KFMRadioBackSteppingPrefix ); + // Convert 32-bit signed integer (TInt32) view uid to TInt64. + TInt64 viewUid = static_cast< TInt64 >( aViewId.iViewUid.iUid ); + buffer.AppendNum( viewUid ); + + TLiwGenericParam state( KFMRadioBSInParamState, TLiwVariant( buffer ) ); + iInParamList->AppendL( state ); + + // Execute back event. + iBsInterface->ExecuteCmdL( KFMRadioBSCmdHandleBackCommand, *iInParamList, *iOutParamList ); + CleanupStack::PopAndDestroy(); + + // Check if BS Service consumes the event. + retVal = HandleResultL(); + + iInParamList->Reset(); + iOutParamList->Reset(); + } + + return retVal; + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::InitializeL +// --------------------------------------------------------------------------- +// +void CFMRadioBackSteppingServiceWrapper::InitializeL( const TUid aUid ) + { + if ( iBsInterface ) + { + // Initialize BS Service. + iInParamList->Reset(); + iOutParamList->Reset(); + + TLiwGenericParam appUid( KFMRadioBSInParamAppUid, TLiwVariant( aUid.iUid ) ); + iInParamList->AppendL( appUid ); + + iBsInterface->ExecuteCmdL( KFMRadioBSCmdInitialize, *iInParamList, *iOutParamList ); + + if ( !HandleResultL() ) + { + // Initialize command was not consumed. + User::Leave( KErrArgument ); + } + + iInParamList->Reset(); + iOutParamList->Reset(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::HandleResultL +// --------------------------------------------------------------------------- +// +TInt CFMRadioBackSteppingServiceWrapper::HandleResultL() + { + TBool retVal( EFalse ); + // Check if error can be found from outparams. + TInt posErr( 0 ); + iOutParamList->FindFirst( posErr, LIW::EGenericParamError ); + if( KErrNotFound != posErr ) + { + // Error code found - extract and handle + TInt errorCode( KErrNone ); + ( *iOutParamList )[posErr].Value().Get( errorCode ); + User::LeaveIfError( errorCode ); + } + // No errors found. Check if status info can be found from outparams. + TInt posStat( 0 ); + iOutParamList->FindFirst( posStat, KFMRadioBSOutParamStatusInfo ); + if( KErrNotFound != posStat ) + { + // Status info present - extract. + ( *iOutParamList )[posStat].Value().Get( retVal ); + } + else + { + // No status info found. + User::Leave( KErrNotFound ); + } + return retVal; + } + +// --------------------------------------------------------------------------- +// CFMRadioBackSteppingServiceWrapper::HandleViewActivation +// --------------------------------------------------------------------------- +// +void CFMRadioBackSteppingServiceWrapper::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, + const TVwsViewId& /*aViewIdToBeDeactivated*/ ) + { + TRAP_IGNORE( HandleViewActivationEventL( aNewlyActivatedViewId, ETrue ) ) + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiochannellistcontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiochannellistcontainer.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,973 @@ +/* +* 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 of the class CFMRadioChannelListContainer +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE +#include "radio.hlp.hrh" +#endif +#include +#include +#include +#include +#include + +#include "fmradioappui.h" +#include "fmradiochannellistcontainer.h" +#include "fmradiochannellistview.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + + +// ---------------------------------------------------------------------------- +// CFMRadioChannelListContainer::CFMRadioChannelListContainer +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioChannelListContainer::CFMRadioChannelListContainer( + CRadioEngine& aRadioEngine, + MChannelListHandler& aObserver ) : + iRadioEngine( aRadioEngine ), + iObserver( aObserver ) + + { + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::NewL +// Two-phase constructor of CFMRadioChannelListContainer +// --------------------------------------------------------- +// +CFMRadioChannelListContainer* CFMRadioChannelListContainer::NewL( const TRect& aRect, + CRadioEngine& aRadioEngine, MChannelListHandler& aObserver ) + { + CFMRadioChannelListContainer* self = new (ELeave) CFMRadioChannelListContainer( aRadioEngine, + aObserver ); + CleanupStack::PushL( self ); + self->ConstructL( aRect ); + CleanupStack::Pop( self ); + return self; + } + +// +// ---------------------------------------------------- +// CFMRadioChannelListContainer::ConstructL +// EPOC two phased constructor +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::ConstructL( const TRect& aRect ) + { + CreateWindowL(); + CAknIconArray* radioTypeIcons = NULL; + + radioTypeIcons = new( ELeave ) CAknIconArray( 2 ); + CleanupStack::PushL( radioTypeIcons ); + + radioTypeIcons->AppendFromResourceL( R_FMRADIO_CHANNEL_LIST_ICON_ARRAY ); + + // Instantiate a listbox for the channel list + iChannelList = new ( ELeave ) CAknDoubleNumberStyleListBox(); + iControls.Append( iChannelList ); + iChannelList->SetContainerWindowL( *this ); + iChannelList->SetListBoxObserver( this ); + iChannelList->ConstructL( this, CEikListBox::ELoopScrolling | EAknListBoxSelectionList ); // Looped list + iChannelList->SetRect( aRect ); // Set boundaries for listbox + // Create scrollbars + iChannelList->CreateScrollBarFrameL( ETrue ); + iChannelList->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); + HBufC* emptyString = NULL; + emptyString = StringLoader::LoadLC( R_QTN_FMRADIO_LIST_NO_STATIONS, iEikonEnv ); + + iChannelList->View()->SetListEmptyTextL( *emptyString ); + CleanupStack::PopAndDestroy( emptyString ); + + // The following line really takes the ownership -- must be the last item + // there, as if leaves and the object is in cleanupstack, problems arise. + // (Cleanup stack corruption!) + // Set the icon array for this list. List takes ownership of the array. + iChannelList->ItemDrawer()->FormattedCellData()->SetIconArrayL( radioTypeIcons ); + CleanupStack::Pop( radioTypeIcons ); + + // Array for channels + iChannelItemArray = new( ELeave ) CDesCArrayFlat( KMaxNumberOfChannelListItems ); + InitializeChannelListL(); + SetRect( aRect ); // Set its rectangle + + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + iChannelView = static_cast ( appUi->View( KFMRadioChannelListViewId ) ); + + ActivateL(); + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::~CFMRadioChannelListContainer +// Class destructor +// ---------------------------------------------------- +// +CFMRadioChannelListContainer::~CFMRadioChannelListContainer() + { + iControls.ResetAndDestroy(); + delete iChannelItemArray; + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::InitializeChannelListL +// Create the channel list (initially all spots are set as empty) +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::InitializeChannelListL() + { + TBuf textChannelItem; + textChannelItem.SetLength( 0 ); + + // Pass the array to the listbox model and set the ownership type + iChannelList->Model()->SetItemTextArray( (MDesCArray*)iChannelItemArray ); + iChannelList->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); + iChannelList->HandleItemAdditionL(); + DrawDeferred(); + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::UpdateChannelListContentL +// Update the content of the channel at aIndex with the +// values specified +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::UpdateChannelListContentL( TInt aIndex, const TDesC& aChannelName, TInt aChannelFrequency ) + { + TBuf textChannelItem; + TBuf textChIndex; + TBuf textChIconIndex; + + textChIndex.Format( KChIndexFormatChList, aIndex+1 ); // One over index + + textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList ); + + //Update to display Devnagari numbers for Text Index. + AknTextUtils::LanguageSpecificNumberConversion( textChIndex ); + // + textChannelItem.Append( textChIndex ); + textChannelItem.Append( KColumnListSeparator ); + textChannelItem.Append( aChannelName ); + textChannelItem.Append( KColumnListSeparator ); + + if ( aChannelFrequency ) + { + TReal frequency = static_cast( aChannelFrequency / static_cast( KHzConversionFactor )); + // Gets locale decimal separator automatically + TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() ); + TBuf<30> frequencyString; + frequencyString.Num( frequency, format ); + + HBufC* stringHolder = StringLoader::LoadLC( R_QTN_FMRADIO_DOUBLE2_FREQ, frequencyString, iEikonEnv ); + //Update for display of Hindi Devnagari Numbers + TPtr textItem2 = stringHolder->Des(); + AknTextUtils::LanguageSpecificNumberConversion(textItem2); + textChannelItem.Append( textItem2 ); + CleanupStack::PopAndDestroy( stringHolder ); + } + + // Set 'Now Playing' icon to the channel item + textChannelItem.Append( KColumnListSeparator ); + + if ( iRadioEngine.GetPresetIndex() == aIndex ) + { + textChannelItem.Append( textChIconIndex ); + } + + if( iChannelItemArray->Count() > 0 ) + { + iChannelItemArray->Delete( aIndex ); + iChannelList->HandleItemRemovalL(); + iChannelItemArray->InsertL( aIndex, textChannelItem ); + //iChannelItemArray->AppendL( textChannelItem ); + + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + } + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::RemoveChannelL +// Removes channel from container list +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::RemoveChannelL( TInt aIndex ) + { + if ( iChannelItemArray->Count() > 0 ) + { + TInt presetIndex = iRadioEngine.GetPresetIndex(); + + iChannelItemArray->Delete( aIndex ); + iChannelList->HandleItemRemovalL(); + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + + if ( iChannelItemArray->Count() > 0 ) + { + ReIndexAllL(); + + if ( presetIndex > aIndex ) + { + // update engine settings also + iRadioEngine.SetCurrentPresetIndex( presetIndex - 1 ); + UpdateItemIconL( presetIndex - 1, KNowPlayingIconIndexChList ); + } + else if ( presetIndex == aIndex ) + { + iRadioEngine.TunePresetL( 0 ); + UpdateItemIconL( 0, KNowPlayingIconIndexChList ); + } + else + { + // NOP + } + iChannelList->SetCurrentItemIndex( 0 ); + } + else + { + // The last item was deleted, tune to current frequency, out of preset mode + iRadioEngine.Tune( iRadioEngine.GetTunedFrequency(), CRadioEngine::ERadioTunerMode ); + } + } + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::AddChannel +// Adds channels to container list +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::AddChannelL( + const TDesC& aChannelName, TInt aChannelFrequency, TBool aNowPlaying ) + { + TBuf textChannelItem; + TBuf textChIndex; + TBuf textChIconIndex; + + textChIndex.Format( KChIndexFormatChList, iChannelItemArray->Count()+1 ); // One over index + + if ( !AknLayoutUtils::PenEnabled() ) + { + textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList ) ; + } + + //Update to display Devnagari numbers for Text Index. + AknTextUtils::LanguageSpecificNumberConversion(textChIndex); + // + textChannelItem.Append( textChIndex ); + textChannelItem.Append( KColumnListSeparator ); + + TReal frequency = static_cast( aChannelFrequency / static_cast( KHzConversionFactor )); + // Gets locale decimal separator automatically + TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() ); + TBuf<30> frequencyString; + frequencyString.Num(frequency,format); + + TBool channelHasName = EFalse; + TInt resId = 0; + // if name exists, place it on the first line + if ( aChannelName.Length() > 0 ) + { + textChannelItem.Append( aChannelName ); + textChannelItem.Append( KColumnListSeparator ); + channelHasName = ETrue; + resId = R_QTN_FMRADIO_DOUBLE2_FREQ; + } + else // frequency goes to first line + { + resId = R_QTN_FMRADIO_DOUBLE1_FREQ; + } + + HBufC* stringHolder = StringLoader::LoadLC( resId, frequencyString, iEikonEnv ); + //Update for display of Hindi Devnagari Numbers + TPtr textItem2 = stringHolder->Des(); + AknTextUtils::LanguageSpecificNumberConversion(textItem2); + textChannelItem.Append( textItem2 ); + CleanupStack::PopAndDestroy( stringHolder ); + + if ( !channelHasName ) + { + // add placeholder for second line + textChannelItem.Append( KColumnListSeparator ); + } + + // Set 'Now Playing' icon to the channel item + textChannelItem.Append( KColumnListSeparator ); + + if( !AknLayoutUtils::PenEnabled() && aNowPlaying ) + { + textChannelItem.Append( textChIconIndex ); + } + + iChannelItemArray->AppendL( textChannelItem ); + + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + + } +// ---------------------------------------------------- +// CFMRadioChannelListContainer::UpdateItemIconL +// Adds icon to a list item +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::UpdateItemIconL( TInt aIndex, TInt aIconIndex ) + { + HideIconsL(); + + if ( aIndex >= 0 && aIndex < iChannelItemArray->Count() ) + { + TBuf textChIconIndex; + textChIconIndex.Format( KChIconIndexFormatChList, aIconIndex ); + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( aIndex ) ); + TPtr ptr( channelItem->Des() ); + ptr.Append( textChIconIndex ); // Add icon index + + iChannelItemArray->Delete( aIndex ); + iChannelList->HandleItemRemovalL(); + iChannelItemArray->InsertL( aIndex, *channelItem ); + CleanupStack::PopAndDestroy( channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + } + // use draw now so that view is up to date during fast channel switching + iChannelList->DrawNow(); + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::HideIconsL +// hide all icons from the list +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::HideIconsL() + { + for ( TInt index = 0 ; index < iChannelItemArray->Count(); index++ ) + { + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) ); + TPtr ptr( channelItem->Des() ); + + TBuf textChIconIndex; + TPtrC iconIndexPtr( textChIconIndex ); + TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr ); + + if ( iconIndexPtr.Length() > 0 ) + { + ptr.Delete( ptr.Length() - iconIndexPtr.Length(), iconIndexPtr.Length() ); // Remove icon index + iChannelItemArray->Delete( index ); + iChannelList->HandleItemRemovalL(); + iChannelItemArray->InsertL( index, *channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + } + CleanupStack::PopAndDestroy( channelItem ); + } + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::SetFaded +// Fades the entire window and controls in the window owned +// by this container control. +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::SetFaded( TBool aFaded ) + { + iFadeStatus = aFaded; + Window().SetFaded( aFaded, RWindowTreeNode::EFadeIncludeChildren ); + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::UpdateLastListenedChannel +// Updates channel index - the highlighted channel in the list. +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::UpdateLastListenedChannel( TInt aIndex ) + { + iLastChIndex = aIndex; + iChannelList->SetCurrentItemIndex( iLastChIndex ); + iChannelList->ScrollToMakeItemVisible( iLastChIndex ); + iChannelList->DrawDeferred(); + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::CurrentlySelectedChannel +// Returns the index of the selected channel item from the +// channel list. +// ---------------------------------------------------- +// +TInt CFMRadioChannelListContainer::CurrentlySelectedChannel() const + { + return iChannelList->CurrentItemIndex(); // Index of selected channel + } + +// ---------------------------------------------------- +// CFMRadioChannelListContainer::HandleListBoxEventL +// For handling listbox-, in this case, channel list events. +// The event equals to selecting a channel item from the list. +// ---------------------------------------------------- +// +void CFMRadioChannelListContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, + TListBoxEvent aEventType ) + { + // Check the event generated by keypress and report the event, + // Also check for Pen Enabled touch screen event + + switch ( aEventType ) + { + case EEventEnterKeyPressed: + { + ReportEventL( MCoeControlObserver::EEventStateChanged ); + break; + } + case EEventItemSingleClicked: + { + if ( iMoveAction ) + { + TouchMoveEventL( CurrentlySelectedChannel() ); + } + else + { + ReportEventL( MCoeControlObserver::EEventStateChanged ); + } + break; + } + default: + { + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CFMRadioChannelListContainer::HandleResourceChange +// ----------------------------------------------------------------------------- +// +void CFMRadioChannelListContainer::HandleResourceChange(TInt aType) + { + CCoeControl::HandleResourceChange(aType); + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + SizeChanged(); + } + } +// --------------------------------------------------------- +// CFMRadioChannelListContainer::SizeChanged +// Called by framework when the view size is changed +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::SizeChanged() + { + // The channel list fills the whole view + iChannelList->SetRect( Rect() ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::CountComponentControls +// Return the number of controls in the window owned by this container +// --------------------------------------------------------- +// +TInt CFMRadioChannelListContainer::CountComponentControls() const + { + return iControls.Count(); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::ComponentControl +// Return the control corresponding to the specified index +// --------------------------------------------------------- +// +CCoeControl* CFMRadioChannelListContainer::ComponentControl( TInt aIndex ) const + { + return STATIC_CAST( CCoeControl *,iControls[aIndex] ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::OfferKeyEventL +// Allow the channel list to process key events +// --------------------------------------------------------- +// +TKeyResponse CFMRadioChannelListContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + TKeyResponse response = EKeyWasNotConsumed; + + switch ( aKeyEvent.iCode ) + { + case EKeyLeftArrow: + case EKeyRightArrow: + { + return EKeyWasNotConsumed; + } + case EKeyUpArrow: + if ( iMoveAction ) + { + MoveUpL(); + } + else + { + response = iChannelList->OfferKeyEventL(aKeyEvent, aType); + if (response == EKeyWasConsumed) + { + ReportEventL( MCoeControlObserver::EEventRequestFocus ); + } + } + return response; + case EKeyDownArrow: + if ( iMoveAction ) + { + MoveDownL(); + } + else + { + response = iChannelList->OfferKeyEventL(aKeyEvent, aType); + if (response == EKeyWasConsumed) + { + ReportEventL( MCoeControlObserver::EEventRequestFocus ); + } + } + return response; + default: + switch ( aKeyEvent.iScanCode ) //we need to use the scan code, because we need to process the event wrt the keyUp and keyDown action + { + case EKeyboardKey1: // Timed key + case EKeyboardKey2: // Normal keys + case EKeyboardKey3: + case EKeyboardKey4: + case EKeyboardKey5: + case EKeyboardKey6: + case EKeyboardKey7: + case EKeyboardKey8: + case EKeyboardKey9: + case EKeyboardKey0: + return EKeyWasNotConsumed; + default: + break; + } + break; + } + return iChannelList->OfferKeyEventL(aKeyEvent, aType); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::Draw +// Redraw the window owned by this container +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::Draw( const TRect& aRect ) const + { + CWindowGc& gc = SystemGc(); + gc.SetPenStyle( CGraphicsContext::ENullPen ); + gc.SetBrushColor( KRgbGray ); + gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); + gc.DrawRect( aRect ); + + // Fade if needed + Window().SetFaded( iFadeStatus, RWindowTreeNode::EFadeIncludeChildren ); + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListContainer::GetHelpContext +// Gets Help +// +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListContainer::GetHelpContext(TCoeHelpContext& aContext) const + { +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE + aContext.iMajor = TUid::Uid( KUidFMRadioApplication ); + aContext.iContext = KFMRADIO_HLP_LIST; +#endif + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::FocusChanged(TDrawNow aDrawNow) +// +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::FocusChanged(TDrawNow aDrawNow) + { + CCoeControl::FocusChanged(aDrawNow); + if ( iChannelList ) + { + iChannelList->SetFocus(IsFocused(), aDrawNow); + } + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::HandlePointerEventL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) + { + // don't handle any pointer events if view is faded + if ( !iFadeStatus ) + { + CCoeControl::HandlePointerEventL( aPointerEvent ); + } + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::ActivateMove +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::ActivateMoveL() + { + + iMoveAction = ETrue; + iMoveIndex = iChannelList->CurrentItemIndex(); + iTouchMoveIndex = iMoveIndex; + UpdateItemIconL( iMoveIndex, KMoveIconIndexChList ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::TouchMoveEventL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::TouchMoveEventL( TInt aIndex ) + { + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( iTouchMoveIndex ) ); + TPtr ptr( channelItem->Des() ); + + TBuf textChIconIndex; + + TPtrC iconIndexPtr( textChIconIndex ); + + TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr ); + + iChannelItemArray->Delete( iTouchMoveIndex ); + iChannelList->HandleItemRemovalL(); + + iChannelItemArray->InsertL( aIndex, *channelItem ); + iChannelList->HandleItemAdditionL(); + iChannelList->UpdateScrollBarsL(); + iChannelList->SetCurrentItemIndex( aIndex ); + iChannelList->DrawDeferred(); + + iTouchMoveIndex = aIndex; + + CleanupStack::PopAndDestroy( channelItem ); + + ReIndexAllL(); + UpdateItemIconL( aIndex, KMoveIconIndexChList ); + iChannelView->MoveActionDoneL(); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::MoveDownL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::MoveDownL() + { + TInt index = iChannelList->CurrentItemIndex(); + TInt originalindex = index; + + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) ); + TPtr ptr( channelItem->Des() ); + + iChannelItemArray->Delete( index ); + iChannelList->HandleItemRemovalL(); + + if ( index < iChannelItemArray->Count() ) + { + index = index+1; + + TBuf channelindex; + + TPtrC indexPtr( channelindex ); + + TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr ); + + ptr.Delete( 0, indexPtr.Length() ); + + channelindex.Format( KChIndexFormatChList, index+1 ); + + AknTextUtils::LanguageSpecificNumberConversion( channelindex ); + + ptr.Insert( 0, channelindex ); + + iChannelItemArray->InsertL( index, *channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->SetCurrentItemIndex( index ); + iChannelList->DrawDeferred(); + + HBufC* origchannelItem = HBufC::NewLC( KLengthOfChannelItemString ); + origchannelItem->Des().Copy( iChannelItemArray->MdcaPoint( originalindex ) ); + TPtr origptr( origchannelItem->Des() ); + + iChannelItemArray->Delete( originalindex ); + iChannelList->HandleItemRemovalL(); + TBuf origchannelindex; + + TPtrC origindexPtr( origchannelindex ); + + TextUtils::ColumnText( origindexPtr, 0, &origptr ); + origptr.Delete( 0, origindexPtr.Length() ); + + origchannelindex.Format( KChIndexFormatChList, originalindex+1 ); + + AknTextUtils::LanguageSpecificNumberConversion( origchannelindex ); + origptr.Insert( 0, origchannelindex ); + iChannelItemArray->InsertL( originalindex, *origchannelItem ); + iChannelList->HandleItemAdditionL(); + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + + CleanupStack::PopAndDestroy( origchannelItem ); + } + else + { + index = 0; + iChannelItemArray->InsertL( index, *channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->SetCurrentItemIndex( index ); + iChannelList->DrawDeferred(); + + ReIndexAllL(); + } + + iChannelList->ScrollToMakeItemVisible( index ); + + CleanupStack::PopAndDestroy( channelItem ); + + } +// --------------------------------------------------------- +// CFMRadioChannelListContainer::MoveUpL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::MoveUpL() + { + TInt index = iChannelList->CurrentItemIndex(); + TInt originalindex = index; + + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) ); + TPtr ptr( channelItem->Des() ); + + iChannelItemArray->Delete( index ); + iChannelList->HandleItemRemovalL(); + + if ( 0 == index ) + { + index = iChannelItemArray->Count(); + + TBuf channelindex; + + TPtrC indexPtr( channelindex ); + + iChannelItemArray->InsertL( index, *channelItem ); + iChannelList->HandleItemAdditionL(); + iChannelList->UpdateScrollBarsL(); + + iChannelList->SetCurrentItemIndex( index ); + + iChannelList->DrawItem( index ); + + ReIndexAllL(); + } + else + { + index = index-1; + + TBuf channelindex; + + TPtrC indexPtr( channelindex ); + + TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr ); + + ptr.Delete( 0, indexPtr.Length() ); + + channelindex.Format( KChIndexFormatChList, index+1 ); + + AknTextUtils::LanguageSpecificNumberConversion( channelindex ); + ptr.Insert( 0, channelindex ); // Remove icon index + + iChannelItemArray->InsertL( index, *channelItem ); + iChannelList->SetCurrentItemIndex( index ); + iChannelList->HandleItemAdditionL(); + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawItem( index ); + + HBufC* origchannelItem = HBufC::NewLC( KLengthOfChannelItemString ); + origchannelItem->Des().Copy( iChannelItemArray->MdcaPoint( originalindex ) ); + TPtr origptr( origchannelItem->Des() ); + + iChannelItemArray->Delete( originalindex ); + iChannelList->HandleItemRemovalL(); + TBuf origchannelindex; + + TPtrC origindexPtr( origchannelindex ); + + TextUtils::ColumnText( origindexPtr, 0, &origptr ); + + origptr.Delete( 0, origindexPtr.Length() ); + + origchannelindex.Format( KChIndexFormatChList, originalindex+1 ); + + AknTextUtils::LanguageSpecificNumberConversion( origchannelindex ); + origptr.Insert( 0, origchannelindex ); + + iChannelItemArray->InsertL( originalindex, *origchannelItem ); + iChannelList->HandleItemAdditionL(); + iChannelList->DrawDeferred(); + + iChannelList->UpdateScrollBarsL(); + + CleanupStack::PopAndDestroy( origchannelItem ); + } + + iChannelList->ScrollToMakeItemVisible( index ); + + CleanupStack::PopAndDestroy( channelItem ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::ReIndexAllL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::ReIndexAllL() + { + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + + for ( TInt index = 0; index < iChannelItemArray->Count(); index++ ) + { + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) ); + TPtr ptr( channelItem->Des() ); + + iChannelItemArray->Delete( index ); + iChannelList->HandleItemRemovalL(); + + TBuf channelindex; + + TPtrC indexPtr( channelindex ); + + TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr ); + + ptr.Delete( 0, indexPtr.Length() ); + + channelindex.Format( KChIndexFormatChList, index+1 ); + + AknTextUtils::LanguageSpecificNumberConversion( channelindex ); + + ptr.Insert( 0, channelindex ); // Remove icon index + + iChannelItemArray->InsertL( index, *channelItem ); + + iChannelList->HandleItemAdditionL(); + iChannelList->DrawDeferred(); + iChannelList->UpdateScrollBarsL(); + } + + CleanupStack::PopAndDestroy( channelItem ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::HandleDropL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::HandleDropL() + { + iMoveAction = EFalse; + + if ( iMoveIndex != iChannelList->CurrentItemIndex() ) + { + iObserver.UpdateChannelsL( EMoveChannels, + iMoveIndex, + iChannelList->CurrentItemIndex() ); + } + HideIconsL(); + iChannelList->DrawDeferred(); + } +// --------------------------------------------------------- +// CFMRadioChannelListContainer::MoveDoneL +// --------------------------------------------------------- +// +void CFMRadioChannelListContainer::MoveDoneL() + { + if ( iMoveAction ) + { + iMoveAction = EFalse; + } + + iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::MoveCanceledL +// --------------------------------------------------------- +// +TBool CFMRadioChannelListContainer::MoveCanceledL() + { + TBool wasmove = EFalse; + + if ( iMoveAction ) + { + iMoveAction = EFalse; + + TInt index = iChannelList->CurrentItemIndex(); + + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) ); + TPtr ptr( channelItem->Des() ); + + TBuf textChIconIndex; + TPtrC iconIndexPtr( textChIconIndex ); + TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr ); + iChannelItemArray->Delete( index ); + iChannelList->HandleItemRemovalL(); + + iChannelItemArray->InsertL( iMoveIndex, *channelItem ); + iChannelList->HandleItemAdditionL(); + iChannelList->SetCurrentItemIndex( iMoveIndex ); + CleanupStack::PopAndDestroy( channelItem ); + + iChannelList->ScrollToMakeItemVisible( index ); + HideIconsL(); + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + wasmove = ETrue; + } + + return wasmove; + } + +// --------------------------------------------------------- +// CFMRadioChannelListContainer::MoveAction() +// --------------------------------------------------------- +// +TBool CFMRadioChannelListContainer::MoveAction() + { + return iMoveAction; + + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiochannellistview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiochannellistview.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1062 @@ +/* +* 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 of the class CFMRadioChannelListView +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioengine.h" +#include "fmradio.hrh" +#include "fmradiochannellistview.h" +#include "fmradiochannellistcontainer.h" +#include "debug.h" +#include "fmradiordsreceiverbase.h" +#include "fmradiopubsub.h" +#include "fmradiofrequencyquerydialog.h" +#include "fmradioappui.h" + +const TInt KMSKControlID(3); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::NewL +// Two-phase constructor of CFMRadioChannelListView +// --------------------------------------------------------------------------- +// +CFMRadioChannelListView* CFMRadioChannelListView::NewL( + CRadioEngine* aRadioEngine, MChannelListHandler& aObserver ) + { + CFMRadioChannelListView* self = new ( ELeave ) CFMRadioChannelListView( aObserver ); + CleanupStack::PushL(self); + self->ConstructL(aRadioEngine); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::CFMRadioChannelListView +// +// --------------------------------------------------------------------------- +// +CFMRadioChannelListView::CFMRadioChannelListView( MChannelListHandler& aObserver ) : + iNowPlayingIndex( KErrNotFound ), + iObserver( aObserver ) + { + } +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::ConstructL +// EPOC two-phased constructor +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::ConstructL( + CRadioEngine* aRadioEngine) + { + iRadioEngine = aRadioEngine; + BaseConstructL( R_FMRADIO_CH_LIST_VIEW ); + PrepareToolbar(); + + if ( !AknLayoutUtils::PenEnabled() ) + { + iToolbar->SetToolbarVisibility( EFalse ); + } + + //called here to ensure that empty channels are named in the way we want them to be. + InitializeChannelsL(); + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::~CFMRadioChannelListView +// Class destructor +// --------------------------------------------------------------------------- +// +CFMRadioChannelListView::~CFMRadioChannelListView() + { + if ( iContainer ) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + } + delete iContainer; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::Id +// Return the unique identifier corresponding to this view +// --------------------------------------------------------------------------- +// +TUid CFMRadioChannelListView::Id() const + { + return KFMRadioChannelListViewId; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::DoActivateL +// Activate the channel list view +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + FTRACE( FPrint( _L("CFMRadioChannelListView::DoActivateL Start") ) ); + + iRadioEngine->RdsReceiver().AddObserver(this); + + iFirstMoveDone = ETrue; + + SetTitleL( R_FMRADIO_STATIONS_VIEW_TITLE ); + + if ( !iContainer ) + { + FTRACE( FPrint( _L("CFMRadioChannelListView::DoActivateL inside second, not iContainer if") ) ); + iContainer = CFMRadioChannelListContainer::NewL( ClientRect(), *iRadioEngine, iObserver ); + iContainer->SetMopParent( this ); + iContainer->SetObserver( this ); + AppUi()->AddToStackL( *this, iContainer ); + } + + InitializeChannelsL(); + + FadeAndShowExit( iFaded ); + + AppUi()->HandleCommandL( EFMRadioCmdChannelListViewActive ); + + UpdateMiddleSoftKeyL(); + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::HandleCommandL +// Interprets view's menu,softkey and other commands and acts +// accordingly by calling the appropriate command handler +// function for further action. +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::HandleCommandL( TInt aCommand ) + { + CFMRadioAppUi* appUi = static_cast( AppUi() ); + switch ( aCommand ) + { + case EFMRadioCmdMove: + { + MoveCurrentItemIndexL(); + break; + } + case EFMRadioCmdDone: + { + iMoveMode = EFalse; + iFirstMoveDone = ETrue; + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); + + UpdateMiddleSoftKeyL(); + + iContainer->MoveDoneL(); + TInt currentIndex = 0; + currentIndex = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); + if ( currentIndex != KErrNotFound ) + { + iRadioEngine->SetCurrentPresetIndex( currentIndex ); + SetNowPlayingChannel( currentIndex ); + } + ShowToolbar( ETrue ); + break; + } + case EFMRadioCmdDrop: + { + iFirstMoveDone = EFalse; + Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_GRAP_DONE ); + iContainer->HandleDropL(); + break; + } + case EFMRadioCmdGrap: + { + if ( iFirstMoveDone ) + { + Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_DROP_CANCEL ); + } + else + { + Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_DROP_DONE ); + } + iContainer->ActivateMoveL(); + break; + } + case EAknSoftkeyBack: // Go back to the main view + { + appUi->ActivateLocalViewL( KFMRadioMainViewId ); + break; + } + case EEikBidCancel: + { + CancelMoveL(); + break; + } + case EAknSoftkeySelect: // Save a channel to the highlighted slot + { + break; + } + case EFMRadioCmdTuneManually: + { + // If manual tuning is canceled, return to previously tuned frequency. + TUint32 prevFreq = iRadioEngine->GetTunedFrequency() / KFMRadioFreqMultiplier; + TUint32 retFreq = prevFreq; + + iManualQueryDialog = CFMRadioFrequencyQueryDialog::NewL( retFreq ); + iManualQueryDialog->SetObserver( this ); + + TInt res = iManualQueryDialog->ExecuteLD( R_FMRADIO_MANUAL_TUNING_QUERY ); + + if ( res ) + { + if ( iObserver.Channels()->Count() < KMaxNumberOfChannelListItems ) + { + TInt usefreq = static_cast( retFreq * KFMRadioFreqMultiplier ); + iRadioEngine->Tune( usefreq ); + TBuf stationName; + stationName.SetLength( 0 ); + + iObserver.AddChannelToListL( stationName, usefreq ); + + iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + + iContainer->AddChannelL( stationName, usefreq, ETrue ); + + iRadioEngine->TunePresetL( iObserver.Channels()->Count()-1 ); + + TInt index = iRadioEngine->GetPresetIndex(); + + iContainer->UpdateItemIconL( index, KNowPlayingIconIndexChList ); + + iContainer->UpdateLastListenedChannel( index ); // Update index + } + else + { + // Show icon, or overwrite last item, or selected item? + CAknInformationNote* infonote = new( ELeave ) CAknInformationNote(); + + HBufC* noteText = StringLoader::LoadLC( + R_QTN_FMRADIO_LIST_QUERY_LIST_FULL, iCoeEnv ); + + + infonote->ExecuteLD( *noteText ); + + CleanupStack::PopAndDestroy( noteText ); + } + } + else //cancel pressed, return to previous frequency + { + iRadioEngine->Tune( static_cast( prevFreq * KFMRadioFreqMultiplier ) ); + } + break; + } + case EFMRadioCmdListenCh: + { + if ( !AknLayoutUtils::PenEnabled() ) + { + appUi->HandleCommandL( aCommand ); + // update msk here + UpdateMiddleSoftKeyL(); + } + if ( iMoveMode ) + { + MoveActionDoneL(); + } + break; + } + case EFMRadioToolbarButtonCmdToggleIhf: + { + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputHeadset ) + { + appUi->HandleCommandL( EFMRadioCmdActivateIhf ); + } + else + { + appUi->HandleCommandL( EFMRadioCmdDeactivateIhf ); + } + break; + } + case EFMRadioCmdErase: + { + TInt selectedIndex = CurrentlySelectedChannel(); + + if ( appUi->EraseChannelL( selectedIndex ) ) + { + if ( iContainer ) + { + iContainer->RemoveChannelL( selectedIndex ); + } + // Dim the rename and delete buttons in case the list is now empty + UpdateToolbar(); + } + break; + } + default: // Send all other commands to AppUi + { + appUi->HandleCommandL( aCommand ); + break; + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::SetLastListenedChannel +// Keep track of the last selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::SetLastListenedChannel( TInt aIndex ) + { + iChIndex = aIndex; + if ( iContainer && !iMoveMode ) + { + iContainer->UpdateLastListenedChannel( aIndex ); // Update index + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::SetNowPlayingChannel +// Keep track of the current selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::SetNowPlayingChannel( TInt aChannelIndex ) + { + iNowPlayingIndex = aChannelIndex; + + if ( iContainer && !iMoveMode ) + { + TRAP_IGNORE( iContainer->UpdateItemIconL( aChannelIndex, KNowPlayingIconIndexChList ) ) + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::CurrentlyPlayingChannel +// Returns the index of the playing channel item from the channel list. +// --------------------------------------------------------------------------- +// +TInt CFMRadioChannelListView::CurrentlyPlayingChannel() + { + return iNowPlayingIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::InitializeChannelsL +// Initialize the channels with the values currently saved in +// the radio engine +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::InitializeChannelsL() + { + FTRACE( FPrint( _L("CFMRadioChannelListView::InitializeChannelsL Start") ) ); + + if ( iContainer ) + { + TBool nowPlaying = EFalse; + + CArrayFixFlat* channels = iObserver.Channels(); + TInt channelCount = channels->Count(); + + for ( TInt channelIndex = 0; channelCount > channelIndex; channelIndex++ ) + { + FTRACE( FPrint( _L("CFMRadioChannelListView::InitializeChannelsL inside Channel in use") ) ); + + iContainer->AddChannelL( channels->At( channelIndex ).iChannelInformation, + channels->At( channelIndex ).iChannelFrequency, + nowPlaying ); + + UpdateMiddleSoftKeyL(); + FTRACE( FPrint( _L("CFMRadioChannelListView::InitializeChannelsL inside Channel in use Channel = %d"), iRadioEngine->GetPresetFrequencyL( channelIndex )) ); + } + + CFMRadioAppUi* appUi = static_cast( AppUi() ); + + TInt currentPresetIndex = iRadioEngine->GetPresetIndex(); + TInt chIndexForTunedFreq = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); + + if ( iRadioEngine->GetRadioMode() == CRadioEngine::ERadioPresetMode && + currentPresetIndex < channelCount && + currentPresetIndex >= 0 ) + { + SetLastListenedChannel( currentPresetIndex ); + SetNowPlayingChannel( currentPresetIndex ); + } + else if ( chIndexForTunedFreq != KErrNotFound ) + { + SetLastListenedChannel( chIndexForTunedFreq ); + SetNowPlayingChannel( chIndexForTunedFreq ); + } + else + { + SetLastListenedChannel( 0 ); + } + } + FTRACE(FPrint(_L("InitializeChannelsL complete"))); + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::ChannelInPlay +// Return true/false to indicate whether the channel specified +// is in play +// --------------------------------------------------------------------------- +// +TBool CFMRadioChannelListView::ChannelInPlay( + TInt aChannelIndex ) const + { + if( aChannelIndex == iNowPlayingIndex ) + { + return ETrue; + } + else + { + return EFalse; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::FadeAndShowExit +// Fade the view and all controls associated with it. Change +// the soft keys so that "Exit" is displayed +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::FadeAndShowExit( TBool aFaded ) + { + iFaded = aFaded; + if( iContainer && iToolbar ) + { + if ( aFaded ) // Fade + { + // In case options menu is open when headset is disconnected + StopDisplayingMenuBar(); + iContainer->SetFaded( aFaded ); + iToolbar->SetDimmed( ETrue ); + TRAP_IGNORE( Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_EXIT ) ); + } + else + { + iContainer->SetFaded(aFaded); + iToolbar->SetDimmed( EFalse ); + UpdateToolbar(); + + if ( iMoveMode ) + { + TRAP_IGNORE + ( + Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_EMPTY_CANCEL ); + UpdateMiddleSoftKeyL(); + ) + } + else + { + TRAP_IGNORE( Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ) ); + } + } + Cba()->DrawDeferred(); + iToolbar->DrawDeferred(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::UpdateDisplayForFocusGained +// Update the view after a focus gained event. +// 1. Fade/Unfade view +// 2. Update MSK label +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::UpdateDisplayForFocusGained() + { + FadeAndShowExit( iFaded ); + + // Don't display MSK if display is faded. + if ( !iFaded ) + { + TRAP_IGNORE( UpdateMiddleSoftKeyL() ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::UpdateChannelListContentL +// Make a request to the channel container to update the +// content of the channel at aIndex with the values specified +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::UpdateChannelListContentL( + TInt aIndex, + const TDesC& aChannelName, + TInt aChannelFrequency ) + { + if ( iContainer ) + { + iContainer->UpdateChannelListContentL( aIndex, aChannelName, aChannelFrequency ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::CurrentlySelectedChannel +// Returns the index of the selected channel item from the +// channel list. If the container is active get the info from +// it, because it may have more up-to-date info. +// --------------------------------------------------------------------------- +// +TInt CFMRadioChannelListView::CurrentlySelectedChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + return iChIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::NextChannel +// Retrieve the index of the next channel that has been set. +// --------------------------------------------------------------------------- +// +TInt CFMRadioChannelListView::NextChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + else + { + iChIndex = iRadioEngine->GetPresetIndex(); + } + + iChIndex = iChIndex + 1; + + if ( iChIndex >= iObserver.Channels()->Count() ) + { + iChIndex = 0; + } + + return iChIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::PreviousChannel +// Retrieve the index of the previous channel that has been set. +// --------------------------------------------------------------------------- +// +TInt CFMRadioChannelListView::PreviousChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + else + { + iChIndex = iRadioEngine->GetPresetIndex(); + } + + + if ( iChIndex <= 0 ) + { + iChIndex = iObserver.Channels()->Count()-1; + } + else + { + iChIndex = iChIndex - 1; + } + + return iChIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::HandleControlEventL +// Handles control event observing. In this case the interest +// is only on the channel selection from the channel list. +// Other events are not reported by the container, +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) + { + if ( aControl == iContainer ) + { + // don't change channels in move mode + if ( !iMoveMode ) + { + if ( aEventType == MCoeControlObserver::EEventRequestFocus ) + { + // Don't display MSK when display is faded. + if ( !iFaded ) + { + if ( !AknLayoutUtils::PenEnabled() ) + { + UpdateMiddleSoftKeyL(); + } + else + { + AppUi()->HandleCommandL( EFMRadioCmdListenCh ); + } + } + } + + else if ( aEventType == MCoeControlObserver::EEventStateChanged ) + { + // Send command to Ui + AppUi()->HandleCommandL( EFMRadioCmdListenCh ); + } + } + } + + else if ( iManualQueryDialog && aControl == iManualQueryDialog && aEventType == MCoeControlObserver::EEventStateChanged ) + { + TUint32 newFreq = static_cast( iManualQueryDialog )->Frequency(); + iRadioEngine->Tune( static_cast( newFreq * KFMRadioFreqMultiplier ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::DoDeactivate +// Deactivate the channel list view +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::DoDeactivate() + { + CFMRadioAppUi* appUi = static_cast(AppUi()); + if ( appUi->RadioEngine() ) + { + iRadioEngine->RdsReceiver().RemoveObserver( this ); + } + + if ( iContainer ) + { + appUi->RemoveFromViewStack( *this, iContainer ); + } + delete iContainer; + iContainer = NULL; + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::DynInitMenuPaneL +// Sets the state of menu items dynamically according to the +// state of application data. +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::DynInitMenuPaneL( + TInt aResourceId, + CEikMenuPane* aMenuPane ) + { + if ( aResourceId == R_FMRADIO_CH_LIST_OPTIONS_MENU ) // Main menu + { + if ( iRadioEngine->IsAudioRoutingPossible() ) + { + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdActivateIhf ); + if ( iRadioEngine->IsHeadsetConnected() ) + { + aMenuPane->SetItemTextL( EFMRadioCmdDeactivateIhf,R_QTN_FMRADIO_OPTIONS_DEACTIVATE ); + } + } + else + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdDeactivateIhf ); + aMenuPane->SetItemTextL( EFMRadioCmdActivateIhf,R_QTN_FMRADIO_OPTIONS_ACTIVATE ); + } + } + else + { + aMenuPane->SetItemDimmed( EFMRadioCmdDeactivateIhf, ETrue ); + aMenuPane->SetItemDimmed( EFMRadioCmdActivateIhf, ETrue ); + } + + // if help is not enabled, disable help option + if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) + { + aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioChannelListView::LayoutChangedL +// --------------------------------------------------------------------------- +// +void CFMRadioChannelListView::LayoutChangedL( + TInt aType ) + { + iContainer->SetRect( ClientRect() ); + iContainer->HandleResourceChange( aType ); + } + +// --------------------------------------------------------------------------------------------- +// Sets middle softkey label. +// --------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::SetMiddleSoftKeyLabelL( + TInt aResourceId, + TInt aCommandId ) + { + + CEikButtonGroupContainer* cbaGroup = Cba(); + if ( cbaGroup ) + { + cbaGroup->RemoveCommandFromStack( KMSKControlID, iCurrentMSKCommandId ); + HBufC* middleSKText = StringLoader::LoadLC( aResourceId, iCoeEnv ); + TPtr mskPtr = middleSKText->Des(); + cbaGroup->AddCommandToStackL( + KMSKControlID, + aCommandId, + mskPtr ); + CleanupStack::PopAndDestroy( middleSKText ); + iCurrentMSKCommandId = aCommandId; + } + } + +// --------------------------------------------------------------------------------------------- +// Updates the middle softkey functionality. +// --------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::UpdateMiddleSoftKeyL() + { + + if ( ( iContainer && + ( iContainer->CurrentlySelectedChannel() == iRadioEngine->GetPresetIndex() + || iObserver.Channels()->Count() == 0 ) ) || + iMoveMode ) + { + SetMiddleSoftKeyLabelL(R_QTN_FMRADIO_NONE, EFMRadioCmdListenCh); + } + else + { + SetMiddleSoftKeyLabelL(R_QTN_FMRADIO_MSK_LISTEN, EFMRadioCmdListenCh); + } + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::SetEmptyChannelListItem +// Set empty channel list item when preset is deleted from fmradiopresetutility +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::SetEmptyChannelListItemL( const TInt aIndex ) const + { + FTRACE( FPrint( _L("CFMRadioChannelListView::SetEmptyChannelListItem index = %d"), aIndex ) ); + + if ( iContainer ) + { + iContainer->RemoveChannelL( aIndex ); + } + + // Dim the rename and delete buttons in case the list is now empty + UpdateToolbar(); + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsDataProgrammeService +// +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsDataProgrammeService( const TDesC& /*aProgramService*/ ) + { + } + +// -------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsDataPsNameIsStatic +// -------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsDataPsNameIsStatic( TBool aStatic ) + { + const TDesC& programmeService = iRadioEngine->RdsReceiver().ProgrammeService(); + if ( iContainer && + aStatic && + programmeService.Length() && + !iMoveMode ) + { + TInt currentPresetIx = iRadioEngine->GetPresetIndex(); + // When we haven't preset name, ps name will save as preset name + if ( iRadioEngine->GetRadioMode() == CRadioEngine::ERadioPresetMode && + currentPresetIx != KErrNotFound ) + { + TBuf stationName; + stationName.SetLength( 0 ); + + + TInt presetFreq( 0 ); + + CArrayFixFlat* channels = iObserver.Channels(); + + // this checks that index is not out of bound and cause -21 error during update + if ( currentPresetIx < channels->Count() ) + { + stationName = channels->At( currentPresetIx ).iChannelInformation; + presetFreq = channels->At( currentPresetIx ).iChannelFrequency; + + if ( stationName.Length() == 0 ) //Set and save PSname only if no name set before + { + TRAP_IGNORE( + { + iContainer->UpdateChannelListContentL( currentPresetIx, + programmeService, + presetFreq ); + + iRadioEngine->SetPresetNameFrequencyL( currentPresetIx, programmeService, presetFreq ); + iObserver.Channels()->At( currentPresetIx ).iChannelInformation = programmeService; + } ); + } + } + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::PrepareToolbar +// Prepare toolbar for displaying basic radio command buttons +// -------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::PrepareToolbar() + { + // get toolbar from view + iToolbar = Toolbar(); + // Set observer + iToolbar->SetToolbarObserver( this ); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::UpdateToolbar +// Set the dimmed status of buttons according to list state +// -------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::UpdateToolbar() const + { + if ( iContainer && iToolbar && AknLayoutUtils::PenEnabled() ) + { + if ( iRadioEngine->IsAudioRoutingPossible() ) + { + if ( iRadioEngine->IsHeadsetConnected() ) + { + CAknButton* centerButton = NULL; + centerButton = static_cast( iToolbar->ControlOrNull( EFMRadioToolbarButtonCmdToggleIhf ) ); + + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, EFalse, ETrue ); + + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + if ( centerButton ) + { + centerButton->SetCurrentState( 1, ETrue ); + } + } + else + { + if ( centerButton ) + { + centerButton->SetCurrentState( 0, ETrue ); + } + } + } + else + { + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, ETrue, ETrue ); + } + } + else + { + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, ETrue, ETrue ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioChannelListView::OfferToolbarEventL +// Handle commands from toolbar. +// -------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::OfferToolbarEventL( TInt aCommandId ) + { + HandleCommandL( aCommandId ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListView::ShowToolbar +// Sets toolbar visibility. +// --------------------------------------------------------- +// +void CFMRadioChannelListView::ShowToolbar( TBool aVisible ) + { + if ( AknLayoutUtils::PenEnabled() && + iToolbar && + iContainer ) + { + iToolbar->SetToolbarVisibility( aVisible ); + iToolbar->UpdateBackground(); + iToolbar->DrawDeferred(); + // set correct container rect with or without toolbar + iContainer->SetRect( ClientRect() ); + } + } + + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsDataRadioText +// From MFMRadioRdsObserver, implementation not needed. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsDataRadioText( const TDesC& /*aRadioText*/ ){} + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsAfSearchBegin +// From MFMRadioRdsObserver, implementation not needed. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsAfSearchBegin(){} + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsAfSearchEnd +// From MFMRadioRdsObserver, implementation not needed. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsAfSearchEnd( TUint32 /* aFrequency*/, TInt /*aError*/ ){} + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsAfSearchStateChange +// From MFMRadioRdsObserver, implementation not needed. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsAfSearchStateChange( TBool /* aEnabled*/ ){} + +// ----------------------------------------------------------------------------------------------- +// CFMRadioChannelListView::RdsAvailable +// From MFMRadioRdsObserver, implementation not needed. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioChannelListView::RdsAvailable( TBool /*aAvailable*/ ){} + +// --------------------------------------------------------- +// CFMRadioChannelListView::SetTitleL +// --------------------------------------------------------- +// +void CFMRadioChannelListView::SetTitleL( TInt aResourceId ) + { + HBufC* title = StringLoader::LoadLC( aResourceId, iCoeEnv ); + static_cast( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) )->SetTextL( *title, ETrue ); + CleanupStack::PopAndDestroy( title ); + } + + +// --------------------------------------------------------- +// CFMRadioChannelListView::MoveCurrentItemIndexL +// --------------------------------------------------------- +// +void CFMRadioChannelListView::MoveCurrentItemIndexL() + { + iMoveMode = ETrue; + + Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_EMPTY_CANCEL ); + UpdateMiddleSoftKeyL(); + ShowToolbar( EFalse ); + + iContainer->HideIconsL(); + + iContainer->ActivateMoveL(); + } + +// --------------------------------------------------------- +// CFMRadioChannelListView::MoveActionDoneL +// --------------------------------------------------------- +// +void CFMRadioChannelListView::MoveActionDoneL() + { + iMoveMode = EFalse; + iFirstMoveDone = ETrue; + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); + + UpdateMiddleSoftKeyL(); + iContainer->HandleDropL(); + iContainer->MoveDoneL(); + + TInt currentIndex = 0; + CFMRadioAppUi* appUi = static_cast( AppUi() ); + currentIndex = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); + + if ( currentIndex != KErrNotFound ) + { + iRadioEngine->SetCurrentPresetIndex( currentIndex ); + SetNowPlayingChannel( currentIndex ); + } + ShowToolbar( ETrue ); + } + +// --------------------------------------------------------- +// CFMRadioChannelListView::CancelMoveL +// --------------------------------------------------------- +// +void CFMRadioChannelListView::CancelMoveL() + { + CFMRadioAppUi* appUi = static_cast( AppUi() ); + TBool viewActive = appUi->ActiveView() == KFMRadioChannelListViewId && iContainer; + if ( viewActive && ( iContainer->MoveCanceledL() || iMoveMode ) ) + { + iMoveMode = EFalse; + iFirstMoveDone = ETrue; + iContainer->ReIndexAllL(); + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); + UpdateMiddleSoftKeyL(); + TInt currentIndex = 0; + currentIndex = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); + if ( currentIndex != KErrNotFound ) + { + SetNowPlayingChannel( currentIndex ); + } + ShowToolbar( ETrue ); + } + } + +// --------------------------------------------------------- +// CFMRadioChannelListView::StopSeekL +// --------------------------------------------------------- +// +void CFMRadioChannelListView::StopSeekL() + { + // update icon if radio is in tuner mode i.e. + // "accessory seek up/down" is launched + if ( iContainer && + iRadioEngine->GetRadioMode() == CRadioEngine::ERadioTunerMode ) + { + CFMRadioAppUi* appUi = static_cast( AppUi() ); + TInt tunedFrequency = iRadioEngine->GetTunedFrequency(); + const TInt index = appUi->MatchingChannelL( tunedFrequency ); + + if ( index == KErrNotFound ) + { + // frequency is not saved, hide now playing icon + iContainer->HideIconsL(); + } + else + { + SetNowPlayingChannel( index ); + SetLastListenedChannel( index ); + } + } + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiocontroleventobserverimpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiocontroleventobserverimpl.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,254 @@ +/* +* 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: Implementation for the control event observer. +* +*/ + +#include +#include "fmradiocontroleventobserverimpl.h" + +#include "fmradio.hrh" +// --------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CFMRadioControlEventObserverImpl::CFMRadioControlEventObserverImpl( CFMRadioAppUi& aAppUi ) + : iAppUi( aAppUi ) + { + + } + + +// --------------------------------------------------------------------------- +// EPOC default constructor can leave. +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CFMRadioControlEventObserverImpl* CFMRadioControlEventObserverImpl::NewL( + CFMRadioAppUi& aAppUi ) + { + CFMRadioControlEventObserverImpl* self = + new( ELeave ) CFMRadioControlEventObserverImpl( aAppUi ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioControlEventObserverImpl::~CFMRadioControlEventObserverImpl() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::StepToChannelL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::StepToChannelL( TFMRadioTuneDirection aDirection ) + { + CAknViewAppUi* appUi = static_cast( CCoeEnv::Static()->AppUi() ); + if( aDirection == EFMRadioDown ) + { + appUi->HandleCommandL( EFMRadioCmdPrevChannel ); + } + else if( aDirection == EFMRadioUp ) + { + appUi->HandleCommandL( EFMRadioCmdNextChannel ); + } + else + { + } + } + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::SetChannelL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::SetChannelL( TInt /*aChannelId*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::SeekL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::SeekL( TFMRadioTuneDirection /*aDirection*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::StepToFrequencyL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::StepToFrequencyL( TFMRadioTuneDirection /*aDirection*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::SetFrequencyL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::SetFrequencyL( TUint32 /*aFreq*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::AdjustVolumeL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::AdjustVolumeL( TFMRadioVolumeSetDirection /*aDirection*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::MuteL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::MuteL( TBool /*aMute*/ ) + { + CAknViewAppUi* appUi = static_cast( CCoeEnv::Static()->AppUi() ); + TRAP_IGNORE( appUi->HandleCommandL( EFMRadioCmdMute ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::PlayL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::PlayL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::PauseL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::PauseL(TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::PausePlayL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::PausePlayL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::StopL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::StopL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::ForwardL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::ForwardL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::FastForwardL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::FastForwardL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::BackwardL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::BackwardL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::RewindL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::RewindL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::ChannelUpL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::ChannelUpL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::ChannelDownL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::ChannelDownL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::VolumeUpL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::VolumeUpL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::VolumeDownL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::VolumeDownL( TBool /*aDownPressed*/ ) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::ChangeViewL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::ChangeViewL(TUid /*aViewId*/, TBool /*aForceChange*/) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::SetAudioOutputDestinationL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::SetAudioOutputDestinationL(TFMRadioOutputDestination /*aDestination*/) +{ +} + +// --------------------------------------------------------------------------- +// CFMRadioControlEventObserverImpl::AnswerEndCallL +// --------------------------------------------------------------------------- +// +void CFMRadioControlEventObserverImpl::AnswerEndCallL() +{ +} diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiodocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiodocument.cpp Tue Feb 02 00:17:10 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: Implementation of the CFMRadioDocument class, which +* handles application data serialization. Owns the Ui +* (controller) and the engine (model) +* +*/ + + +// INCLUDE FILES +#include "fmradiodocument.h" +#include "fmradioappui.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CFMRadioDocument::CFMRadioDocument +// Constructor +// --------------------------------------------------------- +// +CFMRadioDocument::CFMRadioDocument( CEikApplication& aApp ) +: CAknDocument( aApp ) + { + } + +// --------------------------------------------------------- +// CFMRadioDocument::~CFMRadioDocument +// Class destructor +// --------------------------------------------------------- +// +CFMRadioDocument::~CFMRadioDocument() + { + } + +// --------------------------------------------------------- +// CFMRadioDocument::NewL +// Two-phase constructor of CFMRadioDelayTimer +// --------------------------------------------------------- +// +CFMRadioDocument* CFMRadioDocument::NewL( CEikApplication& aApp ) + { + CFMRadioDocument* self = new ( ELeave ) CFMRadioDocument( aApp ); + return self; + } + +// ---------------------------------------------------- +// CFMRadioDocument::CreateAppUiL +// constructs CFMRadioAppUi +// ---------------------------------------------------- +// +CEikAppUi* CFMRadioDocument::CreateAppUiL() + { + return new ( ELeave ) CFMRadioAppUi; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiofrequencyeditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiofrequencyeditor.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,869 @@ +/* +* 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: Custom editor for editing radio frequencies. +* +*/ + + +#include +#include +#include +#include +#include + +#include "fmradiofrequencyeditor.h" +#include "fmradioengineradiosettings.h" +#include "fmradioappui.h" +#include "fmradiofrequencynumber.h" +#include "fmradio.hrh" +#include "debug.h" + +const TInt KNumFields = 3; // Number of fields. +const TInt KIntField = 0; // Index of integer field. +const TInt KDecField = 2; // Index of decimal field. + +const TInt KFMRadioAbsoluteMinimumIntFieldValue = 0; +const TInt KFMRadioAbsoluteMinimumDecFieldValue = 0; + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::CFMRadioFrequencyEditor +// --------------------------------------------------------------------------- +// +CFMRadioFrequencyEditor::CFMRadioFrequencyEditor() : + iMinFreq( 0 ), + iMaxFreq( 0 ), + iPreviousField( KErrNotFound ), + iTypedInDecField( EFalse ), + iValidToReport( EFalse ), + iDecDiv( KFMRadioFreqMultiplier ), + iReportEditorState ( ETrue ) + { + } + + +// --------------------------------------------------------------------------- +// Editor is contructed via this static method by the control framework. +// --------------------------------------------------------------------------- +// +SEikControlInfo CFMRadioFrequencyEditor::StaticCreateCustomEditor( + TInt aIdentifier ) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::StaticCreateCustomEditor") ) ); + SEikControlInfo customInfo; + // zero all variables + Mem::FillZ( &customInfo, sizeof( SEikControlInfo ) ); + if ( aIdentifier == EFMRadioFrequencyEditor ) + { + customInfo.iControl = new CFMRadioFrequencyEditor; + } + return customInfo; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::ConstructL( const TUint32 aFlags ) + { + // Creates space for the fiels in this MFNE. + CreateFieldArrayL( KNumFields ); + + // RadioSettings values are so widely used in this class, that it is + // better to read them into member variables. + CRadioEngine* radioEngine = static_cast( iCoeEnv->AppUi() )->RadioEngine(); + TInt minFreq = 0; + TInt maxFreq = 0; + radioEngine->GetFrequencyBandRange( minFreq, maxFreq ); + iMinFreq = minFreq / KFMRadioFreqMultiplier; + iMaxFreq = maxFreq / KFMRadioFreqMultiplier; + iStepFreq = radioEngine->FrequencyStepSize(); + // Maximum values of fields. + TInt maxIntFieldValue( 0 ); + TInt maxIntFreq = iMaxFreq / KFMRadioFreqMultiplier; + while ( maxIntFieldValue < maxIntFreq ) + { + maxIntFieldValue = maxIntFieldValue*10 + 9; + } + TInt maxDecFieldValue( 0 ); + TInt decimalCounter = radioEngine->DecimalCount(); + while ( decimalCounter-- ) + { + maxDecFieldValue = maxDecFieldValue*10 + 9; + // Calculate also the decimal divider for later use. + iDecDiv = iDecDiv / 10; + } + + // Integer field. Ownership transfers. + CFMRadioFrequencyNumber* field = CFMRadioFrequencyNumber::NewL( *Font(), + KFMRadioAbsoluteMinimumIntFieldValue, maxIntFieldValue, + KFMRadioAbsoluteMinimumIntFieldValue, aFlags ); + field->SetDigitType( AknTextUtils::NumericEditorDigitType(), *Font() ); + AddField( field ); + + // Decimal separator field. Ownership transfers. + HBufC* delim = HBufC::NewLC( 1 ); + TLocale loc; + delim->Des().Append( loc.DecimalSeparator() ); + AddField( CEikMfneSeparator::NewL( delim ) ); + CleanupStack::Pop(); // delim + + // Decimal field. Ownership transfers. + field = CFMRadioFrequencyNumber::NewL( *Font(), KFMRadioAbsoluteMinimumDecFieldValue, + maxDecFieldValue, KFMRadioAbsoluteMinimumDecFieldValue, + aFlags | CEikMfneNumber::EFillWithLeadingZeros ); + field->SetDigitType( AknTextUtils::NumericEditorDigitType(), *Font() ); + AddField( field ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::~CFMRadioFrequencyEditor +// --------------------------------------------------------------------------- +// +CFMRadioFrequencyEditor::~CFMRadioFrequencyEditor() + { + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::SetFrequency +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::SetFrequency( const TUint32 aFreq ) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::SetFrequency (aFreq=%d) "), aFreq ) ); + TUint32 freq = aFreq; + if ( ( iMinFreq != 0 ) && ( iMaxFreq != 0 ) ) + { + if ( freq < iMinFreq ) + { + freq = iMinFreq; + } + else if ( freq > iMaxFreq ) + { + freq = iMaxFreq; + } + else {} + } + TInt intVal = freq / KFMRadioFreqMultiplier; + TInt decVal = ( freq % KFMRadioFreqMultiplier ) / iDecDiv; + static_cast( + Field( KIntField ) )->SetValue( intVal, *Font() ); + static_cast( + Field( KDecField ) )->SetValue( decVal, *Font() ); + UpdateMinimumAndMaximum(); + ValidateFields(); + DrawNow(); + } + + +// --------------------------------------------------------------------------- +// Calculates the frequency from values of the fields. +// --------------------------------------------------------------------------- +// +TUint32 CFMRadioFrequencyEditor::Frequency() const + { + TInt intVal = static_cast( + Field( KIntField ) )->Value(); + TInt decVal = static_cast( + Field( KDecField ) )->Value(); + return ( KFMRadioFreqMultiplier * intVal ) + ( iDecDiv * decVal ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::SetMinimumAndMaximum +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::SetMinimumAndMaximum( + const TUint32 aMinimumFrequency, const TUint32 aMaximumFrequency ) + { + iMinIntValue = aMinimumFrequency / KFMRadioFreqMultiplier; + iMaxIntValue = aMaximumFrequency / KFMRadioFreqMultiplier; + iMinDecValue = ( aMinimumFrequency % KFMRadioFreqMultiplier ) / iDecDiv; + iMaxDecValue = ( aMaximumFrequency % KFMRadioFreqMultiplier ) / iDecDiv; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::GetMinimumAndMaximum +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::GetMinimumAndMaximum( TUint32& aMinimumFrequency, + TUint32& aMaximumFrequency ) const + { + aMinimumFrequency = ( KFMRadioFreqMultiplier * iMinIntValue ) + + ( iDecDiv*iMinDecValue ); + aMaximumFrequency = ( KFMRadioFreqMultiplier * iMaxIntValue ) + + ( iDecDiv * iMaxDecValue ); + } + + +// --------------------------------------------------------------------------- +// From class CCoeControl. +// CFMRadioFrequencyEditor::ConstructFromResourceL +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::ConstructFromResourceL( + TResourceReader& aResourceReader ) + { + TUint32 flags = aResourceReader.ReadUint8(); + ConstructL( EAknEditorFlagDeliverVirtualKeyEventsToApplication ); + } + + +// --------------------------------------------------------------------------- +// From class CEikMfne. +// Every key press may cause some recalculations and/or validations in +// the fields. +// --------------------------------------------------------------------------- +// +TKeyResponse CFMRadioFrequencyEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::OfferKeyEventL ") ) ); + iPreviousField = CurrentField(); + + TKeyResponse resp( EKeyWasNotConsumed ); + + CEikMfneField* currField = Field( CurrentField() ); + + // Check only once per key press. + if ( aType == EEventKey ) + { + TBool dataAltered = EFalse; + TBool error = EFalse; + TInt changeField = 0; + TInt newCurrentField = CurrentField(); + + switch ( aKeyEvent.iCode ) + { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '0': + { + currField->HandleKey( *Font(), aKeyEvent, EFalse, dataAltered, + changeField ); + + // If after number key press we are still on decimal field + // (and were before). + if ( ( !changeField ) && ( CurrentField() == KDecField ) ) + { + // This can mean only that user has typed one number in + // the decimal field and system is waiting for the other. + iTypedInDecField = ETrue; + } + else + { + iTypedInDecField = EFalse; + } + // If after number key press system moved to another field + // (previous field was filled with numbers). + if ( changeField ) + { + if ( CurrentField() == KIntField ) + { + // First check if the changed value is within limits. + error = ValidateIntField(); + // Calculate new minimums and maximums. + UpdateMinimumAndMaximum(); + // Now have to check also whether the other field is + // within new limits. + ValidateDecField(); + } + else if ( CurrentField() == KDecField ) + { + error = ValidateDecField(); + } + else {} + } + break; + } + case EKeyBackspace: + { + // Pressing "c"-key in a field will set the field in + // "typed" state. + currField->HandleKey( *Font(), aKeyEvent, EFalse, dataAltered, + changeField ); + if ( CurrentField() == KDecField ) + { + iTypedInDecField = ETrue; + } + break; + } + case EKeyLeftArrow: // fall-through intended here + case EKeyRightArrow: + { + currField->HandleKey( *Font(), aKeyEvent, EFalse, dataAltered, + changeField ); + FillDecimalField(); + ValidateFields(); + // Minimums and maximums may have to be changed. + UpdateMinimumAndMaximum(); + // Validate according to new minimums and maximums. + ValidateFields(); + break; + } + default: + { + break; + } + } + + if ( changeField ) + { + if ( CurrentField() == KIntField ) + { + newCurrentField = KDecField; + } + else + { + newCurrentField = KIntField; + } + } + TBuf<3> fieldText; + TInt fieldVal = 0; + TRAPD( err, fieldVal = static_cast( currField )->Value() ) + if ( !err ) + { + fieldText.Num( static_cast( fieldVal ) ); + } + CEikMfne::HandleInteraction( changeField, newCurrentField, + Font()->TextWidthInPixels( fieldText ), + currField->HighlightType(), + dataAltered, + error ); + + DrawAndReportL( EFalse ); + } + + return resp; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::FillDecimalField +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::FillDecimalField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::FillDecimalField") ) ); + if ( iTypedInDecField ) + { + CFMRadioFrequencyNumber* field = + static_cast( Field( KDecField ) ); + // Multiply value by iDecDiv. + field->SetValue( iDecDiv*field->Value(), *Font() ); + iTypedInDecField = EFalse; + } + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::CanLeaveEditorL +// --------------------------------------------------------------------------- +// +TBool CFMRadioFrequencyEditor::CanLeaveEditorL() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::CanLeaveEditorL") ) ); + TBool ret = ETrue; + + FillDecimalField(); + + if ( CurrentField() == KIntField ) + { + // First check if the changed value is within limits. + ret = !ValidateIntField(); + // Calculate new minimums and maximums. + UpdateMinimumAndMaximum(); + // Now have to check also whether the other field is within new + // limits. + ValidateDecField(); + } + else if ( CurrentField() == KDecField ) + { + ret = !ValidateDecField(); + } + else {} + + PrepareForFocusLossL(); + + // Draw immediately, otherwise a wrong number is displayed in decimal + // field (for example: 03 instead of 30) + DrawAndReportL( ETrue ); + + return ret; + } + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::IncrementCurrentField +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::IncrementCurrentField() + { + CEikMfneField* currField = Field( CurrentField() ); + // If user is not in the middle of typing numbers. + if ( currField->HighlightType() == + CEikMfneField::EInverseVideo ) + { + if ( CurrentField() == KIntField ) + { + IncrementIntField(); + } + else if ( CurrentField() == KDecField ) + { + IncrementDecField(); + } + else {} + // Minimums and maximums may have to be changed. + UpdateMinimumAndMaximum(); + // Validate according to new minimums and maximums. + ValidateFields(); + } + + TRAP_IGNORE( DrawAndReportL( EFalse ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::DecrementCurrentField +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::DecrementCurrentField() + { + CEikMfneField* currField = Field( CurrentField() ); + // If user is not in the middle of typing numbers. + if ( currField->HighlightType() == + CEikMfneField::EInverseVideo ) + { + if ( CurrentField() == KIntField ) + { + DecrementIntField(); + } + else if ( CurrentField() == KDecField ) + { + DecrementDecField(); + } + else {} + // Minimums and maximums may have to be changed. + UpdateMinimumAndMaximum(); + // Validate according to new minimums and maximums. + ValidateFields(); + } + TRAP_IGNORE( DrawAndReportL( EFalse ) ); + } + +// --------------------------------------------------------------------------- +// Field decrement step is 1. +// If field value is already at maximum, it set to minimum. +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::IncrementIntField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::IncrementIntField") ) ); + CFMRadioFrequencyNumber* field = + static_cast( Field( KIntField ) ); + CFMRadioFrequencyNumber* decField = + static_cast( Field( KDecField ) ); + + if ( field->Value() < iMaxIntValue ) + { + field->SetValue( field->Value() + 1, *Font() ); + } + else if ( field->Value() == iMaxIntValue && decField->Value() == iMaxDecValue) + { + field->SetValue( iMinIntValue, *Font() ); + } + else + { + decField->SetValue( iMaxDecValue, *Font() ); + } + } + + +// --------------------------------------------------------------------------- +// Field decrement step is 1. +// If field value is already at minimum, it set to maximum. +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::DecrementIntField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::DecrementIntField") ) ); + CFMRadioFrequencyNumber* field = + static_cast( Field( KIntField ) ); + CFMRadioFrequencyNumber* decField = + static_cast( Field( KDecField ) ); + + if ( field->Value() > iMinIntValue ) + { + field->SetValue( field->Value() - 1, *Font() ); + } + else if ( field->Value() == iMinIntValue && decField->Value() == iMinDecValue) + { + field->SetValue( iMaxIntValue, *Font() ); + } + else + { + decField->SetValue( iMinDecValue, *Font() ); + } + } + + +// --------------------------------------------------------------------------- +// Field inrement step is defined in RadioSettings. +// If field value is already at maximum, integer field +// has to be incremented and this field set to minimum. +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::IncrementDecField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::IncrementDecField") ) ); + CFMRadioFrequencyNumber* field = + static_cast( Field( KDecField ) ); + if ( field->Value() < iMaxDecValue ) + { + field->SetValue( field->Value() + iStepFreq/iDecDiv, *Font() ); + } + else if ( field->Value() == iMaxDecValue ) + { + IncrementIntField(); + // This is done because min of this field may change when integer + // field is set to it's minimum. + UpdateMinimumAndMaximum(); + field->SetValue( iMinDecValue, *Font() ); + } + else {} + } + + +// --------------------------------------------------------------------------- +// Field decrement step is defined in RadioSettings. +// If field value is already at minimum, integer field +// has to be decremented and this field set to maximum. +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::DecrementDecField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::DecrementDecField") ) ); + CFMRadioFrequencyNumber* field = + static_cast( Field( KDecField ) ); + if ( field->Value() > iMinDecValue ) + { + field->SetValue( field->Value() - iStepFreq/iDecDiv, *Font() ); + } + else if ( field->Value() == iMinDecValue ) + { + DecrementIntField(); + // This is done because max of this field may change when integer + // field is set to it's maximum. + UpdateMinimumAndMaximum(); + field->SetValue( iMaxDecValue, *Font() ); + } + else {} + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::ValidateFields +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::ValidateFields() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::ValidateFields") ) ); + ValidateIntField(); + ValidateDecField(); + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::ValidateIntField +// --------------------------------------------------------------------------- +// +TBool CFMRadioFrequencyEditor::ValidateIntField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::ValidateIntField") ) ); + TBool ret = EFalse; + + // Check if integer field value is within limits. + CFMRadioFrequencyNumber* field = + static_cast( Field( KIntField ) ); + if ( field->Value() < iMinIntValue ) + { + field->SetValue( iMinIntValue, *Font() ); + ret = ETrue; + } + else if ( field->Value() > iMaxIntValue ) + { + field->SetValue( iMaxIntValue, *Font() ); + ret = ETrue; + } + else {} + + return ret; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::ValidateDecField +// --------------------------------------------------------------------------- +// +TBool CFMRadioFrequencyEditor::ValidateDecField() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::ValidateDecField") ) ); + TBool ret = EFalse; + + // Check if decimal field value is within limits. + CFMRadioFrequencyNumber* field = + static_cast( Field( KDecField ) ); + if ( field->Value() < iMinDecValue ) + { + field->SetValue( iMinDecValue, *Font() ); + ret = ETrue; + } + else if ( field->Value() > iMaxDecValue ) + { + field->SetValue( iMaxDecValue, *Font() ); + ret = ETrue; + } + else + { + // Check if decimal field value is within a step. + TInt remainder = static_cast( + ( field->Value()-iMinDecValue ) ) % ( iStepFreq/iDecDiv ); + if ( remainder != 0 ) + { + field->SetValue( field->Value()-remainder, *Font() ); + ret = ETrue; + } + } + + return ret; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::UpdateMinimumAndMaximum +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::UpdateMinimumAndMaximum() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyEditor::UpdateMinimumAndMaximum") ) ); + TInt minIntValue( 0 ); + TInt maxIntValue( 0 ); + TInt minDecValue( 0 ); + TInt maxDecValue( 0 ); + + minIntValue = iMinFreq / KFMRadioFreqMultiplier; + maxIntValue = iMaxFreq / KFMRadioFreqMultiplier; + + if ( ( Frequency() / KFMRadioFreqMultiplier > iMinFreq / KFMRadioFreqMultiplier ) && + ( Frequency() / KFMRadioFreqMultiplier < iMaxFreq / KFMRadioFreqMultiplier ) ) + { + // Remainder of the gap from min freq to next int value. + minDecValue = ( ( ( KFMRadioFreqMultiplier * ( minIntValue + 1 ) ) - iMinFreq ) + % iStepFreq ) / iDecDiv; + // Same kind of thing vice versa. + maxDecValue = ( ( ( iMinFreq - ( KFMRadioFreqMultiplier * ( minIntValue ) ) ) + % iStepFreq ) / iDecDiv ) + KFMRadioFreqMultiplier / iDecDiv + - ( iStepFreq / iDecDiv ); + } + else if ( Frequency() / KFMRadioFreqMultiplier == iMinFreq / KFMRadioFreqMultiplier ) + { + minDecValue = ( iMinFreq % KFMRadioFreqMultiplier ) / iDecDiv; + // Same kind of thing vice versa. + maxDecValue = ( ( ( iMinFreq - ( KFMRadioFreqMultiplier * ( minIntValue ) ) ) + % iStepFreq ) / iDecDiv ) + KFMRadioFreqMultiplier / iDecDiv + - ( iStepFreq / iDecDiv ); + } + else if ( Frequency() / KFMRadioFreqMultiplier == iMaxFreq / KFMRadioFreqMultiplier ) + { + // Remainder of the gap from min freq to next int value. + minDecValue = ( ( ( KFMRadioFreqMultiplier * ( minIntValue + 1 ) ) - iMinFreq ) + % iStepFreq ) / iDecDiv; + maxDecValue = ( iMaxFreq % KFMRadioFreqMultiplier ) / iDecDiv; + } + else {} + + SetMinimumAndMaximum( + ( KFMRadioFreqMultiplier * minIntValue ) + ( iDecDiv * minDecValue ), + ( KFMRadioFreqMultiplier * maxIntValue ) + ( iDecDiv * maxDecValue ) ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::IsValid +// --------------------------------------------------------------------------- +// +TBool CFMRadioFrequencyEditor::IsValid() const + { + return ( Field( CurrentField() )->HighlightType() == + CEikMfneField::EInverseVideo ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::IsValidToReport +// --------------------------------------------------------------------------- +// +TBool CFMRadioFrequencyEditor::IsValidToReport() const + { + return iValidToReport; + } + + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::DrawAndReportL +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::DrawAndReportL( TBool /*aForceDrawNow*/ ) + { + //Switched to always do DrawNow() - DrawDeferred() is too slow for rapid + //frequency changing (long press accelerates after a while) +// if ( !aForceDrawNow && ( DrawableWindow() && !IsBackedUp() ) ) +// { +// // Flicker-free redraw. +// DrawDeferred(); +// } +// else +// { +// DrawNow(); +// } + + DrawNow(); + + + if ( iReportEditorState ) + { + iValidToReport = ETrue; + } + else + { + iValidToReport = EFalse; + } + // Report back finally to main container. + ReportEventL( MCoeControlObserver::EEventStateChanged ); + iValidToReport = EFalse; + } + + +// --------------------------------------------------------------------------- +// From class CCoeControl. +// CFMRadioFrequencyEditor::FocusChanged +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::FocusChanged( TDrawNow /*aDrawNow*/ ) + { + if ( Field( CurrentField() )->HighlightType() == + CEikMfneField::EInverseVideo ) + { + CFMRadioFrequencyNumber* field = + static_cast( Field( KIntField ) ); + field->SetDigitType( AknTextUtils::NumericEditorDigitType(), + *Font() ); + field = NULL; + field = static_cast( Field( KDecField ) ); + field->SetDigitType( AknTextUtils::NumericEditorDigitType(), + *Font() ); + } + + if ( DrawableWindow() && !IsBackedUp() ) + { + // Flicker-free redraw. + reinterpret_cast( DrawableWindow() )->Invalidate(); + } + else + { + DrawNow(); + } + } + +void CFMRadioFrequencyEditor::SetEditorReportState( const TBool aReport ) + { + iReportEditorState = aReport; + } + +// --------------------------------------------------------------------------- +// From class CCoeControl. +// CFMRadioFrequencyEditor::HandlePointerEventL +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent ) + { + if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) + { + TBool dataAltered = EFalse; + TInt newCurrentField = CurrentField(); + TInt error = KErrNone; + + CEikMfneField* currField = Field( CurrentField() ); + TInt fieldWidth = iEditorFrameRect.Width() / 2; + TRect fieldRect; + + if ( CurrentField() == KIntField ) + { + newCurrentField = KDecField; + TPoint fieldPos( iEditorFrameRect.iTl ); + fieldPos.iX += iEditorFrameRect.Width() - fieldWidth; + fieldRect.SetRect( fieldPos, TSize( fieldWidth , iEditorFrameRect.Height() ) ); + } + else + { + newCurrentField = KIntField; + fieldRect.SetRect( iEditorFrameRect.iTl, TSize( fieldWidth , iEditorFrameRect.Height() ) ); + } + + if ( fieldRect.Contains( aPointerEvent.iPosition ) ) + { + FillDecimalField(); + ValidateFields(); + // Minimums and maximums may have to be changed. + UpdateMinimumAndMaximum(); + // Validate according to new minimums and maximums. + ValidateFields(); + + TBuf<3> fieldText; + TInt fieldVal = 0; + TRAPD( err, fieldVal = static_cast( currField )->Value() ) + if ( !err ) + { + fieldText.Num( static_cast( fieldVal ) ); + } + CEikMfne::HandleInteraction( ETrue, + newCurrentField, + Font()->TextWidthInPixels( fieldText ), + currField->HighlightType(), + dataAltered, + error ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioFrequencyEditor::SetEditorFrameRect +// --------------------------------------------------------------------------- +// +void CFMRadioFrequencyEditor::SetEditorFrameRect( const TRect& aRect ) + { + iEditorFrameRect = aRect; + } + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiofrequencynumber.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiofrequencynumber.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,390 @@ +/* +* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Frequency number handling for manual tuning dialog +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include + +#include "fmradiofrequencynumber.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CFMRadioFrequencyNumber::CFMRadioFrequencyNumber(TInt aMinimumValue, TInt aMaximumValue, TUint32 aFlags) + : iMinimumValue(aMinimumValue), iMaximumValue(aMaximumValue), iFlags(aFlags) + { + // Get maximum number of digits. + TBuf<16> maxText; + maxText.AppendNum(static_cast(aMaximumValue)); + iMaxDigits = maxText.Length(); + } + +// EPOC default constructor can leave. +void CFMRadioFrequencyNumber::ConstructL(const CFont& aFont, TInt aInitialValue) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::ConstructL") ) ); + // Init text field containing the value. + iText = HBufC::NewL(iMaxDigits); + SetValue(aInitialValue, aFont); + } + +// Two-phased constructor. +CFMRadioFrequencyNumber* CFMRadioFrequencyNumber::NewL(const CFont& aFont, TInt aMinimumValue, TInt aMaximumValue, TInt aInitialValue, TUint32 aFlags) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::NewL") ) ); + CFMRadioFrequencyNumber* self = new (ELeave) CFMRadioFrequencyNumber(aMinimumValue, aMaximumValue, aFlags); + CleanupStack::PushL(self); + self->ConstructL(aFont, aInitialValue); + CleanupStack::Pop(); + return self; + } + + +// Destructor +CFMRadioFrequencyNumber::~CFMRadioFrequencyNumber() + { + delete iText; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::MaximumWidthInPixels +// TInt addedWith is calculated same way than in TInt CEikMfneField::AdditionalWidthForHighlights, +// which is public but not exported method. +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyNumber::MaximumWidthInPixels(const CFont& aFont, TBool /*aShrinkToMinimumSize*/) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::MaximumWidthInPixels") ) ); + TInt addedWidth = 0; + if ( IsEditable() ) + { + TInt rightHighlight = 0; + TAknTextDecorationMetrics metrics( &aFont ); + // Width is increased only by leftHighlight. This is a compromise in that glyphs already have + // spacing within them to achieve character spacing. This spacing is generally (for numbers) on the right. + metrics.GetLeftAndRightMargins( addedWidth, rightHighlight ); // rightHighlight is not used + } + + return (iMaxDigits * TFindWidthOfWidestDigitType(iDigitType).MaximumWidthInPixels(aFont)) + addedWidth; + } + + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::InputCapabilities +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TCoeInputCapabilities CFMRadioFrequencyNumber::InputCapabilities() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::InputCapabilities") ) ); + return TCoeInputCapabilities::EWesternNumericIntegerPositive; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::Text +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +const TDesC& CFMRadioFrequencyNumber::Text() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::Text") ) ); + + if (iFlags & EIsUninitialised) + { + return KNullDesC(); + } + + return *iText; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::SetValue +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioFrequencyNumber::SetValue(TInt aValue, const CFont& aFont) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::SetValue") ) ); + iFlags &= ~EIsUninitialised; + TPtr text = iText->Des(); + text.SetLength(0); + TInt firstUnsetCharacter = text.Length(); + text.SetLength(firstUnsetCharacter + iMaxDigits); + TInt lastUnsetCharacter = text.Length() - 1; + + if (aValue == 0) + { + text[lastUnsetCharacter--] = TText(iDigitType); + } + else + { + for (; aValue; aValue/=10) + { + text[lastUnsetCharacter--] = (TText)(TText(iDigitType) + (aValue%10)); + } + } + + if (lastUnsetCharacter >= firstUnsetCharacter) + { + if (iFlags & EFillWithLeadingZeros) + { + while (lastUnsetCharacter >= firstUnsetCharacter) + { + text[lastUnsetCharacter--] = TText(iDigitType); + } + } + else + { + text.Delete(firstUnsetCharacter, (lastUnsetCharacter + 1) - firstUnsetCharacter); + } + } + + if (iFlags & EPreserveOldWidthBeforeEditing) + { + iMinimumWidthInPixels = aFont.TextWidthInPixels(Text()); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::Value +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyNumber::Value() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::Value") ) ); + if (iText->Length() == 0) + { + CAknKeySoundSystem* soundPlayer = (static_cast(CEikonEnv::Static()->AppUi()))->KeySounds(); + if (soundPlayer) + { + soundPlayer->PlaySound(EAvkonSIDWarningTone); + } + CBaActiveScheduler::LeaveNoAlert(); + } + + return ValueFromText(); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::IsValid +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyNumber::IsValid() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::IsValid") ) ); + return (iText->Length() != 0); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::IsEditable +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyNumber::IsEditable() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::IsEditable") ) ); + return ETrue; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::HighlightType +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +CEikMfneField::THighlightType CFMRadioFrequencyNumber::HighlightType() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::HighlightType") ) ); + return (iFlags & EIsBeingEditedWithCursor) ? ECursor : EInverseVideo; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::HandleKey +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioFrequencyNumber::HandleKey(const CFont& /*aFont*/, const TKeyEvent& aKeyEvent, TBool /*aInterpretLeftAndRightAsEarEvents*/, TBool& aDataAltered, TInt& aHighlightIncrement) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::HandleKey") ) ); + TChar ch = aKeyEvent.iCode; + TPtr text = iText->Des(); + TInt textLength = text.Length(); + + switch (ch) + { + case EKeyLeftArrow: + case EKeyRightArrow: + { + HandleLeftOrRightArrow(ch, aDataAltered, aHighlightIncrement); + break; + } + case EKeyBackspace: + { + if (textLength) + { + iFlags |= EIsBeingEditedWithCursor; + text.SetLength(textLength-1); + aDataAltered = ETrue; + iFlags &= ~EIsUninitialised; + } + break; + } + default: + { + // Number key: + if (ch.GetNumericValue() != KErrNotFound) + { + if (~iFlags & EIsBeingEditedWithCursor) + { + // If only one number field, do not change to cursor mode. + if (iMaxDigits > 1) + { + iFlags |= EIsBeingEditedWithCursor; + } + text.SetLength(0); + } + + TBuf<1> normCh; + normCh.Append(ch); + NumberConversion::ConvertDigits(normCh, iDigitType); + text.Append(normCh[0]); + aDataAltered = ETrue; + iFlags &= ~EIsUninitialised; + if (iText->Length() >= iMaxDigits) + { + aHighlightIncrement = 1; + } + } + break; + } + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::HandleDeHighlight +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioFrequencyNumber::HandleDeHighlight(const CFont& aFont, CEikonEnv& aEikonEnv, TBool& aDataAltered, TBool& aError) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::HandleDeHighlight") ) ); + iFlags &= ~EIsBeingEditedWithCursor; + + if (iText->Length() == 0) + { + SetValue(iMaximumValue, aFont); + aDataAltered = ETrue; + aError = ETrue; + aEikonEnv.InfoMsg(R_EIK_TBUF_NO_NUMBER_ENTERED); + return; + } + + TInt value = ValueFromText(); + TBuf<128> oldText = *iText; + TBool unInit = iFlags & EIsUninitialised; + SetValue(value, aFont); + + if (oldText != *iText) + { + aDataAltered = ETrue; + } + else + { + if (unInit) + { + iFlags |= EIsUninitialised; + } + else + { + iFlags &= ~EIsUninitialised; + } + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyNumber::ValueFromText +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyNumber::ValueFromText() const + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyNumber::ValueFromText") ) ); + if (!iText->Length()) + { + return iMinimumValue; + } + + TInt i = 0; + TInt valueFromText = 0; + TInt textLength = iText->Length(); + + for (; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiofrequencyquerycontrol.h" +#include "fmradiofrequencyeditor.h" +#include "fmradio.hrh" +#include "debug.h" + +// CONSTANTS + +const TInt KFMRadioButtonLongPressDelay = 450; //microseconds after long press event is reported +const TInt KFMRadioButtonRepeatDelay = 500; //microseconds after repeat event is reported +const TInt KFMRadioButtonRepeatInterval = 200; //microseconds after repeat event is repeated +const TInt KFMRadioButtonRepeatDelayMicroseconds(KFMRadioButtonRepeatDelay*1000); +const TInt KFMRadioButtonRepeatIntervalMicrosecondsAccelerated(KFMRadioButtonRepeatInterval*500); +const TInt KFMRadioButtonRepeatAccelerationDelay(2000000); //Two seconds until accelerate long press repeat + +const TInt KEditorFrameCustomLRMargins = 50; +const TInt KEditorFrameCustomAdditionHeight = 30; + +const TInt KFMRadioEditorCustomInnerFrameSize = 15; +const TInt KFMRadioEditorCustomButtonMarginToLeftFrame = 1; +const TInt KFMRadioEditorCustomButtonSize = 16; + + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CFMRadioFrequencyQueryControl::CFMRadioFrequencyQueryControl() : CAknQueryControl() + { + } + +// Destructor +CFMRadioFrequencyQueryControl::~CFMRadioFrequencyQueryControl() + { + if (iFreqEditor) + AknsUtils::DeregisterControlPosition(iFreqEditor); + delete iFreqEditor; + delete iMyPrompt; + delete iMyEditorIndicator; + delete iEditorContext; + + if ( iLongPressAccelerationTimer ) + { + iLongPressAccelerationTimer->Cancel(); + delete iLongPressAccelerationTimer; + } + if ( iLongPressTimer) + { + iLongPressTimer->Cancel(); + delete iLongPressTimer; + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::StaticCreateCustomControl +// --------------------------------------------------------- +// +SEikControlInfo CFMRadioFrequencyQueryControl::StaticCreateCustomControl(TInt aIdentifier) +{ + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyQueryControl::StaticCreateCustomControl -- ENTER") ) ); + SEikControlInfo customInfo; + Mem::FillZ(&customInfo, sizeof(SEikControlInfo)); // zero all variables + + if (aIdentifier == EFMRadioCtFrequencyQuery) + { + customInfo.iControl = new CFMRadioFrequencyQueryControl; + } + + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyQueryControl::StaticCreateCustomControl -- EXIT") ) ); + return customInfo; +} + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::ConstructQueryL +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::ConstructQueryL(TResourceReader& aRes) + { + + iFreqEditor = new (ELeave) CFMRadioFrequencyEditor; + iFreqEditor->SetContainerWindowL(*this); + iFreqEditor->ConstructFromResourceL(aRes); + iFreqEditor->SetObserver(this); + iFreqEditor->SetSkinTextColorL( EAknsCIQsnTextColorsCG27 );//query text input field + + iMyPrompt = new (ELeave) CEikLabel; + iMyPrompt->SetContainerWindowL( *this ); + HBufC* promptTxt = StringLoader::LoadLC( R_QTN_FMRADIO_MANUAL_TUNE_FREQ ); + iMyPrompt->SetTextL( *promptTxt ); + CleanupStack::PopAndDestroy( promptTxt ); + + iMyEditorIndicator = CFMRadioManualTuningEditorIndicator::NewL( this ); + + // Construct editor context + iEditorContext = CAknsFrameBackgroundControlContext::NewL( + KAknsIIDQsnFrInput, TRect(0,0,1,1), TRect(0,0,1,1), EFalse ); + + if ( AknLayoutUtils::PenEnabled() ) + { + // Buttons with correct icons + iIncreaseValueButton = + CAknButton::NewL(KAvkonBitmapFile, + EMbmAvkonQgn_indi_button_increase, + EMbmAvkonQgn_indi_button_increase_mask, + -1, + -1, + EMbmAvkonQgn_indi_button_increase_pressed, + EMbmAvkonQgn_indi_button_increase_pressed_mask, + -1, + -1, + KNullDesC, + KNullDesC, + KAknButtonNoFrame /*| KAknButtonKeyRepeat*/ | KAknButtonReportOnLongPress, + 0, + KAknsIIDQgnIndiButtonIncrease, + KAknsIIDNone, + KAknsIIDQgnIndiButtonIncreasePressed, + KAknsIIDNone ); + iIncreaseValueButton->SetContainerWindowL(*this); + iIncreaseValueButton->SetParent(this); + iIncreaseValueButton->SetObserver(this); + iIncreaseValueButton->MakeVisible(ETrue); + iIncreaseValueButton->SetFocusing(EFalse); + iIncreaseValueButton->SetKeyRepeatInterval( KFMRadioButtonRepeatDelay, KFMRadioButtonRepeatInterval ); + iIncreaseValueButton->SetLongPressInterval( KFMRadioButtonLongPressDelay ); + + iDecreaseValueButton = + CAknButton::NewL(KAvkonBitmapFile, + EMbmAvkonQgn_indi_button_decrease, + EMbmAvkonQgn_indi_button_decrease_mask, + -1, + -1, + EMbmAvkonQgn_indi_button_decrease_pressed, + EMbmAvkonQgn_indi_button_decrease_pressed_mask, + -1, + -1, + KNullDesC, + KNullDesC, + KAknButtonNoFrame /*| KAknButtonKeyRepeat*/ | KAknButtonReportOnLongPress, + 0, + KAknsIIDQgnIndiButtonDecrease, + KAknsIIDNone, + KAknsIIDQgnIndiButtonDecreasePressed, + KAknsIIDNone ); + iDecreaseValueButton->SetContainerWindowL(*this); + iDecreaseValueButton->SetParent(this); + iDecreaseValueButton->SetObserver(this); + iDecreaseValueButton->MakeVisible(ETrue); + iDecreaseValueButton->SetFocusing(EFalse); + iDecreaseValueButton->SetKeyRepeatInterval( KFMRadioButtonRepeatDelay, KFMRadioButtonRepeatInterval ); + iDecreaseValueButton->SetLongPressInterval( KFMRadioButtonLongPressDelay ); + } + + iLongPressAccelerationTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + iLongPressTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::ComponentControl +// --------------------------------------------------------- +// +CCoeControl* CFMRadioFrequencyQueryControl::ComponentControl(TInt aIndex) const + { + /*lint -save -e1763*/ + CCoeControl* ccontrol = NULL; + + switch (aIndex) + { + case 0: + { + ccontrol = iMyPrompt; + break; + } + case 1: + { + ccontrol = iMyEditorIndicator; + break; + } + case 2: + { + ccontrol = iFreqEditor; + break; + } + case 3: + { + if ( AknLayoutUtils::PenEnabled() ) + { + ccontrol = iIncreaseValueButton; + } + break; + } + + case 4: + { + if ( AknLayoutUtils::PenEnabled() ) + { + ccontrol = iDecreaseValueButton; + } + break; + } + + default: + { + ccontrol = NULL; + break; + } + } + return ccontrol; + /*lint -restore*/ + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::CountComponentControls +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyQueryControl::CountComponentControls() const + { + if ( AknLayoutUtils::PenEnabled() ) + { + return 5; + } + else + { + return 3; + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::FocusChanged +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::FocusChanged(TDrawNow aDrawNow) + { + if (iFreqEditor) + { + iFreqEditor->SetFocus(IsFocused(), aDrawNow); + SizeChanged(); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::PrepareForFocusLossL +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::PrepareForFocusLossL() + { + if (iFreqEditor) + { + iFreqEditor->PrepareForFocusLossL(); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::SetAcceleratedLongPress +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::SetAcceleratedLongPress(TBool aAccelerated) + { + iLongPressAccelerationTimer->Cancel(); + iLongPressTimer->Cancel(); + + if( aAccelerated) + { + //add more speed + iLongPressTimer->Start(KFMRadioButtonRepeatIntervalMicrosecondsAccelerated, + KFMRadioButtonRepeatIntervalMicrosecondsAccelerated, + TCallBack(LongPressTimerCallBack, this)); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LongPressAccelerateCallBack +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyQueryControl::LongPressAccelerateCallBack( TAny* aAny ) + { + ((CFMRadioFrequencyQueryControl*)(aAny))->SetAcceleratedLongPress(ETrue); + return KErrNone; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LongPressTimerCallBack +// --------------------------------------------------------- +// +TInt CFMRadioFrequencyQueryControl::LongPressTimerCallBack( TAny* aAny ) + { + ((CFMRadioFrequencyQueryControl*)(aAny))->DoIncrementOrDecrement(); + return KErrNone; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::DoIncrementOrDecrement +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::DoIncrementOrDecrement() + { + if(iChangeDirectionIncrease) + { + iFreqEditor->IncrementCurrentField(); + } + else + { + iFreqEditor->DecrementCurrentField(); + } + + iKeyPressReported = ETrue; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::StartKeypress +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::StartKeypress() + { + iKeyPressReported = EFalse; + iLongPressAccelerationTimer->Cancel(); + iLongPressAccelerationTimer->Start(KFMRadioButtonRepeatAccelerationDelay, 0, + TCallBack(LongPressAccelerateCallBack, this)); + iLongPressTimer->Start(KFMRadioButtonRepeatDelayMicroseconds, + KFMRadioButtonRepeatDelayMicroseconds, + TCallBack(LongPressTimerCallBack, this)); + iFreqEditor->SetEditorReportState( EFalse ); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::OfferKeyEventL +// --------------------------------------------------------- +// +TKeyResponse CFMRadioFrequencyQueryControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) + { + if ( aType == EEventKeyDown && + (aKeyEvent.iScanCode == EStdKeyUpArrow || aKeyEvent.iScanCode == EStdKeyDownArrow) ) + { + iChangeDirectionIncrease = (aKeyEvent.iScanCode == EStdKeyUpArrow); + StartKeypress(); + + return EKeyWasConsumed; + } + else if ( aType == EEventKeyUp && + (aKeyEvent.iScanCode == EStdKeyUpArrow || aKeyEvent.iScanCode == EStdKeyDownArrow) ) + { + if(!iKeyPressReported) + { + //was not a long press + DoIncrementOrDecrement(); + } + + SetAcceleratedLongPress(EFalse); + iFreqEditor->SetEditorReportState( ETrue ); + iFreqEditor->DrawAndReportL( EFalse ); + + return EKeyWasConsumed; + } + + //eat all up and down events, this is for EEventKey + if(aKeyEvent.iScanCode == EStdKeyUpArrow || aKeyEvent.iScanCode == EStdKeyDownArrow) + { + return EKeyWasConsumed; + } + + return iFreqEditor->OfferKeyEventL(aKeyEvent, aType); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::HandleControlEventL +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType) + { + if ( aEventType == CAknButton::ELongPressEndedEvent ) + { + SetAcceleratedLongPress(EFalse); + iFreqEditor->SetEditorReportState( ETrue ); + iFreqEditor->DrawAndReportL( EFalse ); + } + + if ( (aControl == iIncreaseValueButton || aControl == iDecreaseValueButton ) + && aEventType == CAknButton::ELongPressEvent ) + { + iChangeDirectionIncrease = (aControl == iIncreaseValueButton); + StartKeypress(); + return; + } + + //single presses + if ( aControl == iIncreaseValueButton && aEventType == EEventStateChanged ) + { + iFreqEditor->IncrementCurrentField(); + return; + } + + else if ( aControl == iDecreaseValueButton && aEventType == EEventStateChanged ) + { + iFreqEditor->DecrementCurrentField(); + return; + } + + //finally tune to the frequency + if (iQueryControlObserver && aEventType == EEventStateChanged) + { + if ( iFreqEditor->IsValidToReport() ) + { + MAknQueryControlObserver::TQueryValidationStatus validity = MAknQueryControlObserver::EEditorValueValid; + if ( !iFreqEditor->IsValid() ) + { + validity = MAknQueryControlObserver::EEditorValueNotParsed; + } + iQueryControlObserver->HandleQueryEditorStateEventL( this, MAknQueryControlObserver::EQueryControlEditorStateChanging, validity ); + } + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::SetFrequency +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::SetFrequency(const TUint32 aFreq) + { + if (iFreqEditor) + { + iFreqEditor->SetFrequency(aFreq); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::Frequency +// --------------------------------------------------------- +// +TUint32 CFMRadioFrequencyQueryControl::Frequency() const + { + if (iFreqEditor) + { + return iFreqEditor->Frequency(); + } + return 0; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::ControlByLayoutOrNull +// --------------------------------------------------------- +// +CCoeControl* CFMRadioFrequencyQueryControl::ControlByLayoutOrNull(TInt /*aLayout*/) + { + return iFreqEditor; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::EditorContentIsValidL +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyQueryControl::EditorContentIsValidL() const + { + TInt ret = EFalse; + if (iFreqEditor) + { + CEikMfne* editor = iFreqEditor; + ret = editor->Field(editor->CurrentField())->IsValid(); + } + return ret; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::SetAndUseFlags +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::SetAndUseFlags(TBitFlags16 aFlags) + { + iFlags = aFlags; + iMyEditorIndicator->SetFlags(aFlags); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutEditor +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::LayoutEditor(const TLayoutMethod& aLayoutM) + { + TIndex LAFIndex(NbrOfPromptLines()); + iHasEditor = ETrue; + LayoutEditorFrame(aLayoutM); + LayoutEditorIndicator(aLayoutM); + + CEikMfne* edwin = NULL; + + if ( iFreqEditor ) + { + edwin = iFreqEditor; + } + + if ( edwin ) + { + TInt variety( LAFIndex.PromptLine() ); + if ( AknLayoutUtils::PenEnabled() ) + { + variety = NbrOfPromptLines() != 0 ? ( 6 - NbrOfPromptLines() ) : 5; + } + TAknWindowLineLayout lineLayout( AknLayoutScalable_Avkon::query_popup_pane( variety ) ); + TAknTextComponentLayout textLayout( AknLayoutScalable_Avkon::query_popup_pane_t1() ); + if ( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + lineLayout.it = iDialogSize.iHeight / 2 - lineLayout.iH / 2; + } + + AknLayoutUtils::LayoutMfne( edwin, LayoutRect(), + TAknWindowComponentLayout::ComposeText( + lineLayout, + textLayout ) ); + + + edwin->SetBorder( TGulBorder::ENone ); + if ( IsFocused() && !edwin->IsFocused() ) + { + edwin->SetFocus( ETrue ); + } + edwin->SetUpAndDownKeysConsumed( ETrue ); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutPrompt +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::LayoutPrompt(const TLayoutMethod& /*aLayoutM*/) + { + if (iMyPrompt) + { + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + TRgb color; + TInt error = AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); + + AknLayoutUtils::LayoutLabel(iMyPrompt, LayoutRect(), AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_1(0) ); + + if (!error) + { + TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL( *iMyPrompt, EColorLabelText, color ) ) + } + } + + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutImageOrAnim +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::LayoutImageOrAnim(const TLayoutMethod& /*aLayoutM*/) + { + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutEditorFrame +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::LayoutEditorFrame(const TLayoutMethod& /*aLayoutM*/) + { + TIndex LAFIndex(NbrOfPromptLines()); + TRect rect = LayoutRect(); + + TInt variety( LAFIndex.PromptLine() ); + TAknWindowLineLayout lineLayout(AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_1( variety )); + lineLayout.il += KEditorFrameCustomLRMargins; + lineLayout.ir += KEditorFrameCustomLRMargins; + lineLayout.it -= KEditorFrameCustomAdditionHeight/2; + lineLayout.ib -= KEditorFrameCustomAdditionHeight/2; + lineLayout.iH += KEditorFrameCustomAdditionHeight; + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + lineLayout.it = iDialogSize.iHeight/ 2 - lineLayout.iH / 2; + } + iEditorVerShadow.LayoutRect( rect, lineLayout ); + + lineLayout = AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_2( variety ); + lineLayout.il += KEditorFrameCustomLRMargins; + lineLayout.ir += KEditorFrameCustomLRMargins; + lineLayout.it -= KEditorFrameCustomAdditionHeight/2; + lineLayout.ib -= KEditorFrameCustomAdditionHeight/2; + lineLayout.iH += KEditorFrameCustomAdditionHeight; + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + lineLayout.it = iDialogSize.iHeight/ 2 - lineLayout.iH / 2; + } + iEditorHorShadow.LayoutRect( rect, lineLayout ); + + // variety needs to be adjusted for touch layouts. + if ( AknLayoutUtils::PenEnabled() ) + { + variety = NbrOfPromptLines() != 0 ? ( 6 - NbrOfPromptLines() ) : 5; + } + lineLayout = AknLayoutScalable_Avkon::query_popup_pane( variety ); + lineLayout.il += KEditorFrameCustomLRMargins; + lineLayout.ir += KEditorFrameCustomLRMargins; + lineLayout.it -= KEditorFrameCustomAdditionHeight/2; + lineLayout.ib -= KEditorFrameCustomAdditionHeight/2; + lineLayout.iH += KEditorFrameCustomAdditionHeight; + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + lineLayout.it = iDialogSize.iHeight/ 2 - lineLayout.iH / 2; + } + iEditorFrame.LayoutRect( rect, lineLayout ); + iFreqEditor->SetEditorFrameRect( iEditorFrame.Rect() ); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutEditorIndicator +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::LayoutEditorIndicator(const TLayoutMethod& /*aLayoutM*/) + { + TIndex LAFIndex(NbrOfPromptLines()); + + if (!iMyEditorIndicator) + return; + + TInt variety( LAFIndex.PromptLine() ); + if ( AknLayoutUtils::PenEnabled() ) + { + // adjust layout variety for touch + variety = 5 - variety; + } + TAknWindowLineLayout lineLayout(AknLayoutScalable_Avkon::indicator_popup_pane( variety )); + lineLayout.ir += KEditorFrameCustomLRMargins; + lineLayout.it -= KEditorFrameCustomAdditionHeight/2; + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + lineLayout.it = iDialogSize.iHeight / 2 - lineLayout.iH - iEditorFrame.Rect().Height()/2; + } + AknLayoutUtils::LayoutControl(iMyEditorIndicator, LayoutRect(), lineLayout ); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::LayoutRect +// --------------------------------------------------------- +// +TRect CFMRadioFrequencyQueryControl::LayoutRect() + { + TPoint topLeft = Position(); + TRect parent( TPoint(0,0), iDialogSize ); + TAknLayoutRect layout; + + layout.LayoutRect(parent, AKN_LAYOUT_WINDOW_Note_pop_up_window_graphics_Line_5(parent)); + + TRect rect(layout.Rect()); + topLeft.iX -= rect.iTl.iX; + topLeft.iY -= rect.iTl.iY; + + TPoint bottomRight (topLeft); + TSize size (iDialogSize); + bottomRight.iY += size.iHeight; + bottomRight.iX += size.iWidth; + return TRect(topLeft,bottomRight); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::SetLineWidthsL +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::SetLineWidthsL() + { + if (!iLineWidths) + return; + + iLineWidths->Reset(); + TAknWindowLineLayout lineLayout(AknLayoutScalable_Avkon::popup_query_code_window(0)); + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + lineLayout.it += KFMRadioFrequencyQueryDialogCustomAdditionHeight / 2; + + TAknLayoutRect parentLayoutRect; + parentLayoutRect.LayoutRect(iAvkonAppUi->ClientRect(), lineLayout); + + TAknLayoutText textRect; + for (TInt i = 0; i < 3; i++) + { + TAknTextLineLayout textLineLayout = AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_1(i); + if ( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + textLineLayout.iB -= KFMRadioFrequencyQueryDialogCustomAdditionHeight / 2; + } + textRect.LayoutText(parentLayoutRect.Rect(), textLineLayout); + iLineWidths->AppendL(textRect.TextRect().Width()); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::Draw +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::Draw(const TRect& /*aRect*/) const + { + CWindowGc& gc=SystemGc(); + TRect rect(Rect()); + + TRect dialogRect(TPoint(0,0), iDialogSize ); + rect.iBr.iY += dialogRect.iBr.iY; + + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + + TRgb color; + TInt error = AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); + if ( !error ) + { + TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL( *(CAknQueryControl*)this, EColorLabelText, color ) ); + } + + MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); + AknsDrawUtils::Background( skin, cc, this, gc, rect ); + DrawFrequencyEditorFrame(gc,rect); + } + +/** + * Draw frequency editor frame and shadow + */ +void CFMRadioFrequencyQueryControl::DrawFrequencyEditorFrame(CWindowGc& aGc,TRect& /*aRect*/) const + { + if (iHasEditor) + { + TBool skinnedDraw( EFalse ); + skinnedDraw = AknsDrawUtils::Background( + AknsUtils::SkinInstance(), + iEditorContext, + aGc, + iEditorFrame.Rect() ); + + if( !skinnedDraw ) + { + iEditorFrame.DrawOutLineRect(aGc); + iEditorVerShadow.DrawRect(aGc); + iEditorHorShadow.DrawRect(aGc); + } + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::SizeChanged. +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::SizeChanged() + { + if (iMyPrompt) + { + iMyPrompt->SetRect(LayoutRect()); + LayoutPrompt(ETimeQueryLayoutM); + } + if (iFreqEditor) + { + LayoutEditor(ETimeQueryLayoutM); + } + + if( iHasEditor && iEditorContext ) + { + // Layout editor context + TAknLayoutRect topLeft; + TAknLayoutRect bottomRight; + + TAknWindowLineLayout lineLayout(SkinLayout::Input_field_skin_placing__general__Line_2()); + topLeft.LayoutRect(iEditorFrame.Rect(), lineLayout ); + bottomRight.LayoutRect(TRect(iEditorFrame.Rect().iBr, iEditorFrame.Rect().iBr), SkinLayout::Input_field_skin_placing__general__Line_5()); + + TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); + TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); + + outerRect.iTl.iY -= KFMRadioEditorCustomInnerFrameSize; + outerRect.iBr.iY += KFMRadioEditorCustomInnerFrameSize; + + innerRect.iTl.iY -= KFMRadioEditorCustomInnerFrameSize; + innerRect.iBr.iY += KFMRadioEditorCustomInnerFrameSize; + + iEditorContext->SetFrameRects( outerRect, innerRect ); + // Chain with the background (since the frame doesn't occupy the entire + // layout and it may even be transparent) + iEditorContext->SetParentContext( AknsDrawUtils::ControlContextOfParent( this ) ); + + if ( AknLayoutUtils::PenEnabled() ) + { + if ( !iIncreaseValueButton ) + { + TRAPD( err, iIncreaseValueButton = + CAknButton::NewL(KAvkonBitmapFile, + EMbmAvkonQgn_indi_button_increase, + EMbmAvkonQgn_indi_button_increase_mask, + -1, + -1, + EMbmAvkonQgn_indi_button_increase_pressed, + EMbmAvkonQgn_indi_button_increase_pressed_mask, + -1, + -1, + KNullDesC, + KNullDesC, + KAknButtonNoFrame | KAknButtonKeyRepeat | KAknButtonReportOnLongPress, + 0, + KAknsIIDQgnIndiButtonIncrease, + KAknsIIDNone, + KAknsIIDQgnIndiButtonIncreasePressed, + KAknsIIDNone ); + iIncreaseValueButton->SetContainerWindowL(*this); + ); + + if ( err == KErrNone ) + { + iIncreaseValueButton->SetParent(this); + iIncreaseValueButton->SetObserver(this); + iIncreaseValueButton->MakeVisible(ETrue); + iIncreaseValueButton->SetFocusing(EFalse); + iIncreaseValueButton->SetKeyRepeatInterval( KFMRadioButtonRepeatDelay, KFMRadioButtonRepeatInterval ); + iIncreaseValueButton->SetLongPressInterval( KFMRadioButtonLongPressDelay ); + } + } + + if ( !iDecreaseValueButton ) + { + TRAPD( err, iDecreaseValueButton = CAknButton::NewL(KAvkonBitmapFile, + EMbmAvkonQgn_indi_button_decrease, + EMbmAvkonQgn_indi_button_decrease_mask, + -1, + -1, + EMbmAvkonQgn_indi_button_decrease_pressed, + EMbmAvkonQgn_indi_button_decrease_pressed_mask, + -1, + -1, + KNullDesC, + KNullDesC, + KAknButtonNoFrame | KAknButtonKeyRepeat | KAknButtonReportOnLongPress, + 0, + KAknsIIDQgnIndiButtonDecrease, + KAknsIIDNone, + KAknsIIDQgnIndiButtonDecreasePressed, + KAknsIIDNone ); + iDecreaseValueButton->SetContainerWindowL(*this); + ); + + if ( err == KErrNone ) + { + iDecreaseValueButton->SetParent(this); + iDecreaseValueButton->SetObserver(this); + iDecreaseValueButton->MakeVisible(ETrue); + iDecreaseValueButton->SetFocusing(EFalse); + iDecreaseValueButton->SetKeyRepeatInterval( KFMRadioButtonRepeatDelay, KFMRadioButtonRepeatInterval ); + iDecreaseValueButton->SetLongPressInterval( KFMRadioButtonLongPressDelay ); + } + } + // Position the buttons according to LAF + + TIndex LAFIndex(NbrOfPromptLines()); + TInt variety( 5 - LAFIndex.PQCWindow() ); + + AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); + TInt offset = 0; + if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) + { + offset = 3; + } + else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) + { + offset = 6; + } + variety += offset; + + TAknWindowComponentLayout btnSpaceLayout; + + btnSpaceLayout = AknLayoutScalable_Avkon::button_value_adjust_pane( variety ); + + if ( iIncreaseValueButton ) + { + TAknWindowLineLayout buttonIncr = TAknWindowComponentLayout::Compose( + btnSpaceLayout, + AknLayoutScalable_Avkon::button_value_adjust_pane_g1()).LayoutLine(); + + TInt marginToNumberFrame = KEditorFrameCustomLRMargins - + KFMRadioEditorCustomButtonMarginToLeftFrame - KFMRadioEditorCustomButtonSize; + + buttonIncr.ir += marginToNumberFrame; + buttonIncr.iH += KFMRadioEditorCustomButtonSize; + buttonIncr.iW += KFMRadioEditorCustomButtonSize; + + if ( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + buttonIncr.it = iDialogSize.iHeight / 2 - buttonIncr.iH; + } + + TAknLayoutRect increaseValueButtonRect; + increaseValueButtonRect.LayoutRect( LayoutRect(), buttonIncr ); + iIncreaseValueButton->SetRect(increaseValueButtonRect.Rect()); + } + + if ( iDecreaseValueButton) + { + TAknWindowLineLayout buttonDecr = TAknWindowComponentLayout::Compose( + btnSpaceLayout, + AknLayoutScalable_Avkon::button_value_adjust_pane_g2()).LayoutLine(); + + TInt marginToNumberFrame = KEditorFrameCustomLRMargins - + KFMRadioEditorCustomButtonMarginToLeftFrame - KFMRadioEditorCustomButtonSize; + + buttonDecr.ir += marginToNumberFrame; + buttonDecr.iH += KFMRadioEditorCustomButtonSize; + buttonDecr.iW += KFMRadioEditorCustomButtonSize; + + if ( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + buttonDecr.it = iDialogSize.iHeight / 2; + } + TAknLayoutRect decreaseValueButtonRect; + decreaseValueButtonRect.LayoutRect( LayoutRect(), buttonDecr ); + iDecreaseValueButton->SetRect(decreaseValueButtonRect.Rect()); + } + } + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::MopSupplyObject +// --------------------------------------------------------- +// +TTypeUid::Ptr CFMRadioFrequencyQueryControl::MopSupplyObject(TTypeUid aId) + { + if( (aId.iUid == MAknsControlContext::ETypeId) && + iEditorContext && iHasEditor ) + { + // Return specific context iff editor exists and the context + // has been constructed. + return MAknsControlContext::SupplyMopObject( + aId, iEditorContext ); + } + + if ( aId.iUid == CAknQueryControl::ETypeId ) + { + return aId.MakePtr( this ); + } + + return SupplyMopObject(aId, iMyEditorIndicator); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::WindowLayout +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::WindowLayout( TAknWindowLineLayout& aLayout ) const + { + TIndex LAFIndex(NbrOfPromptLines()); + + aLayout = AknLayoutScalable_Avkon::popup_query_code_window(LAFIndex.PQCWindow()); + if( KFMRadioFrequencyQueryDialogCustomAdditionHeight ) + { + aLayout.iH += KFMRadioFrequencyQueryDialogCustomAdditionHeight; + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::CanLeaveEditorL +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyQueryControl::CanLeaveEditorL() + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyQueryControl::CanLeaveEditorL") ) ); + + if (iFreqEditor) + { + return iFreqEditor->CanLeaveEditorL(); + } + return ETrue; + } + + +/********************************* + * CFMRadioManualTuningEditorIndicator + *********************************/ + +CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator* CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::NewL(CCoeControl* aControl) + { + CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator* self = new(ELeave)CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator(); + CleanupStack::PushL(self); + self->ConstructL(aControl); + CleanupStack::Pop(self); + return self; + } + +CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::~CFMRadioManualTuningEditorIndicator() + { + } + +CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::CFMRadioManualTuningEditorIndicator() : CAknIndicatorContainer(CAknIndicatorContainer::EQueryEditorIndicators) + { + } + +void CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::ConstructL(CCoeControl* aControl) + { + CreateWindowL(aControl); + + TResourceReader reader; + iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_NAVI_PANE_EDITOR_INDICATORS); + ConstructFromResourceL(reader); + CleanupStack::PopAndDestroy(); // resource reader + + SetExtent(TPoint(0,0), TSize(0,0)); + MakeVisible( EFalse ); + //ActivateL(); + } + +void CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::SetState(TAknEditingState aState) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::SetState (%d)"), (int)aState ) ); + if (AknLayoutUtils::Variant() == EEuropeanVariant) + { + SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorNumberCase), (aState == ENumeric) ? EAknIndicatorStateOn : EAknIndicatorStateOff, EFalse); + SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorArabicIndicNumberCase), (aState == EArabicIndicNumeric) ? EAknIndicatorStateOn : EAknIndicatorStateOff, EFalse); + SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorQuery), (aState == EStateNone) ? EAknIndicatorStateOff : EAknIndicatorStateOn, EFalse); + } + else + { + SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorNumberCase), (aState == ENumeric) ? EAknIndicatorStateOn : EAknIndicatorStateOff, EFalse); + SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorQuery), (aState == EStateNone) ? EAknIndicatorStateOff : EAknIndicatorStateOn, EFalse); + } + + MakeVisible( EFalse ); + //DrawDeferred(); + } + +CAknIndicatorContainer* CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::IndicatorContainer() + { + return this; + } + +void CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::SetFlags(TBitFlags16 aFlags) + { + iBitFlags = aFlags; + } + +void CFMRadioFrequencyQueryControl::CFMRadioManualTuningEditorIndicator::Reserved_1() + { + } + +/***************************************************************** + * CFMRadioFrequencyQueryControl::TIndex + * + * Manage indexes into LAF tables + * + * PN stands for "Popup Note" + * + * PQD stands for "Popup Query Data' + * + * PQC stands for "Popup Query Code' + * + * 'DPQ' stands for "Data Query Popup" + ******************************************************************/ + + +CFMRadioFrequencyQueryControl::TIndex::TIndex(TInt aNumberOfPromptLines) + : iNumberOfPromptLines(aNumberOfPromptLines) + { + } + +/** + * Return index into LAF tables that depend directly on number of prompt lines, + * index is equal to number of prompt lines minus one unless there are no prompt + * lines in which case the index is zero + */ +TInt CFMRadioFrequencyQueryControl::TIndex::PromptLine() const + { + return iNumberOfPromptLines > 0 ? iNumberOfPromptLines - 1 : 0; + } + +/** + * Return index into Main Pane PQDC Window, which + * depends on total number of prompt lines minus 2, e.g. + * index 0 for 2 prompt lines total. + * + */ +TInt CFMRadioFrequencyQueryControl::TIndex::DQPWindowTextsLine2(TInt aLineNum) const + { + static const TInt KDataQueryPopupWindowTextsLine2Index[3][5] = + { {0, 1, 2, 3, 4}, //1 PROMPT LINE + {5, 6, 7, 8, 9}, //2 PROMPT LINES + {10, 10, 10, 10, 10} }; //3 PROMPT LINES + + return KDataQueryPopupWindowTextsLine2Index[PromptLine()][aLineNum-1]; + } + +TInt CFMRadioFrequencyQueryControl::TIndex::PNWindow() const + { + static const TInt KPopupNoteWindowIndex[5] = { 0,0,0,1,2 }; + + AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); + if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) + { + // variety numbers for right CBA are 3,4 and 5 + return (KPopupNoteWindowIndex[PromptLine()] + 3); + } + else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) + { + /// variety numbers for left CBA are 6,7 and 8 + return (KPopupNoteWindowIndex[PromptLine()] + 6); + } + else // bottom + { + return KPopupNoteWindowIndex[PromptLine()]; + } + } + +TInt CFMRadioFrequencyQueryControl::TIndex::PQDWindow(TInt aLineNum) const + { + AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); + + if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) + { + static const TInt KPopupQueryDataWindowIndex[7] = + {13, 12, 11, 10, 9, 8, 7}; // variety numbers for right CBA are 7-13 + return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1]; + } + else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) + { + static const TInt KPopupQueryDataWindowIndex[7] = + {20, 19, 18, 17, 16, 15, 14}; // variety numbers for left CBA are 14-20 + return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1]; + } + else // bottom + { + static const TInt KPopupQueryDataWindowIndex[7] = + {0, 1, 2, 3, 4, 5, 6}; // variety numbers for bottom CBA are 0-6 + return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1]; + } + } + +TInt CFMRadioFrequencyQueryControl::TIndex::PQCWindow() const + { + AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); + + if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) + { + // variety numbers for right CBA are 3,4 and 5 + return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1 + 3) : 3; + } + else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) + { + // variety numbers for left CBA are 6,7 and 8 + return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1 + 6) : 6; + } + else // bottom + { + // variety numbers for bottom CBA are 0,1 and 2 + return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1) : 0; + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryControl::HandlePointerEventL +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryControl::HandlePointerEventL( const TPointerEvent& aPointerEvent ) + { + CCoeControl::HandlePointerEventL( aPointerEvent ); + iFreqEditor->HandlePointerEventL( aPointerEvent ); + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiofrequencyquerydialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiofrequencyquerydialog.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Manual tuning dialog for FMRadio +* +*/ + + +// INCLUDE FILES +#include +#include + +#include + +#include "fmradiofrequencyquerydialog.h" +#include "fmradiofrequencyquerycontrol.h" +#include "fmradio.hrh" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CFMRadioFrequencyQueryDialog::CFMRadioFrequencyQueryDialog(TUint32& aFreq, const TTone& aTone) : CAknQueryDialog(aTone), iFreq(aFreq) + { + } + +// Two-phased constructor. +CFMRadioFrequencyQueryDialog* CFMRadioFrequencyQueryDialog::NewL(TUint32& aFreq, const TTone& aTone) + { + CFMRadioFrequencyQueryDialog* self = new (ELeave) CFMRadioFrequencyQueryDialog(aFreq, aTone); + CleanupStack::PushL(self); + CEikonEnv::Static()->AddLibraryL(CFMRadioFrequencyQueryControl::StaticCreateCustomControl); + CleanupStack::Pop(self); + return self; + } + + +// Destructor +CFMRadioFrequencyQueryDialog::~CFMRadioFrequencyQueryDialog() + { + CEikonEnv::Static()->RemoveLibrary(CFMRadioFrequencyQueryControl::StaticCreateCustomControl); + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::QueryControl +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +CAknQueryControl* CFMRadioFrequencyQueryDialog::QueryControl() const + { + CEikCaptionedControl* controlPtr = NULL; + const TInt KMaxNumPages = GetNumberOfPages(); + for (TInt pageCount=0; pageCountiControlType == EFMRadioCtFrequencyQuery) + { + return static_cast(controlPtr->iControl); + } + } + } + return 0; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::PreLayoutDynInitL +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryDialog::PreLayoutDynInitL() + { + // SetBorder(AknBorderId::EAknBorderNotePopup); + SetBorder( TGulBorder::ENone ); + SetEditableL(ETrue) ; + + CFMRadioFrequencyQueryControl* control = static_cast(QueryControl()); + if (control) + { + control->SetQueryControlObserver(this); + control->SetFrequency(iFreq); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::HandleQueryEditorStateEventL +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyQueryDialog::HandleQueryEditorStateEventL(CAknQueryControl* aQueryControl, TQueryControlEvent aEventType, TQueryValidationStatus aStatus) + { + FTRACE( FPrint( _L(" *** FM Radio -- CFMRadioFrequencyQueryDialog::HandleQueryEditorStateEventL") ) ); + CAknQueryDialog::HandleQueryEditorStateEventL(aQueryControl, aEventType, aStatus); + CFMRadioFrequencyQueryControl* control = static_cast(aQueryControl); + if ((control) && (aStatus == MAknQueryControlObserver::EEditorValueValid) && (iFreq != control->Frequency())) + { + iFreq = control->Frequency(); + ReportEventL(EEventStateChanged); + } + return ETrue; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::Frequency +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TUint32 CFMRadioFrequencyQueryDialog::Frequency() const + { + return iFreq; + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::UpdateLeftSoftKeyL +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioFrequencyQueryDialog::UpdateLeftSoftKeyL() + { + CFMRadioFrequencyQueryControl* control = static_cast(QueryControl()); + if ( control ) + { + TBool showCommand = control->EditorContentIsValidL(); + ButtonGroupContainer().MakeCommandVisibleByPosition( CEikButtonGroupContainer::ELeftSoftkeyPosition, showCommand ); + ButtonGroupContainer().MakeCommandVisibleByPosition( CEikButtonGroupContainer::EMiddleSoftkeyPosition, showCommand ); + ButtonGroupContainer().DrawDeferred(); + } + } + +// --------------------------------------------------------- +// CFMRadioFrequencyQueryDialog::OkToExitL +// --------------------------------------------------------- +// +TBool CFMRadioFrequencyQueryDialog::OkToExitL(TInt /*aButtonId*/) + { + CFMRadioFrequencyQueryControl* control = static_cast(QueryControl()); + return control->CanLeaveEditorL(); + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioglobalconfirmationquery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioglobalconfirmationquery.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,127 @@ +/* +* 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: Source file of CFMRadioGlobalConfirmationQuery +* +*/ + + +#include + +#include "fmradiodefines.h" +#include "fmradioapp.h" +#include "fmradioglobalconfirmationquery.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::CFMRadioGlobalConfirmationQuery +// --------------------------------------------------------------------------- +// +CFMRadioGlobalConfirmationQuery::CFMRadioGlobalConfirmationQuery(MFMRadioGlobalConfirmationQueryObserver* aObserver) + : CActive( CActive::EPriorityStandard ), iObserver(aObserver) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioGlobalConfirmationQuery::ConstructL() + { + iAknGlobalConfirmationQuery = CAknGlobalConfirmationQuery::NewL(); + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::NewL +// --------------------------------------------------------------------------- +// +CFMRadioGlobalConfirmationQuery* CFMRadioGlobalConfirmationQuery::NewL(MFMRadioGlobalConfirmationQueryObserver* aObserver) + { + CFMRadioGlobalConfirmationQuery* self = CFMRadioGlobalConfirmationQuery::NewLC(aObserver); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::NewLC +// --------------------------------------------------------------------------- +// +CFMRadioGlobalConfirmationQuery* CFMRadioGlobalConfirmationQuery::NewLC(MFMRadioGlobalConfirmationQueryObserver* aObserver) + { + CFMRadioGlobalConfirmationQuery* self = NULL; + self = new( ELeave ) CFMRadioGlobalConfirmationQuery(aObserver); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::~CFMRadioGlobalConfirmationQuery +// --------------------------------------------------------------------------- +// +CFMRadioGlobalConfirmationQuery::~CFMRadioGlobalConfirmationQuery() + { + Cancel(); + delete iAknGlobalConfirmationQuery; + delete iText; + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::ShowQueryL +// --------------------------------------------------------------------------- +// +void CFMRadioGlobalConfirmationQuery::ShowQueryL(const TDesC& aText, TInt aSoftkeys, TInt aAnimation/*, TInt aDialogId*/) + { + Cancel(); + delete iText; + iText = NULL; + iText = aText.AllocL(); + iAknGlobalConfirmationQuery->ShowConfirmationQueryL( iStatus, *iText, aSoftkeys, aAnimation ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::DoCancel +// --------------------------------------------------------------------------- +// +void CFMRadioGlobalConfirmationQuery::DoCancel() + { + if ( iAknGlobalConfirmationQuery ) + { + iAknGlobalConfirmationQuery->CancelConfirmationQuery(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::RunL +// --------------------------------------------------------------------------- +// +void CFMRadioGlobalConfirmationQuery::RunL() + { + if ( iObserver ) + { + iObserver->GlobalConfirmationQueryDismissedL(iStatus.Int()); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioGlobalConfirmationQuery::RunError +// --------------------------------------------------------------------------- +// +TInt CFMRadioGlobalConfirmationQuery::RunError(TInt /*aError*/) + { + return KErrNone; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioidlecontroller.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioidlecontroller.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,130 @@ +/* +* 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: fmradio media idle controller +* +*/ + +#include "fmradioidlecontroller.h" +#include "fmradioidlecontrolinterface.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +// ---------------------------------------------------------------------------- +// CFMRadioIdleController::CFMRadioIdleController +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioIdleController::CFMRadioIdleController() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioIdleController::ConstructL() + { + FTRACE( FPrint( _L("CFMRadioIdleController::ConstructL()") ) ); + } + + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::NewL +// Two-phase constructor of CFMRadioPreset +// --------------------------------------------------------------------------- +// +CFMRadioIdleController* CFMRadioIdleController::NewL() + { + FTRACE( FPrint( _L("CFMRadioIdleController::NewL()") ) ); + CFMRadioIdleController* self = new ( ELeave ) CFMRadioIdleController(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::~CFMRadioIdleController +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioIdleController::~CFMRadioIdleController() + { + FTRACE( FPrint( _L("CFMRadioIdleController::~CFMRadioIdleController()") ) ); + iControlArray.Close(); + } + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::AddControlItem +// --------------------------------------------------------------------------- +// +void CFMRadioIdleController::AddControlItem( const MFMRadioIdleControlInterface& aControl ) + { + TInt index = iControlArray.FindInAddressOrder( &aControl ); + if ( index == KErrNotFound ) + { + iControlArray.InsertInAddressOrder( &aControl ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::ShowControl +// --------------------------------------------------------------------------- +// +void CFMRadioIdleController::ShowControl( const MFMRadioIdleControlInterface& aControl ) + { + for ( TInt i = 0; i < iControlArray.Count(); i++ ) + { + MFMRadioIdleControlInterface* controlItem = iControlArray[i]; + // show requested item + if ( &aControl == controlItem ) + { + controlItem->Show(); + } + else // hide rest of the items + { + controlItem->Hide(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::HideAllControls +// --------------------------------------------------------------------------- +// +void CFMRadioIdleController::HideAllControls() + { + FTRACE( FPrint( _L("CFMRadioIdleController::HideAllControls()") ) ); + for ( TInt i = 0; i < iControlArray.Count(); i++ ) + { + iControlArray[i]->Hide(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioIdleController::DeactivateControls +// --------------------------------------------------------------------------- +// +void CFMRadioIdleController::DeactivateControls() + { + FTRACE( FPrint( _L("CFMRadioIdleController::DeactivateControls()") ) ); + for ( TInt i = 0; i < iControlArray.Count(); i++ ) + { + iControlArray[i]->Deactivate(); + } + } + +// end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiologo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiologo.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,353 @@ +/* +* 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: Implementation of the class CFMRadioLogo +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiologo.h" +#include "fmradioalfrdsviewobserver.h" +#include "fmradiodefines.h" +#include "debug.h" +#include "fmradiologoobserver.h" + +// CONSTANTS + +const TInt KLogoFadeInDefaultDurationTime = 500; +const TInt KLogoFadeOutDefaultDurationTime = 500; +const TInt KLogoDisplayPeriod = 2000; // milliseconds = 2 sec +const TReal KDefaultOpacityInVisibleState = 1.0f; +const TReal KDefaultOpacityInHiddenState = 0.0f; +const TInt KLAFVarietyBackgroundImagePortrait = 0; +const TInt KLAFVarietyBackgroundImageLandscape = 1; +// bitmap file for the background of the display +_LIT8( KBitmapAnchorTag, "BitmapAnchorTag" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CFMRadioLogo::NewL +// Two-phase constructor of CFMRadioAlfLogo +// --------------------------------------------------------------------------- +// +CFMRadioLogo* CFMRadioLogo::NewL( CAlfEnv& aEnv ) + { + CFMRadioLogo* self = new ( ELeave ) CFMRadioLogo(); + CleanupStack::PushL( self ); + self->ConstructL( aEnv ); + CleanupStack::Pop( self ); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioLogo::CFMRadioLogo +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioLogo::CFMRadioLogo() +: iOpacityInVisibleState( KDefaultOpacityInVisibleState ), + iOpacityInHiddenState( KDefaultOpacityInHiddenState ), + iIsVisible( ETrue ) // visible by default + { + //No implementation needed + } + + +// ---------------------------------------------------------------------------- +// CFMRadioLogo::SetObserver +// Sets observer +// ---------------------------------------------------------------------------- +// +void CFMRadioLogo::SetObserver( MFMRadioLogoObserver* aObserver ) + { + FTRACE( FPrint( _L( "CFMRadioLogo::SetObserver" ) ) ); + TInt index = iObservers.FindInAddressOrder( aObserver ); + if ( index == KErrNotFound ) + { + iObservers.InsertInAddressOrder( aObserver ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioLogo::RemoveObserver +// Removes observer +// ---------------------------------------------------------------------------- +// +void CFMRadioLogo::RemoveObserver( MFMRadioLogoObserver* aObserver ) + { + FTRACE( FPrint( _L( "CFMRadioLogo::RemoveObserver" ) ) ); + TInt index = iObservers.FindInAddressOrder( aObserver ); + + if ( index >= 0 ) + { + iObservers.Remove( index ); + } + } + +// ---------------------------------------------------------------------------- +// CFMRadioLogo::ConstructL +// Symbian 2nd phase constructor can leave. +// ---------------------------------------------------------------------------- +// +void CFMRadioLogo::ConstructL( CAlfEnv& aEnv ) + { + FTRACE( FPrint( _L( "CFMRadioLogo::ConstructL" ) ) ); + CAlfControl::ConstructL( aEnv ); + CreateImageVisualsL(); + } + +// --------------------------------------------------------------------------- +// ~CFMRadioLogo::~CFMRadioLogo +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioLogo::~CFMRadioLogo() + { + FTRACE( FPrint( _L( "CFMRadioLogo::Destructor" ) ) ); + Env().CancelCustomCommands( this ); + iObservers.Close(); + delete iBackgroundBitmapFileName; + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::OfferEventL +// From CAlfControl, takes care of alfred event handling. +// --------------------------------------------------------------------------- +// +TBool CFMRadioLogo::OfferEventL( const TAlfEvent& aEvent ) + { + FTRACE( FPrint( _L( "CFMRadioLogo::OfferEventL" ) ) ); + TBool eventHandled = EFalse; + + if ( aEvent.IsCustomEvent() ) + { + switch( aEvent.CustomParameter() ) + { + case EFadeInCompleted: + { + eventHandled = ETrue; + Env().Send( TAlfCustomEventCommand( ELogoDisplayTimerCompleted, this ), KLogoDisplayPeriod ); + break; + } + case ELogoDisplayTimerCompleted: + { + eventHandled = ETrue; + for ( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->LogoDisplayTimeCompleted(); + } + break; + } + default: + { + break; + } + } + } + return eventHandled; + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::SetRect +// Sets the logo rectangle. +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::SetRect( const TRect& aRect ) + { + iRect = aRect; + if ( iLogoAnchor ) + { + SetAbsoluteCornerAnchors( iLogoAnchor, 0, iRect.iTl, iRect.iBr ); + iLogoAnchor->UpdateChildrenLayout(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::CreateImageVisualsL +// Creates visual for the logo +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::CreateImageVisualsL() + { + // locate source mbm + CCoeEnv* coeEnv = CCoeEnv::Static(); + TFindFile finder( coeEnv->FsSession() ); + TInt err = finder.FindByDir( KFMRadioBmpFile, KDC_APP_BITMAP_DIR ); + if ( err == KErrNone ) + { + iBackgroundBitmapFileName = finder.File().AllocL(); + } + + iLogoAnchor = CAlfAnchorLayout::AddNewL( *this ); + iLogoAnchor->SetTagL( KBitmapAnchorTag ); + + iImageVisual = CAlfImageVisual::AddNewL( *this, iLogoAnchor ); + + // read bitmap size from layout data + TRect temp; + TAknLayoutRect bitmapLayout; + bitmapLayout.LayoutRect( + temp, + AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( KLAFVarietyBackgroundImagePortrait ).LayoutLine() ); + + // image for portrait + iPortraitImage = TAlfImage( KAknsIIDNone, + bitmapLayout.Rect().Size(), + EAspectRatioPreserved, + iBackgroundBitmapFileName, + EMbmFmradioQgn_indi_radio_default, + EMbmFmradioQgn_indi_radio_default_mask ); + + // image for landscape + bitmapLayout.LayoutRect( + temp, + AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( KLAFVarietyBackgroundImageLandscape ).LayoutLine() ); + + iLandscapeImage = TAlfImage( KAknsIIDNone, + bitmapLayout.Rect().Size(), + EAspectRatioPreserved, + iBackgroundBitmapFileName, + EMbmFmradioQgn_indi_radio_default, + EMbmFmradioQgn_indi_radio_default_mask ); + + iImageVisual->SetImage( iPortraitImage ); + iImageVisual->SetSecondaryImage( iLandscapeImage ); + } + +// --------------------------------------------------------- +// CFMRadioLogo::Show +// Fades in the logo with predefined opacity value. +// --------------------------------------------------------- +// +void CFMRadioLogo::Show() + { + // change status only, fade in and the event are allways triggered so don't + // check visibility here + iIsVisible = ETrue; + Env().CancelCustomCommands( this ); + Fade( iImageVisual, KLogoFadeInDefaultDurationTime, iOpacityInVisibleState ); + Env().Send( TAlfCustomEventCommand( EFadeInCompleted, this ), KLogoFadeInDefaultDurationTime ); + } + +// --------------------------------------------------------- +// CFMRadioLogo::Hide +// Fades out the logo with predefined opacity value. +// --------------------------------------------------------- +// +void CFMRadioLogo::Hide() + { + if ( iIsVisible ) + { + iIsVisible = EFalse; + Fade( iImageVisual, KLogoFadeOutDefaultDurationTime, iOpacityInHiddenState ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::SetOpacityInVisibleState +// Sets the indicator opacity in visible state. +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::SetOpacityInVisibleState( const TReal aOpacity ) + { + iOpacityInVisibleState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::SetOpacityInHiddenState +// Sets the logo opacity value in hidden state. +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::SetOpacityInHiddenState( const TReal aOpacity ) + { + iOpacityInHiddenState = aOpacity; + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::SetAbsoluteCornerAnchors +// Sets absolute rect of the anchor by top left and bottom right points. +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, + TInt aOrdinal, + const TPoint& aTopLeftPosition, + const TPoint& aBottomRightPosition ) + { + if ( aAnchor ) + { + // Set top/left anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeTopLeft, + TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + + + // Set bottom/right anchor. + aAnchor->Attach( aOrdinal, + EAlfAnchorTypeBottomRight, + TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), + EAlfAnchorAttachmentOriginTopLeft ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::Fade +// Sets the fading animation to the CAlfVisual object. +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity ) + { + TAlfTimedValue opacity; + opacity.SetTarget( aOpacity, aFadingTime ); + aVisual->SetOpacity( opacity ); + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::SwitchToLandscapeImage +// Use secondary image for landscape and primary for portrait +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::SwitchToLandscapeImage( TBool aShow ) + { + if ( aShow ) + { + iImageVisual->SetSecondaryAlpha( TAlfTimedValue( 1.0 ) ); + } + else + { + iImageVisual->SetSecondaryAlpha( TAlfTimedValue( 0.0 ) ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioLogo::Deactivate +// from MFMRadioIdleControlInterface +// --------------------------------------------------------------------------- +// +void CFMRadioLogo::Deactivate() + { + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiomaincontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiomaincontainer.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,815 @@ +/* +* 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: Implementation of the class CFMRadioMainContainer +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiomaincontainer.h" +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE +#include "radio.hlp.hrh" +#endif +#include "fmradioengine.h" +#include "fmradioalfrdsviewer.h" +#include "fmradioalfvisualizer.h" +#include "fmradioalfmediaidle.h" +#include "fmradioalfindicator.h" +#include "fmradiologo.h" +#include "fmradiordsreceiverbase.h" +#include "fmradioalfrdsviewer.h" +#include "fmradiomainview.h" +#include "fmradioidlecontroller.h" +#include "debug.h" + + +// ~3 seconds, 10 frames / second is used +const TInt KFadeFrames = 30; +const TInt KTenMilliSecondsInMicroSeconds = 100000; +// values from fmradio LAF document +const TInt KLAFVarietyRDSViewerPortrait = 0; +const TInt KLAFVarietyRDSViewerLandscape = 1; +const TInt KLAFVarietyRDSPlusIndicatorPortrait = 0; +const TInt KLAFVarietyRDSPlusIndicatorLandscape = 1; +const TInt KLAFVarietyAFIndicatorPortrait = 0; +const TInt KLAFVarietyAFIndicatorLandscape = 1; +const TInt KLAFVarietyRDSIndicatorPortrait = 0; +const TInt KLAFVarietyRDSIndicatorLandscape = 1; +const TInt KLAFVarietyLogoImagePortrait = 0; +const TInt KLAFVarietyLogoImageLandscape = 1; +const TInt KLAFVarietyIndicatorPanePortrait = 0; +const TInt KLAFVarietyIndicatorPaneLandscape = 1; +const TInt KLAFVarietyVisualPanePortrait = 0; +const TInt KLAFVarietyVisualPaneLandscape = 1; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------------- +// CFMRadioTimer::CFMRadioTimer +// --------------------------------------------------------------------------------- +CFMRadioTimer::CFMRadioTimer( MFMRadioTimer* aTimerObserver ) : + CActive( EPriorityStandard ), + iTimerObserver( aTimerObserver ) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------------- +// CFMRadioTimer::~CFMRadioTimer +// --------------------------------------------------------------------------------- +CFMRadioTimer::~CFMRadioTimer() + { + + Cancel(); + } + +// --------------------------------------------------------------------------------- +// CFMRadioTimer::RunL +// --------------------------------------------------------------------------------- +void CFMRadioTimer::RunL() + { + + iTimerObserver->TimerTimeOut( iStatus.Int() ); + } + +// --------------------------------------------------------------------------------- +// CFMRadioTimer::DoCancel +// --------------------------------------------------------------------------------- +void CFMRadioTimer::DoCancel() + { + + TInt ret = KErrCancel; + iTimerObserver->TimerTimeOut( ret ); + } + +// --------------------------------------------------------------------------------- +// CFMRadioTimer::Activate +// --------------------------------------------------------------------------------- +void CFMRadioTimer::Activate() + { + SetActive(); + } + + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::NewL +// Two-phase constructor of CFMRadioDelayTimer +// -------------------------------------------------------------------------------- +// +CFMRadioMainContainer* CFMRadioMainContainer::NewL( + const TRect& aRect, + CAlfEnv& aAlfEnv, + CRadioEngine& aRadioEngine ) + { + CFMRadioMainContainer* self = new (ELeave) CFMRadioMainContainer( aAlfEnv, aRadioEngine ); + CleanupStack::PushL( self ); + self->ConstructL( aRect ); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::CFMRadioMainContainer +// Default constructor +// -------------------------------------------------------------------------------- +// +CFMRadioMainContainer::CFMRadioMainContainer( CAlfEnv& aAlfEnv, CRadioEngine& aRadioEngine ) : + iAlfEnv ( aAlfEnv ), + iRadioEngine (aRadioEngine ), + iLightsOffCounter(0) + { + //No implementation needed + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::ConstructL +// EPOC two phased constructor +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::ConstructL( + const TRect& aRect ) + { + iCoeEnv = CCoeEnv::Static(); + + TRAP_IGNORE( iLight = CHWRMLight::NewL(this) ); + iTimer = new(ELeave) CFMRadioTimer( this ); + timer.CreateLocal(); + + // check the layout orientation + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + TBool isLandscape = appUi->IsLandscapeOrientation(); + + TRgb color; + + AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); + //CreateWindowL(); // create a window for the container + + // Create alfred display + CAlfDisplay* display = NULL; + if ( iAlfEnv.DisplayCount() > 0 ) + { + display = &(iAlfEnv.PrimaryDisplay()); + } + else + { + display = &(iAlfEnv.NewDisplayL( aRect, CAlfEnv::ENewDisplayAsCoeControl )); + } + + // Setup background. + display->SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground ); + + // Create the control group for HUI visual controls + CAlfControlGroup* group; + if( display->Roster().Count() > 0) + { + group = &( iAlfEnv.ControlGroup( KFMRadioVisualControlsGroupId ) ); + + iVisualControl = static_cast + ( display->Roster().FindControl( KFMRadioVisualControlId ) ); + iMediaIdle = static_cast + ( display->Roster().FindControl( KFMRadioMediaIdleId ) ); + iRdsIndicator = static_cast + ( display->Roster().FindControl( KFMRadioRdsIndicatorId ) ); + iRdsAfIndicator = static_cast + ( display->Roster().FindControl( KFMRadioRdsAfIndicatorId ) ); + iRdsViewer = static_cast + ( display->Roster().FindControl( KFMRadioRdsViewer ) ); + iRdsInteractionIndicator = static_cast + ( display->Roster().FindControl( KFMRadioRdsInteractionIndicatorId ) ); + + iRadioLogo = static_cast + ( display->Roster().FindControl( KFMRadioLogoId ) ); + } + else + { + group = &(iAlfEnv.NewControlGroupL( KFMRadioVisualControlsGroupId ) ); + // Create the vizualizer control for information of the FMRadio + iVisualControl = CFMRadioAlfVisualizer::NewL( iAlfEnv ); + iVisualControl->SetId( KFMRadioVisualControlId ); + // Create the media idle + iMediaIdle = CFMRadioAlfMediaIdle::NewL( iAlfEnv ); + iMediaIdle->SetId( KFMRadioMediaIdleId ); + + // RDS + HBufC* rdsText = StringLoader::LoadLC( R_QTN_FMRADIO_RDS, iCoeEnv ); + iRdsIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); + iRdsIndicator->SetId( KFMRadioRdsIndicatorId ); + iRdsIndicator->SetTextColor( color ); + iRdsIndicator->SetTextL( *rdsText ); + iRdsIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); + CleanupStack::PopAndDestroy( rdsText ); + + // AF + HBufC* afText = StringLoader::LoadLC( R_QTN_FMRADIO_AF, iCoeEnv ); + iRdsAfIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); + iRdsAfIndicator->SetId( KFMRadioRdsAfIndicatorId ); + iRdsAfIndicator->SetTextColor( color ); + iRdsAfIndicator->SetTextL( *afText ); + iRdsAfIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); + CleanupStack::PopAndDestroy( afText ); + + iRdsViewer = CFMRadioAlfRDSViewer::NewL( iAlfEnv ); + iRdsViewer->SetId( KFMRadioRdsViewer ); + iRdsViewer->SetTextColor( color ); + iRdsViewer->SetOpacityInHiddenState( KFMRadioRdsViewerOpacityHidden ); + + // + + HBufC* interactionText = StringLoader::LoadLC( R_QTN_FMRADIO_RTPLUS_INDICATOR_TEXT, iCoeEnv ); + iRdsInteractionIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); + iRdsInteractionIndicator->SetId( KFMRadioRdsInteractionIndicatorId ); + iRdsInteractionIndicator->SetTextColor( color ); + iRdsInteractionIndicator->SetTextL( *interactionText ); + iRdsInteractionIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); + CleanupStack::PopAndDestroy( interactionText ); + + // radio icon + iRadioLogo = CFMRadioLogo::NewL( iAlfEnv ); + iRadioLogo->SetId( KFMRadioLogoId ); + + // Append the controls into the control group. + group->AppendL( iMediaIdle ); + group->AppendL( iVisualControl ); + group->AppendL( iRdsIndicator ); + group->AppendL( iRdsAfIndicator ); + group->AppendL( iRdsViewer ); + group->AppendL( iRdsInteractionIndicator ); + group->AppendL( iRadioLogo ); + } + + iIdleController = CFMRadioIdleController::NewL(); + // Add media idle visuals to the controller. + // Only one of the media idle visuals is visible at a time. + iIdleController->AddControlItem( *iRdsViewer ); + iIdleController->AddControlItem( *iMediaIdle ); + iIdleController->AddControlItem( *iRadioLogo ); + + iMainPaneRect = aRect; + + UpdateTextColorFromSkin(); + SizeChanged(); + //Make the control group active on the display + display->Roster().ShowL( *group ); + display->SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground ); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::Destructor +// -------------------------------------------------------------------------------- +// +CFMRadioMainContainer::~CFMRadioMainContainer() + { + if ( iTimer->IsActive() ) + { + iTimer->Cancel(); + } + + delete iTimer; + iTimer = NULL; + timer.Close(); + + delete iLight; + iLight = NULL; + delete iIdleController; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::SetFaded +// Fades the entire window and controls in the window owned +// by this container control. +// ------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::SetFaded( TBool aFaded ) + { + iFadeStatus = aFaded; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::DisplayChannelInfoL +// Display the channel information +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::DisplayChannelInfoL( + TInt aChannelNumber, + const TDesC& aStationName, + TFMRadioStationChangeType aChangeType, + TInt aFrequency ) + { + HBufC* firstLine = NULL; + HBufC* secondLine = NULL; + TBool programmeServiceNameExists = iRadioEngine.RdsReceiver().ProgrammeService().Length(); + CFMRadioRdsReceiverBase::TFMRadioProgrammeSeviceType PSNameType = + iRadioEngine.RdsReceiver().ProgrammeServiceNameType(); + + TBool useStaticPsName = EFalse; + if ( !aStationName.Length() && + PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameStatic && + programmeServiceNameExists ) + { + useStaticPsName = ETrue; + } + const TDesC& stationName = useStaticPsName ? iRadioEngine.RdsReceiver().ProgrammeService() : aStationName; + + if ( !stationName.Length() ) + { + // PS Name is concidered as dynamic + if( aChannelNumber == KErrNotFound ) + { + firstLine = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_FREQ ); + CleanupStack::PushL( firstLine ); + if( programmeServiceNameExists ) + { + secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); + } + } + else + { + TReal frequency = static_cast( aFrequency / static_cast( KHzConversionFactor )); + + // Gets locale decimal separator automatically + TInt maxDecimalPlaces = iRadioEngine.DecimalCount(); + TRealFormat format( KFrequencyMaxLength, maxDecimalPlaces ); + TBuf frequencyString; + frequencyString.Num( frequency, format ); + AknTextUtils::LanguageSpecificNumberConversion( frequencyString ); + + firstLine = StringLoader::LoadLC( R_QTN_FMRADIO_MEM_LOCATION_FREQ, + frequencyString, aChannelNumber, iCoeEnv ); + + if( programmeServiceNameExists ) + { + secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); + } + } + } + else + { + if( aChannelNumber == KErrNotFound ) + { + firstLine = stationName.AllocLC(); + } + else + { + firstLine = StringLoader::LoadLC( R_QTN_FMRADIO_MEM_LOCATION_NAME, + stationName, aChannelNumber, iCoeEnv ); + } + + if ( programmeServiceNameExists && + PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameDynamic ) + { + // PS Name is concidered as dynamic + secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); + } + else + { + secondLine = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_FREQ ); + } + } + CleanupStack::PushL( secondLine ); + + if( AknLayoutUtils::LayoutMirrored() ) + { + // Add right to left mark in the beginning so that the text is laid out correctly + firstLine = firstLine->ReAllocL( firstLine->Length() + KRightToLeftMark().Length() ); + CleanupStack::Pop( 2 ); // secondLine and old firstLine + CleanupStack::PushL( firstLine ); + CleanupStack::PushL( secondLine ); + firstLine->Des().Insert( 0, KRightToLeftMark ); + + if ( secondLine ) + { + secondLine = secondLine->ReAllocL( secondLine->Length() + KRightToLeftMark().Length() ); + CleanupStack::Pop(); // old secondLine + CleanupStack::PushL( secondLine ); + secondLine->Des().Insert( 0, KRightToLeftMark ); + } + } + + iVisualControl->ChangeStationL( aChangeType, *firstLine, secondLine ); + + HBufC* frequencyString = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_MEDIA_IDLE_FREQ ); + CleanupStack::PushL( frequencyString ); + iMediaIdle->AddMediaIdleContentL( *frequencyString ); + CleanupStack::PopAndDestroy( frequencyString ); + if( aStationName.Length() ) + { + iMediaIdle->AddMediaIdleContentL( stationName ); + } + if ( aStationName != iRadioEngine.RdsReceiver().ProgrammeService() && + PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameStatic ) + { + iMediaIdle->AddPsNameToMediaIdleL( iRadioEngine.RdsReceiver().ProgrammeService() ); + } + + CleanupStack::PopAndDestroy( 2, firstLine ); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::FormattedFrequencyStringL +// Format the frequency +// -------------------------------------------------------------------------------- +// +HBufC* CFMRadioMainContainer::FormattedFrequencyStringL( TInt aFrequency, TInt aResourceId ) + { + TReal frequency = static_cast( aFrequency / static_cast( KHzConversionFactor )); + + // Gets locale decimal separator automatically + TInt maxDecimalPlaces = iRadioEngine.DecimalCount(); + TRealFormat format( KFrequencyMaxLength, maxDecimalPlaces ); + TBuf frequencyString; + frequencyString.Num( frequency, format ); + AknTextUtils::LanguageSpecificNumberConversion( frequencyString ); + + return StringLoader::LoadL( aResourceId, frequencyString, iCoeEnv );; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::ShowRTPlusInteractionIndicator +// Hide/show the RT+ interaction indicator with optional fade effecct +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::ShowRTPlusInteractionIndicator( TBool aVisible, TBool aFadeEffect) + { + if (aVisible) + iRdsInteractionIndicator->Show( aFadeEffect ); + else + iRdsInteractionIndicator->Hide( aFadeEffect ); + } + +// --------------------------------------------------------- +// CFMRadioMainContainer::ShowRdsInfo +// --------------------------------------------------------- +// +void CFMRadioMainContainer::ShowRdsInfo( TBool aShow, TBool aFade, TBool aShowAfMarquee ) + { + if( aShow ) + { + iRdsIndicator->Show( aFade ); + + if( aShowAfMarquee ) + { + iRdsAfIndicator->Show( aFade ); + } + else + { + iRdsAfIndicator->Hide( aFade ); + } + } + else + { + iRdsIndicator->Hide( aFade ); + + iRdsAfIndicator->Hide( aFade ); + } + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioMainContainer::HandleResourceChange +// Handles resource changes +// ---------------------------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::HandleResourceChange( TInt aType ) + { + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + AknLayoutUtils::LayoutMetricsRect( + AknLayoutUtils::EMainPane, iMainPaneRect); + SizeChanged(); + TRAP_IGNORE( iAlfEnv.NotifyLayoutChangedL() ) + iIdleController->ShowControl( *iRadioLogo ); + } + else if ( aType == KAknsMessageSkinChange ) + { + UpdateTextColorFromSkin(); + TRAP_IGNORE( iAlfEnv.NotifySkinChangedL() ); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::SetRect +// Sets rectangle of the alfred display +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::SetRect( const TRect& aRect ) + { + iMainPaneRect = aRect; + SizeChanged(); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::SizeChanged +// Called when the view size is changed +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::SizeChanged() + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + iAlfEnv.PrimaryDisplay().ForceSetVisibleArea( iMainPaneRect ); + + TAknLayoutRect layoutRect; + TAknLayoutText textLayout; + TAknLayoutRect indicatorLayoutRect; + TAknLayoutRect visualPaneLayoutRect; + + TRect displayRect( iMainPaneRect.Size() ); + + iVisualControl->SetMirrored( appUi->IsLayoutMirrored() ); + TBool isLandscape = appUi->IsLandscapeOrientation(); + + TDisplayOrientation alfDisplayOrientation = EPortrait; + CFMRadioAlfMediaIdle::TOrientation mediaIdleOrientation = CFMRadioAlfMediaIdle::EPortrait; + + TInt lafVarietyRdsIndicator = 0; + TInt lafVarietyAfIndicator = 0; + TInt lafVarietyPlusIndicator = 0; + TInt lafVarietyRdsText = 0; + TInt lafVarietyLogo = 0; + TInt lafVarietyIndicatorPane = 0; + TInt lafVarietyVisualPane = 0; + TBool useLandscapeImage = EFalse; + + if ( isLandscape ) + { + alfDisplayOrientation = ELandscape; + mediaIdleOrientation = CFMRadioAlfMediaIdle::ELandscape; + + lafVarietyRdsIndicator = KLAFVarietyRDSIndicatorLandscape; + lafVarietyAfIndicator = KLAFVarietyAFIndicatorLandscape; + lafVarietyPlusIndicator = KLAFVarietyRDSPlusIndicatorLandscape; + lafVarietyRdsText = KLAFVarietyRDSViewerLandscape; + lafVarietyLogo = KLAFVarietyLogoImageLandscape; + lafVarietyIndicatorPane = KLAFVarietyIndicatorPaneLandscape; + lafVarietyVisualPane = KLAFVarietyVisualPaneLandscape; + useLandscapeImage = ETrue; + } + else + { + lafVarietyRdsIndicator = KLAFVarietyRDSIndicatorPortrait; + lafVarietyAfIndicator = KLAFVarietyAFIndicatorPortrait; + lafVarietyPlusIndicator = KLAFVarietyRDSPlusIndicatorPortrait; + lafVarietyRdsText = KLAFVarietyRDSViewerPortrait; + lafVarietyLogo = KLAFVarietyLogoImagePortrait; + lafVarietyIndicatorPane = KLAFVarietyIndicatorPanePortrait; + lafVarietyVisualPane = KLAFVarietyVisualPanePortrait; + } + // indicator pane + indicatorLayoutRect.LayoutRect( displayRect, + AknLayoutScalable_Apps::fmrd2_indi_pane( lafVarietyIndicatorPane ) ); + + // RDS indicator + textLayout.LayoutText( indicatorLayoutRect.Rect(), + AknLayoutScalable_Apps::fmrd2_indi_pane_t3( lafVarietyRdsIndicator ).LayoutLine() ); + + iRdsIndicator->SetRect( textLayout.TextRect() ); + + // AF indicator + textLayout.LayoutText( indicatorLayoutRect.Rect(), + AknLayoutScalable_Apps::fmrd2_indi_pane_t2( lafVarietyAfIndicator ).LayoutLine() ); + + iRdsAfIndicator->SetRect( textLayout.TextRect() ); + + // + indicator + textLayout.LayoutText( indicatorLayoutRect.Rect(), + AknLayoutScalable_Apps::fmrd2_indi_pane_t1( lafVarietyPlusIndicator ).LayoutLine() ); + + iRdsInteractionIndicator->SetRect( textLayout.TextRect() ); + + // RDS Text pane + layoutRect.LayoutRect( displayRect, + AknLayoutScalable_Apps::area_fmrd2_visual_pane( lafVarietyRdsText ).LayoutLine() ); + + iRdsViewer->SetRect( layoutRect.Rect() ); + + // radio icon + visualPaneLayoutRect.LayoutRect( displayRect, + AknLayoutScalable_Apps::area_fmrd2_visual_pane( lafVarietyVisualPane ).LayoutLine() ); + + layoutRect.LayoutRect( visualPaneLayoutRect.Rect(), + AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( lafVarietyLogo ).LayoutLine() ); + + // change image + iRadioLogo->SwitchToLandscapeImage( useLandscapeImage ); + iRadioLogo->SetRect( layoutRect.Rect() ); + + iVisualControl->SetOrientation( alfDisplayOrientation ); + iVisualControl->UpdateLayout( ); + iMediaIdle->SetOrientation( mediaIdleOrientation ); + iMediaIdle->UpdateLayout( ); + } + +// -------------------------------------------------------------------------------------------------- +// CFMRadioMainContainer::GetHelpContext +// -------------------------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::GetHelpContext( TCoeHelpContext& aContext ) const + { +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE + aContext.iMajor = TUid::Uid( KUidFMRadioApplication ); + aContext.iContext = KFMRADIO_HLP_MAIN; +#endif + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::UpdateTextColorFromSkin +// Handles updating main area text colors using current skin. +// -------------------------------------------------------------------------------- +// +void CFMRadioMainContainer::UpdateTextColorFromSkin() + { + // Update text using skin color + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + + TRgb color( KRgbBlue ); + AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); + + iVisualControl->SetStationInformationTextColor( color ); + + iMediaIdle->SetPrimaryColor( color ); + + AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ); + + iMediaIdle->SetSecondaryColor( color ); + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioMainContainer::VisualControl +// Returns a pointer to the station information visualizer +// ---------------------------------------------------------------------------------------------------- +// +CFMRadioAlfVisualizer* CFMRadioMainContainer::VisualControl() + { + return iVisualControl; + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioMainContainer::MediaIdle +// Returns a pointer to Media Idle +// ---------------------------------------------------------------------------------------------------- +// +CFMRadioAlfMediaIdle& CFMRadioMainContainer::MediaIdle() + { + return *iMediaIdle; + } + +// --------------------------------------------------------------------------- +// CFMRadioMainContainer::SetRdsRadioTextL +// Updates the rds information. +// --------------------------------------------------------------------------- +// +void CFMRadioMainContainer::SetRdsRadioTextL( const TDesC& aRadioText ) + { + // Trim the text and check if there is actual content before showing it + HBufC* text = aRadioText.AllocLC(); + text->Des().Trim(); + if ( text->Length() ) + { + if ( iRdsViewer->SetTextL( *text ) ) + { + iIdleController->ShowControl( *iRdsViewer ); + } + } + CleanupStack::PopAndDestroy( text ); + } + +// ---------------------------------------------------------------------------------------------------- +// TimerTimeOut +// ---------------------------------------------------------------------------------------------------- +void CFMRadioMainContainer::TimerTimeOut( TInt aErrorStatus ) + { + + if ( aErrorStatus == KErrNone && iLightsOffCounter < KFadeFrames ) + { + iAlfEnv.RefreshCallBack( &( iAlfEnv ) ); + TTimeIntervalMicroSeconds32 time( KTenMilliSecondsInMicroSeconds ); + + timer.After(iTimer->iStatus, time ); + + iTimer->Activate(); + + iLightsOffCounter++; + + } + else + { + timer.Cancel(); + } + + } + +// --------------------------------------------------------------------------- +// CFMRadioAlfMediaIdle::LightStatusChangedL +// From MHWRMLightObserver +// Prepares media idle to handle new channel information +// --------------------------------------------------------------------------- +// +void CFMRadioMainContainer::LightStatusChanged(TInt aTarget, + CHWRMLight::TLightStatus aStatus) + { + FTRACE( FPrint( _L("CFMRadioMainContainer::LightStatusChanged( Target: %d Lights: %d )"), aTarget, aStatus ) ); + if ( CHWRMLight::ELightOff == aStatus && aTarget == 1 ) + { + CAlfDisplay* display = NULL; + + if( iAlfEnv.DisplayCount() > 0 ) + { + display = &(iAlfEnv.PrimaryDisplay()); + + if ( display->Roster().Count() > 0 ) + { + iIdleController->DeactivateControls(); + + + iAlfEnv.RefreshCallBack( &(iAlfEnv) ); + + if ( !iTimer->IsActive() ) + { + TTimeIntervalMicroSeconds32 time( KTenMilliSecondsInMicroSeconds ); + // Just to make sure, that dimming is really happening + iLightsOffCounter = 0; + timer.After(iTimer->iStatus, time ); + iTimer->Activate(); + } + } + } + } + else if ( CHWRMLight::ELightOn == aStatus && aTarget == 1 ) + { + if ( iTimer ) + { + if ( iTimer->IsActive() ) + { + iTimer->Cancel(); + } + } + + if ( iLightsOffCounter != 0 ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + CFMRadioMainView* mainView = static_cast( appUi->View( KFMRadioMainViewId ) ); + mainView->DetermineActiveMediaIdleComponent(); + + iLightsOffCounter = 0; + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::RdsViewer +// -------------------------------------------------------------------------------- +// +CFMRadioAlfRDSViewer& CFMRadioMainContainer::RdsViewer() const + { + return *iRdsViewer; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::IdleController +// -------------------------------------------------------------------------------- +// +CFMRadioIdleController& CFMRadioMainContainer::IdleController() const + { + return *iIdleController; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainContainer::Logo +// -------------------------------------------------------------------------------- +// +CFMRadioLogo& CFMRadioMainContainer::Logo() const + { + return *iRadioLogo; + } +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiomainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiomainview.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1404 @@ +/* +* 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 of the class CFMRadioMainView +* +*/ + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiomusicstorehandler.h" +#include "fmradiobacksteppingservicewrapper.h" +#include "fmradiodocument.h" +#include "fmradiordsreceiverbase.h" +#include "fmradioalfvisualizer.h" +#include "fmradioengine.h" +#include "fmradiomainview.h" +#include "fmradiomaincontainer.h" +#include "fmradioappui.h" +#include "fmradio.hrh" +#include "fmradioengineradiosettings.h" +#include "fmradioalfmediaidle.h" +#include "fmradiopubsub.h" +#include "fmradioalfrdsviewer.h" +#include "fmradioidlecontroller.h" +#include "fmradiologo.h" +#include "debug.h" + +// A debug flag which is used for differentiating between original version and updated +// version, when set will add identifier on Main View title. Used for testing purposes +#undef __FM_UPDATE_PACKAGE__ + +// CONSTANTS + +#ifdef __FM_UPDATE_PACKAGE__ +_LIT( KFMRadioUpdated, " *" ); +#endif + +// Delay in milliseconds for fading out the RDS indicator +const TInt KFMRadioRdsSignalFadeOutDelay = 1000; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CFMRadioMainView::NewL +// Two-phase constructor of CFMRadioMainView +// --------------------------------------------------------- +// +CFMRadioMainView* CFMRadioMainView::NewL( + CRadioEngine* aRadioEngine, CAlfEnv& aAlfEnv, MChannelListHandler& aObserver ) + { + CFMRadioMainView* self = new (ELeave) CFMRadioMainView( aRadioEngine, aAlfEnv, aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------- +// CFMRadioMainView::ConstructL +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CFMRadioMainView::ConstructL() + { + BaseConstructL( R_FMRADIO_MAIN_VIEW ); + PrepareToolbar(); + + if ( !AknLayoutUtils::PenEnabled() ) + { + ShowToolbar( EFalse ); + } + + iRdsSignalTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iMusicStoreHandler = CFMRadioMusicStoreHandler::NewL( R_FMRADIO_MAIN_OPTIONS_MENU ); + iMusicStoreHandler->EnableMusicStore( ETrue ); + + CAknToolbarExtension* toolbarExt = iToolbar->ToolbarExtension(); + CAknButton* operatorStoreButton = NULL; + operatorStoreButton = static_cast( toolbarExt->ControlOrNull( EFMRadioToolbarButtonCmdOperatorMusicStore ) ); + const TDesC& storeName = iMusicStoreHandler->OperatorMusicStoreName(); + + if ( operatorStoreButton ) + { + // set text for button name and tooltip + operatorStoreButton->State()->SetTextL( storeName ); + operatorStoreButton->State()->SetHelpTextL( storeName ); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::CFMRadioMainView +// default constructor +// --------------------------------------------------------- +// +CFMRadioMainView::CFMRadioMainView( + CRadioEngine* aRadioEngine, + CAlfEnv& /*aAlfEnv*/, + MChannelListHandler& aObserver) + : iRadioEngine( aRadioEngine ), + iSeeking( EFalse ), + iChangeDirection( EFMRadioStationChangeNone ), + iStartUp( ETrue ), + iObserver( aObserver ) + { + } + +// --------------------------------------------------------- +// CFMRadioMainView::~CFMRadioMainView +// Class destructor +// --------------------------------------------------------- +// +CFMRadioMainView::~CFMRadioMainView() + { + if( iRdsSignalTimer && iRdsSignalTimer->IsActive() ) + { + iRdsSignalTimer->Cancel(); + } + if ( iRdsSignalTimer ) + { + delete iRdsSignalTimer; + iRdsSignalTimer = NULL; + } + + CAlfEnv* alfEnv = CAlfEnv::Static(); + if ( alfEnv && iContainer ) + { + iContainer->RdsViewer().RemoveObserver( this ); + iContainer->Logo().RemoveObserver( this ); + } + + delete iContainer; + iContainer = NULL; + + delete iMusicStoreHandler; + } + +// --------------------------------------------------------- +// TUid CFMRadioMainView::Id +// Return the unique identifier corresponding to this view +// --------------------------------------------------------- +// +TUid CFMRadioMainView::Id() const + { + return KFMRadioMainViewId; + } + +// --------------------------------------------------------- +// CFMRadioMainView::StopSeekL +// Seek operation has completed. Update the view to reflect +// this fact. +// --------------------------------------------------------- +// +void CFMRadioMainView::StopSeekL() + { + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL Start") ) ); + if ( iContainer && iSeeking) + { + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL inside first if") ) ); + if ( !AknLayoutUtils::PenEnabled() ) + { + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); // Change softkeys + Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, 0, KNullDesC ); + } + else + { + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT ); // Change softkeys + } + + SetToolbarDimmedState( EFalse ); + iContainer->VisualControl()->StopTuningAnimation(); + iSeeking = EFalse; + Cba()->DrawDeferred(); // Redraw softkeys + } + + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + TInt presetIndex = iRadioEngine->GetPresetIndex(); + TInt channelCount = iObserver.Channels()->Count(); + + if ( iRadioEngine->GetRadioMode() == CRadioEngine::ERadioPresetMode && + channelCount > 0 && + presetIndex < channelCount ) + { + DisplayChannelL( presetIndex ); + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL ERadioPresetMode preset index = %d"),iRadioEngine->GetPresetIndex() ) ); + } + else + { + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL inside else") ) ); + TInt channelIndex = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); //, need to get here! + if ( channelIndex != KErrNotFound ) + { + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL if channelIndex is found, channelIndex = %d"),channelIndex ) ); + iRadioEngine->TunePresetL( channelIndex ); //update engine to let it know that we've locked onto a preset. + } + else + { + FTRACE( FPrint( _L("CFMRadioMainView::StopSeekL else, get tuned freq = %d"),iRadioEngine->GetTunedFrequency() ) ); + DisplayChannelL( KErrNotFound ); + } + } + + // show default radio logo + if ( iContainer ) + { + iContainer->IdleController().ShowControl( iContainer->Logo() ); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::FadeAndShowExit +// Fade the view and all controls associated with it. Change +// the soft keys so that "Exit" is displayed +// --------------------------------------------------------- +// +void CFMRadioMainView::FadeAndShowExit( + TBool aFaded ) + { + iFaded = aFaded; + + if ( iContainer ) + { + if ( aFaded || iRadioEngine->IsInCall() ) // Needs to be faded - headset missing + { + StopDisplayingMenuBar(); // In case options menu is open when headset is disconnected + SetToolbarDimmedState( ETrue ); + TRAP_IGNORE( Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_EXIT ) ); // Change softkeys + } + else // Unfade + { + SetToolbarDimmedState( EFalse ); + if ( !AknLayoutUtils::PenEnabled() ) + { + TRAP_IGNORE( Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); // Change softkeys + Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, 0, KNullDesC ); ) + } + else + { + TRAP_IGNORE ( Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT ); )// Change softkeys + } + } + iContainer->SetFaded( aFaded ); // Unfade controls inside container + Cba()->DrawDeferred(); // Redraw softkeys + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::UpdateDisplayForFocusGained +// Update display to override default behavior +// Can be removed when auto resume is implemented +// --------------------------------------------------------- +// +void CFMRadioMainView::UpdateDisplayForFocusGained() + { + FTRACE( FPrint( _L("CFMRadioMainView::UpdateDisplayForFocusGained") ) ); + FadeAndShowExit( iFaded ); + DetermineActiveMediaIdleComponent(); + } + +// --------------------------------------------------------- +// CFMRadioMainView::SeekL +// Tells the window owning container to display seek note +// and updates softkeys +// --------------------------------------------------------- +// +void CFMRadioMainView::SeekL() + { + if ( iContainer ) + { + HBufC* seekString = StringLoader::LoadLC( R_QTN_FMRADIO_TUNING, iCoeEnv ); + iContainer->VisualControl()->SetStaticInfoTextL( iChangeDirection, *seekString ); + CleanupStack::PopAndDestroy( seekString ); + iContainer->RdsViewer().Reset(); + iContainer->MediaIdle().ResetMediaIdleContent(); + iContainer->ShowRTPlusInteractionIndicator( EFalse, ETrue ); + iContainer->IdleController().ShowControl( iContainer->Logo() ); + iContainer->VisualControl()->StartTuningAnimation(); + iSeeking = ETrue; + SetToolbarDimmedState( ETrue ); + // force update for toolbar extension view + iToolbar->ToolbarExtension()->SetShown( EFalse ); + } + Cba()->SetCommandSetL( R_FMRADIO_MAIN_VIEW_TUNING_STATE_SOFTKEYS ); + + Cba()->DrawDeferred(); // Redraw softkeys + } + +// --------------------------------------------------------- +// CFMRadioMainView::ShowToolbar +// Sets toolbar visibility. +// --------------------------------------------------------- +// +void CFMRadioMainView::ShowToolbar( TBool aVisible ) + { + if ( iToolbar ) + { + iToolbar->SetToolbarVisibility( aVisible ); + iToolbar->UpdateBackground(); + iToolbar->DrawDeferred(); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::HandleForegroundEventL +// --------------------------------------------------------- +// +void CFMRadioMainView::HandleForegroundEventL(TBool aForeground) + { + CAknView::HandleForegroundEventL(aForeground); + CFMRadioAppUi* appUi = static_cast( AppUi() ); + if ( aForeground ) + { + if ( iStartUp ) + { + iStartUp = EFalse; + CFMRadioRdsReceiverBase& receiver = iRadioEngine->RdsReceiver(); + TBool afEnabled = iRadioEngine->RadioSettings().IsRdsAfSearchEnabled(); + iContainer->ShowRdsInfo( receiver.SignalAvailable(), ETrue, afEnabled ); + TBool showMusicStore = IsRTPlusInterActionIndicatorNeeded(); + iContainer->ShowRTPlusInteractionIndicator(showMusicStore, ETrue); + } + } + else + { + CAlfEnv* env = CAlfEnv::Static(); + if ( iContainer && env ) + { + iContainer->IdleController().DeactivateControls(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsDataProgrammeService +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsDataProgrammeService( const TDesC& aProgramService ) + { + TRAP_IGNORE( + RdsDataProgrammeServiceL( aProgramService ) + ); + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsDataPsNameIsStatic +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsDataPsNameIsStatic( TBool aStatic ) + { + TRAP_IGNORE( HandleStaticProgrammeServiceL( aStatic ) ) + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsDataProgrammeServiceL +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsDataProgrammeServiceL( const TDesC& aProgramService ) + { + FTRACE(FPrint(_L("CFMRadioMainView::RdsDataProgrammeServiceL('%S')"), &aProgramService)); + if( iContainer ) + { + CAlfEnv* alfEnv = CAlfEnv::Static(); + if( alfEnv ) + { + if( aProgramService.Length() > 0 ) + { + TInt presetIndexToDisplay = KErrNotFound; + TInt presetIndex = iRadioEngine->GetPresetIndex(); + // When we haven't preset name, ps name will save as preset name + if ( iRadioEngine->GetRadioMode() == CRadioEngine::ERadioPresetMode && + presetIndex < iObserver.Channels()->Count() ) + { + presetIndexToDisplay = presetIndex; + } + SetStationChangeType( EFMRadioStationChangeNone ); + DisplayChannelL( presetIndexToDisplay ); + } + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::HandleStaticProgrammeServiceL +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::HandleStaticProgrammeServiceL( TBool aStatic ) + { + FTRACE(FPrint(_L("CFMRadioMainView::HandleStaticProgrammeServiceL(%d)"), aStatic)); + + if( iContainer ) + { + if ( aStatic ) + { + // When we haven't got a name for preset, a static ps name will be saved + TInt channelCount = iObserver.Channels()->Count(); + TInt currentPresetIx = iRadioEngine->GetPresetIndex(); + + if ( aStatic && iRadioEngine->GetRadioMode() == CRadioEngine::ERadioPresetMode && + currentPresetIx != KErrNotFound && + channelCount > 0 && + currentPresetIx < channelCount ) + { + TDesC& stationName = iObserver.Channels()->At( currentPresetIx ).iChannelInformation; + TInt presetFreq = iObserver.Channels()->At( currentPresetIx ).iChannelFrequency; + + if ( stationName.Length() == 0 && + presetFreq != KErrNotFound && + iRadioEngine->RdsReceiver().ProgrammeService().Length() ) + { + iObserver.Channels()->At( currentPresetIx ).iChannelInformation = iRadioEngine->RdsReceiver().ProgrammeService(); + iObserver.UpdateChannelsL( EStoreIndexToRepository, currentPresetIx, 0 ); + // Update station information display + DisplayChannelL( currentPresetIx ); + } + } + iContainer->MediaIdle().AddPsNameToMediaIdleL( iRadioEngine->RdsReceiver().ProgrammeService() ); + } + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::RdsDataRadioText +// --------------------------------------------------------- +// +void CFMRadioMainView::RdsDataRadioText( const TDesC& aRadioText ) + { + FTRACE(FPrint(_L("CFMRadioMainView::RdsDataRadioText('%S')"), &aRadioText)); + if ( iContainer && aRadioText.Length() > 0 ) + { + TRAP_IGNORE( iContainer->SetRdsRadioTextL( aRadioText ) ); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::RdsDataRadioTextPlus +// --------------------------------------------------------- +// +void CFMRadioMainView::RdsDataRadioTextPlus( const TInt /*aRadioTextPlusClass*/, const TDesC& /*aRadioText*/ ) + { + if ( IsRTPlusInterActionIndicatorNeeded() ) + { + iContainer->ShowRTPlusInteractionIndicator( ETrue, ETrue ); + if ( !iRadioEngine->MusicStoreNoteDisplayed() ) + { + TRAP_IGNORE( ShowRTPlusFirstTimeDialogL() ) + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::IsRTPlusInterActionIndicatorNeeded +// --------------------------------------------------------------------------- +// +TBool CFMRadioMainView::IsRTPlusInterActionIndicatorNeeded() + { + CFMRadioRdsReceiverBase& receiver = iRadioEngine->RdsReceiver(); + TBool songInformation = receiver.RtPlusSong().Length() || + receiver.RtPlusArtist().Length() || + receiver.RtPlusAlbum().Length(); + TBool webLink = receiver.RtPlusProgramUrl().Length() && + iRadioEngine->GetRTPlusSupportLevel() == EFMRadioAllInteractions; + + return songInformation || webLink; + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::ShowRTPlusFirstTimeDialogL +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::ShowRTPlusFirstTimeDialogL() + { + // to avoid further calls + iRadioEngine->SetMusicStoreNoteDisplayed(); + + HBufC* noteTxt = StringLoader::LoadLC( R_QTN_FMRADIO_RTPLUS_FIRSTTIME, iCoeEnv ); + + CAknMessageQueryDialog* rdsFirstTimeDialog = new (ELeave) CAknMessageQueryDialog; + CleanupStack::PushL( rdsFirstTimeDialog ); + rdsFirstTimeDialog->SetMessageTextL( *noteTxt ); + CleanupStack::Pop( rdsFirstTimeDialog ); + rdsFirstTimeDialog->ExecuteLD( R_FMRADIO_RTPLUS_FIRSTTIME_NOTE ); + + CleanupStack::PopAndDestroy( noteTxt ); + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsAfSearchBegin +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsAfSearchBegin() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsAfSearchEnd +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsAfSearchEnd( TUint32 /*aFrequency*/, TInt /*aError*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsAfSearchStateChange +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsAfSearchStateChange( TBool aEnabled ) + { + CFMRadioAppUi* appUi = static_cast(AppUi()); + if( appUi->ActiveView() == KFMRadioMainViewId ) + { + CFMRadioRdsReceiverBase& receiver = iRadioEngine->RdsReceiver(); + TBool show = receiver.SignalAvailable(); + iContainer->ShowRdsInfo( show, ETrue, aEnabled ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::RdsAvailable +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::RdsAvailable( TBool aAvailable ) + { + CAlfEnv* alfEnv = CAlfEnv::Static(); + if( alfEnv ) + { + CFMRadioAppUi* appUi = static_cast(AppUi()); + + if( appUi->ActiveView() == KFMRadioMainViewId ) + { + if( aAvailable ) + { + iRdsSignalTimer->Cancel(); + TBool afEnabled = iRadioEngine->RadioSettings().IsRdsAfSearchEnabled(); + iContainer->ShowRdsInfo( ETrue, ETrue, afEnabled ); + } + else + { + // Start timer only if it wasn't activated before + if( !iRdsSignalTimer->IsActive() ) + { + // Used for conversing milliseconds to format timer understand, ie. microseconds + const TInt timerMultiplier = 1000; + + // Start timer to fade rds icon after a delay + iRdsSignalTimer->Start( TTimeIntervalMicroSeconds32( KFMRadioRdsSignalFadeOutDelay * timerMultiplier ), + TTimeIntervalMicroSeconds32(0), TCallBack( StaticRdsSignalTimerCallback, this ) ); + } + } + } + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::StaticRdsSignalTimerCallback +// --------------------------------------------------------- +TInt CFMRadioMainView::StaticRdsSignalTimerCallback( TAny* aSelfPtr ) + { + CFMRadioMainView* self = reinterpret_cast(aSelfPtr); + if(self) + { + self->iRdsSignalTimer->Cancel(); + if(self->iContainer) + { + self->iContainer->ShowRdsInfo(EFalse, ETrue); + } + } + return KErrNone; + } + +// --------------------------------------------------------- +// CFMRadioMainView::DisplayChannelL +// Inform the window owning container that it should display +// the frequency and name of the channel specified. +// --------------------------------------------------------- +// +void CFMRadioMainView::DisplayChannelL( TInt aChannelIndex ) + { + FTRACE(FPrint(_L("DisplayChannelL Start, index: %d "), aChannelIndex)); + + if ( iContainer ) + { + iContainer->MediaIdle().ResetMediaIdleContent(); + + if ( aChannelIndex != KErrNotFound ) + { + CRadioEngine::TStationName stationName; + TInt channelNumber = aChannelIndex + 1; + TInt channelFrequency = KErrNotFound; + + iRadioEngine->GetPresetNameAndFrequencyL( aChannelIndex, stationName, channelFrequency ); + + TFMRadioStationChangeType seekDirection = iChangeDirection; + + // Hide index number as the frequency was set by RDS AF search. + if ( iRadioEngine->FrequencySetByRdsAf() && channelFrequency != iRadioEngine->GetTunedFrequency() ) + { + channelNumber = KErrNotFound; + channelFrequency = iRadioEngine->GetTunedFrequency(); + seekDirection = EFMRadioStationChangeNone; + } + + // Update view + iContainer->DisplayChannelInfoL( channelNumber, + stationName, + seekDirection, + channelFrequency ); + } + else + { + iContainer->DisplayChannelInfoL( aChannelIndex, + KNullDesC, + iChangeDirection, + iRadioEngine->GetTunedFrequency() ); + } + + FTRACE( FPrint(_L("DisplayChannelL End") ) ); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::HandleCommandL +// All commands are handled by the AppUi +// --------------------------------------------------------- +// +void CFMRadioMainView::HandleCommandL( TInt aCommand ) + { + CFMRadioAppUi* appUi = static_cast( AppUi() ); + switch ( aCommand ) + { + case EAknSoftkeyBack: + { + const TVwsViewId viewId( TUid::Uid( KUidFMRadioApplication ), Id() ); + if ( !appUi->BackSteppingWrapper().HandleBackCommandL( viewId ) ) + { + // Command not consumed by Back Stepping Service, handle here by going background + TApaTask task( iEikonEnv->WsSession() ); + task.SetWgId( iEikonEnv->RootWin().Identifier() ); + task.SendToBackground(); + } + break; + } + case EMPXPbvCmdInternetGoToWeb: + { + LaunchBrowserL( aCommand ); + break; + } + case EFMRadioCmdChannelList: + { + HandleSaveChannelQueryL(); + appUi->HandleCommandL( aCommand ); + break; + } + case EFMRadioRockerButtonKeyUp: + case EFMRadioRockerButtonKeyDown: + { + // NOP + break; + } + case EAknSoftkeySelect: // MSK + { + if ( !iFaded && !iSeeking ) + { + HandleSaveChannelQueryL(); + appUi->HandleCommandL( EFMRadioCmdChannelList ); + } + break; + } + case EFMRadioRockerButtonKeyLeft: + { + if ( !iFaded && !iSeeking ) + { + appUi->HandleCommandL( EFMRadioCmdPrevChannel ); + } + break; + } + case EFMRadioRockerButtonKeyLeftLong: + { + if ( !iFaded && !iSeeking ) + { + appUi->HandleCommandL( EFMRadioCmdSeekDown ); + } + break; + } + case EFMRadioRockerButtonKeyRight: + { + if ( !iFaded && !iSeeking ) + { + appUi->HandleCommandL( EFMRadioCmdNextChannel ); + } + break; + } + case EFMRadioRockerButtonKeyRightLong: + { + if ( !iFaded && !iSeeking ) + { + appUi->HandleCommandL( EFMRadioCmdSeekUp ); + } + break; + } + case EFMRadioCmdErase: + { + if ( appUi->EraseChannelL( iRadioEngine->GetPresetIndex() ) ) + { + // delete has been confirmed, update station info + SetStationChangeType( EFMRadioStationChangeNone ); + iRadioEngine->SetTunerModeOn(); + DisplayChannelL( KErrNotFound ); + } + break; + } + case EFMRadioToolbarButtonCmdToggleIhf: + { + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputHeadset ) + { + appUi->HandleCommandL( EFMRadioCmdActivateIhf ); + } + else + { + appUi->HandleCommandL( EFMRadioCmdDeactivateIhf ); + } + break; + } + default: + { + if ( iMusicStoreHandler->IsMusicStoreCommandId( aCommand ) ) + { + LaunchBrowserL( aCommand ); + } + else + { + appUi->HandleCommandL( aCommand ); + } + break; + } + } + } + +// ---------------------------------------- +// Launch Browser +// ---------------------------------------- +void CFMRadioMainView::LaunchBrowserL( TInt aCommandId ) + { + CFMRadioRdsReceiverBase& receiver = iRadioEngine->RdsReceiver(); + switch ( aCommandId ) + { + case EMPXPbvCmdInternetGoToWeb: + iMusicStoreHandler->LaunchWebPageL( receiver.RtPlusProgramUrl() ); + break; + default: + iMusicStoreHandler->LaunchMusicStoreL( aCommandId, + receiver.RtPlusSong(), + receiver.RtPlusArtist(), + receiver.RtPlusAlbum() ); + break; + } + } + +// ---------------------------------------------------------------------------------------------------- +// CFMRadioMainView::NotifyRdsTextTimerCompletion() +// From MFMRadioAlfRdsViewObserver +// Called when same RT has stayed on display for 60 sec. +// ---------------------------------------------------------------------------------------------------- +// +void CFMRadioMainView::NotifyRdsTextTimerCompletion() + { + DetermineActiveMediaIdleComponent(); + } +// --------------------------------------------------------- +// CFMRadioMainView::DoActivateL +// Activate the main view +// --------------------------------------------------------- +// +void CFMRadioMainView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + CAknTitlePane* titlePane = static_cast( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + titlePane->SetTextToDefaultL(); +#ifdef __FM_UPDATE_PACKAGE__ + const TDesC* titleText = titlePane->Text(); + TBufC<2> titleAddition( KFMRadioUpdated ); + HBufC* newTitle = HBufC::NewLC( titleText->Length() + titleAddition.Length() ); + newTitle->Des().Copy( *titleText ); + newTitle->Des().Append( titleAddition ); + titlePane->SetTextL( *newTitle, ETrue ); + CleanupStack::PopAndDestroy( newTitle ); +#endif + + if ( !iContainer ) + { + CAlfEnv* alfEnv = CAlfEnv::Static(); + CFMRadioAppUi* appUi = static_cast( AppUi() ); + iContainer = CFMRadioMainContainer::NewL( ClientRect() , *alfEnv, *iRadioEngine ); + iContainer->RdsViewer().SetObserver( this ); + iContainer->Logo().SetObserver( this ); + } + if ( !AknLayoutUtils::PenEnabled() ) + { + // explicitly remove the middle softkey that shouldn't be there. + Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, 0, KNullDesC ); + } + + SetStationChangeType( EFMRadioStationChangeNone ); + + if ( !iStartUp ) + { + StopSeekL(); //used to trigger a UI update + } + else + { + AppUi()->HandleCommandL( EFMRadioCmdUpdateVolume ); + } + + AppUi()->HandleCommandL( EFMRadioCmdMainViewActive ); + + iRadioEngine->RdsReceiver().AddObserver( this ); + + TBool afEnabled = iRadioEngine->RadioSettings().IsRdsAfSearchEnabled(); + + iContainer->ShowRdsInfo( iRadioEngine->RdsReceiver().SignalAvailable(), EFalse, afEnabled ); + FadeAndShowExit(iFaded); + } + +// --------------------------------------------------------- +// CFMRadioMainView::DoDeactivate +// Deactivate the main view +// --------------------------------------------------------- +// +void CFMRadioMainView::DoDeactivate() + { + CFMRadioAppUi* appUi = static_cast(AppUi()); + + if ( appUi->RadioEngine() ) + { + iRadioEngine->RdsReceiver().RemoveObserver( this ); + } + + if ( iContainer ) + { + CAlfEnv* alfEnv = CAlfEnv::Static(); + if ( alfEnv ) + { + iContainer->RdsViewer().RemoveObserver( this ); + iContainer->RdsViewer().Reset(); + iContainer->Logo().RemoveObserver( this ); + iContainer->IdleController().HideAllControls(); + } + delete iContainer; + iContainer = NULL; + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::DynInitMenuPaneL +// Sets the state of menu items dynamically according to the +// state of application data. +// --------------------------------------------------------- +// +void CFMRadioMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) + { + iMusicStoreHandler->InitializeMenuL( aResourceId, aMenuPane ); + + if ( aResourceId == R_FMRADIO_MAIN_OPTIONS_MENU ) // Main menu + { + if ( IsWebLinkAvailable() ) + { + aMenuPane->SetItemDimmed( EMPXPbvCmdInternetGoToWeb, EFalse ); + } + else + { + aMenuPane->SetItemDimmed( EMPXPbvCmdInternetGoToWeb, ETrue ); + } + + if ( iRadioEngine->IsAudioRoutingPossible() ) + { + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdActivateIhf ); + if ( iRadioEngine->IsHeadsetConnected() ) + { + aMenuPane->SetItemTextL( EFMRadioCmdDeactivateIhf, R_QTN_FMRADIO_OPTIONS_DEACTIVATE ); + } + else + { + aMenuPane->DeleteMenuItem( EFMRadioCmdDeactivateIhf ); + } + } + else + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdDeactivateIhf ); + aMenuPane->SetItemTextL( EFMRadioCmdActivateIhf,R_QTN_FMRADIO_OPTIONS_ACTIVATE ); + } + } + else + { + aMenuPane->SetItemDimmed( EFMRadioCmdDeactivateIhf, ETrue ); + aMenuPane->SetItemDimmed( EFMRadioCmdActivateIhf, ETrue ); + } + + // if help is not enabled, disable help option + if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) + { + aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); + } + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + if ( appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ) == KErrNotFound ) // current frequency not saved + { + aMenuPane->SetItemDimmed( EFMRadioCmdRename, ETrue ); + aMenuPane->SetItemDimmed( EFMRadioCmdSaveChannel, EFalse ); + aMenuPane->SetItemDimmed( EFMRadioCmdErase, ETrue ); + } + else + { + aMenuPane->SetItemDimmed( EFMRadioCmdRename, EFalse ); + aMenuPane->SetItemDimmed( EFMRadioCmdSaveChannel, ETrue ); + aMenuPane->SetItemDimmed( EFMRadioCmdErase, EFalse ); + } + } + + if ( aResourceId == R_FMRADIO_OPTIONS_AF_SUB_MENU ) // Rds af search sub menu + { + TBool afEnabled = iRadioEngine->RadioSettings().IsRdsAfSearchEnabled(); + if ( afEnabled ) + { + aMenuPane->SetItemButtonState( EFMRadioCmdDisableRdsAfSearch, EEikMenuItemSymbolIndeterminate ); + aMenuPane->SetItemButtonState( EFMRadioCmdEnableRdsAfSearch, EEikMenuItemSymbolOn ); + } + else + { + aMenuPane->SetItemButtonState( EFMRadioCmdEnableRdsAfSearch, EEikMenuItemSymbolIndeterminate ); + aMenuPane->SetItemButtonState( EFMRadioCmdDisableRdsAfSearch, EEikMenuItemSymbolOn ); + } + } + + } + +// --------------------------------------------------------- +// CFMRadioMainView::LayoutChangedL +// --------------------------------------------------------- +// +void CFMRadioMainView::LayoutChangedL( TInt aType ) + { + if ( iContainer ) + { + iContainer->HandleResourceChange( aType ); + } + } + +// --------------------------------------------------------- +// CFMRadioMainView::SetStationChangeType +// --------------------------------------------------------- +// +void CFMRadioMainView::SetStationChangeType( TFMRadioStationChangeType aChangeType ) + { + iChangeDirection = aChangeType; + } + +// --------------------------------------------------------- +// CFMRadioMainView::PrepareViewForChannelChange +// --------------------------------------------------------- +// +void CFMRadioMainView::PrepareViewForChannelChange() + { + TRAP_IGNORE( PrepareViewForChannelChangeL() ); + } + +// --------------------------------------------------------- +// CFMRadioMainView::PrepareViewForChannelChangeL +// --------------------------------------------------------- +// +void CFMRadioMainView::PrepareViewForChannelChangeL() + { + switch ( iChangeDirection ) + { + case EFMRadioStationChangeNext: // fall through + case EFMRadioStationChangePrevious: + case EFMRadioStationChangeScanUp: + case EFMRadioStationChangeScanDown: + { + if( iContainer ) + { + iContainer->VisualControl()->ScrollOutCurrentStationInformationL( iChangeDirection ); + } + } + break; + default: + { + break; + } + } + if ( iContainer ) + { + iContainer->RdsViewer().Reset(); + } + + if ( iContainer ) + { + iContainer->ShowRTPlusInteractionIndicator( EFalse, ETrue); + } + // force update for toolbar extension view + iToolbar->ToolbarExtension()->SetShown( EFalse ); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::PrepareToolbar +// Prepare toolbar for displaying basic radio command buttons +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::PrepareToolbar() + { + // get toolbar from view + iToolbar = Toolbar(); + + // Set observer + iToolbar->SetToolbarObserver( this ); + + CAknButton* leftButton = NULL; + CAknButton* rightButton = NULL; + leftButton = static_cast( iToolbar->ControlOrNull( EFMRadioToolbarButtonCmdTuneDown ) ); + rightButton = static_cast( iToolbar->ControlOrNull( EFMRadioToolbarButtonCmdTuneUp) ); + + //set delay after buttons report long key press + if ( leftButton ) + { + leftButton->SetLongPressInterval( KLongPressDelayValueInMicroseconds ); + } + if ( rightButton ) + { + rightButton->SetLongPressInterval( KLongPressDelayValueInMicroseconds ); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::OfferToolbarEventL +// Handle commands from toolbar. +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::OfferToolbarEventL( TInt aCommandId ) + { + // Event modifiers are valid only during CAknToolbar::OfferToolbarEventL + TBool isHandled = EFalse; + if ( iToolbar->EventModifiers() == CAknToolbar::ELongPress ) + { + switch( aCommandId ) + { + case EFMRadioToolbarButtonCmdTuneDown: + { + isHandled = ETrue; + AppUi()->HandleCommandL( EFMRadioCmdSeekDown ); + break; + } + case EFMRadioToolbarButtonCmdTuneUp: + { + isHandled = ETrue; + AppUi()->HandleCommandL( EFMRadioCmdSeekUp ); + break; + } + default: + { + // fall through. + // dont break here because extension list buttons + // seem to report longpress also after the tuning buttons + // are pressed long. + } + } + } + + if ( iToolbar->EventModifiers() != CAknToolbar::ELongPress && + iToolbar->EventModifiers() != CAknToolbar::ELongPressEnded ) + { + switch( aCommandId ) + { + case EFMRadioToolbarButtonCmdTuneDown: + { + isHandled = ETrue; + AppUi()->HandleCommandL( EFMRadioCmdPrevChannel ); + break; + } + case EFMRadioToolbarButtonCmdTuneUp: + { + isHandled = ETrue; + AppUi()->HandleCommandL( EFMRadioCmdNextChannel ); + break; + } + default: + { + // fall through. + // dont break here because extension list buttons + // seem to report longpress also after the tuning buttons + // are pressed long. + } + } + } + if ( !isHandled ) + { + switch( aCommandId ) + { + case EFMRadioToolbarButtonCmdNokiaMusicStore: + { + HandleCommandL( EFMRadioMusicStoreNokiaMusicShop ); + break; + } + case EFMRadioToolbarButtonCmdOperatorMusicStore: + { + HandleCommandL( EFMRadioMusicStoreOperator ); + break; + } + case EFMRadioCmdRename: + { + iToolbar->ToolbarExtension()->SetShown( EFalse ); + HandleCommandL( aCommandId ); + break; + } + case EFMRadioCmdErase: + { + iToolbar->ToolbarExtension()->SetShown( EFalse ); + HandleCommandL( aCommandId ); + break; + } + case EFMRadioCmdChannelList: + { + iToolbar->ToolbarExtension()->SetShown( EFalse ); + HandleCommandL( aCommandId ); + break; + } + default: + { + HandleCommandL( aCommandId ); + break; + } + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::DynInitToolbarL +// from MAknToolbarObserver +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::DynInitToolbarL( TInt /*aResourceId*/, CAknToolbar* aToolbar ) + { + if ( iToolbar == aToolbar ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + CAknToolbarExtension* toolbarExtension = iToolbar->ToolbarExtension(); + + if ( appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ) == KErrNotFound ) + { + // current frequency not saved + // show save + toolbarExtension->HideItemL( EFMRadioCmdSaveChannel, EFalse ); + // hide rename + toolbarExtension->HideItemL( EFMRadioCmdRename, ETrue ); + // dim delete + toolbarExtension->SetItemDimmed( EFMRadioCmdErase, ETrue ); + } + else + { + // show rename + toolbarExtension->HideItemL( EFMRadioCmdRename, EFalse ); + // hide save + toolbarExtension->HideItemL( EFMRadioCmdSaveChannel, ETrue ); + // undim delete + toolbarExtension->SetItemDimmed( EFMRadioCmdErase, EFalse ); + } + + if ( IsWebLinkAvailable() ) + { + // show web button + toolbarExtension->HideItemL( EMPXPbvCmdInternetGoToWeb, EFalse ); + } + else + { + // hide web button + toolbarExtension->HideItemL( EMPXPbvCmdInternetGoToWeb, ETrue ); + } + + TBool musicStoreEnabled = iMusicStoreHandler->IsMusicStoreEnabled(); + + if ( iMusicStoreHandler->OperatorMusicStoreAvailable() && musicStoreEnabled ) + { + // show operator store + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdOperatorMusicStore, EFalse ); + // hide speaker button + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdToggleIhf, ETrue ); + } + else + { + // hide operator store + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdOperatorMusicStore, ETrue ); + // show and update speaker button + UpdateToolbarSpeakerButtonStatus(); + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdToggleIhf, EFalse ); + } + + if ( iMusicStoreHandler->NokiaMusicStoreAvailable() && musicStoreEnabled ) + { + // show Nokia Music Store + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdNokiaMusicStore, EFalse ); + } + else + { + // hide Nokia Music Store + toolbarExtension->HideItemL( EFMRadioToolbarButtonCmdNokiaMusicStore, ETrue ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::SetToolbarDimmedState +// Set the current state of the buttons in the button group +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::SetToolbarDimmedState( TBool aState ) + { + iToolbar->SetDimmed( aState ); + iToolbar->DrawDeferred(); + } + +// --------------------------------------------------------------------------- +// CFMRadioMainView::HandleSaveChannelQueryL +// show query if the current channel is not saved +// --------------------------------------------------------------------------- +// +void CFMRadioMainView::HandleSaveChannelQueryL() + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + TInt channelIndex = appUi->MatchingChannelL( iRadioEngine->GetTunedFrequency() ); + + if ( KErrNotFound == channelIndex ) + { + TBool accepted = EFalse; // Operation accepted or discarded + CAknQueryDialog* saveQuery = CAknQueryDialog::NewL(); + accepted = saveQuery->ExecuteLD( R_FMRADIO_QUERY_SAVE_CURRENT ); + + if ( accepted ) + { + AppUi()->HandleCommandL( EFMRadioCmdSaveChannel ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::SetEmphasis +// From MEikMenuObserver. +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::SetEmphasis( CCoeControl* aMenuControl, TBool aEmphasis ) + { + CAknView::SetEmphasis( aMenuControl, aEmphasis ); + + if ( iContainer ) + { + if ( aEmphasis ) // options menu opened + { + iOptionsMenuOpen = ETrue; + // deactivate controls to help improve UI performance + iContainer->IdleController().DeactivateControls(); + } + else + { + if ( iOptionsMenuOpen ) + { + // menu has been been really opened so update status + iOptionsMenuOpen = EFalse; + DetermineActiveMediaIdleComponent(); + } + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::LogoDisplayTimeCompleted +// from MFMRadioAlfLogoObserver +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::LogoDisplayTimeCompleted() + { + DetermineActiveMediaIdleComponent(); + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::DetermineActiveMediaIdleComponent +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::DetermineActiveMediaIdleComponent() + { + CFMRadioAppUi* appUi = static_cast (AppUi()); + TBool wizardHandled = appUi->IsStartupWizardHandled(); + + if ( iContainer && + !iOptionsMenuOpen && + wizardHandled && + IsForeground() ) + { + + if ( iContainer->RdsViewer().IsRdsTextVisibilityTimerCompleted() ) + { + // same text displayed for a while, ok to start idle + iContainer->IdleController().ShowControl( iContainer->MediaIdle() ); + } + else + { + // display the rds text until the NotifyRdsTextTimerCompletion() callback + iContainer->IdleController().ShowControl( iContainer->RdsViewer() ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::IsWebLinkAvailabe +// -------------------------------------------------------------------------------- +// +TBool CFMRadioMainView::IsWebLinkAvailable() + { + TBool response = EFalse; + CFMRadioRdsReceiverBase& receiver = iRadioEngine->RdsReceiver(); + if ( receiver.RtPlusProgramUrl().Length() && + iRadioEngine->GetRTPlusSupportLevel() == EFMRadioAllInteractions ) + { + response = ETrue; + } + return response; + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::UpdateToolbarSpeakerButtonStatus +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::UpdateToolbarSpeakerButtonStatus() + { + if ( iToolbar && iContainer ) + { + CAknToolbarExtension* toolbarExtension = iToolbar->ToolbarExtension(); + + if ( iRadioEngine->IsAudioRoutingPossible() ) + { + toolbarExtension->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, EFalse ); + CAknButton* speakerButton = NULL; + + speakerButton = static_cast( toolbarExtension->ControlOrNull( EFMRadioToolbarButtonCmdToggleIhf ) ); + + if ( speakerButton ) + { + if ( iRadioEngine->GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + speakerButton->SetCurrentState( 1, ETrue ); + } + else + { + speakerButton->SetCurrentState( 0, ETrue ); + } + } + } + else + { + toolbarExtension->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, ETrue ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioMainView::ShowDefaultLogo +// -------------------------------------------------------------------------------- +// +void CFMRadioMainView::ShowDefaultLogo() + { + // show default radio logo + if ( iContainer ) + { + iContainer->IdleController().ShowControl( iContainer->Logo() ); + } + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiomusicstorehandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiomusicstorehandler.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,693 @@ +/* +* 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: Implementation for music store integration. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //for p&s keys + +#include "fmradio.hrh" +#include "fmradiomusicstorehandler.h" +#include "debug.h" + +// Some debug flags + +// If defined, forces Operator specific music shop to be enabled, +// regardless if it is supported or not. For debugging purposes +#undef FORCE_OPERATOR_MUSIC_SHOP + +// Following constants are from mpxmusicplayer_101FFCDC.crml +const TUid KCRUidMPXMPSettings = {0x101FFCDC}; // UID for Music Store Settings CenRep +const TUint32 KMPXMusicStoreUID = 0x3; +const TUint32 KOperatorMusicStore = 0x4; +const TUint32 KOperatorMusicStoreType = 0x5; +const TUint32 KOperatorMusicStoreDisplayName = 0x6; +const TUint32 KOperatorMusicStoreNativeUid = 0x7; +const TUint32 KOperatorMusicStoreWebPage = 0x9; +const TUint32 KOperatorMusicStoreURI = 0xA; +const TInt TUInt32HexLength = 8; + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::CMusicStoreHandler +// C++ class constructor. +// ---------------------------------------------------- +// +CFMRadioMusicStoreHandler::CFMRadioMusicStoreHandler( TInt aResourceId ) +: iResourceId( aResourceId ) + { + // Nothing to do + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::~CMusicStoreHandler +// Default destructor. +// ---------------------------------------------------- +// +CFMRadioMusicStoreHandler::~CFMRadioMusicStoreHandler() + { + iOperatorMusicStoreName.Close(); + iOperatorStoreWebsite.Close(); + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::NewL +// Two-phased class constructor. +// ---------------------------------------------------- +// +CFMRadioMusicStoreHandler* CFMRadioMusicStoreHandler::NewL( TInt aResourceId ) + { + CFMRadioMusicStoreHandler* self = new (ELeave) CFMRadioMusicStoreHandler( aResourceId ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::NewL +// Second phase class constructor. +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::ConstructL() + { + iCoeEnv = CEikonEnv::Static(); + CRepository* repository = CRepository::NewL( KCRUidMPXMPSettings ); + CleanupStack::PushL( repository ); + + RBuf8 uidDes; + uidDes.CleanupClosePushL(); + uidDes.CreateL( TUInt32HexLength ); + TInt error = KErrNone; + error = repository->Get( KMPXMusicStoreUID, uidDes ); + + // Check for availability of Nokia Music store + if ( !error ) + { + iMusicStoreUID = Uint32Presentation( uidDes ); + iMusicStoreAppInstalled = IsAppInstalledL( TUid::Uid( iMusicStoreUID ) ); + } + + if ( NokiaMusicStoreAvailable() ) + { + InitializeMusicStore( TUid::Uid( iMusicStoreUID ) ); + } + + // Check if operator provided a music store + TFMRadioOperatorAppType appType = CheckOperatorMusicStoreTypeL( *repository ); + if ( appType != EFMRadioAppNotAvailable ) + { + // Get the name of the music store + const TInt initialNameLength = 11; + iOperatorMusicStoreName.CreateL( initialNameLength ); + TInt realLength = KErrNotFound; + error = repository->Get( KOperatorMusicStoreDisplayName, iOperatorMusicStoreName, realLength ); + if ( error == KErrOverflow ) + { + iOperatorMusicStoreName.ReAllocL( realLength ); + error = repository->Get( KOperatorMusicStoreDisplayName, iOperatorMusicStoreName ); + } + User::LeaveIfError( error ); +#ifdef FORCE_OPERATOR_MUSIC_SHOP + if ( !iOperatorMusicStoreName.Length() ) + { + _LIT( KHardCodedName, "O'MusicShop" ); // length <= initialNameLength + iOperatorMusicStoreName.Copy( KHardCodedName ); + } +#endif + + // Get application type specific parameters + InitializeParametersL( *repository, appType ); + } + CleanupStack::PopAndDestroy( 2 ); // uidDes, repository + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::CheckOperatorMusicStoreTypeL +// ---------------------------------------------------- +// +CFMRadioMusicStoreHandler::TFMRadioOperatorAppType CFMRadioMusicStoreHandler::CheckOperatorMusicStoreTypeL( + CRepository& aRepository ) + { + TFMRadioOperatorAppType appType = EFMRadioAppNotAvailable; + // Check if operator provided a music store + TBool operatorStorePresent = EFalse; + TInt error = aRepository.Get( KOperatorMusicStore, operatorStorePresent ); + if ( error != KErrNotFound ) + { + User::LeaveIfError( error ); + } + if ( operatorStorePresent ) + { + TInt appTypeCR; + error = aRepository.Get( KOperatorMusicStoreType, appTypeCR ); + User::LeaveIfError( error ); + if ( appTypeCR == 0 ) // 0 = Native app + { + appType = EFMRadioNativeApp; + } + else // 1 = Java app + { + appType = EFMRadioJavaApp; + } + } + + // The code assumes that if both application and website is available then + // website is preferred type + TInt website; + error = aRepository.Get( KOperatorMusicStoreWebPage, website ); + User::LeaveIfError( error ); +#ifdef FORCE_OPERATOR_MUSIC_SHOP + website = ETrue; +#endif + if ( website ) + { + appType = EFMRadioWebsite; + } + + return appType; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::InitializeParametersL +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::InitializeParametersL( + CRepository& aRepository, + TFMRadioOperatorAppType aAppType ) + { + TInt error = KErrNone; + switch ( aAppType ) + { + case EFMRadioNativeApp: + { + RBuf8 operatorUidDes; + operatorUidDes.CleanupClosePushL(); + operatorUidDes.CreateL( TUInt32HexLength ); + + TInt error = KErrNone; + error = aRepository.Get( KOperatorMusicStoreNativeUid, operatorUidDes ); + + if ( !error ) + { + iOperatorStoreNativeUID = Uint32Presentation( operatorUidDes ); + // It is assumed that both Nokia Music Shop and operator specific music store use + // same kind of interface to communicate + InitializeMusicStore( TUid::Uid( iOperatorStoreNativeUID ) ); + } + CleanupStack::PopAndDestroy( &operatorUidDes ); + break; + } + case EFMRadioJavaApp: + // Java application not supported currently + break; + case EFMRadioWebsite: + { + const TInt initialSize = 5; + TInt realLength = KErrNotFound; + iOperatorStoreWebsite.Create( initialSize ); + error = aRepository.Get( KOperatorMusicStoreURI, iOperatorStoreWebsite, realLength ); + if ( error == KErrOverflow ) + { + iOperatorStoreWebsite.ReAllocL( realLength ); + error = aRepository.Get( KOperatorMusicStoreURI, iOperatorStoreWebsite ); + } + User::LeaveIfError( error ); +#ifdef FORCE_OPERATOR_MUSIC_SHOP + if ( !iOperatorStoreWebsite.Length() ) + { + _LIT( KHardCodedName, "http://www.google.com/" ); + iOperatorStoreWebsite.ReAllocL( KHardCodedName().Length() ); + iOperatorStoreWebsite.Copy( KHardCodedName ); + } +#endif + break; + } + default: + break; + } + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::InitializeMusicShop +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::InitializeMusicStore( TUid aMusicstoreUid ) + { + //MusicShop CenRep initialization values + _LIT_SECURITY_POLICY_C1(KMPlayerRemoteReadPolicy, ECapabilityReadUserData); + _LIT_SECURITY_POLICY_C1(KMPlayerRemoteWritePolicy, ECapabilityWriteUserData); + TInt retval(KErrNone); + // P/S key for music shop + retval = RProperty::Define( aMusicstoreUid, + KMShopCategoryId, + RProperty::EInt, + KMPlayerRemoteReadPolicy, + KMPlayerRemoteWritePolicy ); + + if( retval != KErrAlreadyExists) + { + RProperty::Set( aMusicstoreUid, + KMShopCategoryId, + KFindInMShopKeyInValid ); // initialize Find In Musicshop was not called + + RProperty::Define( aMusicstoreUid, + KMShopCategoryName, + RProperty::ELargeText, + KMPlayerRemoteReadPolicy, + KMPlayerRemoteWritePolicy ); + } + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::GetUint32Presentation +// ---------------------------------------------------- +// +TUint32 CFMRadioMusicStoreHandler::Uint32Presentation( const TDesC8& aBuf ) + { + TUint32 result = 0; + + const TInt KProEngByteLength( 8 ); + const TInt length( aBuf.Length() ); + const TInt maxBitShift( KProEngByteLength * ( length - 1 ) ); + + for ( TInt i( 0 ); i < length; ++i ) + { + result |= ( aBuf[i] << + ( maxBitShift - ( KProEngByteLength * i ) ) ); + } + return result; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::IsMusicStoreCommandId +// Goes through known command ids and compares to them +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::IsMusicStoreCommandId( TInt aCommandId ) + { + TBool isHandled = EFalse; + switch( aCommandId ) + { + case EFMRadioMusicStore: + case EFMRadioMusicStoreGoogle: + case EFMRadioMusicStoreWikipedia: + case EFMRadioMusicStoreAmg: + case EFMRadioMusicStoreNokiaMusicShop: + case EFMRadioMusicStoreMusicPortl: + case EFMRadioMusicStoreOperator: + isHandled = ETrue; + break; + default: + break; + } + return isHandled; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::MusicStoreCount +// ---------------------------------------------------- +// +TInt CFMRadioMusicStoreHandler::MusicStoreCount() + { + TInt count = 0; + if ( NokiaMusicStoreAvailable() ) + { + count++; + } + if ( OperatorMusicStoreAvailable() ) + { + count++; + } + return count; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::OperatorMusicStoreAvailable +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::OperatorMusicStoreAvailable() + { + return ( iOperatorMusicStoreName.Length() != 0 ); + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::NokiaMusicStoreAvailable +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::NokiaMusicStoreAvailable() + { + TBool response = EFalse; + + if ( iMusicStoreUID != 0 && iMusicStoreAppInstalled ) + { + response = ETrue; + } + return response; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::InitializeMenuL +// Takes care of dynamically initializing menu items related to Music shop. +// Takes care of adding either menu item or cascaded menuitem +// based on how many Music shops there is available. Fills the +// cascaded menuitem automatically. +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::InitializeMenuL( TInt aResourceId, CEikMenuPane* aMenuPane ) + { + TBool resourceHandled = EFalse; + + if ( aResourceId == R_FMRADIO_OPTIONS_MUSIC_STORE_SUB_MENU ) + { + if ( NokiaMusicStoreAvailable() ) + { + aMenuPane->SetItemDimmed( EFMRadioMusicStoreNokiaMusicShop, EFalse ); + } + else + { + aMenuPane->SetItemDimmed( EFMRadioMusicStoreNokiaMusicShop, ETrue ); + } + if ( OperatorMusicStoreAvailable() ) + { + aMenuPane->SetItemTextL( EFMRadioMusicStoreOperator, iOperatorMusicStoreName ); + aMenuPane->SetItemDimmed( EFMRadioMusicStoreOperator, EFalse ); + } + else + { + aMenuPane->SetItemDimmed( EFMRadioMusicStoreOperator, ETrue ); + } + resourceHandled = ETrue; + } + else if ( iResourceId == aResourceId ) + { + const TInt firstIndex = 0; + TInt firstCommand = aMenuPane->MenuItemCommandId( firstIndex ); + if ( MusicStoreCount() > 1 || OperatorMusicStoreAvailable() ) + { + aMenuPane->AddMenuItemsL( R_FMRADIO_OPTIONS_MUSIC_STORE_WITH_SUB_MENU, firstCommand ); + } + else + { + aMenuPane->AddMenuItemsL( R_FMRADIO_OPTIONS_MUSIC_STORE, firstCommand ); + } + + // Show or hide menu item based on Music store state + if ( iState == EFMRadioMusicStoreDisabled || iState == EFMRadioMusicStoreUninitialized ) + { + aMenuPane->SetItemDimmed( EFMRadioMusicStore, ETrue ); + } + else if ( iState == EFMRadioMusicStoreEnabled && !MusicStoreCount() ) + { + aMenuPane->SetItemDimmed( EFMRadioMusicStore, ETrue ); + } + else + { + aMenuPane->SetItemDimmed( EFMRadioMusicStore, EFalse ); + } + } + else + { + //NOP + } + return resourceHandled; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::EnableMusicStore +// Shows or hides Music store related functionality +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::EnableMusicStore( TBool aEnable, TBool aForce ) + { + if ( aForce && aEnable ) + { + iState = EFMRadioMusicStoreForceEnabled; + } + else if ( aEnable ) + { + iState = EFMRadioMusicStoreEnabled; + } + else + { + iState = EFMRadioMusicStoreDisabled; + } + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::LaunchMusicStoreL +// Launches appropriate Music Store functionality based on parameters. +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::LaunchMusicStoreL( + TInt aCommandId, + const TDesC& aTitle, + const TDesC& aArtist, + const TDesC& aAlbum ) + { + if ( aCommandId == EFMRadioMusicStore ) + { + aCommandId = EFMRadioMusicStoreNokiaMusicShop; + } + + HBufC* searchString = NULL; + + TBool isHandled = ETrue; + switch( aCommandId ) + { + case EFMRadioMusicStoreGoogle: + case EFMRadioMusicStoreWikipedia: + case EFMRadioMusicStoreAmg: + case EFMRadioMusicStoreMusicPortl: + isHandled = EFalse; + break; + case EFMRadioMusicStoreNokiaMusicShop: + searchString = NokiaMusicShopSearchLC( aTitle, aArtist, aAlbum ); + break; + case EFMRadioMusicStoreOperator: + if ( iOperatorStoreWebsite.Length() != 0 ) + { + searchString = iOperatorStoreWebsite.AllocLC(); + + } + else if ( iOperatorStoreNativeUID ) + { + // It is assumed that both Nokia Music Shop and operator specific music store use + // same kind of interface to communicate + searchString = NokiaMusicShopSearchLC( aTitle, aArtist, aAlbum ); + } + else + { + isHandled = EFalse; + } + break; + default: + FTRACE( FPrint( _L("CFMRadioMusicStoreHandler::LaunchMusicStoreL - Unknown id = %d"), aCommandId ) ); + isHandled = EFalse; + break; + } + + if ( isHandled ) + { + switch( aCommandId ) + { + case EFMRadioMusicStoreNokiaMusicShop: + { + TUid musicshopUid( TUid::Uid( iMusicStoreUID ) ); + LaunchMusicShopL( musicshopUid, *searchString ); + break; + } + case EFMRadioMusicStoreOperator: + LaunchOperatorMusicStoreL( *searchString ); + break; + default: + LaunchWebPageL( *searchString ); + break; + } + CleanupStack::PopAndDestroy( searchString ); + } + } + +// ----------------------------------------------------------------------------- +// CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL +// ----------------------------------------------------------------------------- +// +void CFMRadioMusicStoreHandler::LaunchOperatorMusicStoreL( const TDesC& aSearchString ) + { + if ( iOperatorStoreWebsite.Length() != 0 ) + { + LaunchWebPageL( aSearchString ); + } + else if ( iOperatorStoreNativeUID ) + { + // It is assumed that both Nokia Music Shop and operator specific music store use + // same kind of interface to communicate + TUid musicshopUid( TUid::Uid( iOperatorStoreNativeUID ) ); + LaunchMusicShopL( musicshopUid, aSearchString ); + } + else + { + //NOP + } + } + +// ----------------------------------------------------------------------------- +// CFMRadioMusicStoreHandler::NokiaMusicShopSearchL +// ----------------------------------------------------------------------------- +// +HBufC* CFMRadioMusicStoreHandler::NokiaMusicShopSearchLC( + const TDesC& aSongName, + const TDesC& aArtistName, + const TDesC& aAlbumName ) + { + CMPXFindInMShop* finder = CMPXFindInMShop::NewL(); //ECom Plugin + CleanupStack::PushL( finder ); + HBufC* url = finder->CreateSearchURLL( aSongName, + aArtistName, + aAlbumName, + KNullDesC, // Composer - Not used + KNullDesC ); // Genre - Not used + + CleanupStack::PopAndDestroy( finder ); // finder + REComSession::FinalClose(); + CleanupStack::PushL( url ); + return url; + } + +// ----------------------------------------------------------------------------- +// CFMRadioMusicStoreHandler::LaunchMusicShopL +// Launch Nokia music shop application +// ----------------------------------------------------------------------------- +// +void CFMRadioMusicStoreHandler::LaunchMusicShopL( TUid aMusicshopUid, const TDesC& aSearchString ) + { + RProperty::Set( aMusicshopUid, + KMShopCategoryName, + aSearchString ); + + RProperty::Set( aMusicshopUid, + KMShopCategoryId, + KFindInMShopKeyValid ); // Set Key to Valid + + TApaTaskList taskList( iCoeEnv->WsSession() ); + TApaTask task = taskList.FindApp( aMusicshopUid ); + + if ( task.Exists() ) + { + task.BringToForeground(); + } + else + { + RApaLsSession session; + User::LeaveIfError( session.Connect() ); + TThreadId threadId; + session.CreateDocument( KNullDesC, aMusicshopUid, threadId ); + session.Close(); + } + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::LaunchWebPageL +// Opens web site based on the string +// ---------------------------------------------------- +// +void CFMRadioMusicStoreHandler::LaunchWebPageL( const TDesC& aWebpage ) + { + _LIT( KCommand, "4 "); + RBuf param; + param.CreateL( KCommand().Length() + aWebpage.Length() ); + param.CleanupClosePushL(); + param.Copy( KCommand() ); //Web Browser requires this in order to fetch url. + param.Append( aWebpage ); + + const TInt KWebBrowserUid = 0x10008D39; + TUid browserId( TUid::Uid( KWebBrowserUid ) ); + TApaTaskList taskList( iCoeEnv->WsSession() ); + TApaTask task = taskList.FindApp( browserId ); + if ( task.Exists() ) + { + HBufC8* param8 = HBufC8::NewLC( param.Length() ); + param8->Des().Append( param ); + task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used + CleanupStack::PopAndDestroy( param8 ); + } + else + { + RApaLsSession session; + User::LeaveIfError( session.Connect() ); + TThreadId threadId; + session.StartDocument( param, browserId, threadId ); + session.Close(); + } + CleanupStack::PopAndDestroy( ¶m ); + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::IsMusicStoreLaunchable +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::IsMusicStoreEnabled() + { + TBool musicStoreLaunchable = EFalse; + + if ( iState != CFMRadioMusicStoreHandler::EFMRadioMusicStoreDisabled && + iState != CFMRadioMusicStoreHandler::EFMRadioMusicStoreUninitialized ) + { + musicStoreLaunchable = ETrue; + } + return musicStoreLaunchable; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::OperatorMusicStoreName +// ---------------------------------------------------- +// +const TDesC& CFMRadioMusicStoreHandler::OperatorMusicStoreName() const + { + return iOperatorMusicStoreName; + } + +// ---------------------------------------------------- +// CFMRadioMusicStoreHandler::IsAppInstalled +// ---------------------------------------------------- +// +TBool CFMRadioMusicStoreHandler::IsAppInstalledL( const TUid& aAppUid ) + { + TBool response = EFalse; + + RApaLsSession apaSession; + CleanupClosePushL( apaSession ); + User::LeaveIfError( apaSession.Connect() ); + apaSession.GetAllApps(); + + TApaAppInfo appInfo; + TInt err = apaSession.GetAppInfo( appInfo, aAppUid ); + CleanupStack::PopAndDestroy( &apaSession ); + + if ( !err ) + { + // app was found + response = ETrue; + } + return response; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiopreset.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiopreset.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,118 @@ +/* +* 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: fmradio preset station information +* +*/ + +#include "fmradiopreset.h" + +// ======== MEMBER FUNCTIONS ======== + +// ---------------------------------------------------------------------------- +// CFMRadioPreset::CFMRadioPreset +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioPreset::CFMRadioPreset() : iNameIsValid( ETrue ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioPreset::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// CFMRadioPreset::NewL +// Two-phase constructor of CFMRadioPreset +// --------------------------------------------------------------------------- +// +CFMRadioPreset* CFMRadioPreset::NewL() + { + CFMRadioPreset* self = new ( ELeave ) CFMRadioPreset; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CFMRadioPreset::~CFMRadioPreset +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioPreset::~CFMRadioPreset() + { + iStationName.Close(); + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::SetPresetNameL +// --------------------------------------------------------------------------- +// +void CFMRadioPreset::SetPresetNameL( const TDesC& aName ) + { + iStationName.Close(); + iStationName.CreateL( aName ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::PresetName +// --------------------------------------------------------------------------- +// +TDesC& CFMRadioPreset::PresetName() + { + return iStationName; + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::SetPresetNameValid +// --------------------------------------------------------------------------- +// +void CFMRadioPreset::SetPresetNameValid( TBool aValid ) + { + iNameIsValid = aValid; + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::PresetNameValid +// --------------------------------------------------------------------------- +// +TBool CFMRadioPreset::PresetNameValid() + { + return iNameIsValid; + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::SetPresetFrequency +// --------------------------------------------------------------------------- +// +void CFMRadioPreset::SetPresetFrequency( TInt aFrequency ) + { + iStationFrequency = aFrequency; + } + +// --------------------------------------------------------------------------- +// CFMRadioPreset::PresetFrequency +// --------------------------------------------------------------------------- +// +TInt CFMRadioPreset::PresetFrequency() + { + return iStationFrequency; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioscanlocalstationscontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioscanlocalstationscontainer.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,606 @@ +/* +* 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: Implementation of the class CFMRadioScanLocalStationsContainer +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE +#include "radio.hlp.hrh" +#endif +#include "fmradioapp.h" +#include "fmradioappui.h" +#include "fmradioscanlocalstationscontainer.h" +#include "fmradioscanlocalstationsview.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::CFMRadioScanLocalStationsContainer +// Default constructor +// ---------------------------------------------------------------------------- +// +CFMRadioScanLocalStationsContainer::CFMRadioScanLocalStationsContainer( CRadioEngine& aRadioEngine ): + iRadioEngine( aRadioEngine ) + { + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::NewL +// Two-phase constructor of CFMRadioScanLocalStationsContainer +// --------------------------------------------------------- +// +CFMRadioScanLocalStationsContainer* CFMRadioScanLocalStationsContainer::NewL( const TRect& aRect, CRadioEngine& aRadioEngine ) + { + CFMRadioScanLocalStationsContainer* self = new (ELeave) CFMRadioScanLocalStationsContainer( aRadioEngine ); + CleanupStack::PushL( self ); + self->ConstructL( aRect ); + CleanupStack::Pop( self ); + return self; + } + +// +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::ConstructL +// EPOC two phased constructor +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::ConstructL( const TRect& aRect ) + { + // check the layout orientation + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + TBool isLandscape = appUi->IsLandscapeOrientation(); + CreateWindowL(); + + // Create the new context with image: KAknsIIDQsnBgAreaMain, and parent absolute layout is not used. + iBackground = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain, Rect(), EFalse ); + iSkin = AknsUtils::SkinInstance(); + + // Instantiate a listbox for the channel list + iChannelList = new ( ELeave ) CAknSingleNumberStyleListBox(); + iControls.Append( iChannelList ); + iChannelList->SetContainerWindowL( *this ); + iChannelList->SetListBoxObserver( this ); + iChannelList->ConstructL( this, CEikListBox::ELoopScrolling | EAknListBoxSelectionList ); // Looped list + // Create scrollbars + iChannelList->CreateScrollBarFrameL( ETrue ); + + CAknIconArray* radioTypeIcons = NULL; + radioTypeIcons = new ( ELeave ) CAknIconArray( 2 ); + CleanupStack::PushL( radioTypeIcons ); + radioTypeIcons->AppendFromResourceL( R_FMRADIO_CHANNEL_LIST_ICON_ARRAY ); + // The following line really takes the ownership -- must be the last item + // there, as if leaves and the object is in cleanupstack, problems arise. + // (Cleanup stack corruption!) + // Set the icon array for this list. List takes ownership of the array. + iChannelList->ItemDrawer()->ColumnData()->SetIconArray( radioTypeIcons ); + CleanupStack::Pop( radioTypeIcons ); + + // Array for channels + iChannelItemArray = new( ELeave ) CDesCArrayFlat( KMaxNumberOfChannelListItems ); + InitializeChannelListL(); + SetRect( aRect ); + + CFMRadioScanLocalStationsView* searchStationsView = static_cast ( appUi->View( KFMRadioScanLocalStationsViewId ) ); + + ActivateL(); + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::~CFMRadioScanLocalStationsContainer +// Class destructor +// ---------------------------------------------------- +// +CFMRadioScanLocalStationsContainer::~CFMRadioScanLocalStationsContainer() + { + iControls.ResetAndDestroy(); + delete iChannelItemArray; + if ( iBackground ) + { + delete iBackground; + iBackground = NULL; + } + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::InitializeChannelListL +// Create the channel list (initially all spots are set as empty) +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::InitializeChannelListL() + { + iChannelList->Reset(); + iChannelItemArray->Reset(); + iChannelList->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); + // Pass the array to the listbox model and set the ownership type + iChannelList->Model()->SetItemTextArray( (MDesCArray*) iChannelItemArray ); + iChannelList->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); + iChannelList->HandleItemAdditionL(); + DrawDeferred(); + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::UpdateChannelListContentL +// Update the content of the channel at aIndex with the +// values specified +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::UpdateChannelListContentL( TInt aIndex, const TDesC& aInfoText, TInt aChannelFrequency, TBool aNowPlaying, TBool aInfoTextPlacement ) + { + TBuf textChannelItem; + TBuf textChIndex; + TBuf textChIconIndex; + + //textChIndex.Format( KChIndexFormatChList, aIndex+1 ); // One over index + textChIndex.SetLength( 0 ); + + textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList ) ; + //Update to display Devnagari numbers for Text Index. + //AknTextUtils::LanguageSpecificNumberConversion(textChIndex); + textChannelItem.Append( textChIndex ); + textChannelItem.Append( KColumnListSeparator ); + + TReal frequency = static_cast( aChannelFrequency / static_cast( KHzConversionFactor )); + // Gets locale decimal separator automatically + TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() ); + TBuf<30> frequencyString; + frequencyString.Num( frequency, format ); + + HBufC* listItemString = NULL; + if ( aInfoTextPlacement ) // frequency and PS name + { + const TInt granularity = 2; + + CDesCArray* stringsArray = new ( ELeave ) CDesCArrayFlat( granularity ); + CleanupStack::PushL( stringsArray ); + stringsArray->AppendL( frequencyString ); + stringsArray->AppendL( aInfoText ); + + listItemString = StringLoader::LoadL( R_QTN_FMRADIO_SINGLE_FREQ_NAME, *stringsArray, iEikonEnv ); + CleanupStack::PopAndDestroy( stringsArray ); + CleanupStack::PushL( listItemString ); + } + else // frequency + { + listItemString = StringLoader::LoadLC( R_QTN_FMRADIO_SINGLE_FREQ, frequencyString, iEikonEnv ); + } + + // Update for display of Hindi Devnagari Numbers + TPtr listItemStringPtr = listItemString->Des(); + AknTextUtils::LanguageSpecificNumberConversion( listItemStringPtr ); + + textChannelItem.Append( *listItemString ); + CleanupStack::PopAndDestroy( listItemString ); + + // Set 'Now Playing' icon to the channel item + textChannelItem.Append( KColumnListSeparator ); + + if ( aNowPlaying ) + { + textChannelItem.Append( textChIconIndex ); + } + + if( aIndex <= ( iChannelItemArray->Count() - 1 ) ) + { + iChannelItemArray->Delete( aIndex ); + iChannelList->HandleItemRemovalL(); + iChannelItemArray->InsertL( aIndex, textChannelItem ); + } + else + { + iChannelItemArray->AppendL( textChannelItem ); + } + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + } + + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::InsertScannedChannelToListL +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::InsertScannedChannelToListL( TInt aIndex, TInt aChannelFrequency ) + { + TBuf textChannelItem; + TBuf textChIndex; + + textChannelItem.Append( textChIndex ); + textChannelItem.Append( KColumnListSeparator ); + + TReal frequency = static_cast( aChannelFrequency / static_cast( KHzConversionFactor )); + // Gets locale decimal separator automatically + TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() ); + TBuf<30> frequencyString; + frequencyString.Num( frequency, format ); + + HBufC* listItemString = listItemString = StringLoader::LoadLC( R_QTN_FMRADIO_SINGLE_FREQ, frequencyString, iEikonEnv ); + // Update for display of Hindi Devnagari Numbers + TPtr listItemStringPtr = listItemString->Des(); + AknTextUtils::LanguageSpecificNumberConversion( listItemStringPtr ); + textChannelItem.Append( *listItemString ); + CleanupStack::PopAndDestroy( listItemString ); + + // Set 'Now Playing' icon to the channel item + textChannelItem.Append( KColumnListSeparator ); + + if ( aIndex <= ( iChannelItemArray->Count() - 1 ) ) + { + iChannelItemArray->InsertL( aIndex, textChannelItem ); + } + else + { + iChannelItemArray->AppendL( textChannelItem ); + } + + iChannelList->HandleItemAdditionL(); // Update list + iChannelList->UpdateScrollBarsL(); + iChannelList->DrawDeferred(); + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::RemoveChannelListContentL +// +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::RemoveChannelListContentL( TInt aIndex ) + { + if ( aIndex < iChannelItemArray->Count() ) + { + iChannelItemArray->Delete( aIndex ); + iChannelList->HandleItemRemovalL(); + iChannelList->UpdateScrollBarsL(); + + TInt channelCount = iChannelItemArray->Count(); + // check if the last channel is saved and update current item + if ( aIndex == channelCount && channelCount > 0 ) + { + iChannelList->SetCurrentItemIndex( channelCount - 1 ); + } + iChannelList->DrawDeferred(); + } + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::UpdateNowPlayingIconL +// Displays 'Now Playing' icon in the current selected channel item. +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::UpdateNowPlayingIconL( TInt aNewIndex, TInt aOldIndex ) + { + HideNowPlayingIconL( aOldIndex, EFalse ); + + if ( aNewIndex >= 0 && aNewIndex < iChannelItemArray->Count() ) + { + TBuf textChIconIndex; + textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList ); + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( aNewIndex ) ); + TPtr ptr( channelItem->Des() ); + ptr.Append( textChIconIndex ); // Add icon index + + iChannelItemArray->InsertL( aNewIndex, *channelItem ); + CleanupStack::PopAndDestroy( channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelItemArray->Delete( aNewIndex + 1 ); + iChannelList->HandleItemRemovalL(); + iChannelList->UpdateScrollBarsL(); + } + // required for fast channel browsing + iChannelList->DrawNow(); + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::HideNowPlayingIconL +// Hides 'Now Playing' icon from the last selected channel. +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::HideNowPlayingIconL( TInt aIndex, TBool aDraw ) + { + if ( aIndex >= 0 && aIndex < iChannelItemArray->Count() ) + { + HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString ); + channelItem->Des().Copy( iChannelItemArray->MdcaPoint( aIndex ) ); + TPtr ptr( channelItem->Des() ); + + TBuf textChIconIndex; + TPtrC iconIndexPtr( textChIconIndex ); + TInt err = TextUtils::ColumnText( iconIndexPtr, 2, &ptr ); + + if ( iconIndexPtr.Length() > 0 ) + { + ptr.Delete( ptr.Length() - iconIndexPtr.Length(), iconIndexPtr.Length() ); // Remove icon index + iChannelItemArray->InsertL( aIndex, *channelItem ); + iChannelList->HandleItemAdditionL(); // Update list + iChannelItemArray->Delete( aIndex + 1 ); + iChannelList->HandleItemRemovalL(); + iChannelList->UpdateScrollBarsL(); + + } + CleanupStack::PopAndDestroy( channelItem ); + if ( aDraw ) + { + iChannelList->DrawDeferred(); + } + } + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::SetFaded +// Fades the entire window and controls in the window owned +// by this container control. +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::SetFaded( TBool aFaded ) + { + iFadeStatus = aFaded; + Window().SetFaded( aFaded, RWindowTreeNode::EFadeIncludeChildren ); + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::UpdateLastListenedChannel +// Updates channel index - the highlighted channel in the list. +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::UpdateLastListenedChannel( TInt aIndex ) + { + if ( aIndex < iChannelItemArray->Count() && + aIndex > -1 ) + { + iLastChIndex = aIndex; + + iChannelList->SetCurrentItemIndex( iLastChIndex ); + iChannelList->ScrollToMakeItemVisible( iLastChIndex ); + DrawDeferred(); + } + + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::CurrentlySelectedChannel +// Returns the index of the selected channel item from the +// channel list. +// ---------------------------------------------------- +// +TInt CFMRadioScanLocalStationsContainer::CurrentlySelectedChannel() const + { + return iChannelList->CurrentItemIndex(); // Index of selected channel + } + +// ---------------------------------------------------- +// CFMRadioScanLocalStationsContainer::HandleListBoxEventL +// For handling listbox-, in this case, channel list events. +// The event equals to selecting a channel item from the list. +// ---------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, + TListBoxEvent aEventType ) + { + // Check the event generated by keypress and report the event, + // Also check for Pen Enabled touch screen event + switch ( aEventType ) + { + case EEventEnterKeyPressed: + case EEventItemSingleClicked: // new event for item activation + { + ReportEventL( MCoeControlObserver::EEventStateChanged ); + break; + } + default: + { + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::HandleResourceChange +// ----------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + SizeChanged(); + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::SizeChanged +// Called by framework when the view size is changed +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::SizeChanged() + { + iChannelList->SetRect( Rect() ); + + if ( iBackground ) + { + iBackground->SetRect( Rect() ); + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::CountComponentControls +// Return the number of controls in the window owned by this container +// --------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsContainer::CountComponentControls() const + { + return iControls.Count(); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::ComponentControl +// Return the control corresponding to the specified index +// --------------------------------------------------------- +// +CCoeControl* CFMRadioScanLocalStationsContainer::ComponentControl( TInt aIndex ) const + { + return STATIC_CAST( CCoeControl*, iControls[aIndex] ); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::OfferKeyEventL +// Allow the channel list to process key events +// --------------------------------------------------------- +// +TKeyResponse CFMRadioScanLocalStationsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + TKeyResponse response = EKeyWasNotConsumed; + + switch ( aKeyEvent.iCode ) + { + case EKeyLeftArrow: + case EKeyRightArrow: + return EKeyWasNotConsumed; + + case EKeyUpArrow: + case EKeyDownArrow: + response = iChannelList->OfferKeyEventL( aKeyEvent, aType ); + if (response == EKeyWasConsumed) + { + ReportEventL( MCoeControlObserver::EEventRequestFocus ); + } + return response; + + + default: + switch ( aKeyEvent.iScanCode ) //we need to use the scan code, because we need to process the event wrt the keyUp and keyDown action + { + case EKeyboardKey1: // Timed key + case EKeyboardKey2: // Normal keys + case EKeyboardKey3: + case EKeyboardKey4: + case EKeyboardKey5: + case EKeyboardKey6: + case EKeyboardKey7: + case EKeyboardKey8: + case EKeyboardKey9: + case EKeyboardKey0: + return EKeyWasNotConsumed; + default: + break; + } + break; + } + return iChannelList->OfferKeyEventL( aKeyEvent, aType ); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::Draw +// Redraw the window owned by this container +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::Draw( const TRect& aRect ) const + { + CWindowGc& gc = SystemGc(); + gc.Clear(); + + if ( iBackground ) + { + if ( !AknsDrawUtils::Background( iSkin, iBackground, this, gc, aRect) ) + { + // The background was not drawn + iBackground->UpdateContext(); + } + } + // Fade if needed + Window().SetFaded( iFadeStatus, RWindowTreeNode::EFadeIncludeChildren ); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::GetHelpContext +// Gets Help +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::GetHelpContext( TCoeHelpContext& aContext ) const + { +#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE + aContext.iMajor = TUid::Uid( KUidFMRadioApplication ); + aContext.iContext = KFMRADIO_HLP_SEARCH; +#endif + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::FocusChanged(TDrawNow aDrawNow) +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::FocusChanged( TDrawNow aDrawNow ) + { + CCoeControl::FocusChanged( aDrawNow ); + if ( iChannelList ) + { + iChannelList->SetFocus( IsFocused(), aDrawNow ); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::ResetChannelListL +// Sets toolbar visibility +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::ResetChannelListL() + { + iChannelItemArray->Reset(); + iChannelList->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); + iChannelList->HandleItemRemovalL(); + iChannelList->DrawDeferred(); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::SetStationListEmptyTextL +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::SetStationListEmptyTextL( const TDesC& aText ) + { + iChannelList->View()->SetListEmptyTextL( aText ); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::HandlePointerEventL +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) + { + // don't handle any pointer events if view is faded + if ( !iFadeStatus ) + { + CCoeControl::HandlePointerEventL( aPointerEvent ); + } + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradioscanlocalstationsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradioscanlocalstationsview.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,1709 @@ +/* +* 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: Implementation of the class CFMRadioScanLocalStationsView +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include // for basic note +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiobacksteppingservicewrapper.h" +#include "fmradioengine.h" +#include "fmradiordsreceiverbase.h" +#include "fmradio.hrh" +#include "fmradioscanlocalstationsview.h" +#include "fmradiopreset.h" +#include "fmradioscanlocalstationscontainer.h" +#include "debug.h" +#include "fmradioappui.h" + + +const TInt KMSKControlID(3); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::NewL +// Two-phase constructor of CFMRadioScanLocalStationsView +// --------------------------------------------------------------------------- +// +CFMRadioScanLocalStationsView* CFMRadioScanLocalStationsView::NewL( CRadioEngine& aRadioEngine, + MChannelListHandler& aObserver ) + { + CFMRadioScanLocalStationsView* self = new (ELeave) CFMRadioScanLocalStationsView( aRadioEngine, + aObserver ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::CFMRadioScanLocalStationsView +// Parameter constructor ( default constructor ) +// --------------------------------------------------------------------------- +// +CFMRadioScanLocalStationsView::CFMRadioScanLocalStationsView( CRadioEngine& aRadioEngine, + MChannelListHandler& aObserver ): + iNowPlayingIndex( KErrNotFound ), + iScanAndSaveActivated( EFalse ), + iScanCancelled( EFalse ), + iRadioEngine( aRadioEngine ), + iTuneRequested( EFalse ), + iObserver( aObserver ), + iCancelType( EFMRadioCancelScanDefault ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ConstructL +// EPOC two-phased constructor +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::ConstructL() + { + BaseConstructL( R_FMRADIO_SEARCH_STATIONS_VIEW ); + PrepareToolbar(); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::~CFMRadioScanLocalStationsView +// Class destructor +// --------------------------------------------------------------------------- +// +CFMRadioScanLocalStationsView::~CFMRadioScanLocalStationsView() + { + if ( iContainer ) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + delete iContainer; + iContainer = NULL; + } + + if ( iScanningNote ) + { + TRAP_IGNORE( iScanningNote->ProcessFinishedL() ); + iScanningNote = NULL; + } + iScannedChannels.ResetAndDestroy(); + iScannedChannels.Close(); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::Id +// Return the unique identifier corresponding to this view +// --------------------------------------------------------------------------- +// +TUid CFMRadioScanLocalStationsView::Id() const + { + return KFMRadioScanLocalStationsViewId; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::DoActivateL +// Activate the channel list view +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::DoActivateL Start") ) ); + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY ); + Cba()->DrawDeferred(); // Redraw softkeys + + + HBufC* title = StringLoader::LoadLC( R_FMRADIO_SEARCH_STATIONS_VIEW_TITLE, iCoeEnv ); + static_cast( StatusPane()->ControlL( + TUid::Uid( EEikStatusPaneUidTitle ) ) )->SetTextL( *title ); + CleanupStack::PopAndDestroy( title ); + + if ( !iContainer ) + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::DoActivateL inside second, not iContainer if") ) ); + iContainer = CFMRadioScanLocalStationsContainer::NewL( ClientRect(), iRadioEngine ); + iContainer->SetMopParent( this ); + iContainer->SetObserver( this ); + AppUi()->AddToStackL( *this, iContainer ); + } + AppUi()->HandleCommandL( EFMRadioCmdScanLocalStationsViewActive ); + + ResetListAndStartScanL(); + iRadioEngine.RdsReceiver().AddObserver( this ); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::HandleCommandL +// Interprets view's menu,softkey and other commands and acts +// accordingly by calling the appropriate command handler +// function for further action. +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::HandleCommandL( TInt aCommand ) + { + CFMRadioAppUi* appUi = static_cast( AppUi() ); + switch ( aCommand ) + { + case EAknSoftkeyBack: // go back to the main view + { + const TVwsViewId viewId( TUid::Uid( KUidFMRadioApplication ), Id() ); + if ( appUi->BackSteppingWrapper().HandleBackCommandL( viewId ) ) + { + // Command was consumed + break; + } + // Fall through to activate previous view + } + case EEikBidCancel: + { + if ( iFaded ) + { + appUi->HandleCommandL( aCommand ); + } + else + { + appUi->ActivateLocalViewL( KFMRadioChannelListViewId ); + } + break; + } + case EFMRadioCmdSaveChannel: + { + HandleOneChannelSaveL(); + break; + } + case EFMRadioCmdSaveAllChannels: + SaveAllChannelsL(); + break; + case EFMRadioCmdScanLocalStationsScan: // start station scanning + { + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY ); + Cba()->DrawDeferred(); // Redraw softkeys + //reset all counters, make station list empty + ResetListAndStartScanL(); + break; + } + + case EFMRadioCmdListenCh: + { + PlayCurrentlySelectedChannelL(); + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR_SAVE ); + break; + } + default: // Send all other commands to AppUi + appUi->HandleCommandL( aCommand ); + break; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetLastListenedChannel +// Keep track of the last selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetLastListenedChannel( TInt aIndex ) + { + iChIndex = aIndex; + if ( iContainer ) + { + iContainer->UpdateLastListenedChannel( aIndex ); // Update index + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetNowPlayingChannelL +// Keep track of the current selected channel +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetNowPlayingChannelL( TInt aChannelIndex ) + { + TInt oldIndex = iNowPlayingIndex; + iNowPlayingIndex = aChannelIndex; + + if ( iContainer && ( aChannelIndex != oldIndex ) ) + { + if ( ChannelInUse( oldIndex ) && + !iScannedChannels[ oldIndex ]->PresetNameValid() ) + { + // Remove dynamic ps name + iContainer->UpdateChannelListContentL( oldIndex, + KNullDesC, + iScannedChannels[ oldIndex ]->PresetFrequency(), + EFalse, + EFalse ); + } + iContainer->UpdateNowPlayingIconL( iNowPlayingIndex, oldIndex ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::CurrentlyPlayingChannel +// Returns the index of the playing channel item from the channel list. +// --------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::CurrentlyPlayingChannel() + { + return iNowPlayingIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ChannelInPlay +// Return true/false to indicate whether the channel specified +// is in play +// --------------------------------------------------------------------------- +// +TBool CFMRadioScanLocalStationsView::ChannelInPlay( TInt aChannelIndex ) const + { + if( aChannelIndex == iNowPlayingIndex ) + { + return ETrue; + } + else + { + return EFalse; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ChannelInUse +// Return true/false to indicate whether the channel specified +// is in use +// --------------------------------------------------------------------------- +// +TBool CFMRadioScanLocalStationsView::ChannelInUse( const TInt aChannelIndex ) const + { + TBool ret = EFalse; + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::ChannelInUse Start") ) ); + + if ( aChannelIndex >= KMinNumberOfChannelListItems && + aChannelIndex < iScannedChannels.Count() ) + { + ret = ETrue; + } + return ret; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::FadeAndShowExit +// Fade the view and all controls associated with it. Change +// the soft keys so that "Exit" is displayed +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::FadeAndShowExit( TBool aFaded ) + { + TInt err = KErrNone; + iFaded = aFaded; + if( iContainer ) + { + if ( aFaded ) // Fade + { + // In case options menu is open when headset is disconnected + StopDisplayingMenuBar(); + SetToolbarDimmedState( ETrue ); + iContainer->SetFaded( aFaded ); + TRAP( err,Cba()->SetCommandSetL( R_FMRADIO_SOFTKEYS_EXIT ) ); + } + else + { + SetToolbarDimmedState( EFalse ); + iContainer->SetFaded(aFaded); + TRAP( err,Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ) ); + // Update index to be sure it is up-to-date (in case if list was scrolled in idle state) + iContainer->UpdateLastListenedChannel( iChIndex ); + + if( iScannedChannels.Count() > 0 ) + { + TRAP_IGNORE( SetMiddleSoftKeyIconL(); ) + + if ( ( CurrentlyPlayingChannel() == CurrentlySelectedChannel() ) ) + { + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR_SAVE ); + } + else + { + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR ); + } + } + } + Cba()->DrawDeferred(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::UpdateDisplayForFocusGained +// Update the view after a focus gained event. +// 1. Fade/Unfade view +// 2. Update MSK label +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::UpdateDisplayForFocusGained() + { + FadeAndShowExit( iFaded ); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::UpdateChannelListContentL +// Make a request to the channel container to update the +// content of the channel at aIndex with the values specified +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::UpdateChannelListContentL( TInt aIndex, + TInt aChannelFrequency ) + { + TBool nowPlaying = EFalse; + if( ChannelInPlay( aIndex ) ) + { + nowPlaying = ETrue; + } + else + { + nowPlaying = EFalse; + } + if ( iContainer ) + { + iContainer->UpdateChannelListContentL( aIndex, KNullDesC, aChannelFrequency, nowPlaying ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::CurrentlySelectedChannel +// Returns the index of the selected channel item from the +// channel list. If the container is active get the info from +// it, because it may have more up-to-date info. +// --------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::CurrentlySelectedChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + return iChIndex; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::NextChannel +// Retrieve the index of the next channel that has been set. +// --------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::NextChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + else + { + iChIndex = iRadioEngine.GetPresetIndex(); + } + + TInt nextChannel = iChIndex; + for ( TInt i = iChIndex + 1; i < KMaxNumberOfChannelListItems; i++ ) + { + if ( ChannelInUse( i ) ) + { + nextChannel = i; + break; + } + } + if ( nextChannel == iChIndex ) + { + for ( TInt i = 0; i < iChIndex; i++ ) + { + if ( ChannelInUse( i ) ) + { + nextChannel = i; + break; + } + } + } + return nextChannel; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::PreviousChannel +// Retrieve the index of the previous channel that has been set. +// --------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::PreviousChannel() + { + if ( iContainer ) + { + iChIndex = iContainer->CurrentlySelectedChannel(); + } + else + { + iChIndex = iRadioEngine.GetPresetIndex(); + } + + TInt previousChannel = iChIndex; + + for ( TInt i = iChIndex - 1; i >= 0; i-- ) + { + if ( ChannelInUse( i ) ) + { + previousChannel = i; + break; + } + } + if ( previousChannel == iChIndex ) + { + for ( TInt i = KMaxNumberOfChannelListItems - 1; i > iChIndex; i-- ) + { + if ( ChannelInUse( i ) ) + { + previousChannel = i; + break; + } + } + } + return previousChannel; + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::HandleControlEventL +// Handles control event observing. In this case the interest +// is only on the channel selection from the channel list. +// Other events are not reported by the container, +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::HandleControlEventL( CCoeControl* aControl, + TCoeEvent aEventType ) + { + if ( aControl == iContainer ) + { + if ( aEventType == MCoeControlObserver::EEventRequestFocus ) + { + // Don't display MSK when display is faded. + if ( !iFaded && !AknLayoutUtils::PenEnabled() ) + { + // event sent if up or down arrow keys are pressed + if ( ( CurrentlyPlayingChannel() == CurrentlySelectedChannel() ) ) + { + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR_SAVE ); + } + else + { + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR ); + } + } + else if ( ChannelInUse( CurrentlySelectedChannel() ) ) + { + PlayCurrentlySelectedChannelL(); + } + } + else if ( aEventType == MCoeControlObserver::EEventStateChanged + && ChannelInUse( CurrentlySelectedChannel() ) ) + { + PlayCurrentlySelectedChannelL(); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::DoDeactivate +// Deactivate the channel list view +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::DoDeactivate() + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::DoDeactivate") ) ); + CFMRadioAppUi* appUi = static_cast( AppUi() ); + + if ( iToolbar ) + { + // hide toolbar so it is not visible when activating view again + iToolbar->SetToolbarVisibility( EFalse ); + } + + if ( appUi->RadioEngine() ) + { + iRadioEngine.RdsReceiver().RemoveObserver( this ); + } + if ( iContainer ) + { + appUi->RemoveFromViewStack( *this, iContainer ); + } + + iScanAndSaveActivated = EFalse; + + // If exiting, iRadioEngine is no longer valid object + if( appUi->RadioEngine() ) + { + appUi->RadioEngine()->CancelScanLocalStationsScan(); + // Stop seek doesn't get called automatically as this is not active view anymore + TRAP_IGNORE( StopSeekL() ) + } + + delete iContainer; + iContainer = NULL; + // release allocated memory for scanned stations + iScannedChannels.ResetAndDestroy(); + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::DynInitMenuPaneL +// Sets the state of menu items dynamically according to the +// state of application data. +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::DynInitMenuPaneL( TInt aResourceId, + CEikMenuPane* aMenuPane ) + { + if ( aResourceId == R_FMRADIO_SEARCH_STATIONS_OPTIONS_MENU ) // Main menu + { + if ( iRadioEngine.IsAudioRoutingPossible() ) + { + if ( iRadioEngine.GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdActivateIhf ); + if ( iRadioEngine.IsHeadsetConnected() ) + { + aMenuPane->SetItemTextL( EFMRadioCmdDeactivateIhf, R_QTN_FMRADIO_OPTIONS_DEACTIVATE ); + } + } + else + { + // Delete existing menu option and add a new one + aMenuPane->DeleteMenuItem( EFMRadioCmdDeactivateIhf ); + aMenuPane->SetItemTextL( EFMRadioCmdActivateIhf, R_QTN_FMRADIO_OPTIONS_ACTIVATE ); + } + } + else + { + aMenuPane->SetItemDimmed( EFMRadioCmdDeactivateIhf, ETrue ); + aMenuPane->SetItemDimmed( EFMRadioCmdActivateIhf, ETrue ); + } + + if ( iScannedChannels.Count() < 2 ) + { + aMenuPane->DeleteMenuItem( EFMRadioCmdSaveAllChannels ); + } + + // if help is not enabled, disable help option + if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) + { + aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::LayoutChangedL +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::LayoutChangedL( TInt aType ) + { + if( iContainer ) + { + iContainer->SetRect( ClientRect() ); + iContainer->HandleResourceChange( aType ); + } + } + +// --------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetMiddleSoftKeyLabelL +// Sets middle softkey label. +// --------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetMiddleSoftKeyLabelL( const TInt aResourceId, + const TInt aCommandId ) + { + if ( !AknLayoutUtils::PenEnabled() ) + { + CEikButtonGroupContainer* cbaGroup = Cba(); + if ( cbaGroup ) + { + cbaGroup->RemoveCommandFromStack( KMSKControlID, iCurrentMSKCommandId ); + HBufC* middleSKText = StringLoader::LoadLC( aResourceId, iCoeEnv ); + TPtr mskPtr = middleSKText->Des(); + cbaGroup->AddCommandToStackL( + KMSKControlID, + aCommandId, + mskPtr ); + CleanupStack::PopAndDestroy( middleSKText ); + iCurrentMSKCommandId = aCommandId; + } + } + } + +// --------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetMiddleSoftKeyIconL +// Sets middle softkey icon. +// --------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetMiddleSoftKeyIconL() + { + if ( !AknLayoutUtils::PenEnabled() ) + { + CEikButtonGroupContainer* cbaGroup = Cba(); + CFbsBitmap* bitmap = NULL; + CFbsBitmap* mask = NULL; + if ( cbaGroup ) + { + TFileName mbmFileName; + TFindFile finder( iCoeEnv->FsSession() ); + TInt err = finder.FindByDir( KFMRadioBmpFile, KDC_APP_BITMAP_DIR ); + if ( err == KErrNone ) + { + mbmFileName.Copy( finder.File() ); + } + + AknsUtils::CreateColorIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropMskMenu, + KAknsIIDQsnComponentColors, + EAknsCIQsnComponentColorsCG13, + bitmap, + mask, + mbmFileName, + EMbmFmradioQgn_prop_msk_menu, + EMbmFmradioQgn_prop_msk_menu_mask, + KRgbBlack ); + + CleanupStack::PushL( bitmap ); + CleanupStack::PushL( mask ); + + cbaGroup->RemoveCommandFromStack( KMSKControlID, iCurrentMSKCommandId ); + cbaGroup->AddCommandToStackL( + KMSKControlID, + EAknSoftkeyContextOptions, + *bitmap, + *mask ); + + iCurrentMSKCommandId = EAknSoftkeyContextOptions; + + CleanupStack::PopAndDestroy( 2, bitmap ); + } + } + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SaveAllChannelsL +// Saves all the scanned channels into Radio Engine's presets. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SaveAllChannelsL() + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + if ( appUi->NumberOfChannelsStored() > 0 ) + { + //We have some tuned channels, + //so we have to check does the user want to + //add new channes or replace the old ones. + TInt numberOfEmptySlots = KMaxNumberOfChannelListItems - appUi->NumberOfChannelsStored(); + if( numberOfEmptySlots >= iScannedChannels.Count() ) + { + //more vacant than new channels + //we can add or replace + TInt index(0); + CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog( &index ); + query->PrepareLC( R_FMRADIO_LISTQUERY_SAVE_ALL_REPLACE_APPEND ); + if( query->RunLD() ) + { + const TInt KIndexOfSaveAllReplaceExistingCmd = 0; + const TInt KIndexOfSaveAllAppendCmd = 1; + if( index == KIndexOfSaveAllReplaceExistingCmd ) + { + SaveFoundChannelsToPresetsL( EReplace ); + } + else if( index == KIndexOfSaveAllAppendCmd ) + { + SaveFoundChannelsToPresetsL( EAppend ); + } + } + else + { + ShowToolbar( ETrue ); + } + } + else + { + //no room for all the channels + if( numberOfEmptySlots == 0 ) + { + CAknQueryDialog* query = CAknQueryDialog::NewL(); + if ( query->ExecuteLD( R_FMRADIO_REPLACE_EXISTING_CHANNELS_QUERY ) ) + { + SaveFoundChannelsToPresetsL( EReplace ); + } + else + { + ShowToolbar( ETrue ); + } + } + else + { + TInt index(0); + CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog( &index ); + query->PrepareLC( R_FMRADIO_LISTQUERY_SAVE_ALL_REPLACE_APPEND_LIST_ALMOST_FULL ); + if( query->RunLD() ) + { + const TInt KIndexOfSaveAllAppendCmd = 0; + const TInt KIndexOfSaveAllReplaceExistingCmd = 1; + if( index == KIndexOfSaveAllReplaceExistingCmd ) + { + SaveFoundChannelsToPresetsL( EReplace ); + } + else if( index == KIndexOfSaveAllAppendCmd ) + { + SaveFoundChannelsToPresetsL( EAppend ); + } + } + else + { + ShowToolbar( ETrue ); + } + } + } + } + else + { + //No previous channels + SaveFoundChannelsToPresetsL( EReplace ); + } + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ShowConfirmationQueryL +// Get confirmation from user. +// ----------------------------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::ShowConfirmationQueryL(TInt aResText, TInt aResQuery) + { + TInt accepted = EFalse; + HBufC* prompt = StringLoader::LoadLC( aResText, iEikonEnv ); + CAknQueryDialog* queryDlg = CAknQueryDialog::NewL(); + accepted = queryDlg->ExecuteLD( aResQuery, *prompt ); + CleanupStack::PopAndDestroy( prompt ); + return accepted; + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::StopSeekL +// Invoked by AppUi when a seek is completed or aborted. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::StopSeekL() + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::StopSeekL") ) ); + + if ( iTuneRequested ) + { + iTuneRequested = EFalse; + + // if tune request comes from scan all (= ResetListAndStartScanL ) + // then start the whole scan + if ( iScanAndSaveActivated ) + { + AppUi()->HandleCommandL( EFMRadioCmdScanLocalStationsScan ); + } + } + else if ( iScanAndSaveActivated ) + { + // No channels found or user has canceled search before any channels are found + if ( iRadioEngine.GetTunedFrequency() == iLowerFrequencyBound && + iScannedChannels.Count() == 0 ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + if ( appUi->IsStartupWizardRunning() ) + { + //no stations are found in Wizard + if (iCancelType == EFMRadioCancelScanDefault) + { + HBufC* string = NULL; + string = StringLoader::LoadLC( R_QTN_FMRADIO_NO_STATIONS_FOUND, iEikonEnv ); + CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); // waiting + note->ExecuteLD( *string ); + CleanupStack::PopAndDestroy( string ); + } + + iScanAndSaveActivated = EFalse; + + RemoveScanningInProgressNoteL(); + RestoreRadio( EFalse ); + appUi->AutoTuneInMainView(ETrue); + + ActivateMainViewL(); + } + else + { + if( iContainer ) + { + HBufC* listEmptyText = NULL; + listEmptyText = StringLoader::LoadLC( R_QTN_FMRADIO_LIST_NO_STATIONS_FOUND, iEikonEnv ); + iContainer->SetStationListEmptyTextL( *listEmptyText ); + CleanupStack::PopAndDestroy( listEmptyText ); + + iContainer->ResetChannelListL(); + } + + iScanAndSaveActivated = EFalse; + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); + Cba()->DrawDeferred(); // Redraw softkeys + RemoveScanningInProgressNoteL(); + + UpdateToolbar(); + ShowToolbar( ETrue ); + RestoreRadio(); + } + } + else + { + AddTunedFrequencyToListL(); + } + } + else + { + RemoveScanningInProgressNoteL(); + TBool restoreFrequency = EFalse; + TInt tunedFrequency = iRadioEngine.GetTunedFrequency(); + + if ( tunedFrequency == iLowerFrequencyBound && + iScannedChannels.Count() == 0 ) + { + restoreFrequency = ETrue; + } + UpdateToolbar(); + RestoreRadio( restoreFrequency ); + + // update now playing index if the tuning is triggered from accessory + TInt frequencyIndex = FrequencyIndex( tunedFrequency ); + + if ( frequencyIndex != KErrNotFound ) + { + SetNowPlayingChannelL( frequencyIndex ); + SetLastListenedChannel( frequencyIndex ); + } + else // frequency is not in the list, remove now playing channel status + { + SetNowPlayingChannelL( KErrNotFound ); + } + } + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RestoreRadio +// Restores the radio after scanning +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RestoreRadio( TBool aTuneInitialFrequency ) + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::RestoreRadio") ) ); + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + // if iInitialTunedFrequency is 0, radio has already been restored + if ( iInitialTunedFrequency ) + { + if ( aTuneInitialFrequency ) + { + iTuneRequested = ETrue; + iRadioEngine.Tune( iInitialTunedFrequency ); + } + //unmute radio + iRadioEngine.SetMuteOn( EFalse ); + iInitialTunedFrequency = 0; + } + appUi->SetStartupWizardRunning( EFalse ); + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::AddTunedFrequencyToListL +// Updates found channels to the list. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::AddTunedFrequencyToListL() + { + FTRACE( FPrint( _L("CFMRadioScanLocalStationsView::AddTunedFrequencyToListL") ) ); + TInt tunedFrequency = iRadioEngine.GetTunedFrequency(); + + if ( KErrNotFound == FrequencyIndex( tunedFrequency ) ) + { + // the frequency is new and may be added + CFMRadioPreset* channel = CFMRadioPreset::NewL(); + CleanupStack::PushL( channel ); + channel->SetPresetFrequency( tunedFrequency ); + // Make the name invalid by default so that possibly dynamic PS name won't get saved + channel->SetPresetNameValid( EFalse ); + + TInt freqIndex = SortedFrequencyListIndex( tunedFrequency ); + + if ( freqIndex < ( iScannedChannels.Count() - 1 ) ) + { + iScannedChannels.Insert( channel, freqIndex ); + } + else + { + iScannedChannels.AppendL( channel ); + } + CleanupStack::Pop( channel ); + + // update a radiostation slot in the list + // check if there is place + if ( iContainer ) + { + iContainer->InsertScannedChannelToListL( freqIndex, tunedFrequency ); + iContainer->DrawDeferred(); + } + // scan for another frequency + AppUi()->HandleCommandL( EFMRadioCmdScanLocalStationsScan ); + } + else + { + //stop scanning + iScanAndSaveActivated = EFalse; + Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); + Cba()->DrawDeferred(); // Redraw softkeys + + RemoveScanningInProgressNoteL(); + SetMiddleSoftKeyIconL(); + SetContextMenu( R_FMRADIO_SCAN_STATIONS_CTX_MENUBAR_SAVE ); + + if ( iContainer ) + { + iContainer->UpdateLastListenedChannel( 0 ); // select the first channel + PlayCurrentlySelectedChannelL(); + iContainer->DrawDeferred(); + } + + //unmute radio + iRadioEngine.SetMuteOn( EFalse ); + + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + if ( appUi->IsStartupWizardRunning() ) + { + appUi->SetStartupWizardRunning( EFalse ); + + if ( iScanCancelled ) + { + iScanCancelled = EFalse; + ActivateMainViewL(); + } + else + { + SaveAllChannelsL(); + } + } + else + { + UpdateToolbar(); + ShowToolbar( ETrue ); + } + } + } + +// ----------------------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ResetCountersL +// Called when a new scan is activated. +// ----------------------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::ResetListAndStartScanL() + { + User::LeaveIfNull( iContainer ); + iNowPlayingIndex = KErrNotFound; + ShowToolbar( EFalse ); + iContainer->SetStationListEmptyTextL( KNullDesC ); + iScanAndSaveActivated = ETrue; + DisplayScanningInProgressNoteL(); + + iInitialTunedFrequency = 0; + iScanCancelled = EFalse; + iCancelType = EFMRadioCancelScanDefault; + iScannedChannels.ResetAndDestroy(); + iContainer->InitializeChannelListL(); + + //mute radio + if ( !iRadioEngine.IsMuteOn() ) + { + iRadioEngine.SetMuteOn( ETrue ); + } + + //update upper and lower frequency bands + iRadioEngine.GetFrequencyBandRange( iLowerFrequencyBound, iUpperFrequencyBound ); + + iInitialTunedFrequency = iRadioEngine.GetTunedFrequency(); + + if ( iRadioEngine.GetTunedFrequency() != iLowerFrequencyBound ) + { + iTuneRequested = ETrue; + iRadioEngine.Tune( iLowerFrequencyBound ); + } + else + { + AppUi()->HandleCommandL( EFMRadioCmdScanLocalStationsScan ); + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::DisplayScanningInProgressNoteL +// Display a wait note while the channel fill is occuring. +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::DisplayScanningInProgressNoteL() + { + iScanningNote = new (ELeave) CAknWaitDialog(REINTERPRET_CAST(CEikDialog**, &iScanningNote)); + iScanningNote->SetCallback( this ); + + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + if ( appUi->IsStartupWizardRunning() ) + { + iScanningNote->PrepareLC( R_FMRADIO_SEARCH_STATIONS_WAIT_CANCEL_NOTE ); + } + else + { + iScanningNote->PrepareLC( R_FMRADIO_SEARCH_STATIONS_WAIT_NOTE ); + } + + iScanningNote->RunLD(); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::RemoveScanningInProgressNoteL +// Remove and destroy the scanning fill note. +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RemoveScanningInProgressNoteL() + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::RemoveScanningInProgressNoteL"))); + if ( iScanningNote ) + { + iScanningNote->ProcessFinishedL(); // Inform seek note to stop and hide it + iScanningNote = NULL; + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::DialogDismissedL +// Called when user cancels waiting note or process finishes +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::DialogDismissedL( TInt aButtonId ) + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::DialogDismissedL"))); + iScanningNote = NULL; + if ( aButtonId == EAknSoftkeyCancel ) + { + // cancel any process in here + /*Dialog get this button ID when dismissed, if headset is pulled off + we don't want to change the cancel type*/ + if( iCancelType != EFMRadioCancelScanByHeadsetDisconnect) + { + SetScanCanceled(EFMRadioCancelScanBySoftkey); + } + iRadioEngine.CancelScanLocalStationsScan(); + } + } + +void CFMRadioScanLocalStationsView::SetScanCanceled( TFMRadioCancelScanType aType ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + if ( appUi->IsStartupWizardRunning() ) + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::SetScanCanceled"))); + iScanCancelled = ETrue; + iCancelType = aType; + } + else + { + iScanCancelled = EFalse; + iCancelType = EFMRadioCancelScanDefault; + } + } + +TFMRadioCancelScanType CFMRadioScanLocalStationsView::CancelType() + { + return iCancelType; + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsContainer::SaveFoundChannelsToPresets +// Save scanned channels to presets +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SaveFoundChannelsToPresetsL( TSavingMode aSavingMode ) + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::SaveFoundChannelsToPresetsL Mode %d"), aSavingMode ) ); + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + + //store as much as the list is keeping + TInt limit; + TInt chCount = iScannedChannels.Count(); + + if ( chCount >= KMaxNumberOfChannelListItems ) + { + limit = KMaxNumberOfChannelListItems; + } + else + { + limit = chCount; + } + + TInt savedChannelCount = 0; + + if( aSavingMode == EAppend ) + { + /** Append found channels to preset list */ + for( TInt freqIx = 0; KMaxNumberOfChannelListItems > iObserver.Channels()->Count() && + chCount > freqIx; freqIx++ ) + { + const TDesC& name = iScannedChannels[ freqIx ]->PresetNameValid() ? + iScannedChannels[ freqIx ]->PresetName() : KNullDesC; + + iObserver.AddChannelToListL( name, + iScannedChannels[ freqIx ]->PresetFrequency() ); + + savedChannelCount++; + + } + + iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + + } + else // Replace + { + iObserver.UpdateChannelsL( ERemoveAllFromRepository, 0, 0 ); + + for ( TInt index = 0; index < limit; index++ ) + { + const TDesC& name = iScannedChannels[ index ]->PresetNameValid() ? + iScannedChannels[ index ]->PresetName() : KNullDesC; + iObserver.AddChannelToListL( name, + iScannedChannels[ index ]->PresetFrequency() ); + savedChannelCount++; + } + iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + } + + // display note about how many many channels were saved to the preset list + HBufC* string = NULL; + string = StringLoader::LoadLC( R_QTN_FMRADIO_STATIONS_SAVED, savedChannelCount, iEikonEnv ); + CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue ); // waiting + note->ExecuteLD( *string ); + CleanupStack::PopAndDestroy( string ); + + ActivateMainViewL(); + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsView::PlayCurrentlySelectedChannel +// Play currently selected channel from scan local stations list +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::PlayCurrentlySelectedChannelL() + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::PlayCurrentlySelectedChannelL"))); + + TInt selectedChannel = CurrentlySelectedChannel(); + if ( ChannelInUse( selectedChannel ) ) + { + TInt selectedFrequency = iScannedChannels[ selectedChannel ]->PresetFrequency(); + + if ( iRadioEngine.GetTunedFrequency() != selectedFrequency ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + iTuneRequested = ETrue; + SetNowPlayingChannelL( selectedChannel ); + SetLastListenedChannel( selectedChannel ); + appUi->TuneL( selectedFrequency ); + } + else + { + SetNowPlayingChannelL( selectedChannel ); + SetLastListenedChannel( selectedChannel ); + } + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsView::ShowToolbar +// Sets toolbar visibility. +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::ShowToolbar( TBool aVisible ) + { + if ( iToolbar && AknLayoutUtils::PenEnabled() ) + { + iToolbar->SetToolbarVisibility( aVisible ); + iToolbar->UpdateBackground(); + iToolbar->DrawDeferred(); + // just to make sure container has the right rect when toolbar is displayed + if ( aVisible && iContainer ) + { + iContainer->SetRect( ClientRect() ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsDataProgrammeService +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsDataProgrammeService( const TDesC& aProgramService ) + { + FTRACE(FPrint(_L("CFMRadioScanLocalStationsView::RdsDataProgrammeService"))); + if ( iContainer && !iTuneRequested && aProgramService.Length() > 0 ) + { + TInt tunedChannel = CurrentlyPlayingChannel(); + + TRAP_IGNORE + ( + if ( ChannelInUse( tunedChannel ) ) + { + iContainer->UpdateChannelListContentL( tunedChannel, + aProgramService, + iScannedChannels[ tunedChannel ]->PresetFrequency(), + ETrue, + ETrue ); + + // update PS name also to the list containing the scanned preset values + iScannedChannels[ tunedChannel ]->SetPresetNameL( aProgramService ); + iContainer->DrawDeferred(); + } + ) + } + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsDataPsNameIsStatic +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsDataPsNameIsStatic( TBool aStatic ) + { + TInt tunedChannel = CurrentlyPlayingChannel(); + if( ChannelInUse( tunedChannel ) ) + { + iScannedChannels[ tunedChannel ]->SetPresetNameValid( aStatic ); + } + } + +// --------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsDataRadioText +// --------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsDataRadioText( const TDesC&/* aRadioText */) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsAfSearchBegin +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsAfSearchBegin() + { + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsAfSearchEnd +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsAfSearchEnd( TUint32 /*aFrequency*/, TInt /*aError*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsAfSearchStateChange +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsAfSearchStateChange( TBool /*aEnabled*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::RdsAvailable +// --------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::RdsAvailable( TBool /*aAvailable*/ ) + { + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::PrepareToolbar +// Prepare toolbar for displaying basic radio command buttons +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::PrepareToolbar() + { + if ( AknLayoutUtils::PenEnabled() ) + { + iToolbar = Toolbar(); + iToolbar->SetToolbarVisibility( EFalse ); + // Set observer + iToolbar->SetToolbarObserver( this ); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::OfferToolbarEventL +// Handle commands from toolbar. +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::OfferToolbarEventL( TInt aCommandId ) + { + switch ( aCommandId ) + { + case EFMRadioToolbarButtonCmdSaveAll: + { + HandleCommandL( EFMRadioCmdSaveAllChannels ); + break; + } + case EFMRadioToolbarButtonCmdScan: + { + HandleCommandL( EFMRadioCmdScanLocalStationsScan ); + break; + } + case EFMRadioToolbarButtonCmdToggleIhf: + { + if ( iRadioEngine.GetAudioOutput() == CRadioEngine::EFMRadioOutputHeadset ) + { + AppUi()->HandleCommandL( EFMRadioCmdActivateIhf ); + } + else + { + AppUi()->HandleCommandL( EFMRadioCmdDeactivateIhf ); + } + break; + } + default: + { + break; + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetToolbarDimmedState +// set toolbar buttons dimmed state +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetToolbarDimmedState( const TBool aState ) + { + if ( iToolbar && AknLayoutUtils::PenEnabled() ) + { + iToolbar->SetDimmed( aState ); + if ( !aState ) + { + UpdateToolbar(); + } + iToolbar->DrawDeferred(); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::UpdateToolbar +// Set save buttons dimming state +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::UpdateToolbar() + { + if ( iContainer && iToolbar && AknLayoutUtils::PenEnabled() ) + { + if ( iRadioEngine.IsAudioRoutingPossible() ) + { + if ( iRadioEngine.IsHeadsetConnected() ) + { + CAknButton* centerButton = NULL; + centerButton = static_cast( iToolbar->ControlOrNull( EFMRadioToolbarButtonCmdToggleIhf ) ); + + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, EFalse, ETrue ); + + if ( iRadioEngine.GetAudioOutput() == CRadioEngine::EFMRadioOutputIHF ) + { + if ( centerButton ) + { + centerButton->SetCurrentState( 1, ETrue ); + } + } + else + { + if ( centerButton ) + { + centerButton->SetCurrentState( 0, ETrue ); + } + } + } + else + { + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, ETrue, ETrue ); + } + } + else + { + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdToggleIhf, ETrue, ETrue ); + } + + TInt chCount = iScannedChannels.Count(); + if ( chCount == 0 ) + { //dim save buttons + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdSaveAll, ETrue, ETrue ); + } + else if ( chCount == 1 ) + { //dim 'save all' button. + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdSaveAll, ETrue, ETrue ); + } + else + { //undim both + iToolbar->SetItemDimmed( EFMRadioToolbarButtonCmdSaveAll, EFalse, ETrue ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::IsFrequencyScanned +// check if the frequency is already found +// -------------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::FrequencyIndex( TInt aFrequency ) + { + TInt frequencyIndex = KErrNotFound; + TInt chCount = iScannedChannels.Count(); + + for ( TInt i = 0; i < chCount; i++ ) + { + if ( aFrequency == iScannedChannels[ i ]->PresetFrequency() ) + { + frequencyIndex = i; + break; + } + } + return frequencyIndex; + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::HandleOneChannelSaveL +// Handle single channel save +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::HandleOneChannelSaveL() + { + TInt currentPresetCount = iObserver.Channels()->Count(); + TInt chIndex = iContainer->CurrentlySelectedChannel(); + TBool continueWithSave = ETrue; + + if ( !ChannelInUse( chIndex ) ) + { + User::Leave( KErrNotFound ); + } + // check if the channel list is full and show replace query if necessary + if ( currentPresetCount == KMaxNumberOfChannelListItems ) + { + CAknQueryDialog* query = CAknQueryDialog::NewL(); + if ( query->ExecuteLD( R_FMRADIO_REPLACE_EXISTING_CHANNELS_QUERY ) ) + { + iObserver.UpdateChannelsL( ERemoveAllFromRepository, 0, 0 ); + } + else + { + continueWithSave = EFalse; + } + } + if ( continueWithSave ) + { + const TDesC& name = iScannedChannels[ chIndex ]->PresetNameValid() ? + iScannedChannels[ chIndex ]->PresetName() : KNullDesC; + TInt presetFrequency = iScannedChannels[ chIndex ]->PresetFrequency(); + iObserver.AddChannelToListL( name, + presetFrequency ); + iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 ); + + TBool updateNowPlayingIcon = EFalse; + TInt tunedIndex = CurrentlyPlayingChannel(); + // update now playing icon and list index + if ( chIndex == tunedIndex ) + { + // channel is going be deleted so now playing index is not in the list + iNowPlayingIndex = KErrNotFound; + } + else if ( chIndex < tunedIndex ) + { + iNowPlayingIndex = tunedIndex - 1; + iContainer->HideNowPlayingIconL( tunedIndex, ETrue ); + updateNowPlayingIcon = ETrue; + } + else + { + // NOP + } + + // remove also from the UI list + iContainer->RemoveChannelListContentL( chIndex ); + + if ( updateNowPlayingIcon ) + { + iContainer->UpdateNowPlayingIconL( tunedIndex - 1 ); + } + // received PS name is shown + if ( name.Length() > 0 ) + { + HBufC* nameSavedString = StringLoader::LoadLC( R_QTN_FMRADIO_SAVING_DONE_ONE, name, iEikonEnv ); + CAknConfirmationNote* saveInfoNote = new ( ELeave ) CAknConfirmationNote( ETrue ); // waiting + saveInfoNote->ExecuteLD( *nameSavedString ); + CleanupStack::PopAndDestroy( nameSavedString ); + } + else // show frequency + { + TReal frequency = static_cast( presetFrequency / static_cast( KHzConversionFactor ) ); + TRealFormat format( KFrequencyMaxLength, iRadioEngine.DecimalCount() ); + TBuf frequencyString; + frequencyString.Num( frequency, format ); + AknTextUtils::LanguageSpecificNumberConversion( frequencyString ); + + HBufC* freqSavedString = StringLoader::LoadLC( R_QTN_FMRADIO_SAVING_DONE_ONE_NO_NAME, frequencyString, iEikonEnv ); + CAknConfirmationNote* saveInfoNote = new ( ELeave ) CAknConfirmationNote( ETrue ); // waiting + saveInfoNote->ExecuteLD( *freqSavedString ); + CleanupStack::PopAndDestroy( freqSavedString ); + } + // channel info is removed after save + delete iScannedChannels[ chIndex ]; + iScannedChannels.Remove( chIndex ); + iScannedChannels.Compress(); + } + UpdateToolbar(); + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::ActivateMainViewL +// Activates main view +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::ActivateMainViewL() + { + CAknViewAppUi* appUi = AppUi(); + + if ( !appUi->IsForeground() ) + { + // don't bring radio automatically to the foreground + // if the view is about to change + // and we are still in the background + appUi->SetCustomControl( 1 ); + appUi->ActivateLocalViewL( KFMRadioMainViewId ); + appUi->SetCustomControl( 0 ); + } + else + { + appUi->ActivateLocalViewL( KFMRadioMainViewId ); + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SetContextMenu +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::SetContextMenu( TInt aMenuTitleResourceId ) + { + if ( !AknLayoutUtils::PenEnabled() ) + { + CEikMenuBar* menubar = MenuBar(); + if ( menubar ) + { + menubar->SetContextMenuTitleResourceId( aMenuTitleResourceId ); + menubar->SetMenuType( CEikMenuBar::EMenuContext ); + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::HandleScanListRemConEventL +// -------------------------------------------------------------------------------- +// +void CFMRadioScanLocalStationsView::HandleScanListRemConEventL( TAccessoryEvent aEvent ) + { + TInt scannedChannelCount = iScannedChannels.Count(); + + if ( scannedChannelCount >= 1 ) + { + TInt selectedChannelIndex = CurrentlySelectedChannel(); + TInt nextChannellIndex = 0; + + if ( aEvent == EForward ) + { + nextChannellIndex = selectedChannelIndex + 1; + + if ( nextChannellIndex >= scannedChannelCount ) + { + // go around the the list to the first channnel + nextChannellIndex = 0; + } + } + else if ( aEvent == ERewind ) + { + nextChannellIndex = selectedChannelIndex - 1; + + if ( nextChannellIndex < KMinNumberOfChannelListItems ) + { + // jump to the last item + nextChannellIndex = scannedChannelCount - 1; + } + } + // check that index is really a valid one + if ( ChannelInUse( nextChannellIndex ) ) + { + TInt nextChannelFrequency = iScannedChannels[ nextChannellIndex ]->PresetFrequency(); + // tune if necessary + if ( iRadioEngine.GetTunedFrequency() != nextChannelFrequency ) + { + CFMRadioAppUi* appUi = static_cast( iCoeEnv->AppUi() ); + appUi->TuneL( nextChannelFrequency ); + } + } + } + } + +// -------------------------------------------------------------------------------- +// CFMRadioScanLocalStationsView::SortedFrequencyListIndex +// -------------------------------------------------------------------------------- +// +TInt CFMRadioScanLocalStationsView::SortedFrequencyListIndex( TInt aFrequency ) + { + TInt channelCount = iScannedChannels.Count(); + TInt sortedIndex = 0; + + for ( TInt i = 0; i < channelCount; i++ ) + { + TInt presetFreq = iScannedChannels[i]->PresetFrequency(); + + if ( aFrequency > presetFreq ) + { + sortedIndex = i + 1; + } + else if ( aFrequency < presetFreq ) + { + sortedIndex = i; + break; + } + } + return sortedIndex; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradio/src/fmradiosvkevents.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradio/src/fmradiosvkevents.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,384 @@ +/* +* 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: +* Class which implements handling Side Volume Key events (SVK). +* This class implements methods of MRemConCoreApiTargetObserver +* +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include // KAknStandardKeyboardRepeatRate +#include + +#include "fmradiosvkevents.h" + + +// CONSTANTS +const TInt KVolumeControlExpiryPeriod = 2000000; +const TInt KVolumeFirstChangePeriod = KAknStandardKeyboardRepeatRate; +const TInt KVolumeChangePeriod = KAknStandardKeyboardRepeatRate; +const TInt KVolumeChangeUp = 1; +const TInt KVolumeChangeDown = -1; + + +// ============================ MEMBER FUNCTIONS =============================== + +// ---------------------------------------------------------------------------- +// CFMRadioSvkEvents +// ---------------------------------------------------------------------------- +// +CFMRadioSvkEvents* CFMRadioSvkEvents::NewL( MFMRadioSvkEventsObserver& aObserver ) + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::NewL")); +#endif + CFMRadioSvkEvents* self = new ( ELeave ) CFMRadioSvkEvents( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ---------------------------------------------------------------------------- +// CFMRadioSvkEvents +// ---------------------------------------------------------------------------- +// +CFMRadioSvkEvents::CFMRadioSvkEvents( MFMRadioSvkEventsObserver& aObserver ) : + iObserver( aObserver ) + { + } + + +// ---------------------------------------------------------------------------- +// CFMRadioSvkEvents::~CFMRadioSvkEvents +// ---------------------------------------------------------------------------- +// +CFMRadioSvkEvents::~CFMRadioSvkEvents() + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::~CFMRadioSvkEvents")); +#endif + delete iRemoveTimer; + delete iVolumeTimer; + delete iInterfaceSelector; + iCoreTarget = NULL; // For LINT. Owned by iInterfaceSelector + iCallTarget = NULL; // For LINT. Owned by iInterfaceSelector + } + +// ---------------------------------------------------------------------------- +// ConstructL +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::ConstructL( ) + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::ConstructL")); +#endif + + iTargetOpen = EFalse; + iInterfaceSelector = CRemConInterfaceSelector::NewL(); + + // owned by iInterfaceSelector + iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); + iCallTarget = CRemConCallHandlingTarget::NewL(*iInterfaceSelector, *this); + + if (!iTargetOpen) + { + iInterfaceSelector->OpenTargetL(); + iTargetOpen = ETrue ; + } + + // Remote control server command repeat timer. + iVolumeTimer = CPeriodic::NewL( EPriorityNormal ); + iRemoveTimer = CPeriodic::NewL( EPriorityNormal ); + } + +// ---------------------------------------------------------------------------- +// CFMRadioSvkEvents::MrccatoCommand +// Handles side volume key events. +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::MrccatoCommand( TRemConCoreApiOperationId aOperationId, + TRemConCoreApiButtonAction aButtonAct ) + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::MrccatoCommand, Operation ID [%d]"), aOperationId); +#endif + switch ( aOperationId ) + { + case ERemConCoreApiVolumeUp: // Volume Up + { + HandleVolumeButtons( aButtonAct, KVolumeChangeUp ); + break; + } + case ERemConCoreApiVolumeDown: // Volume Down + { + HandleVolumeButtons( aButtonAct, KVolumeChangeDown ); + break; + } + case ERemConCoreApiBackward: // Backward + { + iObserver.FMRadioHeadsetEvent( ERewind ); + break; + } + case ERemConCoreApiForward: // Forward + { + iObserver.FMRadioHeadsetEvent( EForward ); + break; + } + case ERemConCoreApiRewind: // Tune down + { + if ( aButtonAct == ERemConCoreApiButtonPress ) + { + TuneChannel( EFMRadioCmdSeekDown ); + } + break; + } + case ERemConCoreApiFastForward: // Tune up + { + if ( aButtonAct == ERemConCoreApiButtonPress ) + { + TuneChannel( EFMRadioCmdSeekUp ); + } + break; + } + case ERemConCoreApiPausePlayFunction: + { + iObserver.FMRadioHeadsetEvent( EPausePlay ); + break; + } + case ERemConCoreApiStop: + { + iObserver.FMRadioHeadsetEvent( EStop ); + break; + } + default : + { + // Don’t Panic or do anything here. Other events such as Stop, Rewind, Forward will fall here. + break; + } + } + } + + +// ---------------------------------------------------------------------------- +// StartRemoveTimerL +// +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::StartRemoveTimerL( ) + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::StartRemoveTimerL" )); +#endif + iRemoveTimer->Cancel(); + iRemoveTimer->Start( KVolumeControlExpiryPeriod, + KVolumeControlExpiryPeriod, + TCallBack( RemoveControl, this ) ); + } + +// ---------------------------------------------------------------------------- +// CancelRemoveTimer +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::CancelRemoveTimer( ) + { + iRemoveTimer->Cancel(); + } + +// ---------------------------------------------------------------------------- +// DoChangeVolume +// +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::DoChangeVolume( ) + { +#ifdef _DEBUG + RDebug::Print(_L("CFMRadioSvkEvents::DoChangeVolume" )); +#endif + TRAP_IGNORE( iObserver.FMRadioSvkChangeVolumeL( iChange ) ); + iRemoveTimer->Cancel(); + iRemoveTimer->Start( KVolumeControlExpiryPeriod, + KVolumeControlExpiryPeriod, + TCallBack( RemoveControl, this ) ); + } + + +// ---------------------------------------------------------------------------- +// TuneChannel +// +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::TuneChannel( TFMRadioCommandIds aDirection ) + { + CAknViewAppUi* appUi = static_cast( CCoeEnv::Static()->AppUi() ); + TRAP_IGNORE( appUi->HandleCommandL( aDirection ) ); + } + +// ---------------------------------------------------------------------------- +// RemoveControlL +// +// ---------------------------------------------------------------------------- +// +void CFMRadioSvkEvents::RemoveControlL( ) + { + iRemoveTimer->Cancel(); + iObserver.FMRadioSvkRemoveVolumeL( ); + } + + + +// ---------------------------------------------------------------------------- +// ChangeVolume +// +// ---------------------------------------------------------------------------- +// +TInt CFMRadioSvkEvents::ChangeVolume( TAny* aObject ) + { + // cast, and call non-static function + static_cast( aObject )->DoChangeVolume( ); + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// RemoveControl +// +// ---------------------------------------------------------------------------- +// +TInt CFMRadioSvkEvents::RemoveControl( TAny* aObject ) + { + // cast, and call non-static function + TRAP_IGNORE( static_cast( aObject )->RemoveControlL() ); + return KErrNone; + } + + +// --------------------------------------------------------- +// CFMRadioSvkEvents::AnswerCall +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::AnswerCall() + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::AnswerEndCall +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::AnswerEndCall() + { + iObserver.FMRadioHeadsetEvent(EForward); + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::DialCall +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::DialCall( const TDesC8& /*aTelNumber*/ ) + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::EndCall +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::EndCall() + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::GenerateDTMF +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::GenerateDTMF( const TChar /*aChar*/ ) + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::LastNumberRedial +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::LastNumberRedial() + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::MultipartyCalling +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::MultipartyCalling( const TDesC8& /*aData*/ ) + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::SpeedDial +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::SpeedDial( const TInt /*aIndex*/ ) + { + } + +// --------------------------------------------------------- +// CFMRadioSvkEvents::VoiceDial +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::VoiceDial( const TBool /*aActivate*/ ) + { + } +// --------------------------------------------------------- +// CFMRadioSvkEvents::HandleVolumeButtons +// --------------------------------------------------------- +// +void CFMRadioSvkEvents::HandleVolumeButtons( TRemConCoreApiButtonAction aButtonAct, TInt aDirection ) + { + switch( aButtonAct ) + { + case ERemConCoreApiButtonPress: + { + // Volume up hold down for 0,6 seconds + iVolumeTimer->Cancel(); + iVolumeTimer->Start( KVolumeFirstChangePeriod, + KVolumeChangePeriod, + TCallBack( ChangeVolume, this ) ); + iChange = aDirection; + DoChangeVolume( ); + break; + } + case ERemConCoreApiButtonRelease: + { + iVolumeTimer->Cancel(); + break; + } + case ERemConCoreApiButtonClick: + { + iChange = aDirection; + DoChangeVolume( ); + break; + } + default: + { + // Never hits this + break; + } + } + } +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/group/bld.inf Tue Feb 02 00:17:10 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: Component definition for the +* FM Radio Action Handler plugin. +* +*/ + +#include + +// Platforms the component needs to be built on +// + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES +fmradioactionhandler.mmp + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/group/fmradioactionhandler.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/group/fmradioactionhandler.mmp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,58 @@ +/* +* 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: Project definition file for project +* FM Radio Action Handler plugin. +* +*/ + +// To get the APP_LAYER_SYSTEMINCLUDE-definition +#include +#include +#include "../resources/fmradioactionhandler.hrh" + +TARGET fmradioactionhandler.dll +TARGETTYPE PLUGIN +UID 0x10009D8D KFMRadioActionHandlerDllUid + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +PAGED + +SOURCEPATH ../resources +START RESOURCE 2001f498.rss +TARGET fmradioactionhandler.rsc +TARGETPATH ECOM_RESOURCE_DIR +END + + +APP_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../resources +USERINCLUDE ../../fmradio/inc +USERINCLUDE ../../fmradioengine/inc + +SOURCEPATH ../src +SOURCE fmradioactionhandler.cpp + +LIBRARY ecom.lib +LIBRARY euser.lib +LIBRARY liwservicehandler.lib +LIBRARY ws32.lib +LIBRARY apgrfx.lib +LIBRARY apparc.lib + +DEBUGLIBRARY flogger.lib +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/inc/fmradioactionhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/inc/fmradioactionhandler.h Tue Feb 02 00:17:10 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: Declaration for the class CFMRadioActionHandler. +* +*/ + +#ifndef FMRADIOACTIONHANDLER_H +#define FMRADIOACTIONHANDLER_H + +#include + +/** + * Action handler provides LIW -based interface for external use (e.g. Homescreen) + * + * The action handler communicates with FM Radio via FM Radio's Publish & Subscribe API. + * + * @lib fmradioactionhandler.lib + */ +NONSHARABLE_CLASS( CFMRadioActionHandler ) : public CAHPlugin + { +public: + /** + * Two-phased constructor. + */ + static CFMRadioActionHandler* NewL(); + + /** + * Destructor + */ + ~CFMRadioActionHandler(); + + // From base class CAHPlugin + TInt ExecuteActionL( const CLiwMap* aMap ); + +private: + /** + * C++ constructor. + */ + CFMRadioActionHandler(); + + /** + * Second phase constructor. + */ + void ConstructL(); + +private: + /** + * Invokes step to previous preset. + */ + void StepPrevious(); + + /** + * Invokes step to next preset. + */ + void StepNext(); + + /** + * Mutes radio. + */ + void Mute(); + + /** + * Unmutes radio. + */ + void Unmute(); + + /** + * Invokes seek up. + */ + void SeekUp(); + + /** + * Invokes seek down. + */ + void SeekDown(); + + /** + * Invokes to go to now playing view. + */ + void StartToNowPlayingL(); + + /** + * Generates start now playing command tail. + * + * @return start now playing command tail. + */ + const TPtrC8 GenerateStartNowPlayingCommandTail(); + + /** + * Extracts the value of the given mapname to given string. + * Reserves memory to argument aString. + * + * @param aMap The map containing the mapname-string pairs. + * @param aString Descriptor where the value is extracted. + * @param aMapName The searched map name. + */ + TInt ExtractStringL( const CLiwMap* aMap, RBuf& aString, const TDesC8& aMapName ); + }; + +#endif /* FMRADIOACTIONHANDLER_H*/ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/inc/fmradioactionhandlerdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/inc/fmradioactionhandlerdefs.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,32 @@ +/* +* 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: Definitions for the FM Radio Action Handler. +* +*/ + +#ifndef FMRADIOACTIONHANDLERDEFS_H +#define FMRADIOACTIONHANDLERDEFS_H + +#include + +_LIT8( KFMRadioCommand, "command" ); +_LIT( KFMRadioCommandValueStepPrevious, "stepprevious" ); +_LIT( KFMRadioCommandValueStepNext, "stepnext" ); +_LIT( KFMRadioCommandValueMute, "mute" ); +_LIT( KFMRadioCommandValueUnmute, "unmute" ); +_LIT( KFMRadioCommandValueSeekUp, "seekup" ); +_LIT( KFMRadioCommandValueSeekDown, "seekdown" ); +_LIT( KFMRadioCommandValueStartNowPlaying, "startnowplaying" ); + +#endif /* FMRADIOACTIONHANDLERDEFS_H */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/resources/2001f498.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/resources/2001f498.rss Tue Feb 02 00:17:10 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: ECom plugin registration resource for FM Radio Action Handler Plugin. +* +*/ + +#include +#include + +#include "fmradioactionhandler.hrh" + +// --------------------------------------------------------------------------- +// Resource information for the ECOM DLL. +// --------------------------------------------------------------------------- +// +RESOURCE REGISTRY_INFO theInfo + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + + dll_uid = KFMRadioActionHandlerDllUid; + + interfaces = + { + INTERFACE_INFO + { + // AH plugin interface + interface_uid = KAHPluginInterfaceUid; + + implementations = + { + // FM Radio Action handler AH plugin implementation + IMPLEMENTATION_INFO + { + implementation_uid = KFMRadioActionHandlerImplementationUid; + version_no = 1; + display_name = ""; + default_data = ""; + opaque_data = ""; + rom_only = 0; + } + }; + } + }; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/resources/fmradioactionhandler.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/resources/fmradioactionhandler.hrh Tue Feb 02 00:17:10 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: Definitions for the FM Radio Action Handler plugin. +* +*/ + +#ifndef FMRADIOACTIONHANDLER_HRH +#define FMRADIOACTIONHANDLER_HRH + +// Ecom DLL UID for FM Radio Action Handler plugin. +#define KFMRadioActionHandlerDllUid 0x2001F498 + +// Ecom implementation UID for FM Radio Action Handler plugin. +#define KFMRadioActionHandlerImplementationUid 0x2001FCB8 + +#endif /* FMRADIOACTIONHANDLER_HRH */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioactionhandler/src/fmradioactionhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioactionhandler/src/fmradioactionhandler.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,263 @@ +/* +* 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: Implementation for the FM Radio Action Handler Plugin. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioactionhandler.h" +#include "fmradioactionhandler.hrh" +#include "fmradioactionhandlerdefs.h" + +// --------------------------------------------------------- +// CFMRadioActionHandler::NewL +// --------------------------------------------------------- +// +CFMRadioActionHandler* CFMRadioActionHandler::NewL() + { + CFMRadioActionHandler* self = new ( ELeave ) CFMRadioActionHandler(); + CleanupStack::PushL( self ); + + self->ConstructL(); + + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::~CFMRadioActionHandler +// --------------------------------------------------------- +// +CFMRadioActionHandler::~CFMRadioActionHandler() + { + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::CFMRadioActionHandler +// --------------------------------------------------------- +// +CFMRadioActionHandler::CFMRadioActionHandler() + { + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::ConstructL +// --------------------------------------------------------- +// +void CFMRadioActionHandler::ConstructL() + { + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::ExecuteActionL +// --------------------------------------------------------- +// +TInt CFMRadioActionHandler::ExecuteActionL( const CLiwMap* aMap ) + { + TInt retValue( KErrNone ); + RBuf command; + CleanupClosePushL( command ); + + retValue = ExtractStringL( aMap, command, KFMRadioCommand); + if ( retValue == KErrNone ) + { + if ( !command.CompareF( KFMRadioCommandValueStepPrevious ) ) + { + StepPrevious(); + } + else if ( !command.CompareF( KFMRadioCommandValueStepNext ) ) + { + StepNext(); + } + else if ( !command.CompareF( KFMRadioCommandValueMute) ) + { + Mute(); + } + else if ( !command.CompareF( KFMRadioCommandValueUnmute ) ) + { + Unmute(); + } + else if ( !command.CompareF( KFMRadioCommandValueSeekUp ) ) + { + SeekUp(); + } + else if ( !command.CompareF( KFMRadioCommandValueSeekDown ) ) + { + SeekDown(); + } + else if ( !command.CompareF( KFMRadioCommandValueStartNowPlaying ) ) + { + StartToNowPlayingL(); + } + else + { + retValue = KErrNotSupported; + } + } + CleanupStack::PopAndDestroy( &command ); + return retValue; + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::StepPrevious +// --------------------------------------------------------- +// +void CFMRadioActionHandler::StepPrevious() + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlStepToChannel, EFMRadioPSStepToChannelDown ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::StepNext +// --------------------------------------------------------- +// +void CFMRadioActionHandler::StepNext() + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlStepToChannel, EFMRadioPSStepToChannelUp ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::Mute +// --------------------------------------------------------- +// +void CFMRadioActionHandler::Mute() + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlSetRadioMuteState, EFMRadioPSMuteStateOn ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::Unmute +// --------------------------------------------------------- +// +void CFMRadioActionHandler::Unmute() + { + RProperty::Set( KFMRadioPSUid, KFMRadioPSControlSetRadioMuteState, EFMRadioPSMuteStateOff ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::SeekUp +// --------------------------------------------------------- +// +void CFMRadioActionHandler::SeekUp() + { + //RProperty::Set( KFMRadioPSUid, KFMRadioPSControlSeek, EFMRadioPSSeekUp ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::SeekDown +// --------------------------------------------------------- +// +void CFMRadioActionHandler::SeekDown() + { + //RProperty::Set( KFMRadioPSUid, KFMRadioPSControlSeek, EFMRadioPSSeekDown ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::StartToNowPlayingL +// --------------------------------------------------------- +// +void CFMRadioActionHandler::StartToNowPlayingL() + { + RWsSession wsSession; + + User::LeaveIfError(wsSession.Connect() ); + CleanupClosePushL( wsSession ); + + TApaTaskList taskList( wsSession ); + TUid appUid = TUid::Uid( KUidFMRadioApplication ); + TApaTask fmRadioTask = taskList.FindApp( appUid ); + + const TInt KFMRadioViewIdLength = 3; + RBuf8 params; + params.CreateL( KFMRadioCommandActivateView().Length() + KFMRadioViewIdLength ); + params.Copy( KFMRadioCommandActivateView ); + params.Append( _L(" ") ); + params.AppendNum( KFMRadioMainViewId.iUid ); + params.CleanupClosePushL(); + + if ( !fmRadioTask.Exists() ) + { + RApaLsSession apaSession; + CleanupClosePushL( apaSession ); + + User::LeaveIfError( apaSession.Connect() ); + User::LeaveIfError( apaSession.GetAllApps() ); + + TApaAppInfo appInfo; + User::LeaveIfError( apaSession.GetAppInfo( appInfo, appUid ) ); + + CApaCommandLine* startParams = CApaCommandLine::NewLC(); + startParams->SetExecutableNameL( appInfo.iFullName ); + startParams->SetCommandL( EApaCommandRun ); + startParams->SetTailEndL( params ); + User::LeaveIfError( apaSession.StartApp( *startParams ) ); + CleanupStack::PopAndDestroy( 2, &apaSession ); + } + else + { + User::LeaveIfError( fmRadioTask.SendMessage( appUid, params ) ); + } + CleanupStack::PopAndDestroy( 2 ); + } + +// --------------------------------------------------------- +// CFMRadioActionHandler::ExtractStringLC +// --------------------------------------------------------- +// +TInt CFMRadioActionHandler::ExtractStringL( const CLiwMap* aMap, RBuf& aString, const TDesC8& aMapName ) + { + TInt err( KErrNotFound ); + TLiwVariant variant; + variant.PushL(); + TPtrC tempString( KNullDesC ); + if ( aMap->FindL( aMapName, variant ) ) + { + variant.Get( tempString ); + aString.Close(); + aString.CreateL( tempString ); + err = KErrNone; + } + CleanupStack::PopAndDestroy( &variant ); + return err; + } + +/** Provides a key-value pair table, that is used to identify the correct construction function for the requested interface. */ +const TImplementationProxy KFMRadioActionHandlerImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( KFMRadioActionHandlerImplementationUid, CFMRadioActionHandler::NewL ) + }; + +const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ); + +// --------------------------------------------------------------------------- +// Returns the implementations provided by this ECOM plugin DLL. +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) + { + aTableCount = sizeof( KFMRadioActionHandlerImplementationTable ) / sizeof( TImplementationProxy ); + return KFMRadioActionHandlerImplementationTable; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/bwins/fmradioengineacu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/bwins/fmradioengineacu.def Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,74 @@ +EXPORTS + ?SetCurrentPresetIndex@CRadioEngine@@QAEXH@Z @ 1 NONAME ; void CRadioEngine::SetCurrentPresetIndex(int) + ?PublishRDSProgramServiceL@CFMRadioPubSub@@QBEXABVTDesC16@@@Z @ 2 NONAME ; void CFMRadioPubSub::PublishRDSProgramServiceL(class TDesC16 const &) const + ?SetVolume@CRadioEngine@@QAEXH@Z @ 3 NONAME ; void CRadioEngine::SetVolume(int) + ?RdsReceiver@CRadioEngine@@QAEAAVCFMRadioRdsReceiverBase@@XZ @ 4 NONAME ; class CFMRadioRdsReceiverBase & CRadioEngine::RdsReceiver(void) + ?SetRegionIdL@CRadioEngine@@QBEXH@Z @ 5 NONAME ; void CRadioEngine::SetRegionIdL(int) const + ?SetMuteOn@CRadioEngine@@QAEXH@Z @ 6 NONAME ; void CRadioEngine::SetMuteOn(int) + ?GetAudioOutput@CRadioEngine@@QBE?AW4TFMRadioAudioOutput@1@XZ @ 7 NONAME ; enum CRadioEngine::TFMRadioAudioOutput CRadioEngine::GetAudioOutput(void) const + ?PublishPresetCountL@CFMRadioPubSub@@QBEXH@Z @ 8 NONAME ; void CFMRadioPubSub::PublishPresetCountL(int) const + ?RegionId@CRadioEngine@@QBEHXZ @ 9 NONAME ; int CRadioEngine::RegionId(void) const + ?GetVolume@CRadioEngine@@QBEHXZ @ 10 NONAME ; int CRadioEngine::GetVolume(void) const + ?PublishApplicationRunningStateL@CFMRadioPubSub@@QBEXW4TFMRadioPSApplicationRunningState@@@Z @ 11 NONAME ; void CFMRadioPubSub::PublishApplicationRunningStateL(enum TFMRadioPSApplicationRunningState) const + ?GetRTPlusSupportLevel@CRadioEngine@@QAE?AW4TFMRadioRTPlusLevel@@XZ @ 12 NONAME ; enum TFMRadioRTPlusLevel CRadioEngine::GetRTPlusSupportLevel(void) + ?GetPresetNameL@CRadioEngine@@QAEAAV?$TBuf@$0CA@@@H@Z @ 13 NONAME ; class TBuf<32> & CRadioEngine::GetPresetNameL(int) + ?IsMuteOn@CRadioEngine@@QBEHXZ @ 14 NONAME ; int CRadioEngine::IsMuteOn(void) const + ?GetMaxVolume@CRadioEngine@@QBEHXZ @ 15 NONAME ; int CRadioEngine::GetMaxVolume(void) const + ?SignalAvailable@CFMRadioRdsReceiverBase@@QBEHXZ @ 16 NONAME ; int CFMRadioRdsReceiverBase::SignalAvailable(void) const + ?SetRdsAfSearchEnable@CRadioEngine@@QAEXH@Z @ 17 NONAME ; void CRadioEngine::SetRdsAfSearchEnable(int) + ?RadioOn@CRadioEngine@@QAEXXZ @ 18 NONAME ; void CRadioEngine::RadioOn(void) + ?SetMusicStoreNoteDisplayed@CRadioEngine@@QAEXXZ @ 19 NONAME ; void CRadioEngine::SetMusicStoreNoteDisplayed(void) + ?RequestTunerControl@CRadioEngine@@QBEXXZ @ 20 NONAME ; void CRadioEngine::RequestTunerControl(void) const + ?CancelScanLocalStationsScan@CRadioEngine@@QAEXXZ @ 21 NONAME ; void CRadioEngine::CancelScanLocalStationsScan(void) + ?GetPresetNameAndFrequencyL@CRadioEngine@@QAEXHAAVTDes16@@AAH@Z @ 22 NONAME ; void CRadioEngine::GetPresetNameAndFrequencyL(int, class TDes16 &, int &) + ?GetRegionL@CRadioEngine@@QBE?AW4TFMRadioRegionSetting@@XZ @ 23 NONAME ; enum TFMRadioRegionSetting CRadioEngine::GetRegionL(void) const + ?GetPresetFrequencyL@CRadioEngine@@QBEHH@Z @ 24 NONAME ; int CRadioEngine::GetPresetFrequencyL(int) const + ?ProgrammeServiceNameType@CFMRadioRdsReceiverBase@@QBE?AW4TFMRadioProgrammeSeviceType@1@XZ @ 25 NONAME ; enum CFMRadioRdsReceiverBase::TFMRadioProgrammeSeviceType CFMRadioRdsReceiverBase::ProgrammeServiceNameType(void) const + ?GetFrequencyBandRange@CRadioEngine@@QAEHAAH0@Z @ 26 NONAME ; int CRadioEngine::GetFrequencyBandRange(int &, int &) + ?RegionIdAtIndex@CRadioEngine@@QBE?AW4TFMRadioRegionSetting@@H@Z @ 27 NONAME ; enum TFMRadioRegionSetting CRadioEngine::RegionIdAtIndex(int) const + ?SetPresetNameFrequencyL@CRadioEngine@@QAEXHABV?$TBuf@$0CA@@@H@Z @ 28 NONAME ; void CRadioEngine::SetPresetNameFrequencyL(int, class TBuf<32> const &, int) + ?FrequencyStepSize@CRadioEngine@@QBEKXZ @ 29 NONAME ; unsigned long CRadioEngine::FrequencyStepSize(void) const + ?PubSubL@CRadioEngine@@QBEAAVCFMRadioPubSub@@XZ @ 30 NONAME ; class CFMRadioPubSub & CRadioEngine::PubSubL(void) const + ?IsInCall@CRadioEngine@@QBEHXZ @ 31 NONAME ; int CRadioEngine::IsInCall(void) const + ?Tune@CRadioEngine@@QAEXHW4TRadioMode@1@@Z @ 32 NONAME ; void CRadioEngine::Tune(int, enum CRadioEngine::TRadioMode) + ?ScanDown@CRadioEngine@@QAEXXZ @ 33 NONAME ; void CRadioEngine::ScanDown(void) + ?CancelScan@CRadioEngine@@QAEXXZ @ 34 NONAME ; void CRadioEngine::CancelScan(void) + ?InitializeRadio@CRadioEngine@@QAEXXZ @ 35 NONAME ; void CRadioEngine::InitializeRadio(void) + ?ScanUp@CRadioEngine@@QAEXXZ @ 36 NONAME ; void CRadioEngine::ScanUp(void) + ?AddObserver@CFMRadioRdsReceiverBase@@QAEXPAVMFMRadioRdsObserver@@@Z @ 37 NONAME ; void CFMRadioRdsReceiverBase::AddObserver(class MFMRadioRdsObserver *) + ?IsRadioOn@CRadioEngine@@QAEHXZ @ 38 NONAME ; int CRadioEngine::IsRadioOn(void) + ?GetRadioMode@CRadioEngine@@QBE?AW4TRadioMode@1@XZ @ 39 NONAME ; enum CRadioEngine::TRadioMode CRadioEngine::GetRadioMode(void) const + ?NewL@CRadioEngine@@SAPAV1@AAVMRadioEngineStateChangeCallback@@@Z @ 40 NONAME ; class CRadioEngine * CRadioEngine::NewL(class MRadioEngineStateChangeCallback &) + ?SetControlEventObserver@CFMRadioPubSub@@QAEXPAVMFMRadioControlEventObserver@@@Z @ 41 NONAME ; void CFMRadioPubSub::SetControlEventObserver(class MFMRadioControlEventObserver *) + ?ProgrammeService@CFMRadioRdsReceiverBase@@QBEABVTDesC16@@XZ @ 42 NONAME ; class TDesC16 const & CFMRadioRdsReceiverBase::ProgrammeService(void) const + ?PublishStateL@CFMRadioPubSub@@QBEXH@Z @ 43 NONAME ; void CFMRadioPubSub::PublishStateL(int) const + ?IsHeadsetConnected@CRadioEngine@@QBEHXZ @ 44 NONAME ; int CRadioEngine::IsHeadsetConnected(void) const + ?RadioOff@CRadioEngine@@QAEXXZ @ 45 NONAME ; void CRadioEngine::RadioOff(void) + ?FrequencySetByRdsAf@CRadioEngine@@QBEHXZ @ 46 NONAME ; int CRadioEngine::FrequencySetByRdsAf(void) const + ?GetAudioMode@CRadioEngine@@QBEHXZ @ 47 NONAME ; int CRadioEngine::GetAudioMode(void) const + ?IsRdsAfSearchEnabled@TRadioSettings@@QAEHXZ @ 48 NONAME ; int TRadioSettings::IsRdsAfSearchEnabled(void) + ?PublishFrequencyL@CFMRadioPubSub@@QBEXK@Z @ 49 NONAME ; void CFMRadioPubSub::PublishFrequencyL(unsigned long) const + ?IsAudioRoutingPossible@CRadioEngine@@QBEHXZ @ 50 NONAME ; int CRadioEngine::IsAudioRoutingPossible(void) const + ?RtPlusAlbum@CFMRadioRdsReceiverBase@@QBEABVTDesC16@@XZ @ 51 NONAME ; class TDesC16 const & CFMRadioRdsReceiverBase::RtPlusAlbum(void) const + ?RtPlusSong@CFMRadioRdsReceiverBase@@QBEABVTDesC16@@XZ @ 52 NONAME ; class TDesC16 const & CFMRadioRdsReceiverBase::RtPlusSong(void) const + ?RtPlusArtist@CFMRadioRdsReceiverBase@@QBEABVTDesC16@@XZ @ 53 NONAME ; class TDesC16 const & CFMRadioRdsReceiverBase::RtPlusArtist(void) const + ?MusicStoreNoteDisplayed@CRadioEngine@@QAEHXZ @ 54 NONAME ; int CRadioEngine::MusicStoreNoteDisplayed(void) + ?SetAudioMode@CRadioEngine@@QAEXW4TFMRadioAudioMode@1@@Z @ 55 NONAME ; void CRadioEngine::SetAudioMode(enum CRadioEngine::TFMRadioAudioMode) + ?SetAudioOutput@CRadioEngine@@QAEXW4TFMRadioAudioOutput@1@@Z @ 56 NONAME ; void CRadioEngine::SetAudioOutput(enum CRadioEngine::TFMRadioAudioOutput) + ?RadioSettings@CRadioEngine@@QAEAAVTRadioSettings@@XZ @ 57 NONAME ; class TRadioSettings & CRadioEngine::RadioSettings(void) + ?IsOfflineProfileL@CRadioEngine@@QAEHXZ @ 58 NONAME ; int CRadioEngine::IsOfflineProfileL(void) + ?GetTunedFrequency@CRadioEngine@@QBEHXZ @ 59 NONAME ; int CRadioEngine::GetTunedFrequency(void) const + ?DecimalCount@CRadioEngine@@QBEHXZ @ 60 NONAME ; int CRadioEngine::DecimalCount(void) const + ?PublishChannelNameL@CFMRadioPubSub@@QBEXABVTDesC16@@@Z @ 61 NONAME ; void CFMRadioPubSub::PublishChannelNameL(class TDesC16 const &) const + ?RemoveObserver@CFMRadioRdsReceiverBase@@QAEXPAVMFMRadioRdsObserver@@@Z @ 62 NONAME ; void CFMRadioRdsReceiverBase::RemoveObserver(class MFMRadioRdsObserver *) + ?IsFlightModeEnabled@CRadioEngine@@QBEHXZ @ 63 NONAME ; int CRadioEngine::IsFlightModeEnabled(void) const + ??1CRadioEngine@@UAE@XZ @ 64 NONAME ; CRadioEngine::~CRadioEngine(void) + ?UpdatedStartupCount@CRadioEngine@@QBEHXZ @ 65 NONAME ; int CRadioEngine::UpdatedStartupCount(void) const + ?TunePresetL@CRadioEngine@@QAEXH@Z @ 66 NONAME ; void CRadioEngine::TunePresetL(int) + ?FillListWithRegionDataL@CRadioEngine@@QBEXAAVCDesC16Array@@@Z @ 67 NONAME ; void CRadioEngine::FillListWithRegionDataL(class CDesC16Array &) const + ?AutomaticSwitchingEnabled@CFMRadioRdsReceiverBase@@QBEHXZ @ 68 NONAME ; int CFMRadioRdsReceiverBase::AutomaticSwitchingEnabled(void) const + ?GetPresetIndex@CRadioEngine@@QBEHXZ @ 69 NONAME ; int CRadioEngine::GetPresetIndex(void) const + ?PublishRDSRadioTextL@CFMRadioPubSub@@QBEXABVTDesC16@@@Z @ 70 NONAME ; void CFMRadioPubSub::PublishRDSRadioTextL(class TDesC16 const &) const + ?RtPlusProgramUrl@CFMRadioRdsReceiverBase@@QBEABVTDesC16@@XZ @ 71 NONAME ; class TDesC16 const & CFMRadioRdsReceiverBase::RtPlusProgramUrl(void) const + ?SetTunerModeOn@CRadioEngine@@QAEXXZ @ 72 NONAME ; void CRadioEngine::SetTunerModeOn(void) + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/cenrep/2001b25e.cre Binary file fmradio/fmradioengine/cenrep/2001b25e.cre has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/cenrep/2001b25e.txt Binary file fmradio/fmradioengine/cenrep/2001b25e.txt has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/data/fmradioengine.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/data/fmradioengine.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,189 @@ +/* +* 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: Resource file for fmradioengine +* +*/ +// RESOURCE IDENTIFIER +NAME FMEN + +// INCLUDES +#include + +#include +#include "fmradioengine.hrh" + +// RESOURCE DEFINITIONS + +// --------------------------------------------------------- +// +// +// Resource signature +// +// --------------------------------------------------------- +// + +RESOURCE RSS_SIGNATURE { } + +// Non-operator customisable settings + + +STRUCT RADIO_REGION + { + WORD id; + WORD stepsize; + LONG minfrequency; + LONG maxfrequency; + WORD decimalcount; + LTEXT countrycodes[] = {""}; + LTEXT regionname; + LTEXT regionsettingname; + } + +STRUCT RADIO_REGION_ARRAY + { + LLINK regions[]; + } + +// --------------------------------------------------------- +// +// r_radio_regions_all +// Array of all the supported regions +// +// --------------------------------------------------------- +// +RESOURCE RADIO_REGION_ARRAY r_radio_regions_all + { + regions = + { + r_radio_region_japan, + r_radio_region_america, + r_radio_region_default + }; + } + +// --------------------------------------------------------- +// +// r_radio_regions_without_japan +// Array of supported regions without Japan +// +// --------------------------------------------------------- +// +RESOURCE RADIO_REGION_ARRAY r_radio_regions_without_japan + { + regions = + { + r_radio_region_america, + r_radio_region_default + }; + } + +// --------------------------------------------------------- +// +// r_radio_region_japan +// Region settings for Japan +// Check country codes from: +// "COMPLEMENT TO ITU-T RECOMMENDATION E.212, LIST OF MOBILE COUNTRY OR GEOGRAPHICAL AREA CODES" +// --------------------------------------------------------- +// +RESOURCE RADIO_REGION r_radio_region_japan + { + id = EFMRadioRegionJapan; + stepsize = 100; + minfrequency = 76000; + maxfrequency = 90000; + decimalcount = 1; + countrycodes = + { + "440", + "441" + }; + regionname = qtn_fmradio_reg_japan; + } + +// --------------------------------------------------------- +// +// r_radio_region_america +// Region settings for America +// "COMPLEMENT TO ITU-T RECOMMENDATION E.212, LIST OF MOBILE COUNTRY OR GEOGRAPHICAL AREA CODES" +// +// --------------------------------------------------------- +// +RESOURCE RADIO_REGION r_radio_region_america + { + id = EFMRadioRegionAmerica; + stepsize = 200; + minfrequency = 88100; + maxfrequency = 107900; + decimalcount = 1; + countrycodes = + { + "302", // Canada + "310", // USA + "311", // USA + "312", // USA + "313", // USA + "314", // USA + "315", // USA + "316", // USA + "332", // USA + "334", // Mexico + "338", // Jamaica + "342", // Barbados + "344", // Antigua and Barbuda + "352", // Grenada + "360", // Saint Vincent and the Grenadines + "364", // Bahamas + "366", // Common Wealth of Dominica + "370", // Dominican Republic + "372", // Haiti + "374", // Trinidad and Tobago + "368", // Cuba + "702", // Belize + "704", // Guatemala + "706", // El Salvador + "708", // Honduras + "710", // Nicaragua + "712", // Costa Rica + "714", // Panama + "716", // Peru + "724", // Brazil + "730", // Chile + "732", // Colombia + "734", // Venezuela + "736", // Bolivia + "738", // Guyana + "740", // Ecuador + "744", // Paraguay + "746", // Suriname + "748" // Uruguay + }; + regionname = qtn_fmradio_reg_america; + } + +// --------------------------------------------------------- +// +// r_radio_region_default +// Region settings for default region +// +// --------------------------------------------------------- +// +RESOURCE RADIO_REGION r_radio_region_default + { + id = EFMRadioRegionDefault; + stepsize = 50; + minfrequency = 87500; + maxfrequency = 108000; + decimalcount = 2; + regionname = qtn_fmradio_reg_other; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/eabi/fmradioengineacu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/eabi/fmradioengineacu.def Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,90 @@ +EXPORTS + _ZN12CRadioEngine10CancelScanEv @ 1 NONAME + _ZN12CRadioEngine11RdsReceiverEv @ 2 NONAME + _ZN12CRadioEngine11TunePresetLEi @ 3 NONAME + _ZN12CRadioEngine12SetAudioModeENS_17TFMRadioAudioModeE @ 4 NONAME + _ZN12CRadioEngine13RadioSettingsEv @ 5 NONAME + _ZN12CRadioEngine14GetPresetNameLEi @ 6 NONAME + _ZN12CRadioEngine14SetAudioOutputENS_19TFMRadioAudioOutputE @ 7 NONAME + _ZN12CRadioEngine14SetTunerModeOnEv @ 8 NONAME + _ZN12CRadioEngine15InitializeRadioEv @ 9 NONAME + _ZN12CRadioEngine17IsOfflineProfileLEv @ 10 NONAME + _ZN12CRadioEngine20SetRdsAfSearchEnableEi @ 11 NONAME + _ZN12CRadioEngine21GetFrequencyBandRangeERiS0_ @ 12 NONAME + _ZN12CRadioEngine21GetRTPlusSupportLevelEv @ 13 NONAME + _ZN12CRadioEngine21SetCurrentPresetIndexEi @ 14 NONAME + _ZN12CRadioEngine23MusicStoreNoteDisplayedEv @ 15 NONAME + _ZN12CRadioEngine23SetPresetNameFrequencyLEiRK4TBufILi32EEi @ 16 NONAME + _ZN12CRadioEngine26GetPresetNameAndFrequencyLEiR6TDes16Ri @ 17 NONAME + _ZN12CRadioEngine26SetMusicStoreNoteDisplayedEv @ 18 NONAME + _ZN12CRadioEngine27CancelScanLocalStationsScanEv @ 19 NONAME + _ZN12CRadioEngine4NewLER31MRadioEngineStateChangeCallback @ 20 NONAME + _ZN12CRadioEngine4TuneEiNS_10TRadioModeE @ 21 NONAME + _ZN12CRadioEngine6ScanUpEv @ 22 NONAME + _ZN12CRadioEngine7RadioOnEv @ 23 NONAME + _ZN12CRadioEngine8RadioOffEv @ 24 NONAME + _ZN12CRadioEngine8ScanDownEv @ 25 NONAME + _ZN12CRadioEngine9IsRadioOnEv @ 26 NONAME + _ZN12CRadioEngine9SetMuteOnEi @ 27 NONAME + _ZN12CRadioEngine9SetVolumeEi @ 28 NONAME + _ZN12CRadioEngineD0Ev @ 29 NONAME + _ZN12CRadioEngineD1Ev @ 30 NONAME + _ZN12CRadioEngineD2Ev @ 31 NONAME + _ZN14CFMRadioPubSub23SetControlEventObserverEP28MFMRadioControlEventObserver @ 32 NONAME + _ZN14TRadioSettings20IsRdsAfSearchEnabledEv @ 33 NONAME + _ZN23CFMRadioRdsReceiverBase11AddObserverEP19MFMRadioRdsObserver @ 34 NONAME + _ZN23CFMRadioRdsReceiverBase14RemoveObserverEP19MFMRadioRdsObserver @ 35 NONAME + _ZNK12CRadioEngine10GetRegionLEv @ 36 NONAME + _ZNK12CRadioEngine12DecimalCountEv @ 37 NONAME + _ZNK12CRadioEngine12GetAudioModeEv @ 38 NONAME + _ZNK12CRadioEngine12GetMaxVolumeEv @ 39 NONAME + _ZNK12CRadioEngine12GetRadioModeEv @ 40 NONAME + _ZNK12CRadioEngine12SetRegionIdLEi @ 41 NONAME + _ZNK12CRadioEngine14GetAudioOutputEv @ 42 NONAME + _ZNK12CRadioEngine14GetPresetIndexEv @ 43 NONAME + _ZNK12CRadioEngine15RegionIdAtIndexEi @ 44 NONAME + _ZNK12CRadioEngine17FrequencyStepSizeEv @ 45 NONAME + _ZNK12CRadioEngine17GetTunedFrequencyEv @ 46 NONAME + _ZNK12CRadioEngine18IsHeadsetConnectedEv @ 47 NONAME + _ZNK12CRadioEngine19FrequencySetByRdsAfEv @ 48 NONAME + _ZNK12CRadioEngine19GetPresetFrequencyLEi @ 49 NONAME + _ZNK12CRadioEngine19IsFlightModeEnabledEv @ 50 NONAME + _ZNK12CRadioEngine19RequestTunerControlEv @ 51 NONAME + _ZNK12CRadioEngine19UpdatedStartupCountEv @ 52 NONAME + _ZNK12CRadioEngine22IsAudioRoutingPossibleEv @ 53 NONAME + _ZNK12CRadioEngine23FillListWithRegionDataLER12CDesC16Array @ 54 NONAME + _ZNK12CRadioEngine7PubSubLEv @ 55 NONAME + _ZNK12CRadioEngine8IsInCallEv @ 56 NONAME + _ZNK12CRadioEngine8IsMuteOnEv @ 57 NONAME + _ZNK12CRadioEngine8RegionIdEv @ 58 NONAME + _ZNK12CRadioEngine9GetVolumeEv @ 59 NONAME + _ZNK14CFMRadioPubSub13PublishStateLEi @ 60 NONAME + _ZNK14CFMRadioPubSub17PublishFrequencyLEm @ 61 NONAME + _ZNK14CFMRadioPubSub19PublishChannelNameLERK7TDesC16 @ 62 NONAME + _ZNK14CFMRadioPubSub19PublishPresetCountLEi @ 63 NONAME + _ZNK14CFMRadioPubSub20PublishRDSRadioTextLERK7TDesC16 @ 64 NONAME + _ZNK14CFMRadioPubSub25PublishRDSProgramServiceLERK7TDesC16 @ 65 NONAME + _ZNK14CFMRadioPubSub31PublishApplicationRunningStateLE33TFMRadioPSApplicationRunningState @ 66 NONAME + _ZNK23CFMRadioRdsReceiverBase10RtPlusSongEv @ 67 NONAME + _ZNK23CFMRadioRdsReceiverBase11RtPlusAlbumEv @ 68 NONAME + _ZNK23CFMRadioRdsReceiverBase12RtPlusArtistEv @ 69 NONAME + _ZNK23CFMRadioRdsReceiverBase15SignalAvailableEv @ 70 NONAME + _ZNK23CFMRadioRdsReceiverBase16ProgrammeServiceEv @ 71 NONAME + _ZNK23CFMRadioRdsReceiverBase16RtPlusProgramUrlEv @ 72 NONAME + _ZNK23CFMRadioRdsReceiverBase24ProgrammeServiceNameTypeEv @ 73 NONAME + _ZNK23CFMRadioRdsReceiverBase25AutomaticSwitchingEnabledEv @ 74 NONAME + _ZTI12CRadioEngine @ 75 NONAME + _ZTI14CFMRadioPubSub @ 76 NONAME + _ZTI18CRadioStateHandler @ 77 NONAME + _ZTI24CFMRadioPropertyObserver @ 78 NONAME + _ZTI25CCentralRepositoryHandler @ 79 NONAME + _ZTI25CFMRadioAccessoryObserver @ 80 NONAME + _ZTI27CFMRadioSystemEventDetector @ 81 NONAME + _ZTV12CRadioEngine @ 82 NONAME + _ZTV14CFMRadioPubSub @ 83 NONAME + _ZTV18CRadioStateHandler @ 84 NONAME + _ZTV24CFMRadioPropertyObserver @ 85 NONAME + _ZTV25CCentralRepositoryHandler @ 86 NONAME + _ZTV25CFMRadioAccessoryObserver @ 87 NONAME + _ZTV27CFMRadioSystemEventDetector @ 88 NONAME + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/group/backup_registration.xml Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,6 @@ + + + + + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/group/bld.inf Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,53 @@ +/* +* 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: Project build file for FMRadioEngine +* +*/ + + +#include + +// Platforms the component needs to be built on +// + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +// Source files which are copied to their following destinations +../inc/fmradiointernalpskeys.h APP_LAYER_PLATFORM_EXPORT_PATH(fmradiointernalpskeys.h) + +//Backup registartion file +backup_registration.xml z:/private/2001b25e/backup_registration.xml + +// iby file +../rom/fmradioengine.iby CORE_APP_LAYER_IBY_EXPORT_PATH(fmradioengine.iby) + +../cenrep/2001b25e.txt z:/private/10202be9/2001b25e.txt + + +// *.mmp files required for building the needed component +// +PRJ_MMPFILES +fmradioengine.mmp + + +// *.mmp files required for building any test programs +// +//PRJ_TESTMMPFILES +//../internal/fmradioenginetest/tfmradioengine.mmp + + + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/group/fmradioengine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/group/fmradioengine.mmp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,91 @@ +/* +* 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: Project file for FMRadioEngine +* +*/ + + +#include +#include +#include "../../inc/fmradiovariant.hrh" + +TARGET fmradioengine.dll +TARGETTYPE DLL +CAPABILITY CAP_GENERAL_DLL ReadUserData +VENDORID VID_DEFAULT +UID 0x1000008D 0x2001B25E + +VERSION 10.0 + +PAGED + +SOURCEPATH ../data +START RESOURCE fmradioengine.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +LANGUAGE_IDS +END // RESOURCE + + +SOURCEPATH ../src +SOURCE fmradioaccessoryobserver.cpp +SOURCE fmradioengine.cpp +SOURCE fmradioenginecentralrepositoryhandler.cpp +SOURCE fmradioengineradiosettings.cpp +SOURCE fmradioengineradiostatehandler.cpp +SOURCE fmradiomobilenetworkinfolistener.cpp +SOURCE fmradiopropertyobserver.cpp +SOURCE fmradiopubsub.cpp +SOURCE fmradiordsreceiver.cpp +SOURCE fmradiordsreceiverbase.cpp +SOURCE fmradiordsreceiversimulator.cpp +SOURCE fmradioregion.cpp +SOURCE fmradiosystemeventdetector.cpp + +#ifndef __ACCESSORY_FW +SOURCE fmradioenginedosserverobserver.cpp +#endif + +USERINCLUDE ../cenrep +USERINCLUDE ../src +USERINCLUDE ../inc +USERINCLUDE ../../inc + +APP_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/mmf/common +#ifdef __FMRADIO_ADVANCED_AUTO_RESUME +SYSTEMINCLUDE /epoc32/include/internal +#endif // __FMRADIO_ADVANCED_AUTO_RESUME + +LIBRARY accmonitor.lib +LIBRARY radio_utility.lib +LIBRARY fmpresetutility.lib +LIBRARY cenrepnotifhandler.lib +LIBRARY centralrepository.lib +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY audiooutputrouting.lib +LIBRARY cone.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY etel.lib +LIBRARY etelmm.lib +LIBRARY commsdat.lib +LIBRARY accclient.lib + +DEBUGLIBRARY flogger.lib + +#ifdef __ACCESSORY_FW +DEFFILE fmradioengineac.def +#endif diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/debug.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,53 @@ +/* +* 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: Central place for nice debug-type macros & functions +* +*/ + + +#ifndef DEBUG_H +#define DEBUG_H + +//INCLUDES +#include +#ifdef _DEBUG +#define FTRACE(a) {a;} +#define FDEBUGVAR(a) a +#else +#define FTRACE(a) +#define FDEBUGVAR(a) +#endif // _DEBUG + + + /** + * Declare the FPrint function + * @since Series 60 2.7 + * @return none + */ +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); + #ifdef _DEBUG + RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3); + #endif + } + +#endif // DEBUG_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioaccessoryobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioaccessoryobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,125 @@ +/* +* 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: Observer of accessory states. +* +*/ + + +#ifndef CFMRADIOACCESSORYOBSERVER_H +#define CFMRADIOACCESSORYOBSERVER_H + +#include +#include +#include + +class MFMRadioHeadsetEventObserver; + +/** + * Observer of accessory states. + * + * Instance of this class observes notifications of headset state changes. + * In its turn it sends notifications to its observer of those changes. + * + */ +class CFMRadioAccessoryObserver : public CActive + { +public: + + /** + * C++ default constructor. + */ + CFMRadioAccessoryObserver(); + + /** + * Static constructor. + */ + static CFMRadioAccessoryObserver* NewL(); + + /** + * Destructor. + */ + virtual ~CFMRadioAccessoryObserver(); + + /** + * Sets observer. The observer will be notified when headset has been + * pressed or headset is connected/disconnected. + * + * @param aObserver Observer + */ + void SetObserver( MFMRadioHeadsetEventObserver* aObserver ); + + /** + * Returns accessory connection state. + * + * @return ETrue if accessory is connected, + * EFalse otherwise + */ + TBool IsHeadsetAccessoryConnected() const; + + // from base class CActive + /** + * From CActive + * + * @see CActive::RunL() + */ + void RunL(); + + /** + * From CActive + * + * @see CActive::DoCancel() + */ + void DoCancel(); + +protected: + +private: + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +public: + +protected: + + /** + * Instance that gets notifications of the headset state changes + */ + MFMRadioHeadsetEventObserver* iObserver; + +private: // Data + + /** + * Session for The Accessory Server. + */ + RAccessoryServer iAccessoryServer; + + /** + * Accessory Mode sub-session + */ + RAccessoryMode iAccessoryModeSession; + + + /** + * Accessory Mode structure, with active audio information. + */ + TAccPolAccessoryMode iAccPolAccessoryMode; + TAccPolAccessoryMode iPrevAccMode; + }; + +#endif // CFMRADIOACCESSORYOBSERVER_H + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioaudioutils.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioaudioutils.hrh Tue Feb 02 00:17:10 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: FM Radio audio related definitions +* +*/ + +#ifndef FMRADIOAUDIOUTILS_HRH +#define FMRADIOAUDIOUTILS_HRH + +/** +* Output sources. +*/ +enum TFMRadioOutputDestination + { + EFMRadioHeadset = 0, /**< Headset in use. */ + EFMRadioSpeaker = 1 /**< Speaker in use. */ + }; + +#endif // FMRADIOAUDIOUTILS_HRH diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiocontroleventobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiocontroleventobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,191 @@ +/* +* 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 the control event observer interface +* +*/ + +#ifndef MFMRADIOCONTROLEVENTOBSERVER_H +#define MFMRADIOCONTROLEVENTOBSERVER_H + +#include "fmradioaudioutils.hrh" +#include "fmradiosystemutils.h" + +/** + * MFMRadioControlEventObserver + * + * MFMRadioControlEventObserver defines observer interface for FM Radio control events. + */ +class MFMRadioControlEventObserver + { + +public: + + /** + * Called when "step to channel" request occurs. + * + * @param aDirection EFMRadioUp for stepping up, EFMRadioDown for stepping down + */ + virtual void StepToChannelL( TFMRadioTuneDirection aDirection ) = 0; + + /** + * Called when "set channel" request occurs. + * + * @param aChannelId Channel id to set + */ + virtual void SetChannelL( TInt aChannelId ) = 0; + + /** + * Called when "seek" request occurs. + * + * @param aDirection If EFMRadioUp seeks up, otherwise seeks down + */ + virtual void SeekL( TFMRadioTuneDirection aDirection ) = 0; + + /** + * Called when "step to frequency up" request occurs. + * + * @param aDirection EFMRadioUp for stepping up, EFMRadioDown for stepping down + */ + virtual void StepToFrequencyL( TFMRadioTuneDirection aDirection ) = 0; + + /** + * Called when "set frequency" request occurs. + * + * @param aFreq Frequency to set + */ + virtual void SetFrequencyL( TUint32 aFreq ) = 0; + + /** + * Called when "adjust volume" request occurs. + * + * @param aDirection If EFMRadioDecVolume decreases, otherwise increases + * volume + */ + virtual void AdjustVolumeL( TFMRadioVolumeSetDirection aDirection ) = 0; + + /** + * Called when "mute" request occurs. + * + * @param aMute if ETrue mutes, else unmutes radio + */ + virtual void MuteL( TBool aMute ) = 0; + + /** + * Called when "play" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void PlayL( TBool aDownPressed ) = 0; + + /** + * Called when "pause" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void PauseL(TBool aDownPressed ) = 0; + + /** + * Called when "play", "pause" or "pauseplay" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void PausePlayL( TBool aDownPressed ) = 0; + + /** + * Called when "stop" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void StopL( TBool aDownPressed ) = 0; + + /** + * Called when "forward" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void ForwardL( TBool aDownPressed ) = 0; + + /** + * Called when "fast forward" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void FastForwardL( TBool aDownPressed ) = 0; + + /** + * Called when "backward" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void BackwardL( TBool aDownPressed ) = 0; + + /** + * Called when "rewind" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void RewindL( TBool aDownPressed ) = 0; + + /** + * Called when "channel up" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void ChannelUpL( TBool aDownPressed ) = 0; + + /** + * Called when "channel down" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void ChannelDownL( TBool aDownPressed ) = 0; + + /** + * Called when "volume up" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void VolumeUpL( TBool aDownPressed ) = 0; + + /** + * Called when "volume down" request occurs. + * + * @param aDownPressed If ETrue, button is down. If EFalse, button is up. + */ + virtual void VolumeDownL( TBool aDownPressed ) = 0; + + /** + * Called when "change view" request occurs + * + * @param aViewId the id of activated view + * @param aForceChange if ETrue, view changing is forced and state + * of FM Radio is not checked + */ + virtual void ChangeViewL(TUid aViewId, TBool aForceChange) = 0; + + /** + * Called when output source is changed + * @param aDestination the current output source + */ + virtual void SetAudioOutputDestinationL(TFMRadioOutputDestination aDestination) = 0; + + /** + * Called when headset button answer/end call is pressed + */ + virtual void AnswerEndCallL() = 0; + }; + +#endif // MFMRADIOCONTROLEVENTOBSERVER_H + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioengine.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,848 @@ +/* +* 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 class implements the core functionality of the +* Radio Engine +* +*/ + + +#ifndef FMRADIOENGINE_H +#define FMRADIOENGINE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradiosystemeventdetectorobserver.h" +#include "fmradionetworkchangeobserver.h" +#include "fmradiordsobserver.h" +#include "fmradioengine.hrh" +#include "fmradioheadseteventobserver.h" + +#ifndef __ACCESSORY_FW +#include +#endif + +// CONSTANTS +const TUint8 KPresetNameLength = 32; +const TInt KDefaultRadioFrequency = 87500000; +_LIT(KFMRadioEngineResourceFile, "fmradioengine.rsc"); +const TInt KFMRadioFreqMultiplier = 1000; + +// FORWARD DECLARATIONS +class CAudioOutput; +class CCentralRepositoryHandler; +class CDesC16Array; +class CFMRadioAccessoryObserver; +class CFMRadioContextPublisher; +class CFMRadioMobileNetworkInfoListener; +class CFMRadioPubSub; +class CFMRadioRdsReceiverBase; +class CFMRadioSystemEventDetector; +class CRadioStateHandler; +class MRadioEngineStateChangeCallback; +class TRadioSettings; + +#ifndef __ACCESSORY_FW +class RDosServer; +class CDosServerObserver; +#endif + +// CLASS DECLARATION + +/** + * This class implements the core functionality of the Radio Engine + * + * @since S60 3.2 + */ +class CRadioEngine : public CBase, + public MRadioPlayerObserver, + public MRadioFmTunerObserver, + public MRadioPresetObserver, + public MFMRadioSystemEventDetectorObserver, + public MFMRadioNetworkChangeObserver, + public MFMRadioRdsObserver, + public MFMRadioHeadsetEventObserver + + { +public: + + typedef TBuf TStationName; + + enum TRadioMode + { + ERadioTunerMode, + ERadioPresetMode + }; + + enum TFMRadioAudioMode + { + EFMRadioStereo = 0, + EFMRadioMono + }; + + enum TFMRadioAudioOutput + { + EFMRadioOutputHeadset = 0, + EFMRadioOutputIHF + }; + +public: + + /** + * Two-phased class constructor. + * @return pointer to CRadioEngine class instance + */ + IMPORT_C static CRadioEngine* NewL( MRadioEngineStateChangeCallback& aCallback ); + /** + * Destructor of CRadioEngine class. + */ + IMPORT_C virtual ~CRadioEngine(); + +public: // New functions + + /** + * Set radio settings to their default values. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void InitializeRadio(); + /** + * Retrieves the current radio mode . + * @since Series 60 3.0 + * @return tune/preset + */ + IMPORT_C TRadioMode GetRadioMode() const; + + /** + * Gets the current audio mode. + * @since Series 60 3.0 + * @return stereo/mono + * @retval 0 = stereo + * @retval 1 = mono + */ + IMPORT_C TInt GetAudioMode() const; + + /** + * Set the radio's audio mode. + * @since Series 60 3.0 + * @param aAudioMode the new audio mode + * @return none + */ + IMPORT_C void SetAudioMode( const TFMRadioAudioMode aAudioMode ); + + /** + * get the currently selected channel index. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C TInt GetPresetIndex() const; + + /** + * Update the channel located at the index to use the frequency specified. + * @since Series 60 3.0 + * @param aIndex index into the channel array. + * @param aStationName name of the channel + * @param aFrequency frequency value to be used. + * @return none + */ + IMPORT_C void SetPresetNameFrequencyL( TInt aIndex, const TStationName& aStationName, TInt aFrequency ); + + /** + * Retrieve the channel frequency at the index specified + * @since Series 60 3.0 + * @param aIndex index into the channel array. + * @return the frequency + */ + IMPORT_C TInt GetPresetFrequencyL(TInt aIndex) const; + + /** + * Retrieve the channel name at the index specified + * @since Series 60 3.0 + * @param aIndex index into the channel array. + * @return the channel name + */ + IMPORT_C CRadioEngine::TStationName& GetPresetNameL( TInt aIndex ); + + /** + * Retrieve the channel name and the frequency at the index specified + * @param aIndex station index + * @param aName stored station name + * @param aFrequency preset frequency + */ + IMPORT_C void GetPresetNameAndFrequencyL( TInt aIndex, TDes& aName, TInt& aFrequency ); + + /** + * Starts the radio. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void RadioOn(); + + /** + * Stops the radio. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void RadioOff(); + + /** + * Returns the radio status + * @since ?? + * @return ETrue = radio is on, EFalse = radio is off + */ + IMPORT_C TBool IsRadioOn(); + + /** + * Checks if offine profile is current active profile + * @since ?? + * @return True / False + */ + IMPORT_C TBool IsOfflineProfileL(); + + /** + * Tune to the specified frequency + * @since Series 60 3.0 + * @param aFrequency - frequency to lock onto. + * @param aRadioMode - The radio mode to be used. Tuner mode by default + * @return none + */ + IMPORT_C void Tune( TInt aFrequency, TRadioMode aRadioMode = ERadioTunerMode ); + + /* + * Sets tuner mode on i.e. preset channel is not active. + * Active preset Channel P&S data is also cleared. + * Useful for example when preset channel is deleted. + */ + IMPORT_C void SetTunerModeOn(); + + /** + * Scan up to the next available frequency. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void ScanUp(); + + /** + * Scan down to the last available frequency. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void ScanDown(); + + /** + * Cancel previously requested scan, and + * return to the already tuned frequency. + * @since Series 60 3.0 + * @return none + */ + IMPORT_C void CancelScan(); + + /** + * Sets the audio mute state + * @since Series 60 3.0 + * @param aMuteOn - flag to determine whether mute should be turned on or off + * @return none + */ + IMPORT_C void SetMuteOn(TBool aMuteOn); + + /** + * Gets the audio mute state + * @since Series 60 3.0 + * @return ETrue or EFalse to indicate whether mute is currently on. + */ + IMPORT_C TBool IsMuteOn() const; + + /** + * Sets the volume level of the FM radio + * @since Series 60 3.0 + * @param aVolume - the volume to be used. + * @return none + */ + IMPORT_C void SetVolume(TInt aVolume); + + /** + * Gets the volumelevel. + * @since Series 60 3.0 + * @return the current volume + */ + IMPORT_C TInt GetVolume() const; + + /** + * Gets the max volumelevel. + * @since Series 60 3.0 + * @return the max volume + */ + IMPORT_C TInt GetMaxVolume() const; + + /** + * Sets the audio Output + * @since Series 60 3.0 + * @param aAudioOutput - where should the audio be routed? + * @return none + */ + IMPORT_C void SetAudioOutput( const TFMRadioAudioOutput aAudioOutput ); + + /** + * Sets the rds af search enabled + * @param aEnabled ETrue if rds af search is enabled; EFalse otherwise. + * @return none + */ + IMPORT_C void SetRdsAfSearchEnable( TBool aEnabled ); + + /** + * Check whether flight mode is currently enabled + * @since Series 60 3.0 + * @return ETrue or EFalse dependent on whether flightmode is enabled + */ + IMPORT_C TBool IsRdsAfSearchEnabled() const; + + /** + * @return reference to settings + */ + IMPORT_C TRadioSettings& RadioSettings( ); + + /** + * Retrieve the current audio output + * @since Series 60 3.0 + * @return EFMRadioOutputIHF or EFMRadioOutputHeadset + */ + IMPORT_C TFMRadioAudioOutput GetAudioOutput() const; + + /** + * Tunes to the chosen channel. + * @since Series 60 3.0 + * @param aIndex - the index number of the channel you wish to tune to. + * @return none + */ + IMPORT_C void TunePresetL(TInt aIndex); + + /** + * Retrieves the current frequency. + * @since Series 60 3.0 + * @return the frequency + */ + IMPORT_C TInt GetTunedFrequency() const; + + /** + * Check whether flight mode is currently enabled + * @since Series 60 3.0 + * @return ETrue or EFalse dependent on whether flightmode is enabled + */ + IMPORT_C TBool IsFlightModeEnabled() const; + + /** + * Get the frequency range (in Hertz) of the specified band. + * This function should be used to enquire the frequency range + * of the bands that GetCapabilities reports as supported. + * @since Series 60 3.0 + * @param aBottomFrequency The variable to set to the lowest frequency allowed + * @param aTopFrequency The variable to set to the highest frequency allowed + * @return A standard system error code + **/ + IMPORT_C TInt GetFrequencyBandRange( TInt& aBottomFrequency, TInt& aTopFrequency ); + + /** + * Check whether call is in progress + * @since Series 60 3.1 + * @return ETrue or EFalse to indicate whether call is in progress + */ + IMPORT_C TBool IsInCall() const; + + /** + * Has the frequency been set by RDS AF search or not. + * + * @return ETrue if frequency was set by RDS AF, otherwise EFalse + */ + IMPORT_C TBool FrequencySetByRdsAf() const; + + /** + * Getter for RDS receiver + * + * @return Reference to CFMRadioRdsReceiver + */ + IMPORT_C CFMRadioRdsReceiverBase& RdsReceiver(); + /** + * Notifies UI that the headset button has been pressed + */ + void HandleHeadsetButtonPress(); + /** + * Switches the engine into flight mode, and notifies the UI of + * the change in status. + */ + void HandleFlightModeEnabled(); + /** + * Switches the engine out of flight mode, and notifies the UI of + * the change in status + */ + void HandleFlightModeDisabled(); + /** + * Calls the User Interface callback function, indicating the event code and + * error code. + */ + void HandleCallback(TInt aEventCode, TInt aErrorCode ); + + /** + * Gets the headset status + * @return ETrue if headset connected + */ + IMPORT_C TBool IsHeadsetConnected() const; + + /** + * From MRadioPlayerObserver. + * Called when Radio state changed. + * + * @since S60 3.2 + * @param aState Radio player state + * @param aError A standard system error code, only used when aState is ERadioPlayerIdle + */ + void MrpoStateChange( TPlayerState aState, TInt aError ); + + /** + * From MRadioPlayerObserver. + * Called when volume changes. This may be caused by other applications. + * + * @since S60 3.2 + * @param aVolume Current volume. + */ + void MrpoVolumeChange( TInt aVolume ); + + /** + * From MRadioPlayerObserver. + * Called when mute setting changes. This may be caused by other applications. + * + * @since S60 3.2 + * @param aMute ETrue indicates audio is muted. + */ + void MrpoMuteChange( TBool aMute ); + + /** + * From MRadioPlayerObserver. + * Called when mute setting changes. This may be caused by other applications. + * + * Called when balance setting changes. This may be caused by other applications. + * + * @since S60 3.2 + * @param aLeftPercentage + * Left speaker volume percentage. This can be any value from zero to 100. + * Zero value means left speaker is muted. + * @param aRightPercentage + * Right speaker volume percentage. This can be any value from zero to 100. + * Zero value means right speaker is muted. + */ + void MrpoBalanceChange( TInt aLeftPercentage, TInt aRightPercentage ); + + + /** + * From MRadioFmTunerObserver. + * Called when Request for tuner control completes. + * + * @since S60 3.2 + * @param aError A standard system error code or FM tuner error (TFmRadioTunerError). + */ + void MrftoRequestTunerControlComplete( TInt aError ); + + /** + * From MRadioFmTunerObserver. + * Set frequency range complete event. This event is asynchronous and is received after + * a call to CRadioFmTunerUtility::SetFrequencyRange. + * + * @since S60 3.2 + * @param aError A standard system error code or FM tuner error (TFmRadioTunerError). + */ + void MrftoSetFrequencyRangeComplete( TInt aError ); + + /** + * From MRadioFmTunerObserver. + * Set frequency complete event. This event is asynchronous and is received after a call to + * CRadioFmTunerUtility::SetFrequency. + * + * @since S60 3.2 + * @param aError A standard system error code or FM tuner error (TFmRadioTunerError). + */ + void MrftoSetFrequencyComplete( TInt aError ); + + /** + * From MRadioFmTunerObserver. + * Station seek complete event. This event is asynchronous and is received after a call to + * CRadioFmTunerUtility::StationSeek. + * + * @since S60 3.2 + * @param aError A standard system error code or FM tuner error (TFmRadioTunerError). + * @param aFrequency The frequency(Hz) of the radio station that was found. + */ + void MrftoStationSeekComplete( TInt aError, TInt aFrequency ); + + /** + * From MRadioFmTunerObserver. + * Called when FM Transmitter status changes (if one is present in the device). Tuner receiver + * is forced to be turned off due to hardware conflicts when FM transmitter is activated. + * + * @since S60 3.2 + * @param aActive ETrue if FM transmitter is active; EFalse otherwise. + */ + void MrftoFmTransmitterStatusChange( TBool aActive ); + + /** + * From MRadioFmTunerObserver. + * Called when antenna status changes. + * + * @since S60 3.2 + * @param aAttached ETrue if antenna is attached; EFalse otherwise. + */ + void MrftoAntennaStatusChange( TBool aAttached ); + + /** + * From MRadioFmTunerObserver. + * Called when offline mode status changes. + * @since S60 3.2 + * + * @param aOfflineMode ETrue if offline mode is enabled; EFalse otherwise. + */ + void MrftoOfflineModeStatusChange( TBool aOfflineMode ); + + /** + * From MRadioFmTunerObserver. + * Called when the frequency range changes. This may be caused by other applications. + * + * @since S60 3.2 + * @param aBand New frequency range. + */ + void MrftoFrequencyRangeChange(TFmRadioFrequencyRange aBand ); + + /** + * From MRadioFmTunerObserver. + * Called when the tuned frequency changes. This may be caused by other + * applications or RDS if AF/TA is enabled. + * + * @since S60 3.2 + * @param aNewFrequency The new tuned frequency(Hz). + */ + void MrftoFrequencyChange( TInt aNewFrequency ); + + /** + * From MRadioFmTunerObserver. + * Called when the forced mono status change. This may be caused by other applications. + * + * @since S60 3.2 + * @param aForcedMono ETrue if forced mono mode is enabled; EFalse otherwise. + */ + void MrftoForcedMonoChange( TBool aForcedMono ); + + /** + * From MRadioFmTunerObserver. + * Called when the squelch (muting the frequencies without broadcast) status change. + * This may be caused by other applications. + * + * @since S60 3.2 + * @param aSquelch ETrue if squelch is enabled; EFalse otherwise. + */ + void MrftoSquelchChange( TBool aSquelch ); + + /** + * From MRadioPresetObserver. + * Called when a preset changes. + * + * NOTE: EPresetDeleted with aIndex == 0, indicates that all presets have been deleted. + * + * @since S60 3.2 + * @param aChange Change event type + * @param aIndex Index to the preset that has changed. Zero means all presets. + */ + void MrpeoPresetChanged( TPresetChangeEvent aChange, TInt aIndex ); + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when networks comes up. + */ + void NetworkUpCallbackL(); + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when network goes down. + */ + void NetworkDownCallbackL(); + + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when audio resources become available. + */ + void AudioResourcesAvailableL(); + + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when audio auto resuming is forbidden. + */ + void AudioAutoResumeForbiddenL(); + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when call becomes active. + */ + void CallActivatedCallbackL(); + + /** + * From base class MFMRadioSystemEventDetectorObserver + * This callback notifies when call becomes deactive. + */ + void CallDeactivatedCallbackL(); + /** + * From base class MFMRadioNetworkChangeObserver + * + * @see MFMRadioNetworkChangeObserver::NetworkIdChanged(); + */ + void NetworkIdChanged(); + + // from base class MFMRAdioRdsObserver + void RdsDataProgrammeService( const TDesC& aProgramService ); + void RdsDataPsNameIsStatic( TBool aStatic ); + void RdsDataRadioText( const TDesC& aRadioText ); + void RdsDataRadioTextPlus( const TInt aRTPlusClass, const TDesC& aRadioTextPlus ); + + void RdsAfSearchBegin(); + void RdsAfSearchEnd( TUint32 aFrequency, TInt aError ); + void RdsAfSearchStateChange( TBool aEnabled ); + void RdsAvailable( TBool aAvailable ); + + // from MFMRadioHeadsetEventObserver + void HeadsetAccessoryConnectedCallbackL(); + void HeadsetAccessoryDisconnectedCallbackL(); + + /** + * Initialize fmradioengine resource file information + */ + void InitializeResourceLoadingL(); + /** + * Convert FMRadio region info to frequency range used by fmradiotunerutility + * @param aRegionId fmradio region + * @return frequency range used by fmradiotunerutility + */ + TFmRadioFrequencyRange TunerFrequencyRangeForRegionId( const TInt aRegionId ) const; + /** + * Determine current region + * @return fmradio region + */ + IMPORT_C TFMRadioRegionSetting GetRegionL() const; + /** + * fill the given list with fmradio regions + * @param aArray array to add regions + */ + IMPORT_C void FillListWithRegionDataL( CDesC16Array& aArray ) const; + /** + * Returns region from the array of supported regions + * @param aIndex index for region + * @return fmradio region + */ + IMPORT_C TFMRadioRegionSetting RegionIdAtIndex( const TInt aIndex ) const; + /** + * Returns current region Id + * @return current region Id. + */ + IMPORT_C TInt RegionId() const; + /** + * Change current region + * @param aRegion region to set + */ + IMPORT_C void SetRegionIdL( TInt aRegion ) const; + /** + * Request tuner control from fmradiotunerutility + */ + IMPORT_C void RequestTunerControl() const; + /** + * Returns decimal count for current region MHz information + * @return decimal count for current region + */ + IMPORT_C TInt DecimalCount() const; + /** + * Return step size for tuning. + * @return step size + */ + IMPORT_C TUint32 FrequencyStepSize() const; + /** + * Returns a reference to P&S interface. + * Method leaves if iPubSub is not allocated + * + * @return PS& interface. + */ + IMPORT_C CFMRadioPubSub& PubSubL() const; + /** + * increases startup count by one and returns amount of app startups. + * + * @return app startup count + */ + IMPORT_C TInt UpdatedStartupCount() const; + /** + * Cancel seek and notify UI + */ + IMPORT_C void CancelScanLocalStationsScan(); + /** + * Is routing between loudspeaker and headset possible + * + * @return ETrue, if routing is possible + */ + IMPORT_C TBool IsAudioRoutingPossible() const; + + /** + * Has RT+ interaction tutorial dialog been shown to user. + * + * @return ETrue after the first time user sees the dialog. + */ + IMPORT_C TBool MusicStoreNoteDisplayed(); + + /** + * Sets music store tutorial note displayed value to true. + * It needs to be false only before supported RT+ features + * become available for the first time. + */ + IMPORT_C void SetMusicStoreNoteDisplayed(); + + /** + * Get level of support for RT+ interactions. + * Values are defined in fmradioengine.hrh:TFMRadioRTPlusLevel. + * + * @return which interactions are supported as a TFMRadioRTPlusLevel value + */ + IMPORT_C TFMRadioRTPlusLevel GetRTPlusSupportLevel(); + + /** + * Sets the currently active preset index + * @param aIndex new active preset index + */ + IMPORT_C void SetCurrentPresetIndex( const TInt aIndex ); + +private: + + /** + * Default class constructor. + */ + CRadioEngine( MRadioEngineStateChangeCallback& aCallback ); + + /** + * Second phase class constructor. + */ + void ConstructL(); + + /** + * ConnectLineL + */ + void ConnectLineL(); + + /** + * Updates the frequency into settings and P&S + * + * @param aFrequency The frequency to be set + */ + void StoreAndPublishFrequency( TInt aFrequency ); + + /** + * Scans all current presets and sets stored frequencies to KErrNotFound + * if the preset name is empty. + */ + void ResetPresetsL(); + + /** + * Resolves if BT audio accessory is connected + * @return ETrue if BT Audio connected + */ + TBool IsBTAccessoryConnectedL(); +private: + + //the internal radio engine states + enum TRadioEngineState + { + EStateRadioOff, + EStateRadioOn, + }; + + // The Radio Utility + CRadioUtility* iRadioUtility; // own + // The Tuner Utility + CRadioFmTunerUtility* iFmTunerUtility; + // The Player Utility + CRadioPlayerUtility* iPlayerUtility; + // The Preset Utility + CRadioFmPresetUtility* iPresetUtility; // own + // Receives and notifies of the RDS data + CFMRadioRdsReceiverBase* iRdsReceiver; + // Capabilities of the tuner + TFmTunerCapabilities iTunerCaps; + // Multiplier used to scale UI volume setting to volume level used by the player utility + TReal iUiVolumeFactor; + // pointer to DosServerObserver +#ifndef __ACCESSORY_FW + CDosServerObserver *iDosServerObserver; //own +#endif + // Audio routing API + CAudioOutput* iAudioOutput; //own + // pointer to CCentralRepositoryHandler + CCentralRepositoryHandler* iCentralRepositoryHandler; // own + // Used to provide async behavior in some callbacks + CRadioStateHandler *iStateHandler; + // flag to indicate if auto resume is supported + TBool iAutoResume; + // flag to indicate if a call is in progress + TBool iInCall; + // pointer to TRadioSettings + TRadioSettings* iRadioSettings; // own + // the current radio state + TRadioEngineState iCurrentRadioState; + // a reference of MRadioEngineStateChangeCallback object + MRadioEngineStateChangeCallback& iCallback; + // temperary frequency + TInt iTempFrequency; + // a flag indicating if tune prset is requestd + TBool iTunePresetRequested; + // Indicates a request to initialized the radio is pending + TBool iInitializeRadioRequestExists; + // Indicates if the tuner control has been granted. + TBool iTunerControl; + // High and low frequency of the current band. + TInt iBottomFrequency; + TInt iTopFrequency; + // ETrue if frequency was set by RDS AF + TBool iFrequencySetByRdsAf; + //Listens changes in network availability + CFMRadioSystemEventDetector* iSystemEventDetector; + // for fmradio engine resource file + TInt iFMRadioEngineResourceOffset; + //Listens changes in network ID and country code + CFMRadioMobileNetworkInfoListener* iNetworkInfoListener; + //P&S interaction interface for FMRadio actions. + CFMRadioPubSub* iPubSub; + // accessory observer + CFMRadioAccessoryObserver* iHeadsetObserver; + // tel server session + RTelServer iTelServer; + // phone + RMobilePhone iPhone; + // line + RMobileLine iLine; + // tsy name + TFileName iTsyName; + // conrrectly constructer + TBool ilineConstructed; + // for storing station name for method GetPresetNameL + TStationName iStationName; + // Local cache for tuning state so that it doesn't get published before should + TFMRadioPSTuningState iTuningState; + // If last time audio is set to IHF with no headset connected. + TBool iHFOptionActivated; + }; + +#endif //FMRADIOENGINE_H + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioengine.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioengine.hrh Tue Feb 02 00:17:10 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: Declaration of radio related enumerations +* +*/ + + +#ifndef FMRADIOENGINE_HRH +#define FMRADIOENGINE_HRH + +/** Regions*/ +enum TFMRadioRegionSetting + { + EFMRadioRegionNone = -1, + EFMRadioRegionDefault, + EFMRadioRegionJapan, + EFMRadioRegionAmerica, + EFMRadioRegionPoland + }; + +enum TFMRadioRTPlusLevel + { + EFMRadioMusicStoreOnly = 0, + EFMRadioAllInteractions + }; + +#endif // FMRADIOENGINE_HRH diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioenginecentralrepositoryhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioenginecentralrepositoryhandler.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,170 @@ +/* +* 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: Defines APIs to communicate with Central Repository +* +*/ + + +#ifndef FMRADIOENGINECENTRALREPOSITORYHANDLER_H +#define FMRADIOENGINECENTRALREPOSITORYHANDLER_H + +// INCLUDES +#include "fmradioregion.h" + +// CONSTANTS +const TInt KBufferLength = 20; +const TInt KStreamBufferSize = 100; + +// Forward declare implementation class +class TRadioSettings; +class CRepository; + +// CLASS DECLARATION + +/** +* it is a wrapper of Central Repository, responsible for the operations that need to access +* the central respositorhy. +* +* @lib FMRadioEngine.lib +* @since Series 60 3.0_version +*/ +class CCentralRepositoryHandler : public CBase + { + public: + /** + * Two-phased class constructor. + * @param aRadioSettings pointer to the CRadioSettings class + */ + static CCentralRepositoryHandler* NewL(TRadioSettings& aRadioSettings); + /** + * Destructor of CCentralRepositoryHandler class. + */ + virtual ~CCentralRepositoryHandler(); + public: + /** + * Save all engine related persistent info back to Central Repository + * @since Series 60 3.0 + * @return none + */ + void SaveEngineSettings(); + + TInt CountRegions() const; + CFMRadioRegion& Region( TInt aIndex ) const; + TInt RegionId() const; + TUint32 FrequencyStepSize() const; + TUint32 MaxFrequency() const; + TUint32 MinFrequency() const; + TInt DecimalCount() const; + + void SetRegionIdL( TInt aRegion ); + + /** + * Determines if RT+ interaction tutorial dialog has been shown. + * See CFMRadioEngine::MusicStoreNoteDisplayed(). + */ + TBool MusicStoreNoteDisplayed(); + /** + * Sets RT+ interaction tutorial dialog as displayed. + * See CFMRadioEngine::SetMusicStoreNoteDisplayed(). + */ + void SetMusicStoreNoteDisplayed(); + /** + * Gets supported RT+ interactions. See CFMradioEngine::GetRTPlusSupportLevel(). + */ + TInt GetRTPlusSupportLevel(); + + /** + * Checks if offine profile is current active profile + * @return true/false + */ + TBool IsOfflineProfileActiveL(); + /** + * Increases startup time by one and returns amount of program startups. + * Also updates count to the repository. + */ + void IncreaseStartupCount() const; + /* + * Save headset volume level to the repository + */ + void SaveHeadsetVolumeSetting() const; + /* + * Save speaker volume level to the repository + */ + void SaveSpeakerVolumeSetting() const; + + private: + /** + * Default class constructor. + * @param aRadioSettings - pointer to the CRadioSettings class + */ + CCentralRepositoryHandler(TRadioSettings& aRadioSettings); + /** + * Second phase class constructor. + */ + void ConstructL(); + /** + * Retrieves persistent settings from Central Repository. + */ + void RetrieveInitialSettings(); + /** + * Initializes the regions as defined in the resource file. + */ + void InitializeRegionsL(); + + /** + * Converts Region ID to index + * + * @param aRegionId The region ID that is wanted to convert + * @return The region index, KErrNotFound if no match found + */ + TInt RegionIndexForId( TInt aRegionId ) const; + + /** + * Updates the current region index + * + * @param aRegionId The new region ID + */ + void UpdateCurrentRegionIdx( TInt aRegionId ); + /* + * Set emulator networkinfo + * + */ + #ifdef __WINS__ + void SetInitialSettings(); + #endif //__WINS__ + /** + * Checks if frequency is in the current region range + * + * @param aFrequency Frequency to check + */ + TBool IsFrequencyValid( TUint32 aFrequency ) const; + + private: // data + + // Handle to Central Repository server + CRepository* iCentralRepository; + // Reference to RadioSetting object + TRadioSettings* iRadioSettings; + /** The current region. */ + TInt iCurrentRegionIdx; + /** The available regions. */ + RPointerArray iRegions; + + + + }; + +#endif // FMRADIOENGINECENTRALREPOSITORYHANDLER_H + +// end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioenginecrkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioenginecrkeys.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,71 @@ +/* +* 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: Definition of central repository keys for FM Radio Engine. +* +*/ + + +#ifndef FMRADIOENGINECRKEYS_H +#define FMRADIOENGINECRKEYS_H + +// FM Radio Engine UID +const TUid KCRUidFMRadioEngine = {0x2001B25E}; + +// Radio headset volume +const TUint32 KRadioHeadsetVolume = 0x00000001; + +// Radio speaker volume +const TUint32 KRadioSpeakerVolume = 0x00000002; + +// The last played radio frequency +const TUint32 KFmRadioFrequency = 0x00000003; + +// The last played radio channel +const TUint32 KFmRadioChannel = 0x00000004; + +// The radio mode before radio off +const TUint32 KFmRadioMode = 0x00000005; + +// Country code + network ID +const TUint32 KFMRadioCREmulatorNetworkInfo = 0x00000006; + +// number of startups +const TUint32 KRadioCRStartupCount = 0x00000007; + +// currently active region +const TUint32 KFMCRCurrentRegion = 0x00000008; + +// Japan region support on/off +const TUint32 KFMCRJapanRegionAllowed = 0x00000050; + +// Rds af seacrh enabled +const TUint32 KFMCRRdsAfSearchEnabled = 0x00000009; + +// The first preset channel's location in central repository +const TUint32 KFmRadioPresetChannel1 = 0x0000000A; + +// Is note "'Music Store' got enabled..." viewed already? +const TUint32 KRadioMusicStoreNoteDisplayed = 0x0000000B; + +// Which RT+ interactions are supported? +const TUint32 KRadioRTPlusSupportLevel = 0x0000000C; + +// Application UID of the song recognition service +const TUint32 KFmRadioSongRecognitionUid = 0x0000000D; + +#endif // FMRADIOENGINECRKEYS_H + +// End of file + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioenginedosserverobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioenginedosserverobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies 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 the CDosServerObserver class. which is the +* notification interface to the DOS Server. +* +*/ + +#ifndef __DOSSERVEROBSERVER_H +#define __DOSSERVEROBSERVER_H + +// INCLUDES +#include + +#include "fmradioengineradiosettings.h" + +class CRadioEngine; + +// CLASS DECLARATION + +/** +* This class implements theis the notification interface to the DOS Server. +*/ +class CDosServerObserver : public CDosEventListenerBase + { + public: + virtual ~CDosServerObserver(); + /** + * Two-phased class constructor. + * @param aEngine - pointer to the CRadioEngine instance (used for callbacks) + * @param aRadioSettings - pointer to the CRadioSettings class + * @return pointer to CDosServerObserver class instance + */ + static CDosServerObserver* NewL(CRadioEngine* aEngine, TRadioSettings* aRadioSettings); + + /** + * Sets the current audio routing. + * @param aAudioOutput Audio output to be used + * @return Symbian error code + */ + + TInt SetAudioRouting(CRadioEngine::TFMRadioAudioOutput aAudioOutput); + + /** + * From CDosEventListenerBase + * It notifies about a headset button state change + * @param aState State of button + */ + void HeadsetButtonChangedL(EPSButtonState aState); + + private: + /** + * Default class constructor. + * @param aEngine - pointer to the CRadioEngine instance (used for callbacks) + * @param aRadioSettings - pointer to the CRadioSettings class + */ + CDosServerObserver(CRadioEngine* aEngine, TRadioSettings* aRadioSettings); + /** + * Second phase class constructor. + */ + void ConstructL(); + + private: + CRadioEngine *iEngine; + TRadioSettings *iRadioSettings; + RDosAudio iDosAudio; + }; + +#endif // __DOSSERVEROBSERVER_H + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioengineradiosettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioengineradiosettings.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,326 @@ +/* +* 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 implementation of the TRadioSettings class, which holds +* the RadioEngine settings. +* +*/ + + +#ifndef FMRADIOSETTINGS_H +#define FMRADIOSETTINGS_H + +#include "fmradioengine.h" + +// CONSTANTS +const TInt KDefaultRadioVolume = 3; + +// CLASS DECLARATION +//class CRadioEngine; + + +/** +* TRadioSettings class. +* Maintain the radio setting data. +* +*/ +class TRadioSettings + { + public: + /** + * default constructor. + */ + TRadioSettings(); + + /** + * return current headset volume. + * @since Series 60 2.7 + * @return current headset volume + */ + TInt HeadsetVolume() const; + /** + * return current speaker volume. + * @since Series 60 2.7 + * @return current speaker volume + */ + TInt SpeakerVolume() const; + /** + * return current preset number. + * @since Series 60 2.7 + * @return current preset number + */ + TInt CurrentPreset() const; + /** + * return current frequency. + * @since Series 60 2.7 + * @return current frequency + */ + TInt Frequency() const; + /** + * return max frequency. + * @return max frequency + */ + TUint32 MaxFrequency() const; + /** + * return min frequency. + * @return min frequency + */ + TUint32 MinFrequency() const; + /** + * return step size for tuning. + * @return step size + */ + TUint32 FrequencyStepSize() const; + /** + * Returns decimal count for current region MHz information + * @return decimal count for current region + */ + TInt DecimalCount() const; + /** + * return current audio mode. + * @since Series 60 2.7 + * @return stereo/mono + */ + CRadioEngine::TFMRadioAudioMode AudioMode() const; + /** + * return current audio output destination. + * @since Series 60 2.7 + * @return headset/IHF + */ + CRadioEngine::TFMRadioAudioOutput AudioOutput() const; + /** + * check if radio is mute. + * @since Series 60 2.7 + * @return true/false + */ + TBool IsMuteOn() const; + /** + * check if radio is on. + * @since Series 60 2.7 + * @return true/false + */ + TBool IsRadioOn() const; + /** + * return radio mode. + * @since Series 60 2.7 + * @return tune/preset mode + */ + CRadioEngine::TRadioMode RadioMode() const; + /** + * check if headset is connected. + * @since Series 60 2.7 + * @return true/false + */ + TBool IsHeadsetConnected() const; + /** + * check if flight mode is enabled. + * @since Series 60 2.7 + * @return true/false + */ + TBool IsFlightModeEnabled() const; + /** + * Retrieves the RDS alternate frequency search setting + * + * @return ETrue if AF search is enabled, otherwise EFalse + */ + IMPORT_C TBool IsRdsAfSearchEnabled(); + /** + * set speaker volume. + * @since Series 60 2.7 + * @param aVolume the new volume + * @return none + */ + void SetSpeakerVolume(const TInt aVolume); + /** + * set headset volume. + * @since Series 60 2.7 + * @param aVolume the new volume + * @return none + */ + void SetHeadsetVolume(const TInt aVolume); + /** + * Set current preset number. + * @since Series 60 2.7 + * @return current preset number + */ + void SetCurrentPreset(const TInt aChannel); + /** + * set current frequency . + * @since Series 60 2.7 + * @param aFrequency the frequency to be set + * @return none + */ + void SetFrequency(const TInt aFrequency); + /** + * set max frequency. + * @param aMaxFrequency the frequency to be set + * @return none + */ + void SetMaxFrequency( const TUint32 aMaxFrequency ); + /** + * set min frequency. + * @param aMinFrequency the frequency to be set + * @return none + */ + void SetMinFrequency( const TUint32 aMinFrequency ); + /** + * set step size for manual tuning. + * @param aFrequencyStepSize frequency step + * @return none + */ + void SetFrequencyStepSize( const TUint32 aFrequencyStepSize ); + /** + * Set decimal count for current region MHz information + * @param aDecimalCount decimals used + * @return none + */ + void SetDecimalCount( const TInt aDecimalCount ); + /** + * set audio mode. + * @since Series 60 2.7 + * @param aAudioMode stereo/mono + * @return none + */ + void SetAudioMode(CRadioEngine::TFMRadioAudioMode aAudioMode); + /** + * set audio output. + * @since Series 60 2.7 + * @param aAudioOutput headset/IHF + */ + void SetAudioOutput(const CRadioEngine::TFMRadioAudioOutput aAudioOutput ); + /** + * set mute on. + * @since Series 60 2.7 + * @return none + */ + void SetMuteOn(); + /** + * set mute on. + * @since Series 60 2.7 + * @return none + */ + void SetMuteOff(); + /** + * set radio on. + * @since Series 60 2.7 + * @return none + */ + void SetRadioOn(); + /** + * set radio off. + * @since Series 60 2.7 + * @return none + */ + void SetRadioOff(); + /** + * set radio mode. + * @since Series 60 2.7 + * @param aRadioMode preset/tune mode + * @return none + */ + void SetRadioMode(const CRadioEngine::TRadioMode aRadioMode); + /** + * set headset connected. + * @since Series 60 2.7 + * @return none + */ + void SetHeadsetConnected(); + /** + * set headset disconnected. + * @since Series 60 2.7 + * @return none + */ + void SetHeadsetDisconnected(); + /** + * set flight mode. + * @since Series 60 2.7 + * @param aEnabled true/false + * @return none + */ + void SetFlightMode( TBool aEnabled ); + /** + * set startup count + * @param aStartupCount number of app startups + */ + void SetStartupCount( const TInt aStartupCount ); + /** + * return startup count + * @return number of app startups + */ + TInt StartupCount() const; + + /** + * Set rds af search enabled. + * @return none + */ + void SetRdsAfSearchEnabled(); + /** + * Set rds af search disabled. + * @return none + */ + void SetRdsAfSearchDisabled(); + /** + * Set Japan region support on/off. + * @param aAllowed true/false + * @return none + */ + void SetJapanRegionAllowed( const TBool aAllowed ); + /** + * Return status of the Japan region support + * @return ETrue if supported + */ + TBool IsJapanRegionAllowed() const; + + private: + /// current headset volume level + TInt iFMRadioHeadsetVolume; + /// current speaker volume level + TInt iFMRadioSpeakerVolume; + /// currently selected channel. + TInt iCurrentPreset; + /// current frequency + TInt iFrequency; + // max frequency + TUint32 iMaxFrequency; + // min frequency + TUint32 iMinFrequency; + // step size + TUint32 iFrequencyStepSize; + // decimal count + TInt iDecimalCount; + /// stereo or mono + CRadioEngine::TFMRadioAudioMode iAudioMode; + /// audio output + CRadioEngine::TFMRadioAudioOutput iAudioOutput; + /// current mute state + TBool iMuteOn; + // radio on/off flag + TBool iRadioOn; + /// preset or direct frequency flag + CRadioEngine::TRadioMode iRadioMode; + /// headset connected flag + TBool iIsHeadsetConnected; + /// flight mode enabled flag + TBool iFlightModeEnabled; + // first startup case flag + TInt iStartupCount; + // rds af search enabled flag + TBool iRdsAfSearchEnabled; + // Japan region support flag + TBool iJapanRegionAllowed; + + }; + +#endif // FMRADIOSETTINGS_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioengineradiostatehandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioengineradiostatehandler.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,96 @@ +/* +* 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 class implements functions handling radio engine state changes +* +*/ + + +#ifndef FMRADIOENGINERADIOSTATEHANDLER_H +#define FMRADIOENGINERADIOSTATEHANDLER_H + +//INCLUDES +#include "fmradioenginestatechangecallback.h" + +// CONSTANTS +const TUint8 KRadioStateEventCallback = 0x01; + +// FORWARD DECLARATIONS +class CRadioEngine; + + +// CLASS DECLARATION +/** +* This class implements the state machines for radio engine state transition. +*/ +class CRadioStateHandler : public CActive + { + public: + /** + * Method for creating new instances of this class. + * @param aEngine a pointer to CRadioEngine + * @return - A pointer to new CRadioEngineTimer object + **/ + static CRadioStateHandler *NewL(CRadioEngine* aEngine); + /** + * Destructor + **/ + virtual ~CRadioStateHandler(); + public: + /** + * Trigger the active object to call the client callback function. + * @since Series 60 2.7 + * @return none + */ + void Callback(MRadioEngineStateChangeCallback::TFMRadioNotifyEvent aEventCode, TInt aErrorCode ); + private: + /** + * c++ default constructor + **/ + CRadioStateHandler(CRadioEngine* aEngine); + /** + * 2nd phase constructor + **/ + void ConstructL(); + /** + * Cancel the timeout timer. This generally means that a response was received from the chip, so the + * timeout is no longer needed or the state machine was transitioned. + * @since Series 60 2.7 + * @return none + **/ + void DoCancel(); + /** + * State Change Request/timeout handler + * @since Series 60 2.7 + * @return none + */ + void RunL(); + /** + * handle any errors that occur in the RunL + * @since Series 60 2.7 + * @return none + */ + TInt RunError( TInt aError ); + private: + // pointer to the session who's timeout we are mananging. + CRadioEngine* iEngine; + // Temporary storage for event code + TInt iCallbackEventCode; + // Temporary storage for error code + TInt iCallbackErrorCode; + + }; // FMRADIOENGINERADIOSTATEHANDLER_H + +// End of File + +#endif diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioenginestatechangecallback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioenginestatechangecallback.h Tue Feb 02 00:17:10 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: Declaration of a simple interface to integrate the FM Radio +* application engine and Ui. +* Ui is derived from this class and Ui implements +* the virtual method HandleRadioEngineCallBackL in class +* CFMRadioAppUi. Radio engine then calls this virtual function +* when it needs to pass information i.e. about its changed +* state where Ui must react to. The traffic between Ui and +* engine goes like: +* Ui::RequestToEngine() -> Engine() -> Ui::DoAndShowItAndUpdateState() +* +*/ + + +#ifndef FMRADIOENGINESTATECHANGECALLBACK_H +#define FMRADIOENGINESTATECHANGECALLBACK_H + +// Class declaration + +/** +* It is interface to integrate the FM Radio +* application engine and Ui. +* @lib FMRadioEngine.lib +* @since Series 60 2.7 +*/ +class MRadioEngineStateChangeCallback +{ + public: + /** + * Event codes for identifying the event that + * caused the change in engine's internal state. + * Also, the possible error context is determined + * from the event code. See the TFMRadioErrorCode + * decalaration below for further information. + */ + enum TFMRadioNotifyEvent + { + // Radio functionality events + EFMRadioEventNone = 0x00, + EFMRadioEventTunerReady, + EFMRadioEventRadioOn, + EFMRadioEventRadioOff, + EFMRadioEventTune, + EFMRadioEventVolumeUpdated, + EFMRadioEventSetAudioMode, + EFMRadioEventSetAudioOutput, + EFMRadioEventHeadsetDisconnected, + EFMRadioEventHeadsetReconnected, + EFMRadioEventButtonPressed, + EFMRadioEventFlightModeEnabled, + EFMRadioEventFlightModeDisabled, + EFMRadioEventStandbyMode, + EFMRadioEventSetMuteState, + EFMRadioEventAudioResourceAvailable, + EFMRadioEventAudioResourcePaused, + EFMRadioEventAudioResourceLost, + EFMRadioEventCallStarted, + EFMRadioEventCallEnded, + EFMRadioEventFMRadioInitialized, + EFMRadioEventFMTransmitterOn, + EFMRadioEventFreqRangeChanged, + EFMRadioEventRDSNotSupported, + EFMRadioEventScanLocalStationsCanceled + + }; + public: + /** + * Interface method to get the callback from the + * radio engine to radio Ui. + * + * @param aEventCode Predefined code of the event which + * caused the change in engine's internal state. + * @param aErrorCode Predefined code of the error if + * one was generated. If no errors, value is 0x00 (NULL). + * @return none + */ + virtual void HandleRadioEngineCallBack(TFMRadioNotifyEvent aEventCode, TInt aErrorCode ) = 0; +}; + +#endif //FMRADIOENGINESTATECHANGECALLBACK_H + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioheadseteventobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioheadseteventobserver.h Tue Feb 02 00:17:10 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: headset event observer interface +* +*/ + + +#ifndef MFMRADIOHEADSETEVENTOBSERVER_H +#define MFMRADIOHEADSETEVENTOBSERVER_H + + +// CLASS DECLARATION + +class MFMRadioHeadsetEventObserver + { + + public: // New functions + + /** + * This callback will notify of the Headset to be connected + */ + virtual void HeadsetAccessoryConnectedCallbackL() = 0; + + /** + * This callback will notify of the Headset to be disconnected + */ + virtual void HeadsetAccessoryDisconnectedCallbackL() = 0; + }; + +#endif // MFMRADIOHEADSETEVENTOBSERVER_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiointernalpskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiointernalpskeys.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,298 @@ +/* +* 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: P&S data for FMRadio +* +*/ +#ifndef FMRADIOINTERNALPSKEYS_H +#define FMRADIOINTERNALPSKEYS_H + +#include +#include + +// FMRadio Application UID +const TUid KFMRadioPSUid = { KUidFMRadioApplication }; + +/////////////////////////////////////////////////////////////////////////////////////////////////////// +/// /// +/// Data properties. These properties are published by fmradio and used by other applications. /// +/// /// +/////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** +* Currently active channel's ID. +* Value KErrNotFound means that no preset channel is active. +* Type RProperty::EInt. +*/ +const TUint32 KFMRadioPSDataChannel = 0x00000000; + +/** +* Currently active frequency. +* Frequency unit is in kHz. +* Type RProperty::EInt. +*/ +const TUint32 KFMRadioPSDataFrequency = 0x00000001; + +/** +* Current power state of the radio. +* Type RProperty::EInt. +* @see TFMRadioPSRadioPowerState. +*/ +const TUint32 KFMRadioPSDataRadioPowerState = 0x00000002; + +/** +* Power state of the radio. +*/ +enum TFMRadioPSRadioPowerState + { + EFMRadioPSRadioPowerStateUninitialized, /**< The key is not yet initialized. */ + EFMRadioPSRadioPowerOn, /**< Radio power on. */ + EFMRadioPSRadioPowerOff /**< Radio power off. */ + }; + +/** +* Current volume level. +* Scale is from 1-10. +* Type RProperty::EInt. +*/ +const TUint32 KFMRadioPSDataVolume = 0x00000003; + +/** +* Changing of this value means that channel +* data of specified channel ID has changed. +* The value remains indicating the last changed channel ID. +* Value KErrNone means that no channel data has been changed yet. +* Type RProperty::EInt. +*/ +const TUint32 KFMRadioPSDataChannelDataChanged = 0x00000004; + +/** +* The current tuning state. +* Type RProperty::EInt. +* @see TFMRadioPSTuningState. +*/ +const TUint32 KFMRadioPSDataTuningState = 0x00000006; + +/** +* Possible tuning states. +*/ +enum TFMRadioPSTuningState + { + EFMRadioPSTuningUninitialized, /**< Currently not tuning. */ + EFMRadioPSTuningStarted, /**< Tuning has been started an lasted less than one second. */ + EFMRadioPSTuningContinues /**< Tuning has taken more than one second. */ + }; + +/** +* Current mute state of radio. +* Type RProperty::EInt. +* @see TFMRadioPSRadioMuteState. +*/ +const TUint32 KFMRadioPSDataRadioMuteState = 0x00000007; + +/** +* Mute state of radio. +*/ +enum TFMRadioPSRadioMuteState + { + EFMRadioPSMuteStateUninitialized, /**< The key has not yet been initialized. */ + EFMRadioPSMuteStateOn, /**< Radio mute state is on. */ + EFMRadioPSMuteStateOff /**< Radio mute state is off. */ + }; + +/** +* Indicates if FM Radio is running or closing. +* Type RProperty::EInt. +* @see TFMRadioPSApplicationRunningState. +*/ +const TUint32 KFMRadioPSDataApplicationRunning = 0x00000008; + +/** +* FM Radio application running states. +*/ +enum TFMRadioPSApplicationRunningState + { + EFMRadioPSApplicationUninitialized, /**< FM Radio application's state is not yet initialized. */ + EFMRadioPSApplicationRunning, /**< FM Radio application is running. */ + EFMRadioPSApplicationClosing /**< FM Radio application is closing. */ + }; + +/** +* Indicates the current antenna connectivity status. +* Type RProperty::EInt. +* @see TFMRadioPSHeadsetStatus +*/ +const TUint32 KFMRadioPSDataHeadsetStatus = 0x00000009; + +/** +* Current antenna status. +*/ +enum TFMRadioPSHeadsetStatus + { + EFMRadioPSHeadsetUninitialized, /**< The antenna status is uninitialized. */ + EFMRadioPSHeadsetDisconnected, /**< The antenna is disconnected. */ + EFMRadioPSHeadsetConnected /**< The antenna is connected. */ + }; + +/** +* The current frequency decimal count. +* Type RProperty::EInt. +* @see TFMRadioPSFrequencyDecimalCount. +*/ +const TUint32 KFMRadioPSDataFrequencyDecimalCount = 0x00000010; + +/** +* The current frequency decimal count. +*/ +enum TFMRadioPSFrequencyDecimalCount + { + EFMRadioPSFrequencyDecimalCountUninitialized, /**< Frequency decimal count has not yet been initialized. */ + EFMRadioPSFrequencyOneDecimal, /**< Frequency accuracy is one decimal. */ + EFMRadioPSFrequencyTwoDecimals, /**< Frequency accuracy is two decimals. */ + EFMRadioPSFrequencyThreeDecimals /**< Frequency accuracy is three decimals. */ + }; + +/** +* Current moving state of application. +* Note that even if user activates the moving state, +* the move can be still canceled. +* Type RProperty::EInt. +* @see TFMRadioPSMovingState +*/ +const TUint32 KFMRadioPSDataMovingState = 0x00000011; + +/** +* The current moving state. +*/ +enum TFMRadioPSMovingState + { + EFMRadioPSMovingStateUninitialized, /**< Moving state is uninitialized. */ + EFMRadioPSMovingStateOn, /**< User has activated moving state. */ + EFMRadioPSMovingStatePerforming, /**< User has performed a channel move. */ + EFMRadioPSMovingStateOff /**< Moving state is off. */ + }; + +/** +* Flag to indicate if we're connected to the network. +*/ +const TUint32 KFMRadioPSDataNetworkConnected = 0x00000014; + +/** +* Flag to indicate if loudspeaker is in use +*/ +const TUint32 KFMRadioPSDataLoudspeakerStatus = 0x00000015; +/** +* Current speaker status. +*/ +enum TFMRadioPSLoudspeakerStatus + { + EFMRadioPSLoudspeakerUninitialized, /**< The speaker status is uninitialized. */ + EFMRadioPSLoudspeakerNotInUse, /**< The speaker is not in use. */ + EFMRadioPSLoudpeakerInUse /**< The speaker is in use. */ + }; + +/** +* RDS Program Service information, property type is text. +*/ + +const TUint32 KFMRadioPSDataRDSProgramService = 0x00000016; + +/** +* RDS Radio Text information. +* Type RProperty::EText. +*/ +const TUint32 KFMRadioPSDataRDSRadioText = 0x00000017; + +/** + * Name of the current channel. + * Type RProperty::EText. + */ +const TUint32 KFMRadioPSDataChannelName = 0x00000018; + + +////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// /// +/// Control properties. These properties are published by other applications and used by FMRadio. /// +/// /// +////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** +* Sets mute state on or off. +* Type RProperty::EInt. +* @see TFMRadioPSRadioMuteState. +*/ +const TUint32 KFMRadioPSControlSetRadioMuteState = 0x00001006; + + +/** +* Increases or decreases volume level. +* Type RProperty::EInt. +* @see TFMRadioPSAdjustVolume. +*/ +const TUint32 KFMRadioPSControlAdjustVolume = 0x00001005; + +/** +* Volume step direction. +*/ +enum TFMRadioPSAdjustVolume + { + EFMRadioPSAdjustVolumeUninitialized = 0, /**< The key has not yet been initialized. */ + EFMRadioPSIncreaseVolume, /**< Increase volume. */ + EFMRadioPSDecreaseVolume /**< Decrease volume. */ + }; + +////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// /// +/// Control properties. These properties are published by other applications and used by FM Radio. /// +/// /// +////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** +* Steps up or down a channel in channel list. +* Type RProperty::EInt. +* @see TFMRadioPSStepToChannel. +*/ +const TUint32 KFMRadioPSControlStepToChannel = 0x00001000; + +/** +* Step direction of channel step. +*/ +enum TFMRadioPSStepToChannel + { + EFMRadioPSStepToChannelUninitialized, /**< Value of the key has not yet been initialized. */ + EFMRadioPSStepToChannelUp, /**< Step to next channel up. */ + EFMRadioPSStepToChannelDown /**< Step to next channel down. */ + }; + +/** +* Seeks to next active frequency up or down. +* Type RProperty::EInt. +* @see TFMRadioPSSeek. +*/ +const TUint32 KFMRadioPSControlSeek = 0x00001002; + +/** +* Seek direction. +*/ +enum TFMRadioPSSeek + { + EFMRadioPSSeekUninitialized, /**< Value of the key has not yet been initialized. */ + EFMRadioPSSeekUp, /**< Seek up. */ + EFMRadioPSSeekDown /**< Seek down. */ + }; + +const TUint32 KFMRadioActiveIdlePresetListCount = 0x00001003; +const TUint32 KFMRadioActiveIdlePresetListFocus = 0x00001004; + + +#endif diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiomobilenetworkinfolistener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiomobilenetworkinfolistener.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,130 @@ +/* +* 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: Header file for CFMRadioMobileNetworkInfoListener. +* +*/ + + +#ifndef FMRADIOMOBILENETWORKINFOLISTENER_H +#define FMRADIOMOBILENETWORKINFOLISTENER_H + +#include +#include + + +const TInt KFMRadioCREmulatorCountryCodeLength = 3; +namespace CommsDat { class CCDIAPRecord; } + +class MFMRadioNetworkChangeObserver; +/** + * Listens changes in network ID and country code. + * + * @ingroup Utils + */ +NONSHARABLE_CLASS(CFMRadioMobileNetworkInfoListener) : public CActive + { +public: + + /** + * Creates a new mobile network info listener. + * @return The newly created mobile network info listener. + */ + static CFMRadioMobileNetworkInfoListener* NewL( + MFMRadioNetworkChangeObserver & aObserver); + + /** + * Destructor. + */ + ~CFMRadioMobileNetworkInfoListener(); + + /** + * Return current combined network ID and country code as TInt. + * @return An integer composed of the current network ID and country code. + */ + TInt CompoundNetworkId() const; + + /** + * Returns current country code. + * @return The current country code. + */ + const TDesC& CountryCode() const; + + /** + * SubscriberId + * @return subscriber id + */ + const TDesC& SubscriberId() const; + +private: + + /** + * Constructor. + */ + CFMRadioMobileNetworkInfoListener(MFMRadioNetworkChangeObserver & aObserver); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Saves fetched network info to local variables. + */ + void SaveNetworkInfo(); + +#ifdef __WINS__ + /** + * Gets network info from Central Repository. + */ + void GetCenRepNetworkInfoL(); +#endif + +// from base class CActive + void RunL(); + void DoCancel(); + +private: // Data + + /** interface to report a condition when network id has changed */ + MFMRadioNetworkChangeObserver & iNetworkChangeObserver; +#ifdef __WINS__ + /** Central repository */ + CRepository* iRepository; + /** Network info from repository */ + HBufC* iEmulatorNetworkInfo; +#else + /** Telephony server. */ + RTelServer iTelServer; + /** Mobile phone. */ + RMobilePhone iPhone; + /** Network info of mobile phone. */ + RMobilePhone::TMobilePhoneNetworkInfoV1 iNetworkInfo; + /** Location of mobile phone. */ + RMobilePhone::TMobilePhoneLocationAreaV1 iLocation; + /** Packaged network info object. */ + RMobilePhone::TMobilePhoneNetworkInfoV1Pckg iNetworkInfoPckg; +#endif + /** Current network ID. */ + RMobilePhone::TMobilePhoneNetworkIdentity iNetworkId; + /** Current country code. */ + RMobilePhone::TMobilePhoneNetworkCountryCode iCountryCode; + /** Combined network ID and country code. */ + TInt iCompoundNetworkId; + /** Previous known non-null combined country code */ + TInt iPreviousCompoundNetworkId; + /** Subsriber (IMSI code) id that has been picked up at the startup */ + HBufC* iSubscriberId; + }; + +#endif // FMRADIOMOBILENETWORKINFOLISTENER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradionetworkchangeobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradionetworkchangeobserver.h Tue Feb 02 00:17:10 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: An interface for notifying about network id changes +* +*/ +/** + * An interface for notifying about network id changes + */ +class MFMRadioNetworkChangeObserver + { + +public: + + /** + * Used for notifying that the network id has changed + */ + virtual void NetworkIdChanged() = 0; + }; diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiopropertyobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiopropertyobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,264 @@ +/* +* 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: Abstract interface for handling property change events. +* +*/ + + +#ifndef CFMRADIOPROPERTYOBSERVER_H +#define CFMRADIOPROPERTYOBSERVER_H + +#include +#include + +/** + * MFMRadioPropertyChangeObserver + * + * Abstract interface for handling property change events. + */ +class MFMRadioPropertyChangeObserver +{ + +public: + + /** + * This is a callback function which is called when a property value of + * type int is changed. + * + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * + * @param aValue the new value + */ + virtual void HandlePropertyChangeL( + const TUid& aCategory, + const TUint aKey, + const TInt aValue ) = 0; + + /** + * This is a callback function which is called when a property value of + * type text is changed. + * + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * @param aValue the new value + **/ + virtual void HandlePropertyChangeL( + const TUid& aCategory, + const TUint aKey, + const TDesC& aValue ) = 0; + + /** + * This is a callback function which is called when a property value of + * type byte array is changed. + * + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * @param aValue the new value + **/ + virtual void HandlePropertyChangeL( + const TUid& aCategory, + const TUint aKey, + const TDesC8& aValue ) = 0; + + /** + * This is a callback function which is called when a P&S components + * returns an error + * + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event + * @param aError an error code + */ + virtual void HandlePropertyChangeErrorL( + const TUid& aCategory, + const TUint aKey, + TInt aError) = 0; +}; + + + +/** + * Observer class that observes changes of Property values and propogates + * them further. + * The class defines a handle to a property, a single data value representing + * an item of state information. + * + */ + class CFMRadioPropertyObserver : public CActive + { + + public: + + /** + * Property type. Cannot use RProperty::TType because EByteArray == EText. + */ + enum TFMRadioPropertyType + { + EFMRadioPropertyInt, // Integral property type. + EFMRadioPropertyByteArray, // Byte-array (8 bit), max size 512 bytes + EFMRadioPropertyText // Text (16 bit), max size 512 bytes + }; + + /** + * Two-phased constructor. + * + * @param aObserver a reference to the observer interface implementer + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * @param aPropertyType property type to observe + */ + static CFMRadioPropertyObserver* NewL( + MFMRadioPropertyChangeObserver& aObserver, + const TUid& aCategory, + const TUint aKey, + const TFMRadioPropertyType aPropertyType); + + /** + * Two-phased constructor. + * + * @param aObserver a reference to the observer interface implementer + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * @param aPropertyType property type to observe + */ + static CFMRadioPropertyObserver* NewLC( + MFMRadioPropertyChangeObserver& aObserver, + const TUid& aCategory, + const TUint aKey, + const TFMRadioPropertyType aPropertyType); + + /** + * Destructor. + */ + ~CFMRadioPropertyObserver(); + + /** + * Subscribes the object to listen to the specified key. Does nothing if already active. + * Must be called after construction, or after calling Cancel(). + */ + void ActivateL(); + + /** + * Returns current integer property value + * @param aUpdate ETrue if the cache value should be updated + * + * @return int value + */ + TInt ValueInt( TBool aUpdate = EFalse ); + + /** + * Returns current byte array property value + ** @param aUpdate ETrue if the cache value should be updated + * + * @return byte array value + */ + const TDesC8& ValueDes8( TBool aUpdate = EFalse ); + + /** + * Returns current text property value + * * @param aUpdate ETrue if the cache value should be updated + * + * @return text value + */ + const TDesC& ValueDes( TBool aUpdate = EFalse ); + +private: + + /** + * C++ default constructor overload. + * Two-phased constructor. + * + * @param aObserver a reference to the observer interface implementer + * @param aCategory UID of Publish And Subscribe category + * @param aKey subkey to specify the category event; to be used with + * Publish And Subscribe + * @param aPropertyType property type to observe + */ + CFMRadioPropertyObserver( + MFMRadioPropertyChangeObserver& aObserver, + const TUid& aCategory, + const TUint aKey, + const TFMRadioPropertyType aPropertyType); + + /** + * By default Symbian 2nd phase constructor is private. + **/ + void ConstructL(); + + // from base class Cactive + /** + * From CActive + * + * @see CActive::RunL() + */ + void RunL(); + + /** + * From CActive, + * + * @see CActive::DoCancel() + */ + void DoCancel(); + +private: // data + + /** + * Value of a subscribed category property of type int. + */ + TInt iValueInt; + + /** + * Value of a subscribed category property of type byte array. + */ + HBufC8* iValueByteArray; + + /** + * Value of a subscribed category property of type text. + */ + HBufC* iValueText; + + /** + * Handle to Publish And Subscribe component + */ + RProperty iProperty; + + /** + * Observer to be notified when particular Property value has changed + */ + MFMRadioPropertyChangeObserver& iObserver; + + /** + * UID of Publish And Subscribe category + */ + TUid iCategory; + + /** + * Subkey to be used with Publish And Subscribe + */ + TUint iKey; + + /** + * Type of the observed property. + */ + TFMRadioPropertyType iPropertyType; + + }; + +#endif // CFMRADIOPROPERTYOBSERVER_H + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiopubsub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiopubsub.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,219 @@ +/* +* 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: Header file for CFMRadioPubSub +* +*/ + + +#ifndef CFMRADIOPUBSUB_H +#define CFMRADIOPUBSUB_H + +#include + +#include "fmradiopropertyobserver.h" + +class MFMRadioControlEventObserver; + +/** + * Publish&Subscribe interface of FMRadioEngine + */ +class CFMRadioPubSub : + public CBase, + public MFMRadioPropertyChangeObserver + { + +public: // Methods + + /** + * Static constructor. + */ + static CFMRadioPubSub* NewL(); + + /** + * Destructor. + */ + virtual ~CFMRadioPubSub(); + + /** + * Publishes active channel number to P&S. + * + * @param aChannelId The channel ID to publish. + */ + void PublishChannelL( TInt aChannelId ) const; + + /** + * Publishes active frequency to P&S. + * + * @param aFreq The frequency to publish. + */ + IMPORT_C void PublishFrequencyL( TUint32 aFreq ) const; + + /** + * Publishes radio power state to P&S. + * + * @param aPowerOn The radio power state to publish. + */ + IMPORT_C void PublishStateL( TBool aPowerOn ) const; + + /** + * Publishes current volume level to P&S. + * + * @param aVol The current volume level to publish. + */ + void PublishVolumeL( TInt aVol ) const; + + /** + * Publishes changed channel number to P&S. + * + * @param aChannelId The channel ID to publish. + */ + void PublishChannelDataChangedL(TInt aChannelId) const; + + /** + * Publishes the tuning state to P&S. + * @param aTuningState The tuning state to publish. + */ + void PublishTuningStateL( TFMRadioPSTuningState aTuningState ) const; + + /** + * Publishes radio mute state to P&S. + * + * @param aMuted The radio mute state to publish. + */ + void PublishRadioMuteStateL( TBool aMuted ) const; + + /** + * Publishes application running state to P&S. + * + * @param aRunningState The application running state. + */ + IMPORT_C void PublishApplicationRunningStateL( + TFMRadioPSApplicationRunningState aRunningState ) const; + + /** + * Publishes the antenna status to P&S. + * + * @param aAntennaStatus The antenna's status. + */ + void PublishAntennaStatusL( TFMRadioPSHeadsetStatus aAntennaStatus ) const; + + /** + * Publishes the frequency decimal count to P&S. + * @param aDecimalCount The decimal count. + */ + void PublishFrequencyDecimalCountL( + TFMRadioPSFrequencyDecimalCount aDecimalCount ) const; + + /** + * Publishes speaker status. Before state is set for first time it is in + * EFMRadioPSLoudspeakerUninitialized state. + * + * @param aLoudspeakerStatus Status of the speaker + */ + void PublishLoudspeakerStatusL( TFMRadioPSLoudspeakerStatus aLoudspeakerStatus ) const; + + /** + * Publishes RDS Program Service information. + * + * @param aProgramService Service text + */ + IMPORT_C void PublishRDSProgramServiceL( const TDesC& aProgramService ) const; + IMPORT_C void PublishRDSRadioTextL( const TDesC& aRadioText ) const; + IMPORT_C void PublishChannelNameL( const TDesC& aName ) const; + + IMPORT_C void PublishPresetCountL( TInt aVal ) const; + +// from base class MFMRadioPropertyChangeObserver + void HandlePropertyChangeL( const TUid& aCategory, const TUint aKey, const TInt aValue ); + void HandlePropertyChangeL( const TUid& aCategory, const TUint aKey, const TDesC8& aValue ); + void HandlePropertyChangeL( const TUid& aCategory, const TUint aKey, const TDesC& aValue ); + void HandlePropertyChangeErrorL( const TUid& aCategory, const TUint aKey, TInt aError ); + + /** + * Sets the UI side control event observer. + * @param aControlEventObserver the observer for control events + */ + IMPORT_C void SetControlEventObserver( MFMRadioControlEventObserver* aControlEventObserver ); + +private: //Methods + + /** + * C++ default constructor. + */ + CFMRadioPubSub(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Defines a property. + * + * @param aKey The key of the property. + * @param aAttr Attributes of the property. + * @param aDataProperty ETrue if the property is a data property, EFalse + * if it is a control property + */ + void DefinePropertyL( + TUint aKey, + TInt aAttr, + TBool aDataProperty ) const; + + /** + * Deletes a property. + * + * @param aKey The key of the property. + */ + void DeleteProperty( TUint aKey ) const; + + /** + * Gets the integer value stored in a property. + * + * @param aKey The key of the property. + * @return The value contained in the property. + */ + TInt PropertyValueIntL( TUint aKey ) const; + + /** + * Sets the value in an integer property. + * + * @param aKey The key of the property. + * @param aValue The value to set. + */ + void SetPropertyValueL( TUint aKey, TInt aValue ) const; + + /** + * Sets the value in a text property. + * + * @param aKey The key of the property. + * @param aValue The value to set. + */ + void SetPropertyValueL( TUint aKey, const TDesC& aValue ) const; + +private: // Data + + /** + * Pointer to observer in UI side, can be NULL. Not owned. + */ + MFMRadioControlEventObserver* iObserver; + + /** + * An array of handlers to P&S interface. + */ + RPointerArray iPropertyArray; + + }; + +#endif // CFMRADIOPUBSUB_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiordsobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiordsobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,83 @@ +/* +* 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: Observer interface for RDS events +* +*/ + + +#ifndef MFMRADIORDSOBSERVER_H +#define MFMRADIORDSOBSERVER_H + +class MFMRadioRdsObserver + { +public: + + /** + * Programme Service data available + * + * @param aProgramService The new Programme Service data + */ + virtual void RdsDataProgrammeService( const TDesC& aProgramService ) = 0; + + /** + * Reports if the programme service name is detected as dynamically changing or not + * + * @param aStatic ETrue if the name is static, EFalse if it is dynamic + */ + virtual void RdsDataPsNameIsStatic( TBool aStatic ) = 0; + + /** + * Radio text data available + * + * @param aRadioText The new Radio text data + */ + virtual void RdsDataRadioText( const TDesC& aRadioText ) = 0; + + /** + * Radio text plus data available + * + * @param aRTPlusClass The type of RT+ text + * @param aRadioTextPlus The new Radio text data + */ + virtual void RdsDataRadioTextPlus( const TInt aRTPlusClass, const TDesC& aRadioTextPlus ) = 0; + + /** + * Notifies of the beginning of Alternate Frequency search + */ + virtual void RdsAfSearchBegin() = 0; + + /** + * Notifies of the completed Alternate Frequency search + * + * @param aFrequency The new frequency + * @param aError A standard system error code + */ + virtual void RdsAfSearchEnd( TUint32 aFrequency, TInt aError ) = 0; + + /** + * Notifies of the changed Alternate Frequency search state + * + * @param aEnabled ETrue if AF search was enabled, otherwise EFalse + */ + virtual void RdsAfSearchStateChange( TBool aEnabled ) = 0; + + /** + * Notifies of the status of RDS signal + * + * @param aAvailable is RDS available + */ + virtual void RdsAvailable( TBool aAvailable ) = 0; + }; + +#endif // MFMRADIORDSOBSERVER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiordsreceiver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiordsreceiver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,71 @@ +/* +* 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: The RDS receiver implementation for FM Radio +* +*/ + + +#ifndef CFMRADIORDSRECEIVER_H +#define CFMRADIORDSRECEIVER_H + +#include "fmradioengineradiosettings.h" +#include "fmradiordsobserver.h" +#include "fmradiordsreceiverbase.h" + +NONSHARABLE_CLASS( CFMRadioRdsReceiver ) : public CFMRadioRdsReceiverBase + { +public: + + /** + * The two-phased constructor + * + * @param aSettings The radio settings + */ + static CFMRadioRdsReceiver* NewL( TRadioSettings& aSettings ); + + /** + * The destructor + */ + virtual ~CFMRadioRdsReceiver(); + + // from CFMRadioRdsReceiverBase + void InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub ); + void SetAutomaticSwitchingL( TBool aEnable ); + void StartReceiver(); + void StopReceiver(); + +private: + + /** + * The default constructor + * + * @param aSettings The radio settings + */ + CFMRadioRdsReceiver( TRadioSettings& aSettings ); + + /** + * Second phase constructor + */ + void ConstructL(); + +private: // data + + /** The RDS utility */ + CRadioRdsUtility* iRdsUtility; + + /** State of the RDS receiver */ + TBool iStarted; + }; + +#endif // CFMRADIORDSRECEIVER_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiordsreceiverbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiordsreceiverbase.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,236 @@ +/* +* 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: The RDS receiver base class for FM Radio +* +*/ + + +#ifndef CFMRADIORDSRECEIVERBASE_H +#define CFMRADIORDSRECEIVERBASE_H + +#include + +#include "fmradiordsobserver.h" + +class TRadioSettings; +class CRadioUtility; +class CFMRadioPubSub; + +NONSHARABLE_CLASS( CFMRadioRdsReceiverBase ) : public CBase, public MRadioRdsObserver + { +public: + + enum TFMRadioProgrammeSeviceType + { + EFMRadioPSNameStaticAssumed = 0,// Default, determination is ongoing + EFMRadioPSNameStatic, // PS name is static + EFMRadioPSNameDynamic // PS name is dynamic + }; + + /** + * The destructor + */ + virtual ~CFMRadioRdsReceiverBase(); + + /** + * Initializes the RDS receiver + * + * @param aRadioUtility A reference to the radio utility + * @param aPubSub Pointer to Publish&Subscribe object + */ + virtual void InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub ) = 0; + + /** + * Adds an observer wich will be notified of the new RDS data + * If observer already exists, it is not added + * + * @param aObserver pointer of the observer instance. + */ + IMPORT_C void AddObserver(MFMRadioRdsObserver* aObserver); + + /** + * Removes the rds observer. + */ + IMPORT_C void RemoveObserver(MFMRadioRdsObserver* aObserver); + + /** + * Getter for automatic switching state of alternate frequencies + * + * @return ETrue if automatic switching is enabled + */ + IMPORT_C TBool AutomaticSwitchingEnabled() const; + + /** + * Getter for the programme service name + * + * @return Programme service name + */ + IMPORT_C const TDesC& ProgrammeService() const; + + /** + * Returns the nature of the PS name + * + * @return The type of PS name + */ + IMPORT_C TFMRadioProgrammeSeviceType ProgrammeServiceNameType() const; + + /** + * Getter for the RDS signal availability + * + * @return ETrue if RDS signal is available, otherwise EFalse + */ + IMPORT_C TBool SignalAvailable() const; + + /** + * Getter for the RDS Text+ station URL + * @return The cached web URL of the station + */ + IMPORT_C const TDesC& RtPlusProgramUrl() const; + + /** + * Getter for the RDS Text+ artist name + * @return The cached artist name + */ + IMPORT_C const TDesC& RtPlusArtist() const; + + /** + * Getter for the RDS Text+ album name + * @return The cached album name + */ + IMPORT_C const TDesC& RtPlusAlbum() const; + + /** + * Getter for the RDS Text+ song name + * @return The cached song name + */ + IMPORT_C const TDesC& RtPlusSong() const; + + /** + * Setter for automatic switching of alternate frequencies + * If this method is overridden, the base implementation should be called + * + * @param aEnable ETrue, if automatic swithing is to be enabled + */ + virtual void SetAutomaticSwitchingL( TBool aEnable ); + + /** + * Clears the RDS information + */ + void ClearRdsInformation(); + + /** + * Starts receiving the RDS information + */ + virtual void StartReceiver() = 0; + + /** + * Stops receiving the RDS information + */ + virtual void StopReceiver() = 0; + +protected: + + /** + * The default constructor + * + * @param aSettings The radio settings + */ + CFMRadioRdsReceiverBase( TRadioSettings& aSettings ); + + /** + * Second phase constructor + */ + void BaseConstructL(); + + /** + * Static callback for the RDS PS name timer + * + * @param aSelf Pointer to self. + * @return KErrNone + */ + static TInt StaticPsNameTimerCallback( TAny* aSelf ); + + /** + * Handles the received RT+ data and passes it to observers + * @param aRtPlusClass The RT+ class + * @param aRtPlusData The received data + */ + void HandleRdsDataRTplusL( TRdsRTplusClass aRtPlusClass, TRdsRadioText& aRtPlusData ); + +// from base class MRadioRdsObserver + void MrroStationSeekByPTYComplete( TInt aError, TInt aFrequency ); + void MrroStationSeekByTAComplete( TInt aError, TInt aFrequency ); + void MrroStationSeekByTPComplete( TInt aError, TInt aFrequency ); + void MrroGetFreqByPTYComplete( TInt aError, RArray& aFreqList ); + void MrroGetFreqByTAComplete( TInt aError, RArray& aFreqList ); + void MrroGetPSByPTYComplete( TInt aError, RArray& aPsList ); + void MrroGetPSByTAComplete( TInt aError, RArray& aPsList ); + void MrroRdsDataPI( TInt aPi ); + void MrroRdsDataPTY( TRdsProgrammeType aPty ); + void MrroRdsDataPS( TRdsPSName& aPs ); + void MrroRdsDataRT( TRdsRadioText& aRt ); + void MrroRdsDataCT( TDateTime& aCt ); + void MrroRdsDataTA( TBool aTaOn ); + void MrroRdsDataRTplus( TRdsRTplusClass aRtPlusClass, TRdsRadioText& aRtPlusData ); + void MrroRdsSearchBeginAF(); + void MrroRdsSearchEndAF( TInt aError, TInt aFrequency ); + void MrroRdsStationChangeTA( TInt aFrequency ); + void MrroRdsEventAutomaticSwitchingChange( TBool aAuto ); + void MrroRdsEventAutomaticTrafficAnnouncement( TBool aAuto ); + void MrroRdsEventSignalChange( TBool aSignal ); + +protected: // data + /** The radio settings */ + TRadioSettings& iSettings; + + /** Publish&Subscribe object. Can be NULL. Not owned. */ + CFMRadioPubSub* iPubSub; + +private: // data + + /** Array of RDS observers. */ + RPointerArray iObservers; + + /** The programme service name cache */ + HBufC* iPsName; + + /** The radio text data cache */ + HBufC* iRadioText; + + /** The cached web URL of the station */ + RBuf iProgramWebUrl; + + /** The cached artist name */ + RBuf iArtistName; + + /** The cached song name */ + RBuf iSongName; + + /** The cached album name */ + RBuf iAlbumName; + + /** ETrue if the RDS signal is available */ + TBool iSignalAvailable; + + /** ETrue if AF is enabled */ + TBool iAfEnabled; + + /** Timer to track the PS name changes */ + CPeriodic* iPsNameTimer; + + /** The type of the PS name */ + TFMRadioProgrammeSeviceType iPsNameType; + }; + +#endif // CFMRADIORDSRECEIVERBASE_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiordsreceiversimulator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiordsreceiversimulator.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,106 @@ +/* +* 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: The RDS receiver simulator for FM Radio +* +*/ + + +#ifndef CFMRADIORDSRECEIVERSIMULATOR_H +#define CFMRADIORDSRECEIVERSIMULATOR_H + +#include "fmradioengineradiosettings.h" +#include "fmradiordsobserver.h" +#include "fmradiordsreceiverbase.h" + +NONSHARABLE_CLASS( CFMRadioRdsReceiverSimulator ) : public CFMRadioRdsReceiverBase + { +public: + + /** + * The two-phased constructor + * + * @param aSettings The radio settings + */ + static CFMRadioRdsReceiverSimulator* NewL( TRadioSettings& aSettings ); + + /** + * The destructor + */ + virtual ~CFMRadioRdsReceiverSimulator(); + + // from CFMRadioRdsReceiverBase + void InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub ); + void StartReceiver(); + void StopReceiver(); + + /** + * For simulate MrftoFrequencyChange method from MRadioFmTunerObserver + */ + void SetRadioEngineForRadioFmTunerSimulation( CRadioEngine* aEngine ); +private: + + /** The simulated events */ + enum TFMRadioRdsSimulationEvent + { + EFMRadioRdsEventSignalOn, + EFMRadioRdsEventSignalOff, + EFMRadioRdsEventPS, + EFMRadioRdsEventRadioText, + EFMRadioRdsEventAFBegin, + EFMRadioRdsEventAFEnd, + EFMRadioRdsEventRadioTextPlus + }; + + /** + * The default constructor + * + * @param aSettings The radio settings + */ + CFMRadioRdsReceiverSimulator( TRadioSettings& aSettings ); + + /** + * Second phase constructor + */ + void ConstructL(); + + /** + * StaticRdsSimulationCallback Callback for RDS simulation + */ + static TInt StaticRdsSimulationCallback( TAny* aSelfPtr ); + +private: // data + + /** Timer for RDS event simulation */ + CPeriodic* iEventSimulatorTimer; + + /** The iterator for RDS events */ + TInt iEventIterator; + + /** The iterator for PS names */ + TInt iPsIterator; + + /** The iterator for radio texts */ + TInt iRadioTextIterator; + + /** The iterator for frequencies */ + TInt iFrequencyIterator; + + /** The iterator for radio text plus'*/ + TInt iRadioTextPlusIterator; + + /** Pointer to the engine for simulate MrftoFrequencyChange method from MRadioFmTunerObserver */ + CRadioEngine* iEngine; + }; + +#endif // CFMRADIORDSRECEIVERSIMULATOR_H diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradioregion.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradioregion.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2004-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: Header file for CFMRadioRegion +* +*/ + + +#ifndef FMRADIOREGION_H +#define FMRADIOREGION_H + +// INCLUDES +#include +#include "fmradioengine.hrh" + +// FORWARD DECLARATIONS +class CFMRadioRegion; +class TResourceReader; + +// DATA TYPES +typedef RPointerArray RFMRadioRegionArray; +typedef RPointerArray RFMRadioCountryCodeArray; + +// CLASS DECLARATION + +/** +* Class CFMRadioRegion provides information about FM region +*/ +NONSHARABLE_CLASS( CFMRadioRegion ) : public CBase + { + public: // Methods + + // Constructors and destructor + + /** + * Static constructor. + */ + static CFMRadioRegion* NewL(TResourceReader& aRr); + + /** + * Destructor. + */ + ~CFMRadioRegion(); + + + // New methods + + /** + * Id Get the id of region + * @return id of region + */ + TFMRadioRegionSetting Id() const; + + /** + * StepSize Get the step interval of region + * @return Step size + */ + TUint32 StepSize() const; + + /** + * Get the minimum frequency of region + * @return Minimum frequency + */ + TUint32 MinFrequency() const; + + /** + * Get the maximum frequency of region + * @return Maximum frequency + */ + TUint32 MaxFrequency() const; + + /** + * Get the decimal count of region. + * @return Decimal count. + */ + TInt DecimalCount() const; + + /** + * CountryCode Get the country code of region + * @return Country code, or empty descriptor if country code doesn't exist + */ + const RFMRadioCountryCodeArray& CountryCodes(); + + /** + * Name Get the name of region + * @return Name of region + */ + const TDesC16& Name() const; + + /** + * SettingItemName Get the name of region for setting item + * @return Name of region + */ + const TDesC16& SettingItemName() const; + + private: //Methods + + /** + * C++ default constructor. + */ + CFMRadioRegion(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(TResourceReader& aRr); + + + private: // Data + + /** Id of the region*/ + TFMRadioRegionSetting iId; + + /** Step interval*/ + TUint16 iStepSize; + + /** Min frequency */ + TUint32 iMinFreq; + + /** Max frequency */ + TUint32 iMaxFreq; + + /** Decimal count */ + TInt iDecimalCount; + + /** Country code*/ + RFMRadioCountryCodeArray iCountryCodes; + + /** Region name*/ + HBufC16* iName; + + /** Region name for setting item*/ + HBufC16* iSettingName; + + }; + +#endif // FMRADIOREGION_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiosystemeventdetector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiosystemeventdetector.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2004-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: Header file for CFMRadioSystemEventDetector. +* +*/ + + +#ifndef CFMRADIOSYSTEMEVENTDETECTOR_H +#define CFMRADIOSYSTEMEVENTDETECTOR_H + +#include + +#include "fmradiopropertyobserver.h" + +class MFMRadioSystemEventDetectorObserver; + +/** System properties mappings */ +enum TFMRadioSystemEvents + { + EFMRadioNetworkCoverageProperty = 0, + EFMRadioCallProperty, + EFMRadioAudioResourcesProperty, + EFMRadioVoiceUiProperty + }; + +/** +* Catches notification of the call and network state changes. +* +* Class provides implementation to detect system events and notify UI components of the event, +* Class keeps several instances of CFMRadioPropertyObserver, and those instances send event notifications +* about the particular system component state change. +*/ +class CFMRadioSystemEventDetector : public CBase, public MFMRadioPropertyChangeObserver + { + public: + + /** + * Two-phased constructor. + * @param aObserver a reference to the observer interface implementer + */ + static CFMRadioSystemEventDetector* NewL(MFMRadioSystemEventDetectorObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CFMRadioSystemEventDetector(); + + /** + * Returns network coverage state. + */ + TBool IsNetworkCoverage() const; + + /** Is Auto resume allowed; based on categories */ + TBool IsAutoResumePossible() const; + + /** + * Returns current call state. + */ + TBool IsCallActive() const; + + + + private: + + /** + * By default EPOC constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aObserver a reference to the observer interface implementer + */ + CFMRadioSystemEventDetector(MFMRadioSystemEventDetectorObserver& aObserver); + /** + * Callback for auto resume timer + * @param aSelfPtr pointer to itself + */ + static TInt StaticAutoResumeTimerCallback( TAny* aSelfPtr ); + /** + * Report audio resource availability to observers. + */ + void NotifyAudioResourcesAvailability(); + + // From base class MFMRadioPropertyChangeObserver + void HandlePropertyChangeL(const TUid& aCategory, const TUint aKey, const TInt aValue); + void HandlePropertyChangeL(const TUid& aCategory, const TUint aKey, const TDesC8& aValue); + void HandlePropertyChangeL(const TUid& aCategory, const TUint aKey, const TDesC& aValue); + void HandlePropertyChangeErrorL(const TUid& aCategory, const TUint aKey, TInt aError); + + private: // Data + + /** Array of audio policy categories that radio must not resume after. */ + RArray iNoAutoResumeAudioCategories; + + /**Observer which will be notified of the call and network state changes*/ + MFMRadioSystemEventDetectorObserver& iObserver; + + /**An array of handlers to Publish & Subscribe interface*/ + RPointerArray iPropertyArray; + + /**Indicator for the network status*/ + TBool iIsNetworkCoverage; + // for tracking currently playing audio clients + TInt iNumberOfActiveAudioClients; + /** Indicator for Voice UI status. */ + TBool iIsVoiceUiActive; + /** flag for call status */ + TBool iIsCallActive; + /** call status observer */ + CFMRadioPropertyObserver* iCallStatusObserver; + /* timer for audio auto resume */ + CPeriodic* iAutoResumeTimer; + + }; + +#endif // CFMRADIOSYSTEMEVENTDETECTOR_H + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiosystemeventdetectorobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiosystemeventdetectorobserver.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2004-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: Interface to observe system events. +* Implementer will be notified each time particular system component +* state has changed. +* +*/ + + +#ifndef MFMRADIOSYSTEMEVENTDETECTOROBSERVER_H +#define MFMRADIOSYSTEMEVENTDETECTOROBSERVER_H + +// CLASS DECLARATION +/** +* +* Observer for the call and network state. Implementer will be notified each time the state has changed +*/ +class MFMRadioSystemEventDetectorObserver + { + public: // New functions + + /** + * This callback notifies when networks comes up. + */ + virtual void NetworkUpCallbackL() = 0; + + /** + * This callback notifies when network goes down. + */ + virtual void NetworkDownCallbackL() = 0; + + /** + * This callback notifies when audio resources become available. + */ + virtual void AudioResourcesAvailableL() = 0; + + /** + * This callback notifies when audio auto resuming is forbidden. + */ + virtual void AudioAutoResumeForbiddenL() = 0; + + /** + * This callback notifies when call becomes active. + */ + virtual void CallActivatedCallbackL() = 0; + + /** + * This callback notifies when call becomes deactive. + */ + virtual void CallDeactivatedCallbackL() = 0; + + }; + +#endif // MFMRADIOSYSTEMEVENTDETECTOROBSERVER_H + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/inc/fmradiosystemutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/inc/fmradiosystemutils.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,39 @@ +/* +* 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: FM Radio related definitions +* +*/ + +#ifndef FMRADIOSYSTEMUTILS_H +#define FMRADIOSYSTEMUTILS_H + +#include + +/** Direction of tuning */ +enum TFMRadioTuneDirection + { + EFMRadioDown, + EFMRadioUp + }; + +/** Direction when setting the volume */ +enum TFMRadioVolumeSetDirection + { + EFMRadioDecVolume, + EFMRadioIncVolume + }; + +#endif // FMRADIOSYSTEMUTILS_H + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/rom/fmradioengine.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/rom/fmradioengine.iby Tue Feb 02 00:17:10 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: File for listing dll's needed +* +*/ + + + +#ifndef FMRADIOENGINE_IBY +#define FMRADIOENGINE_IBY + +#include +#ifdef __S60_FM_RADIO_APPLICATION +file=ABI_DIR\BUILD_DIR\fmradioengine.dll SHARED_LIB_DIR\fmradioengine.dll + +// Backup +data=ZPRIVATE\2001B25E\backup_registration.xml PRIVATE\2001B25E\backup_registration.xml +// Cenrep +data=ZPRIVATE\10202BE9\2001B25E.txt PRIVATE\10202BE9\2001B25E.txt + +#endif // __S60_FM_RADIO_APPLICATION +#endif // FMRADIOENGINE_IBY + + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioaccessoryobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioaccessoryobserver.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,174 @@ +/* +* 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: accessory observer +* +*/ + + +#include + +#include "fmradioaccessoryobserver.h" +#include "fmradioheadseteventobserver.h" +#include "debug.h" + +// --------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CFMRadioAccessoryObserver::CFMRadioAccessoryObserver() : + CActive( CActive::EPriorityStandard ), + iObserver( NULL ) + { + FTRACE( FPrint(_L("CFMRadioAccessoryObserver::CFMRadioAccessoryObserver()") ) ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CFMRadioAccessoryObserver::ConstructL() + { + FTRACE( FPrint(_L("CFMRadioAccessoryObserver::ConstructL() -- ENTER") ) ) + User::LeaveIfError( iAccessoryServer.Connect() ); + + // Creates a new sub-session within an existing session. + User::LeaveIfError( iAccessoryModeSession.CreateSubSession( iAccessoryServer ) ); + User::LeaveIfError( iAccessoryModeSession.GetAccessoryMode( iAccPolAccessoryMode ) ); + + iPrevAccMode = iAccPolAccessoryMode; + + CActiveScheduler::Add( this ); + // Accessory mode is always listened + iAccessoryModeSession.NotifyAccessoryModeChanged( iStatus, iAccPolAccessoryMode ); + SetActive(); + FTRACE( FPrint(_L("CFMRadioAccessoryObserver::ConstructL() -- EXIT") ) ) + } + + +// --------------------------------------------------------------------------- +// Static constructor. +// --------------------------------------------------------------------------- +// +CFMRadioAccessoryObserver* CFMRadioAccessoryObserver::NewL() + { + CFMRadioAccessoryObserver* self = new( ELeave ) CFMRadioAccessoryObserver; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioAccessoryObserver::~CFMRadioAccessoryObserver() + { + Cancel(); + iAccessoryModeSession.CloseSubSession(); + iAccessoryServer.Close(); + } + + +// --------------------------------------------------------------------------- +// CFMRadioAccessoryObserver::IsHeadsetAccessoryConnected +// --------------------------------------------------------------------------- +// +TBool CFMRadioAccessoryObserver::IsHeadsetAccessoryConnected() const + { + TBool accessoryConnected; + +#ifdef __WINS__ + accessoryConnected = ETrue; +#else + switch ( iAccPolAccessoryMode.iAccessoryMode ) + { + case EAccModeWiredHeadset: // Falls through. + case EAccModeLoopset: // Falls through. + case EAccModeHeadphones: + { + accessoryConnected = ETrue; + break; + } + default: + { + accessoryConnected = EFalse; + break; + } + } +#endif + return accessoryConnected; + } + + +// --------------------------------------------------------------------------- +// CFMRadioAccessoryObserver::SetObserver +// --------------------------------------------------------------------------- +// +void CFMRadioAccessoryObserver::SetObserver( MFMRadioHeadsetEventObserver* aObserver ) + { + iObserver = aObserver; + } + + +// --------------------------------------------------------------------------- +// From class CActive +// CFMRadioAccessoryObserver::RunL +// --------------------------------------------------------------------------- +// +void CFMRadioAccessoryObserver::RunL() + { + TRequestStatus status = iStatus; + if ( status == KErrNone ) + { + // Accessory mode may change when combined connection status changes + // or when audio routing status changes. + if ( iObserver ) + { + if ( iPrevAccMode.iAccessoryMode == iAccPolAccessoryMode.iAccessoryMode && + iPrevAccMode.iAudioOutputStatus != iAccPolAccessoryMode.iAudioOutputStatus ) + { + // do nothing since we don't want another callback from same event + } + else + { + if ( IsHeadsetAccessoryConnected() ) + { + iObserver->HeadsetAccessoryConnectedCallbackL(); + } + else + { + iObserver->HeadsetAccessoryDisconnectedCallbackL(); + } + } + iPrevAccMode = iAccPolAccessoryMode; + } + } + iAccessoryModeSession.NotifyAccessoryModeChanged( iStatus, iAccPolAccessoryMode ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// From class CActive +// CFMRadioAccessoryObserver::DoCancel +// --------------------------------------------------------------------------- +// +void CFMRadioAccessoryObserver::DoCancel() + { + iAccessoryModeSession.CancelNotifyAccessoryModeChanged(); + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioengine.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,2073 @@ +/* +* 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: The class implements the core functionality of the Radio Engine +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioengine.h" +#include "fmradioenginestatechangecallback.h" +#include "debug.h" +#include "fmradioengineradiosettings.h" +#include "fmradioengineradiostatehandler.h" +#include "fmradioenginecentralrepositoryhandler.h" +#include "fmradioenginecrkeys.h" +#include "fmradiosystemeventdetector.h" +#include "fmradiomobilenetworkinfolistener.h" +#include "fmradiopubsub.h" +#include "fmradiordsreceiver.h" +#include "fmradiordsreceiversimulator.h" +#include "fmradioaccessoryobserver.h" +#ifndef __ACCESSORY_FW +#include "fmradioenginedosserverobserver.h" +#endif + +// CONSTANTS + +const TInt KFMRadioNumberOfVolumeSteps = 20; + +// ============================ MEMBER FUNCTIONS =============================== +// ---------------------------------------------------- +// CRadioEngine::CRadioEngine +// Default class constructor. +// ---------------------------------------------------- +// +CRadioEngine::CRadioEngine( + MRadioEngineStateChangeCallback& aCallback) + : + iAutoResume(EFalse), + iCurrentRadioState(EStateRadioOff), + iCallback(aCallback), + iTempFrequency(KDefaultRadioFrequency), + iTunePresetRequested(EFalse), + iInitializeRadioRequestExists(EFalse), + ilineConstructed( EFalse ), + iHFOptionActivated ( EFalse ) + { + } + +// ---------------------------------------------------- +// CRadioEngine::ConstructL +// Second phase class constructor. +// ---------------------------------------------------- +// +void CRadioEngine::ConstructL() + { + FTRACE(FPrint(_L("CRadioEngine::ConstructL()"))); + + TRAP_IGNORE( ConnectLineL() ); + + InitializeResourceLoadingL(); + + iRadioSettings = new ( ELeave ) TRadioSettings; + + iCentralRepositoryHandler = CCentralRepositoryHandler::NewL( *iRadioSettings ); + +#ifdef __WINS__ + // NetworkInfoListener takes care of listening to the network id and country code. + iNetworkInfoListener = CFMRadioMobileNetworkInfoListener::NewL( *this ); +#endif + + // for monitoring network availability + iSystemEventDetector = CFMRadioSystemEventDetector::NewL( *this ); + + // create an instance of Radio Utility factory and indicate + // FM Radio is a primary client + iRadioUtility = CRadioUtility::NewL( ETrue ); + + // Get a tuner utility + iFmTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this ); + + // Get a player utility + iPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this ); + + TInt maxVolume = 0; + iPlayerUtility->GetMaxVolume( maxVolume ); + FTRACE(FPrint(_L("CRadioEngine::ConstructL() maxVolume %d"), maxVolume ) ); + // calculate multiplier for scaling the UI volume to the value used by DevSound + iUiVolumeFactor = ( static_cast ( maxVolume ) / KFMRadioNumberOfVolumeSteps ); + + + // Get a preset utility + iPresetUtility = CRadioFmPresetUtility::NewL( *this ); + +#ifdef __WINS__ + iRdsReceiver = CFMRadioRdsReceiverSimulator::NewL( *iRadioSettings ); + static_cast ( iRdsReceiver )->SetRadioEngineForRadioFmTunerSimulation( this ); +#else + iRdsReceiver = CFMRadioRdsReceiver::NewL( *iRadioSettings ); +#endif + + iRdsReceiver->AddObserver( this ); + + iStateHandler = CRadioStateHandler::NewL( this ); + +#ifndef __ACCESSORY_FW + iDosServerObserver = CDosServerObserver::NewL( this, iRadioSettings ); +#else +#ifndef __WINS + TRAP_IGNORE( iAudioOutput = CAudioOutput::NewL( *iPlayerUtility ) ); +#endif +#endif + + iTopFrequency = 0; + iBottomFrequency = 0; + + TInt callState = KErrUnknown; + RMobileCall::TMobileCallStatus linestatus; + iLine.GetMobileLineStatus( linestatus ); + RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + + // check status from line + if ( linestatus != RMobileCall::EStatusIdle && + linestatus != RMobileCall::EStatusUnknown ) + { + // Pre-empted due to phone call, start Call State Observer + iInCall = ETrue; + } + // accessory observer + iHeadsetObserver = CFMRadioAccessoryObserver::NewL(); + iHeadsetObserver->SetObserver( this ); + // Set audio output to current setting + if ( iHeadsetObserver->IsHeadsetAccessoryConnected() ) + { + SetAudioOutput( EFMRadioOutputHeadset ); + } + else + { + SetAudioOutput( EFMRadioOutputIHF ); + } + // Assume headset is connected, we'll be notified later if it's not. + iRadioSettings->SetHeadsetConnected(); + + + // Create P&S interface. + iPubSub = CFMRadioPubSub::NewL(); + + // Publish antenna status as connected, we'll be notified later if it's not. + iPubSub->PublishAntennaStatusL( EFMRadioPSHeadsetConnected ); + + iPubSub->PublishFrequencyDecimalCountL( + TFMRadioPSFrequencyDecimalCount( iRadioSettings->DecimalCount() ) ); + + if ( iRadioSettings->StartupCount() == 0 ) + { + ResetPresetsL(); + } + + FTRACE(FPrint(_L("CRadioEngine::ConstructL() End "))); + } + +// ---------------------------------------------------- +// CRadioEngine::ConnectLineL +// Connects etel server +// ---------------------------------------------------- +// +void CRadioEngine::ConnectLineL() + { + User::LeaveIfError( iTelServer.Connect() ); + + iTelServer.GetTsyName( 0, iTsyName ); + + User::LeaveIfError( iTelServer.LoadPhoneModule( iTsyName ) ); + TInt numberOfPhones( 0 ); + User::LeaveIfError( iTelServer.EnumeratePhones( numberOfPhones ) ); + + RTelServer::TPhoneInfo phoneInfo; + + // Only possible thing to do is leave. We definately need phone. + User::LeaveIfError( iTelServer.GetPhoneInfo( 0, phoneInfo ) ); + + // Only possible thing to do is leave. We definately need phone. + User::LeaveIfError( iPhone.Open( iTelServer, phoneInfo.iName )); + + + RPhone::TLineInfo lineInfo; + + User::LeaveIfError( iPhone.GetLineInfo( 0, lineInfo ) ); + + User::LeaveIfError( iLine.Open( iPhone, lineInfo.iName ) ); + + ilineConstructed = ETrue; + } + +// ---------------------------------------------------- +// CRadioEngine::NewL +// Two-phased class constructor. +// ---------------------------------------------------- +// +EXPORT_C CRadioEngine* CRadioEngine::NewL( + MRadioEngineStateChangeCallback& aCallback ) + { + CRadioEngine* self = new (ELeave) CRadioEngine( aCallback ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------- +// CRadioEngine::~CRadioEngine +// Destructor of CRadioEngine class. +// ---------------------------------------------------- +//// +EXPORT_C CRadioEngine::~CRadioEngine() + { + FTRACE(FPrint(_L("CRadioEngine::~CRadioEngine()"))); + if ( iCentralRepositoryHandler) + { + iCentralRepositoryHandler->SaveEngineSettings(); + delete iCentralRepositoryHandler; + } + + delete iPubSub; + delete iHeadsetObserver; + + RadioOff(); + + delete iNetworkInfoListener; + delete iSystemEventDetector; + delete iPresetUtility; + delete iRadioSettings; + delete iStateHandler; + + if ( iAudioOutput ) + { + TRAP_IGNORE(iAudioOutput->SetAudioOutputL(CAudioOutput::EPrivate)); + delete iAudioOutput; + } + + if ( iRdsReceiver ) + { + iRdsReceiver->RemoveObserver( this ); + } + + delete iRdsReceiver; + + if ( iFmTunerUtility ) + { + iFmTunerUtility->Close(); + } + + if ( iPlayerUtility ) + { + iPlayerUtility->Close(); + } + + delete iRadioUtility; + + #ifndef __ACCESSORY_FW + if (iDosServerObserver) + { + iDosServerObserver->SetAudioRouting(EFMRadioOutputHeadset); + delete iDosServerObserver; + } + #endif + + if ( iFMRadioEngineResourceOffset > 0 ) + { + CCoeEnv::Static()->DeleteResourceFile( iFMRadioEngineResourceOffset ); + } + + if ( ilineConstructed ) + { + iLine.Close(); + iPhone.Close(); + iTelServer.UnloadPhoneModule( iTsyName ); + iTelServer.Close(); + } + } + +// ---------------------------------------------------- +// CRadioEngine::InitializeRadio +// Set radio settings to their default values. +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::InitializeRadio() + { + FTRACE(FPrint(_L("CRadioEngine::InitializeRadio()"))); + iInitializeRadioRequestExists = ETrue; + Tune( iRadioSettings->Frequency() ); +#ifdef __WINS__ + // MrftoRequestTunerControlComplete never completes in WINS, so initialize RdsReceiver here + TRAP_IGNORE( iRdsReceiver->InitL( *iRadioUtility, iPubSub ) ); +#endif + } + +// ---------------------------------------------------- +// CRadioEngine::RadioOn +// Start the radio. +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::RadioOn() + { + FTRACE(FPrint(_L("CRadioEngine::RadioOn()"))); + if ( !iRadioSettings->IsRadioOn() ) + { + FTRACE(FPrint(_L("CRadioEngine::RadioOn() - Turning Radio on, calling play"))); + iRadioSettings->SetRadioOn(); + iPlayerUtility->Play(); + + if ( iPubSub ) + { + TRAP_IGNORE( iPubSub->PublishStateL( ETrue ) ); + } + } + } + +// ---------------------------------------------------- +// CRadioEngine::RadioOff +// Stops the radio. +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::RadioOff() + { + FTRACE(FPrint(_L("CRadioEngine::RadioOff()"))); + if ( iStateHandler ) + { + iStateHandler->Cancel(); + } + + iCurrentRadioState = EStateRadioOff; + + if( iFmTunerUtility && + iRadioSettings && + iRadioSettings->RadioMode() == ERadioTunerMode ) + { + CancelScan(); + } + + if ( iPlayerUtility && + iPlayerUtility->PlayerState() == ERadioPlayerPlaying ) + { + iPlayerUtility->Stop(); + } + + if ( iPubSub ) + { + TRAP_IGNORE( iPubSub->PublishStateL( EFalse ) ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::IsRadioOn +// Returns the radio status. +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsRadioOn() + { + return iRadioSettings->IsRadioOn(); + } + +// ---------------------------------------------------- +// CRadioEngine::IsOfflineProfileL +// Checks if offine profile is current active profile +// Returns: true/false +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsOfflineProfileL() + { + return iCentralRepositoryHandler->IsOfflineProfileActiveL(); + } + +// ---------------------------------------------------- +// CRadioEngine::Tune +// Tune to the specified frequency +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::Tune( TInt aFrequency, TRadioMode aRadioMode ) + { + FTRACE(FPrint(_L("CRadioEngine::Tune()"))); + iTempFrequency = aFrequency; + + iRadioSettings->SetRadioMode( aRadioMode ); + if ( iTunerControl ) + { + iFmTunerUtility->SetFrequency( aFrequency ); + } + else + { + StoreAndPublishFrequency( aFrequency ); + } + if ( iPubSub ) + { + TRAP_IGNORE + ( + iPubSub->PublishFrequencyL( aFrequency ); + if( aRadioMode == ERadioTunerMode ) + { + iPubSub->PublishChannelNameL( KNullDesC ); + iPubSub->PublishChannelL( KErrNotFound ); + } + ) + } + } + +// ---------------------------------------------------- +// CRadioEngine::SetTunerModeOn +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetTunerModeOn() + { + FTRACE(FPrint(_L("CRadioEngine::SetTunerModeOn()"))); + + iRadioSettings->SetRadioMode( ERadioTunerMode ); + + if ( iPubSub ) + { + TRAP_IGNORE + ( + iPubSub->PublishChannelNameL( KNullDesC ); + iPubSub->PublishChannelL( KErrNotFound ); + ) + } + } + +// ---------------------------------------------------- +// CRadioEngine::ScanUp +// Scan up to the next available frequency +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::ScanUp() + { + iRadioSettings->SetRadioMode(ERadioTunerMode); + iFmTunerUtility->StationSeek( ETrue ); + TRAP_IGNORE + ( + iTuningState = EFMRadioPSTuningStarted; + iPubSub->PublishTuningStateL( iTuningState ); + iPubSub->PublishChannelNameL( KNullDesC ); + iPubSub->PublishChannelL( KErrNotFound ); + ) + } + +// ---------------------------------------------------- +// CRadioEngine::ScanDown +// Scan down to the last available frequency +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::ScanDown() + { + iRadioSettings->SetRadioMode(ERadioTunerMode); + iFmTunerUtility->StationSeek( EFalse ); + TRAP_IGNORE + ( + iTuningState = EFMRadioPSTuningStarted; + iPubSub->PublishTuningStateL( iTuningState ); + iPubSub->PublishChannelNameL( KNullDesC ); + iPubSub->PublishChannelL( KErrNotFound ); + ) + } + +// ---------------------------------------------------- +// CRadioEngine::CancelScan +// Cancel previously requested scan, and return to the +// already tuned frequency +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::CancelScan() + { + if( iFmTunerUtility ) + { + iFmTunerUtility->CancelStationSeek(); + iTuningState = EFMRadioPSTuningUninitialized; + TRAP_IGNORE(iPubSub->PublishTuningStateL( iTuningState )); + } + } + +// ---------------------------------------------------- +// CRadioEngine::IsHeadsetConnected +// Check whether the headset is currently connected +// Returns: true/false +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsHeadsetConnected() const + { + return iRadioSettings->IsHeadsetConnected(); + } + +// ---------------------------------------------------- +// CRadioEngine::IsFlightmodeEnabled +// Check whether flight mode is currently enabled +// Returns: true/false +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsFlightModeEnabled() const + { + return iRadioSettings->IsFlightModeEnabled(); + } + +// ---------------------------------------------------- +// CRadioEngine::SetMuteOn +// Sets the audio mute state +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetMuteOn( + TBool aMuteOn) // a flag indicating if set mute on + { + FTRACE(FPrint(_L("CRadioEngine::SetMuteOn()"))); + TInt error = KErrNone; + if ( IsMuteOn() && (!aMuteOn) ) + { + error = iPlayerUtility->Mute( EFalse ); + if( !error ) + { + FTRACE(FPrint(_L("CRadioEngine::SetMuteOn() setting mute off"))); + iRadioSettings->SetMuteOff(); + TRAP_IGNORE(iPubSub->PublishRadioMuteStateL(EFalse)); + } + } + else if ( !IsMuteOn() && aMuteOn ) + { + error = iPlayerUtility->Mute( ETrue ); + if( !error ) + { + FTRACE(FPrint(_L("CRadioEngine::SetMuteOn() setting mute on"))); + iRadioSettings->SetMuteOn(); + TRAP_IGNORE(iPubSub->PublishRadioMuteStateL(ETrue)); + } + } + iStateHandler->Callback( MRadioEngineStateChangeCallback::EFMRadioEventSetMuteState, error ); + } + + +// ---------------------------------------------------- +// CRadioEngine::IsMuteOn +// Gets the audio mute state +// Returns: true/false +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsMuteOn() const + { + return iRadioSettings->IsMuteOn(); + } + +// ---------------------------------------------------- +// CRadioEngine::GetPresetIndex +// Retrieve the currently selected channel +// Returns: the preset channel index +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetPresetIndex() const + { + return iRadioSettings->CurrentPreset(); + } + + +// ---------------------------------------------------- +// CRadioEngine::SetPresetFrequency +// Update the channel located at the index to use the frequency specified. +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetPresetNameFrequencyL( + TInt aIndex, // preset channel index + const TStationName& aStationName, + TInt aFrequency) // preset channel frequency + { + iPresetUtility->SetPresetL(aIndex, aStationName, aFrequency); + if( aIndex == iRadioSettings->CurrentPreset() ) + { + iPubSub->PublishChannelNameL( aStationName ); + if( aFrequency == 0 ) + { + // Current preset was deleted + iPubSub->PublishChannelL( KErrNotFound ); + } + } + iPubSub->PublishChannelDataChangedL( aIndex ); + } + +// ---------------------------------------------------- +// CRadioEngine::GetPresetFrequency +// Retrieve the channel frequency at the index specified +// Returns: tmpFrequency: preset frequency +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetPresetFrequencyL( + TInt aIndex) const // preset channel index + { + TInt tmpFrequency = KDefaultRadioFrequency; + TStationName tmpStationName; + + iPresetUtility->GetPresetL( aIndex, tmpStationName, tmpFrequency ); + + FTRACE(FPrint(_L("CRadioEngine::GetPresetFrequencyL() aIndex %d"), aIndex)); + FTRACE(FPrint(_L("CRadioEngine::GetPresetFrequencyL() Freq %d"), tmpFrequency)); + FTRACE(FPrint(_L("CRadioEngine::GetPresetFrequencyL() Name %S"), &tmpStationName)); + return tmpFrequency; + } + +// ---------------------------------------------------- +// CRadioEngine::GetPresetName +// Retrieve the channel name at the index specified +// Returns: tmpStationName: the channel name +// ---------------------------------------------------- +// +EXPORT_C CRadioEngine::TStationName& CRadioEngine::GetPresetNameL( TInt aIndex ) + { + TInt tmpFrequency; + + iPresetUtility->GetPresetL(aIndex, iStationName, tmpFrequency); + FTRACE(FPrint(_L("CRadioEngine::GetPresetFrequencyL() Freq %d"),tmpFrequency)); + FTRACE(FPrint(_L("CRadioEngine::GetPresetFrequencyL() Name %S"),&iStationName)); + return iStationName; + } + +// ---------------------------------------------------- +// CRadioEngine::GetPresetNameAndFrequencyL +// get preset name frequency from the preset utility +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::GetPresetNameAndFrequencyL( TInt aIndex, TDes& aName, TInt& aFrequency ) + { + TInt tmpFrequency; + TStationName tmpStationName; + + iPresetUtility->GetPresetL( aIndex, tmpStationName, tmpFrequency ); + + aFrequency = tmpFrequency; + aName = tmpStationName; + } + +// ---------------------------------------------------- +// CRadioEngine::GetTunedFrequency +// Retrieves the current frequency. +// Returns: channel frequency +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetTunedFrequency() const + { + return iRadioSettings->Frequency(); + } + +// ---------------------------------------------------- +// CRadioEngine::SetVolume +// Sets the volume level of the FM radio +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetVolume( + TInt aVolume ) + { + FTRACE(FPrint(_L("CRadioEngine::SetVolume( %d )"), aVolume )); + + if ( aVolume < 0 ) + { + aVolume = 0; + } + else if ( aVolume > KFMRadioNumberOfVolumeSteps ) + { + aVolume = KFMRadioNumberOfVolumeSteps; + } + + TInt playerVolume = ( iUiVolumeFactor * aVolume ); + + FTRACE(FPrint(_L("CRadioEngine::SetVolume() playerVolume %d"), playerVolume )); + + TInt error = iPlayerUtility->SetVolume( playerVolume ); + + if ( !error ) + { + if ( iRadioSettings->AudioOutput() == EFMRadioOutputHeadset ) + { + iRadioSettings->SetHeadsetVolume( aVolume ); + iCentralRepositoryHandler->SaveHeadsetVolumeSetting(); + } + else + { + iRadioSettings->SetSpeakerVolume( aVolume ); + iCentralRepositoryHandler->SaveSpeakerVolumeSetting(); + } + } + else + { + iStateHandler->Callback( MRadioEngineStateChangeCallback::EFMRadioEventVolumeUpdated, error ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::GetRadioMode +// Retrieves the current radio mode (tuner or preset). +// Returns: radio mode +// ---------------------------------------------------- +// +EXPORT_C CRadioEngine::TRadioMode CRadioEngine::GetRadioMode() const + { + return iRadioSettings->RadioMode(); + } + +// ---------------------------------------------------- +// CRadioEngine::GetVolume +// Gets the volumelevel. +// Returns: volume +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetVolume() const + { + if ( iRadioSettings->AudioOutput() == EFMRadioOutputHeadset ) + { + return iRadioSettings->HeadsetVolume(); + } + else + { + return iRadioSettings->SpeakerVolume(); + } + } + +// ---------------------------------------------------- +// CRadioEngine::GetMaxVolume +// Gets the max volumelevel. +// Returns: max volume +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetMaxVolume() const + { + TInt maxVolume; + iPlayerUtility->GetMaxVolume( maxVolume ); + return maxVolume; + } + +// ---------------------------------------------------- +// CRadioEngine::GetAudioMode +// Gets the current audio mode. +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetAudioMode() const + { + return iRadioSettings->AudioMode(); + } + +// ---------------------------------------------------- +// CRadioEngine::SetAudioMode +// Set the radio's audio mode (stereo or mono) +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetAudioMode( const TFMRadioAudioMode aAudioMode ) + { + FTRACE(FPrint(_L("CRadioEngine::SetAudioMode"))); + TBool forcedMono = EFalse; + TInt res = KErrNone; + TFMRadioAudioMode audioMode = iRadioSettings->AudioMode(); + if (audioMode != aAudioMode) + { + if ( aAudioMode == EFMRadioMono ) + { + forcedMono = ETrue; + } + res = iFmTunerUtility->ForceMonoReception( forcedMono ); + if ( res ) + { + iRadioSettings->SetAudioMode( aAudioMode ); + } + } + iStateHandler->Callback( MRadioEngineStateChangeCallback::EFMRadioEventSetAudioMode, res ); + } + +// ---------------------------------------------------- +// CRadioEngine::GetAudioOutput +// Retrieve the current audio output +// Returns: audio output +// ---------------------------------------------------- +// +EXPORT_C CRadioEngine::TFMRadioAudioOutput CRadioEngine::GetAudioOutput() const + { + return iRadioSettings->AudioOutput(); + } + +// ---------------------------------------------------- +// CRadioEngine::SetAudioOutput +// Sets the audio Output +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetAudioOutput( const TFMRadioAudioOutput aAudioOutput ) + { + FTRACE(FPrint(_L("CRadioEngine::SetAudioOutput() Output = %d"), aAudioOutput)); + TInt tempError = KErrNone; + // use mute here to avoid any audio peaks during output change + SetMuteOn( ETrue ); + + TBool btAudioConnected = EFalse; + TRAPD( err, btAudioConnected = IsBTAccessoryConnectedL(); ) + if ( err != KErrNone ) + { + btAudioConnected = ETrue; + } + +#ifndef __ACCESSORY_FW + + tempError = iDosServerObserver->SetAudioRouting(aAudioOutput); + FTRACE(FPrint(_L("CRadioEngine::SetAudioOutput() tempError = %d"), tempError)); + +#else + + CAudioOutput::TAudioOutputPreference outputPreference = CAudioOutput::EPrivate; + + if( btAudioConnected && !iHeadsetObserver->IsHeadsetAccessoryConnected() ) + { + FTRACE(FPrint(_L("CRadioEngine::SetAudioOutput() EPublic don't route to BT"))); + outputPreference = CAudioOutput::EPublic; + } + else if ( EFMRadioOutputHeadset == aAudioOutput ) + { + FTRACE(FPrint(_L("CRadioEngine::SetAudioOutput() Headset is set to Output"))); + outputPreference = CAudioOutput::EPrivate; + } + else if ( EFMRadioOutputIHF == aAudioOutput ) + { + FTRACE(FPrint(_L("CRadioEngine::SetAudioOutput() IHF is set to Output"))); + + if ( iHeadsetObserver->IsHeadsetAccessoryConnected() ) + { //user has chosen 'Activate IHF' in options menu + iHFOptionActivated = ETrue; + } + outputPreference = CAudioOutput::EPublic; + } + +#ifndef __WINS + if ( iAudioOutput ) + { + TRAP( tempError, iAudioOutput->SetAudioOutputL( outputPreference ) ); + } +#endif + +#endif + + if ( KErrNone == tempError ) + { + if ( !iHeadsetObserver->IsHeadsetAccessoryConnected() ) + { + iRadioSettings->SetAudioOutput( EFMRadioOutputIHF ); + } + else + { + iRadioSettings->SetAudioOutput( aAudioOutput ); + } + } + + iStateHandler->Callback( MRadioEngineStateChangeCallback::EFMRadioEventSetAudioOutput, tempError ); + } + +// ---------------------------------------------------- +// CRadioEngine::SetRdsAfSearchEnable +// Sets the rds af search enabled +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetRdsAfSearchEnable( TBool aEnabled ) + { + TRAP_IGNORE( iRdsReceiver->SetAutomaticSwitchingL( aEnabled ) ); + aEnabled ? iRadioSettings->SetRdsAfSearchEnabled() : iRadioSettings->SetRdsAfSearchDisabled(); + } + +// ---------------------------------------------------- +// CRadioEngine::RadioSettings +// ---------------------------------------------------- +// +EXPORT_C TRadioSettings& CRadioEngine::RadioSettings( ) + { + return *iRadioSettings; + } + +// ---------------------------------------------------- +// CRadioEngine::TunePreset +// Tunes to the chosen channel. +// Returns: None +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::TunePresetL( TInt aIndex ) + { + FTRACE(FPrint(_L("CRadioEngine::TunePresetL()"))); + iRadioSettings->SetCurrentPreset( aIndex ); + TInt tmpFrequency = 0;// changed back to zero + TStationName name; + + iPresetUtility->GetPresetL( aIndex, name, tmpFrequency ); + // Should not tune if the radio is not on. + if ( iRadioSettings->IsRadioOn()) + { + FTRACE(FPrint(_L("CRadioEngine::TunePresetL() inside if"))); + iTunePresetRequested = ETrue; + iTempFrequency = tmpFrequency; + Tune(tmpFrequency, ERadioPresetMode); + } + else + { + StoreAndPublishFrequency( tmpFrequency ); + } + iPubSub->PublishChannelNameL( name ); + iPubSub->PublishChannelL( aIndex ); + iRadioSettings->SetRadioMode(ERadioPresetMode); + FTRACE(FPrint(_L("CRadioEngine::TunePresetL() end %d"),tmpFrequency)); + } + +// ---------------------------------------------------- +// CRadioEngine::5 +// Return min and max freq for the specified range (band) +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::GetFrequencyBandRange( + TInt& aBottomFrequency, + TInt& aTopFrequency) + { + TBool err = KErrNone; + + aBottomFrequency = iCentralRepositoryHandler->MinFrequency() * KFMRadioFreqMultiplier; + aTopFrequency = iCentralRepositoryHandler->MaxFrequency() * KFMRadioFreqMultiplier; + + return err; + } + +// ---------------------------------------------------- +// CRadioEngine::IsInCall +// ---------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsInCall() const + { + return iInCall; + } + +// --------------------------------------------------------- +// CRadioEngine::FrequencySetByRdsAf +// --------------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::FrequencySetByRdsAf() const + { + return iFrequencySetByRdsAf; + } + +// --------------------------------------------------------- +// CRadioEngine::RdsReceiver +// --------------------------------------------------------- +// +EXPORT_C CFMRadioRdsReceiverBase& CRadioEngine::RdsReceiver() + { + return *iRdsReceiver; + } + +// ---------------------------------------------------- +// CRadioEngine::HandleFlightModeEnabled +// Switches the engine into flight mode, and notifies the UI of +// the change in status. +// ---------------------------------------------------- +// +void CRadioEngine::HandleFlightModeEnabled() + { + FTRACE(FPrint(_L("CRadioEngine::HandleFlightModeEnabled()"))); + iRadioSettings->SetFlightMode(ETrue); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventFlightModeEnabled, KErrNone); + } + +// ---------------------------------------------------- +// CRadioEngine::HandleFlightModeDisabled +// Switches the engine out of flight mode, and notifies the UI of +// the change in status +// ---------------------------------------------------- +// +void CRadioEngine::HandleFlightModeDisabled() + { + FTRACE(FPrint(_L("CRadioEngine::HandleFlightModeDisabled()"))); + iRadioSettings->SetFlightMode(EFalse); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventFlightModeDisabled, KErrNone); + } + + +// ---------------------------------------------------- +// CRadioEngine::HandleCallback +// Calls the User Interface callback function, indicating the event code and +// error code. +// ---------------------------------------------------- +// +void CRadioEngine::HandleCallback(TInt aEventCode, TInt aCode ) + { + FTRACE(FPrint(_L("CRadioEngine::HandleCallback(aEventCode %d, aCode %d "), aEventCode, aCode ) ); + iCallback.HandleRadioEngineCallBack((MRadioEngineStateChangeCallback::TFMRadioNotifyEvent)aEventCode, aCode); + } + +// ---------------------------------------------------- +// CRadioEngine::HandleHeadsetButtonPress +// Notifies UI that the headset button has been pressed +// ---------------------------------------------------- +// +void CRadioEngine::HandleHeadsetButtonPress() + { + FTRACE(FPrint(_L("CRadioEngine::HandleHeadsetButtonPress()"))); + iStateHandler->Callback(MRadioEngineStateChangeCallback::EFMRadioEventButtonPressed, KErrNone); + } + +// ---------------------------------------------------- +// CRadioEngine::HeadsetAccessoryConnectedCallbackL +// ---------------------------------------------------- +// +void CRadioEngine::HeadsetAccessoryConnectedCallbackL() + { + FTRACE(FPrint(_L("CRadioEngine::HeadsetAccessoryConnectedCallbackL"))); + // forward volume changes to headset + if ( iHFOptionActivated ) + { + iHFOptionActivated = EFalse; + } + else + { + SetAudioOutput( EFMRadioOutputHeadset ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::HeadsetAccessoryDisconnectedCallbackL +// ---------------------------------------------------- +// +void CRadioEngine::HeadsetAccessoryDisconnectedCallbackL() + { + FTRACE(FPrint(_L("CRadioEngine::HeadsetAccessoryDisconnectedCallbackL"))); + // forward volume changes to speakers + SetAudioOutput( EFMRadioOutputIHF ); + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoRequestTunerControlComplete +// ---------------------------------------------------- +// +void CRadioEngine::MrftoRequestTunerControlComplete( + TInt aError ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - Error = %d"), aError)); + + if ( aError == KErrNone ) + { + iTunerControl = ETrue; + // Headset must be connected + iRadioSettings->SetHeadsetConnected(); + iFmTunerUtility->GetCapabilities( iTunerCaps ); + + if( iTunerCaps.iTunerFunctions & TFmTunerCapabilities::ETunerRdsSupport ) + { + TRAP_IGNORE( iRdsReceiver->InitL( *iRadioUtility, iPubSub ) ) + } + + TFmRadioFrequencyRange japanFreqRange = EFmRangeJapan; + + if ( TunerFrequencyRangeForRegionId( RegionId() ) == japanFreqRange ) + { + // region is Japan so we need to change the freq range from the default + iFmTunerUtility->SetFrequencyRange( japanFreqRange ); + } + else + { + // allready on correct freq range + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); + } + } + else if ( aError == KFmRadioErrAntennaNotConnected ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - KFmRadioErrAntennaNotConnected"))); + iRadioSettings->SetHeadsetDisconnected(); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventHeadsetDisconnected, KErrNone ); + } + else if ( aError == KErrAlreadyExists ) + { + iTunerControl = ETrue; + // Headset must be connected + iRadioSettings->SetHeadsetConnected(); + iFmTunerUtility->GetCapabilities( iTunerCaps ); + TInt frequency; + iFmTunerUtility->GetFrequency( frequency ); + StoreAndPublishFrequency( frequency ); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, KErrNone ); + } + else if ( aError == KFmRadioErrFmTransmitterActive ) + { + iTunerControl = EFalse; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFMTransmitterOn, KErrNone ); + } + else if ( aError == KFmRadioErrOfflineMode ) + { + iTunerControl = EFalse; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFlightModeEnabled, KErrNone ); + } + else + { + //pass + } + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoSetFrequencyRangeComplete +// +// ---------------------------------------------------- +// +void CRadioEngine::MrftoSetFrequencyRangeComplete( + TInt aError ) + { + if ( aError == KErrNone ) + { + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); + } + + FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyRangeComplete() - error = %d"), aError)); + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoSetFrequencyComplete +// ---------------------------------------------------- +// +void CRadioEngine::MrftoSetFrequencyComplete( + TInt aError ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyComplete() - aError = %d"), aError)); + + + if ( !aError ) + { + iRdsReceiver->ClearRdsInformation(); + StoreAndPublishFrequency( iTempFrequency ); + if ( iTunePresetRequested ) + { + iCentralRepositoryHandler->SaveEngineSettings(); + iTunePresetRequested = EFalse; + } + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, aError ); + + if ( iInitializeRadioRequestExists ) + { + iInitializeRadioRequestExists = EFalse; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFMRadioInitialized, KErrNone ); + } + } + else + { + iInitializeRadioRequestExists = EFalse; + + FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyComplete() - Sending event to UI"))); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, aError ); + } + + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoStationSeekComplete +// +// ---------------------------------------------------- +// +void CRadioEngine::MrftoStationSeekComplete( + TInt aError, + TInt aFrequency ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoStationSeekComplete() - Frequency = %d"), aFrequency)); + FTRACE(FPrint(_L("CRadioEngine::MrftoStationSeekComplete() - error = %d"), aError)); + + if ( !aError ) + { + StoreAndPublishFrequency( aFrequency ); + + iRdsReceiver->ClearRdsInformation(); + StoreAndPublishFrequency( aFrequency ); + if ( iTunePresetRequested ) + { + iCentralRepositoryHandler->SaveEngineSettings(); + iTunePresetRequested = EFalse; + } + iTuningState = EFMRadioPSTuningUninitialized; + // Process the callback first because it might change the tuning state and we must avoid switching it back and forth + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, aError ); + TRAP_IGNORE(iPubSub->PublishTuningStateL( iTuningState )); + + if ( iInitializeRadioRequestExists ) + { + iInitializeRadioRequestExists = EFalse; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFMRadioInitialized, KErrNone ); + } + } + else + { + iInitializeRadioRequestExists = EFalse; + + FTRACE(FPrint(_L("CRadioEngine::MrftoStationSeekComplete() - Sending event to UI"))); + iTuningState = EFMRadioPSTuningUninitialized; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, aError ); + TRAP_IGNORE(iPubSub->PublishTuningStateL( iTuningState )); + } + } + + +// ---------------------------------------------------- +// CRadioEngine::MrftoFmTransmitterStatusChange +// The FM tuner is turned off when FM transmitter is on. +// ---------------------------------------------------- +// +void CRadioEngine::MrftoFmTransmitterStatusChange( + TBool aActive ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoFmTransmitterStatusChange() - Active = %d"), aActive)); + if ( aActive ) + { + // loses tuner control + iTunerControl = EFalse; + } + } + + +// ---------------------------------------------------- +// CRadioEngine::MrftoAntennaStatusChange +// Called when antenna status changes. +// ---------------------------------------------------- +// +void CRadioEngine::MrftoAntennaStatusChange( + TBool aAttached ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoAntennaStatusChange() - Antenna Status = %d"), aAttached)); + if ( aAttached ) + { + if ( !iTunerControl ) + { + iFmTunerUtility->RequestTunerControl(); + } + iRadioSettings->SetHeadsetConnected(); + TRAP_IGNORE( iPubSub->PublishAntennaStatusL( EFMRadioPSHeadsetConnected ) ); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventHeadsetReconnected, KErrNone ); + } + else + { + iRadioSettings->SetHeadsetDisconnected(); + TRAP_IGNORE( iPubSub->PublishAntennaStatusL( EFMRadioPSHeadsetDisconnected ) ); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventHeadsetDisconnected, KErrNone ); + } + } + + +// ---------------------------------------------------- +// CRadioEngine::FlightModeChanged +// Called when offline mode status changes +// ---------------------------------------------------- +// +void CRadioEngine::MrftoOfflineModeStatusChange( + TBool aOfflineMode ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoOfflineModeStatusChange() - Offline Mode = %d"), aOfflineMode)); + + if( aOfflineMode ) + { + HandleFlightModeEnabled(); + } + else + { + if ( !iTunerControl ) + { + iFmTunerUtility->RequestTunerControl(); + } + HandleFlightModeDisabled(); + } + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoFrequencyRangeChange +// +// ---------------------------------------------------- +// +void CRadioEngine::MrftoFrequencyRangeChange( + TFmRadioFrequencyRange FDEBUGVAR( aNewRange ) ) + { + FTRACE( FPrint(_L("CRadioEngine::MrftoFrequencyRangeChange() - Band = %d"), aNewRange ) ); + } + + // ---------------------------------------------------- +// CRadioEngine::MrftoFrequencyChange +// Called when the tuned frequency changes +// ---------------------------------------------------- +// +void CRadioEngine::MrftoFrequencyChange( + TInt aNewFrequency ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoFrequencyChange() - New Frequency = %d"), aNewFrequency)); + + if ( iRadioSettings->Frequency() != aNewFrequency ) + { + iRdsReceiver->ClearRdsInformation(); + StoreAndPublishFrequency( aNewFrequency ); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, KErrNone ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::MTsoForcedMonoChanged +// Called when a client enables/disabled forced mono reception +// ---------------------------------------------------- +// +void CRadioEngine::MrftoForcedMonoChange( + TBool aForcedMono ) + { + FTRACE(FPrint(_L("CRadioEngine::MrftoForcedMonoChange() - Forced Mono = %d"), aForcedMono)); + if ( aForcedMono ) + { + iRadioSettings->SetAudioMode( EFMRadioMono ); + } + else + { + iRadioSettings->SetAudioMode( EFMRadioStereo ); + } + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventSetAudioMode, KErrNone ); + } + +// ---------------------------------------------------- +// CRadioEngine::MrftoSquelchChange +// +// error code. +// ---------------------------------------------------- +// +void CRadioEngine::MrftoSquelchChange( + TBool /*aSquelch*/ ) + { + } + + +// ---------------------------------------------------- +// CRadioEngine::MrpoStateChange This is Tuner State +// Called when the state of the tuner changes +// ---------------------------------------------------- +// +void CRadioEngine::MrpoStateChange( + TPlayerState aState, + TInt aError ) + { + FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() - State Change = %d, Error = %d"), aState, aError)); + + if ( !aError ) + { + if ( aState == ERadioPlayerPlaying ) + { + iRadioSettings->SetRadioOn(); + iCurrentRadioState = EStateRadioOn; + FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() Resource Available Error = %d"), aError )); + iRdsReceiver->StartReceiver(); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventRadioOn, KErrNone); + } + else + { + iRdsReceiver->StopReceiver(); + iRadioSettings->SetRadioOff(); + iCurrentRadioState = EStateRadioOff; + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventRadioOff, KErrNone ); + } + } + else + { + if ( aState == ERadioPlayerIdle && iRadioSettings->IsRadioOn() ) + { + MRadioEngineStateChangeCallback::TFMRadioNotifyEvent ret = + MRadioEngineStateChangeCallback::EFMRadioEventAudioResourcePaused; + iCurrentRadioState = EStateRadioOff; + iRdsReceiver->StopReceiver(); + iRadioSettings->SetRadioOff(); + if ( ( aError == KErrDied ) || + ( aError == KErrAccessDenied ) || + ( aError == KErrNotReady ) || + ( aError == KErrInUse ) ) + { + TInt callState = KErrUnknown; + + RMobileCall::TMobileCallStatus linestatus; + + if ( ilineConstructed ) + { + iLine.GetMobileLineStatus( linestatus ); + } + FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() linestatus = %d"), linestatus)); + + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() callState = %d"), callState)); + + // check status from line + if ( linestatus != RMobileCall::EStatusIdle && + linestatus != RMobileCall::EStatusUnknown || + iSystemEventDetector->IsCallActive() ) + { + FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() EFMRadioEventCallStarted") ) ); + iInCall = ETrue; + ret = MRadioEngineStateChangeCallback::EFMRadioEventCallStarted; + } + } + else if ( aError == KErrHardwareNotAvailable ) // Radio is interrupted by FM Transmitter activation. + { + ret = MRadioEngineStateChangeCallback::EFMRadioEventFMTransmitterOn; + } + HandleCallback( ret, aError ); + } + } + if( iRadioSettings->IsRadioOn() ) + { + TRAP_IGNORE( iPubSub->PublishStateL( ETrue ) ) + } + else + { + TRAP_IGNORE + ( + iTuningState = EFMRadioPSTuningUninitialized; + iPubSub->PublishTuningStateL( iTuningState ); + iPubSub->PublishStateL( EFalse ); + ) + } + } + +// ---------------------------------------------------- +// CRadioEngine::MrpoVolumeChange +// +// ---------------------------------------------------- +// +void CRadioEngine::MrpoVolumeChange( TInt FDEBUGVAR( aVolume ) ) + { + FTRACE(FPrint(_L("CRadioEngine::MrpoVolumeChange() - Volume = %d"), aVolume) ); + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventVolumeUpdated, KErrNone ); + } + +// ---------------------------------------------------- +// CRadioEngine::MrpoMuteChange +// +// ---------------------------------------------------- +// +void CRadioEngine::MrpoMuteChange( TBool aMute ) + { + FTRACE(FPrint(_L("CRadioEngine::MrpoMuteChange() - Mute = %d"), aMute)); + + if ( aMute && !iRadioSettings->IsMuteOn() ) + { + iRadioSettings->SetMuteOn(); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventSetMuteState, KErrNone); + } + else if ( !aMute && iRadioSettings->IsMuteOn() ) + { + iRadioSettings->SetMuteOff(); + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventSetMuteState, KErrNone); + } + } + +// ---------------------------------------------------- +// CRadioEngine::MrpoBalanceChange +// +// ---------------------------------------------------- +// +void CRadioEngine::MrpoBalanceChange( + TInt /*aLeftPercentage*/, + TInt /*aRightPercentage*/ ) + { + // Not supported. + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::MrpeoPresetChanged +// Observer for Presets +// ----------------------------------------------------------------------------- +void CRadioEngine::MrpeoPresetChanged( + TPresetChangeEvent /*aChange*/, + TInt /*aIndex*/ ) + { + + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::NetworkUpCallbackL +// callback notifies when networks comes up +// ----------------------------------------------------------------------------- +// +void CRadioEngine::NetworkUpCallbackL() + { +#ifndef __WINS__ + + if ( !iNetworkInfoListener ) + { + // NetworkInfoListener takes care of listening to the network id and country code. + iNetworkInfoListener = CFMRadioMobileNetworkInfoListener::NewL( *this ); + } +#endif + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::NetworkDownCallbackL +// callback notifies when network goes down +// ----------------------------------------------------------------------------- +// +void CRadioEngine::NetworkDownCallbackL() + { + // No implementation needed + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::NetworkIdChanged +// Used for notifying that the network id has changed +// ----------------------------------------------------------------------------- +// +void CRadioEngine::NetworkIdChanged() + { + // No implementation needed + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::AudioResourcesAvailableL +// This callback notifies when audio resources become available. +// ----------------------------------------------------------------------------- +// +void CRadioEngine::AudioResourcesAvailableL() + { + FTRACE( FPrint( _L("CRadioEngine::AudioResourcesAvailableL()" ) ) ); + if ( iPubSub && !iInCall && iTunerControl ) // if iPubSub exists, then the ConstructL has been successfully completed + { + HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventAudioResourceAvailable, KErrNone ); + } + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::AudioAutoResumeForbiddenL +// This callback notifies when audio auto resuming is forbidden. +// ----------------------------------------------------------------------------- +// +void CRadioEngine::AudioAutoResumeForbiddenL() + { + FTRACE( FPrint( _L("CRadioEngine::AudioAutoResumeForbiddenL()" ) ) ); + if ( iPubSub ) // if iPubSub exists, then the ConstructL has been successfully completed + { + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventAudioResourceLost, KErrNone ); + } + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::CallActivatedCallbackL +// This callback notifies when call becomes active. +// ----------------------------------------------------------------------------- +// +void CRadioEngine::CallActivatedCallbackL() + { + FTRACE( FPrint( _L("CRadioEngine::CallActivatedCallbackL()" ) ) ); + // no implementation needed, CRadioEngine::MrpoStateChange handles call startup + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::CallDeactivatedCallbackL +// This callback notifies when call becomes deactive. +// ----------------------------------------------------------------------------- +// +void CRadioEngine::CallDeactivatedCallbackL() + { + FTRACE( FPrint( _L("CRadioEngine::CallDeactivatedCallbackL()" ) ) ); + iInCall = EFalse; + if ( iPubSub ) // if iPubSub exists, then the ConstructL has been successfully completed + { + HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventCallEnded, KErrNone ); + } + } + +// --------------------------------------------------------- +// CRadioEngine::RdsDataProgrammeService +// --------------------------------------------------------- +// +void CRadioEngine::RdsDataProgrammeService( const TDesC& /*aProgramService*/ ) + { + } + +// --------------------------------------------------------- +// CRadioEngine::RdsDataPsNameIsStatic +// --------------------------------------------------------- +// +void CRadioEngine::RdsDataPsNameIsStatic( TBool /*aStatic*/ ) + { + } + +// --------------------------------------------------------- +// CRadioEngine::RdsDataRadioText +// --------------------------------------------------------- +// +void CRadioEngine::RdsDataRadioText( const TDesC& /*aRadioText*/ ) + { + } + +// --------------------------------------------------------- +// CRadioEngine::RdsDataRadioTextPlus +// --------------------------------------------------------- +// +void CRadioEngine::RdsDataRadioTextPlus( const TInt /*aRTPlusClass*/, const TDesC& /*aRadioText*/ ) + { + } + +// --------------------------------------------------------- +// CRadioEngine::RdsAfSearchBegin +// --------------------------------------------------------- +// +void CRadioEngine::RdsAfSearchBegin() + { + iFrequencySetByRdsAf = ETrue; + } + +// --------------------------------------------------------- +// CRadioEngine::RdsAfSearchEnd +// --------------------------------------------------------- +// +void CRadioEngine::RdsAfSearchEnd( TUint32 /*aFrequency*/, TInt aError ) + { + if( aError != KErrNone ) + { + iFrequencySetByRdsAf = EFalse; + } + } + +// --------------------------------------------------------- +// CRadioEngine::RdsAfSearchStateChange +// --------------------------------------------------------- +// +void CRadioEngine::RdsAfSearchStateChange( TBool /*aEnabled*/ ) + { + } + +// --------------------------------------------------------- +// CRadioEngine::RdsAvailable +// --------------------------------------------------------- +// +void CRadioEngine::RdsAvailable( TBool /*aAvailable*/ ) + { + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::InitializeResourceLoadingL +// add resource file information +// ----------------------------------------------------------------------------- +// +void CRadioEngine::InitializeResourceLoadingL() + { + CCoeEnv* coeEnv = CCoeEnv::Static(); + RFs fs( coeEnv->FsSession() ); + TFileName fileName; + TFileName baseResource; + TFindFile finder( fs ); + TLanguage language( ELangNone ); + + TParsePtrC parse( KFMRadioEngineResourceFile ); + _LIT( resourceFileWildExt, ".r*" ); + + // Make sure to find all resource files, not only .rsc files as it may be so + // that there is only .r01, .r02, etc. files available + fileName.Copy( parse.Name() ); + fileName.Append( resourceFileWildExt ); + + // TFindFile applies search order that is from + // drive Y to A, then Z + CDir* entries = NULL; + TInt err = finder.FindWildByDir( fileName , KDC_RESOURCE_FILES_DIR, entries ); + delete entries; + entries = NULL; + TBool found = EFalse; + while ( !found && err == KErrNone ) + { + // Found file + fileName.Zero(); + TParsePtrC foundPath( finder.File() ); + fileName.Copy( foundPath.DriveAndPath() ); + fileName.Append( KFMRadioEngineResourceFile ); + BaflUtils::NearestLanguageFile( fs, fileName, language ); + if ( language != ELangNone && BaflUtils::FileExists( fs, fileName ) ) + { + found = ETrue; + iFMRadioEngineResourceOffset = coeEnv->AddResourceFileL( fileName ); + } + else + { + if ( language == ELangNone && + !baseResource.Compare( KNullDesC ) && + BaflUtils::FileExists( fs, fileName ) ) + { + baseResource.Copy( fileName ); + } + err = finder.FindWild( entries ); + delete entries; + entries = NULL; + } + } + + if ( !found && baseResource.Compare( KNullDesC ) ) + { + // If we found *.rsc then better to use that than nothing + if ( BaflUtils::FileExists( fs, baseResource ) ) + { + iFMRadioEngineResourceOffset = coeEnv->AddResourceFileL( baseResource ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::TunerFrequencyRangeForRegionId +// convert FMRadio region info to tuner utility frequency range +// ----------------------------------------------------------------------------- +// +TFmRadioFrequencyRange CRadioEngine::TunerFrequencyRangeForRegionId( const TInt aRegionId ) const + { + FTRACE( FPrint( _L("CRadioEngine::TunerFrequencyRangeForRegionId(TInt aRegionID = %d)"), aRegionId ) ); + TFmRadioFrequencyRange result = EFmRangeEuroAmerica; + switch( aRegionId ) + { + case EFMRadioRegionDefault: + { + result = EFmRangeEuroAmerica; + break; + } + case EFMRadioRegionJapan: + { + result = EFmRangeJapan; + break; + } + case EFMRadioRegionAmerica: + { + result = EFmRangeEuroAmerica; + break; + } + default: + break; + } + return result; + } + +// ----------------------------------------------------------------------------- +// CRadioEngine::GetRegionL +// determine current region +// ----------------------------------------------------------------------------- +// +EXPORT_C TFMRadioRegionSetting CRadioEngine::GetRegionL() const + { + FTRACE( FPrint( _L("CRadioEngine::GetRegionL()" ) ) ); + TInt regionCount = iCentralRepositoryHandler->CountRegions(); + TFMRadioRegionSetting reg = EFMRadioRegionNone; + + if ( iSystemEventDetector->IsNetworkCoverage() ) + { + TBool countryCodeMatch( EFalse ); + // Choose the frequency range according to country code + const TDesC& countryCode = + iNetworkInfoListener->CountryCode(); + for ( TInt i = 0 ; i < regionCount ; i++ ) + { + const RFMRadioCountryCodeArray& regionCountryCodes = + iCentralRepositoryHandler->Region( i ).CountryCodes(); + + for ( TInt j = 0 ; j < regionCountryCodes.Count() ; j++ ) + { + if ( countryCode == *regionCountryCodes[j] ) + { + // We have a match + countryCodeMatch = ETrue; + reg = iCentralRepositoryHandler->Region(i).Id(); + } + } + } + if ( !countryCodeMatch ) + { + // All regions have been searched and no direct match found, + // use default one + reg = EFMRadioRegionDefault; + } + } + else + { + if ( iCentralRepositoryHandler->RegionId() != EFMRadioRegionNone ) + { + reg = static_cast( + iCentralRepositoryHandler->RegionId() ); + } + } + return reg; + } + +// ---------------------------------------------------- +// CRadioEngine::FillListWithRegionDataL +// fill given list with fmradio regions +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::FillListWithRegionDataL( CDesC16Array& aArray ) const + { + TInt regionCount = iCentralRepositoryHandler->CountRegions(); + + for ( TInt i = 0 ; i < regionCount ; i++ ) + { + aArray.AppendL( iCentralRepositoryHandler->Region( i ).Name() ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::RegionIdAtIndex +// return region from the array of supported regions +// ---------------------------------------------------- +// +EXPORT_C TFMRadioRegionSetting CRadioEngine::RegionIdAtIndex( const TInt aIndex ) const + { + return iCentralRepositoryHandler->Region( aIndex ).Id(); + } + +// ---------------------------------------------------- +// CRadioEngine::RegionId +// Return current region Id. +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::RegionId() const + { + return iCentralRepositoryHandler->RegionId(); + } + +// ---------------------------------------------------- +// CRadioEngine::SetRegionIdL +// Change the the current region Id. +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetRegionIdL( TInt aRegionId ) const + { + if ( iCentralRepositoryHandler->RegionId() != aRegionId ) + { + // Change only when necessary as it changes also the default tuned frequency + //iSetters.SetRegionIdL( aRegionId ); + iCentralRepositoryHandler->SetRegionIdL( aRegionId ); + iPubSub->PublishFrequencyDecimalCountL( + TFMRadioPSFrequencyDecimalCount( iRadioSettings->DecimalCount() ) ); + } + } + +// ---------------------------------------------------- +// CRadioEngine::RequestTunerControl +// request tuner control from RadioFmTunerUtility +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::RequestTunerControl() const + { + // Before first RequestTunerControl() call it is ok to enable offline mode without checking capabilities + iFmTunerUtility->EnableTunerInOfflineMode( ETrue ); + iFmTunerUtility->RequestTunerControl(); + } + +// ---------------------------------------------------- +// CRadioEngine::DecimalCount +// return decimal count for current region MHz information +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::DecimalCount() const + { + return iCentralRepositoryHandler->DecimalCount(); + } + +// ---------------------------------------------------- +// CRadioEngine::FrequencyStepSize +// return step size for tuning. +// ---------------------------------------------------- +// +EXPORT_C TUint32 CRadioEngine::FrequencyStepSize() const + { + return iRadioSettings->FrequencyStepSize(); + } + +// ---------------------------------------------------- +// CRadioEngine::PubSubL +// Returns a reference to P&S interface +// ---------------------------------------------------- +// +EXPORT_C CFMRadioPubSub& CRadioEngine::PubSubL() const + { + User::LeaveIfNull( iPubSub ); + return *iPubSub; + } + +// ---------------------------------------------------- +// CRadioEngine::StartupCount +// increases startup count by one and returns amount of app startups. +// ---------------------------------------------------- +// +EXPORT_C TInt CRadioEngine::UpdatedStartupCount() const + { + FTRACE( FPrint( _L("CRadioEngine::UpdatedStartupCount()" ) ) ); + iCentralRepositoryHandler->IncreaseStartupCount(); + return iRadioSettings->StartupCount(); + } + +// ---------------------------------------------------- +// CRadioEngine::CancelScanLocalStationsScan +// Cancel seek and notify UI +// ---------------------------------------------------- +// +EXPORT_C void CRadioEngine::CancelScanLocalStationsScan() + { + FTRACE( FPrint( _L("CRadioEngine::CancelScanLocalStationsScan()" ) ) ); + CancelScan(); + TInt error = KErrNone; + iStateHandler->Callback( MRadioEngineStateChangeCallback::EFMRadioEventScanLocalStationsCanceled, error ); + } + +// --------------------------------------------------------------------------- +// CRadioEngine::IsAudioRoutingPossible +// Routing is not possible when headset is not available or radio is off +// --------------------------------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::IsAudioRoutingPossible() const + { + FTRACE( FPrint( _L("CRadioEngine::IsAudioRoutingPossible()" ) ) ); + TBool isAudioRoutingPossible = EFalse; + + TBool headsetConnected = iHeadsetObserver->IsHeadsetAccessoryConnected(); + TBool radioOn = iRadioSettings->IsRadioOn(); + + if ( headsetConnected && radioOn ) + { + isAudioRoutingPossible = ETrue; + } + + return isAudioRoutingPossible; + } + +// --------------------------------------------------------------------------- +// CRadioEngine::MusicStoreNoteDisplayed +// --------------------------------------------------------------------------- +// +EXPORT_C TBool CRadioEngine::MusicStoreNoteDisplayed() + { + return iCentralRepositoryHandler->MusicStoreNoteDisplayed(); + } + +// --------------------------------------------------------------------------- +// CRadioEngine::SetMusicStoreNoteDisplayed +// --------------------------------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetMusicStoreNoteDisplayed() + { + iCentralRepositoryHandler->SetMusicStoreNoteDisplayed(); + } + +// --------------------------------------------------------------------------- +// CRadioEngine::MusicStoreNoteDisplayed +// --------------------------------------------------------------------------- +// +EXPORT_C TFMRadioRTPlusLevel CRadioEngine::GetRTPlusSupportLevel() + { + TInt value = iCentralRepositoryHandler->GetRTPlusSupportLevel(); + + //do not return the value directly - make sure we return a valid value + if ( value == EFMRadioAllInteractions ) + { + return EFMRadioAllInteractions; + } + return EFMRadioMusicStoreOnly; + } + +// --------------------------------------------------------------------------- +// CRadioEngine::SetCurrentPresetIndex +// sets current preset index if the preset database changes +// --------------------------------------------------------------------------- +// +EXPORT_C void CRadioEngine::SetCurrentPresetIndex( const TInt aIndex ) + { + TInt maxNumberOfPresets; + iPresetUtility->GetMaxNumberOfPresets( maxNumberOfPresets ); + + if ( ( aIndex >= KErrNotFound ) && ( aIndex < maxNumberOfPresets ) ) + { + iRadioSettings->SetCurrentPreset( aIndex ); + if ( aIndex >= 0 ) + { + // publish current preset + TRAP_IGNORE + ( + TInt frequency = 0; + TStationName name; + iPresetUtility->GetPresetL( aIndex, name, frequency ); + iPubSub->PublishChannelNameL( name ); + iPubSub->PublishChannelL( aIndex ); + ) + } + } + } + +// --------------------------------------------------------------------------- +// CRadioEngine::StoreAndPublishFrequency +// Updates the frequency into settings and P&S +// --------------------------------------------------------------------------- +// +void CRadioEngine::StoreAndPublishFrequency( TInt aFrequency ) + { + iRadioSettings->SetFrequency( aFrequency ); + TRAP_IGNORE( iPubSub->PublishFrequencyL( aFrequency ); ) + } + +// --------------------------------------------------------------------------- +// CRadioEngine::ResetPresetsL +// initialize channel frequencies +// --------------------------------------------------------------------------- +// +void CRadioEngine::ResetPresetsL() + { + FTRACE( FPrint( _L("CRadioEngine::ResetPresetsL()" ) ) ); + TInt maxNumberOfPresets; + TStationName channelName; + TInt channelFrequency; + + iPresetUtility->GetMaxNumberOfPresets( maxNumberOfPresets ); + + for ( TInt i = 0; i < maxNumberOfPresets; i++ ) + { + iPresetUtility->GetPresetL( i, channelName, channelFrequency ); + + if ( channelName.Length() == 0 && channelFrequency != KErrNotFound ) + { + // set empty name and frequency to KErrNotFound + iPresetUtility->SetPresetL( i, channelName, KErrNotFound ); + } + } + } + +// --------------------------------------------------------------------------- +// CRadioEngine::IsBTAccessoryConnectedL +// Returns ETrue if queried accessory is connected +// --------------------------------------------------------------------------- +// +TBool CRadioEngine::IsBTAccessoryConnectedL ( ) + { + FTRACE(FPrint(_L("CRadioEngine::IsBTAccessoryConnectedL ()" ) ) ); + TBool result = EFalse; + CAccMonitor* accMonitor = CAccMonitor::NewLC(); + + RConnectedAccessories connectedAccessories; + CleanupClosePushL( connectedAccessories ); + + accMonitor->GetConnectedAccessoriesL( connectedAccessories ); + CAccMonitorInfo* accInfo = CAccMonitorInfo::NewLC(); + TInt countOfArray = connectedAccessories.Count(); + + for( TInt i = 0; i != countOfArray; i++ ) + { + TAccMonCapability connectionType = connectedAccessories[ i ]->AccPhysicalConnection(); + if( connectionType == KAccMonBluetooth ) + { + accInfo->CopyL( connectedAccessories[ i ] ); + if ( accInfo->Exists(KAccMonStereoAudio) || + accInfo->Exists(KAccMonMonoAudio) ) + { + result = ETrue; + } + } + } + // Destroy the pointers from the array, because those are owned by the client + CleanupStack::PopAndDestroy( accInfo ); + CleanupStack::PopAndDestroy( &connectedAccessories ); + CleanupStack::PopAndDestroy( accMonitor ); + return result; + } +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioenginecentralrepositoryhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioenginecentralrepositoryhandler.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,494 @@ +/* +* 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 implementation of the CCentralRepositoryHandler class. +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include + +#include "fmradioenginecentralrepositoryhandler.h" +#include "fmradioengineradiosettings.h" +#include "fmradioenginecrkeys.h" +#include "debug.h" + + +// CONSTANTS +const TInt KRadioMaxStartupCountToTrack = 5; +// ============================ MEMBER FUNCTIONS =============================== + +// ---------------------------------------------------- +// CCentralRepositoryHandler::CCentralRepositoryHandler +// Default class constructor. +// ---------------------------------------------------- +// +CCentralRepositoryHandler::CCentralRepositoryHandler( + TRadioSettings& aRadioSettings) // a reference to aRadioSettings + :iRadioSettings(&aRadioSettings) + { + FTRACE(FPrint(_L("calling CCentralRepositoryHandler::NewL()"))); + } + +// ---------------------------------------------------- +// CCentralRepositoryHandler::ConstructL +// Second phase class constructor. +// ---------------------------------------------------- +// +void CCentralRepositoryHandler::ConstructL() + { + iCentralRepository = CRepository::NewL( KCRUidFMRadioEngine ); + + RetrieveInitialSettings(); + InitializeRegionsL(); + + #ifdef __WINS__ + SetInitialSettings(); + #endif //__WINS__ + } + +// ---------------------------------------------------- +// CCentralRepositoryHandler::NewL +// Two-phased class constructor. +// ---------------------------------------------------- +// +CCentralRepositoryHandler* CCentralRepositoryHandler::NewL( + TRadioSettings& aRadioSettings) // a reference to aRadioSettings + { + CCentralRepositoryHandler *self = new(ELeave) CCentralRepositoryHandler(aRadioSettings); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------- +// CCentralRepositoryHandler::~CCentralRepositoryHandler +// Destructor of CCentralRepositoryHandler class. +// ---------------------------------------------------- +// +CCentralRepositoryHandler::~CCentralRepositoryHandler() + { + iRadioSettings = NULL; + if ( iCentralRepository ) + { + delete iCentralRepository; + } + iRegions.ResetAndDestroy(); + iRegions.Close(); + } + + +// ---------------------------------------------------- +// CCentralRepositoryHandler::RetrieveInitialSettings +// Retrieves persistent settings from shared data. +// Returns: None +// ---------------------------------------------------- +// +void CCentralRepositoryHandler::RetrieveInitialSettings() + { + FTRACE(FPrint(_L("calling CCentralRepositoryHandler::RetrieveInitialSettings() Start"))); + TInt tempData; + + if ( iCentralRepository->Get( KRadioHeadsetVolume, tempData ) == KErrNone ) + { + iRadioSettings->SetHeadsetVolume( tempData ); + } + + if ( iCentralRepository->Get( KRadioSpeakerVolume, tempData ) == KErrNone ) + { + iRadioSettings->SetSpeakerVolume( tempData ); + } + + if ( iCentralRepository->Get( KFmRadioFrequency, tempData ) == KErrNone ) + { + iRadioSettings->SetFrequency( tempData ); + } + + if ( iCentralRepository->Get( KFmRadioChannel, tempData ) == KErrNone ) + { + iRadioSettings->SetCurrentPreset( tempData ); + } + + if ( iCentralRepository->Get( KFmRadioMode, tempData ) == KErrNone) + { + iRadioSettings->SetRadioMode( static_cast( tempData ) ); + } + + if ( iCentralRepository->Get( KFMCRCurrentRegion, tempData ) != KErrNone ) + { + iCentralRepository->Set( KFMCRCurrentRegion, KErrNotFound ); + } + + if ( iCentralRepository->Get( KRadioCRStartupCount, tempData ) == KErrNone ) + { + iRadioSettings->SetStartupCount( tempData ); + } + + if ( iCentralRepository->Get( KFMCRRdsAfSearchEnabled, tempData ) == KErrNone ) + { + if ( static_cast ( tempData ) ) + { + iRadioSettings->SetRdsAfSearchEnabled(); + } + else + { + iRadioSettings->SetRdsAfSearchDisabled(); + } + } + + if ( iCentralRepository->Get( KFMCRJapanRegionAllowed, tempData ) == KErrNone ) + { + iRadioSettings->SetJapanRegionAllowed( static_cast( tempData ) ); + } + } + +#ifdef __WINS__ +// ---------------------------------------------------- +// CCentralRepositoryHandler::SetInitialSettings +// Set network info for emulator testing purposes +// ---------------------------------------------------- +// +void CCentralRepositoryHandler::SetInitialSettings() + { + _LIT(KNetworkInfoForEmulator, "358123"); + iCentralRepository->Set( KFMRadioCREmulatorNetworkInfo, KNetworkInfoForEmulator ); + } +#endif //__WINS__ + +// ---------------------------------------------------- +// CCentralRepositoryHandler::SaveEngineSettings +// Save all engine related persistent info back to shared data +// Returns: None +// ---------------------------------------------------- +// +void CCentralRepositoryHandler::SaveEngineSettings() + { + if ( IsFrequencyValid( iRadioSettings->Frequency() / KFMRadioFreqMultiplier ) ) + { + iCentralRepository->Set( KFmRadioFrequency, iRadioSettings->Frequency() ); + } + else + { + TInt freq = MinFrequency() * KFMRadioFreqMultiplier; + iCentralRepository->Set( KFmRadioFrequency, freq ); + } + + iCentralRepository->Set( KFmRadioChannel, iRadioSettings->CurrentPreset() ); + iCentralRepository->Set( KFmRadioMode, iRadioSettings->RadioMode() ); + iCentralRepository->Set( KFMCRRdsAfSearchEnabled, iRadioSettings->IsRdsAfSearchEnabled() ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::CountRegions +// Return count of fmradio regions in regions array +// --------------------------------------------------------------------------- +// +TInt CCentralRepositoryHandler::CountRegions() const + { + return iRegions.Count(); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::Region +// Returns fmradio region at given index +// --------------------------------------------------------------------------- +// +CFMRadioRegion& CCentralRepositoryHandler::Region( TInt aIndex ) const + { + if( aIndex == KErrNotFound ) + { + aIndex = RegionIndexForId( static_cast( EFMRadioRegionDefault ) ); + } + + return *iRegions[aIndex]; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::RegionId +// Return current region Id. +// --------------------------------------------------------------------------- +// +TInt CCentralRepositoryHandler::RegionId() const + { + TInt regionId; + iCentralRepository->Get( KFMCRCurrentRegion, regionId ); + return regionId; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::SetRegionIdL +// Change the the current region Id. +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::SetRegionIdL( TInt aRegion ) + { + iCentralRepository->Set( KFMCRCurrentRegion, aRegion ); + UpdateCurrentRegionIdx( aRegion ); + + iRadioSettings->SetFrequency( Region( iCurrentRegionIdx ).MinFrequency() * KFMRadioFreqMultiplier ); + iRadioSettings->SetMinFrequency( MinFrequency() ); + iRadioSettings->SetMaxFrequency( MaxFrequency() ); + iRadioSettings->SetFrequencyStepSize( FrequencyStepSize() ); + iRadioSettings->SetDecimalCount( DecimalCount() ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::FrequencyStepSize +// Returns frequency step size used for current region +// --------------------------------------------------------------------------- +// +TUint32 CCentralRepositoryHandler::FrequencyStepSize() const + { + return Region( iCurrentRegionIdx ).StepSize(); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::MaxFrequency +// Returns highest allowed frequency for current region +// --------------------------------------------------------------------------- +// +TUint32 CCentralRepositoryHandler::MaxFrequency() const + { + return Region( iCurrentRegionIdx ).MaxFrequency(); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::MinFrequency +// Returns lowest allowed frequency for current region +// --------------------------------------------------------------------------- +// +TUint32 CCentralRepositoryHandler::MinFrequency() const + { + return Region( iCurrentRegionIdx ).MinFrequency(); + } +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::DecimalCount +// return decimal count for current region Mhz information +// --------------------------------------------------------------------------- +// +TInt CCentralRepositoryHandler::DecimalCount() const + { + return Region( iCurrentRegionIdx ).DecimalCount(); + } + + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::InitializeRegionsL +// Initializes the regions based on resources. +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::InitializeRegionsL() + { + iRegions.ResetAndDestroy(); + + TResourceReader reader; + + CCoeEnv* coeEnv = CCoeEnv::Static(); + + if ( iRadioSettings->IsJapanRegionAllowed() ) + { + coeEnv->CreateResourceReaderLC( reader, R_RADIO_REGIONS_ALL ); + } + else // Japan region is not allowed so read region resources without Japan + { + coeEnv->CreateResourceReaderLC( reader, R_RADIO_REGIONS_WITHOUT_JAPAN ); + } + + TInt regionCount = reader.ReadInt16(); + + for( TInt i = 0 ; i < regionCount; i++ ) + { + TInt resId = reader.ReadInt32(); // The next resource ID to read. + TResourceReader regionReader; + coeEnv->CreateResourceReaderLC( regionReader, resId ); + User::LeaveIfError( iRegions.Append( CFMRadioRegion::NewL( regionReader ) ) ); + CleanupStack::PopAndDestroy(); + } + + CleanupStack::PopAndDestroy(); + + UpdateCurrentRegionIdx( RegionId() ); + + iRadioSettings->SetMinFrequency( MinFrequency() * KFMRadioFreqMultiplier ); + iRadioSettings->SetMaxFrequency( MaxFrequency() * KFMRadioFreqMultiplier ); + iRadioSettings->SetFrequencyStepSize( FrequencyStepSize() ); + iRadioSettings->SetDecimalCount( DecimalCount() ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::RegionIndexForId +// Converts Region ID to index +// --------------------------------------------------------------------------- +// +TInt CCentralRepositoryHandler::RegionIndexForId( TInt aRegionId ) const + { + TInt idx = KErrNotFound; + for( TInt i = 0 ; i < CountRegions(); i++ ) + { + if( Region( i ).Id() == static_cast( aRegionId ) ) + { + idx = i; + /*lint -save -e960 (Note -- Violates MISRA Required Rule 58, non-switch break used)*/ + break; + /*lint -restore*/ + } + } + return idx; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::UpdateCurrentRegionIdx +// Updates the current region +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::UpdateCurrentRegionIdx( TInt aRegionId ) + { + iCurrentRegionIdx = RegionIndexForId( aRegionId ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::IsOfflineProfileActiveL +// Checks if offine profile is current active profile +// Returns: true/false +// --------------------------------------------------------------------------- +// +TBool CCentralRepositoryHandler::IsOfflineProfileActiveL() + { + CRepository* repository = CRepository::NewLC( KCRUidProfileEngine ); + + TInt profileId(0); + + // Get ID of current profile + User::LeaveIfError( repository->Get( KProEngActiveProfile, profileId ) ); + + CleanupStack::PopAndDestroy( repository ); + + // Check value to determine the active profile + // 5 = Offline profile + if ( profileId == 5 ) + { + // Current profile is the offline profile + return ETrue; + } + + return EFalse; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::IsFrequencyValid +// Checks if frequency is in the current region range +// --------------------------------------------------------------------------- +// +TBool CCentralRepositoryHandler::IsFrequencyValid( TUint32 aFrequency ) const + { + TBool ret( EFalse ); + if( !aFrequency ) + { + aFrequency = iRadioSettings->Frequency(); + } + if ( aFrequency >= MinFrequency() && aFrequency <= MaxFrequency() ) + { + ret = ETrue; + } + return ret; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::IncreaseStartupCount +// Increases startup time by one and sets the value to the repository +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::IncreaseStartupCount() const + { + TInt startCount = iRadioSettings->StartupCount(); + // Dont update if maximum tracking count is reached + if ( startCount < KRadioMaxStartupCountToTrack ) + { + startCount++; + iRadioSettings->SetStartupCount( startCount ); + iCentralRepository->Set( KRadioCRStartupCount, startCount ); + } + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::SaveHeadsetVolumeSetting +// Save headset volume level to the repository +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::SaveHeadsetVolumeSetting() const + { + FTRACE( FPrint(_L("CCentralRepositoryHandler::SaveHeadsetVolumeSetting()") ) ); + iCentralRepository->Set( KRadioHeadsetVolume, iRadioSettings->HeadsetVolume() ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::SaveSpeakerVolumeSetting +// Save speaker volume level to the repository +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::SaveSpeakerVolumeSetting() const + { + FTRACE( FPrint(_L("CCentralRepositoryHandler::SaveSpeakerVolumeSetting()") ) ); + iCentralRepository->Set( KRadioSpeakerVolume, iRadioSettings->SpeakerVolume() ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::MusicStoreNoteDisplayed +// --------------------------------------------------------------------------- +// +TBool CCentralRepositoryHandler::MusicStoreNoteDisplayed() + { + TBool result; + TInt err = iCentralRepository->Get( KRadioMusicStoreNoteDisplayed, result ); + if ( err != KErrNone ) + { + result = EFalse; + } + return result; + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::SetMusicStoreNoteDisplayed +// --------------------------------------------------------------------------- +// +void CCentralRepositoryHandler::SetMusicStoreNoteDisplayed() + { + iCentralRepository->Set( KRadioMusicStoreNoteDisplayed, 1 ); + } + +// --------------------------------------------------------------------------- +// CCentralRepositoryHandler::GetRTPlusSupportLevel +// --------------------------------------------------------------------------- +// +TInt CCentralRepositoryHandler::GetRTPlusSupportLevel() + { + //See fmradioengine.hrh:TFMRadioRTPlusLevel for correct values + TInt result; + TInt err = iCentralRepository->Get( KRadioRTPlusSupportLevel, result ); + if ( err != KErrNone ) + { + result = KErrNotFound; + } + + return result; + } + +// end of file + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioenginedosserverobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioenginedosserverobserver.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies 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 the CDosServerObserver class. which is the +* notification interface to the DOS Server. +* +*/ + + +// INCLUDES +#include + +#include "debug.h" +#include "fmradioengine.h" +#include "fmradioengineradiosettings.h" +#include "fmradioenginedosserverobserver.h" + +// ---------------------------------------------------- +// CDosServerObserver::CDosServerObserver +// Default class constructor. +// ---------------------------------------------------- +// +CDosServerObserver::CDosServerObserver(CRadioEngine* aEngine, TRadioSettings* aRadioSettings) + : iEngine(aEngine), iRadioSettings(aRadioSettings) + { + } + +// ---------------------------------------------------- +// CDosServerObserver::NewL +// Two-phased class constructor. +// ---------------------------------------------------- +// +CDosServerObserver *CDosServerObserver::NewL(CRadioEngine* aEngine, TRadioSettings* aRadioSettings) + { + CDosServerObserver *self = new (ELeave)CDosServerObserver(aEngine, aRadioSettings); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// ---------------------------------------------------- +// CDosServerObserver::ConstructL +// Second phase class constructor. +// ---------------------------------------------------- +// +void CDosServerObserver::ConstructL() + { + iRadioSettings->SetHeadsetConnected(); + RDosServer* server = const_cast< RDosServer* >( &DosServer() ); + User::LeaveIfError( iDosAudio.Open(*server) ); + TRegisterEvent eventList[] = {{KHandsfreeModeChanged, sizeof(EPSHandsFreeMode),EOnlyLast}, {KHeadsetButtonChanged,sizeof(EPSButtonState), EQueue} }; + StartListeningL(eventList,sizeof(eventList)/sizeof(TRegisterEvent)); + } + +// ---------------------------------------------------- +// CDosServerObserver::~CDosServerObserver +// Destructor of CDosServerObserver class. +// ---------------------------------------------------- +// +CDosServerObserver::~CDosServerObserver() + { + Stop(); + } + + +// --------------------------------------------------------- +// CDosServerObserver::SetAudioRouting +// --------------------------------------------------------- +// +TInt CDosServerObserver::SetAudioRouting(CRadioEngine::TFMRadioAudioOutput aAudioOutput) + { + TInt err(KErrNone); + EPSHandsFreeMode mode = (aAudioOutput == CRadioEngine::EFMRadioOutputHeadset) ? EPSIhfOff : EPSIhfOn; + err = iDosAudio.SetHandsfreeMode(mode); + return err; + } + +// --------------------------------------------------------- +// CDosServerObserver::HeadsetButtonChangedL +// Handling notification about headset button state change. +// (other items were commented in a header). +// Status : Draft/Proposal/Approved +// --------------------------------------------------------- +// +void CDosServerObserver::HeadsetButtonChangedL(EPSButtonState aState) + { + if(aState == EPSButtonUp) + { + iEngine->HandleHeadsetButtonPress(); + } + + } +// end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioengineradiosettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioengineradiosettings.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,490 @@ +/* +* 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 implementation of the TRadioSettings class, which holds +* the RadioEngine settings. +* +*/ + + +// INCLUDES +#include "fmradioengine.h" +#include "fmradioengineradiosettings.h" + + +// ============================ MEMBER FUNCTIONS =============================== + +// ---------------------------------------------------- +// TRadioSettings::TRadioSettings +// Default class constructor. +// ---------------------------------------------------- +// +TRadioSettings::TRadioSettings(): + iFMRadioHeadsetVolume( KDefaultRadioVolume ), + iFMRadioSpeakerVolume( KDefaultRadioVolume ), + iCurrentPreset( 0 ), + iFrequency( KDefaultRadioFrequency ), + iMaxFrequency( 0 ), + iMinFrequency( 0 ), + iFrequencyStepSize( 0 ), + iDecimalCount( 0 ), + iAudioMode( CRadioEngine::EFMRadioStereo ), + iAudioOutput(CRadioEngine::EFMRadioOutputHeadset ), + iMuteOn(EFalse), + iRadioOn( EFalse), + iRadioMode( CRadioEngine::ERadioPresetMode ), + iIsHeadsetConnected( EFalse ), + iFlightModeEnabled( EFalse ), + iStartupCount( 0 ), + iRdsAfSearchEnabled( EFalse ), + iJapanRegionAllowed( ETrue ) + { + } + +// ---------------------------------------------------- +// TRadioSettings::Volume +// retrieve current headset volume level +// Returns: iFMRadioHeadsetVolume: headset volume +// ---------------------------------------------------- +// +TInt TRadioSettings::HeadsetVolume() const + { + return iFMRadioHeadsetVolume; + } + +// ---------------------------------------------------- +// TRadioSettings::SpeakerVolume +// retrieve current speaker volume level +// Returns: iFMRadioSpeakerVolume: speaker volume +// ---------------------------------------------------- +// +TInt TRadioSettings::SpeakerVolume() const + { + return iFMRadioSpeakerVolume; + } + +// ---------------------------------------------------- +// TRadioSettings::CurrentPreset +// retrieve currently selected channel +// Returns: iCurrentPreset: current preset index number +// ---------------------------------------------------- +// +TInt TRadioSettings::CurrentPreset() const + { + return iCurrentPreset; + } + +// ---------------------------------------------------- +// TRadioSettings::Frequency +// retrieve current frequency +// Returns: iFrequency: current frequency +// ---------------------------------------------------- +// +TInt TRadioSettings::Frequency() const + { + return iFrequency; + } + +// ---------------------------------------------------- +// TRadioSettings::MaxFrequency +// retrieve max frequency +// ---------------------------------------------------- +// +TUint32 TRadioSettings::MaxFrequency() const + { + return iMaxFrequency; + } + +// ---------------------------------------------------- +// TRadioSettings::MinFrequency +// retrieve min frequency +// ---------------------------------------------------- +// +TUint32 TRadioSettings::MinFrequency() const + { + return iMinFrequency; + } + +// ---------------------------------------------------- +// TRadioSettings::FrequencyStepSize +// return step size for tuning +// ---------------------------------------------------- +// +TUint32 TRadioSettings::FrequencyStepSize() const + { + return iFrequencyStepSize; + } + +// ---------------------------------------------------- +// TRadioSettings::DecimalCount +// Returns decimal count for current region MHz information +// ---------------------------------------------------- +// +TInt TRadioSettings::DecimalCount() const + { + return iDecimalCount; + } + +// ---------------------------------------------------- +// TRadioSettings::AudioMode +// retrieve current audio mode (stereo or mono) +// Returns: iAudioMode: current mode +// ---------------------------------------------------- +// +CRadioEngine::TFMRadioAudioMode TRadioSettings::AudioMode() const + { + return iAudioMode; + } + +// ---------------------------------------------------- +// TRadioSettings::AudioOutput +// retrieve current audio output (headset/ihf) +// Returns: iAudioOutput: current audio output +// ---------------------------------------------------- +// +CRadioEngine::TFMRadioAudioOutput TRadioSettings::AudioOutput() const + { + return iAudioOutput; + } + +// ---------------------------------------------------- +// TRadioSettings::IsMuteOn +// retrieve current mute state (on/off) +// Returns: iMuteOn: mute flag +// ---------------------------------------------------- +// +TBool TRadioSettings::IsMuteOn() const + { + return iMuteOn; + } + +// ---------------------------------------------------- +// TRadioSettings::IsRadioOn +// retrieve current radio on state (on/off) +// Returns: iRadioOn: a flag indicating radio on/off +// ---------------------------------------------------- +// +TBool TRadioSettings::IsRadioOn() const + { + return iRadioOn; + } + +// ---------------------------------------------------- +// TRadioSettings::RadioMode +// retrieve the current radio mode (preset or direct frequency) +// Returns: iRadioMode: a flag indicating radio mode +// ---------------------------------------------------- +// +CRadioEngine::TRadioMode TRadioSettings::RadioMode() const + { + return iRadioMode; + } + +// ---------------------------------------------------- +// TRadioSettings::IsHeadsetConnected +// retrieve the current headset mode (connected or disconnected) +// Returns: iIsHeadsetConnected: a flag indicating if headset is connected +// ---------------------------------------------------- +// +TBool TRadioSettings::IsHeadsetConnected() const + { + return iIsHeadsetConnected; + } + +// ---------------------------------------------------- +// TRadioSettings::IsFlightModeEnabled +// retrieve the current flight mode status (on/off) +// Returns: iFlightModeEnabled: a flag indicating if flight mode is enabled +// ---------------------------------------------------- +// +TBool TRadioSettings::IsFlightModeEnabled() const + { + return iFlightModeEnabled; + } + +// ---------------------------------------------------- +// TRadioSettings::IsRdsAfSearchEnabled +// ---------------------------------------------------- +// +EXPORT_C TBool TRadioSettings::IsRdsAfSearchEnabled() + { + return iRdsAfSearchEnabled; + } + +// ---------------------------------------------------- +// TRadioSettings::SetHeadsetVolume +// set the current fm radio headset volume +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetHeadsetVolume( + const TInt aVolume) // the new volume + { + iFMRadioHeadsetVolume = aVolume; + } + +// ---------------------------------------------------- +// TRadioSettings::SetSpeakerVolume +// set the current fm radio speaker volume +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetSpeakerVolume( + const TInt aVolume) // new volume + { + iFMRadioSpeakerVolume = aVolume; + } + + +// ---------------------------------------------------- +// TRadioSettings::SetCurrentPreset +// set the current preset +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetCurrentPreset( + const TInt aChannel) //new channel to be set + { + iCurrentPreset = aChannel; + } + +// ---------------------------------------------------- +// TRadioSettings::SetFrequency +// set the current frequency +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetFrequency( + const TInt aFrequency) // new frequency + { + iFrequency = aFrequency; + // if (iFrequency < 87500000 || iFrequency > 108000000) + // iFrequency = 87500000; + } + +// ---------------------------------------------------- +// TRadioSettings::SetMaxFrequency +// set the max frequency +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetMaxFrequency( const TUint32 aMaxFrequency ) + { + iMaxFrequency = aMaxFrequency; + } + +// ---------------------------------------------------- +// TRadioSettings::SetMinFrequency +// set min frequency +// Returns: none +// ---------------------------------------------------- +// + void TRadioSettings::SetMinFrequency( const TUint32 aMinFrequency ) + { + iMinFrequency = aMinFrequency; + } + + // ---------------------------------------------------- + // TRadioSettings::SetFrequencyStepSize + // set step size for manual tuning. + // Returns: none + // ---------------------------------------------------- + // + void TRadioSettings::SetFrequencyStepSize( const TUint32 aFrequencyStepSize ) + { + iFrequencyStepSize = aFrequencyStepSize; + } + + // ---------------------------------------------------- + // TRadioSettings::SetDecimalCount + // Set decimal count for current region MHz information + // Returns: none + // ---------------------------------------------------- + // + void TRadioSettings::SetDecimalCount( const TInt aDecimalCount ) + { + iDecimalCount = aDecimalCount; + } + +// ---------------------------------------------------- +// TRadioSettings::SetAudioMode +// set the current audio mode +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetAudioMode( + const CRadioEngine::TFMRadioAudioMode aAudioMode) // new audio mode + { + iAudioMode = aAudioMode; + } + +// ---------------------------------------------------- +// TRadioSettings::SetAudioOutput +// set the current audio output +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetAudioOutput( + const CRadioEngine::TFMRadioAudioOutput aAudioOutput) // new audio output + { + iAudioOutput = aAudioOutput; + } + +// ---------------------------------------------------- +// TRadioSettings::SetMuteOn +// set mute state to on +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetMuteOn() + { + iMuteOn = ETrue; + } + +// ---------------------------------------------------- +// TRadioSettings::SetMuteOff +// set mute state to off +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetMuteOff() + { + iMuteOn = EFalse; + } + +// ---------------------------------------------------- +// TRadioSettings::SetRadioOn +// set radio state to "on" +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetRadioOn() + { + iRadioOn = ETrue; + } + +// ---------------------------------------------------- +// TRadioSettings::SetRadioOff +// set radio state to "off" +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetRadioOff() + { + iRadioOn = EFalse; + } + +// ---------------------------------------------------- +// TRadioSettings::SetRadioMode +// set radio mode +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetRadioMode( + const CRadioEngine::TRadioMode aRadioMode) // new radio mode + { + iRadioMode = aRadioMode; + } + +// ---------------------------------------------------- +// TRadioSettings::SetHeadsetConnected +// set headset connected +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetHeadsetConnected() + { + iIsHeadsetConnected = ETrue; + } + +// ---------------------------------------------------- +// TRadioSettings::SetHeadsetDisconnected +// set headset disconnected +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetHeadsetDisconnected() + { + iIsHeadsetConnected = EFalse; + } + +// ---------------------------------------------------- +// TRadioSettings::SetFlightMode +// set flightmode status +// Returns: none +// ---------------------------------------------------- +// +void TRadioSettings::SetFlightMode( + TBool aEnabled) // indicating enable/disable + { + iFlightModeEnabled = aEnabled; + } + +// ---------------------------------------------------- +// TRadioSettings::SetStartupCount +// set startup count +// ---------------------------------------------------- +// +void TRadioSettings::SetStartupCount( const TInt aStartupCount ) + { + iStartupCount = aStartupCount; + } + +// ---------------------------------------------------- +// TRadioSettings::StartupCount +// return startup count +// ---------------------------------------------------- +// +TInt TRadioSettings::StartupCount() const + { + return iStartupCount; + } + +// ---------------------------------------------------- +// TRadioSettings::SetRdsAfSearchEnabled +// ---------------------------------------------------- +// +void TRadioSettings::SetRdsAfSearchEnabled() + { + iRdsAfSearchEnabled = ETrue; + } + +// ---------------------------------------------------- +// TRadioSettings::SetRdsAfSearchDisabled +// ---------------------------------------------------- +// +void TRadioSettings::SetRdsAfSearchDisabled() + { + iRdsAfSearchEnabled = EFalse; + } + +// ---------------------------------------------------- +// TRadioSettings::SetJapanRegionAllowed +// ---------------------------------------------------- +// +void TRadioSettings::SetJapanRegionAllowed( const TBool aAllowed ) + { + iJapanRegionAllowed = aAllowed; + } + +// ---------------------------------------------------- +// TRadioSettings::IsJapanRegionAllowed +// ---------------------------------------------------- +// +TBool TRadioSettings::IsJapanRegionAllowed() const + { + return iJapanRegionAllowed; + } + +// end of file + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioengineradiostatehandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioengineradiostatehandler.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,133 @@ +/* +* 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 class implements the powerup/down, and scan and store +* state machines. +* +*/ + + +// INCLUDES +#include + +#include "fmradioengineradiostatehandler.h" +#include "fmradioengine.h" +#include "debug.h" + + +// ============================ MEMBER FUNCTIONS =============================== + +// ---------------------------------------------------- +// CRadioStateHandler::CRadioStateHandler +// c++ default constructor +// ---------------------------------------------------- +// +CRadioStateHandler::CRadioStateHandler(CRadioEngine* aEngine) + : CActive(EPriorityStandard), iEngine(aEngine) + { + CActiveScheduler::Add(this); + } + +// ---------------------------------------------------- +// CRadioStateHandler::ConstructL +// 2nd phase constructor +// ---------------------------------------------------- +// +void CRadioStateHandler::ConstructL() + { + } + +// ---------------------------------------------------- +// CRadioStateHandler::NewL +// Method for creating new instances of this class. +// ---------------------------------------------------- +// +CRadioStateHandler* CRadioStateHandler::NewL( + CRadioEngine* aEngine) //a pointer to CRadioEngine object + { + CRadioStateHandler *self = new(ELeave) CRadioStateHandler(aEngine); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// Destructor +CRadioStateHandler::~CRadioStateHandler() + { + Cancel(); + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ---------------------------------------------------- +// CRadioStateHandler::Callback +// Trigger the active object to call the client callback function +// Returns: None +// ---------------------------------------------------- +// +void CRadioStateHandler::Callback( + MRadioEngineStateChangeCallback::TFMRadioNotifyEvent aEventCode, // a event code + TInt aErrorCode ) // a error code + { + iCallbackEventCode = aEventCode; + iCallbackErrorCode = aErrorCode; + Cancel(); + SetActive(); + TRequestStatus* status=&iStatus; + User::RequestComplete(status, KRadioStateEventCallback); + } + + +// ---------------------------------------------------- +// CRadioStateHandler::DoCancel +// Cancel the timeout timer. This generally means that a +// response was received, so the timeout is no longer needed. +// Returns: None +// ---------------------------------------------------- +// +void CRadioStateHandler::DoCancel() + { + } + +// ---------------------------------------------------- +// CRadioStateHandler::RunL +// State Change Request/timeout handler +// Returns: None +// ---------------------------------------------------- +// +void CRadioStateHandler::RunL() + { + FTRACE(FPrint(_L("inside runL()"))); + + if (iStatus.Int() == KRadioStateEventCallback) + { + iEngine->HandleCallback(iCallbackEventCode, iCallbackErrorCode); + } + } + +// --------------------------------------------------------- +// CRadioStateHandler::RunError +// handle any errors that occur in the RunL +// Returns: aError: the error code +// --------------------------------------------------------- +// +TInt CRadioStateHandler::RunError( + TInt aError ) // error code + { + FTRACE( FPrint( _L("CRadioStateHandler::RunError()") ) ); + return aError; + } + + // end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiomobilenetworkinfolistener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiomobilenetworkinfolistener.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,371 @@ +/* +* Copyright (c) 2004-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: Gets country code and network info from mobile network +* +*/ + + +// INCLUDES +#ifdef __WINS__ +#include +#else +#include +#include +#include +#include +#endif + +#include "fmradionetworkchangeobserver.h" +#include "fmradiomobilenetworkinfolistener.h" +#include "fmradioenginecrkeys.h" + +using namespace CommsDat; + + +#ifdef __WINS__ +// Default size for the cenrep query +const TInt KFMRadioDefaultNetworkInfoBufferSize = 0x80; +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +#ifdef __WINS__ +CFMRadioMobileNetworkInfoListener::CFMRadioMobileNetworkInfoListener(MFMRadioNetworkChangeObserver & aObserver) : + CActive(CActive::EPriorityStandard), iNetworkChangeObserver(aObserver) +#else +CFMRadioMobileNetworkInfoListener::CFMRadioMobileNetworkInfoListener(MFMRadioNetworkChangeObserver & aObserver) : + CActive(CActive::EPriorityStandard), iNetworkChangeObserver(aObserver), iNetworkInfo(), iNetworkInfoPckg(iNetworkInfo) +#endif + { + } + +// EPOC default constructor can leave. +void CFMRadioMobileNetworkInfoListener::ConstructL() + { + +#ifdef __WINS__ + iSubscriberId = KNullDesC().AllocL(); + + TRAPD( err, iRepository = CRepository::NewL( KCRUidFMRadioEngine ) ) + if ( err == KErrNotFound ) + { + // Central Repository not found, so don't request a notification + } + else if ( err != KErrNone ) + { + User::Leave( err ); + } + else + { + // Read initial values from Central Repository + GetCenRepNetworkInfoL(); + SaveNetworkInfo(); + // Start listening + CActiveScheduler::Add( this ); + User::LeaveIfError( iRepository->NotifyRequest( KFMRadioCREmulatorNetworkInfo, iStatus ) ); + SetActive(); + } +#else + // Get default TSY from database. + + CMDBSession * db = CMDBSession::NewL(CMDBSession::LatestVersion()); + CleanupStack::PushL(db); + + CMDBRecordSet * set = new (ELeave) CMDBRecordSet(KCDTIdModemBearerRecord); + CleanupStack::PushL(set); + + set->LoadL(*db); + + TInt index = 0; + CCDModemBearerRecord * record = static_cast(set->iRecords[index++]); + + if(record->iTsyName.IsNull() && set->iRecords.Count() > index) // the first item is normally only a template + { + record = static_cast(set->iRecords[index++]); + } + + TPtrC name(static_cast(record->iTsyName)); + TBuf tsyName; + tsyName.Copy(name); + + CleanupStack::PopAndDestroy(set); + CleanupStack::PopAndDestroy(db); + + // Open phone + User::LeaveIfError(iTelServer.Connect()); + + // TSY module gets automatically unloaded when tel.Close() is called ( and tel is is CU-stack), + // so loaded TSY is also leave-safe + User::LeaveIfError(iTelServer.LoadPhoneModule(tsyName)); + + // Get number of phones. + TInt phones(0); + User::LeaveIfError(iTelServer.EnumeratePhones(phones)); + + // Get phone info of first legal phone. + TInt legalPhoneIndex = KErrNotFound; + RTelServer::TPhoneInfo phoneInfo; + for (TInt i=0; iConstructL(); + CleanupStack::Pop(); + return self; + } + + +// Destructor +CFMRadioMobileNetworkInfoListener::~CFMRadioMobileNetworkInfoListener() + { + Cancel(); +#ifdef __WINS__ + delete iRepository; + delete iEmulatorNetworkInfo; +#else + iPhone.Close(); + iTelServer.Close(); +#endif + delete iSubscriberId; + } + + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::RunL +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioMobileNetworkInfoListener::RunL() + { +#ifdef __WINS__ + GetCenRepNetworkInfoL(); + SaveNetworkInfo(); + + User::LeaveIfError( iRepository->NotifyRequest( KFMRadioCREmulatorNetworkInfo, iStatus ) ); + SetActive(); +#else + TInt statusCode = iStatus.Int(); + if (statusCode == KErrNone) // No other codes are returned (except error). + { + SaveNetworkInfo(); + } + // Start new notify request. + iPhone.NotifyCurrentNetworkChange(iStatus, iNetworkInfoPckg, iLocation); + SetActive(); +#endif + } + + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::DoCancel +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioMobileNetworkInfoListener::DoCancel() + { +#ifdef __WINS__ + iRepository->NotifyCancel( KFMRadioCREmulatorNetworkInfo ); +#else + iPhone.CancelAsyncRequest(EMobilePhoneNotifyCurrentNetworkChange); +#endif + } + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::SaveNetworkInfo +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CFMRadioMobileNetworkInfoListener::SaveNetworkInfo() + { +#ifdef __WINS__ + // iEmulatorNetworkInfo contains country code + network ID + if ( iEmulatorNetworkInfo && iEmulatorNetworkInfo->Length() > KFMRadioCREmulatorCountryCodeLength ) + { + iCountryCode.Copy( iEmulatorNetworkInfo->Left( KFMRadioCREmulatorCountryCodeLength ) ); + iNetworkId.Copy( iEmulatorNetworkInfo->Mid( KFMRadioCREmulatorCountryCodeLength, + Min( iEmulatorNetworkInfo->Length() - KFMRadioCREmulatorCountryCodeLength, + iNetworkId.MaxLength() ) ) ); + } + else + { + iCountryCode.Zero(); + iNetworkId.Zero(); + } +#else + iNetworkInfo = iNetworkInfoPckg(); + iNetworkId.Copy(iNetworkInfo.iNetworkId); + iCountryCode.Copy(iNetworkInfo.iCountryCode); +#endif + + // Create combine network ID and country code. + TBuf<20> compNetworkId; + compNetworkId.Append(iCountryCode); + // have to add '0' digit to the string to get correct id + // 24401 instead 2441, for example + if(iNetworkId.Length() < 2) + { + compNetworkId.AppendNum(static_cast(0)); + } + compNetworkId.Append(iNetworkId); + TLex lexer(compNetworkId); + lexer.Val(iCompoundNetworkId); + if(iCompoundNetworkId != 0 && iPreviousCompoundNetworkId != iCompoundNetworkId) + { + if(iPreviousCompoundNetworkId != 0) + { + iNetworkChangeObserver.NetworkIdChanged(); + } + iPreviousCompoundNetworkId = iCompoundNetworkId; + } + } + + +// --------------------------------------------------------------------------- +// Reads network info from Central Repository +// --------------------------------------------------------------------------- +// +#ifdef __WINS__ +void CFMRadioMobileNetworkInfoListener::GetCenRepNetworkInfoL() + { + TInt length = KFMRadioDefaultNetworkInfoBufferSize; + HBufC* valueString = HBufC::NewLC( length ); + TInt error( KErrTooBig ); + + do + { + TPtr ptr = valueString->Des(); + + error = iRepository->Get( KFMRadioCREmulatorNetworkInfo, ptr ); + if ( error == KErrTooBig ) + { + CleanupStack::PopAndDestroy( valueString ); + length = 2 * length; + valueString = HBufC::NewLC( length ); + } + } while ( error == KErrTooBig ); + + if ( error ) + { + TPtr ptr = valueString->Des(); + ptr.Copy( KNullDesC() ); + } + + CleanupStack::Pop( valueString ); + delete iEmulatorNetworkInfo; + iEmulatorNetworkInfo = valueString; + } +#endif + + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::CompoundNetworkId +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CFMRadioMobileNetworkInfoListener::CompoundNetworkId() const + { + return iCompoundNetworkId; + } + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::CountryCode +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +const TDesC& CFMRadioMobileNetworkInfoListener::CountryCode() const + { + return iCountryCode; + } + +// --------------------------------------------------------- +// CFMRadioMobileNetworkInfoListener::SubscriberId +// ?implementation_description +// (other items were commented in a header). +// --------------------------------------------------------- +// +const TDesC& CFMRadioMobileNetworkInfoListener::SubscriberId() const + { + return *iSubscriberId; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiopropertyobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiopropertyobserver.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,232 @@ +/* +* Copyright (c) 2004-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: Observer for FMRadio property values +* +*/ + + +#include "fmradiopropertyobserver.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CFMRadioPropertyObserver::CFMRadioPropertyObserver(MFMRadioPropertyChangeObserver& aObserver, const TUid& aCategory, const TUint aKey, const TFMRadioPropertyType aPropertyType) + : CActive( CActive::EPriorityStandard ), + iObserver( aObserver ), + iCategory( aCategory ), + iKey( aKey ), + iPropertyType( aPropertyType ) + { + } + +// ----------------------------------------------------------------------------- +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CFMRadioPropertyObserver::ConstructL() + { + switch (iPropertyType) + { + case EFMRadioPropertyInt: + { + break; + } + case EFMRadioPropertyByteArray: + { + iValueByteArray = HBufC8::NewL( RProperty::KMaxPropertySize ); + break; + } + case EFMRadioPropertyText: + { + // Max size in bytes, length is size / 2 + iValueText = HBufC::NewL( RProperty::KMaxPropertySize / 2 ); + break; + } + default: + { + break; + } + } + + User::LeaveIfError( iProperty.Attach( iCategory, iKey ) ); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CFMRadioPropertyObserver* CFMRadioPropertyObserver::NewL( MFMRadioPropertyChangeObserver& aObserver, + const TUid& aCategory, + const TUint aKey, + const TFMRadioPropertyType aPropertyType ) + { + CFMRadioPropertyObserver* self = NewLC( aObserver, + aCategory, + aKey, + aPropertyType ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CFMRadioPropertyObserver* CFMRadioPropertyObserver::NewLC( MFMRadioPropertyChangeObserver& aObserver, + const TUid& aCategory, + const TUint aKey, + const TFMRadioPropertyType aPropertyType ) + { + CFMRadioPropertyObserver* self = new( ELeave )CFMRadioPropertyObserver( aObserver, + aCategory, + aKey, + aPropertyType ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +// +CFMRadioPropertyObserver::~CFMRadioPropertyObserver() + { + Cancel(); + iProperty.Close(); + delete iValueByteArray; + delete iValueText; + } + +// --------------------------------------------------------------------------- +// Subscribes to a property and reads the value, if not already active. +// --------------------------------------------------------------------------- +// +void CFMRadioPropertyObserver::ActivateL() + { + if ( !IsActive() ) + { + RunL(); + } + } + +// ----------------------------------------------------------------------------- +// CFMRadioPropertyObserver::RunL +// ----------------------------------------------------------------------------- +// +void CFMRadioPropertyObserver::RunL() + { + iProperty.Subscribe( iStatus ); + SetActive(); + + TInt err(KErrNone); + + switch (iPropertyType) + { + case EFMRadioPropertyInt: + { + err = iProperty.Get( iValueInt ); + if (!err) + { + iObserver.HandlePropertyChangeL( iCategory, iKey, iValueInt ); + } + break; + } + case EFMRadioPropertyByteArray: + { + TPtr8 ptr8( iValueByteArray->Des() ); + err = iProperty.Get( ptr8 ); + if (!err) + { + iObserver.HandlePropertyChangeL( iCategory, iKey, *iValueByteArray ); + } + break; + } + case EFMRadioPropertyText: + { + TPtr ptr( iValueText->Des() ); + err = iProperty.Get( ptr ); + if (!err) + { + iObserver.HandlePropertyChangeL( iCategory, iKey, *iValueText ); + } + break; + } + + default: + { + break; + } + } + + if (err) + { + iObserver.HandlePropertyChangeErrorL(iCategory, iKey, err); + } + } + +// ----------------------------------------------------------------------------- +// Cancels an outstanding active request +// ----------------------------------------------------------------------------- +// +void CFMRadioPropertyObserver::DoCancel() + { + iProperty.Cancel(); + } + +// ----------------------------------------------------------------------------- +// Getter for integer value +// ----------------------------------------------------------------------------- +// +TInt CFMRadioPropertyObserver::ValueInt( TBool aUpdate ) + { + if( aUpdate ) + { + iProperty.Get( iValueInt ); + } + return iValueInt; + } + +// ----------------------------------------------------------------------------- +// Getter for byte array value +// ----------------------------------------------------------------------------- +// +const TDesC8& CFMRadioPropertyObserver::ValueDes8( TBool aUpdate ) + { + if( aUpdate ) + { + TPtr8 ptr8( iValueByteArray->Des() ); + iProperty.Get( ptr8 ); + } + return *iValueByteArray; + } + +// ----------------------------------------------------------------------------- +// Getter for text value +// ----------------------------------------------------------------------------- +// +const TDesC& CFMRadioPropertyObserver::ValueDes( TBool aUpdate ) + { + if( aUpdate ) + { + TPtr ptr( iValueText->Des() ); + iProperty.Get( ptr ); + } + return *iValueText; + } + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiopubsub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiopubsub.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,516 @@ +/* +* 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: Publish&Subscribe component of FM Radio +* +*/ + +#include "fmradiocontroleventobserver.h" + +#include "fmradiopubsub.h" + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CFMRadioPubSub::CFMRadioPubSub() + { + } + +// --------------------------------------------------------------------------- +// EPOC default constructor can leave. +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::ConstructL() + { + // Define data properties. + DefinePropertyL( KFMRadioPSDataChannel, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataFrequency, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataRadioPowerState, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataVolume, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataChannelDataChanged, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataTuningState, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataRadioMuteState, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataApplicationRunning, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataHeadsetStatus, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataFrequencyDecimalCount, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataLoudspeakerStatus, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioPSDataRDSProgramService, RProperty::EText, ETrue ); + DefinePropertyL( KFMRadioPSDataRDSRadioText, RProperty::EText, ETrue ); + DefinePropertyL( KFMRadioPSDataChannelName, RProperty::EText, ETrue ); + + // Define control properties. + DefinePropertyL( KFMRadioPSControlStepToChannel, RProperty::EInt, EFalse ); + DefinePropertyL( KFMRadioPSControlSeek, RProperty::EInt, EFalse ); + DefinePropertyL( KFMRadioPSControlSetRadioMuteState , RProperty::EInt, EFalse ); + // Observe control properties. + DefinePropertyL( KFMRadioActiveIdlePresetListCount, RProperty::EInt, ETrue ); + DefinePropertyL( KFMRadioActiveIdlePresetListFocus, RProperty::EInt, ETrue ); + + + CFMRadioPropertyObserver* observer = CFMRadioPropertyObserver::NewLC( *this, + KFMRadioPSUid, KFMRadioPSControlStepToChannel, CFMRadioPropertyObserver::EFMRadioPropertyInt); + iPropertyArray.AppendL( observer ); + CleanupStack::Pop( observer ); + + observer = CFMRadioPropertyObserver::NewLC( *this, + KFMRadioPSUid, KFMRadioPSControlSeek, CFMRadioPropertyObserver::EFMRadioPropertyInt ); + iPropertyArray.AppendL( observer ); + CleanupStack::Pop( observer ); + + observer = CFMRadioPropertyObserver::NewLC( *this, + KFMRadioPSUid, KFMRadioPSControlSetRadioMuteState, CFMRadioPropertyObserver::EFMRadioPropertyInt ); + iPropertyArray.AppendL( observer ); + CleanupStack::Pop( observer ); + + observer = CFMRadioPropertyObserver::NewLC( *this, + KFMRadioPSUid, KFMRadioActiveIdlePresetListCount, CFMRadioPropertyObserver::EFMRadioPropertyInt ); + iPropertyArray.AppendL( observer ); + CleanupStack::Pop( observer ); + + for ( TInt i = 0; i < iPropertyArray.Count(); i++ ) + { + iPropertyArray[i]->ActivateL(); + } + } + +// -------------------------------------------------------f-------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CFMRadioPubSub* CFMRadioPubSub::NewL() + { + CFMRadioPubSub* self = new (ELeave) CFMRadioPubSub(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioPubSub::~CFMRadioPubSub() + { + iPropertyArray.ResetAndDestroy(); + iPropertyArray.Close(); + + DeleteProperty( KFMRadioPSDataChannel ); + DeleteProperty( KFMRadioPSDataFrequency ); + DeleteProperty( KFMRadioPSDataRadioPowerState ); + DeleteProperty( KFMRadioPSDataVolume ); + DeleteProperty( KFMRadioPSDataChannelDataChanged ); + DeleteProperty( KFMRadioPSDataTuningState ); + DeleteProperty( KFMRadioPSDataRadioMuteState ); + DeleteProperty( KFMRadioPSDataApplicationRunning ); + DeleteProperty( KFMRadioPSDataHeadsetStatus ); + DeleteProperty( KFMRadioPSDataFrequencyDecimalCount ); + DeleteProperty( KFMRadioPSDataLoudspeakerStatus ); + DeleteProperty( KFMRadioPSDataRDSProgramService ); + DeleteProperty( KFMRadioPSDataRDSRadioText ); + DeleteProperty( KFMRadioPSDataChannelName ); + + DeleteProperty( KFMRadioPSControlStepToChannel ); + DeleteProperty( KFMRadioPSControlSeek ); + DeleteProperty( KFMRadioPSControlSetRadioMuteState ); + DeleteProperty ( KFMRadioActiveIdlePresetListCount); + DeleteProperty ( KFMRadioActiveIdlePresetListFocus); + } + +// --------------------------------------------------------------------------- +// Defines a property. +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::DefinePropertyL( TUint aKey, TInt aAttr, TBool aDataProperty ) const + { + /*lint -save -e648*/ + _LIT_SECURITY_POLICY_PASS( KFMRadioExternalAccessPolicy ); + /*lint -restore*/ + _LIT_SECURITY_POLICY_S0( KFMRadioInternalAccessPolicy, KUidFMRadioApplication ); + + TInt err = KErrNone; + if ( aDataProperty ) + { + // For data properties, grant read access for all, but write access only for FMRadioEngine + err = RProperty::Define( KFMRadioPSUid, aKey, aAttr, KFMRadioExternalAccessPolicy, KFMRadioInternalAccessPolicy ); + } + else + { + // For control properties, grant read access only for FMRadioEngine , but write access for all + err = RProperty::Define( KFMRadioPSUid, aKey, aAttr, KFMRadioInternalAccessPolicy, KFMRadioExternalAccessPolicy ); + } + + + if ( err && err != KErrAlreadyExists ) + { + User::Leave( err ); + } + } + +// --------------------------------------------------------------------------- +// Deletes a property +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::DeleteProperty( TUint aKey ) const + { + RProperty::Delete( KFMRadioPSUid, aKey ); + } + +// --------------------------------------------------------------------------- +// Gets the integer value stored in a property. +// --------------------------------------------------------------------------- +// +TInt CFMRadioPubSub::PropertyValueIntL( TUint aKey ) const + { + TInt value; + User::LeaveIfError( RProperty::Get( KFMRadioPSUid, aKey, value ) ); + return value; + } + +// --------------------------------------------------------------------------- +// Sets a property's value. +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::SetPropertyValueL( TUint aKey, TInt aValue ) const + { + User::LeaveIfError( RProperty::Set( KFMRadioPSUid, aKey, aValue ) ); + } + +// --------------------------------------------------------------------------- +// Sets a text property value +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::SetPropertyValueL( TUint aKey, const TDesC& aValue ) const + { + User::LeaveIfError( RProperty::Set( KFMRadioPSUid, aKey, aValue ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::HandlePropertyChangeL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::HandlePropertyChangeL( const TUid& aCategory, const TUint aKey, const TInt aValue ) + { + if (aCategory != KFMRadioPSUid) + { + User::Leave(KErrArgument); + } + + if (iObserver) + { + if (aKey == KFMRadioPSControlStepToChannel) + { + switch (aValue) + { + case EFMRadioPSStepToChannelUninitialized: + { + break; + } + case EFMRadioPSStepToChannelUp: + { + iObserver->StepToChannelL(EFMRadioUp); + break; + } + case EFMRadioPSStepToChannelDown: + { + iObserver->StepToChannelL(EFMRadioDown); + break; + } + default: + { + break; + } + } + } + else if (aKey == KFMRadioPSControlSeek) + { + switch (aValue) + { + case EFMRadioPSSeekUninitialized: + { + break; + } + case EFMRadioPSSeekUp: + { + iObserver->SeekL(EFMRadioUp); + break; + } + case EFMRadioPSSeekDown: + { + iObserver->SeekL(EFMRadioDown); + break; + } + default: + { + break; + } + } + } + else if (aKey == KFMRadioPSControlSetRadioMuteState) + { + switch (aValue) + { + case EFMRadioPSMuteStateUninitialized: + { + break; + } + case EFMRadioPSMuteStateOn: + { + iObserver->MuteL(ETrue); + break; + } + case EFMRadioPSMuteStateOff: + { + iObserver->MuteL(EFalse); + break; + } + default: + { + break; + } + } + } + } + } + +// --------------------------------------------------------------------------- +// Currently empty implementation because we don't listen byte array type properties. +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::HandlePropertyChangeL(const TUid& /*aCategory*/, const TUint /*aKey*/, const TDesC8& /*aValue*/) + { + } + +// --------------------------------------------------------------------------- +// Currently empty implementation because we don't listen text type properties. +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::HandlePropertyChangeL(const TUid& /*aCategory*/, const TUint /*aKey*/, const TDesC& /*aValue*/) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::HandlePropertyChangeErrorL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::HandlePropertyChangeErrorL (const TUid& /*aCategory*/, const TUint /*aKey*/, TInt /*aError*/ ) + { + //NOP + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishChannelL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishChannelL(TInt aChannelId) const + { + TInt oldChannelId = PropertyValueIntL( KFMRadioPSDataChannel ); + + if ( aChannelId != oldChannelId ) + { + SetPropertyValueL( KFMRadioPSDataChannel, aChannelId ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishFrequencyL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishFrequencyL( TUint32 aFreq ) const + { + TInt oldFreq = PropertyValueIntL( KFMRadioPSDataFrequency ); + + if ( aFreq != oldFreq ) + { + SetPropertyValueL( KFMRadioPSDataFrequency, aFreq ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishStateL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishStateL( TBool aPowerOn ) const + { + // If application process gets killed, power on state remains published. + // Must not compare state transition here, because then power on might not be published. + TFMRadioPSRadioPowerState newState = aPowerOn ? EFMRadioPSRadioPowerOn : EFMRadioPSRadioPowerOff; + SetPropertyValueL( KFMRadioPSDataRadioPowerState, newState ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishVolumeL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishVolumeL( TInt aVol ) const + { + TInt oldVol = PropertyValueIntL( KFMRadioPSDataVolume ); + + if ( aVol != oldVol ) + { + SetPropertyValueL( KFMRadioPSDataVolume, aVol ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishPresetCountL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishPresetCountL( TInt aVal ) const + { + TInt oldVal = PropertyValueIntL( KFMRadioActiveIdlePresetListCount ); + + if ( aVal != oldVal ) + { + SetPropertyValueL( KFMRadioActiveIdlePresetListCount, aVal ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishChannelDataChangedL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishChannelDataChangedL( TInt aChannelId ) const + { + // Channel data changed notifications are allowed for the same channel multiple times, as the same channel's + // data can be changed many times in a row. + + SetPropertyValueL( KFMRadioPSDataChannelDataChanged, aChannelId ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishTuningStateL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishTuningStateL( TFMRadioPSTuningState aTuningState ) const + { + TFMRadioPSTuningState oldState = static_cast( PropertyValueIntL( KFMRadioPSDataTuningState ) ); + + if ( aTuningState != oldState ) + { + SetPropertyValueL( KFMRadioPSDataTuningState, aTuningState ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishMuteStateL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishRadioMuteStateL( TBool aMuted ) const + { + TFMRadioPSRadioMuteState oldState = static_cast( PropertyValueIntL( KFMRadioPSDataRadioMuteState ) ); + TFMRadioPSRadioMuteState newState = aMuted ? EFMRadioPSMuteStateOn : EFMRadioPSMuteStateOff; + + if ( newState != oldState ) + { + SetPropertyValueL( KFMRadioPSDataRadioMuteState, newState ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishApplicationRunningStateL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishApplicationRunningStateL( TFMRadioPSApplicationRunningState aRunningState ) const + { + // If application process gets killed, wrong running state remains published. + // Must not compare state transition here, because then application start might not be published. + SetPropertyValueL( KFMRadioPSDataApplicationRunning, aRunningState ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishAntennaStatusL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishAntennaStatusL( TFMRadioPSHeadsetStatus aAntennaStatus ) const + { + TFMRadioPSHeadsetStatus oldState = static_cast( PropertyValueIntL( KFMRadioPSDataHeadsetStatus ) ); + + if ( aAntennaStatus != oldState ) + { + SetPropertyValueL( KFMRadioPSDataHeadsetStatus, aAntennaStatus ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishFrequencyDecimalCountL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishFrequencyDecimalCountL( TFMRadioPSFrequencyDecimalCount aDecimalCount ) const + { + TFMRadioPSFrequencyDecimalCount oldCount = static_cast( PropertyValueIntL( KFMRadioPSDataFrequencyDecimalCount ) ); + + if ( aDecimalCount != oldCount ) + { + SetPropertyValueL( KFMRadioPSDataFrequencyDecimalCount, aDecimalCount ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishLoudspeakerStatusL +// --------------------------------------------------------------------------- +// +void CFMRadioPubSub::PublishLoudspeakerStatusL( + TFMRadioPSLoudspeakerStatus aLoudspeakerStatus ) const + { + TFMRadioPSLoudspeakerStatus oldLoudspeakerStatus + = static_cast( + PropertyValueIntL(KFMRadioPSDataLoudspeakerStatus) ); + + if(oldLoudspeakerStatus != aLoudspeakerStatus) + { + SetPropertyValueL( KFMRadioPSDataLoudspeakerStatus, aLoudspeakerStatus); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishRDSProgramServiceL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishRDSProgramServiceL( const TDesC& aProgramService ) const + { + SetPropertyValueL( KFMRadioPSDataRDSProgramService, aProgramService ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishRDSRadioTextL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishRDSRadioTextL( const TDesC& aRadioText ) const + { + SetPropertyValueL( KFMRadioPSDataRDSRadioText, aRadioText ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::PublishChannelNameL +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::PublishChannelNameL( const TDesC& aName ) const + { + SetPropertyValueL( KFMRadioPSDataChannelName, aName ); + } + +// --------------------------------------------------------------------------- +// CFMRadioPubSub::SetControlEventObserver +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioPubSub::SetControlEventObserver( MFMRadioControlEventObserver* aControlEventObserver ) + { + iObserver = aControlEventObserver; + } + diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiordsreceiver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiordsreceiver.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,124 @@ +/* +* 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 RDS receiver implementation for FM Radio +* +*/ + + +#include "fmradiordsreceiver.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::CFMRadioRdsReceiver +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiver::CFMRadioRdsReceiver( TRadioSettings& aSettings ) : CFMRadioRdsReceiverBase(aSettings) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiver::ConstructL() + { + BaseConstructL(); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::NewL +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiver* CFMRadioRdsReceiver::NewL( TRadioSettings& aSettings ) + { + CFMRadioRdsReceiver* self = new ( ELeave ) CFMRadioRdsReceiver( aSettings ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::~CFMRadioRdsReceiver +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiver::~CFMRadioRdsReceiver() + { + if( iRdsUtility ) + { + iRdsUtility->Close(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::InitL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub ) + { + iPubSub = aPubSub; + + iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this ); + + SetAutomaticSwitchingL( iSettings.IsRdsAfSearchEnabled() ); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::SetAutomaticSwitchingL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable ) + { + if( iRdsUtility ) + { + User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) ); + } + + CFMRadioRdsReceiverBase::SetAutomaticSwitchingL( aEnable ); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::StartReceiver +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiver::StartReceiver() + { + TRdsData rdsData; + rdsData.iRdsFunctions = ERdsProgrammeService | ERdsAlternateFrequency | ERdsRadioText | ERdsRadioTextPlus; + rdsData.iAdditionalFunctions1 = 0; + rdsData.iAdditionalFunctions2 = 0; + + if( iRdsUtility && !iStarted) + { + if( iRdsUtility->NotifyRdsDataChange( rdsData ) == KErrNone ) + { + // Avoid further calls + iStarted = ETrue; + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiver::StopReceiver +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiver::StopReceiver() + { + if( iRdsUtility ) + { + iRdsUtility->CancelNotifyRdsDataChange(); + } + iStarted = EFalse; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiordsreceiverbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiordsreceiverbase.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,524 @@ +/* +* 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 RDS receiver implementation for FM Radio +* +*/ + + +#include "fmradiordsreceiverbase.h" +#include "fmradiopubsub.h" +#include "fmradioengineradiosettings.h" + +// The delay, in microseconds, after which RDS PS name is concidered static +const TInt KFMRadioStaticRdsPsNameDelay = 10000000; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::CFMRadioRdsReceiverBase +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiverBase::CFMRadioRdsReceiverBase( TRadioSettings& aSettings ) : iSettings(aSettings) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::BaseConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::BaseConstructL() + { + iPsName = HBufC::NewL( TRdsPSName().MaxLength() ); + iRadioText = HBufC::NewL( TRdsRadioText().MaxLength() ); + iPsNameTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::~CFMRadioRdsReceiverBase +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiverBase::~CFMRadioRdsReceiverBase() + { + iObservers.Close(); + delete iPsName; + delete iRadioText; + delete iPsNameTimer; + + iProgramWebUrl.Close(); + iArtistName.Close(); + iSongName.Close(); + iAlbumName.Close(); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::AddObserver +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioRdsReceiverBase::AddObserver( MFMRadioRdsObserver* aObserver ) + { + TInt index = iObservers.FindInAddressOrder( aObserver ); + if( index == KErrNotFound ) + { + iObservers.InsertInAddressOrder( aObserver ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::RemoveObserver +// --------------------------------------------------------------------------- +// +EXPORT_C void CFMRadioRdsReceiverBase::RemoveObserver( MFMRadioRdsObserver* aObserver ) + { + TInt index = iObservers.FindInAddressOrder( aObserver ); + + if( index >= 0 ) + { + iObservers.Remove( index ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::AutomaticSwitchingEnabled +// --------------------------------------------------------------------------- +// +EXPORT_C TBool CFMRadioRdsReceiverBase::AutomaticSwitchingEnabled() const + { + return iAfEnabled; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::ProgrammeService +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioRdsReceiverBase::ProgrammeService() const + { + return *iPsName; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::ProgrammeServiceNameType +// --------------------------------------------------------------------------- +// +EXPORT_C CFMRadioRdsReceiverBase::TFMRadioProgrammeSeviceType CFMRadioRdsReceiverBase::ProgrammeServiceNameType() const + { + return iPsNameType; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::SignalAvailable +// --------------------------------------------------------------------------- +// +EXPORT_C TBool CFMRadioRdsReceiverBase::SignalAvailable() const + { + return iSignalAvailable; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::RtPlusWebUrl +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioRdsReceiverBase::RtPlusProgramUrl() const + { + return iProgramWebUrl; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::RtPlusArtist +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioRdsReceiverBase::RtPlusArtist() const + { + return iArtistName; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::RtPlusAlbum +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioRdsReceiverBase::RtPlusAlbum() const + { + return iAlbumName; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::RtPlusSong +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CFMRadioRdsReceiverBase::RtPlusSong() const + { + return iSongName; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::SetAutomaticSwitchingL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::SetAutomaticSwitchingL( TBool aEnable ) + { + iAfEnabled = aEnable; + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsAfSearchStateChange( iAfEnabled ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::ClearRdsInformation +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::ClearRdsInformation() + { + TRdsPSName name; + TRdsRadioText radioText; + iPsNameTimer->Cancel(); + iPsNameType = EFMRadioPSNameStaticAssumed; + MrroRdsDataPS( name ); + MrroRdsDataRT( radioText ); + iProgramWebUrl.Close(); + iArtistName.Close(); + iSongName.Close(); + iAlbumName.Close(); + MrroRdsEventSignalChange( EFalse ); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::StaticPsNameTimerCallback +// --------------------------------------------------------------------------- +// +TInt CFMRadioRdsReceiverBase::StaticPsNameTimerCallback( TAny* aSelf ) + { + CFMRadioRdsReceiverBase* self = static_cast( aSelf ); + if( self ) + { + self->iPsNameTimer->Cancel(); + if ( self->iPsNameType == EFMRadioPSNameStaticAssumed ) + { + self->iPsNameType = EFMRadioPSNameStatic; + for( TInt i = 0 ; i < self->iObservers.Count() ; i++ ) + { + self->iObservers[i]->RdsDataPsNameIsStatic( ETrue ); + } + } + } + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::HandleRdsDataRTplusL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::HandleRdsDataRTplusL( TRdsRTplusClass aRtPlusClass, TRdsRadioText& aRtPlusData ) + { + TBool dataChanged = EFalse; + switch (aRtPlusClass) + { + case ERTplusItemTitle: + if ( aRtPlusData != iSongName ) + { + dataChanged = ETrue; + iSongName.Close(); + iSongName.CreateL( aRtPlusData ); + } + break; + case ERTplusItemArtist: + case ERTplusItemBand: + if ( aRtPlusData != iArtistName ) + { + dataChanged = ETrue; + iArtistName.Close(); + iArtistName.CreateL( aRtPlusData ); + } + break; + case ERTplusItemAlbum: + if ( aRtPlusData != iAlbumName ) + { + dataChanged = ETrue; + iAlbumName.Close(); + iAlbumName.CreateL( aRtPlusData ); + } + break; + case ERTplusProgramHomepage: + { + if ( aRtPlusData != iProgramWebUrl ) + { + dataChanged = ETrue; + iProgramWebUrl.Close(); + iProgramWebUrl.CreateL( aRtPlusData ); + } + break; + } + default: + // Let uncached values go through + dataChanged = ETrue; + break; + } + + if ( dataChanged ) + { + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsDataRadioTextPlus( aRtPlusClass, aRtPlusData ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroStationSeekByPTYComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroStationSeekByPTYComplete( TInt /*aError*/, TInt /*aFrequency*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroStationSeekByTAComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroStationSeekByTAComplete( TInt /*aError*/, TInt /*aFrequency*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroStationSeekByTPComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroStationSeekByTPComplete( TInt /*aError*/, TInt /*aFrequency*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroGetFreqByPTYComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroGetFreqByPTYComplete( TInt /*aError*/, RArray& /*aFreqList*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroGetFreqByTAComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroGetFreqByTAComplete( TInt /*aError*/, RArray& /*aFreqList*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroGetPSByPTYComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroGetPSByPTYComplete( TInt /*aError*/, RArray& /*aPsList*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroGetPSByTAComplete +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroGetPSByTAComplete( TInt /*aError*/, RArray& /*aPsList*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataPI +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataPI( TInt /*aPi*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataPTY +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataPTY( TRdsProgrammeType /*aPty*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataPS +// Notifies of the New Programme Service data +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataPS( TRdsPSName& aPs ) + { + TBool reportStaticState = EFalse; + if ( iPsName->Length() && aPs.Length() ) + { + if ( *iPsName != aPs && iPsNameTimer->IsActive() ) + { + // PS existed and it changed, cancel the timer as it is not static name anymore + iPsNameTimer->Cancel(); + iPsNameType = EFMRadioPSNameDynamic; + reportStaticState = ETrue; + } + else + { + if ( iPsNameType == EFMRadioPSNameStaticAssumed && !iPsNameTimer->IsActive() ) + { + // The timer should be reactivated in order to complete the determination + iPsNameTimer->Start( KFMRadioStaticRdsPsNameDelay, + 0, + TCallBack( CFMRadioRdsReceiverBase::StaticPsNameTimerCallback, this ) ); + } + } + } + else if ( !iPsName->Length() && aPs.Length() ) + { + // PS name is set for the first time, start the timer to see if it is a static one + iPsNameTimer->Cancel(); + iPsNameTimer->Start( KFMRadioStaticRdsPsNameDelay, + 0, + TCallBack( CFMRadioRdsReceiverBase::StaticPsNameTimerCallback, this ) ); + } + else + { + // PS name is reset + } + + iPsName->Des().Copy( aPs ); + + if ( iPubSub ) + { + TRAP_IGNORE( iPubSub->PublishRDSProgramServiceL( *iPsName )); + } + + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsDataProgrammeService( *iPsName ); + if( reportStaticState ) + { + iObservers[i]->RdsDataPsNameIsStatic( iPsNameType == EFMRadioPSNameStatic ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataRT +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataRT( TRdsRadioText& aRt ) + { + iRadioText->Des().Copy( aRt ); + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsDataRadioText( *iRadioText ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataCT +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataCT( TDateTime& /*aCt*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataTA +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataTA( TBool /*aTaOn*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsDataRTplus +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsDataRTplus( TRdsRTplusClass aRtPlusClass, TRdsRadioText& aRtPlusData ) + { + TRAP_IGNORE( HandleRdsDataRTplusL( aRtPlusClass, aRtPlusData ) ) + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsSearchBeginAF +// Notifies of the start of Alternate Frequency search +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsSearchBeginAF() + { + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsAfSearchBegin(); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsSearchBeginAF +// Notifies of the end of Alternate Frequency search +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsSearchEndAF( TInt aError, TInt aFrequency ) + { + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + // Radio utility uses Hz, UI uses kHz. It's ok to divide with 1000, possible lost fractions are useless. + iObservers[i]->RdsAfSearchEnd( aFrequency / KFMRadioFreqMultiplier, aError ); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsStationChangeTA +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsStationChangeTA( TInt /*aFrequency*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsEventAutomaticSwitchingChange +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsEventAutomaticSwitchingChange( TBool /*aAuto*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsEventAutomaticTrafficAnnouncement +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsEventAutomaticTrafficAnnouncement( TBool /*aAuto*/ ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverBase::MrroRdsEventSignalChange +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverBase::MrroRdsEventSignalChange( TBool aSignal ) + { + if ( aSignal ) + { + if ( iPsName->Length() ) + { + if ( iPsNameType == EFMRadioPSNameStaticAssumed && !iPsNameTimer->IsActive() ) + { + iPsNameTimer->Cancel(); + iPsNameTimer->Start( KFMRadioStaticRdsPsNameDelay, + 0, + TCallBack( CFMRadioRdsReceiverBase::StaticPsNameTimerCallback, this ) ); + } + } + } + else + { + // PS name type determination must be canceled on bad signal + iPsNameTimer->Cancel(); + } + iSignalAvailable = aSignal; + for( TInt i = 0 ; i < iObservers.Count() ; i++ ) + { + iObservers[i]->RdsAvailable( iSignalAvailable ); + } + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiordsreceiversimulator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiordsreceiversimulator.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,276 @@ +/* +* 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 RDS receiver implementation for FM Radio +* +*/ + + +#include "fmradiordsreceiversimulator.h" + +const TInt KFMRadioRdsEventSimulationDelay = 3000000; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::CFMRadioRdsReceiverSimulator +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiverSimulator::CFMRadioRdsReceiverSimulator( TRadioSettings& aSettings ) : CFMRadioRdsReceiverBase(aSettings) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::ConstructL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverSimulator::ConstructL() + { + BaseConstructL(); + iEventSimulatorTimer = CPeriodic::NewL(CActive::EPriorityUserInput); + SetAutomaticSwitchingL( iSettings.IsRdsAfSearchEnabled() ); + StartReceiver(); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::NewL +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiverSimulator* CFMRadioRdsReceiverSimulator::NewL( TRadioSettings& aSettings ) + { + CFMRadioRdsReceiverSimulator* self = new ( ELeave ) CFMRadioRdsReceiverSimulator( aSettings ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::~CFMRadioRdsReceiverSimulator +// --------------------------------------------------------------------------- +// +CFMRadioRdsReceiverSimulator::~CFMRadioRdsReceiverSimulator() + { + if( iEventSimulatorTimer && iEventSimulatorTimer->IsActive() ) + { + iEventSimulatorTimer->Cancel(); + } + + delete iEventSimulatorTimer; + iEventSimulatorTimer = NULL; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::InitL +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverSimulator::InitL( CRadioUtility& /*aRadioUtility*/, CFMRadioPubSub* aPubSub ) + { + iPubSub = aPubSub; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::StartReceiver +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverSimulator::StartReceiver() + { + if( !iEventSimulatorTimer->IsActive() ) + { + iEventSimulatorTimer->Start( TTimeIntervalMicroSeconds32(KFMRadioRdsEventSimulationDelay), + TTimeIntervalMicroSeconds32(KFMRadioRdsEventSimulationDelay), + TCallBack(StaticRdsSimulationCallback, this)); + } + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::StopReceiver +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverSimulator::StopReceiver() + { + iEventSimulatorTimer->Cancel(); + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::SetRadioEngineForRadioFmTunerSimulation +// --------------------------------------------------------------------------- +// +void CFMRadioRdsReceiverSimulator::SetRadioEngineForRadioFmTunerSimulation( CRadioEngine* aEngine ) + { + iEngine = aEngine; + } + +// --------------------------------------------------------------------------- +// CFMRadioRdsReceiverSimulator::StaticRdsSimulationCallback +// --------------------------------------------------------------------------- +// +TInt CFMRadioRdsReceiverSimulator::StaticRdsSimulationCallback( TAny* aSelfPtr ) + { + TFMRadioRdsSimulationEvent events[] = { EFMRadioRdsEventRadioTextPlus, + EFMRadioRdsEventRadioTextPlus, + EFMRadioRdsEventRadioTextPlus, + EFMRadioRdsEventRadioTextPlus, + EFMRadioRdsEventSignalOn, + // EFMRadioRdsEventAFBegin, + // EFMRadioRdsEventAFEnd, + EFMRadioRdsEventPS, + EFMRadioRdsEventRadioText, + //EFMRadioRdsEventSignalOff, + //EFMRadioRdsEventSignalOn, + EFMRadioRdsEventPS, + EFMRadioRdsEventPS, + // EFMRadioRdsEventRadioText, + // EFMRadioRdsEventRadioText + EFMRadioRdsEventAFBegin, + EFMRadioRdsEventPS, + EFMRadioRdsEventAFEnd, + EFMRadioRdsEventSignalOff, + EFMRadioRdsEventRadioTextPlus}; + + TRdsPSName serviceNames[] = + { + _L("RadioXYZ"), + _L("Some"), + _L("program"), + _L("service"), + _L("text") + }; + + TRdsRadioText radioTexts[] = + { + _L("radio text"), + _L("radio text radio text radio text"), + _L("full radio text full radio text full radio text full radio textt") + }; + + TRdsRadioText radioTextsPlus[] = + { + _L("The rock song"), + _L("Album of the year"), + _L("Rock 'n' Rollers"), + _L("http://www.symbianfoundation.org/"), + _L("Disco Dancers"), + _L("The disco song"), + _L("The Greatest"), + _L("http://developer.symbian.org/"), + }; + + TRdsRTplusClass radioTextsPlusClasses[] = + { + ERTplusItemTitle, + ERTplusItemAlbum, + ERTplusItemArtist, + ERTplusProgramHomepage, + ERTplusItemArtist, + ERTplusItemTitle, + ERTplusItemAlbum, + ERTplusProgramHomepage, + }; + + TInt frequencies[] = { 103100000, 95800000 }; // Frequencies in hz + + TInt numEvents = sizeof( events ) / sizeof( TFMRadioRdsSimulationEvent ); + TInt numServiceNames = sizeof( serviceNames ) / sizeof( TRdsPSName ); + TInt numRadioTexts = sizeof( radioTexts ) / sizeof( TRdsRadioText ); + TInt numRadioTextsPlus = sizeof( radioTextsPlus ) / sizeof( TRdsRadioText ); + TInt numFrequencies = sizeof( frequencies ) / sizeof( TInt ); + + CFMRadioRdsReceiverSimulator* self = static_cast(aSelfPtr); + if( self ) + { + switch( events[self->iEventIterator] ) + { + case EFMRadioRdsEventSignalOn: + { + self->MrroRdsEventSignalChange( ETrue ); + break; + } + + case EFMRadioRdsEventSignalOff: + { + self->MrroRdsEventSignalChange( EFalse ); + break; + } + + case EFMRadioRdsEventPS: + { + self->MrroRdsDataPS( serviceNames[self->iPsIterator] ); + self->iPsIterator++; + if( self->iPsIterator >= numServiceNames ) + { + self->iPsIterator = 0; + } + break; + } + case EFMRadioRdsEventRadioText: + { + self->MrroRdsDataRT( radioTexts[self->iRadioTextIterator] ); + self->iRadioTextIterator++; + if( self->iRadioTextIterator >= numRadioTexts ) + { + self->iRadioTextIterator = 0; + } + break; + } + case EFMRadioRdsEventAFBegin: + { + if ( self->AutomaticSwitchingEnabled() ) + { + self->MrroRdsSearchBeginAF(); + } + break; + } + + case EFMRadioRdsEventAFEnd: + { + if ( self->AutomaticSwitchingEnabled() ) + { + // Simulate MrftoFrequencyChange method from MRadioFmTunerObserver + if( self->iEngine ) + { + self->iEngine->MrftoFrequencyChange( frequencies[self->iFrequencyIterator] ); + } + + self->MrroRdsSearchEndAF( KErrNone, frequencies[self->iFrequencyIterator] ); + + self->iFrequencyIterator++; + if( self->iFrequencyIterator >= numFrequencies ) + { + self->iFrequencyIterator = 0; + } + } + break; + } + case EFMRadioRdsEventRadioTextPlus: + { + self->MrroRdsDataRTplus( radioTextsPlusClasses[self->iRadioTextPlusIterator], + radioTextsPlus[self->iRadioTextPlusIterator]); + self->iRadioTextPlusIterator++; + if( self->iRadioTextPlusIterator >= numRadioTextsPlus ) + { + self->iRadioTextPlusIterator = 0; + } + break; + } + default: + break; + } + self->iEventIterator++; + if( self->iEventIterator >= numEvents ) + { + self->iEventIterator = 0; + } + } + return KErrNone; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradioregion.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradioregion.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2004-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: provides information about FM region +* +*/ + + +// INCLUDE FILES +#include +#include "fmradioregion.h" + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CFMRadioRegion::CFMRadioRegion() + { + } + +// EPOC default constructor can leave. +void CFMRadioRegion::ConstructL(TResourceReader& aRr) + { + iId = static_cast(aRr.ReadUint16()); + iStepSize = static_cast( aRr.ReadUint16() ); + iMinFreq = aRr.ReadUint32(); + iMaxFreq = aRr.ReadUint32(); + iDecimalCount = aRr.ReadInt16(); + + TInt countryCodeCount = aRr.ReadInt16(); + for(TInt i = 0 ; i < countryCodeCount ; i++) + { + TPtrC code; + code.Set(aRr.ReadTPtrC()); + User::LeaveIfError(iCountryCodes.Append(code.AllocL())); + } + + iName = aRr.ReadHBufC16L(); + iSettingName = aRr.ReadHBufC16L(); + } + +// Two-phased constructor. +CFMRadioRegion* CFMRadioRegion::NewL(TResourceReader& aRr) + { + CFMRadioRegion* self = new (ELeave) CFMRadioRegion; + + CleanupStack::PushL(self); + self->ConstructL(aRr); + CleanupStack::Pop(); + + return self; + } + + +// Destructor +CFMRadioRegion::~CFMRadioRegion() + { + iCountryCodes.ResetAndDestroy(); + iCountryCodes.Close(); + delete iName; + delete iSettingName; + } + +// --------------------------------------------------------- +// CFMRadioRegion::Id +// Get the id of region +// --------------------------------------------------------- +// +TFMRadioRegionSetting CFMRadioRegion::Id() const + { + return iId; + } + +// --------------------------------------------------------- +// CFMRadioRegion::StepSize +// Get the step interval of region +// --------------------------------------------------------- +// +TUint32 CFMRadioRegion::StepSize() const + { + return iStepSize; + } + +// --------------------------------------------------------- +// CFMRadioRegion::MinFreq +// --------------------------------------------------------- +// +TUint32 CFMRadioRegion::MinFrequency() const + { + return iMinFreq; + } + +// --------------------------------------------------------- +// CFMRadioRegion::MaxFreq +// --------------------------------------------------------- +// +TUint32 CFMRadioRegion::MaxFrequency() const + { + return iMaxFreq; + } + +// --------------------------------------------------------- +// CFMRadioRegion::DecimalCount +// --------------------------------------------------------- +// +TInt CFMRadioRegion::DecimalCount() const + { + return iDecimalCount; + } + +// --------------------------------------------------------- +// CFMRadioRegion::CountryCode +// Get the country code of region +// --------------------------------------------------------- +// +const RFMRadioCountryCodeArray& CFMRadioRegion::CountryCodes() + { + return iCountryCodes; + } + +// --------------------------------------------------------- +// CFMRadioRegion::Name +// Get the name of region +// --------------------------------------------------------- +// +const TDesC16& CFMRadioRegion::Name() const + { + return *iName; + } + +// --------------------------------------------------------- +// CFMRadioRegion::SettingItemName +// Get the name of region +// --------------------------------------------------------- +// +const TDesC16& CFMRadioRegion::SettingItemName() const + { + return *iSettingName; + } + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradioengine/src/fmradiosystemeventdetector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradioengine/src/fmradiosystemeventdetector.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,427 @@ +/* +* 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: Observer for system events +* +*/ + +#include "fmradiovariant.hrh" // include first for variation +#include // Define before audiopolicy defs +#include // Define before audiopolicy defs +#include +#include +#include +#include +#ifndef __WINS__ + +#ifdef __FMRADIO_ADVANCED_AUTO_RESUME + +const TInt KFMRadioAudioCategoryArrayGranularity = 3; +#include +#include + +#else + +#include +#include + +#endif // __FMRADIO_ADVANCED_AUTO_RESUME + +#endif //__WINS__ + +#include "debug.h" +#include "fmradiosystemeventdetector.h" +#include "fmradiosystemeventdetectorobserver.h" + +const TInt KFMRadioAutoResumeDelay = 2000000; // micro seconds -> 2 seconds + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::CFMRadioSystemEventDetector +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CFMRadioSystemEventDetector::CFMRadioSystemEventDetector(MFMRadioSystemEventDetectorObserver& aObserver) + : iObserver( aObserver ), + iIsNetworkCoverage( EFalse), + iIsVoiceUiActive( EFalse ) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::ConstructL +// EPOC default constructor can leave. +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::ConstructL() + { + CFMRadioPropertyObserver* networkObserver = + CFMRadioPropertyObserver::NewLC( *this, + KUidSystemCategory, + KUidNetworkStatusValue, + CFMRadioPropertyObserver::EFMRadioPropertyInt ); + + iPropertyArray.AppendL( networkObserver ); + CleanupStack::Pop( networkObserver ); + + CFMRadioPropertyObserver* voiceUiObserver = + CFMRadioPropertyObserver::NewLC( *this, + KPSUidVoiceUiAccMonitor, + KVoiceUiOpenKey, + CFMRadioPropertyObserver::EFMRadioPropertyInt ); + + iPropertyArray.AppendL( voiceUiObserver ); + CleanupStack::Pop( voiceUiObserver ); + // Initialize call state observer. + iCallStatusObserver = CFMRadioPropertyObserver::NewL( *this, + KPSUidCtsyCallInformation, + KCTsyCallState, + CFMRadioPropertyObserver::EFMRadioPropertyInt); + + iCallStatusObserver->ActivateL(); + iIsCallActive = iCallStatusObserver->ValueInt() != EPSCTsyCallStateNone; + + iAutoResumeTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + +#ifndef __WINS__ +#ifdef __FMRADIO_ADVANCED_AUTO_RESUME + // Define audio types for not resuming. + // Audio categories are currently defined by adaptation of each hw platform. + // Nokia adaptation uses following definitions, which must be replaced by corresponding + // adaptation specific definitions of licensee adaptation. + // No general Symbian Foundation definitions for categories exists yet. + iNoAutoResumeAudioCategories = RArray( KFMRadioAudioCategoryArrayGranularity ); + iNoAutoResumeAudioCategories.AppendL( ECatMediaPlayer ); + iNoAutoResumeAudioCategories.AppendL( ECatMobileTv ); + iNoAutoResumeAudioCategories.AppendL( ECatUnknownPlayer ); + iNoAutoResumeAudioCategories.Compress(); +#endif // __FMRADIO_ADVANCED_AUTO_RESUME + // Start listening audio client events. + CFMRadioPropertyObserver* audioPolicyObserver = + CFMRadioPropertyObserver::NewLC( *this, + KPSUidMMFAudioServer, + KAudioPolicyAudioClients, + CFMRadioPropertyObserver::EFMRadioPropertyByteArray ); + + iPropertyArray.AppendL( audioPolicyObserver ); + CleanupStack::Pop( audioPolicyObserver ); +#endif + for ( TInt i = 0; i < iPropertyArray.Count(); i++ ) + { + iPropertyArray[i]->ActivateL(); + } + + TInt networkAvailability = iPropertyArray[EFMRadioNetworkCoverageProperty]->ValueInt(); + + if (networkAvailability == ESANetworkAvailable) + { + iIsNetworkCoverage = ETrue; + } + else + { + iIsNetworkCoverage = EFalse; + } + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::~CFMRadioSystemEventDetector +// Destructor +// --------------------------------------------------------------------------- +// +CFMRadioSystemEventDetector::~CFMRadioSystemEventDetector() + { + delete iCallStatusObserver; + iPropertyArray.ResetAndDestroy(); + iPropertyArray.Close(); + iNoAutoResumeAudioCategories.Close(); + delete iAutoResumeTimer; + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::NewL +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CFMRadioSystemEventDetector* CFMRadioSystemEventDetector::NewL( + MFMRadioSystemEventDetectorObserver& aObserver) + { + CFMRadioSystemEventDetector* self = new (ELeave) CFMRadioSystemEventDetector(aObserver); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::HandlePropertyChangeL +// Handling of the int property changes is done here. +// Observer components are getting notifications in correspondence with what +// has changed +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::HandlePropertyChangeL( const TUid& aCategory, + const TUint aKey, + const TInt aValue ) + { + if (aCategory == KUidSystemCategory && aKey == KUidNetworkStatusValue) + { + switch (aValue) + { + case ESANetworkAvailable: + { + if (!iIsNetworkCoverage) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver NetworkUpCallbackL") ) ); + iIsNetworkCoverage = ETrue; + iObserver.NetworkUpCallbackL(); + } + break; + } + case ESANetworkUnAvailable: + { + if (iIsNetworkCoverage) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver NetworkDownCallbackL") ) ); + iIsNetworkCoverage = EFalse; + iObserver.NetworkDownCallbackL(); + } + break; + } + default: + { + break; + } + } + } + else if ( aCategory == KPSUidCtsyCallInformation && aKey == KCTsyCallState ) + { + if ( ( !iIsCallActive ) && ( aValue > EPSCTsyCallStateNone ) ) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver iIsCallActive = ETrue;") ) ); + iIsCallActive = ETrue; + iObserver.CallActivatedCallbackL(); + } + else if ( ( iIsCallActive ) && ( aValue <= EPSCTsyCallStateNone ) ) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver iIsCallActive = EFalse;") ) ); + iIsCallActive = EFalse; + iObserver.CallDeactivatedCallbackL(); + } + else + { + // No change + } + } + else if ( aCategory == KPSUidVoiceUiAccMonitor && aKey == KVoiceUiOpenKey ) + { + switch (aValue) + { + case KVoiceUiIsClose: + { + if (iIsVoiceUiActive) + { + iIsVoiceUiActive = EFalse; + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver KVoiceUiIsClose") ) ); + if ( iNumberOfActiveAudioClients == 0 ) + { + NotifyAudioResourcesAvailability(); + } + } + break; + } + case KVoiceUiIsOpen: + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - iObserver KVoiceUiIsOpen") ) ); + if (!iIsVoiceUiActive) + { + iIsVoiceUiActive = ETrue; + + } + break; + } + default: + { + break; + } + } + } + else // NOP + { + } + + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::HandlePropertyChangeErrorL +// This is a callback function which is called when a P&S components returns +// an error +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::HandlePropertyChangeErrorL( const TUid& /*aCategory*/, + const TUint /*aKey*/, + TInt /*aError*/ ) + { + } + +#ifndef __WINS__ +// --------------------------------------------------------------------------- +// Handling of the byte array property changes is done here. +// Observer components are getting notifications in correspondence with what +// has changed +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::HandlePropertyChangeL( const TUid& aCategory, + const TUint aKey, + const TDesC8& aValue) + { + if ( aCategory == KPSUidMMFAudioServer ) + { + if ( aKey == KAudioPolicyAudioClients ) + { + TAudioClientList audioClients; + audioClients.Copy( aValue ); + + iNumberOfActiveAudioClients = audioClients().iNumOfProcesses; + FTRACE(FPrint(_L("CFMRadioSystemEventDetector::HandlePropertyChangeL() number of audio clients: = %d"), iNumberOfActiveAudioClients)); + + TBool autoResumePossible = ETrue; + + if ( iNumberOfActiveAudioClients > 0 ) + { + // cancel any previously started audio resume call + iAutoResumeTimer->Cancel(); + } + + // Check all playing audios! + for ( TInt i = 0; i < iNumberOfActiveAudioClients; i++ ) + { + TInt cat = audioClients().iClientCategoryList[i]; + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - audio category %d"), cat ) ); + + if ( iNoAutoResumeAudioCategories.Find(cat) != KErrNotFound ) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - Radio audio will not be resumed") ) ); + autoResumePossible = EFalse; + } + else + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector - radio audio might be resumed") ) ); + } + } + + // Decide audio resource availability from audio category info. + if ( !autoResumePossible ) + { + // Auto resume forbidden + FTRACE( FPrint( _L("CFMRadioSystemEventDetector::HandlePropertyChangeL - AudioAutoResumeForbiddenL ") ) ); + iObserver.AudioAutoResumeForbiddenL(); + } + else if ( iNumberOfActiveAudioClients == 0 ) + { + if ( !iIsVoiceUiActive ) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector::HandlePropertyChangeL - NotifyAudioResourcesAvailabilityL") ) ); + NotifyAudioResourcesAvailability(); + } + } + else + { + // NOP. Some auto resume neutral audio is playing + } + } + } + } + + +#endif //__WINS__ + +#ifdef __WINS__ +// --------------------------------------------------------------------------- +// Dummy version for WINS in order to avoid compiler warnings. +// The real implementation of function is above. +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::HandlePropertyChangeL( const TUid& /*aCategory*/, + const TUint /*aKey*/, + const TDesC8& /*aValue*/) + { + } +#endif // __WINS__ + +// Handling of the text property changes is done here. +// Observer components are getting notifications in correspondence with what +// has changed +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::HandlePropertyChangeL( const TUid& /*aCategory*/, + const TUint /*aKey*/, + const TDesC& /*aValue*/) + { + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::IsNetworkCoverage +// --------------------------------------------------------------------------- +// +TBool CFMRadioSystemEventDetector::IsNetworkCoverage() const + { +#ifdef __WINS__ + return ETrue; +#else + return iIsNetworkCoverage; +#endif + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::IsCallActive +// --------------------------------------------------------------------------- +// +TBool CFMRadioSystemEventDetector::IsCallActive() const + { + return iIsCallActive; + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::NotifyAudioResourcesAvailability +// --------------------------------------------------------------------------- +// +void CFMRadioSystemEventDetector::NotifyAudioResourcesAvailability() + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector::NotifyAudioResourcesAvailability") ) ); + // call observer interface after a delay + iAutoResumeTimer->Cancel(); + iAutoResumeTimer->Start( TTimeIntervalMicroSeconds32( KFMRadioAutoResumeDelay ), + TTimeIntervalMicroSeconds32( 0 ), + TCallBack( StaticAutoResumeTimerCallback, this ) ); + } + +// --------------------------------------------------------------------------- +// CFMRadioSystemEventDetector::StaticAutoResumeTimerCallback +// --------------------------------------------------------------------------- +// +TInt CFMRadioSystemEventDetector::StaticAutoResumeTimerCallback( TAny* aSelfPtr ) + { + FTRACE( FPrint( _L("CFMRadioSystemEventDetector::StaticAutoResumeTimerCallback") ) ); + CFMRadioSystemEventDetector* self = static_cast( aSelfPtr ); + if ( self ) + { + self->iAutoResumeTimer->Cancel(); + TRAP_IGNORE( self->iObserver.AudioResourcesAvailableL() ) + } + return KErrNone; + } + +// end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/group/bld.inf Tue Feb 02 00:17:10 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: Component definition for the +* FM Radio Content Publisher plugin. +* +*/ + +#include + +// Platforms the component needs to be built on +// + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES +fmradiomcpplugin.mmp + +// End of file diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/group/fmradiomcpplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/group/fmradiomcpplugin.mmp Tue Feb 02 00:17:10 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: Project definition file for project +* FM Radio Content Publisher plugin. +* +*/ + +#include +#include +#include "../resources/fmradiomcpplugin.hrh" + +TARGET fmradiomcpplugin100.dll +TARGETTYPE PLUGIN +UID 0x10009D8D KFMRadioMCPPluginDllUid + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +PAGED + +SOURCEPATH ../resources +START RESOURCE 2001f497.rss +TARGET fmradiomcpplugin100.rsc +TARGETPATH ECOM_RESOURCE_DIR +END + +START RESOURCE fmradiomcpplugin.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +LANGUAGE_IDS +END + +APP_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../fmradio/inc +USERINCLUDE ../resources +USERINCLUDE ../../activeidleengine/inc +USERINCLUDE ../../fmradioactionhandler/inc +USERINCLUDE ../../fmradioactionhandler/resources +USERINCLUDE ../../fmradioengine/inc +USERINCLUDE ../../loc + +SOURCEPATH ../src +SOURCE fmradiomcpplugin.cpp + +LIBRARY avkon.lib +LIBRARY bafl.lib +LIBRARY cone.lib +LIBRARY commonengine.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY euser.lib +LIBRARY liwservicehandler.lib +LIBRARY fmradioactiveidleengine200.lib +LIBRARY fmradioengine.lib + +DEBUGLIBRARY flogger.lib + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/inc/fmradiomcpplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/inc/fmradiomcpplugin.h Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,119 @@ +/* +* 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: Declaration for the class CFMRadioMCPPlugin. +* +*/ + +#ifndef FMRADIOMCPPLUGIN_H +#define FMRADIOMCPPLUGIN_H + +#include +#include +#include + +#include "fmradioactiveidleenginenotifyhandler.h" + +class CFMRadioActiveIdleEngine; +class MFMRadioActiveIdleEngineNotifyHandler; + +/** +* Music content publisher plugin for FM Radio. +* +* Implements MCP plugin which publishes FM Radio state to affected parties. +* +* @lib fmradiomcpplugin100.lib +* +*/ +NONSHARABLE_CLASS( CFMRadioMCPPlugin ) : public CMCPPlugin, + public MFMRadioActiveIdleEngineNotifyHandler + { +public: + + static CFMRadioMCPPlugin* NewL( MMCPPluginObserver* aObserver ); + ~CFMRadioMCPPlugin(); + +// from base class CMCPPlugin + void Deactivate(); + +// from base class MFMRadioActiveIdleEngineNotifyHandler + void HandleRadioVolumeChangeL( TInt aVolume ); + void HandleTuningStateChangeL( TFMRadioPSTuningState aTuningState ); + void HandleFrequencyChangeL( TInt aFrequency ); + void HandleChannelChangeL( TInt aId ); + void HandleChannelModifyL( TInt aId ); + void HandleMuteStateChangeL( TFMRadioPSRadioMuteState aMuteState ); + void HandleApplicationRunningStateChangeL( TFMRadioPSApplicationRunningState aRunningState ); + void HandleFrequencyDecimalCountChangeL( TFMRadioPSFrequencyDecimalCount aDecimalCount ); + void HandleAntennaStatusChangeL( TFMRadioPSHeadsetStatus aAntennaStatus ); + void HandlePowerStateChangeL( TFMRadioPSRadioPowerState aPowerState ); + void HandleRDSProgramServiceChangeL( const TDesC& aProgramService ); + void HandleRDSRadioTextChangeL( const TDesC& aRdsText ); + void HandleChannelNameChangeL( const TDesC& aName ); + void HandlePresetListCountChangeL( TInt aPresetCount ); + void HandlePresetListFocusChangeL( TInt aPresetFocus ); + +private: + void InstallFMRadioCommandActionL( const TDesC& aCommand, TMCPTriggerDestination aDestination ); + void ActivateL(); + void InstallEmptyActionL( TMCPTriggerDestination aDestination ); + void DimmNextAndPrevious(); + void PublishApplicationIconL( TMCPImageDestination aDestination ); + void PublishFrequencyL( TInt aFrequency, TMCPTextDestination aDestination ); + void UpdatePublishedToolBarL(TUint aToolBarState); + void UpdateToolBarL( TBool aForceApplicationClosing = EFalse ); + void UpdateMusicWidgetTextL( TBool aForceApplicationClosing = EFalse ); + + /** + * Transfers the given frequency number as a descriptor + * @param aFrequency The frequency to be formatted + * @return The frequency descriptor. Pushed to Cleanup Stack. Ownership is transfered. + */ + HBufC* FrequencyStringLC( TInt aFrequency ); + +private: + CFMRadioMCPPlugin( MMCPPluginObserver* aObserver ); + void ConstructL(); + void InitializeResourceLoadingL(); + +private: + MMCPPluginObserver* iObserver; + + CFMRadioActiveIdleEngine* iEngine; + TBool iActive; + TInt iResourceOffset; + RBuf iAntennaNotConnectedText; + RBuf iTuningText; + RBuf iSavedStationFormat; + RBuf iSavedStationFormatNoName; + RBuf iFrequencyFormat; + + RBuf iSavedStationFormatMenu; + RBuf iSavedStationFormatNoNameMenu; + RBuf iFrequencyFormatMenu; + RBuf iNowPlayingText; + RBuf iLastPlayedText; + + TUint iTbPreviousState; + TUint iTbMuteUnmuteState; + TUint iTbNextState; + TInt iPresetCount; + + /** + * Name of the mif-file that provides the published icons. + * Owned. + */ + RBuf iMifFileName; + }; + +#endif /* FMRADIOMCPPLUGIN_H */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/resources/2001f497.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/resources/2001f497.rss Tue Feb 02 00:17:10 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: ECom plugin registration resource for FM Radio Content Publisher Plugin. +* +*/ + +#include +#include + +#include "fmradiomcpplugin.hrh" + +// --------------------------------------------------------------------------- +// Resource information for the ECOM DLL. +// --------------------------------------------------------------------------- +// +RESOURCE REGISTRY_INFO theInfo + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + + dll_uid = KFMRadioMCPPluginDllUid; + + interfaces = + { + INTERFACE_INFO + { + // Plugin interface + interface_uid = KMCPPluginUid; + + implementations = + { + // Plugin implementation + IMPLEMENTATION_INFO + { + implementation_uid = KFMRadioMCPPluginImplementationUid; + version_no = 1; + display_name = ""; + default_data = ""; + opaque_data = ""; + rom_only = 0; + } + }; + } + }; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/resources/fmradiomcpplugin.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/resources/fmradiomcpplugin.hrh Tue Feb 02 00:17:10 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: Definitions for the FM Radio Content Publisher plugin. +* +*/ + +#ifndef FMRADIOMCPPLUGIN_HRH +#define FMRADIOMCPPLUGIN_HRH + +// Ecom DLL UID for FM Radio Music Content Publisher Plugin. +#define KFMRadioMCPPluginDllUid 0x2001F497 + +// Ecom implementation UID for FM Radio Music Content Publisher Plugin. +#define KFMRadioMCPPluginImplementationUid 0x2001FCB7 + +#endif /* FMRADIOMCPPLUGIN_HRH */ diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/resources/fmradiomcpplugin.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/resources/fmradiomcpplugin.rss Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,49 @@ +/* +* 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: Resource definitions for FM Radio Content Publisher Plugin. +* +*/ + +NAME FMCP + +#include +#include + +// --------------------------------------------------------------------------- +// The signature of the resource file. +// --------------------------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE + { + } + +// --------------------------------------------------------------------------- +// The default document name of the application. +// --------------------------------------------------------------------------- +// +RESOURCE TBUF + { + buf = ""; + } + +RESOURCE TBUF r_qtn_fmradio_widget_con_headset { buf = qtn_fmradio_widget_con_headset; } +RESOURCE TBUF r_qtn_fmradio_widget_tuning { buf = qtn_fmradio_widget_tuning; } +RESOURCE TBUF r_qtn_fmradio_widget_station_saved { buf = qtn_fmradio_widget_station_saved; } +RESOURCE TBUF r_qtn_fmradio_widget_station_saved_freq { buf = qtn_fmradio_widget_station_saved_freq; } +RESOURCE TBUF r_qtn_fmradio_widget_notsaved_frequency { buf = qtn_fmradio_widget_notsaved_frequency; } +RESOURCE TBUF r_qtn_fmradio_suite_last_played { buf = qtn_fmradio_suite_last_played; } +RESOURCE TBUF r_qtn_fmradio_suite_now_playing { buf = qtn_fmradio_suite_now_playing; } +RESOURCE TBUF r_qtn_fmradio_suite_playing_saved_with_name { buf = qtn_fmradio_suite_playing_saved_with_name; } +RESOURCE TBUF r_qtn_fmradio_suite_playing_saved_without_name { buf = qtn_fmradio_suite_playing_saved_without_name; } +RESOURCE TBUF r_qtn_fmradio_suite_playing_not_saved { buf = qtn_fmradio_suite_playing_not_saved; } diff -r 000000000000 -r f3d95d9c00ab fmradio/fmradiomcpplugin/src/fmradiomcpplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/fmradiomcpplugin/src/fmradiomcpplugin.cpp Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,862 @@ +/* +* 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: Implementation for the FM Radio Content Publisher Plugin. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmradioactionhandler.h" +#include "fmradioactionhandler.hrh" +#include "fmradioactionhandlerdefs.h" +#include "fmradioactiveidleengine.h" +#include "fmradioactiveidleenginenotifyhandler.h" +#include "fmradiodefines.h" +#include "debug.h" +#include "fmradiomcpplugin.h" +#include "fmradiomcpplugin.hrh" +#include "AknsConstants.h" + +_LIT( KFMRadioMifFileName, "fmradio.mif" ); +_LIT( KFMRadioMifDir, "\\resource\\apps\\" ); + +_LIT( KFMRadioMCPPluginResourceFileName, "fmradiomcpplugin.rsc" ); +_LIT8( KFMRadioPluginUid, "plugin_id" ); +_LIT8( KFMRadioData, "data" ); +_LIT8( KType, "type" ); + +const TUint KFMRadioPrevious = 0x001; //000000000001 +const TUint KFMRadioNext = 0x002; //000000000010 +const TUint KFMRadioMute = 0x004; //000000000100 +const TUint KFMRadioUnmute = 0x008; //000000001000 +const TUint KFMRadioPreviousDimmed = 0x010; //000000010000 +const TUint KFMRadioNextDimmed = 0x020; //000000100000 +const TUint KFMRadioMuteDimmed = 0x040; //000001000000 +const TUint KFMRadioUnmuteDimmed = 0x080; //000010000000 + +CFMRadioMCPPlugin* CFMRadioMCPPlugin::NewL( MMCPPluginObserver* aObserver ) + { + CFMRadioMCPPlugin* self = new ( ELeave ) CFMRadioMCPPlugin( aObserver ); + CleanupStack::PushL( self ); + + self->ConstructL(); + + CleanupStack::Pop( self ); + return self; + } + +CFMRadioMCPPlugin::~CFMRadioMCPPlugin() + { + if ( iResourceOffset > 0 ) + { + CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); + } + + delete iEngine; + iNowPlayingText.Close(); + iLastPlayedText.Close(); + iAntennaNotConnectedText.Close(); + iTuningText.Close(); + iSavedStationFormat.Close(); + iSavedStationFormatNoName.Close(); + iFrequencyFormat.Close(); + iSavedStationFormatMenu.Close(); + iSavedStationFormatNoNameMenu.Close(); + iFrequencyFormatMenu.Close(); + + iMifFileName.Close(); + } + +CFMRadioMCPPlugin::CFMRadioMCPPlugin( MMCPPluginObserver* aObserver ) + : iObserver( aObserver ) + { + } + +void CFMRadioMCPPlugin::ConstructL() + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ConstructL" ))); + InitializeResourceLoadingL(); + + CCoeEnv* coeEnv = CCoeEnv::Static(); + + iNowPlayingText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_SUITE_NOW_PLAYING, coeEnv ) ); + iLastPlayedText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_SUITE_LAST_PLAYED, coeEnv ) ); + + iAntennaNotConnectedText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_CON_HEADSET, coeEnv ) ); + iTuningText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_TUNING, coeEnv ) ); + iSavedStationFormat.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_STATION_SAVED, coeEnv ) ); + iSavedStationFormatNoName.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_STATION_SAVED_FREQ, coeEnv ) ); + iFrequencyFormat.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_NOTSAVED_FREQUENCY, coeEnv ) ); + + iSavedStationFormatMenu.Assign( StringLoader::LoadL( R_QTN_FMRADIO_SUITE_PLAYING_SAVED_WITH_NAME, coeEnv ) ); + iSavedStationFormatNoNameMenu.Assign( StringLoader::LoadL( R_QTN_FMRADIO_SUITE_PLAYING_SAVED_WITHOUT_NAME, coeEnv ) ); + iFrequencyFormatMenu.Assign( StringLoader::LoadL( R_QTN_FMRADIO_SUITE_PLAYING_NOT_SAVED, coeEnv ) ); + + // Release the resource file, because we don't want to keep file handle open. + // That would prevent updating the binary with SIS. + if ( iResourceOffset > 0 ) + { + coeEnv->DeleteResourceFile( iResourceOffset ); + iResourceOffset = 0; + } + + TFindFile finder( coeEnv->FsSession() ); + TInt err = finder.FindByDir( KFMRadioMifFileName, KFMRadioMifDir ); + if ( err == KErrNone ) + { + iMifFileName.CreateL( finder.File() ); + } + + iEngine = CFMRadioActiveIdleEngine::NewL( *this ); + iEngine->ActivateL(); + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ConstructL - Exiting." ))); + } + +// --------------------------------------------------------------------------- +// Initialize resource file for loading resources. +// --------------------------------------------------------------------------- +// +void CFMRadioMCPPlugin::InitializeResourceLoadingL() + { + CCoeEnv* coeEnv = CCoeEnv::Static(); + RFs fs( coeEnv->FsSession() ); + TFileName fileName; + TFileName baseResource; + TFindFile finder( fs ); + TLanguage language( ELangNone ); + + TParsePtrC parse( KFMRadioMCPPluginResourceFileName ); + _LIT( resourceFileWildExt, ".r*" ); + + // Make sure to find all resource files, not only .rsc files as it may be so + // that there is only .r01, .r02, etc. files available + fileName.Copy( parse.Name() ); + fileName.Append( resourceFileWildExt ); + + // TFindFile applies search order that is from + // drive Y to A, then Z + CDir* entries = NULL; + TInt err = finder.FindWildByDir( fileName , KDC_RESOURCE_FILES_DIR, entries ); + delete entries; + entries = NULL; + TBool found = EFalse; + while ( !found && err == KErrNone ) + { + // Found file + fileName.Zero(); + TParsePtrC foundPath( finder.File() ); + fileName.Copy( foundPath.DriveAndPath() ); + fileName.Append( KFMRadioMCPPluginResourceFileName ); + BaflUtils::NearestLanguageFile( fs, fileName, language ); + if ( language != ELangNone && BaflUtils::FileExists( fs, fileName ) ) + { + found = ETrue; + iResourceOffset = coeEnv->AddResourceFileL( fileName ); + } + else + { + if ( language == ELangNone && + !baseResource.Compare( KNullDesC ) && + BaflUtils::FileExists( fs, fileName ) ) + { + baseResource.Copy( fileName ); + } + err = finder.FindWild( entries ); + delete entries; + entries = NULL; + } + } + + if ( !found && baseResource.Compare( KNullDesC ) ) + { + // If we found *.rsc then better to use that than nothing + if ( BaflUtils::FileExists( fs, baseResource ) ) + { + iResourceOffset = coeEnv->AddResourceFileL( baseResource ); + found = ETrue; + } + } + + if( !found ) + { + User::Leave( KErrNotFound ); + } + } + +void CFMRadioMCPPlugin::Deactivate() + { + iActive = EFalse; + } + +void CFMRadioMCPPlugin::ActivateL() + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ActivateL()" ))); + iActive = ETrue; + iObserver->BecameActiveL( this ); + + iObserver->PublishTextL( this, EMusicWidgetDefaultText, KNullDesC ); + + iObserver->PublishImageL( this, EMusicMenuMusicInfoImage1, + KAknsIIDQgnIndiRadioDefault, + iMifFileName, + EMbmFmradioQgn_indi_radio_default, + EMbmFmradioQgn_indi_radio_default_mask); + + iObserver->PublishImageL( this, EMusicWidgetImage1, + KAknsIIDQgnIndiRadioDefault, + iMifFileName, + EMbmFmradioQgn_indi_radio_default, + EMbmFmradioQgn_indi_radio_default_mask); + + InstallFMRadioCommandActionL( KFMRadioCommandValueStartNowPlaying, EMusicWidgetTrigger1 ); + InstallFMRadioCommandActionL( KFMRadioCommandValueStartNowPlaying, EMusicMenuMusicInfoTrigger ); + HandleChannelChangeL( iEngine->Channel() ); + } + +// --------------------------------------------------------------------------- +// CFMRadioMCPPlugin::UpdatePublishedToolBarL +// --------------------------------------------------------------------------- +// +void CFMRadioMCPPlugin::UpdatePublishedToolBarL( TUint aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - Entering." ))); + if ( iActive ) + { + TAknsItemID iconId; + if ( KFMRadioPrevious & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 1 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbPrev ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB1, + iconId, + iMifFileName, + EMbmFmradioQgn_prop_image_tb_prev, + EMbmFmradioQgn_prop_image_tb_prev_mask ); + InstallFMRadioCommandActionL( KFMRadioCommandValueStepPrevious, EMusicWidgetTB1Trigger ); + iTbPreviousState = KFMRadioPrevious; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 1 Exit" ))); + } + + if ( KFMRadioPreviousDimmed & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 2 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbPrevDimmed ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB1, + iconId, + iMifFileName, + EMbmFmradioQgn_prop_image_tb_prev_dimmed, + EMbmFmradioQgn_prop_image_tb_prev_dimmed_mask ); + InstallEmptyActionL( EMusicWidgetTB1Trigger ); + iTbPreviousState = KFMRadioPreviousDimmed; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 2 Exit" ))); + } + + if ( KFMRadioNext & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 3 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbNext ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB3, + iconId, + iMifFileName, + EMbmFmradioQgn_prop_image_tb_next, + EMbmFmradioQgn_prop_image_tb_next_mask ); + InstallFMRadioCommandActionL( KFMRadioCommandValueStepNext, EMusicWidgetTB3Trigger ); + iTbNextState = KFMRadioNext; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 3 Exit" ))); + } + + if ( KFMRadioNextDimmed & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 4 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbNextDimmed ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB3, + iconId, + iMifFileName, + EMbmFmradioQgn_prop_image_tb_next_dimmed, + EMbmFmradioQgn_prop_image_tb_next_dimmed_mask ); + InstallEmptyActionL( EMusicWidgetTB3Trigger ); + iTbNextState = KFMRadioNextDimmed; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 4 Exit" ))); + } + + if ( KFMRadioMute & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 5 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSound ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB2, + iconId, + iMifFileName, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_mask ); + InstallFMRadioCommandActionL( KFMRadioCommandValueUnmute, EMusicWidgetTB2Trigger ); + iTbMuteUnmuteState = KFMRadioMute; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 5 Exit" ))); + } + + if ( KFMRadioUnmute & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 6 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundMuted ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB2, + iconId, + iMifFileName, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_mask ); + InstallFMRadioCommandActionL( KFMRadioCommandValueMute, EMusicWidgetTB2Trigger ); + iTbMuteUnmuteState = KFMRadioUnmute; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 6 Exit" ))); + } + + if ( KFMRadioMuteDimmed & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 7 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundDimmed ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB2, + iconId, + iMifFileName, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_dimmed, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_dimmed_mask ); + InstallEmptyActionL( EMusicWidgetTB2Trigger ); + iTbMuteUnmuteState = KFMRadioMuteDimmed; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 7 Exit" ))); + } + + if ( KFMRadioUnmuteDimmed & aToolBarState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 8 Enter" ))); + iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundMutedDimmed ); + iObserver->PublishImageL( this, + EMusicWidgetToolbarB2, + iconId, + iMifFileName, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_dimmed, + EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_dimmed_mask ); + InstallEmptyActionL( EMusicWidgetTB2Trigger ); + iTbMuteUnmuteState = KFMRadioUnmuteDimmed; + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 8 Exit" ))); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMCPPlugin::UpdateToolBarL +// --------------------------------------------------------------------------- +// +void CFMRadioMCPPlugin::UpdateToolBarL( TBool aForceApplicationClosing ) + { + if ( iActive ) + { + TUint muteDimmedState = iEngine->MuteState() == EFMRadioPSMuteStateOn ? + KFMRadioUnmuteDimmed : KFMRadioMuteDimmed; + // Update Next and Previous buttons. + if ( iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 1" ))); + UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); + return; + } + else if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || aForceApplicationClosing ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 2" ))); + UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); + return; + } + else if ( iEngine->PowerState() != EFMRadioPSRadioPowerOn ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 3" ))); + UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); + return; + } + else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 4" ))); + UpdatePublishedToolBarL( KFMRadioPreviousDimmed | KFMRadioNextDimmed ); + } + else if ( iPresetCount > 1 || ( iPresetCount == 1 && iEngine->Channel() == KErrNotFound ) ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 5" ))); + UpdatePublishedToolBarL( KFMRadioPrevious | KFMRadioNext ); + } + else + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 6" ))); + UpdatePublishedToolBarL( KFMRadioPreviousDimmed | KFMRadioNextDimmed ); + } + + // Update Mute/Unmute button + if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || aForceApplicationClosing ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 7" ))); + UpdatePublishedToolBarL( muteDimmedState ); + } + else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 8" ))); + UpdatePublishedToolBarL( muteDimmedState ); + } + else + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 9" ))); + HandleMuteStateChangeL( iEngine->MuteState() ); + } + } + } +// --------------------------------------------------------------------------- +// CFMRadioMCPPlugin::UpdateMusicWidgetTextL +// --------------------------------------------------------------------------- +// +void CFMRadioMCPPlugin::UpdateMusicWidgetTextL( TBool aForceApplicationClosing ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL" ))); + if ( iActive ) + { + TInt rightToLeftCharWidth = AknLayoutUtils::LayoutMirrored() ? sizeof(TText16) : 0; + + // Homescreen publishing + if ( iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected && !aForceApplicationClosing ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS antenna not connected: \"%S\""), &iAntennaNotConnectedText )); + iObserver->PublishTextL( this, EMusicWidgetText1, iAntennaNotConnectedText ); + } + else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized && !aForceApplicationClosing ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS tuning: \"%S\""), &iTuningText )); + iObserver->PublishTextL( this, EMusicWidgetText1, iTuningText ); + } + else if ( iPresetCount && iEngine->Channel() != KErrNotFound ) + { + if( iEngine->ChannelName().Length() ) + { + // Station saved and name is available + RBuf name; + // For widget + // Preserve space for the channel name, format string and maximum index number + name.CreateL( iEngine->ChannelName().Length() + + iSavedStationFormat.Length() + + KDefaultRealWidth + + rightToLeftCharWidth ); + name.CleanupClosePushL(); + StringLoader::Format( name, iSavedStationFormat, KErrNotFound, iEngine->Channel() + 1 ); + + HBufC* tempName = name.AllocL(); + StringLoader::Format( name, *tempName, KErrNotFound, iEngine->ChannelName() ); + delete tempName; + tempName = NULL; + + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + name.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget saved station: \"%S\""), &name )); + iObserver->PublishTextL( this, EMusicWidgetText1, name ); + CleanupStack::PopAndDestroy(); // name + + // For Music Suite + // Preserve space for the channel name, format string and maximum index number + name.CreateL( iEngine->ChannelName().Length() + + iSavedStationFormatMenu.Length() + + KDefaultRealWidth + + rightToLeftCharWidth ); + name.CleanupClosePushL(); + StringLoader::Format( name, iSavedStationFormatMenu, KErrNotFound, iEngine->Channel() + 1 ); + + tempName = name.AllocL(); + StringLoader::Format( name, *tempName, KErrNotFound, iEngine->ChannelName() ); + delete tempName; + tempName = NULL; + + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + name.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Suite saved station: \"%S\""), &name )); + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, name ); + CleanupStack::PopAndDestroy(); // name + } + else + { + // Station saved, but name for it is not available + HBufC* frequencyString = FrequencyStringLC( iEngine->Frequency() ); + RBuf formattedFrequency; + + // For widget + formattedFrequency.CreateL( iSavedStationFormatNoName.Length() + + frequencyString->Length() + + KDefaultRealWidth + + rightToLeftCharWidth ); + formattedFrequency.CleanupClosePushL(); + StringLoader::Format( formattedFrequency, iSavedStationFormatNoName, KErrNotFound, iEngine->Channel() + 1 ); + + HBufC* tempFrequency = formattedFrequency.AllocL(); + StringLoader::Format( formattedFrequency, *tempFrequency, KErrNotFound, *frequencyString ); + delete tempFrequency; + tempFrequency = NULL; + AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); + + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + formattedFrequency.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget saved station with frequency: \"%S\""), &formattedFrequency )); + iObserver->PublishTextL( this, EMusicWidgetText1, formattedFrequency ); + CleanupStack::PopAndDestroy(); // formattedFrequency + + // For Music Suite + formattedFrequency.CreateL( iSavedStationFormatNoNameMenu.Length() + + frequencyString->Length() + + KDefaultRealWidth + + rightToLeftCharWidth ); + formattedFrequency.CleanupClosePushL(); + StringLoader::Format( formattedFrequency, iSavedStationFormatNoNameMenu, KErrNotFound, iEngine->Channel() + 1 ); + + tempFrequency = formattedFrequency.AllocL(); + StringLoader::Format( formattedFrequency, *tempFrequency, KErrNotFound, *frequencyString ); + delete tempFrequency; + tempFrequency = NULL; + + AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + formattedFrequency.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Suite saved station with frequency: \"%S\""), &formattedFrequency )); + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, formattedFrequency ); + CleanupStack::PopAndDestroy( 2, frequencyString ); // formattedFrequency, frequencyString + } + } + else if ( iEngine->RDSProgramService().Length() > 0 ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS PS name: \"%S\""), &iEngine->RDSProgramService() )); + iObserver->PublishTextL( this, EMusicWidgetText1, iEngine->RDSProgramService() ); + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, iEngine->RDSProgramService() ); + } + else + { + TInt currentFrequency = iEngine->Frequency(); + // publish only valid frequency + if ( currentFrequency > 0 ) + { + HBufC* frequencyString = FrequencyStringLC( currentFrequency ); + + RBuf formattedFrequency; + // For widget + // Preserve space for the format string and maximum index number + formattedFrequency.CreateL( iFrequencyFormat.Length() + + frequencyString->Length() + + rightToLeftCharWidth ); + formattedFrequency.CleanupClosePushL(); + StringLoader::Format( formattedFrequency, iFrequencyFormat, KErrNotFound, *frequencyString ); + AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); + + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + formattedFrequency.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget frequency: \"%S\""), &formattedFrequency )); + iObserver->PublishTextL( this, EMusicWidgetText1, formattedFrequency ); + CleanupStack::PopAndDestroy(); // formattedFrequency + + // For Music Suite + // Preserve space for the format string and maximum index number + formattedFrequency.CreateL( iFrequencyFormatMenu.Length() + + frequencyString->Length() + + rightToLeftCharWidth ); + formattedFrequency.CleanupClosePushL(); + StringLoader::Format( formattedFrequency, iFrequencyFormatMenu, KErrNotFound, *frequencyString ); + AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); + + if ( rightToLeftCharWidth ) + { + //E.g. 1. Name -> Name .1 + formattedFrequency.Insert( 0, KRightToLeftMark ); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Suite frequency: \"%S\""), &formattedFrequency )); + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, formattedFrequency ); + CleanupStack::PopAndDestroy( 2, frequencyString ); // formattedFrequency, frequencyString + } + else + { + // Publish empty text instead of 0.00 MHz + iObserver->PublishTextL( this, EMusicWidgetText1, KNullDesC ); + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, KNullDesC ); + } + } + if( iEngine->PowerState() == EFMRadioPSRadioPowerOn && !aForceApplicationClosing ) + { + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine1, iNowPlayingText ); + } + else + { + iObserver->PublishTextL( this, EMusicMenuMusicInfoLine1, iLastPlayedText ); + } + } + } + +// --------------------------------------------------------------------------- +// CFMRadioMCPPlugin::FrequencyStringLC +// --------------------------------------------------------------------------- +// +HBufC* CFMRadioMCPPlugin::FrequencyStringLC( TInt aFrequency ) + { + TReal frequency = static_cast( aFrequency / static_cast( KHzConversionFactor )); + TRealFormat format( KFrequencyMaxLength, iEngine->FrequencyDecimalCount() ); + TBuf frequencyString; + frequencyString.Num( frequency, format ); + + return frequencyString.AllocLC(); + } + +void CFMRadioMCPPlugin::HandleRadioVolumeChangeL( TInt /* aVolume */ ) + { + } + +void CFMRadioMCPPlugin::HandleTuningStateChangeL( TFMRadioPSTuningState FDEBUGVAR( aTuningState ) ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleTuningStateChangeL: aTuningState=[%d]"), aTuningState)); + + if ( iActive ) + { + UpdateMusicWidgetTextL(); + UpdateToolBarL(); + } + + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleTuningStateChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleFrequencyChangeL( TInt FDEBUGVAR( aFrequency ) ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyChangeL: aFrequency=%d"), aFrequency)); + } + +void CFMRadioMCPPlugin::HandleChannelChangeL( TInt FDEBUGVAR( aId ) ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelChangeL: aId=[%d]"), aId )); + if ( iActive ) + { + UpdateMusicWidgetTextL(); + UpdateToolBarL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleChannelModifyL( TInt aId ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelModifyL: aId=[%d]"), aId )); + if ( iActive && aId == iEngine->Channel() ) + { + UpdateMusicWidgetTextL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelModifyL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleMuteStateChangeL( TFMRadioPSRadioMuteState aMuteState ) + { + if ( iActive ) + { + switch( aMuteState ) + { + case EFMRadioPSMuteStateOn: + if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning ) + { + UpdatePublishedToolBarL( KFMRadioUnmuteDimmed ); + } + else + { + UpdatePublishedToolBarL( KFMRadioUnmute ); + } + break; + case EFMRadioPSMuteStateOff: + case EFMRadioPSMuteStateUninitialized: + if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning ) + { + UpdatePublishedToolBarL( KFMRadioMuteDimmed ); + } + else + { + UpdatePublishedToolBarL( KFMRadioMute ); + } + break; + default:break; + } + } + } + +void CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL( TFMRadioPSApplicationRunningState aRunningState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL - aRunningState=%d"), aRunningState )); + + switch ( aRunningState ) + { + case EFMRadioPSApplicationRunning: + break; + case EFMRadioPSApplicationClosing: + UpdateMusicWidgetTextL( ETrue ); + UpdateToolBarL( ETrue ); + Deactivate(); + break; + default: + break; + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL( TFMRadioPSFrequencyDecimalCount /* aDecimalCount */ ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL." ))); + if ( iActive ) + { + UpdateMusicWidgetTextL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleAntennaStatusChangeL( TFMRadioPSHeadsetStatus /*aAntennaStatus*/ ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleAntennaStatusChangeL - Enter"))); + if ( iActive ) + { + UpdateMusicWidgetTextL(); + UpdateToolBarL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleAntennaStatusChangeL - Exiting."))); + } + +void CFMRadioMCPPlugin::HandlePresetListCountChangeL( TInt aPresetCount ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListCountChangeL(%d) - Enter"), aPresetCount)); + iPresetCount = aPresetCount; + if ( iActive ) + { + if( !aPresetCount ) + { + UpdateMusicWidgetTextL(); + } + UpdateToolBarL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListCountChangeL - Exiting."))); + } + +void CFMRadioMCPPlugin::HandlePresetListFocusChangeL( TInt FDEBUGVAR( aPresetFocus ) ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListFocusChangeL - %d"), aPresetFocus )); + } + +void CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL( const TDesC& /*aProgramService*/ ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL." ))); + if ( iActive ) + { + UpdateMusicWidgetTextL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::HandleRDSRadioTextChangeL( const TDesC& /*aRdsText*/ ) + { + } + +void CFMRadioMCPPlugin::HandleChannelNameChangeL( const TDesC& /*aName*/ ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelNameChangeL." ))); + } + +void CFMRadioMCPPlugin::HandlePowerStateChangeL( TFMRadioPSRadioPowerState aPowerState ) + { + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePowerStateChangeL(%d)."), aPowerState )); + if( aPowerState == EFMRadioPSRadioPowerOn ) + { + ActivateL(); + } + if ( iActive ) + { + UpdateMusicWidgetTextL(); + UpdateToolBarL(); + } + FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePowerStateChangeL - Exiting." ))); + } + +void CFMRadioMCPPlugin::InstallEmptyActionL( TMCPTriggerDestination aDestination ) + { + CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); + iObserver->PublishActionL( this, aDestination, mapTrigger ); + CleanupStack::PopAndDestroy( mapTrigger ); + } + +void CFMRadioMCPPlugin::InstallFMRadioCommandActionL( const TDesC& aCommand, TMCPTriggerDestination aDestination ) + { + CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); + CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); + + mapTrigger->InsertL( KFMRadioPluginUid, TLiwVariant( TUid::Uid( KFMRadioActionHandlerImplementationUid ) ) ); + mapData->InsertL( KType, TLiwVariant( aCommand ) ); + mapData->InsertL( KFMRadioCommand , TLiwVariant( aCommand ) ); + mapTrigger->InsertL( KFMRadioData, TLiwVariant( mapData ) ); + + if ( iActive ) + { + iObserver->PublishActionL( this, aDestination, mapTrigger ); + } + + CleanupStack::PopAndDestroy( mapData ); + CleanupStack::PopAndDestroy( mapTrigger ); + } + +/** Provides a key-value pair table, that is used to identify the correct construction function for the requested interface. */ +const TImplementationProxy KFMRadioMCPPluginImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( KFMRadioMCPPluginImplementationUid, CFMRadioMCPPlugin::NewL ) + }; + +const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ); + +// --------------------------------------------------------------------------- +// Returns the implementations provided by this ECOM plugin DLL. +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) + { + aTableCount = sizeof( KFMRadioMCPPluginImplementationTable ) / sizeof( TImplementationProxy ); + return KFMRadioMCPPluginImplementationTable; + } diff -r 000000000000 -r f3d95d9c00ab fmradio/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/group/bld.inf Tue Feb 02 00:17:10 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: This file provides the information required for building the +* whole of a FMRadio. +* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +// export central repository configuration files +../conf/fmradio.confml CONFML_EXPORT_PATH(fmradio.confml, customsw) +../conf/fmradio_2001b25e.crml CRML_EXPORT_PATH(fmradio_2001b25e.crml, customsw) + +// export localization source loc file +../loc/fmradio.loc APP_LAYER_LOC_EXPORT_PATH(fmradio.loc) + +PRJ_MMPFILES +#include "../activeidleengine/group/bld.inf" +#include "../fmradioengine/group/bld.inf" +#include "../fmradioactionhandler/group/bld.inf" +#include "../fmradiomcpplugin/group/bld.inf" +#include "../fmradio/group/bld.inf" +// Help exports +#include "../help/group/bld.inf" +// End of File + diff -r 000000000000 -r f3d95d9c00ab fmradio/help/data/xhtml.zip Binary file fmradio/help/data/xhtml.zip has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/help/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/help/group/bld.inf Tue Feb 02 00:17:10 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/radio.hlp.hrh MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/radio.hlp.hrh) +../rom/fmradiohelps_variant.iby CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(fmradiohelps_variant.iby) diff -r 000000000000 -r f3d95d9c00ab fmradio/help/inc/radio.hlp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/help/inc/radio.hlp.hrh Tue Feb 02 00:17:10 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: +* +*/ + +// +// radio.hlp.hrh generated by CSXHelp Utilities. +// + +#ifndef __RADIO_HLP_HRH__ +#define __RADIO_HLP_HRH__ + +_LIT(KFMRADIO_HLP_MAIN, "FMRADIO_HLP_MAIN"); // +_LIT(KFMRADIO_HLP_SEARCH, "FMRADIO_HLP_SEARCH"); // +_LIT(KFMRADIO_HLP_LIST, "FMRADIO_HLP_LIST"); // + +#endif \ No newline at end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/help/rom/fmradiohelps_variant.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/help/rom/fmradiohelps_variant.iby Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,28 @@ +/* +* 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: Help contents for image building +* +*/ + +#ifndef __FMRADIOHELPS_VARIANT_IBY__ +#define __FMRADIOHELPS_VARIANT_IBY__ + +#if defined(FF_S60_HELPS_IN_USE) && defined(__S60_FM_RADIO_APPLICATION) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10207A89\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x10207A89\contents.zip) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10207A89\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10207A89\index.xml) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10207A89\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10207A89\keywords.xml) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10207A89\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10207A89\meta.xml) +#endif + +#endif diff -r 000000000000 -r f3d95d9c00ab fmradio/inc/fmradioactiveidle.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/inc/fmradioactiveidle.hrh Tue Feb 02 00:17:10 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: Active idle definitions +* +*/ + + +#ifndef FMRADIOACTIVEIDLE_HRH +#define FMRADIOACTIVEIDLE_HRH + +// Ecom DLL UID for FMRadio Active Idle plugin. +#define AI_UID_ECOM_DLL_CONTENTPUBLISHER_FMRADIOPLUGIN 0x20010140 + +// Ecom implementation UID for FMRadio Active Idle plugin. +#define AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_FMRADIOPLUGIN 0x20010141 + +#endif // FMRADIOACTIVEIDLE_HRH diff -r 000000000000 -r f3d95d9c00ab fmradio/inc/fmradiovariant.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/inc/fmradiovariant.hrh Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Local variation flags for OMA Provisioning +* +*/ + + +#ifndef FMRADIOVARIANT_HRH +#define FMRADIOVARIANT_HRH + +/** +* Local variation flags for FM Radio +*/ + +// flag to determine whether an internnal antenna is supported +#define KFMRadioInternalAntennaSupported 0x02 + +#ifdef ASW_CORE_AUDIO_PLATFORM_VERSION // Nokia specific adaptation. + +#define __FMRADIO_ADVANCED_AUTO_RESUME + +#endif // ASW_CORE_AUDIO_PLATFORM_VERSION + + +#endif // FMRADIOVARIANT_HRH + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/loc/fmradio.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/loc/fmradio.loc Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,673 @@ +/* +* 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: This is a localisation file for FMRadio +*/ + + +// Application titles +// + +// d: Application title from list. +// l: list_single_large_graphic_pane_t1 +// +#define qtn_fmradio_app_menu_list "FM Radio" + +// d: Application title from grid. +// l: cell_app_pane_t1 +// +#define qtn_fmradio_app_menu_grid "FM Radio" + +// d: Main view title +// l: title_pane_t2/opt9 +// +#define qtn_fmradio_title "FM Radio" + +// d: Stations view title +// l: title_pane_t2/opt9 +// +#define qtn_fmradio_stations_title "Stations" + +// d: Search stations view title +// l: title_pane_t2/opt9 +// +#define qtn_fmradio_search_stations_title "Search stations" + +// Menu items +// + +// d: Option list item in the Main view. +// d: Opens Nokia Music Store when it is the only store available. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_music_store "Go to Music Store" + +// d: Option list item in the Main view. +// d: Opens a submenu with Nokia Music Store and other additional stores +// l: list_single_pane_t1_cp2/opt3 +// +#define qtn_fmradio_options_music_store_submenu "Go to Music Store" + +// d: Option list submenu item in the Main view for Go to Music Store. +// d: For enabling access to Nokia Music Store when there are +// d: also other music stores (e.g. operator music store) available. +// l: list_single_popup_submenu_pane_t1 +// +#define qtn_fmradio_options_nokia_music_store "Nokia Music Store" + +// d: Option list item in the Main view. +// d: Opens Web address. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_web_address "Go to Web address" + +// d: Option list item in the Main view. +// d: Opens Stations view. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_stations "Stations" + +// d: Option list item in Main and Search stations views. +// d: Saves a single station. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_save "Save" + +// d: Option list item in Main and Stations views. +// d: Renames currently selected station. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_rename "Rename" + +// d: General menu string, in all views. +// d: Activates the IHF-speaker +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_activate "Activate loudspeaker" + +// d: General menu string, in all views. +// d: Deactivate the IHF-speaker. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_deactivate "Deactivate loudspeaker" + +// d: Option list item in the Main view for Alternative frequency (AF) setting. +// d: Opens the submenu for AF setting. +// l: list_single_pane_t1_cp2/opt3 +// +#define qtn_fmradio_options_alternative_freq "Alternative frequency" + +// d: Option list submenu item in the Main view for Alternative frequency. +// d: For setting alternative frequency on. +// l: list_single_popup_submenu_pane_t1/opt1 +// +#define qtn_fmradio_options_on "On" + +// d: Option list submenu item in the Main view for Alternative frequency. +// d: For setting alternative frequency off. +// l: list_single_popup_submenu_pane_t1/opt1 +// +#define qtn_fmradio_options_off "Off" + +// d: Option list item in the Stations view. +// d: Deletes focused station. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_delete "Delete" + +// d: Option list item in the Stations view. +// d: Opens Search stations view. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_search_stations "Search stations" + +// d: Option list item in the Stations view. +// d: Opens dialog for manual tuning. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_tune_manually "Tune manually" + +// d: Option list item in the Search stations view. +// d: Saves all found stations and returns to Stations view. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_options_save_all "Save all" + + + +// Data queries +// + +// d: Data query heading. +// d: Query for entering a new name for saved station. +// l: popup_query_data_window_t3/opt2 +// +#define qtn_fmradio_query_rename "New name:" + +// d: Data query heading +// d: Query for setting a frequency manually. +// l: heading_pane_t1 +// +#define qtn_fmradio_query_frequency "Frequency (MHz):" + + + +// List queries +// + +// d: List query heading for region selection. +// d: Opened if no network coverage, when the application is started for the first time. +// l: heading_pane_t1 +// +#define qtn_fmradio_popup_head_select_reg "Select region:" + +// d: List query item for region selection. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_reg_japan "Japan" + +// d: List query item for region selection. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_reg_america "America" + +// d: List query item for region selection. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_reg_other "Other" + +// d: List query heading for how the user wants the stations to be saved. +// d: If the station list already contains saved channel(s). +// l: heading_pane_t1 +// +#define qtn_fmradio_list_query_save_all "Save all:" + +// d: List query item for save all selection. +// d: Appends the new stations to the end of the list. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_list_query_append "Append to the Stations list" + +// d: List query item for save all and station list full -selections. +// d: Replaces all existing stations with the new ones on the list. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_list_query_replace_all "Replace existing stations" + +// d: List query heading for how the user wants the stations to be saved, +// d: when the stations to be saved do not fit on the stations list. +// l: heading_pane_t1 +// +#define qtn_fmradio_list_query_list_full "Station list full:" + +// d: List query item for station list full related saving. +// d: Appends only the new stations that fits to the end of the list. +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_list_query_all_fits "Append all that fits" + + + +// Confirmation queries +// + +// d: Confirmation query for the Main view. +// d: Displayed when the user is about to change to Stations view and current frequency is not saved. +// l: popup_note_window +// +#define qtn_fmradio_query_save_current "Current station is not saved. Save now?" + +// d: Confirmation query for the Stations view. +// d: Displayed when the user is about to delete a station from the list. +// d: %U is the name of the station, max length 20 characters. +// l: popup_note_window +// +#define qtn_fmradio_query_delete "Delete %U?" + +// d: Confirmation query +// d: Displayed when the user is about to delete a station from the list. +// d: %U is the frequency of the saved station. max length 6 characters. +// l: popup_note_window +// +#define qtn_fmradio_query_delete_mhz "Delete %U MHz?" + +// d: Confirmation query +// d: Displayed when radio is started in off-line mode. +// l: popup_note_window +// +#define qtn_fmradio_query_offline_activate "Activate Radio in off-line mode?" + +// d: Confirmation query +// d: Displayed if the off-line mode is activated while the Radio is on. +// l: popup_note_window +// +#define qtn_fmradio_query_offline_use "Continue using the Radio in off-line mode?" + +// d: Confirmation query +// d: Displayed when the RT+ feature is enabled for the first time. +// l: popup_note_window +// +#define qtn_fmradio_query_rtplus_enabled "’+’ mark got enabled. When this happens, additional services like Music Store are available in the Options menu." + +// d: Confirmation query +// d: Shown if the 3.5mm analog audio accessory required as antenna is not connected +// l: popup_note_window +// +#define qtn_fmradio_error_con_headset "Connect wired headset with 3.5mm connector" + +// d: Confirmation query +// d: Replaces all existing stations with the new ones on the list. +// l: popup_note_window +// +#define qtn_fmradio_query_replace_all "Replace existing stations?" + +// Information notes +// + +// d: Information note for a start-up wizard. +// d: No stations found with the First time usage wizard. +// l: popup_note_window +// +#define qtn_fmradio_no_stations_found "No stations found" + +// d: Information note for radio roaming. +// d: Displayed after the frquency band has been set. +// l: popup_note_window +// +#define qtn_fmradio_conf_freq_band_set_autom "Local frequency band automatically set for radio" + +// d: Information note for radio roaming. +// d: Displayed after the user has selected the region. +// l: popup_note_window +// +#define qtn_fmradio_conf_freq_band_set_manual "Frequency band set for radio according to region." + +// d: Information note for the Search stations view. +// d: Displayed when Save all is selected from Search stations view. +// d: %N is the amount of saved stations, max value 100. +// l: popup_note_window +// +#define qtn_fmradio_saving_done "%N stations saved to the Stations list." + +// d: Information note for the Search stations view. +// d: Displayed when one station with a name is saved in Search stations view. +// d: %U is the name of the saved station, max length 20 characters. +// l: popup_note_window +// +#define qtn_fmradio_saving_done_one "%U saved to the Stations list." + +// d: Information note for the Search stations view. +// d: Displayed when one station without a name is saved in Search stations view. +// d: %U is the frequency of the saved station, max length 6 characters. +// l: popup_note_window +// +#define qtn_fmradio_saving_done_one_no_name "'%U MHz' saved to the Stations list." + +// d: Information note when Fm Transmitter is launched when FM Radio is on, FM Radio gets closed +// l: popup_note_window +// +#define qtn_fmradio_note_fmtx_close_application "FM Radio cannot be used when the FM transmitter is on. FM Radio is closed." + +// d: Information note when Fm Radio is tried to be launched when FM Transmitter is on. FM Radio is not launched. +// l: popup_note_window +// +#define qtn_fmradio_note_fmtx_unable_to_start "FM Radio cannot be started when FM transmitter is on." + + + +// Wait notes +// + +// d: Wait note +// d: Search stations view station list fill ongoing +// d: List fill ongoing on the background, so this note shown as small as possible. +// l: popup_note_wait_window/opt3 +// +#define qtn_fmradio_wait_note_scanning "Scanning..." + + + +// Main view +// + +// d: Custom RDS indicator displayed on the Media Idle (Main pane). +// l: fmrd2_indi_pane_t3 +// +#define qtn_fmradio_rds "RDS" + +// d: Custom AF indicator displayed on the Media Idle (Main pane). +// l: fmrd2_indi_pane_t2 +// +#define qtn_fmradio_af "AF" + +// d: Custom RT+ indicator displayed on the Media Idle (Main pane). +// d: Enabled, if Music Store and/or Web address access are available via +// d: RT+ information that radio Station is possibly sending +// l: fmrd2_indi_pane_t1 +// +#define qtn_fmradio_rtplus "+" + +// d: String shown on the Media Idle (Main pane). +// d: %U is the station frequency. Shown with one or two decimals, depending on region. +// d: Max length for %U is 6 characters. +// l: None +// +#define qtn_fmradio_media_idle_freq "%U MHz" + +// d: String shown on the main pane. +// d: %U is the station frequency. Shown with one or two decimals, depending on region. +// d: Max length for %U is 6 characters. +// l: area_fmrd2_info_pane_t2 +// +#define qtn_fmradio_freq "%U MHz" + +// d: String shown on the main pane. +// d: %N is the station memory location and %U is the frequency. +// d: Memory location number max value is 100. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// l: area_fmrd2_info_pane_t1 +// +#define qtn_fmradio_mem_location_freq "%N. %U MHz" + +// d: String shown on the main pane. +// d: %N is the station memory location and %U is station name. +// d: Memory location number max value is 100. +// d: Station name max length 20 characters. +// l: area_fmrd2_info_pane_t1 +// +#define qtn_fmradio_mem_location_name "%N. %U" + +// d: String shown on the main pane. +// d: Tuning animation text. +// l: area_fmrd2_info_pane_t4 +// +#define qtn_fmradio_scanning "Tuning" + +// d: String shown on the main pane. +// d: When next/prev button is short pressed and no stations stored, this is displayed on place of the station information. +// l: popup_note_window +// +#define qtn_fmradio_use_long_tap "No stations saved. You can tune stations by long pressing the previous and next buttons." + + + +// Stations view +// + +// d: String shown on the stations list 1nd row. +// d: %U is the frequency of the saved station. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// d: Frequency shown on the 1st row, when a station has no saved name. +// l: list_double_number_pane_t2 +// +#define qtn_fmradio_double1_freq "%U MHz" + +// d: String shown on the stations list 2nd row. +// d: %U is the frequency of the saved station, max length 6 characters. +// d: Frequency is shown with one or two decimals. +// d: Frequency shown on the 2nd row, when a station has a name. +// l: list_double_number_pane_t3 +// +#define qtn_fmradio_double2_freq "%U MHz" + +// d: String shown on the empty stations list. +// l: main_list_empty_pane +// +#define qtn_fmradio_list_no_stations "No saved stations. You can search stations via Options->Search stations" + + + +// Search Stations view +// + +// d: String shown on the search stations list row. +// d: %U is the frequency of the saved station. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// d: When a found station has not (yet) a name available. +// l: list_single_pane_t1 +// +#define qtn_fmradio_single_freq "%U MHz" + +// d: String shown on the search stations list row. +// d: %0U is the frequency of the saved station and %1U is the station PSNAME. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// d: Station name max length 20 characters. +// l: list_single_pane_t1 +// +#define qtn_fmradio_single_freq_name "%0U MHz %1U" + +// d: String shown on the empty search stations list. +// l: main_list_empty_pane +// +#define qtn_fmradio_list_no_stations_found "(No stations found)" + + + +// Homescreen Widget +// + +// d: String shown on the Homescreen Widget. +// d: Shown when the application is tuning for a station. +// l: hscr_music_header_text +// +#define qtn_fmradio_widget_tuning "Tuning..." + +// d: String shown on the Homescreen Widget. +// d: Shown if the 3.5mm analog audio accessory required as antenna is not connected +// l: hscr_music_header_text +// +#define qtn_fmradio_widget_con_headset "Connect wired headset with 3.5mm connector" + +// d: String shown on the Homescreen Widget. +// d: Currently active channel index and name +// d: separated by a dot. +// d: Index number max value is 100. +// d: Station name max length 20 characters. +// l: hscr_music_header_text +// +#define qtn_fmradio_widget_station_saved "%N. %U" + +// d: String shown on the Homescreen Widget. +// d: Currently active channel index and frequency +// d: separated by a dot. +// d: Index number max value is 100. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// l: hscr_music_header_text +// +#define qtn_fmradio_widget_station_saved_freq "%N. %U MHz" + +// d: String shown on the Homescreen Widget. +// d: Displays currently active channel frequency. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// l: hscr_music_header_text +// +#define qtn_fmradio_widget_notsaved_frequency "%U MHz" + + + +// Music Suite +// + +// d: The title for the most recently played radio station. +// d: First row of Music Suite Now Playing item. +// d: This is when the FM Radio has been the last application +// d: to control the audio in Music Suite. +// l: aalist_double_graphic_pane_t1 +// +#define qtn_fmradio_suite_last_played "Last Played" + + +// d: The title for the currently playing radio station. +// d: First row of Music Suite Now Playing item. +// d: This is when FM Radio controls the audio in Music SUite. +// l: aalist_double_graphic_pane_t1 +// +#define qtn_fmradio_suite_now_playing "Now Playing" + +// d: Second row of Music Suite Now Playing item. +// d: Currently active channel index and name +// d: separated by a dot. +// d: Index number max value is 100. +// d: Station name max length 20 characters. +// l: list_logical_template_3_detail +// +#define qtn_fmradio_suite_playing_saved_with_name "%N. %U" + +// d: Second row of Music Suite Now Playing item. +// d: Currently active channel index and frequency +// d: separated by a dot. +// d: Index number max value is 100. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// l: list_logical_template_3_detail +// +#define qtn_fmradio_suite_playing_saved_without_name "%N. %U MHz" + +// d: Second row of Music Suite Now Playing item. +// d: Currently active channel frequency. +// d: Frequency is shown with one or two decimals, max length 6 characters. +// l: list_logical_template_3_detail +// +#define qtn_fmradio_suite_playing_not_saved "%U MHz" + + + +// Toolbar tooltips +// + +// d: Main view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_stations "Stations" + +// d: Stations view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_search_stations "Search stations" + +// d: Stations view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_save_all "Save all" + +// d: Stations view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_activate_loudspeaker "Activate loudspeaker" + +// d: Stations view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_deactivate_loudspeaker "Deactivate loudspeaker" + +// d: Stations view tooltip text. +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_tune_manually "Tune manually" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_delete "Delete channel" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_save "Save channel" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_rename "Rename channel" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_web "Go to web adress" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_nokia_music_store "Ovi Music" + +// d: main view toolbar extension tooltip +// d: extension menu button +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_extension "Expand Toolbar" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_recognise_song "Recognise song" + +// d: main view toolbar extension tooltip +// l: popup_preview_text_window_t1 +// +#define qtn_fmradio_tooltip_operator_music_store "Music Store" + +// Toolbar extension +// + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_delete "Delete" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_save "Save" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_list_view "Stations" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_rename "Rename" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_station_web "Station’s web" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_ovi_music "Ovi Music Store" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_activate_loudspeaker "Activate loudspeaker" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_deactivate_loudspeaker "Deactivate loudspeaker" + +// d: main view toolbar extension command text +// l: cell_tb_ext_pane_t1/opt1 +// +#define qtn_tbextension_recognise_song "Recognise song" + +// Stylus popup menu items + +// d: Stations view stylus menu text +// l: list_single_pane_t1_cp2 +// +#define qtn_fmradio_move "Move" + +// End of File diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_cenrep_updated/fmradiocenrep.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/sis/fmradio_cenrep_updated/fmradiocenrep.pkg Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,33 @@ +; +; 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: FMRadio packet file with central repository +; + +;Languages +&EN + +;packet-header (name, uid, major, minor, build, type) +#{"FMRadio Cenrep File"},(0x10202BE9),3,0,0,TYPE=SP + +; Localised vendor name +%{"Symbian"} + +; Unique Vendor name +:"Symbian" + +; FM Radio Central Repository File +"..\..\fmradioengine\cenrep\2001B25E.cre" - "c:\private\10202be9\2001B25E.cre" + +; NOTE: 2001B25E.cre is the binary version of 2001B25E.txt +; For more info, see link: http://s60wiki.nokia.com/S60Wiki/How_to_guide_for_installing_Central_Repository_ini_files#Installing_Central_Repository_ini_file_that_is_already_in_ROM \ No newline at end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_cenrep_updated/fmradiocenrep.sis Binary file fmradio/sis/fmradio_cenrep_updated/fmradiocenrep.sis has changed diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_cenrep_updated/package.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/sis/fmradio_cenrep_updated/package.pkg Tue Feb 02 00:17:10 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: FMRadio packet file with central repository +; + +;Languages +&EN + +;packet-header (name, uid, major, minor, build, type) +#{"FMRadio"},(0x10207A89),3,0,0,TYPE=SA,RU + +; Localised vendor name +%{"Symbian"} + +; Unique Vendor name +:"Symbian" + +; EXE/DLL +"\epoc32\release\armv5\urel\fmradio.exe" -"!:\sys\bin\fmradio.exe" +"\epoc32\release\armv5\urel\fmradioengine.dll" -"!:\sys\bin\fmradioengine.dll" +"\epoc32\release\armv5\urel\fmradioactiveidleengine200.dll" -"!:\sys\bin\fmradioactiveidleengine200.dll" +"\epoc32\release\armv5\urel\fmradiomcpplugin100.dll" -"!:\sys\bin\fmradiomcpplugin100.dll" +"\epoc32\release\armv5\urel\fmradioactionhandler.dll" -"!:\sys\bin\fmradioactionhandler.dll" + +; Resources +"\epoc32\data\z\private\10003a3f\import\apps\fmradio_reg.rsc" -"!:\private\10003a3f\import\apps\fmradio_reg.rsc" +"\epoc32\data\Z\resource\apps\fmradio.rsc" -"!:\resource\apps\fmradio.rsc" +"\epoc32\data\Z\resource\fmradioengine.rsc" -"!:\resource\fmradioengine.rsc" +"\epoc32\data\Z\resource\fmradiomcpplugin.rsc" -"!:\resource\fmradiomcpplugin.rsc" +"\epoc32\data\Z\resource\plugins\fmradiomcpplugin100.rsc" -"!:\resource\plugins\fmradiomcpplugin100.rsc" +"\epoc32\data\Z\resource\plugins\fmradioactionhandler.rsc" -"!:\resource\plugins\fmradioactionhandler.rsc" + + +; Other files +"\epoc32\data\Z\resource\apps\fmradio_aif.mif" -"!:\resource\apps\fmradio_aif.mif" +"\epoc32\data\Z\resource\apps\fmradio.mif" -"!:\resource\apps\fmradio.mif" + +; Cenrep update +@"fmradiocenrep.sis", (0x10202BE9) \ No newline at end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_default/package.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/sis/fmradio_default/package.pkg Tue Feb 02 00:17:10 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: FMRadio packet file +; + +;Languages +&EN + +;packet-header (name, uid, major, minor, build, type) +#{"FMRadio"},(0x10207A89),3,0,0,TYPE=SA,RU + +; Localised vendor name +%{"Symbian"} + +; Unique Vendor name +:"Symbian" + +; EXE/DLL +"\epoc32\release\armv5\urel\fmradio.exe" -"!:\sys\bin\fmradio.exe" +"\epoc32\release\armv5\urel\fmradioengine.dll" -"!:\sys\bin\fmradioengine.dll" +"\epoc32\release\armv5\urel\fmradioactiveidleengine200.dll" -"!:\sys\bin\fmradioactiveidleengine200.dll" +"\epoc32\release\armv5\urel\fmradiomcpplugin100.dll" -"!:\sys\bin\fmradiomcpplugin100.dll" +"\epoc32\release\armv5\urel\fmradioactionhandler.dll" -"!:\sys\bin\fmradioactionhandler.dll" + +; Resources +"\epoc32\data\z\private\10003a3f\import\apps\fmradio_reg.rsc" -"!:\private\10003a3f\import\apps\fmradio_reg.rsc" +"\epoc32\data\Z\resource\apps\fmradio.rsc" -"!:\resource\apps\fmradio.rsc" +"\epoc32\data\Z\resource\fmradioengine.rsc" -"!:\resource\fmradioengine.rsc" +"\epoc32\data\Z\resource\fmradiomcpplugin.rsc" -"!:\resource\fmradiomcpplugin.rsc" +"\epoc32\data\Z\resource\plugins\fmradiomcpplugin100.rsc" -"!:\resource\plugins\fmradiomcpplugin100.rsc" +"\epoc32\data\Z\resource\plugins\fmradioactionhandler.rsc" -"!:\resource\plugins\fmradioactionhandler.rsc" + +; Other files +"\epoc32\data\Z\resource\apps\fmradio_aif.mif" -"!:\resource\apps\fmradio_aif.mif" +"\epoc32\data\Z\resource\apps\fmradio.mif" -"!:\resource\apps\fmradio.mif" diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_default/stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fmradio/sis/fmradio_default/stub.pkg Tue Feb 02 00:17:10 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: FMRadio packet file +; + +;Languages +&EN + +;packet-header (name, uid, major, minor, build, type) +#{"FMRadio"},(0x10207A89),4,0,0,TYPE=SA + +; Localised vendor name +%{"Symbian"} + +; Unique Vendor name +:"Symbian" + +; EXE/DLL +""-"z:\sys\bin\fmradio.exe" +""-"z:\sys\bin\fmradioengine.dll" +""-"z:\sys\bin\fmradioactiveidleengine200.dll" +""-"z:\sys\bin\fmradiomcpplugin100.dll" +""-"z:\sys\bin\fmradioactionhandler.dll" + +; Resources +""-"z:\private\10003a3f\import\apps\fmradio_reg.r*" +""-"z:\resource\apps\fmradio.r*" +""-"z:\resource\fmradioengine.r*" +""-"z:\resource\fmradiomcpplugin.r*" +""-"z:\resource\plugins\fmradiomcpplugin100.rsc" +""-"z:\resource\plugins\fmradioactionhandler.rsc" + +; Other files +""-"z:\resource\apps\fmradio_aif.mif" +""-"z:\resource\apps\fmradio.mif" \ No newline at end of file diff -r 000000000000 -r f3d95d9c00ab fmradio/sis/fmradio_default/stub.sis Binary file fmradio/sis/fmradio_default/stub.sis has changed diff -r 000000000000 -r f3d95d9c00ab group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,19 @@ +/* +* 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 "../fmradio/group/bld.inf" diff -r 000000000000 -r f3d95d9c00ab layers.sysdef.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layers.sysdef.xml Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,14 @@ + + +]> + + + + + + + + + + diff -r 000000000000 -r f3d95d9c00ab package_definition.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_definition.xml Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r f3d95d9c00ab sysdef_1_4_0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_4_0.dtd Tue Feb 02 00:17:10 2010 +0200 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +