--- a/mpengine/src/mpmpxcollectionframeworkwrapper_p.cpp Tue Jul 06 14:13:36 2010 +0300
+++ b/mpengine/src/mpmpxcollectionframeworkwrapper_p.cpp Wed Aug 18 09:46:20 2010 +0300
@@ -16,6 +16,11 @@
*/
#include <QStringList>
+#include <QRegExp>
+#include <QFileInfo>
+#include <QDateTime>
+#include <QTime>
+#include <QDate>
#include <s32strm.h>
#include <s32mem.h>
@@ -32,6 +37,8 @@
#include <mpxmediacollectiondetaildefs.h>
#include <mpxmediamusicdefs.h>
#include <mpxmediageneraldefs.h>
+#include <mpxmediaaudiodefs.h>
+#include <mpxmediadrmdefs.h>
#include <mpxcollectionplugin.hrh>
#include <mpxmessagegeneraldefs.h>
#include <mpxmediacontainerdefs.h>
@@ -50,10 +57,11 @@
#include "mpcommondefs.h"
#include "mptrace.h"
#include "mpsettingsmanager.h"
+#include "mpsongdata.h"
const TInt KIncrementalDelayNone = 0;
-const TInt KIncrementalDelayHalfSecond = 1000000;
-const TInt KIncrementalFetchBlockSize = 40;
+const TInt KIncrementalDelayHalfSecond = 500000;
+const TInt KIncrementalFetchBlockSize = 400;
const TInt KMPXChunkSize = 100; // number of songs added in each chunk, IncAddL
_LIT( KPlaylistPath, "C:\\Data\\Playlists\\" ); // Todo
@@ -84,7 +92,8 @@
iReopen( EFalse ),
iShuffleAll( EFalse ),
iRestoreDefaultPath( EFalse ),
- iRestorePathIndex(0)
+ iRestorePathIndex( 0 ),
+ iSongData( 0 )
{
TX_LOG
}
@@ -121,14 +130,16 @@
/*!
\internal
*/
-void MpMpxCollectionFrameworkWrapperPrivate::init( TUid hostUid )
+void MpMpxCollectionFrameworkWrapperPrivate::init( TUid hostUid, MpSongData *songData )
{
-
- mHostUid = hostUid;
+ TX_ENTRY
+ iHostUid = hostUid;
+ iSongData = songData;
TRAPD( err, DoInitL() );
if ( err != KErrNone ) {
TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
+ TX_EXIT
}
/*!
@@ -385,6 +396,19 @@
/*!
\internal
*/
+void MpMpxCollectionFrameworkWrapperPrivate::retrieveSongDetails( int index )
+{
+ TX_ENTRY
+ TRAPD( err, DoRetrieveSongDetailsL(index) );
+ if ( err != KErrNone ) {
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+ }
+ TX_EXIT
+}
+
+/*!
+ \internal
+ */
void MpMpxCollectionFrameworkWrapperPrivate::savePath( QByteArray &data )
{
TX_ENTRY
@@ -485,8 +509,14 @@
const CMPXMedia& aMedia,
TInt aError )
{
- Q_UNUSED( aMedia );
- Q_UNUSED( aError );
+ TX_ENTRY
+ if ( KErrNone != aError ){
+ TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
+ TX_EXIT
+ return;
+ }
+ iSongData->setMpxMedia( aMedia );
+ TX_EXIT
}
/*!
@@ -629,9 +659,9 @@
void MpMpxCollectionFrameworkWrapperPrivate::DoInitL()
{
TX_ENTRY
- iCollectionUtility = MMPXCollectionUtility::NewL( this, mHostUid );
- iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL( mHostUid );
- iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, mHostUid );
+ iCollectionUtility = MMPXCollectionUtility::NewL( this, iHostUid );
+ iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL( iHostUid );
+ iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, iHostUid );
iCollectionData = new MpMpxCollectionData();
TX_EXIT
}
@@ -721,7 +751,7 @@
TArray<TMPXAttribute> ary = attrs.Array();
iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
iIncrementalOpenUtil->StartL( ary, KIncrementalFetchBlockSize,
- KErrNotFound, CMPXCollectionOpenUtility::EFetchNormal );
+ KErrNotFound, CMPXCollectionOpenUtility::EFetchDown );
iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
CleanupStack::PopAndDestroy( &attrs );
TX_EXIT
@@ -762,8 +792,8 @@
RArray<TMPXAttribute> attrs;
CleanupClosePushL( attrs );
- attrs.Append( KMPXMediaGeneralId );
- attrs.Append( KMPXMediaGeneralTitle );
+ attrs.AppendL( KMPXMediaGeneralId );
+ attrs.AppendL( KMPXMediaGeneralTitle );
CMPXMedia* criteria = CMPXMedia::NewL();
CleanupStack::PushL( criteria );
@@ -1031,7 +1061,7 @@
TX_ENTRY
//TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper.
if ( !iPlaybackUtility ) {
- iPlaybackUtility = MMPXPlaybackUtility::UtilityL( mHostUid );
+ iPlaybackUtility = MMPXPlaybackUtility::UtilityL( iHostUid );
}
// Get the current path
@@ -1100,23 +1130,28 @@
const CMPXMediaArray* mediaArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents );
CMPXMedia* album( mediaArray->AtL( index ) );
- // Fetch the songs for the selected album
+ // Obtain the artistId from the container
+ TMPXItemId artistId = container.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+
+ // Fetch the songs for the selected album and the artist
+ // Specifying artistId is necessary to search for songs in the artist’s unknown album.
TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
CMPXMedia* findCriteria = CMPXMedia::NewL();
CleanupStack::PushL( findCriteria );
findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );
findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong );
findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, albumId );
+ findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralContainerId, artistId );
RArray<TMPXAttribute> attrs;
CleanupClosePushL( attrs );
- attrs.Append( TMPXAttribute( KMPXMediaIdGeneral,
+ attrs.AppendL( TMPXAttribute( KMPXMediaIdGeneral,
EMPXMediaGeneralTitle |
EMPXMediaGeneralUri |
EMPXMediaGeneralId |
EMPXMediaGeneralType |
EMPXMediaGeneralCategory |
EMPXMediaGeneralFlags ) );
- attrs.Append( KMPXMediaMusicAlbumTrack );
+ attrs.AppendL( KMPXMediaMusicAlbumTrack );
iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array(), *this );
CleanupStack::PopAndDestroy( &attrs );
@@ -1238,8 +1273,12 @@
}
}
else if( id == KMPXMessageIdItemChanged ) {
- emit q_ptr->containerContentsChanged();
- }
+ TInt eventType( aMsg.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
+
+ if ( eventType == EMPXItemDeleted || eventType == EMPXItemInserted ) {
+ emit q_ptr->containerContentsChanged();
+ }
+ }
TX_EXIT
}
@@ -1301,7 +1340,7 @@
findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, containerId );
RArray<TMPXAttribute> attrs;
CleanupClosePushL( attrs );
- attrs.Append( TMPXAttribute( KMPXMediaIdGeneral,
+ attrs.AppendL( TMPXAttribute( KMPXMediaIdGeneral,
EMPXMediaGeneralTitle |
EMPXMediaGeneralId ) );
results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array() );
@@ -1365,7 +1404,7 @@
{
if ( !iPlaybackUtility ) {
- iPlaybackUtility = MMPXPlaybackUtility::UtilityL( mHostUid );
+ iPlaybackUtility = MMPXPlaybackUtility::UtilityL( iHostUid );
if ( iShuffleFeature ) {
iPlaybackUtility->SetL( EPbPropertyRandomMode, MpSettingsManager::shuffle() ? ETrue : EFalse );
@@ -1398,6 +1437,59 @@
/*!
\internal
*/
+void MpMpxCollectionFrameworkWrapperPrivate::DoRetrieveSongDetailsL( int index )
+{
+ TX_ENTRY
+ RArray<TMPXAttribute> requestedAttr;
+ CleanupClosePushL( requestedAttr );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralTitle ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicArtist ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbum ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralUri ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralMimeType ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumTrack ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicComposer ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicYear ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicGenre ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralDuration ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaAudioBitrate ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaAudioSamplerate ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralCopyright ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicURL ) );
+ requestedAttr.AppendL( TMPXAttribute( KMPXMediaDrmProtected ) );
+
+ CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
+ CleanupStack::PushL( cpath );
+ TCollectionContext context = iCollectionData->context();
+ if ( context == ECollectionContextArtistAlbumsTBone
+ || context == ECollectionContextAlbumsTBone ) {
+ CMPXMediaArray *mediaArray;
+ const CMPXMedia& container = iCollectionData->containerMedia();
+ mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+ int currentAlbumIndex = iCollectionData->currentAlbumIndex();
+ CMPXMedia* album( mediaArray->AtL( currentAlbumIndex ) );
+ if ( album->IsSupported(KMPXMediaArrayContents) ) {
+ const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+ User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs));
+ CMPXMedia* song = songs->AtL(index);
+ TMPXItemId id( song->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+ cpath->AppendL( id ); // Top level items of songs
+ cpath->Set( 0 ); // Select 1st song
+ }
+ }
+ else {
+ cpath->Set( index );
+ }
+ iCollectionUtility->Collection().MediaL( *cpath, requestedAttr.Array() );
+ CleanupStack::PopAndDestroy( cpath );
+ CleanupStack::PopAndDestroy( &requestedAttr );
+ TX_EXIT
+}
+
+/*!
+ \internal
+ */
void MpMpxCollectionFrameworkWrapperPrivate::DoSavePathL( QByteArray &data )
{
TX_ENTRY