--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper_p.cpp Fri Mar 19 09:28:13 2010 +0200
+++ b/mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper_p.cpp Fri Apr 16 14:56:30 2010 +0300
@@ -69,15 +69,16 @@
\internal
*/
MpMpxFrameworkWrapperPrivate::MpMpxFrameworkWrapperPrivate( MpMpxFrameworkWrapper *wrapper )
- : q_ptr(wrapper),
- iCollectionUtility(0),
- iCollectionUiHelper(0),
- iIncrementalOpenUtil(0),
- iPlaybackUtility(0),
- iHarvesterUtility(0),
- iCollectionData(0),
- iFirstIncrementalOpen(EFalse),
- iUserPlaylists(0)
+ : q_ptr( wrapper ),
+ iCollectionUtility( 0 ),
+ iCollectionUiHelper( 0 ),
+ iIncrementalOpenUtil( 0 ),
+ iIsolatedCollectionHelper( 0 ),
+ iPlaybackUtility( 0 ),
+ iCollectionData( 0 ),
+ iIsolatedCollectionData( 0 ),
+ iFirstIncrementalOpen( EFalse ),
+ iUserPlaylists( 0 )
{
TX_LOG
}
@@ -89,6 +90,7 @@
{
TX_ENTRY
delete iCollectionData;
+ delete iIsolatedCollectionData;
if ( iCollectionUtility ) {
iCollectionUtility->Collection().CancelRequest();
@@ -99,15 +101,12 @@
iCollectionUiHelper->Close();
}
- if ( iPlaybackUtility ) {
+ if ( iPlaybackUtility ) {
iPlaybackUtility->Close();
}
- if ( iHarvesterUtility ) {
- iHarvesterUtility->Close();
- }
-
delete iIncrementalOpenUtil;
+ delete iIsolatedCollectionHelper;
delete iUserPlaylists;
TX_EXIT
@@ -120,9 +119,9 @@
{
iViewMode = viewMode;
- TRAPD(err, DoInitL());
+ TRAPD( err, DoInitL() );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -131,9 +130,9 @@
*/
void MpMpxFrameworkWrapperPrivate::openCollection( TCollectionContext context )
{
- TRAPD(err, DoOpenCollectionL(context));
+ TRAPD( err, DoOpenCollectionL( context ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -142,9 +141,9 @@
*/
void MpMpxFrameworkWrapperPrivate::openCollectionItem( int index )
{
- TRAPD(err, DoOpenCollectionItemL(index));
+ TRAPD( err, DoOpenCollectionItemL( index ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -153,9 +152,9 @@
*/
void MpMpxFrameworkWrapperPrivate::reopenCollection()
{
- TRAPD(err, DoReopenCollectionL());
+ TRAPD( err, DoReopenCollectionL() );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -164,9 +163,9 @@
*/
void MpMpxFrameworkWrapperPrivate::back()
{
- TRAPD(err, DoBackL());
+ TRAPD( err, DoBackL() );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
@@ -174,64 +173,75 @@
*/
void MpMpxFrameworkWrapperPrivate::findPlaylists( QStringList &playlists )
{
- TRAPD(err, DoFindPlaylistsL(playlists));
+ TRAPD( err, DoFindPlaylistsL( playlists ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::createPlaylist( QString playlistName, QList<int> selection )
+void MpMpxFrameworkWrapperPrivate::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
{
- TRAPD(err, DoCreatePlaylistL(playlistName, selection));
+ TRAPD( err, DoCreatePlaylistL( playlistName, selection, collectionData ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+ }
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::saveToPlaylist( int playlistIndex, QList<int> &selection )
+{
+ TRAPD( err, DoSaveToPlaylistL( playlistIndex, selection ) );
+ if ( err != KErrNone ) {
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::saveToPlaylist( int playlistIndex, QList<int> selection )
+void MpMpxFrameworkWrapperPrivate::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
{
- TRAPD(err, DoSaveToPlaylistL(playlistIndex, selection));
+ TRAPD( err, DoSaveToCurrentPlaylistL( selection, collectionData ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+ }
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::deleteSongs( QList<int> &selection )
+{
+ TRAPD( err, DoDeleteSongsL( selection ) );
+ if ( err != KErrNone ) {
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::deleteSongs( QList<int> selection )
-{
- TRAPD(err, DoDeleteSongsL(selection));
+void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString &newName, int index )
+{
+ TRAPD( err, DoRenamePlaylistL( newName, index ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString newName, int index )
+void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString &newName )
{
- TRAPD(err, DoRenamePlaylistL(newName, index));
+ TRAPD( err, DoRenamePlaylistL( newName ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
- }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString newName )
-{
- TRAPD(err, DoRenamePlaylistL(newName));
- if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
/*!
@@ -239,31 +249,9 @@
*/
void MpMpxFrameworkWrapperPrivate::setShuffle( bool active )
{
- TRAPD(err, DoSetShuffleL(active));
- if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
- }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::scan()
-{
- TRAPD(err, DoScanL());
+ TRAPD( err, DoSetShuffleL( active ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
- }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::cancelScan()
-{
- TRAPD(err, DoCancelScanL());
- if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -272,9 +260,42 @@
*/
void MpMpxFrameworkWrapperPrivate::previewItem( int index )
{
- TRAPD(err, DoPreviewItemL(index));
+ TRAPD( err, DoPreviewItemL( index ) );
+ if ( err != KErrNone ) {
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+ }
+}
+
+/*!
+ \internal
+ */
+ void MpMpxFrameworkWrapperPrivate::openIsolatedCollection( TCollectionContext context )
+{
+ TRAPD( err, DoOpenIsolatedCollectionL( context ) );
if ( err != KErrNone ) {
- TX_LOG_ARGS("Error: " << err << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+ }
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::releaseIsolatedCollection()
+{
+ delete iIsolatedCollectionHelper;
+ iIsolatedCollectionHelper = 0;
+ delete iIsolatedCollectionData;
+ iIsolatedCollectionData = 0;
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+ TRAPD( err, DoReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal ) );
+ if ( err != KErrNone ) {
+ TX_LOG_ARGS( "Error: " << err << "; should never get here." );
}
}
@@ -289,23 +310,23 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::HandleOpenL(
+void MpMpxFrameworkWrapperPrivate::HandleOpenL(
const CMPXMedia& aEntries,
TInt aIndex,
TBool aComplete,
TInt aError )
{
- Q_UNUSED(aIndex);
- TX_UNUSED(aComplete);
- TX_ENTRY_ARGS("aError=" << aError << "aComplete=" << aComplete);
+ Q_UNUSED( aIndex );
+ TX_UNUSED( aComplete );
+ TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete );
if ( aError == KErrNone ) {
if ( iFirstIncrementalOpen ) {
- iCollectionData->setMpxMedia(aEntries);
+ iCollectionData->setMpxMedia( aEntries );
iFirstIncrementalOpen = EFalse;
}
}
else {
- TX_LOG_ARGS("Error: " << aError << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
}
TX_EXIT
}
@@ -313,25 +334,25 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::HandleOpenL(
+void MpMpxFrameworkWrapperPrivate::HandleOpenL(
const CMPXCollectionPlaylist& aPlaylist,
TInt aError )
{
- TX_ENTRY_ARGS("aError=" << aError);
+ TX_ENTRY_ARGS( "aError=" << aError );
if ( aError == KErrNone ) {
if ( !iPlaybackUtility ) {
- iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
+ iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) );
if ( iViewMode == MpCommon::DefaultView ) {
iPlaybackUtility->SetL( EPbPropertyRandomMode, MpSettingsManager::shuffle() ? ETrue : EFalse );
- iPlaybackUtility->SetL( EPbPropertyRepeatMode, MpSettingsManager::repeat() ? EPbRepeatAll : EPbRepeatOff);
+ iPlaybackUtility->SetL( EPbPropertyRepeatMode, MpSettingsManager::repeat() ? EPbRepeatAll : EPbRepeatOff );
}
}
iPlaybackUtility->InitL( aPlaylist, ETrue );
emit q_ptr->collectionPlaylistOpened();
}
else {
- TX_LOG_ARGS("Error: " << aError << "; should never get here.");
+ TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
}
TX_EXIT
}
@@ -339,11 +360,11 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMessage(
+void MpMpxFrameworkWrapperPrivate::HandleCollectionMessage(
CMPXMessage* aMsg,
TInt aErr )
{
- TX_ENTRY_ARGS("aErr=" << aErr);
+ TX_ENTRY_ARGS( "aErr=" << aErr );
if ( aErr == KErrNone && aMsg )
{
TRAP_IGNORE( DoHandleCollectionMessageL( *aMsg ) );
@@ -354,48 +375,33 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMediaL(
+void MpMpxFrameworkWrapperPrivate::HandleCollectionMediaL(
const CMPXMedia& aMedia,
TInt aError )
{
- Q_UNUSED(aMedia);
- Q_UNUSED(aError);
+ Q_UNUSED( aMedia );
+ Q_UNUSED( aError );
}
/*!
\internal
Handles the completion of any collection helper event.
*/
-void MpMpxFrameworkWrapperPrivate::HandleOperationCompleteL(
+void MpMpxFrameworkWrapperPrivate::HandleOperationCompleteL(
TCHelperOperation aOperation,
TInt aErr,
void* aArgument )
{
- TX_ENTRY_ARGS("aErr=" << aErr);
+ TX_ENTRY_ARGS( "aErr=" << aErr );
switch( aOperation ) {
case EDeleteOp:
- if ( KErrNone == aErr ) {
- emit q_ptr->songsDeleted(true);
- }
- else {
- emit q_ptr->songsDeleted(false);
- }
+ emit q_ptr->songsDeleted( KErrNone == aErr );
break;
case EAddOp:
- if ( KErrNone == aErr ) {
- emit q_ptr->playlistSaved(true);
- }
- else {
- emit q_ptr->playlistSaved(false);
- }
+ emit q_ptr->playlistSaved( KErrNone == aErr );
break;
case ERenameOp:
- if ( KErrNone == aErr ) {
- emit q_ptr->playlistsRenamed(true);
- }
- else {
- emit q_ptr->playlistsRenamed(false);
- }
+ emit q_ptr->playlistsRenamed( KErrNone == aErr );
break;
default:
break;
@@ -409,6 +415,27 @@
/*!
\internal
*/
+void MpMpxFrameworkWrapperPrivate::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
+{
+ TX_ENTRY_ARGS( "aError=" << aError );
+ if ( aError == KErrNone ) {
+ if ( iIsolatedCollectionData ) {
+ delete iIsolatedCollectionData;
+ iIsolatedCollectionData = 0;
+ }
+ iIsolatedCollectionData = new MpMpxCollectionData();
+ iIsolatedCollectionData->setMpxMedia( aEntries );
+ emit q_ptr->isolatedCollectionOpened( iIsolatedCollectionData );
+ }
+ else {
+ TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
+ }
+ TX_EXIT
+}
+
+/*!
+ \internal
+ */
void MpMpxFrameworkWrapperPrivate::DoInitL()
{
TX_ENTRY
@@ -416,9 +443,6 @@
iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL();
iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this );
- iHarvesterUtility = CMPXHarvesterFactory::NewL();
- iHarvesterUtility->CheckForSystemEventsL();
-
iCollectionData = new MpMpxCollectionData();
TX_EXIT
}
@@ -426,10 +450,10 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoOpenCollectionL(
+void MpMpxFrameworkWrapperPrivate::DoOpenCollectionL(
TCollectionContext aContext )
{
- TX_ENTRY_ARGS("aContext=" << aContext);
+ TX_ENTRY_ARGS( "aContext=" << aContext );
switch ( aContext ) {
case ECollectionContextAllSongs:
@@ -440,7 +464,7 @@
CleanupStack::PopAndDestroy( cpath );
break;
}
- case ECollectionContextArtistAlbums:
+ case ECollectionContextAlbums:
{
CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
CleanupStack::PushL( cpath );
@@ -468,7 +492,7 @@
break;
}
default:
- TX_LOG_ARGS("Error: Unexpected context; should never get here.");
+ TX_LOG_ARGS( "Error: Unexpected context; should never get here." );
break;
}
TX_EXIT
@@ -479,7 +503,7 @@
*/
void MpMpxFrameworkWrapperPrivate::DoOpenCollectionItemL( TInt aIndex )
{
- TX_ENTRY_ARGS("aIndex=" << aIndex);
+ TX_ENTRY_ARGS( "aIndex=" << aIndex );
iCollectionUtility->Collection().OpenL( aIndex );
TX_EXIT
}
@@ -515,7 +539,7 @@
CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
CleanupStack::PushL( cpath );
cpath->Back();
- iCollectionUtility->Collection().OpenL(*cpath);
+ iCollectionUtility->Collection().OpenL( *cpath );
CleanupStack::PopAndDestroy( cpath );
TX_EXIT
}
@@ -546,15 +570,15 @@
CMPXMedia* criteria = CMPXMedia::NewL();
CleanupStack::PushL( criteria );
- criteria->SetTObjectValueL<TMPXGeneralType>(
+ criteria->SetTObjectValueL<TMPXGeneralType>(
KMPXMediaGeneralType, EMPXGroup );
- criteria->SetTObjectValueL<TMPXGeneralCategory>(
+ criteria->SetTObjectValueL<TMPXGeneralCategory>(
KMPXMediaGeneralCategory, EMPXPlaylist );
// Look up collection UID and set to criteria
RArray<TUid> ary;
CleanupClosePushL( ary );
- ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) );
+ ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
CleanupStack::PopAndDestroy( &ary );
@@ -567,10 +591,10 @@
if ( iUserPlaylists ) {
const CMPXMediaArray* mediaArray =
iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
- User::LeaveIfNull(const_cast<CMPXMediaArray*>(mediaArray));
+ User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
TInt count = mediaArray->Count();
for ( TInt i = 0; i < count; i++ ) {
- CMPXMedia* media( mediaArray->AtL(i) );
+ CMPXMedia* media( mediaArray->AtL( i ) );
const TDesC& titleText = media->ValueText( KMPXMediaGeneralTitle );
if ( titleText.Compare( KNullDesC ) != 0 ) {
playlists += QString::fromUtf16( titleText.Ptr(), titleText.Length() );
@@ -583,104 +607,139 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoCreatePlaylistL( QString playlistName, QList<int> selection )
+void MpMpxFrameworkWrapperPrivate::DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
{
- TX_ENTRY_ARGS("playlistName=" << playlistName);
+ TX_ENTRY_ARGS( "playlistName=" << playlistName );
CMPXMedia* tracks = CMPXMedia::NewL();
CleanupStack::PushL( tracks );
- TPtrC ptr(reinterpret_cast<const TText*>(playlistName.constData()));
+ TPtrC ptr( reinterpret_cast<const TText*>( playlistName.constData() ) );
tracks->SetTextValueL( KMPXMediaGeneralTitle, ptr );
tracks->SetTextValueL( KMPXMediaGeneralUri, KPlaylistPath );
- PreparePlaylistMediaL(*tracks, selection);
+ //if collection data is not provided we use the browsing collection.
+ PreparePlaylistMediaL( *tracks, selection, collectionData ? collectionData : iCollectionData );
iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
CleanupStack::PopAndDestroy( tracks );
+ TX_EXIT
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoSaveToPlaylistL( int playlistIndex, QList<int> selection )
+void MpMpxFrameworkWrapperPrivate::DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData )
{
- TX_ENTRY_ARGS("playlistIndex=" << playlistIndex);
+ TX_ENTRY_ARGS( "playlistId=" << int( playlistId ) );
+
CMPXMedia* tracks = CMPXMedia::NewL();
CleanupStack::PushL( tracks );
- const CMPXMediaArray* mediaArray =
- iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
- User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ));
- CMPXMedia* media( mediaArray->AtL(playlistIndex) );
- TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-
RArray<TUid> ary;
CleanupClosePushL( ary );
- ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) );
+ ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
CleanupStack::PopAndDestroy( &ary );
tracks->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, playlistId );
tracks->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection );
- PreparePlaylistMediaL(*tracks, selection);
+ PreparePlaylistMediaL( *tracks, selection, collectionData );
iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
CleanupStack::PopAndDestroy( tracks );
+ TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::DoSaveToPlaylistL( int playlistIndex, QList<int> &selection )
+{
+ TX_ENTRY_ARGS( "playlistIndex=" << playlistIndex );
+
+ const CMPXMediaArray* mediaArray = iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+ User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
+ CMPXMedia* media( mediaArray->AtL( playlistIndex ) );
+ TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
+ DoSaveToPlaylistL( playlistId, selection, iCollectionData );
+ TX_EXIT
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoDeleteSongsL( QList<int> selection )
+void MpMpxFrameworkWrapperPrivate::DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+ TX_ENTRY
+
+ const CMPXMedia& container = iCollectionData->containerMedia();
+ if ( container.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) != EMPXItem &&
+ container.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) != EMPXPlaylist) {
+ User::Leave( KErrArgument );
+ }
+ TMPXItemId playlistId( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+ DoSaveToPlaylistL( playlistId, selection, collectionData );
+ TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::DoDeleteSongsL( QList<int> &selection )
{
int count = selection.count();
- TX_ENTRY_ARGS("selection count=" << count);
+ TX_ENTRY_ARGS( "selection count=" << count );
CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() );
CleanupStack::PushL( path );
for ( TInt i = 0; i < count; i++ ) {
- path->SelectL( selection.at(i) );
+ path->SelectL( selection.at( i ) );
}
iCollectionUiHelper->DeleteL( *path, this );
CleanupStack::PopAndDestroy( path );
+ TX_EXIT
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString newName, int index)
+void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName, int index )
{
+ TX_ENTRY
CMPXMediaArray *mediaArray;
const CMPXMedia& container = iCollectionData->containerMedia();
- mediaArray = const_cast<CMPXMediaArray*>(container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+ mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
CMPXMedia* currentPlaylistMedia( mediaArray->AtL( index ) );
TMPXItemId id( currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
DoRenamePlaylistL( id, newName );
+ TX_EXIT
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString newName )
+void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName )
{
+ TX_ENTRY
const CMPXMedia& container = iCollectionData->containerMedia();
TMPXItemId id( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
DoRenamePlaylistL( id, newName );
+ TX_EXIT
}
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( TMPXItemId id, QString newName )
+void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( TMPXItemId id, QString &newName )
{
CMPXMedia* media = CMPXMedia::NewL();
CleanupStack::PushL( media );
- media->SetTObjectValueL<TMPXGeneralType>(
+ media->SetTObjectValueL<TMPXGeneralType>(
KMPXMediaGeneralType, EMPXItem );
- media->SetTObjectValueL<TMPXGeneralCategory>(
+ media->SetTObjectValueL<TMPXGeneralCategory>(
KMPXMediaGeneralCategory, EMPXPlaylist );
media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
- TPtrC ptr(reinterpret_cast<const TText*>(newName.constData()));
+ TPtrC ptr( reinterpret_cast<const TText*>( newName.constData() ) );
media->SetTextValueL( KMPXMediaGeneralTitle, ptr );
iCollectionUiHelper->RenameL( *media, this );
CleanupStack::PopAndDestroy( media );
@@ -692,7 +751,6 @@
void MpMpxFrameworkWrapperPrivate::DoSetShuffleL( bool active )
{
TX_ENTRY
-
if ( iPlaybackUtility ) {
iPlaybackUtility->SetL( EPbPropertyRandomMode, active );
}
@@ -702,55 +760,27 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoScanL()
-{
- TX_ENTRY
- iNumItemsAdded = 0;
- iHarvesterUtility->ScanL();
- TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoCancelScanL()
-{
- TX_ENTRY
- // If harvester crashes, restart it.
- TRAPD( err, iHarvesterUtility->CancelScanL() );
- if ( err != KErrNone ) {
- iHarvesterUtility->Close();
- iHarvesterUtility = NULL;
- iHarvesterUtility = CMPXHarvesterFactory::NewL();
- iHarvesterUtility->CheckForSystemEventsL();
- }
- TX_EXIT
-}
-
-/*!
- \internal
- */
void MpMpxFrameworkWrapperPrivate::DoPreviewItemL( int index )
{
TX_ENTRY
if ( !iPlaybackUtility ) {
- iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
+ iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) );
}
// Get the current path
CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
CleanupStack::PushL( cpath );
- MPX_DEBUG_PATH(*cpath);
+ MPX_DEBUG_PATH( *cpath );
cpath->Back();
CMPXMediaArray *mediaArray;
const CMPXMedia& container = iCollectionData->containerMedia();
- mediaArray = const_cast<CMPXMediaArray*>(container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+ mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
CMPXMedia* currentMedia( mediaArray->AtL( index ) );
TMPXItemId id( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
- cpath->AppendL(id); // Top level items of songs
- cpath->Set(0); // Select 1st song
+ cpath->AppendL( id ); // Top level items of songs
+ cpath->Set( 0 ); // Select 1st song
CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath );
CleanupStack::PushL( playList );
@@ -767,7 +797,33 @@
/*!
\internal
*/
-void MpMpxFrameworkWrapperPrivate::DoHandleCollectionMessageL(
+void MpMpxFrameworkWrapperPrivate::DoOpenIsolatedCollectionL( TCollectionContext context )
+{
+
+ if ( ECollectionContextAllSongs == context ) {
+ CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL();
+ CleanupStack::PushL( cpath );
+ if ( !iIsolatedCollectionHelper ) {
+ iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( this );
+ }
+ iIsolatedCollectionHelper->OpenCollectionL( *cpath );
+ CleanupStack::PopAndDestroy( cpath );
+ }
+}
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+ iCollectionUiHelper->ReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal, this );
+}
+
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::DoHandleCollectionMessageL(
const CMPXMessage& aMsg )
{
TX_ENTRY
@@ -776,7 +832,7 @@
TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
- TX_LOG_ARGS("event=" << event << ", type=" << type << ", data=" << data);
+ TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data );
if ( event == TMPXCollectionMessage::EPathChanged &&
type == EMcPathChangedByOpen &&
@@ -791,56 +847,25 @@
// This will result in HandleOpenL with CMPXCollectionPlaylist
iCollectionUtility->Collection().OpenL();
}
-
- if ( event == TMPXCollectionMessage::EBroadcastEvent ) {
- switch (type) {
- case EMcMsgRefreshStart:
- emit q_ptr->scanStarted();
- break;
- case EMcMsgRefreshEnd:
- case EMcMsgDiskInserted:
- emit q_ptr->scanEnded();
- break;
- default:
- break;
- }
- }
- }
- else if( KMPXMessageIdItemChanged == id ) {
- if ( aMsg.IsSupported(KMPXMessageArrayContents) ) {
- // Loop through messages for arrays
- const CMPXMessageArray* messageArray =
- aMsg.Value<CMPXMessageArray>(KMPXMessageArrayContents);
- User::LeaveIfNull(const_cast<CMPXMessageArray*>(messageArray));
-
- for ( TInt i=0; i<messageArray->Count(); ++i ) {
- HandleCollectionMessage( messageArray->AtL( i ), KErrNone );
- }
- emit q_ptr->scanCountChanged(iNumItemsAdded);
- }
- else {
- // Single item
- TMPXChangeEventType changeType( aMsg.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
- TMPXGeneralCategory cat(aMsg.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
- if( changeType == EMPXItemInserted &&
- (cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast) ) {
- iNumItemsAdded++;
- }
- }
}
TX_EXIT
}
-void MpMpxFrameworkWrapperPrivate::PreparePlaylistMediaL(
- CMPXMedia& aMedia,
- QList<int> selection )
+
+/*!
+ \internal
+ */
+void MpMpxFrameworkWrapperPrivate::PreparePlaylistMediaL(
+ CMPXMedia& aMedia,
+ QList<int> &selection,
+ MpMpxCollectionData *collectionData )
{
int count = selection.count();
- TX_ENTRY_ARGS("selection count=" << count);
+ TX_ENTRY_ARGS( "selection count=" << count );
- const CMPXMedia& container = iCollectionData->containerMedia();
+ const CMPXMedia& container = collectionData->containerMedia();
const CMPXMediaArray* containerArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents );
- User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ));
+ User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ) );
CMPXMediaArray* tracksArray( CMPXMediaArray::NewL() );
CleanupStack::PushL( tracksArray );
@@ -849,12 +874,12 @@
TMPXItemId collectionId( path->Id( 0 ) );
CleanupStack::PopAndDestroy( path );
- if ( iCollectionData->context() == ECollectionContextArtistAlbums ) {
+ if ( collectionData->context() == ECollectionContextAlbums ) {
for ( TInt i = 0; i < count; i++ ) {
CMPXMedia* results;
CMPXMedia* album( containerArray->AtL( selection[i] ) );
// Fetch the songs for the selected album
- TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+ TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
CMPXMedia* findCriteria = CMPXMedia::NewL();
CleanupStack::PushL( findCriteria );
findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );
@@ -866,26 +891,26 @@
EMPXMediaGeneralTitle |
EMPXMediaGeneralId ) );
attrs.Append( KMPXMediaMusicAlbumTrack );
- results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array());
+ results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array() );
CleanupStack::PopAndDestroy( &attrs );
CleanupStack::PopAndDestroy( findCriteria );
CleanupStack::PushL( results );
const CMPXMediaArray* resultsArray = results->Value<CMPXMediaArray>( KMPXMediaArrayContents );
User::LeaveIfNull( resultsArray );
- for (int j = 0 ; j < resultsArray->Count();j++) {
- CMPXMedia* media( resultsArray->AtL(j) );
+ for ( int j = 0 ; j < resultsArray->Count();j++ ) {
+ CMPXMedia* media( resultsArray->AtL( j ) );
CMPXMedia* entry = CMPXMedia::NewL();
CleanupStack::PushL( entry );
entry->SetTextValueL( KMPXMediaGeneralTitle,
media->ValueText( KMPXMediaGeneralTitle ) );
- entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem);
+ entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
entry->SetTObjectValueL( KMPXMediaGeneralId,
media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
+ CleanupStack::Pop( entry );
tracksArray->AppendL( entry );
- CleanupStack::Pop( entry );
}
CleanupStack::PopAndDestroy( results );
}
@@ -893,18 +918,18 @@
}
else {
for ( TInt i = 0; i < count; i++ ) {
- CMPXMedia* media( containerArray->AtL(selection.at(i)) );
+ CMPXMedia* media( containerArray->AtL( selection.at( i ) ) );
CMPXMedia* entry = CMPXMedia::NewL();
CleanupStack::PushL( entry );
entry->SetTextValueL( KMPXMediaGeneralTitle,
media->ValueText( KMPXMediaGeneralTitle ) );
- entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem);
+ entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
entry->SetTObjectValueL( KMPXMediaGeneralId,
media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
+ CleanupStack::Pop( entry );
tracksArray->AppendL( entry );
- CleanupStack::Pop( entry );
}
}
aMedia.SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXItem );