# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1286140459 -10800 # Node ID 3cd404d311761a1b933bf9c4d75e13235b8c127b # Parent ed94e1e8390e572586483ce41883baff723c476a Revision: 201037 Kit: 201039 diff -r ed94e1e8390e -r 3cd404d31176 app/src/mpmainwindow.cpp --- a/app/src/mpmainwindow.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/app/src/mpmainwindow.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -270,7 +270,7 @@ TX_ENTRY_ARGS("viewType=" << viewType ); bool doTransition = true; - Hb::ViewSwitchFlags transitionFlags = Hb::ViewSwitchDefault; + Hb::ViewSwitchFlags transitionFlags = Hb::ViewSwitchCachedFullScreen; if ( mCurrentViewPlugin ) { disconnectView(); diff -r ed94e1e8390e -r 3cd404d31176 inc/mpengine.h --- a/inc/mpengine.h Fri Sep 17 08:28:52 2010 +0300 +++ b/inc/mpengine.h Mon Oct 04 00:14:19 2010 +0300 @@ -170,6 +170,7 @@ void handleDeleteStarted( TCollectionContext context, int count ); void handleDeleteEnded( bool success ); void cancelCollectionRequest(); + void handleCollectionPlaylistOpened(); // Playback related void playEmbedded( QString aFilename ); diff -r ed94e1e8390e -r 3cd404d31176 inc/mpplaybackdata.h --- a/inc/mpplaybackdata.h Fri Sep 17 08:28:52 2010 +0300 +++ b/inc/mpplaybackdata.h Mon Oct 04 00:14:19 2010 +0300 @@ -74,9 +74,10 @@ void setPlaybackState( const SimplifiedState state ); MpPlaybackData::SimplifiedState playbackState() const; - void commitPlaybackInfo(); + void commitPlaybackInfo( bool changed ); void resetData(); void setCorrupted( int id ); + void handleCollectionPlaylistOpened(); public slots: @@ -91,6 +92,7 @@ void playbackStateChanged(); void playbackInfoChanged(); void fileCorrupted(int id ); + void collectionPlaylistOpened(); private: @@ -108,6 +110,7 @@ HbIcon mAlbumArt; SimplifiedState mPlaybackState; bool mRealAudio; + bool mCollectionPlaylistOpened; Q_DISABLE_COPY(MpPlaybackData) }; diff -r ed94e1e8390e -r 3cd404d31176 mpdata/bwins/mpdatau.def --- a/mpdata/bwins/mpdatau.def Fri Sep 17 08:28:52 2010 +0300 +++ b/mpdata/bwins/mpdatau.def Mon Oct 04 00:14:19 2010 +0300 @@ -161,7 +161,7 @@ ?getStaticMetaObject@MpPlaybackData@@SAABUQMetaObject@@XZ @ 160 NONAME ; struct QMetaObject const & MpPlaybackData::getStaticMetaObject(void) ?composer@MpSongData@@QBE?AVQString@@XZ @ 161 NONAME ; class QString MpSongData::composer(void) const ?albumArt@MpPlaybackData@@QBEXAAVHbIcon@@@Z @ 162 NONAME ; void MpPlaybackData::albumArt(class HbIcon &) const - ?commitPlaybackInfo@MpPlaybackData@@QAEXXZ @ 163 NONAME ; void MpPlaybackData::commitPlaybackInfo(void) + ?commitPlaybackInfo@MpPlaybackData@@QAEX_N@Z @ 163 NONAME ; void MpPlaybackData::commitPlaybackInfo(bool) ?removeRows@MpCollectionDataModel@@UAE_NHHABVQModelIndex@@@Z @ 164 NONAME ; bool MpCollectionDataModel::removeRows(int, int, class QModelIndex const &) ?albumSongId@MpMpxCollectionData@@QAEHH@Z @ 165 NONAME ; int MpMpxCollectionData::albumSongId(int) ?thumbnailReady@MpSongData@@QAEXVQPixmap@@PAXHH@Z @ 166 NONAME ; void MpSongData::thumbnailReady(class QPixmap, void *, int, int) @@ -181,4 +181,6 @@ ?dataChanged@MpMpxCollectionData@@IAEXHH@Z @ 180 NONAME ; void MpMpxCollectionData::dataChanged(int, int) ?reloadData@MpCollectionDataModel@@QAEXHH@Z @ 181 NONAME ; void MpCollectionDataModel::reloadData(int, int) ?incrementalOpenUpdate@MpMpxCollectionData@@QAEXXZ @ 182 NONAME ; void MpMpxCollectionData::incrementalOpenUpdate(void) + ?handleCollectionPlaylistOpened@MpPlaybackData@@QAEXXZ @ 183 NONAME ; void MpPlaybackData::handleCollectionPlaylistOpened(void) + ?collectionPlaylistOpened@MpPlaybackData@@IAEXXZ @ 184 NONAME ; void MpPlaybackData::collectionPlaylistOpened(void) diff -r ed94e1e8390e -r 3cd404d31176 mpdata/eabi/mpdatau.def --- a/mpdata/eabi/mpdatau.def Fri Sep 17 08:28:52 2010 +0300 +++ b/mpdata/eabi/mpdatau.def Mon Oct 04 00:14:19 2010 +0300 @@ -29,7 +29,7 @@ _ZN14MpPlaybackData15positionChangedEv @ 28 NONAME _ZN14MpPlaybackData16setPlaybackStateENS_15SimplifiedStateE @ 29 NONAME _ZN14MpPlaybackData16staticMetaObjectE @ 30 NONAME DATA 16 - _ZN14MpPlaybackData18commitPlaybackInfoEv @ 31 NONAME + _ZN14MpPlaybackData18commitPlaybackInfoEb @ 31 NONAME _ZN14MpPlaybackData19getStaticMetaObjectEv @ 32 NONAME _ZN14MpPlaybackData19playbackInfoChangedEv @ 33 NONAME _ZN14MpPlaybackData20playbackStateChangedEv @ 34 NONAME @@ -181,4 +181,6 @@ _ZN19MpMpxCollectionData11dataChangedEii @ 180 NONAME _ZN19MpMpxCollectionData21incrementalOpenUpdateEv @ 181 NONAME _ZN21MpCollectionDataModel10reloadDataEii @ 182 NONAME + _ZN14MpPlaybackData24collectionPlaylistOpenedEv @ 183 NONAME + _ZN14MpPlaybackData30handleCollectionPlaylistOpenedEv @ 184 NONAME diff -r ed94e1e8390e -r 3cd404d31176 mpdata/src/mpplaybackdata.cpp --- a/mpdata/src/mpplaybackdata.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpdata/src/mpplaybackdata.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -75,7 +75,11 @@ PlayBackWrapper. */ +/*! + \fn void collectionPlaylistOpened() + This signal is emitted when user selects an item from collection view. + */ /*! Constructs a new MpPlaybackData. @@ -90,7 +94,8 @@ mId(0), mAlbumArt( "qtg_large_album_art" ), mPlaybackState( NotPlaying ), - mRealAudio( false ) + mRealAudio( false ), + mCollectionPlaylistOpened( false ) { TX_ENTRY mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForQuality ); @@ -374,12 +379,18 @@ } /*! - + Indicates that all playback information is available and ready to be committed to the view. + Signal is emitted only when any information has changed indicated by \a changed. A special + handling is covered, when the same song is re-selected by the user from the collection view, + in which case we force the reload even if the information hasn’t changed within this class. */ -void MpPlaybackData::commitPlaybackInfo() +void MpPlaybackData::commitPlaybackInfo( bool changed ) { TX_ENTRY - emit playbackInfoChanged(); + if ( changed || mCollectionPlaylistOpened ) { + emit playbackInfoChanged(); + mCollectionPlaylistOpened = false; + } TX_EXIT } @@ -432,3 +443,11 @@ TX_EXIT } +/*! + Emit collectionPlaylistOpened signal when user selects an item from collection view. +*/ +void MpPlaybackData::handleCollectionPlaylistOpened() +{ + mCollectionPlaylistOpened = true; + emit collectionPlaylistOpened(); +} diff -r ed94e1e8390e -r 3cd404d31176 mpengine/bwins/mpengineu.def --- a/mpengine/bwins/mpengineu.def Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/bwins/mpengineu.def Mon Oct 04 00:14:19 2010 +0300 @@ -143,4 +143,5 @@ ?scanFinished@MpSongScanner@@IAEXHH@Z @ 142 NONAME ; void MpSongScanner::scanFinished(int, int) ?setLoudness@MpEngine@@QAEX_N@Z @ 143 NONAME ; void MpEngine::setLoudness(bool) ?handleScanStarted@MpSongScanner@@QAEXXZ @ 144 NONAME ; void MpSongScanner::handleScanStarted(void) + ?handleCollectionPlaylistOpened@MpEngine@@QAEXXZ @ 145 NONAME ; void MpEngine::handleCollectionPlaylistOpened(void) diff -r ed94e1e8390e -r 3cd404d31176 mpengine/eabi/mpengineu.def --- a/mpengine/eabi/mpengineu.def Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/eabi/mpengineu.def Mon Oct 04 00:14:19 2010 +0300 @@ -143,4 +143,5 @@ _ZTV15MpEngineFactory @ 142 NONAME _ZTV8MpEngine @ 143 NONAME _ZN13MpSongScanner17handleScanStartedEv @ 144 NONAME + _ZN8MpEngine30handleCollectionPlaylistOpenedEv @ 145 NONAME diff -r ed94e1e8390e -r 3cd404d31176 mpengine/inc/mpmpxembeddedplaybackhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/inc/mpmpxembeddedplaybackhelper.h Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,82 @@ +/* +* 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: embedded playback helper. +* +*/ + +#ifndef CMPMPXEMBEDDEDPLAYBACKHELPER_H +#define CMPMPXEMBEDDEDPLAYBACKHELPER_H + +#include +#include +#include + +// FOWARD DECLARATION +class MMPXPlaybackUtility; +class MMPXCollectionUtility; +class MMPXCollectionUiHelper; + +class MMpMpxEmbeddedPlaybackHelperObserver +{ +public: + + virtual void HandleEmbeddedPlaybackError( TInt aError ) = 0; + +}; + +class CMpMpxEmbeddedPlaybackHelper : public CBase, + public MMPXCollectionObserver, + public MMPXCHelperEmbeddedOpenObserver +{ + +public: + + static CMpMpxEmbeddedPlaybackHelper* NewL( TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ); + virtual ~CMpMpxEmbeddedPlaybackHelper(); + + void playL( const TDesC& aFilename ); + +private: // from base class + + // From MMPXCollectionObserver + void HandleOpenL( const CMPXMedia& aEntries, + TInt aIndex,TBool aComplete,TInt aError ); + void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError ); + void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr ); + void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError ); + + // From MMPXCHelperEmbeddedOpenObserver + void HandleEmbeddedOpenL( TInt aErr, TMPXGeneralCategory aCategory ); + +private: + + CMpMpxEmbeddedPlaybackHelper( TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ); + void ConstructL(); + + void DoHandleCollectionMessageL( const CMPXMessage& aMsg ); + +private: + MMPXPlaybackUtility *iPlaybackUtility; + MMPXCollectionUtility *iCollectionUtility; //Owned + MMPXCollectionUiHelper *iCollectionUiHelper; //Owned + MMpMpxEmbeddedPlaybackHelperObserver *iObserver; + TUid iHostUid; +}; + +#endif // CMPMPXEMBEDDEDPLAYBACKHELPER_H + diff -r ed94e1e8390e -r 3cd404d31176 mpengine/inc/mpmpxplaybackframeworkwrapper.h --- a/mpengine/inc/mpmpxplaybackframeworkwrapper.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/inc/mpmpxplaybackframeworkwrapper.h Mon Oct 04 00:14:19 2010 +0300 @@ -45,8 +45,8 @@ void setBalance( int balance ); void applyAudioEffects(); void applyEqualizer(); - void retrieveSongDetails(); + void forceStop(); signals: diff -r ed94e1e8390e -r 3cd404d31176 mpengine/inc/mpmpxplaybackframeworkwrapper_p.h --- a/mpengine/inc/mpmpxplaybackframeworkwrapper_p.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/inc/mpmpxplaybackframeworkwrapper_p.h Mon Oct 04 00:14:19 2010 +0300 @@ -20,6 +20,7 @@ #include #include +#include "mpmpxembeddedplaybackhelper.h" #include "mpcommondefs.h" @@ -32,7 +33,8 @@ class MpSongData; class MpMpxPlaybackFrameworkWrapperPrivate : public MMPXPlaybackObserver, - public MMPXPlaybackCallback + public MMPXPlaybackCallback, + public MMpMpxEmbeddedPlaybackHelperObserver { public: @@ -71,7 +73,8 @@ MpPlaybackData *playbackData(); void retrieveSongDetails(); - + void forceStop(); + private: // From MMPXPlaybackObserver @@ -83,6 +86,9 @@ TBool aComplete, TInt aError ); void HandleMediaL( const CMPXMedia& aProperties, TInt aError ); + // From MMpMpxEmbeddedPlaybackHelperObserver + void HandleEmbeddedPlaybackError( TInt aError ); + void DoInitL(); void DoPlayL( QString aFilename ); void DoPlayL( const XQSharableFile& file ); @@ -96,11 +102,12 @@ private: MpMpxPlaybackFrameworkWrapper *q_ptr; - MMPXPlaybackUtility *iPlaybackUtility; // Own - MpPlaybackData *iPlaybackData; // Own + MMPXPlaybackUtility *iPlaybackUtility; // Own + CMpMpxEmbeddedPlaybackHelper *iEmbeddedPlaybackHelper; // Own + MpPlaybackData *iPlaybackData; // Own TUid iHostUid; - MpSongData *iSongData; // Not owned + MpSongData *iSongData; // Not owned bool iDetailsRequest; }; diff -r ed94e1e8390e -r 3cd404d31176 mpengine/mpengine.pro --- a/mpengine/mpengine.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/mpengine.pro Mon Oct 04 00:14:19 2010 +0300 @@ -55,6 +55,7 @@ inc/mpmpxharvesterframeworkwrapper.h \ inc/mpmpxharvesterframeworkwrapper_p.h \ inc/mpmpxplaybackframeworkwrapper.h \ + inc/mpmpxembeddedplaybackhelper.h \ inc/mpmpxplaybackframeworkwrapper_p.h \ inc/mpmpxcollectionframeworkwrapper.h \ inc/mpmpxisolatedcollectionhelper.h \ @@ -70,6 +71,7 @@ src/mpmpxharvesterframeworkwrapper.cpp \ src/mpmpxharvesterframeworkwrapper_p.cpp \ src/mpmpxplaybackframeworkwrapper.cpp \ + src/mpmpxembeddedplaybackhelper.cpp \ src/mpmpxplaybackframeworkwrapper_p.cpp \ src/mpmpxcollectionframeworkwrapper.cpp \ src/mpmpxisolatedcollectionhelper.cpp \ @@ -77,5 +79,5 @@ src/mpaudioeffectsframeworkwrapper.cpp \ src/mpaudioeffectsframeworkwrapper_p.cpp \ src/mpequalizerframeworkwrapper.cpp \ - src/mpequalizerframeworkwrapper_p.cpp + src/mpequalizerframeworkwrapper_p.cpp diff -r ed94e1e8390e -r 3cd404d31176 mpengine/src/mpengine.cpp --- a/mpengine/src/mpengine.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/src/mpengine.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -29,6 +29,7 @@ #include "mpsongscanner.h" #include "mpsongdata.h" #include "mpapplicationmonitor.h" +#include "mpplaybackdata.h" /*! \class MpEngine @@ -222,7 +223,14 @@ MpEngine::~MpEngine() { TX_ENTRY - delete mMpxPlaybackWrapper; + if ( mMpxPlaybackWrapper ) { + // Don't send stop cmd if mode=HomeScreen, because we don't want to stop playback when the music widget is deleted. + if ( mEngineMode != HomeScreen ) { + mMpxPlaybackWrapper->forceStop(); + } + delete mMpxPlaybackWrapper; + } + delete mMpxHarvesterWrapper; delete mMpxCollectionWrapper; delete mAudioEffectsWrapper; @@ -264,7 +272,7 @@ // Collection Wrapper mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( clientSecureId, mSongData ); connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), - this, SIGNAL( collectionPlaylistOpened() ), + this, SLOT( handleCollectionPlaylistOpened() ), Qt::QueuedConnection ); connect( mMpxCollectionWrapper, SIGNAL( aboutToAddSongs(int) ), this, SIGNAL( aboutToAddSongs(int) ) ); @@ -327,7 +335,7 @@ // Collection Wrapper mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( clientSecureId, 0 ); connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), - this, SIGNAL( collectionPlaylistOpened() ), + this, SLOT( handleCollectionPlaylistOpened() ), Qt::QueuedConnection ); // Disabling these since fetch mode plays only one song at a time. mMpxCollectionWrapper->setRepeatFeatureEnabled( false ); @@ -347,7 +355,7 @@ // Collection Wrapper mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( clientSecureId, 0 ); connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), - this, SIGNAL( collectionPlaylistOpened() ), + this, SLOT( handleCollectionPlaylistOpened() ), Qt::QueuedConnection ); connect( mMpxCollectionWrapper, SIGNAL( containerContentsChanged() ), this, SIGNAL( containerContentsChanged() ), @@ -1256,3 +1264,15 @@ TX_EXIT } +/*! + Slot to handle the open of a collecion playlist. + */ +void MpEngine::handleCollectionPlaylistOpened() +{ + TX_ENTRY + + playbackData()->handleCollectionPlaylistOpened(); + emit collectionPlaylistOpened(); + + TX_EXIT +} diff -r ed94e1e8390e -r 3cd404d31176 mpengine/src/mpmpxembeddedplaybackhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/src/mpmpxembeddedplaybackhelper.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,205 @@ +/* +* 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: Embedded playback helper. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mpmpxembeddedplaybackhelper.h" +#include "mptrace.h" + + +/*! + \class CMpMpxEmbeddedPlaybackHelper + \brief Helper class to play isolated media, + + This class is used by mpmpxplaybackframeworkwrapper_p to play isolated content specified by an uri, + when MusicPlayer is launched in embedded mode. +*/ + +/*! + \internal + Two-phased constructor. + */ +CMpMpxEmbeddedPlaybackHelper* CMpMpxEmbeddedPlaybackHelper::NewL( + TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ) +{ + CMpMpxEmbeddedPlaybackHelper* self = + new ( ELeave ) CMpMpxEmbeddedPlaybackHelper( aHostUid, aPlaybackUtility, aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; +} + +/*! + \internal + Destructor + */ +CMpMpxEmbeddedPlaybackHelper::~CMpMpxEmbeddedPlaybackHelper() +{ + TX_ENTRY + if ( iCollectionUtility ) { + iCollectionUtility->Collection().CancelRequest(); + iCollectionUtility->Close(); + } + if ( iCollectionUiHelper ) { + iCollectionUiHelper->Close(); + } + TX_EXIT +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::playL( const TDesC& aFilename ) +{ + TX_LOG + iCollectionUiHelper->OpenL( iHostUid, aFilename, this, EMPXCollectionPluginMusic ); +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::HandleOpenL( + const CMPXMedia& aEntries, + TInt aIndex, + TBool aComplete, + TInt aError ) +{ + Q_UNUSED( aEntries ); + Q_UNUSED( aIndex ); + Q_UNUSED( aComplete ); + Q_UNUSED( aError ); +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::HandleOpenL( + const CMPXCollectionPlaylist& aPlaylist, + TInt aError ) +{ + TX_ENTRY_ARGS( "aError=" << aError ); + if ( aError == KErrNone ) { + iPlaybackUtility->InitL( aPlaylist, ETrue ); + } + else { + iObserver->HandleEmbeddedPlaybackError( aError ); + } + TX_EXIT +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::HandleCollectionMessage( + CMPXMessage* aMsg, + TInt aErr ) +{ + TX_ENTRY_ARGS( "aErr=" << aErr ); + TInt error = aErr; + if ( error == KErrNone && aMsg ) { + TRAP( error, DoHandleCollectionMessageL( *aMsg ) ); + } + + if ( error != KErrNone ) { + iObserver->HandleEmbeddedPlaybackError( error ); + } + TX_EXIT +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::HandleCollectionMediaL( + const CMPXMedia& aMedia, + TInt aError ) +{ + Q_UNUSED( aMedia ); + Q_UNUSED( aError ); +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::HandleEmbeddedOpenL( + TInt aErr, + TMPXGeneralCategory aCategory ) +{ + TX_ENTRY_ARGS( "aErr=" << aErr ); + Q_UNUSED( aCategory ); + if ( aErr != KErrNone ) { + iObserver->HandleEmbeddedPlaybackError( aErr ); + } +} + +/*! + \internal + c++ Contructor + */ +CMpMpxEmbeddedPlaybackHelper::CMpMpxEmbeddedPlaybackHelper( + TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ) + : iPlaybackUtility( aPlaybackUtility ), + iObserver( aObserver ), + iHostUid( aHostUid ) +{ +} + +/*! + \internal + Leaving constructor + */ +void CMpMpxEmbeddedPlaybackHelper::ConstructL() +{ + iCollectionUtility = MMPXCollectionUtility::NewL( this, iHostUid ); + iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL( iHostUid ); +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::DoHandleCollectionMessageL( + const CMPXMessage& aMsg ) +{ + TX_ENTRY + TMPXMessageId id( aMsg.ValueTObjectL( KMPXMessageGeneralId ) ); + if ( KMPXMessageGeneral == id ) { + TInt event( aMsg.ValueTObjectL( KMPXMessageGeneralEvent ) ); + TInt type( aMsg.ValueTObjectL( KMPXMessageGeneralType ) ); + TInt data( aMsg.ValueTObjectL( KMPXMessageGeneralData ) ); + TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data ); + + if ( event == TMPXCollectionMessage::EPathChanged && + type == EMcPathChangedByOpen && + data == EMcItemOpened ) { + // This will result in HandleOpenL with CMPXCollectionPlaylist + iCollectionUtility->Collection().OpenL(); + } + } + TX_EXIT +} + diff -r ed94e1e8390e -r 3cd404d31176 mpengine/src/mpmpxplaybackframeworkwrapper.cpp --- a/mpengine/src/mpmpxplaybackframeworkwrapper.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/src/mpmpxplaybackframeworkwrapper.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -294,3 +294,10 @@ d_ptr->retrieveSongDetails(); } +/*! + Force the playback to stop. + */ +void MpMpxPlaybackFrameworkWrapper::forceStop() +{ + d_ptr->forceStop(); +} diff -r ed94e1e8390e -r 3cd404d31176 mpengine/src/mpmpxplaybackframeworkwrapper_p.cpp --- a/mpengine/src/mpmpxplaybackframeworkwrapper_p.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/src/mpmpxplaybackframeworkwrapper_p.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -55,6 +55,7 @@ MpMpxPlaybackFrameworkWrapperPrivate::MpMpxPlaybackFrameworkWrapperPrivate( MpMpxPlaybackFrameworkWrapper *qq) : q_ptr(qq), iPlaybackUtility(0), + iEmbeddedPlaybackHelper(0), iPlaybackData(0), iDetailsRequest(false) { @@ -68,10 +69,10 @@ { TX_ENTRY if ( iPlaybackUtility ) { - TRAP_IGNORE( ForceStopL() ); TRAP_IGNORE( iPlaybackUtility->RemoveObserverL(*this) ); iPlaybackUtility->Close(); } + delete iEmbeddedPlaybackHelper; delete iPlaybackData; TX_EXIT } @@ -452,6 +453,19 @@ /*! \internal */ +void MpMpxPlaybackFrameworkWrapperPrivate::forceStop() +{ + TX_ENTRY + TRAPD( err, ForceStopL() ); + if ( err != KErrNone ) { + TX_LOG_ARGS("Error: " << err << "; should never get here."); + } + TX_EXIT +} + +/*! + \internal + */ void MpMpxPlaybackFrameworkWrapperPrivate::HandlePlaybackMessage( CMPXMessage *aMessage, TInt aError ) { TX_ENTRY_ARGS("aError=" << aError); @@ -609,10 +623,8 @@ aMedia.ValueTObjectL( KMPXMediaGeneralId ) ); } - if ( changed ) { - // This is required to propagate the playback info to UI at once. - iPlaybackData->commitPlaybackInfo(); - } + // This is required to propagate the playback info to UI at once. + iPlaybackData->commitPlaybackInfo( changed ); } TX_EXIT } @@ -620,6 +632,17 @@ /*! \internal */ +void MpMpxPlaybackFrameworkWrapperPrivate::HandleEmbeddedPlaybackError( TInt aError ) +{ + TX_ENTRY_ARGS( "aError=" << aError ); + Q_UNUSED( aError ); + emit q_ptr->corruptedStop( true ); + TX_EXIT +} + +/*! + \internal + */ void MpMpxPlaybackFrameworkWrapperPrivate::DoInitL() { TX_ENTRY @@ -639,10 +662,17 @@ */ void MpMpxPlaybackFrameworkWrapperPrivate::DoPlayL( QString aFilename ) { - TX_ENTRY - if ( !aFilename.isNull() ) { + TX_ENTRY_ARGS( "Filename: " << aFilename ); + if ( !aFilename.isEmpty() ) { const TDesC& playTitle = TPtrC(reinterpret_cast( aFilename.constData() )); - iPlaybackUtility->InitL( playTitle ); + if ( !iEmbeddedPlaybackHelper ) { + iEmbeddedPlaybackHelper = + CMpMpxEmbeddedPlaybackHelper::NewL( iHostUid, iPlaybackUtility, this ); + } + iEmbeddedPlaybackHelper->playL( playTitle ); + } + else { + HandleEmbeddedPlaybackError( KErrArgument ); } TX_EXIT } @@ -653,15 +683,7 @@ void MpMpxPlaybackFrameworkWrapperPrivate::DoPlayL( const XQSharableFile& file ) { TX_ENTRY - - RFile xqfile; - bool ok = file.getHandle( xqfile ); - if ( ok ) { - iPlaybackUtility->InitL( xqfile ); - } - else { - TX_LOG_ARGS("Error: " << ok << "; should never get here."); - } + DoPlayL( file.fileName() ); TX_EXIT } diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/src/unittest_mpmpxplaybackframeworkwrapper.cpp --- a/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/src/unittest_mpmpxplaybackframeworkwrapper.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/src/unittest_mpmpxplaybackframeworkwrapper.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -24,6 +24,7 @@ #include "stub/inc/mpplaybackdata.h" #include "stub/inc/mpxplaybackutility.h" #include "stub/inc/mpsongdata.h" +#include "stub/inc/mpmpxembeddedplaybackhelper.h" // Do this so we can access all member variables. #define private public @@ -483,7 +484,7 @@ //Play from filename QString fileName = QString("z:\\system\\data\\nullsound.mp3"); mTest->play( fileName ); - QVERIFY( mTestPrivate->iPlaybackUtility->iInitialized ); + QCOMPARE( mTestPrivate->iEmbeddedPlaybackHelper->iFileNameToPlay, fileName ); //Play from Shareable file mTestPrivate->iPlaybackUtility->iInitialized = false; @@ -498,7 +499,7 @@ XQSharableFile* sFile = new XQSharableFile(file); mTest->play( *sFile ); - QVERIFY( mTestPrivate->iPlaybackUtility->iInitialized ); + QCOMPARE( mTestPrivate->iEmbeddedPlaybackHelper->iFileNameToPlay, sFile->fileName() ); sFile->close(); delete sFile; @@ -512,6 +513,15 @@ else { QWARN("Not able to create RF Session"); } + + //Play empty filename + QSignalSpy spy(mTest, SIGNAL(corruptedStop( bool ))); + QList arguments; + QString emptyFileName = ""; + mTest->play( emptyFileName ); + QVERIFY( spy.count() == 1 ); + arguments = spy.takeFirst(); + QVERIFY( arguments.at(0).toBool() == true ); //Play command cleanup(); diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/inc/mpmpxembeddedplaybackhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/inc/mpmpxembeddedplaybackhelper.h Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright ( c ) 2009 Nokia Corporation and/or its subsidiary( -ies ). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: embedded playback helper stub for testing mpmpxpbframeworkwrapper. +* +*/ + +#ifndef CMPMPXEMBEDDEDPLAYBACKHELPER_H +#define CMPMPXEMBEDDEDPLAYBACKHELPER_H + +#include +#include + +// FOWARD DECLARATION +class MMPXPlaybackUtility; + +class MMpMpxEmbeddedPlaybackHelperObserver +{ +public: + + virtual void HandleEmbeddedPlaybackError( TInt aError ) = 0; + +}; + +class CMpMpxEmbeddedPlaybackHelper : public CBase +{ + +public: + + static CMpMpxEmbeddedPlaybackHelper* NewL( TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ); + virtual ~CMpMpxEmbeddedPlaybackHelper(); + + void playL( const TDesC& aFilename ); + void triggerError(); + +private: + + CMpMpxEmbeddedPlaybackHelper( TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ); + +public: + MMPXPlaybackUtility *iPlaybackUtility; + MMpMpxEmbeddedPlaybackHelperObserver *iObserver; + TUid iHostUid; + QString iFileNameToPlay; +}; + +#endif // CMPMPXEMBEDDEDPLAYBACKHELPER_H + diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/inc/mpplaybackdata.h --- a/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/inc/mpplaybackdata.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/inc/mpplaybackdata.h Mon Oct 04 00:14:19 2010 +0300 @@ -52,7 +52,7 @@ const QString& album() const; const QString& artist() const; MpPlaybackData::SimplifiedPlaybackState playbackState(); - void commitPlaybackInfo(); + void commitPlaybackInfo( bool changed ); void handleMediaReady(); bool setRealAudio( bool mode ); bool setAlbumId( int id ); diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/src/mpmpxembeddedplaybackhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/src/mpmpxembeddedplaybackhelper.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,74 @@ +/* +* 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: Embedded playback helper stub for testing mpmpxpbframeworkwrapper. +* +*/ + +#include +#include "stub/inc/mpmpxembeddedplaybackhelper.h" +#include "mptrace.h" + + +/*! + \internal + */ +CMpMpxEmbeddedPlaybackHelper* CMpMpxEmbeddedPlaybackHelper::NewL( + TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ) +{ + CMpMpxEmbeddedPlaybackHelper* self = + new ( ELeave ) CMpMpxEmbeddedPlaybackHelper( aHostUid, aPlaybackUtility, aObserver ); + return self; +} + +/*! + \internal + Destructor + */ +CMpMpxEmbeddedPlaybackHelper::~CMpMpxEmbeddedPlaybackHelper() +{ +} + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::playL( const TDesC& aFilename ) +{ + TX_LOG + iFileNameToPlay = QString::fromUtf16( aFilename.Ptr(), aFilename.Length() ); +} + + +/*! + \internal + */ +void CMpMpxEmbeddedPlaybackHelper::triggerError() +{ + iObserver->HandleEmbeddedPlaybackError( KErrGeneral ); +} + +/*! + \internal + */ +CMpMpxEmbeddedPlaybackHelper::CMpMpxEmbeddedPlaybackHelper( + TUid aHostUid, + MMPXPlaybackUtility* aPlaybackUtility, + MMpMpxEmbeddedPlaybackHelperObserver* aObserver ) + : iPlaybackUtility( aPlaybackUtility ), + iObserver( aObserver ), + iHostUid( aHostUid ) +{ +} + diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/src/mpplaybackdata.cpp --- a/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/src/mpplaybackdata.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/stub/src/mpplaybackdata.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -208,10 +208,10 @@ /*! Stub function. */ -void MpPlaybackData::commitPlaybackInfo() +void MpPlaybackData::commitPlaybackInfo( bool changed ) { TX_ENTRY - mMediaReady = ETrue; + mMediaReady = changed; TX_EXIT } diff -r ed94e1e8390e -r 3cd404d31176 mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/unittest_mpmpxplaybackframeworkwrapper.pro --- a/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/unittest_mpmpxplaybackframeworkwrapper.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/mpengine/tsrc/unittest_mpmpxplaybackframeworkwrapper/unittest_mpmpxplaybackframeworkwrapper.pro Mon Oct 04 00:14:19 2010 +0300 @@ -47,11 +47,13 @@ stub/inc/mpxplaybackutility.h \ stub/inc/hbglobal.h \ stub/inc/mpsongdata.h \ + stub/inc/mpmpxembeddedplaybackhelper.h \ ../../../mpserviceplugins/inc/mpxaudioeffectengine.h SOURCES += src/unittest_mpmpxplaybackframeworkwrapper.cpp \ ../../src/mpmpxplaybackframeworkwrapper.cpp \ stub/src/mpplaybackdata.cpp \ stub/src/mpxplaybackutility.cpp \ - stub/src/mpsongdata.cpp + stub/src/mpsongdata.cpp \ + stub/src/mpmpxembeddedplaybackhelper.cpp diff -r ed94e1e8390e -r 3cd404d31176 mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp --- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -17,7 +17,7 @@ // INCLUDE FILES -#include +#include #include #include diff -r ed94e1e8390e -r 3cd404d31176 mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp --- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -18,7 +18,7 @@ // INCLUDE FILES -#include +#include #include #include #ifdef RD_MULTIPLE_DRIVE diff -r ed94e1e8390e -r 3cd404d31176 mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp --- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -18,7 +18,7 @@ // INCLUDE FILES #include -#include +#include #include #include diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpcollectionviewplugin/src/mpcollectionpopuphandler.cpp --- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectionpopuphandler.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectionpopuphandler.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -308,7 +308,7 @@ mPermanentData->mOriginalName = currentName; getText( hbTrId( "txt_mus_dialog_enter_name" ), currentName, - hbTrId( "txt_common_button_ok" ), //TODO:replace for "rename" when string is available + hbTrId( "txt_mus_button_rename" ), SLOT( handleRenamePlaylistContainer( HbAction* ) ) ); TX_EXIT } @@ -322,7 +322,7 @@ mPermanentData->mOriginalName = currentName; getText( hbTrId( "txt_mus_dialog_enter_name" ), currentName, - hbTrId( "txt_common_button_ok" ),//TODO:replace for "rename" when string is available + hbTrId( "txt_mus_button_rename" ), SLOT( handleRenamePlaylistItem( HbAction* ) ) ); TX_EXIT } @@ -333,7 +333,7 @@ void MpCollectionPopupHandler::openAddSongsToPlaylist( QAbstractItemModel* model ) { TX_ENTRY - getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available + getModelIndexes( hbTrId( "txt_mus_title_add_songs" ), hbTrId( "txt_common_button_add_dialog" ), model, SLOT( handleAddSongsToPlayList( HbAction* ) ) ); @@ -351,7 +351,7 @@ //this item will be deleted when clearing permanent data. model->setParent(mPermanentData); model->refreshModel(); - getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available + getModelIndexes( hbTrId( "txt_mus_title_add_songs" ), hbTrId( "txt_common_button_add_dialog" ), model, SLOT( handleAddSongsToPlayList( HbAction* ) ) ); @@ -387,7 +387,7 @@ collectionDataModel->refreshModel(); mPermanentData->mAbstractItemModel = collectionDataModel; - getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available + getModelIndexes( hbTrId( "txt_mus_title_add_songs" ), hbTrId( "txt_common_button_add_dialog" ), collectionDataModel, SLOT( handleAddToCurrentPlaylist( HbAction* ) ) ); @@ -750,7 +750,7 @@ QString newPlaylistName = dialog->value().toString(); //Store the new playlist name and query for the items to be added mPermanentData->mOriginalName = newPlaylistName; - getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available + getModelIndexes( hbTrId( "txt_mus_title_add_songs" ), hbTrId( "txt_common_button_add_dialog" ), mPermanentData->mAbstractItemModel, SLOT( handleCreateNewPlaylistGetModelIndexesFinished( HbAction* ) ) ); diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp --- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -1108,7 +1108,7 @@ mShuffleAction->setDisabled( true ); } if ( !mCollectionData->isAutoPlaylist() ) { - menuAction = myMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) ); + menuAction = myMenu->addAction( hbTrId( "txt_common_opt_rename_item" ) ); if ( !mUsbBlocked ) { connect( menuAction, SIGNAL( triggered() ), this, SLOT( renameCurrentPlaylistContainer() ) ); } @@ -1119,23 +1119,13 @@ addDefaultMenuOptions( myMenu, true, true ); break; default: - //if we accidentally fall in an unknown context + // Provide 'exit' if we accidentally fall in an unknown context addDefaultMenuOptions( myMenu, false, true ); break; } } else if ( mViewMode == MpCommon::FetchView ) { - switch ( mCollectionContext ) { - case ECollectionContextAllSongs: - case ECollectionContextArtists: - case ECollectionContextAlbums: - addDefaultMenuOptions( myMenu, true, false ); - break; - default: - //if we accidentally fall in an unknown context - addDefaultMenuOptions( myMenu, false, true ); - break; - } + addDefaultMenuOptions( myMenu, true, false ); } setMenu( myMenu ); diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/inc/mplightmonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/inc/mplightmonitor.h Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Light monitor for Playback. +* +*/ + +#ifndef MPLIGHTMONITOR_H +#define MPLIGHTMONITOR_H + +#include + +class MpLightMonitorPrivate; + +class MpLightMonitor : public QObject +{ + Q_OBJECT + + friend class MpLightMonitorPrivate; + +public: + + explicit MpLightMonitor( QObject *parent=0 ); + virtual ~MpLightMonitor(); + +signals: + + void lcdLightStatus( bool lightOn ); + +private: + + Q_DISABLE_COPY( MpLightMonitor ) + MpLightMonitorPrivate *d_ptr; + +}; + +#endif // MPLIGHTMONITOR_H diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/inc/mplightmonitor_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/inc/mplightmonitor_p.h Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Light monitor for Playback - Private. +* +*/ + +#ifndef MPLIGHTMONITOR_P_H +#define MPLIGHTMONITOR_P_H + +#include + +class MpLightMonitor; + +class MpLightMonitorPrivate : public MHWRMLightObserver +{ +public: + + explicit MpLightMonitorPrivate( MpLightMonitor *qq ); + void init(); + virtual ~MpLightMonitorPrivate(); + +private: + + void DoInitL(); + // From MHWRMLightObserver + virtual void LightStatusChanged( TInt aTarget, CHWRMLight::TLightStatus aStatus ); + +private: + + MpLightMonitor *q_ptr; + CHWRMLight::TLightStatus iLightStatus; + CHWRMLight *iLight; //Own + +}; + +#endif // MPLIGHTMONITOR_P_H diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h --- a/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h Mon Oct 04 00:14:19 2010 +0300 @@ -28,6 +28,7 @@ class HbLabel; class MpPlaybackDocumentLoader; class MpAlbumCoverWidget; +class MpLightMonitor; class MpPlaybackWidget : public HbWidget { @@ -50,6 +51,8 @@ void durationChanged(); void positionChanged(); void albumArtChanged(); + void handleLcdLightStatus( bool lightOn ); + void handleCollectionPlaylistOpened(); private slots: @@ -60,11 +63,14 @@ private: QString formatDuration( int seconds ); + void connectPlaybackDataSignals( bool connectSignal ); + void updatePlaybackInfo(); private: MpPlaybackData *mPlaybackData; // Not own MpPlaybackDocumentLoader *mDocumentLoader; // Own + MpLightMonitor *mLightMonitor; // Own HbStackedLayout *mLayout; // Not own HbLabel *mSongTitle; // Not own diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro --- a/mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro Mon Oct 04 00:14:19 2010 +0300 @@ -41,7 +41,8 @@ -lmpsettingsmanager \ -lmpengine \ -lmpdata \ - -lmpalbumcoverwidget + -lmpalbumcoverwidget \ + -lhwrmlightclient # Input HEADERS += ../../inc/mpviewbase.h \ @@ -49,13 +50,17 @@ inc/mpplaybackview.h \ inc/mpplaybackwidget.h \ inc/mpequalizerwidget.h \ - inc/mpplaybackdocumentloader.h + inc/mpplaybackdocumentloader.h \ + inc/mplightmonitor_p.h \ + inc/mplightmonitor.h SOURCES += src/mpplaybackviewplugin.cpp \ src/mpplaybackview.cpp \ src/mpplaybackwidget.cpp \ src/mpequalizerwidget.cpp \ - src/mpplaybackdocumentloader.cpp + src/mpplaybackdocumentloader.cpp \ + src/mplightmonitor_p.cpp \ + src/mplightmonitor.cpp RESOURCES += resources/mpplaybackviewpluginresources.qrc diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/src/mplightmonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/src/mplightmonitor.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Light monitor for Playback. +* +*/ + +#include "mplightmonitor.h" +#include "mplightmonitor_p.h" + + +/*! + \class MpLightMonitor + \brief Wrapper for light monitor. + + MpLightMonitor provides Qt style interface to the Light Observer. + It's implementation is hidden using private class data pattern. +*/ + +/*! + \fn void lcdLightStatus( bool lightOn ); + + This signal is emitted when the device light status changes. + */ + +/*! + \internal + */ +MpLightMonitor::MpLightMonitor( QObject *parent ) + : QObject( parent ) +{ + d_ptr = new MpLightMonitorPrivate ( this ); + d_ptr->init(); +} + +/*! + \internal + */ +MpLightMonitor::~MpLightMonitor() +{ + delete d_ptr; +} + diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/src/mplightmonitor_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/src/mplightmonitor_p.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,91 @@ +/* +* 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: Light monitor for Playback - Private. +* +*/ + +#include "mplightmonitor_p.h" +#include "mplightmonitor.h" +#include "mptrace.h" + + +/*! + \class MpLightMonitorPrivate + \brief Wrapper for light monitor - private implementation. + + This is a private implementation of the light monitor interface. +*/ + +/*! + \internal + */ +MpLightMonitorPrivate::MpLightMonitorPrivate( MpLightMonitor *qq ) + :q_ptr( qq ), + iLightStatus( CHWRMLight::ELightStatusUnknown ), + iLight( 0 ) +{ + TX_LOG +} + +/*! + \internal + */ +void MpLightMonitorPrivate::init() +{ + TX_ENTRY + TRAPD(err, DoInitL()); + if ( err != KErrNone ) { + TX_LOG_ARGS("Error: " << err << "; should never get here."); + } + TX_EXIT +} + +/*! + \internal + */ +void MpLightMonitorPrivate::DoInitL() +{ + TX_ENTRY + iLight = CHWRMLight::NewL( this ); + TX_EXIT +} + +/*! + \internal + */ +MpLightMonitorPrivate::~MpLightMonitorPrivate() +{ + TX_ENTRY + delete iLight; + TX_EXIT +} + +/*! + \internal + */ +void MpLightMonitorPrivate::LightStatusChanged( TInt aTarget, CHWRMLight::TLightStatus aStatus ) +{ + TX_ENTRY + if ( aTarget == CHWRMLight::EPrimaryDisplay && aStatus != iLightStatus ) { + if ( aStatus == CHWRMLight::ELightOn ) { + q_ptr->emit lcdLightStatus ( true ); + } + else if( aStatus == CHWRMLight::ELightOff ) { + q_ptr->emit lcdLightStatus ( false ); + } + iLightStatus = aStatus; + } + TX_EXIT +} + diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp --- a/mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -28,6 +28,7 @@ #include "mpalbumcoverwidget.h" #include "mpplaybackdocumentloader.h" #include "mptrace.h" +#include "mplightmonitor.h" const unsigned int KMicroSecToMiliSec( 1000 ); @@ -45,6 +46,13 @@ position, \a value indicates the position. */ + /*! + \fn void signalPlaybackInfoChanged() + + This signal is emitted when playback information has changed. Added for MATTI testing support. + */ + + /*! Constructs the collection view plugin. */ @@ -52,6 +60,7 @@ : HbWidget(parent), mPlaybackData(data), mDocumentLoader(0), + mLightMonitor(0), mProgreesBarDragging(false), mDuration(0) { @@ -98,21 +107,17 @@ Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget"); } + mLightMonitor = new MpLightMonitor (this); + connect( mLightMonitor, SIGNAL(lcdLightStatus(bool)), this, SLOT(handleLcdLightStatus(bool)) ); + connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) ); connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) ); connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) ); - connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) ); - connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) ); - connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) ); - connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) ); - - //Update to set initial conditions if playback has already started. + connectPlaybackDataSignals(true); + // Update to set initial conditions if playback has already started. if ( mPlaybackData->playbackState() != MpPlaybackData::NotPlaying ) { - playbackInfoChanged(); - durationChanged(); - positionChanged(); - albumArtChanged(); + updatePlaybackInfo(); } TX_EXIT } @@ -124,6 +129,7 @@ { TX_ENTRY delete mDocumentLoader; + delete mLightMonitor; TX_EXIT } @@ -132,7 +138,7 @@ */ void MpPlaybackWidget::repeatChanged( bool value ) { - mRepeatIndicator->setVisible( value ); + mRepeatIndicator->setVisible( value ); } /*! @@ -272,3 +278,72 @@ } +/*! + Slot to be called to handle LCD light status change. + */ +void MpPlaybackWidget::handleLcdLightStatus( bool lightOn ) +{ + TX_ENTRY + if ( lightOn ) { + connectPlaybackDataSignals( true ); + updatePlaybackInfo(); + } + else { + connectPlaybackDataSignals( false ); + } + TX_EXIT +} + +/*! + Connect/disconnect the signals from the Playback data according to /a connect. + */ +void MpPlaybackWidget::connectPlaybackDataSignals( bool connectSignal ) +{ + TX_ENTRY + if ( connectSignal ) { + connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) ); + connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) ); + connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) ); + connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) ); + connect( mPlaybackData, SIGNAL(collectionPlaylistOpened()), this, SLOT(handleCollectionPlaylistOpened()) ); + } + else { + mPlaybackData->disconnect( this ); + } + TX_EXIT +} + +/*! + Update playback information. + */ +void MpPlaybackWidget::updatePlaybackInfo() +{ + TX_ENTRY + playbackInfoChanged(); + durationChanged(); + positionChanged(); + albumArtChanged(); + TX_EXIT +} + +/*! + Slot to be called to handle the selection of an item from collection view when playback + view was previously activated with another item. We reset or hide the view items + in order to reduce the flickering. + */ +void MpPlaybackWidget::handleCollectionPlaylistOpened() +{ + TX_ENTRY + QString blankSpace = " "; + mAlbumArt->setEnabled( false ); + mArtistName->setPlainText( blankSpace ); + mAlbumName->setPlainText( blankSpace ); + mSongTitle->setPlainText( blankSpace ); + mRealAudioIndicator->setVisible( false ); + mProgressBar->setProgressValue( 0 ); + mProgressBar->setSliderValue( 0 ); + mProgressBar->setMinText( formatDuration( 0 ) ); + mProgressBar->setMaxText( formatDuration( 0 ) ); + TX_EXIT +} + diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/tsrc.pro --- a/mpviewplugins/mpplaybackviewplugin/tsrc/tsrc.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/tsrc.pro Mon Oct 04 00:14:19 2010 +0300 @@ -19,8 +19,8 @@ SUBDIRS += unittest_mpequalizerwidget \ unittest_mpplaybackdocumentloader \ unittest_mpplaybackviewplugin \ - unittest_mpplaybackview -# unittest_mpplaybackwidget + unittest_mpplaybackview \ + unittest_mpplaybackwidget CONFIG += ordered diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/inc/unittest_mpplaybackwidget.h --- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/inc/unittest_mpplaybackwidget.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/inc/unittest_mpplaybackwidget.h Mon Oct 04 00:14:19 2010 +0300 @@ -43,7 +43,9 @@ void testDurationChanged(); void testPositionChanged(); void testAlbumArtChanged(); - + void testHandleLcdLightStatus(); + void testHandleCollectionPlaylistOpened(); + private: MpPlaybackWidget *mTest; diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/src/unittest_mpplaybackwidget.cpp --- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/src/unittest_mpplaybackwidget.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/src/unittest_mpplaybackwidget.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -158,5 +158,26 @@ QVERIFY( mTest->mAlbumArt->isEnabled() == true ); } +/*! + test handleLcdLightStatus + */ +void TestMpPlaybackWidget::testHandleLcdLightStatus( ) +{ + mTest->handleLcdLightStatus( true ); + testPlaybackInfoChanged(); + +} + +/*! + test handleCollectionPlaylistOpened + */ +void TestMpPlaybackWidget::testHandleCollectionPlaylistOpened() +{ + mTest->handleCollectionPlaylistOpened(); + QVERIFY( mTest->mSongTitle->plainText() == " " ); + QVERIFY( mTest->mArtistName->plainText() == " " ); + QVERIFY( mTest->mAlbumName->plainText() == " " ); +} + // End of file diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/inc/mplightmonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/inc/mplightmonitor.h Mon Oct 04 00:14:19 2010 +0300 @@ -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: Light monitor for Playback. +* +*/ + +#ifndef MPLIGHTMONITOR_H +#define MPLIGHTMONITOR_H + +#include + +class MpLightMonitorPrivate; + +class MpLightMonitor : public QObject +{ + Q_OBJECT + + friend class MpLightMonitorPrivate; + +public: + + explicit MpLightMonitor( QObject *parent=0 ); + virtual ~MpLightMonitor(); + +signals: + + void lcdLightStatus( bool lightOn ); + +private: + + Q_DISABLE_COPY( MpLightMonitor ) + +}; + +#endif // MPLIGHTMONITOR_H diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/inc/mpplaybackdata.h --- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/inc/mpplaybackdata.h Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/inc/mpplaybackdata.h Mon Oct 04 00:14:19 2010 +0300 @@ -24,7 +24,7 @@ #include -//forward declartions +//forward declarations class MpPlaybackData : public QObject { @@ -66,6 +66,8 @@ void albumArtReady(); void playbackStateChanged(); void playbackInfoChanged(); + void collectionPlaylistOpened(); + public: diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/src/mplightmonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/stub/src/mplightmonitor.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -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: Light monitor for Playback. +* +*/ + +#include "mplightmonitor.h" + + +/*! + \class MpLightMonitor + \brief Wrapper for light monitor. + + MpLightMonitor provides Qt style interface to the Light Observer. + It's implementation is hidden using private class data pattern. +*/ + +/*! + \fn void lcdLightStatus( bool lightOn ); + + This signal is emitted when the device light status changes. + */ + +/*! + \internal + */ +MpLightMonitor::MpLightMonitor( QObject *parent ) + : QObject( parent ) +{ + +} + +/*! + \internal + */ +MpLightMonitor::~MpLightMonitor() +{ +} + diff -r ed94e1e8390e -r 3cd404d31176 mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/unittest_mpplaybackwidget.pro --- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/unittest_mpplaybackwidget.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackwidget/unittest_mpplaybackwidget.pro Mon Oct 04 00:14:19 2010 +0300 @@ -32,6 +32,7 @@ stub/inc/mpplaybackdata.h \ stub/inc/mpalbumcoverwidget.h \ stub/inc/mpplaybackdocumentloader.h \ + stub/inc/mplightmonitor.h \ ../../inc/mpplaybackwidget.h @@ -39,6 +40,7 @@ stub/src/mpplaybackdata.cpp \ stub/src/mpalbumcoverwidget.cpp \ stub/src/mpplaybackdocumentloader.cpp \ + stub/src/mplightmonitor.cpp \ ../../src/mpplaybackwidget.cpp RESOURCES += ../../resources/mpplaybackviewpluginresources.qrc \ No newline at end of file diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/inc/musicwidget.h --- a/musicwidgetplugin/inc/musicwidget.h Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/inc/musicwidget.h Mon Oct 04 00:14:19 2010 +0300 @@ -18,14 +18,10 @@ #ifndef MUSICWIDGET_H #define MUSICWIDGET_H -// System includes -#include -#include +// includes #include #include -#include "mpplaybackdata.h" - // Forward declarations class HbLabel; class HbPushButton; @@ -33,11 +29,13 @@ class HbMarqueeItem; class MpEngine; class MpAlbumCoverWidget; +class MpApplicationMonitor; +class MpPlaybackData; /** * Media key identifier for push button events */ -enum MediaKeyIdentifier{ +enum MediaKeyIdentifier { EPrevious = 1, EPlayPause, ENext @@ -46,9 +44,10 @@ /** * Music Player launch source identifier */ -enum LaunchIdentifier{ - ELaunchFromPlay, - ELaunchFromShortcut +enum LaunchIdentifier { + ELaunchToMainView, + ELaunchToNowPlayingView, + ELaunchToNowPlayingViewWithShuffle }; class MusicWidget: public HbWidget @@ -74,33 +73,32 @@ /** * Launch Music Player to view */ - void launchMusicPlayer(int launchMode = ELaunchFromShortcut); - - /** - * Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally - * Draws the spesified button to disabled state - */ - void mediaButtonDisabled( int aMediaKeyId ); + void launchMusicPlayer( int launchMode ); /** - * Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally - * Draws the spesified button to enabled state - */ - void mediaButtonEnabled( int aMediaKeyId ); + * Update widget buttons according to Music Player state + */ + void updateButtons(); + + /** + * Connect/disconnect Music Player engine and playback data + */ + void connectMusicPlayerEngine( bool connect ); /** - * Disable/enable widget buttons according to Music Player state - */ - void toggleButtons(); - -public: - QRectF boundingRect() const; - QPainterPath shape() const; + * Get the playback state + */ + int getPlaybackState(); + + /** + * Clear the song data + */ + void clearData(); public slots: /** - * Widget slots + * Widget related */ void onInitialize(); void onShow(); @@ -108,64 +106,37 @@ void onUninitialize(); /** - * MpEngine slots - */ + * MpEngine related + */ void libraryUpdateStarted(); void libraryUpdated(); void usbBlocked( bool blocked ); /** - * MpPlaybackData slots + * MpPlaybackData related */ void albumArtReady(); void playbackStateChanged(); void playbackInfoChanged(); - /** - * ????? - */ - bool eventFilter(QObject *target, QEvent *event); - - /** - * Button specific slots - */ - void mediaButtonPressed( int aMediaKeyId ); - void mediaButtonReleased( int aMediaKeyId ); - -protected: - - /** - * Called from mediaButtonPressed and from mediaButtonReleased slots. - * Calls defineMediaButton to redraw the media button - */ - void mediaButtonEvent( MediaKeyIdentifier aMediaKeyId, QString aGraphicsId, QString aIconColor ); - - /** - * Creates the aTarget push button based on params aGraphicsId and aSuffix. - * Used to change the look and feel of the button based to the aState - * param: aTarget is the push button to be changed, must not be Null - * param: aGraphicsId defines the button background graphics - * param: aSuffix filename suffix, see KPrevButPrefix for example from musicwidget.cpp - */ - void defineMediaButton( HbPushButton& aTarget, QString aGraphicsId, QStringList aSuffix, QString aIconColor ); - private slots: /** * Slots to be called after button press */ - void prevSong(); - void playSong(); - void nextSong(); - void shortcutButton(); + void handlePrevButtonClicked(); + void handlePlayButtonClicked(); + void handleNextButtonClicked(); + void handleAlbumArtClicked(); + + /** + * MpApplicationMonitor related + */ + void applicationStatusChanged( bool isrunning ); private: - // mShortcutButtonLayout items - HbPushButton *mShortcutArea; - //mSongDataLayout items - HbWidget *mSongDataBG; - HbLabel *mInformationSongName; + HbLabel *mSongDataBackground; HbMarqueeItem *mMarqueeText; // mControlButtonsLayout items @@ -174,24 +145,22 @@ HbPushButton *mNextPushButton; // MusicPlayer related state identifiers - bool mMusicPlayerNoSongData; bool mMusicPlayerUpdating; bool mMusicPlayerBlocked; + bool mMusicPlayerRunning; // Album art for background MpAlbumCoverWidget *mAlbumArt; - // Artist and song title identifiers - QString mArtist; - QString mTitle; - // Used to launch MusicPlayer XQApplicationManager mApplicationManager; // MusicPlayer control and state updates - MpEngine* mMpEngine; - MpPlaybackData* mMpPlaybackData; - + MpEngine *mMpEngine; + MpPlaybackData *mMpPlaybackData; + + // Music Player observer + MpApplicationMonitor *mMpApplicationMonitor; }; #endif // MUSICWIDGET_H diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/musicwidgetplugin.pro --- a/musicwidgetplugin/musicwidgetplugin.pro Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/musicwidgetplugin.pro Mon Oct 04 00:14:19 2010 +0300 @@ -15,28 +15,34 @@ # TEMPLATE = lib +TARGET = musicwidgetplugin +TRANSLATIONS += musicwidgetplugin.ts CONFIG += plugin mobility hb MOBILITY = serviceframework -LIBS += -lxqservice -LIBS += -lxqserviceutil -LIBS += -lmpengine -LIBS += -lmpdata -LIBS += -lmpalbumcoverwidget +LIBS += -lxqservice \ + -lxqserviceutil \ + -lmpengine \ + -lmpdata \ + -lmpalbumcoverwidget \ + -lmpapplicationmonitor -INCLUDEPATH += ./inc -INCLUDEPATH += ../inc +INCLUDEPATH += inc \ + ../inc -HEADERS += ./inc/*.h -SOURCES += ./src/*.cpp +HEADERS += inc/musicwidget.h \ + inc/musicwidgetdocumentloader.h \ + inc/musicwidgetplugin.h + +SOURCES += src/musicwidget.cpp \ + src/musicwidgetdocumentloader.cpp \ + src/musicwidgetplugin.cpp RESOURCES = resource/musicwidgetui.qrc UID = 200286FA -symbian:include(./rom/rom.pri) - symbian: { DESTDIR = $${PRIVATE}/private/20022F35/import/widgetregistry/$${UID} @@ -45,7 +51,6 @@ TARGET.UID3 = 0x$${UID} TARGET.EPOCALLOWDLLDATA=1 TARGET.CAPABILITY = ALL -TCB - #TRANSLATIONS += musicwidgetplugin.ts plugins.path = $${DESTDIR} plugins.sources = $${TARGET}.dll @@ -53,7 +58,6 @@ widgetResources.path = $${DESTDIR} widgetResources.sources += resource/$${TARGET}.xml widgetResources.sources += resource/$${TARGET}.manifest - widgetResources.sources += resource/musicwidgeticon.png DEPLOYMENT += plugins \ widgetResources diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/resource/music_widget.docml --- a/musicwidgetplugin/resource/music_widget.docml Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/resource/music_widget.docml Mon Oct 04 00:14:19 2010 +0300 @@ -1,21 +1,6 @@ - - - - - - - - - - - - - - - @@ -29,37 +14,29 @@ - - + + - - + + - + + - - + - - - - - - - + - - - - - + + + @@ -68,22 +45,21 @@ - - + + - - - - + + + - + diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/resource/musicwidgeticon.png Binary file musicwidgetplugin/resource/musicwidgeticon.png has changed diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/resource/musicwidgetplugin.manifest --- a/musicwidgetplugin/resource/musicwidgetplugin.manifest Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/resource/musicwidgetplugin.manifest Mon Oct 04 00:14:19 2010 +0300 @@ -1,8 +1,10 @@ - - - + + musicwidgetplugin + txt_muwidget_dblist_music_player + txt_muwidget_dblist_val_quick_access_to_music + qtg_large_music + false + musicwidgetplugin.xml + musicwidgetplugin + diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/resource/musicwidgetplugin.xml --- a/musicwidgetplugin/resource/musicwidgetplugin.xml Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/resource/musicwidgetplugin.xml Mon Oct 04 00:14:19 2010 +0300 @@ -8,7 +8,5 @@ 1.0 Music Player Homescreen Widget - musicwidgeticon.png - Music Widget diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/resource/musicwidgetui.qrc --- a/musicwidgetplugin/resource/musicwidgetui.qrc Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/resource/musicwidgetui.qrc Mon Oct 04 00:14:19 2010 +0300 @@ -1,6 +1,5 @@ - + music_widget.docml.bin - musicwidgeticon.png diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/rom/bld.inf --- a/musicwidgetplugin/rom/bld.inf Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/rom/bld.inf Mon Oct 04 00:14:19 2010 +0300 @@ -20,7 +20,7 @@ PRJ_EXPORTS musicwidgetplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin.iby) -// musicwidgetplugin_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin_resources.iby) +musicwidgetplugin_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin_resources.iby) // #ifdef MARM // START EXTENSION app-services/buildstubsis diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/rom/musicwidgetplugin.iby --- a/musicwidgetplugin/rom/musicwidgetplugin.iby Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/rom/musicwidgetplugin.iby Mon Oct 04 00:14:19 2010 +0300 @@ -22,6 +22,5 @@ data=ZPRIVATE\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.qtplugin private\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.qtplugin data=ZPRIVATE\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.manifest private\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.manifest data=ZPRIVATE\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.xml private\20022f35\import\widgetregistry\200286FA\musicwidgetplugin.xml -data=ZPRIVATE\20022f35\import\widgetregistry\200286FA\musicwidgeticon.png private\20022f35\import\widgetregistry\200286FA\musicwidgeticon.png #endif // MUSICWIDGETPLUGIN_IBY \ No newline at end of file diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/rom/musicwidgetplugin_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/musicwidgetplugin/rom/musicwidgetplugin_resources.iby Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef MUSICWIDGETPLUGIN_RESOURCES_IBY +#define MUSICWIDGETPLUGIN_RESOURCES_IBY + +#include + +data = DATAZ_\QT_TRANSLATIONS_DIR\musicwidgetplugin.qm QT_TRANSLATIONS_DIR\musicwidgetplugin.qm + +#endif // MUSICWIDGETPLUGIN_RESOURCES_IBY \ No newline at end of file diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/rom/rom.pri --- a/musicwidgetplugin/rom/rom.pri Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/rom/rom.pri Mon Oct 04 00:14:19 2010 +0300 @@ -24,17 +24,5 @@ BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/musicwidgetplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin.iby)" #iby exports to language -#BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/musicwidgetplugin_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin_resources.iby)" +BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/musicwidgetplugin_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(musicwidgetplugin_resources.iby)" } - - -BLD_INF_RULES.prj_extensions += \ - -#$$LITERAL_HASH"ifdef MARM" \ -#" START EXTENSION app-services/buildstubsis" \ -#" OPTION SRCDIR rom" \ -#" OPTION SISNAME musicwidgetplugin_stub" \ -#" END" \ -#$$LITERAL_HASH"endif" - - diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/src/musicwidget.cpp --- a/musicwidgetplugin/src/musicwidget.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/src/musicwidget.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -15,9 +15,8 @@ * */ -#include "musicwidget.h" - -#include +// System includes +#include #include #include #include @@ -26,174 +25,95 @@ #include #include #include -#include +#include +// User includes +#include "musicwidget.h" #include "musicwidgetdocumentloader.h" #include "mptrace.h" #include "mpenginefactory.h" #include "mpalbumcoverwidget.h" +#include "mpplaybackdata.h" +#include "mpapplicationmonitor.h" // Constants /** Docml */ -const QString MUSIC_WIDGET_DOCML = ":/gfx/music_widget.docml"; - -/** File name suffix lists for push buttons */ -const QStringList PREV_BUTTON_SUFFIXES = (QStringList() << "_l" << "_c" << "_cr"); -const QStringList PLAY_BUTTON_SUFFIXES = (QStringList() << "_cl" << "_c" << "_cr"); -const QStringList NEXT_BUTTON_SUFFIXES = (QStringList() << "_cl" << "_c" << "_r"); - -/** Prefixes for 3 piece button background graphics */ -const QLatin1String PUSH_BUTTON_NORMAL("qtg_fr_hsbutton_normal"); -const QLatin1String PUSH_BUTTON_PRESSED ("qtg_fr_hsbutton_pressed"); -const QLatin1String PUSH_BUTTON_DISABLED ("qtg_fr_hsbutton_disabled"); - -/** Push button icon colors for each of the states (Normal, Pressed and Disabled) */ -const QLatin1String ICON_COLOR_NORMAL ("qtc_button_normal"); -const QLatin1String ICON_COLOR_PRESSED ("qtc_button_pressed"); -const QLatin1String ICON_COLOR_DISABLED ("qtc_button_disabled"); +const QString MUSIC_WIDGET_DOCML = ":/docml/music_widget.docml"; /** Play and Pause icons */ -const QLatin1String ICON_PLAY ("qtg_mono_play"); -const QLatin1String ICON_PAUSE ("qtg_mono_pause"); -/** Music Player shortcut icon */ -const QLatin1String ICON_LARGE_MUSIC_PLAYER ("qtg_large_music"); -/** Music Player shortcut icon */ -const QLatin1String ICON_FIRST_TIME_USE ("qtg_large_music_empty"); -const QLatin1String ICON_DEFAULT_ART ("qtg_large_album_art"); +const QLatin1String ICON_PLAY ( "qtg_mono_play" ); +const QLatin1String ICON_PAUSE ( "qtg_mono_pause" ); + +/** Album art icon */ +const QLatin1String ICON_DEFAULT_ART ( "qtg_large_music_empty" ); /** HsWidget normal background */ -const QLatin1String WIDGET_BG_NORMAL ("qtg_fr_hswidget_normal"); +const QLatin1String WIDGET_BG_NORMAL ( "qtg_fr_hswidget_normal" ); /** Text background */ -const QLatin1String TEXT_BG_NORMAL ("qtg_fr_multimedia_trans"); +const QLatin1String TEXT_BG_NORMAL ( "qtg_fr_multimedia_trans" ); /** Separator : character and space between artist and song name */ -const QLatin1String SEPARATOR_TEXT (": "); -/** Temporary unknown artist */ -const QLatin1String TEMPORARY_UNKWNOWN_TEXT ("Unknown"); -/** Localized unknown artist */ -const QLatin1String UNKWNOWN_TEXT ("txt_mus_other_unknown_1"); +const QLatin1String SEPARATOR_TEXT ( ": " ); -/** Marquee width */ -const int MARQUEE_WIDTH = 170; /** Infinite loop value for marquee */ const int MARQUEE_LOOP_FOREVER = -1; /** Now playing view with random play */ -const QLatin1String SERVICEREQ_FIRST_TIME_USE ("appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone&shuffle=yes"); +const QLatin1String SERVICEREQ_NOW_PLAYING_VIEW_SHUFFLE ( "appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone&shuffle=yes" ); /** Main view */ -const QLatin1String SERVICEREQ_MAIN_VIEW ("appto://10207C62?activityname=MusicMainView&launchtype=standalone"); +const QLatin1String SERVICEREQ_MAIN_VIEW ( "appto://10207C62?activityname=MusicMainView&launchtype=standalone" ); /** Now playing view */ -const QLatin1String SERVICEREQ_NOW_PLAYING_VIEW ("appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone"); +const QLatin1String SERVICEREQ_NOW_PLAYING_VIEW ( "appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone" ); + +/** DOCML object names */ +const QLatin1String DOCML_CONTAINER_WIDGET ( "containerWidget" ); +const QLatin1String DOCML_BG_ICON ( "widget_background_icon" ); +const QLatin1String DOCML_ALBUM_ART ( "album_art_image" ); +const QLatin1String DOCML_TEXT_BG ( "text_bg" ); +const QLatin1String DOCML_SCROLLING_TEXT ( "scrolling_text" ); +const QLatin1String DOCML_BUTTON_GROUP_CONTAINER ( "button_group_container" ); +const QLatin1String DOCML_PREV_BUTTON ( "btn_previous" ); +const QLatin1String DOCML_PLAY_BUTTON ( "btn_play" ); +const QLatin1String DOCML_NEXT_BUTTON ( "btn_next" ); -/** DOCML object name for main widget */ -const QLatin1String DOCML_CONTAINER_WIDGET ("containerWidget"); -/** DOCML object name for widget background */ -const QLatin1String DOCML_BG_ICON ("widget_background_icon"); -/** DOCML object name for album art image */ -const QLatin1String DOCML_ALBUM_ART ("album_art_image"); -/** DOCML object name for shortcut icon background */ -const QLatin1String DOCML_SHORTCUT_ICON_BG ("shortcut_icon_background"); -/** DOCML object name for shortcut icon */ -const QLatin1String DOCML_SHORTCUT_ICON ("shortcut_icon"); -/** DOCML object name for scrolling text background */ -const QLatin1String DOCML_TEXT_BG ("text_bg"); -/** DOCML object name for scrolling text */ -const QLatin1String DOCML_SCROLLING_TEXT ("scrolling_text"); -/** DOCML object name for button group container */ -const QLatin1String DOCML_BUTTON_GROUP_CONTAINER ("button_group_container"); -/** DOCML object name for prev button */ -const QLatin1String DOCML_PREV_BUTTON ("btn_previous"); -/** DOCML object name for play button */ -const QLatin1String DOCML_PLAY_BUTTON ("btn_play"); -/** DOCML object name for next button */ -const QLatin1String DOCML_NEXT_BUTTON ("btn_next"); +/*! + \class MusicWidget + \brief Provides simple Music Player playback controls from the Home Screen. + */ - -MusicWidget::MusicWidget(QGraphicsItem* parent, Qt::WindowFlags flags): - HbWidget(parent, flags), - mShortcutArea(0), - mSongDataBG(0), - mInformationSongName(0), - mMarqueeText(0), - mPreviousPushButton(0), - mPlayPushButton(0), - mNextPushButton(0), - mMusicPlayerNoSongData(1), - mMusicPlayerUpdating(0), - mMusicPlayerBlocked(0), - mAlbumArt(0), - mArtist(0), - mTitle(0), - mMpEngine(0), - mMpPlaybackData(0) +/*! + Constructs the Music Player home screen widget. + */ +MusicWidget::MusicWidget( QGraphicsItem* parent, Qt::WindowFlags flags ): + HbWidget( parent, flags ), + mSongDataBackground( 0 ), + mMarqueeText( 0 ), + mPreviousPushButton( 0 ), + mPlayPushButton( 0 ), + mNextPushButton( 0 ), + mMusicPlayerUpdating( false ), + mMusicPlayerBlocked( false ), + mMusicPlayerRunning( false ), + mAlbumArt( 0 ), + mMpEngine( 0 ), + mMpPlaybackData( 0 ), + mMpApplicationMonitor( 0 ) { - TX_ENTRY - - // Setup UI - setupUi(); - - // Connect to MP engine and playback data - mMpEngine = MpEngineFactory::createSharedEngine(MpCommon::KMusicPlayerUid, MpEngine::HomeScreen ); - Q_ASSERT_X(mMpEngine, "music_widget", "no music player engine"); - TX_LOG_ARGS("got mp engine") - - mMpPlaybackData = mMpEngine->playbackData(); - Q_ASSERT_X(mMpPlaybackData, "music_widget", "no playback data"); - TX_LOG_ARGS("got playback data") - - // Connect outgoing signals and slots - QObject::connect(mShortcutArea, SIGNAL(clicked()), this, SLOT(shortcutButton())); - - // use signal mapper to indicate button identifiers to button event slots - QSignalMapper* signalMapperPressed = new QSignalMapper( this ); - signalMapperPressed->setMapping( mPreviousPushButton, EPrevious ); - signalMapperPressed->setMapping( mPlayPushButton, EPlayPause); - signalMapperPressed->setMapping( mNextPushButton, ENext); - - // need to use different signal mapper for pressed and released events, - // both have same mappings but they are mapped to different slots - QSignalMapper* signalMapperReleased = new QSignalMapper( this ); - signalMapperReleased->setMapping( mPreviousPushButton, EPrevious ); - signalMapperReleased->setMapping( mPlayPushButton, EPlayPause); - signalMapperReleased->setMapping( mNextPushButton, ENext); - - // Connect button events to signal maps - QObject::connect(mPreviousPushButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); - QObject::connect(mPreviousPushButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); - - QObject::connect(mPlayPushButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); - QObject::connect(mPlayPushButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); - - QObject::connect(mNextPushButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); - QObject::connect(mNextPushButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); - - // Connect mapper signals to self implemented slots - QObject::connect( signalMapperPressed, SIGNAL(mapped(int)), this, SLOT(mediaButtonPressed(int))); - QObject::connect( signalMapperReleased, SIGNAL(mapped(int)), this, SLOT(mediaButtonReleased(int))); - - // Connect clicked events - QObject::connect(mPreviousPushButton, SIGNAL(clicked()), this, SLOT(prevSong())); - QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, SLOT(playSong())); - QObject::connect(mNextPushButton, SIGNAL(clicked()), this, SLOT(nextSong())); - - // MpEngine - QObject::connect(mMpEngine, SIGNAL(libraryUpdateStarted()), this, SLOT(libraryUpdateStarted())); - QObject::connect(mMpEngine, SIGNAL(libraryUpdated()), this, SLOT(libraryUpdated())); - QObject::connect(mMpEngine, SIGNAL(usbBlocked(bool)), this, SLOT(usbBlocked(bool))); - - //MpPlaybackData - QObject::connect(mMpPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtReady())); - QObject::connect(mMpPlaybackData, SIGNAL(playbackStateChanged()), this, SLOT(playbackStateChanged())); - QObject::connect(mMpPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged())); - - // Initial data from Music Player get by onShow method call - TX_EXIT + TX_LOG + HbTranslator translator( QString( "musicwidgetplugin" ) ); } /*! - Destructor -*/ + Destructor + */ MusicWidget::~MusicWidget() { + TX_ENTRY + if ( mMpEngine ) { + MpEngineFactory::close(); + } + + delete mMpApplicationMonitor; + TX_EXIT } /*! @@ -206,235 +126,66 @@ // Use document loader to load the contents MusicWidgetDocumentLoader loader; bool ok = false; - loader.load( MUSIC_WIDGET_DOCML, &ok); - Q_ASSERT_X(ok, "music_widget", "invalid title docml file"); + loader.load( MUSIC_WIDGET_DOCML, &ok ); + Q_ASSERT_X( ok, "music_widget", "invalid title docml file" ); - TX_LOG_ARGS("loaded docml") + TX_LOG_ARGS( "loaded docml" ) - QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical, this); - QGraphicsWidget* container = loader.findWidget(DOCML_CONTAINER_WIDGET); - mainLayout->addItem(container); + QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout( Qt::Vertical, this ); + QGraphicsWidget* container = loader.findWidget( DOCML_CONTAINER_WIDGET ); + mainLayout->addItem( container ); + //Sets parent setLayout( mainLayout ); // Load and set widget background - HbWidget *bgWidget = qobject_cast (loader.findWidget(DOCML_BG_ICON)); - HbFrameItem *frameItem; - if (bgWidget) - { - HbFrameDrawer *drawer = new HbFrameDrawer(WIDGET_BG_NORMAL, - HbFrameDrawer::NinePieces); - frameItem = new HbFrameItem(drawer, bgWidget); - frameItem->setPreferredSize(bgWidget->preferredSize()); - bgWidget->setZValue(1); - } + HbLabel *bgWidget = qobject_cast ( loader.findWidget( DOCML_BG_ICON ) ); + HbFrameItem *frameItemWidgetBg = new HbFrameItem(); + frameItemWidgetBg->frameDrawer().setFrameGraphicsName( WIDGET_BG_NORMAL ); + frameItemWidgetBg->frameDrawer().setFrameType( HbFrameDrawer::NinePieces ); + frameItemWidgetBg->frameDrawer().setFillWholeRect( true ); + bgWidget->setBackgroundItem( frameItemWidgetBg ); // Setup album art area QGraphicsWidget *tmpWidgetPtr; - tmpWidgetPtr = loader.findWidget(DOCML_ALBUM_ART); - mAlbumArt = qobject_cast(tmpWidgetPtr); + tmpWidgetPtr = loader.findWidget( DOCML_ALBUM_ART ); + mAlbumArt = qobject_cast( tmpWidgetPtr ); mAlbumArt->setEnabled( false ); mAlbumArt->setDefaultIcon( HbIcon( ICON_DEFAULT_ART ) ); - // Load shortcut background - HbWidget *shortcutAreaLayout = qobject_cast (loader.findWidget(DOCML_SHORTCUT_ICON_BG)); - HbFrameItem *shortcutFrameItem; - if (shortcutAreaLayout) { - HbFrameDrawer *drawer = new HbFrameDrawer(WIDGET_BG_NORMAL, - HbFrameDrawer::NinePieces); - shortcutFrameItem = new HbFrameItem(drawer, shortcutAreaLayout); - shortcutFrameItem->setPreferredSize(shortcutAreaLayout->preferredSize()); - shortcutAreaLayout->setZValue(3); - } - - // Load shortcut widget and set background - mShortcutArea = qobject_cast (loader.findWidget(DOCML_SHORTCUT_ICON)); - if ( mShortcutArea ) - { - // icon needs to be put as a background so that it fills the whole button area - HbFrameDrawer* drawer = new HbFrameDrawer(ICON_LARGE_MUSIC_PLAYER, HbFrameDrawer::OnePiece); - mShortcutArea->setFrameBackground( drawer ); - } - // Set song data background - mSongDataBG = qobject_cast (loader.findWidget(DOCML_TEXT_BG)); - HbFrameItem *scrollTextItem; - if (mSongDataBG) - { - HbFrameDrawer *drawer = new HbFrameDrawer(TEXT_BG_NORMAL, - HbFrameDrawer::NinePieces); - scrollTextItem = new HbFrameItem(drawer, mSongDataBG); - scrollTextItem->setPreferredSize(mSongDataBG->preferredSize()); - mSongDataBG->setZValue(4); - mSongDataBG->hide(); // Hide initially... - } + mSongDataBackground = qobject_cast ( loader.findWidget( DOCML_TEXT_BG ) ); + HbFrameItem *frameItemSongBg = new HbFrameItem(); + frameItemSongBg->frameDrawer().setFrameGraphicsName( TEXT_BG_NORMAL ); + frameItemSongBg->frameDrawer().setFrameType( HbFrameDrawer::NinePieces ); + frameItemSongBg->frameDrawer().setFillWholeRect( true ); + mSongDataBackground->setBackgroundItem( frameItemSongBg ); + mSongDataBackground->hide(); // Set scrolling song data - mInformationSongName = qobject_cast (loader.findWidget(DOCML_SCROLLING_TEXT)); - if ( mInformationSongName ) - { - // Setting primitive marquee item values from .css doesn't work well, set in code... - mMarqueeText = new HbMarqueeItem(mInformationSongName); - HbFontSpec fs(HbFontSpec::Secondary); - mMarqueeText->setFontSpec(fs); - mMarqueeText->setTextColor(mInformationSongName->textColor()); - mMarqueeText->setMinimumWidth(MARQUEE_WIDTH); - mMarqueeText->setLoopCount(MARQUEE_LOOP_FOREVER); - } - - HbWidget *buttonGroupContainer = qobject_cast (loader.findWidget( - DOCML_BUTTON_GROUP_CONTAINER)); - if (buttonGroupContainer) - { - // Define push buttons in state at this point, check the player status later and update buttons if needed - mPreviousPushButton = qobject_cast (loader.findWidget(DOCML_PREV_BUTTON)); - defineMediaButton( *mPreviousPushButton, PUSH_BUTTON_NORMAL, PREV_BUTTON_SUFFIXES, ICON_COLOR_NORMAL ); - - mPlayPushButton = qobject_cast (loader.findWidget(DOCML_PLAY_BUTTON)); - defineMediaButton( *mPlayPushButton, PUSH_BUTTON_NORMAL, PLAY_BUTTON_SUFFIXES, ICON_COLOR_NORMAL ); - - mNextPushButton = qobject_cast (loader.findWidget(DOCML_NEXT_BUTTON)); - defineMediaButton( *mNextPushButton, PUSH_BUTTON_NORMAL, NEXT_BUTTON_SUFFIXES, ICON_COLOR_NORMAL ); - } - + mMarqueeText = qobject_cast ( loader.findWidget( DOCML_SCROLLING_TEXT ) ); + mMarqueeText->setLoopCount( MARQUEE_LOOP_FOREVER ); + + // Get buttons + HbWidget *buttonGroupContainer = qobject_cast ( loader.findWidget( + DOCML_BUTTON_GROUP_CONTAINER ) ); + if ( buttonGroupContainer ) { + // Define push buttons + mPreviousPushButton = qobject_cast ( loader.findWidget( DOCML_PREV_BUTTON ) ); + mPlayPushButton = qobject_cast ( loader.findWidget( DOCML_PLAY_BUTTON ) ); + mNextPushButton = qobject_cast ( loader.findWidget( DOCML_NEXT_BUTTON ) ); + } + TX_EXIT } /*! - Makes the push button based on information aGraphicsId and aSuffix - */ -void MusicWidget::defineMediaButton( HbPushButton& aTarget, QString aGraphicsId, QStringList aSuffix, QString aIconColor ) - { - TX_ENTRY - - TX_LOG_ARGS("graphics id: " << aGraphicsId) - TX_LOG_ARGS("icon color: " << aIconColor) - - HbFrameDrawer* drawer; - - // First check if the drawer is already created for this push button - if ( !aTarget.frameBackground()){ - // Nope, create one now - drawer = new HbFrameDrawer(aGraphicsId, HbFrameDrawer::ThreePiecesHorizontal); - aTarget.setFrameBackground( drawer ); - TX_LOG_ARGS("created drawer for button bg") - } - else { - // Frame drawer already created, only need to update frame graphics - drawer = aTarget.frameBackground(); - drawer->setFrameGraphicsName( aGraphicsId ); - TX_LOG_ARGS("using existing drawer for button bg") - } - - // Set file name suffix list, so that drawer can load correct 3-piece graphic files - drawer->setFileNameSuffixList( aSuffix ); - - // Update also the icon color - QColor color = HbColorScheme::color(aIconColor); - aTarget.icon().setColor( color ); - - // Lastly, check if the buttton is disabled - if ( aIconColor == ICON_COLOR_DISABLED ) - { - aTarget.setEnabled(false); - TX_LOG_ARGS("button disabled") - } - else - { - aTarget.setEnabled(true); - TX_LOG_ARGS("button enabled") - } - - TX_EXIT - } - -/*! - - */ -void MusicWidget::mediaButtonEvent( MediaKeyIdentifier aMediaKeyId, QString aGraphicsId, QString aIconColor ) - { - TX_ENTRY - - HbPushButton* target = NULL; - QStringList suffix; - - switch ( aMediaKeyId ) - { - case EPrevious: { - TX_LOG_ARGS("previous") - target = mPreviousPushButton; - suffix = PREV_BUTTON_SUFFIXES; - break; - } - case EPlayPause: { - TX_LOG_ARGS("play/pause") - target = mPlayPushButton; - suffix = PLAY_BUTTON_SUFFIXES; - break; - } - case ENext: { - TX_LOG_ARGS("next") - target = mNextPushButton; - suffix = NEXT_BUTTON_SUFFIXES; - break; - } - default: { - // Do proper error handling.. should not be possible to get here ever tough - TX_LOG_ARGS("unknown button") - return; - } - } - - if ( target ) - { - MusicWidget::defineMediaButton( *target, aGraphicsId, suffix, aIconColor ); - } - - TX_EXIT - } - -/*! - Emited from HbPushButton:pressed() signal, changes the button layout to 'Pressed' - */ -void MusicWidget::mediaButtonPressed( int aMediaKeyId ) - { - TX_LOG_ARGS("media key: " << aMediaKeyId ) - mediaButtonEvent( (MediaKeyIdentifier)aMediaKeyId, PUSH_BUTTON_PRESSED, ICON_COLOR_PRESSED ); - } - -/*! - Emited from HbPushButton:released() signal, changes the button layout to 'Normal' - */ -void MusicWidget::mediaButtonReleased( int aMediaKeyId ) - { - TX_LOG_ARGS("media key: " << aMediaKeyId ) - mediaButtonEvent( (MediaKeyIdentifier)aMediaKeyId, PUSH_BUTTON_NORMAL, ICON_COLOR_NORMAL ); - } - -/*! - Disables specified push button - */ -void MusicWidget::mediaButtonDisabled( int aMediaKeyId ) - { - TX_LOG_ARGS("media key: " << aMediaKeyId ) - mediaButtonEvent( (MediaKeyIdentifier)aMediaKeyId, PUSH_BUTTON_DISABLED, ICON_COLOR_DISABLED ); - } - -/*! - Disables specified push button - */ -void MusicWidget::mediaButtonEnabled( int aMediaKeyId ) - { - TX_LOG_ARGS("media key: " << aMediaKeyId ) - mediaButtonEvent( (MediaKeyIdentifier)aMediaKeyId, PUSH_BUTTON_NORMAL, ICON_COLOR_NORMAL ); - } - -/*! Manually update music widget state. */ void MusicWidget::refreshData() { TX_ENTRY + // Get current player state playbackStateChanged(); @@ -443,89 +194,64 @@ // Get current album art albumArtReady(); + TX_EXIT } /*! - Launch music player... + Launch music player. */ -void MusicWidget::launchMusicPlayer(int launchMode) +void MusicWidget::launchMusicPlayer( int launchMode ) { TX_ENTRY - //TODO: Detect if MusicPlayer is running or not properly, handle case where player not available?! - //TODO: Get service status from XQSettingManager - //TODO: Service status from signal: - //TODO: void statusChanged(const XQAiwInterfaceDescriptor& implementation, ServiceStatus currentStatus); - + QUrl url; - XQAiwRequest* req; - - if ( launchMode == ELaunchFromPlay ) - { - TX_LOG_ARGS("launch from play") - // Launch to now playing view, random play to be started! - url.setUrl(SERVICEREQ_FIRST_TIME_USE); - } - else if (mMusicPlayerNoSongData) - { - TX_LOG_ARGS("to main view") - // Launch to main view - url.setUrl(SERVICEREQ_MAIN_VIEW); - } - else - { - TX_LOG_ARGS("to now playing view") - // Launch to now playing view - url.setUrl(SERVICEREQ_NOW_PLAYING_VIEW); - } - - req = mApplicationManager.create(url); - if (req == NULL) - { - // No handlers for the URI - TX_LOG_ARGS("no req created") - return; - } - req->setBackground(false); - req->setSynchronous(false); + switch ( launchMode ) { + case ELaunchToMainView: + TX_LOG_ARGS( "to main view" ) + // Launch to main view + url.setUrl( SERVICEREQ_MAIN_VIEW ); + break; + case ELaunchToNowPlayingView: + TX_LOG_ARGS( "to now playing view" ) + // Launch to now playing view + url.setUrl( SERVICEREQ_NOW_PLAYING_VIEW ); + break; + case ELaunchToNowPlayingViewWithShuffle: + TX_LOG_ARGS( "to now playing view with shuffle" ) + // Launch to now playing view with shuffle + url.setUrl( SERVICEREQ_NOW_PLAYING_VIEW_SHUFFLE ); + break; + default: + //should never get here + TX_LOG_ARGS( "Error: invalid launchMode." ) + return; + } - // Set function parameters - QList args; - args << url.toString(); - req->setArguments(args); + XQAiwRequest* req; + req = mApplicationManager.create( url ); + if ( req ) { + req->setBackground( false ); + req->setSynchronous( false ); + + // Set function parameters + QList args; + args << url.toString(); + req->setArguments( args ); - // Send the request - bool res = req->send(); - if (!res) - { - // Request failed. - int error = req->lastError(); - // Handle error - TX_LOG_ARGS("req send error: " << error) - } - - delete req; + // Send the request + bool res = req->send(); + if ( !res ) { + // Request failed. + int error = req->lastError(); + // Handle error + TX_LOG_ARGS( "req send error: " << error ) + } + delete req; + } - TX_EXIT -} - -/*! - Return bounding rect -*/ -QRectF MusicWidget::boundingRect() const -{ - return childrenBoundingRect(); -} - -/*! - Return shape -*/ -QPainterPath MusicWidget::shape() const -{ - QPainterPath path; - path.addRect(boundingRect()); - return path; + TX_EXIT } /*! @@ -533,7 +259,33 @@ */ void MusicWidget::onInitialize() { - TX_LOG + TX_ENTRY + + // Setup UI + setupUi(); + + // Start Monitoring Music Player running status. + mMpApplicationMonitor = new MpApplicationMonitor(); + + // Check if Music Player UI is up and running + mMusicPlayerRunning = mMpApplicationMonitor->isApplicationRunning(); + + // Connect to MP engine and playback data + connectMusicPlayerEngine( mMusicPlayerRunning ); + + // Connect albumart click signal + QObject::connect( mAlbumArt, SIGNAL( clicked() ), this, SLOT( handleAlbumArtClicked() ) ); + + // Connect button clicked signals + QObject::connect( mPreviousPushButton, SIGNAL( clicked() ), this, SLOT( handlePrevButtonClicked() ) ); + QObject::connect( mPlayPushButton, SIGNAL( clicked() ), this, SLOT( handlePlayButtonClicked() ) ); + QObject::connect( mNextPushButton, SIGNAL( clicked() ), this, SLOT( handleNextButtonClicked() ) ); + + // Connect Music Player observer signal + QObject::connect( mMpApplicationMonitor, SIGNAL( applicationStatusChanged( bool ) ), + this, SLOT ( applicationStatusChanged( bool ) ) ); + + TX_EXIT } /*! @@ -541,8 +293,9 @@ */ void MusicWidget::onShow() { - TX_LOG + TX_ENTRY refreshData(); + TX_EXIT } /*! @@ -551,6 +304,9 @@ void MusicWidget::onHide() { TX_LOG + if ( mMarqueeText->isAnimating() ) { + mMarqueeText->stopAnimation(); + } } /*! @@ -562,268 +318,340 @@ } /*! - Slot for shortcut button clicked. + Slot to handle when the album art area is clicked. */ -void MusicWidget::shortcutButton() +void MusicWidget::handleAlbumArtClicked() { - TX_LOG - launchMusicPlayer(ELaunchFromShortcut); + TX_ENTRY + if ( getPlaybackState() == MpPlaybackData::NotPlaying ) { + launchMusicPlayer( ELaunchToMainView ); + } + else { + launchMusicPlayer( ELaunchToNowPlayingView ); + } + TX_EXIT } /*! Slot for previous button clicked. */ -void MusicWidget::prevSong() +void MusicWidget::handlePrevButtonClicked() { - TX_LOG - mMpEngine->skipBackward(); + TX_ENTRY + if ( mMpEngine ) { + mMpEngine->skipBackward(); + } + TX_EXIT } /*! Slot for play button clicked. Handles both Play and Pause! */ -void MusicWidget::playSong() +void MusicWidget::handlePlayButtonClicked() { TX_ENTRY - if (mMusicPlayerNoSongData && mMpPlaybackData->playbackState() != MpPlaybackData::Playing ) - { + // If nothing to play, start music player in playback view. + if ( getPlaybackState() == MpPlaybackData::NotPlaying ) { //Signal music player to start playing all songs with random - launchMusicPlayer(ELaunchFromPlay); + launchMusicPlayer( ELaunchToNowPlayingViewWithShuffle ); + } + else { + // send play/pause command. + if ( mMpEngine ) { + mMpEngine->playPause(); } - - mMpEngine->playPause(); + } TX_EXIT } + /*! Slot for next button clicked. */ -void MusicWidget::nextSong() +void MusicWidget::handleNextButtonClicked() { - TX_LOG - mMpEngine->skipForward(); + TX_ENTRY + if ( mMpEngine ) { + mMpEngine->skipForward(); + } + TX_EXIT } /*! - + Slot to handle when the music player running status changed. */ -bool MusicWidget::eventFilter(QObject *target, QEvent *event) - { - // pass the event on to the parent class - return HbWidget::eventFilter(target, event); +void MusicWidget::applicationStatusChanged( bool isRunning ) +{ + TX_ENTRY_ARGS( "running " << isRunning ); + + // Connect/disconnect engine base on music player running state. + if ( mMusicPlayerRunning != isRunning ) { + TX_LOG_ARGS("running state changed"); + mMusicPlayerRunning = isRunning; + connectMusicPlayerEngine( isRunning ); + // refresh data if musicplayer is on, otherwise clear data + if ( isRunning ) { + refreshData(); + } + else { + clearData(); + } + } + + TX_EXIT } /*! - MpEngine related + Library started refreshing. */ void MusicWidget::libraryUpdateStarted() { - TX_LOG + TX_ENTRY //Refresh Library start mMusicPlayerUpdating = true; // Update button enabled/disabled state - toggleButtons(); + updateButtons(); + TX_EXIT } /*! - MpEngine related + Library is finished refreshing. */ void MusicWidget::libraryUpdated() { - TX_LOG + TX_ENTRY //Refresh Library done mMusicPlayerUpdating = false; // Update button enabled/disabled state - toggleButtons(); + updateButtons(); + TX_EXIT } /*! - MpEngine related + USB blocking state has changed. */ void MusicWidget::usbBlocked( bool blocked ) { - TX_LOG_ARGS("blocked: " << blocked) - //Blocked state - //Mass storage mode - //Media transfer mode - //Ovi Suite mode - //Insert memory card - + TX_ENTRY_ARGS( "blocked: " << blocked ) mMusicPlayerBlocked = blocked; // Update button enabled/disabled state - toggleButtons(); + updateButtons(); + TX_EXIT } /*! - MpPlaybackData related + The album art has changed. */ void MusicWidget::albumArtReady() { TX_ENTRY HbIcon icon; - if ( mMpPlaybackData->playbackState() == MpPlaybackData::NotPlaying ) - { - TX_LOG_ARGS("1st time album art") - icon = HbIcon(ICON_FIRST_TIME_USE); + if ( getPlaybackState() == MpPlaybackData::NotPlaying ) { + TX_LOG_ARGS( "default album art" ) + icon = HbIcon( ICON_DEFAULT_ART ); + } + else { + TX_LOG_ARGS( "playback data album art" ) + if ( mMpPlaybackData ) { + mMpPlaybackData->albumArt( icon ); } - else - { - TX_LOG_ARGS("playback data album art") - mMpPlaybackData->albumArt( icon ); - } + } mAlbumArt->setIcon( icon ); mAlbumArt->setEnabled( true ); + TX_EXIT +} + +/*! + Playback state has changed. + */ +void MusicWidget::playbackStateChanged() +{ + TX_ENTRY + + if ( getPlaybackState() == MpPlaybackData::Playing ) { + TX_LOG_ARGS( "pause icon" ) + mPlayPushButton->setIcon( HbIcon( ICON_PAUSE ) ); + } + else { + TX_LOG_ARGS( "play icon" ) + mPlayPushButton->setIcon( HbIcon( ICON_PLAY ) ); + } + + // Update button enabled/disabled state + updateButtons(); TX_EXIT } -void MusicWidget::playbackStateChanged() -{ +/*! + Song data has changed. + */ +void MusicWidget::playbackInfoChanged() +{ TX_ENTRY - // Set play/pause icon and start/stop marquee. - QString iconName; + + QString songData; + QString artist; + QString title; - int state = mMpPlaybackData->playbackState(); - - TX_LOG_ARGS("state: " << state) + if ( mMpPlaybackData ) { + artist = mMpPlaybackData->artist(); + title = mMpPlaybackData->title(); + } - switch (state) - { - case MpPlaybackData::Playing: - { - TX_LOG_ARGS("pause icon, start marquee") - iconName.append(ICON_PAUSE); + if ( !title.length() ) { + artist.clear(); + title.clear(); + // Initialize marquee with something (space), to ensure text updates to display as well. + songData = " "; + TX_LOG_ARGS( "no song data" ) + } + else { + if ( !artist.length() ) { + //Show localized "Unknown" if there is no artist name + songData.append( hbTrId( "txt_muwidget_other_unknown_1" ).arg( title ) ); + } + else { + songData.append( artist ); + songData.append( SEPARATOR_TEXT ); + songData.append( title ); + } + TX_LOG_ARGS( "song data received" ) + } + + mMarqueeText->setText( songData ); + TX_LOG_ARGS( "marquee text: " << songData ) + + // Display song data if it exist. + if ( title.length() ) { + if ( !mSongDataBackground->isVisible() ) { + mSongDataBackground->show(); + } + if ( !mMarqueeText->isAnimating() ) { mMarqueeText->startAnimation(); - break; - } - case MpPlaybackData::Paused: - case MpPlaybackData::Stopped: - case MpPlaybackData::NotPlaying: - { - TX_LOG_ARGS("play icon, stop marquee") - iconName.append(ICON_PLAY); + } + } + else { + if ( mSongDataBackground->isVisible() ) { + mSongDataBackground->hide(); + } + if ( mMarqueeText->isAnimating() ) { mMarqueeText->stopAnimation(); - break; - } } - - HbIcon iconPlayPause(iconName); - mPlayPushButton->setIcon(iconPlayPause); + } TX_EXIT } /*! - MpPlaybackData related + Update buttons to disabled/enabled as required. */ -void MusicWidget::playbackInfoChanged() +void MusicWidget::updateButtons() { TX_ENTRY - // Initialize maqruee with something (space), to ensure - // text updates to display as well. - QString songData; - mArtist = mMpPlaybackData->artist(); - mTitle = mMpPlaybackData->title(); - - if ( !mTitle.length() ) - { - mArtist.clear(); - mTitle.clear(); - songData = " "; - - //1st time launch - mMusicPlayerNoSongData = true; - - TX_LOG_ARGS("no song data") - } - else - { - if ( !mArtist.length() ) - { - //Show localized "Unknown" if there is no artist name - - //TODO: Widget needs own localization?!?! - //mArtist.append( hbTrId(UNKWNOWN_TEXT) ); - - //TODO: Remove temporary unknown string when localization resolved. - mArtist.append( TEMPORARY_UNKWNOWN_TEXT ); - } - - songData.append(mArtist); - songData.append(SEPARATOR_TEXT); - songData.append(mTitle); - - mMusicPlayerNoSongData = false; - - TX_LOG_ARGS("song data received") - } - - mMarqueeText->setText(songData); - TX_LOG_ARGS("marquee text: " << songData) - - // Show dark BG to songdata only if there is songdata... - if ( mMusicPlayerNoSongData && mSongDataBG->isVisible() ) - { - TX_LOG_ARGS("hide marquee bg") - mSongDataBG->hide(); - } - else if ( !mMusicPlayerNoSongData && !mSongDataBG->isVisible() ) - { - TX_LOG_ARGS("show marquee bg") - mSongDataBG->show(); - } - - // Update button enabled/disabled state - toggleButtons(); + // All buttons disabled if updating or usb blocked + if ( mMusicPlayerUpdating || mMusicPlayerBlocked ) { + TX_LOG_ARGS( "refreshing" ) + mPreviousPushButton->setEnabled( false ); + mPlayPushButton->setEnabled( false ); + mNextPushButton->setEnabled( false ); + } + // Only play button enabled if there is no song data + else if ( getPlaybackState() == MpPlaybackData::NotPlaying ) { + TX_LOG_ARGS( "no song data" ) + mPreviousPushButton->setEnabled( false ); + mPlayPushButton->setEnabled( true ); + mNextPushButton->setEnabled( false ); + } + // Enable all buttons if there is song data + else { + TX_LOG_ARGS( "enable all buttons" ) + mPreviousPushButton->setEnabled( true ); + mPlayPushButton->setEnabled( true ); + mNextPushButton->setEnabled( true ); + } TX_EXIT } /*! - Toggle buttons to disabled/enabled as required. + Connect/disconnect Music Player engine and playback data */ -void MusicWidget::toggleButtons() -{ +void MusicWidget::connectMusicPlayerEngine( bool connect ) +{ TX_ENTRY - // All buttons disabled if updating - if ( mMusicPlayerUpdating ) - { - TX_LOG_ARGS("updating") - mediaButtonDisabled( EPlayPause ); - mediaButtonDisabled( EPrevious ); - mediaButtonDisabled( ENext ); - } + + if ( mMpEngine ) { + MpEngineFactory::close(); + mMpEngine = 0; + mMpPlaybackData = 0; + mMusicPlayerUpdating = false; + mMusicPlayerBlocked = false; + } - // All buttons disabled if blocked - else if ( mMusicPlayerBlocked ) - { - TX_LOG_ARGS("blocked") - mediaButtonDisabled( EPlayPause ); - mediaButtonDisabled( EPrevious ); - mediaButtonDisabled( ENext ); - } + if ( connect ) { + // Connect to MP engine and playback data + mMpEngine = MpEngineFactory::createSharedEngine( MpCommon::KMusicPlayerUid, MpEngine::HomeScreen ); + Q_ASSERT_X( mMpEngine, "music_widget", "no music player engine" ); + TX_LOG_ARGS( "got mp engine" ) + + mMpPlaybackData = mMpEngine->playbackData(); + Q_ASSERT_X( mMpPlaybackData, "music_widget", "no playback data" ); + TX_LOG_ARGS( "got playback data" ) - // Only play button enabled if there is no song data, 1st time use - else if ( mMusicPlayerNoSongData ) - { - TX_LOG_ARGS("no song data") - mediaButtonEnabled( EPlayPause ); - mediaButtonDisabled( EPrevious ); - mediaButtonDisabled( ENext ); - } + // MpEngine + QObject::connect( mMpEngine, SIGNAL( libraryUpdateStarted() ), this, SLOT( libraryUpdateStarted() ) ); + QObject::connect( mMpEngine, SIGNAL( libraryUpdated() ), this, SLOT( libraryUpdated() ) ); + QObject::connect( mMpEngine, SIGNAL( usbBlocked( bool ) ), this, SLOT( usbBlocked( bool ) ) ); + + //MpPlaybackData + QObject::connect( mMpPlaybackData, SIGNAL( albumArtReady() ), this, SLOT( albumArtReady() ) ); + QObject::connect( mMpPlaybackData, SIGNAL( playbackStateChanged() ), this, SLOT( playbackStateChanged() ) ); + QObject::connect( mMpPlaybackData, SIGNAL( playbackInfoChanged() ), this, SLOT( playbackInfoChanged() ) ); + } - // Enable all buttons if there is song data - else - { - TX_LOG_ARGS("enable all buttons") - mediaButtonEnabled( EPlayPause ); - mediaButtonEnabled( EPrevious ); - mediaButtonEnabled( ENext ); - } TX_EXIT } + +/*! + Get the playback state + */ +int MusicWidget::getPlaybackState() +{ + TX_ENTRY + int state; + if ( mMpPlaybackData ) { + state = mMpPlaybackData->playbackState(); + } + else { + state = MpPlaybackData::NotPlaying; + } + TX_EXIT_ARGS( "playback state = " << state ); + return state; +} + +/*! + Clear the song data + */ +void MusicWidget::clearData() +{ + TX_ENTRY + // set play button to PLAY icon. + mPlayPushButton->setIcon( HbIcon( ICON_PLAY ) ); + updateButtons(); + + // remove song data. + mMarqueeText->setText( QString( " " ) ); + mMarqueeText->stopAnimation(); + mSongDataBackground->hide(); + + // set default album art + mAlbumArt->setIcon( HbIcon( ICON_DEFAULT_ART ) ); + mAlbumArt->setEnabled( true ); + TX_EXIT +} diff -r ed94e1e8390e -r 3cd404d31176 musicwidgetplugin/src/musicwidgetdocumentloader.cpp --- a/musicwidgetplugin/src/musicwidgetdocumentloader.cpp Fri Sep 17 08:28:52 2010 +0300 +++ b/musicwidgetplugin/src/musicwidgetdocumentloader.cpp Mon Oct 04 00:14:19 2010 +0300 @@ -17,6 +17,7 @@ #include +#include #include "musicwidgetdocumentloader.h" #include "mpalbumcoverwidget.h" @@ -47,6 +48,14 @@ return object; } + if (type == HbMarqueeItem::staticMetaObject.className()) + { + QObject *object = new HbMarqueeItem; + object->setObjectName(name); + TX_EXIT + return object; + } + TX_EXIT return HbDocumentLoader::createObject(type, name); } diff -r ed94e1e8390e -r 3cd404d31176 package_definition.xml --- a/package_definition.xml Fri Sep 17 08:28:52 2010 +0300 +++ b/package_definition.xml Mon Oct 04 00:14:19 2010 +0300 @@ -20,7 +20,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -99,7 +99,7 @@ - + diff -r ed94e1e8390e -r 3cd404d31176 tsrc/qvptestresultgen.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/qvptestresultgen.pl Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,1172 @@ +# +# 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: +# + +#------------------------------------------------------------------------------------ +# Includes +#------------------------------------------------------------------------------------ +use strict; +use warnings; +use Cwd; # for cwd +use FindBin; # for FindBin:Bin +use File::Path; # for mkpath +use Date::Calc; + +{ # No globals. + my $cgidir = GetCgiDir(); + #require( $cgidir . "utils.pl" ); +} + +#------------------------------------------------------------------------------------ +# Globals +#------------------------------------------------------------------------------------ +my $lineFeed = "\n"; + +my $RESULT_TESTCLASS = 0; # string +my $RESULT_TESTCASE = 1; # string +my $RESULT_PASSEDCOUNT = 2; # num +my $RESULT_FAILEDCOUNT = 3; # num +my $RESULT_SKIPPEDCOUNT = 4; # num +my $RESULT_TOTALCOUNT = 5; # num +my $RESULT_WARNINGMSGS = 6; # array of strings +my $RESULT_DEBUGMSGS = 7; # array of strings +my $RESULT_DEPRECATIONMSGS = 8; # array of strings +my $RESULT_ALLCASES = 9; # array of arrays ( result(fail=0, pass=1), string method name, array of info strings ) + my $CASE_RESULT = 0; + my $CASE_NAME = 1; + my $CASE_INFO = 2; +my $RESULT_SKIPPEDCASES = 10; # array of strings + +my $optionTextReport = 0; + +#------------------------------------------------------------------------------------ +# Main code +#------------------------------------------------------------------------------------ + +ReadArgs(); + +Main(); + +exit(); + +#------------------------------------------------------------------------------------ +# Subs +#------------------------------------------------------------------------------------ + +sub ReadArgs +{ + while( scalar(@ARGV) > 0 ) + { + my $argument = shift(@ARGV); + + if( $argument eq "-h" ) + { + ShowHelp(); + } + elsif( $argument eq "-txt" ) + { + $optionTextReport = 1; + } + elsif( $argument ne "" ) + { + print "Uknown argument: $argument\n"; + ShowHelp(); + } + }; +} + +sub ShowHelp +{ + +print < + +Options + -h Shows help. + -txt Creates test report in text format instead of xml (Excel). + +Copy the Qt test result files from device c:\\data to same folder with +the script and run it. Creates report from the results. + +Script can be run from videoplayer/internal/qt folder. + +USAGE_EOF + + exit(); + +} + +sub Main +{ + my @files; + FindFiles(".", "txt", 1, \@files); + + my @allResults; + + foreach my $file ( @files ) + { + my @results; + + if( ReadTestRunResults( $file, \@results ) ) + { + push @allResults, [ @results ]; + } + } + + my @totals; + GetTotals( \@totals, \@allResults ); + + if( $optionTextReport ) + { + CreateTextReport( \@totals, \@allResults ); + } + else + { + CreateXmlReport( \@totals, \@allResults ); + } +} + +sub ReadTestRunResults +{ + my ( $file, $refResults ) = @_; + + open( FILE_HANDLE, $file ) or die("ERROR! Could not open file '" . $file . "'\n"); + my @lines = ; + close(FILE_HANDLE); + + my $isQtResultFile = 0; + for( my $i = 0; $i < 10; $i++ ) + { + if( $i < scalar( @lines ) && $lines[$i] =~ m/Using QTest library/i ) + { + $isQtResultFile = 1; + last; + } + } + return 0 if( !$isQtResultFile ); + + @$refResults[$RESULT_TESTCLASS] = ""; + @$refResults[$RESULT_TESTCASE] = ""; + @$refResults[$RESULT_PASSEDCOUNT] = 0; + @$refResults[$RESULT_FAILEDCOUNT] = 0; + @$refResults[$RESULT_SKIPPEDCOUNT] = 0; + @$refResults[$RESULT_TOTALCOUNT] = 0; + @$refResults[$RESULT_WARNINGMSGS] = [ () ]; + @$refResults[$RESULT_DEBUGMSGS] = [ () ]; + @$refResults[$RESULT_DEPRECATIONMSGS] = [ () ]; + @$refResults[$RESULT_ALLCASES] = [ () ]; + @$refResults[$RESULT_SKIPPEDCASES] = [ () ]; + + for( my $i = 0; $i < scalar(@lines); $i++ ) + { + my $line = $lines[$i]; + + # msg class function + if( $line =~ /([a-z\!]+)[ ]+\:[ ]+([a-z0-9\_\-]+)\:\:([a-z0-9\_\-]+\(\))/i ) + { + my $result = $1; + my $testClass = $2; + my $testFunc = $3; + #print("result: $result, class: $testClass, func: $testFunc\n"); + + @$refResults[$RESULT_TESTCLASS] = $testClass; + @$refResults[$RESULT_TESTCASE] = $testFunc; + + my @case; + $case[$CASE_RESULT] = -1; + $case[$CASE_NAME] = $testClass . "::" . $testFunc;; + $case[$CASE_INFO] = [ () ]; + + if( $result =~ /pass/i ) + { + @$refResults[$RESULT_PASSEDCOUNT]++; + $case[$CASE_RESULT] = 1; + } + if( $result =~ /fail\!/i ) + { + @$refResults[$RESULT_FAILEDCOUNT]++; + + $case[$CASE_RESULT] = 0; + + my @info; + # Read rest of the line for info. + my $reason = substr( $line, rindex( $line, $testFunc ) + length( $testFunc ) ); + RemoveWhiteSpaces( \$reason ); + push @info, $reason; + + # Read next lines starting with space to info. + while( $lines[$i+1] =~ m/^ / ) + { + my $str = $lines[$i+1]; + RemoveWhiteSpaces( \$str ); + push @info, $str; + $i++; + last if(!defined($lines[$i+1])); + } + + $case[$CASE_INFO] = [ @info ]; + } + + my $refAllCases = @$refResults[$RESULT_ALLCASES]; + push @$refAllCases, [ @case ]; + + if( $result =~ /skip/i ) + { + @$refResults[$RESULT_SKIPPEDCOUNT]++; + push @{@$refResults[$RESULT_SKIPPEDCASES]}, $testClass . "::" . $testFunc; + } + if( $result =~ /qdebug/i ) + { + push @{@$refResults[$RESULT_DEBUGMSGS]}, $line; + if( $line =~ m/deprecated/i ) + { + push @{@$refResults[$RESULT_DEPRECATIONMSGS]}, $line; + } + } + if( $result =~ /qwarn/i ) + { + push @{@$refResults[$RESULT_WARNINGMSGS]}, $line; + } + } + } + + @$refResults[$RESULT_TOTALCOUNT] = @$refResults[$RESULT_PASSEDCOUNT] + @$refResults[$RESULT_FAILEDCOUNT] + @$refResults[$RESULT_SKIPPEDCOUNT]; + return 1; +} + +sub GetTotals +{ + my ( $refTotals, $refAllResults ) = @_; + + @$refTotals[$RESULT_TESTCLASS] = ""; + @$refTotals[$RESULT_TESTCASE] = ""; + @$refTotals[$RESULT_PASSEDCOUNT] = 0; + @$refTotals[$RESULT_FAILEDCOUNT] = 0; + @$refTotals[$RESULT_SKIPPEDCOUNT] = 0; + @$refTotals[$RESULT_TOTALCOUNT] = 0; + @$refTotals[$RESULT_WARNINGMSGS] = [ () ]; + @$refTotals[$RESULT_DEBUGMSGS] = [ () ]; + @$refTotals[$RESULT_DEPRECATIONMSGS] = [ () ]; + @$refTotals[$RESULT_ALLCASES] = [ () ]; + @$refTotals[$RESULT_SKIPPEDCASES] = [ () ]; + + foreach my $refResults ( @$refAllResults ) + { + @$refTotals[$RESULT_TESTCLASS] = ""; + @$refTotals[$RESULT_TESTCASE] = ""; + @$refTotals[$RESULT_PASSEDCOUNT] += @$refResults[$RESULT_PASSEDCOUNT]; + @$refTotals[$RESULT_FAILEDCOUNT] += @$refResults[$RESULT_FAILEDCOUNT]; + @$refTotals[$RESULT_SKIPPEDCOUNT] += @$refResults[$RESULT_SKIPPEDCOUNT]; + @$refTotals[$RESULT_TOTALCOUNT] += @$refResults[$RESULT_TOTALCOUNT]; + @$refTotals[$RESULT_WARNINGMSGS] = [ ( @{@$refTotals[$RESULT_WARNINGMSGS]}, @{@$refResults[$RESULT_WARNINGMSGS]} ) ]; + @$refTotals[$RESULT_DEBUGMSGS] = [ ( @{@$refTotals[$RESULT_DEBUGMSGS]}, @{@$refResults[$RESULT_DEBUGMSGS]} ) ]; + @$refTotals[$RESULT_DEPRECATIONMSGS] = [ ( @{@$refTotals[$RESULT_DEPRECATIONMSGS]}, @{@$refResults[$RESULT_DEPRECATIONMSGS]} ) ]; + @$refTotals[$RESULT_ALLCASES] = [ ( @{@$refTotals[$RESULT_ALLCASES]}, @{@$refResults[$RESULT_ALLCASES]} ) ]; + @$refTotals[$RESULT_SKIPPEDCASES] = [ ( @{@$refTotals[$RESULT_SKIPPEDCASES]}, @{@$refResults[$RESULT_SKIPPEDCASES]} ) ]; + } +} + + +sub CreateTextReport +{ + my ( $refTotals, $refAllResults ) = @_; + + my $template = +" +Test Results for qvideoplayer + +HW: +SW: + +Test Execution Metrics +Passed: TEMPLATE_PASSED +Failed: TEMPLATE_FAILED +N/A (skipped): TEMPLATE_SKIPPED +Total number of cases: TEMPLATE_TOTAL +Pass rate of total: TEMPLATE_PRT +Pass rate of planned: TEMPLATE_PRP + +Tests +TEMPLATE_TESTLIST + +Warnings: +TEMPLATE_WARNINGS +Debug message count from tests: TEMPLATE_DEBUG_COUNT +Deprecation message count from tests: TEMPLATE_DEPRECATION_COUNT + +Failed test cases: +TEMPLATE_FAILED_CASES + +Passed test cases +TEMPLATE_PASSED_CASES + +"; + + # List of tests. + + my $str = ""; + + my @testResults; + GetTestResults(\@testResults, $refAllResults); + foreach my $refRes( @testResults ) + { + my $testName = @$refRes[0]; + my $testResult = @$refRes[1]; + RemoveWhiteSpaces( \$testName ); + RemoveWhiteSpaces( \$testResult ); + $str .= " $testName $testResult\n" if( $testName ne "" ); + } + + $template =~ s/TEMPLATE_TESTLIST/$str/; + + # Numeric data. + + $template =~ s/TEMPLATE_PASSED/@$refTotals[$RESULT_PASSEDCOUNT]/; + $template =~ s/TEMPLATE_FAILED/@$refTotals[$RESULT_FAILEDCOUNT]/; + $template =~ s/TEMPLATE_SKIPPED/@$refTotals[$RESULT_SKIPPEDCOUNT]/; + $template =~ s/TEMPLATE_TOTAL/@$refTotals[$RESULT_TOTALCOUNT]/; + + # Pass rates. + + my $prt = @$refTotals[$RESULT_PASSEDCOUNT] / @$refTotals[$RESULT_TOTALCOUNT] * 100; + $prt = sprintf( "%.2f", $prt ); + $template =~ s/TEMPLATE_PRT/$prt/; + + my $prp = @$refTotals[$RESULT_PASSEDCOUNT] / ( @$refTotals[$RESULT_PASSEDCOUNT] + @$refTotals[$RESULT_FAILEDCOUNT] ) * 100; + $prp = sprintf( "%.2f", $prp ); + $template =~ s/TEMPLATE_PRP/$prp/; + + # Message counts. + + $str = ""; + foreach my $warning ( @{@$refTotals[$RESULT_WARNINGMSGS]} ) + { + RemoveWhiteSpaces( \$warning ); + $str .= " $warning\n"; + } + $template =~ s/TEMPLATE_WARNINGS/$str/; + + my $count = scalar( @{@$refTotals[$RESULT_DEBUGMSGS]} ); + $template =~ s/TEMPLATE_DEBUG_COUNT/$count/; + + $count = scalar( @{@$refTotals[$RESULT_DEPRECATIONMSGS]} ); + $template =~ s/TEMPLATE_DEPRECATION_COUNT/$count/; + + # Failed cases. + + $str = "\n"; + foreach my $refCase ( @{@$refTotals[$RESULT_ALLCASES]} ) + { + if( @$refCase[$CASE_RESULT] == 0 ) + { + my $case = @$refCase[$CASE_NAME]; + my $refInfoArray = @$refCase[$CASE_INFO]; + if( $case ne "" ) + { + $str .= " $case \n"; + $str .= " Info: \n"; + foreach my $infoLine ( @$refInfoArray ) + { + $str .= " $infoLine \n"; + } + } + $str .= "\n"; + } + } + $str = substr( $str, 0, length( $str ) - 1 ) if( length( $str ) > 1 ); # Remove line break from last line. + $template =~ s/TEMPLATE_FAILED_CASES/$str/; + + # Passed cases. + + $str = "\n"; + foreach my $refCase ( @{@$refTotals[$RESULT_ALLCASES]} ) + { + if( @$refCase[$CASE_RESULT] == 1) + { + my $case = @$refCase[$CASE_NAME]; + $str .= " $case \n"; + } + } + + $str = substr( $str, 0, length( $str ) - 1 ) if( length( $str ) > 1 ); # Remove line break from last line. + $template =~ s/TEMPLATE_PASSED_CASES/$str/; + + # Print to default output and file. + print( $template); + + open(FILE_HANDLE, ">" . "qvptestreport.txt") or die("ERROR! Could not open file '" . "qvptestreport.txt" . "'\n"); + print FILE_HANDLE $template; + close FILE_HANDLE; +} + +sub CreateXmlReport +{ + my ( $refTotals, $refAllResults ) = @_; + + my $data = ""; + my $str = ""; + + my $rows = @$refTotals[$RESULT_TOTALCOUNT] + scalar( @{@$refTotals[$RESULT_WARNINGMSGS]} ) + scalar( @{@$refTotals[$RESULT_DEBUGMSGS]} ) + + scalar( @{@$refTotals[$RESULT_DEPRECATIONMSGS]} ); + + # Excel xml header + + $data = XmlHeader( $rows*2 + 100 ); + + $data .= XmlEmptyRow(); + + # HW and SW + + $str = XmlSwHwRow(); + $str =~ s/REPLACE/INSERT SW HERE/; + $data .= $str; + + $str = XmlSwHwRow(); + $str =~ s/REPLACE/INSERT HW HERE/; + $data .= $str; + + $data .= XmlEmptyRow(); + + # Metrics + + my $passCount = @$refTotals[$RESULT_PASSEDCOUNT]; + my $failCount = @$refTotals[$RESULT_FAILEDCOUNT]; + my $skipCount = @$refTotals[$RESULT_SKIPPEDCOUNT]; + my $totalCount = @$refTotals[$RESULT_TOTALCOUNT]; + + my $passRateTotal = $passCount / $totalCount * 100; + $passRateTotal = sprintf( "%.2f", $passRateTotal ); + + my $passRateRun = $passCount / ( $passCount + $failCount ) * 100; + $passRateRun = sprintf( "%.2f", $passRateRun ); + + my $runRate = ( $passCount + $failCount ) / $totalCount * 100; + $runRate = sprintf( "%.2f", $runRate ); + + $str = XmlMetrics(); + $str =~ s/TOTALCASECOUNT/$totalCount/; + $str =~ s/PASSEDCASECOUNT/$passCount/; + $str =~ s/FAILEDCASECOUNT/$failCount/; + $str =~ s/SKIPPEDCASECOUNT/$skipCount/; + $str =~ s/PASSRATEOFTOTAL/$passRateTotal/; + $str =~ s/PASSRATEOFRUN/$passRateRun/; + $str =~ s/RUNRATE/$runRate/; + $data .= $str; + + $data .= XmlEmptyRow(); + + # List of tests. + + $str = XmlTitleOnBlueRow(); + $str =~ s/THETITLE/Tests/; + $data .= $str; + + my @testResults; + GetTestResults(\@testResults, $refAllResults); + foreach my $refRes( @testResults ) + { + $str = XmlTestNameRow(); + my $testName = @$refRes[0]; + my $testResult = @$refRes[1]; + XmlReadyText( \$testName ); + XmlReadyText( \$testResult ); + RemoveWhiteSpaces( \$testName ); + RemoveWhiteSpaces( \$testResult ); + $str =~ s/TESTNAME/$testName/; + $str =~ s/TESTRESULT/$testResult/; + $data .= $str; + } + + $data .= XmlEmptyRow(); + + # Case list. + + $str = XmlTitleOnBlueRow(); + $str =~ s/THETITLE/Cases/; + $data .= $str; + + my $cleanupTestCaseFound = 0; + my $caseName = ""; + my $caseTestClass = ""; + + foreach my $refCase ( @{@$refTotals[$RESULT_ALLCASES]} ) + { + $caseName = @$refCase[$CASE_NAME]; + + # Write warning if cleanupTestCase is not found for the test. + if( index($caseName, "::") != -1 ) + { + my $tc = substr($caseName, 0, index($caseName, "::")); + if($caseTestClass ne "" && $caseTestClass ne $tc) + { + if(!$cleanupTestCaseFound) + { + $str = XmlTextRowRed(); + $str =~ s/REPLACE/cleanupTestCase was not found! Test did not finish?/; + $data .= $str; + } + $cleanupTestCaseFound = 0; + } + $caseTestClass = $tc; + } + $cleanupTestCaseFound = 1 if($caseName =~ "cleanupTestCase"); + + next if( $caseName eq "" ); + + if( @$refCase[$CASE_RESULT] == 0 ) + { + my $infoStr = ""; + my $refInfoArray = @$refCase[$CASE_INFO]; + foreach my $infoLine ( @$refInfoArray ) + { + $infoStr .= "$infoLine\n"; + } + + $str = XmlFailedCaseRow(); + XmlReadyText( \$caseName ); + $str =~ s/TESTCASENAME/$caseName/; + XmlReadyText( \$infoStr ); + $str =~ s/FAILREASON/$infoStr/; + $data .= $str; + } + elsif( @$refCase[$CASE_RESULT] == 1 ) + { + $str = XmlPassedCaseRow(); + XmlReadyText( \$caseName ); + $str =~ s/TESTCASENAME/$caseName/; + $data .= $str; + } + } + + $data .= XmlEmptyRow(); + + # Warning messages + + $str = XmlTitleOnBlueRow(); + $str =~ s/THETITLE/Warning messages/; + $data .= $str; + + foreach my $warning ( @{@$refTotals[$RESULT_WARNINGMSGS]} ) + { + RemoveWhiteSpaces( \$warning ); + XmlReadyText( \$warning ); + $str = XmlMessageRow(); + $str =~ s/MESSAGE/$warning/; + $data .= $str; + } + + $data .= XmlEmptyRow(); + + # Message counts. + + my $msgCountStr = "Debug message count: " . scalar( @{@$refTotals[$RESULT_DEBUGMSGS]} ); + $str = XmlMessageRow(); + $str =~ s/MESSAGE/$msgCountStr/; + $data .= $str; + + $msgCountStr = "Deprecation message count: " . scalar( @{@$refTotals[$RESULT_DEPRECATIONMSGS]} ); + $str = XmlMessageRow(); + $str =~ s/MESSAGE/$msgCountStr/; + $data .= $str; + + for( my $i = 0; $i < 20; $i++ ) + { + $data .= XmlEmptyRow(); + } + + # Excel xml footer. + $data .= XmlFooter(); + + open(FILE_HANDLE, ">" . "qvptestreport.xml") or die("ERROR! Could not open file '" . "qvptestreport.xml" . "'\n"); + print FILE_HANDLE $data; + close FILE_HANDLE; +} + +sub GetTestResults +{ + my ($refResults, $refAllResults) = @_; + + # Read tests and results from file. + open(TRFH, "qvptestresults.txt") or return ""; + my @lines = ; + close(TRFH); + + foreach my $line( @lines ) + { + my @res = split(/\t/, $line); + RemoveWhiteSpaces(\$res[0]); + RemoveWhiteSpaces(\$res[1]); + + # Check if there's already result for the test. + my $found = 0; + foreach my $refRes ( @$refResults ) + { + if(@$refRes[0] eq $res[0] ) + { + # Update test result. + @$refRes[1] .= " " . $res[1]; + $found = 1; + last; + } + } + + # Test not found, add new. + if( !$found ) + { + push @$refResults, [ @res ]; + } + } + + # And add those tests that were not in the result file. + + foreach my $refResult ( @$refAllResults ) + { + my $testName = @$refResult[$RESULT_TESTCLASS]; + + my $found = 0; + foreach my $refRes ( @$refResults ) + { + if(@$refRes[0] eq $testName ) + { + $found = 1; + last; + } + } + + if(!$found) + { + push @$refResults, [ ($testName, "" ) ]; + } + } +} + +sub FindFiles +{ + my ($godir, $fileSearch, $searchType, $refIncfiles) = @_; + + my $startDir = cwd; + + chdir($godir) or return; + + #print("Now in: " . cwd . "\n"); + + opendir(DIR, "."); + my @filelist = sort(readdir(DIR)); + closedir(DIR); + + foreach my $file(@filelist) + { + if($file eq "." or $file eq "..") {next}; + + if (-d $file) + { + FindFiles( $file, $fileSearch, $searchType, $refIncfiles); + } else + { + if( ($file =~ m/$fileSearch/i and $searchType == 0 ) or ($file =~ m/$fileSearch$/i and $searchType == 1 ) ) + { + $file = cwd . "/" . $file; + push @$refIncfiles, $file; + #print("$file\n"); + } + } + } + + chdir ($startDir); +} + + +sub GetCgiDir + { + # Solve where the script is located. + $0=~/^(.+[\\\/])[^\\\/]+[\\\/]*$/; + my $cgidir= $1 || "./"; + + # And try to solve relative path. + if( index( $cgidir, "..\\" ) != -1 ) + { + my $p = cwd; + $p =~ s/\//\\/g; + $cgidir =~ s/\//\\/g; + while(1) + { + my $pos = index( $cgidir, "..\\" ); + last if( $pos == -1 ); + $cgidir = substr( $cgidir, $pos+3 ); + + $pos = rindex( $p, "\\" ); + last if( $pos == -1 ); + $p = substr( $p, 0, $pos); + } + $cgidir = $p . "\\" . $cgidir; + } + return $cgidir; +} + +sub GetPathFileName +{ + my ($str) = @_; + + my $startPos = rindex($str, "\\"); + if($startPos == -1) + { + $startPos = rindex($str, "/"); + return $str if($startPos == -1); + } + + my $filename = substr($str, $startPos+1); + + return $filename; +} + +sub GetPathDir +{ + my ($str) = @_; + + my $endPos = rindex($str, "\\"); + if($endPos == -1) + { + $endPos = rindex($str, "/"); + return $str if($endPos == -1); + } + + my $filename = substr($str, 0, $endPos); + + return $filename; +} + +sub RemoveWhiteSpaces +{ + my ($text) = @_; + ${$text} =~ s/\s+$//; #whitespaces in the end + ${$text} =~ s/^\s+//; #whitespaces at the start +} + +sub XmlReadyText +{ + my ($text) = @_; + + my $txtlt = "<"; + my $txtgt = ">"; + ${$text} =~ s//$txtgt/g; + + ${$text} =~ s/Ä/Ä/g; + ${$text} =~ s/ä/ä/g; + ${$text} =~ s/Ö/Ö/g; + ${$text} =~ s/ö/ö/g; + + #ä ä + +# Ö Ö + +# ö ö +} + +sub XmlHeader +{ + my ( $rowCount ) = @_; + my $str = +"\n" . +"\n" . +"\n" . +" \n" . +" Senbom Petri\n" . +" Senbom Petri\n" . +" 2006-06-09T11:08:05Z\n" . +" Nokia Oyj\n" . +" 11.9999\n" . +" \n" . +" \n" . +" 12210\n" . +" 18780\n" . +" 360\n" . +" 255\n" . +" False\n" . +" False\n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n"; + + $str =~ s/EXCELEXPANDEDROWCOUNT/$rowCount/; + return $str; +}; + +sub XmlFooter +{ + return +"
\n" . +" \n" . +" \n" . +" \n" . +" 9\n" . +" 600\n" . +" 600\n" . +" \n" . +" \n" . +" \n" . +" \n" . +" 3\n" . +" 1\n" . +" R2C1:R2C14\n" . +" \n" . +" \n" . +" False\n" . +" False\n" . +" \n" . +"
\n" . +"
\n"; +} + +sub XmlEmptyRow +{ + return +" \n" . +" \n" . +" \n"; +} + +sub XmlSwHwRow +{ + return +" \n" . +" REPLACE\n" . +" \n"; +} + +sub XmlMetrics +{ + return +" \n" . +" Test Execution Metrics\n" . +" \n" . +" \n" . +" \n" . +" Total cases\n" . +" TOTALCASECOUNT\n" . +" \n" . +" \n" . +" \n" . +" Passed\n" . +" PASSEDCASECOUNT\n" . +" \n" . +" \n" . +" \n" . +" Failed\n" . +" FAILEDCASECOUNT\n" . +" \n" . +" \n" . +" \n" . +" Skipped\n" . +" SKIPPEDCASECOUNT\n" . +" \n" . +" \n" . +" \n" . +" Pass rate % (total cases)\n" . +" PASSRATEOFTOTAL\n" . +" \n" . +" \n" . +" \n" . +" Pass rate % (run cases)\n" . +" PASSRATEOFRUN\n" . +" \n" . +" \n" . +" \n" . +" Run rate %\n" . +" RUNRATE\n" . +" \n" . +" \n"; +} + +sub XmlTitleOnBlueRow +{ + return +" \n" . +" THETITLE\n" . +" \n" . +" \n"; +} + +sub XmlTestNameRow +{ + return +" \n" . +" TESTNAME\n" . +" TESTRESULT\n" . +" \n" . +" \n"; +} + +sub XmlMessageRow +{ + return +" \n" . +" MESSAGE\n" . +" \n" . +" \n"; +} + +sub XmlPassedCaseRow +{ + return +" \n" . +" PASSED\n" . +" TESTCASENAME\n" . +" \n" . +" \n"; +} + +sub XmlFailedCaseRow +{ + return +" \n" . +" FAILED\n" . +" TESTCASENAME\n" . +" FAILREASON\n" . +" \n" . +" \n" . +" \n" . +" \n" . +" \n"; +} + +sub XmlTextRowRed +{ + return +" \n" . +" \n" . +" REPLACE\n" . +" \n" . +" \n"; +} + +sub XmlTextRowRedx +{ + return +" \n" . +" REPLACE\n" . +" \n"; +} diff -r ed94e1e8390e -r 3cd404d31176 tsrc/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/readme.txt Mon Oct 04 00:14:19 2010 +0300 @@ -0,0 +1,8 @@ +Script taken from videoplayer. Thanks. :) + +qvptestresultgen.pl +---------------------------------------------------------------------- +Creates report from the Qt test results. Copy the test result files +from device c:\data or emulator \epoc32\winscw\c\data to same folder with +the script and run it. +