Revision: 201023 RCL_3 PDK_3.0.1
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 15:37:19 +0300
branchRCL_3
changeset 40 cb96c29156b2
parent 31 a12246c97fcc
child 49 455f89b7fcc5
child 62 714af566785b
Revision: 201023 Kit: 2010125
mpxmusicplayer/app/inc/mpxcontroller.h
mpxmusicplayer/app/src/mpxcontroller.cpp
mpxmusicplayer/mediakeyhandler/inc/mpxremconkeyresponse.h
mpxmusicplayer/mediakeyhandler/src/mpxmediakeyhandlerimp.cpp
mpxmusicplayer/mediakeyhandler/src/mpxremconkeyresponse.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxcollectiondbmanager.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastcollectiondbdef.h
mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp
mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbmanager.cpp
mpxplugins/viewplugins/views/addtracksdialog/data/mpxaddtracksdialog.rss
mpxplugins/viewplugins/views/addtracksdialog/loc/mpxaddtracksdialog.loc
mpxplugins/viewplugins/views/audioeffectsview/inc/mpxaudioeffectsviewimp.h
mpxplugins/viewplugins/views/audioeffectsview/src/mpxaudioeffectsviewimp.cpp
mpxplugins/viewplugins/views/collectionview/loc/mpxcollectionview.loc
mpxplugins/viewplugins/views/collectionviewhg/data/mpxcollectionviewhg.rss
mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgcontainer.h
mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgimp.h
mpxplugins/viewplugins/views/collectionviewhg/loc/mpxcollectionviewhg.loc
mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp
mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgimp.cpp
mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhglistboxarray.cpp
mpxplugins/viewplugins/views/commoncontainer/inc/mpxcommoncontainerhgimp.h
mpxplugins/viewplugins/views/commoncontainer/src/mpxcommoncontainerhgimp.cpp
mpxplugins/viewplugins/views/inc/mpxcommoncontainer.h
mpxplugins/viewplugins/views/podcastview/data/mpxpodcastcollectionview.rss
mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewcontainer.h
mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewimp.h
mpxplugins/viewplugins/views/podcastview/loc/mpxpodcastcollectionview.loc
mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewcontainer.cpp
mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewimp.cpp
mpxplugins/viewplugins/views/waitnotedialog/inc/mpxscanningdialog.h
mpxplugins/viewplugins/views/waitnotedialog/src/mpxscanningdialog.cpp
--- a/mpxmusicplayer/app/inc/mpxcontroller.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxmusicplayer/app/inc/mpxcontroller.h	Mon Jun 21 15:37:19 2010 +0300
@@ -220,6 +220,7 @@
     CAknQueryDialog*            iQueryDialog;  // not owned, only for dismissal
     TInt                        iCurSystemEvent;
     TInt                        iCurPlugin;
+    RArray<TMPXAttribute>       iCurAtts;
     TBool                       iOutOfDisk;
     TBool                       iDiskDismountDuringFormat;
     TBool                       iRestartWaitDialog;
--- a/mpxmusicplayer/app/src/mpxcontroller.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxmusicplayer/app/src/mpxcontroller.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -151,6 +151,7 @@
         
     delete iCurPath;
     delete iIdle;
+    iCurAtts.Close();
     }
 
     
@@ -378,14 +379,7 @@
             //
             if( (iCurSystemEvent == KErrNotFound) && !iOutOfDisk )
                 {
-                // Fetch the extra data
-                RArray<TMPXAttribute> atts;
-                CleanupClosePushL( atts );
-                atts.Append(KMPXMediaColDetailDBCreated);
-                atts.Append(KMPXMediaColDetailDBCorrupted);
-                
-                iCollectionUtility->Collection().MediaL(*iCurPath, atts.Array() );
-                CleanupStack::PopAndDestroy( &atts );    
+                iCollectionUtility->Collection().MediaL(*iCurPath, iCurAtts.Array() );
                 }
             else
                 {
@@ -507,16 +501,14 @@
             
             // Do a MediaL to re-retrieve details
             //
-            RArray<TMPXAttribute> atts;
-            CleanupClosePushL( atts );
+            iCurAtts.Reset();
             if(!aSkipAttribute)
                 {
-                atts.Append(KMPXMediaColDetailDBCreated);
-                atts.Append(KMPXMediaColDetailDBCorrupted);
+                iCurAtts.Append(KMPXMediaColDetailDBCreated);
+                iCurAtts.Append(KMPXMediaColDetailDBCorrupted);
                 }
 
-            iCollectionUtility->Collection().MediaL(*iCurPath, atts.Array() );
-            CleanupStack::PopAndDestroy( &atts );
+            iCollectionUtility->Collection().MediaL(*iCurPath, iCurAtts.Array() );
             }
         }
     }
@@ -549,7 +541,7 @@
             iInitDBNeeded = EFalse;
             iInitDBCorrupted = EFalse;
             
-            DoRetrieveDetailsL(iOutOfDisk);
+            DoRetrieveDetailsL(data != KErrNone);
             }
         else if(event == TMPXCollectionMessage::EBroadcastEvent && 
                 op == EMcMsgRefreshStart)
--- a/mpxmusicplayer/mediakeyhandler/inc/mpxremconkeyresponse.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxmusicplayer/mediakeyhandler/inc/mpxremconkeyresponse.h	Mon Jun 21 15:37:19 2010 +0300
@@ -97,6 +97,8 @@
      * Not own.
      */
     CRemConCoreApiTarget& iRemConCoreApiTarget;
+public:    
+    TInt iCountOfVolumeCommands;
     }; 
 
 #endif  // C_CMPXREMCONKEYRESPONSE_H
--- a/mpxmusicplayer/mediakeyhandler/src/mpxmediakeyhandlerimp.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxmusicplayer/mediakeyhandler/src/mpxmediakeyhandlerimp.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -501,8 +501,9 @@
                     }
                     else if ( aValue != iCurrentVol )
                     {
-                    if ( aValue != 0 )
+                    if ( aValue != 0 && ( iResponseHandler->iCountOfVolumeCommands == 0 ) )
                         {
+                        // if we are processing remcon events we shouldn't change the current volume value
                         iCurrentVol = aValue;
                         }
                     }
@@ -1124,6 +1125,7 @@
         case ERemConCoreApiVolumeUp:
         case ERemConCoreApiVolumeDown:
             {
+            iResponseHandler->iCountOfVolumeCommands++;
             iTimer->Cancel();
             MMPXPlaybackUtility* pbUtil( NULL );
             MPX_TRAPD( err, pbUtil = MMPXPlaybackUtility::UtilityL( KPbModeActivePlayer ));
--- a/mpxmusicplayer/mediakeyhandler/src/mpxremconkeyresponse.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxmusicplayer/mediakeyhandler/src/mpxremconkeyresponse.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -32,7 +32,8 @@
 CMPXRemConKeyResponse::CMPXRemConKeyResponse( 
     CRemConCoreApiTarget& aRemConCoreApiTarget ) : 
     CActive( CActive::EPriorityStandard ),
-    iRemConCoreApiTarget( aRemConCoreApiTarget )
+    iRemConCoreApiTarget( aRemConCoreApiTarget ),
+    iCountOfVolumeCommands( 0 )
     {
     CActiveScheduler::Add( this );
     }
@@ -75,12 +76,14 @@
                 {
                 iRemConCoreApiTarget.VolumeUpResponse( iStatus, KErrNone );
                 SetActive();
+                iCountOfVolumeCommands--;
                 break;
                 }
             case ERemConCoreApiVolumeDown:
                 {
                 iRemConCoreApiTarget.VolumeDownResponse( iStatus, KErrNone );
                 SetActive();
+                iCountOfVolumeCommands--;
                 break;
                 }
             default:
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -269,16 +269,20 @@
             }
 
         TInt count(iDatabaseHandles.Count());
-        TBool ret = EFalse;
         for ( TInt i = 0; i < count ; ++i )
             {
+            if ( ! iDatabaseHandles[i].iOpen )
+                {
+                MPX_DEBUG1("CMPXDbManager::CopyDBsToRamL DB not open (assuming drive is not present)");
+                continue;
+                }
             if ( iDatabaseHandles[i].iUseRAMdb )
                 {
                 // already used
                 MPX_DEBUG1("CMPXDbManager::CopyDBsToRamL iUseRAMdb already ETrue");
                 continue;
                 }
-            CloseDatabaseAtIndexL( i ); // let leave: not much we can't do if we can't close the original DB
+            CloseDatabaseAtIndexL( i ); // let leave: not much we can do if we can't close the original DB
             DoCopyDBToRam( i, aIsMTPInUse ); // copies if it can
             TRAPD( err, OpenDatabaseAtIndexL( i ) );
             if ( err != KErrNone )
@@ -861,30 +865,27 @@
     {
     MPX_FUNC("CMPXDbManager::CloseAllDatabases");
 
-    if (iInitialized)
-        {
-        // Close all prepared statements if a db is closed
-        //
-        ResetPreparedQueries();
+    // Close all prepared statements if a db is closed
+    //
+    ResetPreparedQueries();
 
-        TInt count(iDatabaseHandles.Count());
-        for (TInt i = 0; i < count; ++i)
-            {
-            delete iDatabaseHandles[i].iAliasname;
-            iDatabaseHandles[i].iAliasname = 0;
+    TInt count(iDatabaseHandles.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        delete iDatabaseHandles[i].iAliasname;
+        iDatabaseHandles[i].iAliasname = 0;
 #ifdef __RAMDISK_PERF_ENABLE 
-            RemoveDummyFile(i);            	
-            delete iDatabaseHandles[i].iOrigFullFilePath;
-			iDatabaseHandles[i].iOrigFullFilePath = 0;
-            delete iDatabaseHandles[i].iTargetFullFilePath;
-			iDatabaseHandles[i].iTargetFullFilePath = 0;
+        RemoveDummyFile(i);            	
+        delete iDatabaseHandles[i].iOrigFullFilePath;
+        iDatabaseHandles[i].iOrigFullFilePath = 0;
+        delete iDatabaseHandles[i].iTargetFullFilePath;
+        iDatabaseHandles[i].iTargetFullFilePath = 0;
 #endif //__RAMDISK_PERF_ENABLE 
-            }
+        }
 
-        iDatabaseHandles.Reset();
-        iDatabase.Close();
-        iInitialized = EFalse;
-        }
+    iDatabaseHandles.Reset();
+    iDatabase.Close();
+    iInitialized = EFalse;
     }
 
 // ----------------------------------------------------------------------------
@@ -1726,6 +1727,16 @@
     }
 
 // ----------------------------------------------------------------------------
+// CleanupTransaction: close transaction when creating DB
+// ----------------------------------------------------------------------------
+//
+static void CleanupTransaction(TAny * aDatabase)
+    {
+    TInt err = ((RSqlDatabase*)aDatabase)->Exec(KRollbackTransaction);
+    MPX_DEBUG2("CMPXDbManager CleanupTransaction rollback, error %d", err);
+    }
+    
+// ----------------------------------------------------------------------------
 // CMPXDbManager::CreateTablesL
 // ----------------------------------------------------------------------------
 //
@@ -1733,11 +1744,26 @@
 	RSqlDatabase& aDatabase,
 	TBool aCorrupt)
 	{
+	MPX_FUNC("CMPXDbManager::CreateTablesL");
+    TInt err = aDatabase.Exec(KBeginTransaction);
+    if (err < 0)
+       {
+       MPX_DEBUG2("SQL BEGIN TRANSACTION error %d", err);
+       User::Leave (err);
+       }
+    CleanupStack::PushL(TCleanupItem(&CleanupTransaction, &aDatabase));
     TInt count(iTables.Count());
     for (TInt i = 0; i < count; ++i)
         {
         iTables[i]->CreateTableL(aDatabase, aCorrupt);
         }
+    err = aDatabase.Exec(KCommitTransaction);
+    if (err < 0)
+        {
+        MPX_DEBUG2("SQL COMMIT TRANSACTION error %d", err);
+        User::Leave (err);
+        }
+    CleanupStack::Pop();
 	}
 
 // ----------------------------------------------------------------------------
@@ -2017,12 +2043,7 @@
         User::Leave(KErrNotReady);
         }
     
-#ifndef __RAMDISK_PERF_ENABLE 
-    
     EnsureDiskSpaceL(aDrive);
-    
-#endif //__RAMDISK_PERF_ENABLE
-
     }
     
 // ----------------------------------------------------------------------------
@@ -2862,19 +2883,24 @@
     TInt count(iDatabaseHandles.Count());
     for (TInt i = 0; i < count; ++i)
         {
+        DatabaseHandle& database = iDatabaseHandles[i];
         if (((KDbManagerAllDrives == aDrive) ||
-            (aDrive == iDatabaseHandles[i].iDrive)) &&
-            iDatabaseHandles[i].iOpen)
+            (aDrive == database.iDrive)) &&
+            database.iOpen
+#ifdef __RAMDISK_PERF_ENABLE
+            && !database.iUseRAMdb
+#endif
+            )
             {
             if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, 0,
-                iDatabaseHandles[i].iDrive))
+                database.iDrive))
                 {
                 MPX_DEBUG1("CMPXDbManager::EnsureDiskSpaceL Error diskspace full");
                 User::Leave(KErrDiskFull);
                 }
             }
 
-        if (aDrive == iDatabaseHandles[i].iDrive)
+        if (aDrive == database.iDrive)
             {
             // exit if just one drive to check
             break;
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h	Mon Jun 21 15:37:19 2010 +0300
@@ -28,9 +28,11 @@
 
 // Db filename
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
-_LIT(KMCDbFile, "mpxv2_6.db");
+_LIT(KMCDbFile, "mpxv3_0.db");
+_LIT(KMCDbFileEMMC, "mpxv3_0i.db");
 #else 
-_LIT(KMCDbFile, "mpxv2_5.db");
+_LIT(KMCDbFile, "mpxv3_0n.db");
+_LIT(KMCDbFileEMMC, "mpxv3_0in.db");
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
 // Collection Db resource file
 _LIT(KMPXCollectionDbResourceFile,  "mpxcollectiondbhgres.rsc");
@@ -133,6 +135,8 @@
 _LIT(KMCPlaylistSongInfoVolumeId,   "VolumeId");
 _LIT(KMCPlaylistSongInfoDbFlag,     "DbFlag");
 
+// == Album TABLE FIELDS ==============================================
+_LIT(KMCAlbumArtistName, "ArtistName");
 // == Auxiliary TABLE FIELDS ==================================================
 // Version of database
 // The version integer looks like:
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h	Mon Jun 21 15:37:19 2010 +0300
@@ -156,6 +156,25 @@
         */
         void GetAllItemsWithNoSongL(RArray<TUint32>& aItemsIds);
 
+        /**
+        * Create Thumbnail Manager session.
+        * Create Thumbnail Manager session when needed: rename/delete entries in Thumbnail table.
+        */
+        void CreateTNMSessionL();
+        
+        /**
+        * Remove all abstractalbum items with no songs associated,
+        * TN entry and .alb files also removed.
+        *
+        */
+        void RemoveAbstractAlbumsWithNoSongL();
+        
+        /**
+        /* When refresh library, Remove .alb entry from AbstractAlnum table, TN table if .alb files already deleted 
+        /* from file system via file manager.
+        */
+        void AbstractAlbumCleanUpL();
+       
     private:
 
 
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h	Mon Jun 21 15:37:19 2010 +0300
@@ -30,7 +30,7 @@
     {
     public:
         virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0;
-        virtual TUint32 HandleArtistForAlbumL( const TUint32 aId ) = 0;
+        virtual HBufC* HandleArtistForAlbumL( const TUint32 aId ) = 0;
         /**
         * HandleAlbumartForAlbumL.
         * @param aId, The album ID.
@@ -86,7 +86,7 @@
         *        into consideration when generating the unique row id
         * @return The unique id of the row added.
         */
-        TUint32 AddItemL(const TDesC& aName, TUint32 aArtist, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
+        TUint32 AddItemL(const TDesC& aName, const TDesC& aArtistName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
             TBool aCaseSensitive = ETrue);
 
         /**
@@ -163,7 +163,12 @@
 
         TBool IsUnknownArtistL(TUint32 aId);
 
-        TUint32 ArtistForAlbumL(const TUint32 aId);
+        /**
+        * Get the ArtistName of song which belongs to the specified Album.
+        * @param aId The ID of the album
+        * @returns alternative artistname retrieved in the specified Album.
+        */
+        HBufC* ArtistForAlbumL(const TUint32 aId);
         /**
         * Get the Albumart of song which belongs to the specified Album.
         * @param aId The ID of the album
@@ -206,11 +211,10 @@
         enum TAlbumColumns
             {
             EAlbumUniqueId = KMPXTableDefaultIndex,
+            EAlbumArtistName,
             EAlbumName,
-            EAlbumSongCount,
-            EAlbumArtist,
+            EAlbumSongCount,      
             EAlbumArt,
-            EAlbumArtistName,
             EAlbumFieldCount
             };
 
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h	Mon Jun 21 15:37:19 2010 +0300
@@ -905,21 +905,7 @@
         void DoRemoveSongFromPlaylistL(TUint32 aPlaylistId, const TMPXItemId& aSongId,
             TInt aOrdinal, CMPXMessageArray& aItemChangedMessages);
 
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED  
-        /**
-        * Remove all abstractalbum items with no songs associated,
-        * TN and .alb files also removed.
-        *
-        */
-        void RemoveAbstractAlbumsWithNoSongL();
-        
-          /**
-        /* When refresh library, Remove .alb entry from AbstractAlnum table, TN table if .alb files deleted 
-        /* from file manager 
-        */
-        void AbstractAlbumCleanUpL();
-       
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
 
         /**
         * Deletes all song records marked as deleted.
@@ -1044,7 +1030,7 @@
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
 
        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
-            TUint32 aArtist, const TDesC& aArt,
+           const TDesC& aArtistName, const TDesC& aArt,
             TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
 
        virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
@@ -1083,7 +1069,12 @@
     * @see MMPXDbAlbumObserver
     */
     virtual TBool HandleIsUnknownArtistL(TUint32 aArtistId);
-    virtual TUint32 HandleArtistForAlbumL(const TUint32 aAlbumId);
+    /**
+    * Get the Artistname of song which belongs to the specified Album.     
+    * @param aId, The Album ID.
+	* @returns alternative artistname retrieved in the specified Album.
+    */
+    virtual HBufC* HandleArtistForAlbumL(const TUint32 aAlbumId);
         
     /**
     * Get the Albumart of song which belongs to the specified Album.     
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h	Mon Jun 21 15:37:19 2010 +0300
@@ -80,7 +80,7 @@
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
        // for Album and Artist table
         virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
-            TUint32 aArtistId, const TDesC& aArt,
+            const TDesC& aArtistName, const TDesC& aArt,
             TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
         /**
         * Called when the ID of a category item changed for a Music record, for example when
@@ -528,7 +528,7 @@
          * Get the ID of Artist which belongs to the specified Album
          * @param aId, the ID of Album
          */
-        TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId);
+        TUint32 ArtistForAlbumL(const TUint32 aId);
             
         /**
         * Get the Albumart of song which belongs to the specified Album
@@ -688,9 +688,6 @@
             const TMPXAttribute& aAttribute, TUint32 aOldId, TInt aDriveId,
             CMPXMessageArray* aItemChangedMessages, TUint32& aItemId);
 
-        TBool UpdateCategoryFieldL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia,
-          const TMPXAttribute& aAttribute, TUint32 aOldId, TInt aDriveId,
-          CMPXMessageArray* aItemChangedMessages, TUint32& aItemId, TUint32 aArtistId);
         /**
         * Checks if extra attributes are required. The "standard attribute set includes:
         * EMPXMediaGeneralId, EMPXMediaGeneralType, EMPXMediaGeneralCategory,
@@ -707,6 +704,12 @@
         *  otherwise EFalse.
         */
         TBool IsSupported(const CMPXMedia& aMedia);
+        
+        /**
+         * Query all songs from the database and add results to the 
+         * iAllSongsQueryResult cache array.
+         */
+        void ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs);
 
     private:    // from MMPXTable
 
@@ -809,6 +812,7 @@
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED 
         TBool iArtNeedUpdated;
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
+        RPointerArray<CMPXMedia> iAllSongsQueryResult;
     };
 
 #endif // MPXDBMUSIC_H
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h	Mon Jun 21 15:37:19 2010 +0300
@@ -270,9 +270,9 @@
 _LIT(KAuxiliaryDropTable,"DROP TABLE Auxiliary");
 _LIT(KAuxiliaryCheckTable, "SELECT Id,Version,TimeRefreshed,TimeSynced,Corrupt,SaveDeletedRecordCount FROM AUXILIARY");
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
-_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.5.0',%u)");
+_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.6.0',%u)");
 #else
-_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.4.0',%u)");
+_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.6.1',%u)");
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
 _LIT(KQueryAuxiliarySetTime, "UPDATE :dbname.Auxiliary SET TimeRefreshed='%S', Corrupt=0");
 _LIT(KQueryAuxiliaryGetTime, "SELECT TimeRefreshed FROM :dbname.Auxiliary");
@@ -427,18 +427,20 @@
 //
 _LIT(KAlbumCreateTable,"CREATE TABLE Album("
     L"UniqueId INTEGER PRIMARY KEY,"
+    L"ArtistName TEXT COLLATE NOCASE,"
     L"Name TEXT COLLATE NOCASE,"
     L"SongCount INTEGER,"
-    L"Artist INTEGER,"
-    L"Art TEXT)");
+	L"Art TEXT)");
 
-_LIT(KAlbumCheckTable,"SELECT UniqueId,Name,SongCount,Artist,Art FROM Album");
+_LIT(KAlbumCheckTable,"SELECT UniqueId,ArtistName,Name,SongCount,Art FROM Album");
 
-_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,Name,SongCount,Artist,Art) VALUES(%u,'%S',%u,%u,'%S')");
+_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,ArtistName,Name,SongCount,Art) VALUES(%u,'%S','%S',%u,'%S')");
 _LIT(KQueryAlbumUpdate, "UPDATE :dbname.Album SET %S WHERE UniqueId=%u");
 
 _LIT(KQueryAlbumItem, "SELECT Album.*,Artist.Name FROM :dbname.Album,:dbname.Artist WHERE Album.Artist=Artist.UniqueId AND UniqueId=%u");
-_LIT(KQueryAlbumAll, "SELECT Album.*,Artist.Name FROM :dbname.Album,:dbname.Artist WHERE Album.Artist=Artist.UniqueId ORDER BY 6, 2");
+_LIT(KQueryAlbumAll, "SELECT Album.* FROM :dbname.Album ORDER BY ArtistName, Name");
+_LIT(KCriterionArtistName, "ArtistName='%S'");
+_LIT(KCriterionArt, "Art='%S'");
 
 // == Artist table queries ==========================================
 //
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxcollectiondbmanager.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxcollectiondbmanager.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -80,7 +80,26 @@
 void CMPXCollectionDbManager::ConstructL()
     {
     MPX_FUNC("CMPXCollectionDbManager::ConstructL");
-    CMPXDbManager::ConstructL(TFileName(KMCDbFile));
+    //Find out if the system has an internal drive (eMMC)
+    TBool eMMC( EFalse );
+    TDriveInfo driveInfo;  
+    if( Fs().Drive( driveInfo, EDriveE ) == KErrNone )
+    	{
+        if ( driveInfo.iDriveAtt & KDriveAttInternal )
+        	eMMC = ETrue;
+    	}
+    
+    //Use different name for Dbs if the system has an internal drive vs. MMC-only.	
+    //Since hard-coded drive letters in the Thumbnail URIs
+    //So Dbs are not interchangeable between an internal drive system and MMC-only system.
+    if ( eMMC )	
+        {
+        CMPXDbManager::ConstructL(TFileName( KMCDbFileEMMC ));
+        }
+    else
+        {
+        CMPXDbManager::ConstructL(TFileName( KMCDbFile ));
+    	}
     }
 
 // End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -78,7 +78,8 @@
     {
     MPX_FUNC("CMPXDbAbstractAlbum::~CMPXDbAbstractAlbum");
 #ifdef RD_MPX_TNM_INTEGRATION
-    delete iTNManager;
+    if (iTNManager)
+        delete iTNManager;
 #endif //RD_MPX_TNM_INTEGRATION
     }
 
@@ -222,6 +223,81 @@
     }
 
 // ----------------------------------------------------------------------------
+// Remove abstractalbums which have no songs associated.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::RemoveAbstractAlbumsWithNoSongL()
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::RemoveAbstractAlbumsWithNoSongL");
+    
+    RArray<TUint32> iItemsIds;
+    CleanupClosePushL(iItemsIds);
+    
+    //get all abstractalbum with no songs associated.
+    GetAllItemsWithNoSongL(iItemsIds);
+    TInt count = iItemsIds.Count();
+    TInt err = KErrNone;
+    if (count)
+        {           	
+        MPX_DEBUG2("CMPXDbAbstractAlbum::RemoveAbstractAlbumsWithNoSongL, abstractalbum count[%d] ", iItemsIds.Count());
+        CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
+        CleanupStack::PushL(itemChangedMessages);
+
+        //go through each one to delete
+        for (TInt i=0; i< count; i++)
+            {
+            TRAP(err, RemoveAbstractAlbumL(iItemsIds[i], *itemChangedMessages, EFalse));
+            if (err != KErrNone)
+                {
+                MPX_DEBUG2("CMPXDbAbstractAlbum::RemoveAbstractAlbumsWithNoSongL, error happens when delete abstractalbum, err ", err);
+                }
+            }
+       CleanupStack::PopAndDestroy(itemChangedMessages);
+       }
+    CleanupStack::PopAndDestroy(&iItemsIds);
+  }
+
+// ----------------------------------------------------------------------------
+// Remove .alb entry from AbstractAlnum table, TN table if .alb files deleted 
+// from file manager when refresh library
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::AbstractAlbumCleanUpL()
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::AbstractAlbumCleanUpL");
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL(attributes);
+    attributes.AppendL(KMPXMediaGeneralUri);
+    CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
+    CleanupStack::PushL(mediaArray);
+    
+    GetAllCategoryItemsL(attributes.Array(), *mediaArray);
+
+    TInt count(mediaArray->Count());
+    if (count)
+        {      
+        CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
+        CleanupStack::PushL(itemChangedMessages);
+        for (TInt i = 0; i < count; i++)
+            {
+            CMPXMedia* element = mediaArray->AtL(i);
+            const TDesC& uri = element->ValueText(KMPXMediaGeneralUri);                                 
+
+            //check if the file exists in file system
+            if (!(BaflUtils::FileExists(iFs, uri)))
+                {
+                //generate abstractalbum UID with the Uri
+                TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse));
+                RemoveAbstractAlbumL(abstractAlbumId, *itemChangedMessages, ETrue);             
+                }
+            }
+            CleanupStack::PopAndDestroy(itemChangedMessages);
+        }
+        CleanupStack::PopAndDestroy(mediaArray);       
+        CleanupStack::PopAndDestroy(&attributes);     
+    }
+
+// ----------------------------------------------------------------------------
 // CMPXDbAbstractAlbum::RemoveAbstractAlbumL
 // ----------------------------------------------------------------------------
 //
@@ -255,7 +331,10 @@
         const TDesC& aNewPath, TInt aPriority )
   {
   MPX_FUNC("CMPXDbAbstractAlbum::HandleTNL");
-
+  if (!iTNManager)
+      {
+      CreateTNMSessionL();
+      }
   if (aNewPath.Compare(KNullDesC)==0 && aOldPath.Compare(KNullDesC)!=0)
       {         
       // remove from thumbnail database table
@@ -263,13 +342,15 @@
       CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(
                aOldPath, KImageFileType );
       iTNManager->DeleteThumbnails( *source );
+          
       CleanupStack::PopAndDestroy( source );
       }
    else if (aNewPath.Compare(KNullDesC)!=0)
       {
       //rename thumbnail
-      MPX_DEBUG1("CMPXDbAbstractAlbum::HandleTNL, rename TN");
-      iTNManager->RenameThumbnailsL( aOldPath,  aNewPath, aPriority );
+      MPX_DEBUG1("CMPXDbAbstractAlbum::HandleTNL, rename Thumbnail entry in Thumbnail table");
+    
+      iTNManager->RenameThumbnailsL( aOldPath,  aNewPath, aPriority );  
       //after rename, reset flag
       iRenameTN = EFalse;
       }
@@ -531,6 +612,7 @@
     CMPXDbManager& aDbManager,
     TMPXGeneralCategory aCategory, RFs& aFs) :
     CMPXDbCategory(aDbManager, aCategory),
+    iTNManager(NULL),
     iFs(aFs)
     {
     MPX_FUNC("CMPXDbAbstractAlbum::CMPXDbAbstractAlbum");
@@ -545,11 +627,7 @@
     MPX_FUNC("CMPXDbAbstractAlbum::ConstructL");
 
     BaseConstructL();
-#ifdef RD_MPX_TNM_INTEGRATION
-    // Create Thumbnail Manager instance. This object is the observer.
-    iTNManager = CThumbnailManager::NewL( *this );
     iRenameTN = EFalse;
-#endif //RD_MPX_TNM_INTEGRATION
     }
 
 
@@ -572,4 +650,16 @@
         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
     {
     }
+
+// ---------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::CreateTNMSessionL
+// Create thumbnail session
+// ---------------------------------------------------------------------------    
+void CMPXDbAbstractAlbum::CreateTNMSessionL()
+    {
+    if(!iTNManager)
+        {
+        iTNManager = CThumbnailManager::NewL( *this );
+        }
+    }
 // End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -112,7 +112,7 @@
 //
 TUint32 CMPXDbAlbum::AddItemL(
     const TDesC& aName,
-    TUint32 aArtist,
+    const TDesC& aArtistName,
     const TDesC& aArt,
     TInt aDriveId,
     TBool& aNewRecord,
@@ -130,11 +130,13 @@
         // insert new
         HBufC* query = PreProcessStringLC(KQueryAlbumInsert);
         HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+        HBufC* artistname = MPXDbCommonUtil::ProcessSingleQuotesLC(aArtistName);
 		HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
 
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, aArtist, art);
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, artistname, name, 1, art); 
 
 		CleanupStack::PopAndDestroy(art);
+        CleanupStack::PopAndDestroy(artistname);
         CleanupStack::PopAndDestroy(name);
         CleanupStack::PopAndDestroy(query);
         }
@@ -154,17 +156,23 @@
 	    }
 
         // Artist
-        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
+        TPtrC artistname(KNullDesC);
+        artistname.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName));
+
 
         // the current one is Unknown and the new one is Not Unknown.
-        if ( IsUnknownArtistL( artistId ) && !IsUnknownArtistL( aArtist ) )
+         if ( artistname == KNullDesC  && aArtistName!= KNullDesC )
             {
-            _LIT( KFormatArtistId, "Artist=%d" );
-            HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
-            setStr->Des().Format( KFormatArtistId, aArtist );
-
+            HBufC* artistnameReplaceSingleQuote = 
+                            MPXDbCommonUtil::ProcessSingleQuotesLC( aArtistName );
+            TPtrC criteria(KCriterionArtistName);
+            HBufC* setStr = HBufC::NewLC(criteria.Length() + artistnameReplaceSingleQuote->Length()); 
+            setStr->Des().Format( KCriterionArtistName, artistnameReplaceSingleQuote );
+           
             iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
             CleanupStack::PopAndDestroy(setStr);
+            CleanupStack::PopAndDestroy(artistnameReplaceSingleQuote);
+
             }
 
         // Album Art
@@ -176,9 +184,10 @@
             {
             HBufC* artReplaceSingleQuote = 
                             MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
-            _LIT( KFormatArt, "Art=\'%S\'" );
-            HBufC* setStr = HBufC::NewLC(256);
-            setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
+
+            TPtrC criteria(KCriterionArt);
+            HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); 
+            setStr->Des().Format( KCriterionArt, artReplaceSingleQuote );
 
             iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
             CleanupStack::PopAndDestroy(setStr);
@@ -240,24 +249,31 @@
             User::Leave(KErrNotFound);
         }
 
-        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
         TBool itemModified = EFalse;
+        TPtrC artistname(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName));
+        TUint32 artistId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXArtist,
+	            artistname, ETrue);
 
         // the current artist is equal to deleted song's artist
         if ( artistId == aArtist )
             {
-            TUint32 newArtistId = ArtistForAlbumL(aId);
-            if ( artistId != newArtistId )
-                {
-                _LIT( KFormatArtistId, "Artist=%d" );
-                HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
-                setStr->Des().Format(KFormatArtistId, newArtistId);
+            HBufC* newArtistname = ArtistForAlbumL(aId);
+            
+            CleanupStack::PushL(newArtistname);
+            if (newArtistname && newArtistname->CompareF(artistname)!=0)
+                { 
+                HBufC* artistnameReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArtistname );
+                TPtrC criteria(KCriterionArtistName);
+                HBufC* setStr = HBufC::NewLC(criteria.Length() + artistnameReplaceSingleQuote->Length()); 
+                setStr->Des().Format( KCriterionArtistName, artistnameReplaceSingleQuote );                    	
 
                 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
                 CleanupStack::PopAndDestroy(setStr);
+                CleanupStack::PopAndDestroy(artistnameReplaceSingleQuote);
                 itemModified = ETrue;
                 }
-            }
+            CleanupStack::PopAndDestroy(newArtistname);             
+            }         
         
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED      
     TBool nonEmbeddedArt = EFalse;
@@ -290,9 +306,9 @@
                 {
                 MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForCategoryL, get newArt");
                 HBufC* artReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArt );
-                _LIT( KFormatArt, "Art=\'%S\'" );
-                HBufC* setStr = HBufC::NewLC(256);                 
-                setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
+                TPtrC criteria(KCriterionArt);   
+                HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); 
+                setStr->Des().Format( KCriterionArt, artReplaceSingleQuote );
 
                 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
                 CleanupStack::PopAndDestroy(setStr);
@@ -535,9 +551,7 @@
 	if (aMedia.IsSupported(KMPXMediaMusicArtist))
 	    {
 	    const TDesC& artistName = aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen);
-	    TUint32 artistId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXArtist,
-	            artistName, ETrue);
-	    MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, artistId);
+	    MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCAlbumArtistName, artistName);
 	    }
 	}
 
@@ -554,7 +568,7 @@
 // CMPXDbAlbum::ArtistForAlbumL
 // ----------------------------------------------------------------------------
 //
-TUint32 CMPXDbAlbum::ArtistForAlbumL(const TUint32 aId)
+HBufC* CMPXDbAlbum::ArtistForAlbumL(const TUint32 aId)
     {
     return iObserver.HandleArtistForAlbumL(aId);
     }
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -1537,6 +1537,8 @@
             iOutOfDisk = ETrue;
         }
 
+    User::LeaveIfError( err );
+    	
     if(!iOutOfDisk)
     {
         MPX_TRAP(err,CheckDiskSpaceOnDrivesL());
@@ -1561,26 +1563,28 @@
 void CMPXDbHandler::RefreshEndL()
     {
     MPX_FUNC("CMPXDbHandler::RefreshEndL");
-    iRefresh = EFalse;
-    EndTransactionL(KErrNone);
-    if (!iOutOfDisk)
-        {
-        // Write last refreshed time as current time
-        // This also sets corrupt = 0
-        TTime curTime;
-        curTime.HomeTime();
-        SetLastRefreshedTimeL(curTime);
-        }
+    if ( iRefresh )
+        { 
+        iRefresh = EFalse;
+        EndTransactionL(KErrNone);
+        if (!iOutOfDisk)
+            {
+            // Write last refreshed time as current time
+            // This also sets corrupt = 0
+            TTime curTime;
+            curTime.HomeTime();
+            SetLastRefreshedTimeL(curTime);
+            }
 
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
     //for AbstractAlbum garbage collection
-    //can not leave
-    TRAP_IGNORE( AbstractAlbumCleanUpL() );
+    TRAP_IGNORE( iDbAbstractAlbum->AbstractAlbumCleanUpL() );
 #endif
    
 #ifdef __RAMDISK_PERF_ENABLE
-    iDbManager->CopyDBsFromRamL();
+        iDbManager->CopyDBsFromRamL();
 #endif //__RAMDISK_PERF_ENABLE
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -1605,6 +1609,12 @@
     
         iDbManager->BeginL();
         }
+//create Thumbnail manager session for cleanup for abstractalbum when MTP end.
+//because when MTP end comes, in case of mode switching, we need to do it as fast as possible, 
+//hence we don’t want the delay happens on that time.    
+#ifdef RD_MPX_TNM_INTEGRATION           
+    iDbAbstractAlbum->CreateTNMSessionL();
+#endif  //RD_MPX_TNM_INTEGRATION
     MPX_DEBUG1("<--CMPXDbHandler::MtpStartL");
     }
 
@@ -1630,11 +1640,13 @@
 #endif //__RAMDISK_PERF_ENABLE
 
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
-    TRAP(err, RemoveAbstractAlbumsWithNoSongL());
+    BeginTransactionL();
+    TRAP(err, iDbAbstractAlbum->RemoveAbstractAlbumsWithNoSongL());
     if ( err != KErrNone )
         {
         MPX_DEBUG2("CMPXDbHandler::MtpEndL error happened when cleanup albstractalbum with no songs association[%d]", err);
         }
+    EndTransactionL(err);
 #endif
     MPX_DEBUG1("<--CMPXDbHandler::MtpEndL");
     }
@@ -2366,83 +2378,6 @@
         EMPXSong, KDBPluginUid);
     }
     
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED  
-// ----------------------------------------------------------------------------
-// Remove abstractalbums which have no songs associated.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL()
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL");
-    
-    BeginTransactionL();
-    RArray<TUint32> iItemsIds;
-    CleanupClosePushL(iItemsIds);
-      //get all abstractalbum with no songs associated.
-    iDbAbstractAlbum->GetAllItemsWithNoSongL(iItemsIds);
-    TInt count = iItemsIds.Count();
-    TInt err = KErrNone;
-    if (count)
-        {
-        MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, abstractalbum count[%d] ", iItemsIds.Count());
-        CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
-        CleanupStack::PushL(itemChangedMessages);
-
-        //go through each one to delete
-        for (TInt i=0; i< count; i++)
-            {
-            TRAP(err, RemoveAbstractAlbumL(iItemsIds[i], *itemChangedMessages, EFalse));
-            if (err != KErrNone)
-                {
-                MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, error happens when delete abstractalbum, err ", err);
-                }
-            }
-       CleanupStack::PopAndDestroy(itemChangedMessages);
-       }
-    CleanupStack::PopAndDestroy(&iItemsIds);
-    EndTransactionL(err); 
-  }
-  
-// ----------------------------------------------------------------------------
-// Remove .alb entry from AbstractAlnum table, TN table if .alb files deleted 
-// from file manager when refresh library
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::AbstractAlbumCleanUpL()
-    {
-    MPX_FUNC("CMPXDbHandler::AbstractAlbumCleanUpL");
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL(attributes);
-    attributes.AppendL(KMPXMediaGeneralUri);
-    CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
-    CleanupStack::PushL(mediaArray);
-    
-    iDbAbstractAlbum->GetAllCategoryItemsL(attributes.Array(), *mediaArray);
-
-    TInt count(mediaArray->Count());
-    if (count)
-        {
-        CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
-        CleanupStack::PushL(itemChangedMessages);
-        for (TInt i = 0; i < count; i++)
-            {
-            CMPXMedia* element = mediaArray->AtL(i);
-            const TDesC& uri = element->ValueText(KMPXMediaGeneralUri);                                 
-
-            //check if the file exists in file system
-            if (!(BaflUtils::FileExists(iFs, uri)))
-                {
-                //generate abstractalbum UID with the Uri
-                TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse));
-                RemoveAbstractAlbumL(abstractAlbumId, *itemChangedMessages, ETrue);             
-                }
-            }
-            CleanupStack::PopAndDestroy(itemChangedMessages);
-        }
-        CleanupStack::PopAndDestroy(mediaArray);       
-        CleanupStack::PopAndDestroy(&attributes);     
-    }
-#endif //ABSTRACTAUDIOALBUM_INCLUDED
 
 // ----------------------------------------------------------------------------
 // CMPXDbHandler::DoCleanupDeletedRecordsL
@@ -2894,22 +2829,6 @@
 
         // append the drive to the drive list
         iDbDrives.AppendL(driveUnit);
-
-        // make sure the folder is created
-        TVolumeInfo info;
-        if (iFs.Volume(info, driveUnit) == KErrNone)
-           {
-            if (!BaflUtils::PathExists(iFs, folder))
-                {
-                // create music folder if necessary
-                TInt err(iFs.MkDirAll(folder));
-                MPX_DEBUG3("Try to create music folder %S return code %d", &folder, err);
-                if (err != KErrAlreadyExists)
-                    {
-                    User::LeaveIfError(err);
-                    }
-                }
-            }
         }
     }
 
@@ -3185,7 +3104,7 @@
 TUint32 CMPXDbHandler::AddCategoryItemL(
         TMPXGeneralCategory aCategory,
         const TDesC& aName,
-        TUint32 aArtist,
+        const TDesC& aArtistName,
         const TDesC& aArt,
         TInt aDriveId,
         CMPXMessageArray* aItemChangedMessages,
@@ -3198,9 +3117,9 @@
     TBool newRecord(EFalse);
 
     TUint32 id = 0;
-    if ( aArtist )
+    if(aCategory == EMPXAlbum)
         {
-        id = iDbAlbum->AddItemL(aName, aArtist, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
+        id = iDbAlbum->AddItemL(aName, aArtistName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
         }
     else
         {
@@ -3362,9 +3281,12 @@
 // CMPXDbHandler::HandleArtistForAlbumL
 // ---------------------------------------------------------------------------
 //
-TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
+HBufC* CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
     {
-    return iDbMusic->ArtistForAlbumL(aAlbumId);
+
+    TUint32 artistId = iDbMusic->ArtistForAlbumL(aAlbumId);
+    HBufC* artistname = GetNameMatchingIdL(artistId);
+    return artistname;
     }
 
 // ---------------------------------------------------------------------------
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -56,6 +56,7 @@
 _LIT( KAbstractAlbumExt, ".alb" );
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
 
+const TInt KAllSongsQueryResultGranularity = 250;
 
 // ============================ MEMBER FUNCTIONS ==============================
 
@@ -99,6 +100,7 @@
     {
     MPX_FUNC("CMPXDbMusic::~CMPXDbMusic");
     delete iExtensionsDrm;
+    iAllSongsQueryResult.ResetAndDestroy();
     }
 
 // ----------------------------------------------------------------------------
@@ -113,6 +115,7 @@
 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
     ,iArtNeedUpdated(ETrue)
 #endif
+    ,iAllSongsQueryResult(KAllSongsQueryResultGranularity)
     {
     MPX_FUNC("CMPXDbMusic::CMPXDbMusic");
     }
@@ -682,14 +685,55 @@
     {
     MPX_FUNC("CMPXDbMusic::GetAllSongsLimitedL");
 
-    // Gets a subset of the data from all songs ordered by title
-    HBufC* query = HBufC::NewLC( KQueryMusicGetSongsLimited().Length() + KMCIntegerLen );
-    query->Des().Format( KQueryMusicGetSongsLimited, aLimit );
-    ExecuteMediaQueryL(aAttrs, aMediaArray, *query);
-    CleanupStack::PopAndDestroy( query );    
+	// Reset and create a cache for the query results.
+	if (iAllSongsQueryResult.Count())
+		{
+        iAllSongsQueryResult.ResetAndDestroy();
+		}
+
+	ExecuteQueryAllSongsL(aAttrs);
+
+    TInt limit = aLimit > iAllSongsQueryResult.Count() ?
+    	iAllSongsQueryResult.Count() : aLimit;
+
+	for ( TInt i=0; i < limit; i++ )
+		{
+        CMPXMedia* m = iAllSongsQueryResult[i];
+		aMediaArray.AppendL(*m);
+		}
     }
 
 // ----------------------------------------------------------------------------
+// CMPXDbMusic::ExecuteQueryAllSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs)
+    {
+    // Run query and add result media objects to the cache array.
+    MPX_FUNC("CMPXDbMusic::ExecuteQueryAllSongsL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongs));
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        UpdateMediaL(recordset, aAttrs, *media);
+        iAllSongsQueryResult.AppendL(media);
+        CleanupStack::Pop(media);
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    if (err!= KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
 // CMPXDbMusic::GetSongsInBlockL
 // ----------------------------------------------------------------------------
 //
@@ -723,12 +767,23 @@
                                      TInt aOffset,
                                      TInt aCount )
     {
-    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL <--");   
+	MPX_DEBUG3("CMPXDbMusic::GetSongsAtOffsetL offset[%d], count[%d]", aOffset, aCount);
+
+	if ( !iAllSongsQueryResult.Count() )
+		{
+		// If there's no cache, create a cache for the query results.
+		ExecuteQueryAllSongsL(aAttrs);
+		}
 
-    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsAtOffset, 
-                       aCount, aOffset, EOffSetQuery );
-    
-    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL() -->"); 
+	TInt limit = aOffset + aCount > iAllSongsQueryResult.Count() ?
+		iAllSongsQueryResult.Count() : aOffset + aCount;
+	for ( TInt i = aOffset; i < limit; i++ )
+		{
+        CMPXMedia* m = iAllSongsQueryResult[i];
+		aMediaArray.AppendL(*m);
+		}
+
+    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL() -->");
     }
 
 // ----------------------------------------------------------------------------
@@ -2078,7 +2133,7 @@
     TUint32 id(0);
     TUint32 artistIdForAlbum(artistId);
     if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
-        aDrive, aItemChangedMessages, id, 0))
+        aDrive, aItemChangedMessages, id))
         {
         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
         metaDataModified = (aMusicTable != NULL);
@@ -2088,7 +2143,7 @@
 
     // update the album field
     if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId,
-        aDrive, aItemChangedMessages, id, artistIdForAlbum))
+        aDrive, aItemChangedMessages, id))
         {
         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id);
         metaDataModified = (aMusicTable != NULL);
@@ -2478,6 +2533,25 @@
                     }
                 else
 #endif // ABSTRACTAUDIOALBUM_INCLUDED
+                    if (aCategory == EMPXArtist || aCategory == EMPXAlbum)
+                    {
+                    TPtrC art(KNullDesC);
+                    TPtrC artistname(KNullDesC);
+
+                    if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
+                        {
+                        art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
+                        }
+                    if (aCategory == EMPXAlbum)
+                        {
+                        if (aMedia.IsSupported(KMPXMediaMusicArtist))
+                            {
+                            artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
+                            }
+                        }
+                    iObserver.AddCategoryItemL(aCategory, name, artistname, art, aDriveId, aItemChangedMessages, itemAdded);
+                    }
+                else
                     {
                     // ignore the return value
                     iObserver.AddCategoryItemL(aCategory, name, aDriveId,
@@ -2513,8 +2587,27 @@
                     }            
                else
 #endif // ABSTRACTAUDIOALBUM_INCLUDED        
-                      {              
-                      // ignore the return value
+                    if (aCategory == EMPXArtist || aCategory == EMPXAlbum)
+                   {
+                   TPtrC art(KNullDesC);
+                   TPtrC artistname(KNullDesC);
+                   if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
+                       {
+                       art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
+                        }
+                   if (aCategory == EMPXAlbum)
+                       {
+                       if (aMedia.IsSupported(KMPXMediaMusicArtist))
+                           {
+                           artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
+                           }
+                       }
+                   iObserver.AddCategoryItemL(aCategory, KNullDesC, artistname, art, aDriveId,
+                        aItemChangedMessages, itemAdded);
+                   }
+               else
+                   {
+                   // ignore the return value
                       iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId,
                             aItemChangedMessages, itemAdded);
                       }
@@ -2585,132 +2678,7 @@
     return updated;
     }
 
-TBool CMPXDbMusic::UpdateCategoryFieldL(
-    TMPXGeneralCategory aCategory,
-    const CMPXMedia& aMedia,
-    const TMPXAttribute& aAttribute,
-    TUint32 aOldId,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TUint32& aItemId,
-    TUint32 aArtistId)
-    {
-    TBool updated(EFalse);
-    TBool itemNotRemoved( EFalse );
-    TBool itemAdded( EFalse );
 
-    // update category table and add category Id to the music table
-    if (!aOldId || aMedia.IsSupported(aAttribute))
-        {
-        TInt changeMsgCount( 0 );
-        if( aItemChangedMessages )
-            {
-            changeMsgCount = aItemChangedMessages->Count();
-            }
-
-        if (aMedia.IsSupported(aAttribute))
-            {
-            TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen));
-
-            // construct the new ID for the category record
-            // only genre is not case sensitive
-            aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory,
-                name, (aCategory != EMPXGenre));
-            if (!aOldId || (aOldId != aItemId))
-                {
-                // only add if the ID changed,
-                // otherwise the song was updated but the artist name was not
-                TPtrC art(KNullDesC);
-                if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
-                    {
-                    art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
-                    }
-
-                iObserver.AddCategoryItemL(aCategory, name, aArtistId, art, aDriveId, aItemChangedMessages, itemAdded);
-                updated = ETrue;
-                }
-            }
-        else
-            {
-            // only genre is not case sensitive
-            aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC,
-                (aCategory != EMPXGenre));
-            if (!aOldId || (aOldId != aItemId))
-                {
-				TPtrC art(KNullDesC);
-				if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
-					{
-					art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
-					}
-
-				iObserver.AddCategoryItemL(aCategory, KNullDesC, aArtistId, art, aDriveId,
-                    aItemChangedMessages, itemAdded);
-                updated = ETrue;
-                }
-            }
-
-        if (aOldId && (aOldId != aItemId))
-            {
-            iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId,
-                aItemChangedMessages, itemNotRemoved);
-            updated = ETrue;
-            }
-
-        // Special case where the item(s) has been renamed.
-        // In this case, a new category is created +1 change msg
-        //               a old category is removed +1 change msg
-        // We merge these 2 change messages into one using the deprecated ID
-        //
-        if( aItemChangedMessages )
-            {
-            TInt newChangeMsgCount( aItemChangedMessages->Count() );
-            if(  newChangeMsgCount - changeMsgCount > 0 )
-                {
-                TInt oldId = KErrNotFound;
-                TInt newId = KErrNotFound;
-                for( TInt i=0; i<newChangeMsgCount; ++i )
-                    {
-                    CMPXMessage& msg = *(*aItemChangedMessages)[i];
-
-                    TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId);
-                    TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType);
-
-                    // Look for the added and deleted category IDs
-                    //
-                    if( id == aOldId && changeType == EMPXItemDeleted )
-                        {
-                        oldId = i;
-                        }
-                    else if( id == aItemId && changeType == EMPXItemInserted )
-                        {
-                        newId = i;
-                        }
-                    }
-
-                if( oldId != KErrNotFound &&
-                    newId != KErrNotFound )
-                    {
-                    aItemChangedMessages->Remove(oldId);  // category removed
-                    aItemChangedMessages->Remove(newId);  // category added
-                    MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified,
-                                                            aCategory, KDBPluginUid, aOldId );
-                    }
-                else if ( oldId !=KErrNotFound && itemAdded ) // old item removed, new item already exist
-                    {
-                    MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified,
-                                                            aCategory, KDBPluginUid, aOldId );
-                    }
-                else if ( newId !=KErrNotFound && itemNotRemoved ) // new item added, old item still exist
-                    {
-                    MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aOldId, EMPXItemModified,
-                                                            aCategory, KDBPluginUid, aItemId );
-                    }
-                }
-            }
-        }
-
-    return updated;
-    }
 // ----------------------------------------------------------------------------
 // CMPXDbMusic::ExtraFieldsRequired
 // ----------------------------------------------------------------------------
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -412,7 +412,6 @@
         case EMcRefreshEnded:
             {
             MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcRefreshEnded");
-            iDbHandler->CheckDiskSpaceOnDrivesL();
             // ask the handler to finalize the transaction
             iDbHandler->RefreshEndL();
             iRefreshing=EFalse;
@@ -444,7 +443,6 @@
             iDbHandler->MtpStartL();
             break;
         case EMcCmdMtpEnd:
-            iDbHandler->CheckDiskSpaceOnDrivesL();
             iMtpInUse = EFalse;
             iDbHandler->MtpEndL();
             break;
@@ -4059,12 +4057,13 @@
     TInt numItems = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLNumItems );
 
     TReadDirection direction(EReadUnknown);
+/*  Ascending and Decending reads are currently not used. We optimized for offset reads.
     if( aCmd.IsSupported(KMPXCollectionCommandIdIncOpenLAscDsc) &&
         aCmd.IsSupported(KMPXCollectionCommandIdIncOpenLKeyItem) )
         {
         direction = aCmd.ValueTObjectL<TReadDirection>(KMPXCollectionCommandIdIncOpenLAscDsc);
         }
-
+*/
     CMPXCollectionPath* path =  aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCollectionCommandIdIncOpenLPath);
     CleanupStack::PushL( path );
     MPX_DEBUG_PATH( *path );
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastcollectiondbdef.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastcollectiondbdef.h	Mon Jun 21 15:37:19 2010 +0300
@@ -27,7 +27,7 @@
 
 // Db filename
 _LIT(KMCDbFile, "pcv6_1.db");
-
+_LIT(KMCDbFileEMMC, "pcv6_1i.db");
 // Collection Db resource file
 _LIT(KMPXCollectionDbResourceFile,  "PCRes.rsc");
 
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -1319,22 +1319,6 @@
 
         // append the drive to the drive list
         iDbDrives.AppendL(driveUnit);
-
-        // make sure the folder is created
-        TVolumeInfo info;
-        if (iFs.Volume(info, driveUnit) == KErrNone)
-           {
-            if (!BaflUtils::PathExists(iFs, folder))
-                {
-                // create music folder if necessary
-                TInt err(iFs.MkDirAll(folder));
-                MPX_DEBUG3("Try to create podcast folder %S return code %d", &folder, err);
-                if (err != KErrAlreadyExists)
-                    {
-                    User::LeaveIfError(err);
-                    }
-                }
-            }
         }
     }
 
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbmanager.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbmanager.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -80,7 +80,26 @@
 void CMPXPodcastDbManager::ConstructL()
     {
     MPX_FUNC("CMPXPodcastDbManager::ConstructL");
-    CMPXDbManager::ConstructL(TFileName(KMCDbFile));
+    //Find out if the system has an internal drive (eMMC)
+    TBool eMMC( EFalse );
+    TDriveInfo driveInfo;
+    if( Fs().Drive( driveInfo, EDriveE ) == KErrNone )
+    	{
+        if ( driveInfo.iDriveAtt & KDriveAttInternal )
+            eMMC = ETrue;
+        }
+
+    //Use different name for Dbs if the system has an internal drive vs. MMC-only.
+    //Since hard-coded drive letters in the Thumbnail URIs
+    //So Dbs are not interchangeable between an internal drive system and MMC-only system.
+    if( eMMC )	
+        {
+        CMPXDbManager::ConstructL(TFileName( KMCDbFileEMMC ));
+        }
+    else
+        {
+        CMPXDbManager::ConstructL(TFileName( KMCDbFile ));
+        }
     }
 
 // End of File
--- a/mpxplugins/viewplugins/views/addtracksdialog/data/mpxaddtracksdialog.rss	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/addtracksdialog/data/mpxaddtracksdialog.rss	Mon Jun 21 15:37:19 2010 +0300
@@ -288,7 +288,7 @@
 //  
 RESOURCE TBUF r_mpx_qtn_mp_unknown
     {
-    buf = qtn_mp_list_unknown;
+    buf = qtn_mp_single_list_unknown;
     }   
 
 // -----------------------------------------------------------------------------
--- a/mpxplugins/viewplugins/views/addtracksdialog/loc/mpxaddtracksdialog.loc	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/addtracksdialog/loc/mpxaddtracksdialog.loc	Mon Jun 21 15:37:19 2010 +0300
@@ -108,11 +108,11 @@
 //
 #define qtn_nmp_addsongs_num_songs  "Songs (%N)"
 
-// d:Unknown in listbox.
+// d:Unknown in Song selection view
 // l:list_single_graphic_pane_t1
-// r:3.1
+// r:5.2
 //
-#define qtn_mp_list_unknown "Unknown"
+#define qtn_mp_single_list_unknown "Unknown"
 
 // d:Text for wait note for opening
 // l:popup_note_wait_window
--- a/mpxplugins/viewplugins/views/audioeffectsview/inc/mpxaudioeffectsviewimp.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/audioeffectsview/inc/mpxaudioeffectsviewimp.h	Mon Jun 21 15:37:19 2010 +0300
@@ -23,7 +23,7 @@
 
 //INCLUDES
 #include <mpxplaybackframeworkdefs.h>
-
+#include <mpxviewactivationobserver.h>
 #include "mpxaudioeffectsview.h"
 
 
@@ -41,7 +41,7 @@
 *  @lib mpxaudioeffectsview.dll
 *  @since Series 60 3.0
 */
-NONSHARABLE_CLASS( CMPXAudioEffectsViewImp ) : public CMPXAudioEffectsView
+NONSHARABLE_CLASS( CMPXAudioEffectsViewImp ) : public CMPXAudioEffectsView, public MMPXViewActivationObserver
     {
 public:
 
@@ -116,6 +116,27 @@
     * From CAknView
     */
     void DoDeactivate();
+    
+    // from MMPXViewActivationObserver
+
+    /**
+     * From MMPXViewActivationObserver
+     * Handle view activation.
+     *
+     * @param aCurrentViewType Current view type Uid.
+     * @param aPreviousViewType Previous view type Uid.
+     */
+    void HandleViewActivation(
+        const TUid& aCurrentViewType,
+        const TUid& aPreviousViewType );
+    /**
+     * @see MMPXViewActivationObserver
+     */
+    void HandleViewUpdate(
+        TUid aViewUid,
+        MMPXViewActivationObserver::TViewUpdateEvent aUpdateEvent,
+        TBool aLoaded,
+        TInt aData);
 
 private: // data
 
@@ -126,6 +147,7 @@
     TVwsViewId iPreviousView;
     TInt iResourceOffset;
     MMPXViewUtility* iViewUtility;
+    TBool iGoPreviousView;
     };
 
 #endif    // C_CMPXAUDIOEFFECTSVIEWIMP_H
--- a/mpxplugins/viewplugins/views/audioeffectsview/src/mpxaudioeffectsviewimp.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/audioeffectsview/src/mpxaudioeffectsviewimp.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -24,7 +24,9 @@
 #include <hlplch.h>
 #include <data_caging_path_literals.hrh>
 #include <avkon.rsg>
+#include <akntitle.h>
 #include <mpxuser.h>
+#include <mpxmusicplayerviewplugin.hrh>
 
 #include <mpxplaybackutility.h>
 #include <mpxaudioeffectsview.rsg>
@@ -39,7 +41,7 @@
 
 // CONSTANTS
 _LIT( KMPXAudioEffectsRscPath, "mpxaudioeffectsview.rsc" );
-
+_LIT(KEmptyTitle, " ");
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -74,6 +76,8 @@
     iModel = CMPXAudioEffectsModel::NewL( *iPlaybackUtility );
         
     iViewUtility = MMPXViewUtility::UtilityL();
+    iViewUtility->AddObserverL(this);
+    iGoPreviousView = EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -119,6 +123,7 @@
 
     if ( iViewUtility )
         {
+		iViewUtility->RemoveObserver( this );
         iViewUtility->Close();
         }
 
@@ -170,6 +175,7 @@
             }
         case EAknSoftkeyBack:
             {
+            iGoPreviousView = ETrue;
             iViewUtility->ActivatePreviousViewL();
             break;
             }
@@ -205,6 +211,51 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPXAudioEffectsViewImp::HandleViewActivation
+// Handle view activation
+// -----------------------------------------------------------------------------
+//
+void CMPXAudioEffectsViewImp::HandleViewActivation(
+    const TUid& aCurrentViewType,
+    const TUid& /*aPreviousViewType*/ )
+    {
+    MPX_FUNC( "CMPXAudioEffectsViewImp::HandleViewActivation" );
+    if ( ( aCurrentViewType.iUid == KMPXPluginTypePlaybackUid ) && ( iGoPreviousView == EFalse ) )
+        {
+		// It is view switching when launched from other applications
+		// deactivate this view to avoid flickering 
+		// since this view is the current active view, it receives this event
+    
+        if ( iContainer )
+            {      
+            // set title to blank to avoid title flickering
+            CAknTitlePane* title( static_cast<CAknTitlePane*>
+                ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ))));
+            if ( title )
+                {
+                title->SetTextL(KEmptyTitle); 
+                title->DrawNow();
+                }
+            }
+        
+        DoDeactivate();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CMPXAudioEffectsViewImp::HandleViewUpdate
+// -----------------------------------------------------------------------------
+//
+void CMPXAudioEffectsViewImp::HandleViewUpdate(
+    TUid /* aViewUid */,
+    MMPXViewActivationObserver::TViewUpdateEvent /* aUpdateEvent */,
+    TBool /* aLoaded */,
+    TInt /* aData */)
+    {
+    // Do nothing, this should be handled by the AppUI
+    }
+
+// -----------------------------------------------------------------------------
 // CMPXAudioEffectsViewImp::DoDeactivate
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
@@ -216,6 +267,7 @@
         AppUi()->RemoveFromStack( iContainer );
         delete iContainer;
         iContainer = NULL;
+        iGoPreviousView = EFalse;
         }
     }
 
--- a/mpxplugins/viewplugins/views/collectionview/loc/mpxcollectionview.loc	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionview/loc/mpxcollectionview.loc	Mon Jun 21 15:37:19 2010 +0300
@@ -74,7 +74,7 @@
 // l:list_single_pane_t1_cp2/opt1
 // r:5.0
 //
-#define qtn_nmp_options_reorder_list "Reorder list"
+#define qtn_nmp_options_reorder_list "Move song"
 
 // d:Options menu item for removing from playlist.
 // l:list_single_pane_t1_cp2/opt1
@@ -372,9 +372,8 @@
 #define qtn_nmp_prmpt_new_name "New name:"
 
 // d:Text for an item with unknown description
-// d:Part of text for wait note
-// l:popup_note_wait_window
-// r:5.0
+// l:list_double_large_graphic_pane_t1
+// r:5.2
 //
 #define qtn_mp_list_unknown "Unknown"
 
--- a/mpxplugins/viewplugins/views/collectionviewhg/data/mpxcollectionviewhg.rss	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/data/mpxcollectionviewhg.rss	Mon Jun 21 15:37:19 2010 +0300
@@ -242,6 +242,7 @@
             {
             command = EMPXCmdReorder;
             txt = qtn_nmp_options_reorder_list;
+            flags = EEikMenuItemSpecific;
             },
         MENU_ITEM
             {
@@ -630,6 +631,26 @@
         };
     }
 
+// ---------------------------------------------------------------------------
+// r_mpx_cui_reorder_cancel_cba
+// ---------------------------------------------------------------------------
+// 
+RESOURCE CBA r_mpx_cui_reorder_cancel_cba
+    {
+    buttons = 
+        {
+        CBA_BUTTON
+            {
+            txt = text_softkey_empty;
+            },
+        CBA_BUTTON
+            {
+            id = EMPXCmdReorderCancel;
+            txt = text_softkey_cancel;
+            }
+        };
+    }
+    
 #ifdef __ENABLE_MSK
 // ---------------------------------------------------------------------------
 // r_mpx_cui_reorder_drop_cancel_cba
@@ -1850,4 +1871,24 @@
     buf = qtn_vmp_no_genres;
     }
 
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_query_conf_delete_all
+// Text for Unknown album deletion wait note.
+// ---------------------------------------------------------------------------
+//
+RESOURCE TBUF r_mpx_qtn_mus_query_conf_delete_all_unknown
+    {
+    buf = qtn_mus_query_conf_delete_all_unknown;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_nmp_query_conf_delete_group
+// Text for Unknown album deletion confirmation query.
+// ---------------------------------------------------------------------------
+//
+RESOURCE TBUF r_mpx_qtn_nmp_query_conf_delete_group_unknown
+    {
+    buf = qtn_nmp_query_conf_delete_group_unknown;
+    }
+
 // End of File
--- a/mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgcontainer.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgcontainer.h	Mon Jun 21 15:37:19 2010 +0300
@@ -224,6 +224,11 @@
      * @since 3.1
      */
     TInt CurrentLbxItemIndex() const;
+    
+	/*
+     * Mark the grabbed item for reordering the playlist.
+     */
+    void MarkGrabedItemL( TInt aIndex ); 
 
     /**
      * Get current selected listbox items indices (relative to the original
@@ -566,7 +571,11 @@
 	 */
 	void SetPreviousViewId(TUid aViewUid);
 
-
+	/**
+	 * Hides container window controls.
+	 */
+    void HideContainerWindow(); 
+	
 private:
 
     /**
@@ -1012,6 +1021,7 @@
     TRect iPopupListRect;
     TUid iPreviousViewId;
     TBool iPreviousOrientation;
+    TBool iDrawBackGround;
     };
 
 #endif  // CMPXCOLLECTIONVIEWHGCONTAINER_H
--- a/mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgimp.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgimp.h	Mon Jun 21 15:37:19 2010 +0300
@@ -1015,6 +1015,7 @@
     
     TBool                       iDialogDismissed;
     HBufC*                      iTitleWait; // Owned
+    TBool                       iGoToNowPlaying;
     };
 
 #endif  // C_CMPXCOLLECTIONVIEWHGIMP_H
--- a/mpxplugins/viewplugins/views/collectionviewhg/loc/mpxcollectionviewhg.loc	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/loc/mpxcollectionviewhg.loc	Mon Jun 21 15:37:19 2010 +0300
@@ -74,7 +74,7 @@
 // l:list_single_pane_t1_cp2/opt1
 // r:5.0
 //
-#define qtn_nmp_options_reorder_list "Reorder list"
+#define qtn_nmp_options_reorder_list "Move song"
 
 // d:Options menu item for removing from playlist.
 // l:list_single_pane_t1_cp2/opt1
@@ -387,9 +387,8 @@
 #define qtn_nmp_prmpt_new_name "New name:"
 
 // d:Text for an item with unknown description
-// d:Part of text for wait note
-// l:popup_note_wait_window
-// r:5.0
+// l:list_double_large_graphic_pane_t1
+// r:5.2
 //
 #define qtn_mp_list_unknown "Unknown"
 
@@ -712,4 +711,17 @@
 //
 #define qtn_vmp_no_genres "(no genres)"
 
+// d:Text for wait note for deleting a unknown album
+// l:popup_note_wait_window
+// r:5.2
+//
+#define qtn_mus_query_conf_delete_all_unknown "Deleting songs from 'Unknown'"
+
+// d:Text for a confirmation query shown when user attempts to delete
+// d:all tracks belonging to a unknown album.
+// l:popup_note_window/opt1
+// r:5.2
+//
+#define qtn_nmp_query_conf_delete_group_unknown "Delete all songs from 'Unknown'?"
+
 // End of File
--- a/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -162,7 +162,8 @@
 	iShuffleItem(0),
 	iSetEmptyTextNeeded(EFalse),
 	iPopupListRect(TRect(0,0,0,0)),
-	iPreviousViewId(TUid::Uid(0))
+	iPreviousViewId(TUid::Uid(0)),
+	iDrawBackGround(EFalse)
     {
     }
 
@@ -818,7 +819,7 @@
 //
 void CMPXCollectionViewHgContainer::Draw(const TRect& /*aRect*/) const
     {
-    if ( iContext == EContextUnknown )
+    if ( iContext == EContextUnknown || iDrawBackGround != EFalse )
         {
         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
         MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
@@ -1502,10 +1503,15 @@
     if( iListWidget )
         {
         TRect clientRect = ((CAknView*)iView)->ClientRect();
-        TInt mediaIndex = MediaIndex(iListWidget->SelectedIndex());
+        TInt index = MediaIndex(iListWidget->SelectedIndex()); 
+        TInt mediaIndex (index);
         mediaIndex = ( KErrNotFound == mediaIndex ) ? iListWidget->FirstIndexOnScreen() : mediaIndex;
         mediaIndex = ( mediaIndex >= 0 && (mediaIndex < (mediaCount)) ) ? mediaIndex : (mediaCount - 1);
-
+		// No need to modify index of first item, if reorder is activated
+        if ( IsInReorderMode() && index == KErrNotFound )
+            {
+            mediaIndex = KErrNotFound;  
+            }      
         TInt prevItemCount = iListWidget->ItemCount();
 
         iListWidget->InitScreenL( clientRect );
@@ -1520,6 +1526,19 @@
             iListWidget->ResizeL( aCount );
             ProvideDataWithoutThumbnailsL(aMediaArray);
             iListWidget->SetSelectedIndex( mediaIndex + iShuffleItem );
+		    // Reserve mark icon for playlist in reorder mode
+			if ( IsInReorderMode() )
+                {
+                MarkGrabedItemL( CurrentLbxItemIndex() + 1 );
+                }
+				
+			// To remove flicker of default albumart in playlist track level
+			if ( iContext == EContextItemPlaylist )
+			    {  
+            	iDefaultIconSet = EFalse;
+            	// Setting an empty icon to the list as default icon.
+            	iListWidget->SetDefaultIconL(CGulIcon::NewL(new CFbsBitmap()));
+            	}	
             }
         else
             {
@@ -1890,7 +1909,7 @@
 		   {
 	     ResolvePopupListSizeL();
 		   }
-		
+
     iMediaWall->SetOpenedItemRect( iPopupListRect );
     iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationZoomToFront );
 
@@ -2221,6 +2240,11 @@
     // ganes list components still uses this version of the HandleOpen
     if ( iContext == EContextItemAlbum  )
 		{
+        if( iCurrentViewType == EMPXViewTBone )
+            {
+            iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
+            iMediaWall->DrawNow();
+            }
         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
 		UpdatePathAndOpenL(index);
         // Start animation now as next view activated is
@@ -2242,15 +2266,28 @@
     else if ( iContext == EContextGroupSong || iContext == EContextItemPlaylist || iContext == EContextItemGenre )
         {
         // Check if shuffle play all was selected.
-        if (!ShufflePlayAllL(index))
+        TBool inReorderMode ( IsInReorderMode() );
+        if ( inReorderMode && index == KErrNotFound )
+            {
+			// If Shuffle is selected in reorder mode than Grabbed item should move 
+			// to first position in the playlist, just after shuffle item.
+            SetLbxCurrentItemIndex(1);
+            iView->ProcessCommandL( EMPXCmdCommonEnterKey );
+            }
+        else if ( !ShufflePlayAllL(index) )
             {
             // To open the selected album.
             iView->ProcessCommandL( EMPXCmdCommonEnterKey );
             }
-        // Start animation now as next view activated is
-        // now playing view. We will end animation in now playing view.
-        SetupTransitionType(KMPXInterviewTransition);
-        BeginFullScreenAnimation();
+
+		// Disable transition in reorder mode
+        if( !inReorderMode )
+            {   
+			// Start animation now as next view activated is
+            // now playing view. We will end animation in now playing view.
+            SetupTransitionType(KMPXInterviewTransition);
+            BeginFullScreenAnimation();
+            }
         }
     else
 		{
@@ -5083,6 +5120,25 @@
     }
 
 // ---------------------------------------------------------------------------
+// Hides container window controls
+// ---------------------------------------------------------------------------
+//
+void CMPXCollectionViewHgContainer::HideContainerWindow()
+    {
+    if( iMediaWall )
+        iMediaWall->MakeVisible(EFalse);
+    if( iListWidget )
+        iListWidget->MakeVisible(EFalse);
+    if( iMwListWidget )
+        iMwListWidget->MakeVisible(EFalse);
+
+	// draw background application rectangle
+    iDrawBackGround = ETrue;
+    DrawNow();
+    iDrawBackGround = EFalse;
+     }
+
+// ---------------------------------------------------------------------------
 // Prepare and begin fullscreen animation effects
 // ---------------------------------------------------------------------------
 //
@@ -5171,7 +5227,7 @@
     CleanupStack::PushL( dialog );
 
     listBox->ConstructL( dialog, EAknListBoxViewerFlags );
-    
+
     // title can be hardcoded because it is not shown to user. Just for the calculations.
     dialog->SetTitleL(_L("Foo"));
     iPopupListRect = dialog->LayoutRect();
@@ -5179,4 +5235,15 @@
     CleanupStack::PopAndDestroy( dialog );
     CleanupStack::PopAndDestroy( listBox );
     }
+
+// ---------------------------------------------------------------------------
+// Marked the grabbed item for reordering
+// ---------------------------------------------------------------------------
+//
+void CMPXCollectionViewHgContainer::MarkGrabedItemL(TInt aIndex)
+    {
+	MPX_DEBUG2( "CMPXCollectionViewHgContainer::MarkGrabedItemL item %d", aIndex + iShuffleItem );
+    iListWidget->Mark( aIndex + iShuffleItem );
+    }
+
 //  End of File
--- a/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgimp.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgimp.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -131,7 +131,7 @@
 _LIT( KCategoryEmpty, "" );
 
 const TInt KIncrementalDelayNone = 0;
-const TInt KIncrementalDelayHalfSecond = 1000000;
+const TInt KIncrementalDelayHalfSecond = 500000;
 const TInt KIncrementalFetchBlockSize = 400;
 const TInt KIncrementalDirectionCount = 8;
 const TInt KWaitNoteImpUid = 0x101FFC6C; // refresh wait note UID
@@ -167,6 +167,7 @@
 const TInt KMPXCollectionArtistAlbum( 3 );
 const TInt KMPXCollectionGenre( 5 );
 
+_LIT(KEmptyTitle, " ");
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -357,6 +358,7 @@
     // grab the current process priority
     RProcess proc;
     iPriority = proc.Priority();
+    iGoToNowPlaying = EFalse; 
     }
 
 void CMPXCollectionViewHgImp::HandleStatusPaneSizeChange()
@@ -986,15 +988,10 @@
                         // check for unknown entry
                         // if it's the last entry, and it's null text
                         // load "unknown" text to display in prompt
-                        HBufC* unknownText( StringLoader::LoadLC( R_MPX_QTN_MP_UNKNOWN ) );
                         waitNoteText = StringLoader::LoadLC(
-                            R_MPX_QTN_MUS_QUERY_CONF_DELETE_ALL, *unknownText );
-                        promptTxt = StringLoader::LoadL(
-                            R_MPX_QTN_NMP_QUERY_CONF_DELETE_GROUP, *unknownText );
-                        CleanupStack::Pop( waitNoteText );
-                        CleanupStack::PopAndDestroy( unknownText );
-                        CleanupStack::PushL( waitNoteText );
-                        CleanupStack::PushL( promptTxt );
+                            R_MPX_QTN_MUS_QUERY_CONF_DELETE_ALL_UNKNOWN);
+                        promptTxt = StringLoader::LoadLC(
+                            R_MPX_QTN_NMP_QUERY_CONF_DELETE_GROUP_UNKNOWN);
                         }
                     else
                         {
@@ -1517,6 +1514,8 @@
     TInt currentItem( iContainer->CurrentLbxItemIndex() );
     iContainer->EnableFindBox( EFalse );
     iContainer->SetReorderGrabbedMode( ETrue, currentItem );
+	// mark the grabbed item
+    iContainer->MarkGrabedItemL( currentItem );
     if ( !iContainer->IsInReorderMode() )
         {
         iContainer->UpdateReorderTitleIconL();
@@ -1541,7 +1540,7 @@
             iDuration = NULL;
             }
         iContainer->ActivateReorderMode( ETrue );
-        SetNewCbaL( R_MPX_CUI_REORDER_DROP_CANCEL_CBA );
+        SetNewCbaL( R_MPX_CUI_REORDER_CANCEL_CBA );
         }
     iContainer->SetLbxCurrentItemIndexAndDraw( currentItem );
     UpdateReorderNaviPaneL();
@@ -1596,6 +1595,7 @@
         iContainer->ActivateReorderMode( EFalse );
         iContainer->EnableFindBox( ETrue );
         }
+    iHandlingKeyEvent = ETrue;
     iContainer->HandleLbxItemAdditionPreserveIndexL();
     }
 
@@ -4136,7 +4136,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 );
 
@@ -5240,6 +5240,7 @@
             }
         case EMPXCmdGoToNowPlaying:
             {
+            iGoToNowPlaying = ETrue;
             AppUi()->HandleCommandL( aCommand );
             break;
             }
@@ -6069,6 +6070,8 @@
 	   delete iTitle;
        iTitle = NULL;
        }
+    // for Avkon calling Deactivate, not manually hiding window contorls, reset iGoToNowPlaying
+    iGoToNowPlaying = EFalse;
     // Cleanup view deactivation observer
     AppUi()->RemoveViewDeactivationObserver( this );
     }
@@ -6813,75 +6816,57 @@
 								
             HandleInitMusicMenuPaneL(aMenuPane);
             aMenuPane->SetItemDimmed( EMPXCmdGoToNowPlaying, NowPlayingOptionVisibilityL() );
-			if ( isListEmpty )
+            aMenuPane->SetItemDimmed( EMPXCmdFind, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdUpnpPlayVia, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdUPnPAiwCmdCopyToExternalCriteria, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdCreatePlaylist, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdAddToPlaylist, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdReorder, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdSend, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdDelete, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdRemove, ETrue );
+            aMenuPane->SetItemDimmed( EMPXCmdPlayItem, ETrue );
+            
+            if( iContainer->IsInReorderMode() )
+                break;
+            
+			if ( usbUnblockingStatus == EMPXUSBUnblockingPSStatusActive )
 				{
-				aMenuPane->SetItemDimmed( EMPXCmdFind, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdUpnpPlayVia, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdUPnPAiwCmdCopyToExternalCriteria, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdCreatePlaylist, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdAddToPlaylist, ETrue );
+				aMenuPane->SetItemDimmed( EMPXCmdAddSongs, ETrue );
+				aMenuPane->SetItemDimmed( EMPXCmdSend, SendOptionVisibilityL() );
+				aMenuPane->SetItemDimmed( EMPXCmdRemove, ETrue );
 				aMenuPane->SetItemDimmed( EMPXCmdReorder, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdSend, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdDelete, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdRemove, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdPlayItem, ETrue );
+				}
+			else
+				{
+				TInt selectionCount( 0 );
+				iSelectionIndexCache = iContainer->CurrentSelectionIndicesL(); // not owned
+				if ( iSelectionIndexCache)
+					{
+					selectionCount = iSelectionIndexCache->Count();
+					}
+				// do not display add songs option when marking is on or USB is connected
 				if ( usbUnblockingStatus == EMPXUSBUnblockingPSStatusActive )
 					{
 					aMenuPane->SetItemDimmed( EMPXCmdAddSongs, ETrue );
 					}
-                else
+				else
+					{
+					aMenuPane->SetItemDimmed( EMPXCmdAddSongs, selectionCount > 0 );
+					}
+
+				if ( iContainer->CurrentLbxItemIndex() > KErrNotFound )
 					{
-					aMenuPane->SetItemDimmed( EMPXCmdAddSongs, EFalse );
+					aMenuPane->SetItemDimmed( EMPXCmdSend, SendOptionVisibilityL() );
+					aMenuPane->SetItemDimmed( EMPXCmdRemove, EFalse );
+					if ( iContainer->CurrentListItemCount() > 1 )
+					    {
+					    aMenuPane->SetItemDimmed( EMPXCmdReorder, EFalse );
+					    }
 					}
 				}
-			else
-				{
-                aMenuPane->SetItemDimmed( EMPXCmdUpnpPlayVia, ETrue );
-                aMenuPane->SetItemDimmed( EMPXCmdUPnPAiwCmdCopyToExternalCriteria, ETrue );
-                aMenuPane->SetItemDimmed( EMPXCmdFind, ETrue );
-                aMenuPane->SetItemDimmed( EMPXCmdCreatePlaylist, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdAddToPlaylist, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdReorder, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdDelete, ETrue );
-                aMenuPane->SetItemDimmed( EMPXCmdSend, ETrue );
-                aMenuPane->SetItemDimmed( EMPXCmdRemove, ETrue );
-				aMenuPane->SetItemDimmed( EMPXCmdPlayItem, ETrue );
 				
-
-
-				if ( usbUnblockingStatus == EMPXUSBUnblockingPSStatusActive )
-					{
-					aMenuPane->SetItemDimmed( EMPXCmdAddSongs, ETrue );
-					aMenuPane->SetItemDimmed( EMPXCmdSend, SendOptionVisibilityL() );
-					aMenuPane->SetItemDimmed( EMPXCmdRemove, ETrue );
-					}
-				else
-					{
-					TInt selectionCount( 0 );
-					iSelectionIndexCache = iContainer->CurrentSelectionIndicesL(); // not owned
-					if ( iSelectionIndexCache)
-						{
-						selectionCount = iSelectionIndexCache->Count();
-						}
-					// do not display add songs option when marking is on or USB is connected
-					if ( usbUnblockingStatus == EMPXUSBUnblockingPSStatusActive )
-						{
-						aMenuPane->SetItemDimmed( EMPXCmdAddSongs, ETrue );
-						}
-					else
-						{
-						aMenuPane->SetItemDimmed( EMPXCmdAddSongs, selectionCount > 0 );
-						}
-
-					if ( iContainer->CurrentLbxItemIndex() > KErrNotFound )
-						{
-						aMenuPane->SetItemDimmed( EMPXCmdSend, SendOptionVisibilityL() );
-						aMenuPane->SetItemDimmed( EMPXCmdRemove, EFalse );
-						}
-					}
-				} 
-
-            CMPXCollectionViewListBoxArray* array =
+			CMPXCollectionViewListBoxArray* array =
             static_cast<CMPXCollectionViewListBoxArray*>(
                     iContainer->ListBoxArray() );
             const CMPXMedia& containerMedia = array->ContainerMedia();
@@ -6909,7 +6894,11 @@
             aMenuPane->SetItemDimmed( EMPXCmdUseAsCascade, ETrue );
             aMenuPane->SetItemDimmed( EMPXCmdAlbumArt, ETrue );
             aMenuPane->SetItemDimmed( EMPXCmdFindInMusicShop, ETrue );
-
+            aMenuPane->SetItemDimmed( EMPXCmdSongDetails, ETrue );
+            
+            if( iContainer->IsInReorderMode() )
+                break;
+            
 			TInt selectionCount( 0 );
 			iSelectionIndexCache = iContainer->CurrentSelectionIndicesL(); // not owned
 			if ( iSelectionIndexCache)
@@ -7150,9 +7139,8 @@
                 {
                 ProcessCommandL( iContainer->IsInReorderMode() ?
                     EMPXCmdReorderDrop : EMPXCmdReorderGrab );
-                iIsGrabbed = !iIsGrabbed;
-                }
-            else if ( !iHandlingKeyEvent )
+                }
+		    else if ( !iHandlingKeyEvent )
                 {
                 TMPXPlaybackState pbState( iPlaybackUtility->StateL() );
                 TBool isEqual( EFalse );
@@ -7289,8 +7277,7 @@
             {
             SaveCurrentPlaylistL();
             iContainer->ConfirmReorderL();
-            DeactivateReorderGrabbedModeL( EFalse );
-            SetNewCbaL( R_MPX_CUI_REORDER_GRAB_DONE_CBA );
+            DeactivateReorderGrabbedModeL( ETrue );
             break;
             }
         case EMPXCmdReorderGrab:
@@ -7947,6 +7934,26 @@
             iInSongDetails = EFalse;
             }
         }
+     else if ( ( aCurrentViewType.iUid == KMPXPluginTypePlaybackUid ) && ( iGoToNowPlaying == EFalse ) )        
+        {
+		// It is view switching when launched from other applications
+		// hide this view to avoid flickering 
+		// since this view is the current active view, it receives this event
+
+		if ( iContainer )
+        	{
+            iContainer->HideContainerWindow();
+   	  
+            // set title to blank to avoid title flickering
+            CAknTitlePane* title( static_cast<CAknTitlePane*>
+                ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ))));
+            if ( title )
+                {
+                title->SetTextL(KEmptyTitle); 
+                title->DrawNow();
+	            }
+		    }
+        }
     }
 
 // -----------------------------------------------------------------------------
--- a/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhglistboxarray.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhglistboxarray.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -383,33 +383,27 @@
         flags = entry->ValueTObjectL<TUint>( KMPXMediaGeneralFlags );
         }
 
-    // reorder icon
-    if ( ( iReorder ) && ( aIndex == iMovedIndex ) )
+  
+    // All icons should also be visible even in reorder mode.
+    // playback status icon
+    if ( iIndex == index )
         {
-        iconIndices.Append( GetReorderIcon() );
-        }
-    else if ( !iReorderActivated )
-        {
-        // playback status icon
-        if ( iIndex == index )
+        switch ( iPbState )
             {
-            switch ( iPbState )
+            case EPbStatePlaying:
                 {
-                case EPbStatePlaying:
-                    {
-                    iconIndices.Append( EMPXClvIconPlay );
-                    break;
-                    }
-                case EPbStatePaused:
-                    {
-                    iconIndices.Append( EMPXClvIconPause );
-                    break;
-                    }
-                default:
-                    {
-                    // other playback states, not handled
-                    break;
-                    }
+                iconIndices.Append( EMPXClvIconPlay );
+                break;
+                }
+            case EPbStatePaused:
+                {
+                iconIndices.Append( EMPXClvIconPause );
+                break;
+                }
+            default:
+                {
+                // other playback states, not handled
+                break;
                 }
             }
         }
@@ -1056,51 +1050,40 @@
         ptr.Format( KMPXCommonListboxFormatString, iconID, &title );
 
         iconID = EMPXClvIconNone;
-        // reorder icon
-        if ( ( iReorder ) && ( aIndex == iMovedIndex ) )
+        // All icons should also be visible even in reorder mode. 
+        // playback status icon
+        if ( iIndex == index )
             {
-            iconID = GetReorderIcon();
-            }
-        else if ( !iReorderActivated )
-            {
-            // playback status icon
-            if ( iIndex == index )
+            switch ( iPbState )
                 {
-                switch ( iPbState )
+                case EPbStatePlaying:
+                    {
+                    iconID = EMPXClvIconPlay;
+                    break;
+                    }
+                case EPbStatePaused:
                     {
-                    case EPbStatePlaying:
-                        {
-                        iconID = EMPXClvIconPlay;
-                        break;
-                        }
-                    case EPbStatePaused:
-                        {
-                        iconID = EMPXClvIconPause;
-                        break;
-                        }
-                    case EPbStateSeekingForward:
-                        {
-                        iconID = EMPXClvIconForward;
-                        break;
-                        }
-                    case EPbStateSeekingBackward:
-                        {
-                        iconID = EMPXClvIconRewind;
-                        break;
-                        }
-                    default:
-                        {
-                        // other playback states, not handled
-                        break;
-                        }
+                    iconID = EMPXClvIconPause;
+                    break;
+                    }
+                case EPbStateSeekingForward:
+                    {
+                    iconID = EMPXClvIconForward;
+                    break;
+                    }
+                case EPbStateSeekingBackward:
+                    {
+                    iconID = EMPXClvIconRewind;
+                    break;
+                    }
+                default:
+                    {
+                    // other playback states, not handled
+                    break;
                     }
                 }
             }
-        else
-            {
-            // Do nothing
-            }
-
+       
         if ( iconID != EMPXClvIconNone )
             {
             ptr.Append( KMPXTab );
--- a/mpxplugins/viewplugins/views/commoncontainer/inc/mpxcommoncontainerhgimp.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/commoncontainer/inc/mpxcommoncontainerhgimp.h	Mon Jun 21 15:37:19 2010 +0300
@@ -477,6 +477,11 @@
      * @param aIndex Opened item index.
      */
     void HandleOpenL( TInt aIndex );
+    
+    /**
+     * Hides container list view
+     */
+    void HideListView();
 
 public: // from base class MThumbnailManagerObserver
 
--- a/mpxplugins/viewplugins/views/commoncontainer/src/mpxcommoncontainerhgimp.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/commoncontainer/src/mpxcommoncontainerhgimp.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -296,6 +296,17 @@
     return iBottomIndex;
     }
 
+// -----------------------------------------------------------------------------
+// Hides listbox
+// -----------------------------------------------------------------------------
+//
+void CMPXCommonContainerHgImp::HideListView()
+    {
+    if ( iListWidget )
+           {
+           iListWidget->MakeVisible(EFalse);
+           }
+    }
 
 // -----------------------------------------------------------------------------
 // Gets current listbox item index (relative to the original listbox).
--- a/mpxplugins/viewplugins/views/inc/mpxcommoncontainer.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/inc/mpxcommoncontainer.h	Mon Jun 21 15:37:19 2010 +0300
@@ -304,6 +304,11 @@
     virtual void ConstructContainerL( TMPXCommonContainerCollectionType aCollectionType ) = 0;
 
     /**
+     * Hides container list view
+     */
+    virtual void HideListView() = 0;
+    
+    /**
      * Enable/disable find box
      *
      * @since 3.1
--- a/mpxplugins/viewplugins/views/podcastview/data/mpxpodcastcollectionview.rss	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/data/mpxpodcastcollectionview.rss	Mon Jun 21 15:37:19 2010 +0300
@@ -363,17 +363,7 @@
     {
     buf = qtn_mp_title_my_podcast;
     }
-
-            
-// -----------------------------------------------------------------------------
-// r_mpx_qtn_nmp_unknown_title
-// -----------------------------------------------------------------------------
-//  
-RESOURCE TBUF r_mpx_qtn_nmp_unknown_title
-    {
-    buf = qtn_mp_list_unknown;
-    }   
-
+           
 // ---------------------------------------------------------------------------
 // r_mpx_playback_collection_via_sub_menu
 // Collection view UPnP Play Via sub menu items.
--- a/mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewcontainer.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewcontainer.h	Mon Jun 21 15:37:19 2010 +0300
@@ -121,6 +121,11 @@
      * @return Indicator icon indices
      */
     RArray<TInt> IndicatorsL( TInt aIndex );
+    
+    /**
+     * Hides container controls.
+     */
+    void HideContainerWindow();
 
 private:
 
--- a/mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewimp.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/inc/mpxpodcastcollectionviewimp.h	Mon Jun 21 15:37:19 2010 +0300
@@ -681,6 +681,7 @@
 #ifdef UPNP_INCLUDED
     CUpnpCopyCommand* iUpnpCopyCommand; 
 #endif
+    TBool iGoToNowPlaying;
     };
 
 #endif  // C_CMPXPODCASTCOLLECTIONVIEWIMP_H
--- a/mpxplugins/viewplugins/views/podcastview/loc/mpxpodcastcollectionview.loc	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/loc/mpxpodcastcollectionview.loc	Mon Jun 21 15:37:19 2010 +0300
@@ -152,7 +152,7 @@
 
 // d:Collection details popup label.
 // d:Label for collection details popup.
-// l:list_single_heading_pane_t1_cp2
+// l:list_single_heading_pane_t2_cp2
 // r:5.0
 //
 #define qtn_nmp_details_phone_memory "Phone Memory"
@@ -199,12 +199,6 @@
 //
 #define qtn_nmp_memory_unavailable "Unavailable"
 
-// d:Unknown in listbox.
-// l:list_single_graphic_pane_t1
-// r:5.0
-//
-#define qtn_mp_list_unknown "Unknown"
-
 // d:Text for wait note for deleting one item
 // l:popup_note_wait_window
 // r:5.0
--- a/mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewcontainer.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewcontainer.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -134,6 +134,18 @@
     }
 
 // ---------------------------------------------------------------------------
+// Hides container list box
+// ---------------------------------------------------------------------------
+//
+void CMPXPodcastCollectionViewContainer::HideContainerWindow()
+    {
+        if ( iCommonContainer )
+            {
+            iCommonContainer->HideListView();
+            }
+    }
+	
+// ---------------------------------------------------------------------------
 // Sets the current view to be used to determine the correct help context
 // ---------------------------------------------------------------------------
 //
--- a/mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewimp.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewimp.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -125,6 +125,8 @@
 // MACROS
 _LIT(KMPXCollDetailsItemsFormat, "%S\t%S");
 
+_LIT(KEmptyTitle, " ");
+
 #ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
 #define KMusicCollectionUid 0x101FFC3A
 #endif
@@ -176,6 +178,7 @@
 
     if (iViewUtility)
         {
+        iViewUtility->RemoveObserver( this );
         iViewUtility->Close();
         }
 
@@ -489,6 +492,7 @@
     // status of listbox items before the list box is updated in HandleOpen
     iHandleOpenProcessed = EFalse;
     iSelectedItem = KMPXInvalidItemId;
+    iGoToNowPlaying = EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -662,7 +666,7 @@
                 MPX_DEBUG2("CMPXPodcastCollectionViewImp::UpdateTitlePaneL Title is %S", iTitle);
                 if (iTitle->Length() == 0)
                     {
-                    HBufC* titleText = StringLoader::LoadLC(R_MPX_QTN_NMP_UNKNOWN_TITLE);
+                    HBufC* titleText = StringLoader::LoadLC(R_MPX_TITLE_UNKNOWN_PODCAST);
                     title->SetTextL(*titleText);
                     CleanupStack::PopAndDestroy(titleText);
                     }
@@ -3089,6 +3093,7 @@
             }
         case EMPXCmdGoToNowPlaying:
             {
+            iGoToNowPlaying = ETrue;
             AppUi()->HandleCommandL( aCommand );
             break;
             }
@@ -3554,6 +3559,8 @@
         iNumEpisode = NULL;
         TRAP_IGNORE(UpdateNaviPaneL());
         }
+	// for Avkon calling Deactivate, not manually hiding controls, reset iGoToNowPlaying
+    iGoToNowPlaying = EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -3938,6 +3945,11 @@
                 CleanupStack::PushL(cpath);
 
                 MPX_DEBUG_PATH(*cpath);
+                
+				// It is in episode list view and opens now playing view
+                if ( cpath->Levels() == 3 )
+                    iGoToNowPlaying = ETrue;
+                
                 if (cpath->Levels() == (iLastDepth + 1))
                     {
                     // navigated in one level
@@ -4239,7 +4251,23 @@
     if ( aCurrentViewType.iUid == KMPXPluginTypeCollectionUid )
         {
         TRAP_IGNORE( UpdateNaviPaneL() );
-        }
+        } 
+    else if ( ( aCurrentViewType.iUid == KMPXPluginTypePlaybackUid ) && ( iGoToNowPlaying == EFalse ) ) 
+        {
+        if ( iContainer )
+            {
+            iContainer->HideContainerWindow();
+                    
+            // set title to blank to avoid title flickering
+            CAknTitlePane* title( static_cast<CAknTitlePane*>
+                ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ))));
+            if ( title )
+                {
+                title->SetTextL(KEmptyTitle); 
+                title->DrawNow();
+                }
+            }
+     	}   
     }
 
 // -----------------------------------------------------------------------------
--- a/mpxplugins/viewplugins/views/waitnotedialog/inc/mpxscanningdialog.h	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/waitnotedialog/inc/mpxscanningdialog.h	Mon Jun 21 15:37:19 2010 +0300
@@ -126,6 +126,7 @@
     CAsyncCallBack*        iAsyncCallBack; //owned
     TAsyncEvent            iAsyncEvent;
     TBool                  iCancelScan;
+    TBool                  iRefreshEnd;
     };
 
 
--- a/mpxplugins/viewplugins/views/waitnotedialog/src/mpxscanningdialog.cpp	Wed Jun 09 09:38:28 2010 +0300
+++ b/mpxplugins/viewplugins/views/waitnotedialog/src/mpxscanningdialog.cpp	Mon Jun 21 15:37:19 2010 +0300
@@ -55,6 +55,7 @@
     iInitialCount = 0;
     isCollectionDBChanged = EFalse;
     iAsyncEvent = ECmdIdle;
+    iRefreshEnd = EFalse;
 
     }
 
@@ -183,11 +184,14 @@
 		    iCancelScan = ETrue;
 			}
 
-        // When stop refreshing library, prompt a process waiting dialog.
-        // Inform user to wait for the updating library.
-        HBufC* waitText = StringLoader::LoadLC( R_MPX_UPDATING_LIBRARY_TXT );  
-        DisplayProcessWaitDialogL( R_MPX_GENERIC_WAIT_NOTE, *waitText );
-        CleanupStack::PopAndDestroy( waitText );
+		if (!iRefreshEnd)
+			{
+			// When stop refreshing library, prompt a process waiting dialog.
+			// Inform user to wait for the updating library.
+			HBufC* waitText = StringLoader::LoadLC( R_MPX_UPDATING_LIBRARY_TXT );
+			DisplayProcessWaitDialogL( R_MPX_GENERIC_WAIT_NOTE, *waitText );
+			CleanupStack::PopAndDestroy( waitText );
+			}
         }
     else if( iScanningError >= KErrNone )
         {
@@ -354,6 +358,7 @@
                 }
             if( op == EMcMsgRefreshStart )
                 {
+				iRefreshEnd = EFalse;
                 isCollectionDBChanged = EFalse;
                 MPX_DEBUG1("refreshStart store the initial count");
                 iInitialCount = songTotal;
@@ -396,6 +401,7 @@
                     }
                 };
             
+			iRefreshEnd = ETrue;
             // If cancel was pressed, iWaitDialog is NULL
             //
             if( iWaitDialog )