Revision: 201015
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 12:29:20 +0300
changeset 22 ecf06a08d4d9
parent 20 82baf59ce8dd
child 23 d45f4c087764
child 25 3ec52facab4d
child 34 2c5162224003
Revision: 201015 Kit: 201018
app/app.pro
app/data/service_conf.xml
app/inc/mpmainwindow.h
app/src/mpmainwindow.cpp
inc/mpcollectiondatamodel.h
inc/mpcommondefs.h
inc/mpengine.h
inc/mpmpxcollectiondata.h
inc/mpmpxcollectionviewdefs.h
inc/mpplaybackdata.h
inc/musicplayerbldvariant.hrh
mpdata/bwins/mpdatau.def
mpdata/eabi/mpdatau.def
mpdata/inc/mpcollectionalbumartmanager.h
mpdata/inc/mpmpxcollectiondata_p.h
mpdata/mpdata.pro
mpdata/rom/mpdata.iby
mpdata/rom/rom.pri
mpdata/src/mpcollectionalbumartmanager.cpp
mpdata/src/mpcollectiondatamodel.cpp
mpdata/src/mpmpxcollectiondata.cpp
mpdata/src/mpmpxcollectiondata_p.cpp
mpdata/src/mpplaybackdata.cpp
mpdata/tsrc/unittest_mpcollectionalbumartmanager/inc/unittest_mpcollectionalbumartmanager.h
mpdata/tsrc/unittest_mpcollectionalbumartmanager/resources/default_album.png
mpdata/tsrc/unittest_mpcollectionalbumartmanager/resources/unittest_mpcollectionalbumartmanagerresources.qrc
mpdata/tsrc/unittest_mpcollectionalbumartmanager/src/unittest_mpcollectionalbumartmanager.cpp
mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/mpmpxcollectiondata.h
mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/thumbnailmanager_qt.h
mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/src/mpmpxcollectiondata.cpp
mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/src/thumbnailmanager_qt.cpp
mpdata/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager.pro
mpdata/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager_template.pkg
mpdata/tsrc/unittest_mpcollectiondatamodel/inc/unittest_helper.h
mpdata/tsrc/unittest_mpcollectiondatamodel/inc/unittest_mpcollectiondatamodel.h
mpdata/tsrc/unittest_mpcollectiondatamodel/resources/default_album.png
mpdata/tsrc/unittest_mpcollectiondatamodel/resources/unittest_mpcollectiondatamodelresources.qrc
mpdata/tsrc/unittest_mpcollectiondatamodel/src/unittest_helper.cpp
mpdata/tsrc/unittest_mpcollectiondatamodel/src/unittest_mpcollectiondatamodel.cpp
mpdata/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpcollectionalbumartmanager.h
mpdata/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpmpxcollectiondata.h
mpdata/tsrc/unittest_mpcollectiondatamodel/stub/src/mpcollectionalbumartmanager.cpp
mpdata/tsrc/unittest_mpcollectiondatamodel/stub/src/mpmpxcollectiondata.cpp
mpdata/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel.pro
mpdata/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel_template.pkg
mpdata/tsrc/unittest_mpmpxcollectiondata/inc/unittest_mpmpxcollectiondata.h
mpdata/tsrc/unittest_mpmpxcollectiondata/src/unittest_mpmpxcollectiondata.cpp
mpdata/tsrc/unittest_mpmpxcollectiondata/unittest_mpmpxcollectiondata.pro
mpdata/tsrc/unittest_mpplaybackdata/inc/unittest_mpplaybackdata.h
mpdata/tsrc/unittest_mpplaybackdata/src/unittest_mpplaybackdata.cpp
mpdata/tsrc/unittest_mpplaybackdata/stub/inc/thumbnailmanager_qt.h
mpdata/tsrc/unittest_mpplaybackdata/stub/src/thumbnailmanager_qt.cpp
mpdata/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata.pro
mpdata/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata_template.pkg
mpengine/bwins/mpengineu.def
mpengine/eabi/mpengineu.def
mpengine/inc/mpmpxcollectionframeworkwrapper.h
mpengine/inc/mpmpxcollectionframeworkwrapper_p.h
mpengine/inc/mpmpxframeworkwrapper.h
mpengine/inc/mpmpxframeworkwrapper_p.h
mpengine/inc/mpmpxharvesterframeworkwrapper.h
mpengine/inc/mpmpxharvesterframeworkwrapper_p.h
mpengine/inc/mpmpxisolatedcollectionhelper.h
mpengine/inc/mpmpxplaybackframeworkwrapper.h
mpengine/inc/mpmpxplaybackframeworkwrapper_p.h
mpengine/inc/mpsongscanner.h
mpengine/mpengine.pro
mpengine/src/mpengine.cpp
mpengine/src/mpmpxcollectionframeworkwrapper.cpp
mpengine/src/mpmpxcollectionframeworkwrapper_p.cpp
mpengine/src/mpmpxframeworkwrapper.cpp
mpengine/src/mpmpxframeworkwrapper_p.cpp
mpengine/src/mpmpxharvesterframeworkwrapper.cpp
mpengine/src/mpmpxharvesterframeworkwrapper_p.cpp
mpengine/src/mpmpxisolatedcollectionhelper.cpp
mpengine/src/mpmpxplaybackframeworkwrapper.cpp
mpengine/src/mpmpxplaybackframeworkwrapper_p.cpp
mpengine/src/mpsongscanner.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/inc/unittest_mpmpxcollectionframeworkwrapper.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/src/unittest_mpmpxcollectionframeworkwrapper.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpmpxcollectiondata.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpmpxisolatedcollectionhelper.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionhelperfactory.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionopenutility.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionuihelper.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionutility.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxplaybackutility.h
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpmpxcollectiondata.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpmpxisolatedcollectionhelper.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionhelperfactory.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionopenutility.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionuihelper.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionutility.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxplaybackutility.cpp
mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/unittest_mpmpxcollectionframeworkwrapper.pro
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/inc/unittest_mpmpxharvesterframeworkwrapper.h
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/src/unittest_mpmpxharvesterframeworkwrapper.cpp
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/inc/mpxcollectionutility.h
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/inc/mpxharvesterutility.h
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/src/mpxcollectionutility.cpp
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/src/mpxharvesterutility.cpp
mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/unittest_mpmpxharvesterframeworkwrapper.pro
mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/inc/unittest_mpmpxisolatedcollectionhelper.h
mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/src/unittest_mpmpxisolatedcollectionhelper.cpp
mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/inc/mpxcollectionopenutility.h
mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/src/mpxcollectionopenutility.cpp
mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/unittest_mpmpxisolatedcollectionhelper.pro
mpserviceplugins/audioeffects/group/mpxaudioeffectengine.mmp
mpserviceplugins/inc/mpxdbcommonutil.h
mpserviceplugins/inc/mpxdbmanager.h
mpserviceplugins/inc/mpxdbtable.h
mpserviceplugins/localaudio/src/mpxlocalaudioplayback.cpp
mpserviceplugins/mpxsqlitedbcommon/bwinscw/mpxsqlitedbcommonu.def
mpserviceplugins/mpxsqlitedbcommon/eabi/mpxsqlitedbcommonu.def
mpserviceplugins/mpxsqlitedbcommon/group/mpxsqlitedbcommon.mmp
mpserviceplugins/mpxsqlitedbcommon/src/mpxdbcommonutil.cpp
mpserviceplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp
mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp
mpserviceplugins/mpxsqlitedbhgplugin/data/10207C85.RSS
mpserviceplugins/mpxsqlitedbhgplugin/data/mpxcollectiondbhgres.rss
mpserviceplugins/mpxsqlitedbhgplugin/group/bld.inf
mpserviceplugins/mpxsqlitedbhgplugin/group/iconlist.txt
mpserviceplugins/mpxsqlitedbhgplugin/group/mpxdbpluginiconshg.mk
mpserviceplugins/mpxsqlitedbhgplugin/group/mpxsqlitedbhgplugin.mmp
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondb.hrh
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbmanager.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbstd.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbartist.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbautoplaylist.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbauxiliary.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbcategory.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbcomposer.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbgenre.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplaylist.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplaylistsongs.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplugin.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h
mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbutil.h
mpserviceplugins/mpxsqlitedbhgplugin/rom/mpxsqlitedbhgplugin.iby
mpserviceplugins/mpxsqlitedbhgplugin/rom/mpxsqlitedbhgpluginrsc.iby
mpserviceplugins/mpxsqlitedbhgplugin/rom/rom.pri
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxcollectiondbmanager.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbartist.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbautoplaylist.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbauxiliary.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbcategory.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbcomposer.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbgenre.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplaylist.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplaylistsongs.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbpluginproxy.cpp
mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbutil.cpp
mpserviceplugins/mpxsqlitedbplugin/data/101FFC3E.RSS
mpserviceplugins/mpxsqlitedbplugin/data/mpxcollectiondbres.rss
mpserviceplugins/mpxsqlitedbplugin/group/bld.inf
mpserviceplugins/mpxsqlitedbplugin/group/iconlist.txt
mpserviceplugins/mpxsqlitedbplugin/group/mpxdbpluginicons.mk
mpserviceplugins/mpxsqlitedbplugin/group/mpxsqlitedbplugin.mmp
mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondb.hrh
mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbdef.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbmanager.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbstd.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbalbum.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbartist.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbautoplaylist.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbauxiliary.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbcategory.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbcomposer.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbgenre.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbhandler.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbmusic.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplaylist.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplaylistsongs.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplugin.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbpluginqueries.h
mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbutil.h
mpserviceplugins/mpxsqlitedbplugin/rom/mpxsqlitedbplugin.iby
mpserviceplugins/mpxsqlitedbplugin/rom/mpxsqlitedbpluginrsc.iby
mpserviceplugins/mpxsqlitedbplugin/rom/rom.pri
mpserviceplugins/mpxsqlitedbplugin/src/mpxcollectiondbmanager.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbalbum.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbartist.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbautoplaylist.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbauxiliary.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbcategory.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbcomposer.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbgenre.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbhandler.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbmusic.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplaylist.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplaylistsongs.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplugin.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbpluginproxy.cpp
mpserviceplugins/mpxsqlitedbplugin/src/mpxdbutil.cpp
mpserviceplugins/mpxsqlitepodcastdbplugin/group/bld.inf
mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbhandler.h
mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbpluginqueries.h
mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp
mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp
mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp
mpviewplugins/mpcollectionviewplugin/inc/mpcollectionalbumartmanager.h
mpviewplugins/mpcollectionviewplugin/inc/mpcollectioncontainer.h
mpviewplugins/mpcollectionviewplugin/inc/mpcollectiondatamodel.h
mpviewplugins/mpcollectionviewplugin/inc/mpcollectionview.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectiondata.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectiondata_p.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectionviewdefs.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxframeworkwrapper.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxframeworkwrapper_p.h
mpviewplugins/mpcollectionviewplugin/inc/mpmpxisolatedcollectionhelper.h
mpviewplugins/mpcollectionviewplugin/mpcollectionviewplugin.pro
mpviewplugins/mpcollectionviewplugin/src/mpcollectionalbumartmanager.cpp
mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainer.cpp
mpviewplugins/mpcollectionviewplugin/src/mpcollectiondatamodel.cpp
mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp
mpviewplugins/mpcollectionviewplugin/src/mpcollectionviewplugin.cpp
mpviewplugins/mpcollectionviewplugin/src/mpmpxcollectiondata.cpp
mpviewplugins/mpcollectionviewplugin/src/mpmpxcollectiondata_p.cpp
mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper.cpp
mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper_p.cpp
mpviewplugins/mpcollectionviewplugin/src/mpmpxisolatedcollectionhelper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/inc/unittest_mpcollectionalbumartmanager.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/src/unittest_mpcollectionalbumartmanager.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/mpmpxcollectiondata.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/thumbnailmanager_qt.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/src/mpmpxcollectiondata.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/src/thumbnailmanager_qt.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager.pro
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/inc/unittest_helper.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/inc/unittest_mpcollectiondatamodel.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/src/unittest_helper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/src/unittest_mpcollectiondatamodel.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpcollectionalbumartmanager.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpmpxcollectiondata.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/src/mpcollectionalbumartmanager.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/src/mpmpxcollectiondata.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel.pro
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/inc/unittest_mpmpxcollectiondata.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/src/unittest_mpmpxcollectiondata.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/unittest_mpmpxcollectiondata.pro
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/inc/unittest_mpmpxframeworkwrapper.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/src/unittest_mpmpxframeworkwrapper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpmpxcollectiondata.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpmpxisolatedcollectionhelper.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionhelperfactory.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionopenutility.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionuihelper.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionutility.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxharvesterutility.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxplaybackutility.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpmpxcollectiondata.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpmpxisolatedcollectionhelper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionhelperfactory.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionopenutility.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionuihelper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionutility.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxharvesterutility.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxplaybackutility.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/unittest_mpmpxframeworkwrapper.pro
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/inc/unittest_mpmpxisolatedcollectionhelper.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/src/unittest_mpmpxisolatedcollectionhelper.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/inc/mpxcollectionopenutility.h
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/src/mpxcollectionopenutility.cpp
mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/unittest_mpmpxisolatedcollectionhelper.pro
mpviewplugins/mpdetailsviewplugin/inc/mpdetailsview.h
mpviewplugins/mpdetailsviewplugin/mpdetailsviewplugin.pro
mpviewplugins/mpdetailsviewplugin/src/mpdetailsview.cpp
mpviewplugins/mpplaybackviewplugin/inc/mpmpxpbframeworkwrapper.h
mpviewplugins/mpplaybackviewplugin/inc/mpmpxpbframeworkwrapper_p.h
mpviewplugins/mpplaybackviewplugin/inc/mpplaybackdata.h
mpviewplugins/mpplaybackviewplugin/inc/mpplaybackview.h
mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h
mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro
mpviewplugins/mpplaybackviewplugin/src/mpmpxpbframeworkwrapper.cpp
mpviewplugins/mpplaybackviewplugin/src/mpmpxpbframeworkwrapper_p.cpp
mpviewplugins/mpplaybackviewplugin/src/mpplaybackdata.cpp
mpviewplugins/mpplaybackviewplugin/src/mpplaybackview.cpp
mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp
mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/inc/unittest_mpplaybackdata.h
mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/src/unittest_mpplaybackdata.cpp
mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/stub/inc/thumbnailmanager_qt.h
mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/stub/src/thumbnailmanager_qt.cpp
mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata.pro
mpviewplugins/mpsettingsviewplugin/inc/mpsettingsview.h
mpviewplugins/mpsettingsviewplugin/mpsettingsviewplugin.pro
mpviewplugins/mpsettingsviewplugin/src/mpsettingsview.cpp
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/inc/unittest_mpmpxasframeworkwrapper.h
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/src/unittest_mpmpxasframeworkwrapper.cpp
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxaudioeffectproperties.h
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxplaybackutility.h
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxaudioeffectproperties.cpp
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxplaybackutility.cpp
mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/unittest_mpmpxasframeworkwrapper.pro
musicfetcher/bwins/musicfetcheru.def
musicfetcher/eabi/musicfetcheru.def
musicfetcher/inc/musicfetcher.h
musicfetcher/musicfetcher.pro
musicfetcher/rom/musicfetcher.iby
musicfetcher/rom/rom.pri
musicfetcher/src/musicfetcher.cpp
musicservices/bwins/musicservices.def
musicservices/eabi/musicservices.def
musicservices/inc/getmusicservice.h
musicservices/inc/musicservices.h
musicservices/inc/playmusicservice.h
musicservices/musicservices.pro
musicservices/rom/musicservices.iby
musicservices/rom/rom.pri
musicservices/src/getmusicservice.cpp
musicservices/src/musicservices.cpp
musicservices/src/playmusicservice.cpp
musicservices/tsrc/unittest_musicservices/inc/unittest_musicservices.h
musicservices/tsrc/unittest_musicservices/src/unittest_musicservices.cpp
musicservices/tsrc/unittest_musicservices/unittest_musicservices.pro
qtmusicplayer.pro
tsrc/mpfetchertestapp/inc/mpfetchertestappview.h
tsrc/mpfetchertestapp/mpfetchertestapp.pro
tsrc/mpfetchertestapp/src/mpfetchertestappview.cpp
utilities/mpsettingsmanager/conf/musicplayer.confml
utilities/mpsettingsmanager/conf/musicplayer_10207C92.crml
utilities/mpsettingsmanager/inc/mpsettingsmanagerdefs.h
--- a/app/app.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/app/app.pro	Mon May 03 12:29:20 2010 +0300
@@ -21,7 +21,7 @@
 INCLUDEPATH += . \
 	 inc \
 	 ../inc \
-         ../musicfetcher/inc
+         ../musicservices/inc
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
 
 CONFIG += hb
@@ -37,7 +37,7 @@
 # Service provider specific configuration.
 # If in-process plugin specific implementation
 # will be possible in future, service configuration
-# can be located in musicfetcher library's pro file.
+# can be located in musicservices library's pro file.
 SERVICE.FILE = data/service_conf.xml
 SERVICE.OPTIONS = embeddable
 CONFIG += service
@@ -49,8 +49,9 @@
     -lfbscli.dll \
     -lxqplugins.dll \
     -lmpxviewframeworkqt.dll \
+    -lxqservice \
     -lxqserviceutil \
-    -lmusicfetcher \
+    -lmusicservices \
     -lmpengine
     
     
@@ -69,4 +70,45 @@
     
 RESOURCES += resources/musiplayerapp.qrc
 
-TRANSLATIONS = musicplayer.ts
\ No newline at end of file
+TRANSLATIONS = musicplayer.ts
+
+RSS_RULES += \
+"    datatype_list =" \
+"        {" \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-midi\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/midi\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/sp-midi\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-beatnik-rmf\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-rmf\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/rmf\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/mobile-xmf\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/vnd.nokia.mobile-xmf\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-mrv.xml\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-mrv.wbxml\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-ms-wma\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"x-caf-audio/x-ms-wma\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-pn-realaudio\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-realaudio\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/vnd.rn-realaudio\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"playlist/mpegurl\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/mpeg\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/mp3\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/m4a\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-mp3\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/3gpp\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/3gpp2\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/mp4\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/aac\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/basic\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/amr\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/amr-wb\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/awb\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-amr\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-epoc-wve\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-sibo-wve\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/wav\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-wav\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/x-au\"; }," \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"audio/au\"; }, " \
+"        DATATYPE { priority=EDataTypePrioritySystem; type=\"application/vnd.nokia.ringing-tone\"; }" \
+"        };" \     
\ No newline at end of file
--- a/app/data/service_conf.xml	Fri Apr 16 14:56:30 2010 +0300
+++ b/app/data/service_conf.xml	Mon May 03 12:29:20 2010 +0300
@@ -1,11 +1,16 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <service>
-  <name>Music Fetcher</name>
+  <name>musicplayer</name>
   <filepath>No path</filepath>
-  <description>Music Fetcher</description>
+  <description>Music Services</description>
   <interface>
-     <name>com.nokia.services.media.Music</name>
+     <name>com.nokia.symbian.IMusicFetch</name>
      <version>1.0</version>
-     <description>Interface for fetching music URIs</description>
+     <description>Music fetcher service</description>
+   </interface>
+   <interface>
+     <name>com.nokia.symbian.IFileView</name>
+     <version>1.0</version>
+     <description>Interface for showing Files</description>
    </interface>
 </service>
\ No newline at end of file
--- a/app/inc/mpmainwindow.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/app/inc/mpmainwindow.h	Mon May 03 12:29:20 2010 +0300
@@ -23,15 +23,16 @@
 #include <hbmainwindow.h>
 #include <mpxviewframeworkqt.h>
 
+#include "mpcommondefs.h"
+
 // Forward declarations
 class MpxViewPlugin;
-class MusicFetcher;
+class MusicServices;
 
 // Class declaration
 class MpMainWindow: public MpxViewFramework
 {
     Q_OBJECT
-    Q_PROPERTY(MpxViewPlugin* mCurrentViewPlugin READ currentViewPlugin)
 
 public:
 
@@ -45,27 +46,31 @@
     ~MpMainWindow();
 
     void initialize();
-    MpxViewPlugin* currentViewPlugin();
 
 public slots:
     void handleCommand( int commandCode );
     void handleLibraryUpdated();
-    void handleExitApplication();
+
+    void switchView( Qt::Orientation orientation );
+    void initializeServiceView( TUid hostUid );
 
 private:
     void activateView(ViewType);
     void connectView();
     void disconnectView();
 
+    MpxViewPlugin*  loadView( ViewType type, MpCommon::MpViewMode viewMode= MpCommon::DefaultView );
+
 private:
 
-    MpxViewPlugin         *mCollectionViewPlugin; // Not own
-    MpxViewPlugin         *mPlaybackViewPlugin;   // Not own
-    MpxViewPlugin         *mSettingsViewPlugin;   // Not own
-    MpxViewPlugin         *mDetailsViewPlugin;    // Not own
-    MpxViewPlugin         *mCurrentViewPlugin;    // Not own
-    MpxViewPlugin         *mPreviousViewPlugin;   // Not own
-    MusicFetcher		  *mMusicFetcher; 		  // Own
+    MpxViewPlugin         *mCollectionViewPlugin; // Own
+    MpxViewPlugin         *mPlaybackViewPlugin;   // Own
+    MpxViewPlugin         *mSettingsViewPlugin;   // Own
+    MpxViewPlugin         *mDetailsViewPlugin;    // Own
+
+    MpxViewPlugin         *mCurrentViewPlugin;    // Own
+    ViewType              mVerticalViewType;
+    MusicServices         *mMusicServices;        // Own
 
 };
 
--- a/app/src/mpmainwindow.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/app/src/mpmainwindow.cpp	Mon May 03 12:29:20 2010 +0300
@@ -22,13 +22,13 @@
 #include <xqpluginloader.h>
 #include <xqplugininfo.h>
 #include <xqserviceutil.h>
+#include <xqsharablefile.h>
 #include <QTranslator>
 #include <QLocale>
 
 #include "mpmainwindow.h"
-#include "mpcommondefs.h"
 #include "mpviewbase.h"
-#include "musicfetcher.h"
+#include "musicservices.h"
 #include "mpengine.h"
 #include "mptrace.h"
 
@@ -51,8 +51,8 @@
       mSettingsViewPlugin(0),
       mDetailsViewPlugin(0),
       mCurrentViewPlugin(0),
-      mPreviousViewPlugin(0),
-      mMusicFetcher(0)
+      mVerticalViewType( CollectionView ),
+      mMusicServices(0)
 {
     TX_LOG
 }
@@ -63,8 +63,10 @@
 MpMainWindow::~MpMainWindow()
 {
     TX_ENTRY
-    delete mMusicFetcher;
-
+    if(mMusicServices){
+        delete mMusicServices;
+    }
+    
     if (mCollectionViewPlugin) {
         mCollectionViewPlugin->destroyView();
         delete mCollectionViewPlugin;
@@ -82,6 +84,9 @@
         delete mDetailsViewPlugin;
     }
 
+    MpEngine::instance()->close();
+
+
     TX_EXIT
 }
 
@@ -115,76 +120,33 @@
 #endif // _DEBUG
 
     if ( XQServiceUtil::isService() ) {
-        // Music Fetcher mode
+        // Music Service mode
         // Set the Collection View and Playback View to fetcher mode
-        mMusicFetcher = new MusicFetcher();
-    }
-
-    XQPluginLoader collectionLoader(MpCommon::KCollectionViewUid);
-    XQPluginLoader playbackLoader(MpCommon::KPlaybackViewUid);
-
-    // Loading the collection plugin
-    QObject* collectionInstance = collectionLoader.instance();
-    TX_LOG_ARGS("collection instance: " << reinterpret_cast<int>(collectionInstance));
-    mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( collectionInstance )->viewPlugin();
-    TX_LOG_ARGS("collection view plugin: " << reinterpret_cast<int>(mCollectionViewPlugin));
-    if ( mCollectionViewPlugin ) {
-        mCollectionViewPlugin->createView();
-        MpViewBase* collectionView = reinterpret_cast<MpViewBase*>(mCollectionViewPlugin->getView());
-        if ( mMusicFetcher ) {
-            collectionView->setViewMode(MpCommon::FetchView);
-            collectionView->setTitle(mMusicFetcher->contextTitle());
-            int err = connect(collectionView, SIGNAL(songSelected(QString)), mMusicFetcher, SLOT(itemSelected(QString)));
-            TX_LOG_ARGS("connection error: " << err);
-            err = connect(mMusicFetcher, SIGNAL(titleReady(const QString&)), collectionView, SLOT(setTitle(const QString&)));
-            TX_LOG_ARGS("connection error: " << err);
-        }
-        else {
-            collectionView->setTitle(hbTrId("txt_mus_title_music"));
-        }
-        // Collection view is the default view.
-        activateView(MpMainWindow::CollectionView);
-    }
-
-    // Pre-load the playback plugin
-    QObject* playbackInstance = playbackLoader.instance();
-    TX_LOG_ARGS("playback instance: " << reinterpret_cast<int>(playbackInstance));
-    mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( playbackInstance )->viewPlugin();
-    TX_LOG_ARGS("playback view plugin: " << reinterpret_cast<int>(mPlaybackViewPlugin));
-    if ( mPlaybackViewPlugin ) {
-        mPlaybackViewPlugin->createView();
-        MpViewBase* playbackView = reinterpret_cast<MpViewBase*>(mPlaybackViewPlugin->getView());
-        if ( mMusicFetcher ) {
-            playbackView->setViewMode(MpCommon::FetchView);
-            playbackView->setTitle(mMusicFetcher->contextTitle());
-            int err = connect(playbackView, SIGNAL(songSelected(QString)), mMusicFetcher, SLOT(itemSelected(QString)));
-            TX_LOG_ARGS("connection error: " << err);
-            err = connect(mMusicFetcher, SIGNAL(titleReady(const QString&)), playbackView, SLOT(setTitle(const QString&)));
-            TX_LOG_ARGS("connection error: " << err);
-        }
-        else {
-            playbackView->setTitle(hbTrId("txt_mus_title_music"));
-        }
+        mMusicServices = new MusicServices();
+        int err = connect(mMusicServices, SIGNAL(serviceActive( TUid )), this, SLOT(initializeServiceView( TUid )));
+        TX_LOG_ARGS("connection error: " << err);
+        XQServiceUtil::toBackground( false );
     }
 
     MpEngine *engine = MpEngine::instance();
-    connect( engine, SIGNAL( libraryRefreshed() ), this, SLOT( handleLibraryUpdated() ) );
-    connect( engine, SIGNAL( exitApplication() ), this, SLOT( handleExitApplication() ) );
+
+    if ( !mMusicServices ) {
+        engine->initialize(MpCommon::DefaultView);
+      
+        loadView(CollectionView);
+        activateView(CollectionView);
 
+        connect(this, SIGNAL( orientationChanged( Qt::Orientation ) ), SLOT( switchView( Qt::Orientation ) ) );
+        connect( engine, SIGNAL( libraryRefreshed() ), SLOT( handleLibraryUpdated() ) );
+        engine->checkForSystemEvents();
+        loadView( PlaybackView );
+    }
+    setOrientation(Qt::Vertical, true);//This sould prevent media wall activation.
     TX_EXIT
 }
 
 /*!
- Returns the current view plugin.
- */
-MpxViewPlugin* MpMainWindow::currentViewPlugin()
-{
-    TX_LOG
-    return mCurrentViewPlugin;
-}
-
-/*!
- Handle the \a commandCode.
+ Slot to be called to handle the \a commandCode.
  */
 void MpMainWindow::handleCommand( int commandCode )
 {
@@ -214,60 +176,50 @@
 }
 
 /*!
+ Slot to be called to switch view based on \a orientation.
+ */
+void MpMainWindow::switchView( Qt::Orientation orientation )
+{
+        if (orientation == Qt::Vertical) {
+            activateView( mVerticalViewType );   
+        }
+
+}
+
+/*!
  Activate the \a viewType view.
  */
 void MpMainWindow::activateView(MpMainWindow::ViewType viewType)
 {
     TX_ENTRY_ARGS("viewType=" << viewType );
 
-    if ( mCurrentViewPlugin ) {
-
+    bool doTransition = true;
+    Hb::ViewSwitchFlags  transitionFlags = Hb::ViewSwitchDefault;
+    
+    if ( mCurrentViewPlugin ) {     
         disconnectView();
         mCurrentViewPlugin->deactivateView();
-        mPreviousViewPlugin = mCurrentViewPlugin;
+        if ( viewType  == CollectionView && mCurrentViewPlugin == mPlaybackViewPlugin ||
+                  viewType  == PlaybackView && mCurrentViewPlugin == mDetailsViewPlugin ||
+                  viewType  == PlaybackView && mCurrentViewPlugin == mSettingsViewPlugin ) {
+            transitionFlags |= Hb::ViewSwitchUseBackAnim;
+        }
         mCurrentViewPlugin = 0;
     }
 
-    if ( viewType == MpMainWindow::CollectionView && mCollectionViewPlugin ) {
-        mCurrentViewPlugin = mCollectionViewPlugin;
-    }
-    else if ( viewType == MpMainWindow::PlaybackView && mPlaybackViewPlugin ) {
-        mCurrentViewPlugin = mPlaybackViewPlugin;
-    }
-    else if ( viewType == MpMainWindow::SettingsView ) {
-        if ( mSettingsViewPlugin ) {
-            mCurrentViewPlugin = mSettingsViewPlugin;
-        }
-		else {
-			XQPluginLoader settingsLoader( MpCommon::KSettingsViewUid );
-            QObject* settingsInstance = settingsLoader.instance();
-            mSettingsViewPlugin = qobject_cast<MpxViewPlugin*>( settingsInstance )->viewPlugin();
-            mSettingsViewPlugin->createView();
-            mCurrentViewPlugin = mSettingsViewPlugin;
-        }
-    }
-    else if ( viewType == MpMainWindow::DetailsView ) {
-        if ( mDetailsViewPlugin ) {
-            mCurrentViewPlugin = mDetailsViewPlugin;
-        }
-        else {
-            XQPluginLoader detailsLoader( MpCommon::KDetailsViewUid );
-            QObject* detailsInstance = detailsLoader.instance();
-            mDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( detailsInstance )->viewPlugin();
-            mDetailsViewPlugin->createView();
-            mCurrentViewPlugin = mDetailsViewPlugin;
-        }
-    }
+    // loadView will not reload the view if is already loaded.
+    mCurrentViewPlugin = loadView( viewType );
+    Q_ASSERT( mCurrentViewPlugin );
 
     if ( mCurrentViewPlugin ) {
-        addView( mCurrentViewPlugin->getView() );
+        
+        mVerticalViewType = viewType;
+        
+        addView( reinterpret_cast<HbView*>( mCurrentViewPlugin->getView() ) );
+        setCurrentView( reinterpret_cast<HbView*>( mCurrentViewPlugin->getView() ) , doTransition , transitionFlags);
         mCurrentViewPlugin->activateView();
         connectView();
     }
-
-    if ( mPreviousViewPlugin ) {
-        removeView( mPreviousViewPlugin->getView() );
-    }
     TX_EXIT
 }
 
@@ -283,11 +235,6 @@
 					 SIGNAL(command(int)),
 					 this,
 					 SLOT(handleCommand(int)));
-
-	QObject::connect(this,
-					 SIGNAL( orientationChanged( Qt::Orientation ) ),
-					 mCurrentViewPlugin,
-					 SLOT( orientationChange( Qt::Orientation ) ) );
     TX_EXIT
 }
 
@@ -302,12 +249,6 @@
 					 SIGNAL(command(int)),
 					 this,
 					 SLOT(handleCommand(int)));
-
-	QObject::disconnect(this,
-					 SIGNAL( orientationChanged( Qt::Orientation ) ),
-					 mCurrentViewPlugin,
-					 SLOT( orientationChange( Qt::Orientation ) ) );
-
     TX_EXIT
 }
 
@@ -332,17 +273,92 @@
 }
 
 /*!
- Slot to be called when application must exit.
+ Reimp.
  */
-void MpMainWindow::handleExitApplication()
-{
-    TX_ENTRY
+
 
-    if ( mCurrentViewPlugin ) {
-        disconnectView();
+void MpMainWindow::initializeServiceView( TUid hostUid ){
+    
+    MpEngine *engine = MpEngine::instance();
+        
+    switch (mMusicServices->currentService()) {
+ 
+    case MusicServices::EUriFetcher:
+        {
+            engine->initialize( MpCommon::FetchView, hostUid );
+            loadView( CollectionView, MpCommon::FetchView );
+            MpViewBase* collectionView = reinterpret_cast<MpViewBase*>(mCollectionViewPlugin->getView());
+            connect(collectionView, SIGNAL(songSelected(QString)), mMusicServices, SLOT(itemSelected(QString)));
+            activateView( CollectionView );           
+            loadView(PlaybackView, MpCommon::FetchView );
+            MpViewBase* playbackView = reinterpret_cast<MpViewBase*>(mPlaybackViewPlugin->getView());
+            connect(playbackView, SIGNAL(songSelected(QString)), mMusicServices, SLOT(itemSelected(QString)));
+            connect( engine, SIGNAL( libraryRefreshed() ), this, SLOT( handleLibraryUpdated() ) );
+            engine->checkForSystemEvents();
+            break;
+        }
+    case MusicServices::EPlayback:
+        {
+            engine->initialize( MpCommon::EmbeddedView, hostUid );
+            loadView(PlaybackView, MpCommon::EmbeddedView );   
+            MpViewBase* playbackView = reinterpret_cast<MpViewBase*>(mPlaybackViewPlugin->getView());
+            connect(mMusicServices, SIGNAL(playReady(QString)), engine, SLOT(playEmbedded(QString)));
+            connect(mMusicServices, SIGNAL(playReady(const XQSharableFile&)), engine, SLOT(playEmbedded(const XQSharableFile&)));
+            connect(playbackView, SIGNAL(songSelected(QString)), mMusicServices, SLOT(itemSelected(QString)));
+            activateView( PlaybackView );
+            break;
+        }
+        default:
+        Q_ASSERT_X(false, "MpMainWindow::initializeServiceView", "undefined service");
+        break;
     }
-    qApp->quit();
-
-    TX_EXIT
 }
 
+/*!
+  loads a view if type \a  type, return the view plugin, if view is already loaded it will not reload the view.
+ */
+MpxViewPlugin* MpMainWindow::loadView( ViewType type, MpCommon::MpViewMode viewMode )
+{
+    MpxViewPlugin** plugin = 0;
+    long int pluginUid = 0;    
+    switch (type) { 
+    case CollectionView:
+        pluginUid = MpCommon::KCollectionViewUid;
+        plugin = &mCollectionViewPlugin;
+        break;
+    case PlaybackView:
+        pluginUid = MpCommon::KPlaybackViewUid;
+        plugin = &mPlaybackViewPlugin;
+        break;
+    case SettingsView:
+        pluginUid = MpCommon::KSettingsViewUid;
+        plugin = &mSettingsViewPlugin;
+        break;
+    case DetailsView:
+        pluginUid = MpCommon::KDetailsViewUid;
+        plugin = &mDetailsViewPlugin;
+        break;
+
+    default:
+        Q_ASSERT_X(false, "MpMainWindow::loadView", "undefined view type");
+        break;
+    }
+    Q_ASSERT( plugin && pluginUid);
+    if ( plugin && !(*plugin) ) {
+        //plugin was not loded before, loding plugin.
+        XQPluginLoader pluginLoader( pluginUid );
+        QObject* pluginInstance = pluginLoader.instance();
+        (*plugin) = qobject_cast<MpxViewPlugin*>( pluginInstance )->viewPlugin();
+        Q_ASSERT( *plugin );
+        
+        if ( *plugin ) {
+            (*plugin)->createView();
+            MpViewBase* view = reinterpret_cast<MpViewBase*>( (*plugin)->getView() );
+            view->setTitle( mMusicServices ? mMusicServices->contextTitle() : hbTrId("txt_mus_title_music"));
+            view->setViewMode( viewMode );
+        }
+    }
+    Q_ASSERT( plugin ? *plugin : 0 );
+    return plugin ? *plugin : 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/mpcollectiondatamodel.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection abstract data model.
+*
+*/
+
+#ifndef MPCOLLECTIONDATAMODEL_H
+#define MPCOLLECTIONDATAMODEL_H
+
+#include <QAbstractListModel>
+
+class MpMpxCollectionData;
+class MpCollectionAlbumArtManager;
+
+#if defined(BUILD_MPDATA_LIB)
+#define MPDATA_EXPORT Q_DECL_EXPORT
+#else
+#define MPDATA_EXPORT Q_DECL_IMPORT
+#endif
+
+class MPDATA_EXPORT MpCollectionDataModel : public QAbstractListModel
+{
+    Q_OBJECT
+
+public:
+
+    explicit MpCollectionDataModel( MpMpxCollectionData *data, QObject *parent=0 );
+    virtual ~MpCollectionDataModel();
+
+    int rowCount(const QModelIndex &parent=QModelIndex()) const;
+    QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
+    Qt::DropActions supportedDropActions() const;
+    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+    QStringList mimeTypes() const;
+    QMimeData *mimeData(const QModelIndexList &indexes) const;
+    bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+                              int row, int column, const QModelIndex &parent);
+    
+    MpMpxCollectionData *collectionData();
+    
+signals:
+    void orderChanged( int containerId, int itemId, int itemOrdinal, int newOrdinal );
+
+public slots:
+
+    void updateAlbumArt( int index );
+    void refreshModel();
+
+private:
+
+    MpMpxCollectionData             *mCollectionData;
+	MpCollectionAlbumArtManager     *mAlbumArtManager;  // Own
+    int                             mRowCount;
+
+};
+
+#endif // MPCOLLECTIONDATAMODEL_H
+
--- a/inc/mpcommondefs.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/inc/mpcommondefs.h	Mon May 03 12:29:20 2010 +0300
@@ -48,7 +48,8 @@
      */
     enum MpViewMode {
         DefaultView,
-        FetchView
+        FetchView,
+        EmbeddedView
     };
 }
 
--- a/inc/mpengine.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/inc/mpengine.h	Mon May 03 12:29:20 2010 +0300
@@ -19,14 +19,22 @@
 #define MPENGINE_H
 
 #include <QObject>
+#include "mpmpxcollectionviewdefs.h"
 #include "mpmpxcommondefs.h"
+#include "mpcommondefs.h"
+
 
 class QStringList;
 class QTranslator;
-class HbNotificationDialog;
-class MpMpxFrameworkWrapper;
+class HbProgressDialog;
+class MpMpxHarvesterFrameworkWrapper;
 class MpSongScanner;
 class MpMediaKeyHandler;
+class MpMpxCollectionFrameworkWrapper;
+class MpMpxPlaybackFrameworkWrapper;
+class MpMpxCollectionData;
+class MpPlaybackData;
+class XQSharableFile;
 
 #if defined(BUILD_MPENGINE_LIB)
 #define MPENGINE_EXPORT Q_DECL_EXPORT
@@ -55,25 +63,79 @@
     virtual ~MpEngine();
     static MpEngine *instance();
 
+    void initialize(MpCommon::MpViewMode viewMode, TUid uid = TUid::Uid( MpCommon::KMusicPlayerUid ) );
+    void close();
+	
+    // Harvester related
     void refreshLibrary();
     bool verifyUsbBlocking( bool showMessage = false );
+    void checkForSystemEvents();
+    
+    // Collection related
+    void openCollection( TCollectionContext context );
+    void openCollectionItem( int index );
+    void back();
+    void findPlaylists( QStringList &playlists );
+    void createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData = 0  );
+    void saveToPlaylist( int playlistIndex, QList<int> &selection );
+    void saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData );    
+    void renamePlaylist( QString &newName, int index );
+    void renamePlaylist( QString &newName );
+    void deleteSongs( QList<int> &selection );
+
+    
+    void previewItem( int index );
+    void openIsolatedCollection( TCollectionContext context );
+    void releaseIsolatedCollection();
+    
+    MpMpxCollectionData *collectionData();
+    
+    // Playback related
+    
+    MpPlaybackData *playbackData();
 
 signals:
-
+    
+    // Harvester related
     void libraryAboutToRefresh();
     void libraryRefreshed();
     void usbBlocked( bool blocked );
-    void exitApplication();
+    
+    // Collection related
+    void collectionPlaylistOpened();
+    void playlistSaved( bool success );
+    void songsDeleted( bool success );
+    void playlistsRenamed( bool success );
+    
+    void isolatedCollectionOpened( MpMpxCollectionData* collectionData );
 
 public slots:
 
+    // Harvester related
     void handleScanStarted();
     void handleScanEnded( int count, int error );
     void handleDiskEvent( MpxDiskEvents event );
     void handleUsbEvent( MpxUsbEvents event );
+    void handleBlockingNoteClosing();
+    
+    // Collection related
+    void reopenCollection();
+    void reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal );
 
+	// Playback related
+	void playEmbedded( QString aFilename );
+	void playEmbedded( const XQSharableFile&  file );
+    void playPause();
+    void stop();
+    void skipForward();
+    void skipBackward();
+    void setPosition( int position );
+    void setShuffle( bool mode );
+    void setRepeat( bool mode );
+	
 private:
 
+    // Harvester related
     void handleUsbMassStorageStartEvent();
     void handleUsbMassStorageEndEvent();
     void handleUsbMtpStartEvent();
@@ -81,20 +143,30 @@
     void handleUsbMtpNotActive();
 
     void changeUsbBlockingState( UsbBlockingState state );
+    void launchBlockingNote();
 
 private:
 
     Q_DISABLE_COPY( MpEngine )
 
-    MpMpxFrameworkWrapper       *mMpxWrapper;       // Own
-    MpSongScanner               *mSongScanner;      // Own
-    MpMediaKeyHandler           *mMediaKeyHandler;  // Own
+    // Harvesting related
+    MpMpxHarvesterFrameworkWrapper       *mMpxHarvesterWrapper;  // Own
+    MpSongScanner                        *mSongScanner;          // Own
+    MpMediaKeyHandler                    *mMediaKeyHandler;      // Own
+    HbProgressDialog                     *mUsbBlockingNote;      // Own
+    
+    // Collection related
+    MpMpxCollectionFrameworkWrapper      *mMpxCollectionWrapper; //Own
 
-    HbNotificationDialog        *mUsbBlockingNote;  // Own
-    QTranslator                 *mMpTranslator;     // Own
-
-    UsbBlockingState            mUsbBlockingState;
-    UsbBlockingState            mPreviousUsbState;
+    // Playback related
+    MpMpxPlaybackFrameworkWrapper        *mMpxPlaybackWrapper; //Own
+        
+    // General
+    QTranslator                          *mMpTranslator;         // Own
+    UsbBlockingState                     mUsbBlockingState;
+    UsbBlockingState                     mPreviousUsbState;    
+    MpCommon::MpViewMode                 mViewMode;
+    TUid                                 mHostUid;
 
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/mpmpxcollectiondata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection data.
+*
+*/
+
+#ifndef MPMPXCOLLECTIONDATA_H
+#define MPMPXCOLLECTIONDATA_H
+
+#include <QObject>
+
+#include "mpmpxcollectionviewdefs.h"
+
+class MpMpxCollectionDataPrivate;
+class CMPXMedia;
+
+#if defined(BUILD_MPDATA_LIB)
+#define MPDATA_EXPORT Q_DECL_EXPORT
+#else
+#define MPDATA_EXPORT Q_DECL_IMPORT
+#endif
+
+class MPDATA_EXPORT MpMpxCollectionData : public QObject
+{
+    Q_OBJECT
+
+    friend class MpMpxCollectionDataPrivate;
+
+public:
+
+    enum DataType {
+        Title,
+        Uri,
+        Duration,
+        Count,
+        Artist,
+        Album,
+        Genre,
+        Rating,
+        AlbumArtUri
+    };
+
+    explicit MpMpxCollectionData( QObject *parent=0 );
+    virtual ~MpMpxCollectionData();
+
+    TCollectionContext context() const;
+
+    int count() const;
+    QString collectionTitle() const;
+    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
+
+    bool isAutoPlaylist();
+    bool isAutoPlaylist( int index );
+    int itemCount( int index );
+    int containerId();
+    int itemId(int index);
+    void removeItem(int index);
+    bool testCachedItem( int itemId );
+    void insertCachedItem(int index);
+
+    void setMpxMedia( const CMPXMedia& entries );
+    const CMPXMedia& containerMedia();
+
+signals:
+
+    void contextChanged( TCollectionContext context );
+private:
+
+    Q_DISABLE_COPY(MpMpxCollectionData)
+    MpMpxCollectionDataPrivate *d_ptr;
+
+};
+
+#endif // MPMPXCOLLECTIONDATA_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/mpmpxcollectionviewdefs.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection view common definitions.
+*
+*/
+
+#ifndef MPMPXCOLLECTIONVIEWDEFS_H
+#define MPMPXCOLLECTIONVIEWDEFS_H
+
+#include <QMetaType>
+
+// Context of collection view.
+// It's the exact location within collection navigation.
+enum TCollectionContext {
+    ECollectionContextUnknown = 0,
+    ECollectionContextAllSongs,
+	ECollectionContextArtists,
+	ECollectionContextArtistAlbums,
+	ECollectionContextArtistSongs,
+    ECollectionContextAlbums,
+    ECollectionContextAlbumSongs,
+    ECollectionContextPlaylists,
+    ECollectionContextPlaylistSongs,
+    ECollectionContextGenres,
+    ECollectionContextGenreSongs
+};
+// Register so type can be used in signal and slot connection
+Q_DECLARE_METATYPE(TCollectionContext)
+
+#endif  // MPMPXCOLLECTIONVIEWDEFS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/mpplaybackdata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Playback Data provider for playback view.
+*
+*/
+
+#ifndef MPPLAYBACKDATA_H
+#define MPPLAYBACKDATA_H
+
+#include <QObject>
+#include <QString>
+#include <QPixmap>
+
+//forward declartions
+
+class HbIcon;
+class ThumbnailManager;
+
+#if defined(BUILD_MPDATA_LIB)
+#define MPDATA_EXPORT Q_DECL_EXPORT
+#else
+#define MPDATA_EXPORT Q_DECL_IMPORT
+#endif
+
+class MPDATA_EXPORT MpPlaybackData : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    enum SimplifiedState {
+        Playing,
+        Paused,
+        Stopped
+    };
+
+    explicit MpPlaybackData( QObject *parent=0 );
+    virtual ~MpPlaybackData();
+
+    void setDuration( int duration );
+    int duration() const;
+    void setPosition( int position );
+    int position() const;
+
+    bool setTitle( const QString& title );
+    const QString& title() const;
+    bool setArtist( const QString& artist );
+    const QString& artist() const;
+    bool setAlbum( const QString& album );
+    const QString& album() const;
+    bool setUri( const QString& uri );
+    const QString& uri() const;
+
+    void setAlbumArtUri( const QString& albumArtUri );
+    void albumArt( HbIcon& icon ) const;
+
+    void setPlaybackState( const SimplifiedState state );
+    MpPlaybackData::SimplifiedState playbackState() const;
+
+    void commitPlaybackInfo();
+
+public slots:
+
+    void thumbnailReady( const QPixmap& pixmap, void *data, int id, int error );
+
+signals:
+
+    void durationChanged();
+    void positionChanged();
+    void albumArtReady();
+    void playbackStateChanged();
+    void playbackInfoChanged();
+
+private:
+
+    ThumbnailManager         *mThumbnailManager; //owned
+    int                      mReqId;
+
+    int                      mDuration;
+    int                      mPosition;
+    QString                  mTitle;
+    QString                  mAlbum;
+    QString                  mArtist;
+    QString                  mUri;
+    HbIcon                   *mAlbumArt;
+    HbIcon                   *mDefaultAlbumArt;
+    SimplifiedState          mPlaybackState;
+
+    Q_DISABLE_COPY(MpPlaybackData)
+};
+
+#endif // MPPLAYBACKDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/musicplayerbldvariant.hrh	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  bldvariant headers for project musicplayer
+*
+*/
+
+
+
+#ifndef MUSICPLAYERBLDVARIANT_HRH
+#define MUSICPLAYERBLDVARIANT_HRH
+
+
+#undef  IAD_INCLUDE_BACKSTEPPING
+#define IAD_INCLUDE_ENHANCED_HOMESCREEN
+#define IAD_INCLUDE_UPNP
+#define IAD_INCLUDE_SINGLE_CLICK
+#define IAD_INCLUDE_ABSTRACTAUDIOALBUM
+
+#endif  // MUSICPLAYERBLDVARIANT_HRH
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/bwins/mpdatau.def	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,87 @@
+EXPORTS
+	?tr@MpMpxCollectionData@@SA?AVQString@@PBD0@Z @ 1 NONAME ; class QString MpMpxCollectionData::tr(char const *, char const *)
+	?album@MpPlaybackData@@QBEABVQString@@XZ @ 2 NONAME ; class QString const & MpPlaybackData::album(void) const
+	?dropMimeData@MpCollectionDataModel@@UAE_NPBVQMimeData@@W4DropAction@Qt@@HHABVQModelIndex@@@Z @ 3 NONAME ; bool MpCollectionDataModel::dropMimeData(class QMimeData const *, enum Qt::DropAction, int, int, class QModelIndex const &)
+	?count@MpMpxCollectionData@@QBEHXZ @ 4 NONAME ; int MpMpxCollectionData::count(void) const
+	?refreshModel@MpCollectionDataModel@@QAEXXZ @ 5 NONAME ; void MpCollectionDataModel::refreshModel(void)
+	?contextChanged@MpMpxCollectionData@@IAEXW4TCollectionContext@@@Z @ 6 NONAME ; void MpMpxCollectionData::contextChanged(enum TCollectionContext)
+	?testCachedItem@MpMpxCollectionData@@QAE_NH@Z @ 7 NONAME ; bool MpMpxCollectionData::testCachedItem(int)
+	?tr@MpCollectionDataModel@@SA?AVQString@@PBD0@Z @ 8 NONAME ; class QString MpCollectionDataModel::tr(char const *, char const *)
+	?mimeData@MpCollectionDataModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 9 NONAME ; class QMimeData * MpCollectionDataModel::mimeData(class QList<class QModelIndex> const &) const
+	?setTitle@MpPlaybackData@@QAE_NABVQString@@@Z @ 10 NONAME ; bool MpPlaybackData::setTitle(class QString const &)
+	?trUtf8@MpMpxCollectionData@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString MpMpxCollectionData::trUtf8(char const *, char const *, int)
+	?tr@MpMpxCollectionData@@SA?AVQString@@PBD0H@Z @ 12 NONAME ; class QString MpMpxCollectionData::tr(char const *, char const *, int)
+	??_EMpMpxCollectionData@@UAE@I@Z @ 13 NONAME ; MpMpxCollectionData::~MpMpxCollectionData(unsigned int)
+	?trUtf8@MpCollectionDataModel@@SA?AVQString@@PBD0@Z @ 14 NONAME ; class QString MpCollectionDataModel::trUtf8(char const *, char const *)
+	?qt_metacast@MpCollectionDataModel@@UAEPAXPBD@Z @ 15 NONAME ; void * MpCollectionDataModel::qt_metacast(char const *)
+	?staticMetaObject@MpCollectionDataModel@@2UQMetaObject@@B @ 16 NONAME ; struct QMetaObject const MpCollectionDataModel::staticMetaObject
+	?updateAlbumArt@MpCollectionDataModel@@QAEXH@Z @ 17 NONAME ; void MpCollectionDataModel::updateAlbumArt(int)
+	??_EMpPlaybackData@@UAE@I@Z @ 18 NONAME ; MpPlaybackData::~MpPlaybackData(unsigned int)
+	?metaObject@MpPlaybackData@@UBEPBUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const * MpPlaybackData::metaObject(void) const
+	?data@MpCollectionDataModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 20 NONAME ; class QVariant MpCollectionDataModel::data(class QModelIndex const &, int) const
+	?removeItem@MpMpxCollectionData@@QAEXH@Z @ 21 NONAME ; void MpMpxCollectionData::removeItem(int)
+	?getStaticMetaObject@MpMpxCollectionData@@SAABUQMetaObject@@XZ @ 22 NONAME ; struct QMetaObject const & MpMpxCollectionData::getStaticMetaObject(void)
+	?mimeTypes@MpCollectionDataModel@@UBE?AVQStringList@@XZ @ 23 NONAME ; class QStringList MpCollectionDataModel::mimeTypes(void) const
+	?itemCount@MpMpxCollectionData@@QAEHH@Z @ 24 NONAME ; int MpMpxCollectionData::itemCount(int)
+	?collectionTitle@MpMpxCollectionData@@QBE?AVQString@@XZ @ 25 NONAME ; class QString MpMpxCollectionData::collectionTitle(void) const
+	?isAutoPlaylist@MpMpxCollectionData@@QAE_NH@Z @ 26 NONAME ; bool MpMpxCollectionData::isAutoPlaylist(int)
+	?tr@MpPlaybackData@@SA?AVQString@@PBD0@Z @ 27 NONAME ; class QString MpPlaybackData::tr(char const *, char const *)
+	?qt_metacall@MpPlaybackData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 28 NONAME ; int MpPlaybackData::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?position@MpPlaybackData@@QBEHXZ @ 29 NONAME ; int MpPlaybackData::position(void) const
+	?setAlbumArtUri@MpPlaybackData@@QAEXABVQString@@@Z @ 30 NONAME ; void MpPlaybackData::setAlbumArtUri(class QString const &)
+	??_EMpCollectionDataModel@@UAE@I@Z @ 31 NONAME ; MpCollectionDataModel::~MpCollectionDataModel(unsigned int)
+	?insertCachedItem@MpMpxCollectionData@@QAEXH@Z @ 32 NONAME ; void MpMpxCollectionData::insertCachedItem(int)
+	?positionChanged@MpPlaybackData@@IAEXXZ @ 33 NONAME ; void MpPlaybackData::positionChanged(void)
+	?title@MpPlaybackData@@QBEABVQString@@XZ @ 34 NONAME ; class QString const & MpPlaybackData::title(void) const
+	??0MpMpxCollectionData@@QAE@PAVQObject@@@Z @ 35 NONAME ; MpMpxCollectionData::MpMpxCollectionData(class QObject *)
+	?setArtist@MpPlaybackData@@QAE_NABVQString@@@Z @ 36 NONAME ; bool MpPlaybackData::setArtist(class QString const &)
+	?qt_metacall@MpCollectionDataModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 37 NONAME ; int MpCollectionDataModel::qt_metacall(enum QMetaObject::Call, int, void * *)
+	??1MpMpxCollectionData@@UAE@XZ @ 38 NONAME ; MpMpxCollectionData::~MpMpxCollectionData(void)
+	?playbackState@MpPlaybackData@@QBE?AW4SimplifiedState@1@XZ @ 39 NONAME ; enum MpPlaybackData::SimplifiedState MpPlaybackData::playbackState(void) const
+	??0MpPlaybackData@@QAE@PAVQObject@@@Z @ 40 NONAME ; MpPlaybackData::MpPlaybackData(class QObject *)
+	?trUtf8@MpCollectionDataModel@@SA?AVQString@@PBD0H@Z @ 41 NONAME ; class QString MpCollectionDataModel::trUtf8(char const *, char const *, int)
+	?context@MpMpxCollectionData@@QBE?AW4TCollectionContext@@XZ @ 42 NONAME ; enum TCollectionContext MpMpxCollectionData::context(void) const
+	?metaObject@MpMpxCollectionData@@UBEPBUQMetaObject@@XZ @ 43 NONAME ; struct QMetaObject const * MpMpxCollectionData::metaObject(void) const
+	?qt_metacast@MpMpxCollectionData@@UAEPAXPBD@Z @ 44 NONAME ; void * MpMpxCollectionData::qt_metacast(char const *)
+	?qt_metacast@MpPlaybackData@@UAEPAXPBD@Z @ 45 NONAME ; void * MpPlaybackData::qt_metacast(char const *)
+	?supportedDropActions@MpCollectionDataModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 46 NONAME ; class QFlags<enum Qt::DropAction> MpCollectionDataModel::supportedDropActions(void) const
+	?durationChanged@MpPlaybackData@@IAEXXZ @ 47 NONAME ; void MpPlaybackData::durationChanged(void)
+	?staticMetaObject@MpPlaybackData@@2UQMetaObject@@B @ 48 NONAME ; struct QMetaObject const MpPlaybackData::staticMetaObject
+	?containerId@MpMpxCollectionData@@QAEHXZ @ 49 NONAME ; int MpMpxCollectionData::containerId(void)
+	?orderChanged@MpCollectionDataModel@@IAEXHHHH@Z @ 50 NONAME ; void MpCollectionDataModel::orderChanged(int, int, int, int)
+	?containerMedia@MpMpxCollectionData@@QAEABVCMPXMedia@@XZ @ 51 NONAME ; class CMPXMedia const & MpMpxCollectionData::containerMedia(void)
+	??1MpCollectionDataModel@@UAE@XZ @ 52 NONAME ; MpCollectionDataModel::~MpCollectionDataModel(void)
+	?setUri@MpPlaybackData@@QAE_NABVQString@@@Z @ 53 NONAME ; bool MpPlaybackData::setUri(class QString const &)
+	?tr@MpCollectionDataModel@@SA?AVQString@@PBD0H@Z @ 54 NONAME ; class QString MpCollectionDataModel::tr(char const *, char const *, int)
+	?collectionData@MpCollectionDataModel@@QAEPAVMpMpxCollectionData@@XZ @ 55 NONAME ; class MpMpxCollectionData * MpCollectionDataModel::collectionData(void)
+	??0MpCollectionDataModel@@QAE@PAVMpMpxCollectionData@@PAVQObject@@@Z @ 56 NONAME ; MpCollectionDataModel::MpCollectionDataModel(class MpMpxCollectionData *, class QObject *)
+	?isAutoPlaylist@MpMpxCollectionData@@QAE_NXZ @ 57 NONAME ; bool MpMpxCollectionData::isAutoPlaylist(void)
+	?trUtf8@MpMpxCollectionData@@SA?AVQString@@PBD0@Z @ 58 NONAME ; class QString MpMpxCollectionData::trUtf8(char const *, char const *)
+	?setPosition@MpPlaybackData@@QAEXH@Z @ 59 NONAME ; void MpPlaybackData::setPosition(int)
+	??1MpPlaybackData@@UAE@XZ @ 60 NONAME ; MpPlaybackData::~MpPlaybackData(void)
+	?setAlbum@MpPlaybackData@@QAE_NABVQString@@@Z @ 61 NONAME ; bool MpPlaybackData::setAlbum(class QString const &)
+	?setPlaybackState@MpPlaybackData@@QAEXW4SimplifiedState@1@@Z @ 62 NONAME ; void MpPlaybackData::setPlaybackState(enum MpPlaybackData::SimplifiedState)
+	?trUtf8@MpPlaybackData@@SA?AVQString@@PBD0@Z @ 63 NONAME ; class QString MpPlaybackData::trUtf8(char const *, char const *)
+	?itemId@MpMpxCollectionData@@QAEHH@Z @ 64 NONAME ; int MpMpxCollectionData::itemId(int)
+	?setMpxMedia@MpMpxCollectionData@@QAEXABVCMPXMedia@@@Z @ 65 NONAME ; void MpMpxCollectionData::setMpxMedia(class CMPXMedia const &)
+	?artist@MpPlaybackData@@QBEABVQString@@XZ @ 66 NONAME ; class QString const & MpPlaybackData::artist(void) const
+	?getStaticMetaObject@MpPlaybackData@@SAABUQMetaObject@@XZ @ 67 NONAME ; struct QMetaObject const & MpPlaybackData::getStaticMetaObject(void)
+	?albumArt@MpPlaybackData@@QBEXAAVHbIcon@@@Z @ 68 NONAME ; void MpPlaybackData::albumArt(class HbIcon &) const
+	?playbackStateChanged@MpPlaybackData@@IAEXXZ @ 69 NONAME ; void MpPlaybackData::playbackStateChanged(void)
+	?duration@MpPlaybackData@@QBEHXZ @ 70 NONAME ; int MpPlaybackData::duration(void) const
+	?commitPlaybackInfo@MpPlaybackData@@QAEXXZ @ 71 NONAME ; void MpPlaybackData::commitPlaybackInfo(void)
+	?removeRows@MpCollectionDataModel@@UAE_NHHABVQModelIndex@@@Z @ 72 NONAME ; bool MpCollectionDataModel::removeRows(int, int, class QModelIndex const &)
+	?getStaticMetaObject@MpCollectionDataModel@@SAABUQMetaObject@@XZ @ 73 NONAME ; struct QMetaObject const & MpCollectionDataModel::getStaticMetaObject(void)
+	?setDuration@MpPlaybackData@@QAEXH@Z @ 74 NONAME ; void MpPlaybackData::setDuration(int)
+	?playbackInfoChanged@MpPlaybackData@@IAEXXZ @ 75 NONAME ; void MpPlaybackData::playbackInfoChanged(void)
+	?itemData@MpMpxCollectionData@@QBE?AVQString@@HW4DataType@1@@Z @ 76 NONAME ; class QString MpMpxCollectionData::itemData(int, enum MpMpxCollectionData::DataType) const
+	?uri@MpPlaybackData@@QBEABVQString@@XZ @ 77 NONAME ; class QString const & MpPlaybackData::uri(void) const
+	?rowCount@MpCollectionDataModel@@UBEHABVQModelIndex@@@Z @ 78 NONAME ; int MpCollectionDataModel::rowCount(class QModelIndex const &) const
+	?trUtf8@MpPlaybackData@@SA?AVQString@@PBD0H@Z @ 79 NONAME ; class QString MpPlaybackData::trUtf8(char const *, char const *, int)
+	?thumbnailReady@MpPlaybackData@@QAEXABVQPixmap@@PAXHH@Z @ 80 NONAME ; void MpPlaybackData::thumbnailReady(class QPixmap const &, void *, int, int)
+	?staticMetaObject@MpMpxCollectionData@@2UQMetaObject@@B @ 81 NONAME ; struct QMetaObject const MpMpxCollectionData::staticMetaObject
+	?tr@MpPlaybackData@@SA?AVQString@@PBD0H@Z @ 82 NONAME ; class QString MpPlaybackData::tr(char const *, char const *, int)
+	?metaObject@MpCollectionDataModel@@UBEPBUQMetaObject@@XZ @ 83 NONAME ; struct QMetaObject const * MpCollectionDataModel::metaObject(void) const
+	?albumArtReady@MpPlaybackData@@IAEXXZ @ 84 NONAME ; void MpPlaybackData::albumArtReady(void)
+	?qt_metacall@MpMpxCollectionData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 85 NONAME ; int MpMpxCollectionData::qt_metacall(enum QMetaObject::Call, int, void * *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/eabi/mpdatau.def	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,87 @@
+EXPORTS
+	_ZN14MpPlaybackData11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME
+	_ZN14MpPlaybackData11qt_metacastEPKc @ 2 NONAME
+	_ZN14MpPlaybackData11setDurationEi @ 3 NONAME
+	_ZN14MpPlaybackData11setPositionEi @ 4 NONAME
+	_ZN14MpPlaybackData13albumArtReadyEv @ 5 NONAME
+	_ZN14MpPlaybackData14setAlbumArtUriERK7QString @ 6 NONAME
+	_ZN14MpPlaybackData14thumbnailReadyERK7QPixmapPvii @ 7 NONAME
+	_ZN14MpPlaybackData15durationChangedEv @ 8 NONAME
+	_ZN14MpPlaybackData15positionChangedEv @ 9 NONAME
+	_ZN14MpPlaybackData16setPlaybackStateENS_15SimplifiedStateE @ 10 NONAME
+	_ZN14MpPlaybackData16staticMetaObjectE @ 11 NONAME DATA 16
+	_ZN14MpPlaybackData18commitPlaybackInfoEv @ 12 NONAME
+	_ZN14MpPlaybackData19getStaticMetaObjectEv @ 13 NONAME
+	_ZN14MpPlaybackData19playbackInfoChangedEv @ 14 NONAME
+	_ZN14MpPlaybackData20playbackStateChangedEv @ 15 NONAME
+	_ZN14MpPlaybackData6setUriERK7QString @ 16 NONAME
+	_ZN14MpPlaybackData8setAlbumERK7QString @ 17 NONAME
+	_ZN14MpPlaybackData8setTitleERK7QString @ 18 NONAME
+	_ZN14MpPlaybackData9setArtistERK7QString @ 19 NONAME
+	_ZN14MpPlaybackDataC1EP7QObject @ 20 NONAME
+	_ZN14MpPlaybackDataC2EP7QObject @ 21 NONAME
+	_ZN14MpPlaybackDataD0Ev @ 22 NONAME
+	_ZN14MpPlaybackDataD1Ev @ 23 NONAME
+	_ZN14MpPlaybackDataD2Ev @ 24 NONAME
+	_ZN19MpMpxCollectionData10removeItemEi @ 25 NONAME
+	_ZN19MpMpxCollectionData11containerIdEv @ 26 NONAME
+	_ZN19MpMpxCollectionData11qt_metacallEN11QMetaObject4CallEiPPv @ 27 NONAME
+	_ZN19MpMpxCollectionData11qt_metacastEPKc @ 28 NONAME
+	_ZN19MpMpxCollectionData11setMpxMediaERK9CMPXMedia @ 29 NONAME
+	_ZN19MpMpxCollectionData14containerMediaEv @ 30 NONAME
+	_ZN19MpMpxCollectionData14contextChangedE18TCollectionContext @ 31 NONAME
+	_ZN19MpMpxCollectionData14isAutoPlaylistEi @ 32 NONAME
+	_ZN19MpMpxCollectionData14isAutoPlaylistEv @ 33 NONAME
+	_ZN19MpMpxCollectionData14testCachedItemEi @ 34 NONAME
+	_ZN19MpMpxCollectionData16insertCachedItemEi @ 35 NONAME
+	_ZN19MpMpxCollectionData16staticMetaObjectE @ 36 NONAME DATA 16
+	_ZN19MpMpxCollectionData19getStaticMetaObjectEv @ 37 NONAME
+	_ZN19MpMpxCollectionData6itemIdEi @ 38 NONAME
+	_ZN19MpMpxCollectionData9itemCountEi @ 39 NONAME
+	_ZN19MpMpxCollectionDataC1EP7QObject @ 40 NONAME
+	_ZN19MpMpxCollectionDataC2EP7QObject @ 41 NONAME
+	_ZN19MpMpxCollectionDataD0Ev @ 42 NONAME
+	_ZN19MpMpxCollectionDataD1Ev @ 43 NONAME
+	_ZN19MpMpxCollectionDataD2Ev @ 44 NONAME
+	_ZN21MpCollectionDataModel10removeRowsEiiRK11QModelIndex @ 45 NONAME
+	_ZN21MpCollectionDataModel11qt_metacallEN11QMetaObject4CallEiPPv @ 46 NONAME
+	_ZN21MpCollectionDataModel11qt_metacastEPKc @ 47 NONAME
+	_ZN21MpCollectionDataModel12dropMimeDataEPK9QMimeDataN2Qt10DropActionEiiRK11QModelIndex @ 48 NONAME
+	_ZN21MpCollectionDataModel12orderChangedEiiii @ 49 NONAME
+	_ZN21MpCollectionDataModel12refreshModelEv @ 50 NONAME
+	_ZN21MpCollectionDataModel14collectionDataEv @ 51 NONAME
+	_ZN21MpCollectionDataModel14updateAlbumArtEi @ 52 NONAME
+	_ZN21MpCollectionDataModel16staticMetaObjectE @ 53 NONAME DATA 16
+	_ZN21MpCollectionDataModel19getStaticMetaObjectEv @ 54 NONAME
+	_ZN21MpCollectionDataModelC1EP19MpMpxCollectionDataP7QObject @ 55 NONAME
+	_ZN21MpCollectionDataModelC2EP19MpMpxCollectionDataP7QObject @ 56 NONAME
+	_ZN21MpCollectionDataModelD0Ev @ 57 NONAME
+	_ZN21MpCollectionDataModelD1Ev @ 58 NONAME
+	_ZN21MpCollectionDataModelD2Ev @ 59 NONAME
+	_ZNK14MpPlaybackData10metaObjectEv @ 60 NONAME
+	_ZNK14MpPlaybackData13playbackStateEv @ 61 NONAME
+	_ZNK14MpPlaybackData3uriEv @ 62 NONAME
+	_ZNK14MpPlaybackData5albumEv @ 63 NONAME
+	_ZNK14MpPlaybackData5titleEv @ 64 NONAME
+	_ZNK14MpPlaybackData6artistEv @ 65 NONAME
+	_ZNK14MpPlaybackData8albumArtER6HbIcon @ 66 NONAME
+	_ZNK14MpPlaybackData8durationEv @ 67 NONAME
+	_ZNK14MpPlaybackData8positionEv @ 68 NONAME
+	_ZNK19MpMpxCollectionData10metaObjectEv @ 69 NONAME
+	_ZNK19MpMpxCollectionData15collectionTitleEv @ 70 NONAME
+	_ZNK19MpMpxCollectionData5countEv @ 71 NONAME
+	_ZNK19MpMpxCollectionData7contextEv @ 72 NONAME
+	_ZNK19MpMpxCollectionData8itemDataEiNS_8DataTypeE @ 73 NONAME
+	_ZNK21MpCollectionDataModel10metaObjectEv @ 74 NONAME
+	_ZNK21MpCollectionDataModel20supportedDropActionsEv @ 75 NONAME
+	_ZNK21MpCollectionDataModel4dataERK11QModelIndexi @ 76 NONAME
+	_ZNK21MpCollectionDataModel8mimeDataERK5QListI11QModelIndexE @ 77 NONAME
+	_ZNK21MpCollectionDataModel8rowCountERK11QModelIndex @ 78 NONAME
+	_ZNK21MpCollectionDataModel9mimeTypesEv @ 79 NONAME
+	_ZTI14MpPlaybackData @ 80 NONAME
+	_ZTI19MpMpxCollectionData @ 81 NONAME
+	_ZTI21MpCollectionDataModel @ 82 NONAME
+	_ZTV14MpPlaybackData @ 83 NONAME
+	_ZTV19MpMpxCollectionData @ 84 NONAME
+	_ZTV21MpCollectionDataModel @ 85 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/inc/mpcollectionalbumartmanager.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection album art manager.
+*
+*/
+
+
+#ifndef MPCOLLECTIONALBUMARTMANAGER_H
+#define MPCOLLECTIONALBUMARTMANAGER_H
+
+#include <QObject>
+#include <QCache>
+#include <QIcon>
+#include <QList>
+
+class MpMpxCollectionData;
+class ThumbnailManager;
+
+class MpCollectionAlbumArtManager : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    explicit MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent=0 );
+    virtual ~MpCollectionAlbumArtManager();
+
+    const QIcon* albumArt( int index );
+    void cacheFirstScreen();
+    void cancel();
+
+signals:
+
+    void albumArtReady( int index );
+
+public slots:
+
+    void thumbnailReady( QPixmap pixmap, void *data, int id, int error );
+
+private:
+
+    MpMpxCollectionData             *mCollectionData;
+    ThumbnailManager                *mThumbnailManager;
+    QCache<int, QIcon>              mImageCache;
+    bool                            mCachingInProgress;
+
+    QIcon                           *mDefaultIcon;
+
+    QList<int>                      mRequestQueue;
+    bool                            mPendingRequest;
+    int                             mRequestId;
+
+};
+
+#endif // MPCOLLECTIONALBUMARTMANAGER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/inc/mpmpxcollectiondata_p.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection data - private implementation.
+*
+*/
+
+#ifndef MPMPXCOLLECTIONDATA_P_H
+#define MPMPXCOLLECTIONDATA_P_H
+
+#include <e32base.h>
+
+#include "mpmpxcollectiondata.h"
+#include "mpmpxcollectionviewdefs.h"
+
+class CMPXMedia;
+class CMPXMediaArray;
+
+
+class MpMpxCollectionDataPrivate
+{
+public:
+
+    explicit MpMpxCollectionDataPrivate( MpMpxCollectionData *wrapper );
+    virtual ~MpMpxCollectionDataPrivate();
+
+    TCollectionContext context() const;
+
+    int count() const;
+    QString collectionTitle() const;
+    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
+
+    bool isAutoPlaylist();
+    bool isAutoPlaylist( int index );
+    int itemCount( int index );
+    int containerId();
+    int itemId(int index);
+    void removeItem(int index);
+    bool testCachedItem( int itemId );
+    void insertCachedItem(int index);
+
+    void setMpxMedia( const CMPXMedia& entries );
+    const CMPXMedia& containerMedia();
+
+private:
+
+    void DoGetDataL( int index, MpMpxCollectionData::DataType type, QString& data ) const;
+    bool DoIsAutoPlaylistL();
+    bool DoIsAutoPlaylistL( int index );
+    int DoGetItemCountL( int index );
+    int DoGetContainerIdL();
+    int DoGetItemIdL( int index );
+    void DoRemoveItemL( int index );
+    bool DoTestCachedItemL( int itemId );
+    
+    void SetCollectionContextL();
+    void DoSetMpxMediaL( const CMPXMedia& entries );
+
+private:
+
+    MpMpxCollectionData     *q_ptr;
+
+    CMPXMedia               *iContainerMedia;       // Owned
+    CMPXMediaArray          *iMediaArray;           // Not owned
+
+    TCollectionContext      iContext;
+    
+    CMPXMedia               *iCachedRemovedItem; //Owned
+
+};
+
+#endif // MPMPXCOLLECTIONDATA_P_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/mpdata.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Project file for Music Player Data.
+#
+
+symbian:TARGET.UID3 = 0x10207C95
+
+TEMPLATE = lib
+CONFIG += hb
+TARGET = mpdata
+
+TARGET.CAPABILITY = CAP_GENERAL_DLL
+
+INCLUDEPATH += . \
+    	inc \
+    	../inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lmpxcommon.dll \
+    -lthumbnailmanagerqt.dll
+    
+symbian:TARGET.EPOCALLOWDLLDATA	= 1
+
+HEADERS += ../inc/mpmpxcollectiondata.h \
+           inc/mpmpxcollectiondata_p.h \
+           ../inc/mpcollectiondatamodel.h \
+    	     inc/mpcollectionalbumartmanager.h \
+    	     ../inc/mpplaybackdata.h
+
+SOURCES += src/mpmpxcollectiondata.cpp \
+           src/mpmpxcollectiondata_p.cpp \
+           src/mpcollectiondatamodel.cpp \
+    	     src/mpcollectionalbumartmanager.cpp \
+           src/mpplaybackdata.cpp
+           
+DEFINES += BUILD_MPDATA_LIB
+
+myDefInclude = "NOSTRICTDEF" \
+"$${LITERAL_HASH}if defined(WINS)"\
+"DEFFILE  bwins/mpdatau.def "\
+"$${LITERAL_HASH}else "\
+"DEFFILE  eabi/mpdatau.def "\
+"$${LITERAL_HASH}endif"
+MMP_RULES += myDefInclude
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/rom/mpdata.iby	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __MPDATA_IBY__
+#define __MPDATA_IBY__
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\mpdata.dll          SHARED_LIB_DIR\mpdata.dll
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/rom/rom.pri	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+symbian {
+MP_IBY_DIR = $$section(PWD,":",1)
+
+BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/mpdata.iby CORE_APP_LAYER_IBY_EXPORT_PATH(mpdata.iby)"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/src/mpcollectionalbumartmanager.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,216 @@
+
+
+
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection album art manager.
+*
+*/
+
+#include <thumbnailmanager_qt.h>
+#include <hbicon.h>
+
+#include "mpcollectionalbumartmanager.h"
+#include "mpmpxcollectiondata.h"
+#include "mptrace.h"
+
+const int KInitCacheSize = 10;
+const int KMaxCacheSize = 50;
+
+/*!
+    \class MpCollectionAlbumArtManager
+    \brief Music Player collection album art manager.
+
+    Collection album art manager provides access to album art needed for
+    display in certain collection views. It hides interface to the thumbnail
+    manager and also implements a caching mechanism for performance reasons.
+*/
+
+/*!
+    \fn void albumArtReady( int index )
+
+    This signal is emitted when album art for \a index is ready.
+
+    \sa getAlbumArt()
+ */
+
+/*!
+    \fn void albumCacheReady()
+
+    This signal is emitted when album art cache is ready.
+
+    \sa cacheAlbumArt()
+ */
+
+/*!
+ Constructs the album art manager.
+ */
+MpCollectionAlbumArtManager::MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent )
+    : QObject(parent),
+      mCollectionData(data),
+      mThumbnailManager(0),
+      mCachingInProgress(false),
+      mDefaultIcon(0),
+      mPendingRequest(false)
+{
+    TX_ENTRY
+    mThumbnailManager = new ThumbnailManager(this);
+    mThumbnailManager->setMode(ThumbnailManager::Default);
+    mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
+    mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailSmall);
+
+    connect( mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+             this, SLOT(thumbnailReady(QPixmap, void *, int, int)) );
+
+    mImageCache.setMaxCost(KMaxCacheSize);
+    //TODO: Change to final resource when available
+    HbIcon albumArt( "qtg_large_music" );
+    mDefaultIcon = new QIcon( albumArt.qicon() );
+    TX_EXIT
+}
+
+/*!
+ Destructs the album art manager.
+ */
+MpCollectionAlbumArtManager::~MpCollectionAlbumArtManager()
+{
+    TX_ENTRY
+    cancel();
+    delete mThumbnailManager;
+    delete mDefaultIcon;
+    TX_EXIT
+}
+
+/*!
+ Returns the album art for the given \a index. If the album art is not
+ available in its cache, an asynchronous request is made to the thumbnail manager
+ and default icon is returned.
+
+ \sa signal albumArtReady
+ */
+const QIcon* MpCollectionAlbumArtManager::albumArt( int index )
+{
+    TX_ENTRY_ARGS("index=" << index);
+    QIcon *icon = mImageCache[index];
+    if ( !icon ) {
+        icon = mDefaultIcon;
+        if ( !mRequestQueue.contains(index) ) {
+            // Icon was not found in cache. If the item has AlbumArtUri, request it
+            // through ThumbnailManager interface.
+            QString albumArtUri = mCollectionData->itemData(index, MpMpxCollectionData::AlbumArtUri);
+            if ( !albumArtUri.isEmpty() ) {
+                if ( !mPendingRequest ) {
+                    void *clientData = reinterpret_cast<void *>(index);
+                    mRequestId = mThumbnailManager->getThumbnail( albumArtUri, clientData );
+                    if ( mRequestId != -1 ) {
+                        mPendingRequest = true;
+                        TX_EXIT_ARGS("false - album art requested");
+                    }
+                    else {
+                        TX_EXIT_ARGS("Err: thumbnail manager returned (-1) for getThumbnail request!");
+                    }
+                }
+                else {
+                    mRequestQueue.append( index );
+                    TX_EXIT_ARGS("false - request queued");
+                }
+            }
+        }
+    }
+    return icon;
+}
+
+/*!
+ Before providing the new data to the view (list, grid, etc.), we want
+ to make sure that we have enough album arts for the first screen.
+ */
+void MpCollectionAlbumArtManager::cacheFirstScreen()
+{
+    TX_ENTRY
+    int count = mCollectionData->count();
+    int initCount = ( count > KInitCacheSize ) ? KInitCacheSize : count;
+    for ( int i = 0; i < initCount; i++ ) {
+        albumArt(i);
+    }
+    if ( mPendingRequest ) {
+        mCachingInProgress = true;
+    }
+    TX_EXIT
+}
+
+/*!
+ Cancels all outstanding album art requests.
+
+ \sa getAlbumArt, cacheAlbumArt
+ */
+void MpCollectionAlbumArtManager::cancel()
+{
+    TX_ENTRY
+    if ( mPendingRequest ) {
+        mThumbnailManager->cancelRequest(mRequestId);
+    }
+    mImageCache.clear();
+    mRequestQueue.clear();
+    mPendingRequest = false;
+    mCachingInProgress = false;
+    TX_EXIT
+}
+
+/*!
+ Slot to be called when thumbnail bitmap generation or loading is complete.
+ */
+void MpCollectionAlbumArtManager::thumbnailReady( QPixmap pixmap, void *data, int id, int error )
+{
+    int index = reinterpret_cast<int>(data);
+    TX_ENTRY_ARGS("index=" << index << ", id=" << id << ", error=" << error);
+    if ( !error && id == mRequestId && !pixmap.isNull() ) {
+        // Find the index
+        mImageCache.insert(index, new QIcon(pixmap));
+        TX_LOG_ARGS("Album art ready for index=" << index);
+        if ( !mCachingInProgress ) {
+            emit albumArtReady(index);
+        }
+    }
+    else {
+        TX_EXIT_ARGS("Err: thumbnail manager returned error for getThumbnail request!");
+    }
+
+    if ( mCachingInProgress ) {
+        if ( index >= (KInitCacheSize - 1) || !mRequestQueue.count() ) {
+            mCachingInProgress = false;
+            for ( int i = 0; i <= KInitCacheSize; ++i ) {
+                if ( mImageCache.contains(i) ) {
+                    emit albumArtReady(i);
+                }
+            }
+        }
+    }
+
+    mPendingRequest = false;
+    if ( mRequestQueue.count() ) {
+        int index = mRequestQueue.takeFirst();
+        QString albumArtUri = mCollectionData->itemData(index, MpMpxCollectionData::AlbumArtUri);
+        void *clientData = reinterpret_cast<void *>(index);
+        mRequestId = mThumbnailManager->getThumbnail( albumArtUri, clientData );
+        if ( mRequestId != -1 ) {
+            mPendingRequest = true;
+            TX_EXIT_ARGS("next album art requested");
+        }
+        else {
+            TX_EXIT_ARGS("Err: thumbnail manager returned (-1) for getThumbnail request!");
+        }
+    }
+    TX_EXIT
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/src/mpcollectiondatamodel.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,311 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection data model.
+*
+*/
+
+#include <QIcon>
+#include <QList>
+#include <qmimedata.h>
+#include <hbicon.h>
+#include <hbnamespace.h>
+
+#include "mpcollectiondatamodel.h"
+#include "mpcollectionalbumartmanager.h"
+#include "mpmpxcollectiondata.h"
+#include "mptrace.h"
+
+/*!
+    \class MpCollectionDataModel
+    \brief Music Player collection data model.
+
+    Collection data model implements the interface specified by HbAbstractDataModel,
+    which defines the standard interface that item models must use to be able to
+    interoperate with other components in the model/view architecture.
+
+    Every item of data that can be accessed via a model has an associated model
+    index.
+
+    Each item has a number of data elements associated with it and they can be
+    retrieved by specifying a role (see Qt::ItemDataRole) to the model's data
+    returned by itemData() function.
+
+    \sa HbAbstractDataModel
+*/
+
+/*!
+    \fn void orderChanged( int containerId, int itemId, int itemOrdinal, int newOrdinal )
+
+    This signal is emitted when a reorder operations is propagated to the 
+    model, indicates that the item with \a containerId , \a itemId is to 
+    be moved from \a itemOrdinal to \a newOrdinal.
+ */
+
+/*!
+ Constructs the collection data model.
+ */
+MpCollectionDataModel::MpCollectionDataModel( MpMpxCollectionData *data, QObject *parent )
+    : QAbstractListModel(parent),
+      mCollectionData(data),
+      mRowCount(0)
+{
+    TX_ENTRY
+    mAlbumArtManager = new MpCollectionAlbumArtManager(mCollectionData);
+    connect( mAlbumArtManager, SIGNAL(albumArtReady(int)), this, SLOT(updateAlbumArt(int)) );
+    TX_EXIT
+}
+
+/*!
+ Destructs the collection data model.
+ */
+MpCollectionDataModel::~MpCollectionDataModel()
+{
+    TX_ENTRY
+    delete mAlbumArtManager;
+    TX_EXIT
+}
+
+/*!
+ Returns the number of rows under the given \a parent.
+
+ View will request for the row count immediately after a model is set.
+ To prevent it from reading data while caching the album art for the first
+ screen, return row count as zero.
+
+ \reimp
+ */
+int MpCollectionDataModel::rowCount( const QModelIndex &parent ) const
+{
+    TX_LOG
+    Q_UNUSED(parent);
+    return mRowCount;
+}
+
+/*!
+ Returns the data stored for the item referred to by the \a index.
+
+ \reimp
+ */
+QVariant MpCollectionDataModel::data(const QModelIndex &index, int role) const
+{
+    TX_ENTRY
+    QVariant returnValue = QVariant();
+    if ( !index.isValid() ) {
+        return returnValue;
+    }
+
+    int row = index.row();
+    TX_LOG_ARGS("index=" << row << ", role=" << role);
+    TCollectionContext context = mCollectionData->context();
+    if ( role == Qt::DisplayRole ) {
+        QStringList display;
+        // Fetch the primary text, which is the title, if available.
+        QString primaryText;
+        primaryText = mCollectionData->itemData(row, MpMpxCollectionData::Title);
+        if ( !primaryText.isEmpty() ) {
+            display << primaryText;
+        }
+        else {
+            display << hbTrId("txt_mus_other_unknown4");
+        }
+
+        // Fetch the secondary text, which depends on the current context, if available.
+        QString secondaryText;
+        switch ( context ) {
+            case ECollectionContextAllSongs:
+            case ECollectionContextAlbums:
+            case ECollectionContextPlaylistSongs:
+                secondaryText = mCollectionData->itemData(row, MpMpxCollectionData::Artist);
+                if ( !secondaryText.isEmpty() ) {
+                    display << secondaryText;
+                }
+                else {
+                    display << hbTrId("txt_mus_other_unknown3");
+                }
+                break;
+            case ECollectionContextArtistSongs: 
+                secondaryText = mCollectionData->itemData(row, MpMpxCollectionData::Album);
+                if ( !secondaryText.isEmpty() ) {
+                    display << secondaryText;
+                }
+                else {
+                    display << hbTrId("txt_mus_other_unknown4");
+                }
+                break;
+            default:
+                break;
+        }
+        returnValue = display;
+    }
+    else if ( role == Qt::DecorationRole ) {
+        switch ( context ) {
+            case ECollectionContextAlbums:
+            case ECollectionContextArtistAlbums:
+                const QIcon *icon = mAlbumArtManager->albumArt(row);
+                QVariant iconVariant(QVariant::Icon, icon);
+                returnValue = iconVariant;
+                break;
+        }
+    }
+    else if ( role == Hb::IndexFeedbackRole ) {
+        QString feedbackIndex;
+        feedbackIndex = mCollectionData->itemData(row, MpMpxCollectionData::Title);
+        returnValue = feedbackIndex;
+    }
+    TX_EXIT
+    return returnValue;
+}
+
+/*!
+ \reimp
+ */
+Qt::DropActions MpCollectionDataModel::supportedDropActions() const
+{
+    return Qt::MoveAction;
+}
+
+/*! 
+ \reimp
+*/
+bool MpCollectionDataModel::removeRows(int row, int count, const QModelIndex &parent )
+{
+    if ( count != 1 || row >= mRowCount ) {
+        return false;
+    }
+    beginRemoveRows ( parent, row, row);
+    //This call internally caches the item, to be inserted if it it drag and drop.
+    mCollectionData->removeItem(row);
+    mRowCount--;
+    endRemoveRows();
+    return true;
+}
+
+/*! 
+ \reimp
+*/
+QStringList MpCollectionDataModel::mimeTypes() const
+{
+    QStringList types;
+    types << QLatin1String("application/x-mpcollectiondatamodelrowandids");
+    return types;
+}
+
+/*! 
+ \reimp
+*/
+QMimeData *MpCollectionDataModel::mimeData(const QModelIndexList &indexes) const
+{
+    if (indexes.count() != 1)
+        return 0;
+    QStringList types = mimeTypes();
+    if (types.isEmpty())
+        return 0;
+    QMimeData *data = new QMimeData();
+    QString format = types.at(0);
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexes.at(0).row();
+    stream << mCollectionData->containerId();
+    stream << mCollectionData->itemId( indexes.at(0).row() );
+    
+    data->setData(format, encoded);
+    return data;
+}
+
+/*! 
+ \reimp
+*/
+bool MpCollectionDataModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
+                          int row, int column, const QModelIndex &parent)
+{
+    Q_UNUSED(column);
+    // check if the action is supported
+    if (!data || action != Qt::MoveAction | row > mRowCount ) {
+        return false;
+    }
+    // check if the format is supported
+    QStringList types = mimeTypes();
+    if (types.isEmpty()) {
+        return false;
+    }
+    QString format = types.at(0);
+    if (!data->hasFormat(format)) {
+        return false;
+    }
+    // decode and insert
+    QByteArray encoded = data->data(format);
+    QDataStream stream(&encoded, QIODevice::ReadOnly);
+    int rowFrom = -1;
+    int mpxContainerId = -1;
+    int mpxItemId = -1;
+    if (!stream.atEnd()) {
+        stream >> rowFrom;
+        stream >> mpxContainerId;
+        stream >> mpxItemId;
+    } 
+    if ( rowFrom == -1 || mpxContainerId == -1 || mpxItemId == -1  || 
+            !mCollectionData->testCachedItem( mpxItemId ) || rowFrom > mRowCount) {
+        return false;
+    }    
+        
+    beginInsertRows( parent, row, row );
+    emit orderChanged( mpxContainerId, mpxItemId, rowFrom, row );
+    mCollectionData->insertCachedItem( row );
+    mRowCount++;
+    endInsertRows();
+    return true;
+}
+
+/*!
+ Returns pointer to MpMpxCollectionData, which is the collection data.
+ */
+MpMpxCollectionData *MpCollectionDataModel::collectionData()
+{
+    return mCollectionData;
+}
+
+/*!
+ Slot to be called when album art for the \a index needs to be updated.
+ */
+void MpCollectionDataModel::updateAlbumArt( int index )
+{
+    TX_ENTRY_ARGS("index=" << index);
+    if ( index >= 0 && index < mRowCount ) {
+        QModelIndex modelIndex = QAbstractItemModel::createIndex(index, 0);
+        emit dataChanged(modelIndex, modelIndex);
+    }
+    TX_EXIT
+}
+
+/*!
+ Slot to be called when data has changed and model needs to be refreshed
+ to reflect the new data.
+ */
+void MpCollectionDataModel::refreshModel()
+{
+    TX_ENTRY
+    // Cancel all outstanding album art request first, then reset the model.
+    mAlbumArtManager->cancel();
+    mRowCount = mCollectionData->count();
+
+    TCollectionContext context = mCollectionData->context();
+    if ( context == ECollectionContextAlbums || ECollectionContextArtistAlbums ) {
+        // Before providing the new data to the view (list, grid, etc.), we want
+        // to make sure that we have enough album arts for the first screen.
+        mAlbumArtManager->cacheFirstScreen();
+    }
+    reset();
+    TX_EXIT
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/src/mpmpxcollectiondata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection data.
+*
+*/
+
+#include "mpmpxcollectiondata.h"
+#include "mpmpxcollectiondata_p.h"
+
+/*!
+    \class MpMpxCollectionData
+    \brief Music Player collection data.
+
+    Collection data provides access to collection data needed by the view.
+    Every item of data can be accessed via an index and its details by specifying
+    the data type of the selected data item.
+*/
+
+/*!
+    \enum MpMpxCollectionData::DataType
+
+    This enum defines available data types.
+ */
+
+/*!
+    \fn void contextChanged( TCollectionContext context )
+
+    This signal is emitted when a new data set is available and the
+    collection context is changed.
+
+    \sa setMpxMedia()
+ */
+
+/*!
+ Constructs the collection data.
+ */
+MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
+    : QObject(parent)
+{
+    d_ptr = new MpMpxCollectionDataPrivate(this);
+}
+
+/*!
+ Destructs the collection data.
+ */
+MpMpxCollectionData::~MpMpxCollectionData()
+{
+    delete d_ptr;
+}
+
+/*!
+ Returns the current collection context.
+ */
+TCollectionContext MpMpxCollectionData::context() const
+{
+    return d_ptr->context();
+}
+
+/*!
+ Returns the number of data entries.
+ */
+int MpMpxCollectionData::count() const
+{
+    return d_ptr->count();
+}
+
+/*!
+ Returns the \a title of the collection data based on the current context.
+ */
+QString MpMpxCollectionData::collectionTitle() const
+{
+    return d_ptr->collectionTitle();
+}
+
+/*!
+ Returns the data for the specified \a index and \a type.
+ */
+QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
+{
+    return d_ptr->itemData(index, type);
+}
+
+/*!
+ Returns if the current container is of type 'Auto playlist'.
+ */
+bool MpMpxCollectionData::isAutoPlaylist()
+{
+    return d_ptr->isAutoPlaylist();
+}
+
+/*!
+ Returns if the item specified by \a index is of type 'Auto playlist'.
+ */
+bool MpMpxCollectionData::isAutoPlaylist( int index )
+{
+    return d_ptr->isAutoPlaylist(index);
+}
+
+/*!
+ Returns the count of the items contained within item specified by \a index.
+ */
+int MpMpxCollectionData::itemCount( int index )
+{
+    return d_ptr->itemCount(index);
+}
+
+/*!
+ Returns the current container id.
+ */
+int MpMpxCollectionData::containerId()
+{
+    return d_ptr->containerId();
+}
+
+/*!
+ Returns id of the item specified by \a index
+ */
+int MpMpxCollectionData::itemId(int index)
+{
+    return d_ptr->itemId(index);
+}
+
+/*!
+ Removes item specified by \a index, also internally caches the item for drag
+ and drop operations.
+ 
+ \sa testCachedItem() insertCachedItem()
+ */
+void MpMpxCollectionData::removeItem(int index)
+{
+    d_ptr->removeItem(index);
+}
+
+/*!
+ Test wether the cached item matches \a itemId.
+ \sa removeItem() insertCachedItem()
+ */
+bool MpMpxCollectionData::testCachedItem( int itemId )
+{
+    return d_ptr->testCachedItem( itemId );
+}
+
+/*!
+ Inserts the cached item in the location specified by \a index
+ \sa removeItem() testCachedItem()
+ */
+void MpMpxCollectionData::insertCachedItem(int index)
+{
+    return d_ptr->insertCachedItem( index );
+}
+
+/*!
+ Sets the media \a entries from the MPX framework.
+ Internal usage only from MpMpxFrameworkWrapper.
+ */
+void MpMpxCollectionData::setMpxMedia( const CMPXMedia& entries )
+{
+    d_ptr->setMpxMedia(entries);
+}
+
+/*!
+ Returns the container media from the MPX framework.
+ Internal usage only from MpMpxFrameworkWrapper.
+
+
+ \sa setMpxMedia()
+ */
+const CMPXMedia& MpMpxCollectionData::containerMedia()
+{
+    return d_ptr->containerMedia();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/src/mpmpxcollectiondata_p.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,518 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection data - private implementation.
+*
+*/
+
+#include <thumbnaildata.h>
+#include <thumbnailobjectsource.h>
+
+#include <mpxmedia.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediaarray.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediamusicdefs.h>
+
+#include "mpmpxcollectiondata_p.h"
+#include "mptrace.h"
+
+_LIT( KSong, " song" );
+_LIT( KSongs, " songs" );
+
+/*!
+    \class MpMpxCollectionDataPrivate
+    \brief Music Player collection data - private implementation.
+
+    This is a private implementation of the collection data interface.
+*/
+
+/*!
+ \internal
+ */
+MpMpxCollectionDataPrivate::MpMpxCollectionDataPrivate( MpMpxCollectionData *wrapper )
+    : q_ptr( wrapper ),
+      iContainerMedia(0),
+      iMediaArray(0),
+      iContext( ECollectionContextUnknown ),
+      iCachedRemovedItem ( 0 )
+{
+    TX_LOG
+}
+
+/*!
+ \internal
+ */
+MpMpxCollectionDataPrivate::~MpMpxCollectionDataPrivate()
+{
+    TX_ENTRY
+    delete iContainerMedia;
+    delete iCachedRemovedItem;
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+TCollectionContext MpMpxCollectionDataPrivate::context() const
+{
+    return iContext;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::count() const
+{
+    if ( iMediaArray ) {
+        return iMediaArray->Count();
+    }
+    return 0;
+}
+
+/*!
+ \internal
+ */
+QString MpMpxCollectionDataPrivate::collectionTitle() const
+{
+    TX_ENTRY
+    QString title;
+    if ( iContainerMedia && iContainerMedia->IsSupported( KMPXMediaGeneralTitle ) ) {
+        const TDesC& titleText = iContainerMedia->ValueText( KMPXMediaGeneralTitle );
+        if ( titleText.Compare( KNullDesC ) != 0 ) {
+            title = QString::fromUtf16( titleText.Ptr(), titleText.Length() );
+        }
+    }
+    TX_EXIT_ARGS("title =" << title);
+    return title;
+}
+
+/*!
+ \internal
+ */
+QString MpMpxCollectionDataPrivate::itemData( int index, MpMpxCollectionData::DataType type ) const
+{
+    TX_ENTRY_ARGS("index=" << index << ", type=" << type);
+    QString data;
+    TRAPD(err, DoGetDataL(index, type, data));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return data;
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::isAutoPlaylist()
+{
+    TX_ENTRY
+    if ( iContext != ECollectionContextPlaylistSongs ) {
+        TX_EXIT
+        return false;
+    }
+
+    bool isAuto = false;
+    TRAPD(err, isAuto = DoIsAutoPlaylistL());
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("isAuto=" << isAuto);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return isAuto;
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::isAutoPlaylist( int index )
+{
+    TX_ENTRY_ARGS("index=" << index);
+    if ( iContext != ECollectionContextPlaylists ) {
+        TX_EXIT
+        return false;
+    }
+
+    bool isAuto = false;
+    TRAPD(err, isAuto = DoIsAutoPlaylistL(index));
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("isAuto=" << isAuto);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return isAuto;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::itemCount( int index )
+{
+    TX_ENTRY_ARGS("index=" << index);
+    int count = 0;
+    TRAPD(err, count = DoGetItemCountL(index));
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("count=" << count);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return count;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::containerId()
+{
+    int id = -1;
+    TRAPD( err, id = DoGetContainerIdL() );
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("id=" << id);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return id;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::itemId(int index)
+{
+    TX_ENTRY_ARGS("index=" << index);
+    int id = -1;
+    TRAPD(err, id = DoGetItemIdL(index));
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("id=" << id);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return id;
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::removeItem(int index)
+{
+    TX_ENTRY_ARGS("index=" << index);
+     TRAPD(err,  DoRemoveItemL(index));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::testCachedItem( int itemId )
+{
+    TX_ENTRY_ARGS( "itemId=" << itemId);
+    bool match = false;
+    TRAPD( err, match = DoTestCachedItemL( itemId ) );
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("match=" << match);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+    return match;
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::insertCachedItem(int index)
+{
+    TX_ENTRY_ARGS("index=" << index);
+    iMediaArray->Insert( iCachedRemovedItem, index );
+    iCachedRemovedItem = 0; //ownership tranferred above.
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::setMpxMedia( const CMPXMedia& entries )
+{
+    TX_ENTRY
+    TRAPD(err, DoSetMpxMediaL(entries));
+    if ( err == KErrNone ) {
+        TX_LOG_ARGS("Context changed: iContext=" << iContext);
+        emit q_ptr->contextChanged(iContext);
+    }
+    else {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::DoGetDataL( int index, MpMpxCollectionData::DataType type, QString& data ) const
+{
+    TX_ENTRY
+    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
+
+    TBuf<256> countBuf;
+    TBuf<20> temp;
+    TInt count = 0;
+    switch ( type ) {
+        case MpMpxCollectionData::Title:
+            if ( currentMedia->IsSupported( KMPXMediaGeneralTitle ) ) {
+                const TDesC& title = currentMedia->ValueText( KMPXMediaGeneralTitle );
+                if ( title.Compare( KNullDesC ) != 0 ) {
+                    data = QString::fromUtf16( title.Ptr(), title.Length() );
+                }
+            }
+            break;
+        case MpMpxCollectionData::Artist:
+            if ( currentMedia->IsSupported( KMPXMediaMusicArtist ) ) {
+                const TDesC& artist = currentMedia->ValueText( KMPXMediaMusicArtist );
+                if ( artist.Compare( KNullDesC ) != 0 ) {
+                    data = QString::fromUtf16( artist.Ptr(), artist.Length() );
+                }
+            }
+            break;
+        case MpMpxCollectionData::Album:
+            if ( currentMedia->IsSupported( KMPXMediaMusicAlbum ) ) {
+                const TDesC& album = currentMedia->ValueText( KMPXMediaMusicAlbum );
+                if ( album.Compare( KNullDesC ) != 0 ) {
+                    data = QString::fromUtf16( album.Ptr(), album.Length() );
+                }
+            }
+            break;
+        case MpMpxCollectionData::Count:
+            if ( currentMedia->IsSupported( KMPXMediaGeneralCount ) ) {
+                count = currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount );
+            }
+            temp.AppendNum( count );
+            //AknTextUtils::LanguageSpecificNumberConversion( temp );
+            countBuf.Append( temp );
+            countBuf.Append( (count > 1 ) ? KSongs() : KSong() );
+            data = QString::fromUtf16( countBuf.Ptr(), countBuf.Length() );
+            break;
+        case MpMpxCollectionData::AlbumArtUri:
+            if ( currentMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) {
+                const TDesC& album = currentMedia->ValueText( KMPXMediaMusicAlbumArtFileName );
+                if ( album.Compare( KNullDesC ) != 0 ) {
+                    data = QString::fromUtf16( album.Ptr(), album.Length() );
+                }
+            }
+            break;
+        case MpMpxCollectionData::Uri:
+            if ( currentMedia->IsSupported( KMPXMediaGeneralUri ) ) {
+                const TDesC& uri = currentMedia->ValueText( KMPXMediaGeneralUri );
+                if ( uri.Compare( KNullDesC ) != 0 ) {
+                    data = QString::fromUtf16( uri.Ptr(), uri.Length() );
+                }
+            }
+            break;
+        default:
+            break;
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::DoIsAutoPlaylistL()
+{
+    if ( iContainerMedia->IsSupported(KMPXMediaGeneralNonPermissibleActions) ) {
+        TMPXGeneralNonPermissibleActions attr(
+                iContainerMedia->ValueTObjectL<TMPXGeneralNonPermissibleActions>(
+                KMPXMediaGeneralNonPermissibleActions ) );
+        if ( attr & EMPXWrite ) {
+            return true;
+        }
+    }
+    return false;
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::DoIsAutoPlaylistL( int index )
+{
+    const CMPXMediaArray* containerArray = iContainerMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ));
+    CMPXMedia* media( containerArray->AtL(index) );
+
+    if ( media->IsSupported(KMPXMediaGeneralNonPermissibleActions) ) {
+        TMPXGeneralNonPermissibleActions attr(
+            media->ValueTObjectL<TMPXGeneralNonPermissibleActions>(
+                KMPXMediaGeneralNonPermissibleActions ) );
+        if ( attr & EMPXWrite ) {
+            return true;
+        }
+    }
+    return false;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::DoGetItemCountL( int index )
+{
+    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
+    int count = 0;
+    if ( currentMedia->IsSupported( KMPXMediaGeneralCount ) ) {
+        count = currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount );
+    }
+    return count;
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::DoGetContainerIdL()
+{
+    if ( !iContainerMedia->IsSupported( KMPXMediaGeneralId ) ) {
+        User::Leave(KErrNotFound);
+    }
+    return iContainerMedia->ValueTObjectL<TInt>( KMPXMediaGeneralId );
+}
+
+/*!
+ \internal
+ */
+int MpMpxCollectionDataPrivate::DoGetItemIdL( int index )
+{
+    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
+    if ( !currentMedia->IsSupported( KMPXMediaGeneralId ) ) {
+        User::Leave(KErrNotFound);
+    }
+    return currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralId );
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::DoRemoveItemL( int index )
+{
+    delete iCachedRemovedItem;
+    iCachedRemovedItem = 0;
+    iCachedRemovedItem = CMPXMedia::NewL( *iMediaArray->AtL( index ) );
+    iMediaArray->Remove( index );
+}
+
+/*!
+ \internal
+ */
+bool MpMpxCollectionDataPrivate::DoTestCachedItemL( int itemId )
+{
+    if ( !iCachedRemovedItem && !iCachedRemovedItem->IsSupported( KMPXMediaGeneralId ) ) {
+        User::Leave(KErrNotFound);
+    }
+    return ( itemId == iCachedRemovedItem->ValueTObjectL<TInt>( KMPXMediaGeneralId ) );
+}
+
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::SetCollectionContextL()
+{
+    TX_ENTRY
+    TMPXGeneralType containerType( EMPXNoType );
+    if ( iContainerMedia->IsSupported( KMPXMediaGeneralType ) ) {
+        containerType = iContainerMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType );
+    }
+
+    TMPXGeneralCategory containerCategory( EMPXNoCategory );
+    if( iContainerMedia->IsSupported( KMPXMediaGeneralCategory ) ) {
+        containerCategory = iContainerMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory );
+    }
+    TX_LOG_ARGS("type=" << containerType << ", category=" << containerCategory );
+
+    iContext = ECollectionContextUnknown;
+    if ( containerType == EMPXGroup ) {
+        switch (containerCategory) {
+            case EMPXSong:
+                iContext = ECollectionContextAllSongs;
+                break;
+            case EMPXArtist:
+                iContext = ECollectionContextArtists;
+                break;
+            case EMPXAlbum:
+                iContext = ECollectionContextAlbums;
+                break;
+            case EMPXPlaylist:
+                iContext = ECollectionContextPlaylists;
+                break;
+            case EMPXGenre:
+                iContext = ECollectionContextGenres;
+                break;
+        }
+    }
+    else if ( containerType == EMPXItem ) {
+        switch (containerCategory) {
+            case EMPXArtist:
+                iContext = ECollectionContextArtistAlbums;
+                break;
+            case EMPXAlbum:
+                iContext = ECollectionContextAlbumSongs;
+                break;
+            case EMPXSong:
+                iContext = ECollectionContextArtistSongs;
+                break;
+            case EMPXPlaylist:
+                iContext = ECollectionContextPlaylistSongs;
+                break;
+            case EMPXGenre:
+                iContext = ECollectionContextGenreSongs;
+                break;
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionDataPrivate::DoSetMpxMediaL( const CMPXMedia& entries )
+{
+    TX_ENTRY
+    delete iContainerMedia;
+    iContainerMedia = 0;
+    iContainerMedia = CMPXMedia::NewL(entries);
+    iMediaArray = const_cast<CMPXMediaArray*>(iContainerMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+    TX_LOG_ARGS("media count=" << iMediaArray->Count() );
+
+    SetCollectionContextL();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+const CMPXMedia& MpMpxCollectionDataPrivate::containerMedia()
+{
+    return *iContainerMedia;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/src/mpplaybackdata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Playback Data provider for playback view.
+*
+*/
+
+#include <qicon>
+#include <qstring>
+#include <qpixmap>
+#include <qpainter>
+#include <hbicon.h>
+#include <thumbnailmanager_qt.h>
+
+#include "mpplaybackdata.h"
+#include "mptrace.h"
+
+const int KUndefined = -1;
+
+/*!
+    \class MpPlaybackData
+    \brief Music Player playback data.
+
+    Playback data provides access to current playing song data, and playback
+    properties, it is designed as an interface between the playback wrapper
+    and the UI, it also provides album art extraction.
+*/
+
+/*!
+    \fn void durationChanged()
+
+    This signal is emitted when duration changes.
+ */
+
+/*!
+    \fn void positionChanged()
+
+    This signal is emitted when position changes.
+ */
+
+/*!
+    \fn void albumArtReady()
+
+    This signal is emitted when album art is ready.
+ */
+
+/*!
+    \fn void playbackStateChanged()
+
+    This signal is emitted when there is a *transition* on the playback state,
+    this is based on a simple state.
+ */
+
+/*!
+    \fn void playbackInfoChanged()
+
+    This signal is emitted when playback info changes. This includes:
+    title, artist and album name.
+ */
+
+
+
+/*!
+    Constructs a new MpPlaybackData.
+ */
+MpPlaybackData::MpPlaybackData( QObject *parent )
+    : QObject(parent),
+      mThumbnailManager(0),
+      mReqId(KUndefined),
+      mDuration(0),
+      mPosition(0),
+      mAlbumArt(),
+      mPlaybackState(Stopped)
+{
+    TX_ENTRY
+    mThumbnailManager = new ThumbnailManager(this);
+    mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
+    mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
+    connect( mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+             this, SLOT(thumbnailReady(QPixmap, void *, int, int)) );
+
+    //TODO: Change to final resource when available
+    mDefaultAlbumArt =  new HbIcon("qtg_large_music");
+    TX_EXIT
+}
+
+/*!
+ Constructs a new MpPlaybackData.
+ */
+MpPlaybackData::~MpPlaybackData()
+{
+    TX_ENTRY
+    delete mThumbnailManager;
+    TX_EXIT
+}
+
+/*!
+ Sets the song \a duration.
+*/
+void MpPlaybackData::setDuration( int duration )
+{
+    TX_ENTRY_ARGS( "duration = " << duration )
+    mDuration = duration;
+    emit durationChanged();
+    TX_EXIT
+}
+
+/*!
+ Returns the song duration.
+*/
+int MpPlaybackData::duration() const
+{
+    TX_LOG_ARGS( "mDuration = " << mDuration )
+    return mDuration;
+}
+
+/*!
+ Sets the song \a position.
+*/
+void MpPlaybackData::setPosition( int position )
+{
+    TX_ENTRY_ARGS( "position = " << position )
+    mPosition = position;
+    emit positionChanged();
+    TX_EXIT
+}
+
+/*!
+ Returns the song position.
+*/
+int MpPlaybackData::position() const
+{
+    TX_ENTRY_ARGS( "mPosition = " << mPosition )
+    return mPosition;
+}
+
+/*!
+ Sets the song \a title, returns true if the value is new.
+*/
+bool MpPlaybackData::setTitle( const QString& title )
+{
+    TX_ENTRY_ARGS( "title = " << title )
+    bool change = false;
+    if ( title != mTitle ) {
+        change = true;
+        mTitle = title;
+    }
+    TX_EXIT
+    return change;
+}
+
+/*!
+ Returns the song title.
+*/
+const QString& MpPlaybackData::title() const
+{
+    TX_ENTRY_ARGS( "mTitle = " << mTitle )
+    return mTitle;
+}
+
+/*!
+ Sets the song \a artist, returns true if the value is new.
+*/
+bool MpPlaybackData::setArtist( const QString& artist )
+{
+    TX_ENTRY_ARGS( "artist = " << artist )
+    bool change = false;
+    if ( artist != mArtist ) {
+        change = true;
+        mArtist = artist;
+    }
+    TX_EXIT
+    return change;
+}
+
+/*!
+ Returns the song artist.
+*/
+const QString& MpPlaybackData::artist() const
+{
+    TX_ENTRY_ARGS( "mArtist = " << mArtist )
+    return mArtist;
+}
+
+/*!
+ Sets the song \a album, returns true if the value is new.
+*/
+bool MpPlaybackData::setAlbum( const QString& album )
+{
+    TX_ENTRY_ARGS( "album = " << album )
+    bool change = false;
+    if ( album != mAlbum ) {
+        change = true;
+        mAlbum = album;
+    }
+    TX_EXIT
+    return change;
+}
+
+/*!
+ Returns the song album.
+*/
+const QString& MpPlaybackData::album() const
+{
+    TX_ENTRY_ARGS( "mAlbum = " << mAlbum )
+    return mAlbum;
+}
+
+/*!
+ Sets the song \a uri, returns true if the value is new.
+*/
+bool MpPlaybackData::setUri( const QString& uri )
+{
+    TX_ENTRY_ARGS( "uri = " << uri )
+    bool change = false;
+    if ( uri != mUri ) {
+        change = true;
+        mUri = uri;
+    }
+    TX_EXIT
+    return change;
+}
+
+/*!
+ Returns the song uri.
+*/
+const QString& MpPlaybackData::uri() const
+{
+    TX_ENTRY_ARGS( "mUri = " << mUri )
+    return mUri;
+}
+
+/*!
+ Sets the song \a albumArtUri.
+*/
+void MpPlaybackData::setAlbumArtUri( const QString& albumArtUri )
+{
+    TX_ENTRY_ARGS( "albumArtUri = " << albumArtUri )
+    if ( !albumArtUri.isEmpty() ) {
+        bool ok = true;
+        if ( mReqId != KUndefined ) {
+            // There is already an outstanding request. Cancel it first.
+            bool ok = mThumbnailManager->cancelRequest(mReqId);
+        }
+        if ( ok ) {
+            mReqId = mThumbnailManager->getThumbnail( albumArtUri );
+            if ( mReqId == KUndefined ) {
+                // Request failed. Set default album art.
+                mAlbumArt = mDefaultAlbumArt;
+                emit albumArtReady();
+            }
+        }
+    }
+    else {
+        // No album art uri. Set default album art.
+        mAlbumArt = mDefaultAlbumArt;
+        emit albumArtReady();
+    }
+    TX_EXIT
+}
+
+/*!
+ Returns the song album art on \a icon.
+*/
+void MpPlaybackData::albumArt( HbIcon& icon ) const
+{
+    TX_ENTRY
+    if ( mAlbumArt->isNull() ) {
+        icon = HbIcon();
+     }
+     else {
+        icon = *mAlbumArt ;
+     }
+    TX_EXIT
+}
+
+/*!
+ Sets the playback \a state.
+*/
+void MpPlaybackData::setPlaybackState( const SimplifiedState state )
+{
+    TX_ENTRY_ARGS( "state = " << state )
+    if ( state != mPlaybackState ) {
+        mPlaybackState = state;
+        emit playbackStateChanged();
+    }
+    TX_EXIT
+}
+
+/*!
+ Returns the playback state.
+*/
+MpPlaybackData::SimplifiedState MpPlaybackData::playbackState() const
+{
+    TX_LOG_ARGS( "mPlaybackState = " << mPlaybackState )
+    return mPlaybackState;
+}
+
+/*!
+
+*/
+void MpPlaybackData::commitPlaybackInfo()
+{
+    TX_ENTRY
+    emit playbackInfoChanged();
+    TX_EXIT
+}
+
+/*!
+ Slot to handle the album art thumb.
+*/
+void MpPlaybackData::thumbnailReady(
+    const QPixmap& pixmap, void *data, int id, int error )
+{
+    TX_LOG_ARGS( "error = " << error << ", id = " << id )
+    Q_UNUSED(data);
+    if ( error == 0 && mReqId == id ) {
+        QIcon qicon;
+        QPixmap mCompositePixmap;
+        mReqId = KUndefined;
+        
+        mCompositePixmap = QPixmap( 360, 360 );
+        mCompositePixmap.fill( Qt::transparent );
+        QPainter painter(&mCompositePixmap);
+        painter.setCompositionMode(QPainter::CompositionMode_Clear);
+        painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+        painter.fillRect(mCompositePixmap.rect(), Qt::transparent);
+        painter.drawPixmap(QRect(0, 0,360,360), pixmap);
+        
+        if ( !mCompositePixmap.isNull() ) {
+            qicon = QIcon( mCompositePixmap );
+        }
+        else {
+            qicon = QIcon( pixmap );
+        }
+        
+        
+        mAlbumArt = new HbIcon(qicon);
+        
+        emit albumArtReady();
+    }
+    else {
+        mReqId = KUndefined;
+        mAlbumArt = mDefaultAlbumArt;
+        emit albumArtReady();
+    }
+    TX_EXIT
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/inc/unittest_mpcollectionalbumartmanager.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpcollectionalbumartmanager
+*
+*/
+
+#ifndef TESTMPCOLLECTIONALBUMARTMANAGER_H
+#define TESTMPCOLLECTIONALBUMARTMANAGER_H
+
+#include <QtTest/QtTest>
+#include <QIcon>
+
+class MpCollectionAlbumArtManager;
+class MpMpxCollectionData;
+
+class TestMpCollectionAlbumArtManager : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    TestMpCollectionAlbumArtManager();
+    virtual ~TestMpCollectionAlbumArtManager();
+
+signals:
+
+    void thumbnailReady( QPixmap pixmap, void *data, int id, int error );
+
+public slots:
+
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+
+    void testMemberCleanup();
+    void testAlbumArtNoCache();
+    void testAlbumArtNoCacheQueue();
+    void testAlbumArtCache();
+    void testAlbumArtNoUri();
+    void testAlbumArtFail();
+    void testCacheFirstScreenEmpty();
+    void testCacheFirstScreen();
+    void testCacheFirstScreenAllCached();
+    void testCancel();
+    void testThumbnailReadyCache();
+    void testThumbnailReadyCacheError();
+    void testThumbnailReadyAlbumArt();
+    void testThumbnailReadyAlbumArtError();
+
+private:
+
+    MpCollectionAlbumArtManager *mTest;
+    MpMpxCollectionData         *mStubData;
+    QIcon                       mIcon;
+
+};
+
+#endif  // TESTMPCOLLECTIONALBUMARTMANAGER_H
+
+
+
+
Binary file mpdata/tsrc/unittest_mpcollectionalbumartmanager/resources/default_album.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/resources/unittest_mpcollectionalbumartmanagerresources.qrc	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/testicons" >      
+        <file alias="default_album.png">default_album.png</file>    
+    </qresource>    
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/src/unittest_mpcollectionalbumartmanager.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,390 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpnowplayingbackend
+*
+*/
+
+#include <QSignalSpy>
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbicon.h>
+
+#include "unittest_mpcollectionalbumartmanager.h"
+#include "stub/inc/thumbnailmanager_qt.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpcollectionalbumartmanager.h"
+#undef private
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMpCollectionAlbumArtManager tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpcollectionalbumartmanager.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpCollectionAlbumArtManager::TestMpCollectionAlbumArtManager()
+    : mTest(0),
+      mStubData(0)
+{
+}
+
+TestMpCollectionAlbumArtManager::~TestMpCollectionAlbumArtManager()
+{
+    delete mTest;
+    delete mStubData;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpCollectionAlbumArtManager::initTestCase()
+{
+    mStubData = new MpMpxCollectionData();
+
+    // Create an icon (any icon will do) to help with testing.
+    mIcon = QIcon(":/testicons/default_album.png");
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpCollectionAlbumArtManager::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpCollectionAlbumArtManager::init()
+{
+    mTest = new MpCollectionAlbumArtManager(mStubData);
+    mStubData->mCount = 100;
+    mStubData->mItemDataReturn = true;
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpCollectionAlbumArtManager::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests correct cleanup of member variables.
+ */
+void TestMpCollectionAlbumArtManager::testMemberCleanup()
+{
+    cleanup();
+    ThumbnailManager::resetInitCounter();
+    init();
+    cleanup();
+    QCOMPARE(ThumbnailManager::getInitCounter(), 0);
+}
+
+/*!
+ Tests albumArt() request when album art is not in local cache.
+ Single request.
+ */
+void TestMpCollectionAlbumArtManager::testAlbumArtNoCache()
+{
+    const QIcon* icon = mTest->albumArt(1);
+    // Verify that:
+    // - It returned default icon
+    // - A request has been made to thumbnail manager
+    QVERIFY(icon->isNull() == false);
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
+}
+
+/*!
+ Tests albumArt() request when art is not in local cache.
+ Request more than 1 to test request queue.
+ */
+void TestMpCollectionAlbumArtManager::testAlbumArtNoCacheQueue()
+{
+    for ( int i = 0; i < 3; i++) {
+        const QIcon* icon = mTest->albumArt(i);
+        QVERIFY(icon->isNull() == false);
+    }
+    // Verify that:
+    // - Max number of requests were sent to thumbnail manager
+    // - A request has been queued
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
+}
+
+/*!
+ Tests albumArt() request when art is in local cache.
+ */
+void TestMpCollectionAlbumArtManager::testAlbumArtCache()
+{
+    mTest->mImageCache.insert(0, new QIcon(mIcon));
+
+    const QIcon* icon = mTest->albumArt(0);
+    // Verify that:
+    // - A valid icon has been returned
+    // - No request has been sent to thumbnail manager
+    QVERIFY(icon->isNull() == false);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
+}
+
+/*!
+ Tests albumArt() request when item doesn't have AlbumArtUri.
+ */
+void TestMpCollectionAlbumArtManager::testAlbumArtNoUri()
+{
+    mTest->mCollectionData->mItemDataReturn = false;
+    const QIcon* icon = mTest->albumArt(0);
+    // Verify that:
+    // - It returned default icon
+    // - There is no request pending from thumbnail manager
+    QVERIFY(icon->isNull() == false);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+}
+
+/*!
+ Tests albumArt() request when thumbnail request fails.
+ */
+void TestMpCollectionAlbumArtManager::testAlbumArtFail()
+{
+    mTest->mThumbnailManager->mGetThumbFails = true;
+    const QIcon* icon = mTest->albumArt(0);
+    // Verify that:
+    // - It returned default icon
+    // - There is no request pending from thumbnail manager
+    QVERIFY(icon->isNull() == false);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+}
+
+/*!
+ Tests cacheFirstScreen() request with empty list.
+ */
+void TestMpCollectionAlbumArtManager::testCacheFirstScreenEmpty()
+{
+    mTest->mCollectionData->mCount = 0;
+    mTest->cacheFirstScreen();
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mCachingInProgress, false);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
+}
+
+/*!
+ Tests cacheFirstScreen() request with 1 item in the list.
+ */
+void TestMpCollectionAlbumArtManager::testCacheFirstScreen()
+{
+    mTest->mCollectionData->mCount = 1;
+    mTest->cacheFirstScreen();
+    QCOMPARE(mTest->mCachingInProgress, true);
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
+}
+
+/*!
+ Tests cacheFirstScreen() request with all items already in local cache.
+ */
+void TestMpCollectionAlbumArtManager::testCacheFirstScreenAllCached()
+{
+    mTest->mCollectionData->mCount = 3;
+    mTest->mImageCache.insert(0, new QIcon(mIcon));
+    mTest->mImageCache.insert(1, new QIcon(mIcon));
+    mTest->mImageCache.insert(2, new QIcon(mIcon));
+    mTest->cacheFirstScreen();
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
+}
+
+/*!
+ Tests cancel() request.
+ */
+void TestMpCollectionAlbumArtManager::testCancel()
+{
+    // First send enough requests to trigger requests to be queued.
+    for ( int i = 0; i < 3; i++) {
+        const QIcon* icon = mTest->albumArt(i);
+        QVERIFY(icon->isNull() == false);
+    }
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
+
+    // Verify that:
+    // - All requests to thumbnail manager are cancelled
+    // - Queue is emptied
+    mTest->cancel();
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mThumbnailManager->mCancelCounter, 1);
+}
+
+/*!
+ Tests thumbnailReady() slot.
+ Tests completion of cacheFirstScreen() request.
+ */
+void TestMpCollectionAlbumArtManager::testThumbnailReadyCache()
+{
+    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
+
+    // First send cacheAlbumArt() request with 3 items.
+    mTest->mCollectionData->mCount = 3;
+    mTest->cacheFirstScreen();
+    QCOMPARE(mTest->mCachingInProgress, true);
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+
+    // Emit thumbnailReady() signal for each request. Then verify that:
+    // - Test object emitted signal albumArtReady() for 3 items
+    // - 3 items are present in local cache
+    for ( int i = 0; i < 3; i++ ) {
+        void *clientData = reinterpret_cast<void *>(i);
+        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, 0);
+    }
+
+    QCOMPARE(spy.count(), 3);
+    QCOMPARE(mTest->mCachingInProgress, false);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mImageCache.count(), 3);
+    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+}
+
+/*!
+ Tests thumbnailReady() slot.
+ Tests completion of cacheFirstScreen() request with error code returned.
+ */
+void TestMpCollectionAlbumArtManager::testThumbnailReadyCacheError()
+{
+    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
+
+    // First send cacheAlbumArt() request with 3 items.
+    mTest->mCollectionData->mCount = 3;
+    mTest->cacheFirstScreen();
+    QCOMPARE(mTest->mCachingInProgress, true);
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+
+    // Emit thumbnailReady() signal for each request with error. Then verify that:
+    // - Test object doesn't emit signal albumArtReady()
+    // - 0 item is present in local cache
+    for ( int i = 0; i < 3; i++ ) {
+        void *clientData = reinterpret_cast<void *>(i);
+        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, -1);
+    }
+    QCOMPARE(spy.count(), 0);
+    QCOMPARE(mTest->mCachingInProgress, false);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mImageCache.count(), 0);
+    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+}
+
+/*!
+ Tests thumbnailReady() slot.
+ Tests completion of albumArt() request with empty request queue.
+ */
+void TestMpCollectionAlbumArtManager::testThumbnailReadyAlbumArt()
+{
+    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
+
+    // First send 3 albumArt() requests.
+    for ( int i = 0; i < 3; i++) {
+        const QIcon* icon = mTest->albumArt(i);
+        QVERIFY(icon->isNull() == false);
+    }
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+
+    // Emit thumbnailReady() signal for each request. Then verify that:
+    // - Test object emitted signal albumArtReady() 3 times
+    // - 3 items are present in local cache
+    for ( int i = 0; i < 3; i++ ) {
+        void *clientData = reinterpret_cast<void *>(i);
+        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, 0);
+    }
+    QCOMPARE(spy.count(), 3);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mImageCache.count(), 3);
+    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+}
+
+/*!
+ Tests thumbnailReady() slot.
+ Tests completion of albumArt() request with error code returned.
+ This covers a case with no pending items in the queue.
+ */
+void TestMpCollectionAlbumArtManager::testThumbnailReadyAlbumArtError()
+{
+    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
+
+    // First send 3 albumArt() requests.
+    for ( int i = 0; i < 3; i++) {
+        const QIcon* icon = mTest->albumArt(i);
+        QVERIFY(icon->isNull() == false);
+    }
+    QCOMPARE(mTest->mPendingRequest, true);
+    QCOMPARE(mTest->mRequestQueue.count(), 2);
+
+    // Emit thumbnailReady() signal for each request with error. Then verify that:
+    // - Test object doesn't emitted signal albumArtReady()
+    // - 0 items are present in local cache
+    for ( int i = 0; i < 3; i++ ) {
+        void *clientData = reinterpret_cast<void *>(i);
+        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, -1);
+    }
+    QCOMPARE(spy.count(), 0);
+    QCOMPARE(mTest->mPendingRequest, false);
+    QCOMPARE(mTest->mRequestQueue.count(), 0);
+    QCOMPARE(mTest->mImageCache.count(), 0);
+    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
+        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
+}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/mpmpxcollectiondata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
+*
+*/
+
+#ifndef MPMPXCOLLECTIONDATA_H
+#define MPMPXCOLLECTIONDATA_H
+
+#include <QObject>
+
+#include "mpmpxcollectionviewdefs.h"
+
+
+class MpMpxCollectionData : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    enum DataType {
+        Title,
+        Artist,
+        Count,
+        AlbumArtUri
+    };
+
+    // Stub functions
+    explicit MpMpxCollectionData( QObject *parent=0 );
+    virtual ~MpMpxCollectionData();
+
+    TCollectionContext context() const;
+    int count() const;
+    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
+
+signals:
+
+    void contextChanged( TCollectionContext context );
+
+public:
+
+    TCollectionContext      mContext;
+    int                     mCount;
+    bool                    mItemDataReturn;
+
+};
+
+#endif // MPMPXCOLLECTIONDATA_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/thumbnailmanager_qt.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ThumbnailManager stub for testing MpCollectionAlbumArtManager
+*
+*/
+
+#ifndef THUMBNAILMANAGER_QT_H
+#define THUMBNAILMANAGER_QT_H
+
+#include <qobject>
+#include <QPixmap.h>
+
+
+/** default priority value */
+const int tnmWrapperPriorityIdle = -100;
+
+class ThumbnailManager : public QObject
+    {
+    Q_OBJECT
+
+public:
+
+
+    /** Thumbnail size. */
+    enum ThumbnailSize
+    {
+        /**
+         * Small thumbnail
+         */
+        ThumbnailSmall = 0,
+        /**
+         * Medium thumbnail
+         */
+        ThumbnailMedium,
+        /**
+         * Large thumbnail
+         */
+        ThumbnailLarge
+    };
+
+    /** Mode of thumbnail creation. */
+    enum ThumbnailMode
+        {
+        /**
+         * Default mode. This means that:
+         * - Thumbnail must be as large as requested (unless the actual object is smaller).
+         * - Smaller thumbnails may be up scaled to desired resolution.
+         * - Aspect ratio is maintained and thumbnails are not cropped. The
+         *   resulting thumbnail may smaller in either width or height if
+         *   the aspect ratio of the object does not match the aspect ratio
+         *   of the requested size.
+         */
+        Default = 0,
+
+        /**
+         * Allow thumbnails which are smaller than requested are. Thumbnail
+         * bitmaps are never up scaled if this flag is set.
+         */
+        AllowAnySize = 1,
+
+        /**
+         * New thumbnail images are not created if this flag is set. Only
+         * existing thumbnails may be returned. If a requested thumbnail does
+         * not exist null pixmap will be returned.
+         */
+        DoNotCreate = 2,
+
+        /**
+         * Thumbnail images are cropped to match requested aspect ratio. If
+         * this mode is set, the size of the resulting thumbnail always
+         * matches the requested size.
+         */
+        CropToAspectRatio = 4
+    };
+
+    /**  Quality versus speed preference setting */
+    enum QualityPreference
+    {
+        /**
+         * Prefer thumbnails in the highest quality possible disregarding
+         * any negative impact on performance.
+         */
+        OptimizeForQuality,
+
+        /**
+         * Get thumbnails as fast as possible, even if
+         * it means lower quality.
+         */
+        OptimizeForPerformance
+    };
+
+    // Test utility functions
+    static int getInitCounter();
+    static void resetInitCounter();
+
+    // Stub functions
+    ThumbnailManager( QObject* parentPtr = NULL );
+    virtual ~ThumbnailManager();
+    bool setMode( ThumbnailMode mode );
+    bool setQualityPreference( QualityPreference qualityPreference );
+    bool setThumbnailSize( ThumbnailSize thumbnailSize );
+    int getThumbnail( const QString& fileName, void * clientData = NULL,
+            int priority = tnmWrapperPriorityIdle );
+    bool cancelRequest( int id );
+
+signals:
+
+    void thumbnailReady( QPixmap , void * , int , int );
+
+public:
+
+    bool    mGetThumbFails;
+    int     mThumbnailReqCounter;
+    int     mCancelCounter;
+
+};
+
+#endif // THUMBNAILMANAGER_QT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/src/mpmpxcollectiondata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
+*
+*/
+
+#include "mptrace.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+
+/*!
+ Stub function.
+ */
+MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
+    : QObject(parent),
+      mContext(ECollectionContextUnknown),
+      mCount(0),
+      mItemDataReturn(true)
+{
+}
+
+/*!
+ Stub function.
+ */
+MpMpxCollectionData::~MpMpxCollectionData()
+{
+}
+
+/*!
+ Stub function.
+ */
+TCollectionContext MpMpxCollectionData::context() const
+{
+    return mContext;
+}
+
+/*!
+ Stub function.
+ */
+int MpMpxCollectionData::count() const
+{
+    return mCount;
+}
+
+/*!
+ Stub function.
+ */
+QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
+{
+    if ( index < 0 || index > mCount ) {
+        TX_LOG_ARGS("index=" << index);
+        qFatal("MpMpxCollectionData::itemData called with index out of range");
+    }
+    QString data;
+    if ( !mItemDataReturn && (type != MpMpxCollectionData::Count) ) {
+        return data;
+    }
+    switch ( type ) {
+        case MpMpxCollectionData::Title:
+            data = QString("Title");
+            break;
+        case MpMpxCollectionData::Artist:
+            data = QString("Artist");
+            break;
+        case MpMpxCollectionData::Count:
+            data = QString("Count");
+            break;
+        case MpMpxCollectionData::AlbumArtUri:
+            data = QString("AlbumArtUri");
+            break;
+        default:
+            qFatal("MpMpxCollectionData::itemData called with unknown type");
+            break;
+    }
+    return data;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/stub/src/thumbnailmanager_qt.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ThumbnailManager stub for testing MpCollectionAlbumArtManager
+*
+*/
+
+#include <qsize.h>
+#include "stub/inc/thumbnailmanager_qt.h"
+
+int gInitCounter = 0;
+
+/*!
+ Returns gInitCounter.
+ gInitCounter counts the number of constructor/destructor calls.
+ */
+int ThumbnailManager::getInitCounter()
+{
+    return gInitCounter;
+}
+
+/*!
+ Resets gInitCounter to zero.
+ */
+void ThumbnailManager::resetInitCounter()
+{
+    gInitCounter = 0;
+}
+
+/*!
+ Stub function.
+ */
+ThumbnailManager::ThumbnailManager( QObject* parentPtr ) :
+QObject( parentPtr ),
+mGetThumbFails(false),
+mThumbnailReqCounter(0),
+mCancelCounter(0)
+{
+    gInitCounter++;
+}
+
+/*!
+ Stub function.
+ */
+ThumbnailManager::~ThumbnailManager()
+{
+    gInitCounter--;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setMode( ThumbnailMode mode )
+{
+    Q_UNUSED(mode);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setQualityPreference( QualityPreference
+    qualityPreference )
+{
+    Q_UNUSED(qualityPreference);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setThumbnailSize( ThumbnailSize thumbnailSize )
+{
+    Q_UNUSED(thumbnailSize);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+int ThumbnailManager::getThumbnail( const QString& fileName, void *clientData,
+        int priority )
+{
+    Q_UNUSED(fileName);
+    Q_UNUSED(priority);
+    Q_UNUSED(clientData);
+
+    if ( mGetThumbFails ) {
+        return -1;
+    }
+
+    mThumbnailReqCounter++;
+    return mThumbnailReqCounter;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::cancelRequest( int id )
+{
+    Q_UNUSED(id);
+    mCancelCounter++;
+    return true;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Unit test for mpcollectionalbumartmanager
+#
+
+
+TEMPLATE = app
+CONFIG += qtestlib hb
+TARGET = 
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    stub/inc \
+    ../../inc \
+    ../../../inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lestor.dll \
+        -lfbscli.dll
+
+HEADERS += inc/unittest_mpcollectionalbumartmanager.h \
+           stub/inc/thumbnailmanager_qt.h \
+           stub/inc/mpmpxcollectiondata.h \
+           ../../inc/mpcollectionalbumartmanager.h \
+               
+SOURCES += src/unittest_mpcollectionalbumartmanager.cpp \
+           stub/src/thumbnailmanager_qt.cpp \
+           stub/src/mpmpxcollectiondata.cpp \
+           ../../src/mpcollectionalbumartmanager.cpp
+
+RESOURCES += resources/unittest_mpcollectionalbumartmanagerresources.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager_template.pkg	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,32 @@
+; unittest_mpcollectionalbumartmanager_template.pkg generated by qmake at 2010-04-05T18:18:57
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"unittest_mpcollectionalbumartmanager"},(0xE48c0263),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+ 
+; Default dependency to Qt libraries
+(0x2001E61C), , , , {"Qt"}
+
+; Executable and default resource files
+"/epoc32/release/$(PLATFORM)/$(TARGET)/unittest_mpcollectionalbumartmanager.exe"    - "!:\sys\bin\unittest_mpcollectionalbumartmanager.exe"
+"/epoc32/data/z/resource/apps/unittest_mpcollectionalbumartmanager.rsc"    - "!:\resource\apps\unittest_mpcollectionalbumartmanager.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/unittest_mpcollectionalbumartmanager_reg.rsc"    - "!:\private\10003a3f\import\apps\unittest_mpcollectionalbumartmanager_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/inc/unittest_helper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test helper for mpcollectiondatamodel
+*
+*/
+
+#ifndef TESTHELPER_H
+#define TESTHELPER_H
+
+#include <QAbstractListModel>
+
+class TestHelper : public QAbstractListModel
+{
+    Q_OBJECT
+
+public:
+
+    TestHelper(QObject *parent=0);
+    virtual ~TestHelper();
+
+    // These are dummy; We have to inherit from QAbstractListModel so that
+    // we can invoke the protected member QAbstractItemModel::createIndex()
+    int rowCount(const QModelIndex &parent=QModelIndex()) const;
+    QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
+
+    QModelIndex indexFor(int index);
+};
+
+#endif  // TESTHELPER_H
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/inc/unittest_mpcollectiondatamodel.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpcollectiondatamodel
+*
+*/
+
+#ifndef TESTMPCOLLECTIONDATAMODEL_H
+#define TESTMPCOLLECTIONDATAMODEL_H
+
+#include <QtTest/QtTest>
+
+class QTranslator;
+class MpCollectionDataModel;
+class MpMpxCollectionData;
+class TestHelper;
+
+class TestMpCollectionDataModel : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    TestMpCollectionDataModel();
+    virtual ~TestMpCollectionDataModel();
+
+signals:
+
+    void updateAlbumArt( int index );
+    void albumCacheReady();
+
+public slots:
+
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+
+    void testMemberCleanup();
+    void testRefreshModel();
+    void testRefreshModelZeroCount();
+    void testCollectionData();
+    void testDataAllSongs();
+    void testDataAllSongsNoData();
+    void testDataArtists();
+    void testDataArtistsNoData();
+    void testDataArtistAlbums();
+    void testDataArtistAlbumsNoData();
+    void testDataArtistSongs();
+    void testDataArtistSongsNoData();
+    void testDataAlbums();
+    void testDataAlbumsNoData();
+    void testDataAlbumSongs();
+    void testDataAlbumSongsNoData();
+    void testDataPlaylists();
+    void testDataPlaylistsNoData();
+    void testDataPlaylistSongs();
+    void testDataPlaylistSongsNoData();
+    void testDataAnyOtherRole();
+    void testUpdateAlbumArt();
+    void testSupportedDropActions();
+    void testRemoveRows();
+    void testMimeTypes();
+    void testMimeData();
+    void testDropMimeData();
+
+private:
+
+    MpCollectionDataModel   *mTest;
+    TestHelper              *mHelper;
+    MpMpxCollectionData     *mStubData;
+    QTranslator             *mMpTranslator; // Own
+
+};
+
+#endif  // TESTMPCOLLECTIONDATAMODEL_H
+
+
+
+
Binary file mpdata/tsrc/unittest_mpcollectiondatamodel/resources/default_album.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/resources/unittest_mpcollectiondatamodelresources.qrc	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/testicons" >      
+        <file alias="default_album.png">default_album.png</file>    
+    </qresource>    
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/src/unittest_helper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test helper for TestHelper
+*
+*/
+
+#include "unittest_helper.h"
+
+
+TestHelper::TestHelper(QObject *parent)
+    : QAbstractListModel(parent)
+{
+}
+
+TestHelper::~TestHelper()
+{
+}
+
+/*!
+ Dummy function to satisfy QAbstractListModel inheritance.
+ */
+int TestHelper::rowCount( const QModelIndex &parent ) const
+{
+    Q_UNUSED(parent);
+    return 0;
+}
+
+/*!
+ Dummy function to satisfy QAbstractListModel inheritance.
+ */
+QVariant TestHelper::data(const QModelIndex &index, int role) const
+{
+    Q_UNUSED(index);
+    Q_UNUSED(role);
+    return QVariant();
+}
+
+/*!
+ Slot to be called when album art for the \a index needs to be updated.
+ */
+QModelIndex TestHelper::indexFor(int index)
+{
+    return QAbstractItemModel::createIndex(index, 0);
+}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/src/unittest_mpcollectiondatamodel.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,868 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpcollectiondatamodel
+*
+*/
+
+#include <QAbstractItemModel>
+#include <QSignalSpy>
+#include <QMetaType>
+#include <QTranslator>
+#include <QLocale>
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbicon.h>
+#include <hbnamespace.h>
+
+#include "unittest_mpcollectiondatamodel.h"
+#include "unittest_helper.h"
+#include "stub/inc/mpcollectionalbumartmanager.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpcollectiondatamodel.h"
+#undef private
+
+// Init cache size defined in mpcollectiondatamodel.cpp
+const int KInitCacheSize = 11;
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMpCollectionDataModel tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpcollectiondatamodel.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpCollectionDataModel::TestMpCollectionDataModel()
+    : mTest(0),
+      mHelper(0),
+      mStubData(0),
+      mMpTranslator(0)
+{
+}
+
+TestMpCollectionDataModel::~TestMpCollectionDataModel()
+{
+    delete mTest;
+    delete mHelper;
+    delete mStubData;
+    delete mMpTranslator;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpCollectionDataModel::initTestCase()
+{
+    QString lang = QLocale::system().name();
+    QString path = QString("z:/resource/qt/translations/");
+    bool translatorLoaded = false;
+
+    mMpTranslator = new QTranslator(this);
+    translatorLoaded = mMpTranslator->load(path + "musicplayer_" + lang);
+    if ( translatorLoaded ) {
+        qApp->installTranslator(mMpTranslator);
+    }
+
+    mStubData = new MpMpxCollectionData();
+    mHelper = new TestHelper();
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpCollectionDataModel::cleanupTestCase()
+{
+    delete mStubData;
+    mStubData = 0;
+    delete mHelper;
+    mHelper = 0;
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpCollectionDataModel::init()
+{
+    mTest = new MpCollectionDataModel(mStubData);
+    MpMpxCollectionData::resetItemDataCounter();
+    mTest->mCollectionData->mItemDataReturn = true;
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpCollectionDataModel::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests correct cleanup of member variables.
+ */
+void TestMpCollectionDataModel::testMemberCleanup()
+{
+    cleanup();
+    MpCollectionAlbumArtManager::resetInitCounter();
+    int count = MpMpxCollectionData::getInitCounter();
+    init();
+    cleanup();
+    QCOMPARE(MpCollectionAlbumArtManager::getInitCounter(), 0);
+    QCOMPARE(MpMpxCollectionData::getInitCounter(), count);
+}
+
+/*!
+ Tests refreshModel() request.
+ */
+void TestMpCollectionDataModel::testRefreshModel()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAlbums;
+    mTest->refreshModel();
+    // Verify that:
+    // - It sets correct row count
+    QCOMPARE(mTest->mRowCount, 100);
+    QCOMPARE(mTest->mAlbumArtManager->mCacheAlbumArtCount, 1);
+    // Stub QAbstractListModel to verify call to reset()
+    mTest->mCollectionData->mCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtistAlbums;
+    mTest->refreshModel();
+    // Verify that:
+    // - It sets correct row count
+    QCOMPARE(mTest->mRowCount, 100);
+    QCOMPARE(mTest->mAlbumArtManager->mCacheAlbumArtCount, 2);
+}
+
+/*!
+ Tests refreshModel() request with empty data model.
+ */
+void TestMpCollectionDataModel::testRefreshModelZeroCount()
+{
+    mTest->mCollectionData->mCount = 0;
+    mTest->refreshModel();
+    // Verify that:
+    // - It sets correct row count
+    QCOMPARE(mTest->mRowCount, 0);
+}
+
+/*!
+ Tests collectionData() request.
+ */
+void TestMpCollectionDataModel::testCollectionData()
+{
+    QVERIFY(mTest->collectionData() == mStubData);
+}
+
+/*!
+ Tests data() request for AllSongs context.
+ */
+void TestMpCollectionDataModel::testDataAllSongs()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAllSongs;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), QString("Title"));
+    QCOMPARE(dataList.at(1), QString("Artist"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+    
+    
+}
+
+/*!
+ Tests data() request for AllSongs context with no data available.
+ */
+void TestMpCollectionDataModel::testDataAllSongsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAllSongs;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for Artists context.
+ */
+void TestMpCollectionDataModel::testDataArtists()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtists;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), QString("Title"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for Artists context with no data available.
+ */
+void TestMpCollectionDataModel::testDataArtistsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtists;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for Artist Albums context.
+ */
+void TestMpCollectionDataModel::testDataArtistAlbums()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtistAlbums;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), QString("Title"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for Artist Albums context with no data available.
+ */
+void TestMpCollectionDataModel::testDataArtistAlbumsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtistAlbums;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for Artist Songs context.
+ */
+void TestMpCollectionDataModel::testDataArtistSongs()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtistSongs;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), QString("Title"));
+    QCOMPARE(dataList.at(1), QString("Album"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for Artists context with no data available.
+ */
+void TestMpCollectionDataModel::testDataArtistSongsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextArtistSongs;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+
+/*!
+ Tests data() request for Albums context.
+ */
+void TestMpCollectionDataModel::testDataAlbums()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAlbums;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), QString("Title"));
+    QCOMPARE(dataList.at(1), QString("Artist"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for Albums context with no data available.
+ */
+void TestMpCollectionDataModel::testDataAlbumsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAlbums;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
+        
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for AlbumSongs context.
+ */
+void TestMpCollectionDataModel::testDataAlbumSongs()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAlbumSongs;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), QString("Title"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for AlbumSongs context with no data available.
+ */
+void TestMpCollectionDataModel::testDataAlbumSongsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextAlbumSongs;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for Playlists context.
+ */
+void TestMpCollectionDataModel::testDataPlaylists()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextPlaylists;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), QString("Title"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for Playlists context with no data available.
+ */
+void TestMpCollectionDataModel::testDataPlaylistsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextPlaylists;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 1);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for PlaylistSongs context.
+ */
+void TestMpCollectionDataModel::testDataPlaylistSongs()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextPlaylistSongs;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), QString("Title"));
+    QCOMPARE(dataList.at(1), QString("Artist"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString("Title"));
+}
+
+/*!
+ Tests data() request for PlaylistSongs context with no data available.
+ */
+void TestMpCollectionDataModel::testDataPlaylistSongsNoData()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+    mTest->mCollectionData->mContext = ECollectionContextPlaylistSongs;
+    mTest->mCollectionData->mItemDataReturn = false;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
+    QCOMPARE(data.canConvert(QVariant::StringList), true);
+    QStringList dataList = data.toStringList();
+    QCOMPARE(dataList.count(), 2);
+    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
+    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
+
+    // Qt::DecorationRole
+    data = mTest->data(modelIndex, Qt::DecorationRole);
+    QCOMPARE(data.isNull(), true);
+    
+    // Hb::IndexFeedbackRole
+    data = mTest->data(modelIndex, Hb::IndexFeedbackRole);
+    QCOMPARE(data.toString(), QString(""));
+}
+
+/*!
+ Tests data() request for a role it doesn't support.
+ Make sure it doesn't crash.
+ */
+void TestMpCollectionDataModel::testDataAnyOtherRole()
+{
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+
+    QModelIndex modelIndex = mHelper->indexFor(1);
+
+    // Qt::DisplayRole
+    QVariant data = mTest->data(modelIndex, Qt::EditRole);
+    QCOMPARE(data.isValid(), false);
+}
+
+/*!
+ Tests updateAlbumArt() slot.
+ */
+void TestMpCollectionDataModel::testUpdateAlbumArt()
+{
+    connect( this, SIGNAL(updateAlbumArt(int)),
+        mTest->mAlbumArtManager, SIGNAL(albumArtReady(int)) );
+    qRegisterMetaType<QModelIndex>("QModelIndex");
+    QSignalSpy spy(mTest, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
+    mTest->mCollectionData->mCount = 100;
+    mTest->mRowCount = 100;
+
+    emit updateAlbumArt(15);
+    QCOMPARE(spy.count(), 1);
+
+    disconnect( this, SIGNAL(updateAlbumArt(int)),
+        mTest->mAlbumArtManager, SIGNAL(albumArtReady(int)) );
+}
+
+/*!
+ Tests supportedDropActions()
+ */
+void TestMpCollectionDataModel::testSupportedDropActions()
+{
+ QCOMPARE(mTest->supportedDropActions(), Qt::MoveAction);
+}
+
+/*!
+ Tests removeRows()
+ */
+void TestMpCollectionDataModel::testRemoveRows()
+{
+    QSignalSpy spy(mTest, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
+    QSignalSpy spy2(mTest, SIGNAL(rowsRemoved(QModelIndex, int, int)));
+    MpMpxCollectionData::resetItemDataCounter();
+    mTest->mCollectionData->mCount = 2;
+    mTest->mRowCount = 2;
+    
+    QVERIFY(!mTest->removeRows(0,0,QModelIndex())); //no rows to remove.
+    QVERIFY(!mTest->removeRows(0,2,QModelIndex())); //more than one row.
+    QVERIFY(!mTest->removeRows(2,1,QModelIndex())); //row out of bounds.
+    
+    //a valid row to be removed.
+    QVERIFY(mTest->removeRows(0,1,QModelIndex()));
+    QCOMPARE(spy.count(), 1);
+    QCOMPARE(spy2.count(), 1);
+    QCOMPARE(MpMpxCollectionData::getremoveItemCounter(), 1);
+    QCOMPARE(mTest->mRowCount, 1);
+    
+}
+
+/*!
+ Tests mimeTypes()
+ */
+void TestMpCollectionDataModel::testMimeTypes()
+{
+ QCOMPARE(mTest->mimeTypes().count(), 1);
+ QCOMPARE(mTest->mimeTypes().at(0), QLatin1String("application/x-mpcollectiondatamodelrowandids"));
+}
+
+/*!
+ Tests mimeTypes()
+ */
+void TestMpCollectionDataModel::testMimeData()
+{
+    QModelIndexList indexList;
+    indexList << mHelper->indexFor(2);
+    indexList << mHelper->indexFor(5);
+    QVERIFY(!mTest->mimeData(indexList)); //more than one item is not valid
+    indexList.removeLast();
+    QMimeData *data;
+    data = mTest->mimeData(indexList);
+    QVERIFY(data); //one item row 2
+    
+    QByteArray encoded = data->data(QLatin1String("application/x-mpcollectiondatamodelrowandids"));
+    QDataStream stream(&encoded, QIODevice::ReadOnly);
+    int rowFrom;
+    int mpxContainerId;
+    int mpxItemId;
+    stream >> rowFrom;
+    stream >> mpxContainerId;
+    stream >> mpxItemId;
+    QCOMPARE(rowFrom,2);
+    QCOMPARE(mpxContainerId,65535); //dummy value from the stub collection data stub
+    QCOMPARE(mpxItemId,2000+2); //id from collection data stub is index with offset of 2000.
+}
+
+/*!
+ Tests dropMimeData()
+ */
+void TestMpCollectionDataModel::testDropMimeData()
+{
+    int indexFrom = 5;
+    int containerId = 123;
+    int itemId = 20;
+    
+    QSignalSpy spy(mTest, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
+    QSignalSpy spy2(mTest, SIGNAL(rowsInserted(QModelIndex, int, int)));
+    QSignalSpy spy3(mTest, SIGNAL(orderChanged(int, int, int, int)));
+    MpMpxCollectionData::resetInsertCachedItemCounter();
+
+    {//no data
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 10;
+    QVERIFY(!mTest->dropMimeData(0,Qt::MoveAction,0,0,QModelIndex()));
+    }
+
+    {//drag row out of bounds
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << 15;
+    stream << containerId;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 10;
+
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,0,0,QModelIndex()));
+    delete data;
+    }    
+    
+    {//drop row out of bounds
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    stream << containerId;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 10;
+
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,15,0,QModelIndex()));
+    delete data;
+    }    
+    
+    {//incorrect action
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    stream << containerId;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 10;
+
+    QVERIFY(!mTest->dropMimeData(data,Qt::IgnoreAction,0,0,QModelIndex()));
+    delete data;
+    }    
+    
+    {//bad item ids
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 2;
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,0,0,QModelIndex()));
+    delete data;
+    }  
+    
+    {//bad item ids 2
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    stream << -1;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 2;
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,0,0,QModelIndex()));
+    delete data;
+    } 
+    
+    {//data with bad format
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    stream << containerId;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-blabla"), encoded);
+    MpMpxCollectionData::setCachedItemId(itemId);
+    mTest->mRowCount = 10;        
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,0,0,QModelIndex()));
+    delete data;
+    }    
+     
+    QMimeData *data = new QMimeData();
+    QByteArray encoded;
+    QDataStream stream(&encoded, QIODevice::WriteOnly);
+    stream << indexFrom;
+    stream << containerId;
+    stream << itemId;
+    data->setData(QLatin1String("application/x-mpcollectiondatamodelrowandids"), encoded);
+    MpMpxCollectionData::setCachedItemId(0);
+    mTest->mRowCount = 10;
+    
+    // not matching item id
+    QVERIFY(!mTest->dropMimeData(data,Qt::MoveAction,0,0,QModelIndex()));
+   
+    //matching item id
+    MpMpxCollectionData::setCachedItemId(itemId);
+
+    
+    QVERIFY(mTest->dropMimeData(data,Qt::MoveAction,5,0,QModelIndex()));
+    delete data;    
+    QCOMPARE(spy.count(), 1);
+    QCOMPARE(spy2.count(), 1);
+    QCOMPARE(spy3.count(), 1);
+    QList<QVariant> arguments = spy3.takeFirst();
+    QCOMPARE(arguments.at(0).toInt(), containerId);
+    QCOMPARE(arguments.at(1).toInt(), itemId);
+    QCOMPARE(arguments.at(2).toInt(), indexFrom);
+    QCOMPARE(arguments.at(3).toInt(), 5);
+    QCOMPARE(MpMpxCollectionData::getInsertCachedItemCounter(),1);
+}
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpcollectionalbumartmanager.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpCollectionAlbumArtManager stub for testing MpCollectionDataModel
+*
+*/
+
+
+#ifndef MPCOLLECTIONALBUMARTMANAGER_H
+#define MPCOLLECTIONALBUMARTMANAGER_H
+
+#include <QObject>
+#include <QIcon>
+
+class MpMpxCollectionData;
+
+class MpCollectionAlbumArtManager : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    // Test utility functions
+    static int getInitCounter();
+    static void resetInitCounter();
+
+    // Stub functions
+    explicit MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent=0 );
+    virtual ~MpCollectionAlbumArtManager();
+
+    const QIcon* albumArt( int index );
+    void cacheFirstScreen();
+    void cancel();
+
+signals:
+
+    void albumArtReady( int index );
+
+public:
+
+    QIcon       *mIcon;
+    int         mAlbumArtCount;
+    int         mCacheAlbumArtCount;
+
+};
+
+#endif // MPCOLLECTIONALBUMARTMANAGER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpmpxcollectiondata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
+*
+*/
+
+#ifndef MPMPXCOLLECTIONDATA_H
+#define MPMPXCOLLECTIONDATA_H
+
+#include <QObject>
+
+#include "mpmpxcollectionviewdefs.h"
+
+
+class MpMpxCollectionData : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    enum DataType {
+        Title,
+        Artist,
+        Album,
+        Count,
+        AlbumArtUri
+    };
+
+    // Test utility functions
+    static int getInitCounter();
+    static void resetInitCounter();
+    static int getItemDataCounter();
+    static void resetItemDataCounter();
+    static int getremoveItemCounter();
+    static void resetremoveItemCounter();
+    static void setCachedItemId (int id);
+    static int getInsertCachedItemCounter();
+    static void resetInsertCachedItemCounter();
+    
+    // Stub functions
+    explicit MpMpxCollectionData( QObject *parent=0 );
+    virtual ~MpMpxCollectionData();
+
+    TCollectionContext context() const;
+    int count() const;
+    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
+    int containerId();
+    int itemId(int index);
+    void removeItem(int index);
+    bool testCachedItem( int itemId );
+    void insertCachedItem(int index);
+
+signals:
+
+    void contextChanged( TCollectionContext context );
+
+public:
+
+    TCollectionContext      mContext;
+    int                     mCount;
+    bool                    mItemDataReturn;
+
+};
+
+#endif // MPMPXCOLLECTIONDATA_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/stub/src/mpcollectionalbumartmanager.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,88 @@
+
+
+
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player collection album art manager.
+*
+*/
+
+#include "stub/inc/mpcollectionalbumartmanager.h"
+
+int gAlbumInitCounter = 0;
+
+/*!
+ Returns gAlbumInitCounter.
+ gAlbumInitCounter counts the number of constructor/destructor calls.
+ */
+int MpCollectionAlbumArtManager::getInitCounter()
+{
+    return gAlbumInitCounter;
+}
+
+/*!
+ Resets gAlbumInitCounter to zero.
+ */
+void MpCollectionAlbumArtManager::resetInitCounter()
+{
+    gAlbumInitCounter = 0;
+}
+
+/*!
+ Stub function.
+ */
+MpCollectionAlbumArtManager::MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent )
+    : QObject(parent),
+      mIcon(0),
+      mAlbumArtCount(0),
+      mCacheAlbumArtCount(0)
+{
+    Q_UNUSED(data);
+    gAlbumInitCounter++;
+    mIcon = new QIcon(":/testicons/default_album.png");
+}
+
+/*!
+ Stub function.
+ */
+MpCollectionAlbumArtManager::~MpCollectionAlbumArtManager()
+{
+    gAlbumInitCounter--;
+    delete mIcon;
+}
+
+/*!
+ Stub function.
+ */
+const QIcon* MpCollectionAlbumArtManager::albumArt( int index )
+{
+    Q_UNUSED(index);
+    mAlbumArtCount++;
+    return mIcon;
+}
+
+/*!
+ Stub function.
+ */
+void MpCollectionAlbumArtManager::cacheFirstScreen()
+{
+    mCacheAlbumArtCount++;
+}
+
+/*!
+ Stub function.
+ */
+void MpCollectionAlbumArtManager::cancel()
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/stub/src/mpmpxcollectiondata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
+*
+*/
+
+#include "mptrace.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+
+
+int gInitCounter = 0;
+int gItemDataCount = 0;
+int gRemoveItemCount = 0;
+int gCachedItemId = 0;
+int gInsertCachedItemCount = 0;
+
+/*!
+ Returns gInitCounter.
+ gInitCounter counts the number of constructor/destructor calls.
+ */
+int MpMpxCollectionData::getInitCounter()
+{
+    return gInitCounter;
+}
+
+/*!
+ Resets gInitCounter to zero.
+ */
+void MpMpxCollectionData::resetInitCounter()
+{
+    gInitCounter = 0;
+}
+
+/*!
+ Returns gItemDataCount.
+ gItemDataCount counts the number of itemData() calls.
+ */
+int MpMpxCollectionData::getItemDataCounter()
+{
+    return gItemDataCount;
+}
+
+/*!
+ Resets gItemDataCount to zero.
+ */
+void MpMpxCollectionData::resetItemDataCounter()
+{
+    gItemDataCount = 0;
+}
+
+/*!
+ Returns gItemDataCount.
+ gRemoveItemCount counts the number of itemData() calls.
+ */
+int MpMpxCollectionData::getremoveItemCounter()
+{
+    return gRemoveItemCount;
+}
+
+/*!
+Resets gRemoveItemCount to zero.
+*/
+void MpMpxCollectionData::resetremoveItemCounter()
+{
+    gRemoveItemCount = 0;
+}
+
+/*!
+Sets gCachedItemId.
+*/
+void MpMpxCollectionData::setCachedItemId(int id)
+{
+    gCachedItemId = id;
+}
+
+/*!
+ Returns gInsertCachedItemCount.
+ */
+int MpMpxCollectionData::getInsertCachedItemCounter()
+{
+    return gInsertCachedItemCount;
+}
+
+/*!
+ Resets gInsertCachedItemCount to zero.
+ */
+void MpMpxCollectionData::resetInsertCachedItemCounter()
+{
+    gInsertCachedItemCount = 0;
+}
+
+/*!
+ Stub function.
+ */
+MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
+    : QObject(parent),
+      mContext(ECollectionContextUnknown),
+      mCount(0),
+      mItemDataReturn(true)
+{
+    gInitCounter++;
+}
+
+/*!
+ Stub function.
+ */
+MpMpxCollectionData::~MpMpxCollectionData()
+{
+    gInitCounter--;
+}
+
+/*!
+ Stub function.
+ */
+TCollectionContext MpMpxCollectionData::context() const
+{
+    return mContext;
+}
+
+/*!
+ Stub function.
+ */
+int MpMpxCollectionData::count() const
+{
+    return mCount;
+}
+
+/*!
+ Stub function.
+ */
+QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
+{
+    if ( index < 0 || index > mCount ) {
+        TX_LOG_ARGS("index=" << index);
+        qFatal("MpMpxCollectionData::itemData called with index out of range");
+    }
+    gItemDataCount++;
+    QString data;
+    if ( !mItemDataReturn && (type != MpMpxCollectionData::Count) ) {
+        return data;
+    }
+    switch ( type ) {
+        case MpMpxCollectionData::Title:
+            data = QString("Title");
+            break;
+        case MpMpxCollectionData::Artist:
+            data = QString("Artist");
+            break;
+        case MpMpxCollectionData::Album:
+            data = QString("Album");
+            break;
+        case MpMpxCollectionData::Count:
+            data = QString("Count");
+            break;
+        case MpMpxCollectionData::AlbumArtUri:
+            data = QString("AlbumArtUri");
+            break;
+        default:
+            qFatal("MpMpxCollectionData::itemData called with unknown type");
+            break;
+    }
+    return data;
+}
+
+/*!
+ Stub function.
+ */
+int MpMpxCollectionData::containerId()
+{
+    return 65535;
+}
+
+/*!
+ Stub function.
+ */
+int MpMpxCollectionData::itemId(int index)
+{
+    return 2000+index;
+}
+
+/*!
+ Stub function.
+ */
+void MpMpxCollectionData::removeItem(int index)
+{
+    Q_UNUSED(index);
+    gRemoveItemCount++;
+    return ;
+}
+
+/*!
+ Stub function.
+ */
+bool MpMpxCollectionData::testCachedItem( int itemId )
+{
+    return gCachedItemId == itemId;
+}
+
+/*!
+ Stub function.
+ */
+void MpMpxCollectionData::insertCachedItem(int index)
+{
+    Q_UNUSED(index);
+    gInsertCachedItemCount++;
+    return ;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Unit test for mpcollectiondatamodel
+#
+
+
+TEMPLATE = app
+CONFIG += qtestlib hb
+TARGET = 
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    stub/inc \
+    ../../inc \
+    ../../../inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lestor.dll \
+        -lfbscli.dll
+
+HEADERS += inc/unittest_mpcollectiondatamodel.h \
+           inc/unittest_helper.h \
+           stub/inc/mpcollectionalbumartmanager.h \
+           stub/inc/mpmpxcollectiondata.h \
+           ../../../inc/mpcollectiondatamodel.h \
+               
+SOURCES += src/unittest_mpcollectiondatamodel.cpp \
+           src/unittest_helper.cpp \
+           stub/src/mpcollectionalbumartmanager.cpp \
+           stub/src/mpmpxcollectiondata.cpp \
+           ../../src/mpcollectiondatamodel.cpp
+
+DEFINES += BUILD_MPDATA_LIB
+
+RESOURCES += resources/unittest_mpcollectiondatamodelresources.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel_template.pkg	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,32 @@
+; unittest_mpcollectiondatamodel_template.pkg generated by qmake at 2010-04-05T18:50:04
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"unittest_mpcollectiondatamodel"},(0xE05e4948),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+ 
+; Default dependency to Qt libraries
+(0x2001E61C), , , , {"Qt"}
+
+; Executable and default resource files
+"/epoc32/release/$(PLATFORM)/$(TARGET)/unittest_mpcollectiondatamodel.exe"    - "!:\sys\bin\unittest_mpcollectiondatamodel.exe"
+"/epoc32/data/z/resource/apps/unittest_mpcollectiondatamodel.rsc"    - "!:\resource\apps\unittest_mpcollectiondatamodel.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/unittest_mpcollectiondatamodel_reg.rsc"    - "!:\private\10003a3f\import\apps\unittest_mpcollectiondatamodel_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpmpxcollectiondata/inc/unittest_mpmpxcollectiondata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MpMpxCollectionData
+*
+*/
+
+#ifndef TESTMPMPXCOLLECTIONDATA_H
+#define TESTMPMPXCOLLECTIONDATA_H
+
+#include <QtTest/QtTest>
+
+class MpMpxCollectionData;
+class MpMpxCollectionDataPrivate;
+
+class TestMpMpxCollectionData : public QObject
+{
+    Q_OBJECT
+
+public:
+    TestMpMpxCollectionData();
+    virtual ~TestMpMpxCollectionData();
+
+
+public slots:
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+    void testConstructor();
+    void testContextRetrieval();
+    void testCount();
+    void testCollectionTitle();
+    void testItemData();
+    void testIsAutoPlaylist();
+    void testIsAutoPlaylistWithIndex();
+    void TestItemCountWithIndex();
+    void testSetCollectionContextL();
+    void testSetMpxMediaAllSongs();
+    void testContainerId();
+    void testItemId();
+    void testRemoveItem();
+    void testTestCachedItem();
+    void testInsertCachedItemItem();
+    
+private:
+    MpMpxCollectionData         *mTest;
+    MpMpxCollectionDataPrivate  *mTestPrivate;
+
+};
+
+#endif  // TESTMPMPXCOLLECTIONDATA_H
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpmpxcollectiondata/src/unittest_mpmpxcollectiondata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,711 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MpMpxCollectionData
+*
+*/
+
+#include <QSignalSpy>
+#include <QMetaType>
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+#include <apacmdln.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxcollectionpath.h>
+
+#include <mpxcollectionuihelper.h>
+#include <mpxcollectionhelperfactory.h>
+
+
+#include "unittest_mpmpxcollectiondata.h"
+#include "mpcommondefs.h"
+
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpmpxcollectiondata.h"
+#include "mpmpxcollectiondata_p.h"
+#undef private
+
+//This so we can test private functions
+#include "mpmpxcollectiondata_p.cpp"
+
+struct TTestAttrs
+    {
+    const wchar_t* GeneralTitle;
+    const wchar_t* MusicArtist;
+    const TInt GeneralCount;
+    const wchar_t* MusicAlbumArtFileName;
+    };
+    
+const TTestAttrs KAllSongsTestData[] =
+    {
+     { L"Title 1", L"Artist 1", 1, L"e:\\data\\images\\art1.jpg" }
+    ,{ L"Title 2", L"Artist 2", 1, L"e:\\data\\images\\art2.jpg" }
+    ,{ L"Title 3", L"Artist 3", 1, L"e:\\data\\images\\art3.jpg" }
+    ,{ L"Title 4", L"Artist 4", 1, L"e:\\data\\images\\art4.jpg" }
+    ,{ L"Title 5", L"Artist 5", 1, L"e:\\data\\images\\art5.jpg" }
+    ,{ L"Title 6", L"Artist 6", 1, L"e:\\data\\images\\art6.jpg" }
+    ,{ L"Title 7", L"Artist 7", 1, L"e:\\data\\images\\art7.jpg" }
+    ,{ L"Title 8", L"Artist 8", 1, L"e:\\data\\images\\art8.jpg" }
+    ,{ L"Title 9", L"Artist 9", 1, L"e:\\data\\images\\art9.jpg" }
+    ,{ L"Title 10", L"Artist 10", 1, L"e:\\data\\images\\art10.jpg" }
+    };
+    
+    
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMpMpxCollectionData tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpmpxcollectiondata.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpMpxCollectionData::TestMpMpxCollectionData()
+    : mTest(0)
+{
+}
+
+TestMpMpxCollectionData::~TestMpMpxCollectionData()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpMpxCollectionData::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpMpxCollectionData::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpMpxCollectionData::init()
+{
+    mTest = new MpMpxCollectionData();
+    mTestPrivate = mTest->d_ptr;
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpMpxCollectionData::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests constructor. Good case.
+ */
+void TestMpMpxCollectionData::testConstructor()
+{
+    QCOMPARE(mTestPrivate->iContext, ECollectionContextUnknown);
+}
+
+/*!
+ Tests getter for context.
+ */
+void TestMpMpxCollectionData::testContextRetrieval()
+{
+    QCOMPARE(mTest->context(), ECollectionContextUnknown);
+    mTestPrivate->iContext = ECollectionContextPlaylistSongs;
+    QCOMPARE(mTest->context(), ECollectionContextPlaylistSongs);
+}
+
+
+/*!
+ Tests count().
+ */
+void TestMpMpxCollectionData::testCount()
+{
+    mTestPrivate->iMediaArray = NULL;
+    QCOMPARE(mTest->count(), 0);
+    
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);   
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+        mTestPrivate->iMediaArray = array;
+        QCOMPARE(mTest->count(), i);
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
+        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
+        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+    }
+    mTestPrivate->iMediaArray = array;
+    QCOMPARE(mTest->count(), count);
+    CleanupStack::PopAndDestroy(array);
+}
+
+/*!
+ Tests collectionTitle().
+ */
+void TestMpMpxCollectionData::testCollectionTitle()
+{
+    mTestPrivate->iContainerMedia = NULL;
+    QCOMPARE(mTest->collectionTitle(), QString());   
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+        
+    mTestPrivate->iContainerMedia = entries;
+    QCOMPARE(mTest->collectionTitle(), QString());
+    
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
+
+    mTestPrivate->iContainerMedia = entries;
+    QCOMPARE(mTest->collectionTitle(), QString("All songs"));
+    mTestPrivate->iContainerMedia = NULL;
+    CleanupStack::PopAndDestroy(entries);
+}
+
+/*!
+ Tests itemData().
+ */
+void TestMpMpxCollectionData::testItemData()
+{
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);   
+    mTestPrivate->iMediaArray = array;
+        
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
+        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
+        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+        mTestPrivate->iMediaArray = array;
+
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
+        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::Title), QString::fromUtf16( title.Ptr(), title.Length()));
+
+        const TDesC& artist = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist));
+        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::Artist), QString::fromUtf16( artist.Ptr(), artist.Length()));
+
+        //verification depends on language, just exercising the item.
+        QVERIFY(!mTest->itemData( i, MpMpxCollectionData::Count).isNull());
+
+        const TDesC& albumArtUri = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName));
+        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::AlbumArtUri), QString::fromUtf16( albumArtUri.Ptr(), albumArtUri.Length()));
+
+    }
+    mTestPrivate->iMediaArray = array;
+
+    CMPXMedia* media = CMPXMedia::NewL();
+    CleanupStack::PushL(media);
+    array->AppendL(*media);
+    mTestPrivate->iMediaArray = array;
+    media->SetTextValueL(KMPXMediaGeneralTitle,KNullDesC );
+    media->SetTextValueL(KMPXMediaMusicArtist, KNullDesC);
+    media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 0);
+    media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, KNullDesC);
+    array->AppendL(*media);
+    CleanupStack::PopAndDestroy(media);
+    mTestPrivate->iMediaArray = array;
+    
+    //Media without attributes.
+    QVERIFY(mTest->itemData( count, MpMpxCollectionData::Title).isNull());
+    QVERIFY(mTest->itemData( count, MpMpxCollectionData::Artist).isNull());
+    //verification depends on language, just exercising the item.
+    QVERIFY(!mTest->itemData( count, MpMpxCollectionData::Count).isNull());
+    QVERIFY(mTest->itemData( count, MpMpxCollectionData::AlbumArtUri).isNull());
+    
+    //Media with empty attributes.
+    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::Title).isNull());
+    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::Artist).isNull());
+    //verification depends on language, just exercising the item.
+    QVERIFY(!mTest->itemData( count + 1, MpMpxCollectionData::Count).isNull());
+    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::AlbumArtUri).isNull());
+
+    /*Test Attributes that are not implemented yet.
+        Uri,
+        Duration,
+        Album,
+        Genre,
+        Rating,
+    */
+    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Uri).isNull());
+    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Duration).isNull());
+    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Album).isNull());
+    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Genre).isNull());
+    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Rating).isNull());
+
+    CleanupStack::PopAndDestroy(array);
+    mTestPrivate->iMediaArray = NULL;
+}
+
+/*!
+ Tests isAutoPlaylis().
+ */
+void TestMpMpxCollectionData::testIsAutoPlaylist()
+{
+    //if cotext is different than playlistsongs value returned should be false
+    QVERIFY(!mTest->isAutoPlaylist());
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("My Test Playlist Songs"));
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    CleanupStack::PopAndDestroy(array);
+    qRegisterMetaType<TCollectionContext>();
+    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
+    mTest->setMpxMedia(*entries);
+    QCOMPARE(spy.count(), 1);
+    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
+    QCOMPARE(context, ECollectionContextPlaylistSongs);
+    QVERIFY(!mTest->isAutoPlaylist());  
+    
+    entries->SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
+    mTest->setMpxMedia(*entries);
+    QCOMPARE(spy.count(), 2);
+    context = qvariant_cast<TCollectionContext>(spy.at(1).at(0));
+    QCOMPARE(context, ECollectionContextPlaylistSongs);
+    QVERIFY(mTest->isAutoPlaylist());  
+    CleanupStack::PopAndDestroy(entries);
+
+}
+
+/*!
+ Tests testIsAutoPlaylist(int)
+ */
+void TestMpMpxCollectionData::testIsAutoPlaylistWithIndex()
+{
+    //if cotext is different than playlists value returned should be false
+    QVERIFY(!mTest->isAutoPlaylist(0));
+    
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
+        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
+        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
+        if (i%2) {
+            media->SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
+        }
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+
+    }
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("My Test Playlist container"));
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    CleanupStack::PopAndDestroy(array);
+        
+    qRegisterMetaType<TCollectionContext>();
+    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
+    mTest->setMpxMedia(*entries);
+    QCOMPARE(spy.count(), 1);
+    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
+    QCOMPARE(context, ECollectionContextPlaylists);
+    QVERIFY(!mTest->isAutoPlaylist( 0 ));
+    QVERIFY(mTest->isAutoPlaylist( 1 ));
+}
+
+/*!
+ Tests itemCount(int).
+ */
+void TestMpMpxCollectionData::TestItemCountWithIndex()
+{
+
+
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    
+    CMPXMedia* media = CMPXMedia::NewL();
+    CleanupStack::PushL(media);
+    //no attributes
+    array->AppendL(*media);
+    CleanupStack::PopAndDestroy(media);
+
+    CMPXMedia* media2 = CMPXMedia::NewL();
+    CleanupStack::PushL(media2);
+    media2->SetTObjectValueL<TInt>(KMPXMediaGeneralCount,0);
+    array->AppendL(*media2);
+    CleanupStack::PopAndDestroy(media2);
+
+    CMPXMedia* media3 = CMPXMedia::NewL();
+    CleanupStack::PushL(media3);
+    media3->SetTObjectValueL<TInt>(KMPXMediaGeneralCount,20);
+    array->AppendL(*media3);
+    CleanupStack::PopAndDestroy(media3);
+    
+    
+    mTestPrivate->iMediaArray=array;
+    QCOMPARE(mTest->itemCount(0),0);
+    QCOMPARE(mTest->itemCount(1),0);
+    QCOMPARE(mTest->itemCount(2),20);
+
+    mTestPrivate->iMediaArray=NULL;
+    CleanupStack::PopAndDestroy(array);
+}
+
+/*!
+ Tests setCollectionContext().
+ */
+void TestMpMpxCollectionData::testSetCollectionContextL()
+{
+    
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+
+
+    
+    /* FROM MPXDBPLUGIN.CPP
+    // All Songs
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong ...
+    ...
+    // All artists  
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXArtist ...
+    ...            
+    // All albums of an artist
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXArtist ...
+    ...
+    // all songs for an artist
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXSong ...
+    ...        
+    // all songs of an album for an artist
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum ...
+    ...        
+    // All Albums
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum ...
+    ...
+    // All songs in one or multiple albums
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum ...
+    ...       
+    // All playlists
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPlaylist ...
+    ...
+    // All songs in a playlist
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist ...
+    ...     
+    // All genres
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXGenre ...
+    ...            
+    // All songs of a genre
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXGenre ...
+    ...                    
+    // All composers
+    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXComposer ...
+    ...
+    // All songs of a composer
+    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXComposer ...
+    */
+    
+    // All Songs
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextAllSongs);
+    
+    // All artists  
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
+    
+    // All albums of an artist
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
+    
+    // all songs for an artist
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
+    
+    // all songs of an album for an artist
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbumSongs);
+    
+    // All Albums
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbums);
+
+    // All songs in one or multiple albums
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbumSongs);
+    
+    // All playlists
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextPlaylists);
+    
+    // All songs in a playlist
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextPlaylistSongs);
+    
+    // All genres
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXGenre);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextGenres);//not in use and implementation could go away.
+    
+    // All songs of a genre
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXGenre);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextGenreSongs);///not in use and implementation could go away.
+    
+    // All composers
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXComposer);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
+    
+    // All songs of a composer
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXComposer);
+    mTestPrivate->iContainerMedia = entries;
+    mTestPrivate->SetCollectionContextL();
+    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
+    
+    
+    mTestPrivate->iContainerMedia = NULL;
+    CleanupStack::PopAndDestroy(entries);
+}
+
+/*!
+ Tests SetMpxMedia use case for all songs.
+ */
+void TestMpMpxCollectionData::testSetMpxMediaAllSongs()
+{
+
+
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
+        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
+        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+    }
+    
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
+   
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    CleanupStack::PopAndDestroy(array);
+ 
+    qRegisterMetaType<TCollectionContext>();
+    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
+    mTest->setMpxMedia(*entries);
+    QCOMPARE(spy.count(), 1);
+    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
+    QCOMPARE(context, ECollectionContextAllSongs);
+    CleanupStack::PopAndDestroy(entries);
+}
+
+/*!
+ Tests containerId().
+ */
+void TestMpMpxCollectionData::testContainerId()
+{
+    int containerId = 123;
+    CMPXMedia* container = CMPXMedia::NewL();
+    mTestPrivate->iContainerMedia = container;
+    QCOMPARE( mTest->containerId(), -1);
+
+    container->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, containerId );
+    QCOMPARE( mTest->containerId(), containerId);
+    delete container;
+    mTestPrivate->iContainerMedia = 0;
+    
+}
+
+/*!
+ Tests itemId().
+ */
+void TestMpMpxCollectionData::testItemId()
+{
+    int itemId = 321;
+    CMPXMedia* item = CMPXMedia::NewL();
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    array->AppendL(item);
+
+    mTestPrivate->iMediaArray = array;
+    QCOMPARE( mTest->itemId(0), -1);
+
+    item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
+    QCOMPARE( mTest->itemId(0), itemId);
+    
+    delete array;
+    mTestPrivate->iMediaArray = 0;
+    
+}
+
+/*!
+ Tests removeItem().
+ */
+void TestMpMpxCollectionData::testRemoveItem()
+{
+    int itemId = 567;
+    CMPXMedia* item = CMPXMedia::NewL();
+    item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    array->AppendL(item);
+    mTestPrivate->iMediaArray = array;
+    
+    mTest->removeItem(0);
+    QVERIFY( mTestPrivate->iCachedRemovedItem );
+    QCOMPARE( int(mTestPrivate->iCachedRemovedItem->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId )), itemId );
+    QCOMPARE( mTestPrivate->iMediaArray->Count(), 0 );
+    
+    delete array;
+    mTestPrivate->iMediaArray = 0;
+}
+
+/*!
+ Tests testCachedItem().
+ */
+void TestMpMpxCollectionData::testTestCachedItem()
+{
+    int itemId = 556;
+    CMPXMedia* item = CMPXMedia::NewL();
+    item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
+    mTestPrivate->iCachedRemovedItem = item;
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    mTestPrivate->iMediaArray = array;
+    
+    mTest->insertCachedItem(0);
+    QCOMPARE( mTestPrivate->iMediaArray->Count(), 1 );
+    QCOMPARE( int(mTestPrivate->iMediaArray->AtL( 0 )->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId )), itemId );
+    QVERIFY( !mTestPrivate->iCachedRemovedItem );
+    
+    delete array;
+    mTestPrivate->iMediaArray = 0;
+}
+
+/*!
+ Tests insertCachedItemItem().
+ */
+void TestMpMpxCollectionData::testInsertCachedItemItem()
+{
+    int itemId = 147;
+    CMPXMedia* item = CMPXMedia::NewL();
+    
+    mTestPrivate->iCachedRemovedItem = item;
+    QVERIFY( !mTest->testCachedItem( itemId ) );
+        
+    item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
+    QVERIFY( mTest->testCachedItem( itemId ) );
+        
+    delete mTestPrivate->iCachedRemovedItem;
+    mTestPrivate->iCachedRemovedItem = 0;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpmpxcollectiondata/unittest_mpmpxcollectiondata.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+
+TEMPLATE = app
+CONFIG += qtestlib hb
+TARGET = 
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../inc \
+    ../../../inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lestor.dll \
+        -lmpxcommon.dll
+
+HEADERS += inc/unittest_mpmpxcollectiondata.h \
+           ../../../inc/mpmpxcollectiondata.h
+           
+SOURCES += src/unittest_mpmpxcollectiondata.cpp \
+           ../../src/mpmpxcollectiondata.cpp
+
+DEFINES += BUILD_MPDATA_LIB
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/inc/unittest_mpplaybackdata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MpPlaybackData
+*
+*/
+
+#ifndef TESTMPMPPLAYBACKDATA_H
+#define TESTMPMPPLAYBACKDATA_H
+
+#include <QtTest/QtTest>
+
+class MpPlaybackData;
+
+class TestMpPlaybackData : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    TestMpPlaybackData();
+    virtual ~TestMpPlaybackData();
+
+signals:
+
+
+public slots:
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+    void testConstructor();
+    void testSetDuration();
+    void testSetPosition();
+    void testSetTitle();
+    void testSetArtist();
+    void testSetAlbum();
+    void testSetUri();
+    void testSetAlbumArtUri();
+    void testThumbnailReady();
+    void testSetPlaybackState();
+    void testCommitPlaybackInfo();
+    
+//    void testDeactivateView();
+//    void testGetView();
+private:
+
+    MpPlaybackData          *mTest;
+
+};
+
+#endif  // TESTMPMPPLAYBACKDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/src/unittest_mpplaybackdata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MpPlaybackData
+*
+*/
+
+#include <QSignalSpy>
+#include <qnamespace.h>
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbInstance.h>
+
+#include "unittest_mpplaybackdata.h"
+#include "stub/inc/thumbnailmanager_qt.h"
+
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpplaybackdata.h"
+#undef private
+
+const int KUndefined = -1;
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+    TestMpPlaybackData tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpplaybackdata.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpPlaybackData::TestMpPlaybackData()
+    : mTest(0)
+{
+}
+
+TestMpPlaybackData::~TestMpPlaybackData()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpPlaybackData::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpPlaybackData::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpPlaybackData::init()
+{
+    mTest = new MpPlaybackData();
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpPlaybackData::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ testConstructor
+ */
+void TestMpPlaybackData::testConstructor()
+{
+    QVERIFY(mTest->mThumbnailManager != 0);
+    QCOMPARE(mTest->mThumbnailManager->getInitCounter(), 1);
+    QVERIFY(mTest->mDuration == 0);
+    QVERIFY(mTest->mPosition == 0);
+    QVERIFY(!mTest->mDefaultAlbumArt);
+
+}
+
+/*!
+ test setDuration and duration
+ */
+void TestMpPlaybackData::testSetDuration()
+{
+    QSignalSpy spy(mTest, SIGNAL(durationChanged()));
+    for(int i= 0; i < 10; i++){
+        mTest->setDuration(i);
+        QCOMPARE(mTest->mDuration, i);
+        QCOMPARE(mTest->duration(),i);
+        QCOMPARE(spy.count(),i+1);
+    }
+}
+
+/*!
+ test setPosition and position
+ */
+void TestMpPlaybackData::testSetPosition()
+{
+    QSignalSpy spy(mTest, SIGNAL(positionChanged()));
+    for(int i= 0; i < 10; i++){
+        mTest->setPosition(i);
+        QCOMPARE(mTest->mPosition, i);
+        QCOMPARE(mTest->position(),i);
+        QCOMPARE(spy.count(),i+1);
+    }
+}
+
+/*!
+ test setTitle and title
+ */
+void TestMpPlaybackData::testSetTitle()
+{
+    bool changed;
+    
+    changed = mTest->setTitle(QString("Title 1"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mTitle, QString("Title 1"));
+    QCOMPARE(mTest->title(), QString("Title 1"));
+    changed = mTest->setTitle(QString("Title 1"));
+    QCOMPARE(changed, false);
+    QCOMPARE(mTest->title(), QString("Title 1"));
+    changed = mTest->setTitle(QString("Title 1"));
+    changed = mTest->setTitle(QString("Title 2"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mTitle, QString("Title 2"));
+    QCOMPARE(mTest->title(), QString("Title 2"));
+    
+}
+
+/*!
+ test setArtist and artist
+ */
+void TestMpPlaybackData::testSetArtist()
+{
+    bool changed;
+    
+    changed = mTest->setArtist(QString("Artist 1"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mArtist, QString("Artist 1"));
+    QCOMPARE(mTest->artist(), QString("Artist 1"));
+    changed = mTest->setArtist(QString("Artist 1"));
+    QCOMPARE(changed, false);
+    QCOMPARE(mTest->mArtist, QString("Artist 1"));
+    QCOMPARE(mTest->artist(), QString("Artist 1"));  
+    changed = mTest->setArtist(QString("Artist 2"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mArtist, QString("Artist 2"));
+    QCOMPARE(mTest->artist(), QString("Artist 2"));
+    
+}
+
+/*!
+ test setAlbum and album
+ */
+void TestMpPlaybackData::testSetAlbum()
+{
+    bool changed;
+    
+    changed = mTest->setAlbum(QString("Album 1"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mAlbum, QString("Album 1"));
+    QCOMPARE(mTest->album(), QString("Album 1"));
+    changed = mTest->setAlbum(QString("Album 1"));
+    QCOMPARE(changed, false);
+    QCOMPARE(mTest->mAlbum, QString("Album 1"));
+    QCOMPARE(mTest->album(), QString("Album 1"));
+    changed = mTest->setAlbum(QString("Album 2"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mAlbum, QString("Album 2"));
+    QCOMPARE(mTest->album(), QString("Album 2"));
+    
+}
+
+/*!
+ test setUri and uri
+ */
+void TestMpPlaybackData::testSetUri()
+{
+    bool changed;
+    
+    changed = mTest->setUri(QString("Uri 1"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mUri, QString("Uri 1"));
+    QCOMPARE(mTest->uri(), QString("Uri 1"));
+    changed = mTest->setUri(QString("Uri 1"));
+    QCOMPARE(changed, false);
+    QCOMPARE(mTest->mUri, QString("Uri 1"));
+    QCOMPARE(mTest->uri(), QString("Uri 1"));
+    changed = mTest->setUri(QString("Uri 2"));
+    QCOMPARE(changed, true);
+    QCOMPARE(mTest->mUri, QString("Uri 2"));
+    QCOMPARE(mTest->uri(), QString("Uri 2"));
+    
+}
+
+/*!
+ test setAlbumArtUri
+ */
+void TestMpPlaybackData::testSetAlbumArtUri()
+{
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady()));
+    //Empty string
+    mTest->setAlbumArtUri(QString(""));
+    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    //Request failed
+    mTest->mThumbnailManager->mGetThumbFails = true;
+    mTest->setAlbumArtUri(QString("AlbumArt"));
+    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    //Succesful requests
+    mTest->mThumbnailManager->mGetThumbFails = false;
+    for(int i = 1; i < 10; i++){
+        mTest->setAlbumArtUri(QString("AlbumArt"));
+        QCOMPARE(mTest->mReqId, i);
+        QCOMPARE(spy.count(),0);
+        mTest->mReqId = KUndefined;
+    }
+    
+    //Pending request
+    mTest->mReqId = 1;
+    for(int i = 1; i < 10; i++){
+        mTest->setAlbumArtUri(QString("AlbumArt"));
+        QCOMPARE(spy.count(),0);
+        QCOMPARE(mTest->mThumbnailManager->mCancelCounter, i);
+    }
+}
+
+/*!
+ test ThumbnailReady and albumArt
+ */
+void TestMpPlaybackData::testThumbnailReady()
+{
+    void* temp;
+    temp=0;
+    QSignalSpy spy(mTest, SIGNAL(albumArtReady()));
+    QPixmap albumArt(100,100);
+    QPixmap albumArt2;
+   
+    //Error
+    mTest->thumbnailReady(albumArt,temp,KUndefined,KUndefined);
+    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt); 
+    QCOMPARE(mTest->mReqId, KUndefined);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    //Wrong id
+    mTest->mReqId = 1;
+    mTest->thumbnailReady(albumArt,temp,KUndefined,0);
+    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt); 
+    QCOMPARE(mTest->mReqId, KUndefined);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    //Update album art
+    mTest->mReqId = 1;
+    mTest->thumbnailReady(albumArt,temp,1,0);
+    QCOMPARE(mTest->mReqId, KUndefined);
+    QCOMPARE(spy.count(),1);
+    mTest->albumArt(albumArt2);
+    QCOMPARE(albumArt,albumArt2);
+}
+
+/*!
+ test setPlaybackState and playbackState
+ */
+void TestMpPlaybackData::testSetPlaybackState()
+{
+    QSignalSpy spy(mTest, SIGNAL(playbackStateChanged()));
+    
+    mTest->mPlaybackState = MpPlaybackData::Paused;
+    
+    mTest->setPlaybackState(MpPlaybackData::Playing);
+    QCOMPARE(mTest->playbackState(),MpPlaybackData::Playing);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    mTest->setPlaybackState(MpPlaybackData::Stopped);
+    QCOMPARE(mTest->playbackState(),MpPlaybackData::Stopped);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    mTest->setPlaybackState(MpPlaybackData::Paused);
+    QCOMPARE(mTest->playbackState(),MpPlaybackData::Paused);
+    QCOMPARE(spy.count(),1);
+    spy.clear();
+    
+    mTest->setPlaybackState(MpPlaybackData::Paused);
+    QCOMPARE(mTest->playbackState(),MpPlaybackData::Paused);
+    QCOMPARE(spy.count(),0);
+    
+}
+
+
+/*!
+ test commitPlaybackInfo
+ */
+void TestMpPlaybackData::testCommitPlaybackInfo()
+{
+    QSignalSpy spy(mTest, SIGNAL(playbackInfoChanged()));
+    
+    for(int i = 1; i < 10; i++){
+        mTest->commitPlaybackInfo();
+        QCOMPARE(spy.count(),i);
+    }
+}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/stub/inc/thumbnailmanager_qt.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ThumbnailManager stub for testing MpPlaybackData
+*
+*/
+
+#ifndef THUMBNAILMANAGER_QT_H
+#define THUMBNAILMANAGER_QT_H
+
+#include <qobject>
+#include <QPixmap.h>
+
+
+/** default priority value */
+const int tnmWrapperPriorityIdle = -100;
+
+class ThumbnailManager : public QObject
+    {
+    Q_OBJECT
+
+public:
+
+
+    /** Thumbnail size. */
+    enum ThumbnailSize
+    {
+        /**
+         * Small thumbnail
+         */
+        ThumbnailSmall = 0,
+        /**
+         * Medium thumbnail
+         */
+        ThumbnailMedium,
+        /**
+         * Large thumbnail
+         */
+        ThumbnailLarge
+    };
+
+    /** Mode of thumbnail creation. */
+    enum ThumbnailMode
+        {
+        /**
+         * Default mode. This means that:
+         * - Thumbnail must be as large as requested (unless the actual object is smaller).
+         * - Smaller thumbnails may be up scaled to desired resolution.
+         * - Aspect ratio is maintained and thumbnails are not cropped. The
+         *   resulting thumbnail may smaller in either width or height if
+         *   the aspect ratio of the object does not match the aspect ratio
+         *   of the requested size.
+         */
+        Default = 0,
+
+        /**
+         * Allow thumbnails which are smaller than requested are. Thumbnail
+         * bitmaps are never up scaled if this flag is set.
+         */
+        AllowAnySize = 1,
+
+        /**
+         * New thumbnail images are not created if this flag is set. Only
+         * existing thumbnails may be returned. If a requested thumbnail does
+         * not exist null pixmap will be returned.
+         */
+        DoNotCreate = 2,
+
+        /**
+         * Thumbnail images are cropped to match requested aspect ratio. If
+         * this mode is set, the size of the resulting thumbnail always
+         * matches the requested size.
+         */
+        CropToAspectRatio = 4
+    };
+
+    /**  Quality versus speed preference setting */
+    enum QualityPreference
+    {
+        /**
+         * Prefer thumbnails in the highest quality possible disregarding
+         * any negative impact on performance.
+         */
+        OptimizeForQuality,
+
+        /**
+         * Get thumbnails as fast as possible, even if
+         * it means lower quality.
+         */
+        OptimizeForPerformance
+    };
+
+    // Test utility functions
+    static int getInitCounter();
+    static void resetInitCounter();
+
+    // Stub functions
+    ThumbnailManager( QObject* parentPtr = NULL );
+    virtual ~ThumbnailManager();
+    bool setMode( ThumbnailMode mode );
+    bool setQualityPreference( QualityPreference qualityPreference );
+    bool setThumbnailSize( ThumbnailSize thumbnailSize );
+    int getThumbnail( const QString& fileName, void * clientData = NULL,
+            int priority = tnmWrapperPriorityIdle );
+    bool cancelRequest( int id );
+
+signals:
+
+    void thumbnailReady( QPixmap , void * , int , int );
+
+public:
+
+    bool    mGetThumbFails;
+    int     mThumbnailReqCounter;
+    int     mCancelCounter;
+
+};
+
+#endif // THUMBNAILMANAGER_QT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/stub/src/thumbnailmanager_qt.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ThumbnailManager stub for testing MpPlaybackData
+*
+*/
+
+#include <qsize.h>
+#include "stub/inc/thumbnailmanager_qt.h"
+
+int gInitCounter = 0;
+
+/*!
+ Returns gInitCounter.
+ gInitCounter counts the number of constructor/destructor calls.
+ */
+int ThumbnailManager::getInitCounter()
+{
+    return gInitCounter;
+}
+
+/*!
+ Resets gInitCounter to zero.
+ */
+void ThumbnailManager::resetInitCounter()
+{
+    gInitCounter = 0;
+}
+
+/*!
+ Stub function.
+ */
+ThumbnailManager::ThumbnailManager( QObject* parentPtr ) :
+QObject( parentPtr ),
+mGetThumbFails(false),
+mThumbnailReqCounter(0),
+mCancelCounter(0)
+{
+    gInitCounter++;
+}
+
+/*!
+ Stub function.
+ */
+ThumbnailManager::~ThumbnailManager()
+{
+    gInitCounter--;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setMode( ThumbnailMode mode )
+{
+    Q_UNUSED(mode);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setQualityPreference( QualityPreference
+    qualityPreference )
+{
+    Q_UNUSED(qualityPreference);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::setThumbnailSize( ThumbnailSize thumbnailSize )
+{
+    Q_UNUSED(thumbnailSize);
+    return true;
+}
+
+/*!
+ Stub function.
+ */
+int ThumbnailManager::getThumbnail( const QString& fileName, void *clientData,
+        int priority )
+{
+    Q_UNUSED(fileName);
+    Q_UNUSED(priority);
+
+    if (clientData) {
+        // Delete this to prevent memory leak
+        int *data = (int *)clientData;
+        delete data;
+
+        data = 0;
+    }
+
+    if ( mGetThumbFails ) {
+        return -1;
+    }
+
+    mThumbnailReqCounter++;
+    return mThumbnailReqCounter;
+}
+
+/*!
+ Stub function.
+ */
+bool ThumbnailManager::cancelRequest( int id )
+{
+    Q_UNUSED(id);
+    mCancelCounter++;
+    return true;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+TEMPLATE = app
+CONFIG += qtestlib hb
+TARGET = 
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+	stub/inc \
+    ../../inc \
+    ../../../inc
+
+
+    
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lestor.dll \
+    	-lfbscli.dll \
+				
+HEADERS += inc/unittest_mpplaybackdata.h \        
+           stub/inc/thumbnailmanager_qt.h \
+           ../../../inc/mpplaybackdata.h 
+           
+               
+SOURCES += src/unittest_mpplaybackdata.cpp \
+		       ../../src/mpplaybackdata.cpp \
+           stub/src/thumbnailmanager_qt.cpp
+
+DEFINES += BUILD_MPDATA_LIB
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpdata/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata_template.pkg	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,32 @@
+; unittest_mpplaybackdata_template.pkg generated by qmake at 2010-04-05T19:32:11
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"unittest_mpplaybackdata"},(0xE0350e5d),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+ 
+; Default dependency to Qt libraries
+(0x2001E61C), , , , {"Qt"}
+
+; Executable and default resource files
+"/epoc32/release/$(PLATFORM)/$(TARGET)/unittest_mpplaybackdata.exe"    - "!:\sys\bin\unittest_mpplaybackdata.exe"
+"/epoc32/data/z/resource/apps/unittest_mpplaybackdata.rsc"    - "!:\resource\apps\unittest_mpplaybackdata.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/unittest_mpplaybackdata_reg.rsc"    - "!:\private\10003a3f\import\apps\unittest_mpplaybackdata_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- a/mpengine/bwins/mpengineu.def	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/bwins/mpengineu.def	Mon May 03 12:29:20 2010 +0300
@@ -1,31 +1,66 @@
 EXPORTS
-	?metaObject@MpEngine@@UBEPBUQMetaObject@@XZ @ 1 NONAME ; struct QMetaObject const * MpEngine::metaObject(void) const
-	?refreshLibrary@MpEngine@@QAEXXZ @ 2 NONAME ; void MpEngine::refreshLibrary(void)
-	?exitApplication@MpEngine@@IAEXXZ @ 3 NONAME ; void MpEngine::exitApplication(void)
-	?trUtf8@MpEngine@@SA?AVQString@@PBD0H@Z @ 4 NONAME ; class QString MpEngine::trUtf8(char const *, char const *, int)
-	?handleUsbEvent@MpEngine@@QAEXW4MpxUsbEvents@@@Z @ 5 NONAME ; void MpEngine::handleUsbEvent(enum MpxUsbEvents)
-	?handleUsbMassStorageStartEvent@MpEngine@@AAEXXZ @ 6 NONAME ; void MpEngine::handleUsbMassStorageStartEvent(void)
-	?tr@MpEngine@@SA?AVQString@@PBD0@Z @ 7 NONAME ; class QString MpEngine::tr(char const *, char const *)
-	?getStaticMetaObject@MpEngine@@SAABUQMetaObject@@XZ @ 8 NONAME ; struct QMetaObject const & MpEngine::getStaticMetaObject(void)
-	?qt_metacast@MpEngine@@UAEPAXPBD@Z @ 9 NONAME ; void * MpEngine::qt_metacast(char const *)
-	?handleDiskEvent@MpEngine@@QAEXW4MpxDiskEvents@@@Z @ 10 NONAME ; void MpEngine::handleDiskEvent(enum MpxDiskEvents)
-	?verifyUsbBlocking@MpEngine@@QAE_N_N@Z @ 11 NONAME ; bool MpEngine::verifyUsbBlocking(bool)
-	?handleUsbMassStorageEndEvent@MpEngine@@AAEXXZ @ 12 NONAME ; void MpEngine::handleUsbMassStorageEndEvent(void)
-	?usbBlocked@MpEngine@@IAEX_N@Z @ 13 NONAME ; void MpEngine::usbBlocked(bool)
-	?libraryRefreshed@MpEngine@@IAEXXZ @ 14 NONAME ; void MpEngine::libraryRefreshed(void)
-	??0MpEngine@@AAE@XZ @ 15 NONAME ; MpEngine::MpEngine(void)
-	?tr@MpEngine@@SA?AVQString@@PBD0H@Z @ 16 NONAME ; class QString MpEngine::tr(char const *, char const *, int)
-	?handleUsbMtpEndEvent@MpEngine@@AAEXXZ @ 17 NONAME ; void MpEngine::handleUsbMtpEndEvent(void)
-	?trUtf8@MpEngine@@SA?AVQString@@PBD0@Z @ 18 NONAME ; class QString MpEngine::trUtf8(char const *, char const *)
-	?libraryAboutToRefresh@MpEngine@@IAEXXZ @ 19 NONAME ; void MpEngine::libraryAboutToRefresh(void)
-	?staticMetaObject@MpEngine@@2UQMetaObject@@B @ 20 NONAME ; struct QMetaObject const MpEngine::staticMetaObject
-	?handleScanEnded@MpEngine@@QAEXHH@Z @ 21 NONAME ; void MpEngine::handleScanEnded(int, int)
-	??_EMpEngine@@UAE@I@Z @ 22 NONAME ; MpEngine::~MpEngine(unsigned int)
-	??1MpEngine@@UAE@XZ @ 23 NONAME ; MpEngine::~MpEngine(void)
-	?handleUsbMtpStartEvent@MpEngine@@AAEXXZ @ 24 NONAME ; void MpEngine::handleUsbMtpStartEvent(void)
-	?changeUsbBlockingState@MpEngine@@AAEXW4UsbBlockingState@1@@Z @ 25 NONAME ; void MpEngine::changeUsbBlockingState(enum MpEngine::UsbBlockingState)
-	?instance@MpEngine@@SAPAV1@XZ @ 26 NONAME ; class MpEngine * MpEngine::instance(void)
-	?qt_metacall@MpEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 27 NONAME ; int MpEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?handleScanStarted@MpEngine@@QAEXXZ @ 28 NONAME ; void MpEngine::handleScanStarted(void)
-	?handleUsbMtpNotActive@MpEngine@@AAEXXZ @ 29 NONAME ; void MpEngine::handleUsbMtpNotActive(void)
+	?releaseIsolatedCollection@MpEngine@@QAEXXZ @ 1 NONAME ; void MpEngine::releaseIsolatedCollection(void)
+	?metaObject@MpEngine@@UBEPBUQMetaObject@@XZ @ 2 NONAME ; struct QMetaObject const * MpEngine::metaObject(void) const
+	?refreshLibrary@MpEngine@@QAEXXZ @ 3 NONAME ; void MpEngine::refreshLibrary(void)
+	?launchBlockingNote@MpEngine@@AAEXXZ @ 4 NONAME ; void MpEngine::launchBlockingNote(void)
+	?playEmbedded@MpEngine@@QAEXVQString@@@Z @ 5 NONAME ; void MpEngine::playEmbedded(class QString)
+	?tr@MpEngine@@SA?AVQString@@PBD0@Z @ 6 NONAME ; class QString MpEngine::tr(char const *, char const *)
+	?setPosition@MpEngine@@QAEXH@Z @ 7 NONAME ; void MpEngine::setPosition(int)
+	?saveToCurrentPlaylist@MpEngine@@QAEXAAV?$QList@H@@PAVMpMpxCollectionData@@@Z @ 8 NONAME ; void MpEngine::saveToCurrentPlaylist(class QList<int> &, class MpMpxCollectionData *)
+	?getStaticMetaObject@MpEngine@@SAABUQMetaObject@@XZ @ 9 NONAME ; struct QMetaObject const & MpEngine::getStaticMetaObject(void)
+	?renamePlaylist@MpEngine@@QAEXAAVQString@@@Z @ 10 NONAME ; void MpEngine::renamePlaylist(class QString &)
+	?setRepeat@MpEngine@@QAEX_N@Z @ 11 NONAME ; void MpEngine::setRepeat(bool)
+	?collectionData@MpEngine@@QAEPAVMpMpxCollectionData@@XZ @ 12 NONAME ; class MpMpxCollectionData * MpEngine::collectionData(void)
+	?createPlaylist@MpEngine@@QAEXAAVQString@@AAV?$QList@H@@PAVMpMpxCollectionData@@@Z @ 13 NONAME ; void MpEngine::createPlaylist(class QString &, class QList<int> &, class MpMpxCollectionData *)
+	?collectionPlaylistOpened@MpEngine@@IAEXXZ @ 14 NONAME ; void MpEngine::collectionPlaylistOpened(void)
+	?playlistsRenamed@MpEngine@@IAEX_N@Z @ 15 NONAME ; void MpEngine::playlistsRenamed(bool)
+	?playPause@MpEngine@@QAEXXZ @ 16 NONAME ; void MpEngine::playPause(void)
+	?checkForSystemEvents@MpEngine@@QAEXXZ @ 17 NONAME ; void MpEngine::checkForSystemEvents(void)
+	?renamePlaylist@MpEngine@@QAEXAAVQString@@H@Z @ 18 NONAME ; void MpEngine::renamePlaylist(class QString &, int)
+	?handleUsbMtpEndEvent@MpEngine@@AAEXXZ @ 19 NONAME ; void MpEngine::handleUsbMtpEndEvent(void)
+	?playEmbedded@MpEngine@@QAEXABVXQSharableFile@@@Z @ 20 NONAME ; void MpEngine::playEmbedded(class XQSharableFile const &)
+	?libraryAboutToRefresh@MpEngine@@IAEXXZ @ 21 NONAME ; void MpEngine::libraryAboutToRefresh(void)
+	?skipForward@MpEngine@@QAEXXZ @ 22 NONAME ; void MpEngine::skipForward(void)
+	?staticMetaObject@MpEngine@@2UQMetaObject@@B @ 23 NONAME ; struct QMetaObject const MpEngine::staticMetaObject
+	?setShuffle@MpEngine@@QAEX_N@Z @ 24 NONAME ; void MpEngine::setShuffle(bool)
+	?openIsolatedCollection@MpEngine@@QAEXW4TCollectionContext@@@Z @ 25 NONAME ; void MpEngine::openIsolatedCollection(enum TCollectionContext)
+	?handleUsbMtpStartEvent@MpEngine@@AAEXXZ @ 26 NONAME ; void MpEngine::handleUsbMtpStartEvent(void)
+	?instance@MpEngine@@SAPAV1@XZ @ 27 NONAME ; class MpEngine * MpEngine::instance(void)
+	?openCollectionItem@MpEngine@@QAEXH@Z @ 28 NONAME ; void MpEngine::openCollectionItem(int)
+	?qt_metacall@MpEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 29 NONAME ; int MpEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?playlistSaved@MpEngine@@IAEX_N@Z @ 30 NONAME ; void MpEngine::playlistSaved(bool)
+	?handleScanStarted@MpEngine@@QAEXXZ @ 31 NONAME ; void MpEngine::handleScanStarted(void)
+	?initialize@MpEngine@@QAEXW4MpViewMode@MpCommon@@VTUid@@@Z @ 32 NONAME ; void MpEngine::initialize(enum MpCommon::MpViewMode, class TUid)
+	?playbackData@MpEngine@@QAEPAVMpPlaybackData@@XZ @ 33 NONAME ; class MpPlaybackData * MpEngine::playbackData(void)
+	?stop@MpEngine@@QAEXXZ @ 34 NONAME ; void MpEngine::stop(void)
+	?back@MpEngine@@QAEXXZ @ 35 NONAME ; void MpEngine::back(void)
+	?openCollection@MpEngine@@QAEXW4TCollectionContext@@@Z @ 36 NONAME ; void MpEngine::openCollection(enum TCollectionContext)
+	?trUtf8@MpEngine@@SA?AVQString@@PBD0H@Z @ 37 NONAME ; class QString MpEngine::trUtf8(char const *, char const *, int)
+	?reopenCollection@MpEngine@@QAEXXZ @ 38 NONAME ; void MpEngine::reopenCollection(void)
+	?handleUsbEvent@MpEngine@@QAEXW4MpxUsbEvents@@@Z @ 39 NONAME ; void MpEngine::handleUsbEvent(enum MpxUsbEvents)
+	?songsDeleted@MpEngine@@IAEX_N@Z @ 40 NONAME ; void MpEngine::songsDeleted(bool)
+	?handleUsbMassStorageStartEvent@MpEngine@@AAEXXZ @ 41 NONAME ; void MpEngine::handleUsbMassStorageStartEvent(void)
+	?qt_metacast@MpEngine@@UAEPAXPBD@Z @ 42 NONAME ; void * MpEngine::qt_metacast(char const *)
+	?handleDiskEvent@MpEngine@@QAEXW4MpxDiskEvents@@@Z @ 43 NONAME ; void MpEngine::handleDiskEvent(enum MpxDiskEvents)
+	?verifyUsbBlocking@MpEngine@@QAE_N_N@Z @ 44 NONAME ; bool MpEngine::verifyUsbBlocking(bool)
+	?saveToPlaylist@MpEngine@@QAEXHAAV?$QList@H@@@Z @ 45 NONAME ; void MpEngine::saveToPlaylist(int, class QList<int> &)
+	?handleUsbMassStorageEndEvent@MpEngine@@AAEXXZ @ 46 NONAME ; void MpEngine::handleUsbMassStorageEndEvent(void)
+	?usbBlocked@MpEngine@@IAEX_N@Z @ 47 NONAME ; void MpEngine::usbBlocked(bool)
+	??0MpEngine@@AAE@XZ @ 48 NONAME ; MpEngine::MpEngine(void)
+	?handleUsbMtpNotActive@MpEngine@@AAEXXZ @ 49 NONAME ; void MpEngine::handleUsbMtpNotActive(void)
+	?libraryRefreshed@MpEngine@@IAEXXZ @ 50 NONAME ; void MpEngine::libraryRefreshed(void)
+	?tr@MpEngine@@SA?AVQString@@PBD0H@Z @ 51 NONAME ; class QString MpEngine::tr(char const *, char const *, int)
+	?trUtf8@MpEngine@@SA?AVQString@@PBD0@Z @ 52 NONAME ; class QString MpEngine::trUtf8(char const *, char const *)
+	?findPlaylists@MpEngine@@QAEXAAVQStringList@@@Z @ 53 NONAME ; void MpEngine::findPlaylists(class QStringList &)
+	?close@MpEngine@@QAEXXZ @ 54 NONAME ; void MpEngine::close(void)
+	?isolatedCollectionOpened@MpEngine@@IAEXPAVMpMpxCollectionData@@@Z @ 55 NONAME ; void MpEngine::isolatedCollectionOpened(class MpMpxCollectionData *)
+	?handleScanEnded@MpEngine@@QAEXHH@Z @ 56 NONAME ; void MpEngine::handleScanEnded(int, int)
+	?previewItem@MpEngine@@QAEXH@Z @ 57 NONAME ; void MpEngine::previewItem(int)
+	?skipBackward@MpEngine@@QAEXXZ @ 58 NONAME ; void MpEngine::skipBackward(void)
+	??1MpEngine@@UAE@XZ @ 59 NONAME ; MpEngine::~MpEngine(void)
+	??_EMpEngine@@UAE@I@Z @ 60 NONAME ; MpEngine::~MpEngine(unsigned int)
+	?changeUsbBlockingState@MpEngine@@AAEXW4UsbBlockingState@1@@Z @ 61 NONAME ; void MpEngine::changeUsbBlockingState(enum MpEngine::UsbBlockingState)
+	?handleBlockingNoteClosing@MpEngine@@QAEXXZ @ 62 NONAME ; void MpEngine::handleBlockingNoteClosing(void)
+	?deleteSongs@MpEngine@@QAEXAAV?$QList@H@@@Z @ 63 NONAME ; void MpEngine::deleteSongs(class QList<int> &)
+	?reorderPlaylist@MpEngine@@QAEXHHHH@Z @ 64 NONAME ; void MpEngine::reorderPlaylist(int, int, int, int)
 
--- a/mpengine/eabi/mpengineu.def	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/eabi/mpengineu.def	Mon May 03 12:29:20 2010 +0300
@@ -1,31 +1,66 @@
 EXPORTS
-	_ZN8MpEngine10usbBlockedEb @ 1 NONAME
-	_ZN8MpEngine11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME
-	_ZN8MpEngine11qt_metacastEPKc @ 3 NONAME
-	_ZN8MpEngine14handleUsbEventE12MpxUsbEvents @ 4 NONAME
-	_ZN8MpEngine14refreshLibraryEv @ 5 NONAME
-	_ZN8MpEngine15exitApplicationEv @ 6 NONAME
-	_ZN8MpEngine15handleDiskEventE13MpxDiskEvents @ 7 NONAME
-	_ZN8MpEngine15handleScanEndedEii @ 8 NONAME
-	_ZN8MpEngine16libraryRefreshedEv @ 9 NONAME
-	_ZN8MpEngine16staticMetaObjectE @ 10 NONAME DATA 16
-	_ZN8MpEngine17handleScanStartedEv @ 11 NONAME
-	_ZN8MpEngine17verifyUsbBlockingEb @ 12 NONAME
-	_ZN8MpEngine19getStaticMetaObjectEv @ 13 NONAME
-	_ZN8MpEngine20handleUsbMtpEndEventEv @ 14 NONAME
-	_ZN8MpEngine21libraryAboutToRefreshEv @ 15 NONAME
-	_ZN8MpEngine22changeUsbBlockingStateENS_16UsbBlockingStateE @ 16 NONAME
-	_ZN8MpEngine22handleUsbMtpStartEventEv @ 17 NONAME
-	_ZN8MpEngine28handleUsbMassStorageEndEventEv @ 18 NONAME
-	_ZN8MpEngine30handleUsbMassStorageStartEventEv @ 19 NONAME
-	_ZN8MpEngine8instanceEv @ 20 NONAME
-	_ZN8MpEngineC1Ev @ 21 NONAME
-	_ZN8MpEngineC2Ev @ 22 NONAME
-	_ZN8MpEngineD0Ev @ 23 NONAME
-	_ZN8MpEngineD1Ev @ 24 NONAME
-	_ZN8MpEngineD2Ev @ 25 NONAME
-	_ZNK8MpEngine10metaObjectEv @ 26 NONAME
-	_ZTI8MpEngine @ 27 NONAME
-	_ZTV8MpEngine @ 28 NONAME
-	_ZN8MpEngine21handleUsbMtpNotActiveEv @ 29 NONAME
+	_ZN8MpEngine10initializeEN8MpCommon10MpViewModeE4TUid @ 1 NONAME
+	_ZN8MpEngine10setShuffleEb @ 2 NONAME
+	_ZN8MpEngine10usbBlockedEb @ 3 NONAME
+	_ZN8MpEngine11deleteSongsER5QListIiE @ 4 NONAME
+	_ZN8MpEngine11previewItemEi @ 5 NONAME
+	_ZN8MpEngine11qt_metacallEN11QMetaObject4CallEiPPv @ 6 NONAME
+	_ZN8MpEngine11qt_metacastEPKc @ 7 NONAME
+	_ZN8MpEngine11setPositionEi @ 8 NONAME
+	_ZN8MpEngine11skipForwardEv @ 9 NONAME
+	_ZN8MpEngine12playEmbeddedE7QString @ 10 NONAME
+	_ZN8MpEngine12playEmbeddedERK14XQSharableFile @ 11 NONAME
+	_ZN8MpEngine12playbackDataEv @ 12 NONAME
+	_ZN8MpEngine12skipBackwardEv @ 13 NONAME
+	_ZN8MpEngine12songsDeletedEb @ 14 NONAME
+	_ZN8MpEngine13findPlaylistsER11QStringList @ 15 NONAME
+	_ZN8MpEngine13playlistSavedEb @ 16 NONAME
+	_ZN8MpEngine14collectionDataEv @ 17 NONAME
+	_ZN8MpEngine14createPlaylistER7QStringR5QListIiEP19MpMpxCollectionData @ 18 NONAME
+	_ZN8MpEngine14handleUsbEventE12MpxUsbEvents @ 19 NONAME
+	_ZN8MpEngine14openCollectionE18TCollectionContext @ 20 NONAME
+	_ZN8MpEngine14refreshLibraryEv @ 21 NONAME
+	_ZN8MpEngine14renamePlaylistER7QString @ 22 NONAME
+	_ZN8MpEngine14renamePlaylistER7QStringi @ 23 NONAME
+	_ZN8MpEngine14saveToPlaylistEiR5QListIiE @ 24 NONAME
+	_ZN8MpEngine15handleDiskEventE13MpxDiskEvents @ 25 NONAME
+	_ZN8MpEngine15handleScanEndedEii @ 26 NONAME
+	_ZN8MpEngine15reorderPlaylistEiiii @ 27 NONAME
+	_ZN8MpEngine16libraryRefreshedEv @ 28 NONAME
+	_ZN8MpEngine16playlistsRenamedEb @ 29 NONAME
+	_ZN8MpEngine16reopenCollectionEv @ 30 NONAME
+	_ZN8MpEngine16staticMetaObjectE @ 31 NONAME DATA 16
+	_ZN8MpEngine17handleScanStartedEv @ 32 NONAME
+	_ZN8MpEngine17verifyUsbBlockingEb @ 33 NONAME
+	_ZN8MpEngine18launchBlockingNoteEv @ 34 NONAME
+	_ZN8MpEngine18openCollectionItemEi @ 35 NONAME
+	_ZN8MpEngine19getStaticMetaObjectEv @ 36 NONAME
+	_ZN8MpEngine20checkForSystemEventsEv @ 37 NONAME
+	_ZN8MpEngine20handleUsbMtpEndEventEv @ 38 NONAME
+	_ZN8MpEngine21handleUsbMtpNotActiveEv @ 39 NONAME
+	_ZN8MpEngine21libraryAboutToRefreshEv @ 40 NONAME
+	_ZN8MpEngine21saveToCurrentPlaylistER5QListIiEP19MpMpxCollectionData @ 41 NONAME
+	_ZN8MpEngine22changeUsbBlockingStateENS_16UsbBlockingStateE @ 42 NONAME
+	_ZN8MpEngine22handleUsbMtpStartEventEv @ 43 NONAME
+	_ZN8MpEngine22openIsolatedCollectionE18TCollectionContext @ 44 NONAME
+	_ZN8MpEngine24collectionPlaylistOpenedEv @ 45 NONAME
+	_ZN8MpEngine24isolatedCollectionOpenedEP19MpMpxCollectionData @ 46 NONAME
+	_ZN8MpEngine25handleBlockingNoteClosingEv @ 47 NONAME
+	_ZN8MpEngine25releaseIsolatedCollectionEv @ 48 NONAME
+	_ZN8MpEngine28handleUsbMassStorageEndEventEv @ 49 NONAME
+	_ZN8MpEngine30handleUsbMassStorageStartEventEv @ 50 NONAME
+	_ZN8MpEngine4backEv @ 51 NONAME
+	_ZN8MpEngine4stopEv @ 52 NONAME
+	_ZN8MpEngine5closeEv @ 53 NONAME
+	_ZN8MpEngine8instanceEv @ 54 NONAME
+	_ZN8MpEngine9playPauseEv @ 55 NONAME
+	_ZN8MpEngine9setRepeatEb @ 56 NONAME
+	_ZN8MpEngineC1Ev @ 57 NONAME
+	_ZN8MpEngineC2Ev @ 58 NONAME
+	_ZN8MpEngineD0Ev @ 59 NONAME
+	_ZN8MpEngineD1Ev @ 60 NONAME
+	_ZN8MpEngineD2Ev @ 61 NONAME
+	_ZNK8MpEngine10metaObjectEv @ 62 NONAME
+	_ZTI8MpEngine @ 63 NONAME
+	_ZTV8MpEngine @ 64 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxcollectionframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx collection framework utilities.
+*
+*/
+
+#ifndef MPMPXCOLLECTIONFRAMEWORKWRAPPER_H
+#define MPMPXCOLLECTIONFRAMEWORKWRAPPER_H
+
+#include <QObject>
+
+#include "mpmpxcollectionviewdefs.h"
+#include "mpcommondefs.h"
+
+class MpMpxCollectionFrameworkWrapperPrivate;
+class MpMpxCollectionData;
+class QStringList;
+
+
+class MpMpxCollectionFrameworkWrapper : public QObject
+{
+    Q_OBJECT
+
+    friend class MpMpxCollectionFrameworkWrapperPrivate;
+
+public:
+
+    explicit MpMpxCollectionFrameworkWrapper( 
+                MpCommon::MpViewMode viewMode=MpCommon::DefaultView, TUid hostUid = TUid::Uid( MpCommon::KMusicPlayerUid ), QObject *parent=0 );
+    virtual ~MpMpxCollectionFrameworkWrapper();
+
+    void openCollection( TCollectionContext context );
+    void openCollectionItem( int index );
+    void back();
+    void findPlaylists( QStringList &playlists );
+    void createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData = 0  );
+    void saveToPlaylist( int playlistIndex, QList<int> &selection );
+    void saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData );    
+    void renamePlaylist( QString &newName, int index );
+    void renamePlaylist( QString &newName );
+    void deleteSongs( QList<int> &selection );
+    void setShuffle( bool active );
+    
+    void previewItem( int index );
+    void openIsolatedCollection( TCollectionContext context );
+    void releaseIsolatedCollection();
+    
+    MpMpxCollectionData *collectionData();
+    
+    void reopenCollection();
+    void reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal );
+    
+signals:
+
+    void collectionPlaylistOpened();
+    void playlistSaved( bool success );
+    void songsDeleted( bool success );
+    void playlistsRenamed( bool success );
+    
+    void isolatedCollectionOpened( MpMpxCollectionData* collectionData );
+
+private:
+
+    Q_DISABLE_COPY( MpMpxCollectionFrameworkWrapper )
+    MpMpxCollectionFrameworkWrapperPrivate *d_ptr;
+
+};
+
+#endif // MPMPXCOLLECTIONFRAMEWORKWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxcollectionframeworkwrapper_p.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx collection framework utilities - private implementation.
+*
+*/
+
+#ifndef MPMPXCOLLECTIONFRAMEWORKWRAPPER_P_H
+#define MPMPXCOLLECTIONFRAMEWORKWRAPPER_P_H
+
+#include <e32base.h>
+#include <mpxcollectionobserver.h>
+#include <mpxcollectionuihelperobserver.h>
+
+#include "mpmpxisolatedcollectionhelper.h" //MMpMpxIsolatedCollectionHelperObserver
+#include "mpmpxcollectionviewdefs.h"
+#include "mpcommondefs.h"
+
+class MMPXCollectionUtility;
+class MMPXCollectionUiHelper;
+class CMPXCollectionOpenUtility;
+class MMPXPlaybackUtility;
+class MpMpxCollectionData;
+class MpMpxCollectionFrameworkWrapper;
+class QStringList;
+
+
+class MpMpxCollectionFrameworkWrapperPrivate : public MMPXCollectionObserver,
+                                     public MMPXCHelperObserver,
+                                     public MMpMpxIsolatedCollectionHelperObserver
+{
+public:
+
+    explicit MpMpxCollectionFrameworkWrapperPrivate( MpMpxCollectionFrameworkWrapper *wrapper );
+    virtual ~MpMpxCollectionFrameworkWrapperPrivate();
+
+    void init( MpCommon::MpViewMode viewMode, TUid hostUid );
+    void openCollection( TCollectionContext context );
+    void openCollectionItem( int index );
+    void reopenCollection();
+    void back();
+    void findPlaylists( QStringList &playlists );
+    void createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData *collectionData );
+    void saveToPlaylist( int playlistIndex, QList<int> &selection );
+    void saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData );    
+    void deleteSongs( QList<int> &selection );
+    void renamePlaylist( QString &newName, int index );
+    void renamePlaylist( QString &newName );
+    void setShuffle( bool active );
+    void previewItem( int index );
+    void openIsolatedCollection( TCollectionContext context );
+    void releaseIsolatedCollection();
+    void reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal );
+
+    MpMpxCollectionData *collectionData();
+
+private:
+
+
+    void HandleOpenL( const CMPXMedia& aEntries,
+                     TInt aIndex,TBool aComplete,TInt aError );
+    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
+    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
+    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
+    void HandleOperationCompleteL( TCHelperOperation aOperation, TInt aErr, void* aArgument );
+    void HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError );
+    
+    void DoInitL();
+    void DoOpenCollectionL( TCollectionContext aContext );
+    void DoOpenCollectionItemL( TInt aIndex );
+    void DoIncrementalOpenL();
+    void DoReopenCollectionL();
+    void DoBackL();
+    void DoFindPlaylistsL( QStringList &playlists );
+    void DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData );
+    void DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData );
+    void DoSaveToPlaylistL( int playlistIndex, QList<int> &selection );
+    
+    void DoDeleteSongsL( QList<int> &selection );
+    void DoRenamePlaylistL( QString &newName, int index );
+    void DoRenamePlaylistL( QString &newname );
+    void DoRenamePlaylistL( TMPXItemId id, QString &newName );
+    void DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData );
+    void DoSetShuffleL( bool active );
+    void DoPreviewItemL( int index );
+    void DoOpenIsolatedCollectionL( TCollectionContext context );
+    void DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal );
+    void DoHandleCollectionMessageL( const CMPXMessage& aMsg );
+
+    void PreparePlaylistMediaL( CMPXMedia& aMedia, QList<int> &selection, MpMpxCollectionData *collectionData );
+
+private:
+
+    MpMpxCollectionFrameworkWrapper   *q_ptr;
+
+    MMPXCollectionUtility             *iCollectionUtility;
+    MMPXCollectionUiHelper            *iCollectionUiHelper;
+    CMPXCollectionOpenUtility         *iIncrementalOpenUtil;
+    CMpMpxIsolatedCollectionHelper    *iIsolatedCollectionHelper;
+    MMPXPlaybackUtility               *iPlaybackUtility;
+    MpMpxCollectionData               *iCollectionData;         // Owned
+    MpMpxCollectionData               *iIsolatedCollectionData; // Owned
+    TBool                             iFirstIncrementalOpen;
+    CMPXMedia                         *iUserPlaylists;          // Owned
+    TInt                              iNumItemsAdded;
+    MpCommon::MpViewMode              iViewMode;
+    TUid                              mHostUid;
+
+};
+
+#endif // MPMPXCOLLECTIONFRAMEWORKWRAPPER_P_H
+
--- a/mpengine/inc/mpmpxframeworkwrapper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities.
-*
-*/
-
-#ifndef MPMPXFRAMEWORKWRAPPER_H
-#define MPMPXFRAMEWORKWRAPPER_H
-
-#include <QObject>
-#include "mpmpxcommondefs.h"
-
-class MpMpxFrameworkWrapperPrivate;
-class MpSongScannerHelper;
-class HbNotificationDialog;
-class QStringList;
-class QTranslator;
-
-class MpMpxFrameworkWrapper : public QObject
-{
-    Q_OBJECT
-
-    friend class MpMpxFrameworkWrapperPrivate;
-
-public:
-
-    explicit MpMpxFrameworkWrapper( QObject *parent=0 );
-    virtual ~MpMpxFrameworkWrapper();
-
-    void scan();
-    void cancelScan();
-
-signals:
-
-    void scanStarted();
-    void scanEnded( int count, int error );
-    void scanCountChanged( int count );
-
-    void diskEvent( MpxDiskEvents event );
-    void usbEvent( MpxUsbEvents event );
-
-private:
-
-    Q_DISABLE_COPY( MpMpxFrameworkWrapper )
-    MpMpxFrameworkWrapperPrivate *d_ptr;
-
-};
-
-#endif // MPMPXFRAMEWORKWRAPPER_H
--- a/mpengine/inc/mpmpxframeworkwrapper_p.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities - private implementation.
-*
-*/
-
-#ifndef MPMPXFRAMEWORKWRAPPER_P_H
-#define MPMPXFRAMEWORKWRAPPER_P_H
-
-#include <e32base.h>
-#include <mpxcollectionobserver.h>
-#include <mpxcollectionuihelperobserver.h>
-
-class MMPXCollectionUtility;
-class MMPXHarvesterUtility;
-class MpMpxFrameworkWrapper;
-class QStringList;
-
-
-class MpMpxFrameworkWrapperPrivate : public MMPXCollectionObserver
-{
-public:
-
-    explicit MpMpxFrameworkWrapperPrivate( MpMpxFrameworkWrapper *wrapper );
-    virtual ~MpMpxFrameworkWrapperPrivate();
-
-    void init();
-    void scan();
-    void cancelScan();
-
-private:
-
-    void HandleOpenL( const CMPXMedia& aEntries,
-                     TInt aIndex,TBool aComplete,TInt aError );
-    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
-    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
-    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
-
-    void DoInitL();
-    void DoScanL();
-    void DoCancelScanL();
-    void DoHandleCollectionMessageL( const CMPXMessage& aMsg );
-    TBool BroadcastEventFilter( TInt aMsg );
-
-private:
-
-    MpMpxFrameworkWrapper           *q_ptr;
-
-    MMPXCollectionUtility           *iCollectionUtility;
-    MMPXHarvesterUtility            *iHarvesterUtility;
-    TInt                            iNumItemsAdded;
-    TBool                           iScanning;
-    TInt                            iPreviousBroadCastMsg;
-
-};
-
-#endif // MPMPXFRAMEWORKWRAPPER_P_H
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxharvesterframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx harvester framework utilities.
+*
+*/
+
+#ifndef MPMPXHARVESTERFRAMEWORKWRAPPER_H
+#define MPMPXHARVESTERFRAMEWORKWRAPPER_H
+
+#include <QObject>
+#include "mpmpxcommondefs.h"
+#include "mpcommondefs.h"
+
+class MpMpxHarvesterFrameworkWrapperPrivate;
+class MpSongScannerHelper;
+class HbNotificationDialog;
+class QStringList;
+class QTranslator;
+
+class MpMpxHarvesterFrameworkWrapper : public QObject
+{
+    Q_OBJECT
+
+    friend class MpMpxHarvesterFrameworkWrapperPrivate;
+
+public:
+
+    explicit MpMpxHarvesterFrameworkWrapper( 
+                MpCommon::MpViewMode viewMode=MpCommon::DefaultView, TUid hostUid = TUid::Uid( MpCommon::KMusicPlayerUid ), QObject *parent=0 );
+    virtual ~MpMpxHarvesterFrameworkWrapper();
+
+    void scan();
+    void cancelScan();
+    void checkForSystemEvents();
+
+signals:
+
+    void scanStarted();
+    void scanEnded( int count, int error );
+    void scanCountChanged( int count );
+
+    void diskEvent( MpxDiskEvents event );
+    void usbEvent( MpxUsbEvents event );
+
+private:
+
+    Q_DISABLE_COPY( MpMpxHarvesterFrameworkWrapper )
+    MpMpxHarvesterFrameworkWrapperPrivate *d_ptr;
+
+};
+
+#endif // MPMPXHARVESTERFRAMEWORKWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxharvesterframeworkwrapper_p.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx harvester framework utilities - private implementation.
+*
+*/
+
+#ifndef MPMPXHARVESTERFRAMEWORKWRAPPER_P_H
+#define MPMPXHARVESTERFRAMEWORKWRAPPER_P_H
+
+#include <e32base.h>
+#include <mpxcollectionobserver.h>
+#include <mpxcollectionuihelperobserver.h>
+
+class MMPXCollectionUtility;
+class MMPXHarvesterUtility;
+class MpMpxHarvesterFrameworkWrapper;
+class QStringList;
+
+
+class MpMpxHarvesterFrameworkWrapperPrivate : public MMPXCollectionObserver
+{
+public:
+
+    explicit MpMpxHarvesterFrameworkWrapperPrivate( MpMpxHarvesterFrameworkWrapper *wrapper );
+    virtual ~MpMpxHarvesterFrameworkWrapperPrivate();
+
+    void init( MpCommon::MpViewMode viewMode, TUid hostUid );
+    void scan();
+    void cancelScan();
+    void checkForSystemEvents();
+
+private:
+
+    void HandleOpenL( const CMPXMedia& aEntries,
+                     TInt aIndex,TBool aComplete,TInt aError );
+    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
+    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
+    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
+
+    void DoInitL();
+    void DoScanL();
+    void DoCancelScanL();
+    void DoHandleCollectionMessageL( const CMPXMessage& aMsg );
+    TBool BroadcastEventFilter( TInt aMsg );
+    void DoCheckForSystemEventsL();
+
+private:
+
+    MpMpxHarvesterFrameworkWrapper  *q_ptr;
+
+    MMPXCollectionUtility           *iCollectionUtility;
+    MMPXHarvesterUtility            *iHarvesterUtility;
+    TInt                            iNumItemsAdded;
+    TBool                           iScanning;
+    TInt                            iPreviousBroadCastMsg;
+    MpCommon::MpViewMode            iViewMode;
+    TUid                            mHostUid;
+
+};
+
+#endif // MPMPXHARVESTERFRAMEWORKWRAPPER_P_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxisolatedcollectionhelper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright ( c ) 2009 Nokia Corporation and/or its subsidiary( -ies ).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolated collection helper.
+*
+*/
+
+#ifndef CMPMPXISOLATEDCOLLECTIONHELPER_H
+#define CMPMPXISOLATEDCOLLECTIONHELPER_H
+
+#include <mpxcollectionobserver.h>
+
+class CMPXCollectionOpenUtility;
+class CMPXCollectionPath;
+
+/*!
+    \class MpMpxIsolatedCollectionHelperObserver
+    \brief Observer interface for class CMpMpxIsolatedCollectionHelper
+
+    This is a helper class to open an insolated collection.
+*/
+class MMpMpxIsolatedCollectionHelperObserver
+{
+public:
+
+    virtual void HandleIsolatedOpenL( const CMPXMedia& aEntries, 
+            TInt aError ) = 0;
+};
+
+class CMpMpxIsolatedCollectionHelper : public CBase,
+                                      public MMPXCollectionObserver
+{
+public:
+
+    static CMpMpxIsolatedCollectionHelper* NewL( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+    static CMpMpxIsolatedCollectionHelper* NewLC( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+    virtual ~CMpMpxIsolatedCollectionHelper();
+    void OpenCollectionL( CMPXCollectionPath& aPath );
+    
+private:
+    CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+    void ConstructL();
+    void HandleOpenL( const CMPXMedia& aEntries,
+                     TInt aIndex,TBool aComplete,TInt aError );
+    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
+    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
+    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
+
+private:
+    MMpMpxIsolatedCollectionHelperObserver* iObserver;
+    CMPXCollectionOpenUtility*              iIncrementalOpenUtil; //owned
+    TBool                                   iFirstIncrementalOpen;
+
+};
+
+#endif // CMPMPXISOLATEDCOLLECTIONHELPER_H
+    
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxplaybackframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Framework wraper for Playback utility.
+*
+*/
+
+#ifndef MPMPXPLAYBACKFRAMEWORKWRAPPER_H
+#define MPMPXPLAYBACKFRAMEWORKWRAPPER_H
+
+#include <QObject>
+#include "mpmpxcommondefs.h"
+#include "mpcommondefs.h"
+#include <xqsharablefile.h>
+
+class MpMpxPlaybackFrameworkWrapperPrivate;
+class MpPlaybackData;
+class QStringList;
+
+
+class MpMpxPlaybackFrameworkWrapper : public QObject
+{
+    Q_OBJECT
+
+    friend class MpMpxPlaybackFrameworkWrapperPrivate;
+
+public:
+
+    explicit MpMpxPlaybackFrameworkWrapper( 
+                MpCommon::MpViewMode viewMode=MpCommon::DefaultView, TUid hostUid = TUid::Uid( MpCommon::KMusicPlayerUid ), QObject *parent=0 );
+    virtual ~MpMpxPlaybackFrameworkWrapper();
+    
+    MpPlaybackData *playbackData();
+    
+public slots:
+    
+    void play( QString aFilename );
+    void play( const XQSharableFile& file );
+    void playPause();
+    void stop();
+    void skipForward();
+    void skipBackward();
+    void setPosition( int position );
+    void setShuffle( bool mode );
+    void setRepeat( bool mode );
+    
+private:
+
+    Q_DISABLE_COPY(MpMpxPlaybackFrameworkWrapper)
+    MpMpxPlaybackFrameworkWrapperPrivate *d_ptr;
+
+};
+
+#endif  // MPMPXPLAYBACKFRAMEWORKWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/inc/mpmpxplaybackframeworkwrapper_p.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Framework wraper for Playback - Private.
+*
+*/
+
+#ifndef MPMPXPLAYBACKFRAMEWORKWRAPPER_P_H
+#define MPMPXPLAYBACKFRAMEWORKWRAPPER_P_H
+
+#include <e32base.h>
+#include <mpxplaybackobserver.h>
+#include "mpmpxcollectionviewdefs.h"
+#include "mpcommondefs.h"
+
+
+class MMPXPlaybackUtility;
+class MpMpxPlaybackFrameworkWrapper;
+class QStringList;
+class CMPXMedia;
+class MpPlaybackData;
+class XQSharableFile;
+
+
+class MpMpxPlaybackFrameworkWrapperPrivate : public MMPXPlaybackObserver,
+                                             public MMPXPlaybackCallback
+{
+public:
+
+    explicit MpMpxPlaybackFrameworkWrapperPrivate( MpMpxPlaybackFrameworkWrapper *wrapper );
+    virtual ~MpMpxPlaybackFrameworkWrapperPrivate();
+
+    void init( MpCommon::MpViewMode viewMode, TUid hostUid );
+
+    void play( QString aFilename );
+    void play( const XQSharableFile& file );
+    void playPause();
+    void stop();
+    void skipForward();
+    void skipBackward();
+    void setPosition( int value );
+    void setShuffle( bool mode );
+    void setRepeat( bool mode );
+
+    MpPlaybackData *playbackData();
+
+    // From MMPXPlaybackObserver
+    void HandlePlaybackMessage( CMPXMessage *aMessage, TInt aError );
+
+    // From MMPXPlaybackCallback
+    void HandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError );
+    void HandleSubPlayerNamesL( TUid aPlayer, const MDesCArray *aSubPlayers,
+                                TBool aComplete, TInt aError );
+    void HandleMediaL( const CMPXMedia& aProperties, TInt aError );
+    
+private:
+
+    void DoInitL();
+    void DoPlayL( QString aFilename );
+    void DoPlayL( const XQSharableFile& file );
+    void DoHandlePlaybackMessageL( const CMPXMessage& aMessage );
+    void ForceStopL();
+    void UpdateStateL();
+    void RetrieveSongDetailsL();
+
+private:
+
+    MpMpxPlaybackFrameworkWrapper       *q_ptr;
+    MMPXPlaybackUtility                 *iPlaybackUtility;     // Own
+    CMPXMedia                           *iMedia;               // Own
+    MpPlaybackData                      *iPlaybackData;        // Own
+    MpCommon::MpViewMode                iViewMode;
+    TUid                                mHostUid;
+    
+};
+
+#endif  // MPMPXPLAYBACKFRAMEWORKWRAPPER_P_H
--- a/mpengine/inc/mpsongscanner.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/inc/mpsongscanner.h	Mon May 03 12:29:20 2010 +0300
@@ -19,7 +19,7 @@
 #ifndef MPSONGSCANNER_H
 #define MPSONGSCANNER_H
 
-class MpMpxFrameworkWrapper;
+class MpMpxHarvesterFrameworkWrapper;
 class HbProgressDialog;
 
 #include <QObject>
@@ -31,7 +31,7 @@
 
 public:
 
-    explicit MpSongScanner( MpMpxFrameworkWrapper *wrapper, QObject *parent=0 );
+    explicit MpSongScanner( MpMpxHarvesterFrameworkWrapper *wrapper, QObject *parent=0 );
     virtual ~MpSongScanner();
 
     void scan();
@@ -48,9 +48,9 @@
 
 private:
 
-    MpMpxFrameworkWrapper       *mMpxWrapper;       // Not own
-    HbProgressDialog            *mScanProgressNote; // Own
-    TBool                       mScanning;
+    MpMpxHarvesterFrameworkWrapper       *mMpxWrapper;       // Not own
+    HbProgressDialog                     *mScanProgressNote; // Own
+    TBool                                mScanning;
 
 };
 
--- a/mpengine/mpengine.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/mpengine.pro	Mon May 03 12:29:20 2010 +0300
@@ -27,31 +27,45 @@
     	../inc
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
 
-LIBS += -lxqservice \
+LIBS += -lestor.dll \
     -lmpxplaybackutility.dll \
     -lmpxcollectionutility.dll \
     -lmpxharvesterutility.dll \
     -lmpxcommon.dll \
+    -lmpxcollectionhelper.dll \
     -lremconcoreapi.dll \
-    -lremconinterfacebase.dll
+    -lremconinterfacebase.dll \
+    -lmpsettingsmanager \
+    -lmpdata.dll \
+    -lxqserviceutil
     
 symbian:TARGET.EPOCALLOWDLLDATA	= 1
 
 HEADERS += ../inc/mpengine.h \
-           inc/mpmpxframeworkwrapper.h \
-           inc/mpmpxframeworkwrapper_p.h \
+           inc/mpmpxharvesterframeworkwrapper.h \
+           inc/mpmpxharvesterframeworkwrapper_p.h \
+           inc/mpmpxplaybackframeworkwrapper.h \
+           inc/mpmpxplaybackframeworkwrapper_p.h \
            inc/mpsongscanner.h \
            inc/mpmediakeyhandler.h \
            inc/mpmediakeyhandler_p.h\
-           inc/mpmediakeyremconresponse.h
+           inc/mpmediakeyremconresponse.h \
+           inc/mpmpxcollectionframeworkwrapper.h \
+           inc/mpmpxisolatedcollectionhelper.h \
+           inc/mpmpxcollectionframeworkwrapper_p.h
 
 SOURCES += src/mpengine.cpp \
-           src/mpmpxframeworkwrapper.cpp \
-           src/mpmpxframeworkwrapper_p.cpp \
+           src/mpmpxharvesterframeworkwrapper.cpp \
+           src/mpmpxharvesterframeworkwrapper_p.cpp \
+           src/mpmpxplaybackframeworkwrapper.cpp \
+           src/mpmpxplaybackframeworkwrapper_p.cpp \
            src/mpsongscanner.cpp \
            src/mpmediakeyhandler.cpp \
            src/mpmediakeyhandler_p.cpp \
-           src/mpmediakeyremconresponse.cpp
+           src/mpmediakeyremconresponse.cpp \
+           src/mpmpxcollectionframeworkwrapper.cpp \
+           src/mpmpxisolatedcollectionhelper.cpp \
+           src/mpmpxcollectionframeworkwrapper_p.cpp       
 
 DEFINES += BUILD_MPENGINE_LIB
 
--- a/mpengine/src/mpengine.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/src/mpengine.cpp	Mon May 03 12:29:20 2010 +0300
@@ -18,11 +18,14 @@
 #include <QTranslator>
 #include <QLocale>
 #include <hbmessagebox.h>
-#include <hbnotificationdialog.h>
+#include <hbprogressdialog.h>
 #include <hbinstance.h>
+#include <xqsharablefile.h>
 
 #include "mpengine.h"
-#include "mpmpxframeworkwrapper.h"
+#include "mpmpxharvesterframeworkwrapper.h"
+#include "mpmpxcollectionframeworkwrapper.h"
+#include "mpmpxplaybackframeworkwrapper.h"
 #include "mpsongscanner.h"
 #include "mpmediakeyhandler.h"
 #include "mptrace.h"
@@ -36,6 +39,12 @@
 */
 
 /*!
+-------------------------------------------------------------------------------
+    Harvesting related signals
+-------------------------------------------------------------------------------
+*/
+
+/*!
     \fn void scanStarted()
 
     This signal is emitted when scan operation is started.
@@ -120,42 +129,68 @@
 
  */
 
+
+/*!
+-------------------------------------------------------------------------------
+    Collection related signals
+-------------------------------------------------------------------------------
+*/
+
+/*!
+    \fn void collectionPlaylistOpened()
+
+    This signal is emitted when A new collection playlist is opened and 
+    playback is initialized.
+
+ */
+
+/*!
+    \fn void playlistSaved( bool success )
+
+    This signal is emitted when playlist save operation is completed, it 
+    indicates the operation \a success .
+
+ */
+
+/*!
+    \fn void songsDeleted( bool success )
+
+    This signal is emitted when song delete operation is completed, it 
+    indicates the operation \a success .
+
+ */
+
+/*!
+    \fn void playlistsRenamed( bool success )
+
+    This signal is emitted when playlist rename operation is completed, it
+    indicates the operation  \a success .
+
+ */
+
+/*!
+    \fn void isolatedCollectionOpened( MpMpxCollectionData* collectionData )
+
+    This signal is emitted when an isolated collection is opened on \a context
+
+ */
+
 /*!
  Constructs music player engine.
  */
 MpEngine::MpEngine()
-    : mMpxWrapper(0),
+    : mMpxHarvesterWrapper(0),
       mSongScanner(0),
       mMediaKeyHandler(0),
       mUsbBlockingNote(0),
+      mMpxCollectionWrapper(0),
+      mMpxPlaybackWrapper(0),
       mMpTranslator(0),
       mUsbBlockingState(USB_NotConnected),
-      mPreviousUsbState(USB_NotConnected)
+      mPreviousUsbState(USB_NotConnected),
+      mViewMode(MpCommon::DefaultView)
 {
-    TX_ENTRY
-
-    mMpxWrapper = new MpMpxFrameworkWrapper();
-    connect( mMpxWrapper, SIGNAL( scanStarted() ), this, SLOT( handleScanStarted() ) );
-    connect( mMpxWrapper, SIGNAL( scanEnded(int, int) ), this, SLOT( handleScanEnded(int, int) ) );
-    connect( mMpxWrapper, SIGNAL( diskEvent(MpxDiskEvents) ), this, SLOT( handleDiskEvent(MpxDiskEvents) ) );
-    connect( mMpxWrapper, SIGNAL( usbEvent(MpxUsbEvents) ), this, SLOT( handleUsbEvent(MpxUsbEvents) ) );
-
-    mSongScanner = new MpSongScanner( mMpxWrapper );
-    mMediaKeyHandler = new MpMediaKeyHandler();
-
-    //Load musicplayer translator
-    QString lang = QLocale::system().name();
-    QString path = QString( "z:/resource/qt/translations/" );
-    bool translatorLoaded = false;
-
-    mMpTranslator = new QTranslator( this );
-    translatorLoaded = mMpTranslator->load( path + "musicplayer_" + lang );
-    TX_LOG_ARGS( "Loading translator ok=" << translatorLoaded );
-    if ( translatorLoaded ) {
-        qApp->installTranslator( mMpTranslator );
-    }
-
-    TX_EXIT
+    TX_LOG
 }
 
 /*!
@@ -164,10 +199,6 @@
 MpEngine::~MpEngine()
 {
     TX_ENTRY
-    delete mMpTranslator;
-    delete mSongScanner;
-    delete mMediaKeyHandler;
-    delete mUsbBlockingNote;
     TX_EXIT
 }
 
@@ -181,14 +212,105 @@
 }
 
 /*!
+ Initialize engine
+ */
+void MpEngine::initialize( MpCommon::MpViewMode viewMode, TUid hostUid )
+{
+    TX_ENTRY
+    mViewMode = viewMode;
+    mHostUid = hostUid;
+    
+    //Load musicplayer translator
+    QString lang = QLocale::system().name();
+    QString path = QString( "z:/resource/qt/translations/" );
+    bool translatorLoaded = false;
+
+    mMpTranslator = new QTranslator( this );
+    translatorLoaded = mMpTranslator->load( path + "musicplayer_" + lang );
+    TX_LOG_ARGS( "Loading translator ok=" << translatorLoaded );
+    if ( translatorLoaded ) {
+        qApp->installTranslator( mMpTranslator );
+    }
+    
+    if( mViewMode == MpCommon::DefaultView || mViewMode == MpCommon::FetchView ){
+        // Harvesting Wrapper
+        mMpxHarvesterWrapper = new MpMpxHarvesterFrameworkWrapper( mViewMode, mHostUid );
+        connect( mMpxHarvesterWrapper, SIGNAL( scanStarted() ), 
+                 this, SLOT( handleScanStarted() ), Qt::QueuedConnection );
+        connect( mMpxHarvesterWrapper, SIGNAL( scanEnded(int, int) ), 
+                 this, SLOT( handleScanEnded(int, int) ), Qt::QueuedConnection );
+        qRegisterMetaType<MpxDiskEvents>("MpxDiskEvents");
+        connect( mMpxHarvesterWrapper, SIGNAL( diskEvent(MpxDiskEvents) ), 
+                 this, SLOT( handleDiskEvent(MpxDiskEvents) ), Qt::QueuedConnection );
+        qRegisterMetaType<MpxUsbEvents>("MpxUsbEvents");
+        connect( mMpxHarvesterWrapper, SIGNAL( usbEvent(MpxUsbEvents) ), 
+                 this, SLOT( handleUsbEvent(MpxUsbEvents) ), Qt::QueuedConnection );
+        mSongScanner = new MpSongScanner( mMpxHarvesterWrapper );
+        mMediaKeyHandler = new MpMediaKeyHandler();
+        
+        // Collection Wrapper
+        mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( mViewMode, mHostUid );
+        connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ),
+                this, SIGNAL( collectionPlaylistOpened() ),
+                Qt::QueuedConnection );
+        connect( mMpxCollectionWrapper, SIGNAL( playlistSaved( bool ) ),
+                this, SIGNAL( playlistSaved( bool ) ),
+                Qt::QueuedConnection );
+        connect( mMpxCollectionWrapper, SIGNAL( songsDeleted( bool ) ),
+                this, SIGNAL( songsDeleted( bool ) ),
+                Qt::QueuedConnection );
+        connect( mMpxCollectionWrapper, SIGNAL( playlistsRenamed( bool ) ),
+                this, SIGNAL( playlistsRenamed( bool ) ),
+                Qt::QueuedConnection );
+        connect( mMpxCollectionWrapper, SIGNAL( isolatedCollectionOpened( MpMpxCollectionData* ) ),
+                this, SIGNAL( isolatedCollectionOpened( MpMpxCollectionData* ) ),
+                Qt::QueuedConnection );
+    }
+
+    // Playback Wrapper 
+    mMpxPlaybackWrapper = new MpMpxPlaybackFrameworkWrapper( mViewMode, mHostUid );
+
+    TX_EXIT
+}
+
+/*!
+  Deinitialize wrappers
+ */
+void MpEngine::close( )
+{
+    delete mMpTranslator;
+    mMpTranslator = 0;
+    delete mSongScanner;
+    mSongScanner = 0;
+    delete mMediaKeyHandler;
+    mMediaKeyHandler = 0;   
+    delete mUsbBlockingNote;
+    mUsbBlockingNote = 0;
+    delete mMpxPlaybackWrapper;
+    mMpxPlaybackWrapper = 0;
+    delete mMpxHarvesterWrapper;
+    mMpxHarvesterWrapper = 0;
+    delete mMpxCollectionWrapper;
+    mMpxCollectionWrapper = 0;
+}
+
+/*!
+-------------------------------------------------------------------------------
+    Harvesting related
+-------------------------------------------------------------------------------
+*/
+
+/*!
  Refresh library by starting the scan.
  If scanning is already ongoing, this request is ignored.
  */
 void MpEngine::refreshLibrary()
 {
     TX_ENTRY
-    emit libraryAboutToRefresh();
-    mSongScanner->scan();
+    if ( !verifyUsbBlocking( true ) ) {
+        emit libraryAboutToRefresh();
+        mSongScanner->scan();
+    }
     TX_EXIT
 }
 
@@ -215,6 +337,17 @@
 }
 
 /*!
+ \
+ Request Harvester to check if there are any system events active.
+ */
+void MpEngine::checkForSystemEvents()
+{
+    TX_ENTRY
+    mMpxHarvesterWrapper->checkForSystemEvents();
+    TX_EXIT
+}
+
+/*!
  Slot to be called when song scanning starts.
  */
 void MpEngine::handleScanStarted() {
@@ -249,14 +382,17 @@
             mMediaKeyHandler->setEnabled(true);
             break;
         case DiskRemoved:
-            if ( mUsbBlockingState == USB_NotConnected ) {
-                emit exitApplication();
+            if ( mUsbBlockingState != USB_Synchronizing ) {
+                emit libraryRefreshed();
             }
             break;
         case DiskInserted:
             if ( mUsbBlockingState == USB_NotConnected ) {
                 refreshLibrary();
             }
+            else if ( mUsbBlockingState == USB_Connected ) {
+                emit libraryRefreshed();
+            }
             break;
         default:
             break;
@@ -292,6 +428,16 @@
 }
 
 /*!
+ Slot to be called when mUsbBlockingNote is about to close.
+ */
+void MpEngine::handleBlockingNoteClosing()
+{
+    TX_ENTRY
+    mUsbBlockingNote = 0;
+    TX_EXIT
+}
+
+/*!
  To be called when EMcMsgUSBMassStorageStart event is received.
  */
 void MpEngine::handleUsbMassStorageStartEvent()
@@ -302,13 +448,8 @@
     changeUsbBlockingState( USB_Synchronizing );
     emit usbBlocked(true);
     
-    if ( !mUsbBlockingNote ) {
-        mUsbBlockingNote = new HbNotificationDialog();
-        mUsbBlockingNote->setText( QString( tr( "USB connection in progress" ) ) );
-        mUsbBlockingNote->setModal( true );
-        mUsbBlockingNote->setTimeout( HbPopup::NoTimeout );
-    }
-    mUsbBlockingNote->show();
+    launchBlockingNote();
+    
     TX_EXIT
 }
 
@@ -324,8 +465,7 @@
     emit usbBlocked(false);
     
     if ( mUsbBlockingNote ) {
-        delete mUsbBlockingNote;
-        mUsbBlockingNote = 0;
+        mUsbBlockingNote->close();
     }
     HbMessageBox promptRefresh( HbMessageBox::MessageTypeQuestion );
     promptRefresh.setText( QString( tr( "List may need refreshing due to recent USB synchronisation. Refresh now?" ) ) );
@@ -349,13 +489,11 @@
     changeUsbBlockingState( USB_Synchronizing );
     emit usbBlocked(true);
     
-    if ( !mUsbBlockingNote ) {
-        mUsbBlockingNote = new HbNotificationDialog();
-        mUsbBlockingNote->setText( QString( tr( "USB connection in progress" ) ) );
-        mUsbBlockingNote->setModal( true );
-        mUsbBlockingNote->setTimeout( HbPopup::NoTimeout );
-    }
-    mUsbBlockingNote->show();
+    //Cancel any ongoing operation.
+    emit libraryAboutToRefresh();
+    
+    launchBlockingNote();
+    
     TX_EXIT
 }
 
@@ -371,8 +509,7 @@
     emit usbBlocked(false);
     
     if ( mUsbBlockingNote ) {
-        delete mUsbBlockingNote;
-        mUsbBlockingNote = 0;
+        mUsbBlockingNote->close();
     }
     if ( mPreviousUsbState == USB_Synchronizing ) {
         emit libraryRefreshed();
@@ -386,10 +523,8 @@
 void MpEngine::handleUsbMtpNotActive()
 {
     TX_ENTRY
-
     changeUsbBlockingState( USB_Connected );
     emit usbBlocked(true);
-
     TX_EXIT
 }
 
@@ -400,9 +535,274 @@
 void MpEngine::changeUsbBlockingState( UsbBlockingState state )
 {
     TX_ENTRY
-
     mPreviousUsbState = mUsbBlockingState;
     mUsbBlockingState = state;
+    TX_EXIT
+}
+
+/*!
+ Internal
+ Used to launch the usb blocking note
+ */
+void MpEngine::launchBlockingNote()
+{
+    TX_ENTRY
+    if ( !mUsbBlockingNote ) {
+        mUsbBlockingNote = new HbProgressDialog( HbProgressDialog::WaitDialog );        
+        mUsbBlockingNote->setModal( true );
+        mUsbBlockingNote->setPrimaryAction( 0 );
+        mUsbBlockingNote->setTextAlignment( Qt::AlignCenter );
+        mUsbBlockingNote->setAttribute( Qt::WA_DeleteOnClose );
+        mUsbBlockingNote->setDismissPolicy( HbPopup::NoDismiss );        
+        mUsbBlockingNote->setText( QString( tr( "USB connection in progress" ) ) );
+        connect( mUsbBlockingNote, SIGNAL( aboutToClose() ), this, SLOT( handleBlockingNoteClosing() ) );
+    }
+    
+    mUsbBlockingNote->show();
 
     TX_EXIT
 }
+
+/*!
+-------------------------------------------------------------------------------
+    Collection related
+-------------------------------------------------------------------------------
+*/
+
+/*!
+ Opens the collection for the given \a context.
+
+ \sa collectionOpened()
+ */
+void MpEngine::openCollection( TCollectionContext context )
+{
+    mMpxCollectionWrapper->openCollection( context );
+}
+
+/*!
+ Opens the collection at a specific \a index.
+
+ \sa collectionOpened(), playlistOpened()
+ */
+void MpEngine::openCollectionItem( int index )
+{
+    mMpxCollectionWrapper->openCollectionItem( index );
+}
+
+/*!
+ Navigates back to the container of the current items.
+
+ \sa collectionOpened()
+ */
+void MpEngine::back()
+{
+    mMpxCollectionWrapper->back();
+}
+
+/*!
+ Loads the user created \a playLists.
+
+ */
+void MpEngine::findPlaylists( QStringList &playlists )
+{
+    mMpxCollectionWrapper->findPlaylists( playlists );
+}
+
+/*!
+ Creates a new playlist with name \a playlistName and adds \a selection and optionally uses \a collectionData.
+ */
+void MpEngine::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->createPlaylist( playlistName, selection, collectionData );
+    }
+}
+
+/*!
+ Adds \a selection to the playlist specified in \a playlistIndex.
+ */
+void MpEngine::saveToPlaylist( int playlistIndex, QList<int> &selection )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->saveToPlaylist( playlistIndex, selection );
+    }
+}
+
+/*!
+ Rename a playlist by \a index with \a name.
+ */
+void MpEngine::renamePlaylist( QString &newName, int index )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->renamePlaylist( newName, index );
+    }
+}
+
+/*!
+ Adds \a selection to the current playlist from the specified \a collectionData.
+ */
+void MpEngine::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->saveToCurrentPlaylist( selection, collectionData );
+    }
+}
+
+/*!
+ Rename a playlist with \a name.
+ */
+void MpEngine::renamePlaylist( QString &newName )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->renamePlaylist( newName );
+    }
+}
+
+/*!
+ Deletes \a selection from the collection.
+ */
+void MpEngine::deleteSongs( QList<int> &selection )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->deleteSongs( selection );
+    }
+}
+
+
+
+/*!
+ Initiate a playback preview for the selected item.
+ */
+void MpEngine::previewItem( int index )
+{
+    mMpxCollectionWrapper->previewItem( index );
+}
+
+
+/*!
+ Opens the an isolated collection with \a context.
+ \sa isolatedCollectionOpened()
+ */
+void MpEngine::openIsolatedCollection( TCollectionContext context )
+{
+    if ( !verifyUsbBlocking( true ) ) {
+        mMpxCollectionWrapper->openIsolatedCollection( context );
+    }
+}
+
+/*!
+ Releases the resources used for the isolated collection.
+ */
+void MpEngine::releaseIsolatedCollection()
+{
+    mMpxCollectionWrapper->releaseIsolatedCollection();
+}
+
+/*!
+ Returns pointer to MpMpxCollectionData, which is the collection data.
+ */
+MpMpxCollectionData *MpEngine::collectionData()
+{
+    return mMpxCollectionWrapper->collectionData();
+}
+
+/*!
+ Slot to be called to reopen the collection in its current state.
+
+ \sa collectionOpened()
+ */
+void MpEngine::reopenCollection()
+{
+    mMpxCollectionWrapper->reopenCollection();
+}
+
+/*!
+ Slot to be called to request a reorder operation , indicates that 
+ the item with \a playlistId , \a songId is to be moved from 
+ \a originalOrdinal to \a newOrdinal.
+ */
+void MpEngine::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+    mMpxCollectionWrapper->reorderPlaylist( playlistId, songId, originalOrdinal, newOrdinal );
+}
+
+/*!
+ Returns pointer to MpPlaybackData, which is the playback data.
+ */
+MpPlaybackData *MpEngine::playbackData()
+{
+    return mMpxPlaybackWrapper->playbackData();
+}
+/*!
+ Slot to be called to request embedded playback of item with Uri aFilename
+ */
+
+void MpEngine::playEmbedded( QString aFilename )
+{
+    mMpxPlaybackWrapper->play( aFilename );
+}
+
+/*!
+ Slot to be called to request embedded playback of item with file handle
+ */
+
+void MpEngine::playEmbedded(const XQSharableFile& file )
+{
+    mMpxPlaybackWrapper->play( file );
+}
+/*!
+ Slot to handle a play pause.
+ */
+void MpEngine::playPause()
+{
+    mMpxPlaybackWrapper->playPause();
+}
+
+/*!
+ Slot to handle a stop.
+ */
+void MpEngine::stop()
+{
+    mMpxPlaybackWrapper->stop();
+}
+
+/*!
+ Slot to handle a skeep forward.
+ */
+void MpEngine::skipForward()
+{
+    mMpxPlaybackWrapper->skipForward();
+}
+
+/*!
+ Slot to handle a skeep backwards.
+ */
+void MpEngine::skipBackward()
+{
+    mMpxPlaybackWrapper->skipBackward();
+}
+
+/*!
+ Slot to handle a request to change \a position.
+ */
+void MpEngine::setPosition( int position )
+{
+    mMpxPlaybackWrapper->setPosition( position );
+}
+
+/*!
+ Slot to handle a request to change shuffle \a mode.
+ */
+void MpEngine::setShuffle( bool mode )
+{
+    mMpxPlaybackWrapper->setShuffle( mode );
+}
+
+/*!
+ Slot to handle a request to change repeat \a mode.
+ */
+void MpEngine::setRepeat( bool mode )
+{
+    mMpxPlaybackWrapper->setRepeat( mode );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxcollectionframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,237 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx collection framework utilities.
+*
+*/
+
+#include "mpmpxcollectionframeworkwrapper.h"
+#include "mpmpxcollectionframeworkwrapper_p.h"
+
+/*!
+    \class MpMpxCollectionFrameworkWrapper
+    \brief Wrapper for mpx framework utilities.
+
+    MPX framework wrapper provides Qt style interface to the MPX framework
+    utilities. Its implementation is hidden using private class data pattern.
+*/
+
+/*!
+    \fn void collectionPlaylistOpened()
+
+    This signal is emitted when A new collection playlist is opened and 
+    playback is initialized.
+
+ */
+
+/*!
+    \fn void playlistSaved( bool success )
+
+    This signal is emitted when playlist save operation is completed, it 
+    indicates the operation \a success .
+
+ */
+
+/*!
+    \fn void songsDeleted( bool success )
+
+    This signal is emitted when song delete operation is completed, it 
+    indicates the operation \a success .
+
+ */
+
+/*!
+    \fn void playlistsRenamed( bool success )
+
+    This signal is emitted when playlist rename operation is completed, it
+    indicates the operation  \a success .
+
+ */
+
+/*!
+    \fn void isolatedCollectionOpened( MpMpxCollectionData* collectionData )
+
+    This signal is emitted when an isolated collection is opened on \a context
+
+ */
+ 
+ 
+ 
+/*!
+ Constructs the utility wrapper.
+ */
+MpMpxCollectionFrameworkWrapper::MpMpxCollectionFrameworkWrapper( MpCommon::MpViewMode viewMode, TUid hostUid, QObject *parent )
+    : QObject( parent )
+{
+    d_ptr = new MpMpxCollectionFrameworkWrapperPrivate( this );
+    d_ptr->init( viewMode, hostUid );
+}
+
+/*!
+ Destructs the utility wrapper.
+ */
+MpMpxCollectionFrameworkWrapper::~MpMpxCollectionFrameworkWrapper()
+{
+    delete d_ptr;
+}
+
+/*!
+ Opens the collection for the given \a context.
+
+ \sa collectionOpened()
+ */
+void MpMpxCollectionFrameworkWrapper::openCollection( TCollectionContext context )
+{
+    d_ptr->openCollection( context );
+}
+
+/*!
+ Opens the collection at a specific \a index.
+
+ \sa collectionOpened(), playlistOpened()
+ */
+void MpMpxCollectionFrameworkWrapper::openCollectionItem( int index )
+{
+    d_ptr->openCollectionItem( index );
+}
+
+/*!
+ Navigates back to the container of the current items.
+
+ \sa collectionOpened()
+ */
+void MpMpxCollectionFrameworkWrapper::back()
+{
+    d_ptr->back();
+}
+
+/*!
+ Loads the user created \a playLists.
+
+ */
+void MpMpxCollectionFrameworkWrapper::findPlaylists( QStringList &playlists )
+{
+    d_ptr->findPlaylists( playlists );
+}
+
+/*!
+ Creates a new playlist with name \a playlistName and adds \a selection and optionally uses \a collectionData.
+ */
+void MpMpxCollectionFrameworkWrapper::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
+{
+    d_ptr->createPlaylist( playlistName, selection, collectionData );
+}
+
+/*!
+ Adds \a selection to the playlist specified in \a playlistIndex.
+ */
+void MpMpxCollectionFrameworkWrapper::saveToPlaylist( int playlistIndex, QList<int> &selection )
+{
+    d_ptr->saveToPlaylist( playlistIndex, selection );
+}
+
+/*!
+ Rename a playlist by \a index with \a name.
+ */
+void MpMpxCollectionFrameworkWrapper::renamePlaylist( QString &newName, int index )
+{
+    d_ptr->renamePlaylist( newName, index );
+}
+
+/*!
+ Adds \a selection to the current playlist from the specified \a collectionData.
+ */
+void MpMpxCollectionFrameworkWrapper::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+    d_ptr->saveToCurrentPlaylist( selection, collectionData );
+}
+
+/*!
+ Rename a playlist with \a name.
+ */
+void MpMpxCollectionFrameworkWrapper::renamePlaylist( QString &newName )
+{
+    d_ptr->renamePlaylist( newName );
+}
+
+/*!
+ Deletes \a selection from the collection.
+ */
+void MpMpxCollectionFrameworkWrapper::deleteSongs( QList<int> &selection )
+{
+    d_ptr->deleteSongs( selection );
+}
+
+/*!
+ Sets the suffle according to \a active.
+ */
+void MpMpxCollectionFrameworkWrapper::setShuffle( bool active )
+{
+    d_ptr->setShuffle( active );
+}
+
+/*!
+ Initiate a playback preview for the selected item.
+ */
+void MpMpxCollectionFrameworkWrapper::previewItem( int index )
+{
+    d_ptr->previewItem( index );
+}
+
+
+/*!
+ Opens the an isolated collection with \a context.
+ \sa isolatedCollectionOpened()
+ */
+void MpMpxCollectionFrameworkWrapper::openIsolatedCollection( TCollectionContext context )
+{
+       d_ptr->openIsolatedCollection( context );     
+}
+
+/*!
+ Releases the resources used for the isolated collection.
+ */
+void MpMpxCollectionFrameworkWrapper::releaseIsolatedCollection()
+{
+    d_ptr->releaseIsolatedCollection();
+}
+
+/*!
+ Returns pointer to MpMpxCollectionData, which is the collection data.
+ */
+MpMpxCollectionData *MpMpxCollectionFrameworkWrapper::collectionData()
+{
+    return d_ptr->collectionData();
+}
+
+/*!
+ Called from an engine slot to reopen the collection in its current state.
+
+ \sa collectionOpened()
+ */
+void MpMpxCollectionFrameworkWrapper::reopenCollection()
+{
+    d_ptr->reopenCollection();
+}
+
+/*!
+ Called from an engine slot to request a reorder operation , indicates that 
+ the item with \a playlistId , \a songId is to be moved from 
+ \a originalOrdinal to \a newOrdinal.
+ */
+void MpMpxCollectionFrameworkWrapper::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+    d_ptr->reorderPlaylist( playlistId, songId, originalOrdinal, newOrdinal );
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxcollectionframeworkwrapper_p.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,961 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx collection framework utilities - private implementation.
+*
+*/
+
+#include <QStringList>
+
+#include <s32strm.h>
+#include <s32mem.h>
+#include <apgcli.h>
+#include <apacmdln.h>
+
+#include <mpxplaybackutility.h>
+#include <mpxcollectionutility.h>
+#include <mpxharvesterutility.h>
+#include <mpxcollectionpath.h>
+#include <mpxcollectionmessage.h>
+#include <mpxcollectionplaylist.h>
+#include <mpxmessagecontainerdefs.h>
+#include <mpxmediacollectiondetaildefs.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxcollectionplugin.hrh>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxcollectionmessagedefs.h>
+#include <mpxparameter.h>
+#include <mpxcollectionhelperfactory.h>
+#include <mpxcollectionuihelper.h>
+#include <mpxcollectionopenutility.h>
+#include <mpxmediaarray.h>
+#include <mpxmedia.h>
+#include <mpxlog.h>
+
+#include "mpmpxcollectionframeworkwrapper_p.h"
+#include "mpmpxcollectionframeworkwrapper.h"
+#include "mpmpxcollectiondata.h"
+#include "mpcommondefs.h"
+#include "mptrace.h"
+#include "mpsettingsmanager.h"
+
+const TInt KIncrementalDelayNone = 0;
+const TInt KIncrementalDelayHalfSecond = 1000000;
+const TInt KIncrementalFetchBlockSize = 40;
+
+const TInt KMPXChunkSize = 100;  // number of songs added in each chunk, IncAddL
+_LIT( KPlaylistPath, "C:\\Data\\Playlists\\" ); // Todo
+
+/*!
+    \class MpMpxCollectionFrameworkWrapperPrivate
+    \brief Wrapper for mpx framework utilities - private implementation.
+
+    This is a private implementation of the mpx framework wrapper utilties interface.
+*/
+
+/*!
+ \internal
+ */
+MpMpxCollectionFrameworkWrapperPrivate::MpMpxCollectionFrameworkWrapperPrivate( MpMpxCollectionFrameworkWrapper *wrapper )
+    : q_ptr( wrapper ),
+      iCollectionUtility( 0 ),
+      iCollectionUiHelper( 0 ),
+      iIncrementalOpenUtil( 0 ),
+      iIsolatedCollectionHelper( 0 ),
+      iPlaybackUtility( 0 ),
+      iCollectionData( 0 ),
+      iIsolatedCollectionData( 0 ),
+      iFirstIncrementalOpen( EFalse ),
+      iUserPlaylists( 0 )
+{
+    TX_LOG
+}
+
+/*!
+ \internal
+ */
+MpMpxCollectionFrameworkWrapperPrivate::~MpMpxCollectionFrameworkWrapperPrivate()
+{
+    TX_ENTRY
+    delete iCollectionData;
+    delete iIsolatedCollectionData;
+
+    if ( iCollectionUtility ) {
+        iCollectionUtility->Collection().CancelRequest();
+        iCollectionUtility->Close();
+    }
+
+    if ( iCollectionUiHelper ) {
+        iCollectionUiHelper->Close();
+    }
+
+    if ( iPlaybackUtility ) {
+        iPlaybackUtility->Close();
+    }
+
+    delete iIncrementalOpenUtil;
+    delete iIsolatedCollectionHelper;
+    delete iUserPlaylists;
+
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::init( MpCommon::MpViewMode viewMode, TUid hostUid )
+{
+
+    iViewMode = viewMode;
+    mHostUid = hostUid;
+    TRAPD( err, DoInitL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::openCollection( TCollectionContext context )
+{
+    TRAPD( err, DoOpenCollectionL( context ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::openCollectionItem( int index )
+{
+    TRAPD( err, DoOpenCollectionItemL( index ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::reopenCollection()
+{
+    TRAPD( err, DoReopenCollectionL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::back()
+{
+    TRAPD( err, DoBackL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::findPlaylists( QStringList &playlists )
+{
+    TRAPD( err, DoFindPlaylistsL( playlists ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
+{
+    TRAPD( err, DoCreatePlaylistL( playlistName, selection, collectionData ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::saveToPlaylist( int playlistIndex, QList<int> &selection )
+{
+    TRAPD( err, DoSaveToPlaylistL( playlistIndex, selection ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+    TRAPD( err, DoSaveToCurrentPlaylistL( selection, collectionData ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+} 
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::deleteSongs( QList<int> &selection )
+{
+    TRAPD( err, DoDeleteSongsL( selection ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::renamePlaylist( QString &newName, int index )
+{      
+    TRAPD( err, DoRenamePlaylistL( newName, index ) );
+    if ( err != KErrNone ) {
+    TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::renamePlaylist( QString &newName )
+{      
+    TRAPD( err, DoRenamePlaylistL( newName ) );
+    if ( err != KErrNone ) {
+    TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::setShuffle( bool active )
+{
+    TRAPD( err, DoSetShuffleL( active ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::previewItem( int index )
+{
+    TRAPD( err, DoPreviewItemL( index ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+ void MpMpxCollectionFrameworkWrapperPrivate::openIsolatedCollection( TCollectionContext context )
+{
+    TRAPD( err, DoOpenIsolatedCollectionL( context ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::releaseIsolatedCollection()
+{
+    delete iIsolatedCollectionHelper;
+    iIsolatedCollectionHelper = 0;
+    delete iIsolatedCollectionData;
+    iIsolatedCollectionData = 0;
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+    TRAPD( err, DoReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+MpMpxCollectionData *MpMpxCollectionFrameworkWrapperPrivate::collectionData()
+{
+    return iCollectionData;
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleOpenL( 
+    const CMPXMedia& aEntries,
+    TInt aIndex,
+    TBool aComplete,
+    TInt aError )
+{
+    Q_UNUSED( aIndex );
+    TX_UNUSED( aComplete );
+    TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete );
+    if ( aError == KErrNone ) {
+        if ( iFirstIncrementalOpen ) {
+            iCollectionData->setMpxMedia( aEntries );
+            iFirstIncrementalOpen = EFalse;
+        }
+    }
+    else {
+        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleOpenL( 
+    const CMPXCollectionPlaylist& aPlaylist,
+    TInt aError )
+{
+    TX_ENTRY_ARGS( "aError=" << aError );
+
+    if ( aError == KErrNone ) {
+        if ( !iPlaybackUtility ) {
+
+            iPlaybackUtility = MMPXPlaybackUtility::UtilityL( mHostUid );
+
+            if ( iViewMode == MpCommon::DefaultView ) {
+                iPlaybackUtility->SetL( EPbPropertyRandomMode, MpSettingsManager::shuffle() ? ETrue : EFalse );
+                iPlaybackUtility->SetL( EPbPropertyRepeatMode, MpSettingsManager::repeat() ? EPbRepeatAll : EPbRepeatOff );
+            }
+        }
+        iPlaybackUtility->InitL( aPlaylist, ETrue );
+        emit q_ptr->collectionPlaylistOpened();
+    }
+    else {
+        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleCollectionMessage( 
+    CMPXMessage* aMsg,
+    TInt aErr )
+{
+    TX_ENTRY_ARGS( "aErr=" << aErr );
+    if ( aErr == KErrNone && aMsg )
+        {
+        TRAP_IGNORE( DoHandleCollectionMessageL( *aMsg ) );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleCollectionMediaL( 
+    const CMPXMedia& aMedia,
+    TInt aError )
+{
+    Q_UNUSED( aMedia );
+    Q_UNUSED( aError );
+}
+
+/*!
+ \internal
+ Handles the completion of any collection helper event.
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleOperationCompleteL( 
+    TCHelperOperation aOperation,
+    TInt aErr,
+    void* aArgument )
+{
+    TX_ENTRY_ARGS( "aErr=" << aErr );
+    switch( aOperation ) {
+    case EDeleteOp:
+        emit q_ptr->songsDeleted( KErrNone == aErr );
+        break;
+    case EAddOp:
+        emit q_ptr->playlistSaved( KErrNone == aErr );
+        break;
+    case ERenameOp:
+        emit q_ptr->playlistsRenamed( KErrNone == aErr );
+        break;
+    default:
+        break;
+    }
+
+    if ( aArgument ) {
+        delete ( CBase* )aArgument;
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
+{
+    TX_ENTRY_ARGS( "aError=" << aError );
+    if ( aError == KErrNone ) {
+        if ( iIsolatedCollectionData ) {
+            delete iIsolatedCollectionData;
+            iIsolatedCollectionData = 0;
+        }  
+        iIsolatedCollectionData = new MpMpxCollectionData();
+        iIsolatedCollectionData->setMpxMedia( aEntries );
+        emit q_ptr->isolatedCollectionOpened( iIsolatedCollectionData );
+    }
+    else {
+        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoInitL()
+{
+    TX_ENTRY
+    if ( iViewMode == MpCommon::FetchView ) {
+        iCollectionUtility = MMPXCollectionUtility::NewL( this, mHostUid );
+        iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL( mHostUid );
+        iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, mHostUid );
+    }
+    else {
+        iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault );
+        iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL();
+        iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this );
+    }
+    
+    iCollectionData = new MpMpxCollectionData();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoOpenCollectionL( 
+    TCollectionContext aContext )
+{
+    TX_ENTRY_ARGS( "aContext=" << aContext );
+
+    switch ( aContext ) {
+    case ECollectionContextAllSongs:
+        {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL();
+        CleanupStack::PushL( cpath );
+        iCollectionUtility->Collection().OpenL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+        break;
+        }
+    case ECollectionContextArtists:
+        {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
+        CleanupStack::PushL( cpath );
+        cpath->AppendL( 2 );
+        iCollectionUtility->Collection().OpenL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+        break;
+        }
+    case ECollectionContextAlbums:
+        {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
+        CleanupStack::PushL( cpath );
+        cpath->AppendL( 3 );
+        iCollectionUtility->Collection().OpenL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+        break;
+        }
+    case ECollectionContextPlaylists:
+        {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicPlaylistPathL();
+        CleanupStack::PushL( cpath );
+        iCollectionUtility->Collection().OpenL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+        break;
+        }
+    case ECollectionContextGenres:
+        {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
+        CleanupStack::PushL( cpath );
+        // Temp
+        cpath->AppendL( 5 );
+        iCollectionUtility->Collection().OpenL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+        break;
+        }
+    default:
+        TX_LOG_ARGS( "Error: Unexpected context; should never get here." );
+        break;
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoOpenCollectionItemL( TInt aIndex )
+    {
+    TX_ENTRY_ARGS( "aIndex=" << aIndex );
+    iCollectionUtility->Collection().OpenL( aIndex );
+    TX_EXIT
+    }
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoIncrementalOpenL()
+{
+    TX_ENTRY
+    // Cancel any reads
+    iIncrementalOpenUtil->Stop();
+
+    // Start the read
+    iFirstIncrementalOpen = ETrue;
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    TArray<TMPXAttribute> ary = attrs.Array();
+    iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
+    iIncrementalOpenUtil->StartL( ary, KIncrementalFetchBlockSize,
+                                  KErrNotFound, CMPXCollectionOpenUtility::EFetchNormal );
+    iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
+    CleanupStack::PopAndDestroy( &attrs );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoReopenCollectionL()
+{
+    TX_ENTRY
+    CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( cpath );
+    cpath->Back();
+    iCollectionUtility->Collection().OpenL( *cpath );
+    CleanupStack::PopAndDestroy( cpath );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoBackL()
+{
+    TX_ENTRY
+    iCollectionUtility->Collection().BackL();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoFindPlaylistsL( QStringList &playlists )
+{
+    TX_ENTRY
+    delete iUserPlaylists;
+    iUserPlaylists = NULL;
+
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    attrs.Append( KMPXMediaGeneralId );
+    attrs.Append( KMPXMediaGeneralTitle );
+
+    CMPXMedia* criteria = CMPXMedia::NewL();
+    CleanupStack::PushL( criteria );
+    criteria->SetTObjectValueL<TMPXGeneralType>( 
+        KMPXMediaGeneralType, EMPXGroup );
+    criteria->SetTObjectValueL<TMPXGeneralCategory>( 
+        KMPXMediaGeneralCategory, EMPXPlaylist );
+
+    // Look up collection UID and set to criteria
+    RArray<TUid> ary;
+    CleanupClosePushL( ary );
+    ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
+    TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
+    CleanupStack::PopAndDestroy( &ary );
+
+    criteria->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection );
+
+    iUserPlaylists = iCollectionUtility->Collection().FindAllL( *criteria, attrs.Array() );
+    CleanupStack::PopAndDestroy( criteria );
+    CleanupStack::PopAndDestroy( &attrs );
+
+    if ( iUserPlaylists ) {
+        const CMPXMediaArray* mediaArray =
+            iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+        User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
+        TInt count = mediaArray->Count();
+        for ( TInt i = 0; i < count; i++ ) {
+            CMPXMedia* media( mediaArray->AtL( i ) );
+            const TDesC& titleText = media->ValueText( KMPXMediaGeneralTitle );
+            if ( titleText.Compare( KNullDesC ) != 0 ) {
+            playlists += QString::fromUtf16( titleText.Ptr(), titleText.Length() );
+            }
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
+{
+    TX_ENTRY_ARGS( "playlistName=" << playlistName );
+    CMPXMedia* tracks = CMPXMedia::NewL();
+    CleanupStack::PushL( tracks );
+
+    TPtrC ptr( reinterpret_cast<const TText*>( playlistName.constData() ) );
+    tracks->SetTextValueL( KMPXMediaGeneralTitle, ptr );
+    tracks->SetTextValueL( KMPXMediaGeneralUri, KPlaylistPath );
+    //if collection data is not provided we use the browsing collection.
+    PreparePlaylistMediaL( *tracks, selection, collectionData ? collectionData : iCollectionData );
+
+    iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
+    CleanupStack::PopAndDestroy( tracks );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+    TX_ENTRY_ARGS( "playlistId=" << int( playlistId ) );
+    
+    CMPXMedia* tracks = CMPXMedia::NewL();
+    CleanupStack::PushL( tracks );
+
+    RArray<TUid> ary;
+    CleanupClosePushL( ary );
+    ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
+    TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
+    CleanupStack::PopAndDestroy( &ary );
+
+    tracks->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, playlistId );
+    tracks->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection );
+    PreparePlaylistMediaL( *tracks, selection, collectionData );
+
+    iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
+    CleanupStack::PopAndDestroy( tracks );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToPlaylistL( int playlistIndex, QList<int> &selection )
+{
+    TX_ENTRY_ARGS( "playlistIndex=" << playlistIndex );
+
+    const CMPXMediaArray* mediaArray =  iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
+    CMPXMedia* media( mediaArray->AtL( playlistIndex ) );
+    TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
+    DoSaveToPlaylistL( playlistId, selection, iCollectionData );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData )
+{
+    TX_ENTRY
+
+    const CMPXMedia& container = iCollectionData->containerMedia();
+    if ( container.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) != EMPXItem && 
+        container.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) != EMPXPlaylist) {
+        User::Leave( KErrArgument );
+    }
+    TMPXItemId playlistId( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+    DoSaveToPlaylistL( playlistId, selection, collectionData );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoDeleteSongsL( QList<int> &selection )
+{
+    int count = selection.count();
+    TX_ENTRY_ARGS( "selection count=" << count );
+
+    CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() );
+    CleanupStack::PushL( path );
+
+    for ( TInt i = 0; i < count; i++ ) {
+        path->SelectL( selection.at( i ) );
+    }
+    iCollectionUiHelper->DeleteL( *path, this );
+    CleanupStack::PopAndDestroy( path );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName, int index )
+{
+    TX_ENTRY
+    CMPXMediaArray *mediaArray;  
+    const CMPXMedia& container = iCollectionData->containerMedia();
+    mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+    CMPXMedia* currentPlaylistMedia( mediaArray->AtL( index ) );
+    TMPXItemId id( currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+    DoRenamePlaylistL( id, newName );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName )
+{
+    TX_ENTRY
+    const CMPXMedia& container = iCollectionData->containerMedia();
+    TMPXItemId id( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+    DoRenamePlaylistL( id, newName );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( TMPXItemId id, QString &newName )
+ {
+     CMPXMedia* media = CMPXMedia::NewL();
+     CleanupStack::PushL( media );
+     media->SetTObjectValueL<TMPXGeneralType>( 
+     KMPXMediaGeneralType, EMPXItem );
+     media->SetTObjectValueL<TMPXGeneralCategory>( 
+     KMPXMediaGeneralCategory, EMPXPlaylist );
+     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
+     TPtrC ptr( reinterpret_cast<const TText*>( newName.constData() ) );
+     media->SetTextValueL( KMPXMediaGeneralTitle, ptr );
+     iCollectionUiHelper->RenameL( *media, this );
+     CleanupStack::PopAndDestroy( media );
+ }     
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoSetShuffleL( bool active )
+{
+    TX_ENTRY
+    if ( iPlaybackUtility ) {
+        iPlaybackUtility->SetL( EPbPropertyRandomMode, active );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoPreviewItemL( int index )
+{
+    TX_ENTRY
+    if ( !iPlaybackUtility ) {
+        iPlaybackUtility = MMPXPlaybackUtility::UtilityL( mHostUid );
+    }
+
+    // Get the current path
+    CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( cpath );
+    MPX_DEBUG_PATH( *cpath );
+    cpath->Back();
+
+    CMPXMediaArray *mediaArray;
+    const CMPXMedia& container = iCollectionData->containerMedia();
+    mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+    CMPXMedia* currentMedia( mediaArray->AtL( index ) );
+    TMPXItemId id( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+
+    cpath->AppendL( id ); // Top level items of songs
+    cpath->Set( 0 ); // Select 1st song
+
+    CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath );
+    CleanupStack::PushL( playList );
+    playList->SetToFirst();
+
+    iPlaybackUtility->InitL( *playList, ETrue );
+    emit q_ptr->collectionPlaylistOpened();
+
+    CleanupStack::PopAndDestroy( playList );
+    CleanupStack::PopAndDestroy( cpath );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoOpenIsolatedCollectionL( TCollectionContext context )
+{
+
+    if ( ECollectionContextAllSongs == context ) {
+        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL();
+        CleanupStack::PushL( cpath );
+        if ( !iIsolatedCollectionHelper ) {
+            iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( this );
+        }   
+        iIsolatedCollectionHelper->OpenCollectionL( *cpath );
+        CleanupStack::PopAndDestroy( cpath );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal )
+{
+    iCollectionUiHelper->ReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal, this );           
+}
+
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::DoHandleCollectionMessageL( 
+    const CMPXMessage& aMsg )
+{
+    TX_ENTRY
+    TMPXMessageId id( aMsg.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
+    if ( KMPXMessageGeneral == id ) {
+        TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
+        TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
+        TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
+        TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data );
+
+        if ( event == TMPXCollectionMessage::EPathChanged &&
+             type == EMcPathChangedByOpen &&
+             data == EMcContainerOpened ) {
+            // Incremental Open when browsing to the next level
+            DoIncrementalOpenL();
+        }
+        else if ( event == TMPXCollectionMessage::EPathChanged &&
+                  type == EMcPathChangedByOpen &&
+                  data == EMcItemOpened ) {
+            // Opened a song
+            // This will result in HandleOpenL with CMPXCollectionPlaylist
+            iCollectionUtility->Collection().OpenL();
+        }
+    }
+    TX_EXIT
+}
+
+
+/*!
+ \internal
+ */
+void MpMpxCollectionFrameworkWrapperPrivate::PreparePlaylistMediaL( 
+        CMPXMedia& aMedia,
+        QList<int> &selection,
+        MpMpxCollectionData *collectionData )
+{
+    int count = selection.count();
+    TX_ENTRY_ARGS( "selection count=" << count );
+
+    const CMPXMedia& container = collectionData->containerMedia();
+    const CMPXMediaArray* containerArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ) );
+    CMPXMediaArray* tracksArray( CMPXMediaArray::NewL() );
+    CleanupStack::PushL( tracksArray );
+
+    CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() );
+    CleanupStack::PushL( path );
+    TMPXItemId collectionId( path->Id( 0 ) );
+    CleanupStack::PopAndDestroy( path );
+
+    if ( collectionData->context() == ECollectionContextAlbums ) {
+        for ( TInt i = 0; i < count; i++ ) {
+            CMPXMedia* results;
+            CMPXMedia* album( containerArray->AtL( selection[i] ) );
+            // Fetch the songs for the selected album
+            TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
+            CMPXMedia* findCriteria = CMPXMedia::NewL();
+            CleanupStack::PushL( findCriteria );
+            findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );
+            findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong );
+            findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, albumId );
+            RArray<TMPXAttribute> attrs;
+            CleanupClosePushL( attrs );
+            attrs.Append( TMPXAttribute( KMPXMediaIdGeneral,
+                                         EMPXMediaGeneralTitle |
+                                         EMPXMediaGeneralId ) );
+            attrs.Append( KMPXMediaMusicAlbumTrack );
+            results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array() );
+            CleanupStack::PopAndDestroy( &attrs );
+            CleanupStack::PopAndDestroy( findCriteria );
+            CleanupStack::PushL( results );
+            
+            const CMPXMediaArray* resultsArray = results->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+            User::LeaveIfNull( resultsArray );
+            for ( int j = 0 ; j < resultsArray->Count();j++ ) {
+                CMPXMedia* media( resultsArray->AtL( j ) );
+                CMPXMedia* entry = CMPXMedia::NewL();
+                CleanupStack::PushL( entry );
+                entry->SetTextValueL( KMPXMediaGeneralTitle,
+                    media->ValueText( KMPXMediaGeneralTitle ) );
+                entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
+                entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
+                entry->SetTObjectValueL( KMPXMediaGeneralId,
+                    media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+                entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
+                CleanupStack::Pop( entry );
+                tracksArray->AppendL( entry );
+            }
+            CleanupStack::PopAndDestroy( results );
+        }
+        
+    }
+    else {   
+        for ( TInt i = 0; i < count; i++ ) {
+            CMPXMedia* media( containerArray->AtL( selection.at( i ) ) );
+            CMPXMedia* entry = CMPXMedia::NewL();
+            CleanupStack::PushL( entry );
+            entry->SetTextValueL( KMPXMediaGeneralTitle,
+                media->ValueText( KMPXMediaGeneralTitle ) );
+            entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
+            entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
+            entry->SetTObjectValueL( KMPXMediaGeneralId,
+                media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
+            entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
+            CleanupStack::Pop( entry );
+            tracksArray->AppendL( entry );
+        }
+    }
+    aMedia.SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXItem );
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXPlaylist );
+    aMedia.SetCObjectValueL( KMPXMediaArrayContents, tracksArray );
+    aMedia.SetTObjectValueL( KMPXMediaArrayCount, tracksArray->Count() );
+
+    CleanupStack::PopAndDestroy( tracksArray );
+    TX_EXIT
+}
--- a/mpengine/src/mpmpxframeworkwrapper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities.
-*
-*/
-
-#include "mpmpxframeworkwrapper.h"
-#include "mpmpxframeworkwrapper_p.h"
-
-/*!
-    \class MpMpxFrameworkWrapper
-    \brief Wrapper for mpx framework utilities.
-
-    MPX framework wrapper provides Qt style interface to the MPX framework
-    utilities. Its implementation is hidden using private class data pattern.
-*/
-
-/*!
-    \fn void scanStarted()
-
-    This signal is emitted when scan operation is started.
-
- */
-
-/*!
-    \fn void scanEnded( int count, int error )
-
-    This signal is emitted when scan operation ends. It indicates the number
-    of songs added and whether there was an error.
-
- */
-
-/*!
-    \fn void scanCountChanged( int count )
-
-    This signal is emitted when scan count is updated.
-
- */
-
-/*!
-    \fn void diskEvent( MpxDiskEvent event )
-
-    This signal is emitted when a disk event is received from MPX framework.
-
- */
-
- /*!
-     \fn void usbEvent( MpxUsbEvent event )
-
-     This signal is emitted when an USB event is received from MPX framework.
-
- */
-
-/*!
- Constructs the utility wrapper.
- */
-MpMpxFrameworkWrapper::MpMpxFrameworkWrapper( QObject *parent )
-    : QObject( parent )
-{
-    d_ptr = new MpMpxFrameworkWrapperPrivate( this );
-    d_ptr->init();
-}
-
-/*!
- Destructs the utility wrapper.
- */
-MpMpxFrameworkWrapper::~MpMpxFrameworkWrapper()
-{
-    delete d_ptr;
-}
-
-/*!
- Initiates song scanning.
- */
-void MpMpxFrameworkWrapper::scan()
-{
-    d_ptr->scan();
-}
-
-/*!
- Cancels ongoing song scanning.
- */
-void MpMpxFrameworkWrapper::cancelScan()
-{
-    d_ptr->cancelScan();
-}
-
--- a/mpengine/src/mpmpxframeworkwrapper_p.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,297 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities - private implementation.
-*
-*/
-
-#include <QStringList>
-
-#include <s32strm.h>
-#include <s32mem.h>
-#include <apgcli.h>
-#include <apacmdln.h>
-
-#include <mpxcollectionutility.h>
-#include <mpxharvesterutility.h>
-#include <mpxcollectionmessage.h>
-#include <mpxmessagecontainerdefs.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxcollectionmessagedefs.h>
-#include <mpxlog.h>
-
-#include "mpmpxframeworkwrapper.h"
-#include "mpmpxframeworkwrapper_p.h"
-#include "mptrace.h"
-
-/*!
-    \class MpMpxFrameworkWrapperPrivate
-    \brief Wrapper for mpx framework utilities - private implementation.
-
-    This is a private implementation of the mpx framework wrapper utilties interface.
-*/
-
-const int NoPreviousBroadCastMsg = -1;
-
-/*!
- \internal
- */
-MpMpxFrameworkWrapperPrivate::MpMpxFrameworkWrapperPrivate( MpMpxFrameworkWrapper *wrapper )
-    : q_ptr(wrapper),
-      iCollectionUtility(0),
-      iHarvesterUtility(0),
-      iNumItemsAdded(0),
-      iScanning( EFalse ),
-      iPreviousBroadCastMsg( NoPreviousBroadCastMsg )
-{
-    TX_LOG
-}
-
-/*!
- \internal
- */
-MpMpxFrameworkWrapperPrivate::~MpMpxFrameworkWrapperPrivate()
-{
-    TX_ENTRY
-    if ( iCollectionUtility ) {
-        iCollectionUtility->Collection().CancelRequest();
-        iCollectionUtility->Close();
-    }
-
-    if ( iHarvesterUtility ) {
-        iHarvesterUtility->Close();
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::init()
-{
-    TRAPD( err, DoInitL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::scan()
-{
-    TRAPD( err, DoScanL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::cancelScan()
-{
-    TRAPD( err, DoCancelScanL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleOpenL(
-    const CMPXMedia& aEntries,
-    TInt aIndex,
-    TBool aComplete,
-    TInt aError )
-{
-    Q_UNUSED( aIndex );
-    Q_UNUSED( aComplete );
-    Q_UNUSED( aError );
-    Q_UNUSED( aEntries );
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleOpenL(
-    const CMPXCollectionPlaylist& aPlaylist,
-    TInt aError )
-{
-    Q_UNUSED( aPlaylist );
-    Q_UNUSED( aError );
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMediaL(
-    const CMPXMedia& aMedia,
-    TInt aError )
-{
-    Q_UNUSED( aMedia );
-    Q_UNUSED( aError );
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMessage(
-    CMPXMessage* aMsg,
-    TInt aErr )
-{
-    TX_ENTRY_ARGS( "aErr=" << aErr );
-    if ( aErr == KErrNone && aMsg ) {
-        TRAP_IGNORE( DoHandleCollectionMessageL(*aMsg) );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoInitL()
-{
-    TX_ENTRY
-    iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault );
-
-    iHarvesterUtility = CMPXHarvesterFactory::NewL();
-    iHarvesterUtility->CheckForSystemEventsL();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoScanL()
-{
-    TX_ENTRY
-    iNumItemsAdded = 0;
-    iHarvesterUtility->ScanL();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoCancelScanL()
-{
-    TX_ENTRY
-    // If harvester crashes, restart it.
-    TRAPD( err, iHarvesterUtility->CancelScanL() );
-    if ( err != KErrNone ) {
-        iHarvesterUtility->Close();
-        iHarvesterUtility = NULL;
-        iHarvesterUtility = CMPXHarvesterFactory::NewL();
-        iHarvesterUtility->CheckForSystemEventsL();
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoHandleCollectionMessageL(
-    const CMPXMessage& aMsg )
-{
-    TX_ENTRY
-    TMPXMessageId id( aMsg.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
-    if ( KMPXMessageGeneral == id ) {
-        TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
-        TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
-        TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
-        TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data );
-
-        if ( event == TMPXCollectionMessage::EBroadcastEvent &&
-            BroadcastEventFilter( type ) ) {
-            switch ( type ) {
-                case EMcMsgFormatStart:
-                    emit q_ptr->diskEvent(DiskFormatStarted);
-                    break;
-                case EMcMsgFormatEnd:
-                    emit q_ptr->diskEvent(DiskFormatEnded);
-                    break;
-                case EMcMsgDiskRemoved:
-                    emit q_ptr->diskEvent(DiskRemoved);
-                    break;
-                case EMcMsgDiskInserted:
-                    emit q_ptr->diskEvent(DiskInserted);
-                    break;
-                case EMcMsgUSBMassStorageStart:
-                    emit q_ptr->usbEvent(UsbMassStorageStarted);
-                    break;
-                case EMcMsgUSBMassStorageEnd:
-                    emit q_ptr->usbEvent(UsbMassStorageEnded);
-                    break;
-                case EMcMsgUSBMTPStart:
-                    emit q_ptr->usbEvent(UsbMtpStarted);
-                    break;
-                case EMcMsgUSBMTPEnd:
-                    emit q_ptr->usbEvent(UsbMtpEnded);
-                    break;
-                case EMcMsgUSBMTPNotActive:
-                    emit q_ptr->usbEvent(UsbMtpNotActive);
-                    break;
-                case EMcMsgRefreshStart:
-                    iScanning = ETrue;
-                    emit q_ptr->scanStarted();
-                    break;
-                case EMcMsgRefreshEnd:
-                    iScanning = EFalse;
-                    emit q_ptr->scanEnded( iNumItemsAdded, data );
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-    else if( KMPXMessageIdItemChanged == id && iScanning ) {
-        if ( aMsg.IsSupported( KMPXMessageArrayContents ) ) {
-            // Loop through messages for arrays
-            const CMPXMessageArray* messageArray =
-                        aMsg.Value<CMPXMessageArray>( KMPXMessageArrayContents );
-            User::LeaveIfNull( const_cast<CMPXMessageArray*>( messageArray ) );
-
-            for ( TInt i=0; i<messageArray->Count(); ++i ) {
-                  HandleCollectionMessage( messageArray->AtL( i ), KErrNone );
-            }
-            emit q_ptr->scanCountChanged( iNumItemsAdded );
-        }
-        else {
-            // Single item
-            TMPXChangeEventType changeType( aMsg.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
-            TMPXGeneralCategory cat( aMsg.ValueTObjectL<TMPXGeneralCategory>( KMPXMessageMediaGeneralCategory ) );
-            if( changeType == EMPXItemInserted &&
-                ( cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast ) ) {
-                iNumItemsAdded++;
-            }
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- Returns false if same event has been received more than once
- */
-TBool MpMpxFrameworkWrapperPrivate::BroadcastEventFilter( TInt aMsg )
-{
-    if ( aMsg != iPreviousBroadCastMsg ) {
-        iPreviousBroadCastMsg = aMsg;
-        return true;
-    }
-
-    return false;    
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxharvesterframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx harvester framework utilities.
+*
+*/
+
+#include "mpmpxharvesterframeworkwrapper.h"
+#include "mpmpxharvesterframeworkwrapper_p.h"
+
+/*!
+    \class MpMpxHarvesterFrameworkWrapper
+    \brief Wrapper for mpx framework utilities.
+
+    MPX harvester framework wrapper provides Qt style interface to the MPX harvester framework
+    utilities. Its implementation is hidden using private class data pattern.
+*/
+
+/*!
+    \fn void scanStarted()
+
+    This signal is emitted when scan operation is started.
+
+ */
+
+/*!
+    \fn void scanEnded( int count, int error )
+
+    This signal is emitted when scan operation ends. It indicates the number
+    of songs added and whether there was an error.
+
+ */
+
+/*!
+    \fn void scanCountChanged( int count )
+
+    This signal is emitted when scan count is updated.
+
+ */
+
+/*!
+    \fn void diskEvent( MpxDiskEvent event )
+
+    This signal is emitted when a disk event is received from MPX framework.
+
+ */
+
+ /*!
+     \fn void usbEvent( MpxUsbEvent event )
+
+     This signal is emitted when an USB event is received from MPX framework.
+
+ */
+
+/*!
+ Constructs the utility wrapper.
+ */
+MpMpxHarvesterFrameworkWrapper::MpMpxHarvesterFrameworkWrapper( MpCommon::MpViewMode viewMode, TUid hostUid, QObject *parent )
+    : QObject( parent )
+{
+    d_ptr = new MpMpxHarvesterFrameworkWrapperPrivate( this );
+    d_ptr->init( viewMode, hostUid );
+}
+
+/*!
+ Destructs the utility wrapper.
+ */
+MpMpxHarvesterFrameworkWrapper::~MpMpxHarvesterFrameworkWrapper()
+{
+    delete d_ptr;
+}
+
+/*!
+ Initiates song scanning.
+ */
+void MpMpxHarvesterFrameworkWrapper::scan()
+{
+    d_ptr->scan();
+}
+
+/*!
+ Cancels ongoing song scanning.
+ */
+void MpMpxHarvesterFrameworkWrapper::cancelScan()
+{
+    d_ptr->cancelScan();
+}
+
+/*!
+ Request Harvester to check if there are any system events active.
+ */
+void MpMpxHarvesterFrameworkWrapper::checkForSystemEvents()
+{
+    d_ptr->checkForSystemEvents();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxharvesterframeworkwrapper_p.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,327 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Wrapper for mpx harvester framework utilities - private implementation.
+*
+*/
+
+#include <QStringList>
+
+#include <s32strm.h>
+#include <s32mem.h>
+#include <apgcli.h>
+#include <apacmdln.h>
+
+#include <mpxcollectionutility.h>
+#include <mpxharvesterutility.h>
+#include <mpxcollectionmessage.h>
+#include <mpxmessagecontainerdefs.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxcollectionmessagedefs.h>
+#include <mpxlog.h>
+
+#include "mpmpxharvesterframeworkwrapper.h"
+#include "mpmpxharvesterframeworkwrapper_p.h"
+#include "mptrace.h"
+
+/*!
+    \class MpMpxHarvesterFrameworkWrapperPrivate
+    \brief Wrapper for mpx harvester framework utilities - private implementation.
+
+    This is a private implementation of the mpx harvester framework wrapper utilties interface.
+*/
+
+const int NoPreviousBroadCastMsg = -1;
+
+/*!
+ \internal
+ */
+MpMpxHarvesterFrameworkWrapperPrivate::MpMpxHarvesterFrameworkWrapperPrivate( MpMpxHarvesterFrameworkWrapper *wrapper )
+    : q_ptr(wrapper),
+      iCollectionUtility(0),
+      iHarvesterUtility(0),
+      iNumItemsAdded(0),
+      iScanning( EFalse ),
+      iPreviousBroadCastMsg( NoPreviousBroadCastMsg )
+{
+    TX_LOG
+}
+
+/*!
+ \internal
+ */
+MpMpxHarvesterFrameworkWrapperPrivate::~MpMpxHarvesterFrameworkWrapperPrivate()
+{
+    TX_ENTRY
+    if ( iCollectionUtility ) {
+        iCollectionUtility->Collection().CancelRequest();
+        iCollectionUtility->Close();
+    }
+
+    if ( iHarvesterUtility ) {
+        iHarvesterUtility->Close();
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::init( MpCommon::MpViewMode viewMode, TUid hostUid )
+{
+    iViewMode = viewMode;
+    mHostUid = hostUid;
+    TRAPD( err, DoInitL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::scan()
+{
+    TRAPD( err, DoScanL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::cancelScan()
+{
+    TRAPD( err, DoCancelScanL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::checkForSystemEvents()
+{
+    TRAPD( err, DoCheckForSystemEventsL() );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::HandleOpenL(
+    const CMPXMedia& aEntries,
+    TInt aIndex,
+    TBool aComplete,
+    TInt aError )
+{
+    Q_UNUSED( aIndex );
+    Q_UNUSED( aComplete );
+    Q_UNUSED( aError );
+    Q_UNUSED( aEntries );
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::HandleOpenL(
+    const CMPXCollectionPlaylist& aPlaylist,
+    TInt aError )
+{
+    Q_UNUSED( aPlaylist );
+    Q_UNUSED( aError );
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::HandleCollectionMediaL(
+    const CMPXMedia& aMedia,
+    TInt aError )
+{
+    Q_UNUSED( aMedia );
+    Q_UNUSED( aError );
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::HandleCollectionMessage(
+    CMPXMessage* aMsg,
+    TInt aErr )
+{
+    TX_ENTRY_ARGS( "aErr=" << aErr );
+    if ( aErr == KErrNone && aMsg ) {
+        TRAP_IGNORE( DoHandleCollectionMessageL(*aMsg) );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::DoInitL()
+{
+    TX_ENTRY
+    if ( iViewMode == MpCommon::FetchView ) {
+        iCollectionUtility = MMPXCollectionUtility::NewL( this, mHostUid );
+    }
+    else {
+        iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault );
+    }
+    iHarvesterUtility = CMPXHarvesterFactory::NewL();
+    iHarvesterUtility->CheckForSystemEventsL();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::DoScanL()
+{
+    TX_ENTRY
+    iNumItemsAdded = 0;
+    iHarvesterUtility->ScanL();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::DoCancelScanL()
+{
+    TX_ENTRY
+    // If harvester crashes, restart it.
+    TRAPD( err, iHarvesterUtility->CancelScanL() );
+    if ( err != KErrNone ) {
+        iHarvesterUtility->Close();
+        iHarvesterUtility = NULL;
+        iHarvesterUtility = CMPXHarvesterFactory::NewL();
+        iHarvesterUtility->CheckForSystemEventsL();
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::DoHandleCollectionMessageL(
+    const CMPXMessage& aMsg )
+{
+    TX_ENTRY
+    TMPXMessageId id( aMsg.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
+    if ( KMPXMessageGeneral == id ) {
+        TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
+        TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
+        TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
+        TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data );
+
+        if ( event == TMPXCollectionMessage::EBroadcastEvent &&
+            BroadcastEventFilter( type ) ) {
+            switch ( type ) {
+                case EMcMsgFormatStart:
+                    emit q_ptr->diskEvent(DiskFormatStarted);
+                    break;
+                case EMcMsgFormatEnd:
+                    emit q_ptr->diskEvent(DiskFormatEnded);
+                    break;
+                case EMcMsgDiskRemoved:
+                    emit q_ptr->diskEvent(DiskRemoved);
+                    break;
+                case EMcMsgDiskInserted:
+                    emit q_ptr->diskEvent(DiskInserted);
+                    break;
+                case EMcMsgUSBMassStorageStart:
+                    emit q_ptr->usbEvent(UsbMassStorageStarted);
+                    break;
+                case EMcMsgUSBMassStorageEnd:
+                    emit q_ptr->usbEvent(UsbMassStorageEnded);
+                    break;
+                case EMcMsgUSBMTPStart:
+                    emit q_ptr->usbEvent(UsbMtpStarted);
+                    break;
+                case EMcMsgUSBMTPEnd:
+                    emit q_ptr->usbEvent(UsbMtpEnded);
+                    break;
+                case EMcMsgUSBMTPNotActive:
+                    emit q_ptr->usbEvent(UsbMtpNotActive);
+                    break;
+                case EMcMsgRefreshStart:
+                    iScanning = ETrue;
+                    emit q_ptr->scanStarted();
+                    break;
+                case EMcMsgRefreshEnd:
+                    iScanning = EFalse;
+                    emit q_ptr->scanEnded( iNumItemsAdded, data );
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+    else if( KMPXMessageIdItemChanged == id && iScanning ) {
+        if ( aMsg.IsSupported( KMPXMessageArrayContents ) ) {
+            // Loop through messages for arrays
+            const CMPXMessageArray* messageArray =
+                        aMsg.Value<CMPXMessageArray>( KMPXMessageArrayContents );
+            User::LeaveIfNull( const_cast<CMPXMessageArray*>( messageArray ) );
+
+            for ( TInt i=0; i<messageArray->Count(); ++i ) {
+                  HandleCollectionMessage( messageArray->AtL( i ), KErrNone );
+            }
+            emit q_ptr->scanCountChanged( iNumItemsAdded );
+        }
+        else {
+            // Single item
+            TMPXChangeEventType changeType( aMsg.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
+            TMPXGeneralCategory cat( aMsg.ValueTObjectL<TMPXGeneralCategory>( KMPXMessageMediaGeneralCategory ) );
+            if( changeType == EMPXItemInserted &&
+                ( cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast ) ) {
+                iNumItemsAdded++;
+            }
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ Returns false if same event has been received more than once
+ */
+TBool MpMpxHarvesterFrameworkWrapperPrivate::BroadcastEventFilter( TInt aMsg )
+{
+    TX_ENTRY_ARGS( "New msg=" << aMsg << ", Prev. msg=" << iPreviousBroadCastMsg );
+    if ( aMsg != iPreviousBroadCastMsg ) {
+        iPreviousBroadCastMsg = aMsg;
+        return true;
+    }
+
+    return false;    
+}
+
+/*!
+ \internal
+ Request Harvester to check if there are any system events active.
+ */
+void MpMpxHarvesterFrameworkWrapperPrivate::DoCheckForSystemEventsL()
+{
+    TX_ENTRY
+    iPreviousBroadCastMsg = NoPreviousBroadCastMsg;    
+    iHarvesterUtility->CheckForSystemEventsL();
+    TX_EXIT
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxisolatedcollectionhelper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolated collection helper.
+*
+*/
+
+
+#include <mpxcollectionhelperfactory.h>
+#include <mpxcollectionuihelper.h>
+#include <mpxcollectionopenutility.h>
+
+#include "mpmpxisolatedcollectionhelper.h"
+#include "mpxlog.h"
+
+
+
+const TInt KIncrementalDelayNone = 0;
+const TInt KIncrementalDelayHalfSecond = 1000000;
+const TInt KIncrementalFetchBlockSize = 20;
+const TInt KIncrementalNullOffset = 0;
+
+
+/*!
+    \class CMpMpxIsolatedCollectionHelper
+    \brief Helper class to open an isolated collection.
+
+    This is a helper class to open an insolated collection.
+*/
+
+/*!
+ \internal
+ Two-phased constructor.
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    {
+    CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+/*!
+ \internal
+ Two-phased constructor.
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    {
+    CMpMpxIsolatedCollectionHelper* self =
+            new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+/*!
+ \internal
+ Destructor
+ */
+CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
+    {
+    delete iIncrementalOpenUtil;
+    }
+    
+
+/*!
+ \internal
+ Opens an isolated collection with the /a path.
+ */
+void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath )
+    {
+    //Using incremental open to open the collection.
+    
+    // Cancel any reads
+    iIncrementalOpenUtil->Stop();
+
+    // Start the read
+    iFirstIncrementalOpen = ETrue;
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    TArray<TMPXAttribute> ary = attrs.Array();
+    iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
+    iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
+                                  KIncrementalNullOffset, CMPXCollectionOpenUtility::EFetchNormal );
+    iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
+    CleanupStack::PopAndDestroy( &attrs );
+    }
+
+/*!
+ \internal
+ c++ Contructor
+ */
+CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    : iObserver( aObserver ),
+      iIncrementalOpenUtil( 0 ),
+      iFirstIncrementalOpen( EFalse )
+    {
+    }
+
+/*!
+ \internal
+ Leaving constructor
+ */
+void CMpMpxIsolatedCollectionHelper::ConstructL()
+    {
+    iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
+
+    }
+
+
+/*!
+ \internal
+ reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
+    const CMPXMedia& aEntries,
+    TInt /*aIndex*/,
+    TBool /*aComplete*/,
+    TInt aError )
+    {
+    if ( iFirstIncrementalOpen )
+        {
+        iObserver->HandleIsolatedOpenL( aEntries, aError );
+        iFirstIncrementalOpen = EFalse;
+        }
+    }
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
+    const CMPXCollectionPlaylist& /*aPlaylist*/,
+    TInt /*aError*/ )
+    {
+    }
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage( 
+    CMPXMessage* /*aMsg*/,
+    TInt /*aErr*/ )
+    {
+    }
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL( 
+    const CMPXMedia& /*aMedia*/,
+    TInt /*aError*/ )
+    {
+    }
+    
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxplaybackframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Framework wraper for Playback Utility.
+*
+*/
+
+
+#include "mpmpxplaybackframeworkwrapper.h"
+#include "mpmpxplaybackframeworkwrapper_p.h"
+#include "mptrace.h"
+
+/*!
+    \class MpMpxPlaybackFrameworkWrapper
+    \brief Wrapper for mpx framework utilities.
+
+    MPX framework wrapper provides Qt style interface to the MPX framework
+    utilities. Its implementation is hidden using private class data pattern.
+*/
+
+/*!
+ Constructs the utility wrapper.
+ */
+MpMpxPlaybackFrameworkWrapper::MpMpxPlaybackFrameworkWrapper( MpCommon::MpViewMode viewMode, TUid hostUid, QObject *parent )
+    : QObject(parent)
+{
+    d_ptr = new MpMpxPlaybackFrameworkWrapperPrivate(this );
+    d_ptr->init( viewMode, hostUid );
+}
+
+/*!
+ Destructs the utility wrapper.
+ */
+MpMpxPlaybackFrameworkWrapper::~MpMpxPlaybackFrameworkWrapper()
+{
+    delete d_ptr;
+}
+
+/*!
+ Returns pointer to MpPlaybackData, which is the playback data.
+ */
+MpPlaybackData *MpMpxPlaybackFrameworkWrapper::playbackData()
+{
+    return d_ptr->playbackData();
+}
+
+/*!
+ Slot to handle a play from Uri aFilename
+ */
+void MpMpxPlaybackFrameworkWrapper::play( QString aFilename )
+{
+    d_ptr->play( aFilename );
+}
+
+/*!
+ Slot to handle a play from file handle
+ */
+void MpMpxPlaybackFrameworkWrapper::play( const XQSharableFile& file)
+{
+    d_ptr->play( file );
+}
+
+/*!
+ Slot to handle a play pause.
+ */
+void MpMpxPlaybackFrameworkWrapper::playPause()
+{
+    d_ptr->playPause();
+}
+
+/*!
+ Slot to handle a stop.
+ */
+void MpMpxPlaybackFrameworkWrapper::stop()
+{
+    d_ptr->stop();
+}
+
+/*!
+ Slot to handle a skeep forward.
+ */
+void MpMpxPlaybackFrameworkWrapper::skipForward()
+{
+    d_ptr->skipForward();
+}
+
+/*!
+ Slot to handle a skeep backwards.
+ */
+void MpMpxPlaybackFrameworkWrapper::skipBackward()
+{
+    d_ptr->skipBackward();
+}
+
+/*!
+ Slot to handle a request to change \a position.
+ */
+void MpMpxPlaybackFrameworkWrapper::setPosition( int position )
+{
+    d_ptr->setPosition( position );
+}
+
+/*!
+ Slot to handle a request to change shuffle \a mode.
+ */
+void MpMpxPlaybackFrameworkWrapper::setShuffle( bool mode )
+{
+    d_ptr->setShuffle( mode );
+}
+
+/*!
+ Slot to handle a request to change repeat \a mode.
+ */
+void MpMpxPlaybackFrameworkWrapper::setRepeat( bool mode )
+{
+    d_ptr->setRepeat( mode );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxplaybackframeworkwrapper_p.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,512 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Framework wraper for Playback - Private.
+*
+*/
+
+#include <mpxplaybackutility.h>
+#include <mpxmedia.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxcommandgeneraldefs.h>
+#include <mpxplaybackmessage.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxplaybackmessagedefs.h>
+#include <mpxplaybackframeworkdefs.h>
+#include <hbglobal.h>
+#include <xqsharablefile.h>
+
+#include "mpmpxplaybackframeworkwrapper_p.h"
+#include "mpmpxplaybackframeworkwrapper.h"
+#include "mpplaybackdata.h"
+#include "mpcommondefs.h"
+#include "mptrace.h"
+/*!
+    \class MpMpxPlaybackFrameworkWrapperPrivate
+    \brief Wrapper for mpx framework utilities - private implementation.
+
+    This is a private implementation of the mpx framework wrapper utilties interface.
+*/
+
+/*!
+ \internal
+ */
+MpMpxPlaybackFrameworkWrapperPrivate::MpMpxPlaybackFrameworkWrapperPrivate( MpMpxPlaybackFrameworkWrapper *qq)
+    : q_ptr( qq ),
+      iPlaybackUtility(0),
+      iMedia(0),
+      iPlaybackData(0)
+{
+    TX_LOG
+}
+
+/*!
+ \internal
+ */
+MpMpxPlaybackFrameworkWrapperPrivate::~MpMpxPlaybackFrameworkWrapperPrivate()
+{
+    TX_ENTRY
+
+    if ( iPlaybackUtility ) {
+        ForceStopL();
+        iPlaybackUtility->RemoveObserverL(*this);
+        iPlaybackUtility->Close();
+    }
+
+    delete iMedia;
+    delete iPlaybackData;
+
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::init( MpCommon::MpViewMode viewMode, TUid hostUid )
+{
+    iViewMode = viewMode;
+    mHostUid = hostUid;
+    TRAPD(err, DoInitL());
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::play( QString aFilename )
+{
+    TRAPD( err, DoPlayL(aFilename) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::play( const XQSharableFile& file )
+{
+    TRAPD( err, DoPlayL( file ) );
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
+    }
+}
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::playPause()
+{
+    TX_ENTRY
+    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdPlayPause));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::stop()
+{
+    TX_ENTRY
+    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdStop));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::skipForward()
+{
+    TX_ENTRY
+    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdNext));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::skipBackward()
+{
+    TX_ENTRY
+    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdPrevious));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::setPosition( int value )
+{
+    TX_ENTRY_ARGS("value =" << value);
+    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyPosition, value));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::setShuffle( bool mode )
+{
+    TX_ENTRY_ARGS("mode =" << mode);
+    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyRandomMode, mode));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::setRepeat( bool mode )
+{
+    TX_ENTRY_ARGS("mode =" << mode);
+    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyRepeatMode, mode ? EPbRepeatAll : EPbRepeatOff));
+    if ( err != KErrNone ) {
+        TX_LOG_ARGS("Error: " << err << "; should never get here.");
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+MpPlaybackData *MpMpxPlaybackFrameworkWrapperPrivate::playbackData()
+{
+    return iPlaybackData;
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::HandlePlaybackMessage( CMPXMessage *aMessage, TInt aError )
+{
+    TX_ENTRY_ARGS("aError=" << aError);
+    if ( aError == KErrNone && aMessage ) {
+        TRAP_IGNORE( DoHandlePlaybackMessageL(*aMessage) );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::HandlePropertyL(
+    TMPXPlaybackProperty aProperty,
+    TInt aValue,
+    TInt aError )
+{
+    TX_ENTRY_ARGS("aProperty=" << aProperty << "aValue=" << aValue << "aError=" << aError)
+    if ( KErrNone == aError ) {
+        switch ( aProperty  ) {
+            case EPbPropertyPosition:
+                TX_LOG_ARGS("EPbPropertyPosition")
+                iPlaybackData->setPosition(aValue);
+                break;
+            case EPbPropertyDuration:
+                TX_LOG_ARGS("EPbPropertyDuration")
+                iPlaybackData->setDuration(aValue);
+                break;
+            default:
+                break;
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::HandleSubPlayerNamesL(
+    TUid aPlayer,
+    const MDesCArray *aSubPlayers,
+    TBool aComplete,
+    TInt aError )
+{
+    Q_UNUSED(aPlayer);
+    Q_UNUSED(aSubPlayers);
+    Q_UNUSED(aComplete);
+    Q_UNUSED(aError);
+    TX_LOG
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::HandleMediaL(
+    const CMPXMedia& aProperties,
+    TInt aError )
+{
+    TX_ENTRY_ARGS("aError=" << aError);
+    if ( KErrNone != aError || !iPlaybackData ) {
+        TX_EXIT
+        return;
+    }
+
+    if ( iMedia ) {
+        delete iMedia;
+        iMedia = NULL;
+    }
+    iMedia = CMPXMedia::NewL( aProperties );
+
+    bool changed = false;
+    if ( aProperties.IsSupported( KMPXMediaGeneralTitle ) ) {
+        changed |= iPlaybackData->setTitle(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaGeneralTitle ).Ptr(),
+                aProperties.ValueText( KMPXMediaGeneralTitle ).Length() ) );
+    }
+    else {
+        changed |= iPlaybackData->setTitle(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaGeneralUri ).Ptr(),
+                aProperties.ValueText( KMPXMediaGeneralUri ).Length() ) );
+    }
+    
+    if ( aProperties.IsSupported( KMPXMediaMusicArtist ) ) {
+        changed |= iPlaybackData->setArtist(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaMusicArtist ).Ptr(),
+                aProperties.ValueText( KMPXMediaMusicArtist ).Length() ) );
+    }
+    else {
+            changed |= iPlaybackData->setArtist(hbTrId("txt_mus_other_unknown3"));
+    }
+    if ( aProperties.IsSupported( KMPXMediaMusicAlbum ) ) {
+        changed |= iPlaybackData->setAlbum(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaMusicAlbum ).Ptr(),
+                aProperties.ValueText( KMPXMediaMusicAlbum ).Length() ) );
+    }
+    else {
+            changed |= iPlaybackData->setAlbum(hbTrId("txt_mus_other_unknown4"));
+    }
+    if ( changed ) {
+        // This is required to propagate the playback info to UI at once.
+        iPlaybackData->commitPlaybackInfo();
+    }
+
+    if ( aProperties.IsSupported( KMPXMediaGeneralUri) ) {
+        iPlaybackData->setUri(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaGeneralUri ).Ptr(),
+                aProperties.ValueText( KMPXMediaGeneralUri ).Length() ) );
+    }
+    if (aProperties.IsSupported(TMPXAttribute(KMPXMediaMusicAlbumArtFileName))) {
+        iPlaybackData->setAlbumArtUri(
+            QString::fromUtf16(
+                aProperties.ValueText(KMPXMediaMusicAlbumArtFileName).Ptr(),
+                aProperties.ValueText(KMPXMediaMusicAlbumArtFileName).Length()));
+    }
+    else {
+        iPlaybackData->setAlbumArtUri(
+            QString::fromUtf16(
+                aProperties.ValueText( KMPXMediaGeneralUri ).Ptr(),
+                aProperties.ValueText( KMPXMediaGeneralUri ).Length() ) );
+    }
+    
+  
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::DoInitL()
+{
+    TX_ENTRY
+
+   iPlaybackUtility = MMPXPlaybackUtility::UtilityL( mHostUid );
+   iPlaybackUtility->AddObserverL( *this );
+   iPlaybackData = new MpPlaybackData();
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::DoPlayL( QString aFilename )
+{
+    TX_ENTRY
+    if ( !aFilename.isNull() ) {
+        const TDesC& playTitle = TPtrC(reinterpret_cast<const TText*>( aFilename.constData() ));
+        iPlaybackUtility->InitL( playTitle );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::DoPlayL( const XQSharableFile& file )
+{
+    TX_ENTRY
+        
+    RFile xqfile;
+    bool ok = file.getHandle( xqfile );
+    if ( ok ) {
+        iPlaybackUtility->InitL( xqfile );
+    }
+	else {
+		TX_LOG_ARGS("Error: " << ok << "; should never get here.");
+	}
+    
+    
+    TX_EXIT
+}
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::DoHandlePlaybackMessageL( const CMPXMessage& aMessage )
+{
+    TX_ENTRY
+    TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
+    if ( KMPXMessageGeneral == id ) {
+        TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
+        TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
+        TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
+        TX_LOG_ARGS("event=" << event << ", type=" << type << ", data=" << data);
+
+        switch ( event ) {
+            case TMPXPlaybackMessage::EStateChanged:
+                TX_LOG_ARGS("TMPXPlaybackMessage::EStateChanged")
+                UpdateStateL();
+                break;
+            case TMPXPlaybackMessage::EInitializeComplete:
+                TX_LOG_ARGS("TMPXPlaybackMessage::EInitializeComplete")
+                if ( data ) {
+                    // Play the track
+                    CMPXCommand *cmd( CMPXCommand::NewL() );
+                    CleanupStack::PushL( cmd );
+                    cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId,
+                            KMPXCommandIdPlaybackGeneral );
+                    cmd->SetTObjectValueL<TInt>(
+                            KMPXCommandPlaybackGeneralType,
+                            EPbCmdPlay );
+                    cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync,
+                            ETrue );
+                    cmd->SetTObjectValueL<TBool>(
+                            KMPXCommandPlaybackGeneralNoBuffer,
+                            ETrue );
+                    iPlaybackUtility->CommandL( *cmd );
+                    CleanupStack::PopAndDestroy( cmd );
+                }
+                break;
+            case TMPXPlaybackMessage::EPropertyChanged:
+                TX_LOG_ARGS("TMPXPlaybackMessage::EPropertyChanged")
+                TMPXPlaybackProperty property;
+                property = static_cast<TMPXPlaybackProperty>( type );
+                HandlePropertyL( property, data, KErrNone );
+                break;
+            case TMPXPlaybackMessage::EMediaChanged:
+                TX_LOG_ARGS("TMPXPlaybackMessage::EMediaChanged")
+                RetrieveSongDetailsL();
+                break;
+            default:
+                break;
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::ForceStopL()
+{
+    TX_ENTRY
+    if ( iPlaybackData->playbackState() != MpPlaybackData::Stopped ) {
+        // Stop the track
+        CMPXCommand *cmd( CMPXCommand::NewL() );
+        CleanupStack::PushL( cmd );
+        cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral );
+        cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, EPbCmdStop );
+        cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
+        cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue );
+        iPlaybackUtility->CommandL( *cmd );
+        CleanupStack::PopAndDestroy( cmd );
+
+       // iPlaybackUtility->RemoveObserverL(*this);
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::UpdateStateL()
+{
+    TX_ENTRY
+    if ( !iPlaybackUtility->Source() ) {
+        TX_LOG_ARGS("There is no source")
+        iPlaybackData->setPlaybackState( MpPlaybackData::Stopped );
+    }
+    else {
+        switch ( iPlaybackUtility->StateL() ) {
+            case EPbStatePlaying:
+                TX_LOG_ARGS("EPbStatePlaying")
+                iPlaybackData->setPlaybackState( MpPlaybackData::Playing );
+                break;
+            case EPbStatePaused:
+                TX_LOG_ARGS("EPbStatePaused")
+                iPlaybackData->setPlaybackState( MpPlaybackData::Paused );
+                break;
+            case EPbStateStopped:
+                TX_LOG_ARGS("EPbStateStopped")
+                iPlaybackData->setPlaybackState( MpPlaybackData::Stopped );
+                break;
+            default:
+                break;
+        }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ */
+void MpMpxPlaybackFrameworkWrapperPrivate::RetrieveSongDetailsL()
+{
+    TX_ENTRY
+    MMPXSource *mediaSrc = iPlaybackUtility->Source();
+    User::LeaveIfNull( mediaSrc );
+    RArray<TMPXAttribute> requestedAttr;
+    CleanupClosePushL( requestedAttr );
+    requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralTitle ) );
+    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicArtist ) );
+    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbum ) );
+    requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralUri ) );
+    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) );
+
+    mediaSrc->MediaL( requestedAttr.Array(), *this );
+    CleanupStack::PopAndDestroy( &requestedAttr );
+    TX_EXIT
+}
+
--- a/mpengine/src/mpsongscanner.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpengine/src/mpsongscanner.cpp	Mon May 03 12:29:20 2010 +0300
@@ -19,9 +19,10 @@
 #include <hbnotificationdialog.h>
 #include <hblabel.h>
 #include <hbfontspec.h>
+#include <hbmessagebox.h>
 
 #include "mpsongscanner.h"
-#include "mpmpxframeworkwrapper.h"
+#include "mpmpxharvesterframeworkwrapper.h"
 #include "mptrace.h"
 
 /*!
@@ -43,7 +44,7 @@
 /*!
  Constructs the song scanner.
  */
-MpSongScanner::MpSongScanner( MpMpxFrameworkWrapper *wrapper, QObject *parent )
+MpSongScanner::MpSongScanner( MpMpxHarvesterFrameworkWrapper *wrapper, QObject *parent )
     : QObject( parent ),
       mMpxWrapper(wrapper),
       mScanProgressNote(0),
@@ -124,35 +125,48 @@
  */
 void MpSongScanner::handleScanEnded( int numItemsAdded, int error )
 {
-    QString added;
-
-    HbNotificationDialog *finishedDialog = new HbNotificationDialog();
-    finishedDialog->setModal(true);
-    finishedDialog->setAttribute( Qt::WA_DeleteOnClose );
-
-    added = hbTrId( "txt_mus_dpopinfo_ln_songs_added", numItemsAdded );
-    finishedDialog->setText( added );
-
-    if( error < 0) {
-        if ( mScanProgressNote ) {     
-            mScanProgressNote->cancel();
+    if (error == KErrDiskFull) {
+		if ( mScanProgressNote ) {     
+                mScanProgressNote->cancel();
         }
-        finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
-        finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) );
+        HbMessageBox *diskFullDialog = new HbMessageBox();
+        diskFullDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
+        diskFullDialog->setText( hbTrId( "txt_mus_title_refresh_cancelled" ) );
+        diskFullDialog->setTimeout( HbPopup::NoTimeout);
+        diskFullDialog->exec();
+        mScanning = false;
+               
     }
-    else if ( mScanning ) {
-        if ( mScanProgressNote ) {     
-            mScanProgressNote->cancel();
+    else{
+        QString added;
+        HbNotificationDialog *finishedDialog = new HbNotificationDialog();
+        finishedDialog->setModal(true);
+        finishedDialog->setAttribute( Qt::WA_DeleteOnClose );
+    
+        added = hbTrId( "txt_mus_dpopinfo_ln_songs_added", numItemsAdded );
+        finishedDialog->setText( added );
+              
+        if( error < 0) {
+            if ( mScanProgressNote ) {     
+                mScanProgressNote->cancel();
+            }
+            finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
+            finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) );
         }
-        finishedDialog->setIcon( HbIcon( QString("qtg_large_ok") ) );
-        finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_complete" ) );
+        else if ( mScanning ) {
+            if ( mScanProgressNote ) {     
+                mScanProgressNote->cancel();
+            }
+            finishedDialog->setIcon( HbIcon( QString("qtg_large_ok") ) );
+            finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_complete" ) );
+        }
+        else {
+            finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
+            finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) );
+        }
+        mScanning = false;
+        finishedDialog->show();
     }
-    else {
-        finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
-        finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) );
-    }
-    mScanning = false;
-    finishedDialog->show();
 }
 
 /*!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/inc/unittest_mpmpxcollectionframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpmpxcollectionframeworkwrapper
+*
+*/
+
+#ifndef TESTMPMPXCOLLECTIONFRAMEWORKWRAPPER_H
+#define TESTMPMPXCOLLECTIONFRAMEWORKWRAPPER_H
+
+#include <QtTest/QtTest>
+
+class MpMpxCollectionFrameworkWrapper;
+class MpMpxCollectionFrameworkWrapperPrivate;
+class CMPXMedia;
+
+class TestMpMpxCollectionFrameworkWrapper : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    TestMpMpxCollectionFrameworkWrapper();
+    virtual ~TestMpMpxCollectionFrameworkWrapper();
+    //test utility functions
+    void loadTestData();
+    void loadPlaylists();
+    bool waitForSignal(QSignalSpy* spy, int timeoutms);  
+
+public slots:
+
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+
+    void testConstructor();
+    void testReleaseIsolatedCollection();
+    void testCollectionData();
+    void testHandleOpenEntries();
+    void testHandleOpenPlaylist();    
+    void testHandleOperationComplete();
+    void testHandleIsolatedOpen();
+    void testOpenCollection();  
+    void testDoIncrementalOpen();
+    void testReopenCollection();
+    void testOpenCollectionItem();  
+    void testGoBack();
+    void testFindPlaylists();
+    void testCreatePlaylist();
+    void testCreatePlaylistWithProvidedCollectionData();   
+    void testSaveToPlaylist();
+    void testSaveToCurrentPlaylist();
+    void testRenamePlaylist();
+    void testDeleteSongs();
+    void testSetShuffle();
+    void testPreviewItem();
+    void testOpenIsolatedCollection();
+    void testHandleCollectionMessage();
+    void testPreparePlaylistMediaSongsContext();
+    void testPreparePlaylistMediaArtistAlbumsContext();
+    void testReorderPlaylist();
+
+private:
+
+    MpMpxCollectionFrameworkWrapper           *mTest;
+    MpMpxCollectionFrameworkWrapperPrivate    *mTestPrivate;
+    CMPXMedia                                 *iMediaTestData;
+    CMPXMedia                                 *iPlaylistsTestData;
+
+};
+
+#endif  // TESTMPMPXCOLLECTIONFRAMEWORKWRAPPER_H
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/src/unittest_mpmpxcollectionframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,983 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpmpxcollectionframeworkwrapper
+*
+*/
+
+#include <QSignalSpy>
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+#include <mpxmedia.h>
+#include <mpxcollectionplaylist.h>
+
+#include "unittest_mpmpxcollectionframeworkwrapper.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+#include "stub/inc/mpxcollectionopenutility.h"
+#include "stub/inc/mpxcollectionuihelper.h"
+#include "stub/inc/mpxcollectionutility.h"
+#include "stub/inc/mpxplaybackutility.h"
+#include "stub/inc/mpmpxisolatedcollectionhelper.h"
+#include "mpsettingsmanager.h"
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpmpxcollectionframeworkwrapper.h"
+#include "mpmpxcollectionframeworkwrapper_p.h"
+#undef private
+
+//This so we can test private functions
+#include "mpmpxcollectionframeworkwrapper_p.cpp"
+
+//Test data
+struct TTestAttrs
+    {
+    const wchar_t* GeneralTitle;
+    const wchar_t* MusicArtist;
+    const TInt GeneralCount;
+    const wchar_t* MusicAlbumArtFileName;
+    };
+    
+const TTestAttrs KAllSongsTestData[] =
+    {
+     { L"Title 1", L"Artist 1", 1, L"e:\\data\\images\\art1.jpg" }
+    ,{ L"Title 2", L"Artist 2", 1, L"e:\\data\\images\\art2.jpg" }
+    ,{ L"Title 3", L"Artist 3", 1, L"e:\\data\\images\\art3.jpg" }
+    ,{ L"Title 4", L"Artist 4", 1, L"e:\\data\\images\\art4.jpg" }
+    ,{ L"Title 5", L"Artist 5", 1, L"e:\\data\\images\\art5.jpg" }
+    ,{ L"Title 6", L"Artist 6", 1, L"e:\\data\\images\\art6.jpg" }
+    ,{ L"Title 7", L"Artist 7", 1, L"e:\\data\\images\\art7.jpg" }
+    ,{ L"Title 8", L"Artist 8", 1, L"e:\\data\\images\\art8.jpg" }
+    ,{ L"Title 9", L"Artist 9", 1, L"e:\\data\\images\\art9.jpg" }
+    ,{ L"Title 10", L"Artist 10", 1, L"e:\\data\\images\\art10.jpg" }
+    };
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMpMpxCollectionFrameworkWrapper tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpmpxcollectionframeworkwrapper.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpMpxCollectionFrameworkWrapper::TestMpMpxCollectionFrameworkWrapper()
+    : mTest(0),
+      iMediaTestData(0),
+      iPlaylistsTestData(0)
+{
+}
+
+TestMpMpxCollectionFrameworkWrapper::~TestMpMpxCollectionFrameworkWrapper()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpMpxCollectionFrameworkWrapper::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpMpxCollectionFrameworkWrapper::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpMpxCollectionFrameworkWrapper::init()
+{
+    mTest = new MpMpxCollectionFrameworkWrapper();
+    mTestPrivate = mTest->d_ptr;
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpMpxCollectionFrameworkWrapper::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests constructor.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testConstructor()
+{
+    QVERIFY(mTestPrivate->iCollectionUtility != 0);
+    QVERIFY(mTestPrivate->iCollectionUiHelper != 0);
+    QVERIFY(mTestPrivate->iIncrementalOpenUtil != 0);
+    QVERIFY(mTestPrivate->iCollectionData != 0);
+}
+
+/*!
+ Tests collectionData
+ */
+void TestMpMpxCollectionFrameworkWrapper::testReleaseIsolatedCollection()
+{  
+    mTestPrivate->iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( mTestPrivate );
+    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
+    mTest->releaseIsolatedCollection();
+    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
+    QVERIFY(mTestPrivate->iIsolatedCollectionData == 0);
+}
+
+/*!
+ Tests collectionData
+ */
+void TestMpMpxCollectionFrameworkWrapper::testCollectionData()
+{
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    MpMpxCollectionData *collectionData = mTest->collectionData();
+    QCOMPARE(collectionData->mContainerMedia->ValueTObjectL<TInt>(KMPXMediaArrayCount),iMediaTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount));
+}
+
+/*!
+ Tests handleOpen when given entries. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testHandleOpenEntries()
+{
+    CMPXMedia* media = CMPXMedia::NewL();
+    
+    //Called with some error
+    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNotFound);
+    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(EFalse));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
+    
+    
+    //Called without error 
+    mTestPrivate->iFirstIncrementalOpen = EFalse;
+    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNone);
+    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(EFalse));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
+    
+    //Called without error 
+    mTestPrivate->iFirstIncrementalOpen = ETrue;
+    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNone);
+    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
+    QCOMPARE(mTestPrivate->iFirstIncrementalOpen, TBool(EFalse));
+}
+
+/*!
+ Tests handleOpen when given a playlist. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testHandleOpenPlaylist()
+{
+    CMPXCollectionPlaylist* playlist = CMPXCollectionPlaylist::NewL();
+    CMPXMedia* media = CMPXMedia::NewL();
+
+    //Called with some error
+    QSignalSpy spy(mTest, SIGNAL(collectionPlaylistOpened()));
+    mTestPrivate->HandleOpenL(*playlist, KErrNotFound);
+    QCOMPARE(spy.count(), 0);
+    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
+    
+    //Called without error
+    QSignalSpy spy2( MpSettingsManager::instance(),SIGNAL(shuffleChanged(bool)));
+    MpSettingsManager::setRepeat(false);
+    MpSettingsManager::setShuffle(false);
+    if(waitForSignal(&spy2, 1000)){
+        bool shuffle = MpSettingsManager::shuffle();
+        TX_LOG_ARGS("shuffle changed to "<< shuffle);
+        bool repeat = MpSettingsManager::repeat();
+        TX_LOG_ARGS("repeat changed to "<< repeat);
+    }
+    mTestPrivate->HandleOpenL(*playlist, KErrNone);
+    QCOMPARE(spy.count(), 1);
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iRepeat, TInt(EPbRepeatOff));
+    
+    cleanup();
+    init();
+    QSignalSpy spy3(mTest, SIGNAL(collectionPlaylistOpened()));
+
+    //Called without error
+    spy2.clear();
+    MpSettingsManager::setRepeat(true);
+    MpSettingsManager::setShuffle(true);
+    
+    if(waitForSignal(&spy2, 1000)){
+        bool shuffle = MpSettingsManager::shuffle();
+        TX_LOG_ARGS("shuffle2 changed to "<< shuffle);
+        bool repeat = MpSettingsManager::repeat();
+        TX_LOG_ARGS("repeat2 changed to "<< repeat);
+    }
+    
+    mTestPrivate->HandleOpenL(*playlist, KErrNone);
+    QCOMPARE(spy3.count(), 1);
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iRepeat, TInt(EPbRepeatAll));
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
+       
+    //Called without error 
+    spy3.clear();
+    mTestPrivate->HandleOpenL(*playlist, KErrNone);
+    QCOMPARE(spy3.count(), 1);
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
+}
+
+/*!
+ Tests handleOperationComplete. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testHandleOperationComplete()
+{
+    void* temp;
+    temp=0;
+    QSignalSpy spy(mTest, SIGNAL(songsDeleted(bool)));
+    mTestPrivate->HandleOperationCompleteL(EDeleteOp, KErrNone, temp);
+    mTestPrivate->HandleOperationCompleteL(EDeleteOp, KErrNotFound, temp);
+    QCOMPARE(spy.count(), 2);
+    bool result = qvariant_cast<bool>(spy.at(0).at(0));
+    QCOMPARE(result, true);
+    result = qvariant_cast<bool>(spy.at(1).at(0));
+    QCOMPARE(result, false);
+    
+    QSignalSpy spy2(mTest, SIGNAL(playlistSaved(bool)));
+    mTestPrivate->HandleOperationCompleteL(EAddOp, KErrNone, temp);
+    mTestPrivate->HandleOperationCompleteL(EAddOp, KErrNotFound, temp);
+    QCOMPARE(spy2.count(), 2);
+    result = qvariant_cast<bool>(spy2.at(0).at(0));
+    QCOMPARE(result, true);
+    result = qvariant_cast<bool>(spy2.at(1).at(0));
+    QCOMPARE(result, false);
+    
+    QSignalSpy spy3(mTest, SIGNAL(playlistsRenamed(bool)));
+    mTestPrivate->HandleOperationCompleteL(ERenameOp, KErrNone, temp);
+    mTestPrivate->HandleOperationCompleteL(ERenameOp, KErrNotFound, temp);
+    QCOMPARE(spy3.count(), 2);
+    result = qvariant_cast<bool>(spy2.at(0).at(0));
+    QCOMPARE(result, true);
+    result = qvariant_cast<bool>(spy2.at(1).at(0));
+    QCOMPARE(result, false);
+}
+
+/*!
+ Tests HandleIsolatedOpen.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testHandleIsolatedOpen()
+{
+    loadTestData();
+    QSignalSpy spy(mTest, SIGNAL(isolatedCollectionOpened(MpMpxCollectionData*)));
+        
+    mTestPrivate->iIsolatedCollectionData = 0;
+    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNone ) ;
+    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(ETrue));
+    delete mTestPrivate->iIsolatedCollectionData;
+            
+    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
+    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNone ) ;
+    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(ETrue));
+    delete mTestPrivate->iIsolatedCollectionData;
+    
+    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
+    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNotFound ) ;
+    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(EFalse));
+
+    QCOMPARE(spy.count(), 2);
+}
+
+/*!
+ Tests openCollection for different contexts.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testOpenCollection()
+{
+    
+    mTest->openCollection(ECollectionContextAllSongs);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 6);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
+    cleanup();
+    init();
+    mTest->openCollection(ECollectionContextAlbums);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 1);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
+    cleanup();
+    init();
+    mTest->openCollection(ECollectionContextPlaylists);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 4);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
+    cleanup();
+    init();
+    mTest->openCollection(ECollectionContextGenres);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 1);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
+    cleanup();
+    init();
+    mTest->openCollection(ECollectionContextUnknown);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse));
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 0);
+    
+}
+
+/*!
+ Tests doIncrementalOpen. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testDoIncrementalOpen()
+{
+    mTestPrivate->DoIncrementalOpenL();
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
+}
+
+/*!
+ Tests reopenCollection.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testReopenCollection()
+{
+    mTest->reopenCollection();
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));    
+}
+
+/*!
+ Tests openCollection for a specific item.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testOpenCollectionItem()
+{
+    for(int index=0; index<10; index++){
+            mTest->openCollectionItem(index);
+            QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
+            QCOMPARE(mTestPrivate->iCollectionUtility->iIndex,index);
+        }
+}
+
+/*!
+ Tests goBack.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testGoBack()
+{
+    mTest->back();
+    QCOMPARE(mTestPrivate->iCollectionUtility->iBack, TBool(ETrue));
+}
+
+/*!
+ Tests findPlaylists.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testFindPlaylists()
+{
+    QStringList testList;
+    loadPlaylists();
+    mTestPrivate->iCollectionUtility->setPlaylists(*iPlaylistsTestData);
+    mTest->findPlaylists(testList);
+    TInt count = iPlaylistsTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    QCOMPARE(count,testList.count());
+    for(TInt i=0; i < count; i++){
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
+        QCOMPARE(testList.at(i),QString::fromUtf16( title.Ptr(), title.Length() ));        
+    }
+}
+
+/*!
+ Tests createPlaylist.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testCreatePlaylist()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    QString playListName("playlistname");
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    mTest->createPlaylist(playListName,selection);
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
+    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+    const TDesC& playlistTitle = TPtrC(reinterpret_cast<const TText*>(playListName.constData()));
+    const TDesC& playlistPath = TPtrC(KPlaylistPath);
+    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralTitle),playlistTitle);
+    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralUri), playlistPath);
+    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    QCOMPARE(count, selection.count());
+    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    for( TInt i = 0; i < count; i++ ){
+        CMPXMedia* track( testArray->AtL(i) );
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
+        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+    }
+}
+
+/*!
+ Tests createPlaylist with a provided collection data.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testCreatePlaylistWithProvidedCollectionData()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    QString playListName("playlistname");
+    loadTestData();
+    
+    //test with a collection data different that the browsing collection.
+    MpMpxCollectionData *collectionData;
+    collectionData = new MpMpxCollectionData();
+    collectionData->setMpxMedia(*iMediaTestData);
+    mTest->createPlaylist(playListName,selection, collectionData);
+    delete collectionData;
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
+    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+    const TDesC& playlistTitle = TPtrC(reinterpret_cast<const TText*>(playListName.constData()));
+    const TDesC& playlistPath = TPtrC(KPlaylistPath);
+    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralTitle),playlistTitle);
+    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralUri), playlistPath);
+    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    QCOMPARE(count, selection.count());
+    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    for( TInt i = 0; i < count; i++ ){
+        CMPXMedia* track( testArray->AtL(i) );
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
+        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+    }
+}
+
+/*!
+ Tests saveToPlaylist.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testSaveToPlaylist()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    loadPlaylists();
+    mTestPrivate->iUserPlaylists =  CMPXMedia::NewL(*iPlaylistsTestData);
+    TInt countPlaylist = iPlaylistsTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    for( TInt j = 0; j < countPlaylist; j++){
+        mTest->saveToPlaylist(j,selection);
+        QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
+        CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
+        QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+        QCOMPARE(testTracks->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId),TMPXItemId(j));
+        
+        QCOMPARE(testTracks->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId),TUid::Uid(EMPXCollectionPluginMusic));
+        TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+        QCOMPARE(count, selection.count());
+        CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+        for( TInt i = 0; i < count; i++ ){
+            CMPXMedia* track( testArray->AtL(i) );
+            const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
+            QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+            QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+            QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+        }
+    }
+}
+
+/*!
+ Tests SaveToCurrentPlaylist.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testSaveToCurrentPlaylist()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    loadTestData();
+    
+    MpMpxCollectionData *testCollectionData = new MpMpxCollectionData();
+    testCollectionData->setMpxMedia(*iMediaTestData);
+    
+    //Reusing the same data, just setting some parameters to make it look like playlist tracks.
+    iMediaTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1234));
+    iMediaTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    iMediaTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    mTest->saveToCurrentPlaylist( selection, testCollectionData );
+    
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
+    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId),TMPXItemId(1234));
+    
+    QCOMPARE(testTracks->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId),TUid::Uid(EMPXCollectionPluginMusic));
+    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    QCOMPARE(count, selection.count());
+    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    for( TInt i = 0; i < count; i++ ){
+        CMPXMedia* track( testArray->AtL(i) );
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
+        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+    }
+
+}
+
+/*!
+ Tests renamePlaylist.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testRenamePlaylist()
+{
+    
+    loadPlaylists();
+    mTestPrivate->iCollectionData->setMpxMedia(*iPlaylistsTestData);
+    QString newPlaylistName("New Playlist Name");
+    mTest->renamePlaylist(newPlaylistName,3);
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iValidRename, TBool(ETrue));
+    CMPXMediaArray *mediaArray;
+    mediaArray = const_cast<CMPXMediaArray*>(iPlaylistsTestData->Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
+    CMPXMedia* currentPlaylistMedia( mediaArray->AtL( 3 ) );
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iPlaylistId, currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ));
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iRenameTitle, newPlaylistName);
+    
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    QString newPlaylistName2("New Playlist Name 2");
+    mTest->renamePlaylist(newPlaylistName2);
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iValidRename, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iRenameTitle, newPlaylistName2);
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iPlaylistId, TMPXItemId(1));
+}
+
+/*!
+ Tests deleteSongs.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testDeleteSongs()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    mTest->deleteSongs(selection);
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iDelete, TBool(ETrue));
+}
+
+/*!
+ Tests setShuffle.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testSetShuffle()
+{
+    
+    mTest->setShuffle(true);
+    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
+    mTestPrivate->iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
+    mTest->setShuffle(true);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
+    mTest->setShuffle(false);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
+    cleanup();
+    init();
+    mTest->setShuffle(false);
+    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
+    mTestPrivate->iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
+    mTest->setShuffle(false);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
+    mTest->setShuffle(true);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
+}
+
+/*!
+ Tests PreviewItem
+ */
+void TestMpMpxCollectionFrameworkWrapper::testPreviewItem()
+{
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    QSignalSpy spy(mTest, SIGNAL(collectionPlaylistOpened()));
+    mTest->previewItem(1);
+    
+    // Playback utility should be created.
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
+    QCOMPARE(spy.count(), 1);
+}
+
+/*!
+ Tests OpenIsolatedCollection
+ */
+void TestMpMpxCollectionFrameworkWrapper::testOpenIsolatedCollection()
+{
+
+    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
+    mTest->openIsolatedCollection( ECollectionContextAllSongs );
+    QVERIFY(mTestPrivate->iIsolatedCollectionHelper != 0);
+    QCOMPARE(dynamic_cast<MMpMpxIsolatedCollectionHelperObserver*>(mTestPrivate),mTestPrivate->iIsolatedCollectionHelper->iObserver);
+    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iCountPath, 6);
+    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iOpenCount, 1);
+          
+    delete mTestPrivate->iIsolatedCollectionHelper;
+    mTestPrivate->iIsolatedCollectionHelper = 0;
+    mTest->openIsolatedCollection( ECollectionContextUnknown );
+    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
+
+}
+
+
+
+/*!
+ Tests handleCollectionMessage. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testHandleCollectionMessage()
+{
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMessageContentIdGeneral );
+    CMPXMedia* testMessage = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(testMessage);
+    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral);
+    
+    //Incremental open
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EPathChanged);
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcPathChangedByOpen);
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,EMcContainerOpened);
+    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse)); 
+    
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(ETrue));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
+
+    //Opened a song
+    cleanup();
+    init();
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EPathChanged);
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcPathChangedByOpen);
+    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,EMcItemOpened);
+    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
+    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));   
+        
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, 0);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(EFalse));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(EFalse));
+    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(EFalse));
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchDown);
+    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, 0);
+    
+    CleanupStack::PopAndDestroy(testMessage);    
+}
+
+/*!
+ Tests preparePlaylistMedia for track level. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testPreparePlaylistMediaSongsContext()
+{
+    QList<int> selection;
+    selection.append(1);
+    selection.append(3);
+    selection.append(5);
+    
+    loadTestData();
+    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
+    CMPXMedia* testTracks = CMPXMedia::NewL();
+    CleanupStack::PushL( testTracks ); 
+    
+    mTestPrivate->PreparePlaylistMediaL(*testTracks,selection,mTestPrivate->iCollectionData);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
+    QCOMPARE(count, selection.count());
+    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    for( TInt i = 0; i < count; i++ ){
+        CMPXMedia* track( testArray->AtL(i) );
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
+        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+    }
+    CleanupStack::PopAndDestroy( testTracks );
+}
+
+
+/*!
+ Tests preparePlaylistMedia for artist albums level. Part of private implementation.
+ */
+void TestMpMpxCollectionFrameworkWrapper::testPreparePlaylistMediaArtistAlbumsContext()
+{
+    
+    
+    //Loading Test Data.
+    
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* albumsTestData = CMPXMedia::NewL(supportedIds.Array());
+    CMPXMedia* albumOneTracksTestData = CMPXMedia::NewL(supportedIds.Array());
+    CMPXMedia* albumTwoTracksTestData = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(albumsTestData);
+    CleanupStack::PushL(albumOneTracksTestData);
+    CleanupStack::PushL(albumTwoTracksTestData);
+
+    {//Loading pseudo data for albums container
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    CMPXMedia* media1 = CMPXMedia::NewL();
+    CleanupStack::PushL(media1);
+    media1->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(0));
+    array->AppendL(*media1);
+    CleanupStack::PopAndDestroy(media1);
+    CMPXMedia* media2 = CMPXMedia::NewL();
+    CleanupStack::PushL(media2);
+    media2->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(1));
+    array->AppendL(*media2);
+    CleanupStack::PopAndDestroy(media2);
+    CMPXMedia* media3 = CMPXMedia::NewL();
+    CleanupStack::PushL(media3);
+    media3->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(2));
+    array->AppendL(*media3);
+    CleanupStack::PopAndDestroy(media3);
+    albumsTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    albumsTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    albumsTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
+    albumsTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    albumsTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(88));//any number
+    CleanupStack::PopAndDestroy(array);
+    }
+    
+    {//Loading pseudo data for album one
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count/2; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(i));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+    }
+    albumOneTracksTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    albumOneTracksTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    albumOneTracksTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
+    albumOneTracksTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    albumOneTracksTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1));
+    CleanupStack::PopAndDestroy(array);
+    }
+    
+    {//Loading pseudo data for album two
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i = count/2; i < count; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, (i));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+    }
+    albumTwoTracksTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    albumTwoTracksTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+    albumTwoTracksTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
+    albumTwoTracksTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    albumTwoTracksTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(2));
+    CleanupStack::PopAndDestroy(array);
+    }
+    
+    CMPXMediaArray* albumsTracksTestData = CMPXMediaArray::NewL();
+    
+    albumsTracksTestData->AppendL(CMPXMedia::NewL()); //empty, this album is not selected for the test case.
+    albumsTracksTestData->AppendL(*albumOneTracksTestData);
+    albumsTracksTestData->AppendL(*albumTwoTracksTestData);
+    CleanupStack::PopAndDestroy(albumTwoTracksTestData);
+    CleanupStack::PopAndDestroy(albumOneTracksTestData);
+        
+
+
+    QList<int> selection;
+    selection.append(1);
+    selection.append(2);
+       
+    mTestPrivate->iCollectionUtility->iAlbumSongs = albumsTracksTestData;
+    mTestPrivate->iCollectionData->setMpxMedia(*albumsTestData);
+    mTestPrivate->iCollectionData->mContext = ECollectionContextAlbums;
+
+    CMPXMedia* testTracks = CMPXMedia::NewL();
+    CleanupStack::PushL( testTracks ); 
+    
+    mTestPrivate->PreparePlaylistMediaL(*testTracks,selection,mTestPrivate->iCollectionData);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    QCOMPARE(count, testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount));
+    const CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    for( TInt i = 0; i < count; i++ ){
+        CMPXMedia* track( testArray->AtL(i) );
+        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
+        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
+        QCOMPARE(TInt (track->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)),i);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
+        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
+    }
+    CleanupStack::PopAndDestroy( testTracks );
+    CleanupStack::PopAndDestroy(albumsTestData);
+}
+
+/*!
+ Used to test reorderPlaylist
+ */
+void TestMpMpxCollectionFrameworkWrapper::testReorderPlaylist()
+{    
+    loadTestData();
+    int originalOrdinal(0);
+    int newOrdinal(3);
+    int playListId = iMediaTestData->ValueTObjectL<TInt>( KMPXMediaGeneralId );
+    CMPXMediaArray* testArray = iMediaTestData->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    CMPXMedia* testSong( testArray->AtL(0) );
+    int songId = testSong->ValueTObjectL<TInt>(KMPXMediaGeneralId);
+    
+    mTest->reorderPlaylist(playListId,songId,originalOrdinal,newOrdinal);
+
+    QCOMPARE(mTestPrivate->iCollectionUiHelper->iValidReorder, TBool(ETrue));
+}
+
+/*!
+ Used to load test data
+ */
+void TestMpMpxCollectionFrameworkWrapper::loadTestData()
+{
+    if(iMediaTestData){
+        delete iMediaTestData;
+        iMediaTestData=0;
+    }
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMediaIdMusic );
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
+        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
+        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+    }
+    
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
+   
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    entries->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1));
+    CleanupStack::PopAndDestroy(array);
+ 
+    iMediaTestData = CMPXMedia::NewL(*entries);
+    
+    CleanupStack::PopAndDestroy(entries);
+}
+
+/*!
+ Used to load test playlists
+ */
+void TestMpMpxCollectionFrameworkWrapper::loadPlaylists()
+{
+    if(iPlaylistsTestData){
+        delete iPlaylistsTestData;
+        iPlaylistsTestData=0;
+    }
+    
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    
+    supportedIds.AppendL( KMPXMediaIdGeneral );
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
+    for (TInt i =0; i < count; i++) {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
+        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(i));
+        array->AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+        
+    }
+    
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All playlists"));
+   
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+    CleanupStack::PopAndDestroy(array);
+    
+    iPlaylistsTestData = CMPXMedia::NewL(*entries);
+    
+    CleanupStack::PopAndDestroy(entries);
+}
+
+/*!
+ Used to wait on spy signal
+ */
+bool TestMpMpxCollectionFrameworkWrapper::waitForSignal(QSignalSpy* spy, int timeoutms) 
+{ 
+    QTime timer; 
+    timer.start(); 
+    while (spy->isEmpty() && timer.elapsed() < timeoutms) 
+    { 
+        QCoreApplication::processEvents(); 
+    } 
+    return !spy->isEmpty(); 
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpmpxcollectiondata.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing mpmpxframeworkwrapper
+*
+*/
+
+#ifndef MPMPXCOLLECTIONDATA_H
+#define MPMPXCOLLECTIONDATA_H
+
+#include "mpmpxcollectionviewdefs.h"
+
+class CMPXMedia;
+ 
+
+class MpMpxCollectionData 
+{
+
+public:
+
+    enum DataType {
+        Title,
+        Uri,
+        Duration,
+        Count,
+        Artist,
+        Album,
+        Genre,
+        Rating,
+        AlbumArtUri
+    };
+
+    // Stub functions
+     MpMpxCollectionData();
+    ~MpMpxCollectionData();
+
+    TCollectionContext context();
+    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
+
+    void setMpxMedia( const CMPXMedia& entries );
+    const CMPXMedia& containerMedia();
+
+public:
+    CMPXMedia               *mContainerMedia;
+    TBool                   mMediaSet;
+    TCollectionContext      mContext;
+
+};
+
+#endif // MPMPXCOLLECTIONDATA_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpmpxisolatedcollectionhelper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright ( c ) 2009 Nokia Corporation and/or its subsidiary( -ies ).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolated collection helper stub for testing mpmpxframeworkwrapper.
+*
+*/
+
+#ifndef CMPMPXISOLATEDCOLLECTIONHELPER_H
+#define CMPMPXISOLATEDCOLLECTIONHELPER_H
+
+#include <e32base.h>
+class CMPXCollectionPath;
+class CMPXMedia;
+
+class MMpMpxIsolatedCollectionHelperObserver
+{
+public:
+
+    virtual void HandleIsolatedOpenL( const CMPXMedia& aEntries, 
+            TInt aError ) = 0;
+};
+
+class CMpMpxIsolatedCollectionHelper : public CBase
+{
+public:
+
+    static CMpMpxIsolatedCollectionHelper* NewL( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+    static CMpMpxIsolatedCollectionHelper* NewLC( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+    virtual ~CMpMpxIsolatedCollectionHelper();
+    void OpenCollectionL( CMPXCollectionPath& aPath );
+    
+private:
+    CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver );
+
+public:
+    MMpMpxIsolatedCollectionHelperObserver* iObserver;
+    TBool          iOpen;
+    TInt           iOpenCount;
+    TInt           iCountPath;
+
+};
+
+#endif // CMPMPXISOLATEDCOLLECTIONHELPER_H
+    
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionhelperfactory.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  mpxcollectionhelperfactory stub for testing mpmpxframeworkwrapper 
+*
+*/
+
+
+
+#ifndef MMPXCOLLECTIONHELPERFACTORY_H
+#define MMPXCOLLECTIONHELPERFACTORY_H
+
+#include <bautils.h>
+#include <mpxcollectionframeworkdefs.h>
+
+// FORWARD DECLARATIONS
+class MMPXCollectionUiHelper;
+ 
+/**
+ *  Factory stub class to construct collection helpers.
+ */
+class CMPXCollectionHelperFactory : public CBase
+{
+
+public:
+    
+    // Stub functions
+    static MMPXCollectionUiHelper* NewCollectionUiHelperL(const TUid& aModeId = KMcModeDefault);
+
+    
+};
+       
+#endif // MMPXCOLLECTIONHELPERFACTORY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionopenutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  mpxcollectionopenutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#ifndef C_CMPXCOLLECTIONOPENUTILITY_H
+#define C_CMPXCOLLECTIONOPENUTILITY_H
+
+#include <mpxcollectionobserver.h>
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxcollectionopenlresultdef.h>
+
+
+class CMPXCollectionOpenUtility  
+{
+public:
+    
+    // Stub functions
+    enum TDirection
+        {
+        EFetchNormal,
+        EFetchUp,
+        EFetchDown
+        };
+     static CMPXCollectionOpenUtility* NewL( MMPXCollectionObserver* aObs, TUid aMode = KMcModeDefault );
+     CMPXCollectionOpenUtility();
+     ~CMPXCollectionOpenUtility();
+     void StartL( TArray<TMPXAttribute> aAttrs,
+                              TInt aChunkSize,
+                              TInt aOffset = 0,
+                              TDirection aDirection = EFetchNormal,
+                              TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute );
+     void Stop();
+     void SetDelay( TInt aDelay );
+public:
+     TInt       iDelay;
+     TInt       iChunkSize;
+     TBool      iStop;
+     TBool      iStart;
+     TDirection iDirection;
+    };
+
+#endif // C_CMPXCOLLECTIONOPENUTILITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionuihelper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
+*
+*/
+
+#ifndef MMPXCOLLECTIONUIHELPER_H
+#define MMPXCOLLECTIONUIHELPER_H
+
+#include <mpxmediageneraldefs.h>
+#include <mpxcommonframeworkdefs.h>
+#include <mpxmediageneraldefs.h>
+#include <QString.h>
+
+
+// FORWARD DECLARATIONS
+class CMPXCollectionPath;
+class CMPXMedia;
+class MMPXCHelperObserver;
+
+class MMPXCollectionUiHelper
+{
+public:
+    
+    // Stub functions
+    MMPXCollectionUiHelper();
+    ~MMPXCollectionUiHelper();
+    
+   void DeleteL( CMPXCollectionPath& aPath,
+                          MMPXCHelperObserver* aObserver );
+    CMPXCollectionPath* MusicMenuPathL();
+    CMPXCollectionPath* MusicAllSongsPathL();
+    CMPXCollectionPath* MusicPlaylistPathL(); 
+    void Close();
+    void IncAddL( const CMPXMedia& aMedia,
+                          MMPXCHelperObserver* aObserver=0,
+                          const TInt aSize=0 );
+    void RenameL( const CMPXMedia& aMedia,
+                              MMPXCHelperObserver* aObserver );
+    void ReorderPlaylistL(const TMPXItemId& aPlaylistId,
+                                      const TMPXItemId& aSongId,
+                                      TUint aOriginalOrdinal,
+                                      TUint aNewOrdinal,
+                                      MMPXCHelperObserver* aObserver);
+    
+public:
+    
+    TBool           iIncAdd;
+    TBool           iDelete;
+    CMPXMedia       *iMedia;
+    TBool           iValidRename;
+    TBool           iValidReorder;
+    TMPXItemId      iPlaylistId;
+    QString         iRenameTitle;
+
+};
+
+
+#endif // MMPXCOLLECTIONUIHELPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxcollectionutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#ifndef MMPXCOLLECTIONUTILITY_H
+#define MMPXCOLLECTIONUTILITY_H
+
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxcommonframeworkdefs.h>
+#include <mpxcollectionobserver.h>
+#include <mpxattribute.h>
+#include <mpxsearchcriteria.h>
+#include <mpxattributespecs.h>
+
+#include <badesca.h>
+
+
+//Forward declarations
+class CMPXCollectionPath;
+
+class MMPXCollection
+{
+public:
+    
+    // Stub functions interface
+    virtual void OpenL(TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
+    virtual void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
+    virtual void OpenL(const CMPXCollectionPath& aPath,
+                       TMPXOpenMode aMode=EMPXOpenDefault) = 0;
+    virtual CMPXCollectionPath* PathL() = 0;
+    virtual void BackL() = 0;
+    virtual void CancelRequest() = 0;
+    virtual CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
+                                const TArray<TMPXAttribute>& aAttrs) = 0;
+   
+};
+
+class MMPXCollectionUtility : public MMPXCollection
+{
+public:
+
+    // Test utility functions
+    void setPlaylists( const CMPXMedia& entries );
+
+    // Stub functions
+    static MMPXCollectionUtility* NewL( MMPXCollectionObserver* aObs = NULL,
+                                        const TUid& aModeId = KMcModeDefault);
+    MMPXCollectionUtility();
+    ~MMPXCollectionUtility();
+    MMPXCollection& Collection();
+    TUid CollectionIDL(const TArray<TUid>& aUids);
+    void Close();
+    
+    //From MMPXCollection
+    void OpenL(TMPXOpenMode aMode=EMPXOpenDefault);
+    void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault);
+    void OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode=EMPXOpenDefault);
+    CMPXCollectionPath* PathL();
+    void BackL();
+    void CancelRequest();
+    CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
+                                    const TArray<TMPXAttribute>& aAttrs);
+    
+public:
+ 
+    TBool          iBack;
+    TBool          iOpen;
+    TInt           iOpenCount;
+    TInt           iCountPath;
+    int            iIndex;
+    CMPXMedia      *iPlaylists; //Owned
+    CMPXMediaArray *iAlbumSongs; //Owned
+};
+
+
+
+
+
+#endif      // MMPXCOLLECTIONUTILITY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/inc/mpxplaybackutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxplaybackutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#ifndef MMPXPLAYBACKUTILITY_H
+#define MMPXPLAYBACKUTILITY_H
+
+#include <mpxplaybackframeworkdefs.h>
+#include <mpxcommonframeworkdefs.h>
+#include <badesca.h>
+#include <mpxattribute.h>
+#include <mpxattributespecs.h>
+
+//Forward declarations
+class CMPXCollectionPlaylist;
+
+class MMPXPlaybackUtility
+{
+public:
+
+    // Stub functions
+    MMPXPlaybackUtility();
+    ~MMPXPlaybackUtility();
+    static MMPXPlaybackUtility* UtilityL(const TUid& aModeId = KPbModeDefault);
+    void Close();
+    void InitL(const CMPXCollectionPlaylist& aPlaylist, TBool aPlay=ETrue);
+    void InitL(const TDesC& aUri, const TDesC8* aType=NULL);
+    void SetL(TMPXPlaybackProperty aProperty, TInt aValue);
+
+public:
+
+    TInt                    iShuffle;
+    TInt                    iRepeat;
+    TMPXPlaybackProperty    iProperty;
+    TBool                   iPlay;
+};
+
+#endif      // MMPXPLAYBACKUTILITY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpmpxcollectiondata.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MpMpxCollectionData stub for testing mpmpxframeworkwrapper
+*
+*/
+
+#include "mptrace.h"
+#include "stub/inc/mpmpxcollectiondata.h"
+#include <mpxmedia.h>
+
+
+/*!
+ Stub function.
+ */
+MpMpxCollectionData::MpMpxCollectionData()
+    :mContainerMedia(0),
+    mMediaSet(EFalse),
+    mContext (ECollectionContextUnknown)
+{   
+}
+
+/*!
+ Stub function.
+*/
+MpMpxCollectionData::~MpMpxCollectionData()
+{   
+}
+
+/*!
+ Stub function.
+*/
+TCollectionContext MpMpxCollectionData::context()
+{
+    return mContext;
+}
+
+/*!
+ Stub function.
+*/
+QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
+{
+    Q_UNUSED(index);
+    if ( type == MpMpxCollectionData::Uri ) {
+        return QString("Uri");
+    }
+    else {
+        return QString();
+    }
+}
+/*!
+ Stub function.
+*/
+void MpMpxCollectionData::setMpxMedia( const CMPXMedia& entries )
+{
+    delete mContainerMedia;
+    mContainerMedia = 0;
+    mContainerMedia = CMPXMedia::NewL(entries);
+    mMediaSet = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+const CMPXMedia& MpMpxCollectionData::containerMedia()
+{
+    return *mContainerMedia;
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpmpxisolatedcollectionhelper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolated collection helper stub for testing mpmpxframeworkwrapper.
+*
+*/
+
+
+#include <mpxcollectionpath.h>
+
+#include "stub/inc/mpmpxisolatedcollectionhelper.h"
+
+
+
+
+/*!
+ \internal
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    {
+    CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+/*!
+ \internal
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    {
+    CMpMpxIsolatedCollectionHelper* self =
+            new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+/*!
+ \internal
+ */
+CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
+    {
+    }
+    
+
+/*!
+ \internal
+ */
+void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath )
+    {
+    iCountPath = aPath.Count();
+    iOpen = ETrue;
+    iOpenCount++;
+    }
+
+/*!
+ \internal
+ */
+CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    : iObserver( aObserver ),
+      iOpen(EFalse),
+      iOpenCount(0),
+      iCountPath(0)
+    {
+    }
+
+    
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionhelperfactory.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+
+
+#include <e32debug.h>
+
+#include "stub/inc/mpxcollectionhelperfactory.h"
+#include "stub/inc/mpxcollectionuihelper.h"
+
+
+/*!
+ Stub function.
+ */
+MMPXCollectionUiHelper* CMPXCollectionHelperFactory::NewCollectionUiHelperL(const TUid& aModeId)
+{
+    Q_UNUSED(aModeId);
+    return new MMPXCollectionUiHelper();
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionopenutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionopenutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+
+#include <e32debug.h>
+#include <Qt>
+
+#include "stub/inc/mpxcollectionopenutility.h"
+
+
+/*!
+ Stub function.
+*/
+CMPXCollectionOpenUtility::CMPXCollectionOpenUtility():iDelay(0),
+                                                       iStart(EFalse),
+                                                       iStop(EFalse),
+                                                       iChunkSize(0),
+                                                       iDirection(EFetchDown)
+{
+    
+}
+
+/*!
+ Stub function.
+*/   
+CMPXCollectionOpenUtility* CMPXCollectionOpenUtility::NewL(MMPXCollectionObserver* aObs, TUid aMode)
+{
+    Q_UNUSED(aObs);
+    Q_UNUSED(aMode);
+    CMPXCollectionOpenUtility* collectionOpenUtility = new CMPXCollectionOpenUtility();
+    return collectionOpenUtility;
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionOpenUtility::~CMPXCollectionOpenUtility()
+{
+    
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::Stop()
+{
+    iStop=ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::SetDelay( TInt aDelay )
+{
+    iDelay = aDelay;
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::StartL( TArray<TMPXAttribute> aAttrs,
+                              TInt aChunkSize,
+                              TInt aOffset,
+                              TDirection aDirection,
+                              TMPXAttribute aKeyAttribute)
+{
+    Q_UNUSED(aAttrs);
+    Q_UNUSED(aOffset);
+    Q_UNUSED(aKeyAttribute);
+    iStart = ETrue;
+    iChunkSize = aChunkSize;
+    iDirection = aDirection;
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionuihelper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#include <mpxmedia.h>
+#include <mpxmediacollectiondetaildefs.h>
+#include <mpxcollectionpath.h>
+#include <mpxcollectionplugin.hrh>
+#include <e32debug.h>
+
+#include "stub/inc/mpxcollectionuihelper.h"
+const TInt KMPXAllSongsViewIndex = 0;
+const TInt KMPXPlaylistViewIndex = 1;
+
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUiHelper::MMPXCollectionUiHelper():iIncAdd(EFalse),
+                                                 iDelete(EFalse),
+                                                 iValidRename(EFalse),
+                                                 iValidReorder(EFalse),
+                                                 iMedia(0)
+{   
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUiHelper::~MMPXCollectionUiHelper()
+{   
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUiHelper::Close()
+{
+    delete this;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUiHelper::IncAddL( const CMPXMedia& aMedia,
+                          MMPXCHelperObserver* aObserver,
+                          const TInt aSize)
+{
+    Q_UNUSED(aObserver);
+    Q_UNUSED(aSize);
+    iIncAdd = ETrue;
+    delete iMedia;
+    iMedia = 0;
+    iMedia = CMPXMedia::NewL(aMedia);
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUiHelper::RenameL( const CMPXMedia& aMedia,
+                              MMPXCHelperObserver* aObserver )
+{
+    Q_UNUSED(aObserver);
+    iValidRename = EFalse;
+    TMPXGeneralType mediaType =
+            aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
+
+    TMPXGeneralCategory mediaCategory =
+            aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
+    
+    if ( mediaType == EMPXItem && mediaCategory == EMPXPlaylist ){
+        iValidRename = ETrue;
+    }
+    iPlaylistId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+    const TDesC& title = aMedia.ValueText(KMPXMediaGeneralTitle);
+    iRenameTitle = QString::fromUtf16(title.Ptr(), title.Length());
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUiHelper::ReorderPlaylistL(const TMPXItemId& aPlaylistId,
+                                  const TMPXItemId& aSongId,
+                                  TUint aOriginalOrdinal,
+                                  TUint aNewOrdinal,
+                                  MMPXCHelperObserver* aObserver)
+{
+    Q_UNUSED(aOriginalOrdinal);
+    Q_UNUSED(aNewOrdinal);
+    Q_UNUSED(aObserver);
+    iValidReorder = aPlaylistId != aSongId;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUiHelper::DeleteL( CMPXCollectionPath& aPath,
+                          MMPXCHelperObserver* aObserver )
+{
+    Q_UNUSED(aPath);
+    Q_UNUSED(aObserver);
+    iDelete = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionPath* MMPXCollectionUiHelper::MusicMenuPathL()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
+    path->AppendL( KMPXPlaylistViewIndex );
+    //Fake some elements for the path to make it unique
+    for(TInt i=0; i<10; i++){
+        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
+    }
+    CleanupStack::Pop( path );
+        
+    return path;    
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionPath* MMPXCollectionUiHelper::MusicAllSongsPathL()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
+    path->AppendL( KMPXPlaylistViewIndex );
+    //Fake some elements for the path to make it unique
+    for(TInt i=0; i<5; i++){
+        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
+    }
+    CleanupStack::Pop( path );
+        
+    return path;    
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionPath* MMPXCollectionUiHelper::MusicPlaylistPathL()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
+    path->AppendL( KMPXPlaylistViewIndex );
+    //Fake some elements for the path to make it unique
+    for(TInt i=0; i<3; i++){
+        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
+    }
+    CleanupStack::Pop( path );
+        
+    return path;    
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxcollectionutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#include <mpxmedia.h>
+#include <mpxmessage.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxcollectionmessage.h>
+#include <mpxcollectionmessagedefs.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediacollectiondetaildefs.h>
+#include <mpxcollectionplugin.hrh>
+#include <mpxcollectionpath.h>
+#include "mptrace.h"
+#include <e32debug.h>
+
+#include "stub/inc/mpxcollectionutility.h"
+const TInt KMPXAllSongsViewIndex = 0;
+const TInt KMPXPlaylistViewIndex = 1;
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility::MMPXCollectionUtility():iBack(EFalse),
+                                               iOpen(EFalse),
+                                               iIndex(0),
+                                               iOpenCount(0),
+                                               iCountPath(0),
+                                               iPlaylists(0),
+                                               iAlbumSongs(0)
+{
+    
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility::~MMPXCollectionUtility()
+{
+    if (iAlbumSongs)
+    {
+        delete iAlbumSongs;
+    }
+    if (iPlaylists)
+    {
+        delete iPlaylists;
+    }
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility* MMPXCollectionUtility::NewL(MMPXCollectionObserver* aObs, const TUid& aModeId)
+{
+    Q_UNUSED(aObs);
+    Q_UNUSED(aModeId);
+    MMPXCollectionUtility* temp = new MMPXCollectionUtility();
+    return temp;
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollection& MMPXCollectionUtility::Collection()
+{ 
+    return *this;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::Close()
+{
+    delete this;
+}
+
+/*!
+ Stub function.
+*/
+CMPXMedia* MMPXCollectionUtility::FindAllL(const CMPXSearchCriteria& aCriteria,
+                                    const TArray<TMPXAttribute>& aAttrs)
+{
+    Q_UNUSED(aAttrs);
+    
+    // Find Playlists
+    if(aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
+       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXPlaylist == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory))
+        {
+        return CMPXMedia::NewL(*iPlaylists);
+        }
+    // Find Album with ID
+    else if (aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
+       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXSong == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) &&
+       aCriteria.IsSupported(KMPXMediaGeneralId) && iAlbumSongs &&
+       //it is assumed that album ID matches index on the media array, just to make test logic more simple.
+       TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) >= 0 && TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) < iAlbumSongs->Count())
+        {
+        return CMPXMedia::NewL(*iAlbumSongs->AtL(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
+        }
+    else
+        {
+        return NULL;
+        }
+
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::CancelRequest()
+{   
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::BackL()
+{
+    iBack = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionPath* MMPXCollectionUtility::PathL()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
+    path->AppendL( KMPXPlaylistViewIndex );
+    //Fake some elements for the path
+    for(TInt i = 0; i < 10; i++){
+        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
+    }
+    CleanupStack::Pop( path );
+        
+    return path;
+}
+
+/*!
+ Stub function.
+*/
+TUid MMPXCollectionUtility::CollectionIDL(const TArray<TUid>& aUids)
+{ 
+    Q_UNUSED(aUids);
+    return TUid::Uid(EMPXCollectionPluginMusic);
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iOpen = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(TInt aIndex,TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iIndex = aIndex;  
+    iOpen = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iCountPath = aPath.Count();
+    iOpen = ETrue;
+    iOpenCount++;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::setPlaylists( const CMPXMedia& entries )
+{
+    delete iPlaylists;
+    iPlaylists = 0;
+    iPlaylists = CMPXMedia::NewL(entries);
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/stub/src/mpxplaybackutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxplaybackutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+#include <Qt>
+#include <mpxcollectionplaylist.h>
+#include <mptrace.h>
+
+#include "stub/inc/mpxplaybackutility.h"
+
+/*!
+ Stub function.
+*/
+MMPXPlaybackUtility::MMPXPlaybackUtility():iShuffle(-1),
+                                           iRepeat(-1),
+                                           iProperty(EPbPropertyVolume),
+                                           iPlay(EFalse)
+{
+}
+
+/*!
+ Stub function.
+*/
+MMPXPlaybackUtility::~MMPXPlaybackUtility()
+{
+}
+
+/*!
+ Stub function.
+ */
+MMPXPlaybackUtility* MMPXPlaybackUtility::UtilityL(const TUid& aModeId)
+{
+    Q_UNUSED(aModeId);
+    static MMPXPlaybackUtility playbackUtilility;
+    return &playbackUtilility;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXPlaybackUtility::Close()
+{
+}
+
+/*!
+ Stub function.
+*/
+void MMPXPlaybackUtility::InitL(const CMPXCollectionPlaylist& aPlaylist, TBool aPlay)
+{
+    Q_UNUSED(aPlaylist);
+    iPlay = aPlay;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXPlaybackUtility::InitL(const TDesC& aUri, const TDesC8* aType)
+{
+    Q_UNUSED(aUri);
+    Q_UNUSED(aType);
+    iPlay = ETrue;
+}
+
+
+/*!
+ Stub function.
+*/
+void MMPXPlaybackUtility::SetL(TMPXPlaybackProperty aProperty, TInt aValue)
+{
+    iProperty = aProperty;
+    if(iProperty == EPbPropertyRandomMode){
+        iShuffle = aValue;
+        TX_LOG_ARGS("PbUtility shuffle set to "<< aValue);
+    }else if (iProperty == EPbPropertyRepeatMode){
+        iRepeat = aValue;
+        TX_LOG_ARGS("PbUtility repeat set to "<< aValue);
+    }    
+    
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxcollectionframeworkwrapper/unittest_mpmpxcollectionframeworkwrapper.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,52 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description: Unit test for mpmpxframeworkwrapper
+TEMPLATE = app
+CONFIG += qtestlib \
+    hb
+TARGET = 
+
+TARGET.CAPABILITY = All -TCB
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../inc \
+    ../../../inc
+
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+LIBS += -lestor.dll \
+    -lfbscli.dll \
+    -lmpxcommon.dll \
+    -lmpxcollectionutility.dll \
+    -lmpsettingsmanager
+
+HEADERS += inc/unittest_mpmpxcollectionframeworkwrapper.h \
+    ../../inc/mpmpxcollectionframeworkwrapper.h \
+    ../../inc/mpmpxcollectionframeworkwrapper_p.h \
+    stub/inc/mpmpxcollectiondata.h \
+    stub/inc/mpxcollectionopenutility.h \
+    stub/inc/mpxcollectionuihelper.h \
+    stub/inc/mpxcollectionutility.h \
+    stub/inc/mpxcollectionhelperfactory.h \
+    stub/inc/mpxplaybackutility.h \
+    stub/inc/mpmpxisolatedcollectionhelper.h
+
+SOURCES += src/unittest_mpmpxcollectionframeworkwrapper.cpp \
+    ../../src/mpmpxcollectionframeworkwrapper.cpp \
+    stub/src/mpmpxcollectiondata.cpp \
+    stub/src/mpxcollectionopenutility.cpp \
+    stub/src/mpxcollectionuihelper.cpp \
+    stub/src/mpxcollectionutility.cpp \
+    stub/src/mpxcollectionhelperfactory.cpp \
+    stub/src/mpxplaybackutility.cpp \
+    stub/src/mpmpxisolatedcollectionhelper.cpp
+
+# RESOURCES += ../../resources/mpcollectionviewresources.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/inc/unittest_mpmpxharvesterframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpmpxharvesterframeworkwrapper
+*
+*/
+
+#ifndef TESTMPMPXHARVESTERFRAMEWORKWRAPPER_H
+#define TESTMPMPXHARVESTERFRAMEWORKWRAPPER_H
+
+#include <QtTest/QtTest>
+
+class MpMpxHarvesterFrameworkWrapper;
+class MpMpxHarvesterFrameworkWrapperPrivate;
+
+class TestMpMpxHarvesterFrameworkWrapper : public QObject
+{
+    Q_OBJECT
+
+public:
+    TestMpMpxHarvesterFrameworkWrapper();
+    virtual ~TestMpMpxHarvesterFrameworkWrapper();
+
+public slots:
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+    void testConstructor();    
+    void testScan();
+    void testCancelScan();
+    void testHandleCollectionMessageRefreshing();
+    void testHandleCollectionMessageDisk();
+    void testHandleCollectionMessageUSB();
+    void testBroadcastEventFilter();
+    void testCheckForSystemEvents();
+
+private:
+
+    MpMpxHarvesterFrameworkWrapper           *mTest;
+    MpMpxHarvesterFrameworkWrapperPrivate    *mTestPrivate;
+
+};
+
+#endif  // TESTMPMPXHARVESTERFRAMEWORKWRAPPER_H
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/src/unittest_mpmpxharvesterframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,418 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for mpmpxharvesterframeworkwrapper
+*
+*/
+
+#include <QSignalSpy>
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+#include <mpxmedia.h>
+#include <mpxcollectionplaylist.h>
+
+#include "unittest_mpmpxharvesterframeworkwrapper.h"
+#include "stub/inc/mpxcollectionutility.h"
+#include "stub/inc/mpxharvesterutility.h"
+
+// Do this so we can access all member variables.
+#define private public
+#include "mpmpxharvesterframeworkwrapper.h"
+#include "mpmpxharvesterframeworkwrapper_p.h"
+#undef private
+
+//This so we can test private functions
+#include "mpmpxharvesterframeworkwrapper_p.cpp"
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMpMpxHarvesterFrameworkWrapper tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpmpxharvesterframeworkwrapper.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMpMpxHarvesterFrameworkWrapper::TestMpMpxHarvesterFrameworkWrapper()
+    : mTest(0)
+{
+}
+
+TestMpMpxHarvesterFrameworkWrapper::~TestMpMpxHarvesterFrameworkWrapper()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::init()
+{
+    mTest = new MpMpxHarvesterFrameworkWrapper();
+    mTestPrivate = mTest->d_ptr;
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests constructor.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testConstructor()
+{
+    QVERIFY( mTestPrivate->iCollectionUtility != 0 );
+    QVERIFY( mTestPrivate->iHarvesterUtility != 0 );
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iCheckSystemEvents, TBool(ETrue) );
+}
+
+/*!
+ Tests scan
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testScan()
+{
+    mTest->scan();
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iScan, TBool(ETrue) );
+}
+
+/*!
+ Tests cancelScan
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testCancelScan()
+{
+    mTestPrivate->iHarvesterUtility->iScan = ETrue;
+    mTest->cancelScan();
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iScan, TBool(EFalse) );
+    
+    mTestPrivate->iHarvesterUtility->iScan = ETrue;
+    mTestPrivate->iHarvesterUtility->iLeave = ETrue;
+    mTest->cancelScan();
+    QVERIFY( mTestPrivate->iHarvesterUtility != 0 );
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iCheckSystemEvents, TBool(ETrue) );
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iScan, TBool(EFalse) );
+}
+
+/*!
+ Tests handleCollectionMessage for Refreshing events. Part of private implementation.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testHandleCollectionMessageRefreshing()
+{
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMessageContentIdGeneral );
+    CMPXMedia* testMessage = CMPXMedia::NewL( supportedIds.Array() );
+    CleanupStack::PopAndDestroy( &supportedIds );
+    CleanupStack::PushL( testMessage );
+    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
+        
+    //Refresh ended
+    QSignalSpy spy( mTest, SIGNAL( scanEnded( int, int ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgRefreshEnd );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, KErrCancel);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( mTestPrivate->iScanning, TBool( EFalse ) );   
+    QCOMPARE( spy.count(), 1 );
+    QList<QVariant> arguments = spy.takeFirst();
+    TInt count = arguments.at(0).toInt();    
+    QCOMPARE(count, mTestPrivate->iNumItemsAdded);    
+    TInt error = arguments.at(1).toInt();
+    QCOMPARE( error, KErrCancel );
+        
+    //Refresh started
+    cleanup();
+    init();
+    QSignalSpy spy2(mTest, SIGNAL( scanStarted( void ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgRefreshStart );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0 );
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( mTestPrivate->iScanning, TBool( ETrue ) );   
+    QCOMPARE( spy2.count(), 1 );       
+
+    //Items changed
+    cleanup();
+    init();
+    QSignalSpy spy3( mTest, SIGNAL( scanCountChanged( int ) ) );
+    mTest->scan();
+    
+    //Emulate Harvester started refreshing
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    
+    RArray<TInt> supportedIds2;
+    CleanupClosePushL( supportedIds2 );
+    supportedIds2.AppendL( KMPXMessageContentIdGeneral );
+    supportedIds2.AppendL( KMPXMessageIdContainer );
+    CMPXMedia* testMessage2 = CMPXMedia::NewL( supportedIds2.Array() );
+    CleanupStack::PopAndDestroy( &supportedIds2 );
+    CleanupStack::PushL( testMessage2 );
+        
+    CMPXMessageArray* array = CMPXMessageArray::NewL();
+    CleanupStack::PushL(array);
+    //EMPXNoCategory, EMPXCollection, EMPXPlaylist, EMPXSong, EMPXPodcast three possible and two extra items
+    for (TInt i =0; i < 5; i++) {
+        RArray<TInt> supportedIds3;
+        CleanupClosePushL( supportedIds3 );
+        supportedIds2.AppendL( KMPXMessageContentIdGeneral );
+        CMPXMedia* media = CMPXMedia::NewL(supportedIds3.Array());
+        CleanupStack::PopAndDestroy(&supportedIds3);
+        CleanupStack::PushL(media);
+        media->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, EMPXItemInserted);
+        media->SetTObjectValueL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory, TMPXGeneralCategory(i));
+        media->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageIdItemChanged);
+        array->AppendL( *media );
+        CleanupStack::PopAndDestroy( media );
+    }
+    testMessage2->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageIdItemChanged); 
+    testMessage2->SetCObjectValueL( KMPXMessageArrayContents, array );
+    testMessage2->SetTObjectValueL<TInt>( KMPXMessageArrayCount, array->Count() );
+    CleanupStack::PopAndDestroy( array );
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage2 );
+    CleanupStack::PopAndDestroy( testMessage2 );
+    QCOMPARE( mTestPrivate->iNumItemsAdded, 3 );
+    QCOMPARE( spy3.count(), 1 );
+    TInt itemsCount = qvariant_cast<int>( spy3.at( 0 ).at( 0 ) );
+    QCOMPARE( itemsCount, mTestPrivate->iNumItemsAdded );
+    
+    CleanupStack::PopAndDestroy( testMessage );
+}
+
+/*!
+ Tests handleCollectionMessage for Disk events. Part of private implementation.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testHandleCollectionMessageDisk()
+{
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMessageContentIdGeneral );
+    CMPXMedia* testMessage = CMPXMedia::NewL( supportedIds.Array() );
+    CleanupStack::PopAndDestroy( &supportedIds );
+    CleanupStack::PushL( testMessage );
+    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
+        
+    qRegisterMetaType<MpxDiskEvents>("MpxDiskEvents");
+
+    //Format started
+    QSignalSpy spy( mTest, SIGNAL( diskEvent( MpxDiskEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgFormatStart );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy.count(), 1 );
+    TInt diskEvent = qvariant_cast<MpxDiskEvents>( spy.at( 0 ).at( 0 ) );
+    QVERIFY( diskEvent == DiskFormatStarted );    
+        
+    //Format ended
+    cleanup();
+    init();
+    QSignalSpy spy2( mTest, SIGNAL( diskEvent( MpxDiskEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgFormatEnd );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy2.count(), 1 );
+    TInt diskEvent2 = qvariant_cast<MpxDiskEvents>( spy2.at( 0 ).at( 0 ) );
+    QVERIFY( diskEvent2 == DiskFormatEnded );
+    
+    //Disk removed
+    cleanup();
+    init();
+    QSignalSpy spy3( mTest, SIGNAL( diskEvent( MpxDiskEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgDiskRemoved );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy3.count(), 1 );
+    TInt diskEvent3 = qvariant_cast<MpxDiskEvents>( spy3.at( 0 ).at( 0 ) );
+    QVERIFY( diskEvent3 == DiskRemoved );
+    
+    //Disk inserted
+    cleanup();
+    init();
+    QSignalSpy spy4( mTest, SIGNAL( diskEvent( MpxDiskEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgDiskInserted );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy4.count(), 1 );
+    TInt diskEvent4 = qvariant_cast<MpxDiskEvents>( spy4.at( 0 ).at( 0 ) );
+    QVERIFY( diskEvent4 == DiskInserted );
+    
+    CleanupStack::PopAndDestroy( testMessage );
+}
+
+/*!
+ Tests handleCollectionMessage for USB events. Part of private implementation.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testHandleCollectionMessageUSB()
+{
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMessageContentIdGeneral );
+    CMPXMedia* testMessage = CMPXMedia::NewL( supportedIds.Array() );
+    CleanupStack::PopAndDestroy( &supportedIds );
+    CleanupStack::PushL( testMessage );
+    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
+        
+    qRegisterMetaType<MpxUsbEvents>("MpxUsbEvents");
+
+    //USB Mass storage started
+    QSignalSpy spy( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMassStorageStart );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy.count(), 1 );
+    TInt usbEvent = qvariant_cast<MpxUsbEvents>( spy.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent == UsbMassStorageStarted );    
+        
+    //USB Mass storage ended
+    cleanup();
+    init();
+    QSignalSpy spy2( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMassStorageEnd );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy2.count(), 1 );
+    TInt usbEvent2 = qvariant_cast<MpxUsbEvents>( spy2.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent2 == UsbMassStorageEnded );
+    
+    //USB MTP started
+    cleanup();
+    init();
+    QSignalSpy spy3( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMTPStart );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy3.count(), 1 );
+    TInt usbEvent3 = qvariant_cast<MpxUsbEvents>( spy3.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent3 == UsbMtpStarted );
+    
+    //USB MTP ended
+    cleanup();
+    init();
+    QSignalSpy spy4( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMTPEnd );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy4.count(), 1 );
+    TInt usbEvent4 = qvariant_cast<MpxUsbEvents>( spy4.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent4 == UsbMtpEnded );
+    
+    //USB MTP NotActive
+    cleanup();
+    init();
+    QSignalSpy spy5( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMTPNotActive );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QCOMPARE( spy5.count(), 1 );
+    TInt usbEvent5 = qvariant_cast<MpxUsbEvents>( spy5.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent5 == UsbMtpNotActive );
+    
+    CleanupStack::PopAndDestroy( testMessage );
+}
+
+/*!
+ Tests broadcastEventFilter. Part of private implementation.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testBroadcastEventFilter()
+{
+    RArray<TInt> supportedIds;
+    CleanupClosePushL( supportedIds );
+    supportedIds.AppendL( KMPXMessageContentIdGeneral );
+    CMPXMedia* testMessage = CMPXMedia::NewL( supportedIds.Array() );
+    CleanupStack::PopAndDestroy( &supportedIds );
+    CleanupStack::PushL( testMessage );
+    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
+        
+    qRegisterMetaType<MpxUsbEvents>("MpxUsbEvents");
+
+    //Verify default values:
+    QVERIFY( mTestPrivate->iPreviousBroadCastMsg == NoPreviousBroadCastMsg ); 
+    
+    //Send USB Mass storage started message, usbEvent signal should be emitted
+    QSignalSpy spy( mTest, SIGNAL( usbEvent( MpxUsbEvents ) ) );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMassStorageStart );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );    
+    QVERIFY( mTestPrivate->iPreviousBroadCastMsg == EMcMsgUSBMassStorageStart );
+    QCOMPARE( spy.count(), 1 );    
+    TInt usbEvent = qvariant_cast<MpxUsbEvents>( spy.at( 0 ).at( 0 ) );
+    QVERIFY( usbEvent == UsbMassStorageStarted );
+    
+    //Send for second time USB Mass storage started message, same message no new signal should be emitted
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QVERIFY( mTestPrivate->iPreviousBroadCastMsg == EMcMsgUSBMassStorageStart );
+    QCOMPARE( spy.count(), 1 );    
+        
+    //Send USB Mass storage ended, different message new signal should be emitted
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, EMcMsgUSBMassStorageEnd );
+    testMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0);
+    mTestPrivate->DoHandleCollectionMessageL( *testMessage );
+    QVERIFY( mTestPrivate->iPreviousBroadCastMsg == EMcMsgUSBMassStorageEnd );
+    QCOMPARE( spy.count(), 2 );
+    TInt usbEvent2 = qvariant_cast<MpxUsbEvents>( spy.at( 1 ).at( 0 ) );
+    QVERIFY( usbEvent2 == UsbMassStorageEnded );
+    
+    CleanupStack::PopAndDestroy( testMessage );
+}
+
+/*!
+ Tests testCheckForSystemEvents. Part of private implementation.
+ */
+void TestMpMpxHarvesterFrameworkWrapper::testCheckForSystemEvents()
+{
+    mTest->checkForSystemEvents();
+    QVERIFY( mTestPrivate->iPreviousBroadCastMsg == NoPreviousBroadCastMsg );    
+    QCOMPARE( mTestPrivate->iHarvesterUtility->iCheckSystemEvents, TBool(ETrue) );
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/inc/mpxcollectionutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#ifndef MMPXCOLLECTIONUTILITY_H
+#define MMPXCOLLECTIONUTILITY_H
+
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxcommonframeworkdefs.h>
+#include <mpxcollectionobserver.h>
+#include <mpxattribute.h>
+#include <mpxsearchcriteria.h>
+#include <mpxattributespecs.h>
+
+#include <badesca.h>
+
+
+//Forward declarations
+class CMPXCollectionPath;
+
+class MMPXCollection
+{
+public:
+    
+    // Stub functions interface
+    virtual void OpenL(TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
+    virtual void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
+    virtual void OpenL(const CMPXCollectionPath& aPath,
+                       TMPXOpenMode aMode=EMPXOpenDefault) = 0;
+    virtual CMPXCollectionPath* PathL() = 0;
+    virtual void BackL() = 0;
+    virtual void CancelRequest() = 0;
+    virtual CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
+                                const TArray<TMPXAttribute>& aAttrs) = 0;
+   
+};
+
+class MMPXCollectionUtility : public MMPXCollection
+{
+public:
+
+    // Test utility functions
+    void setPlaylists( const CMPXMedia& entries );
+
+    // Stub functions
+    static MMPXCollectionUtility* NewL( MMPXCollectionObserver* aObs = NULL,
+                                        const TUid& aModeId = KMcModeDefault);
+    MMPXCollectionUtility();
+    ~MMPXCollectionUtility();
+    MMPXCollection& Collection();
+    TUid CollectionIDL(const TArray<TUid>& aUids);
+    void Close();
+    
+    //From MMPXCollection
+    void OpenL(TMPXOpenMode aMode=EMPXOpenDefault);
+    void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault);
+    void OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode=EMPXOpenDefault);
+    CMPXCollectionPath* PathL();
+    void BackL();
+    void CancelRequest();
+    CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
+                                    const TArray<TMPXAttribute>& aAttrs);
+    
+public:
+ 
+    TBool          iBack;
+    TBool          iOpen;
+    TInt           iOpenCount;
+    TInt           iCountPath;
+    int            iIndex;
+    CMPXMedia      *iPlaylists; //Owned
+    CMPXMediaArray *iAlbumSongs; //Owned
+};
+
+
+
+
+
+#endif      // MMPXCOLLECTIONUTILITY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/inc/mpxharvesterutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Harvester Utility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#ifndef MMPXHARVESTERUTILITY_H
+#define MMPXHARVESTERUTILITY_H
+
+#include <bamdesca.h>
+
+
+class MMPXHarvesterUtility
+{
+
+public:
+    
+    //Stub Functions
+    MMPXHarvesterUtility();
+    ~MMPXHarvesterUtility();
+    void ScanL();
+    void CancelScanL();
+    void CheckForSystemEventsL();
+    void Close();
+    
+public:
+    TBool   iScan;
+    TBool   iCheckSystemEvents;
+    TBool   iLeave;
+  
+};
+
+//  Utility Factory class to create the utility
+
+class CMPXHarvesterFactory : CBase
+{
+public:
+    
+    //Factory stub function to create the utility
+
+    static MMPXHarvesterUtility* NewL();
+};
+
+
+#endif // MMPXHARVESTERUTILITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/src/mpxcollectionutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#include <mpxmedia.h>
+#include <mpxmessage.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxcollectionmessage.h>
+#include <mpxcollectionmessagedefs.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediacollectiondetaildefs.h>
+#include <mpxcollectionplugin.hrh>
+#include <mpxcollectionpath.h>
+#include "mptrace.h"
+#include <e32debug.h>
+
+#include "stub/inc/mpxcollectionutility.h"
+const TInt KMPXAllSongsViewIndex = 0;
+const TInt KMPXPlaylistViewIndex = 1;
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility::MMPXCollectionUtility():iBack(EFalse),
+                                               iOpen(EFalse),
+                                               iIndex(0),
+                                               iOpenCount(0),
+                                               iCountPath(0),
+                                               iPlaylists(0),
+                                               iAlbumSongs(0)
+{
+    
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility::~MMPXCollectionUtility()
+{
+    if (iAlbumSongs)
+    {
+        delete iAlbumSongs;
+    }
+    if (iPlaylists)
+    {
+        delete iPlaylists;
+    }
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollectionUtility* MMPXCollectionUtility::NewL(MMPXCollectionObserver* aObs, const TUid& aModeId)
+{
+    Q_UNUSED(aObs);
+    Q_UNUSED(aModeId);
+    MMPXCollectionUtility* temp = new MMPXCollectionUtility();
+    return temp;
+}
+
+/*!
+ Stub function.
+*/
+MMPXCollection& MMPXCollectionUtility::Collection()
+{ 
+    return *this;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::Close()
+{
+    delete this;
+}
+
+/*!
+ Stub function.
+*/
+CMPXMedia* MMPXCollectionUtility::FindAllL(const CMPXSearchCriteria& aCriteria,
+                                    const TArray<TMPXAttribute>& aAttrs)
+{
+    Q_UNUSED(aAttrs);
+    
+    // Find Playlists
+    if(aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
+       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXPlaylist == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory))
+        {
+        return CMPXMedia::NewL(*iPlaylists);
+        }
+    // Find Album with ID
+    else if (aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
+       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXSong == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) &&
+       aCriteria.IsSupported(KMPXMediaGeneralId) && iAlbumSongs &&
+       //it is assumed that album ID matches index on the media array, just to make test logic more simple.
+       TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) >= 0 && TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) < iAlbumSongs->Count())
+        {
+        return CMPXMedia::NewL(*iAlbumSongs->AtL(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
+        }
+    else
+        {
+        return NULL;
+        }
+
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::CancelRequest()
+{   
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::BackL()
+{
+    iBack = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionPath* MMPXCollectionUtility::PathL()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
+    path->AppendL( KMPXPlaylistViewIndex );
+    //Fake some elements for the path
+    for(TInt i = 0; i < 10; i++){
+        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
+    }
+    CleanupStack::Pop( path );
+        
+    return path;
+}
+
+/*!
+ Stub function.
+*/
+TUid MMPXCollectionUtility::CollectionIDL(const TArray<TUid>& aUids)
+{ 
+    Q_UNUSED(aUids);
+    return TUid::Uid(EMPXCollectionPluginMusic);
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iOpen = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(TInt aIndex,TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iIndex = aIndex;  
+    iOpen = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode)
+{
+    Q_UNUSED(aMode);
+    iCountPath = aPath.Count();
+    iOpen = ETrue;
+    iOpenCount++;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXCollectionUtility::setPlaylists( const CMPXMedia& entries )
+{
+    delete iPlaylists;
+    iPlaylists = 0;
+    iPlaylists = CMPXMedia::NewL(entries);
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/stub/src/mpxharvesterutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Harvester Utility stub for testing mpmpxframeworkwrapper
+*
+*/
+
+
+#include <e32base.h>
+#include "stub/inc/mpxharvesterutility.h"
+
+/*!
+ Stub function.
+*/
+MMPXHarvesterUtility::MMPXHarvesterUtility():iCheckSystemEvents(EFalse),
+                                             iScan(EFalse),
+                                             iLeave(EFalse)
+{
+}
+
+/*!
+ Stub function.
+*/
+MMPXHarvesterUtility::~MMPXHarvesterUtility()
+{
+}
+
+/*!
+ Stub function.
+*/
+void MMPXHarvesterUtility::ScanL()
+{
+    iScan = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXHarvesterUtility::CancelScanL()
+{
+    if(iLeave){
+        User::Leave(KErrNotFound);
+    }else{
+        iScan = EFalse;
+    }
+    
+}
+
+/*!
+ Stub function.
+*/
+void MMPXHarvesterUtility::CheckForSystemEventsL()
+{
+    iCheckSystemEvents = ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void MMPXHarvesterUtility::Close()
+{
+    delete this;
+}
+
+/*!
+ Stub function.
+*/
+MMPXHarvesterUtility* CMPXHarvesterFactory::NewL()
+{
+    return new MMPXHarvesterUtility();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxharvesterframeworkwrapper/unittest_mpmpxharvesterframeworkwrapper.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,40 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description: Unit test for mpmpxframeworkwrapper
+TEMPLATE = app
+CONFIG += qtestlib \
+    hb
+TARGET = 
+
+TARGET.CAPABILITY = All -TCB
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../inc \
+    ../../../inc
+
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+LIBS += -lestor.dll \
+    -lfbscli.dll \
+    -lmpxcommon.dll \
+    -lmpxcollectionutility.dll
+
+HEADERS += inc/unittest_mpmpxharvesterframeworkwrapper.h \
+    ../../inc/mpmpxharvesterframeworkwrapper.h \
+    ../../inc/mpmpxharvesterframeworkwrapper_p.h \
+    stub/inc/mpxcollectionutility.h \
+    stub/inc/mpxharvesterutility.h
+
+SOURCES += src/unittest_mpmpxharvesterframeworkwrapper.cpp \
+    ../../src/mpmpxharvesterframeworkwrapper.cpp \
+    stub/src/mpxcollectionutility.cpp \
+    stub/src/mpxharvesterutility.cpp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/inc/unittest_mpmpxisolatedcollectionhelper.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for CMpMpxIsolatedCollectionHelper
+*
+*/
+
+#ifndef TESTMPMPXISOLATEDCOLLECTIONHELPER_H
+#define TESTMPMPXISOLATEDCOLLECTIONHELPER_H
+
+#include <QtTest/QtTest>
+
+/* in our unit test usually this goes on the CPP file, but in this case we need it here to get
+ the observer interface, and also the mpxcollectionopenutility stub before the tested class so 
+ we get the stub instead of the normal mpxcollectionopenutility.*/
+#include "stub/inc/mpxcollectionopenutility.h"
+// Do this so we can access all member variables.
+#define private public
+#include "mpmpxisolatedcollectionhelper.h"
+#undef private
+
+class CMpMpxIsolatedCollectionHelper;
+class CMPXMedia;
+
+class TestCMpMpxIsolatedCollectionHelper : public QObject,
+                                                  MMpMpxIsolatedCollectionHelperObserver
+{
+    Q_OBJECT
+
+public:
+
+    TestCMpMpxIsolatedCollectionHelper();
+    virtual ~TestCMpMpxIsolatedCollectionHelper();
+
+private:
+    
+    void HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError );
+    
+public slots:
+
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+
+    void testConstructor();
+    void testOpenCollection();
+    void testHandleOpen();
+
+private:
+
+    CMpMpxIsolatedCollectionHelper  *mTest;
+    const CMPXMedia                 *iEntriesFromoOpenCallback; //not own
+    TInt                             iErrorFromoOpenCallback;
+    TInt                             iOpenCallbackCounter;
+
+};
+
+#endif  // TESTMPMPXISOLATEDCOLLECTIONHELPER_H
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/src/unittest_mpmpxisolatedcollectionhelper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for CMpMpxIsolatedCollectionHelper
+*
+*/
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+#include <mpxmedia.h>
+#include <mpxcollectionplaylist.h>
+#include <mpxcollectionpath.h>
+
+#include "unittest_mpmpxisolatedcollectionhelper.h"
+
+
+//This so we can test private functions
+#include "../../src/mpmpxisolatedcollectionhelper.cpp"
+
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestCMpMpxIsolatedCollectionHelper tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_mpmpxisolatedcollectionhelper.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestCMpMpxIsolatedCollectionHelper::TestCMpMpxIsolatedCollectionHelper()
+    : mTest( 0 ),
+      iEntriesFromoOpenCallback ( 0 ),
+      iErrorFromoOpenCallback( KErrNone ),
+      iOpenCallbackCounter( 0 )
+{
+}
+
+TestCMpMpxIsolatedCollectionHelper::~TestCMpMpxIsolatedCollectionHelper()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestCMpMpxIsolatedCollectionHelper::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestCMpMpxIsolatedCollectionHelper::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestCMpMpxIsolatedCollectionHelper::init()
+{
+    mTest = CMpMpxIsolatedCollectionHelper::NewL( this );
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestCMpMpxIsolatedCollectionHelper::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests constructor.
+*/
+void TestCMpMpxIsolatedCollectionHelper::testConstructor()
+{
+    QVERIFY(mTest->iIncrementalOpenUtil != 0);
+    QCOMPARE(mTest->iIncrementalOpenUtil->iMode , KMcModeIsolated);
+    QCOMPARE(mTest->iObserver , dynamic_cast<MMpMpxIsolatedCollectionHelperObserver*>(this));
+}
+
+/*!
+ Tests OpenCollection.
+ */
+void TestCMpMpxIsolatedCollectionHelper::testOpenCollection()
+{
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    mTest->OpenCollectionL(*path);
+    QCOMPARE(mTest->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
+    QCOMPARE(mTest->iIncrementalOpenUtil->iStop,TBool(ETrue));
+    QCOMPARE(mTest->iIncrementalOpenUtil->iStart,TBool(ETrue));
+    QCOMPARE(mTest->iFirstIncrementalOpen,TBool(ETrue));
+    QCOMPARE(mTest->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
+    QCOMPARE(mTest->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
+    QCOMPARE((int)mTest->iIncrementalOpenUtil->iPath, (int)path);
+    delete path;
+}
+
+/*!
+ Tests HandleOpen.
+ */
+void TestCMpMpxIsolatedCollectionHelper::testHandleOpen()
+{
+     iEntriesFromoOpenCallback = 0;
+     iErrorFromoOpenCallback = KErrArgument;
+     iOpenCallbackCounter = 0;
+     CMPXMedia *media = CMPXMedia::NewL();
+     mTest->iFirstIncrementalOpen = ETrue;
+     mTest->HandleOpenL(*media, 0, false, KErrNone);
+     QCOMPARE((int)iEntriesFromoOpenCallback,(int)media);
+     QCOMPARE(iErrorFromoOpenCallback,KErrNone);
+     QCOMPARE(iOpenCallbackCounter,1);
+}
+ 
+/*!
+ Used to keep track of the callback from teh isolated collection helper.
+ */
+void TestCMpMpxIsolatedCollectionHelper::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
+{
+     iEntriesFromoOpenCallback = &aEntries;
+     iErrorFromoOpenCallback = aError;
+     iOpenCallbackCounter++;
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/inc/mpxcollectionopenutility.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  mpxcollectionopenutility stub for testing CMpMpxIsolatedCollectionHelper
+*
+*/
+
+
+#ifndef C_CMPXCOLLECTIONOPENUTILITY_H
+#define C_CMPXCOLLECTIONOPENUTILITY_H
+
+#include <mpxcollectionobserver.h>
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxcollectionopenlresultdef.h>
+
+class CMPXCollectionPath;
+
+class CMPXCollectionOpenUtility  
+{
+public:
+    
+    // Stub functions
+    enum TDirection
+        {
+        EFetchNormal,
+        EFetchUp,
+        EFetchDown
+        };
+     static CMPXCollectionOpenUtility* NewL( MMPXCollectionObserver* aObs, TUid aMode = KMcModeDefault );
+     CMPXCollectionOpenUtility();
+     ~CMPXCollectionOpenUtility();
+     void StartL( const CMPXCollectionPath& aPath,
+                              TArray<TMPXAttribute> aAttrs,
+                              TInt aChunkSize,
+                              TInt aOffset = 0,
+                              TDirection aDirection = EFetchNormal,
+                              TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute );
+     void Stop();
+     void SetDelay( TInt aDelay );
+public:
+     TInt                      iDelay;
+     TInt                      iChunkSize;
+     TBool                     iStop;
+     TBool                     iStart;
+     TDirection                iDirection;
+     const CMPXCollectionPath *iPath; //not own
+     TUid                      iMode;
+    };
+
+#endif // C_CMPXCOLLECTIONOPENUTILITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/src/mpxcollectionopenutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mpxcollectionopenutility stub for testing CMpMpxIsolatedCollectionHelper
+*
+*/
+
+
+
+#include <e32debug.h>
+#include <Qt>
+
+#include "stub/inc/mpxcollectionopenutility.h"
+
+
+/*!
+ Stub function.
+*/
+CMPXCollectionOpenUtility::CMPXCollectionOpenUtility():iDelay(0),
+                                                       iStart(EFalse),
+                                                       iStop(EFalse),
+                                                       iChunkSize(0),
+                                                       iDirection(EFetchDown),
+                                                       iMode(TUid::Null())
+{
+    
+}
+
+/*!
+ Stub function.
+*/   
+CMPXCollectionOpenUtility* CMPXCollectionOpenUtility::NewL(MMPXCollectionObserver* aObs, TUid aMode)
+{
+    Q_UNUSED(aObs);
+    CMPXCollectionOpenUtility* collectionOpenUtility = new CMPXCollectionOpenUtility();
+    collectionOpenUtility->iMode = aMode;
+    return collectionOpenUtility;
+}
+
+/*!
+ Stub function.
+*/
+CMPXCollectionOpenUtility::~CMPXCollectionOpenUtility()
+{
+    
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::Stop()
+{
+    iStop=ETrue;
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::SetDelay( TInt aDelay )
+{
+    iDelay = aDelay;
+}
+
+/*!
+ Stub function.
+*/
+void CMPXCollectionOpenUtility::StartL( const CMPXCollectionPath& aPath,
+                              TArray<TMPXAttribute> aAttrs,
+                              TInt aChunkSize,
+                              TInt aOffset,
+                              TDirection aDirection,
+                              TMPXAttribute aKeyAttribute)
+{
+    Q_UNUSED(aAttrs);
+    Q_UNUSED(aOffset);
+    Q_UNUSED(aKeyAttribute);
+    iPath = &aPath;
+    iStart = ETrue;
+    iChunkSize = aChunkSize;
+    iDirection = aDirection;
+}
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/unittest_mpmpxisolatedcollectionhelper.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,35 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description: Unit test for CMpMpxIsolatedCollectionHelper
+TEMPLATE = app
+CONFIG += qtestlib \
+    hb
+TARGET = 
+
+TARGET.CAPABILITY = All -TCB
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../inc \
+    ../../../inc
+
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+LIBS += -lestor.dll \
+    -lfbscli.dll \
+    -lmpxcommon.dll \
+    -lmpxcollectionutility.dll
+
+HEADERS += inc/unittest_mpmpxisolatedcollectionhelper.h \
+    ../../inc/mpmpxisolatedcollectionhelper.h \
+    stub/inc/mpxcollectionopenutility.h
+
+SOURCES += src/unittest_mpmpxisolatedcollectionhelper.cpp \
+        stub/src/mpxcollectionopenutility.cpp
--- a/mpserviceplugins/audioeffects/group/mpxaudioeffectengine.mmp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/audioeffects/group/mpxaudioeffectengine.mmp	Mon May 03 12:29:20 2010 +0300
@@ -34,7 +34,6 @@
 
 USERINCLUDE     ../inc
 USERINCLUDE     ../../inc
-//USERINCLUDE     ../../../../inc	// remove because of checksource error
 
 APP_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE   /epoc32/include/mmf/common
--- a/mpserviceplugins/inc/mpxdbcommonutil.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/inc/mpxdbcommonutil.h	Mon May 03 12:29:20 2010 +0300
@@ -410,6 +410,19 @@
         */
         IMPORT_C static TPtrC GetColumnTextL(RSqlStatement& aStatement, TInt aField);
 
+        /**
+        * Constructs an item changed message and adds it to the array
+        * @param aMessageArray array to add the message to
+        * @param aId item ID
+        * @param aChangeType change type
+        * @param aCategory category of the item changed
+        * @param aUid plugin UID
+        * @param aAlbumArt is the flag for album art changed
+        * @param aDeprecatedId deprecated id of the item after it's been moved/renamed
+        */
+        IMPORT_C static void AddItemAlbumChangedMessageL(CMPXMessageArray& aMessageArray, TMPXItemId aId,
+            TMPXChangeEventType aChangeType, TMPXGeneralCategory aCategory, TUint aUid,
+            TBool aAlbumArt, TMPXItemId aDeprecatedId = 0 );
     private:
         /**
         * Create a media object with title, type, category and ID and push onto the CS.
--- a/mpserviceplugins/inc/mpxdbmanager.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/inc/mpxdbmanager.h	Mon May 03 12:29:20 2010 +0300
@@ -293,6 +293,130 @@
         IMPORT_C RSqlStatement ExecuteSelectQueryOnAllDrivesL(TInt aDrive, TRefByValue<const TDesC> aFmt,
             ...);
 
+        /**
+        * Copy all databases from RAM disk back to normal drive, E, F,...
+        * 
+        * @return none
+        */
+        IMPORT_C void CopyDBsFromRamL(); 
+
+        /**
+        * Copy all databases to RAM disk back from normal drive, E, F,...
+        * 
+        * @return none
+        */
+        IMPORT_C void CopyDBsToRamL( TBool aIsMTPInUse = EFalse);
+        
+
+        /**
+        * Check if RAM disk is enough to operatte. If not, DBs will be copied back to drives.
+        *
+        * @return TInt index to the database handler
+        */
+        IMPORT_C void EnsureRamSpaceL() ;
+
+        /**
+        *  Move DBs from RAMDisk to disks
+        */
+        //IMPORT_C void BackupDBsL();
+
+    private:
+
+        /**
+        * Find available RAMDISK
+        * @return error code
+        */
+        TInt GetRAMDiskPath();
+
+        /**
+        * Check if RAM disk is available to copy.
+        *
+        * @return ETrue if there is enough space, EFalse otherwise
+        */
+        TBool IsRamDiskSpaceAvailable();
+        
+        /**
+        * To block a diskspace so that it can gurantee for a write back from RAM disk
+        *
+        * @return ETrue if the dummy file is created successfully, EFalse otherwise
+        */
+        TBool BlockDiskSpace( TDriveUnit aDrive, TInt aOrigDbSize, TBool aIsMTPInUse = EFalse );
+        
+        /**
+        * To copy db from regular drive to RAM
+        *
+        * @return ETrue if succeed 
+        * @leave KErrDiskFull if there is any difficulty copying files
+        */
+        TBool DoCopyDBToRamL( TDriveUnit aDrive, TBool aIsMTPInUse );
+
+        /**
+        * To copy db back regular drive from RAM
+        *
+        */
+        void DoCopyDBFromRamL( TInt aIndex );
+    
+        /**
+        * To replace dummy file with new content
+        * Writes over previous dummy file without freeing disk space
+        */
+        void ReplaceFileL( const TDesC& aSrcName, const TDesC& aDstName );
+        	
+        /**
+        * To calculate necessary file size of the dummy file
+        *
+        * @return TInt64 estimated file size
+        */
+        TInt64 CalculateInitalDummyDBSize( const TVolumeInfo& aVol, TInt aOrigDbSize, TBool aIsMTPInUse = EFalse);
+        
+        /**
+        * Get database index by giving drive index
+        *
+        * @return TInt index to the database handler
+        */
+        TInt GetDatabaseIndex(TInt aDrive);
+
+        /**
+         * Sum up the total size in bytes of the databases.
+         * 
+         * @param aSize - On return, the total size of the databases.
+         * @return TInt System error.
+         */
+        TInt GetTotalDatabasesSize(TInt& aSize);
+
+        /**
+         * Sum up the total size in bytes of the databases on the RAM drive.
+         * 
+         * @param aSize - On return, the total size of the databases on the RAM drive.
+         * @return TInt System error.
+         */
+        TInt GetTotalRamDatabasesSize(TInt& aSize);
+
+        /**
+        * Remove dummy file
+        *
+        * @return TInt index to the database handler
+        */
+        void RemoveDummyFile( TInt index );
+
+        
+
+/**
+        * Check if disksapce is enough to operatte. If not, it leaves with KErrDiskFull
+        *
+        */
+        void EnsureDiskSpaceL(TInt aDrive) ;
+        
+        /** 
+         * Begin transaction, leaves on error
+         */
+        void DoBeginL();
+        
+        /** 
+         * Commit transaction, leaves on error
+         */
+        void DoCommitL();
+
     protected:  // Types
 
         typedef struct
@@ -300,6 +424,12 @@
             TInt iDrive;
             TBool iOpen;
             HBufC* iAliasname;
+#ifdef __RAMDISK_PERF_ENABLE 
+            TBool iUseRAMdb;
+            HBufC* iOrigFullFilePath;
+            HBufC* iTargetFullFilePath;
+            TFileName iDummyFilePath;
+#endif //__RAMDISK_PERF_ENABLE 
             } DatabaseHandle;
 
     protected:  // Data
@@ -492,6 +622,14 @@
 
         RArray<TSqlStatementState> iPreparedStatements;
         RPointerArray<RSqlStatement> iStatements;
+
+        // Defined for RAM disk performance
+        TBool                   iRAMDiskPerfEnabled;  // flag to indicate RAM disk feature is enabled from cenrep.
+        TUint64                 iMaximumAllowedRAMDiskSpaceToCopy; // maximum number of megabytes allow to do RAM disk operation.
+        TFileName               iRAMFolder;
+        TChar                   iRAMDrive;
+        TBool                   iRAMInUse;
+        TInt64                  iEstimatedDBSizes;
     };
 
 #endif  // MPXDBMANAGER_H
--- a/mpserviceplugins/inc/mpxdbtable.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/inc/mpxdbtable.h	Mon May 03 12:29:20 2010 +0300
@@ -373,6 +373,13 @@
         IMPORT_C void ExecuteMediaQueryOnDriveL(TInt aDrive,const TArray<TMPXAttribute>& aAttrs,
         	    CMPXMediaArray& aMediaArray, const TDesC& aQuery);
             
+        /**
+        * Executes a sum query with a string and two int parameters.
+        * @param aQuery query to be executed
+        * @param aPlaylistId string parameter
+        * @param aDrive integer parameter
+        */
+        IMPORT_C TInt ExecuteSumExQueryL(const TDesC& aQuery, TUint32 aPlaylistId, TInt aDrive);        
     protected:    // Data
 
         CMPXDbManager& iDbManager;
--- a/mpserviceplugins/localaudio/src/mpxlocalaudioplayback.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/localaudio/src/mpxlocalaudioplayback.cpp	Mon May 03 12:29:20 2010 +0300
@@ -50,11 +50,8 @@
 
 // CONSTANTS
 const TUid  KLocalPlaybackUid={0x101FFC06};
-// added because of build warning
-#if defined(__HIGH_RESOLUTION_VOLUME)
-_LIT(KWmaExtension, ".wma");
-_LIT(KRaExtension, ".ra");
-#endif
+//_LIT(KWmaExtension, ".wma");
+//_LIT(KRaExtension, ".ra"); 
 
     
 // ============================ LOCAL FUNCTIONS ==============================
@@ -307,7 +304,25 @@
                     {
                     if (iConsumeStarted)
                         {
-                        TRAP_IGNORE( ConsumeRightsL( ContentAccess::EContinue ) );
+                        TRAPD( drmErr, ConsumeRightsL( ContentAccess::EContinue ) );
+                        if ( drmErr == KErrCANoRights )
+                            {
+                            iDrmMediaUtility->Close();
+                            iPlayer->Stop();
+                            iIsPlaying = EFalse;
+                            iAudioEffects->DestroyAudioEffect();
+                            iPlayer->Close();
+                            iObs->HandlePluginEvent(
+                                    MMPXPlaybackPluginObserver::EPStopped, 0,
+                                    drmErr);
+                            iFile.Close();
+                            iState = EStateNotInitialised;
+                            iObs->HandlePluginEvent(
+                                    MMPXPlaybackPluginObserver::EPClosed,
+                                    EPbCmdStop, drmErr);
+                            iClosedByAudioPolicy = EFalse;
+                            break;
+                            }
                         }
                     else
                         {
@@ -483,6 +498,25 @@
                 {
                 iPlayer->Pause();
                 iPlayer->SetPosition(pos);
+                //Handle error of license expired when tapping the progress playing bar 
+                TRAPD( drmErr, ConsumeRightsL( ContentAccess::EContinue ) );
+                if ( drmErr == KErrCANoRights )
+                    {
+                    iDrmMediaUtility->Close();
+                    iPlayer->Stop();
+                    iIsPlaying = EFalse;
+                    iAudioEffects->DestroyAudioEffect();
+                    iPlayer->Close();
+                    iObs->HandlePluginEvent(
+                            MMPXPlaybackPluginObserver::EPStopped, 0, drmErr);
+                    iFile.Close();
+                    iState = EStateNotInitialised;
+                    iObs->HandlePluginEvent(
+                            MMPXPlaybackPluginObserver::EPClosed, EPbCmdStop,
+                            drmErr);
+                    iClosedByAudioPolicy = EFalse;
+                    return;
+                    }
                 iPlayer->Play();
                 }
             else
--- a/mpserviceplugins/mpxsqlitedbcommon/bwinscw/mpxsqlitedbcommonu.def	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/bwinscw/mpxsqlitedbcommonu.def	Mon May 03 12:29:20 2010 +0300
@@ -1,124 +1,129 @@
 EXPORTS
-	??0CMPXDbManager@@IAE@AAVRFs@@@Z @ 1 NONAME ; CMPXDbManager::CMPXDbManager(class RFs &)
-	??0CMPXDbTable@@IAE@AAVCMPXDbManager@@@Z @ 2 NONAME ; CMPXDbTable::CMPXDbTable(class CMPXDbManager &)
-	??1CMPXDbActiveTask@@UAE@XZ @ 3 NONAME ; CMPXDbActiveTask::~CMPXDbActiveTask(void)
-	??1CMPXDbManager@@UAE@XZ @ 4 NONAME ; CMPXDbManager::~CMPXDbManager(void)
-	??1CMPXDbTable@@MAE@XZ @ 5 NONAME ; CMPXDbTable::~CMPXDbTable(void)
-	?AddItemChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@I1@Z @ 6 NONAME ; void MPXDbCommonUtil::AddItemChangedMessageL(class CMPXMediaArray &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, class TMPXItemId)
-	?AddSqlCriterionL@MPXDbCommonUtil@@SAHAAVCDesC16Array@@ABVTDesC16@@1@Z @ 7 NONAME ; int MPXDbCommonUtil::AddSqlCriterionL(class CDesC16Array &, class TDesC16 const &, class TDesC16 const &)
-	?AddSqlCriterionL@MPXDbCommonUtil@@SAHAAVCDesC16Array@@ABVTDesC16@@H@Z @ 8 NONAME ; int MPXDbCommonUtil::AddSqlCriterionL(class CDesC16Array &, class TDesC16 const &, int)
-	?AppendMediaL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@ABVTDesC16@@W4TMPXGeneralType@@W4TMPXGeneralCategory@@VTMPXItemId@@HI@Z @ 9 NONAME ; void MPXDbCommonUtil::AppendMediaL(class CMPXMediaArray &, class TDesC16 const &, enum TMPXGeneralType, enum TMPXGeneralCategory, class TMPXItemId, int, unsigned int)
-	?AppendValueL@MPXDbCommonUtil@@SAXAAVCDesC16Array@@0ABVTDesC16@@1@Z @ 10 NONAME ; void MPXDbCommonUtil::AppendValueL(class CDesC16Array &, class CDesC16Array &, class TDesC16 const &, class TDesC16 const &)
-	?AppendValueL@MPXDbCommonUtil@@SAXAAVCDesC16Array@@0ABVTDesC16@@K@Z @ 11 NONAME ; void MPXDbCommonUtil::AppendValueL(class CDesC16Array &, class CDesC16Array &, class TDesC16 const &, unsigned long)
-	?AttributeExists@MPXDbCommonUtil@@SAHABV?$TArray@VTMPXAttribute@@@@ABVTMPXAttribute@@@Z @ 12 NONAME ; int MPXDbCommonUtil::AttributeExists(class TArray<class TMPXAttribute> const &, class TMPXAttribute const &)
-	?BaseConstructL@CMPXDbTable@@IAEXXZ @ 13 NONAME ; void CMPXDbTable::BaseConstructL(void)
-	?BeginL@CMPXDbManager@@QAEXXZ @ 14 NONAME ; void CMPXDbManager::BeginL(void)
-	?CheckDiskSpaceL@CMPXDbManager@@QAEXH@Z @ 15 NONAME ; void CMPXDbManager::CheckDiskSpaceL(int)
-	?CloseAllDatabases@CMPXDbManager@@QAEXXZ @ 16 NONAME ; void CMPXDbManager::CloseAllDatabases(void)
-	?CloseDatabaseL@CMPXDbManager@@QAEXH@Z @ 17 NONAME ; void CMPXDbManager::CloseDatabaseL(int)
-	?CommitL@CMPXDbManager@@QAEXXZ @ 18 NONAME ; void CMPXDbManager::CommitL(void)
-	?ConstructL@CMPXDbManager@@IAEXABV?$TBuf@$0BAA@@@@Z @ 19 NONAME ; void CMPXDbManager::ConstructL(class TBuf<256> const &)
-	?CreateFullPathL@MPXDbCommonUtil@@SAPAVHBufC16@@HABVTDesC16@@@Z @ 20 NONAME ; class HBufC16 * MPXDbCommonUtil::CreateFullPathL(int, class TDesC16 const &)
-	?CreateTablesL@CMPXDbManager@@IAEXAAVRSqlDatabase@@@Z @ 21 NONAME ; void CMPXDbManager::CreateTablesL(class RSqlDatabase &)
-	?CurrentDateDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@XZ @ 22 NONAME ; class HBufC16 * MPXDbCommonUtil::CurrentDateDesLC(void)
-	?CurrentTimeDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@XZ @ 23 NONAME ; class HBufC16 * MPXDbCommonUtil::CurrentTimeDesLC(void)
-	?DatabaseCount@CMPXDbManager@@QBEHXZ @ 24 NONAME ; int CMPXDbManager::DatabaseCount(void) const
-	?DbDrive@CMPXDbManager@@QBEHH@Z @ 25 NONAME ; int CMPXDbManager::DbDrive(int) const
-	?DeleteFile@MPXDbCommonUtil@@SAHAAVRFs@@ABVTDesC16@@@Z @ 26 NONAME ; int MPXDbCommonUtil::DeleteFile(class RFs &, class TDesC16 const &)
-	?DesToTTimeL@MPXDbCommonUtil@@SA?AVTTime@@ABVTDesC16@@@Z @ 27 NONAME ; class TTime MPXDbCommonUtil::DesToTTimeL(class TDesC16 const &)
-	?DoCancel@CMPXDbActiveTask@@MAEXXZ @ 28 NONAME ; void CMPXDbActiveTask::DoCancel(void)
-	?DoCheckTable@CMPXDbTable@@IAEHAAVRSqlDatabase@@ABVTDesC16@@@Z @ 29 NONAME ; int CMPXDbTable::DoCheckTable(class RSqlDatabase &, class TDesC16 const &)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@0@Z @ 30 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, class TDesC16 const &)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@0K@Z @ 31 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@@Z @ 32 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@K@Z @ 33 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, unsigned long)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@KK@Z @ 34 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, unsigned long, unsigned long)
-	?ExecuteIntQueryL@CMPXDbTable@@IAEKHABVTDesC16@@@Z @ 35 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(int, class TDesC16 const &)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@ABVTDesC16@@@Z @ 36 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMedia &, class TDesC16 const &)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@ABVTDesC16@@H@Z @ 37 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMedia &, class TDesC16 const &, int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@22@Z @ 38 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2@Z @ 39 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2H2H@Z @ 40 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int, class TDesC16 const &, int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2H@Z @ 41 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2HHI@Z @ 42 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int, int, unsigned int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@@Z @ 43 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@H@Z @ 44 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@HH@Z @ 45 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int, int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@HHI@Z @ 46 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int, int, unsigned int)
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@HABVTDesC16@@@Z @ 47 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, int, class TDesC16 const &)
-	?ExecuteQueryL@CMPXDbManager@@QAAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 48 NONAME ; void CMPXDbManager::ExecuteQueryL(int, class TRefByValue<class TDesC16 const >, ...)
-	?ExecuteSelectQueryL@CMPXDbManager@@QAA?AVRSqlStatement@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 49 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryL(int, class TRefByValue<class TDesC16 const >, ...)
-	?ExecuteSelectQueryL@CMPXDbManager@@QAA?AVRSqlStatement@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 50 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryL(class TRefByValue<class TDesC16 const >, ...)
-	?ExecuteSelectQueryL@CMPXDbManager@@QAAAAVRSqlStatement@@IABVTDesC16@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 51 NONAME ; class RSqlStatement & CMPXDbManager::ExecuteSelectQueryL(unsigned int, class TDesC16 const &, int, class TRefByValue<class TDesC16 const >, ...)
-	?ExecuteSelectQueryL@CMPXDbManager@@QAAAAVRSqlStatement@@IHHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 52 NONAME ; class RSqlStatement & CMPXDbManager::ExecuteSelectQueryL(unsigned int, int, int, class TRefByValue<class TDesC16 const >, ...)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@00@Z @ 53 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@0@Z @ 54 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@0K0K@Z @ 55 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long, class TDesC16 const &, unsigned long)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@@Z @ 56 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@K@Z @ 57 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@KK@Z @ 58 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long, unsigned long)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@KKK@Z @ 59 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long, unsigned long, unsigned long)
-	?ExecuteSumQueryL@CMPXDbTable@@IAEKABVTDesC16@@0K@Z @ 60 NONAME ; unsigned long CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long)
-	?FillInSupportedUIDsL@MPXDbCommonUtil@@SAXABV?$TArray@VTMPXAttribute@@@@AAV?$RArray@H@@@Z @ 61 NONAME ; void MPXDbCommonUtil::FillInSupportedUIDsL(class TArray<class TMPXAttribute> const &, class RArray<int> &)
-	?FillItemChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMedia@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@I1@Z @ 62 NONAME ; void MPXDbCommonUtil::FillItemChangedMessageL(class CMPXMedia &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, class TMPXItemId)
-	?FindAndReplaceSingleQuote@MPXDbCommonUtil@@SAXABVTDesC16@@AAVTDes16@@@Z @ 63 NONAME ; void MPXDbCommonUtil::FindAndReplaceSingleQuote(class TDesC16 const &, class TDes16 &)
-	?FindItemChangedMessageL@MPXDbCommonUtil@@SAHABVCMPXMediaArray@@ABVCMPXMedia@@@Z @ 64 NONAME ; int MPXDbCommonUtil::FindItemChangedMessageL(class CMPXMediaArray const &, class CMPXMedia const &)
-	?Fs@CMPXDbManager@@QAEAAVRFs@@XZ @ 65 NONAME ; class RFs & CMPXDbManager::Fs(void)
-	?GenerateUniqueIdL@MPXDbCommonUtil@@SAKAAVRFs@@W4TMPXGeneralCategory@@ABVTDesC16@@H@Z @ 66 NONAME ; unsigned long MPXDbCommonUtil::GenerateUniqueIdL(class RFs &, enum TMPXGeneralCategory, class TDesC16 const &, int)
-	?GetChangeMessages@CMPXDbActiveTask@@QAEAAVCMPXMediaArray@@XZ @ 67 NONAME ; class CMPXMediaArray & CMPXDbActiveTask::GetChangeMessages(void)
-	?GetColumnTextL@MPXDbCommonUtil@@SA?AVTPtrC16@@AAVRSqlStatement@@H@Z @ 68 NONAME ; class TPtrC16 MPXDbCommonUtil::GetColumnTextL(class RSqlStatement &, int)
-	?GetCommand@CMPXDbActiveTask@@QAEAAVCMPXMedia@@XZ @ 69 NONAME ; class CMPXMedia & CMPXDbActiveTask::GetCommand(void)
-	?GetDRMTypeL@MPXDbCommonUtil@@SA?AW4TMCDrmType@@ABVTDesC16@@@Z @ 70 NONAME ; enum TMCDrmType MPXDbCommonUtil::GetDRMTypeL(class TDesC16 const &)
-	?GetDriveIdMatchVolIdL@MPXDbCommonUtil@@SAHAAVRFs@@I@Z @ 71 NONAME ; int MPXDbCommonUtil::GetDriveIdMatchVolIdL(class RFs &, unsigned int)
-	?GetDriveL@MPXDbCommonUtil@@SAHABVTDesC16@@AAVTDriveUnit@@@Z @ 72 NONAME ; int MPXDbCommonUtil::GetDriveL(class TDesC16 const &, class TDriveUnit &)
-	?GetMimeTypeForUriL@MPXDbCommonUtil@@SA?AVTDataType@@ABVTDesC16@@@Z @ 73 NONAME ; class TDataType MPXDbCommonUtil::GetMimeTypeForUriL(class TDesC16 const &)
-	?GetStep@CMPXDbActiveTask@@QAEHXZ @ 74 NONAME ; int CMPXDbActiveTask::GetStep(void)
-	?GetTask@CMPXDbActiveTask@@QAEKXZ @ 75 NONAME ; unsigned long CMPXDbActiveTask::GetTask(void)
-	?GetVisibleChange@CMPXDbActiveTask@@QAE?AW4TChangeVisibility@1@XZ @ 76 NONAME ; enum CMPXDbActiveTask::TChangeVisibility CMPXDbActiveTask::GetVisibleChange(void)
-	?GetVolIdMatchDriveIdL@MPXDbCommonUtil@@SAIAAVRFs@@H@Z @ 77 NONAME ; unsigned int MPXDbCommonUtil::GetVolIdMatchDriveIdL(class RFs &, int)
-	?InTransaction@CMPXDbManager@@QAEHXZ @ 78 NONAME ; int CMPXDbManager::InTransaction(void)
-	?InitDatabasesL@CMPXDbManager@@QAEXV?$RArray@H@@@Z @ 79 NONAME ; void CMPXDbManager::InitDatabasesL(class RArray<int>)
-	?IsInitialized@CMPXDbManager@@QAEHXZ @ 80 NONAME ; int CMPXDbManager::IsInitialized(void)
-	?IsOpen@CMPXDbManager@@QBEHH@Z @ 81 NONAME ; int CMPXDbManager::IsOpen(int) const
-	?IsRemoteDrive@CMPXDbManager@@QAEHW4TDriveNumber@@@Z @ 82 NONAME ; int CMPXDbManager::IsRemoteDrive(enum TDriveNumber)
-	?NewL@CMPXDbActiveTask@@SAPAV1@AAVMMPXDbActiveTaskObserver@@@Z @ 83 NONAME ; class CMPXDbActiveTask * CMPXDbActiveTask::NewL(class MMPXDbActiveTaskObserver &)
-	?NewL@CMPXResource@@SAPAV1@ABVTDesC16@@@Z @ 84 NONAME ; class CMPXResource * CMPXResource::NewL(class TDesC16 const &)
-	?NewLC@CMPXResource@@SAPAV1@ABVTDesC16@@@Z @ 85 NONAME ; class CMPXResource * CMPXResource::NewLC(class TDesC16 const &)
-	?OpenAllDatabasesL@CMPXDbManager@@QAEXXZ @ 86 NONAME ; void CMPXDbManager::OpenAllDatabasesL(void)
-	?OpenDatabaseL@CMPXDbManager@@QAEXH@Z @ 87 NONAME ; void CMPXDbManager::OpenDatabaseL(int)
-	?PrependMediaL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@ABVTDesC16@@W4TMPXGeneralType@@W4TMPXGeneralCategory@@VTMPXItemId@@HIH@Z @ 88 NONAME ; void MPXDbCommonUtil::PrependMediaL(class CMPXMediaArray &, class TDesC16 const &, enum TMPXGeneralType, enum TMPXGeneralCategory, class TMPXItemId, int, unsigned int, int)
-	?PrintDatabaseL@CMPXDbManager@@QAEXXZ @ 89 NONAME ; void CMPXDbManager::PrintDatabaseL(void)
-	?ProcessPatternCharsLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 90 NONAME ; class HBufC16 * MPXDbCommonUtil::ProcessPatternCharsLC(class TDesC16 const &)
-	?ProcessSingleQuotesLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 91 NONAME ; class HBufC16 * MPXDbCommonUtil::ProcessSingleQuotesLC(class TDesC16 const &)
-	?ReadDesCArrayL@CMPXResource@@QAEPAVCDesC16ArrayFlat@@H@Z @ 92 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadDesCArrayL(int)
-	?ReadDesCArrayLC@CMPXResource@@QAEPAVCDesC16ArrayFlat@@H@Z @ 93 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadDesCArrayLC(int)
-	?ReadHBufCL@CMPXResource@@QAEPAVHBufC16@@H@Z @ 94 NONAME ; class HBufC16 * CMPXResource::ReadHBufCL(int)
-	?ReadMenuArrayL@CMPXResource@@QAEPAVCDesC16ArrayFlat@@HAAV?$RArray@H@@@Z @ 95 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadMenuArrayL(int, class RArray<int> &)
-	?ReadMenuArrayLC@CMPXResource@@QAEPAVCDesC16ArrayFlat@@HAAV?$RArray@H@@@Z @ 96 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadMenuArrayLC(int, class RArray<int> &)
-	?RecreateAllDatabasesL@CMPXDbManager@@QAEXXZ @ 97 NONAME ; void CMPXDbManager::RecreateAllDatabasesL(void)
-	?RecreateDatabaseL@CMPXDbManager@@QAEXH@Z @ 98 NONAME ; void CMPXDbManager::RecreateDatabaseL(int)
-	?RegenerateAllDatabasesL@CMPXDbManager@@QAEXXZ @ 99 NONAME ; void CMPXDbManager::RegenerateAllDatabasesL(void)
-	?RegisterTableL@CMPXDbManager@@QAEXAAVMMPXTable@@@Z @ 100 NONAME ; void CMPXDbManager::RegisterTableL(class MMPXTable &)
-	?Release@CMPXResource@@QAEXXZ @ 101 NONAME ; void CMPXResource::Release(void)
-	?RollbackL@CMPXDbManager@@QAEXXZ @ 102 NONAME ; void CMPXDbManager::RollbackL(void)
-	?RunError@CMPXDbActiveTask@@MAEHH@Z @ 103 NONAME ; int CMPXDbActiveTask::RunError(int)
-	?RunL@CMPXDbActiveTask@@MAEXXZ @ 104 NONAME ; void CMPXDbActiveTask::RunL(void)
+	?StringFromArrayLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVCDesC16Array@@ABVTDesC16@@@Z @ 1 NONAME ; class HBufC16 * MPXDbCommonUtil::StringFromArrayLC(class CDesC16Array const &, class TDesC16 const &)
+	?IsInitialized@CMPXDbManager@@QAEHXZ @ 2 NONAME ; int CMPXDbManager::IsInitialized(void)
+	?AppendValueL@MPXDbCommonUtil@@SAXAAVCDesC16Array@@0ABVTDesC16@@1@Z @ 3 NONAME ; void MPXDbCommonUtil::AppendValueL(class CDesC16Array &, class CDesC16Array &, class TDesC16 const &, class TDesC16 const &)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEKABVTDesC16@@0K@Z @ 4 NONAME ; unsigned long CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long)
+	?DbDrive@CMPXDbManager@@QBEHH@Z @ 5 NONAME ; int CMPXDbManager::DbDrive(int) const
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@0@Z @ 6 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &)
+	?DesToTTimeL@MPXDbCommonUtil@@SA?AVTTime@@ABVTDesC16@@@Z @ 7 NONAME ; class TTime MPXDbCommonUtil::DesToTTimeL(class TDesC16 const &)
+	?CloseDatabaseL@CMPXDbManager@@QAEXH@Z @ 8 NONAME ; void CMPXDbManager::CloseDatabaseL(int)
+	?AddSqlCriterionL@MPXDbCommonUtil@@SAHAAVCDesC16Array@@ABVTDesC16@@1@Z @ 9 NONAME ; int MPXDbCommonUtil::AddSqlCriterionL(class CDesC16Array &, class TDesC16 const &, class TDesC16 const &)
+	?TTimeToDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTTime@@@Z @ 10 NONAME ; class HBufC16 * MPXDbCommonUtil::TTimeToDesLC(class TTime const &)
+	?ConstructL@CMPXDbManager@@IAEXABV?$TBuf@$0BAA@@@@Z @ 11 NONAME ; void CMPXDbManager::ConstructL(class TBuf<256> const &)
+	?SetVisibleChange@CMPXDbActiveTask@@QAEXW4TChangeVisibility@1@@Z @ 12 NONAME ; void CMPXDbActiveTask::SetVisibleChange(enum CMPXDbActiveTask::TChangeVisibility)
+	?ExecuteSelectQueryL@CMPXDbManager@@QAA?AVRSqlStatement@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 13 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryL(int, class TRefByValue<class TDesC16 const >, ...)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@ABVTDesC16@@@Z @ 14 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMedia &, class TDesC16 const &)
+	?StringFromArraysLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVCDesC16Array@@0ABVTDesC16@@1@Z @ 15 NONAME ; class HBufC16 * MPXDbCommonUtil::StringFromArraysLC(class CDesC16Array const &, class CDesC16Array const &, class TDesC16 const &, class TDesC16 const &)
+	?CurrentDateDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@XZ @ 16 NONAME ; class HBufC16 * MPXDbCommonUtil::CurrentDateDesLC(void)
+	?ReadMenuArrayLC@CMPXResource@@QAEPAVCDesC16ArrayFlat@@HAAV?$RArray@H@@@Z @ 17 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadMenuArrayLC(int, class RArray<int> &)
+	?NewL@CMPXResource@@SAPAV1@ABVTDesC16@@@Z @ 18 NONAME ; class CMPXResource * CMPXResource::NewL(class TDesC16 const &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@HH@Z @ 19 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int, int)
+	?AppendMediaL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@ABVTDesC16@@W4TMPXGeneralType@@W4TMPXGeneralCategory@@VTMPXItemId@@HI@Z @ 20 NONAME ; void MPXDbCommonUtil::AppendMediaL(class CMPXMediaArray &, class TDesC16 const &, enum TMPXGeneralType, enum TMPXGeneralCategory, class TMPXItemId, int, unsigned int)
+	?EnsureRamSpaceL@CMPXDbManager@@QAEXXZ @ 21 NONAME ; void CMPXDbManager::EnsureRamSpaceL(void)
+	?ExecuteSelectQueryL@CMPXDbManager@@QAAAAVRSqlStatement@@IHHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 22 NONAME ; class RSqlStatement & CMPXDbManager::ExecuteSelectQueryL(unsigned int, int, int, class TRefByValue<class TDesC16 const >, ...)
+	?CopyDBsToRamL@CMPXDbManager@@QAEXH@Z @ 23 NONAME ; void CMPXDbManager::CopyDBsToRamL(int)
+	?AppendValueL@MPXDbCommonUtil@@SAXAAVCDesC16Array@@0ABVTDesC16@@K@Z @ 24 NONAME ; void MPXDbCommonUtil::AppendValueL(class CDesC16Array &, class CDesC16Array &, class TDesC16 const &, unsigned long)
+	?RunL@CMPXDbActiveTask@@MAEXXZ @ 25 NONAME ; void CMPXDbActiveTask::RunL(void)
+	?CreateFullPathL@MPXDbCommonUtil@@SAPAVHBufC16@@HABVTDesC16@@@Z @ 26 NONAME ; class HBufC16 * MPXDbCommonUtil::CreateFullPathL(int, class TDesC16 const &)
+	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@HH@Z @ 27 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, int, int)
+	?GetTask@CMPXDbActiveTask@@QAEKXZ @ 28 NONAME ; unsigned long CMPXDbActiveTask::GetTask(void)
+	?RecreateAllDatabasesL@CMPXDbManager@@QAEXXZ @ 29 NONAME ; void CMPXDbManager::RecreateAllDatabasesL(void)
+	?ReadDesCArrayL@CMPXResource@@QAEPAVCDesC16ArrayFlat@@H@Z @ 30 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadDesCArrayL(int)
+	??1CMPXDbActiveTask@@UAE@XZ @ 31 NONAME ; CMPXDbActiveTask::~CMPXDbActiveTask(void)
+	?FillInSupportedUIDsL@MPXDbCommonUtil@@SAXABV?$TArray@VTMPXAttribute@@@@AAV?$RArray@H@@@Z @ 32 NONAME ; void MPXDbCommonUtil::FillInSupportedUIDsL(class TArray<class TMPXAttribute> const &, class RArray<int> &)
+	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@0@Z @ 33 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &)
+	?SqlCriterion64LC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@_J1@Z @ 34 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterion64LC(class TDesC16 const &, long long, long long)
+	?ExecuteSelectQueryL@CMPXDbManager@@QAAAAVRSqlStatement@@IABVTDesC16@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 35 NONAME ; class RSqlStatement & CMPXDbManager::ExecuteSelectQueryL(unsigned int, class TDesC16 const &, int, class TRefByValue<class TDesC16 const >, ...)
+	?UpdateMediaL@CMPXDbTable@@MAEXAAVRSqlStatement@@ABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@@Z @ 36 NONAME ; void CMPXDbTable::UpdateMediaL(class RSqlStatement &, class TArray<class TMPXAttribute> const &, class CMPXMedia &)
+	?CreateTablesL@CMPXDbManager@@IAEXAAVRSqlDatabase@@@Z @ 37 NONAME ; void CMPXDbManager::CreateTablesL(class RSqlDatabase &)
+	??1CMPXDbManager@@UAE@XZ @ 38 NONAME ; CMPXDbManager::~CMPXDbManager(void)
+	?ExecuteQueryL@CMPXDbManager@@QAAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 39 NONAME ; void CMPXDbManager::ExecuteQueryL(int, class TRefByValue<class TDesC16 const >, ...)
+	?CommitL@CMPXDbManager@@QAEXXZ @ 40 NONAME ; void CMPXDbManager::CommitL(void)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2@Z @ 41 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &)
+	??1CMPXDbTable@@MAE@XZ @ 42 NONAME ; CMPXDbTable::~CMPXDbTable(void)
+	?ProcessSingleQuotesLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 43 NONAME ; class HBufC16 * MPXDbCommonUtil::ProcessSingleQuotesLC(class TDesC16 const &)
+	?GetDRMTypeL@MPXDbCommonUtil@@SA?AW4TMCDrmType@@ABVTDesC16@@@Z @ 44 NONAME ; enum TMCDrmType MPXDbCommonUtil::GetDRMTypeL(class TDesC16 const &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@H@Z @ 45 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@@Z @ 46 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &)
+	?InitDatabasesL@CMPXDbManager@@QAEXV?$RArray@H@@@Z @ 47 NONAME ; void CMPXDbManager::InitDatabasesL(class RArray<int>)
+	?GetChangeMessages@CMPXDbActiveTask@@QAEAAVCMPXMediaArray@@XZ @ 48 NONAME ; class CMPXMediaArray & CMPXDbActiveTask::GetChangeMessages(void)
+	?ExecuteSelectQueryL@CMPXDbManager@@QAA?AVRSqlStatement@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 49 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryL(class TRefByValue<class TDesC16 const >, ...)
+	?ReadHBufCL@CMPXResource@@QAEPAVHBufC16@@H@Z @ 50 NONAME ; class HBufC16 * CMPXResource::ReadHBufCL(int)
+	?GetCommand@CMPXDbActiveTask@@QAEAAVCMPXMedia@@XZ @ 51 NONAME ; class CMPXMedia & CMPXDbActiveTask::GetCommand(void)
+	?GetMimeTypeForUriL@MPXDbCommonUtil@@SA?AVTDataType@@ABVTDesC16@@@Z @ 52 NONAME ; class TDataType MPXDbCommonUtil::GetMimeTypeForUriL(class TDesC16 const &)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@0K@Z @ 53 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long)
+	?OpenDatabaseL@CMPXDbManager@@QAEXH@Z @ 54 NONAME ; void CMPXDbManager::OpenDatabaseL(int)
+	?ExecuteMediaQueryOnDriveL@CMPXDbTable@@IAEXHABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@@Z @ 55 NONAME ; void CMPXDbTable::ExecuteMediaQueryOnDriveL(int, class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2HHI@Z @ 56 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int, int, unsigned int)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@22@Z @ 57 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
+	?NewLC@CMPXResource@@SAPAV1@ABVTDesC16@@@Z @ 58 NONAME ; class CMPXResource * CMPXResource::NewLC(class TDesC16 const &)
+	?RegisterTableL@CMPXDbManager@@QAEXAAVMMPXTable@@@Z @ 59 NONAME ; void CMPXDbManager::RegisterTableL(class MMPXTable &)
+	?PrintDatabaseL@CMPXDbManager@@QAEXXZ @ 60 NONAME ; void CMPXDbManager::PrintDatabaseL(void)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2H@Z @ 61 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int)
+	?RollbackL@CMPXDbManager@@QAEXXZ @ 62 NONAME ; void CMPXDbManager::RollbackL(void)
+	?BeginL@CMPXDbManager@@QAEXXZ @ 63 NONAME ; void CMPXDbManager::BeginL(void)
+	??0CMPXDbManager@@IAE@AAVRFs@@@Z @ 64 NONAME ; CMPXDbManager::CMPXDbManager(class RFs &)
+	?RecreateDatabaseL@CMPXDbManager@@QAEXH@Z @ 65 NONAME ; void CMPXDbManager::RecreateDatabaseL(int)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@K@Z @ 66 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, unsigned long)
+	?RegenerateAllDatabasesL@CMPXDbManager@@QAEXXZ @ 67 NONAME ; void CMPXDbManager::RegenerateAllDatabasesL(void)
+	?NewL@CMPXDbActiveTask@@SAPAV1@AAVMMPXDbActiveTaskObserver@@@Z @ 68 NONAME ; class CMPXDbActiveTask * CMPXDbActiveTask::NewL(class MMPXDbActiveTaskObserver &)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@0K0K@Z @ 69 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, unsigned long, class TDesC16 const &, unsigned long)
+	?ReadDesCArrayLC@CMPXResource@@QAEPAVCDesC16ArrayFlat@@H@Z @ 70 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadDesCArrayLC(int)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKHABVTDesC16@@@Z @ 71 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(int, class TDesC16 const &)
+	?AttributeExists@MPXDbCommonUtil@@SAHABV?$TArray@VTMPXAttribute@@@@ABVTMPXAttribute@@@Z @ 72 NONAME ; int MPXDbCommonUtil::AttributeExists(class TArray<class TMPXAttribute> const &, class TMPXAttribute const &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@HHI@Z @ 73 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int, int, unsigned int)
+	?OpenAllDatabasesL@CMPXDbManager@@QAEXXZ @ 74 NONAME ; void CMPXDbManager::OpenAllDatabasesL(void)
+	?Release@CMPXResource@@QAEXXZ @ 75 NONAME ; void CMPXResource::Release(void)
+	?CopyDBsFromRamL@CMPXDbManager@@QAEXXZ @ 76 NONAME ; void CMPXDbManager::CopyDBsFromRamL(void)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@@Z @ 77 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &)
+	?GetVisibleChange@CMPXDbActiveTask@@QAE?AW4TChangeVisibility@1@XZ @ 78 NONAME ; enum CMPXDbActiveTask::TChangeVisibility CMPXDbActiveTask::GetVisibleChange(void)
+	?SqlCriterion64LC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@_J@Z @ 79 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterion64LC(class TDesC16 const &, long long)
+	?GetStep@CMPXDbActiveTask@@QAEHXZ @ 80 NONAME ; int CMPXDbActiveTask::GetStep(void)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@0@Z @ 81 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, class TDesC16 const &)
+	?GetVolIdMatchDriveIdL@MPXDbCommonUtil@@SAIAAVRFs@@H@Z @ 82 NONAME ; unsigned int MPXDbCommonUtil::GetVolIdMatchDriveIdL(class RFs &, int)
+	?FindItemChangedMessageL@MPXDbCommonUtil@@SAHABVCMPXMediaArray@@ABVCMPXMedia@@@Z @ 83 NONAME ; int MPXDbCommonUtil::FindItemChangedMessageL(class CMPXMediaArray const &, class CMPXMedia const &)
+	?IsOpen@CMPXDbManager@@QBEHH@Z @ 84 NONAME ; int CMPXDbManager::IsOpen(int) const
+	?PrependMediaL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@ABVTDesC16@@W4TMPXGeneralType@@W4TMPXGeneralCategory@@VTMPXItemId@@HIH@Z @ 85 NONAME ; void MPXDbCommonUtil::PrependMediaL(class CMPXMediaArray &, class TDesC16 const &, enum TMPXGeneralType, enum TMPXGeneralCategory, class TMPXItemId, int, unsigned int, int)
+	?GetDriveL@MPXDbCommonUtil@@SAHABVTDesC16@@AAVTDriveUnit@@@Z @ 86 NONAME ; int MPXDbCommonUtil::GetDriveL(class TDesC16 const &, class TDriveUnit &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@HABVTDesC16@@@Z @ 87 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, int, class TDesC16 const &)
+	?AddItemChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@I1@Z @ 88 NONAME ; void MPXDbCommonUtil::AddItemChangedMessageL(class CMPXMediaArray &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, class TMPXItemId)
+	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@0H0H@Z @ 89 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &, int, class TDesC16 const &, int)
+	?RunError@CMPXDbActiveTask@@MAEHH@Z @ 90 NONAME ; int CMPXDbActiveTask::RunError(int)
+	??0CMPXDbTable@@IAE@AAVCMPXDbManager@@@Z @ 91 NONAME ; CMPXDbTable::CMPXDbTable(class CMPXDbManager &)
+	?DoCheckTable@CMPXDbTable@@IAEHAAVRSqlDatabase@@ABVTDesC16@@@Z @ 92 NONAME ; int CMPXDbTable::DoCheckTable(class RSqlDatabase &, class TDesC16 const &)
+	?StartL@CMPXDbActiveTask@@QAEXKABVCMPXMedia@@@Z @ 93 NONAME ; void CMPXDbActiveTask::StartL(unsigned long, class CMPXMedia const &)
+	?DoCancel@CMPXDbActiveTask@@MAEXXZ @ 94 NONAME ; void CMPXDbActiveTask::DoCancel(void)
+	?ExecuteIntQueryL@CMPXDbTable@@IAEKABVTDesC16@@KK@Z @ 95 NONAME ; unsigned long CMPXDbTable::ExecuteIntQueryL(class TDesC16 const &, unsigned long, unsigned long)
+	?Fs@CMPXDbManager@@QAEAAVRFs@@XZ @ 96 NONAME ; class RFs & CMPXDbManager::Fs(void)
+	?GenerateUniqueIdL@MPXDbCommonUtil@@SAKAAVRFs@@W4TMPXGeneralCategory@@ABVTDesC16@@H@Z @ 97 NONAME ; unsigned long MPXDbCommonUtil::GenerateUniqueIdL(class RFs &, enum TMPXGeneralCategory, class TDesC16 const &, int)
+	?DeleteFile@MPXDbCommonUtil@@SAHAAVRFs@@ABVTDesC16@@@Z @ 98 NONAME ; int MPXDbCommonUtil::DeleteFile(class RFs &, class TDesC16 const &)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@00@Z @ 99 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
+	?ExecuteSelectQueryOnAllDrivesL@CMPXDbManager@@QAA?AVRSqlStatement@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 100 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryOnAllDrivesL(int, class TRefByValue<class TDesC16 const >, ...)
+	?ReadMenuArrayL@CMPXResource@@QAEPAVCDesC16ArrayFlat@@HAAV?$RArray@H@@@Z @ 101 NONAME ; class CDesC16ArrayFlat * CMPXResource::ReadMenuArrayL(int, class RArray<int> &)
+	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@H@Z @ 102 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, int)
+	?GetDriveIdMatchVolIdL@MPXDbCommonUtil@@SAHAAVRFs@@I@Z @ 103 NONAME ; int MPXDbCommonUtil::GetDriveIdMatchVolIdL(class RFs &, unsigned int)
+	?BaseConstructL@CMPXDbTable@@IAEXXZ @ 104 NONAME ; void CMPXDbTable::BaseConstructL(void)
 	?SetHBuf@MPXDbCommonUtil@@SAHAAPAVHBufC16@@PBVTDesC16@@H@Z @ 105 NONAME ; int MPXDbCommonUtil::SetHBuf(class HBufC16 * &, class TDesC16 const *, int)
-	?SetVisibleChange@CMPXDbActiveTask@@QAEXW4TChangeVisibility@1@@Z @ 106 NONAME ; void CMPXDbActiveTask::SetVisibleChange(enum CMPXDbActiveTask::TChangeVisibility)
-	?SqlCriterion64LC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@_J1@Z @ 107 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterion64LC(class TDesC16 const &, long long, long long)
-	?SqlCriterion64LC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@_J@Z @ 108 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterion64LC(class TDesC16 const &, long long)
-	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@00@Z @ 109 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
-	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@0@Z @ 110 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &)
-	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@0H0H@Z @ 111 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &, int, class TDesC16 const &, int)
-	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@H@Z @ 112 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, int)
-	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@HH@Z @ 113 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, int, int)
-	?StartL@CMPXDbActiveTask@@QAEXKABVCMPXMedia@@@Z @ 114 NONAME ; void CMPXDbActiveTask::StartL(unsigned long, class CMPXMedia const &)
-	?StringFromArrayLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVCDesC16Array@@ABVTDesC16@@@Z @ 115 NONAME ; class HBufC16 * MPXDbCommonUtil::StringFromArrayLC(class CDesC16Array const &, class TDesC16 const &)
-	?StringFromArraysLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVCDesC16Array@@0ABVTDesC16@@1@Z @ 116 NONAME ; class HBufC16 * MPXDbCommonUtil::StringFromArraysLC(class CDesC16Array const &, class CDesC16Array const &, class TDesC16 const &, class TDesC16 const &)
-	?TTimeToDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTTime@@@Z @ 117 NONAME ; class HBufC16 * MPXDbCommonUtil::TTimeToDesLC(class TTime const &)
-	?UpdateMediaL@CMPXDbTable@@MAEXAAVRSqlStatement@@ABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@@Z @ 118 NONAME ; void CMPXDbTable::UpdateMediaL(class RSqlStatement &, class TArray<class TMPXAttribute> const &, class CMPXMedia &)
-	?Version@CMPXDbManager@@QBE?AVTVersion@@XZ @ 119 NONAME ; class TVersion CMPXDbManager::Version(void) const
-	?ExecuteMediaQueryL@CMPXDbTable@@IAEXHABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@H@Z @ 120 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(int, class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int)
-	?ExecuteMediaQueryOnDriveL@CMPXDbTable@@IAEXHABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@@Z @ 121 NONAME ; void CMPXDbTable::ExecuteMediaQueryOnDriveL(int, class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &)
-	?ExecuteSelectQueryOnAllDrivesL@CMPXDbManager@@QAA?AVRSqlStatement@@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 122 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryOnAllDrivesL(int, class TRefByValue<class TDesC16 const >, ...)
+	?FindAndReplaceSingleQuote@MPXDbCommonUtil@@SAXABVTDesC16@@AAVTDes16@@@Z @ 106 NONAME ; void MPXDbCommonUtil::FindAndReplaceSingleQuote(class TDesC16 const &, class TDes16 &)
+	?SqlCriterionLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@00@Z @ 107 NONAME ; class HBufC16 * MPXDbCommonUtil::SqlCriterionLC(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMedia@@ABVTDesC16@@H@Z @ 108 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMedia &, class TDesC16 const &, int)
+	?CurrentTimeDesLC@MPXDbCommonUtil@@SAPAVHBufC16@@XZ @ 109 NONAME ; class HBufC16 * MPXDbCommonUtil::CurrentTimeDesLC(void)
+	?AddSqlCriterionL@MPXDbCommonUtil@@SAHAAVCDesC16Array@@ABVTDesC16@@H@Z @ 110 NONAME ; int MPXDbCommonUtil::AddSqlCriterionL(class CDesC16Array &, class TDesC16 const &, int)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@KKK@Z @ 111 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long, unsigned long, unsigned long)
+	?InTransaction@CMPXDbManager@@QAEHXZ @ 112 NONAME ; int CMPXDbManager::InTransaction(void)
+	?DatabaseCount@CMPXDbManager@@QBEHXZ @ 113 NONAME ; int CMPXDbManager::DatabaseCount(void) const
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXHABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@H@Z @ 114 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(int, class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, int)
+	?ExecuteSumExQueryL@CMPXDbTable@@IAEHABVTDesC16@@KH@Z @ 115 NONAME ; int CMPXDbTable::ExecuteSumExQueryL(class TDesC16 const &, unsigned long, int)
+	?CheckDiskSpaceL@CMPXDbManager@@QAEXH@Z @ 116 NONAME ; void CMPXDbManager::CheckDiskSpaceL(int)
+	?ProcessPatternCharsLC@MPXDbCommonUtil@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 117 NONAME ; class HBufC16 * MPXDbCommonUtil::ProcessPatternCharsLC(class TDesC16 const &)
+	?GetColumnTextL@MPXDbCommonUtil@@SA?AVTPtrC16@@AAVRSqlStatement@@H@Z @ 118 NONAME ; class TPtrC16 MPXDbCommonUtil::GetColumnTextL(class RSqlStatement &, int)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@K@Z @ 119 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long)
+	?CloseAllDatabases@CMPXDbManager@@QAEXXZ @ 120 NONAME ; void CMPXDbManager::CloseAllDatabases(void)
+	?ExecuteMediaQueryL@CMPXDbTable@@IAEXABV?$TArray@VTMPXAttribute@@@@AAVCMPXMediaArray@@ABVTDesC16@@2H2H@Z @ 121 NONAME ; void CMPXDbTable::ExecuteMediaQueryL(class TArray<class TMPXAttribute> const &, class CMPXMediaArray &, class TDesC16 const &, class TDesC16 const &, int, class TDesC16 const &, int)
+	?FillItemChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMedia@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@I1@Z @ 122 NONAME ; void MPXDbCommonUtil::FillItemChangedMessageL(class CMPXMedia &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, class TMPXItemId)
+	?Version@CMPXDbManager@@QBE?AVTVersion@@XZ @ 123 NONAME ; class TVersion CMPXDbManager::Version(void) const
+	?IsRemoteDrive@CMPXDbManager@@QAEHW4TDriveNumber@@@Z @ 124 NONAME ; int CMPXDbManager::IsRemoteDrive(enum TDriveNumber)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@@Z @ 125 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &)
+	?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@KK@Z @ 126 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long, unsigned long)
+	?AddItemAlbumChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@IH1@Z @ 127 NONAME ; void MPXDbCommonUtil::AddItemAlbumChangedMessageL(class CMPXMediaArray &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, int, class TMPXItemId)
 
--- a/mpserviceplugins/mpxsqlitedbcommon/eabi/mpxsqlitedbcommonu.def	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/eabi/mpxsqlitedbcommonu.def	Mon May 03 12:29:20 2010 +0300
@@ -28,110 +28,115 @@
 	_ZN11CMPXDbTable18ExecuteMediaQueryLERK6TArrayI13TMPXAttributeER14CMPXMediaArrayiRK7TDesC16 @ 27 NONAME
 	_ZN11CMPXDbTable18ExecuteMediaQueryLERK6TArrayI13TMPXAttributeER9CMPXMediaRK7TDesC16 @ 28 NONAME
 	_ZN11CMPXDbTable18ExecuteMediaQueryLERK6TArrayI13TMPXAttributeER9CMPXMediaRK7TDesC16i @ 29 NONAME
-	_ZN11CMPXDbTableC2ER13CMPXDbManager @ 30 NONAME
-	_ZN11CMPXDbTableD0Ev @ 31 NONAME
-	_ZN11CMPXDbTableD1Ev @ 32 NONAME
-	_ZN11CMPXDbTableD2Ev @ 33 NONAME
-	_ZN12CMPXResource10ReadHBufCLEi @ 34 NONAME
-	_ZN12CMPXResource14ReadDesCArrayLEi @ 35 NONAME
-	_ZN12CMPXResource14ReadMenuArrayLEiR6RArrayIiE @ 36 NONAME
-	_ZN12CMPXResource15ReadDesCArrayLCEi @ 37 NONAME
-	_ZN12CMPXResource15ReadMenuArrayLCEiR6RArrayIiE @ 38 NONAME
-	_ZN12CMPXResource4NewLERK7TDesC16 @ 39 NONAME
-	_ZN12CMPXResource5NewLCERK7TDesC16 @ 40 NONAME
-	_ZN12CMPXResource7ReleaseEv @ 41 NONAME
-	_ZN13CMPXDbManager10ConstructLERK4TBufILi256EE @ 42 NONAME
-	_ZN13CMPXDbManager13CreateTablesLER12RSqlDatabase @ 43 NONAME
-	_ZN13CMPXDbManager13ExecuteQueryLEi11TRefByValueIK7TDesC16Ez @ 44 NONAME
-	_ZN13CMPXDbManager13InTransactionEv @ 45 NONAME
-	_ZN13CMPXDbManager13IsInitializedEv @ 46 NONAME
-	_ZN13CMPXDbManager13IsRemoteDriveE12TDriveNumber @ 47 NONAME
-	_ZN13CMPXDbManager13OpenDatabaseLEi @ 48 NONAME
-	_ZN13CMPXDbManager14CloseDatabaseLEi @ 49 NONAME
-	_ZN13CMPXDbManager14InitDatabasesLE6RArrayIiE @ 50 NONAME
-	_ZN13CMPXDbManager14PrintDatabaseLEv @ 51 NONAME
-	_ZN13CMPXDbManager14RegisterTableLER9MMPXTable @ 52 NONAME
-	_ZN13CMPXDbManager15CheckDiskSpaceLEi @ 53 NONAME
-	_ZN13CMPXDbManager17CloseAllDatabasesEv @ 54 NONAME
-	_ZN13CMPXDbManager17OpenAllDatabasesLEv @ 55 NONAME
-	_ZN13CMPXDbManager17RecreateDatabaseLEi @ 56 NONAME
-	_ZN13CMPXDbManager19ExecuteSelectQueryLE11TRefByValueIK7TDesC16Ez @ 57 NONAME
-	_ZN13CMPXDbManager19ExecuteSelectQueryLEi11TRefByValueIK7TDesC16Ez @ 58 NONAME
-	_ZN13CMPXDbManager19ExecuteSelectQueryLEjRK7TDesC16i11TRefByValueIS1_Ez @ 59 NONAME
-	_ZN13CMPXDbManager19ExecuteSelectQueryLEjii11TRefByValueIK7TDesC16Ez @ 60 NONAME
-	_ZN13CMPXDbManager21RecreateAllDatabasesLEv @ 61 NONAME
-	_ZN13CMPXDbManager23RegenerateAllDatabasesLEv @ 62 NONAME
-	_ZN13CMPXDbManager2FsEv @ 63 NONAME
-	_ZN13CMPXDbManager6BeginLEv @ 64 NONAME
-	_ZN13CMPXDbManager7CommitLEv @ 65 NONAME
-	_ZN13CMPXDbManager9RollbackLEv @ 66 NONAME
-	_ZN13CMPXDbManagerC1ER3RFs @ 67 NONAME
-	_ZN13CMPXDbManagerC2ER3RFs @ 68 NONAME
-	_ZN13CMPXDbManagerD0Ev @ 69 NONAME
-	_ZN13CMPXDbManagerD1Ev @ 70 NONAME
-	_ZN13CMPXDbManagerD2Ev @ 71 NONAME
-	_ZN15MPXDbCommonUtil10DeleteFileER3RFsRK7TDesC16 @ 72 NONAME
-	_ZN15MPXDbCommonUtil11DesToTTimeLERK7TDesC16 @ 73 NONAME
-	_ZN15MPXDbCommonUtil11GetDRMTypeLERK7TDesC16 @ 74 NONAME
-	_ZN15MPXDbCommonUtil12AppendMediaLER14CMPXMediaArrayRK7TDesC1615TMPXGeneralType19TMPXGeneralCategory10TMPXItemIdij @ 75 NONAME
-	_ZN15MPXDbCommonUtil12AppendValueLER12CDesC16ArrayS1_RK7TDesC16S4_ @ 76 NONAME
-	_ZN15MPXDbCommonUtil12AppendValueLER12CDesC16ArrayS1_RK7TDesC16m @ 77 NONAME
-	_ZN15MPXDbCommonUtil12TTimeToDesLCERK5TTime @ 78 NONAME
-	_ZN15MPXDbCommonUtil13PrependMediaLER14CMPXMediaArrayRK7TDesC1615TMPXGeneralType19TMPXGeneralCategory10TMPXItemIdiji @ 79 NONAME
-	_ZN15MPXDbCommonUtil14GetColumnTextLER13RSqlStatementi @ 80 NONAME
-	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_ @ 81 NONAME
-	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_S2_ @ 82 NONAME
-	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_iS2_i @ 83 NONAME
-	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16i @ 84 NONAME
-	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16ii @ 85 NONAME
-	_ZN15MPXDbCommonUtil15AttributeExistsERK6TArrayI13TMPXAttributeERKS1_ @ 86 NONAME
-	_ZN15MPXDbCommonUtil15CreateFullPathLEiRK7TDesC16 @ 87 NONAME
-	_ZN15MPXDbCommonUtil16AddSqlCriterionLER12CDesC16ArrayRK7TDesC16S4_ @ 88 NONAME
-	_ZN15MPXDbCommonUtil16AddSqlCriterionLER12CDesC16ArrayRK7TDesC16i @ 89 NONAME
-	_ZN15MPXDbCommonUtil16CurrentDateDesLCEv @ 90 NONAME
-	_ZN15MPXDbCommonUtil16CurrentTimeDesLCEv @ 91 NONAME
-	_ZN15MPXDbCommonUtil16SqlCriterion64LCERK7TDesC16x @ 92 NONAME
-	_ZN15MPXDbCommonUtil16SqlCriterion64LCERK7TDesC16xx @ 93 NONAME
-	_ZN15MPXDbCommonUtil17GenerateUniqueIdLER3RFs19TMPXGeneralCategoryRK7TDesC16i @ 94 NONAME
-	_ZN15MPXDbCommonUtil17StringFromArrayLCERK12CDesC16ArrayRK7TDesC16 @ 95 NONAME
-	_ZN15MPXDbCommonUtil18GetMimeTypeForUriLERK7TDesC16 @ 96 NONAME
-	_ZN15MPXDbCommonUtil18StringFromArraysLCERK12CDesC16ArrayS2_RK7TDesC16S5_ @ 97 NONAME
-	_ZN15MPXDbCommonUtil20FillInSupportedUIDsLERK6TArrayI13TMPXAttributeER6RArrayIiE @ 98 NONAME
-	_ZN15MPXDbCommonUtil21GetDriveIdMatchVolIdLER3RFsj @ 99 NONAME
-	_ZN15MPXDbCommonUtil21GetVolIdMatchDriveIdLER3RFsi @ 100 NONAME
-	_ZN15MPXDbCommonUtil21ProcessPatternCharsLCERK7TDesC16 @ 101 NONAME
-	_ZN15MPXDbCommonUtil21ProcessSingleQuotesLCERK7TDesC16 @ 102 NONAME
-	_ZN15MPXDbCommonUtil22AddItemChangedMessageLER14CMPXMediaArray10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjS2_ @ 103 NONAME
-	_ZN15MPXDbCommonUtil23FillItemChangedMessageLER9CMPXMedia10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjS2_ @ 104 NONAME
-	_ZN15MPXDbCommonUtil23FindItemChangedMessageLERK14CMPXMediaArrayRK9CMPXMedia @ 105 NONAME
-	_ZN15MPXDbCommonUtil25FindAndReplaceSingleQuoteERK7TDesC16R6TDes16 @ 106 NONAME
-	_ZN15MPXDbCommonUtil7SetHBufERP7HBufC16PK7TDesC16i @ 107 NONAME
-	_ZN15MPXDbCommonUtil9GetDriveLERK7TDesC16R10TDriveUnit @ 108 NONAME
-	_ZN16CMPXDbActiveTask10GetCommandEv @ 109 NONAME
-	_ZN16CMPXDbActiveTask16GetVisibleChangeEv @ 110 NONAME
-	_ZN16CMPXDbActiveTask16SetVisibleChangeENS_17TChangeVisibilityE @ 111 NONAME
-	_ZN16CMPXDbActiveTask17GetChangeMessagesEv @ 112 NONAME
-	_ZN16CMPXDbActiveTask4NewLER24MMPXDbActiveTaskObserver @ 113 NONAME
-	_ZN16CMPXDbActiveTask4RunLEv @ 114 NONAME
-	_ZN16CMPXDbActiveTask6StartLEmRK9CMPXMedia @ 115 NONAME
-	_ZN16CMPXDbActiveTask7GetStepEv @ 116 NONAME
-	_ZN16CMPXDbActiveTask7GetTaskEv @ 117 NONAME
-	_ZN16CMPXDbActiveTask8DoCancelEv @ 118 NONAME
-	_ZN16CMPXDbActiveTask8RunErrorEi @ 119 NONAME
-	_ZN16CMPXDbActiveTaskD0Ev @ 120 NONAME
-	_ZN16CMPXDbActiveTaskD1Ev @ 121 NONAME
-	_ZN16CMPXDbActiveTaskD2Ev @ 122 NONAME
-	_ZNK13CMPXDbManager13DatabaseCountEv @ 123 NONAME
-	_ZNK13CMPXDbManager6IsOpenEi @ 124 NONAME
-	_ZNK13CMPXDbManager7DbDriveEi @ 125 NONAME
-	_ZNK13CMPXDbManager7VersionEv @ 126 NONAME
-	_ZTI11CMPXDbTable @ 127 NONAME ; #<TI>#
-	_ZTI12CMPXResource @ 128 NONAME ; #<TI>#
-	_ZTI13CMPXDbManager @ 129 NONAME ; #<TI>#
-	_ZTV11CMPXDbTable @ 130 NONAME ; #<VT>#
-	_ZTV12CMPXResource @ 131 NONAME ; #<VT>#
-	_ZTV13CMPXDbManager @ 132 NONAME ; #<VT>#
-	_ZN11CMPXDbTable18ExecuteMediaQueryLEiRK6TArrayI13TMPXAttributeER14CMPXMediaArrayRK7TDesC16i @ 133 NONAME
-	_ZN11CMPXDbTable25ExecuteMediaQueryOnDriveLEiRK6TArrayI13TMPXAttributeER14CMPXMediaArrayRK7TDesC16 @ 134 NONAME
-	_ZN13CMPXDbManager30ExecuteSelectQueryOnAllDrivesLEi11TRefByValueIK7TDesC16Ez @ 135 NONAME
+	_ZN11CMPXDbTable18ExecuteMediaQueryLEiRK6TArrayI13TMPXAttributeER14CMPXMediaArrayRK7TDesC16i @ 30 NONAME
+	_ZN11CMPXDbTable18ExecuteSumExQueryLERK7TDesC16mi @ 31 NONAME
+	_ZN11CMPXDbTable25ExecuteMediaQueryOnDriveLEiRK6TArrayI13TMPXAttributeER14CMPXMediaArrayRK7TDesC16 @ 32 NONAME
+	_ZN11CMPXDbTableC2ER13CMPXDbManager @ 33 NONAME
+	_ZN11CMPXDbTableD0Ev @ 34 NONAME
+	_ZN11CMPXDbTableD1Ev @ 35 NONAME
+	_ZN11CMPXDbTableD2Ev @ 36 NONAME
+	_ZN12CMPXResource10ReadHBufCLEi @ 37 NONAME
+	_ZN12CMPXResource14ReadDesCArrayLEi @ 38 NONAME
+	_ZN12CMPXResource14ReadMenuArrayLEiR6RArrayIiE @ 39 NONAME
+	_ZN12CMPXResource15ReadDesCArrayLCEi @ 40 NONAME
+	_ZN12CMPXResource15ReadMenuArrayLCEiR6RArrayIiE @ 41 NONAME
+	_ZN12CMPXResource4NewLERK7TDesC16 @ 42 NONAME
+	_ZN12CMPXResource5NewLCERK7TDesC16 @ 43 NONAME
+	_ZN12CMPXResource7ReleaseEv @ 44 NONAME
+	_ZN13CMPXDbManager10ConstructLERK4TBufILi256EE @ 45 NONAME
+	_ZN13CMPXDbManager13CopyDBsToRamLEi @ 46 NONAME
+	_ZN13CMPXDbManager13CreateTablesLER12RSqlDatabase @ 47 NONAME
+	_ZN13CMPXDbManager13ExecuteQueryLEi11TRefByValueIK7TDesC16Ez @ 48 NONAME
+	_ZN13CMPXDbManager13InTransactionEv @ 49 NONAME
+	_ZN13CMPXDbManager13IsInitializedEv @ 50 NONAME
+	_ZN13CMPXDbManager13IsRemoteDriveE12TDriveNumber @ 51 NONAME
+	_ZN13CMPXDbManager13OpenDatabaseLEi @ 52 NONAME
+	_ZN13CMPXDbManager14CloseDatabaseLEi @ 53 NONAME
+	_ZN13CMPXDbManager14InitDatabasesLE6RArrayIiE @ 54 NONAME
+	_ZN13CMPXDbManager14PrintDatabaseLEv @ 55 NONAME
+	_ZN13CMPXDbManager14RegisterTableLER9MMPXTable @ 56 NONAME
+	_ZN13CMPXDbManager15CheckDiskSpaceLEi @ 57 NONAME
+	_ZN13CMPXDbManager15CopyDBsFromRamLEv @ 58 NONAME
+	_ZN13CMPXDbManager15EnsureRamSpaceLEv @ 59 NONAME
+	_ZN13CMPXDbManager17CloseAllDatabasesEv @ 60 NONAME
+	_ZN13CMPXDbManager17OpenAllDatabasesLEv @ 61 NONAME
+	_ZN13CMPXDbManager17RecreateDatabaseLEi @ 62 NONAME
+	_ZN13CMPXDbManager19ExecuteSelectQueryLE11TRefByValueIK7TDesC16Ez @ 63 NONAME
+	_ZN13CMPXDbManager19ExecuteSelectQueryLEi11TRefByValueIK7TDesC16Ez @ 64 NONAME
+	_ZN13CMPXDbManager19ExecuteSelectQueryLEjRK7TDesC16i11TRefByValueIS1_Ez @ 65 NONAME
+	_ZN13CMPXDbManager19ExecuteSelectQueryLEjii11TRefByValueIK7TDesC16Ez @ 66 NONAME
+	_ZN13CMPXDbManager21RecreateAllDatabasesLEv @ 67 NONAME
+	_ZN13CMPXDbManager23RegenerateAllDatabasesLEv @ 68 NONAME
+	_ZN13CMPXDbManager2FsEv @ 69 NONAME
+	_ZN13CMPXDbManager30ExecuteSelectQueryOnAllDrivesLEi11TRefByValueIK7TDesC16Ez @ 70 NONAME
+	_ZN13CMPXDbManager6BeginLEv @ 71 NONAME
+	_ZN13CMPXDbManager7CommitLEv @ 72 NONAME
+	_ZN13CMPXDbManager9RollbackLEv @ 73 NONAME
+	_ZN13CMPXDbManagerC1ER3RFs @ 74 NONAME
+	_ZN13CMPXDbManagerC2ER3RFs @ 75 NONAME
+	_ZN13CMPXDbManagerD0Ev @ 76 NONAME
+	_ZN13CMPXDbManagerD1Ev @ 77 NONAME
+	_ZN13CMPXDbManagerD2Ev @ 78 NONAME
+	_ZN15MPXDbCommonUtil10DeleteFileER3RFsRK7TDesC16 @ 79 NONAME
+	_ZN15MPXDbCommonUtil11DesToTTimeLERK7TDesC16 @ 80 NONAME
+	_ZN15MPXDbCommonUtil11GetDRMTypeLERK7TDesC16 @ 81 NONAME
+	_ZN15MPXDbCommonUtil12AppendMediaLER14CMPXMediaArrayRK7TDesC1615TMPXGeneralType19TMPXGeneralCategory10TMPXItemIdij @ 82 NONAME
+	_ZN15MPXDbCommonUtil12AppendValueLER12CDesC16ArrayS1_RK7TDesC16S4_ @ 83 NONAME
+	_ZN15MPXDbCommonUtil12AppendValueLER12CDesC16ArrayS1_RK7TDesC16m @ 84 NONAME
+	_ZN15MPXDbCommonUtil12TTimeToDesLCERK5TTime @ 85 NONAME
+	_ZN15MPXDbCommonUtil13PrependMediaLER14CMPXMediaArrayRK7TDesC1615TMPXGeneralType19TMPXGeneralCategory10TMPXItemIdiji @ 86 NONAME
+	_ZN15MPXDbCommonUtil14GetColumnTextLER13RSqlStatementi @ 87 NONAME
+	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_ @ 88 NONAME
+	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_S2_ @ 89 NONAME
+	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16S2_iS2_i @ 90 NONAME
+	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16i @ 91 NONAME
+	_ZN15MPXDbCommonUtil14SqlCriterionLCERK7TDesC16ii @ 92 NONAME
+	_ZN15MPXDbCommonUtil15AttributeExistsERK6TArrayI13TMPXAttributeERKS1_ @ 93 NONAME
+	_ZN15MPXDbCommonUtil15CreateFullPathLEiRK7TDesC16 @ 94 NONAME
+	_ZN15MPXDbCommonUtil16AddSqlCriterionLER12CDesC16ArrayRK7TDesC16S4_ @ 95 NONAME
+	_ZN15MPXDbCommonUtil16AddSqlCriterionLER12CDesC16ArrayRK7TDesC16i @ 96 NONAME
+	_ZN15MPXDbCommonUtil16CurrentDateDesLCEv @ 97 NONAME
+	_ZN15MPXDbCommonUtil16CurrentTimeDesLCEv @ 98 NONAME
+	_ZN15MPXDbCommonUtil16SqlCriterion64LCERK7TDesC16x @ 99 NONAME
+	_ZN15MPXDbCommonUtil16SqlCriterion64LCERK7TDesC16xx @ 100 NONAME
+	_ZN15MPXDbCommonUtil17GenerateUniqueIdLER3RFs19TMPXGeneralCategoryRK7TDesC16i @ 101 NONAME
+	_ZN15MPXDbCommonUtil17StringFromArrayLCERK12CDesC16ArrayRK7TDesC16 @ 102 NONAME
+	_ZN15MPXDbCommonUtil18GetMimeTypeForUriLERK7TDesC16 @ 103 NONAME
+	_ZN15MPXDbCommonUtil18StringFromArraysLCERK12CDesC16ArrayS2_RK7TDesC16S5_ @ 104 NONAME
+	_ZN15MPXDbCommonUtil20FillInSupportedUIDsLERK6TArrayI13TMPXAttributeER6RArrayIiE @ 105 NONAME
+	_ZN15MPXDbCommonUtil21GetDriveIdMatchVolIdLER3RFsj @ 106 NONAME
+	_ZN15MPXDbCommonUtil21GetVolIdMatchDriveIdLER3RFsi @ 107 NONAME
+	_ZN15MPXDbCommonUtil21ProcessPatternCharsLCERK7TDesC16 @ 108 NONAME
+	_ZN15MPXDbCommonUtil21ProcessSingleQuotesLCERK7TDesC16 @ 109 NONAME
+	_ZN15MPXDbCommonUtil22AddItemChangedMessageLER14CMPXMediaArray10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjS2_ @ 110 NONAME
+	_ZN15MPXDbCommonUtil23FillItemChangedMessageLER9CMPXMedia10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjS2_ @ 111 NONAME
+	_ZN15MPXDbCommonUtil23FindItemChangedMessageLERK14CMPXMediaArrayRK9CMPXMedia @ 112 NONAME
+	_ZN15MPXDbCommonUtil25FindAndReplaceSingleQuoteERK7TDesC16R6TDes16 @ 113 NONAME
+	_ZN15MPXDbCommonUtil7SetHBufERP7HBufC16PK7TDesC16i @ 114 NONAME
+	_ZN15MPXDbCommonUtil9GetDriveLERK7TDesC16R10TDriveUnit @ 115 NONAME
+	_ZN16CMPXDbActiveTask10GetCommandEv @ 116 NONAME
+	_ZN16CMPXDbActiveTask16GetVisibleChangeEv @ 117 NONAME
+	_ZN16CMPXDbActiveTask16SetVisibleChangeENS_17TChangeVisibilityE @ 118 NONAME
+	_ZN16CMPXDbActiveTask17GetChangeMessagesEv @ 119 NONAME
+	_ZN16CMPXDbActiveTask4NewLER24MMPXDbActiveTaskObserver @ 120 NONAME
+	_ZN16CMPXDbActiveTask4RunLEv @ 121 NONAME
+	_ZN16CMPXDbActiveTask6StartLEmRK9CMPXMedia @ 122 NONAME
+	_ZN16CMPXDbActiveTask7GetStepEv @ 123 NONAME
+	_ZN16CMPXDbActiveTask7GetTaskEv @ 124 NONAME
+	_ZN16CMPXDbActiveTask8DoCancelEv @ 125 NONAME
+	_ZN16CMPXDbActiveTask8RunErrorEi @ 126 NONAME
+	_ZN16CMPXDbActiveTaskD0Ev @ 127 NONAME
+	_ZN16CMPXDbActiveTaskD1Ev @ 128 NONAME
+	_ZN16CMPXDbActiveTaskD2Ev @ 129 NONAME
+	_ZNK13CMPXDbManager13DatabaseCountEv @ 130 NONAME
+	_ZNK13CMPXDbManager6IsOpenEi @ 131 NONAME
+	_ZNK13CMPXDbManager7DbDriveEi @ 132 NONAME
+	_ZNK13CMPXDbManager7VersionEv @ 133 NONAME
+	_ZTI11CMPXDbTable @ 134 NONAME
+	_ZTI12CMPXResource @ 135 NONAME
+	_ZTI13CMPXDbManager @ 136 NONAME
+	_ZTV11CMPXDbTable @ 137 NONAME
+	_ZTV12CMPXResource @ 138 NONAME
+	_ZTV13CMPXDbManager @ 139 NONAME
+	_ZN15MPXDbCommonUtil27AddItemAlbumChangedMessageLER14CMPXMediaArray10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjiS2_ @ 140 NONAME
 
--- a/mpserviceplugins/mpxsqlitedbcommon/group/mpxsqlitedbcommon.mmp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/group/mpxsqlitedbcommon.mmp	Mon May 03 12:29:20 2010 +0300
@@ -27,6 +27,9 @@
 
 CAPABILITY      CAP_GENERAL_DLL
 
+MACRO __RAMDISK_PERF_ENABLE
+#define __RAMDISK_PERF_ENABLE
+
 VERSION 15.0
 
 SOURCEPATH      ../src
@@ -59,6 +62,10 @@
 LIBRARY         bafl.lib
 LIBRARY         ecom.lib // DestroyedImplementation
 LIBRARY         mpxcommon.lib
+LIBRARY         centralrepository.lib
+
+ALWAYS_BUILD_AS_ARM
+OPTION ARMCC -O3 -Otime
 
 #if defined(ARMCC)
 deffile ../eabi/ 
--- a/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbcommonutil.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbcommonutil.cpp	Mon May 03 12:29:20 2010 +0300
@@ -41,6 +41,120 @@
 // CONSTANTS
 _LIT(KPathStart, ":\\");
 
+// ============================ FILE EXTENSION TO MIME MAP ==============================
+
+// ----------------------------------------------------------------------------------------------------------
+// Statically allocated Mime Map
+// ----------------------------------------------------------------------------------------------------------
+//
+
+_LIT( KExtensionAac,    "aac" );
+_LIT( KExtensionAif,    "aif"); 
+_LIT( KExtensionAifc,   "aifc"); 
+_LIT( KExtensionAiff,   "aiff");
+_LIT( KExtensionAmr,    "amr" );
+_LIT( KExtensionAu,     "au" );
+_LIT( KExtensionAwb,    "awb" );
+_LIT( KExtensionMid,    "mid" );
+_LIT( KExtensionMidi,   "midi" );
+_LIT( KExtensionMka,    "mka" );
+_LIT( KExtensionMp3,    "mp3" );
+_LIT( KExtensionOgg,    "ogg");
+_LIT( KExtensionRa,     "ra"); 
+_LIT( KExtensionRam,    "ram"); 
+_LIT( KExtensionRmi,    "rmi"); 
+_LIT( KExtensionSnd,    "snd" );
+_LIT( KExtensionSpMid,  "spmid" );
+_LIT( KExtensionWav,    "wav" );
+_LIT( KExtensionWma,    "wma" );
+
+_LIT8( KMimeTypeAac,      "audio/aac" );
+_LIT8( KMimeTypeAiff,     "audio/x-aiff");
+_LIT8( KMimeTypeAmr,      "audio/amr" );
+_LIT8( KMimeTypeAu,       "audio/au" );
+_LIT8( KMimeTypeAwb,      "audio/amr-wb" );
+_LIT8( KMimeTypeBasic,    "audio/basic");
+_LIT8( KMimeTypeMatroska, "audio/x-matroska");
+_LIT8( KMimeTypeMid,      "audio/mid");
+_LIT8( KMimeTypeMidi,     "audio/midi" );
+_LIT8( KMimeTypeMpeg,     "audio/mpeg" );
+_LIT8( KMimeTypeOgg,      "audio/ogg");
+_LIT8( KMimeTypeReal,     "audio/x-pn-realaudio");
+_LIT8( KMimeTypeSpMidi,   "audio/sp-midi" );
+_LIT8( KMimeTypeWav,      "audio/wav" ); 
+_LIT8( KMimeTypeWma,      "audio/x-ms-wma");
+
+struct TMimeMapItem {
+	const TDesC  * iExt;
+	const TDesC8 * iType;
+};
+
+// We need to explicitly cast here as LitC::operator& requires writable DLL data (even though it is just a cast)
+#define MIME_MAP_ITEM(ext,type) { &REINTERPRET_CAST(const TDesC&, ext), &REINTERPRET_CAST(const TDesC8&, type) }
+
+// THIS ARRAY MUST BE SORTED BY EXTENSION
+static const TMimeMapItem KMimeMap [] = {
+    MIME_MAP_ITEM( KExtensionAac,   KMimeTypeAac),
+    MIME_MAP_ITEM( KExtensionAif,   KMimeTypeAiff ),
+    MIME_MAP_ITEM( KExtensionAifc,  KMimeTypeAiff ),
+    MIME_MAP_ITEM( KExtensionAiff,  KMimeTypeAiff ),
+    MIME_MAP_ITEM( KExtensionAmr,   KMimeTypeAmr ),
+    MIME_MAP_ITEM( KExtensionAu,    KMimeTypeAu ), // KMimeTypeAudioBasic?  "audio/x-au"?
+    MIME_MAP_ITEM( KExtensionAwb,   KMimeTypeAwb ),
+    MIME_MAP_ITEM( KExtensionMid,   KMimeTypeMidi ),
+    MIME_MAP_ITEM( KExtensionMidi,  KMimeTypeMidi ),
+    MIME_MAP_ITEM( KExtensionMka,   KMimeTypeMatroska ),
+    MIME_MAP_ITEM( KExtensionMp3,   KMimeTypeMpeg ),
+    MIME_MAP_ITEM( KExtensionOgg,   KMimeTypeOgg ),
+    MIME_MAP_ITEM( KExtensionRa,    KMimeTypeReal ),
+    MIME_MAP_ITEM( KExtensionRam,   KMimeTypeReal ),
+    MIME_MAP_ITEM( KExtensionRmi,   KMimeTypeMid ),
+    MIME_MAP_ITEM( KExtensionSnd,   KMimeTypeBasic ),
+    MIME_MAP_ITEM( KExtensionSpMid, KMimeTypeSpMidi ),
+    MIME_MAP_ITEM( KExtensionWav,   KMimeTypeWav ), // "audio/x-wav"?
+    MIME_MAP_ITEM( KExtensionWma,   KMimeTypeWma )
+};
+
+// ----------------------------------------------------------------------------------------------------------
+// Look for Mime Type from map by file extension
+// Returns NULL if file extension is not known
+// ----------------------------------------------------------------------------------------------------------
+//
+static const TDesC8 * FindMimeTypeFromMap ( const TDesC& aFilename )
+    {
+    // extract extension
+   	TPtrC extension;
+    TInt pos = aFilename.LocateReverseF( '.' );
+    if ( pos < 0  || ++pos >= aFilename.Length() )
+        {
+        return NULL;
+        }
+    extension.Set( aFilename.Mid( pos ) );
+
+    // binary search from Mime Map
+    TUint begin = 0;
+    TUint end = sizeof KMimeMap / sizeof (TMimeMapItem);
+    while (begin < end)
+        {
+        TUint at = (begin + end) / 2;
+        const TMimeMapItem & item = KMimeMap[at];
+        TInt r = item.iExt->CompareF(extension);
+        if (r == 0)
+            {
+            return item.iType;
+            }
+        else if (r > 0)
+            {
+            end = at;
+            }
+        else
+            {
+            begin = at + 1;
+            }
+        }
+    return NULL;
+}
+
 // ============================ MEMBER FUNCTIONS ==============================
 
 // ----------------------------------------------------------------------------------------------------------
@@ -369,14 +483,7 @@
 
     if ((aDeprecatedId != 0) && (aId != aDeprecatedId))
         {
-        if ( aCategory == EMPXAlbum && aChangeType == EMPXItemModified )
-            {
-            aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aId);
-            }
-        else
-            {
-            aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aDeprecatedId);
-            }
+        aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aDeprecatedId);
         }
     }
 
@@ -809,7 +916,11 @@
     {
     MPX_FUNC("MPXDbUtil::GetMimeTypeForUriL");
 
-    TParsePtrC parse(aUri);
+    if ( const TDesC8 * type = FindMimeTypeFromMap (aUri) )
+        {
+        return TDataType(*type);
+        }
+    
     RApaLsSession appArc;
     User::LeaveIfError(appArc.Connect());
     CleanupClosePushL(appArc);
@@ -1167,5 +1278,33 @@
     return text;
 	}
 
+// ----------------------------------------------------------------------------
+// Add an album item changed message to the message array
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void MPXDbCommonUtil::AddItemAlbumChangedMessageL(
+    CMPXMessageArray& aMessageArray,
+    TMPXItemId aId,
+    TMPXChangeEventType aChangeType,
+    TMPXGeneralCategory aCategory,
+    TUint aUid,
+    TBool aAlbumArt,
+    TMPXItemId aDeprecatedId)
+    {
+    MPX_FUNC("MPXDbCommonUtil::AddItemChangedMessageL");
+    CMPXMessage* message = CMPXMedia::NewL();
+    CleanupStack::PushL(message);
 
+    FillItemChangedMessageL(*message, aId, aChangeType, aCategory, aUid,
+    		aDeprecatedId );
+    if ( aAlbumArt )
+        {
+        message->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aId);
+        }
+    if (FindItemChangedMessageL(aMessageArray, *message) == KErrNotFound)
+        {
+        aMessageArray.AppendL(*message); // ownership xfer
+        }
+    CleanupStack::PopAndDestroy(message);
+    }
 // End of File
--- a/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp	Mon May 03 12:29:20 2010 +0300
@@ -27,6 +27,10 @@
 //#include <sqlrowsetutil.h>
 //#endif
 #include <sysutil.h>
+#ifdef __RAMDISK_PERF_ENABLE
+#include <centralrepository.h>
+#include <BAUTILS.H>  
+#endif //__RAMDISK_PERF_ENABLE
 
 #include <mpxlog.h>
 
@@ -68,6 +72,24 @@
 const TInt KMaxLogQuery = 248;
 const TInt KBufIncrement = 10;
 
+#ifdef __RAMDISK_PERF_ENABLE
+_LIT(KSecurePath,   "[%x]%S");
+_LIT(KRAMAliasName, "%S");
+_LIT( KDummyDbFile, "%c:\\private\\10281e17\\dummydb.dat" );
+const TInt64 KMPMegaByte = 1048576;
+const TInt64 KMPEstimatedSongInBytes = KMPMegaByte * 2; 
+const TInt KMPEstimatedSizePerDBEntry = 3000; // worst scenario, can be lower if needed
+const TInt KMPMinimumRAMSizeToRun = 6 * KMPMegaByte; 
+// if RAM is lower than 5MB, doesn't seem enough for SQL as well.
+// so we set this number to move back DBs before being kicked out
+
+// Cenrep key defs -- Only temporary:  Need to find a better place for these
+const TUid KMPCenRepSettingsFeature               = { 0x10207C92 };
+const TUint32 KMPCenRepSettingRamdiskEnabled      = { 0x00000005 };
+const TUint32 KMPCenRepSettingRamdiskMaxDiskSpace = { 0x00000006 };
+
+#endif //__RAMDISK_PERF_ENABLE
+
 // Used to suppress overflow when appending formatted text to a buffer.
 class TOverflowHandle :
     public TDesOverflow
@@ -102,7 +124,10 @@
 //
 EXPORT_C CMPXDbManager::CMPXDbManager(
     RFs& aFs) :
-    iFs(aFs)
+    iFs(aFs), 
+    iRAMDiskPerfEnabled(EFalse),
+    iMaximumAllowedRAMDiskSpaceToCopy(0),
+    iRAMInUse(EFalse)
     {
     MPX_FUNC("CMPXDbManager::CMPXDbManager");
     }
@@ -116,6 +141,33 @@
     {
     MPX_FUNC("CMPXDbManager::ConstructL");
     iDbFile = aDatabaseFile.AllocL();
+    
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt temp;
+    CRepository* repository = CRepository::NewLC( KMPCenRepSettingsFeature );
+    User::LeaveIfError( repository->Get( KMPCenRepSettingRamdiskEnabled, temp ));
+    iRAMDiskPerfEnabled = temp;
+    
+    User::LeaveIfError( repository->Get( KMPCenRepSettingRamdiskMaxDiskSpace, temp) );
+    iMaximumAllowedRAMDiskSpaceToCopy = temp * KMPMegaByte;
+    CleanupStack::PopAndDestroy(repository);
+            
+    if ( iRAMDiskPerfEnabled )
+        {
+        MPX_DEBUG1("CMPXDbManager::ConstructL RAMDisk performance is enabled.");
+        MPX_DEBUG2("CMPXDbManager::ConstructL RAMDisk iMaximumAllowedRAMDiskSpaceToCopy=%Lu", iMaximumAllowedRAMDiskSpaceToCopy);
+        if ( GetRAMDiskPath() != KErrNone )
+            {
+            // Error finding ram drive, disable ram disk
+            iRAMDiskPerfEnabled = EFalse;
+            }
+        }
+    else
+        {
+        MPX_DEBUG2("CMPXDbManager::ConstructL RAMDisk iRAMDiskPerfEnabled=%d", iRAMDiskPerfEnabled);
+        MPX_DEBUG2("CMPXDbManager::ConstructL RAMDisk iMaximumAllowedRAMDiskSpaceToCopy=%Lu", iMaximumAllowedRAMDiskSpaceToCopy);
+        }
+#endif //__RAMDISK_PERF_ENABLE
     }
 
 // ----------------------------------------------------------------------------
@@ -141,6 +193,14 @@
     CloseAllDatabases();
 
     delete iDbFile;
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt count(iDatabaseHandles.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        RemoveDummyFile(i);
+        }    
+#endif //__RAMDISK_PERF_ENABLE
+    iDatabaseHandles.Close();
     }
 
 // ----------------------------------------------------------------------------
@@ -165,20 +225,344 @@
 
     if (++iTransactionCount == 1)
         {
-        TInt err = iDatabase.Exec(KBeginTransaction);
+        DoBeginL();
+        }
+    }
+
+void CMPXDbManager::DoBeginL()
+    {
+    MPX_FUNC("CMPXDbManager::DoBeginL");
+
+    TInt err = iDatabase.Exec(KBeginTransaction);
         
-        // transforms SQL error to KErrNotReady
-        if( (err <= KSqlErrGeneral && err >= KSqlErrNotDb) || err == KSqlErrStmtExpired )
+    // transforms SQL error to KErrNotReady
+    if( (err <= KSqlErrGeneral && err >= KSqlErrNotDb) || err == KSqlErrStmtExpired )
+        {
+        User::Leave(KErrNotReady);
+        }
+    else
+        {
+        User::LeaveIfError(err);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Copy all DBs to RAM disk
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CMPXDbManager::CopyDBsToRamL( TBool aIsMTPInUse )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::CopyDBsToRamL");
+    if( iRAMDiskPerfEnabled )
+        {
+        if ( !IsRamDiskSpaceAvailable() )
+            {
+            return;
+            }
+        
+        // Check if we are over the allowed ram space.
+        TInt dbSize=0;
+        TInt err = GetTotalDatabasesSize(dbSize);
+        if ( err || (dbSize > iMaximumAllowedRAMDiskSpaceToCopy) )
             {
-            User::Leave(KErrNotReady);
+            MPX_DEBUG2("<--CMPXDbManager::CopyDBsToRamL Over the allowed Ram disk limit %Lu", iMaximumAllowedRAMDiskSpaceToCopy );
+            return;
+            }
+        
+        TInt transactionCount = iTransactionCount;
+        if (iTransactionCount > 0) 
+            {
+            iTransactionCount = 0;
+            DoCommitL();
             }
-        else
+
+        TInt count(iDatabaseHandles.Count());
+        TBool ret = EFalse;
+        for ( TInt i = 0; i < count ; ++i )
             {
-            User::LeaveIfError(err);
+            if ( iDatabaseHandles[i].iUseRAMdb )
+                {
+                // already used
+                MPX_DEBUG1("CMPXDbManager::CopyDBsToRamL iUseRAMdb already ETrue");
+                continue;
+                }
+            iDatabaseHandles[i].iUseRAMdb = ETrue;
+            TRAPD(err, ret = DoCopyDBToRamL( iDatabaseHandles[i].iDrive, aIsMTPInUse ))
+            if ( err != KErrNone )
+                {
+                MPX_DEBUG2("CMPXDbManager::CopyDBsToRamL error=%d", err);
+                // remove dymmy file
+                RemoveDummyFile(i);
+                // try to close database that is opened from RAM disk
+                TRAP_IGNORE(CloseDatabaseL( iDatabaseHandles[i].iDrive ));
+                iDatabaseHandles[i].iUseRAMdb = EFalse;
+                // reopen database from drive not from RAM
+                OpenDatabaseL( iDatabaseHandles[i].iDrive );
+                continue; // continue to copy for next drive
+                }
+            if ( !ret )
+                {
+                iDatabaseHandles[i].iUseRAMdb = EFalse;
+                }
+            }
+            
+        if (transactionCount > 0) 
+            {
+            DoBeginL();
+            iTransactionCount = transactionCount;
             }
         }
+    iRAMInUse = ETrue;
+	
+    MPX_DEBUG1("<--CMPXDbManager::CopyDBsToRamL");
+#endif //__RAMDISK_PERF_ENABLE
+
     }
 
+
+// ----------------------------------------------------------------------------
+// CMPXDbManager::DoCopyDBsToRamL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbManager::DoCopyDBToRamL( TDriveUnit aDrive, TBool aIsMTPInUse )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG2("-->CMPXDbManager::DoCopyDBsToRamL drive=%d", (TInt)aDrive);
+    TFileName dst;
+    TFileName src;
+    dst.Append(iRAMFolder);
+    src.Append(aDrive.Name());
+    src.Append(KDBFilePath);
+    TRAPD( err, BaflUtils::EnsurePathExistsL( iFs, dst ));
+    if ( err != KErrNone )
+        {
+        return EFalse;
+        }
+    TFileName filename;            
+    filename.Format(KSecurePath, User::Identity().iUid, iDbFile); //x:\private\10281e17\[sldfdsf]mpxv2_5.db
+    src.Append(filename);
+    MPX_DEBUG2("RAMDisk src path=%S", &src);
+    TEntry entry;
+    iFs.Entry( src, entry );
+    if (!BlockDiskSpace( aDrive, entry.iSize, aIsMTPInUse ) )
+        {
+        MPX_DEBUG1("CMPXDbManager::DoCopyDBsToRamL() BlockDiskSpace failed");
+        return EFalse; // continue for next drive
+        }
+    TBuf<2> d;
+    d.Append(aDrive.Name());
+    HBufC* temp = HBufC::NewLC(KMaxFileName);
+    temp->Des().Append(d.Left(1));
+    temp->Des().Append(iDbFile->Des());
+    filename.Format(KSecurePath, User::Identity().iUid, temp);
+    CleanupStack::PopAndDestroy(temp);
+    dst.Append(filename);
+    MPX_DEBUG2("RAMDisk dst path=%S", &dst);
+    TInt index( GetDatabaseIndex((TInt)aDrive) );
+    delete iDatabaseHandles[index].iOrigFullFilePath;
+    iDatabaseHandles[index].iOrigFullFilePath = 0;
+    delete iDatabaseHandles[index].iTargetFullFilePath;
+    iDatabaseHandles[index].iTargetFullFilePath = 0;
+    
+    // Save these path so it is convenient to copy back
+    iDatabaseHandles[index].iOrigFullFilePath = HBufC::NewL(src.Length());
+    iDatabaseHandles[index].iTargetFullFilePath = HBufC::NewL(dst.Length());
+        
+    iDatabaseHandles[index].iOrigFullFilePath->Des().Append(src);
+    iDatabaseHandles[index].iTargetFullFilePath->Des().Append(dst);
+
+    TRAP(err, CloseDatabaseL(aDrive));
+    if ( err != KErrNone )
+        {
+        MPX_DEBUG2("<--CMPXDbManager::DoCopyDBsToRamL error=%d", err);
+        TInt index(GetDatabaseIndex((TInt)aDrive));
+        if ( index >= 0 )
+            {
+            RemoveDummyFile( index );
+            }
+        return EFalse;
+        }
+    User::LeaveIfError( BaflUtils::CopyFile(iFs, src, dst ));
+    OpenDatabaseL((TInt)aDrive);
+
+    MPX_DEBUG2("RAMDisk Database opened=%d", (TInt)aDrive);
+    MPX_DEBUG1("<--CMPXDbManager::DoCopyDBsToRamL");
+    return ETrue;    
+#endif //__RAMDISK_PERF_ENABLE
+    }
+
+// ----------------------------------------------------------------------------
+// Copy all DBs from RAM disk back to normal drives
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CMPXDbManager::CopyDBsFromRamL()
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::CopyDBsFromRamL");
+    if( iRAMDiskPerfEnabled )
+       {
+        TInt transactionCount = iTransactionCount;
+        if (iTransactionCount > 0) 
+            {
+            iTransactionCount = 0;
+            DoCommitL();
+            }
+
+        TInt count(iDatabaseHandles.Count());
+        for (TInt i = 0; i < count && iDatabaseHandles[i].iUseRAMdb; ++i)
+            {
+            TRAPD(err, DoCopyDBFromRamL(i));
+            if ( err != KErrNone )
+                {
+                MPX_DEBUG2("<--CMPXDbManager::CopyDBsFromRamL error=%d", err);                
+                //anyting wrong, delete the temp file and open database from drive
+                RemoveDummyFile(i);
+                // delete Db on RAM
+                User::LeaveIfError( BaflUtils::DeleteFile(iFs, 
+                    *iDatabaseHandles[i].iTargetFullFilePath));
+                }
+            iDatabaseHandles[i].iUseRAMdb = EFalse;
+            // open db from drive
+            OpenDatabaseL( iDatabaseHandles[i].iDrive );      
+            }
+
+        if (transactionCount > 0) 
+            {
+            DoBeginL();
+            iTransactionCount = transactionCount;
+            }
+        }
+    iRAMInUse = EFalse;
+        
+    MPX_DEBUG1("<--CMPXDbManager::CopyDBsFromRamL");
+#endif //__RAMDISK_PERF_ENABLE
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbManager::DoCopyDBsToRamL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbManager::DoCopyDBFromRamL( TInt aIndex )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::DoCopyDBsFromRamL");    
+    MPX_DEBUG2("-->CMPXDbManager::DoCopyDBsFromRamL Drive %d will be closed before copying db from RAM.",
+         iDatabaseHandles[aIndex].iDrive);
+
+    CloseDatabaseL(iDatabaseHandles[aIndex].iDrive);            
+
+    // Delete existing DB on drive
+    User::LeaveIfError( BaflUtils::DeleteFile(iFs, 
+        *iDatabaseHandles[aIndex].iOrigFullFilePath));
+    MPX_DEBUG1("CMPXDbManager::DoCopyDBsFromRamL old DB on drive deleted");
+
+    // Rename dummy file to be orignal file name
+    User::LeaveIfError( BaflUtils::RenameFile(iFs, 
+        iDatabaseHandles[aIndex].iDummyFilePath, 
+        *iDatabaseHandles[aIndex].iOrigFullFilePath) );
+    MPX_DEBUG1("CMPXDbManager::CopyDBsFromRamL RAMDisk renamed.");
+
+    //Copy Db from RAM to replace dummy file
+    ReplaceFileL( *iDatabaseHandles[aIndex].iTargetFullFilePath, *iDatabaseHandles[aIndex].iOrigFullFilePath);
+    
+    MPX_DEBUG1("CMPXDbManager::CopyDBsFromRamL RAMDisk copied back.");
+
+    // Delete existing DB on RAM
+    User::LeaveIfError( BaflUtils::DeleteFile(iFs, *iDatabaseHandles[aIndex].iTargetFullFilePath));
+    MPX_DEBUG1("CMPXDbManager::DoCopyDBsFromRamL RAMDisk deleted");
+
+    MPX_DEBUG1("<--CMPXDbManager::DoCopyDBsFromRamL");
+#endif //__RAMDISK_PERF_ENABLE
+    } 
+
+// ----------------------------------------------------------------------------
+// CMPXDbManager::ReplaceFileL
+//
+// Replaces a file with another writing over the destination file.
+// Leaves on error.
+// Implementation follows CFileMan::Copy except that 
+//  - we don't resize target file to zero
+//  - we can assume that files already exist
+//  - we don't copy file attributes & timestamp
+// ----------------------------------------------------------------------------
+//
+void CMPXDbManager::ReplaceFileL( const TDesC& aSrcName, const TDesC& aDstName )
+    {
+    // open files
+    RFile srcFile;
+    User::LeaveIfError( srcFile.Open(iFs, aSrcName, EFileRead|EFileShareReadersOnly) );
+    CleanupClosePushL( srcFile );
+    
+    RFile dstFile;
+    User::LeaveIfError( dstFile.Open(iFs, aDstName, EFileWrite|EFileWriteDirectIO|EFileShareExclusive) );
+    CleanupClosePushL( dstFile );
+    
+    // resize destination file
+    TInt remainingBytes;
+    User::LeaveIfError( srcFile.Size(remainingBytes) );
+    User::LeaveIfError( dstFile.SetSize(remainingBytes) );
+
+    // allocate buffer
+   	const TInt KBigBufSize = 512 * 1024;
+    const TInt KMediumBufSize = 32 * 1024;
+    const TInt KSmallBufSize = 4 * 1024;
+    HBufC8* bufPtr=HBufC8::New( Min(KBigBufSize, remainingBytes) );
+    if (bufPtr==NULL)
+        bufPtr=HBufC8::New(KMediumBufSize);
+    if (bufPtr==NULL)
+        bufPtr=HBufC8::New(KSmallBufSize);
+    if (bufPtr == NULL)
+        User::Leave(KErrNoMemory);
+    CleanupStack::PushL(bufPtr);
+
+    // copy
+    TPtr8 copyBuf=bufPtr->Des();
+    TInt pos=0;
+    while( remainingBytes > 0 )
+        {
+        TInt s = Min( remainingBytes, copyBuf.MaxSize() );
+        TInt ret = srcFile.Read(pos, copyBuf, s);
+        if (ret == KErrNone && copyBuf.Length()!= s )
+            {
+            ret = KErrCorrupt;
+            }
+        if (ret == KErrNone)
+            {
+            ret = dstFile.Write(pos, copyBuf, s);
+            }
+        User::LeaveIfError (ret);
+        pos += s;
+        remainingBytes -= s;
+        }
+    User::LeaveIfError( dstFile.Flush() );
+    CleanupStack::PopAndDestroy(3); // bufPtr, dstFile, srcFile
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbManager::RemoveDummyFile
+// ----------------------------------------------------------------------------
+//
+void CMPXDbManager::RemoveDummyFile( TInt index )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::RemoveDummyFile");
+       
+    if ( iDatabaseHandles[index].iDummyFilePath.Length() )
+        {
+        TInt err = BaflUtils::DeleteFile(iFs, iDatabaseHandles[index].iDummyFilePath);
+        if ( !err )
+            {
+            iDatabaseHandles[index].iDummyFilePath.Zero();
+            }
+        }
+    MPX_DEBUG1("<--CMPXDbManager::RemoveDummyFile");
+#endif //__RAMDISK_PERF_ENABLE
+
+    }
+
+
 // ----------------------------------------------------------------------------
 // Commits a transaction on all databases.
 // ----------------------------------------------------------------------------
@@ -191,20 +575,31 @@
         {
         if (--iTransactionCount == 0)
             {
-            TInt err = iDatabase.Exec(KCommitTransaction);
-            
-            // transforms SQL error to KErrNotReady
-            if( (err <= KSqlErrGeneral && err >= KSqlErrNotDb) || err == KSqlErrStmtExpired )
-                {
-                User::Leave(KErrNotReady);
-                }
-            else
-                {
-                User::LeaveIfError(err);
-                }
+            DoCommitL();
             }
         }
     }
+    
+// ----------------------------------------------------------------------------
+// Commits a transaction on all databases.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbManager::DoCommitL()
+    {
+    MPX_FUNC("CMPXDbManager::DoCommitL");
+    TInt err = iDatabase.Exec(KCommitTransaction);
+    
+    // transforms SQL error to KErrNotReady
+    if( (err <= KSqlErrGeneral && err >= KSqlErrNotDb) || err == KSqlErrStmtExpired )
+        {
+        MPX_DEBUG2("CMPXDbManager::CommitL failed err=%d", err);
+        User::Leave(KErrNotReady);
+        }
+    else
+        {
+        User::LeaveIfError(err);
+        }
+    }
 
 // ----------------------------------------------------------------------------
 // Rolls back a transaction on all databases.
@@ -273,6 +668,12 @@
             handle.iAliasname = HBufC::NewL(KAliasName().Length());
             handle.iAliasname->Des().Format(KAliasName, &driveName);
             handle.iOpen = EFalse;
+#ifdef __RAMDISK_PERF_ENABLE
+            handle.iOrigFullFilePath = HBufC::NewL(0);
+            handle.iTargetFullFilePath = HBufC::NewL(0);
+            handle.iDummyFilePath.Zero();
+            handle.iUseRAMdb = EFalse;
+#endif //__RAMDISK_PERF_ENABLE
 
             iDatabaseHandles.AppendL(handle);
 
@@ -313,8 +714,10 @@
             {
             if (iDatabaseHandles[i].iDrive == aDrive)
                 {
+                MPX_DEBUG2("CMPXDbManager::OpenDatabaseL found %d", aDrive);
                 if (!iDatabaseHandles[i].iOpen)
                     {
+                    MPX_DEBUG1("CMPXDbManager::OpenDatabaseL not open found");
                     // make sure the database is created
 					CreateDatabaseL(drive);
 
@@ -329,6 +732,7 @@
         }
     if (!found)
         {
+        MPX_DEBUG1("CMPXDbManager::OpenDatabaseL not found");
         User::Leave(KErrArgument);
         }
 
@@ -366,8 +770,10 @@
             {
             if (iDatabaseHandles[i].iDrive == aDrive)
                 {
+                MPX_DEBUG2("CMPXDbManager::CloseDatabaseL found %d", aDrive);
                 if (iDatabaseHandles[i].iOpen)
                     {
+                    MPX_DEBUG1("CMPXDbManager::CloseDatabaseL found open");
                     DetachDatabaseL(drive);
                     }
 
@@ -378,6 +784,7 @@
         }
     if (!found)
         {
+        MPX_DEBUG1("CMPXDbManager::CloseDatabaseL not found");
         User::Leave(KErrArgument);
         }
 
@@ -401,6 +808,11 @@
         for (TInt i = 0; i < count; ++i)
             {
             delete iDatabaseHandles[i].iAliasname;
+#ifdef __RAMDISK_PERF_ENABLE 
+            delete iDatabaseHandles[i].iOrigFullFilePath;
+            delete iDatabaseHandles[i].iTargetFullFilePath;
+            iDatabaseHandles[i].iDummyFilePath.Zero();
+#endif //__RAMDISK_PERF_ENABLE 
             }
 
         iDatabaseHandles.Reset();
@@ -1295,7 +1707,7 @@
 
     if (database.Open(filename->Des()) != KErrNone)
         {
-        MPX_DEBUG2("CMPXDbManager::CreateDatabaseL - cannot open the database on drive %d", TInt(aDrive));
+        MPX_DEBUG3("CMPXDbManager::CreateDatabaseL - cannot open db on drive %d %S", TInt(aDrive), filename);
 
         // close the database first
         database.Close();
@@ -1350,19 +1762,50 @@
                 {
                 HBufC* filename = CreateFilenameL(aDrive);
                 CleanupStack::PushL(filename);
+                
+#ifdef __RAMDISK_PERF_ENABLE
+                if( iDatabaseHandles[i].iUseRAMdb )
+                    {
+                    delete iDatabaseHandles[i].iAliasname;
+                    iDatabaseHandles[i].iAliasname = HBufC::NewL(KAliasName().Length());
+                    HBufC* temp = HBufC::NewLC(2); // form of DE, DF, DX,...
+                    temp->Des().Append(iRAMDrive); // length == 2
+                    TDriveUnit pdrive(aDrive);
+                    temp->Des().Append(pdrive.Name().Left(1)); //length == 2+ 1
+                    iDatabaseHandles[i].iAliasname->Des().Format(KRAMAliasName, temp);
+                    MPX_DEBUG2("CMPXDbManager::AttachDatabaseL - RAM change aliasname of %S", iDatabaseHandles[i].iAliasname );
+                    CleanupStack::PopAndDestroy(temp);
+                    }
+                else
+#endif //__RAMDISK_PERF_ENABLE
+                   {
+                   delete iDatabaseHandles[i].iAliasname;
+                   TDriveUnit drive(aDrive);
+                   const TDesC& driveName = drive.Name();
+                   iDatabaseHandles[i].iAliasname = HBufC::NewL(KAliasName().Length());
+                   iDatabaseHandles[i].iAliasname->Des().Format(KAliasName, &driveName);
+                   MPX_DEBUG2("CMPXDbManager::AttachDatabaseL - normal change aliasname of %S", iDatabaseHandles[i].iAliasname);
+                   }
 
-                User::LeaveIfError(iDatabase.Attach(filename->Des(),
-                    *(iDatabaseHandles[i].iAliasname)));
+                TInt err = iDatabase.Attach(filename->Des(), *(iDatabaseHandles[i].iAliasname));
+                MPX_DEBUG2("CMPXDbManager::AttachDatabaseL - Attach Error =%d", err);
+                User::LeaveIfError(err);
                 iDatabaseHandles[i].iOpen = ETrue;
 
                 CleanupStack::PopAndDestroy(filename);
                 }
+            else
+                {
+                MPX_DEBUG1("CMPXDbManager::AttachDatabaseL - found already open");    
+                }
+            
             found = ETrue;
             break;
             }
         }
     if (!found)
         {
+        MPX_DEBUG1("CMPXDbManager::AttachDatabaseL - not found");
         User::Leave(KErrNotFound);
         }
     }
@@ -1384,9 +1827,24 @@
         {
         if (iDatabaseHandles[i].iDrive == aDrive)
             {
-            if (iDatabaseHandles[i].iOpen)
+#ifdef __RAMDISK_PERF_ENABLE
+            if ( iDatabaseHandles[i].iOpen || iDatabaseHandles[i].iUseRAMdb )
+#else //__RAMDISK_PERF_ENABLE
+            if ( iDatabaseHandles[i].iOpen )
+#endif //__RAMDISK_PERF_ENABLE
+
                 {
-                User::LeaveIfError(iDatabase.Detach(*(iDatabaseHandles[i].iAliasname)));
+                MPX_DEBUG1("CMPXDbManager::DetachDatabaseL found drive that is opening");
+                TInt err = iDatabase.Detach(*(iDatabaseHandles[i].iAliasname));
+                if ( err )
+                    {
+                    MPX_DEBUG2("CMPXDbManager::DetachDatabaseL detach failed Error=%d", err);
+                    }
+                else
+                    {
+                    MPX_DEBUG2("CMPXDbManager::DetachDatabaseL iAliasname=%S", iDatabaseHandles[i].iAliasname);
+                    }
+                User::LeaveIfError(err);
                 iDatabaseHandles[i].iOpen = EFalse;
                 }
 
@@ -1396,6 +1854,7 @@
         }
     if (!found)
         {
+        MPX_DEBUG1("CMPXDbManager::DetachDatabaseL drive not found in iDatabaseHandlers");
         User::Leave(KErrNotFound);
         }
     }
@@ -1414,8 +1873,33 @@
     const TDesC& securefilePath = KSecureFilePath;
     TDriveUnit cdrive(KRootDrive());
 
-    const TDesC& driveName = aDrive.Name();
-    filename->Des().Format(securefilePath, &driveName, User::Identity().iUid, iDbFile);
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt index(GetDatabaseIndex((TInt)aDrive));    
+    if ( index >=0 && iDatabaseHandles[index].iUseRAMdb && aDrive != cdrive )
+        {
+        MPX_DEBUG1("CMPXDbManager::CreateFilenameL - use RAMDisk");
+        TFileName path;
+        path.Append(iRAMDrive);
+        path.Append(_L(":"));
+        TBuf<2> d;
+        d.Append(aDrive.Name());
+        HBufC* temp = HBufC::NewLC(KMaxFileName);
+        temp->Des().Append(d.Left(1)); // attach original drive name
+        temp->Des().Append(iDbFile->Des()); 
+        filename->Des().Format(securefilePath, &path, User::Identity().iUid, temp);
+        MPX_DEBUG3("CMPXDbManager::CreateFilenameL - path=%S filename=%S", &path, filename);
+        CleanupStack::PopAndDestroy(temp);
+        }
+    else
+#endif //__RAMDISK_PERF_ENABLE
+        {
+        MPX_DEBUG1("CMPXDbManager::CreateFilenameL - use normal drive");
+        const TDesC& driveName = aDrive.Name();
+        filename->Des().Format(securefilePath, &driveName, User::Identity().iUid, iDbFile);
+
+        }
+    
+    MPX_DEBUG2("CMPXDbManager::CreateFilenameL filename = %S", filename); 
     return filename;
     }
 
@@ -1512,43 +1996,13 @@
         MPX_DEBUG1("invalid driveId, leave with KErrNotReady");
         User::Leave(KErrNotReady);
         }
-
-    // handle the case of C drive
-    TDriveUnit drive(aDrive);
-    TDriveUnit cdrive(KRootDrive());
-
-    if(drive == cdrive)
-        {
-        if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, 0, aDrive))
-            {
-            User::Leave(KErrDiskFull);
-            }
-
-        return;
-        }
+    
+#ifndef __RAMDISK_PERF_ENABLE 
+    
+    EnsureDiskSpaceL(aDrive);
+    
+#endif //__RAMDISK_PERF_ENABLE
 
-    // handle other drives (eg. removable EDriveE)
-    TInt count(iDatabaseHandles.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-
-        if (((KDbManagerAllDrives == aDrive) ||
-            (aDrive == iDatabaseHandles[i].iDrive)) &&
-            iDatabaseHandles[i].iOpen)
-            {
-            if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, 0,
-                iDatabaseHandles[i].iDrive))
-                {
-                User::Leave(KErrDiskFull);
-                }
-            }
-
-        if (aDrive == iDatabaseHandles[i].iDrive)
-            {
-            // exit if just one drive to check
-            break;
-            }
-        }
     }
     
 // ----------------------------------------------------------------------------
@@ -1984,7 +2438,24 @@
     // remove old databases before creating/replacing new database
     TInt driveNameLen = aDrive.Name().Length();
     
-    TFileName dbFileName(aDrive.Name()); //initialise with drive name        
+    TFileName dbFileName;
+
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt index(GetDatabaseIndex((TInt)aDrive));
+    if( index >= 0 && iDatabaseHandles[index].iUseRAMdb )
+        {
+        dbFileName.Append(iRAMDrive); // RAM
+        dbFileName.Append(_L(":")); // RAM
+        }
+    else 
+#endif //__RAMDISK_PERF_ENABLE
+        {
+        MPX_DEBUG1("CMPXDbManager::CreateDatabaseL - E:");
+        dbFileName.Append(aDrive.Name()); //initialise with drive name
+        }
+        
+
+    MPX_DEBUG2("CMPXDbManager::CreateDatabaseL - dbFileName=%S", &dbFileName);
     dbFileName.Append(KDBFilePath);  // append private path
     
     //append file name
@@ -2048,5 +2519,491 @@
     CleanupStack::PopAndDestroy(filename);
     CleanupStack::PopAndDestroy(&database);
     }
+	
+// ---------------------------------------------------------------------------
+// CMPXDbManager::GetRAMDiskPath
+// ---------------------------------------------------------------------------
+//
+TInt CMPXDbManager::GetRAMDiskPath()
+    {
+    TInt error = KErrNotSupported;
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::GetRAMDiskPath");
+    TDriveList driveList;
+    TBool ramDriveFound = EFalse;
+    TInt driveOffset = 'A';
+    iRAMFolder.Zero();
+    
+    error = iFs.DriveList( driveList );
+    if ( error == KErrNone )
+        {
+        for ( TInt i = 0; i < driveList.Length(); i++ )
+            {
+            if ( driveList[i] != 0 )
+                {
+                TDriveInfo info;
+                TInt err = iFs.Drive( info, i );
+                if ( !err && info.iType == EMediaRam )
+                    {
+                    iRAMDrive = driveOffset + i;
+                    iRAMFolder.Append(iRAMDrive);
+                    iRAMFolder.Append(_L(":"));
+                    iRAMFolder.Append(KDBFilePath);
+                    ramDriveFound = ETrue;
+                    MPX_DEBUG2("RAMDisk path=%S", &iRAMFolder);
+                    break;
+                    }
+                }
+            }
+        
+        // Check if ram drive is found.
+        if ( !ramDriveFound )
+            {
+            error = KErrNotFound;
+            }
+        }
+    MPX_DEBUG2("CMPXDbManager::GetRAMDiskPath Get DriveList error=%d", error);
+    MPX_DEBUG1("<--CMPXDbManager::GetRAMDiskPath");
+#endif //__RAMDISK_PERF_ENABLE
+    return error;
+    }
 
+// ---------------------------------------------------------------------------
+// CMPXDbManager::IsRamDiskSpaceAvailable
+// ---------------------------------------------------------------------------
+//
+TBool CMPXDbManager::IsRamDiskSpaceAvailable()
+    {
+
+#ifdef __RAMDISK_PERF_ENABLE
+
+    MPX_DEBUG1("-->CMPXDbManager::IsDiskSpaceAvailable" );
+    TInt driveIndex;
+    RFs::CharToDrive(iRAMDrive, driveIndex);
+    TVolumeInfo vol;
+    TInt err = iFs.Volume( vol, driveIndex );
+    if ( err == KErrNone )
+        {
+        MPX_DEBUG2("CMPXDbManager::IsRamDiskSpaceAvailable Free in bytes =%Lu", vol.iFree);
+        if ( vol.iFree > KMPMinimumRAMSizeToRun )
+            {
+            MPX_DEBUG1("CMPXDbManager::IsRamDiskSpaceAvailable Ok to copy");
+            return ETrue;
+            }
+        MPX_DEBUG1("CMPXDbManager::IsRamDiskSpaceAvailable NOT Ok to copy");
+        return EFalse;
+        }
+    
+    MPX_DEBUG2("CMPXDbManager::IsRamDiskSpaceAvailable Disk Not available to use. %d", err);
+    MPX_DEBUG1("<--CMPXDbManager::IsDiskSpaceAvailable");
+
+#endif //__RAMDISK_PERF_ENABLE
+
+    return EFalse;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::BlockDiskSpaceL
+// ---------------------------------------------------------------------------
+//
+TBool CMPXDbManager::BlockDiskSpace( TDriveUnit aDrive, TInt aOrigDbSize, TBool aIsMTPInUse )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+
+    MPX_DEBUG2("-->CMPXDbManager::BlockDiskSpaceL %d", (TInt)aDrive );
+    
+    // if current DB size can not fit in RAM, abort now
+    TInt ramDrive;
+    RFs::CharToDrive(iRAMDrive, ramDrive);
+    TVolumeInfo vol;
+    TInt err = iFs.Volume( vol, ramDrive );
+    if ( vol.iFree <= aOrigDbSize + KMPMinimumRAMSizeToRun )
+        {
+        MPX_DEBUG1("-->CMPXDbManager::BlockDiskSpaceL Not enough even for copy original DB file, leave" );
+        return EFalse;
+        }
+
+    // ensure you have the disk volume and database
+    err = iFs.Volume( vol, (TInt)aDrive );
+    if (err != KErrNone) 
+        {
+        MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Volume not available on drive %d", (TInt)aDrive);
+        return EFalse;
+        }
+
+    TInt index( GetDatabaseIndex((TInt)aDrive) );
+    if (index < 0) 
+        {
+        MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Database not available for drive %d", (TInt)aDrive);
+        return EFalse;
+        }
+
+    // Check if the drive has enough space to block
+    MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Disk total free space in bytes =%Lu", vol.iFree);
+    TInt64 blockingSize( CalculateInitalDummyDBSize( vol, aOrigDbSize, aIsMTPInUse ));
+    MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Disk blocking size =%Lu", blockingSize);
+    if ( vol.iFree <= blockingSize + 1*KMPMegaByte )
+        {
+        MPX_DEBUG1("CMPXDbManager::BlockDiskSpaceL NOk to block");
+        return EFalse;
+        }
+
+    // Create and resize the dummy file
+    TFileName dummyDbFileName; 
+    TChar ch;
+    RFs::DriveToChar((TInt)aDrive, ch );
+    dummyDbFileName.Format( KDummyDbFile, (TUint)ch);
+    RFile dummyDb;
+    err = dummyDb.Replace( iFs, dummyDbFileName, EFileWrite );
+    if (err != KErrNone) 
+        {
+        MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Can't open dummy file %d", err);
+        return EFalse;
+        }
+    err = dummyDb.SetSize( blockingSize );
+    if ( err )
+        {
+        MPX_DEBUG2("CMPXDbManager::BlockDiskSpaceL Can't resize dummy file %d", err);
+        dummyDb.Close();
+        return EFalse;
+        }
+
+    dummyDb.Close();
+    MPX_DEBUG1("CMPXDbManager::BlockDiskSpaceL Ok to block");
+
+    iDatabaseHandles[index].iDummyFilePath.Copy(dummyDbFileName);
+    MPX_DEBUG1("<--CMPXDbManager::BlockDiskSpace");
+
+    return ETrue;
+#else
+    return EFalse;
+#endif //__RAMDISK_PERF_ENABLE
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::CalculateInitalDummyDBSizeL
+//
+//a) MTP case
+//-------------
+//        totalNumOfSongsCanFit = <disk free space> / 2 MB;
+//        metadataSize = totalNumOfSongsCanFit * 3000B 
+//        estimatedDBSize = metadataSize + <orig DB size>;
+//        dummyDBSize = MIN (iMaximumAllowedRAMDiskSpaceToCopy , estimatedDBSize )
+
+//b) Harvesting case
+//-------------------
+//        totalNumOfSongsCanFit = <disk total size>/ 2 MB
+//        metadataSize = totalNumOfSongsCanFit * 3000B 
+//        estimatedSize = metadataSize+ <orig DB size>
+//        freeDiskSpace = <disk free space> - 1 MB
+//        dummyDBSize = MIN (freeDiskSpace, iMaximumAllowedRAMDiskSpaceToCopy , estimatedSize);
+//
+// ---------------------------------------------------------------------------
+//
+TInt64 CMPXDbManager::CalculateInitalDummyDBSize( const TVolumeInfo& aVol, TInt aOrigDbSize, TBool aIsMTPInUse )
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::CalculateInitalDummyDBSize");
+
+    if ( aIsMTPInUse )
+        {
+        TInt64 totalNumOfSongsCanFit = aVol.iFree / KMPEstimatedSongInBytes;
+        MPX_DEBUG2("-->CMPXDbManager::CalculateInitalDummyDBSize aVol.iFree=%Lu", aVol.iFree );
+        MPX_DEBUG2("-->CMPXDbManager::CalculateInitalDummyDBSize totalNumOfSongsCanFit=%Lu", totalNumOfSongsCanFit );
+        TInt64 estimatedSize = totalNumOfSongsCanFit * (TInt64) KMPEstimatedSizePerDBEntry + aOrigDbSize;
+        MPX_DEBUG2("-->CMPXDbManager::CalculateInitalDummyDBSize (MTP case) estimated DB size from calculation=%Lu", estimatedSize );
+        if ( estimatedSize > iMaximumAllowedRAMDiskSpaceToCopy )
+            {
+            MPX_DEBUG2("<--CMPXDbManager::CalculateInitalDummyDBSize returned iMaximumAllowedRAMDiskSpaceToCopy %d", iMaximumAllowedRAMDiskSpaceToCopy);
+            return iMaximumAllowedRAMDiskSpaceToCopy;
+            }
+        else
+            {
+            MPX_DEBUG2("<--CMPXDbManager::CalculateInitalDummyDBSize returned %Lu", estimatedSize );
+            return estimatedSize;
+            }
+        }
+    else
+        {
+        TInt64 totalNumOfSongsCanFit = aVol.iSize / KMPEstimatedSongInBytes;
+        TInt64 estimatedSize = totalNumOfSongsCanFit * (TInt64) KMPEstimatedSizePerDBEntry + aOrigDbSize;
+        MPX_DEBUG2("-->CMPXDbManager::CalculateInitalDummyDBSize estimated DB size from calculation=%Lu", estimatedSize );
+        if ( estimatedSize > iMaximumAllowedRAMDiskSpaceToCopy )
+            {
+            MPX_DEBUG1("<--CMPXDbManager::CalculateInitalDummyDBSize");
+            // If estimated size is larger than expected free RAM size, 
+            // and if the RAM size is larger than free disk space,
+            // then use free disk space. 1*KMPMegaByte prevent MP to use up all diskspace
+            //return iMaximumAllowedRAMDiskSpaceToCopy > aVol.iFree - 1*KMPMegaByte  
+            //    ? aVol.iFree - 1*KMPMegaByte : iMaximumAllowedRAMDiskSpaceToCopy;
+            return iMaximumAllowedRAMDiskSpaceToCopy;
+            }
+        else
+            {
+            MPX_DEBUG1("<--CMPXDbManager::CalculateInitalDummyDBSize");
+            // If estimated size is larger than disk free size, use free diskspace size,            
+            //return estimatedSize > aVol.iFree - 1*KMPMegaByte
+            //    ? aVol.iFree - 1*KMPMegaByte : estimatedSize;
+            return estimatedSize;
+            }
+        }
+    
+#endif //__RAMDISK_PERF_ENABLE    
+    }
+    
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::GetDatabaseIndex
+// ---------------------------------------------------------------------------
+//
+TInt CMPXDbManager::GetDatabaseIndex(TInt aDrive) 
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG2("-->CMPXDbManager::GetDatabaseIndex %d", aDrive );
+    TInt count(iDatabaseHandles.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        if ( iDatabaseHandles[i].iDrive == aDrive )
+            {
+            return i;
+            }
+        }    
+#endif //__RAMDISK_PERF_ENABLE    
+    MPX_DEBUG1("<--CMPXDbManager::GetDatabaseIndex returned -1");
+    return -1;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::EnsureRamSpaceL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CMPXDbManager::EnsureRamSpaceL() 
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::EnsureRamSpaceL");
+
+    if ( iRAMInUse )
+        {
+        TVolumeInfo vol;
+        TInt driveIndex;
+        RFs::CharToDrive( iRAMDrive, driveIndex );
+
+        TInt errRAM = iFs.Volume( vol, driveIndex );
+        if ( errRAM == KErrNone && vol.iFree < KMPMinimumRAMSizeToRun )
+            {
+            // RAM not enough, copy back to normal drive and continue to harvest.
+            MPX_DEBUG1("CMPXDbManager::EnsureRamSpaceL RAM diskspace is full, copy dbs back");
+            CopyDBsFromRamL();
+            }
+        else
+            {
+            TInt size=0;
+            TInt err = GetTotalRamDatabasesSize(size);
+            if ( err || (size > iMaximumAllowedRAMDiskSpaceToCopy) )
+                {
+                // Databases using too much RAM space, copy back to normal drive and continue to harvest.
+                if ( err )
+                    {
+                    MPX_DEBUG2("CMPXDbManager::EnsureRamSpaceL Get DBs Size Err = %d, copy dbs back", err);
+                    }
+                else
+                    {
+                    MPX_DEBUG2("CMPXDbManager::EnsureRamSpaceL DBs using too much RAM space size = %d, copy dbs back", size);
+                    }
+                CopyDBsFromRamL();
+                }
+            }
+        }
+    MPX_DEBUG1("<--CMPXDbManager::EnsureRamSpaceL");
+#endif //__RAMDISK_PERF_ENABLE    
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::EnsureDiskSpaceL
+// ---------------------------------------------------------------------------
+//
+void CMPXDbManager::EnsureDiskSpaceL(TInt aDrive) 
+    {
+    MPX_DEBUG2("-->CMPXDbManager::EnsureDiskSpaceL for drive %d", aDrive);
+    // handle the case of C drive
+    TDriveUnit drive(aDrive);
+    TDriveUnit cdrive(KRootDrive());
+
+    if(drive == cdrive)
+        {
+        if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, 0, aDrive))
+            {
+            MPX_DEBUG1("CMPXDbManager::EnsureDiskSpaceL Error diskspace full");
+            User::Leave(KErrDiskFull);
+            }
+
+        return;
+        }
+
+    // handle other drives (eg. removable EDriveE)
+    TInt count(iDatabaseHandles.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        if (((KDbManagerAllDrives == aDrive) ||
+            (aDrive == iDatabaseHandles[i].iDrive)) &&
+            iDatabaseHandles[i].iOpen)
+            {
+            if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, 0,
+                iDatabaseHandles[i].iDrive))
+                {
+                MPX_DEBUG1("CMPXDbManager::EnsureDiskSpaceL Error diskspace full");
+                User::Leave(KErrDiskFull);
+                }
+            }
+
+        if (aDrive == iDatabaseHandles[i].iDrive)
+            {
+            // exit if just one drive to check
+            break;
+            }
+        }
+    MPX_DEBUG1("<--CMPXDbManager::EnsureDiskSpaceL");
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbManager::DoBackupDBs
+// ---------------------------------------------------------------------------
+//
+/*EXPORT_C void CMPXDbManager::BackupDBsL()
+    {
+#ifdef __RAMDISK_PERF_ENABLE
+    MPX_DEBUG1("-->CMPXDbManager::BackupDBsL");
+
+    TInt transactionCount = iTransactionCount;
+    if (iTransactionCount > 0) 
+        {
+        iTransactionCount = 0;
+        DoCommitL();
+        }
+    
+    TInt count(iDatabaseHandles.Count());
+    for (TInt i = 0; i < count && iDatabaseHandles[i].iUseRAMdb ; ++i)
+        {
+        CloseDatabaseL( iDatabaseHandles[i].iDrive );            
+
+        TInt err= BaflUtils::CopyFile(iFs, 
+            iDatabaseHandles[i].iTargetFullFilePath->Des(), 
+            iDatabaseHandles[i].iOrigFullFilePath->Des());
+
+        MPX_DEBUG2("CMPXDbManager::BackupDBsL err = %d", err);     
+
+        OpenDatabaseL( iDatabaseHandles[i].iDrive );      
+        }
+        
+    if (transactionCount > 0) 
+        {
+        DoBeginL();
+        iTransactionCount = transactionCount;
+        }
+    MPX_DEBUG1("<--CMPXDbManager::BackupDBsL");
+#endif //__RAMDISK_PERF_ENABLE    
+    }*/
+    
+// ---------------------------------------------------------------------------
+// CMPXDbManager::GetTotalDatabasesSize
+// ---------------------------------------------------------------------------
+//
+TInt CMPXDbManager::GetTotalDatabasesSize(TInt& aSize)
+    {
+    MPX_FUNC("CMPXDbManager::GetTotalDatabasesSize");
+    TInt err = KErrNotSupported;
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt size=0;
+    TInt count(iDatabaseHandles.Count());
+    err = KErrNone;
+    for ( TInt i = 0; i < count ; ++i )
+        {
+        // Generate database name.
+        TFileName dbFilename;
+        TDriveUnit drive(iDatabaseHandles[i].iDrive);
+        dbFilename.Append(drive.Name());
+        dbFilename.Append(KDBFilePath);
+        TFileName filename;            
+        filename.Format(KSecurePath, User::Identity().iUid, iDbFile); //x:\private\10281e17\[sldfdsf]mpxv2_5.db
+        dbFilename.Append(filename);
+        MPX_DEBUG2("CMPXDbManager::GetTotalDatabasesSize - Database name = %S", &dbFilename);
+        TEntry entry;
+        err = iFs.Entry( dbFilename, entry );
+        if (err == KErrNotFound || err == KErrNotReady )
+            {
+            MPX_DEBUG3("CMPXDbManager::GetTotalDatabasesSize - Ignored %S, error = %d", &dbFilename, err);
+            err = KErrNone;
+            continue;
+            }
+        if ( err != KErrNone )
+            {
+            break;
+            }
+        MPX_DEBUG3("CMPXDbManager::GetTotalDatabasesSize - Size of Db %S = %d", &dbFilename, entry.iSize);
+        // sum up size
+        size += entry.iSize;
+        }
+    aSize = size;
+    MPX_DEBUG2("CMPXDbManager::GetTotalDatabasesSize - Total Size of Dbs = %d", size);
+    
+#endif //__RAMDISK_PERF_ENABLE    
+    MPX_DEBUG2("CMPXDbManager::GetTotalDatabasesSize - Return err = %d", err);
+    return err;
+    }
+    
+// ---------------------------------------------------------------------------
+// CMPXDbManager::GetTotalRamDatabasesSize
+// ---------------------------------------------------------------------------
+//
+TInt CMPXDbManager::GetTotalRamDatabasesSize(TInt& aSize)
+    {
+    MPX_FUNC("CMPXDbManager::GetTotalRamDatabasesSize");
+    TInt err = KErrNotSupported;
+#ifdef __RAMDISK_PERF_ENABLE
+    TInt size=0;
+    TInt count(iDatabaseHandles.Count());
+    err = KErrNone;
+    for ( TInt i = 0; i < count ; ++i )
+        {
+        // make sure this db is in ram drive.
+        if ( !iDatabaseHandles[i].iUseRAMdb )
+            {
+            continue;
+            }
+        // Generate database name.
+        TFileName dbFilename;
+        dbFilename.Append(iRAMFolder);
+        TBuf<2> d;
+        TDriveUnit drive(iDatabaseHandles[i].iDrive);
+        d.Append(drive.Name());
+        HBufC* temp = HBufC::NewLC(KMaxFileName);
+        temp->Des().Append(d.Left(1));
+        temp->Des().Append(iDbFile->Des());
+        TFileName filename;            
+        filename.Format(KSecurePath, User::Identity().iUid, temp);
+        CleanupStack::PopAndDestroy(temp);
+        dbFilename.Append(filename);
+        MPX_DEBUG2("CMPXDbManager::GetTotalRamDatabasesSize - Database name = %S", &dbFilename);
+        TEntry entry;
+        err = iFs.Entry( dbFilename, entry );
+        if ( (err != KErrNone) && (err != KErrNotFound) )
+            {
+            break;
+            }
+        MPX_DEBUG3("CMPXDbManager::GetTotalRamDatabasesSize - Size of Db %S = %d", &dbFilename, entry.iSize);
+        // sum up size
+        size += entry.iSize;
+        }
+    aSize = size;
+    MPX_DEBUG2("CMPXDbManager::GetTotalRamDatabasesSize - Total Size of Dbs = %d", size);
+#endif //__RAMDISK_PERF_ENABLE    
+    MPX_DEBUG2("CMPXDbManager::GetTotalRamDatabasesSize - Return err = %d", err);
+    return err;
+    }
+    
 // End of File
--- a/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp	Mon May 03 12:29:20 2010 +0300
@@ -764,6 +764,41 @@
     }
 
 // ----------------------------------------------------------------------------
+// CMPXDbTable::ExecuteSumExQueryL
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt CMPXDbTable::ExecuteSumExQueryL(
+    const TDesC& aQuery, 
+    TUint32 aPlaylistId, 
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbTable::ExecuteSumExQueryL");
+
+    HBufC* query = HBufC::NewLC(aQuery.Length() + KMCIntegerLen);
+    query->Des().Format(aQuery, aPlaylistId);  
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryOnAllDrivesL(aDrive, *query));
+    CleanupClosePushL(recordset);
+
+    TInt sum(0);
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        sum += recordset.ColumnInt64(KMPXTableDefaultIndex);
+        }
+    
+    CleanupStack::PopAndDestroy(&recordset);
+    CleanupStack::PopAndDestroy(query);
+
+    if (err != KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    return sum;
+    }
+
+// ----------------------------------------------------------------------------
 // CMPXDbTable::ExecuteMediaQueryL
 // ----------------------------------------------------------------------------
 //
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/data/10207C85.RSS	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+#include <mpxcollectionplugin.hrh>
+#include "mpxpluginresource.hrh"
+
+/**
+ * The opaque_data syntax is made up of three parts: 
+ * a list of Uids for resolving the view plugin, feature flags, priority.
+ * 
+ * <p>uid1;uid2;uid3</p>
+ *  uid*: Supported plugin types.
+ *  E.g. if podcast plugin may support music plugin as well, KMPXColPluginMusic
+ *
+ * <t>uid</t>
+ *  uid: plugin type uid.
+ *  E.g. for music plugin will be: 0x101FFCDA
+ *
+ * <f>flags</f> [optional]
+ *  flags: sum of the required feature flags
+ *         Collection specific flags include:
+ *                EMPXCollectionPluginFlagCacheable - Are media results cachable in the collection cache
+ *         General flags include: 
+ *                EMPXPluginFlagPreLoad - Should the plugin be pre loaded when the collection starts
+ *                
+ *
+ * <i>priority</i> [optional]
+ *  priority: a value of type TMPXCollectionPluginPriorities. This value determines
+ *  the returning order when several plugins can support the same set of Uids. 
+ *  Default value of this field is EMPXCollectionPluginPriorityNormal.
+ *
+ * <c>non-cacheable attributes</c> optional
+ *  List of content IDs that cannot be cached in the collection cache.
+ *  The list is a list of hexidecimal numbers, semicolon seperated
+ *  For example, <c>0x101FFC45</c> not cache media objects w/ drm attributes
+ *
+ */
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x10207C85;
+
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KMPXCollectionPluginInterfaceUid;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x101FFC3A;
+                    version_no = 1;
+                    display_name = "";
+                    default_data = "audio/mp3;audio/x-mp3;audio/mp4;audio/3gpp;audio/3gpp2;audio/wav;audio/x-wav;audio/x-au;audio/au;audio/3gp;audio/mpeg;audio/aac;audio/x-ms-wma;x-caf-audio/x-ms-wma;audio/x-pn-realaudio;audio/x-realaudio;audio/vnd.rn-realaudio";
+                    opaque_data = "<s>*<e>.mp3;.aac;.3gp;.3gpp;.3g2;.3gpp2;.m4a;.wav;.mp4;.wma;.dcf;.odf;.asf;.m3u;.rm;.ra;.o4a;.dm;.3ga"
+                                  "<t>"EMPXCollectionPluginMusic"</t>"
+                                  "<i>"EMPXPluginPriorityHighest"</i>"
+                                  "<c>"EDRMContentId"</c>" // DRM
+                                  "<f>"EPreloadAndCache"</f>";
+                    }
+                };
+            }
+        };
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/data/mpxcollectiondbhgres.rss	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,322 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains all the resources for the Music Collection
+*
+*/
+
+
+//  INCLUDES
+#include <bldvariant.hrh>
+#include <badef.rh>
+#include <pathconfiguration.hrh>
+#include "mpxcollectiondb.hrh"
+
+
+STRUCT MENU_ITEM
+    {
+    LONG   id;
+    STRUCT name;
+    }
+
+STRUCT MENU_ITEM_ARRAY
+    {
+    STRUCT array_of_menu_items[];
+    }
+
+//  RESOURCE IDENTIFIER
+NAME    OAMC // 4 letter ID
+
+//  RESOURCE DEFINITIONS
+
+RESOURCE BA_RSS_SIGNATURE { }
+
+//----------------------------------------------------
+//
+//    r_mc_music_library_menu_items
+//    Menu items to be displayed in the music library view
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_ITEM_ARRAY r_mc_menu_items_array
+    {
+    array_of_menu_items =
+        {
+        MENU_ITEM {id = EBrowseAll;      name = LBUF {txt = qtn_mus_all_tracks;};},
+        MENU_ITEM {id = EBrowsePlaylist; name = LBUF {txt = qtn_mus_playlists;};},
+        MENU_ITEM {id = EBrowseArtist;   name = LBUF {txt = qtn_mus_artists;};},
+        MENU_ITEM {id = EBrowseAlbum;    name = LBUF {txt = qtn_mus_albums;};},
+#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU        
+        MENU_ITEM {id = EBrowsePodcasts; name = LBUF {txt = qtn_mus_podcasts;};},
+#endif
+        MENU_ITEM {id = EBrowseGenre;    name = LBUF {txt = qtn_mus_genres;};},
+        MENU_ITEM {id = EBrowseComposer; name = LBUF {txt = qtn_mus_composers;};}        
+        };
+    }
+
+RESOURCE TBUF { buf="MPXCOLLECTIONDBRES"; }
+
+//----------------------------------------------------
+//
+//    r_mc_music_library_title_items
+//    titles to be displayed in the music player
+//
+//    added album for ganes
+//----------------------------------------------------
+//
+RESOURCE MENU_ITEM_ARRAY r_mc_title_items_array
+    {
+    array_of_menu_items =
+        {
+        MENU_ITEM {id = EBrowseAll;      name = LBUF {txt = qtn_mus_title_tracks;};},
+        MENU_ITEM {id = EBrowsePlaylist; name = LBUF {txt = qtn_mus_title_pls;};},
+        MENU_ITEM {id = EBrowseArtist;   name = LBUF {txt = qtn_mus_title_artists;};},
+        MENU_ITEM {id = EBrowseAlbum;    name = LBUF {txt = qtn_mus_title_artists_and_albums;};},
+#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU                
+        MENU_ITEM {id = EBrowsePodcasts; name = LBUF {txt = qtn_mus_podcasts;};},
+#endif        
+        MENU_ITEM {id = EBrowseGenre;    name = LBUF {txt = qtn_mus_title_genres;};},
+        MENU_ITEM {id = EBrowseComposer; name = LBUF {txt = qtn_mus_title_composers;};},     
+        MENU_ITEM {id = EBrowseAlbumSong;    name = LBUF {txt = qtn_mus_title_album;};}
+        };
+    }
+
+
+// ** DEFAULT MUSIC FOLDER STRINGS
+
+//----------------------------------------------------
+//
+//    r_mc_default_music_folders
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_mc_default_music_folders
+    {
+    items =
+        {
+        LBUF {txt = text_memory_card_root_path;},
+        LBUF {txt = text_phone_memory_root_path;}
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_mc_music_file_extensions
+//    file extensions which be scanned by music collection
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_mc_music_file_extensions
+    {
+    items =
+        {
+#if (defined __WMA || defined __WINDOWS_MEDIA)
+        LBUF {txt = ".wma";},
+#endif
+        LBUF {txt = ".mp3";},
+        LBUF {txt = ".m4a";},
+        LBUF {txt = ".aac";}
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_mc_file_extensions_mime
+//    file extensions which can be scanned by music
+//    collection, however, these files types must be
+//    checked whether their MIME types match as well
+//    because they can be DRM or video files
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_mc_file_extensions_mime
+    {
+    items =
+        {
+        LBUF {txt = "";},
+#ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
+        LBUF {txt = ".ra";},
+        LBUF {txt = ".rm";},
+#endif
+        LBUF {txt = ".mp4";},
+        LBUF {txt = ".3gpp";},
+        LBUF {txt = ".3gp";},
+        LBUF {txt = ".3gpp2";},
+        LBUF {txt = ".3g2";},
+        LBUF {txt = ".3ga";},
+        LBUF {txt = ".dcf";},
+        LBUF {txt = ".dm";},
+        LBUF {txt = ".odf";}
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_mc_file_extensions_drm
+//    file extensions which can be scanned by music
+//    collection, however, these files types must be
+//    checked which type of DRM is used
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_mc_file_extensions_drm
+    {
+    items =
+        {
+        LBUF {txt = "";},
+        LBUF {txt = ".dcf";},
+        LBUF {txt = ".dm";},
+        LBUF {txt = ".odf";},
+        LBUF {txt = ".o4a";}
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_mc_mime_types
+//    Mime types which be scanned by music collection
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_mc_mime_types
+    {
+    items =
+        {
+#ifdef __WMA
+        LBUF {txt = "audio/x-ms-wma";},
+#endif
+#ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
+        LBUF {txt = "audio/x-pn-realaudio";},
+        LBUF {txt = "audio/x-realaudio";},
+        LBUF {txt = "audio/vnd.rn-realaudio";},
+//        LBUF {txt = "application/vnd.rn-realmedia";}
+#endif
+        LBUF {txt = "audio/mpeg";},
+        LBUF {txt = "audio/aac";},
+        LBUF {txt = "audio/mp3";},
+        LBUF {txt = "audio/x-mp3";},
+        LBUF {txt = "audio/mp4";},
+        LBUF {txt = "audio/3gpp";},
+        LBUF {txt = "audio/m4a";},
+        LBUF {txt = "audio/3gpp2";},
+        LBUF {txt = "audio/mpeg4";}
+        };
+    }
+
+// ** All songs for an artist
+RESOURCE LBUF r_mc_all_songs_for_artist
+    {
+    txt = qtn_nmp_all_by;
+    }
+
+// ** Recently played
+RESOURCE LBUF r_mc_recently_played_playlist
+    {
+    txt = qtn_mus_pl_recently_played;
+    }
+
+// ** Most played
+RESOURCE LBUF r_mc_most_played_playlist
+    {
+    txt = qtn_mus_pl_most_played;
+    }
+
+// ** Recently added
+RESOURCE LBUF r_mc_recently_added_playlist
+    {
+    txt = qtn_mus_pl_recently_downloaded;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_music_num_songs
+// Number of songs text
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mpx_qtn_mus_music_num_songs
+    {
+    txt = qtn_mus_music_num_songs;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_music_one_song
+// One song text
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mpx_qtn_mus_music_one_song
+    {
+    txt = qtn_mus_music_one_song;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_music
+// Collection Plugin Name
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mpx_qtn_mus_music
+    {
+    txt = qtn_mus_music;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_title_music_menu
+// Music Menu Title
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mpx_qtn_mus_title_music_menu
+    {
+    txt = qtn_mus_title_music_menu;
+    }
+
+#ifdef __ENABLE_MUSIC_TEXT_ALIGNMENT
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mp_title_my_music_menu_nseries
+// My Music Menu Title
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mpx_qtn_mp_title_my_music_menu_nseries
+    {
+    txt = qtn_mp_title_my_music_menu_nseries;
+    }
+#endif //__ENABLE_MUSIC_TEXT_ALIGNMENT
+
+// ---------------------------------------------------------------------------
+// r_mc_title_most_played
+// Title for Most Played item in the playlists menu
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mc_title_most_played
+    {
+    txt = qtn_mus_title_most_played;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_title_music_menu
+// Title for Recently Played item in the playlists menu
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mc_title_recently_played
+    {
+    txt = qtn_mus_title_recently_played;
+    }
+
+// ---------------------------------------------------------------------------
+// r_mpx_qtn_mus_title_music_menu
+// Title for Recently Added item in the playlists menu
+// ---------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mc_title_recently_downloaded
+    {
+    txt = qtn_mus_title_recently_downloaded;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/group/bld.inf	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project Sqlite Collection plugin.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+OPTION TARGETFILE mpxdbhgplugin.mif
+OPTION HEADERFILE mpxdbhgplugin.mbg
+OPTION SOURCES -c8,8 qgn_graf_mup_dlst_music
+END
+
+
+PRJ_MMPFILES
+
+mpxsqlitedbhgplugin.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/group/iconlist.txt	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,1 @@
+/c8,8 qgn_graf_mup_dlst_music
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/group/mpxdbpluginiconshg.mk	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icons makefile for project mpxdbplugin
+#
+
+
+ifeq (WINS,$(findstring WINS,$(PLATFORM)))
+ZDIR=$(EPOCROOT)epoc32/release/$(PLATFORM)/$(CFG)/z
+else
+ZDIR=$(EPOCROOT)epoc32/data/z
+endif
+
+TARGETDIR=$(ZDIR)/resource/apps
+HEADERDIR=$(EPOCROOT)epoc32/include
+ICONTARGETFILENAME=$(TARGETDIR)/mpxdbplugin.mif
+HEADERFILENAME=$(HEADERDIR)/mpxdbplugin.mbg
+
+MAKMAKE : ;
+
+BLD : ;
+
+CLEAN : ;
+
+LIB : ;
+
+CLEANLIB : ;
+
+RESOURCE : 
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/Ficonlist.txt
+
+FREEZE : ;
+
+SAVESPACE : ;
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : ;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/group/mpxsqlitedbhgplugin.mmp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Collection file db plugin project specification
+*
+*/
+
+
+#include <bldvariant.hrh>
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+#include "../../../inc/musicplayerbldvariant.hrh"
+
+TARGET          mpxsqlitedbhgplugin.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x10207C85
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_ECOM_PLUGIN
+
+VERSION 15.0
+
+MACRO __ENABLE_PODCAST_IN_MUSIC_MENU
+#define __ENABLE_PODCAST_IN_MUSIC_MENU
+//MACRO RD_MPX_COLLECTION_CACHE
+MACRO __RAMDISK_PERF_ENABLE
+#define __RAMDISK_PERF_ENABLE
+
+#ifdef IAD_INCLUDE_ABSTRACTAUDIOALBUM
+MACRO ABSTRACTAUDIOALBUM_INCLUDED
+MACRO RD_MPX_TNM_INTEGRATION
+#define RD_MPX_TNM_INTEGRATION
+#endif // IAD_INCLUDE_ABSTRACTAUDIOALBUM
+
+SOURCEPATH      ../src
+SOURCE          mpxdbplugin.cpp
+SOURCE          mpxdbpluginproxy.cpp
+SOURCE          mpxdbutil.cpp
+
+SOURCE          mpxcollectiondbmanager.cpp
+
+SOURCE          mpxdbcategory.cpp
+SOURCE          mpxdbmusic.cpp
+SOURCE          mpxdbplaylist.cpp
+SOURCE          mpxdbplaylistsongs.cpp
+SOURCE          mpxdbauxiliary.cpp
+SOURCE          mpxdbautoplaylist.cpp
+SOURCE          mpxdbhandler.cpp
+SOURCE          mpxdbartist.cpp
+SOURCE          mpxdbalbum.cpp
+SOURCE          mpxdbgenre.cpp
+SOURCE          mpxdbcomposer.cpp
+#ifdef IAD_INCLUDE_ABSTRACTAUDIOALBUM
+SOURCE          mpxdbabstractalbum.cpp
+#endif // IAD_INCLUDE_ABSTRACTAUDIOALBUM
+
+SOURCEPATH       ../data
+START RESOURCE  mpxcollectiondbhgres.rss
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+LANGUAGE_IDS 
+END
+
+SOURCEPATH      ../data
+START RESOURCE  10207C85.RSS
+TARGET          mpxsqlitedbhgplugin.rsc
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         sqldb.lib
+LIBRARY         bafl.lib
+LIBRARY         apmime.lib
+LIBRARY         sysutil.lib
+#ifdef __MTP_PROTOCOL_SUPPORT
+LIBRARY         centralrepository.lib
+#endif
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         PlatformEnv.lib
+#endif //RD_MULTIPLE_DRIVE
+
+LIBRARY         mpxsqlitedbcommon.lib
+LIBRARY         mpxcommon.lib
+#ifdef RD_MPX_TNM_INTEGRATION
+LIBRARY         thumbnailmanager.lib
+#endif 
+ALWAYS_BUILD_AS_ARM
+OPTION ARMCC -O3 -Otime
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondb.hrh	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains declarations for constants of Music
+*                Collection. The file can be included in C++ or resource file.
+*
+*/
+
+
+
+#ifndef MPXCOLLECTIONDB_HRH
+#define MPXCOLLECTIONDB_HRH
+
+enum TMCBrowseType
+    {
+    EBrowseAll = 0,
+    EBrowsePlaylist,
+    EBrowseArtist,
+    EBrowseAlbum,
+#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU            
+    EBrowsePodcasts,
+#endif    
+    EBrowseGenre,
+    EBrowseComposer,        
+    EBrowseAlbumSong //added for ganes
+    };
+
+#endif      // MPXCOLLECTIONDB_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,159 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This header file contains macro definitions used by the
+*                database subsystem.
+*
+*/
+
+#ifndef MPXCOLLECTIONDBDEF_H
+#define MPXCOLLECTIONDBDEF_H
+
+// INCLUDES
+#include <mmfmeta.h>
+
+// CONSTANTS
+
+// ================================== DATABASE ================================
+
+// Db filename
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KMCDbFile, "mpxv2_6.db");
+#else 
+_LIT(KMCDbFile, "mpxv2_5.db");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+// Collection Db resource file
+_LIT(KMPXCollectionDbResourceFile,  "mpxcollectiondbhgres.rsc");
+
+// == TABLE NAMES =============================================================
+// The Auxiliary table stores general database metadata
+_LIT(KMCAuxiliaryTable,             "Auxiliary");
+// The Music table stores songs information
+_LIT(KMCMusicTable,                 "Music");
+// The Playlist table stores playlists information
+_LIT(KMCPlaylistTable,              "Playlist");
+// The PlaylistSongs table stores the song instances for each playlist
+_LIT(KMCPlaylistSongsTable,         "PlaylistSongs");
+// The PlaylistSongInfo table stores the songs that are included in playlists
+_LIT(KMCPlaylistSongInfoTable,      "PlaylistSongInfo");
+// The Artist table stores artist information
+_LIT(KMCArtistTable,                "Artist");
+// The Album table stores albums information
+_LIT(KMCAlbumTable,                 "Album");
+// The Genre table stores genres information
+_LIT(KMCGenreTable,                 "Genre");
+// The Composer table stores composers information
+_LIT(KMCComposerTable,              "Composer");
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// The AbstractAlbum table stores Abstract Album Art information
+_LIT(KMCAbstractAlbumTable,              "AbstractAlbum");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+// == Music TABLE FIELDS ======================================================
+_LIT(KMCMusicUniqueId,          "UniqueId");
+
+// From MMF (MmfMeta.h)
+#define KMCMusicName                KMMFMetaEntrySongTitle           // "title"
+#define KMCMusicArtist              KMMFMetaEntryArtist              // "artist"
+#define KMCMusicAlbum               KMMFMetaEntryAlbum               // "album"
+#define KMCMusicTrackNumber         KMMFMetaEntryAlbumTrack          // "albumtrack"
+#define KMCMusicGenre               KMMFMetaEntryGenre               // "genre"
+#define KMCMusicComposer            KMMFMetaEntryComposer            // "composer"
+#define KMCMusicComment             KMMFMetaEntryComment             // "comment"
+#define KMCMusicCopyright           KMMFMetaEntryCopyright           // "copyright"
+#define KMCMusicOrigArtist          KMMFMetaEntryOriginalArtist      // "originalartist"
+//end of MMF support data
+
+// NOTE: Location will store the path without drive letter
+_LIT(KMCMusicLocation,              "Location");
+_LIT(KMCMusicDuration,              "Duration");
+_LIT(KMCMusicReleaseDate,           "ReleaseDate");
+_LIT(KMCMusicTimeAdded,             "TimeAdded");
+_LIT(KMCMusicPlayCount,             "PlayCount");
+_LIT(KMCMusicTimePlayed,            "TimePlayed");
+_LIT(KMCMusicRating,                "Rating");
+_LIT(KMCMusicArt,                   "Art");
+_LIT(KMCMusicDbFlag,                "DbFlag");
+_LIT(KMCMusicSync,                  "Sync");
+_LIT(KMCMusicMod,                   "Modified");
+_LIT(KMCMusicDel,                   "Deleted");
+_LIT(KMCMusicUrl,                   "Url");
+_LIT(KMCMusicDRM,                   "DRM");
+_LIT(KMCMusicLastPlayPosition,      "LastPlayPosition");
+_LIT(KMCMusicSampleRate,            "SampleRate");
+_LIT(KMCMusicBitRate,               "BitRate");
+_LIT(KMCMusicVolumeId,              "VolumeId");
+
+// Number of channels: required by MTP to support Play4sure
+_LIT(KMCMusicNumChannels,           "NumChannels");
+
+// Audio Codec: required by MTP to support Play4sure
+_LIT(KMCMusicCodec,                 "Codec");
+_LIT(KMCMusicMimeType,              "MimeType");
+_LIT(KMCMusicMTPDrmStatus,          "MTPDrmStatus");
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KMCMusicAlbumArtist,           "AlbumArtist");
+_LIT(KMCMusicContainEmbeddedArt,    "ContainEmbeddedArt");
+_LIT(KMCMusicAbstractAlbum,         "AbstractAlbum");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// == Category TABLE FIELDS ===================================================
+_LIT(KMCCategoryUniqueId,           "UniqueId");
+_LIT(KMCCategoryName,               "Name");
+_LIT(KMCCategorySongCount,          "SongCount");
+
+// == Playlist TABLE FIELDS ===================================================
+_LIT(KMCPlaylistUniqueId,           "UniqueId");
+_LIT(KMCPlaylistName,               "Name");
+_LIT(KMCPlaylistUri,                "Uri");
+_LIT(KMCPlaylistVolumeId,           "VolumeId");
+_LIT(KMCPlaylistSync,               "Sync");
+_LIT(KMCPlaylistDbFlag,             "DbFlag");
+_LIT(KMCPlaylistTime,               "Time");
+
+// == PlaylistSongs TABLE FIELDS ==============================================
+_LIT(KMCPlaylistSongsUniqueId,      "UniqueId");
+_LIT(KMCPlaylistSongsSongId,        "SongId");
+_LIT(KMCPlaylistSongsPlaylistId,        "PlaylistId");
+_LIT(KMCPlaylistSongsOrdinal,   "Ordinal");
+
+// == PlaylistSongInfo TABLE FIELDS ===========================================
+_LIT(KMCPlaylistSongInfoSongId,     "SongId");
+_LIT(KMCPlaylistSongInfoUri,        "Uri");
+_LIT(KMCPlaylistSongInfoTitle,      "Title");
+_LIT(KMCPlaylistSongInfoVolumeId,   "VolumeId");
+_LIT(KMCPlaylistSongInfoDbFlag,     "DbFlag");
+
+// == Auxiliary TABLE FIELDS ==================================================
+// Version of database
+// The version integer looks like:
+// 31     23      15           0 bit
+// -----------------------------
+// |Major |Minor  |Build       |
+// -----------------------------
+_LIT(KMCAuxVersion,                 "Version");
+
+// Last time db was refreshed
+_LIT(KMCAuxTimeRefresh,             "TimeRefreshed");
+
+// Last time db was synced
+_LIT(KMCAuxTimeSync,                "TimeSynced");
+
+// Database Corrupted bit
+_LIT(KMCMusicCorruptDB,             "Corrupt");
+
+// Number of records that have been marked as deleted
+_LIT(KMCSavedDeletedRecordCount,    "SaveDeletedRecordCount");
+
+#endif // MPXCOLLECTIONDBDEF_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbmanager.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for managing all of music collection
+*                databases.
+*
+*/
+
+
+#ifndef MPXCOLLECTIONDBMANAGER_H
+#define MPXCOLLECTIONDBMANAGER_H
+
+// INCLUDES
+
+#include "mpxdbmanager.h"
+
+// CLASS DECLARATION
+
+/**
+* Database manager specialization for the collection plugin.
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXCollectionDbManager :
+    public CMPXDbManager
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aFs file server session
+        * @return The constructed object of CMPXDbManager
+        */
+        static CMPXCollectionDbManager* NewL(RFs& aFs);
+
+        /**
+        * Two-phased constructor.
+        * @param aFs file server session
+        * @return The constructed object of CMPXDbManager
+        */
+        static CMPXCollectionDbManager* NewLC(RFs& aFs);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXCollectionDbManager();
+
+    private:
+
+        /**
+        * C++ default constructor
+        * @param aFs file server session
+        */
+        CMPXCollectionDbManager(RFs& aFs);
+
+        /**
+        * The second phase constructor ConstructL to safely construct things
+        * that can leave
+        */
+        void ConstructL();
+    };
+
+#endif  // MPXCOLLECTIONDBMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbstd.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006,2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This header file contains constants definitions and type
+*                definition
+*
+*/
+
+
+#ifndef MPXCOLLECTIONDBSTD_H
+#define MPXCOLLECTIONDBSTD_H
+
+// CONSTANTS
+enum TMPXAutoPlaylistType
+    {
+    EMPXNoAutoPlaylist = -1,
+    EMPXRecentlyPlayedPlaylist,
+    EMPXMostPlayedPlaylist,
+    EMPXRecentlyAddedPlaylist,
+    EMPXAutoPlaylistCount
+    };
+
+const TInt KDBPluginUid = 0x101FFC3A;
+
+const TInt KMPXMaxRecentlyPlayedSongs = 20;
+const TInt KMPXMaxMostPlayedSongs = 20;
+const TInt KMPXRecentlyAddedInterval = 7;
+
+const TInt KMCMaxTextLen          = 255; // Maximum field size for categories is 255
+
+#endif // MPXCOLLECTIONDBSTD_H
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,208 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all category tables (Artist,
+*                Album, Genre, Composer, AbstractAlbum).
+*
+*
+*/
+
+
+#ifndef MPXDBABSTRACTALBUM_H
+#define MPXDBABSTRACTALBUM_H
+
+// INCLUDES
+#include <thumbnailmanager.h>
+#include <thumbnailmanagerobserver.h>
+#include "mpxdbcategory.h"
+
+
+// CLASS FORWARDS
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+
+class CMPXDbAbstractAlbum :
+    public CMPXDbCategory,
+    public MThumbnailManagerObserver
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance.
+        */
+        static CMPXDbAbstractAlbum* NewL(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance on the cleanup stack.
+        */
+        static CMPXDbAbstractAlbum* NewLC(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbAbstractAlbum();
+
+        /**
+        * Find the drive Id for a abstractalbum
+        * @param aAbstractAlbumId identifies the abstractalbum
+        * @return corresponding drive id
+        */
+        TInt GetDriveIdL(TUint32 aAbstractAlbumId);
+
+        /**
+        * Add a category item. If the record already exists, its counter will
+        * be incremented.
+        * @param aName: This is the name to be entered into the row
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aNewRecord: indicates to the caller if a new record is created.
+        *        ETrue if a new row is created in the table; otherwise EFalse.
+        * @param aCaseSensitive indicates whether case sensitivity should be taken
+        *        into consideration when generating the unique row id
+        * @return The unique id of the row added.
+        */
+        TUint32 AddItemL( const TDesC& aName, const TDesC& aAlbumArtist, const TDesC& aGenre, TInt aDriveId, TBool& aNewRecord,
+            TBool aCaseSensitive = ETrue);
+        
+        /**
+        * Decrement the number of songs for the item. If the count gets to 0, remove
+        * the item.
+        * @param aId: The ID of the category to delete.
+        * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
+        *                  drives may belong to the same album or artist; consequently, one
+        *                  row for each artist/album id and drive ID pair will exist in the
+        *                  lookup table with a count existing for each row that tracks the
+        *                  number number of songs on that drive with that album/artist.
+        * @param aItemChangedMessages if valid on return contains a deleted message if the
+        *                  category was deleted
+        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
+        *        EFalse otherwise
+        */
+        void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse);
+  
+        /**
+        * Remove a abstractalbum and return its URI
+        * @param aAbstractAlbumId identifies the abstractalbum
+        * @return HBufC containing the URI. Ownership is transferred.
+        */
+        HBufC* DeleteAbstractAlbumL(TUint32 aAbstractAlbumId, TInt aDriveId = 0);
+        
+        /**
+        * Update a category item.
+        * @param aId: The ID of the category to update
+        * @param aMedia: The media data
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aItemChangedMessages: if valid on return contains a updated message if the
+        *        category was updated
+        */
+        void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+
+    private:
+
+
+        /**
+        * Updates the media with information from the table
+        * @param aRecord record containing the source fields
+        * @param aAttrs attributes to be returned
+        * @param aMedia returns the requested attributes
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Generate searching criteria for album table from the given criteria
+        * @param aMedia media data
+        * @param aFields fields of Album table
+        * @param aValues values of each field of Album table
+        * @return a string containing the selection criteria. The ownership is passed to the caller.
+        */
+        void GenerateAbstractAlbumFieldsValuesL(const CMPXMedia& aMedia,
+            CDesCArray& aFields, CDesCArray& aValues);
+
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+
+        
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+        
+        
+    
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbAbstractAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+        
+        
+        /**
+        * MThumbnailManagerObserver
+        */
+        void ThumbnailPreviewReady(
+            MThumbnailData& aThumbnail, TThumbnailRequestId aId );
+        /**
+        * MThumbnailManagerObserver
+        */
+        void ThumbnailReady(
+            TInt aError, 
+            MThumbnailData& aThumbnail, TThumbnailRequestId aId );
+
+    public:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TAbstractAlbumColumns
+            {
+            EAbstractAlbumUniqueId = KMPXTableDefaultIndex,
+            EAbstractAlbumName,
+            EAbstractAlbumArtist,
+            EAbstractAlbumGenre,
+            EAbstractAlbumSongCount,
+            EAbstractAlbumVolumeId,
+            EAbstractAlbumFieldCount
+            };
+
+    private:    // Data
+        CThumbnailManager*        iTNManager;
+
+    };
+#endif // MPXDBAbstractAlbum_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all category tables (Artist,
+*                Album, Genre, Composer).
+*
+*
+*/
+
+
+#ifndef MPXDBALBUM_H
+#define MPXDBALBUM_H
+
+// INCLUDES
+#include "mpxdbcategory.h"
+
+// CLASS DECLARATION
+
+class MMPXDbAlbumObserver
+    {
+    public:
+        virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0;    
+        virtual TUint32 HandleArtistForAlbumL( const TUint32 aId ) = 0;
+    };
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+
+class CMPXDbAlbum :
+    public CMPXDbCategory
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance.
+        */
+        static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance on the cleanup stack.
+        */
+        static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbAlbum();
+
+    public:
+
+        /**
+        * Add a category item. If the record already exists, its counter will
+        * be incremented.
+        * @param aName: This is the name to be entered into the row
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aNewRecord: indicates to the caller if a new record is created.
+        *        ETrue if a new row is created in the table; otherwise EFalse.
+        * @param aCaseSensitive indicates whether case sensitivity should be taken
+        *        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,
+            TBool aCaseSensitive = ETrue);
+
+        /**
+        * Decrement the number of songs for the item. If the count gets to 0, remove
+        * the item.
+        * @param aId: The ID of the category to delete.
+        * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
+        *                  drives may belong to the same album or artist; consequently, one
+        *                  row for each artist/album id and drive ID pair will exist in the
+        *                  lookup table with a count existing for each row that tracks the
+        *                  number number of songs on that drive with that album/artist.
+        * @param aItemChangedMessages if valid on return contains a deleted message if the
+        *                  category was deleted
+        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
+        *        EFalse otherwise
+		* @param aArtist: The ID of the artist
+        */
+        void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TUint32 aArtist);
+        
+		/**
+	* Gets the details for all category items.
+	* @param aAttrs attributes to be returned
+	* @param aMediaArray returns the requested attributes for all items
+	*/
+		void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
+			CMPXMediaArray& aMediaArray);
+
+		/**
+	* Update a category item. 
+	* @param aId: The ID of the category to update
+	* @param aMedia: The media data
+	* @param aDriveId: The Drive Id the name (category) belongs
+	* @param aItemChangedMessages: if valid on return contains a updated message if the
+    *        category was updated
+	*/
+		void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+
+	public:
+		/**
+	* Get albums count for a specified artist
+	* @param aId: The ID of the artist
+	*/		
+	    TInt GetAlbumsCountForArtistL(TUint32 aArtistId);
+
+		/**
+	* Get songs count for a specified album and a specified artist
+	* @param aArtistId: The ID of the artist
+	* @param aAlbumId: The ID of the album
+	*/		
+		TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
+		
+    private:	
+        /**
+        * Updates the media with information from the table
+        * @param aRecord record containing the source fields
+        * @param aAttrs attributes to be returned
+        * @param aMedia returns the requested attributes
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+         /**
+        * Generate searching criteria for album table from the given criteria
+        * @param aMedia media data
+        * @param aFields fields of Album table
+        * @param aValues values of each field of Album table
+        * @return a string containing the selection criteria. The ownership is passed to the caller.
+        */
+		void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, 
+			CDesCArray& aFields, CDesCArray& aValues);
+
+
+		TBool IsUnknownArtistL(TUint32 aId);
+		
+		TUint32 ArtistForAlbumL(const TUint32 aId);
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+    private:
+
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+
+    public:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TAlbumColumns
+            {
+            EAlbumUniqueId = KMPXTableDefaultIndex,
+            EAlbumName,
+            EAlbumSongCount,
+            EAlbumArtist,
+            EAlbumArt,
+            EAlbumArtistName,
+            EAlbumFieldCount
+            };
+
+    private:    // Data
+        MMPXDbAlbumObserver& iObserver;
+    };
+#endif // MPXDBALBUM_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbartist.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for Artist table.
+*
+*
+*/
+
+
+#ifndef MPXDBARTIST_H
+#define MPXDBARTIST_H
+
+// INCLUDES
+#include "mpxdbcategory.h"
+
+// CLASS DECLARATION
+class MMPXDbArtistObserver
+    {
+    public:
+		virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aId) = 0;
+	};
+
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+
+class CMPXDbArtist :
+    public CMPXDbCategory
+    {
+    public:
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbArtist instance.
+        */
+        static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbArtist instance on the cleanup stack.
+        */
+        static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbArtist();
+       
+    public:
+        /**
+        * Add a category item. If the record already exists, its counter will
+        * be incremented.
+        * @param aName: This is the name to be entered into the row
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aNewRecord: indicates to the caller if a new record is created.
+        *        ETrue if a new row is created in the table; otherwise EFalse.
+        * @param aCaseSensitive indicates whether case sensitivity should be taken
+        *        into consideration when generating the unique row id
+        * @return The unique id of the row added.
+        */
+        TUint32 AddItemL(const TDesC& aName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
+            TBool aCaseSensitive = ETrue);
+        
+        /**
+        * Gets the details for all category items.
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray returns the requested attributes for all items
+        */
+        void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+        
+        /**
+        * Update a category item. 
+        * @param aId: The ID of the category to update
+        * @param aMedia: The media data
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aItemChangedMessages: if valid on return contains a updated message if the
+        *        category was updated
+        */
+        void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+        
+        /*
+        * Checks if the specified artist item is unknown
+        * @param aId identifies the artist item
+        * @return ETrue if it is unknown, EFalse otherwise
+        */        
+        TBool IsUnknownArtistL(TUint32 aId);
+        
+    private:
+
+        /**
+        * Updates the media with information from the table
+        * @param aRecord record containing the source fields
+        * @param aAttrs attributes to be returned
+        * @param aMedia returns the requested attributes
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Generate searching criteria for artist table from the given criteria
+        * @param aMedia media data
+        * @param aFields fields of Artist table
+        * @param aValues values of each field of Artist table
+        * @return a string containing the selection criteria. The ownership is passed to the caller.
+        */
+        void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, 
+            CDesCArray& aFields, CDesCArray& aValues);
+       
+        /**
+        * Gets the Album counts for a Artist item
+        * @param aId identifies the Artist item
+        * @return value of the Album counts
+        */
+        TInt GetAlbumsCountL(TUint32 aId);
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+        
+    private:
+
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TArtistColumns
+            {
+            EArtistUniqueId = KMPXTableDefaultIndex,
+            EArtistName,
+            EArtistSongCount,
+            EArtistArt,
+            EArtistFieldCount
+            };
+
+    private:    // Data
+        MMPXDbArtistObserver& iObserver;
+    };
+#endif // MPXDBARTIST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbautoplaylist.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for the auto playlist functionality.
+*
+*/
+
+
+#ifndef MPXDBAUTOPLAYLIST_H
+#define MPXDBAUTOPLAYLIST_H
+
+// INCLUDES
+#include <e32base.h>
+#include <mpxattribute.h>
+
+// CLASS FORWARDS
+class CMPXMedia;
+class CMPXMediaArray;
+class CMPXDbManager;
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing the music table
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXDbAutoPlaylist :
+    public CBase
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @return new CMPXDbAutoPlaylist instance.
+        */
+        static CMPXDbAutoPlaylist* NewL(CMPXDbManager& aDbManager, RFs& aFs, CMPXResource& aResource);
+
+        /**
+        * Two-phased constructor.
+        * @return new CMPXDbAutoPlaylist instance on the cleanup stack.
+        */
+        static CMPXDbAutoPlaylist* NewLC(CMPXDbManager& aDbManager, RFs& aFs, CMPXResource& aResource);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbAutoPlaylist();
+
+    public:
+
+        /**
+        * Get the playlist ID of an auto-playlist by type
+        * @param aPlaylistType type of the auto-playlist
+        * @return auto playlist ID
+        * @leave KErrNotSupported if invalid playlist type
+        */
+        TUint32 AutoPlaylistIdL(TMPXAutoPlaylistType aPlaylistType);
+
+        /**
+        * Get the name of an auto playlist
+        * @param aPlaylistId identifies the playlist
+        * @return the name of the playlist
+        * @leave KErrNotSupported if invalid playlist ID
+        */
+        TPtrC AutoPlaylistNameL(TUint32 aPlaylistId);
+
+        /**
+        * Checks whether the playlist ID corresponds to an auto playlist or not.
+        * @param aPlaylistId identifies the playlist
+        * @return Auto playlist type or EMPXNoAutoPlaylist if not found
+        */
+        TMPXAutoPlaylistType AutoPlaylistTypeL(TUint32 aPlaylistId);
+
+        /**
+        * Get information on a specified playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aAttrs the attributes to include for the playlists found.
+        * @param aMedia returns the playlist information
+        * @leave KErrNotSupported if invalid playlist ID
+        */
+        void GetPlaylistL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Get information on all auto playlists
+        * @param aMediaArray returns information on all auto playlists
+        */
+        void GetAllPlaylistsL(CMPXMediaArray& aMediaArray);
+
+    private:
+        
+        /**
+        * Get count and duration information of the auto-playlist
+        * @param aType the type of the auto-playlist
+        * @param aCount reference to count to be returned
+        * @param aDuration reference to duration to be returned
+        */
+        void GetPlaylistDetailsL(TMPXAutoPlaylistType aType, TInt& aCount, TInt& aDuration);
+
+        /**
+        * Update the media with information about the auto-playlist
+        * @param aPlaylistId Id of the auto-playlist
+        * @param aAttrs the attributes to include for the playlist matching the
+        *        selection criteria
+        * @param aMedia the playlist details object
+        */
+        void UpdateMediaL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+    private:
+
+        /**
+        * C++ constructor
+        */
+        CMPXDbAutoPlaylist(CMPXDbManager& aDbManager);
+
+        /**
+        * Second phase constructor
+        */
+        void ConstructL(RFs& aFs, CMPXResource& aResource);
+
+    private:    // Data
+        TUint32             iRecentlyPlayedPlaylistId; // recently played playlist ID
+        TUint32             iMostPlayedPlaylistId;     // most played playlist ID
+        TUint32             iRecentlyAddedPlaylistId;  // recently added playlist ID
+
+        // owned
+        HBufC*              iRecentlyPlayedPlaylist;   // recently played playlist name
+        HBufC*              iMostPlayedPlaylist;       // most played playlist name
+        HBufC*              iRecentlyAddedPlaylist;    // recently added playlist name
+        CMPXDbManager&      iDbManager;
+    };
+
+#endif // MPXDBAUTOPLAYLIST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbauxiliary.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for interacting with the Auxiliary
+*                table.
+*
+*/
+
+
+#ifndef MPXDBAUXILIARY_H
+#define MPXDBAUXILIARY_H
+
+// INCLUDES
+#include "mpxdbtable.h"
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing the playlist tables
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXDbAuxiliary :
+    public CMPXDbTable
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbManager instance.
+        */
+        static CMPXDbAuxiliary* NewL(CMPXDbManager& aDbManager);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbManager instance on the cleanup stack.
+        */
+        static CMPXDbAuxiliary* NewLC(CMPXDbManager& aDbManager);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbAuxiliary();
+
+    public:
+
+        /**
+        * Sets the last refreshed time in the auxiliary table.
+        * @param aTime the last refreshed time value
+        */
+        void SetLastRefreshedTimeL(TTime aTime);
+
+        /**
+        * Gets the last refreshed time from the auxiliary table.
+        * @return last refreshed time value
+        */
+        TTime LastRefreshedTimeL();
+
+        /**
+        * Sets the db corrupted flag in the auxiliary table.
+        * @param aCorrupted db corrupted flag value
+        */
+        void SetDBCorruptedL(TBool aCorrupted);
+
+        /**
+        * Gets the db corrupted flag value from the auxiliary table.
+        * @return db corrupted flag value
+        */
+        TBool DBCorruptedL();
+
+        /**
+        * Sets the save deleted record count value.
+        * @param aDrive drive identifier
+        * @param aValue new field value
+        *
+        */
+        void SetSaveDeletedRecordCountL(TInt aDrive,TUint32 aValue);
+
+        /**
+        * Gets the save deleted record count field value.
+        * @return field value
+        */
+        TUint32 SaveDeletedRecordCountL();
+
+        /**
+         * Gets the save deleted record count field value.
+         * @param aDrive drive identifier
+         * @return field value
+         */
+         TUint32 SaveDeletedRecordCountL(TInt aDrive);
+
+        /**
+        * Checks if all databases have been refreshed.
+        * @return EFalse if at least one database has not been refreshed.
+        */
+        TBool IsRefreshedL();
+
+        /**
+        * Get the auxilary id for a drive
+        * @param aDrive drive to get the volume id
+        * @return TInt id for the aux database
+        */
+        TInt IdL( TInt aDrive );
+
+        /**
+        * Set the auxilary id for a drive
+        * @param aDrive,
+        * @param aId
+        */
+        void SetIdL( TInt aDrive, TInt aId );
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void DropTableL(RSqlDatabase& aDatabase);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+    private:
+
+        /**
+        * C++ constructor
+        * @param aDbManager database manager to use for database interactions
+        */
+        CMPXDbAuxiliary(CMPXDbManager& aDbManager);
+
+        /**
+        * Safely construct things that can leave
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the auxiliary table
+        */
+        enum TAuxiliaryColumns
+            {
+            EAuxiliaryId = KMPXTableDefaultIndex,
+            EAuxiliaryVersion,
+            EAuxiliaryTimeRefreshed,
+            EAuxiliaryTimeSynced,
+            EAuxiliaryCorrupt,
+            EAuxiliarySavedDeletedRecordCount
+            };
+
+    };
+
+#endif // MPXDBAUXILIARY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbcategory.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all category tables (Artist,
+*                Album, Genre, Composer).
+*
+*
+*/
+
+
+#ifndef MPXDBCATEGORY_H
+#define MPXDBCATEGORY_H
+
+// INCLUDES
+#include "mpxdbtable.h"
+#include "mpxmediageneraldefs.h"
+#include "mpxmessage2.h"
+
+// CLASS FORWARDS
+class CMPXMedia;
+class CMPXMediaArray;
+class RSqlStatement;
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXDbCategory :
+    public CMPXDbTable
+    {
+    protected:
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbCategory();
+
+
+    public:
+
+        /**
+        * Add a category item. If the record already exists, its counter will
+        * be incremented.
+        * @param aName: This is the name to be entered into the row
+        * @param aDriveId: The Drive Id the name (category) belongs
+        * @param aNewRecord: indicates to the caller if a new record is created.
+        *        ETrue if a new row is created in the table; otherwise EFalse.
+        * @param aCaseSensitive indicates whether case sensitivity should be taken
+        *        into consideration when generating the unique row id
+        * @return The unique id of the row added.
+        */
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        virtual TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
+            TBool aCaseSensitive = ETrue);
+#else 
+        TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
+            TBool aCaseSensitive = ETrue);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+        /**
+        * Get the name field for a given ID.
+        * @param aId identifies the category item
+        * @return name that matches aId. Ownership is abandoned.
+        */
+        HBufC* GetNameL(TUint32 aId);
+
+        /**
+        * Gets the total number of items in the category table.
+        * @return number of items
+        */
+        TInt CountL();
+
+        /**
+        * Find record(s) matching the criteria
+        * @param aCriteria, selection criteria
+        * @param aAttrs, attributes for the matching record(s)
+        * @param aMediaArray returns the matching record(s)
+        */
+        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Decrement the number of songs for the item. If the count gets to 0, remove
+        * the item.
+        * @param aId: The ID of the category to delete.
+        * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
+        *                  drives may belong to the same album or artist; consequently, one
+        *                  row for each artist/album id and drive ID pair will exist in the
+        *                  lookup table with a count existing for each row that tracks the
+        *                  number number of songs on that drive with that album/artist.
+        * @param aItemChangedMessages if valid on return contains a deleted message if the
+        *                  category was deleted
+        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
+        *        EFalse otherwise
+        */
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse = EFalse);
+#else
+        void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Deletes a category.
+        * @param aId identifies the category
+        * @param aDriveId category drive
+        */
+        void DeleteCategoryL(TUint32 aId, TInt aDriveId);
+
+        /**
+        * Gets the details for multiple category items.
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray inout parameter, on input contains the IDs of the
+        *       category items to be returned, on exit contains the requested
+        *       attributes for these items
+        */
+        void GetCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Gets the details for all category items.
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray returns the requested attributes for all items
+        */
+        void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Gets details for one category item.
+        * @param aId identifies the category item
+        * @param aAttrs attributes to be returned
+        * @param aMedia returns the requested attributes for te item
+        * @leave KErrCorrupt if there are multiple items with the same ID
+        *        KErrNotFound if there is no item with the specified ID
+        */
+        void GetCategoryItemL(TUint32 aId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Gets details for the category items under a parent category item.
+        * This applies to albums for a given artist. The method panics if the
+        * category or parent category are invalid.
+        * @param aParentCategory identifies the parent category
+        * @param aParentId identifies the parent item
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray returns the requested attributes for all items
+        */
+        void GetSubCategoryItemsL(TMPXGeneralCategory aParentCategory, TUint32 aParentId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Checks if the specified category item exists.
+        * @param aDriveId drive to check or KDbManagerAllDrives
+        * @param aId identifies the category item
+        * @return ETrue if it exists, EFalse otherwise
+        */
+        TBool CategoryItemExistsL(TInt aDriveId, TUint32 aId);
+
+        /**
+        * Gets the CountSongs field for a category item
+        * @param aDriveId drive to check or KDbManagerAllDrives
+        * @param aId identifies the category item
+        * @return value of the CountSongs field.
+        */
+        TInt GetSongsCountL(TInt aDriveId, TUint32 aId);
+
+		/**
+	    * Update a category item. 
+	    * @param aId: The ID of the category to update
+	    * @param aMedia: The media data
+	    * @param aDriveId: The Drive Id the name (category) belongs
+	    * @param aItemChangedMessages: if valid on return contains a updated message if the
+        * category was updated
+        */
+		void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+		
+    protected:
+
+        /**
+        * Updates the media with information from the table
+        * @param aRecord record containing the source fields
+        * @param aAttrs attributes to be returned
+        * @param aMedia returns the requested attributes
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Returns the category record for a given ID
+        * @param aId identifies the category item
+        * @return rowset
+        */
+        RSqlStatement GetCategoryRecordL(TUint32 aId);
+
+        /**
+        * Replaces the table placeholder in the string parameter with the
+        * category table name.
+        * @param aQuery raw query string
+        * @return processed query string, ownership is transferred.
+        */
+        HBufC* PreProcessStringLC(const TDesC& aQuery);
+
+        /**
+        * Processes a recordset by constructing media instances and adding them
+        * to the specified array.
+        * @param aAttrs attributes to be returned
+        * @param aRecordset recordset to be processed
+        * @param aMediaArray returns the media instances
+        */
+        void ProcessRecordsetL(const TArray<TMPXAttribute>& aAttrs,
+            RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void DropTableL(RSqlDatabase& aDatabase);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+    protected:
+
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbCategory(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
+
+        /**
+        * Second phase constructor.
+        */
+        void BaseConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TCategoryColumns
+            {
+            ECategoryUniqueId = KMPXTableDefaultIndex,
+            ECategoryName,
+            ECategorySongCount
+            };
+
+    protected:
+
+        HBufC* iTableName;              // owned
+        TMPXGeneralCategory iCategory;
+
+    };
+
+#endif // MPXDBCATEGORY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbcomposer.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all category tables (Artist,
+*                Album, Genre, Composer).
+*
+*
+*/
+
+
+#ifndef MPXDBCOMPOSER_H
+#define MPXDBCOMPOSER_H
+
+// INCLUDES
+#include "mpxdbcategory.h"
+
+// CLASS FORWARDS
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+
+class CMPXDbComposer :
+    public CMPXDbCategory
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance.
+        */
+        static CMPXDbComposer* NewL(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance on the cleanup stack.
+        */
+        static CMPXDbComposer* NewLC(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbComposer();
+
+    private:
+
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbComposer(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TComposerColumns
+            {
+            EComposerUniqueId = KMPXTableDefaultIndex,
+            EComposerName,
+            EComposerSongCount,
+            EAlbumFieldCount
+            };
+
+    private:    // Data
+
+    };
+#endif // MPXDBCOMPOSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbgenre.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all category tables (Artist,
+*                Album, Genre, Composer).
+*
+*
+*/
+
+
+#ifndef MPXDBGENRE_H
+#define MPXDBGENRE_H
+
+// INCLUDES
+#include "mpxdbcategory.h"
+
+// CLASS FORWARDS
+class CMPXMedia;
+class CMPXMediaArray;
+class RSqlStatement;
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing all music databases
+*
+* @lib MPXDbPlugin.lib
+*/
+
+class CMPXDbGenre :
+    public CMPXDbCategory
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance.
+        */
+        static CMPXDbGenre* NewL(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        * @return New CMPXDbCategory instance on the cleanup stack.
+        */
+        static CMPXDbGenre* NewLC(CMPXDbManager& aDbManager,
+            TMPXGeneralCategory aCategory);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbGenre();
+
+    private:
+
+        /**
+        * C++ constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aCategory identifies the category
+        */
+        CMPXDbGenre(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the category tables
+        */
+        enum TGenreColumns
+            {
+            EGenreUniqueId = KMPXTableDefaultIndex,
+            EGenreName,
+            EGenreSongCount,
+            EGenreFieldCount
+            };
+
+    private:    // Data
+
+    };
+#endif // MPXDBGENRE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,1133 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class provides the functions to manipulate the music collection
+*                database.
+*
+*/
+
+
+#ifndef MPXDBHANDLER_H
+#define MPXDBHANDLER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+
+#include <mpxattribute.h>
+#include <mpxmessage2.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxcollectionmessagedefs.h>
+
+#include "mpxcollectiondbstd.h"
+#include "mpxcollectiondb.hrh"
+#include "mpxdbactivetask.h"
+#include "mpxdbmusic.h"     // for MMPXDbMusicObserver
+#include "mpxdbartist.h"    // for MMPXDbArtistObserver
+#include "mpxdbalbum.h"     // for MMPXDbAlbumObserver
+#include "mpxdbplaylist.h"	// for MMPXDbPlaylistObserver
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+#include "mpxdbabstractalbum.h"
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class CMPXMediaArray;
+class CMPXCollectionDbManager;
+class CMPXDbPlaylist;
+class CMPXDbCategory;
+class CMPXDbAuxiliary;
+class CMPXDbAutoPlaylist;
+class CMPXDbArtist;
+class CMPXDbAlbum;
+class CMPXDbGenre;
+class CMPXDbComposer;
+
+// CLASS DECLARATION
+
+/**
+*  Music collection database handler
+*
+*  @lib MPXDbPlugin.lib
+*/
+class CMPXDbHandler :
+    public CBase,
+    public MMPXDbMusicObserver,
+    public MMPXDbArtistObserver,
+    public MMPXDbAlbumObserver,
+	public MMPXDbPlaylistObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aFs file server session
+        * @return a new CMPXDbHandler instance
+        */
+        static CMPXDbHandler* NewL(RFs& aFs, CMPXResource& aResource);
+
+        /**
+        * Two-phased constructor.
+        * @param aFs file server session
+        * @return a new CMPXDbHandler instance
+        */
+        static CMPXDbHandler* NewLC(RFs& aFs, CMPXResource& aResource);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CMPXDbHandler();
+
+    public:
+
+        /**
+        * Add a song to the music collection database
+        * @param aMedia media object which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aMessageArray change event message to notify client of the changes
+        * @return TUint32 id of the item added
+        */
+        TUint32 AddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL);
+
+        /**
+        * Add a song to the music collection without a database transaction; it
+        * is assumed the transaction is created at a higher leve
+        * @param aMedia media object which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aMessageArray change event message to notify client of the changes
+        * @return TUint32 id of the item added
+        */
+        TUint32 AddSongWithNoTransactionL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL);
+        
+        /**
+        * Add a playlist to the collection
+        * @param aMedia playlist media object with title and URI of the playlist.
+        * @return playlist Id of the playlist created
+        */
+        TUint32 AddPlaylistL(const CMPXMedia& aMedia);
+
+        /**
+        * Add songs to the specified playlist
+        * @param aMedia playlist media object with playlist Id.
+        * @return playlist Id of the playlist
+        */
+        TUint32 AddSongToPlaylistL(const CMPXMedia& aMedia);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED        
+        /**
+        * Add an abstractalbum to the collection
+        * @param aMedia abstractalbum media object with URI of the abstractalbum.
+        * @return abstractalbum Id of the abstractalbum created
+        */  
+        TUint32 AddAbstractAlbumL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Update song info for a song in the music collection database
+        * @param aMedia songDetails object  which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aItemChangedMessages a list of change events as a result of the
+        *           song update
+        * @return ETrue if UI visible change else EFalse
+        */
+        CMPXDbActiveTask::TChangeVisibility UpdateSongL(const CMPXMedia& aMedia,
+            CMPXMessageArray& aItemChangedMessages);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED        
+        /**
+        * Update songs info for songs associated with abstractalbum
+        *           in the music collection database
+        * @param aMedia songDetails object  which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aItemChangedMessages a list of change events as a result of the
+        *           song update
+        * @return ETrue if UI visible change else EFalse
+        */       
+        CMPXDbActiveTask::TChangeVisibility UpdateAbstractAlbumSongsL(const CMPXMedia& aMedia,
+            CMPXMessageArray& aItemChangedMessages);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED      
+        /**
+        * Update playlist info in the music collection database
+        * @param aMedia playlist details object which contains file path,
+        *           timestamps etc.
+        * @param aMessageArray change event messages for the playlist update
+        */
+        void UpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
+
+        /**
+        * Update the songs for a playlist in the music collection database
+        * @param aMedia playlist details object which contains the playlist songs.
+        * @param aMessage change event message for the playlist update
+        */
+        void UpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage);
+
+        /**
+        * Reorder the specified song in the specified playlist
+        * @param aPlaylistId id of the playlist which contains the song to be reordered
+        * @param aSongId id of the song to be reordered
+        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
+        *        Ordinal starts from 0.
+        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
+        *        starts from 0.
+        * @param aMessage change event message for the playlist update
+        */
+        void ReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
+            TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage);
+
+        /**
+        * Remove all songs within music collection database
+        */
+        void RemoveEntireCollectionL();
+
+        /**
+        * Remove a song from the music collection database
+        * @param aSongId ID of the song to be removed
+        * @param aUriArray a descriptor array to contain the URI of the deleted file
+        * @param aItemChangedMessages a list of change events as a result of the song removal
+        * @param aDeleteRecord indicates whether the client has explictly requested
+        *                to delete the records from the database. If ETrue, records
+        *                associated with the media will be deleted from the database;
+        *                if EFalse, whether to mark the records as deleted or to delete
+        *                the records will be based on other deciding factors.
+        */
+        void RemoveSongL(TUint32 aSongId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord = EFalse);
+
+        /**
+        * Removes a category of songs from the music collection, and its
+        * corresponding category in the lookup table
+        * @param aCategory the category to remove
+        * @param aCategoryId ID of the category to remove
+        * @param aUriArray a descriptor array to contain the URI of the deleted songs
+        * @param aItemChangedMessages a list of change events as a result of the song removal
+        */
+        void RemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Removes songs from the music collection belonging to the
+        * specified artist and album as well as the actual category
+        * in the lookup table
+        * @param aArtistId id of the artist
+        * @param aAlbumId id of the album
+        * @param aUriArray a descriptor array to contain the URI of the deleted file(s)
+        * @param aItemChangedMessages a list of change events as a result of the song removal
+        */
+        void RemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId,
+            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Remove all playlists from the collection
+        */
+        void RemoveAllPlaylistsL();
+
+        /**
+        * Remove a playlist This will remove all the songs from the playlist
+        * @param aPlaylistId ID of the playlist to remove
+        * @param aUriArray a descriptor array to contain the URI of the deleted file
+        * @param aItemChangedMessages a list of change events as a result of the
+        *        playlist removal
+        */
+        void RemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Remove a abstractalbum This will remove all the songs from the abstractalbum
+        * @param aAbstractAlbumId ID of the abstractalbum to remove
+        * @param aUriArray a descriptor array to contain the URI of the deleted file
+        * @param aItemChangedMessages a list of change events as a result of the
+        *        abstractalbum removal
+        */
+        void RemoveAbstractAlbumL(TUint32 aAbstractAlbumId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED         
+
+        /**
+        * Remove a song from the specified playlist.
+        * @param aPlaylistId ID of the playlist to remove the song from
+        * @param aSongId Id of the song in the playlist to be removed
+        * @param aOrdinal the ordinal of the song in the playlist. This uniquely
+        *        identifies which song in the playlist to be removed; whereas song
+        *        Id doesn't because duplicate tracks in the playlist are allowed.
+        *        The position is relative to zero, i.e. zero implies that the song
+        *        at the beginning of the playlist is to be removed.
+        * @param aItemChangedMessages a list of change events as a result of the
+        *        song removal
+        */
+        void RemoveSongFromPlaylistL(TUint32 aPlaylist, const TMPXItemId& aSongId,
+            TInt aOrdinal, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Delete records in all databases which have been marked as deleted
+        */
+        void CleanupDeletedRecordsL();
+
+        /**
+        * Get all songs from the music collection databasee
+        * @param aMediaArray Array to place all the songs' required info
+        * @param aAttrs required attributes
+        */
+        void GetAllSongsL(CMPXMediaArray* aMediaArray,
+            const TArray<TMPXAttribute>& aAttrs);
+
+        /**
+        * Get a limited number of songs from the music collection databasee
+        * @param aMediaArray Array to place all the songs' required info
+        * @param aAttrs required attributes
+        * @param aLimit maximum number of songs to retrieve
+        */
+        void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,
+                                 CMPXMediaArray& aMediaArray, TInt aLimit);
+
+        /**
+        * Get songs from the music collection database incrementally
+        * @param aMediaArray Array to place all the songs' required info
+        * @param aAttrs required attributes
+        * @param aTitle title to use as a key
+        * @param aNumOfSongs number of songs to read
+        * @param aAsc ascending or descending data read
+        */
+        void GetSongsInBlockL(CMPXMediaArray* aMediaArray,
+            const TArray<TMPXAttribute>& aAttrs,
+            TPtrC aTitle,
+            TUint aNumOfSongs,
+            TBool aAsc);
+
+
+        /**
+        * Get songs from the music collection starting at a particular offset
+        * ONLY use this as the first query to locate particular item. Should use
+        * GetSongsInBlockL() to fetch in blocks with a particular index
+        * @param aMediaArray Array to store the results
+        * @param aAttrs attributes to fetch
+        * @param aOffset offset to start reading
+        * @param aCount number of items to get
+        */
+        void GetSongsAtOffsetL( CMPXMediaArray* aMediaArray,
+                                const TArray<TMPXAttribute>& aAttrs,
+                                TInt aOffset,
+                                TInt aCount );
+
+        /**
+        * Get all the songs that match the given artist ID
+        * @param aArtistId ID of the artist to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching songs' required
+        *        attributes
+        */
+        void GetSongsMatchingArtistL(TUint aArtistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the songs that match the given album ID
+        * @param aAlbumId ID of the album to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching songs' required info
+        */
+        void GetSongsMatchingAlbumL(TUint aAlbumId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the songs that match the given artist and album ID
+        * @param aArtistId ID of the artist to match
+        * @param aAlbumId ID of the album to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching songs' required info
+        */
+        void GetSongsMatchingArtistAndAlbumL(TUint aArtistId, TUint aAlbumId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the songs that match the given genre ID
+        * @param aGenreId ID of the genre to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching songs' required info
+        */
+        void GetSongsMatchingGenreL(TUint aGenreId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the songs that match the given composer ID
+        * @param aComposerId ID of the composer to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching songs' required info
+        */
+        void GetSongsMatchingComposerL(TUint aComposerId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the songs that match the given playlist ID
+        * @param aPlaylistId ID of the playlist to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the required song info
+        */
+        void GetSongsMatchingPlaylistL(TUint aPlaylistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get the song info that matches the given song ID from Songs table.
+        * @param aSongId ID of the song
+        * @param aAttrs required attributes
+        * @param aMedia returns the song info
+        */
+        void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Appends the media object with the song information to the specified array.
+        * @param aSongId ID of the song
+        * @param aAttrs required attributes
+        * @param aMediaArray on return the song info is appended to this array
+        */
+        void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get the song info that matches the given song ID from Songs table.
+        * The song info will first be populated from Playlist table and
+        * if the Songs table exists in the drive where the song is located,
+        * song info will be overwritten from Songs table. This enables the
+        * support for displaying song title in a playlist when the drive
+        * where the song is located is not present.
+        * @aSongId ID of the song
+        * @aPlaylistId ID of the playlist the song belongs to.
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the required song info
+        * @leave KErrNotFound if the song could not be found in the
+        *       PlaylistSongs table
+        */
+        void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
+
+        /**
+        * Appends the a media object with the song information to the specified array.
+        * @param aSongId ID of the song
+        * @param aPlaylistId ID of the playlist
+        * @param aAttrs required attributes
+        * @param aMediaArray on return the song info is appended to this array
+        */
+        void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get the song ID of the song that matches the given URI
+        * @param aUri URI to match
+        * @return song ID
+        */
+        TUint32 GetSongIdMatchingUriL(const TDesC& aUri);
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Get the abstractalbum ID of the abstractalbum that matches the given URI
+        * @param aUri URI to match
+        * @return abstractalbum ID
+        */
+        TUint32 GetAbstractAlbumIdMatchingUriL(const TDesC& aUri);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Get all the artist names from the music collection database sorted by name.
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the artists' required info
+        */
+        void GetAllArtistsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the album names from the music collection database sorted by name.
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the albums' required info
+        */
+        void GetAllAlbumsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the albums that match the given artist ID sorted by name.
+        * @param aArtistId ID of the artist to match
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the matching albums' required info
+        */
+        void GetAlbumsMatchingArtistL(TUint aArtistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get all the genre names from the collection
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the genres' required info
+        */
+        void GetAllGenresL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get all the composer names from the collection
+        * @param aAttrs required attributes
+        * @param aMediaArray Array to place all the composers' required info
+        */
+        void GetAllComposersL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get the playlist ID of the playlist that matches the given URI
+        * @param aUri URI to match
+        * @return playlist ID to return
+        */
+        TUint32 GetPlaylistIdMatchingUriL(const TDesC& aUri);
+
+        /**
+        * Checks if the specified ID corresponds to an auto playlist.
+        * @param aPlaylistId ID to be checked
+        * @return ETrue if it corresponds to an auto playlist, EFalse otherwise
+        */
+        TBool IsAutoPlaylistL(TUint32 aPlaylistId);
+
+        /**
+        * Get all the playlist names from the collection
+        * @param aMediaArray Array to place all the playlists' required info
+        * @param aAttrs required attributes
+        */
+        void GetAllPlaylistsL(CMPXMediaArray* aMediaArray,
+            const TArray<TMPXAttribute>& aAttrs);
+
+        /**
+        * Get all the system playlist names from the collection
+        * @param aMediaArray Array to place all the system playlists' required info
+        */
+        void GetAllSystemPlaylistNamesL(CMPXMediaArray* aMediaArray);
+
+        /**
+        * Get title from the Id
+        * @param Id to search for
+        * @return name matching the ID
+        */
+        HBufC* GetNameMatchingIdL(const TUint32 aId) const;
+
+        /**
+        * Get URI from the Id
+        * @param Id to search for
+        * @return URI matching the ID
+        * @leave KErrNotSupported if the ID refers to an invalid category
+        */
+        HBufC* GetUriMatchingIdL(const TUint32 aId) const;
+
+        /**
+        * Retrieve category record with information as specified in the given
+        * attributes
+        * @param aCategoryId Id of the record to be retrieved
+        * @param aCategory category type
+        * @param aAttrs information to return about the specified category
+        * @param aMedia returns the category information
+        */
+        void GetCategoryL(const TUint32 aCategoryId, TMPXGeneralCategory aCategory,
+                const TArray<TMPXAttribute>& aAttrs, CMPXMedia* aMedia);
+
+        /**
+        * Get the duration for all songs
+        * @return duration
+        */
+        TInt GetAllSongsDurationL();
+
+        /**
+        * Get the duration for all songs for a specified artist
+        * @param aArtistId identifies the artist
+        * @return duration
+        */
+        TInt GetArtistDurationL(TInt aArtistId);
+
+        /**
+        * Get the duration for all songs in a specified album
+        * @param aAlbumId identifies the album
+        * @return duration
+        */
+        TInt GetAlbumDurationL(TInt aAlbumId);
+
+        /**
+        * Get the duration for all songs for a specified artist and album
+        * @param aArtistId identifies the artist
+        * @param aAlbumId identifies the album
+        * @return duration
+        */
+        TInt GetArtistAlbumDurationL(TInt aArtistId, TInt aAlbumId);
+
+        /**
+        * Get the duration for all songs for a specified composer
+        * @param aComposerId identifies the composer
+        * @return duration
+        */
+        TInt GetComposerDurationL(TInt aComposerId);
+
+        /**
+        * Get the duration for all songs for a specified genre
+        * @param aGenreId identifies the genre
+        * @return duration
+        */
+        TInt GetGenreDurationL(TInt aGenreId);
+
+        /**
+        * Get the duration for all songs in a user playlist
+        * @param aPlaylistId identifies the playlist
+        * @return duration
+        */
+        TInt GetUserPlaylistDurationL(TInt aPlaylistId);
+
+        /**
+        * Get the duration for all songs for a specified playlist
+        * @param aPlaylistId identifies the playlist
+        * @return duration
+        */
+        TInt GetPlaylistDurationL(TInt aPlaylistId);
+
+        /**
+        * Fetch the total number of items in the specified category
+        * @param aCategory category to be queried
+        * @return number of items.
+        */
+        TInt NumberOfItemsL(TMPXGeneralCategory aCategory);
+
+        /**
+        * Find media(s) from the collection
+        * @param aCriteria selection criteria
+        * @param aAttrs attributes for the matching media
+        * @return matching media. Ownership is transferred.
+        * @leave KErrArgument if the criteria do not include a type
+        *           or category
+        */
+        CMPXMedia* FindAllLC(const CMPXMedia& aCriteria,
+            const TArray<TMPXAttribute>& aAttrs);
+
+        /**
+        * Set the last refreshed time
+        * @param aTime the updated last refresh time
+        */
+        void SetLastRefreshedTimeL(TTime aTime);
+
+        /**
+        * Get the last refreshed time
+        * @return last refreshed time
+        */
+        TTime GetLastRefreshedTimeL();
+
+        /**
+        * Set the db corrupted bit in the aux table for all drives
+        * @param aCorrupted flag indicating whether or not the db is corrupted
+        */
+        void SetDBCorruptedL(TBool aCorrupted);
+
+        /**
+        * Get the db corrupted bit in the aux table ( or of all drives )
+        * @return ETrue if database is corrupted, else EFalse
+        */
+        TBool IsDBCorruptedL();
+
+        /**
+        * Checks if the database has been created
+        * @return ETrue if file has been created
+        */
+        TBool DatabaseCreated();
+
+        /**
+        * Close and re-open the music collection database stored on the
+        * specified drive
+        * @param aDrive drive containing the music collection database to re-open
+        */
+        void OpenDatabaseL(TInt aDrive);
+
+        /**
+        * Close a database for a particular drive
+        * @param aDrive drive to close
+        */
+        void CloseDatabaseL(TInt aDrive);
+
+        /**
+        * Recreate all databases.
+        */
+        void ReCreateDatabasesL();
+
+        /**
+        * Starts a refresh operation.
+        */
+        void RefreshStartL();
+
+        /**
+        * Ends a refresh operation.
+        */
+        void RefreshEndL();
+        
+        /**
+        * Notification of mtp start
+        */
+        void MtpStartL();
+
+        /**
+        * Notification of mtp end
+        */
+        void MtpEndL();
+        /**
+        * Get total record count for music in db
+        * @param aDrive, specifies drive number for db selection
+        * @return count
+        */
+        TUint GetMusicCountL(TInt aDrive);
+
+        /**
+        * Get total record count for playlists in db
+        * @param aDrive, specifies drive number for db selection
+        * @return count
+        */
+        TUint GetPlaylistCountL(TInt aDrive);
+
+        /**
+        * Get total record count for music and playlists in db
+        * @param aDrive, specifies drive number for db selection
+        * @return count
+        */
+        TUint GetTotalCountL(TInt aDrive);
+
+        /**
+        * Get URIs for a given amount of songs
+        * @param aDrive, specifies drive number for db selection
+        * @param aFromID, specifies unique ID of last record retrieved
+        * @param aRecords, specifies the number of records to get
+        * @param aUriArr, will contain all URIs on return
+        * @param aLastID, will contain unique ID of a last record in the array
+        */
+        void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                               CDesCArray& aUriArr, TInt& aLastID);
+
+        /**
+        * Get URIs for a given amount of playlists
+        * @param aDrive, specifies drive number for db selection
+        * @param aFromID, specifies unique ID of last record retrieved
+        * @param aRecords, specifies the number of records to get
+        * @param aUriArr, will contain all URIs on return
+        * @param aLastID, will contain unique ID of a last record in the array
+        */
+        void GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                  CDesCArray& aUriArr, TInt& aLastID);
+
+        /**
+        * Starts a transaction on all open databases.
+        */
+        void BeginTransactionL();
+
+        /**
+        * Commits or rolls back a transaction.
+        * @param aError if error then rolls back the transaction and leaves
+        *               if KErrNone it commits the transaction
+        */
+        void EndTransactionL(TInt aError);
+
+        /**
+        * Checks if the database is currently in a transaction.
+        *
+        * @return ETrue if database is currently in a transaction, EFalse otherwise
+        */
+        TBool InTransaction();
+
+        /**
+         * Notifies the handler that the collection will be closed.
+         * It is called before closing the collection.
+         */
+        void PreCloseCollectionL();
+
+        /**
+         * Notifies the handler that the collection was closed.
+         */
+         void CollectionClosed();
+
+         /**
+         * Notifies the handler that the collection was opened.
+         */
+         void CollectionOpenedL();
+         
+         /**
+          * Checks if the spefified drive is a remove drive
+          */      
+         TBool IsRemoteDrive(TDriveNumber aDrive);
+         
+         /**
+          * Checks if there is a drive that has a low disk space
+          * @leave KErrDiskFull if the space on one of the drives is below the
+          *         critical level
+          */
+         void CheckDiskSpaceOnDrivesL();
+
+    private:
+
+        /**
+        * Add a song to the music collection database
+        * @param aMedia: media object which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aMessage change event message to notify client of the changes
+        * @return Id of the song added
+        * @leave KErrArgument if the media doe snot include the song URI
+        */
+        TUint32 DoAddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray);
+
+        /**
+        * Add a playlist to the collection
+        * @param aMedia playlist media object with title and URI of the playlist.
+        * @return ID of the playlist created
+        */
+        TUint32 DoAddPlaylistL(const CMPXMedia& aMedia);
+
+        /**
+        * Add songs to the specified playlist
+        * @param aMedia playlist media object with playlist Id.
+        * @return playlist Id of the playlist
+        */
+        TUint32 DoAddSongToPlaylistL(const CMPXMedia& aMedia);
+
+        /**
+        * Update song info for a song in the music collection database
+        * @param aMedia songDetails object  which contains file path,
+        *           artist, composer, name(title), track, etc...
+        * @param aItemChangedMessages a list of items changed
+        * @return ETrue if UI visible change
+        * @leave KErrNotSupported if the song ID could not be constructed
+        */
+        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(const CMPXMedia& aMedia,
+            CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Update playlist info in the music collection database
+        * @param aMedia playlist details object which contains file path,
+        *           timestamps etc...
+        * @param aMessage change event message for the playlist update
+        */
+        void DoUpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
+
+        /**
+        * Replace all songs for a playlist. This method is called when harvester
+        * scans an updated playlist. This will also be called if MTP wants to
+        * replace the contents of an existing playlist. The implementation deleted the
+        * existing songs first and then inserts the new ones.
+        * @param aMedia playlist and songs details object which contains file path,
+        *           timestamps etc...
+        * @param aMessage change event message for the playlist update
+        */
+        void DoUpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage);
+
+        /**
+        * Reorder the specified song in the specified playlist
+        * @param aPlaylistId id of the playlist which contains the song to be reordered
+        * @param aSongId id of the song to be reordered
+        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
+        *        Ordinal starts from 0.
+        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
+        *        starts from 0.
+        * @param aMessage change event message for the playlist update
+        */
+        void DoReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
+            TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage);
+
+        /**
+        * Deletes a song. In addition to deleting the song record from the music
+        * table takes care of updating the category and playlist tables.
+        * @param aSongId song to be deleted
+        * @param aUriArray on return contains the URIs of the song deleted.
+        * @param aItemChangedMessages on return contains changed messages for all
+        *        affected items
+        * @param aDeleteRecord ETrue if the record is to be deleted, EFalse if it is
+        *        to be marked as deleted.
+        */
+        void DoRemoveSongL(TUint32 aSongId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord);
+
+        /**
+         * Deletes the song  from the playlist tables
+         * @param aSongId song to be deleted
+         * @param aItemChangedMessages on return contains changed messages for all
+         *        affected items
+         */
+        void DoRemoveSongFromPlaylistL(TUint32 aSongId,CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Deletes all the songs for a given category. The implementation uses
+        * DoRemoveSongL for the business logic.
+        * @param aCategory category type (artist/album/genre/composer)
+        * @param aCategoryId identifies the category item
+        * @param aUriArray on return contains the URIs of the songs deleted.
+        * @param aItemChangedMessages on return contains changed messages for all
+        *        affected items
+        * @leave KErrNotSupported if invalid category
+        */
+        void DoRemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory,
+            TUint32 aCategoryId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Deletes all the songs for a given artist and album.
+        * The implementation uses DoRemoveSongL for the business logic.
+        * @param aArtistId identifies the artist
+        * @param aAlbumId identifies the album
+        * @param aUriArray on return contains the URIs of the songs deleted.
+        * @param aItemChangedMessages on return contains changed messages for all affected items
+        */
+        void DoRemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId,
+            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Deletes all the playlists in all databases. Note that the songs are not affected.
+        */
+        void DoRemoveAllPlaylistsL();
+
+        /**
+        * Deletes a specified playlist.
+        * @param aPlaylistId the playlist to be deleted.
+        * @param aUriArray on return contains the URIs of the items deleted.
+        * @param aItemChangedMessages on return contains changed messages for all
+        *        affected items
+        */
+        void DoRemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED        
+        /**
+        * Deletes a specified abstractalbum.
+        * @param aAbstractAlbumId the abstractalbum to be deleted.
+        * @param aUriArray on return contains the URIs of the items deleted.
+        * @param aItemChangedMessages on return contains changed messages for all
+        *        affected items
+        */
+        void DoRemoveAbstractAlbumL(TUint32 aAbstractalbumId, CDesCArray& aUriArray,
+            CMPXMessageArray& aItemChangedMessages);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Deletes a song from a playlist.
+        * @param aPlaylistId identifies the playlist.
+        * @param aSongId song to be deleted.
+        * @param aOrdinal song ordinal in case there are multiple instances of the same
+        *        song in the playlist.
+        * @param aItemChangedMessages on return contains changed messages for all
+        *        affected items
+        */
+        void DoRemoveSongFromPlaylistL(TUint32 aPlaylistId, const TMPXItemId& aSongId,
+            TInt aOrdinal, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Deletes all song records marked as deleted.
+        */
+        void DoCleanupDeletedRecordsL();
+
+        /**
+        * Find items in the collection
+        * @param aCriteria selection criteria
+        * @param aAttrs attributes for the matching media
+        * @param aMediaArray returns the matching entries
+        */
+        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray* aMediaArray);
+
+        /**
+        * Find a song.
+        * @param aCriteria selection criteria
+        * @param aAttrs attributes for the matching media
+        * @param aMediaArray returns the matching entries
+        */
+        void FindSongL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Gets the songs for a specified playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray returns the matching entries
+        */
+        void GetPlaylistSongsL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Find an album
+        * @param aCriteria selection criteria
+        * @param aAttrs attributes to be returned
+        * @param aMediaArray returns the matching entries
+        */
+        void FindAlbumL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Extracts the playlist ID and drive ID from the media object.
+        * @param aMedia playlist information
+        * @param aPlaylistId returns the playlist ID
+        * @param aPlaylistDriveId returns the drive ID
+        * @leave KErrArgument if the media does not include the ID and URI
+        */
+        void ProcessPlaylistMediaL(CMPXMedia& aMedia, TUint32& aPlaylistId,
+            TInt& aPlaylistDriveId);
+
+        /**
+        * Updates all the song entries in the playlist media with extra
+        * information from the music table.
+        * @param aMedia inout, contains the playlist/songs information
+        * @leave KErrArgument if the song does not exist in the music table and
+        *        the media does not include a URI
+        */
+        void UpdatePlaylistSongInfoL(CMPXMedia& aMedia);
+
+        /**
+        * Makes sure all the folders specified in the array parameter are created,
+        * otherwise it tries to create them. Updates the iDbDrives member variable
+        * with the drives corresponding to the folders.
+        * @param aFolders contains all the folders to be processed
+        */
+        void ProcessMusicFoldersL(const CDesCArray& aFolders);
+
+        /**
+        * Returns the CMPXDbCategory instance associated with the specified
+        * category type
+        * @param aCategory category type
+        * @return corresponding CMPXDbCategory instance
+        * @leave KErrNotSupported if invalid category
+        */
+        CMPXDbCategory* DbCategoryL(TMPXGeneralCategory aCategory) const;
+
+        /**
+        * Verify the volume id for the databases
+        */
+        void VerifyVolumeIdL( TInt aDrive );
+        void VerifyVolumeIdL();
+
+
+#if defined (__MTP_PROTOCOL_SUPPORT)
+        /**
+        * Reads the "save deleted records" MTP flag from CenRep and returns
+        * the value.
+        * @return value of the "save deleted records" MTP flag
+        */
+        TBool SaveDeletedSongs();
+#endif
+
+#ifdef RD_MULTIPLE_DRIVE
+        /**
+        * Retrieve all visible music folder locations.
+        */
+        CDesCArrayFlat* GetMusicFoldersL();
+#endif // RD_MULTIPLE_DRIVE
+
+    private:    // From MMPXDbMusicObserver
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory,
+            const TDesC& aName, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist,
+            const TDesC& aAlbumArtist=KNullDesC,
+            const TDesC& aGenre=KNullDesC);
+#else
+
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory,
+            const TDesC& aName, TInt aDriveId,
+            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+		virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
+			TUint32 aArtist, const TDesC& aArt,
+			TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
+
+		virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, 
+			const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages);
+			
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory,
+            TUint32 aCategoryId, TInt aDriveId, CMPXMessageArray* aItemChangedMessages,
+            TBool& aItemExist);
+
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED      
+        /**
+        * @see MMPXDbMusicObserver
+        */
+        virtual HBufC* HandleGetAlbumNameFromIdL(TUint32 aId);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    private:    // From MMPXDbArtistObserver
+    /**
+    * @see MMPXDbArtistObser
+    */
+        virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aArtistId);
+
+    private:    // From MMPXDbAlbumObserver
+    /**
+    * @see MMPXDbAlbumObserver
+    */
+        virtual TBool HandleIsUnknownArtistL(TUint32 aArtistId);
+        virtual TUint32 HandleArtistForAlbumL(const TUint32 aAlbumId);
+        
+    private:	// From MMPXDbPlaylistObserver
+	/**
+	* @see MMPXDbPlaylistObserver
+	*/
+		virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId);
+        virtual void HandlePlaylistInfoL(TUint32 aPlaylistId, TInt& aCount, TInt& aDuration);
+
+    private:
+
+        /**
+        * C++ constructor.
+        * @param file session
+        */
+        CMPXDbHandler(RFs& aFs, CMPXResource& aResource);
+
+        /**
+        * Symbian 2nd phase constructor..
+        */
+        void ConstructL();
+
+    private:    // Data
+
+        // owned member variables
+        CMPXCollectionDbManager* iDbManager;
+        CMPXDbMusic* iDbMusic;
+        CMPXDbPlaylist* iDbPlaylist;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        CMPXDbAbstractAlbum* iDbAbstractAlbum;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        CMPXDbArtist* iDbArtist;
+        CMPXDbAlbum* iDbAlbum;
+        CMPXDbGenre* iDbGenre;
+        CMPXDbComposer* iDbComposer;
+        CMPXDbAuxiliary* iDbAuxiliary;
+
+        CMPXDbAutoPlaylist* iAutoPlaylist;
+
+        CDesCArrayFlat* iMimeTypes;         // MIME types supported
+        CDesCArrayFlat* iExtensions;        // file extensions supported
+        CDesCArrayFlat* iExtensionsMime;    // file extensions to check MIME
+        CDesCArrayFlat* iExtensionsDrm;     // file extensions to check DRM type
+        RArray<TInt> iDbDrives;
+
+        // not owned member variables
+        RFs& iFs;
+        CMPXResource& iResource;
+        TBool iOutOfDisk;                   // Are we in out of disk mode?
+        TBool iSynchronizeBasicTable;       // Basic music table was not updated during last refresh
+        TBool iCollectionOpen;              // Databases opened
+        TBool iRefresh;                     // Refresh operation currently performed
+        TBool iMtpInUse;                    // Flag for MTP operation
+        TInt  iOpOnDbCount;                 // Count to provide a min op amount in one transaction
+    };
+
+#endif      // MPXDBHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,819 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for all music table functionality.
+*                The Music table contains one record for each song on the database
+*                drive.
+*
+*
+*/
+
+
+#ifndef MPXDBMUSIC_H
+#define MPXDBMUSIC_H
+
+// INCLUDES
+#include "mpxdbtable.h"
+#include "mpxdbcommonstd.h"
+#include "mpxdbactivetask.h"
+
+// CLASS FORWARDS
+class CMPXMedia;
+class CMPXMediaArray;
+
+// CLASS DECLARATION
+
+/**
+* Observer interface for handling the category ID functionality.
+* This is needed because the incoming CMPXMedia parameters in Add and Update methods
+* contain the names for the category items and the music table has to use IDs linking
+* to the category tables. Using this interface removes the dependency to the category
+* class.
+*
+* Note that this interface is only used when information is written to the Music table,
+* when information is retrieved the query takes care of also retrieving the names from
+* the corresponding category tables so the outgoing CMPXMedia will contain the correct
+* information.
+*/
+class MMPXDbMusicObserver
+    {
+    public:
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Called when a new category item has to be added to a category table.
+        * @param aCategory category type
+        * @param aName name string
+        * @param aDrive drive to add the category to
+        * @param aItemChangedMessages changed mesages array to be updated or NULL
+        * @param aItemExist Out parameter, ETrue if the item already exist before the add,
+        *        EFalse otherwise
+        * @param aAlbumArtist AlbumArtist string
+        * @param aGenre Genre string
+        * @return the ID of the category item (new or existing)
+        */
+        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
+            TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aAlbumArtist=KNullDesC,
+            const TDesC& aGenre=KNullDesC) = 0;
+#else
+        /**
+        * Called when a new category item has to be added to a category table.
+        * @param aCategory category type
+        * @param aName name string
+        * @param aDrive drive to add the category to
+        * @param aItemChangedMessages changed mesages array to be updated or NULL
+        * @param aItemExist Out parameter, ETrue if the item already exist before the add,
+        *        EFalse otherwise
+        * @return the ID of the category item (new or existing)
+        */
+        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
+            TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+       // for Album and Artist table
+        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
+            TUint32 aArtistId, 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
+        * the artist name changed for a song. The implementation is supposed to update the
+        * category record and add corresponding item changed messages to the array parameter.
+        * @param aCategory category type
+        * @param aCategoryId old category item ID
+        * @param aDrive drive the category item is on
+        * @param aItemChangedMessages changed mesages array to be updated or NULL
+        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
+        *        EFalse otherwise
+        */
+        virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+            TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
+
+        /**
+        * Called when the play count attribute of a song is changed. Should add an item changed
+        * message to the array.
+        * @param aItemChangedMessages array of item changed messages to add to
+        */
+        virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages) = 0;
+
+        /**
+        * Called when the playback time attribute of a song is changed. Should add an item changed
+        * message to the array.
+        * @param aItemChangedMessages array of item changed messages to add to
+        */
+        virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages) = 0;
+
+        /**
+         * Called when category item is changed. Should add an item changed
+         * message to the array.
+         * @param aCategory category type
+         * @param aCategoryId old category item ID
+         * @param aDrive drive the category item is on
+         * @param aMedia media data
+         * @param aItemChangedMessages changed mesages array to be updated or NULL
+         */
+        virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+             const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Get title from the Id
+        * @param Id to search for
+        * @return name matching the ID
+        */
+        virtual HBufC* HandleGetAlbumNameFromIdL( TUint32 aId ) = 0;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED    
+	};
+
+/**
+* Responsible for managing the Music table
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXDbMusic :
+    public CMPXDbTable
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aObserver observer reference
+        * @return New CMPXDbMusic instance.
+        */
+        static CMPXDbMusic* NewL(CMPXDbManager& aDbManager, CMPXResource& aResource,
+            MMPXDbMusicObserver& aObserver);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @param aObserver observer reference
+        * @return New CMPXDbMusic instance on the cleanup stack.
+        */
+        static CMPXDbMusic* NewLC(CMPXDbManager& aDbManager, CMPXResource& aResource,
+            MMPXDbMusicObserver& aObserver);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbMusic();
+
+    public:
+
+        /**
+        * Add a song to the music table
+        * @param aMedia contains the song details
+        * @param aDrive drive to add the song to
+        * @param aMessageArray change event message to notify client of the changes
+        * @return The unique ID of the song added.
+        */
+        TUint32 AddSongL(const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aMessageArray=NULL);
+
+        /**
+        * Remove a song from the music table
+        * @param aSongId the ID of the song to be removed
+        * @param aDrive song drive
+        * @param aDeleteRecord indicates whether the client has explictly requested
+        *                to delete the records from the database. If ETrue, records
+        *                associated with the media will be deleted from the database;
+        *                if EFalse, whether to mark the records as deleted or to delete
+        *                the records will be based on other deciding factors.
+        */
+        void DeleteSongL(TUint32 aSongId, TInt aDrive, TBool aDeleteRecord = EFalse);
+
+        /**
+        * Remove songs matching a category from the music table
+        * @param aCategory the category to remove
+        * @param aCategoryId ID of the category to remove
+        * @param aUriArray on return will be filled with all the paths that were removed
+        * @param aItemChangedMessages a list of change events as a result of the song removal
+        * @param aDrive drive the category record is on
+        */
+        void DeleteCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages, TInt aDrive);
+
+        /**
+        * Deletes all songs marked as deleted
+        */
+        void CleanupL();
+
+        /**
+        * Update song info for a song in the music table
+        * @param aSongId song ID
+        * @param aMedia media object which contains file path,
+        *                artist, composer, name(title), track, etc...
+        * @param aItemChangedMessages a list of change events as a result of the song removal
+        * @return ETrue if the change is visible in the UI
+        */
+        CMPXDbActiveTask::TChangeVisibility UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia,
+            CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Get the name of the song that matches the given song ID
+        * @param aSongId ID of the song
+        * @return Song name, ownership is transferred to the caller.
+        */
+        HBufC* GetNameL(TUint32 aSongId);
+
+        /**
+        * Get URI of the song
+        * @param aSongId ID of the song
+        * @return Song URI, ownership is transferred to the caller.
+        */
+        HBufC* GetUriL(TUint32 aSongId);
+
+        /**
+        * Get the drive of the song
+        * @param aSongId ID of the song
+        * @return Song drive
+        */
+        TInt GetDriveL(TUint32 aSongId);
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Get the drive and category IDs for a specified song
+        * @param aSongId song to be retrieved
+        * @param aArtistId returns the artist ID
+        * @param aAlbumId returns the artist ID
+        * @param aGenreId returns the artist ID
+        * @param aComposerId returns the artist ID
+        * @param aAbstractAlbumId returns the AbstractAlbum ID
+        * @param aDriveId returns the song drive
+        * @return song URI. The ownership is transferred.
+        */
+        HBufC* GetSongInfoL(TUint32 aSongId, TUint32& aArtistId, TUint32& aAlbumId,
+            TUint32& aGenreId, TUint32& aComposerId, TUint32& aAbstractAlbumId, TInt& aDriveId);
+#else 
+        /**
+        * Get the drive and category IDs for a specified song
+        * @param aSongId song to be retrieved
+        * @param aArtistId returns the artist ID
+        * @param aAlbumId returns the artist ID
+        * @param aGenreId returns the artist ID
+        * @param aComposerId returns the artist ID
+        * @param aDriveId returns the song drive
+        * @return song URI. The ownership is transferred.
+        */
+        HBufC* GetSongInfoL(TUint32 aSongId, TUint32& aArtistId, TUint32& aAlbumId,
+            TUint32& aGenreId, TUint32& aComposerId, TInt& aDriveId);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Get the song Id, title, URI, and general flags from the given song Id and/or URI
+        * @param aCriteria search the media by song Id and/or URI
+        * @param aMedia returns the song details
+        * @return error code KErrNotFound if unable to find the specified song in the
+        *          collection; otherwise KErrNone
+        */
+        TInt GetSongL(const CMPXMedia& aCriteria, CMPXMedia*& aMedia);
+
+        /**
+        * Get the most recently played songs. Returns a maximum of KMPXMaxRecentlyPlayedSongs
+        * songs.
+        * @param aAttrs attributes to include
+        * @param aMediaArray returns the songs' info
+        */
+        void GetRecentlyPlayedSongsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get the most played songs from the music table. Returns a maximum of
+        * KMPXMaxMostPlayedSongs songs.
+        * @param aAttrs attributes to include
+        * @param aMediaArray returns the songs' info
+        */
+        void GetMostPlayedSongsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get the recently added songs from the music table (7 days)
+        * @param aAttrs attributes to include
+        * @param aMediaArray returns the songs' info
+        */
+        void GetRecentlyAddedSongsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+       /**
+        * Get the total number of songs
+        * @return total number of songs
+        */
+        TInt CountL();
+
+        /**
+        * Get all the albums for a specified artist
+        * @param aArtistId artist ID
+        * @param aMediaArray returns the album(s) matching the artist
+        */
+        void GetAlbumsForArtistL(TUint32 aArtistId, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns details about the specified song.
+        * @param aSongId identifies the song
+        * @param aAttrs attributes to be retrieved
+        * @param aMedia returns the song information
+        */
+        void GetSongL(TInt aSongId, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
+        
+        /**
+        * Returns all songs in the playlist.
+        * @param aDrive identifies in db
+        * @param aPlaylistId identifies the playlist
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetAllSongsL(TInt aDrive,TInt aPlaylistId,const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns all songs in the database.
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetAllSongsL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get from all songs with a limit (first N items)
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        * @param aLimit maximum number of songs to retrieve
+        */
+        void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray, TInt aLimit);
+
+        /**
+        * Returns a block of songs as specified
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        * @param aTitle title of the song that marks the beginning of the block
+        * @param aNumOfSongs the number of songs in the block
+        * @param aAsc
+        */
+        void GetSongsInBlockL( const TArray<TMPXAttribute>& aAttrs,
+                               CMPXMediaArray& aMediaArray,
+                               TPtrC aTitle,
+                               TUint aNumOfSongs,
+                               TBool aAsc);
+
+
+        /**
+        * Get songs from the music collection starting at a particular offset
+        * ONLY use this as the first query to locate particular item. Should use
+        * GetSongsInBlockL() to fetch in blocks with a particular index
+        * @param aMediaArray Array to store the results
+        * @param aAttrs attributes to fetch
+        * @param aOffset offset to start reading
+        * @param aCount number of items to get
+        */
+        void GetSongsAtOffsetL( CMPXMediaArray& aMediaArray,
+                                const TArray<TMPXAttribute>& aAttrs,
+                                TInt aOffset,
+                                TInt aCount );
+
+        /**
+        * Returns all songs for a given artist.
+        * @param aArtistId artist to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetSongsForArtistL(TUint aArtistId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns all songs for a given album.
+        * @param aAlbumId album to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetSongsForAlbumL(TUint aAlbumId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns all songs for a given artist and album.
+        * @param aArtistId artist to get the songs for
+        * @param aAlbumId album to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetSongsForArtistAndAlbumL(TUint aArtistId, TUint aAlbumId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns all songs for a given genre.
+        * @param aGenreId genre to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetSongsForGenreL(TUint aGenreId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns all songs for a given composer.
+        * @param aComposerId composer to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetSongsForComposerL(TUint aComposerId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+	    /**
+        * Returns all songs for a given abstractalbum.
+        * @param aDrive drive ID AbstractAlbum stored
+        * @param aAbstractAlbumId abstractalbum to get the songs for
+        * @param aAttrs attributes to be retrieved
+        * @param aMediaArray returns the song attributes.
+        */
+        void GetAllSongsForAbstractAlbumL(TInt aDrive, TInt aAbstractAlbumId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        /**
+        * Returns the duration of all songs.
+        * @return the duration value
+        */
+        TInt AllSongsDurationL();
+
+        /**
+        * Returns the duration for a specified artist.
+        * @param aArtistId artist to get the duration for
+        * @return the duration value
+        */
+        TInt ArtistDurationL(TUint aArtistId);
+
+        /**
+        * Returns the duration for a specified album.
+        * @param aAlbumId album to get the duration for
+        * @return the duration value
+        */
+        TInt AlbumDurationL(TUint aAlbumId);
+
+        /**
+        * Returns the duration for a specified artist and album.
+        * @param aArtistId artist to get the duration for
+        * @param aAlbumId album to get the duration for
+        * @return the duration value
+        */
+        TInt ArtistAlbumDurationL(TUint aArtistId, TUint aAlbumId);
+
+        /**
+        * Returns the duration for a specified genre.
+        * @param aGenreId genre to get the duration for
+        * @return the duration value
+        */
+        TInt GenreDurationL(TUint aGenreId);
+
+        /**
+        * Returns the duration for a specified composer.
+        * @param aComposerId composer to get the duration for
+        * @return the duration value
+        */
+        TInt ComposerDurationL(TUint aComposerId);
+
+        /**
+        * Returns the duration for the recently played songs.
+        * @return the duration value
+        */
+        TInt RecentlyPlayedDurationL();
+
+        /**
+        * Returns the duration for the most played songs.
+        * @return the duration value
+        */
+        TInt MostPlayedDurationL();
+
+        /**
+        * Returns the duration for the recently added songs.
+        * @return the duration value
+        */
+        TInt RecentlyAddedDurationL();
+
+        /**
+        * Find the songs for the selection criteria
+        * @param aGeneralId selection criteria (could be song/album/artist/genre/composer ID)
+        * @param aContainerId selection criteria (could be artist/album id)
+        * @param aType criteria type (EMPXItem or EMPXGroup)
+        * @param aCriteria selection criteria
+        * @param aAttrs the attributes to include for the artist(s) matching the
+        *        selection criteria
+        * @param aMediaArray returns the songs
+        */
+        void FindSongsL(TUint32 aGeneralId, TUint32 aContainerId, TMPXGeneralType aType,
+            const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Returns the track count for a given drive
+        * @param aDrive drive
+        * @return the count
+        */
+        TUint GetDriveTrackCountL(TInt aDrive);
+
+        /**
+        * Get URIs for a given number of tracks
+        * @param aDrive, specifies drive number for db selection
+        * @param aFromID, specifies unique ID of last record retrieved
+        * @param aRecords, specifies the number of records to get
+        * @param aUriArr, will contain all URIs on return
+        * @param aLastID, will contain unique ID of a last record in the array
+        */
+        void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                               CDesCArray& aUriArr, TInt& aLastID);
+
+        /**
+         * Get the ID of Artist which belongs to the specified Album
+		 * @param aId, the ID of Album
+         */
+        TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId);
+        
+        /**
+        * Signals the start of a refresh operation
+        */
+        void RefreshStartL();
+
+        /**
+        * Signals the end of a refresh operation
+        */
+        void RefreshEndL();
+
+        /*
+        * Refresh music basic table
+        */
+        void RefreshBasicTableL();
+
+        /*
+        * Check the integrity of the music basic table
+        */
+        void CheckMusicBasicTableL();
+
+    private:
+
+        /**
+        * Checks if the specified song exists.
+        * @param aId identifies the song
+        * @return ETrue if it exists, EFalse otherwise
+        */
+        TBool SongExistsL(TUint32 aSongId);
+
+        /**
+        * Update the media with information found in the Music table
+        * @param aMusicTable music table record
+        * @param aAttrs the attributes to include
+        * @param aMedia returns the song details
+        */
+        void UpdateMediaL(RSqlStatement& aMusicTable, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Update the media general attributes from the Music table
+        * @param aMusicTable music table view
+        * @param aAttrId the required attributes
+        * @param aMedia the media object to set
+        */
+        void UpdateMediaGeneralL(RSqlStatement& aMusicTable, const TUint aAttrId,
+            CMPXMedia& aMedia);
+
+        /**
+        * Update the media music attributes from the Music table
+        * @param aMusicTable music table view
+        * @param aAttrId the required attributes
+        * @param aMedia the media object to set
+        */
+        void UpdateMediaMusicL(RSqlStatement& aMusicTable, const TUint aAttrId,
+            CMPXMedia& aMedia);
+
+        /**
+        * Update the media audio attributes from the Music table
+        * @param aMusicTable music table view
+        * @param aAttrId the required attributes
+        * @param aMedia the media object to set
+        */
+        void UpdateMediaAudioL(RSqlStatement& aMusicTable, const TUint aAttrId,
+            CMPXMedia& aMedia);
+
+        /**
+        * Update the media MTP attributes from the Music table
+        * @param aMusicTable music table view
+        * @param aAttrId the required attributes
+        * @param aMedia the media object to set
+        */
+        void UpdateMediaMTPL(RSqlStatement& aMusicTable, const TUint aAttrId,
+            CMPXMedia& aMedia);
+
+        /**
+        * Adds a song to the Music table
+        * @param aSongId identifies the song
+        * @param aMedia contains the song attributes
+        * @param aDrive drive to add the song to
+        * @param aItemChangedMessages item changed messages to update
+        */
+        TBool DoAddSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive,
+            CMPXMessageArray* aItemChangedMessages);
+
+        /**
+        * Updates a song in the Music table
+        * @param aSongId identifies the song
+        * @param aMedia contains the song attributes
+        * @param aItemChangedMessages item changed messages to update or NULL
+        */
+        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia,
+            CMPXMessageArray* aItemChangedMessages);
+
+        /**
+        * Updates a song in the Music table
+        * @param aSongId identifies the song
+        * @param aMedia contains the song attributes
+        * @param aDrive drive to add the song to
+        * @param aItemChangedMessages item changed messages to update
+        * @param aRecordset current song record in the Music table.
+        *       Required to detect any field changes.
+        */
+        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive,
+            CMPXMessageArray* aItemChangedMessages, RSqlStatement& aRecordset);
+
+        /**
+        * Get the DRM type of the given file
+        * @param aFile file
+        * @return DRM type.
+        */
+        TMCDrmType DRMTypeL(const TDesC& aFile);
+
+        /**
+        * Generate searching criteria for music table from the given criteria
+        * @param aGeneralId selection criteria (could be song/album/artist/genre/composer Id)
+        * @param aContainerId selection criteria (could be artist/album id)
+        * @param aType criteria type (EMPXItem or EMPXGroup)
+        * @param aCriteria input criteria
+        * @return a string containing the selection criteria. The ownership is passed to the caller.
+        */
+        HBufC* GenerateMusicMatchingCriteriaLC(TUint32 aGeneralId, TUint32 aContainerId,
+            TMPXGeneralType aType, const CMPXMedia& aCriteria);
+
+        /**
+        * Constructs the fields and corresponding values to be written into the music
+        * table for update and insert statements.
+        * @param aSongId identifies the song
+        * @param aMedia contains the new song attributes
+        * @param aItemChangedMessages item changed mesages to add to
+        * @param aMusicTable points to the existing record in the Music table for updates or NULL
+        *       for inserts
+        * @param aFields returns the field names to be updated
+        * @param aValues returns the field values to be updated
+        * @param aDrive drive the song is on
+        * @return ETrue if the change is visible in the UI
+        */
+        CMPXDbActiveTask::TChangeVisibility GenerateMusicFieldsValuesL(TUint32 aSongId, const CMPXMedia& aMedia,
+            CMPXMessageArray* aItemChangedMessages, RSqlStatement* aMusicTable,
+            CDesCArray& aFields, CDesCArray& aValues, TInt aDrive);
+
+        /**
+        * Generates the full URI from a music record.
+        * @param aMusicTable music table record
+        * @return Full URI string. The ownership is passed to the caller.
+        */
+        HBufC* ConstructUriL(RSqlStatement& aMusicTable, TUint32 aMediaId);
+
+        /**
+        * Checks if the specified category field (artist/album/genre/composer)
+        * will change and notifies the observer if so.
+        * @param aCategory identifies the category
+        * @param aMedia contains the new record attributes
+        * @param aAttribute corresponding attribute in the media parameter
+        * @param aColumnIndex column index in the recordset
+        * @param aMusicTable current record in the music table or NULL if this is an insert
+        * @param aDriveId drive ID the update is for
+        * @param aItemChangedMessages item changed messages to append to
+        * @param aItemId returns the category item ID
+        * @return ETrue if the field was modified
+        */
+        TBool UpdateCategoryFieldL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia,
+            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,
+        * EMPXMediaGeneralTitle, EMPXMediaGeneralUri, and EMPXMediaGeneralFlags
+        * @param aAttrs attributes to be checked
+        * @return ETrue if extra attributes are required
+        */
+        TBool ExtraFieldsRequired(const TArray<TMPXAttribute>& aAttrs);
+
+        /**
+        * Test whether the given media contains any supported attribute
+        * @param aMedia media to be tested
+        * @return ETrue if the media contains one or more supported attribute;
+        *  otherwise EFalse.
+        */
+		TBool IsSupported(const CMPXMedia& aMedia);
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void DropTableL(RSqlDatabase& aDatabase);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+    private:
+
+        /**
+        * C++ constructor
+        * @param aDbManager database manager to use for database interactions
+        */
+        CMPXDbMusic(CMPXDbManager& aDbManager, MMPXDbMusicObserver& aObserver);
+
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL(CMPXResource& aResource);
+
+    private:
+
+        /**
+        * Column indexes in the music table
+        */
+        enum TMusicColumns
+        	{
+        	EMusicUniqueId = KMPXTableDefaultIndex,
+            EMusicDbFlag,
+            EMusicVolumeId,
+            EMusicTitle,
+            EMusicArtist,
+            EMusicArt,
+            EMusicDeleted,
+            EMusicLocation,
+            EMusicAlbumTrack,
+            EMusicPlayCount,
+            EMusicTimeAdded,
+            EMusicTimePlayed,
+            EMusicDuration,
+            EMusicSync,
+            EMusicModified,
+            EMusicAlbum,
+            EMusicGenre,
+            EMusicComposer,
+            EMusicReleaseDate,
+            EMusicRating,
+            EMusicComment,
+            EMusicCopyright,
+            EMusicUrl,
+            EMusicDRM,
+            EMusicLastPlayPosition,
+            EMusicSampleRate,
+            EMusicBitRate,
+            EMusicNumChannels,
+            EMusicCodec,
+            EMusicMimeType,
+            EMusicMTPDrmStatus,
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+            EMusicAlbumArtist,
+            EMusicContainEmbeddedArt,
+            EMusicAbstractAlbum,
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+            EMusicArtistName,
+            EMusicAlbumName,
+            EMusicGenreName,
+            EMusicComposerName,
+            EMusicFieldCount
+            };
+
+         /*
+         * Unique ID for Queries with a lifetime
+         */
+         enum TMusicStatements
+             {
+             EOffsetQueryBasic = 0xabcd0001,
+             EAscQueryBasic = 0xabcd0002,
+             EDscQueryBasic = 0xabcd0003,
+             EOffSetQuery = 0xabcd0004,
+             EAscQuery = 0xabcd0005,
+             EDscQuery = 0xabcd0006
+             };
+
+    private:    // Data
+
+        // file extensions to check DRM type, owned
+        CDesCArrayFlat* iExtensionsDrm;
+        MMPXDbMusicObserver& iObserver;
+        TBool iRefresh;
+    };
+
+#endif // MPXDBMUSIC_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplaylist.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,336 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class manages the Playlist table and owns a
+*                CMPXPlaylistSongs instance for managing the PlaylistSongs and
+*                PlaylistSongInfo tables.
+*
+*                The Playlist table stores one record for each playlist.
+*
+*
+*/
+
+
+#ifndef MPXDBPLAYLIST_H
+#define MPXDBPLAYLIST_H
+
+// INCLUDES
+#include "mpxdbtable.h"
+
+// CLASS FORWARDS
+class RSqlStatement;
+class CMPXDbPlaylistSongs;
+class CMPXMedia;
+class CMPXMediaArray;
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing the playlist tables
+*
+* @lib MPXDbPlugin.lib
+*/
+class MMPXDbPlaylistObserver
+	{
+	public:
+		virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId) = 0;
+        virtual void HandlePlaylistInfoL(TUint32 aPlaylistId, TInt& aCount, TInt& aDuration) = 0;
+	};
+class CMPXDbPlaylist : public CMPXDbTable
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbPlaylist instance.
+        */
+        static CMPXDbPlaylist* NewL(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbManager instance on the cleanup stack.
+        */
+        static CMPXDbPlaylist* NewLC(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbPlaylist();
+
+    public:
+
+        /**
+        * Add a playlist to the playlist table.  If playlist already exists,
+        * it is updated.
+        * @param aMedia playlist media to be added to the collection
+        * @return The unique id of the playlist
+        */
+        TUint32 AddPlaylistL(const CMPXMedia& aMedia);
+
+        /**
+        * Add one or multiple songs to the playlist.
+        * @param aPlaylistId identifies the playlist
+        * @param aMediaArray contains the song information to be added
+        */
+        void AddSongsL(TUint32 aPlaylistId, const CMPXMediaArray& aMediaArray);
+
+        /**
+        * Update playlist info
+        * @param aMedia playlist object which contains playlist Id, file path,
+        *               timestamp, etc... to be updated in the playlist table
+        * @param aMessage change event message for the playlist updated
+        */
+        void UpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessage& aMessage, TInt aDriveId);
+
+        /**
+        * Update a playlist song
+        * @param aMedia song info
+        * @param aResetFlags indicates whether the song db flags should be reset or just updated
+        * @param aItemChangedMessages returns the change messages for the playlists updated
+        * @return ETrue if the change is visible in the UI
+        */
+        TBool UpdateSongL(const CMPXMedia& aMedia, TBool aResetFlags,
+            CMPXMessageArray* aItemChangedMessages = NULL);
+
+        /**
+        * Remove a playlist and return its URI
+        * @param aPlaylistId identifies the playlist
+        * @return HBufC containing the URI. Ownership is transferred.
+        */
+        HBufC* DeletePlaylistL(TUint32 aPlaylistId);
+
+        /**
+        * Remove a playlist
+        * @param aPlaylistId identifies the playlist
+        */
+        void DeletePlaylistNoUriL(TUint32 aPlaylistId);
+
+        /**
+        * Delete a song from the playlist tables.
+        * @param aSongId identifies the song
+        * @param aItemChangedMessages returns the item changed messages
+        */
+        void DeleteSongL(TUint32 aSongId, CMPXMessageArray& aItemChangedMessages);
+
+        /**
+        * Delete a song from the playlist tables.
+        * @param aPlaylistId identifies the playlist
+        * @param aSongId identifies the song
+        * @param aOrdinal song ordinal
+        */
+        void DeleteSongL(TUint32 aPlaylistId, TUint32 aSongId, TInt aOrdinal);
+
+        /**
+        * Remove all playlists.
+        */
+        void DeleteAllPlaylistsL();
+
+        /**
+        * Gets the total number of playlists.
+        * @return number of playlists
+        */
+        TInt CountL();
+
+        /**
+        * Get information on a specified playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aAttrs the attributes to include for the playlists found.
+        * @param aMedia returns the playlist information
+        */
+        void GetPlaylistL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Get all playlists
+        * @param aAttrs the attributes to include for the playlists found.
+        * @param aMediaArray returns the playlist information
+        */
+        void GetAllPlaylistsL(const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get the name of a playlist.
+        * @param aPlaylistId identifies the playlist
+        * @return name matching the specified playlist ID. Ownership is transferred.
+        */
+        HBufC* GetNameL(TUint32 aPlaylistId);
+
+        /**
+        * Get a playlist' uri
+        * @param aPlaylistId identifies the playlist
+        * @return URI matching the specified playlist ID. Ownership is transferred.
+        */
+        HBufC* GetUriL(TUint32 aPlaylistId);
+
+        /**
+        * Return the playlist ID for a specified URI.
+        * @param aUri URI of the playlistId
+        * @return playlist ID
+        */
+        TUint32 GetIdL(const TDesC& aUri);
+
+        /**
+        * Find playlist(s) which match(es) the selection criteria
+        * @param aCriteria selection criteria
+        * @param aAttrs the attributes to include for the playlist(s) matching the
+        *        selection criteria
+        * @param aMediaArray playlist(s) matching the selection criteria
+        */
+        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMediaArray& aMediaArray);
+
+        /**
+        * Find the drive Id for a playlist
+        * @param aPlaylistId identifies the playlist
+        * @return corresponding drive id
+        */
+        TInt GetDriveIdL(TUint32 aPlaylistId);
+
+        /**
+        * Provides access to the songs for the current playlist.
+        * @return CMPXDbPlaylistSongs reference to be used to access the songs
+        */
+        CMPXDbPlaylistSongs& Songs();
+
+        /**
+        * Returns the playlist count for a given drive
+        * @param aDrive drive
+        * @return the count
+        */
+        TUint GetDrivePlaylistCountL(TInt aDrive);
+
+        /**
+        * Get URIs for a given number of playlists
+        * @param aDrive, specifies drive number for db selection
+        * @param aFromID, specifies unique ID of last record retrieved
+        * @param aRecords, specifies the number of records to get
+        * @param aUriArr, will contain all URIs on return
+        * @param aLastID, will contain unique ID of a last record in the array
+        */
+        void GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                  CDesCArray& aUriArr, TInt& aLastID);
+
+    private:
+
+        /**
+        * Update the media with information found in the Playlist table
+        * @param aRecord playlist table
+        * @param aAttrs the attributes to include for the playlist matching the
+        *        selection criteria
+        * @param aMedia returns playlist details
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Create playlist table view and have the current row point to aPlaylistId
+        * @param aPlaylistId ID of the playlist to match
+        * @return RSqlStatement with row pointing to selected aPlaylistId
+        * Function leaves with KErrNotFound if RSqlStatement is unable to initialize
+        * or row cannot be found
+        */
+        RSqlStatement GetPlaylistRecordL(TUint32 aPlaylistId);
+
+        /**
+        * Add a new playlist
+        * @param aMedia contains the playlist info
+        * @param aDriveId drive to add the playlist to
+        * @return ID of the new playlist
+        */
+        TUint32 DoAddPlaylistL(const CMPXMedia& aMedia, TInt aDriveId);
+
+        /**
+        * Update a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aMedia contains the playlist info
+        * @param aDriveId drive to add the playlist to
+        * @param aMessage change event message for the playlist updated
+        */
+        void DoUpdatePlaylistL(TUint32 aPlaylistId, const CMPXMedia& aMedia, TInt aDriveId,
+            CMPXMessage& aMessage);
+
+        /**
+        * Sets the Time field for all playlists that contain the specified song to the
+        * current time
+        * @param aSongId identifies the song
+        * @param aItemChangedMessages if not NULL item changed messages are added for all
+        *           updated playlists
+        * @param aSongInPlaylists out parameter that flags if the song is part of a playlist or not
+        */
+        void UpdatePlaylistsForSongL(TUint32 aSongId, CMPXMessageArray* aItemChangedMessages,TBool &aSongInPlaylists);
+
+        /**
+        * Sets the Time field for a playlist to the current time.
+        * @param aPlaylistId identifies the playlist
+        * @param aDrive playlist drive
+        */
+        void UpdatePlaylistTimeL(TUint32 aPlaylistId, TInt aDrive);
+
+        TInt GetDrivePlaylistDuration(TUint32 aPlaylistId);
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void DropTableL(RSqlDatabase& aDatabase);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+     private:
+
+        /**
+        * C++ constructor
+        * @param aDbManager database manager to use for database interactions
+        */
+        CMPXDbPlaylist(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
+
+        /**
+        * Second phase constructor
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the playlist table
+        */
+        enum TPlaylistColumns
+            {
+            EPlaylistUniqueId = KMPXTableDefaultIndex,
+            EPlaylistVolumeId,
+            EPlaylistDbFlag,
+            EPlaylistSync,
+            EPlaylistName,
+            EPlaylistUri,
+            EPlaylistTime
+            };
+
+    private:    // Data
+
+        CMPXDbPlaylistSongs* iPlaylistSongs;
+		MMPXDbPlaylistObserver& iObserver;
+    };
+
+#endif // MPXDBPLAYLIST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplaylistsongs.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,328 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for the functionality related to
+*                playlist songs. The class operates on two tables: PlaylistSongs
+*                and PlaylistSongInfo.
+*
+*                The PlaylistSongs table contains records for all song instances in
+*                playlists. For example if a playlist contains 7 songs, there will be 7
+*                corresponding records in the PlaylistSongs table, even if one song has
+*                multiple instances in the playlist.
+*
+*                The PlaylistSongInfo table contains one record for each song included
+*                in at least one playlist. Redundant song information is stored in this
+*                table to help with songs on different drives than the playlist.
+*
+*
+*/
+
+
+#ifndef MPXDBPLAYLISTSONGS_H
+#define MPXDBPLAYLISTSONGS_H
+
+// INCLUDES
+#include "mpxdbtable.h"
+
+// CLASS FORWARDS
+class CMPXMedia;
+class CMPXMediaArray;
+
+// CLASS DECLARATION
+
+/**
+* Responsible for managing the music table
+*
+* @lib MPXDbPlugin.lib
+*/
+class CMPXDbPlaylistSongs :
+    public CMPXDbTable
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbPlaylistSongs instance.
+        */
+        static CMPXDbPlaylistSongs* NewL(CMPXDbManager& aDbManager);
+
+        /**
+        * Two-phased constructor.
+        * @param aDbManager database manager to use for database interactions
+        * @return New CMPXDbPlaylistSongs instance on the cleanup stack.
+        */
+        static CMPXDbPlaylistSongs* NewLC(CMPXDbManager& aDbManager);
+
+        /**
+        * Destructor
+        */
+        virtual ~CMPXDbPlaylistSongs();
+
+    public:
+
+        /**
+        * Add a song/songs to the given playlist
+        * @param aPlaylistId playlist id
+        * @param aMediaArray media array which contains the tracks to be added to the playlist
+        * @param aDriveId Drive Id of corresponding playlist
+        */
+        void AddSongsL(TUint32 aPlaylistId, const CMPXMediaArray& aMediaArray, TInt aDriveId);
+
+        /**
+        * Add a song to playlist songs table for the given playlist
+        * @param aPlaylistId id of the playlist to add the song to
+        * @param aDriveId drive the song is on
+        * @param aMedia song media to be added to the playlist songs table for the playlist
+        * @return song ID
+        */
+        TUint32 AddSongL(TUint32 aPlaylistId, const CMPXMedia& aMedia, TInt aDriveId);
+
+        /**
+        * Add a song to playlist songs table for the given playlist
+        * @param aPlaylistId id of the playlist to add the song to
+        * @param aOrdinal ordinal of the song to be added
+        * @param aDriveId drive the song is on
+        * @param aMedia song media to be added to the playlist songs table for the playlist
+        * @return song ID
+        */
+        TUint32 AddSongL(TUint32 aPlaylistId, TInt aOrdinal, const CMPXMedia& aMedia,
+            TInt aDriveId);
+
+        /**
+        * Update song info for a song in the playlist songs table
+        * @param aSongId identifies the song
+        * @param aMedia song information
+        * @param aResetFlags indicates whether the song db flags should be reset or just updated
+        * @param aUpdated returns ETrue if the song information has changed
+        */
+        TBool UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TBool aResetFlags,
+            TBool& aUpdated);
+
+        /**
+        * Update songs in a playlist to reflect playlist id change
+        * @param aPlaylistId identifies the songs in the playlist
+        * @param aNewPlaylistId specifies the new playlist id the songs should be associated with
+        */
+        void UpdateSongsL(TUint32 aPlaylistId, TUint32 aNewPlaylistId);
+
+        /**
+        * Reorder the song in the playlist
+        * @param aPlaylistId id of the playlist which contains the song to be reordered
+        * @param aSongId id of the song to be reordered
+        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
+        *        Ordinal starts from 0.
+        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
+        *        starts from 0.
+        */
+        void ReorderSongL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
+            TUint aOriginalOrdinal, TUint aNewOrdinal);
+
+        /**
+        * Remove the given song from all playlists
+        * @param aSongId ID of the song to remove
+        * @param aDriveId identifies the database to be updated
+        */
+        void DeleteSongL(TUint32 aSongId);
+
+        /**
+        * Remove a song from the playlist.
+        * @param aPlaylistId ID of the playlist to remove the song from
+        * @param aSongId Id of the song in the playlist to be removed
+        * @param aOrdinal the ordinal of the song in the playlist. This uniquely
+        *        identifies which song in the playlist to be removed; whereas song
+        *        ID doesn't because duplicate tracks in the playlist are allowed.
+        *        The position is relative to zero, i.e. zero implies that the song
+        *        at the beginning of the playlist is to be removed.
+        * @param aDriveId identifies the database to be updated
+        */
+        void DeleteSongL(TUint32 aPlaylistId, TUint32 aSongId, TInt aOrdinal, TInt aDriveId);
+
+        /**
+        * Remove all songs from the specified playlist
+        * @param aPlaylistId ID of the playlist.
+        * @param aDriveId identifies the database.
+        */
+        void DeleteSongsL(TUint32 aPlaylistId, TInt aDriveId);
+
+        /**
+        * Remove the songs for a given category from all playlists.
+        * @param aCategory identifies the category
+        * @param aCategoryId identifies the category item
+        * @param aDriveId identifies the database to be updated
+        */
+        void DeleteSongsForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+            TInt aDriveId);
+
+        /**
+        * Remove the songs for a given category from all playlists.
+        * @param aCategory identifies the category
+        * @param aCategoryId identifies the category item
+        * @param aDriveId identifies the database to be updated
+        */
+        void DeleteSongsForArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId, TInt aDriveId);
+
+        /**
+        * Remove all songs from the playlist songs table
+        */
+        void DeleteAllSongsL();
+
+        /**
+        * Get ids of all songs in a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aMediaArray returns songs' id
+        */
+        void GetSongsL(TUint32 aPlaylistId, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get ids of all songs in a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aAttrs attributes to return
+        * @param aMediaArray returns songs' id
+        */
+        TBool GetSongsL( TUint32 aPlaylistId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
+
+        /**
+        * Get information on a song in a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aSongId identifies the song
+        * @param aAttrs attributes to return
+        * @param aMedia returns song info
+        */
+        TBool GetSongL(TUint32 aPlaylistId, TUint32 aSongId,
+            const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
+
+        /**
+        * Get information on a song
+        * @param aSongId identifies the song
+        * @param aAttrs attributes to return
+        * @param aMedia returns song info
+        */
+        TBool GetSongL(const TMPXItemId& aSongId, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia*& aMedia);
+
+
+        /**
+        * Get the number of songs for a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aDriveId identifies the database to be query
+        * @return number of songs
+        */
+        TInt CountL(TUint32 aPlaylistId, TInt aDriveId);     
+
+    private:
+
+        /**
+        * Update the media from the table
+        * @param aRecord playlist table view
+        * @param aAttrs the attributes to return
+        * @param aMedia updated with the playlist song info
+        */
+        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
+            CMPXMedia& aMedia);
+
+        /**
+        * Get the number of instances of a song in a playlist
+        * @param aPlaylistId identifies the playlist
+        * @param aSongId identifies the song
+        * @return number of instances
+        */
+        TInt SongInstanceCountL(TUint32 aPlaylistId, TUint32 aSongId);
+
+        /**
+        * Get the number of instances of a song in the PlaylistSongs table.
+        * @param aSongId identifies the song
+        * @return number of instances
+        */
+        TInt SongCountL(TUint32 aSongId);
+
+        /**
+        * Checks if the specified song exists in the PlaylisySongInfo table.
+        * @param aDriveId drive to check or KDbManagerAllDrives
+        * @param aSongId identifies the song
+        * @return ETrue if it exists, EFalse otherwise
+        */
+        TBool SongInfoExistsL(TInt aDriveId, TUint32 aSongId);
+
+        /**
+        * Deletes all orphaned records in the PlaylistSongInfo table
+        * (songs not included in any playlist).
+        * @param aDriveId database to cleanup
+        */
+        void CleanupSongInfoL(TInt aDriveId);
+
+    private:    // from MMPXTable
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual void DropTableL(RSqlDatabase& aDatabase);
+
+        /**
+        * @see MMPXTable
+        */
+        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
+
+    private:
+
+        /**
+        * C++ constructor
+        * @param aDbManager database manager to use for database interactions
+        */
+        CMPXDbPlaylistSongs(CMPXDbManager& aDbManager);
+
+        /**
+        * Safely construct things that can leave
+        */
+        void ConstructL();
+
+    private:
+
+        /**
+        * Column indexes in the playlist songs query
+        */
+        enum TPlaylistSongsColumns
+            {
+            EPlaylistSongsUniqueId = KMPXTableDefaultIndex,
+            EPlaylistSongsSongId,
+            EPlaylistSongsPlaylistId,
+            EPlaylistSongsOrdinal,
+            EPlaylistSongsVolumeId,
+            EPlaylistSongsDbFlag,
+            EPlaylistSongsUri,
+            EPlaylistSongsTitle
+            };
+
+        /**
+        * Column indexes in the playlist song info table
+        */
+        enum TPlaylistSongInfoColumns
+            {
+            EPlaylistSongInfoSongId = KMPXTableDefaultIndex,
+            EPlaylistSongInfoVolumeId,
+            EPlaylistSongInfoDbFlag,
+            EPlaylistSongInfoUri,
+            EPlaylistSongInfoTitle
+            };
+
+    };
+
+#endif // MPXDBPLAYLISTSONGS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbplugin.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,794 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of collection Database Plugin interface
+*
+*/
+
+
+#ifndef MPXDBPLUGIN_H
+#define MPXDBPLUGIN_H
+
+// INCLUDES
+#include <badesca.h>
+#include <mpxcommonframeworkdefs.h>
+#include <mpxcollectionframeworkdefs.h>
+#include <mpxcollectionplugin.h>
+#include <mpxcollectionpath.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmessage2.h>
+
+#include "mpxdbactivetask.h"
+#include "mpxcollectiondb.hrh"
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class CMPXDbHandler;
+class CMPXDrmMediaUtility;
+class CMPXMediaArray;
+class CMPXResource;
+struct TMPXOpenDataBlock;
+
+// CLASS DECLARATION
+
+/**
+* CMPXDbPlugin class
+* Implements the plugin interface.
+*
+* @lib MPXDbPlugin.lib
+*/
+NONSHARABLE_CLASS(CMPXDbPlugin) :
+    public CMPXCollectionPlugin,
+    public MMPXDbActiveTaskObserver
+    {
+public: // Constructors and destructor
+
+    /**
+    * Two-phased constructor
+    * @param aInitParams: initialization parameters
+    * @return object constructed
+    */
+    static CMPXDbPlugin* NewL (TAny* aInitParams);
+
+    /**
+    * Destructor
+    */
+    virtual ~CMPXDbPlugin();
+
+public: // from base classes
+
+    /**
+    * From CMPXCollectionPlugin
+    * Navigates to the given path. This method is serviced
+    * asynchronously and HandleOpenL is called upon completion
+    * @param aPath a path
+    * @param aAttrs attributes requested
+    * @param aFilter filter to apply or NULL if none
+    */
+    void OpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXFilter* aFilter);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Get the extended properties of the item referred to by the
+    * specified collection path.  This method is serviced asynchronously and
+    * HandleMediaL is called upon completion
+    * @param aPath a collection path referring to the item to retrieve the
+    *               extended properties for
+    * @param aAttrs array of attributes requested
+    * @param aCaps platsec capabilities of client requesting media; plug-in
+    *        should also verify its process capabilities (not yet supported)
+    * @aParam aSpecs specifications for attributes (not yet supported)
+    */
+    void MediaL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        const TArray<TCapability>& aCaps, CMPXAttributeSpecs* aSpecs);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Cancel outstanding request. Note*** CancelRequest is not currently
+    * implemented because all requests are processed synchronously
+    */
+    void CancelRequest();
+
+    /**
+    * From CMPXCollectionPlugin
+    * Executes the given TMPXCollectionCommand command on the collection
+    * @param aCmd a command
+    * @param aArg an argument
+    */
+    void CommandL (TMPXCollectionCommand aCmd, TInt aArg = 0);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Executes the given CMPXCommand command on the collection
+    * @param aCmd a command
+    */
+    void CommandL(CMPXCommand& aCmd);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Adds an item (song or playlist) to the collection
+    * @param aMedia Properties of the item
+    */
+    void AddL(const CMPXMedia& aMedia);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Remove an item from the collection database using the given path
+    * Note that the selection indices are hidden within the path
+    * @param aPath path to the item to be removed
+    *
+    */
+    void RemoveL(const CMPXCollectionPath& aPath);
+
+    /**
+    *  Remove item(s) from the collection database using the given media properties
+    *  @param aMedia Properties of the item(s) to be removed. May cantain a URI
+    *           or metadata. All item(s) matching the specified properties
+    *           will be removed.
+    */
+    void RemoveL(const CMPXMedia& aMedia);
+
+    /**
+    *  Sets/updates the specified media for an item in the collection.  Media
+    *  is identified by specifying an ID or URI.
+    *  @param aMedia new property values for the item
+    */
+    void SetL(const CMPXMedia& aMedia);
+
+    /**
+    * From CMPXCollectionPlugin
+    *  Find the items matching the media specifications.  This method is serviced
+    *  asynchronously and HandleFindAllL is called upon completion
+    *  @param aCriteria Properties of the item that is to be found
+    *  @param aAttrs Requested attributes to return
+    */
+    void FindAllL (const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs);
+
+    /**
+    *  From CMPXCollectionPlugin
+    *  Find the items matching the media specifications
+    *  @param aCriteria Properties of the item that is to be found
+    *  @param aAttrs Requested attributes to return
+    *  @return results of the search. Method abandons ownership of results.
+    */
+    CMPXMedia* FindAllSyncL(const CMPXMedia& aCriteria,
+        const TArray<TMPXAttribute>& aAttrs);
+
+    /**
+    * From CMPXCollectionPlugin
+    * Get the list of supported capabilities
+    * @return TCollectionCapability, bitmask of supported capabilities
+    */
+    TCollectionCapability GetCapabilities ();
+
+    /**
+    * From MMPXDbActiveTaskObserver
+    */
+    TBool HandleStepL();
+
+    /**
+    * From MMPXDbActiveTaskObserver
+    */
+    void HandleOperationCompleted(TInt aErr);
+
+private:
+    /**
+    * Constructor
+    */
+    CMPXDbPlugin();
+
+    /**
+    * Symbian 2nd phase constructor.
+    */
+    void ConstructL();
+
+    /**
+    * Process the OpenL command
+    * @param aPath a path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aFilter CMPXFilter Object
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntries, CMPXFilter* aFilter );
+
+    /**
+    * Process the OpenL(EBrowseAll) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowseAllL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process the OpenL(EBrowseArtist) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowseArtistL(const CMPXCollectionPath& aPath,
+        const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process the OpenL(EBrowseAlbum) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowseAlbumL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process the OpenL(EBrowsePlaylist) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowsePlaylistL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process the OpenL(EBrowseGenre) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowseGenreL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+       CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process the OpenL(EBrowseComposer) command
+    * @param aPath Path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries (Output parameter) collection items containing media properties
+    *                  of all items, returned if opening a group of items
+    * @param aArray (Output parameter) collection items
+    * @return ETrue if the open is for a song, EFalse otherwise
+    */
+    TBool DoOpenBrowseComposerL(const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Process an OpenL command with a EMPXOpenPlaylistOnly open mode
+    * @param aPath path that we want to open
+    * @param aAttrs default attributes to fetch
+    * @return CMPXCollectionPath* which is the new valid browse path
+    */
+    CMPXCollectionPath* DoOpenPlaylistL( const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs );
+
+    /**
+    * Process the MediaL command
+    * @param aPath a path
+    * @param aAttrs Requested attributes to return
+    * @param aEntries collection items containing media properties of all items, returned if opening a group of items
+    */
+    void DoMediaL (const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries);
+
+    /**
+    * Get the plugin title, subtitle, icons for this plugin
+    * @param aAttrs attributes to find
+    * @param aMedia media object
+    */
+    void DoRootMediaL(const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
+
+    /**
+    * Get the media under ALL SONGS category
+    * @param aPath path that leads to a media under ALL SONGS
+    * @param aAttrs attributes of media to find
+    * @param aEntries the media referred by the path
+    * @param aMediaArray media entries contained in the media referred by the path
+    */
+    void DoAllSongsMediaL(const CMPXCollectionPath& aPath,
+                            const TArray<TMPXAttribute>& aAttrs,
+                            CMPXMedia& aEntries,
+                            CMPXMediaArray& aMediaArray);
+
+    /**
+    * Get the media under ARTISTS category
+    * @param aPath path that leads to a media under ARTISTS
+    * @param aAttrs attributes of media to find
+    * @param aEntries the media referred by the path
+    * @param aMediaArray media entries contained in the media referred by the path
+    */
+    void DoArtistMediaL(const CMPXCollectionPath& aPath,
+                          const TArray<TMPXAttribute>& aAttrs,
+                          CMPXMedia& aEntries,
+                          CMPXMediaArray& aMediaArray);
+
+    /**
+    * Get the root media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
+    * @param aAttrs attributes of media to find
+    * @param aRootCategoryId Id of the root media in the category, i.e. all albums,
+    *        ...etc.
+    * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
+    *        EMPXGenre, or EMPXComposer
+    * @param aEntries the media referred by the path
+    */
+    void DoRootCategoryMediaL(const TArray<TMPXAttribute>& aAttrs,
+                               TMPXItemId aRootCategoryId,
+                               TMPXGeneralCategory aCategory,
+                               CMPXMedia& aEntries);
+
+    /**
+    * Get the media under album/playlist/genre/composer category
+    * @param aPath path that leads to a media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
+    * @param aAttrs attributes of media to find
+    * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
+    *        EMPXGenre, or EMPXComposer
+    * @param aEntries the media referred by the path
+    * @param aMediaArray medias contained in the media referred by the path
+    */
+    void DoCategoryMediaL(const CMPXCollectionPath& aPath,
+                           const TArray<TMPXAttribute>& aAttrs,
+                           TMPXGeneralCategory aCategory,
+                           CMPXMedia& aEntries,
+                           CMPXMediaArray& aMediaArray);
+
+    /**
+    * Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm
+    * @param aMedia, media to update
+    * @param aDrmAttributes, bitwise or of the flags we want
+    * @param aLocation, full file path including filename
+    */
+    void DoSetMediaDrmL(CMPXMedia& aMedia, TUint aDrmAttributes, const TDesC& aLocation);
+
+    /**
+    * Add media objects to the array with attributes from song details
+    * @param aPath a path
+    * @param aAttrs requested attributes
+    * @param aEntry media to contain information about the container if it contains
+    *        than one entry
+    * @param aMediaArray array to contain all the media objects added
+    */
+    void GetSongInfoL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
+        CMPXMedia& aEntry, CMPXMediaArray& aMediaArray);
+
+    /**
+    * Add media objects to the array with attributes from song details
+    * @param aAttrs requested attributes
+    * @param aEntryId song ID
+    * @param aPlaylistId corresponding playlist ID, if 0 the attributes will be read from
+    *        the songs table, otherwise they will be read from the playlist table.
+    * @param aEntry media to contain information about the container if it contains
+    *        than one entry
+    */
+    void DoGetSongInfoL(const TArray<TMPXAttribute>& aAttrs, TInt aEntryId, TInt aPlaylistId,
+        CMPXMedia& aEntry);
+
+    /**
+    * Get the collection details from the db
+    * @param aAttrs, attributes to find
+    * @param aMedia, media object
+    */
+    void DoHandleOtherMediaAttributesL(const TArray<TMPXAttribute>& aAttrs,
+        const CMPXCollectionPath& aPath, CMPXMedia& aMedia);
+
+    /**
+    * Remove an item from the collection database using the given path
+    * Note that the selection indices are hidden within the path
+    * @param aPath path to the item to be removed
+    * @param aChangeMsgArray array to store change messages
+    * @return an array of files associated with the removed media entries
+    */
+    CDesCArray* DoRemoveL(const CMPXCollectionPath& aPath,
+        CMPXMessageArray& aChangeMsgArray);
+
+    /**
+    * Remove an item/items from the collection database using the given media properties
+    * @param aMedia: Properties of the item that is to be removed. It may cantain URI only
+    *                or meta data, all of items matched properties will be removed.
+    * @param aDeleteRecord: indicates whether the client has explictly requested
+    *                to delete the records from the database. If ETrue, records
+    *                associated with the media will be deleted from the database;
+    *                if EFalse, whether to mark the records as deleted or to delete
+    *                the records will be based on other deciding factors.
+    */
+    void DoRemoveL(const CMPXMedia& aMedia, TBool aDeleteRecord);
+
+    /**
+    * Remove an item from the collection database using a command
+    * @param aCmd: remove command which contains collection path to the media(s) to be
+    *        removed. This method should be called until all the selected items are
+    *        removed. When that happens, EMPXCommandCompleted flag is set to ETrue.
+    *        see KMPXCommandIdCollectionRemove in mpxcollectioncommanddefs.h
+    */
+    void DoRemovePathL(CMPXCommand& aCmd);
+
+    /**
+    * Remove a media/medias from the collection database using a command
+    * @param aCmd: remove command which contains the media(s) to be removed. This
+    *        will delete the records from the database rather than marking them
+    *        as deleted. Designated caller is MTP.
+    */
+    void DoRemoveMediaL(CMPXCommand& aCmd);
+
+    /**
+    * Remove a media/medias from all songs view
+    * @param aPath, collection path that points to the media items to be removed
+    * @param aSelections, multiple media items selected. This array contains the id
+    *        of the selected media.
+    * @param aUriArray: a descriptor array containing the URI(s) of the deleted file(s)
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void DoRemoveFromAllSongsL(const CMPXCollectionPath& aPath,
+                               const TArray<TMPXItemId>& aSelections,
+                               CDesCArray& aUriArray,
+                               CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media/medias from artists view
+    * @param aPath, collection path that points to the media(s) to be removed
+    * @param aSelections, multiple media items selected. This array contains the id
+    *        of the selected media.
+    * @param aUriArray: a descriptor array to contain the URI of the deleted file
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void DoRemoveFromArtistsL(const CMPXCollectionPath& aPath,
+                              const TArray<TMPXItemId>& aSelections,
+                              CDesCArray& aUriArray,
+                              CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media/medias from artists view
+    * @param aPath, collection path that points to the media(s) to be removed
+    * @param aItemId media item to be removed.
+    * @param aUriArray: a descriptor array to contain the URI of the deleted file
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void RemoveFromArtistsL(const CMPXCollectionPath& aPath,
+                                TUint32 aItemId,
+                                CDesCArray& aUriArray,
+                                CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media entry/entries from albums/genres/composers view
+    * @param aPath, collection path that points to the media entry/entries to be removed
+    * @param aSelections, multiple media entries selected. This array contains the id
+    *        of the selected media.
+    * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
+    *        EMPXComposer
+    * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void DoRemoveFromCategoriesL(const CMPXCollectionPath& aPath,
+                                 const TArray<TMPXItemId>& aSelections,
+                                 TMPXGeneralCategory aCategory,
+                                 CDesCArray& aUriArray,
+                                 CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media entry from albums/genres/composers view
+    * @param aPath, collection path that points to the media entry/entries to be removed
+    * @param aItemId item ID to be removed.
+    * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
+    *        EMPXComposer
+    * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void RemoveFromCategoriesL(const CMPXCollectionPath& aPath,
+                                TUint32 aItemId,
+                                TMPXGeneralCategory aCategory,
+                                CDesCArray& aUriArray,
+                                CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media entry/entries from playlists view
+    * @param aPath, collection path that points to the media(s) to be removed
+    * @param aSelections, multiple medias selected. This array contains the id
+    *        of the selected media.
+    * @param aUriArray: a descriptor array to contain the URI of the deleted file
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void DoRemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
+                                const TArray<TMPXItemId>& aSelections,
+                                CDesCArray& aUriArray,
+                                CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Remove a media entry/entries from playlists view
+    * @param aPath, collection path that points to the media(s) to be removed
+    * @param aItemId item to be removed
+    * @param aIndex item index to be removed
+    * @param aUriArray: a descriptor array to contain the URI of the deleted file
+    * @param aItemChangedMessages: a list of change events as a result of the
+    *        song removals
+    */
+    void RemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
+                                const TMPXItemId& aItemId,
+                                TInt aIndex,
+                                CDesCArray& aUriArray,
+                                CMPXMessageArray& aItemChangedMessages);
+
+    /**
+    * Retrieves URIs associated with the path for file deletion
+    * @param aCmd, command to retrieve associated URIs for the given path. If
+    *        path ends with a particular artist/album/genre/composer, the path
+    *        will be updated to include all songs in that category. If path
+    *        ends with one or more medias in a particular playlist, an array
+    *        of 0 elements will be returned to avoid client deleting them from
+    *        the file system. see KMPXCommandIdCollectionRetrieveUriForDeletion
+    *        defined in mpxcollectioncommanddefs.h
+    */
+    void DoRetrieveUriForDeletionL(CMPXCommand& aCmd);
+
+    /**
+    * Deletes records which have been marked as deleted from the collection
+    * @param aCmd command to cleanup deleted medias.
+    *        see KMPXCommandIdCollectionCleanupDeletedRecords defined in
+    *        mpxcollectioncommanddefs.h
+    */
+    void CleanupDeletedRecordsL(CMPXCommand& aCmd);
+
+    /**
+    * Fetch the duration for a specific category
+    * @param aMedia a media object of which EMPXMediaGeneralDuration is to be
+    *        populated with the duration calculated in this method
+    * @param aFirstCat category of the 1st Id
+    * @param aId id for identifying which category to calculate the duration for
+    * @param aSecondCat category of the 2nd Id
+    * @param aSubId 2nd id for identifying which category to calculate the
+    *        duration for. For example, to calculate the duration of an album of
+    *        a particular artist, 1st Id provided will be the artist Id and the
+    *        2nd Id provided will be the album Id.
+    */
+    TInt DoDurationL(CMPXMedia& aMedia, TMPXGeneralCategory aFirstCat, TMPXItemId aId = 0,
+                      TMPXGeneralCategory aSecondCat = EMPXNoCategory, TMPXItemId aSubId = 0);
+
+    /**
+    * Append a collection level to the collection path
+    * @param aPath, path to append the level to
+    * @param aMedia, media to extract media ids from
+    * @note: Selection will be put on the first song in the collection path
+    */
+    TInt DoAppendLevelL(CMPXCollectionPath& aPath, CMPXMedia& aMedia);
+
+    /**
+    * Append a collection level to the collection path with all songs under the
+    * selected category/categories (e.g. artist/artist-album/album/genre/composer).
+    * Once the level is appended, all songs under the selected category/categories
+    * are selected.
+    * @param aPath, path to append the level to. Path remains unchanged if it's not
+    *        one of the following:
+    *        1) path ends at an artist or selected artists
+    *        2) path ends at an album of an artist or selected albums of an artist
+    *        3) path ends at an album or selected albums
+    *        4) path ends at a genre or selected genres
+    *        5) path ends at a composer or selected composers
+    */
+    void DoAppendLevelL(CMPXCollectionPath& aPath);
+
+    /**
+    * Execute a task step for an asynchronous add
+    */
+    TBool DoAddAsyncL();
+
+    /**
+    * Add a media object to the collection
+    * @param aMedia media to add
+    * @return TUint32 item id of the item added
+    */
+    TUint32 DoAddL(const CMPXMedia& aMedia);
+
+    /**
+    * Add an item into the collection
+    * @param aMedia media to add
+    * @param aMessageArray change message array
+    */
+    TUint32 DoAddItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray,
+                        TBool aBatchCommit = EFalse);
+
+    /**
+    * Set a media object to update the collection
+    * @param aMedia media can be an item or a list. The item is treated as a list
+    *               if it contains a media array
+    */
+    void DoSetL(const CMPXMedia& aMedia);
+
+    /**
+    * Execute a task step for an asynchronous set
+    */
+    TBool DoSetAsyncL();
+
+    /**
+    * Set an item media to update the collection
+    * @param aMedia media to update
+    * @param aMessageArray array to append change messages
+    * @return ETrue if the update is UI visible, EFalse otherwise
+    */
+    CMPXDbActiveTask::TChangeVisibility DoSetItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
+
+    /**
+    * Set the drm properties for an array of medias
+    * @param mediaArray CMPXMediaArray list of medias
+    * @param aAtts attribute list
+    */
+    void DoSetDrmForArrayL(const CMPXMediaArray& mediaArray,
+                            const TArray<TMPXAttribute>& aAttrs);
+
+    /**
+    * Send a change message
+    *
+    * @param aMessage: a change message to be sent
+    */
+    void HandleChangeL(const CMPXMessage& aMessage);
+
+    /**
+    * Construct a CMPXMedia from the array parameter and call HandleChange
+    *
+    * @param aItemChangedMessages: array in the change message to be sent
+    * @param aCommandid command that was executed
+    */
+    void DoHandleChangeL(CMPXMessageArray* aItemChangedMessages,
+                         TMPXCommandId aCommandId = 0 );
+
+    /**
+    * Returns the category for a given browse type.
+    *
+    * @param aBrowseType browse type
+    * @return Category ID
+    */
+    TMPXGeneralCategory CategoryForBrowseType(TMCBrowseType aBrowseType);
+
+    /**
+    * Returns the browse type for a given category ID.
+    *
+    * @param aCategory category ID
+    * @return Browse type
+    */
+    TMCBrowseType BrowseTypeForCategory(TMPXGeneralCategory aCategory);
+
+    /**
+    * Sets the type, category and title attributes in the specified media.
+    *
+    * @param aMedia media instance to be updated
+    * @param aType type attribute value
+    * @param aCategory category attribute value
+    * @param aTitle title attribute value
+    */
+    void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
+        TMPXGeneralCategory aCategory, const TDesC& aTitle);
+
+    /**
+    * Sets the type, category and title attributes in the specified media.
+    *
+    * @param aMedia media instance to be updated
+    * @param aType type attribute value
+    * @param aCategory category attribute value
+    * @param aId ID of the item to the title from
+    */
+    void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
+        TMPXGeneralCategory aCategory, TInt aId);
+
+    /**
+    * Leaving function to handle async op completion
+    * @param aErr error code
+    */
+    void DoHandleOperationCompletedL(TInt aErr);
+
+    /**
+    * Complete a delete operation
+    * Sends out change messages and compacts the database
+    */
+    void DoHandleDeleteCompleteL( CMPXCommand& aCmd );
+
+    /**
+    * Reorder a song in a playlist
+    * @param aCmd command to reoder a song in a playlist
+    *        see KMPXCommandIdReorderPlaylist defined in
+    *        mpxcollectioncommanddefs.h
+    */
+    void DoReorderPlaylistL( const CMPXCommand& aCmd );
+
+    /**
+    * Get total song and playlist count
+    * @param aCmd command to return count
+    *        see KMPXCommandCollectionGetCount defined in
+    *        mpxcollectioncommanddefs.h
+    */
+    void DoGetCollectionCountL( const CMPXCommand& aCmd );
+
+    /**
+    * Get an array of URIs for all songs and playlists in a given db
+    * @param aCmd command to return CDesCArray
+    *        see KMPXCommandCollectionGetURIs defined in
+    *        mpxcollectioncommanddefs.h
+    */
+    void DoGetCollectionUriL( const CMPXCommand& aCmd );
+
+    /**
+    * Perform 1 step of the incremental read operation
+    * @param aCmd Command to process
+    */
+    void DoIncrementalOpenL( const CMPXCommand& aCmd );
+
+    /**
+    * Open the all songs view incrementally
+    * @param aPath path that leads to a media under ALL SONGS
+    * @param aAttrs attributes of media to find
+    * @param aEntries the media referred by the path
+    * @param aMediaArray media entries contained in the media referred by the path
+    */
+    TBool DoOpenIncrementalL( const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
+                              CMPXMedia& aEntries, CMPXMediaArray* aArray);
+
+    /**
+    * Set the attribute list according to current path
+    * @param aPath a path
+    * @param aAttrs attributes array to be filled
+    * @param aSupportedIds array of supported content IDs to be filled
+    */
+    void SetAttributesL( const CMPXCollectionPath& aPath, RArray<TMPXAttribute>& aAttrs,
+                         RArray<TInt>& aSupportedIds );
+
+#ifdef _DEBUG
+    /**
+    * Prints messages for debugging
+    * @param aMessage: message(s) to be printed
+    */
+    void PrintMessagesL(const CMPXMessage& aMessage);
+
+    /**
+    * Prints a single message for debugging
+    * @param aMessage: a message to be printed
+    */
+    void PrintMessage(const CMPXMessage& aMessage);
+#endif // _DEBUG
+
+private:
+    // owned member variables
+    RFs                  iFs;
+    CMPXResource*        iResource;
+    CMPXDbHandler*       iDbHandler;
+    CMPXDrmMediaUtility* iDrmMediaUtility;
+    CDesCArrayFlat*      iMusicLibraryMenuTitles;      // titles for each of the menu items
+    CDesCArrayFlat*      iMusicLibraryTitles;          // titles for each of the category views
+    RArray<TInt>         iMusicLibraryMenuIds;         // music library item menu IDs
+    HBufC*               iAllSongsForArtistTitle;
+    HBufC*               iMusicMenuTitle;
+    TBool                iDisablePodcasting;
+    TBool                iMtpInUse;
+    TBool                iRefreshing;
+    CMPXDbActiveTask*    iActiveTask;
+    RArray<TMPXItemId>   iSelections;   //selected items in the path
+    TBool iFirstDeleteStep;
+    TBool iAllSongsValid;    //to indicate if there's enough space to get all songs information from collection DB.
+    };
+
+#endif   // MPXDBPLUGIN_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,473 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SQLite queries for MPX collection db
+*
+*/
+
+
+#ifndef MPXDBPLUGINQUERIES_H
+#define MPXDBPLUGINQUERIES_H
+
+// SQLite queries
+
+// == Music table queries =====================================================
+//
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KMusicCreateTable, "CREATE TABLE Music("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"DbFlag INTEGER,"
+    L"VolumeId INTEGER,"
+    L"Title TEXT COLLATE NOCASE,"
+    L"Artist INTEGER,"
+    L"Art TEXT,"
+    L"Deleted INTEGER DEFAULT 0,"
+    L"Location TEXT,"
+    L"AlbumTrack INTEGER,"
+    L"PlayCount INTEGER DEFAULT 0,"
+    L"TimeAdded TEXT,"
+    L"TimePlayed TEXT DEFAULT '',"
+    L"Duration INTEGER,"
+    L"Sync INTEGER DEFAULT 0,"
+    L"Modified INTEGER DEFAULT 0,"
+    L"Album INTEGER,"
+    L"Genre INTEGER,"
+    L"Composer INTEGER,"
+    L"ReleaseDate TEXT DEFAULT '',"
+    L"Rating INTEGER,"
+    L"Comment TEXT,"
+    L"Copyright TEXT,"
+    L"Url TEXT,"
+    L"DRM INTEGER,"
+    L"LastPlayPosition INTEGER DEFAULT 0,"
+    L"SampleRate INTEGER,"
+    L"BitRate INTEGER,"
+    L"NumChannels INTEGER,"
+    L"Codec INTEGER,"
+    L"MimeType TEXT,"
+    L"MTPDrmStatus INTEGER," 
+    L"AlbumArtist TEXT,"
+    L"ContainEmbeddedArt INTEGER DEFAULT 0,"
+    L"AbstractAlbum INTEGER)");
+
+#else
+_LIT(KMusicCreateTable, "CREATE TABLE Music("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"DbFlag INTEGER,"
+    L"VolumeId INTEGER,"
+    L"Title TEXT COLLATE NOCASE,"
+    L"Artist INTEGER,"
+    L"Art TEXT,"
+    L"Deleted INTEGER DEFAULT 0,"
+    L"Location TEXT,"
+    L"AlbumTrack INTEGER,"
+    L"PlayCount INTEGER DEFAULT 0,"
+    L"TimeAdded TEXT,"
+    L"TimePlayed TEXT DEFAULT '',"
+    L"Duration INTEGER,"
+    L"Sync INTEGER DEFAULT 0,"
+    L"Modified INTEGER DEFAULT 0,"
+    L"Album INTEGER,"
+    L"Genre INTEGER,"
+    L"Composer INTEGER,"
+    L"ReleaseDate TEXT DEFAULT '',"
+    L"Rating INTEGER,"
+    L"Comment TEXT,"
+    L"Copyright TEXT,"
+    L"Url TEXT,"
+    L"DRM INTEGER,"
+    L"LastPlayPosition INTEGER DEFAULT 0,"
+    L"SampleRate INTEGER,"
+    L"BitRate INTEGER,"
+    L"NumChannels INTEGER,"
+    L"Codec INTEGER,"
+    L"MimeType TEXT,"
+    L"MTPDrmStatus INTEGER)");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+_LIT(KMusicDropTable,"DROP TABLE Music");
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KMusicCheckTable,"SELECT UniqueId,Title,Location,Artist,Album,AlbumTrack,Genre,Composer,Duration,ReleaseDate,TimeAdded,PlayCount,TimePlayed,Rating,Comment,Copyright,Art,DbFlag,Sync,Modified,Deleted,Url,DRM,LastPlayPosition,SampleRate,BitRate,VolumeId,NumChannels,Codec,MimeType,MTPDrmStatus,AlbumArtist,ContainEmbeddedArt,AbstractAlbum FROM Music");
+#else
+_LIT(KMusicCheckTable,"SELECT UniqueId,Title,Location,Artist,Album,AlbumTrack,Genre,Composer,Duration,ReleaseDate,TimeAdded,PlayCount,TimePlayed,Rating,Comment,Copyright,Art,DbFlag,Sync,Modified,Deleted,Url,DRM,LastPlayPosition,SampleRate,BitRate,VolumeId,NumChannels,Codec,MimeType,MTPDrmStatus FROM Music");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+// indexes
+_LIT(KMusicDeletedIdIndex,"CREATE INDEX IndexMusicDeletedId ON Music(Deleted,UniqueId)");
+_LIT(KMusicDeletedTitleIndex,"CREATE INDEX IndexMusicDeletedTitle ON Music(Deleted,Title)");
+_LIT(KMusicDeletedArtistTitleIndex,"CREATE INDEX IndexMusicArtistDeletedTitle ON Music(Artist,Deleted,Title)");
+_LIT(KMusicDeletedAlbumTitleIndex,"CREATE INDEX IndexMusicAlbumDeletedTitle ON Music(Album,Deleted,Title)");
+_LIT(KMusicDeletedAlbumTrackTitleIndex,"CREATE INDEX IndexMusicAlbumDeletedTrackTitle ON Music(Album,Deleted,AlbumTrack,Title)");
+_LIT(KMusicDeletedGenreTitleIndex,"CREATE INDEX IndexMusicGenreDeletedTitle ON Music(Genre,Deleted,Title)");
+_LIT(KMusicDeletedComposerTitleIndex,"CREATE INDEX IndexMusicComposerDeletedTitle ON Music(Composer,Deleted,Title)");
+
+_LIT(KQueryMusicInsert, "INSERT INTO :dbname.Music(%S) VALUES(%S)");
+_LIT(KQueryMusicUpdate, "UPDATE :dbname.Music SET %S WHERE UniqueId=%u");
+_LIT(KQueryMusicDelete, "DELETE FROM :dbname.Music WHERE UniqueId=%u");
+_LIT(KQueryMusicDeleteUpdate, "UPDATE :dbname.Music SET Deleted=1 WHERE UniqueId=%u");
+_LIT(KQueryMusicDeleteForCategory, "UPDATE :dbname.Music SET Deleted=0 WHERE %S=%u");
+_LIT(KQueryMusicCleanup, "DELETE FROM :dbname.Music WHERE Deleted=1");
+
+// Note: The no categories queries below only retrieve a limited number of fields from the Music table
+//       as opposed to *. This is an optimization that matches the DBMS version of the plugin and assumes
+//       that the client only requests those fields. From the C++ code perspective there is no difference
+//       in processing as the five fields in question reside at the beginning of the table. If the client
+//       is modified to request more attributes then the queries below will have to be changed to return *.
+//
+//       As far as performance goes, the queries that only return six fields are a little faster than
+//       the ones that return *, for example, for a * query that takes 2.1 seconds the equivalent
+//       optimized query is faster by more than 100ms.
+
+_LIT(KQueryMusicGetSong, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.UniqueId=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId");
+
+// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
+// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
+// calculate column number from SELECT fields, first field is column 1 (not 0)
+/*
+_LIT(KQueryMusicGetAllSongs, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
+_LIT(KQueryMusicGetSongsForArtist, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
+_LIT(KQueryMusicGetSongsForAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.AlbumTrack, Music.Title");
+_LIT(KQueryMusicGetSongsForUnknownAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
+_LIT(KQueryMusicGetSongsForArtistAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.AlbumTrack, Music.Title");
+_LIT(KQueryMusicGetSongsForGenre, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Genre=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
+_LIT(KQueryMusicGetSongsForComposer, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Composer=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
+_LIT(KQueryMusicGetRecentlyPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.TimePlayed<>'' AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetMostPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.PlayCount<>0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetRecentlyAdded, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND (julianday(Music.TimeAdded)>julianday('now','-7 days')) AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.TimeAdded DESC");
+*/
+_LIT(KQueryMusicGetAllSongs, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
+_LIT(KQueryMusicGetSongsForArtist, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
+_LIT(KQueryMusicGetSongsForAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 9, 4");
+_LIT(KQueryMusicGetSongsForUnknownAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
+_LIT(KQueryMusicGetSongsForArtistAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 9, 4");
+_LIT(KQueryMusicGetSongsForGenre, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Genre=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
+_LIT(KQueryMusicGetSongsForComposer, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Composer=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
+_LIT(KQueryMusicGetRecentlyPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.TimePlayed<>'' AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 12 DESC LIMIT %u");
+_LIT(KQueryMusicGetMostPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.PlayCount<>0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetRecentlyAdded, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND (julianday(Music.TimeAdded)>julianday('now','-7 days')) AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 11 DESC");
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KQueryMusicGetSongsForAbstractAlbum,"SELECT Music.*,AbstractAlbum.Name FROM :dbname.Music,:dbname.AbstractAlbum WHERE Music.Deleted=0 AND Music.AbstractAlbum=AbstractAlbum.UniqueId AND AbstractAlbum.UniqueId=%u");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KQueryMusicSong, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE %S");
+_LIT(KQueryMusicFindAll, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE %S AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId %S");
+
+// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
+// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
+// calculate column number from SELECT fields, first field is column 1 (not 0)
+/*
+_LIT(KQueryMusicFindAllSortOrderTrack, "ORDER BY Music.AlbumTrack,Music.Title");
+_LIT(KQueryMusicFindAllSortOrderTitle, "ORDER BY Music.Title");
+*/
+_LIT(KQueryMusicFindAllSortOrderTrack, "ORDER BY 9, 4");
+_LIT(KQueryMusicFindAllSortOrderTitle, "ORDER BY 4");
+
+// no categories queries
+_LIT(KQueryMusicGetSongNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryMusicGetAllSongsNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 ORDER BY Title");
+_LIT(KQueryMusicGetSongsForArtistNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Title");
+_LIT(KQueryMusicGetSongsForAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,AlbumTrack FROM :dbname.Music WHERE Deleted=0 AND Album=%u ORDER BY AlbumTrack,Title");
+_LIT(KQueryMusicGetSongsForUnknownAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Album=%u ORDER BY Title");
+_LIT(KQueryMusicGetSongsForArtistAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,AlbumTrack FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u ORDER BY AlbumTrack,Title");
+_LIT(KQueryMusicGetSongsForGenreNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Genre=%u ORDER BY Title");
+_LIT(KQueryMusicGetSongsForComposerNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Composer=%u ORDER BY Title");
+_LIT(KQueryMusicGetRecentlyPlayedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetMostPlayedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetRecentlyAddedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,TimeAdded FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded)>julianday('now','-7 days')) ORDER BY TimeAdded DESC");
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KQueryMusicGetSongsInBlockAsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,'',0,0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title > :title ORDER BY 4 ASC LIMIT :limit");
+_LIT(KQueryMusicGetSongsInBlockDsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,'',0,0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title < :title ORDER BY 4 DESC LIMIT :limit");
+_LIT(KQueryMusicGetSongsAtOffset, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,'',0,0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT :limit OFFSET :offset");
+_LIT(KQueryMusicGetSongsLimited, "Select Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,'',0,0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT %u");
+#else
+_LIT(KQueryMusicGetSongsInBlockAsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title > :title ORDER BY 4 ASC LIMIT :limit");
+_LIT(KQueryMusicGetSongsInBlockDsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title < :title ORDER BY 4 DESC LIMIT :limit");
+_LIT(KQueryMusicGetSongsAtOffset, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT :limit OFFSET :offset");
+_LIT(KQueryMusicGetSongsLimited, "Select Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT %u");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KQueryMusicGetUri, "SELECT Location,VolumeId FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryMusicGetTitle, "SELECT Title FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryMusicGetMusicUris, "SELECT UniqueId,Location FROM :dbname.Music WHERE Deleted=0 ORDER BY UniqueId ASC LIMIT %u");
+_LIT(KQueryMusicGetMusicUrisFrom, "SELECT UniqueId,Location FROM :dbname.Music WHERE Deleted=0 AND UniqueId > %u ORDER BY UniqueId ASC LIMIT %u");
+
+_LIT(KQueryMusicCount, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0");
+_LIT(KQueryMusicAlbum, "SELECT DISTINCT Album FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Album");
+_LIT(KQueryMusicVolume, "SELECT VolumeId FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryMusicVolumeAll, "SELECT VolumeId FROM :dbname.Music WHERE UniqueId=%u");
+_LIT(KQueryMusicInfo, "SELECT * FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryOtherSongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND UniqueId<>%u AND Artist=%u AND Album=%u");
+
+_LIT(KQueryMusicDurationAll, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0");
+_LIT(KQueryMusicDurationArtist, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u");
+_LIT(KQueryMusicDurationAlbum, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Album=%u");
+_LIT(KQueryMusicDurationArtistAlbum, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u");
+_LIT(KQueryMusicDurationGenre, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Genre=%u");
+_LIT(KQueryMusicDurationComposer, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Composer=%u");
+_LIT(KQueryMusicDurationRecentlyPlayed, "SELECT sum(Duration) FROM (SELECT Duration,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u)");
+_LIT(KQueryMusicDurationMostPlayed, "SELECT sum(Duration) FROM (SELECT Duration,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC,TimePlayed DESC LIMIT %u)");
+_LIT(KQueryMusicDurationRecentlyAdded, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded) > julianday('now','-7 days'))");
+
+_LIT(KQueryMusicGetDurationRecentlyPlayed, "SELECT Duration,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetDurationMostPlayed, "SELECT Duration,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC,TimePlayed DESC LIMIT %u");
+_LIT(KQueryMusicGetDurationRecentlyAdded, "SELECT Duration FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded) > julianday('now','-7 days'))");
+
+// Select songs information from music, playlistsongs and playlistsonginfo via playlistid order by playlistsongs's ordinal
+_LIT(KQueryMusicGetAllSongsbyPl,"select mu.UniqueId,mu.DbFlag,mu.VolumeId,mu.Title,mu.Artist,mu.Art,0,mu.Location,pl.UniqueId as PlUId, pl.ordinal from :dbname.music as mu,:pldbname.playlistsongs as pl where mu.Deleted=0 AND mu.uniqueid = pl.songid and pl.playlistid =%u ORDER BY 10");
+_LIT(KQueryMusicGetAllSongsInfobyPl,"SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name,pl.UniqueId as PlUId,pl.ordinal FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer,:pldbname.playlistsongs as pl WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId AND Music.UniqueId=pl .songid and pl .PlaylistId=%u ORDER BY 40");
+
+_LIT(KQuerySongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u");
+_LIT(KQueryMusicGetArtistForAlbum, "SELECT Artist FROM :dbname.Music,:dbname.Artist WHERE Music.Deleted=0 AND Music.Artist=Artist.UniqueId AND Music.Album=%u");
+
+// == Category table queries ==================================================
+//
+_LIT(KCategoryTablePlaceholder, "##table##");
+
+_LIT(KCategoryCreateTable,"CREATE TABLE ##table##("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"Name TEXT COLLATE NOCASE,"
+    L"SongCount INTEGER)");
+
+_LIT(KCategoryDropTable,"DROP TABLE ##table##");
+_LIT(KCategoryCheckTable,"SELECT UniqueId,Name,SongCount FROM ##table##");
+_LIT(KCategoryNameIndex,"CREATE INDEX Index##table##Name ON ##table##(Name)");
+
+_LIT(KQueryCategoryInsert, "INSERT INTO :dbname.##table##(UniqueId,Name,SongCount) VALUES(%u,'%S',%u)");
+_LIT(KQueryCategoryDelete, "DELETE FROM :dbname.##table## WHERE UniqueId=%u");
+
+_LIT(KQueryCategoryCount, "SELECT count(*) FROM :dbname.##table##");
+_LIT(KQueryCategoryItem, "SELECT * FROM :dbname.##table## WHERE UniqueId=%u");
+_LIT(KQueryCategoryItemBySongId, "SELECT ##table##.* FROM :dbname.##table##,:dbname.Music WHERE Music.Deleted=0 AND Music.UniqueId=%u AND ##table##.UniqueId=Music.%S");
+_LIT(KQueryCategoryAll, "SELECT * FROM :dbname.##table## ORDER BY Name");
+_LIT(KQueryCategoryItems, "SELECT * FROM :dbname.##table## WHERE %S ORDER BY Name ASC");
+_LIT(KQueryCategorySongCount, "SELECT SongCount FROM :dbname.##table## WHERE UniqueId=%u");
+_LIT(KQueryCategorySubcategoryItems, "SELECT Album.* FROM :dbname.Album,:dbname.Music WHERE Music.Deleted=0 AND Music.Artist=%u AND Album.UniqueId=Music.Album ORDER BY Name");
+
+_LIT(KQueryCategoryIncrementSongCount, "UPDATE :dbname.##table## SET SongCount=SongCount+1 WHERE UniqueId=%u");
+_LIT(KQueryCategoryDecrementSongCount, "UPDATE :dbname.##table## SET SongCount=SongCount-1 WHERE UniqueId=%u");
+_LIT(KQueryCategoryGetSongCount, "SELECT SongCount FROM :dbname.##table## WHERE UniqueId=%u");
+
+// == Auxiliary table queries =================================================
+//
+_LIT(KAuxiliaryCreateTable, "CREATE TABLE Auxiliary("
+    L"Id INTEGER,"
+    L"Version TEXT,"
+    L"TimeRefreshed TEXT,"
+    L"TimeSynced TEXT,"
+    L"Corrupt INTEGER DEFAULT 0,"
+    L"SaveDeletedRecordCount INTEGER DEFAULT 0)");
+_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)");
+#else 
+_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.4.0',%u)");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+_LIT(KQueryAuxiliarySetTime, "UPDATE :dbname.Auxiliary SET TimeRefreshed='%S', Corrupt=0");
+_LIT(KQueryAuxiliaryGetTime, "SELECT TimeRefreshed FROM :dbname.Auxiliary");
+_LIT(KQueryAuxiliarySetCorrupt, "UPDATE :dbname.Auxiliary SET Corrupt=%u");
+_LIT(KQueryAuxiliaryGetCorrupt, "SELECT Corrupt FROM :dbname.Auxiliary");
+_LIT(KQueryAuxiliaryGetCount, "SELECT SaveDeletedRecordCount FROM :dbname.Auxiliary");
+_LIT(KQueryAuxiliarySetCount, "UPDATE :dbname.Auxiliary SET SaveDeletedRecordCount=%u");
+_LIT(KQueryAuxiliaryGetId, "SELECT Id FROM :dbname.Auxiliary");
+_LIT(KQueryAuxiliarySetId, "UPDATE :dbname.Auxiliary SET Id=%u");
+
+// == Playlist table queries ==================================================
+//
+_LIT(KPlaylistCreateTable, "CREATE TABLE Playlist("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"VolumeId INTEGER,"
+    L"DbFlag INTEGER,"
+    L"Sync INTEGER,"
+    L"Name TEXT COLLATE NOCASE,"
+    L"Uri TEXT,"
+    L"Time TEXT)");
+_LIT(KPlaylistDropTable,"DROP TABLE Playlist");
+_LIT(KPlaylistCheckTable, "SELECT UniqueId,Name,Uri,VolumeId,Sync,DbFlag,Time FROM Playlist");
+_LIT(KPlaylistNameIndex,"CREATE INDEX IndexPlaylistName ON Playlist(Name)");
+
+_LIT(KQueryPlaylistInsert, "INSERT INTO :dbname.Playlist(UniqueId,Name,Uri,VolumeId,Sync,DbFlag,Time) VALUES(%u,'%S','%S',%u,0,%u,'%S')");
+_LIT(KQueryPlaylistUpdate, "UPDATE :dbname.Playlist SET %S WHERE UniqueId=%u");
+_LIT(KQueryPlaylistUpdateTime, "UPDATE :dbname.Playlist SET Time='%S' WHERE UniqueId=%u");
+_LIT(KQueryPlaylistUpdateTimeForSong, "UPDATE :dbname.Playlist SET Time='%S' WHERE UniqueId IN (SELECT DISTINCT PlaylistId FROM :dbname.PlaylistSongs WHERE SongId=%u)");
+_LIT(KQueryPlaylistDeleteAll, "DELETE FROM :dbname.Playlist");
+_LIT(KQueryPlaylistDelete, "DELETE FROM :dbname.Playlist WHERE UniqueId=%u");
+
+_LIT(KQueryPlaylistCount, "SELECT count(*) FROM :dbname.Playlist");
+_LIT(KQueryPlaylistGetAll, "SELECT * FROM :dbname.Playlist ORDER BY Name ASC");
+_LIT(KQueryPlaylistGet, "SELECT * FROM :dbname.Playlist WHERE UniqueId=%u");
+_LIT(KQueryPlaylistDuration, "SELECT sum(Music.Duration) FROM :dbname.Music,:dbname.Playlist,:dbname.PlaylistSongs WHERE Music.UniqueId=PlaylistSongs.SongId AND PlaylistSongs.PlaylistId=%u");
+_LIT(KQueryPlaylistId, "SELECT UniqueId FROM :dbname.Playlist WHERE Uri='%S'");
+_LIT(KQueryLikePlaylistId, "SELECT UniqueId FROM :dbname.Playlist WHERE Uri LIKE '%%%%%S%%%%' ESCAPE '\\'");
+_LIT(KQueryPlaylistDriveId, "SELECT VolumeId FROM :dbname.Playlist WHERE UniqueId=%u");
+_LIT(KQueryPlaylistItems, "SELECT * FROM :dbname.Playlist WHERE %S ORDER BY Name ASC");
+_LIT(KQueryPlaylistGetForSong, "SELECT DISTINCT PlaylistId FROM :dbname.PlaylistSongs WHERE SongId=%u");
+_LIT(KQueryPlaylistFileCount, "SELECT count(*) FROM :dbname.Playlist WHERE Uri LIKE '%%.m3u'");
+//see "Efficient Use of Symbinan SQL How-To Document" for details about following queries:
+_LIT(KQueryPlaylistGetFileUris, "SELECT UniqueId,Uri FROM :dbname.Playlist WHERE Uri LIKE '%%%%.m3u' ORDER BY UniqueId ASC LIMIT %u");
+_LIT(KQueryPlaylistGetFileUrisFrom, "SELECT UniqueId,Uri FROM :dbname.Playlist WHERE Uri LIKE '%%%%.m3u' AND UniqueId > %u ORDER BY UniqueId ASC LIMIT %u");
+
+// == PlaylistSongs table queries =============================================
+//
+_LIT(KPlaylistSongsCreateTable, "CREATE TABLE PlaylistSongs("
+    L"UniqueId INTEGER PRIMARY KEY AUTOINCREMENT,"
+    L"SongId INTEGER,"
+    L"PlaylistId INTEGER,"
+    L"Ordinal INTEGER)");
+_LIT(KPlaylistSongsDropTable,"DROP TABLE PlaylistSongs");
+_LIT(KPlaylistSongsCheckTable, "SELECT UniqueId,SongId,PlaylistId,Ordinal FROM PlaylistSongs");
+
+_LIT(KQueryPlaylistSongsInsert, "INSERT INTO :dbname.PlaylistSongs(PlaylistId,SongId,Ordinal) VALUES(%u,%u,%u)");
+_LIT(KQueryPlaylistSongsUpdate, "UPDATE :dbname.PlaylistSongs SET SongId=%u WHERE SongId=%u");
+_LIT(KQueryPlaylistSongsUpdatePlaylistId, "UPDATE :dbname.PlaylistSongs SET PlaylistId=%u WHERE PlaylistId=%u");
+_LIT(KQueryPlaylistSongsDelete, "DELETE FROM :dbname.PlaylistSongs WHERE SongId=%u");
+_LIT(KQueryPlaylistSongsDeleteAll, "DELETE FROM :dbname.PlaylistSongs");
+_LIT(KQueryPlaylistSongsDeletePlaylist, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u");
+_LIT(KQueryPlaylistSongsDeleteSong, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u");
+_LIT(KQueryPlaylistSongsDeleteSongOrdinal, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u AND Ordinal=%u");
+_LIT(KQueryPlaylistSongsDeleteForCategory, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistSongs.SongId=Music.UniqueId AND Music.%S=%u");
+_LIT(KQueryPlaylistSongsDeleteForArtistAlbum, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistSongs.SongId=Music.UniqueId AND Music.Artist=%u AND Music.Album=%u");
+
+_LIT(KQueryPlaylistSongsCount, "SELECT count(*) FROM :dbname.music as m,:pldbname.Playlistsongs as pl WHERE pl.PlaylistId=%u AND m.UniqueId=pl.SongId AND m.Deleted=0");
+_LIT(KQueryPlaylistSongsPlaylistSongCount, "SELECT count(*) FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u");
+_LIT(KQueryPlaylistSongsSongCount, "SELECT count(*) FROM :dbname.PlaylistSongs WHERE SongId=%u");
+_LIT(KQueryPlaylistSongsGetSongs, "SELECT UniqueId,SongId,Ordinal FROM :dbname.PlaylistSongs WHERE PlaylistId=%u ORDER BY Ordinal");
+
+// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
+// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
+// calculate column number from SELECT fields, first field is column 1 (not 0)
+//_LIT(KQueryPlaylistSongsGetSong, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.PlaylistId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId ORDER BY PlaylistSongs.Ordinal");
+_LIT(KQueryPlaylistSongsGetSong, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.PlaylistId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId ORDER BY 4");
+_LIT(KQueryPlaylistSongsGetSongsInfo, " SELECT PlaylistSongs.*,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.SongId=PlaylistSongInfo.SongId AND PlaylistSongs.PlaylistId=%u ORDER BY 4");
+
+_LIT(KQueryPlaylistSongsGetSongInfo, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.UniqueId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId");
+
+_LIT(KQueryPlaylistSongsUpdateSongOrdinalAfterDelete, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal-1 WHERE PlaylistId=%u AND Ordinal>%u");
+_LIT(KQueryPlaylistSongsUpdateSongOrdinal, "UPDATE :dbname.PlaylistSongs SET Ordinal=%u WHERE SongId=%u");
+_LIT(KQueryPlaylistSongsMoveSongUp, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal+1 WHERE PlaylistId=%u AND Ordinal>=%u AND Ordinal<%u");
+_LIT(KQueryPlaylistSongsMoveSongDown, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal-1 WHERE PlaylistId=%u AND Ordinal<=%u AND Ordinal>%u");
+
+// == PlaylistSongInfo table queries ==========================================
+//
+_LIT(KPlaylistSongInfoCreateTable, "CREATE TABLE PlaylistSongInfo("
+    L"SongId INTEGER PRIMARY KEY,"
+    L"VolumeId INTEGER,"
+    L"DbFlag INTEGER,"
+    L"Uri TEXT,"
+    L"Title TEXT COLLATE NOCASE)");
+_LIT(KPlaylistSongInfoDropTable,"DROP TABLE PlaylistSongInfo");
+_LIT(KPlaylistSongInfoCheckTable, "SELECT SongId,VolumeId,DbFlag,Uri,Title FROM PlaylistSongInfo");
+
+_LIT(KQueryPlaylistSongInfoInsert, "INSERT INTO :dbname.PlaylistSongInfo(SongId,Uri,Title,VolumeId,DbFlag) VALUES(%u,'%S','%S',%u,%u)");
+_LIT(KQueryPlaylistSongInfoDelete, "DELETE FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
+_LIT(KQueryPlaylistSongInfoDeleteAll, "DELETE FROM :dbname.PlaylistSongInfo");
+_LIT(KQueryPlaylistSongInfoCleanup, "DELETE FROM :dbname.PlaylistSongInfo WHERE SongId NOT IN (SELECT DISTINCT SongId FROM :dbname.PlaylistSongs)");
+_LIT(KQueryPlaylistSongInfoUpdateTitle, "UPDATE :dbname.PlaylistSongInfo SET Title='%S' WHERE SongId=%u");
+_LIT(KQueryPlaylistSongInfoUpdate, "UPDATE :dbname.PlaylistSongInfo SET SongId=%u,Uri='%S',VolumeId=%u WHERE SongId=%u");
+_LIT(KQueryPlaylistSongInfoUpdateFlags, "UPDATE :dbname.PlaylistSongInfo SET DbFlag=%u WHERE SongId=%u");
+
+_LIT(KQueryPlaylistSongInfoExists, "SELECT SongId FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
+_LIT(KQueryPlaylistSongInfoGet, "SELECT * FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
+
+// == Criteria strings ========================================================
+//
+// Music criteria
+_LIT(KCriterionMusicUniqueId, "Music.UniqueId=%u");
+_LIT(KCriterionMusicNotDeleted, "Music.Deleted=0");
+_LIT(KCriterionMusicArtist, "Music.artist=%u");
+_LIT(KCriterionMusicAlbum, "Music.album=%u");
+_LIT(KCriterionMusicGenre, "Music.genre=%u");
+_LIT(KCriterionMusicComposer, "Music.composer=%u");
+// SQLite requires LIKE statement to include an ESCAPE clause if an escaped percentage
+// or underscore is to be used as regular search text instead of pattern matching
+// characters. See http://www.sqlite.org/lang_expr.html for an explanation. To supprt
+// partial title matching, our goal is to have the following statement as an example:
+//      SELECT * FROM Music WHERE title LIKE '%xyz%' ESCAPE '\'
+// To achieve this, we specify the format to be %%%%%S%%%%. The 1st percentage is the
+// escape character for string formatter to output the 2nd percentage sign. Similiarly
+// for the 3rd, 4th, 6th, 7th, 8th, and 9th. The 5th percentage instructs string formatter
+// to substitute a string, i.e. %S. After subsititution, we will have, for example, %%xyz%%.
+// Because this substituted string will be substituted again into a WHERE clause, we need
+// to escape the percentage signs in order to get %xyz% as the end result.
+_LIT(KCriterionMusicTitle, "Music.title LIKE '%%%%%S%%%%' ESCAPE '\\'");
+_LIT(KCriterionMusicVolume, "Music.VolumeId=%u");
+_LIT(KCriterionMusicLocation, "Music.Location='%S'");
+_LIT(KCriterionMusicSync, "Music.Sync=%u");
+_LIT(KCriterionMusicDeleted, "Music.Deleted=%u");
+_LIT(KCriterionMusicModified, "Music.Modified=%u");
+
+// Category criteria
+_LIT(KCriterionCategoryUniqueId, "##table##.UniqueId=%u");
+_LIT(KCriterionCategoryName, "##table##.Name LIKE '%%%%%S%%%%' ESCAPE '\\'");
+
+// Playlist criteria
+_LIT(KCriterionPlaylistUniqueId, "UniqueId=%u");
+_LIT(KCriterionPlaylistVolumeId, "VolumeId=%u");
+_LIT(KCriterionPlaylistTitle, "Name='%S'");
+_LIT(KCriterionPlaylistLikeTitle, "Name LIKE '%%%%%S%%%%' ESCAPE '\\'");
+_LIT(KCriterionPlaylistUri, "Uri='%S'");
+_LIT(KCriterionPlaylistSync, "Sync=%u");
+_LIT(KCriterionPlaylistTime, "Time='%S'");
+
+// PlaylistSongs criteria
+_LIT(KCriterionPlaylistSongId, "PlaylistSongs.SongId=%u");
+
+// == Album table queries ==========================================
+//
+_LIT(KAlbumCreateTable,"CREATE TABLE Album("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"Name TEXT COLLATE NOCASE,"
+    L"SongCount INTEGER,"
+    L"Artist INTEGER,"
+	L"Art TEXT)");
+
+_LIT(KAlbumCheckTable,"SELECT UniqueId,Name,SongCount,Artist,Art FROM Album");
+
+_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,Name,SongCount,Artist,Art) VALUES(%u,'%S',%u,%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 2");
+
+// == Artist table queries ==========================================
+//
+_LIT(KArtistCreateTable,"CREATE TABLE Artist("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"Name TEXT COLLATE NOCASE,"
+    L"SongCount INTEGER,"
+    L"Art TEXT)");
+
+_LIT(KArtistCheckTable,"SELECT UniqueId,Name,SongCount,Art FROM Artist");
+
+_LIT(KQueryArtistInsert, "INSERT INTO :dbname.Artist(UniqueId,Name,SongCount,Art) VALUES(%u,'%S',%u,'%S')");
+_LIT(KQueryArtistUpdate, "UPDATE :dbname.Artist SET %S WHERE UniqueId=%u");
+
+_LIT(KQueryArtistAll, "SELECT Artist.* FROM :dbname.Artist ORDER BY 2");
+_LIT(KQueryArtistName, "SELECT Artist.Name FROM :dbname.Artist WHERE UniqueId=%u");
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// == AbstractAlbum table queries ==========================================
+//
+_LIT(KAbstractAlbumCreateTable,"CREATE TABLE AbstractAlbum("
+    L"UniqueId INTEGER PRIMARY KEY,"
+    L"Name TEXT COLLATE NOCASE,"
+    L"AlbumArtist TEXT,"
+    L"Genre TEXT,"
+    L"SongCount INTEGER,"
+    L"VolumeId INTEGER)");
+
+_LIT(KAbstractAlbumCheckTable,"SELECT UniqueId,Name,SongCount,VolumeId FROM AbstractAlbum");
+_LIT(KCriterionAbstractAlbumVolumeId, "VolumeId=%u");
+_LIT(KQueryAbstractAlbumInsert, "INSERT INTO :dbname.AbstractAlbum(UniqueId,Name,AlbumArtist,Genre,SongCount,VolumeId) VALUES(%u,'%S','%S','%S',%u,%u)");
+_LIT(KQueryAbstractAlbumUpdate, "UPDATE :dbname.AbstractAlbum SET %S WHERE UniqueId=%u");
+_LIT(KCriterionCategoryVolumeId, "SELECT VolumeId FROM :dbname.AbstractAlbum WHERE UniqueId=%u");
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+#endif // MPXDBPLUGINQUERIES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/inc/mpxdbutil.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The class MPXDbUtil which contains utilities functions
+*
+*/
+
+
+#ifndef MPXDBUTIL_H
+#define MPXDBUTIL_H
+
+// INCLUDES
+#include <mpxmediageneraldefs.h>
+#include "mpxcollectiondbstd.h"
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class CMPXMediaArray;
+
+// CLASS DECLARATION
+
+/**
+* This static class contains utilities functions used by Music Collection
+*
+* @lib MPXDbPlugin.lib
+*/
+class MPXDbUtil
+    {
+    public:
+        /**
+        * Filter out duplicated Ids in the array
+        * @param aIds array containing Ids to be filtered
+        * @param aFilteredIds filtered Ids without duplicates, generated from
+        *        the input array
+        */
+        static void FilterDuplicatedIdsL(const TArray<TUint32>& aIds,
+            RArray<TUint32>& aFilteredIds);
+
+        /**
+        * Returns the table name for a specified category
+        * @param aCategory identifies the category
+        * @return corresponding table name
+        */
+        static TPtrC TableNameForCategoryL(TMPXGeneralCategory aCategory);
+
+        /**
+        * Returns the music field name for a specified category
+        * @param aCategory identifies the category
+        * @return corresponding field name
+        */
+        static TPtrC MusicFieldNameForCategoryL(TMPXGeneralCategory aCategory);
+    };
+
+#endif // MPXDBUTIL_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/rom/mpxsqlitedbhgplugin.iby	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project mpxsqlitedbhgplugin
+*
+*/
+
+
+
+#ifndef MPXSQLITEDBHGPLUGIN_IBY
+#define MPXSQLITEDBHGPLUGIN_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+ECOM_PLUGIN( mpxsqlitedbhgplugin.dll, 10207C85.rsc )
+SCALABLE_IMAGE( APP_RESOURCE_DIR, APP_RESOURCE_DIR, mpxdbhgplugin )
+
+#endif // MPXSQLITEDBHGPLUGIN_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/rom/mpxsqlitedbhgpluginrsc.iby	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project mpxsqlitedbhgplugin
+*
+*/
+
+
+
+#ifndef MPXSQLITEDBPLUGINHGRSC_IBY
+#define MPXSQLITEDBPLUGINHGRSC_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+data=DATAZ_\APP_RESOURCE_DIR\mpxcollectiondbhgres.rsc     APP_RESOURCE_DIR\mpxcollectiondbhgres.rsc
+
+#endif // MPXSQLITEDBPLUGINHGRSC_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/rom/rom.pri	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+symbian {
+MP_IBY_DIR = $$section(PWD,":",1)
+
+BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/mpxsqlitedbhgplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(mpxsqlitedbhgplugin.iby)" \
+                             "$$MP_IBY_DIR/mpxsqlitedbhgpluginrsc.iby CORE_APP_LAYER_IBY_EXPORT_PATH(mpxsqlitedbhgpluginrsc.iby)"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxcollectiondbmanager.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is responsible for managing all of music collection
+*                databases.
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include "mpxcollectiondbdef.h"
+#include "mpxcollectiondbmanager.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXCollectionDbManager* CMPXCollectionDbManager::NewL(
+    RFs& aFs)
+    {
+    MPX_FUNC("CMPXCollectionDbManager::NewL");
+
+    CMPXCollectionDbManager* self = CMPXCollectionDbManager::NewLC(aFs);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXCollectionDbManager* CMPXCollectionDbManager::NewLC(
+    RFs& aFs)
+    {
+    MPX_FUNC("CMPXCollectionDbManager::NewLC");
+
+    CMPXCollectionDbManager* self = new (ELeave) CMPXCollectionDbManager(aFs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXCollectionDbManager::~CMPXCollectionDbManager()
+    {
+    MPX_FUNC("CMPXCollectionDbManager::~CMPXCollectionDbManager");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXCollectionDbManager::CMPXCollectionDbManager(
+    RFs& aFs) :
+    CMPXDbManager(aFs)
+    {
+    MPX_FUNC("CMPXCollectionDbManager::CMPXCollectionDbManager");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXCollectionDbManager::ConstructL()
+    {
+    MPX_FUNC("CMPXCollectionDbManager::ConstructL");
+    CMPXDbManager::ConstructL(TFileName(KMCDbFile));
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,463 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the category tables:
+*                Artist, Album, Genre, Composer and AbstractAlbum
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include <bautils.h>
+#include <mpxmediamusicdefs.h>
+#include "mpxdbabstractalbum.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbmanager.h"
+#include "mpxdbcommonutil.h"
+#include "mpxcollectiondbstd.h"
+#include "mpxdbcommondef.h"
+#include "mpxcollectiondbdef.h"
+
+#ifdef RD_MPX_TNM_INTEGRATION
+_LIT( KImageFileType, "image/jpeg" );
+#endif //RD_MPX_TNM_INTEGRATION
+
+
+// CONSTANTS
+
+
+
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAbstractAlbum* CMPXDbAbstractAlbum::NewL(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::NewL");
+
+    CMPXDbAbstractAlbum* self = CMPXDbAbstractAlbum::NewLC(aDbManager, aCategory);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAbstractAlbum* CMPXDbAbstractAlbum::NewLC(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::NewLC");
+
+    CMPXDbAbstractAlbum* self = new (ELeave) CMPXDbAbstractAlbum(aDbManager, aCategory);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAbstractAlbum::~CMPXDbAbstractAlbum()
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::~CMPXDbAbstractAlbum");
+#ifdef RD_MPX_TNM_INTEGRATION
+    delete iTNManager;
+#endif //RD_MPX_TNM_INTEGRATION
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::GetDriveIdL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbAbstractAlbum::GetDriveIdL(
+    TUint32 aAbstractAlbumId)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::GetDriveIdL");
+    return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+        ExecuteIntQueryL(KCriterionCategoryVolumeId, aAbstractAlbumId));
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::AddItemL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAbstractAlbum::AddItemL(
+    const TDesC& aName,
+    const TDesC& aAlbumArtist,
+    const TDesC& aGenre,
+    TInt aDriveId,
+    TBool& aNewRecord,
+    TBool aCaseSensitive)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::AddItemL");
+
+    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAbstractAlbum,
+        aName, aCaseSensitive));
+  
+    if ( aNewRecord )
+        {
+        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+        HBufC* albumartist = MPXDbCommonUtil::ProcessSingleQuotesLC(aAlbumArtist);
+        HBufC* genre = MPXDbCommonUtil::ProcessSingleQuotesLC(aGenre);
+        
+        iDbManager.ExecuteQueryL(aDriveId, KQueryAbstractAlbumInsert, rowId, name, albumartist, genre, 0, MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), aDriveId));
+        CleanupStack::PopAndDestroy(3, name);        
+        }
+    else
+        {
+        // increment the number of songs for the category
+        HBufC* query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
+        CleanupStack::PopAndDestroy(query);
+        }
+
+    return rowId;
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::DecrementSongsForCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::DecrementSongsForCategoryL(
+    const TUint32 aId,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TBool& aItemExist,
+    TBool aMtpInUse)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::DecrementSongsForCategoryL");
+    
+    TInt songCount = GetSongsCountL(aDriveId, aId);
+       // if just one song uses this category. Use <= just in case
+       //while MTP connection, just decrease songCount in DB, do not do deletion.
+    if ( songCount > 0 )
+        {
+        aItemExist = ETrue;
+        // decrement the number of songs for the category
+        HBufC* query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, aId);
+        CleanupStack::PopAndDestroy(query);
+        songCount--;
+        }
+    
+    if ((songCount == 0) && !aMtpInUse)
+        {
+        HBufC* uri = DeleteAbstractAlbumL(aId, aDriveId);
+        MPX_DEBUG1("CMPXDbAbstractAlbum::DeleteAbstractAlbumL,implicitly delete AbstractAlbum Object when it has 0 references");  
+        aItemExist = EFalse;
+        if (aItemChangedMessages)
+            {
+            // add the item changed message
+            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
+                EMPXAbstractAlbum, KDBPluginUid);   
+            }
+        delete uri;
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::DeleteAbstractAlbumL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbAbstractAlbum::DeleteAbstractAlbumL(
+    TUint32 aAbstractAlbumId, TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::DeleteAbstractAlbumL");
+
+    //before delete category, get the abstract album path
+    HBufC* uri = GetNameL(aAbstractAlbumId);
+    // delete the category
+    if (uri)
+        {
+        CleanupStack::PushL(uri);
+         
+    if (aDriveId)
+        DeleteCategoryL(aAbstractAlbumId, aDriveId);
+    else
+        {
+        TInt drive = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+            ExecuteIntQueryL(KCriterionCategoryVolumeId, aAbstractAlbumId));
+        DeleteCategoryL(aAbstractAlbumId, drive);
+        }
+//delete abstract album .alb from TN table
+#ifdef RD_MPX_TNM_INTEGRATION
+        // remove from thumbnail database table
+        CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(
+                *uri, KImageFileType );
+        iTNManager->DeleteThumbnails( *source );
+        CleanupStack::PopAndDestroy( source );
+#endif //RD_MPX_TNM_INTEGRATION
+
+       
+        //delete abstract album .alb file from file system
+        RFs rFs;
+        User::LeaveIfError( rFs.Connect() );
+        CleanupClosePushL( rFs );
+
+        TInt err = BaflUtils::DeleteFile(rFs, *uri);
+        if(KErrNone != err)
+            {
+            MPX_DEBUG2("CMPXDbAbstractAlbum::DeleteAbstractAlbumL,File not deleted from file system with err=%d", err);
+            }
+
+        CleanupStack::PopAndDestroy( &rFs );
+        }
+
+    CleanupStack::Pop(uri);
+    return uri;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::UpdateItemL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::UpdateItemL(
+    TUint32 aId,
+    const CMPXMedia& aMedia,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::UpdateItemL");
+
+    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EAbstractAlbumFieldCount);
+    CleanupStack::PushL(fields);
+    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EAbstractAlbumFieldCount);
+    CleanupStack::PushL(values);
+
+    // process the media parameter and construct the fields and values array
+    GenerateAbstractAlbumFieldsValuesL(aMedia, *fields, *values);
+
+    // construct the SET string
+    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
+
+    if (setStr->Length())
+        {
+        // execute the query
+        iDbManager.ExecuteQueryL(aDriveId, KQueryAbstractAlbumUpdate, setStr, aId);
+        MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
+                EMPXAbstractAlbum, KDBPluginUid, ETrue, 0 );
+        }
+
+    CleanupStack::PopAndDestroy(setStr);
+    CleanupStack::PopAndDestroy(values);
+    CleanupStack::PopAndDestroy(fields);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+     MPX_FUNC("CMPXDbAbstractAlbum::UpdateMediaL");
+
+       TInt count(aAttrs.Count());
+       for (TInt i = 0; i < count; ++i)
+           {
+           TInt contentId(aAttrs[i].ContentId());
+           TUint attributeId(aAttrs[i].AttributeId());
+
+           if (contentId == KMPXMediaIdGeneral)
+               {
+               if (attributeId & EMPXMediaGeneralId)
+                   {
+                   aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+                       aRecord.ColumnInt64(EAbstractAlbumUniqueId));
+                   }
+               if (attributeId & EMPXMediaGeneralTitle)
+                   {
+                   TPtrC title(MPXDbCommonUtil::GetColumnTextL(aRecord, EAbstractAlbumName));
+                   aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
+                   MPX_DEBUG2("    AbstractAlbumName[%S]", &title);
+                   }                          
+               if (attributeId & EMPXMediaGeneralCount)
+                   {
+                   TInt songCount = GetSongsCountL(KDbManagerAllDrives,
+                                aRecord.ColumnInt64(EAbstractAlbumUniqueId));
+                   aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
+                   }
+               if (attributeId & EMPXMediaGeneralDrive)
+                   {
+                   TUint32 volId(aRecord.ColumnInt64(EAbstractAlbumVolumeId));
+                   TInt driveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
+
+                   // LTAN-7GH6BZ, crash if eject memory card when adding song to existing AbstractAlbum
+                   // due to special timing issue, it is possible drive number is -1 and create a
+                   // panic when use for TDriveUnit
+                   MPX_DEBUG3("volId = %d, driveId = %d", volId, driveId);
+
+                   // handle possibly delay from framework notification
+                   if (driveId < 0)
+                       {
+                       MPX_DEBUG1("invalid driveId, leave with KErrNotReady");
+                       User::Leave(KErrNotReady);
+                       }
+                   TDriveUnit driveUnit(driveId);
+
+                   aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveUnit.Name());
+
+                   }
+               } // end if contentId == KMPXMediaIdGeneral          
+           else if ( contentId == KMPXMediaIdMusic)
+               {
+               if (attributeId & EMPXMediaMusicAlbumArtist)
+                   {         
+                   TPtrC albumartist(MPXDbCommonUtil::GetColumnTextL(aRecord, EAbstractAlbumArtist));
+                   aMedia.SetTextValueL(KMPXMediaMusicAlbumArtist, albumartist);
+                   
+                  
+                   
+                   MPX_DEBUG2("    albumartist[%S]", &albumartist);
+                   } 
+               if (attributeId & EMPXMediaMusicGenre)
+                   {                 
+                   TPtrC genre(MPXDbCommonUtil::GetColumnTextL(aRecord, EAbstractAlbumGenre));
+                   aMedia.SetTextValueL(KMPXMediaMusicGenre, genre);
+                   MPX_DEBUG2("    Genre[%S]", &genre);
+                   }
+               }
+               
+           } // end for
+       aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+       aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAbstractAlbum);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::GenerateAlbumFieldsValuesL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::GenerateAbstractAlbumFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::GenerateAbstractAlbumFieldsValuesL");
+//support Winlogo use case
+   if (aMedia.IsSupported(KMPXMediaGeneralTitle))
+        {
+        TPtrC truncatedName(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCCategoryName, truncatedName);
+        }
+//support Winlogo use case
+   if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist))
+        {
+        TPtrC truncatedAlbumArtist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbumArtist, truncatedAlbumArtist);
+        }
+   if (aMedia.IsSupported(KMPXMediaMusicGenre))
+        {
+        TPtrC truncatedGenre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen));
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicGenre, truncatedGenre);    
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::CreateTableL");
+
+    // create the table
+    HBufC* query = PreProcessStringLC(KAbstractAlbumCreateTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    // do not create an index on the Name field
+    // as it only slows down the insert/update queries overall
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAbstractAlbum::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::CheckTableL");
+
+    HBufC* query = PreProcessStringLC(KAbstractAlbumCheckTable);
+    TBool check(DoCheckTable(aDatabase, *query));
+    CleanupStack::PopAndDestroy(query);
+
+    return check;
+    }
+
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAbstractAlbum::CMPXDbAbstractAlbum(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory) :
+    CMPXDbCategory(aDbManager, aCategory)
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::CMPXDbAbstractAlbum");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAbstractAlbum::ConstructL()
+    {
+    MPX_FUNC("CMPXDbAbstractAlbum::ConstructL");
+
+    BaseConstructL();
+#ifdef RD_MPX_TNM_INTEGRATION
+    // Create Thumbnail Manager instance. This object is the observer.
+    iTNManager = CThumbnailManager::NewL( *this );
+#endif //RD_MPX_TNM_INTEGRATION
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::ThumbnailReady 
+// Callback but not used here
+// ---------------------------------------------------------------------------
+void CMPXDbAbstractAlbum::ThumbnailPreviewReady( 
+        MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
+    {
+    }
+        
+
+// ---------------------------------------------------------------------------
+// CMPXDbAbstractAlbum::ThumbnailReady
+// Callback but not used here
+// ---------------------------------------------------------------------------
+void CMPXDbAbstractAlbum::ThumbnailReady( TInt /*aError*/, 
+        MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
+    {
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,545 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the category tables:
+*                Artist, Album, Genre and Composer
+*
+*/
+
+
+// INCLUDE FILES
+#include <sqldb.h>
+
+#include <mpxlog.h>
+
+#include "mpxdbcommonutil.h"
+#include "mpxdbcommondef.h"
+#include "mpxdbmanager.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxmediamusicdefs.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbutil.h"
+#include "mpxdbalbum.h"
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAlbum* CMPXDbAlbum::NewL(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbAlbumObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbAlbum::NewL");
+
+    CMPXDbAlbum* self = CMPXDbAlbum::NewLC(aDbManager, aCategory, aObserver);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAlbum* CMPXDbAlbum::NewLC(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbAlbumObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbAlbum::NewLC");
+
+    CMPXDbAlbum* self = new (ELeave) CMPXDbAlbum(aDbManager, aCategory, aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAlbum::~CMPXDbAlbum()
+    {
+    MPX_FUNC("CMPXDbAlbum::~CMPXDbAlbum");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAlbum::CMPXDbAlbum(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbAlbumObserver& aObserver) :
+    CMPXDbCategory(aDbManager, aCategory),
+    iObserver(aObserver)
+    {
+    MPX_FUNC("CMPXDbAlbum::CMPXDbAlbum");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::ConstructL()
+    {
+    MPX_FUNC("CMPXDbAlbum::ConstructL");
+
+    BaseConstructL();
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::AddItemL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAlbum::AddItemL(
+    const TDesC& aName,
+    TUint32 aArtist,
+    const TDesC& aArt,
+    TInt aDriveId,
+    TBool& aNewRecord,
+    TBool aCaseSensitive)
+    {
+    MPX_FUNC("CMPXDbAlbum::AddItemL");
+    
+    // try to find the item first
+    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
+        aName, aCaseSensitive));
+    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
+
+    if (aNewRecord)
+        {      
+        // insert new
+        HBufC* query = PreProcessStringLC(KQueryAlbumInsert);
+        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+		HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
+
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, aArtist, art);
+
+		CleanupStack::PopAndDestroy(art);
+        CleanupStack::PopAndDestroy(name);
+        CleanupStack::PopAndDestroy(query);
+        }
+    else
+        {
+        // retrieve the existing record
+        HBufC* query = NULL;
+        query = PreProcessStringLC(KQueryCategoryItem);
+        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
+        CleanupStack::PopAndDestroy(query);
+		
+        CleanupClosePushL(recordset);
+		
+        if (recordset.Next() != KSqlAtRow)
+            {
+            User::Leave(KErrNotFound);
+	    }
+
+        // Artist
+        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
+	    
+        // the current one is Unknown and the new one is Not Unknown.
+        if ( IsUnknownArtistL( artistId ) && !IsUnknownArtistL( aArtist ) )
+            {
+            _LIT( KFormatArtistId, "Artist=%d" );
+            HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
+            setStr->Des().Format( KFormatArtistId, aArtist );
+        
+            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
+            CleanupStack::PopAndDestroy(setStr);            
+            }
+	        
+        // Album Art
+        TPtrC art(KNullDesC);
+        art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt));
+	
+        // the current one is Unknown and the new one is Not Unknown
+        if ( art == KNullDesC && aArt != KNullDesC )
+            {
+            HBufC* artReplaceSingleQuote = 
+                            MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
+            _LIT( KFormatArt, "Art=\'%S\'" );
+            HBufC* setStr = HBufC::NewLC(256);
+            setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
+
+            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
+            CleanupStack::PopAndDestroy(setStr);
+            CleanupStack::PopAndDestroy(artReplaceSingleQuote);
+            }
+		
+        CleanupStack::PopAndDestroy(&recordset);
+		
+        // increment the number of songs for the category
+        query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
+        CleanupStack::PopAndDestroy(query);
+        }
+
+    return rowId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::DecrementSongsForCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::DecrementSongsForCategoryL(
+    const TUint32 aId,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TBool& aItemExist,
+    const TUint32 aArtist)
+    {
+    MPX_FUNC("CMPXDbAlbum::DecrementSongsForCategoryL");
+
+    // if just one song uses this category. Use <= just in case
+    if (GetSongsCountL(aDriveId, aId) <= 1)
+        {
+        aItemExist = EFalse;
+        // delete the category
+        DeleteCategoryL(aId, aDriveId);
+
+        if (aItemChangedMessages)
+            {
+            // add the item changed message
+            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
+                iCategory, KDBPluginUid);
+            }
+        }
+    else
+        {
+        aItemExist = ETrue;
+        
+        // retrieve the existing record
+        HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId));
+        CleanupStack::PopAndDestroy(query);
+        
+        CleanupClosePushL(recordset);
+        
+        if (recordset.Next() != KSqlAtRow)
+            {
+            User::Leave(KErrNotFound);
+        }
+
+        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
+        
+        CleanupStack::PopAndDestroy(&recordset);
+        
+        // the current artist is equal to deleted song's artist
+        if ( artistId == aArtist )
+            {
+            TUint32 newArtistId = ArtistForAlbumL(aId);
+            
+            _LIT( KFormatArtistId, "Artist=%d" );
+            HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
+            setStr->Des().Format(KFormatArtistId, newArtistId);
+        
+            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
+            CleanupStack::PopAndDestroy(setStr);
+            
+            if (aItemChangedMessages)
+                {
+                // add the item changed message
+                MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
+                    EMPXAlbum, KDBPluginUid, ETrue, 0 );  
+                }
+            }
+
+        // decrement the number of songs for the category
+        query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, aId);
+        CleanupStack::PopAndDestroy(query);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::GetAllCategoryItemsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::GetAllCategoryItemsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL");
+
+    HBufC* query = PreProcessStringLC(KQueryAlbumAll);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    CleanupClosePushL(recordset);
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::UpdateItemL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::UpdateItemL(
+    TUint32 aId, 
+    const CMPXMedia& aMedia, 
+    TInt aDriveId, 
+    CMPXMessageArray* aItemChangedMessages)
+	{
+	MPX_FUNC("CMPXDbAlbum::UpdateItemL");
+
+	CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EAlbumFieldCount);
+	CleanupStack::PushL(fields);
+	CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EAlbumFieldCount);
+	CleanupStack::PushL(values);
+
+	// process the media parameter and construct the fields and values array
+	GenerateAlbumFieldsValuesL(aMedia, *fields, *values);
+
+	// construct the SET string
+	HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
+
+    if (setStr->Length())
+        {
+        // execute the query
+        iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
+        MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
+        		EMPXAlbum, KDBPluginUid, ETrue, 0 );    
+        }
+
+	CleanupStack::PopAndDestroy(setStr);
+	CleanupStack::PopAndDestroy(values);
+	CleanupStack::PopAndDestroy(fields);
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::GetAlbumsCountForArtistL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbAlbum::GetAlbumsCountForArtistL(TUint32 aArtistId)
+	{
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryCategorySubcategoryItems, aArtistId));
+
+    TInt prevId(0);
+    TInt count(0);
+	TInt err(KErrNone);
+	
+    while ((err = recordset.Next()) == KSqlAtRow)
+		{
+		TUint32 rowId(recordset.ColumnInt64(EAlbumUniqueId));
+        if (prevId == rowId)
+            {
+            continue;
+            }
+		
+		count++;
+		prevId = rowId;
+		}
+
+    if (err != KSqlAtEnd)
+        {
+        User::Leave(err);
+        }
+
+	return count;
+
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId)
+	{
+	MPX_FUNC("CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL");
+	
+	return ExecuteSumQueryL(KQuerySongsInArtistAlbum, aArtistId, aAlbumId);
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbAlbum::UpdateMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+        TUint attributeId(aAttrs[i].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            if (attributeId & EMPXMediaGeneralId)
+                {
+                MPX_DEBUG1("    EMPXMediaGeneralId");
+                
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+                    aRecord.ColumnInt64(EAlbumUniqueId));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                MPX_DEBUG1("    EMPXMediaGeneralTitle");
+                
+                TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) );
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
+                    MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName));
+                MPX_DEBUG2("	Album[%S]", &album );
+                }
+            if (attributeId & EMPXMediaGeneralCount)
+                {
+                MPX_DEBUG1("    EMPXMediaGeneralCount");
+
+				TInt songCount = GetSongsCountL(KDbManagerAllDrives,
+					aRecord.ColumnInt64(EAlbumUniqueId));
+                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
+				MPX_DEBUG2("	SongCount[%d]", songCount );
+                }
+            } // end if contentId == KMPXMediaIdGeneral
+		else if ( contentId == KMPXMediaIdMusic )
+			{
+			if (attributeId & EMPXMediaMusicArtist)
+				{				
+				MPX_DEBUG1("	EMPXMediaMusicArtist");
+
+				TPtrC artistName(KNullDesC);
+				
+				// if album is unknown, ignore arist name
+				if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
+					{
+					artistName.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName));
+					}
+				
+				aMedia.SetTextValueL(KMPXMediaMusicArtist, artistName);
+				MPX_DEBUG2("	Artist[%S]", &artistName);
+				}
+
+			if (attributeId & EMPXMediaMusicAlbum)
+				{
+				MPX_DEBUG1("	EMPXMediaMusicAlbum");
+
+				TPtrC albumName(KNullDesC);
+                TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) );
+
+
+				// if album is unknown
+				if ( album != KNullDesC)
+					{
+					albumName.Set(album);
+					}
+
+				aMedia.SetTextValueL(KMPXMediaMusicAlbum, albumName);
+				MPX_DEBUG2("	Album[%S]", &albumName);
+				}
+			if (attributeId & EMPXMediaMusicAlbumArtFileName)
+				{
+				MPX_DEBUG1("	EMPXMediaMusicAlbumArtFileName");
+
+				TPtrC art(KNullDesC);
+				
+				// if album is unknown, ignore album art name
+				if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
+					{
+					art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt));
+					}
+				
+				aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
+				MPX_DEBUG2("	Art[%S]", &art);
+				}
+			}
+		} // end for
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::GenerateAlbumFieldsValuesL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
+	{
+	if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
+		{
+		const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
+		MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
+		}
+		
+	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);	    
+	    }
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::IsUnknownArtistL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::IsUnknownArtistL(TUint32 aId)
+	{
+	return iObserver.HandleIsUnknownArtistL(aId);
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::ArtistForAlbumL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAlbum::ArtistForAlbumL(const TUint32 aId)
+    {
+    return iObserver.HandleArtistForAlbumL(aId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbCategory::CreateTableL");
+
+    // create the table
+    HBufC* query = PreProcessStringLC(KAlbumCreateTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    // do not create an index on the Name field
+    // as it only slows down the insert/update queries overall
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbCategory::CheckTableL");
+
+    HBufC* query = PreProcessStringLC(KAlbumCheckTable);
+    TBool check(DoCheckTable(aDatabase, *query));
+    CleanupStack::PopAndDestroy(query);
+
+    return check;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbartist.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,381 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the Artist table
+*
+*
+*/
+
+
+// INCLUDE FILES
+#include <sqldb.h>
+
+#include <mpxlog.h>
+
+#include "mpxdbcommonutil.h"
+#include "mpxdbcommondef.h"
+#include "mpxmediamusicdefs.h"
+#include "mpxdbmanager.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbutil.h"
+#include "mpxdbartist.h"
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbArtist* CMPXDbArtist::NewL(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbArtistObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbArtist::NewL");
+
+    CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory, aObserver);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbArtist* CMPXDbArtist::NewLC(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbArtistObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbArtist::NewLC");
+
+    CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory, aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbArtist::~CMPXDbArtist()
+    {
+    MPX_FUNC("CMPXDbArtist::~CMPXDbArtist");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbArtist::CMPXDbArtist(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory,
+    MMPXDbArtistObserver& aObserver) :
+    CMPXDbCategory(aDbManager, aCategory), 
+    iObserver(aObserver)
+    {
+    MPX_FUNC("CMPXDbArtist::CMPXDbArtist");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::ConstructL()
+    {
+    MPX_FUNC("CMPXDbArtist::ConstructL");
+
+    BaseConstructL();
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::AddItemL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbArtist::AddItemL(
+    const TDesC& aName,
+    const TDesC& aArt,
+    TInt aDriveId,
+    TBool& aNewRecord,
+    TBool aCaseSensitive)
+    {
+    MPX_FUNC("CMPXDbArtist::AddItemL");
+
+    // try to find the item first
+    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
+        aName, aCaseSensitive));
+    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
+
+    if (aNewRecord)
+        {      
+        // insert new
+        HBufC* query = PreProcessStringLC(KQueryArtistInsert);
+        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+        HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
+
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, art);
+
+        CleanupStack::PopAndDestroy(art);
+        CleanupStack::PopAndDestroy(name);
+        CleanupStack::PopAndDestroy(query);
+        }
+    else
+        {
+        // retrieve the existing record
+        HBufC* query = NULL;
+        query = PreProcessStringLC(KQueryCategoryItem);
+        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
+        CleanupStack::PopAndDestroy(query);
+        
+        CleanupClosePushL(recordset);
+        
+        if (recordset.Next() != KSqlAtRow)
+            {
+            User::Leave(KErrNotFound);
+        }
+            
+        // Album Art
+        TPtrC art(KNullDesC);
+        art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt));
+    
+        // the current one is Unknown and the new one is Not Unknown
+        if ( art == KNullDesC && aArt != KNullDesC )
+            {
+            HBufC* artReplaceSingleQuote = 
+                MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
+            _LIT( KFormatArt, "Art=\'%S\'" );
+            HBufC* setStr = HBufC::NewLC(256);
+            setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
+
+            iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId);
+            CleanupStack::PopAndDestroy(setStr);
+            CleanupStack::PopAndDestroy(artReplaceSingleQuote);
+            }
+        
+        CleanupStack::PopAndDestroy(&recordset);
+        
+        // increment the number of songs for the category
+        query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
+        CleanupStack::PopAndDestroy(query);
+        }
+
+    return rowId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::IsUnknownArtistL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbArtist::IsUnknownArtistL(TUint32 aId)
+    {
+	MPX_FUNC("CMPXDbArtist::IsUnknownArtistL");
+	
+    HBufC* name = GetNameL(aId);
+	
+	TInt ret = EFalse;
+	if (*name == KNullDesC)
+		{
+		ret = ETrue;
+		}
+	delete name;
+	
+	return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbArtist::UpdateMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+        TUint attributeId(aAttrs[i].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            if (attributeId & EMPXMediaGeneralId)
+                {
+                MPX_DEBUG1("	EMPXMediaGeneralId");
+				
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+                    aRecord.ColumnInt64(EArtistUniqueId));
+				MPX_DEBUG2("	Id[%d]", aRecord.ColumnInt64(EArtistUniqueId));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                MPX_DEBUG1("	EMPXMediaGeneralTitle");
+				
+                TPtrC artist( MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName) );
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
+                    MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName));
+
+				MPX_DEBUG2("	Artist[%S]", &artist);
+                }
+            if (attributeId & EMPXMediaGeneralCount)
+                {
+//				TInt albumCount = GetAlbumsCountL(aRecord.ColumnInt64(EArtistUniqueId));
+//              aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,albumCount);
+//              MPX_DEBUG1("	EMPXMediaGeneralCount");
+//				MPX_DEBUG2("	AlbumCount[%d]", albumCount);
+                // get songs count from all drives
+                TInt songCount = GetSongsCountL( KDbManagerAllDrives,
+                                    aRecord.ColumnInt64( EArtistUniqueId ) );
+				aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount); // mod by anjokela
+				
+                MPX_DEBUG1("	EMPXMediaGeneralCount");
+				MPX_DEBUG2("	SongCount[%d]", songCount);
+                }
+            } // end if contentId == KMPXMediaIdGeneral
+        else if ( contentId == KMPXMediaIdMusic )
+            {
+            if (attributeId & EMPXMediaMusicAlbumArtFileName)
+                {
+                MPX_DEBUG1("    EMPXMediaMusicAlbumArtFileName");
+                TPtrC art(KNullDesC);                
+                art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistArt));
+                aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
+                MPX_DEBUG2("    Art[%S]", &art);
+                }
+            }
+		} // end for
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::GenerateArtistFieldsValuesL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
+    {
+    if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
+        {
+        const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
+        }
+    }
+	
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::GetAlbumsCountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbArtist::GetAlbumsCountL(TUint32 aId)
+    {
+    MPX_FUNC("CMPXDbArtist::GetAlbumsCountL");
+	
+	return iObserver.HandleGetAlbumsCountForArtistL(aId);
+    }
+	
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::GetAllCategoryItemsL
+// ----------------------------------------------------------------------------
+//	
+void CMPXDbArtist::GetAllCategoryItemsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbArtist::GetAllCategoryItemsL");
+    HBufC* query = PreProcessStringLC(KQueryArtistAll);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
+    CleanupStack::PopAndDestroy(query);
+    CleanupClosePushL(recordset);
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::UpdateItemL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::UpdateItemL(
+    TUint32 aId, 
+    const CMPXMedia& aMedia, 
+    TInt aDriveId, 
+    CMPXMessageArray* aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbAlbum::UpdateItemL");
+
+    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
+    CleanupStack::PushL(fields);
+    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
+    CleanupStack::PushL(values);
+
+    // process the media parameter and construct the fields and values array
+    GenerateArtistFieldsValuesL(aMedia, *fields, *values);
+
+    // construct the SET string
+    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
+
+    if (setStr->Length())
+        {
+        // execute the query
+        iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, aId);
+        MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
+        		EMPXArtist, KDBPluginUid, ETrue, 0 );          
+        }
+
+    CleanupStack::PopAndDestroy(setStr);
+    CleanupStack::PopAndDestroy(values);
+    CleanupStack::PopAndDestroy(fields);
+    }
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbCategory::CreateTableL");
+
+    // create the table
+    HBufC* query = PreProcessStringLC(KArtistCreateTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    // do not create an index on the Name field
+    // as it only slows down the insert/update queries overall
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbArtist::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbCategory::CheckTableL");
+
+    HBufC* query = PreProcessStringLC(KArtistCheckTable);
+    TBool check(DoCheckTable(aDatabase, *query));
+    CleanupStack::PopAndDestroy(query);
+
+    return check;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbautoplaylist.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,414 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for the auto playlist functionality.
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include <mpxcollectiondbhgres.rsg>
+#include <sqldb.h>
+
+#include "mpxresource.h"
+#include "mpxdbcommonutil.h"
+#include "mpxdbmanager.h"
+#include "mpxdbutil.h"
+#include "mpxcollectiondbdef.h"
+#include "mpxdbautoplaylist.h"
+#include "mpxdbpluginqueries.h"
+
+const TInt KMPXTableDefaultIndex = 0;
+const TInt32 KMPXRecentlyPlayedPlaylistId = 0x20000000;
+const TInt32 KMPXMostPlayedPlaylistId = 0x20000001;
+const TInt32 KMPXRecentlyAddedPlaylistId = 0x20000002;
+
+const TInt KPlaylistTitleSize = 32;
+_LIT( KMostPlayed, "Most played" );
+_LIT( KRecentlyPlayed, "Recently played" );
+_LIT( KRecentlyAdded, "Recently added" );
+
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAutoPlaylist* CMPXDbAutoPlaylist::NewL(
+    CMPXDbManager& aDbManager,
+    RFs& aFs,
+    CMPXResource& aResource)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::NewL");
+
+    CMPXDbAutoPlaylist* self = CMPXDbAutoPlaylist::NewLC(aDbManager, aFs, aResource);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAutoPlaylist* CMPXDbAutoPlaylist::NewLC(
+    CMPXDbManager& aDbManager,
+    RFs& aFs,
+    CMPXResource& aResource)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::NewLC");
+
+    CMPXDbAutoPlaylist* self = new (ELeave) CMPXDbAutoPlaylist(aDbManager);
+    CleanupStack::PushL(self);
+    self->ConstructL(aFs, aResource);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAutoPlaylist::~CMPXDbAutoPlaylist()
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::~CMPXDbAutoPlaylist");
+
+    delete iRecentlyPlayedPlaylist;
+    delete iMostPlayedPlaylist;
+    delete iRecentlyAddedPlaylist;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAutoPlaylist::CMPXDbAutoPlaylist(CMPXDbManager& aDbManager)
+    : iDbManager(aDbManager)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::CMPXDbAutoPlaylist");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAutoPlaylist::ConstructL(
+    RFs& /*aFs*/,
+    CMPXResource& /*aResource*/)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::ConstructL");
+    iRecentlyPlayedPlaylist = HBufC::NewL(KPlaylistTitleSize);
+    iRecentlyPlayedPlaylist->Des().Append(KMostPlayed);
+    iMostPlayedPlaylist = HBufC::NewL(KPlaylistTitleSize);
+    iMostPlayedPlaylist->Des().Append(KRecentlyPlayed);
+    iRecentlyAddedPlaylist = HBufC::NewL(KPlaylistTitleSize);
+    iRecentlyAddedPlaylist->Des().Append(KRecentlyAdded);
+
+    iRecentlyPlayedPlaylistId = KMPXRecentlyPlayedPlaylistId;
+    iMostPlayedPlaylistId = KMPXMostPlayedPlaylistId;
+    iRecentlyAddedPlaylistId = KMPXRecentlyAddedPlaylistId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::AutoPlaylistIdL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAutoPlaylist::AutoPlaylistIdL(
+    TMPXAutoPlaylistType aPlaylistType)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistIdL");
+
+    TUint32 id(0);
+    switch (aPlaylistType)
+        {
+        case EMPXRecentlyPlayedPlaylist:
+            {
+            id = iRecentlyPlayedPlaylistId;
+            }
+            break;
+
+        case EMPXMostPlayedPlaylist:
+            {
+            id = iMostPlayedPlaylistId;
+            }
+            break;
+
+        case EMPXRecentlyAddedPlaylist:
+            {
+            id = iRecentlyAddedPlaylistId;
+            }
+            break;
+
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    return id;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::AutoPlaylistNameL
+// ----------------------------------------------------------------------------
+//
+TPtrC CMPXDbAutoPlaylist::AutoPlaylistNameL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistNameL");
+
+    TPtrC ptr;
+    if (aPlaylistId == iRecentlyPlayedPlaylistId)
+        {
+        ptr.Set(*iRecentlyPlayedPlaylist);
+        }
+    else if (aPlaylistId == iMostPlayedPlaylistId)
+        {
+        ptr.Set(*iMostPlayedPlaylist);
+        }
+    else if (aPlaylistId == iRecentlyAddedPlaylistId)
+        {
+        ptr.Set(*iRecentlyAddedPlaylist);
+        }
+    else
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    return ptr;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::AutoPlaylistTypeL
+// ----------------------------------------------------------------------------
+//
+TMPXAutoPlaylistType CMPXDbAutoPlaylist::AutoPlaylistTypeL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistTypeL");
+
+    TMPXAutoPlaylistType type(EMPXNoAutoPlaylist);
+    if (aPlaylistId == iRecentlyPlayedPlaylistId)
+        {
+        type = EMPXRecentlyPlayedPlaylist;
+        }
+    else if (aPlaylistId == iMostPlayedPlaylistId)
+        {
+        type = EMPXMostPlayedPlaylist;
+        }
+    else if (aPlaylistId == iRecentlyAddedPlaylistId)
+        {
+        type = EMPXRecentlyAddedPlaylist;
+        }
+    else
+        {
+        // do nothing
+        }
+
+    return type;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::GetPlaylistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAutoPlaylist::GetPlaylistL(
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::GetPlaylistL");
+
+    if (EMPXNoAutoPlaylist == AutoPlaylistTypeL(aPlaylistId))
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    UpdateMediaL(aPlaylistId, aAttrs, aMedia);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::GetAllPlaylistsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAutoPlaylist::GetAllPlaylistsL(
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::GetAllPlaylistsL");
+
+    MPX_ASSERT(aMediaArray.Count());
+    MPX_ASSERT(aMediaArray[0]->IsSupported(KMPXMediaGeneralValue));
+    TInt pPath = aMediaArray[0]->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+    MPX_ASSERT(pPath);
+    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iMostPlayedPlaylist, EMPXItem,
+        EMPXPlaylist, iMostPlayedPlaylistId, EMPXWrite);
+    TInt count = aMediaArray.Count();
+    TMPXItemId id = aMediaArray[count-1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+    if (count==2)
+        { // the first playlist
+        if (((CMPXCollectionPath*)pPath)->Id()==KMPXInvalidItemId)
+            { // Remove top level with invalid id
+            ((CMPXCollectionPath*)pPath)->Back();
+            }
+        ((CMPXCollectionPath*)pPath)->AppendL(id);
+        }
+    else
+        { // append the end
+        ((CMPXCollectionPath*)pPath)->InsertL(id,
+                                              ((CMPXCollectionPath*)pPath)->Count());
+        }
+    TInt songCount = 0;
+    TInt duration = 0;
+    GetPlaylistDetailsL(EMPXMostPlayedPlaylist, songCount, duration);
+    aMediaArray[count-1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
+    aMediaArray[count-1]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
+
+    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iRecentlyPlayedPlaylist, EMPXItem,
+        EMPXPlaylist, iRecentlyPlayedPlaylistId, EMPXWrite);
+    id = aMediaArray[count]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+    ((CMPXCollectionPath*)pPath)->InsertL(id, ((CMPXCollectionPath*)pPath)->Count());
+    songCount = 0;
+    duration = 0;
+    GetPlaylistDetailsL(EMPXRecentlyPlayedPlaylist, songCount, duration);
+	aMediaArray[count]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
+   	aMediaArray[count]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
+
+    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iRecentlyAddedPlaylist, EMPXItem,
+        EMPXPlaylist, iRecentlyAddedPlaylistId, EMPXWrite);
+    id = aMediaArray[count+1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+    ((CMPXCollectionPath*)pPath)->InsertL(id, ((CMPXCollectionPath*)pPath)->Count());
+    songCount = 0;
+	duration = 0;
+	GetPlaylistDetailsL(EMPXRecentlyAddedPlaylist, songCount, duration);
+	aMediaArray[count+1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
+	aMediaArray[count+1]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::GetPlaylistDetails
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAutoPlaylist::GetPlaylistDetailsL(TMPXAutoPlaylistType aType, TInt& aCount, TInt& aDuration)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::GetPlaylistDetails");
+
+    HBufC* query = NULL;
+  
+    switch ( aType )
+    	{
+		case EMPXMostPlayedPlaylist:
+		    query = HBufC::NewLC(KQueryMusicGetDurationMostPlayed().Length() + KMCIntegerLen);
+		    query->Des().Format(KQueryMusicGetDurationMostPlayed(), KMPXMaxMostPlayedSongs);
+		    break;
+		case EMPXRecentlyPlayedPlaylist:
+		    query = HBufC::NewLC(KQueryMusicGetDurationRecentlyPlayed().Length() + KMCIntegerLen);
+		    query->Des().Format(KQueryMusicGetDurationRecentlyPlayed(), KMPXMaxRecentlyPlayedSongs);
+			break;
+		case EMPXRecentlyAddedPlaylist:
+		    query = HBufC::NewLC(KQueryMusicGetDurationRecentlyAdded().Length());
+		    query->Des().Append(KQueryMusicGetDurationRecentlyAdded());
+			break;
+		default:
+			User::Leave(KErrArgument);
+			break;
+		}
+    
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
+    CleanupClosePushL(recordset);
+
+    TInt sum(0);
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        aCount++;
+        sum += recordset.ColumnInt64(KMPXTableDefaultIndex);
+        }
+    
+    CleanupStack::PopAndDestroy(&recordset);
+    CleanupStack::PopAndDestroy(query);
+    
+    if (err != KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    aDuration = sum;
+    MPX_DEBUG3("    Count[%d], Duration[%d]", aCount, aDuration);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAutoPlaylist::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAutoPlaylist::UpdateMediaL(
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbAutoPlaylist::UpdateMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            TUint attributeId(aAttrs[i].AttributeId());
+
+            if (attributeId & EMPXMediaGeneralId)
+                {
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPlaylistId);
+                }
+            if (attributeId & EMPXMediaGeneralCollectionId )
+                {
+                aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
+                    TUid::Uid(KDBPluginUid));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                if (aPlaylistId == iRecentlyPlayedPlaylistId)
+                    {
+                    aMedia.SetTextValueL(KMPXMediaGeneralTitle, *iRecentlyPlayedPlaylist);
+                    }
+                 else if (aPlaylistId == iMostPlayedPlaylistId)
+                    {
+                    aMedia.SetTextValueL(KMPXMediaGeneralTitle,*iMostPlayedPlaylist);
+                    }
+                 else if (aPlaylistId == iRecentlyAddedPlaylistId)
+                    {
+                    aMedia.SetTextValueL(KMPXMediaGeneralTitle, *iRecentlyAddedPlaylist);
+                    }
+                 else
+                    {
+                    User::Leave(KErrArgument);
+                    }
+                }
+            if (attributeId & EMPXMediaGeneralSynchronized)
+                {
+                aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, EFalse);
+                }
+            if (attributeId & EMPXMediaGeneralNonPermissibleActions)
+                {
+                aMedia.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
+                }
+            // EMPXMediaGeneralCount, EMPXMediaGeneralDate, EMPXMediaGeneralDuration,
+            // EMPXMediaGeneralUri, EMPXMediaGeneralDrive, and EMPXMediaGeneralFlags
+            // attributes are not applicable for auto-playlists
+            } // end if contentId == KMPXMediaIdGeneral
+        } // end for
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbauxiliary.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,294 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interaction with the Auxiliary table.
+*
+*/
+
+
+// INCLUDE FILES
+#include <sqldb.h>
+#include <mpxlog.h>
+
+#include "mpxdbcommonutil.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbmanager.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbauxiliary.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAuxiliary* CMPXDbAuxiliary::NewL(
+    CMPXDbManager& aDbManager)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::NewL");
+
+    CMPXDbAuxiliary* self = CMPXDbAuxiliary::NewLC(aDbManager);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbAuxiliary* CMPXDbAuxiliary::NewLC(
+    CMPXDbManager& aDbManager)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::NewLC");
+
+    CMPXDbAuxiliary* self = new (ELeave) CMPXDbAuxiliary(aDbManager);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAuxiliary::~CMPXDbAuxiliary()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::~CMPXDbAuxiliary");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbAuxiliary::CMPXDbAuxiliary(
+    CMPXDbManager& aDbManager) :
+    CMPXDbTable(aDbManager)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::CMPXDbAuxiliary");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::ConstructL()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::ConstructL");
+    BaseConstructL();
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SetLastRefreshedTimeL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::SetLastRefreshedTimeL(
+    TTime aTime)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::SetLastRefreshedTimeL");
+
+    // update all databases
+    HBufC* time = MPXDbCommonUtil::TTimeToDesLC(aTime);
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryAuxiliarySetTime, time);
+    CleanupStack::PopAndDestroy(time);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::LastRefreshedTimeL
+// ----------------------------------------------------------------------------
+//
+TTime CMPXDbAuxiliary::LastRefreshedTimeL()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::LastRefreshedTimeL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    // read the time string and convert it to TTime
+    TTime time(MPXDbCommonUtil::DesToTTimeL(
+    	MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex)));
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return time;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SetDBCorruptedL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::SetDBCorruptedL(
+    TBool aCorrupt)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::SetDBCorruptedL");
+
+    // update all databases
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryAuxiliarySetCorrupt,
+        aCorrupt);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::DBCorruptedL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAuxiliary::DBCorruptedL()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::DBCorruptedL");
+    return (ExecuteSumQueryL(KQueryAuxiliaryGetCorrupt) > 0);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SetSaveDeletedRecordCountL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::SetSaveDeletedRecordCountL(TInt aDrive,
+    TUint32 aValue)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::SetSaveDeletedRecordCountL");
+
+    // update all databases
+    iDbManager.ExecuteQueryL(aDrive, KQueryAuxiliarySetCount, aValue);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SaveDeletedRecordCountL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAuxiliary::SaveDeletedRecordCountL()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::SaveDeletedRecordCountL");
+    return ExecuteSumQueryL(KQueryAuxiliaryGetCount);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SaveDeletedRecordCountL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAuxiliary::SaveDeletedRecordCountL(TInt aDriveID)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::SaveDeletedRecordCountL ");
+    return ExecuteIntQueryL(aDriveID, KQueryAuxiliaryGetCount);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::IsRefreshedL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAuxiliary::IsRefreshedL()
+    {
+    MPX_FUNC("CMPXDbAuxiliary::IsRefreshedL");
+
+    TBool refreshed(ETrue);
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+    CleanupClosePushL(recordset);
+
+    TInt count(0);
+    while (recordset.Next() == KSqlAtRow)
+        {
+        count++;
+
+        // read the time string and convert it to TTime
+        if (Time::NullTTime() == MPXDbCommonUtil::DesToTTimeL(
+        	MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex)))
+            {
+            refreshed = EFalse;
+            break;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    return refreshed && (count > 0);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::IdL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbAuxiliary::IdL( TInt aDrive )
+    {
+    MPX_DEBUG1("CMPXDbAuxiliary::IdL <--");
+    TInt id(0);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive, KQueryAuxiliaryGetId));
+    CleanupClosePushL( recordset );
+
+    while(recordset.Next() == KSqlAtRow )
+        {
+        id = recordset.ColumnInt(KMPXTableDefaultIndex);
+        }
+
+    CleanupStack::PopAndDestroy( &recordset );
+    MPX_DEBUG1("CMPXDbAuxiliary::IdL -->");
+    return id;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::SetIdL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::SetIdL( TInt aDrive, TInt aId )
+    {
+    MPX_DEBUG1("CMPXDbAuxiliary::SetIdL <--");
+    iDbManager.ExecuteQueryL(aDrive,KQueryAuxiliarySetId, aId);
+    MPX_DEBUG1("CMPXDbAuxiliary::SetIdL -->");
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool aCorruptTable)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::CreateTableL");
+
+    // create the table
+    User::LeaveIfError(aDatabase.Exec(KAuxiliaryCreateTable));
+
+    // insert the default record
+    // use the same length as '%u' is longer than '0' or '1'
+    HBufC* query = KQueryAuxiliaryInsert().AllocLC();
+    query->Des().Format(KQueryAuxiliaryInsert, aCorruptTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::DropTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAuxiliary::DropTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::DropTableL");
+    User::LeaveIfError(aDatabase.Exec(KAuxiliaryDropTable));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAuxiliary::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAuxiliary::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbAuxiliary::CheckTableL");
+    return DoCheckTable(aDatabase, KAuxiliaryCheckTable);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbcategory.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,708 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the category tables:
+*                Artist, Album, Genre and Composer
+*
+*/
+
+
+// INCLUDE FILES
+#include <sqldb.h>
+
+#include <mpxlog.h>
+
+#include "mpxdbcommonutil.h"
+#include "mpxdbcommondef.h"
+#include "mpxdbmanager.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbutil.h"
+#include "mpxdbcategory.h"
+
+// CONSTANTS
+
+// maximum number of table name entries per query
+const TInt KMaxTableNameCount = 2;
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbCategory::~CMPXDbCategory()
+    {
+    MPX_FUNC("CMPXDbCategory::~CMPXDbCategory");
+    delete iTableName;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbCategory::CMPXDbCategory(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory) :
+    CMPXDbTable(aDbManager),
+    iCategory(aCategory)
+    {
+    MPX_FUNC("CMPXDbCategory::CMPXDbCategory");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::BaseConstructL()
+    {
+    MPX_FUNC("CMPXDbCategory::BaseConstructL");
+
+    CMPXDbTable::BaseConstructL();
+    iTableName = MPXDbUtil::TableNameForCategoryL(iCategory).AllocL();
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::AddItemL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbCategory::AddItemL(
+    const TDesC& aName,
+    TInt aDriveId,
+    TBool& aNewRecord,
+    TBool aCaseSensitive)
+    {
+    MPX_FUNC("CMPXDbCategory::AddItemL");
+
+    // try to find the item first
+    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
+        aName, aCaseSensitive));
+    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
+
+    if (aNewRecord)
+        {
+        // insert new
+        HBufC* query = PreProcessStringLC(KQueryCategoryInsert);
+        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1);
+
+        CleanupStack::PopAndDestroy(name);
+        CleanupStack::PopAndDestroy(query);
+        }
+    else
+        {
+        // increment the number of songs for the category
+        HBufC* query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
+        CleanupStack::PopAndDestroy(query);
+        }
+
+    return rowId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetNameL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbCategory::GetNameL(
+    TUint32 aId)
+    {
+    MPX_FUNC("CMPXDbCategory::GetNameL");
+
+    RSqlStatement recordset(GetCategoryRecordL(aId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
+
+    HBufC* name = MPXDbCommonUtil::GetColumnTextL(recordset, ECategoryName).AllocL();
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return name;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::CountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbCategory::CountL()
+    {
+    MPX_FUNC("CMPXDbCategory::CountL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryCount);
+    TInt count(ExecuteSumQueryL(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    return count;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::FindAllL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::FindAllL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbCategory::FindAllL");
+
+    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
+
+    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
+    TInt criteriaCount(criteria.Count());
+
+    // process the criteria and construct the criteria string
+    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(criteriaCount + 1);
+    CleanupStack::PushL(criteriaArray);
+
+    for (TInt i = 0; i < criteriaCount; ++i)
+        {
+        const TMPXAttribute& criterion = criteria[i];
+        if ((type == EMPXItem) && (criterion == KMPXMediaGeneralId))
+            {
+            TUint32 itemId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+            if (MPX_ITEM_CATEGORY(itemId) != iCategory)
+                {
+                User::Leave(KErrNotSupported);
+                }
+
+            HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, itemId);
+            CleanupStack::PopAndDestroy(critStr);
+            }
+        else if (criterion == KMPXMediaGeneralTitle)
+            {
+#ifdef RD_MPX_COLLECTION_CACHE
+           
+            if (aCriteria.ValueText(KMPXMediaGeneralTitle).Length() <= 0)
+                {
+                TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(
+                                    iDbManager.Fs(), iCategory, KNullDesC, EFalse);
+                HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
+                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, itemId);
+                CleanupStack::PopAndDestroy(critStr);
+                }
+            else
+                {
+
+#endif //RD_MPX_COLLECTION_CACHE
+                HBufC* critStr = PreProcessStringLC(KCriterionCategoryName);
+                HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
+                    aCriteria.ValueText(KMPXMediaGeneralTitle));
+                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, *title);
+                CleanupStack::PopAndDestroy(2, critStr); // title & critStr
+#ifdef RD_MPX_COLLECTION_CACHE
+                }
+#endif //RD_MPX_COLLECTION_CACHE
+            }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+          else if (criterion == KMPXMediaGeneralUri)
+                 {  
+                 TUint32 itemId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
+                       aCriteria.ValueText(KMPXMediaGeneralUri), (iCategory != EMPXGenre)));   
+                   HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
+                   MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, itemId);
+             CleanupStack::PopAndDestroy(critStr);
+             }
+        else if (criterion == KMPXMediaGeneralDrive)
+            {
+            const TDesC& drive(aCriteria.ValueText(KMPXMediaGeneralDrive));
+            TDriveUnit driveUnit(drive);
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionAbstractAlbumVolumeId,
+                MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
+            }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        else
+            {
+            // ignore attribute
+            }
+        }
+
+    // construct criteria string
+    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
+
+    // either get all items or items filtered based on criteria
+    HBufC* query = PreProcessStringLC(criteriaStr->Length() ?
+        KQueryCategoryItems() : KQueryCategoryAll());
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, criteriaStr));
+    CleanupStack::PopAndDestroy(3, criteriaArray); // query, criteriaStr, criteriaArray
+    CleanupClosePushL(recordset);
+
+    // process the results
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::DecrementSongsForCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::DecrementSongsForCategoryL(
+    const TUint32 aId,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TBool& aItemExist,
+    TBool /*aMTPInUse*/)
+    {
+    MPX_FUNC("CMPXDbCategory::DecrementSongsForCategoryL");
+
+    // if just one song uses this category. Use <= just in case
+    if (GetSongsCountL(aDriveId, aId) <= 1)
+        {
+        aItemExist = EFalse;
+        // delete the category
+        DeleteCategoryL(aId, aDriveId);
+
+        if (aItemChangedMessages)
+            {
+            // add the item changed message
+            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
+                iCategory, KDBPluginUid);
+            }
+        }
+    else
+        {
+        aItemExist = ETrue;
+        // decrement the number of songs for the category
+        HBufC* query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
+        iDbManager.ExecuteQueryL(aDriveId, *query, aId);
+        CleanupStack::PopAndDestroy(query);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::DeleteCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::DeleteCategoryL(
+    TUint32 aId,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbCategory::DeleteCategoryL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryDelete);
+    iDbManager.ExecuteQueryL(aDriveId, *query, aId);
+    CleanupStack::PopAndDestroy(query);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetCategoryItemsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::GetCategoryItemsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbCategory::GetCategoryItemsL");
+
+    // have to run one query to get all items as opposed to individual queries
+    // because of the sorting
+
+    // construct the unique ID criteria string
+    // (UniqueId = %u OR UniqueId = %u ...)
+    TInt count(aMediaArray.Count());
+    HBufC* criteria = HBufC::NewLC((2 * KCriterionCategoryUniqueId().Length() +
+        KMCIntegerLen + KMCOrKeyword().Length() + 2) * count);
+    TPtr ptr(criteria->Des());
+    ptr.Append(KMCOpenBracket);
+    for (TInt index = 0; index < count; ++index)
+        {
+        CMPXMedia* media = aMediaArray[index];
+
+        HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
+        HBufC* criterion = MPXDbCommonUtil::SqlCriterionLC(*critStr,
+            (media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId1);
+        ptr.Append(*criterion);
+        CleanupStack::PopAndDestroy(criterion);
+        CleanupStack::PopAndDestroy(critStr);
+
+        if (index < (count - 1))
+            {
+            ptr.Append(KMCOrKeyword);
+            }
+        }
+    ptr.Append(KMCCloseBracket);
+
+    // the array has to be reset as the items have to be returned in a different sort order
+    aMediaArray.Reset();
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryItems);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, criteria));
+
+    CleanupStack::PopAndDestroy(query);
+    CleanupStack::PopAndDestroy(criteria);
+
+    CleanupClosePushL(recordset);
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetAllCategoryItemsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::GetAllCategoryItemsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbCategory::GetAllCategoryItemsL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryAll);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    CleanupClosePushL(recordset);
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetCategoryItemL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::GetCategoryItemL(
+    TUint32 aId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbCategory::GetCategoryItemL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+    ExecuteMediaQueryL(aAttrs, aMedia, *query, aId);
+    CleanupStack::PopAndDestroy(query);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetSubCategoryItemsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::GetSubCategoryItemsL(
+    TMPXGeneralCategory aParentCategory,
+    TUint32 aParentId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbCategory::GetSubCategoryItemsL");
+
+    // this is only valid for albums belonging to an artist
+    ASSERT((iCategory == EMPXAlbum) && (aParentCategory == EMPXArtist));
+
+    // to handle the UREL warning
+    (void)aParentCategory;
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryCategorySubcategoryItems, aParentId));
+    CleanupClosePushL(recordset);
+    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
+    CleanupStack::PopAndDestroy(&recordset);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::CategoryItemExistsL
+// The category records must be in the same database as the corresponding
+// Music record, otherwise when adding a duplicate of a song on a
+// different drive this method will return true and the category record won't
+// be created.
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbCategory::CategoryItemExistsL(
+    TInt aDriveId,
+    TUint32 aId)
+    {
+    MPX_FUNC("CMPXDbCategory::CategoryItemExistsL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+    RSqlStatement recordset(
+        iDbManager.ExecuteSelectQueryL(aDriveId, *query, aId));
+
+    TBool exists(recordset.Next() == KSqlAtRow);
+
+    recordset.Close();
+    CleanupStack::PopAndDestroy(query);
+
+    return exists;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetSongsCountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbCategory::GetSongsCountL(
+    TInt aDriveId,
+    TUint32 aId)
+    {
+    MPX_FUNC("CMPXDbCategory::GetSongsCountL");
+
+    HBufC* query = PreProcessStringLC(KQueryCategoryGetSongCount);
+    RSqlStatement recordset(
+        iDbManager.ExecuteSelectQueryL(aDriveId, *query, aId));
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    TInt ret(0);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        ret += recordset.ColumnInt(KMPXTableDefaultIndex);
+        }
+
+    if (err != KSqlAtEnd)
+        {
+        User::Leave(err);
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    CleanupStack::PopAndDestroy(query);
+
+    return ret;
+    }
+
+void CMPXDbCategory::UpdateItemL(
+    TUint32 /*aId*/, 
+    const CMPXMedia& /*aMedia*/, 
+    TInt /*aDriveId*/, 
+    CMPXMessageArray* /*aItemChangedMessages*/)
+	{
+	// nothing
+	}
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbCategory::UpdateMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+        TUint attributeId(aAttrs[i].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            if (attributeId & EMPXMediaGeneralId)
+                {
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+                    aRecord.ColumnInt64(ECategoryUniqueId));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
+                    MPXDbCommonUtil::GetColumnTextL(aRecord, ECategoryName));
+                }
+            if (attributeId & EMPXMediaGeneralCount)
+                {
+                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
+                    GetSongsCountL(KDbManagerAllDrives,
+                    aRecord.ColumnInt64(ECategoryUniqueId)));
+                }
+            } // end if contentId == KMPXMediaIdGeneral
+        } // end for
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::GetCategoryRecordL
+// ----------------------------------------------------------------------------
+//
+RSqlStatement CMPXDbCategory::GetCategoryRecordL(
+    TUint32 aId)
+    {
+    MPX_FUNC("CMPXDbCategory::GetCategoryRecordL");
+    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+    RSqlStatement statement(iDbManager.ExecuteSelectQueryL(*query, aId));
+    CleanupStack::PopAndDestroy(query);
+
+    return statement;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::PreProcessStringLC
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbCategory::PreProcessStringLC(
+    const TDesC& aQuery)
+    {
+    MPX_FUNC("CMPXDbCategory::PreProcessStringLC");
+
+    HBufC* query = HBufC::NewLC(aQuery.Length() + KMaxTableNameCount * (iTableName->Length() +
+        KCategoryTablePlaceholder().Length()));
+    TPtr queryPtr(query->Des());
+
+    // copy the query string
+    queryPtr = aQuery;
+
+    // replace all instances of the placeholder with the actual table name
+    TInt index(0);
+    while ((index = queryPtr.Find(KCategoryTablePlaceholder)) != KErrNotFound)
+        {
+        queryPtr.Replace(index, KCategoryTablePlaceholder().Length(), *iTableName);
+        }
+
+    return query;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::ProcessRecordsetL
+// Unknown item is stored in the database as NULL (name field). This ensures the
+// unknown item to be the 1st found record if it exists. This will save time in
+// searching for the unknown record among the results and avoid performing
+// descriptor comparison. If the 1st record is the unknown item, it won't be
+// appended to the array until all other records have been put in the array.
+//
+// NOTE: putting unknown item to the end of the array only takes place when title
+//       field is requested. normal sorting algorithm occurs if title isn't
+//       requested.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::ProcessRecordsetL(
+    const TArray<TMPXAttribute>& aAttrs,
+    RSqlStatement& aRecordset,
+    CMPXMediaArray& aMediaArray)
+    {
+    // populate the array
+    TBool firstRecord(ETrue);
+    CMPXMedia* unknownMedia(NULL);
+    TInt prevId(0);
+    TInt err(KErrNone);
+
+    TInt pPath(0);
+    if (aMediaArray.Count())
+        {
+        CMPXMedia* pMedia = aMediaArray[0];
+        if (pMedia->IsSupported(KMPXMediaGeneralValue))
+            { // Query excuted by OpenL
+            pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+            MPX_ASSERT(pPath);
+            }
+        }
+    RArray<TMPXItemId> ids;
+    CleanupClosePushL(ids);
+
+    while ((err = aRecordset.Next()) == KSqlAtRow)
+        {
+        TUint32 rowId(aRecordset.ColumnInt64(ECategoryUniqueId));
+        if (prevId == rowId)
+            {
+            continue;
+            }
+
+        prevId = rowId;
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+
+        UpdateMediaL(aRecordset, aAttrs, *media);
+
+        if (firstRecord &&
+            (MPXDbCommonUtil::GetColumnTextL(aRecordset, ECategoryName).Length() == 0))
+            {
+            unknownMedia = media;
+            }
+
+        if (!firstRecord || !unknownMedia)
+            {
+            if (media->IsSupported(KMPXMediaGeneralId) && pPath)
+                {
+                ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+                }
+            aMediaArray.AppendL(*media);
+            CleanupStack::PopAndDestroy(media);
+            }
+
+        firstRecord = EFalse;
+        } // end while
+
+    if (err != KSqlAtEnd)
+        {
+        User::LeaveIfError(err);
+        }
+
+    if (unknownMedia)
+        {
+        if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+            {
+            ids.AppendL(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+            }
+        aMediaArray.AppendL(*unknownMedia);
+        CleanupStack::PopAndDestroy(unknownMedia);
+        }
+
+    // Append ids to the returned path
+    if (pPath)
+        {
+        ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
+        }
+    CleanupStack::PopAndDestroy(&ids);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbCategory::CreateTableL");
+
+    // create the table
+    HBufC* query = PreProcessStringLC(KCategoryCreateTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+
+    // do not create an index on the Name field
+    // as it only slows down the insert/update queries overall
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::DropTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbCategory::DropTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbCategory::DropTableL");
+
+    HBufC* query = PreProcessStringLC(KCategoryDropTable);
+    User::LeaveIfError(aDatabase.Exec(*query));
+    CleanupStack::PopAndDestroy(query);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbCategory::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbCategory::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbCategory::CheckTableL");
+
+    HBufC* query = PreProcessStringLC(KCategoryCheckTable);
+    TBool check(DoCheckTable(aDatabase, *query));
+    CleanupStack::PopAndDestroy(query);
+
+    return check;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbcomposer.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the category tables:
+*                Artist, Album, Genre and Composer
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include "mpxdbcomposer.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbComposer* CMPXDbComposer::NewL(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbComposer::NewL");
+
+    CMPXDbComposer* self = CMPXDbComposer::NewLC(aDbManager, aCategory);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbComposer* CMPXDbComposer::NewLC(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbComposer::NewLC");
+
+    CMPXDbComposer* self = new (ELeave) CMPXDbComposer(aDbManager, aCategory);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbComposer::~CMPXDbComposer()
+    {
+    MPX_FUNC("CMPXDbComposer::~CMPXDbComposer");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbComposer::CMPXDbComposer(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory) :
+    CMPXDbCategory(aDbManager, aCategory)
+    {
+    MPX_FUNC("CMPXDbComposer::CMPXDbComposer");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbComposer::ConstructL()
+    {
+    MPX_FUNC("CMPXDbComposer::ConstructL");
+
+    BaseConstructL();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbgenre.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the category tables:
+*                Artist, Album, Genre and Composer
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include "mpxdbgenre.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbGenre* CMPXDbGenre::NewL(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbGenre::NewL");
+
+    CMPXDbGenre* self = CMPXDbGenre::NewLC(aDbManager, aCategory);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbGenre* CMPXDbGenre::NewLC(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbGenre::NewLC");
+
+    CMPXDbGenre* self = new (ELeave) CMPXDbGenre(aDbManager, aCategory);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbGenre::~CMPXDbGenre()
+    {
+    MPX_FUNC("CMPXDbGenre::~CMPXDbGenre");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbGenre::CMPXDbGenre(
+    CMPXDbManager& aDbManager,
+    TMPXGeneralCategory aCategory) :
+    CMPXDbCategory(aDbManager, aCategory)
+    {
+    MPX_FUNC("CMPXDbGenre::CMPXDbGenre");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbGenre::ConstructL()
+    {
+    MPX_FUNC("CMPXDbGenre::ConstructL");
+
+    BaseConstructL();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,3276 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is used by db plugin for all database related
+*                functionality. The main responsibilities are:
+*
+*/
+
+
+// INCLUDE FILES
+#include <bautils.h>
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#include <pathinfo.h>
+#endif //RD_MULTIPLE_DRIVE
+
+#include <mpxcollectiondbhgres.rsg>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxmediaaudiodefs.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxcollectionpath.h>
+#include <mpxlog.h>
+
+#include "mpxresource.h"
+#include "mpxdbcommonutil.h"
+
+#include "mpxdbutil.h"
+#include "mpxcollectiondbdef.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxcollectiondbmanager.h"
+#include "mpxdbplaylist.h"
+#include "mpxdbplaylistsongs.h"
+#include "mpxdbcategory.h"
+#include "mpxdbauxiliary.h"
+#include "mpxdbautoplaylist.h"
+#include "mpxdbhandler.h"
+#include "mpxdbartist.h"
+#include "mpxdbalbum.h"
+#include "mpxdbgenre.h"
+#include "mpxdbcomposer.h"
+
+// CONSTANTS
+_LIT(KMPXVirtualPlaylistExt, ".vir");
+static const TInt KMaxOpInTransaction = 100;
+
+const TInt KSqlDbCorrupted = -321;
+
+#if defined (__MTP_PROTOCOL_SUPPORT)
+
+#include <centralrepository.h>
+
+// MTP CenRep Key UID
+const TUid KMPXMtpSettings = {0x101FFC53};
+// MTP CenRep Key for Delete contents
+const TUint32 KMPXMtpSaveDeletedRecordFlag = 0x00000001;
+
+#endif
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbHandler* CMPXDbHandler::NewL(
+    RFs& aFs,
+    CMPXResource& aResource)
+    {
+    MPX_FUNC("CMPXDbHandler::NewL");
+    CMPXDbHandler* self = CMPXDbHandler::NewLC(aFs, aResource);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbHandler* CMPXDbHandler::NewLC(
+    RFs& aFs,
+    CMPXResource& aResource)
+    {
+    MPX_FUNC("CMPXDbHandler::NewLC");
+    CMPXDbHandler* self = new (ELeave) CMPXDbHandler(aFs, aResource);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbHandler::~CMPXDbHandler()
+    {
+    MPX_FUNC("CMPXDbHandler::~CMPXDbHandler");
+
+    delete iAutoPlaylist;
+
+    delete iDbMusic;
+    delete iDbPlaylist;
+    delete iDbArtist;
+    delete iDbAlbum;
+    delete iDbGenre;
+    delete iDbComposer;
+    delete iDbAuxiliary;
+    delete iDbManager;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    delete iDbAbstractAlbum;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    delete iMimeTypes;
+    delete iExtensions;
+    delete iExtensionsMime;
+    delete iExtensionsDrm;
+
+    iDbDrives.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// C++ default constructor can NOT contain any code, that might leave
+// ----------------------------------------------------------------------------
+//
+CMPXDbHandler::CMPXDbHandler(
+    RFs& aFs,
+    CMPXResource& aResource) :
+    iFs(aFs),
+    iResource(aResource)
+    {
+    MPX_FUNC("CMPXDbHandler::CMPXDbHandler");
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::ConstructL()
+    {
+    MPX_FUNC("CMPXDbHandler::ConstructL");
+
+    iMimeTypes = iResource.ReadDesCArrayL(R_MC_MIME_TYPES);
+    iExtensions = iResource.ReadDesCArrayL(R_MC_MUSIC_FILE_EXTENSIONS);
+    iExtensionsMime = iResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_MIME);
+    iExtensionsDrm = iResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_DRM);
+    
+    // make sure all databases are created and valid
+    iDbManager = CMPXCollectionDbManager::NewL(iFs);
+    
+    CDesCArrayFlat* musicFolders =
+#ifdef RD_MULTIPLE_DRIVE
+        GetMusicFoldersL();
+#else
+        iResource.ReadDesCArrayL(R_MC_DEFAULT_MUSIC_FOLDERS);
+#endif
+
+    // create the music folders and initialize iDbDrives
+    CleanupStack::PushL(musicFolders);
+    ProcessMusicFoldersL(*musicFolders);
+    CleanupStack::PopAndDestroy(musicFolders);
+
+    // Create the db infrastructure, 
+    //
+    iDbMusic = CMPXDbMusic::NewL(*iDbManager, iResource, *this);
+    iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this);
+    iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this);
+	iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this);
+    iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre);
+    iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED  
+    iDbAbstractAlbum = CMPXDbAbstractAlbum::NewL(*iDbManager, EMPXAbstractAlbum);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED 
+    iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource);
+    iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager);
+
+    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
+    iCollectionOpen = ETrue;
+
+    // If KErrCorrupt is returned, a database file was found to be corrupted
+    // and was replaced with a new one.  The db plugin can ignore this error and continue
+    // because a new db file was successfully created in a subsequent retry.
+    if ((err != KErrNone) && (err != KErrCorrupt) && (err != KErrDiskFull))
+        {
+        // leave to signal the caller that there was an error why creating and opening
+        // one or more of the databases
+        User::Leave(err);
+        }
+    else if (err == KErrDiskFull)
+        {
+        iOutOfDisk = ETrue;
+        }
+    else
+        {
+        // do nothing
+        }
+
+    // Verify the volume ids of each drive matches the database
+    MPX_TRAP(err,VerifyVolumeIdL());
+    if ((err != KErrNone) && (err != KErrDiskFull))
+        {
+        // leave to signal the caller that there was an error why creating and opening
+        // one or more of the databases
+        User::Leave(err);
+        }
+    else if (err == KErrDiskFull)
+        {
+        iOutOfDisk = ETrue;
+        }
+
+//#ifdef _DEBUG
+//    iDbManager->PrintDatabaseL();    // PREQ2536 the files sqlrowsetutil.h and sqlrowsetutil.cpp has been removed
+//#endif
+
+    MPX_DEBUG2("CMPXDbHandler::ConstructL DbCount[%d]", iDbManager->DatabaseCount());
+    }
+
+// ----------------------------------------------------------------------------
+// Add song to collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddSongL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::AddSongL");
+
+    BeginTransactionL();
+    TUint32 songId(0);
+    MPX_TRAPD(err, songId = DoAddSongL(aMedia,aMessageArray));
+
+    if (iOutOfDisk && (err == KErrNotFound))
+        {
+        err = KErrDiskFull;
+        }
+    EndTransactionL(err);
+
+    return songId;
+    }
+
+// ----------------------------------------------------------------------------
+// Add song to collection with no database transaction
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddSongWithNoTransactionL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::AddSongWithNoTransactionL");
+
+    TUint32 songId(0);
+    MPX_TRAPD(err, songId = DoAddSongL(aMedia,aMessageArray));
+
+    if (iOutOfDisk && (err == KErrNotFound))
+        {
+        err = KErrDiskFull;
+        }
+    User::LeaveIfError(err);
+
+    return songId;
+    }
+
+// ----------------------------------------------------------------------------
+// Add playlist to collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddPlaylistL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::AddPlaylistL");
+
+    BeginTransactionL();
+    TUint32 playlistId(0);
+    MPX_TRAPD(err, playlistId = DoAddPlaylistL(aMedia));
+    EndTransactionL(err);
+
+    return playlistId;
+    }
+
+// ----------------------------------------------------------------------------
+// Add song to playlist
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddSongToPlaylistL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::AddSongToPlaylistL");
+
+    BeginTransactionL();
+    TUint32 playlistId(0);
+    MPX_TRAPD(err, playlistId = DoAddSongToPlaylistL(aMedia));
+    EndTransactionL(err);
+
+    return playlistId;
+    }
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// ----------------------------------------------------------------------------
+// Add AbstractAlbum to collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddAbstractAlbumL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::AddAbstractAlbumL");
+
+    BeginTransactionL();
+   // TUint32 abstractAlbumId(0);
+    TBool newRecord(EFalse);
+    TInt err(KErrNone);
+
+    TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
+    TPtrC name(aMedia.ValueText(KMPXMediaGeneralUri).Left(KMCMaxTextLen));
+    TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
+    TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen));
+    
+    //only insert to AbstractAlbum table when it is new item  
+     TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, name, (EMPXAbstractAlbum!=EMPXGenre)));      
+   
+    newRecord = !iDbAbstractAlbum->CategoryItemExistsL(drive, abstractAlbumId);
+   
+    
+    if (newRecord)   
+        {
+        MPX_TRAP(err, abstractAlbumId = iDbAbstractAlbum->AddItemL( name, albumartist, genre, drive, newRecord, (EMPXAbstractAlbum != EMPXGenre)));      
+        if (iOutOfDisk && (err == KErrNotFound))
+            {
+            err = KErrDiskFull;
+            }
+        if (aMessageArray)
+            {
+            MPXDbCommonUtil::AddItemChangedMessageL(*aMessageArray, abstractAlbumId, EMPXItemInserted,
+            EMPXAbstractAlbum, KDBPluginUid);
+            }
+        }
+    EndTransactionL(err);
+
+    return abstractAlbumId;  
+    }
+
+// ----------------------------------------------------------------------------
+// Update all songs which associate with AbstractAlbum in the collection
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateAbstractAlbumSongsL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::UpdateAbstractAlbumSongsL");
+
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+
+    if (aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        const TDesC& art(aMedia.ValueText (KMPXMediaGeneralUri));
+    
+        TBool existRecord(EFalse); 
+        TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
+        TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, art, (EMPXAbstractAlbum != EMPXGenre)));    
+        //check if abstractAlbum in ABSTRACTALBUM table before update songs
+        existRecord = iDbAbstractAlbum->CategoryItemExistsL(drive, rowId);
+         
+        //update songs associated with abstractalbum only when abstractalbum associated already
+        //in the AbstractAlbum table     
+        if (existRecord)
+            {         
+            if (aMedia.IsSupported(KMPXMediaArrayContents))
+                {
+
+                CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+                User::LeaveIfNull(mediaArray);
+                TInt count(mediaArray->Count());
+                for (TInt i = 0; i < count; i++)
+                    {
+                    CMPXMedia* element = mediaArray->AtL(i);
+                    element->SetTextValueL(KMPXMediaMusicAlbumArtFileName, art );
+                    visibleChange = UpdateSongL(*element, aItemChangedMessages);
+                    }
+               }
+            else
+                {
+                iDbAbstractAlbum->UpdateItemL(rowId, aMedia, drive, &aItemChangedMessages);
+                }
+          }
+        }
+    return visibleChange;
+}
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+// ----------------------------------------------------------------------------
+// Update a song in the collection
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::UpdateSongL");
+
+    BeginTransactionL();
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+    MPX_TRAPD(err, visibleChange = DoUpdateSongL(aMedia, aItemChangedMessages));
+    EndTransactionL(err);
+    return visibleChange;
+    }
+
+// ----------------------------------------------------------------------------
+// Update a playlist in the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::UpdatePlaylistL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::UpdatePlaylistL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoUpdatePlaylistL(aMedia, aMessageArray));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Updates the playlist songs
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::UpdatePlaylistSongsL(
+    const CMPXMedia& aMedia,
+    CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbHandler::UpdatePlaylistSongsL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoUpdatePlaylistSongsL(aMedia, aMessage));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Reorder a song in a playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::ReorderPlaylistL(
+    const TMPXItemId& aPlaylistId,
+    const TMPXItemId& aSongId,
+    TUint aOriginalOrdinal,
+    TUint aNewOrdinal,
+    CMPXMessage& aMessage)
+    {
+    MPX_DEBUG5("-->CMPXDbHandler::ReorderPlaylistL(0x%x, 0x%x, %d, %d)",
+               aPlaylistId.iId2, aSongId.iId2, aOriginalOrdinal, aNewOrdinal);
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoReorderPlaylistL(aPlaylistId, aSongId, aOriginalOrdinal, aNewOrdinal, aMessage));
+    EndTransactionL(err);
+    MPX_DEBUG2("<--CMPXDbHandler::ReorderPlaylistL() error=%d", err);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove the entire music collection database
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveEntireCollectionL()
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveEntireCollectionL");
+    BeginTransactionL();
+    MPX_TRAPD(err, iDbManager->RecreateAllDatabasesL());
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Delete a song from collection
+// The function notifies collection model to perform deletion
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveSongL(
+    TUint32 aSongId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages,
+    TBool aDeleteRecord)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveSongL");
+
+    MPX_TRAPD(err, DoRemoveSongL(aSongId, aUriArray, aItemChangedMessages, aDeleteRecord));
+
+    MPX_TRAP(err, DoRemoveSongFromPlaylistL(aSongId,aItemChangedMessages));
+
+    }
+
+// ----------------------------------------------------------------------------
+// Removes a category of songs from the music collection,
+// and its corresponding category in the lookup table
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveSongsMatchingCategoryL(
+    TMPXGeneralCategory aCategory,
+    TUint32 aCategoryId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingCategoryL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoRemoveSongsMatchingCategoryL(aCategory, aCategoryId, aUriArray, aItemChangedMessages));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Delete songs for the specified artist and album from collection
+// The function notifies collection model to perform deletion
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL(
+    TUint32 aArtistId,
+    TUint32 aAlbumId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoRemoveSongsMatchingArtistAndAlbumL(aArtistId, aAlbumId, aUriArray,
+        aItemChangedMessages));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove all playlists from collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveAllPlaylistsL()
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveAllPlaylistsL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoRemoveAllPlaylistsL());
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove specified playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemovePlaylistL(
+    TUint32 aPlaylistId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemovePlaylistL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoRemovePlaylistL(aPlaylistId, aUriArray, aItemChangedMessages));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove song from playlist songs table
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveSongFromPlaylistL(
+    TUint32 aPlaylistId,
+    const TMPXItemId& aSongId,
+    TInt aOrdinal,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveSongFromPlaylistL");
+    MPX_DEBUG5("CMPXDbHandler::RemoveSongFromPlaylistL(playlist 0x%x, songId [0x%x,0x%x], ordinal %d)",
+        aPlaylistId, aSongId.iId1, aSongId.iId2, aOrdinal);
+
+    MPX_TRAPD(err, DoRemoveSongFromPlaylistL(aPlaylistId, aSongId, aOrdinal, aItemChangedMessages));
+    if ( err && InTransaction() )
+        {
+        // only end transaction if there's an error
+        EndTransactionL( err );
+        }
+    }
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// ----------------------------------------------------------------------------
+// Remove specified abstractalbum
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RemoveAbstractAlbumL(
+    TUint32 aAbstractAlbumId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoRemoveAbstractAlbumL(aAbstractAlbumId, aUriArray, aItemChangedMessages));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove specified abstractalbum
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveAbstractAlbumL(
+    TUint32 aAbstractAlbumId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveAbstractAlbumL");
+
+
+    HBufC* uri(iDbAbstractAlbum->DeleteAbstractAlbumL(aAbstractAlbumId));
+    if (uri)
+        {
+        CleanupStack::PushL(uri);
+        aUriArray.AppendL(*uri);
+        CleanupStack::PopAndDestroy(uri);
+        }
+
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aAbstractAlbumId, EMPXItemDeleted,
+        EMPXAbstractAlbum, KDBPluginUid);
+
+   
+    }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// ----------------------------------------------------------------------------
+// Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted
+// at the end of its session.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::CleanupDeletedRecordsL()
+    {
+    MPX_FUNC("CMPXDbHandler::CleanupDeletedRecordsL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, DoCleanupDeletedRecordsL());
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+//  Read all songs and cache them into an array ordered by song name
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllSongsL(
+    CMPXMediaArray* aMediaArray,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllSongsL");
+    iDbMusic->GetAllSongsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+//  Read a limited # of songs and cache them into an array ordered by song name
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,
+                                        CMPXMediaArray& aMediaArray, TInt aLimit)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllSongsLimitedL");
+    iDbMusic->GetAllSongsLimitedL( aAttrs, aMediaArray, aLimit );
+    }
+
+// ----------------------------------------------------------------------------
+//  Read all songs and cache them into an array ordered by song name
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsInBlockL(
+    CMPXMediaArray* aMediaArray,
+    const TArray<TMPXAttribute>& aAttrs,
+    TPtrC aTitle,
+    TUint aNumOfSongs,
+    TBool aAsc)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsInBlockL");
+    iDbMusic->GetSongsInBlockL(aAttrs, *aMediaArray, aTitle, aNumOfSongs, aAsc);
+    }
+
+// ----------------------------------------------------------------------------
+//  Read songs at a particular offset
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsAtOffsetL( CMPXMediaArray* aMediaArray,
+                                       const TArray<TMPXAttribute>& aAttrs,
+                                       TInt aOffset,
+                                       TInt aCount )
+    {
+    MPX_DEBUG1("CMPXDbHandler::GetSongsAtOffsetL <--");
+    iDbMusic->GetSongsAtOffsetL( *aMediaArray, aAttrs, aOffset, aCount );
+    }
+
+// ----------------------------------------------------------------------------
+// Get all songs matching the given artist ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingArtistL(
+    TUint aArtistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingArtistL");
+    iDbMusic->GetSongsForArtistL(aArtistId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all songs matching the given album ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingAlbumL(
+    TUint aAlbumId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingAlbumL");
+    iDbMusic->GetSongsForAlbumL(aAlbumId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Get all songs matching the given artist and album ID
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingArtistAndAlbumL(
+    TUint aArtistId,
+    TUint aAlbumId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingArtistAndAlbumL");
+    iDbMusic->GetSongsForArtistAndAlbumL(aArtistId, aAlbumId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all songs matching the given genre ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingGenreL(
+    TUint aGenreId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingGenreL");
+    iDbMusic->GetSongsForGenreL(aGenreId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all songs matching the given composer ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingComposerL(
+    TUint aComposerId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingComposerL");
+    iDbMusic->GetSongsForComposerL(aComposerId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all songs that belong to the given playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongsMatchingPlaylistL(
+    TUint aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongsMatchingPlaylistL");
+    GetPlaylistSongsL(aPlaylistId, aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get song matching the given song ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongL(
+    TUint32 aSongId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongL");
+    iDbMusic->GetSongL(aSongId, aAttrs, aMedia);
+    }
+
+// ----------------------------------------------------------------------------
+// GetSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetSongL(
+    TUint32 aSongId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongL");
+
+    CMPXMedia* media = CMPXMedia::NewL();
+    CleanupStack::PushL(media);
+
+    GetSongL(aSongId, aAttrs, *media);
+    aMediaArray.AppendL(*media);
+
+    CleanupStack::PopAndDestroy(media);
+    }
+
+// ----------------------------------------------------------------------------
+// Get song matching the given song ID and playlist ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetPlaylistSongL(
+    TUint32 aSongId,
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_DEBUG3("-->CMPXDbHandler::GetPlaylistSongL songId[0x%x] playlistId[0x%x]", aSongId, aPlaylistId);
+
+    // complete the song information from the Music table
+    MPX_TRAPD(err, iDbMusic->GetSongL(aSongId, aAttrs, aMedia));
+
+    //
+    // song not found in Music table
+    //
+    if (err == KErrNotFound)
+        {
+        //
+        // Leave with KErrNotFound if one of the following is true:
+        // 1) the requested song is in an auto playlist. Since auto-playlist isn't
+        //    stored in playlist tables, we won't be able to retrieve info elsewhere
+        // 2) the requested song is in a user playlist but we cannot find the song
+        //    info from playlist tables either
+        //
+        if (EMPXNoAutoPlaylist != iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) ||
+            !iDbPlaylist->Songs().GetSongL(aPlaylistId, aSongId, aAttrs, aMedia))
+            {
+            User::Leave(KErrNotFound);
+            }
+        }
+
+    //
+    // Unable to read information from Music table
+    //
+    else
+        {
+        // ignore the error if KErrNotFound
+        User::LeaveIfError(err);
+        }
+    MPX_DEBUG1("<--CMPXDbHandler::GetPlaylistSongL");
+    }
+
+// ----------------------------------------------------------------------------
+// GetPlaylistSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetPlaylistSongL(
+    TUint32 aSongId,
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistSongL");
+
+    CMPXMedia* media = CMPXMedia::NewL();
+    CleanupStack::PushL(media);
+
+    GetPlaylistSongL(aSongId, aPlaylistId, aAttrs, *media);
+    aMediaArray.AppendL(*media);
+
+    CleanupStack::PopAndDestroy(media);
+    }
+
+// ----------------------------------------------------------------------------
+// Get song matching the given URI
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::GetSongIdMatchingUriL(
+    const TDesC& aUri)
+    {
+    MPX_FUNC("CMPXDbHandler::GetSongIdMatchingUriL");
+    return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, aUri, EFalse);
+    }
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// ----------------------------------------------------------------------------
+// Get abstractalbum Id matching the given URI
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::GetAbstractAlbumIdMatchingUriL(
+    const TDesC& aUri)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAbstractAlbumIdMatchingUriL");
+    return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, aUri, ETrue);
+    }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// ----------------------------------------------------------------------------
+// Get all artists
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllArtistsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllArtistsL");
+    iDbArtist->GetAllCategoryItemsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all albums
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllAlbumsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllAlbumsL");
+    iDbAlbum->GetAllCategoryItemsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all albums for the given artist ID
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAlbumsMatchingArtistL(
+    TUint aArtistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAlbumsMatchingArtistL");
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL( attributes );
+        
+    TBool tryGetSongCount = EFalse;
+    TInt attrCount(aAttrs.Count());
+    TInt i = 0;
+    for (i = 0; i < attrCount; i++)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+        TUint attributeId(aAttrs[i].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral && attributeId & EMPXMediaGeneralCount)
+            {
+            MPX_DEBUG1("    EMPXMediaGeneralCount");
+
+            attributes.Append(TMPXAttribute(KMPXMediaIdGeneral, attributeId & ~EMPXMediaGeneralCount));
+
+            tryGetSongCount = ETrue;
+            break;
+            }
+        
+        attributes.Append(aAttrs[i]);
+        }
+    
+    for (TInt j = i+1; j < attrCount; j++)
+        {
+        attributes.Append(aAttrs[j]);
+        }
+    iDbAlbum->GetSubCategoryItemsL(EMPXArtist, aArtistId, attributes.Array(), aMediaArray);
+    CleanupStack::PopAndDestroy(&attributes);
+    
+    TInt pPath(0);
+    if (aMediaArray.Count())
+        {
+        CMPXMedia* pMedia = aMediaArray[0];
+        if (pMedia->IsSupported(KMPXMediaGeneralValue))
+            {
+            pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+            MPX_ASSERT(pPath);
+            }
+        }
+    
+    TInt albumCount(aMediaArray.Count());
+    if (albumCount)
+        {
+        if ( tryGetSongCount )
+            {
+            TInt startIndex = pPath ? 1 : 0;
+            
+            for (TInt i = startIndex; i < albumCount; i++)
+                {
+                CMPXMedia* media = aMediaArray[i];
+                TUint32 albumId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
+
+				TInt songCount = iDbAlbum->GetSongsCountInAlbumMatchingArtistL(aArtistId, albumId);
+
+                media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
+                MPX_DEBUG2("    SongCount[%d]", songCount );
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Get all genres
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllGenresL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllGenresL");
+    iDbGenre->GetAllCategoryItemsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all composers
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllComposersL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllComposersL");
+    iDbComposer->GetAllCategoryItemsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get the playlist ID of the playlist that matches the given URI
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::GetPlaylistIdMatchingUriL(
+    const TDesC& aUri)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistIdMatchingUriL");
+    return iDbPlaylist->GetIdL(aUri);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::IsAutoPlaylistL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::IsAutoPlaylistL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbHandler::IsAutoPlaylistL");
+    return (iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) != EMPXNoAutoPlaylist);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all user playlist names
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllPlaylistsL(
+    CMPXMediaArray* aMediaArray,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllPlaylistsL");
+    iDbPlaylist->GetAllPlaylistsL(aAttrs, *aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all system playlist names
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetAllSystemPlaylistNamesL(
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllSystemPlaylistNamesL()");
+    iAutoPlaylist->GetAllPlaylistsL(*aMediaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Get the name of the row matching the given ID
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbHandler::GetNameMatchingIdL(
+    const TUint32 aId) const
+    {
+    MPX_FUNC("CMPXDbHandler::GetNameMatchingIdL()");
+
+    HBufC* name(NULL);
+    TMPXGeneralCategory category(MPX_ITEM_CATEGORY(aId));
+    switch (category)
+        {
+        case EMPXCollection:
+            {
+            // song name
+            name = iDbMusic->GetNameL(aId);
+            break;
+            }
+        case EMPXPlaylist:
+            {
+            // playlist name
+            if (iAutoPlaylist->AutoPlaylistTypeL(aId) != EMPXNoAutoPlaylist)
+                {
+                name = iAutoPlaylist->AutoPlaylistNameL(aId).AllocL();
+                }
+            else
+                {
+                name = iDbPlaylist->GetNameL(aId);
+                }
+            break;
+            }
+        default:
+            {
+            // category name
+            name = DbCategoryL(category)->GetNameL(aId);
+            break;
+            }
+        }
+
+    return name;
+    }
+
+// ----------------------------------------------------------------------------
+// Get the URI of the row matching the given ID
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbHandler::GetUriMatchingIdL(
+    const TUint32 aId) const
+    {
+    MPX_FUNC("CMPXDbHandler::GetUriMatchingIdL");
+
+    HBufC* uri(NULL);
+    switch (MPX_ITEM_CATEGORY(aId))
+        {
+        case EMPXCollection:
+            {
+            // song URI
+            uri = iDbMusic->GetUriL(aId);
+            break;
+            }
+        case EMPXPlaylist:
+            {
+            // playlist URI
+            uri = iDbPlaylist->GetUriL(aId);
+            break;
+            }
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    return uri;
+    }
+
+// ----------------------------------------------------------------------------
+// Get category
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetCategoryL(
+    const TUint32 aCategoryId,
+    TMPXGeneralCategory aCategory,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia* aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::GetCategoryL");
+
+    switch (aCategory)
+        {
+        case EMPXPlaylist:
+            {
+            if (iAutoPlaylist->AutoPlaylistTypeL(aCategoryId) != EMPXNoAutoPlaylist)
+                {
+                iAutoPlaylist->GetPlaylistL(aCategoryId, aAttrs, *aMedia);
+                }
+            else
+                {
+                iDbPlaylist->GetPlaylistL(aCategoryId, aAttrs, *aMedia);
+                }
+            break;
+            }
+        default:
+            {
+            DbCategoryL(aCategory)->GetCategoryItemL(aCategoryId, aAttrs, *aMedia);
+            break;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for all songs
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetAllSongsDurationL()
+    {
+    MPX_FUNC("CMPXDbHandler::GetAllSongsDurationL");
+    return iDbMusic->AllSongsDurationL();
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for an artist
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetArtistDurationL(
+    TInt aArtistId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetArtistDurationL");
+    return iDbMusic->ArtistDurationL(aArtistId);
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for an album
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetAlbumDurationL(
+    TInt aAlbumId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetAlbumDurationL");
+    return iDbMusic->AlbumDurationL(aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for an artist/album combination
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetArtistAlbumDurationL(
+    TInt aArtistId,
+    TInt aAlbumId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetArtistAlbumDurationL");
+    return iDbMusic->ArtistAlbumDurationL(aArtistId, aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for a composer
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetComposerDurationL(
+    TInt aComposerId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetComposerDurationL");
+    return iDbMusic->ComposerDurationL(aComposerId);
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for a genre
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetGenreDurationL(
+    TInt aGenreId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetGenreDurationL");
+    return iDbMusic->GenreDurationL(aGenreId);
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for a user playlist
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetUserPlaylistDurationL(
+    TInt aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetUserPlaylistDurationL");
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL(attributes);
+    attributes.AppendL(KMPXMediaGeneralId);
+    attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralDuration));
+
+    CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
+    CleanupStack::PushL(mediaArray);
+
+    GetPlaylistSongsL(aPlaylistId, attributes.Array(), *mediaArray);
+
+    TInt duration(0);
+    TInt count(mediaArray->Count());
+    for (TInt index = 0; index < count; ++index)
+        {
+        CMPXMedia* media((*mediaArray)[index]);
+        if (media->IsSupported(KMPXMediaGeneralDuration))
+            {
+            duration += media->ValueTObjectL<TInt>(KMPXMediaGeneralDuration);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(mediaArray);
+    CleanupStack::PopAndDestroy(&attributes);
+
+    return duration;
+    }
+
+// ----------------------------------------------------------------------------
+//  Get the duration for a playlist
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::GetPlaylistDurationL(
+    TInt aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistDurationL");
+
+    TInt duration(0);
+
+    if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist))
+        {
+        duration = iDbMusic->RecentlyPlayedDurationL();
+        }
+    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist))
+        {
+        duration = iDbMusic->MostPlayedDurationL();
+        }
+    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyAddedPlaylist))
+        {
+        duration = iDbMusic->RecentlyAddedDurationL();
+        }
+    else
+        {
+        duration = GetUserPlaylistDurationL(aPlaylistId);
+        }
+
+    return duration;
+    }
+
+// ----------------------------------------------------------------------------
+// Find the number of items of a specified type
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbHandler::NumberOfItemsL(
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbHandler::NumberOfItemsL");
+
+    TInt count(0);
+    switch(aCategory)
+        {
+        case EMPXSong:
+            {
+            count = iDbMusic->CountL();
+            break;
+            }
+        case EMPXPlaylist:
+            {
+            // return the total number of playlists, including the system ones
+            count = iDbPlaylist->CountL() + EMPXAutoPlaylistCount;
+            break;
+            }
+        default:
+            {
+            count = DbCategoryL(aCategory)->CountL();
+            break;
+            }
+        }
+
+    return count;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::FindAllLC
+// ----------------------------------------------------------------------------
+//
+CMPXMedia* CMPXDbHandler::FindAllLC(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbHandler::FindAllLC");
+
+    // leave if the given media doesn't contain the following attributes
+    if (!aCriteria.IsSupported(KMPXMediaGeneralType) ||
+        !aCriteria.IsSupported(KMPXMediaGeneralCategory))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    RArray<TInt> supportedIds;
+    CleanupClosePushL(supportedIds);
+    supportedIds.AppendL(KMPXMediaIdContainer);
+    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
+
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+
+    FindAllL(aCriteria, aAttrs, array);
+
+    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory,
+        aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory));
+    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+
+    CleanupStack::PopAndDestroy(array);
+    return entries;
+    }
+
+// ----------------------------------------------------------------------------
+// Set the last refreshed time into the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::SetLastRefreshedTimeL(
+    TTime aTime)
+    {
+    MPX_FUNC("CMPXDbHandler::SetLastRefreshedTimeL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, iDbAuxiliary->SetLastRefreshedTimeL(aTime));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Get the last refreshed time from the collection
+// ----------------------------------------------------------------------------
+//
+TTime CMPXDbHandler::GetLastRefreshedTimeL()
+    {
+    MPX_FUNC("CMPXDbHandler::GetLastRefreshedTimeL");
+    return iDbAuxiliary->LastRefreshedTimeL();
+    }
+
+// ----------------------------------------------------------------------------
+// Set the db corrupted state for all drives
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::SetDBCorruptedL(
+    TBool aCorrupted)
+    {
+    MPX_FUNC("CMPXDbHandler::SetDBCorruptedL");
+
+    BeginTransactionL();
+    MPX_TRAPD(err, iDbAuxiliary->SetDBCorruptedL(aCorrupted));
+    EndTransactionL(err);
+    }
+
+// ----------------------------------------------------------------------------
+// Gets the db corrupted state for all drives
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::IsDBCorruptedL()
+    {
+    MPX_FUNC("CMPXDbHandler::IsDBCorruptedL");
+    return iDbAuxiliary->DBCorruptedL();
+    }
+
+// ----------------------------------------------------------------------------
+// Have the databases been created?
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::DatabaseCreated()
+    {
+    MPX_FUNC("CMPXDbHandler::DatabaseCreatedL");
+
+    TBool AuxilaryDbIsRefreshed(EFalse);
+    TRAP_IGNORE(AuxilaryDbIsRefreshed = iDbAuxiliary->IsRefreshedL());
+    // If none of the databases were available, ie out of disk we return EFalse
+    return iDbManager->IsInitialized() && AuxilaryDbIsRefreshed;
+    }
+
+// ----------------------------------------------------------------------------
+// Open a database
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::OpenDatabaseL(
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbHandler::OpenDatabaseL");
+    MPX_DEBUG2( "CMPXDbHandler::OpenDatabaseL: %i", aDrive);
+    iDbManager->OpenDatabaseL(aDrive);
+
+    // Verify the volume ID after a remount event
+    VerifyVolumeIdL( aDrive );
+    }
+
+// ----------------------------------------------------------------------------
+// Close a database
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::CloseDatabaseL(
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbHandler::CloseDatabaseL");
+    MPX_DEBUG2( "CMPXDbHandler::CloseDatabaseL drive: %i", aDrive );
+    iDbManager->CloseDatabaseL(aDrive);
+    }
+
+// ----------------------------------------------------------------------------
+// Re-create all databases
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::ReCreateDatabasesL()
+    {
+    MPX_FUNC("CMPXDbHandler::ReCreateDatabasesL");
+    iDbManager->RecreateAllDatabasesL();
+    }
+
+// ----------------------------------------------------------------------------
+// Set handler refresh status
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::RefreshStartL()
+    {
+    MPX_FUNC("CMPXDbHandler::RefreshStartL");
+
+    iOutOfDisk = EFalse;
+    // Re-open databases
+    // This is needed for the case where we were OOD before, but user
+    // has cleared some space but now try to refresh
+    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
+    iCollectionOpen = ETrue;
+    // Update (synchronize) music basic table if it's not
+    // in sync with music table
+    if(iSynchronizeBasicTable)
+        {
+        iDbMusic->RefreshEndL();
+        }
+    iSynchronizeBasicTable = ETrue;
+
+    if(err == KErrDiskFull)
+        {
+            iOutOfDisk = ETrue;
+        }
+
+    if(!iOutOfDisk)
+    {
+        MPX_TRAP(err,CheckDiskSpaceOnDrivesL());
+
+        if(err == KErrDiskFull)
+            {
+            iOutOfDisk = ETrue;
+            }
+    }
+    
+#ifdef __RAMDISK_PERF_ENABLE
+    iDbManager->CopyDBsToRamL();
+#endif //__RAMDISK_PERF_ENABLE
+    iDbMusic->RefreshStartL();
+
+    BeginTransactionL();
+    iRefresh = ETrue;
+    }
+
+// ----------------------------------------------------------------------------
+// Re-set handler refresh status
+// ----------------------------------------------------------------------------
+//
+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);
+        }
+    iDbMusic->RefreshEndL();
+    //Update of music basic table fails when the collection is not open
+    //Next time the collection is opened the music basic table must be updated
+    if (iCollectionOpen )
+        {
+        iSynchronizeBasicTable = EFalse;
+        }
+
+#ifdef __RAMDISK_PERF_ENABLE
+    iDbManager->CopyDBsFromRamL();
+#endif //__RAMDISK_PERF_ENABLE
+    }
+
+// ----------------------------------------------------------------------------
+// Notification of Mtp status change
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::MtpStartL()
+    {
+    MPX_DEBUG1("-->CMPXDbHandler::MtpStartL");
+    if(!iMtpInUse)
+        {
+        iMtpInUse = ETrue;
+        iOpOnDbCount = 0;
+    
+    #ifdef __RAMDISK_PERF_ENABLE
+        TRAPD(err, iDbManager->CopyDBsToRamL(iMtpInUse));
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CMPXDbHandler::MtpStartL error=%d", err);
+            }
+    #endif //__RAMDISK_PERF_ENABLE
+    
+        iDbManager->BeginL();
+        }
+    MPX_DEBUG1("<--CMPXDbHandler::MtpStartL");
+    }
+
+// ----------------------------------------------------------------------------
+// Notification of Mtp status change
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::MtpEndL()
+    {
+    MPX_DEBUG1("-->CMPXDbHandler::MtpEndL");
+    iMtpInUse = EFalse;
+    iOpOnDbCount = 0;
+    iDbManager->CommitL();
+
+#ifdef __RAMDISK_PERF_ENABLE
+    TRAPD(err, iDbManager->CopyDBsFromRamL());
+    if ( err != KErrNone )
+        {
+        MPX_DEBUG2("CMPXDbHandler::MtpEndL error=%d", err);
+        }
+#endif //__RAMDISK_PERF_ENABLE
+    
+    MPX_DEBUG1("<--CMPXDbHandler::MtpEndL");
+    }
+
+// ----------------------------------------------------------------------------
+// Get all records count for music
+// ----------------------------------------------------------------------------
+//
+TUint CMPXDbHandler::GetMusicCountL(TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbHandler::GetMusicCountL");
+    TUint total(0);
+
+    //music
+    total += iDbMusic->GetDriveTrackCountL(aDrive);
+
+    return total;
+    }
+
+// ----------------------------------------------------------------------------
+// Get all records count for playlists
+// ----------------------------------------------------------------------------
+//
+TUint CMPXDbHandler::GetPlaylistCountL(TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistCountL");
+    TUint total(0);
+
+    //playlist
+    total += iDbPlaylist->GetDrivePlaylistCountL(aDrive);
+
+    return total;
+    }
+
+// ----------------------------------------------------------------------------
+// Get all records count for music and playlists
+// ----------------------------------------------------------------------------
+//
+TUint CMPXDbHandler::GetTotalCountL(TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbHandler::GetTotalCountL");
+    TUint total(0);
+
+    //music
+    total += iDbMusic->GetDriveTrackCountL(aDrive);
+    //playlist
+    total += iDbPlaylist->GetDrivePlaylistCountL(aDrive);
+
+    return total;
+    }
+
+// ----------------------------------------------------------------------------
+// Get all records count for music and playlists
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                      CDesCArray& aUriArr, TInt& aLastID)
+    {
+    MPX_FUNC("CMPXDbHandler::GetMusicUriArrayL");
+
+    iDbMusic->GetMusicUriArrayL(aDrive,aFromID,aRecords,aUriArr,aLastID);
+    }
+
+// ----------------------------------------------------------------------------
+// Get all records count for music and playlists
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                         CDesCArray& aUriArr, TInt& aLastID)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistUriArrayL");
+
+    iDbPlaylist->GetPlaylistUriArrayL(aDrive,aFromID,aRecords,aUriArr,aLastID);
+    }
+
+// ----------------------------------------------------------------------------
+// Starts a transaction on all databases
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::BeginTransactionL()
+    {
+    MPX_FUNC("CMPXDbHandler::BeginTransactionL");
+
+#ifdef __RAMDISK_PERF_ENABLE
+    // EnsureRamSpaceL will copy dbs from ram if ram space is low or dbs exceeded
+    // max space.
+	TRAPD(err, iDbManager->EnsureRamSpaceL());
+	if (err)
+		{
+		//error but continue
+		}
+#endif //__RAMDISK_PERF_ENABLE
+
+    if(!iMtpInUse)
+        {
+        iDbManager->BeginL();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Ends a transaction on all databases
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::EndTransactionL(
+    TInt aError)
+    {
+    MPX_FUNC("CMPXDbHandler::EndTransactionL");
+
+    if(iMtpInUse)
+        {
+        if (aError)
+            {
+            iOpOnDbCount = 0;
+            iDbManager->RollbackL();
+            User::Leave(aError);
+            }
+        
+        if(iOpOnDbCount >= KMaxOpInTransaction)
+            {
+            MPX_DEBUG2("CMPXDbHandler::EndTransactionL - %d>KMaxOpInTransaction Commiting",iOpOnDbCount);
+            iOpOnDbCount = 0;
+            iDbManager->CommitL();
+            iDbManager->BeginL();
+            }        
+        }
+    else
+        {
+        if (aError)
+            {
+            MPX_DEBUG2("CMPXDbHandler::EndTransactionL - Rollback [%d]", aError);
+
+            iDbManager->RollbackL();
+            
+            // KSqlDbCorrupted indicates DB corrupted, need to recreate.
+            if ( aError != KSqlDbCorrupted )
+                {
+                User::Leave(aError);
+                }
+            }
+        else
+            {
+            iDbManager->CommitL();
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Checks if the database is currently in a transaction
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::InTransaction()
+    {
+    MPX_FUNC("CMPXDbHandler::InTransaction");
+    return iDbManager->InTransaction();
+    }
+
+// ----------------------------------------------------------------------------
+// Notifies the handler that the collection will be closed.
+// It is called before closing the collection.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::PreCloseCollectionL()
+    {
+    MPX_FUNC("CMPXDbHandler::PreCloseCollectionL");
+    // Complete pending transaction and set the latest refresh time
+    // before closing the databases if collection close event occurs
+    // before the end of the refresh operation
+    if(iRefresh)
+        {
+        EndTransactionL(KErrNone);
+        if (!iOutOfDisk)
+            {
+            // Write last refreshed time as current time
+            // This also sets corrupt = 0
+            TTime curTime;
+            curTime.HomeTime();
+            SetLastRefreshedTimeL(curTime);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Notifies the handler that the collection was closed.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::CollectionClosed()
+    {
+    MPX_FUNC("CMPXDbHandler::CollectionClosed");
+
+    iCollectionOpen = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+//Notifies the handler that the collection was opened.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::CollectionOpenedL()
+    {
+    MPX_FUNC("CMPXDbHandler::CollectionOpened");
+
+    iCollectionOpen = ETrue;
+    // Update (synchronize) music basic table if it's not
+    // in sync with music table
+    if(iSynchronizeBasicTable)
+        {
+        iDbMusic->RefreshEndL();
+        iSynchronizeBasicTable = EFalse;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Add song to collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::DoAddSongL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::DoAddSongL");
+
+    if (!aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    // add the song to the Music table
+    TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
+    TUint32 songId(iDbMusic->AddSongL(aMedia, drive,
+                                      iRefresh?NULL:aMessageArray));
+
+    // update the playlist tables
+    // make sure the song db flags are reset and not just updated
+    iDbPlaylist->UpdateSongL(aMedia, ETrue);
+    
+    if(iMtpInUse)
+        {
+        ++iOpOnDbCount;
+        }
+
+    return songId;
+    }
+
+// ----------------------------------------------------------------------------
+// Add playlist to collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::DoAddPlaylistL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::DoAddPlaylistL");
+
+    CMPXMedia* media = CMPXMedia::NewL(aMedia);
+    CleanupStack::PushL(media);
+
+    const TDesC& playlistUri = media->ValueText(KMPXMediaGeneralUri);
+
+    //
+    // client has asked to create a virtual playlist if file name is not specified
+    // in the URI. In this case, generate URI for virtual playlist specified as
+    // follows:
+    //          <dir path>\timestamp.vir
+    //
+    TParsePtrC parser(playlistUri);
+
+    if (!parser.NameOrExtPresent() ||
+        parser.IsNameWild() ||
+        parser.IsExtWild())
+        {
+        HBufC* newUri = HBufC::NewLC(parser.DriveAndPath().Length() + KMCMaxTextLen +
+            KMPXVirtualPlaylistExt().Length());
+
+        TPtr ptr = newUri->Des();
+        ptr.Append(parser.DriveAndPath());
+        TTime time;
+        time.HomeTime();
+        ptr.AppendNum(time.Int64());
+        ptr.Append(KMPXVirtualPlaylistExt);
+
+        // overwrite the old uri with the new one with full path and playlist
+        // playlist filename
+        media->SetTextValueL(KMPXMediaGeneralUri, *newUri);
+
+        CleanupStack::PopAndDestroy(newUri);
+
+        // set DbFlags to indicate that this is a virtual playlist
+        media->SetTObjectValueL<TUint>(KMPXMediaGeneralFlags,
+            KMPXMediaGeneralFlagsSetOrUnsetBit | KMPXMediaGeneralFlagsIsVirtual);
+        }
+
+    // complete the song attributes from the music table
+    UpdatePlaylistSongInfoL(*media);
+
+    // add playlist to the database
+    TUint32 playlistId = iDbPlaylist->AddPlaylistL(*media);
+
+    CleanupStack::PopAndDestroy(media);
+    return playlistId;
+    }
+
+// ----------------------------------------------------------------------------
+// Add song to playlist
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::DoAddSongToPlaylistL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::DoAddSongToPlaylistL");
+
+    CMPXMedia* media = CMPXMedia::NewL(aMedia);
+    CleanupStack::PushL(media);
+
+    // complete the song attributes from the music table
+    UpdatePlaylistSongInfoL(*media);
+
+    // add the songs to the playlist
+    TUint32 playlistId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+
+    CMPXMediaArray* ary( aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents) );
+    User::LeaveIfNull( ary );
+    iDbPlaylist->AddSongsL(playlistId,*ary);
+
+    CleanupStack::PopAndDestroy(media);
+    return playlistId;
+    }
+
+// ----------------------------------------------------------------------------
+// Update a song in the collection
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::DoUpdateSongL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoUpdateSongL");
+
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+
+    TUint32 songId(0);
+
+    if (aMedia.IsSupported(KMPXMediaGeneralId))
+        {
+        songId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+        }
+    if (aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
+        songId = MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, uri, EFalse);
+        }
+    if (!songId)
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    // Update the Music table
+    TRAPD(err, visibleChange = iDbMusic->UpdateSongL(songId, aMedia, aItemChangedMessages));
+
+    // do not leave if song is not found in Music table
+    // leave for other errors such as disk full
+    if(err != KErrNone && err != KErrNotFound)
+        {
+        User::Leave(err);
+        }
+
+    // Update the Playlist table
+    TBool visible = EFalse;
+
+    TRAP( err, visible = iDbPlaylist->UpdateSongL(aMedia, EFalse, &aItemChangedMessages));
+
+    // do not leave if song is not found in Playlist table
+    // leave for other errors such as disk full
+    if(err != KErrNone && err != KErrNotFound)
+        {
+        User::Leave(err);
+        }
+
+    // make it visible if either table is updated
+    if (visible)
+        {
+        visibleChange = CMPXDbActiveTask::EAllVisible;
+        }
+    if ( aMedia.ValueTObjectL<TInt>( KMPXMediaMusicAlbumArtChanged )== 1 )
+        {
+        ( const_cast<CMPXMedia*>( &aMedia ) 
+        		)->SetTObjectValueL<TInt>( KMPXMediaMusicAlbumArtChanged, 0 );
+        }
+
+    return visibleChange;
+    }
+
+// ----------------------------------------------------------------------------
+// Update a playlist in the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoUpdatePlaylistL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aMessageArray)
+    {
+    MPX_FUNC("CMPXDbHandler::DoUpdatePlaylistL");
+
+    TUint32 playlistId(0);
+    TInt drive(0);
+
+    CMPXMedia* media = CMPXMedia::NewL(aMedia);
+    CleanupStack::PushL(media);
+
+
+    ProcessPlaylistMediaL(*media, playlistId, drive);
+
+    CMPXMessage* m1 = CMPXMessage::NewL();
+    CleanupStack::PushL(m1);
+    CMPXMessage* m2 = CMPXMessage::NewL();
+    CleanupStack::PushL(m2);
+
+    // send 2 messages to notify the playlist change & to refresh the display (update playlist name)
+    MPXDbCommonUtil::FillItemChangedMessageL(*m1, playlistId, EMPXItemModified,
+            EMPXPlaylist, KDBPluginUid);
+
+    MPXDbCommonUtil::FillItemChangedMessageL(*m2, EBrowsePlaylist, EMPXItemModified,
+                EMPXPlaylist, KDBPluginUid);
+
+    iDbPlaylist->UpdatePlaylistL(*media, *m1, drive);
+
+    aMessageArray.AppendL(*m1);
+    aMessageArray.AppendL(*m2);
+
+
+    CleanupStack::PopAndDestroy(m2);
+    CleanupStack::PopAndDestroy(m1);
+    CleanupStack::PopAndDestroy(media);
+    }
+
+// ----------------------------------------------------------------------------
+// Update a playlist in the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoUpdatePlaylistSongsL(
+    const CMPXMedia& aMedia,
+    CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbHandler::DoUpdatePlaylistSongsL");
+
+    CMPXMedia* media = CMPXMedia::NewL(aMedia);
+    CleanupStack::PushL(media);
+
+    TUint32 playlistId(0);
+    TInt drive(0);
+
+    // get the playlist ID and drive ID
+    ProcessPlaylistMediaL(*media, playlistId, drive);
+    MPXDbCommonUtil::FillItemChangedMessageL(aMessage, playlistId, EMPXItemModified,
+        EMPXPlaylist, KDBPluginUid);
+
+    // complete the song attributes from the Music table
+    UpdatePlaylistSongInfoL(*media);
+
+    // delete existing songs for the playlist first
+    iDbPlaylist->Songs().DeleteSongsL(playlistId, drive);
+
+    // add new songs to the playlist
+    CMPXMediaArray* ary( media->Value<CMPXMediaArray>(KMPXMediaArrayContents ) );
+    User::LeaveIfNull( ary );
+    iDbPlaylist->AddSongsL(playlistId, *ary);
+
+    CleanupStack::PopAndDestroy(media);
+    }
+
+// ----------------------------------------------------------------------------
+// Reorder a song in a playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoReorderPlaylistL(
+    const TMPXItemId& aPlaylistId,
+    const TMPXItemId& aSongId,
+    TUint aOriginalOrdinal,
+    TUint aNewOrdinal,
+    CMPXMessage& aMessage)
+    {
+    MPX_DEBUG1("-->CMPXDbHandler::DoReorderPlaylistL()");
+
+    if (aOriginalOrdinal != aNewOrdinal)
+        {
+        iDbPlaylist->Songs().ReorderSongL(aPlaylistId, aSongId, aOriginalOrdinal, aNewOrdinal);
+
+        MPXDbCommonUtil::FillItemChangedMessageL(aMessage, aPlaylistId.iId2, EMPXItemModified,
+            EMPXPlaylist, KDBPluginUid);
+        }
+
+    MPX_DEBUG1("<--CMPXDbHandler::DoReorderPlaylistL()");
+    }
+
+// ----------------------------------------------------------------------------
+// Delete a song from collection
+// The function notifies collection model to perform deletion
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveSongL(
+    TUint32 aSongId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages,
+    TBool aDeleteRecord)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveSongL");
+
+    // Get the song drive
+    TUint32 artistID(0);
+    TUint32 albumID(0);
+    TUint32 genreID(0);
+    TUint32 composerID(0);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    TUint32 abstractAlbumID(0);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    TInt drive(0);
+
+// Get information from the Music table first
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, abstractAlbumID, drive);
+#else
+    HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, drive);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+    // add the URI to the return array
+    CleanupStack::PushL(uri);
+    aUriArray.AppendL(*uri);
+    CleanupStack::PopAndDestroy(uri);
+
+    // Update the category records
+    TBool categoryExist( EFalse );
+    iDbArtist->DecrementSongsForCategoryL(artistID, drive, &aItemChangedMessages, categoryExist);
+    iDbAlbum->DecrementSongsForCategoryL(albumID, drive, &aItemChangedMessages, categoryExist, artistID);
+    iDbGenre->DecrementSongsForCategoryL(genreID, drive, &aItemChangedMessages, categoryExist);
+    iDbComposer->DecrementSongsForCategoryL(composerID, drive, &aItemChangedMessages, categoryExist);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    if (abstractAlbumID)
+        {
+        iDbAbstractAlbum->DecrementSongsForCategoryL(abstractAlbumID, drive, &aItemChangedMessages, categoryExist, iMtpInUse);
+        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    // Update the music table
+    TBool deleteRecord(ETrue);
+
+#if defined (__MTP_PROTOCOL_SUPPORT)
+    // Mark the song record as deleted if the following is true; otherwise, delete the
+    // song record.
+    //
+    // A client other than MTP has initiated this song deletion (aDeleteRecord is EFalse)
+    // and MTP has turned on its cenrep key to save deleted records and current number of
+    // saved deleted records has not exceeded its maximum, KMCMaxSavedDeletedRecords.
+    //
+    // Songs are marked as deleted in order to support auto-sync. MTP will delete these
+    // marked records at the end of each session via CleanupDeletedRecordsL.
+    //
+    // For performance consideration, if the number of saved records exceeds its maximum,
+    // song record will be deleted.
+    if (!aDeleteRecord && SaveDeletedSongs())
+        {
+        TUint32 savedDeletedRecordCount(iDbAuxiliary->SaveDeletedRecordCountL());
+        MPX_DEBUG2("Current number of saved deleted record count is %d", savedDeletedRecordCount);
+
+        if (savedDeletedRecordCount < KMCMaxSavedDeletedRecords)
+            {
+            deleteRecord = EFalse;
+            TUint32 savedDeletedDriveRecordCount(iDbAuxiliary->SaveDeletedRecordCountL(drive));
+            iDbAuxiliary->SetSaveDeletedRecordCountL(drive,++savedDeletedDriveRecordCount);
+            }
+        }
+#endif
+
+    // delete the song from the Music table
+    iDbMusic->DeleteSongL(aSongId, drive, deleteRecord);
+
+    // add the item changed message
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted,
+        EMPXSong, KDBPluginUid);
+        
+
+    if(iMtpInUse)
+        {
+        ++iOpOnDbCount;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Delete a song from playlist tables
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveSongFromPlaylistL(TUint32 aSongId,CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveSongFromPlaylistL");
+    // delete song from the playlist tables on all drives
+    iDbPlaylist->DeleteSongL(aSongId, aItemChangedMessages);
+    }
+
+// ----------------------------------------------------------------------------
+// Removes a category of songs from the music collection,
+// and its corresponding category in the lookup table
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveSongsMatchingCategoryL(
+    TMPXGeneralCategory aCategory,
+    TUint32 aCategoryId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveSongsMatchingCategoryL");
+
+    // get the songs for the specified category
+    CMPXMediaArray* songs = CMPXMediaArray::NewL();
+    CleanupStack::PushL(songs);
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL(attributes);
+    attributes.AppendL(KMPXMediaGeneralId);
+
+    switch (aCategory)
+        {
+        case EMPXArtist:
+            {
+            iDbMusic->GetSongsForArtistL(aCategoryId, attributes.Array(), *songs);
+            break;
+            }
+        case EMPXAlbum:
+            {
+            iDbMusic->GetSongsForAlbumL(aCategoryId, attributes.Array(), *songs);
+            break;
+            }
+        case EMPXGenre:
+            {
+            iDbMusic->GetSongsForGenreL(aCategoryId, attributes.Array(), *songs);
+            break;
+            }
+        case EMPXComposer:
+            {
+            iDbMusic->GetSongsForComposerL(aCategoryId, attributes.Array(), *songs);
+            break;
+            }
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    CleanupStack::PopAndDestroy(&attributes);
+
+    // iterate the songs and remove them one by one
+    // so records in the category tables can also be updated
+    TInt count(songs->Count());
+    for (TInt index = 0; index < count; ++index)
+        {
+        CMPXMedia* song = (*songs)[index];
+        if (song->IsSupported(KMPXMediaGeneralId))
+            {
+            DoRemoveSongL((song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2,
+                aUriArray, aItemChangedMessages, EFalse);
+            DoRemoveSongFromPlaylistL((song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2,aItemChangedMessages);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(songs);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Delete songs for the specified artist and album from collection
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveSongsMatchingArtistAndAlbumL(
+    TUint32 aArtistId,
+    TUint32 aAlbumId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL");
+
+    // get the songs for the specified artist and album
+    CMPXMediaArray* songs = CMPXMediaArray::NewL();
+    CleanupStack::PushL(songs);
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL (attributes);
+    attributes.AppendL(KMPXMediaGeneralId);
+
+    iDbMusic->GetSongsForArtistAndAlbumL(aArtistId, aAlbumId, attributes.Array(), *songs);
+    CleanupStack::PopAndDestroy(&attributes);
+
+    // iterate the songs and remove them one by one
+    // so records in the category tables can also be updated
+    TInt count(songs->Count());
+    for (TInt index = 0; index < count; ++index)
+        {
+        CMPXMedia* song = (*songs)[index];
+        if (song->IsSupported(KMPXMediaGeneralId))
+            {
+            DoRemoveSongL( song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId),
+                aUriArray, aItemChangedMessages, EFalse);
+            DoRemoveSongFromPlaylistL(song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId),aItemChangedMessages);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(songs);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove all playlists from collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveAllPlaylistsL()
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveAllPlaylistsL");
+    iDbPlaylist->DeleteAllPlaylistsL();
+    }
+
+// ----------------------------------------------------------------------------
+// Remove specified playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemovePlaylistL(
+    TUint32 aPlaylistId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemovePlaylistL");
+
+    HBufC* uri(iDbPlaylist->DeletePlaylistL(aPlaylistId));
+    if (uri)
+        {
+        CleanupStack::PushL(uri);
+        aUriArray.AppendL(*uri);
+        CleanupStack::PopAndDestroy(uri);
+        }
+
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aPlaylistId, EMPXItemDeleted,
+        EMPXPlaylist, KDBPluginUid);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove song from playlist songs table
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoRemoveSongFromPlaylistL(
+    TUint32 aPlaylistId,
+    const TMPXItemId& aSongId,
+    TInt aOrdinal,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::DoRemoveSongFromPlaylistL");
+    MPX_DEBUG5("CMPXDbHandler::DoRemoveSongFromPlaylistL(playlist 0x%x, songId [0x%x,0x%x], ordinal %d)",
+        aPlaylistId, aSongId.iId1, aSongId.iId2, aOrdinal);
+
+    // delete the song
+    iDbPlaylist->DeleteSongL(aPlaylistId, aSongId.iId2, aOrdinal);
+
+    // Send a playlist modified message
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aPlaylistId, EMPXItemModified,
+        EMPXPlaylist, KDBPluginUid);
+
+    // Send a message on the song in the playlist that is deleted
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted,
+        EMPXSong, KDBPluginUid);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::DoCleanupDeletedRecordsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DoCleanupDeletedRecordsL()
+    {
+    MPX_FUNC("CMPXDbHandler::DoCleanupDeletedRecordsL");
+
+    // delete all marked records from the Music table
+    iDbMusic->CleanupL();
+
+    // reset the count in the Auxiliary table
+    iDbAuxiliary->SetSaveDeletedRecordCountL(KDbManagerAllDrives,0);
+    }
+
+// ----------------------------------------------------------------------------
+// FindAllL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::FindAllL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray* aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::FindAllL");
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL(attributes);
+    MPXUser::MergeAttributeL(aAttrs, attributes);
+
+    TMPXGeneralCategory category = aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
+    switch (category)
+        {
+        case EMPXPlaylist:
+            {
+            TUint32 playlistId(0);
+            if (aCriteria.IsSupported(KMPXMediaGeneralId))
+                {
+                playlistId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+                }
+
+            if (iAutoPlaylist->AutoPlaylistTypeL(playlistId) != EMPXNoAutoPlaylist)
+                {
+                CMPXMedia* media = CMPXMedia::NewL();
+                CleanupStack::PushL(media);
+
+                iAutoPlaylist->GetPlaylistL(playlistId, aAttrs, *media);
+
+                aMediaArray->AppendL(*media);
+                CleanupStack::PopAndDestroy(media);
+                }
+            else
+                {
+                iDbPlaylist->FindAllL(aCriteria, attributes.Array(), *aMediaArray);
+                }
+
+            break;
+            }
+        case EMPXSong:
+            {
+            FindSongL(aCriteria, attributes.Array(), *aMediaArray);
+            break;
+            }
+        default:
+            {
+            DbCategoryL(category)->FindAllL(aCriteria, attributes.Array(), *aMediaArray);
+            break;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&attributes);
+    }
+
+// ----------------------------------------------------------------------------
+// Get song(s) from the music table that match the given criteria
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::FindSongL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbCollection::FindSongL");
+
+    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
+
+    TUint32 id(0);
+    if (aCriteria.IsSupported(KMPXMediaGeneralId))
+        {
+        id = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+        }
+
+    TUint32 containerId(0);
+    if (aCriteria.IsSupported(KMPXMediaGeneralContainerId))
+        {
+        containerId = aCriteria.ValueTObjectL<TUint32>(KMPXMediaGeneralContainerId);
+        }
+
+    //////////////////////////////////////////////////////////////////////
+    // Find songs in the specified playlist
+    //////////////////////////////////////////////////////////////////////
+    TMPXGeneralCategory cat(MPX_ITEM_CATEGORY(id));
+
+    if (type == EMPXGroup &&
+        (cat == EMPXPlaylist ||
+        MPX_ITEM_CATEGORY(containerId) == EMPXPlaylist))
+        {
+        TUint32 playlistId = (cat == EMPXPlaylist) ?
+            id : (containerId & KMCCategoryMask);
+
+        GetPlaylistSongsL(playlistId, aAttrs, aMediaArray);
+        }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    else if (type == EMPXGroup &&
+        (cat == EMPXAbstractAlbum ||
+        MPX_ITEM_CATEGORY(containerId) == EMPXAbstractAlbum))
+        {
+        TUint32 abstractAlbumId = (cat == EMPXAbstractAlbum) ?
+            id : (containerId & KMCCategoryMask);
+        TInt attrCount(aAttrs.Count());
+        if ( attrCount > 1 || (attrCount == 1 && !(aAttrs[0] == KMPXMediaGeneralId)) )
+            {
+            TInt abstractAlbumDrive(iDbAbstractAlbum->GetDriveIdL(abstractAlbumId));
+            MPX_TRAPD(err, iDbMusic->GetAllSongsForAbstractAlbumL(abstractAlbumDrive, abstractAlbumId, aAttrs, aMediaArray));
+        if (err == KErrNotFound)
+            {
+            //
+            // Leave with KErrNotFound
+            User::Leave(KErrNotFound);
+            }
+        else
+            {
+            // Leave if error
+            User::LeaveIfError(err);
+            }
+        }
+    }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    //////////////////////////////////////////////////////////////////////
+    // Find a particular song in the specified playlist. This fills the
+    // song with info from Playlist table first then overwrites it with
+    // info from Songs table if Songs table where this song is located
+    // is present in order to support the display of song titles in a
+    // playlist when memory card is removed if the playlist refers to
+    // songs on the memory card. Caller of this scenario is OpenL/MediaL.
+    // When user attempts to play a track in an auto-playlist, we will
+    // find the song from Songs table directly since auto-playlists are
+    // not stored in the Playlist table. Auto-playlists are query-based,
+    // therefore, when memory card is removed, songs on the memory card
+    // will not be shown in the auto-playlist; hence they do not exhibit
+    // the same challenge as user created playlists.
+    //////////////////////////////////////////////////////////////////////
+    else if (type == EMPXItem &&
+        cat == EMPXCollection &&
+        MPX_ITEM_CATEGORY(containerId) == EMPXPlaylist)
+        {
+        if (iAutoPlaylist->AutoPlaylistTypeL(containerId) != EMPXNoAutoPlaylist)
+            {
+            // auto playlist song, get the song details from the music table
+            iDbMusic->FindSongsL(id, 0, type, aCriteria, aAttrs, aMediaArray);
+            }
+        else
+            {
+            GetPlaylistSongL(id, containerId, aAttrs, aMediaArray);
+            }
+        }
+
+    //////////////////////////////////////////////////////////////////////
+    // Find all songs, all songs in a particular album and/or artist, or
+    // a particular song
+    //////////////////////////////////////////////////////////////////////
+    else
+        {
+        iDbMusic->FindSongsL(id, containerId, type, aCriteria, aAttrs, aMediaArray);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Get song(s) in the specified playlist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::GetPlaylistSongsL(
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::GetPlaylistSongsL");
+    MPX_DEBUG2("CMPXDbHandler::GetPlaylistSongsL(0x%x)", aPlaylistId);
+
+    // check the auto playlists first
+    if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist))
+        {
+        iDbMusic->GetRecentlyPlayedSongsL(aAttrs, aMediaArray);
+        }
+    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist))
+        {
+        iDbMusic->GetMostPlayedSongsL(aAttrs, aMediaArray);
+        }
+    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyAddedPlaylist))
+        {
+        iDbMusic->GetRecentlyAddedSongsL(aAttrs, aMediaArray);
+        }
+    else
+        {
+        TInt attrCount(aAttrs.Count());
+        if ( attrCount > 1 || (attrCount == 1 && !(aAttrs[0] == KMPXMediaGeneralId)) )
+            {
+	        TInt plDrive(iDbPlaylist->GetDriveIdL(aPlaylistId));
+	        MPX_TRAPD(err, iDbMusic->GetAllSongsL(plDrive, aPlaylistId, aAttrs, aMediaArray));
+
+	        // song not found in Music table
+	        if (err == KErrNotFound)
+	            {
+	            //
+	            // Leave with KErrNotFound if one of the following is true:
+	            // 1) the requested song is in an auto playlist. Since auto-playlist isn't
+	            //    stored in playlist tables, we won't be able to retrieve info elsewhere
+	            // 2) the requested song is in a user playlist but we cannot find the song
+	            //    info from playlist tables either
+	            //
+	           if (EMPXNoAutoPlaylist != iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) ||
+	                !iDbPlaylist->Songs().GetSongsL(aPlaylistId, aAttrs, aMediaArray))
+	               {
+	               User::Leave(KErrNotFound);
+	               }
+	            }
+	        else
+	            {
+	            // ignore the error if KErrNotFound
+	            User::LeaveIfError(err);
+	            }
+            }
+        else
+            {
+            // get ids of the songs in the playlist
+            iDbPlaylist->Songs().GetSongsL(aPlaylistId, aMediaArray);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Find all albums or the albums for a specified artist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::FindAlbumL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbHandler::FindAlbumL");
+
+    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
+
+    TUint32 id(0);
+    if (aCriteria.IsSupported(KMPXMediaGeneralId))
+        {
+        id = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+        }
+
+    if ((type == EMPXGroup) && (MPX_ITEM_CATEGORY(id) == EMPXArtist))
+        {
+        // get all the albums for the artist
+        GetAlbumsMatchingArtistL(id, aAttrs, aMediaArray);
+        }
+    else
+        {
+        // look up all albums from album table
+        iDbAlbum->FindAllL(aCriteria, aAttrs, aMediaArray);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Extracts the playlist ID and drive ID from a playlist media instance
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::ProcessPlaylistMediaL(
+    CMPXMedia& aMedia,
+    TUint32& aPlaylistId,
+    TInt& aPlaylistDriveId)
+    {
+    MPX_FUNC("CMPXDbHandler::ProcessPlaylistMediaL");
+
+    if (aMedia.IsSupported(KMPXMediaGeneralId))
+        {
+        aPlaylistId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+
+        if (aMedia.IsSupported(KMPXMediaGeneralUri))
+            {
+            // find drive id of the playlist
+            aPlaylistDriveId = TDriveUnit(aMedia.ValueText(KMPXMediaGeneralUri));
+            }
+        else
+            {
+            // Find drive Id(s) of corresponding Playlist Id
+            aPlaylistDriveId = iDbPlaylist->GetDriveIdL(aPlaylistId);
+            }
+        }
+    else if (aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        const TDesC& playlistUri = aMedia.ValueText(KMPXMediaGeneralUri);
+        // find drive id of the playlist
+        aPlaylistDriveId = TDriveUnit(playlistUri);
+
+        // aMedia does not have an ID, make sure the add it
+        aPlaylistId = GetPlaylistIdMatchingUriL(playlistUri);
+        aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPlaylistId);
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Makes sure that all songs in the specified playlist have the ID, title and URI attributes
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::UpdatePlaylistSongInfoL(
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbHandler::UpdatePlaylistSongInfoL");
+
+    CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+    User::LeaveIfNull(mediaArray);
+
+    // make sure each song has Id, Uri, and Title before they can be added to playlist
+    TInt count(mediaArray->Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        CMPXMedia* element = mediaArray->AtL(i);
+
+        // copy each song to deal w/ global heap issues
+        CMPXMedia* entry = CMPXMedia::NewL(*element);
+        CleanupStack::PushL(entry);
+
+        // song has everything, go to next song
+        if (entry->IsSupported(KMPXMediaGeneralUri) &&
+            entry->IsSupported(KMPXMediaGeneralId) &&
+            entry->IsSupported(KMPXMediaGeneralTitle))
+            {
+            // pop entry to maintain CleanupStack
+            CleanupStack::PopAndDestroy(entry);
+            continue;
+            }
+
+        // songs must contain (at minimum) an Uri or an Id
+        if (!entry->IsSupported(KMPXMediaGeneralUri) &&
+            !entry->IsSupported(KMPXMediaGeneralId))
+            {
+            User::Leave(KErrArgument);
+            }
+
+        // get Id
+        if (!entry->IsSupported(KMPXMediaGeneralId))
+            {
+            // fill in the ID if not present
+            TParsePtrC parser(entry->ValueText(KMPXMediaGeneralUri));
+            entry->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+                MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, parser.FullName(), EFalse));
+            }
+
+        CMPXMedia* song(NULL);
+
+        // update songs info
+        TInt error(iDbMusic->GetSongL(*entry, song));
+        TBool result (ETrue);
+
+        // error can only be KErrNone or KErrNotFound
+        // from CMPXDbMusic::GetSongL
+        // if not found in Music, get info from PlaylistSongs (PlaylistSongs & PlaylistSongInfo) DB
+        if (error == KErrNotFound)
+            {
+            RArray<TMPXAttribute> attributes;
+            CleanupClosePushL(attributes);
+            attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
+                EMPXMediaGeneralId | EMPXMediaGeneralTitle | EMPXMediaGeneralUri | EMPXMediaGeneralFlags));
+
+            // this song doesn't exist in Music table. This song is either a broken link or
+            // is of an unsupported song type that exists in the file system. Broken links
+            // have already been marked as such during playlist import.
+            result = iDbPlaylist->Songs().GetSongL(entry->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId), attributes.Array(), song);
+            if (!result)
+                {
+                // song is a broken link
+                //TUint flags = KMPXMediaGeneralFlagsSetOrUnsetBit;
+                //flags |= KMPXMediaGeneralFlagsIsInvalid; // set flag
+                //t->SetTObjectValueL<TUint>( KMPXMediaGeneralFlags, flags );
+
+                if (entry->IsSupported(KMPXMediaGeneralUri))
+                    {
+                    // no valid Id but has Uri, just verify Title is present
+                    // this is the case if the song is a broken link or podcast
+                    if (!entry->IsSupported(KMPXMediaGeneralTitle))
+                        {
+                        // does not have Title, make up the Title from file name
+                        TParsePtrC parser(entry->ValueText(KMPXMediaGeneralUri));
+                        entry->SetTextValueL(KMPXMediaGeneralTitle, parser.Name());
+                        }
+                    }
+                else
+                    {
+                    // no valid Id & no Uri, bad argument
+                    User::Leave(KErrArgument);
+                    }
+                }
+            CleanupStack::PopAndDestroy(&attributes);
+            }
+
+        // update attributes
+        CleanupStack::PushL(song);
+
+        // song not found in Music or Playlist DB, update entry
+        if(error == KErrNotFound && !result)
+            {
+            mediaArray->InsertL(*entry,i);
+            }
+        else  // found in DB, replace entry
+            {
+            mediaArray->InsertL(*song,i);
+            }
+
+        // replace element in the array
+        CleanupStack::PopAndDestroy(song);
+        CleanupStack::PopAndDestroy(entry);
+        mediaArray->Remove(i+1);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::ProcessMusicFoldersL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::ProcessMusicFoldersL(
+    const CDesCArray& aFolders)
+    {
+    MPX_FUNC("CMPXDbHandler::ProcessMusicFoldersL");
+
+    TInt count(aFolders.MdcaCount());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TPtrC16 folder = aFolders.MdcaPoint(i);
+
+        // check if disk is inserted and act accordingly
+        TDriveUnit driveUnit(folder);
+        if (!iFs.IsValidDrive(driveUnit))
+            {
+            User::Leave(KErrArgument);
+            }
+
+        // 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);
+                    }
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::DbCategoryL
+// ----------------------------------------------------------------------------
+//
+CMPXDbCategory* CMPXDbHandler::DbCategoryL(
+    TMPXGeneralCategory aCategory) const
+    {
+    MPX_FUNC("CMPXDbHandler::DbCategoryL");
+
+    CMPXDbCategory* dbCategory(NULL);
+    switch (aCategory)
+        {
+        case EMPXArtist:
+            {
+            dbCategory = (CMPXDbCategory*)iDbArtist;
+            break;
+            }
+        case EMPXAlbum:
+            {
+            dbCategory = (CMPXDbCategory*)iDbAlbum;
+            break;
+            }
+        case EMPXGenre:
+            {
+            dbCategory = (CMPXDbCategory*)iDbGenre;
+            break;
+            }
+        case EMPXComposer:
+            {
+            dbCategory = (CMPXDbCategory*)iDbComposer;
+            break;
+            }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXAbstractAlbum:
+            {
+            dbCategory = (CMPXDbCategory*)iDbAbstractAlbum;
+            break;
+            }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    return dbCategory;
+    }
+
+// ----------------------------------------------------------------------------
+// Verifies that the volume ID of the database matches the drive
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::VerifyVolumeIdL( TInt aDrive )
+    {
+    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--");
+        if( iDbManager->IsOpen( aDrive ) )
+            {
+            TVolumeInfo volInfo;
+            iFs.Volume(volInfo, aDrive );
+            TUint curId(volInfo.iUniqueID);
+
+            TInt volId = iDbAuxiliary->IdL( aDrive );
+
+            // New database, no volume id set, mask out top bit because this is an uint
+            //
+            MPX_DEBUG3("CMPXDBHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
+            if( volId == 0 && (curId&0x7FFFFFFF) )
+                {
+                MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- New ID");
+                BeginTransactionL();
+                TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) );
+                EndTransactionL( err );
+
+                // KSqlDbCorrupted indicates DB corrupted, need to recreate.
+                if ( err == KSqlDbCorrupted )
+                    {
+                    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
+                    iDbManager->RecreateDatabaseL(aDrive);
+                    BeginTransactionL();
+                    TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+                    EndTransactionL( err );
+                    }
+                }
+            // Unmatched volume id, mark db as corrupt and break
+            //
+            else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
+                {
+                MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- ID match FAILED");
+                iDbManager->RecreateDatabaseL(aDrive);
+                BeginTransactionL();
+                TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+                EndTransactionL( err );
+                }
+            }
+
+    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->");
+    }
+
+// ----------------------------------------------------------------------------
+// Verifies that the volume ID of the database matches the drive
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::VerifyVolumeIdL()
+    {
+    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--");
+    TInt count( iDbDrives.Count() );
+    for( TInt i=0; i<count; ++i )
+        {
+        VerifyVolumeIdL(iDbDrives[i]);
+        }
+    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->");
+    }
+
+
+// ----------------------------------------------------------------------------
+// Checks if there is a drive that has a low disk space
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::CheckDiskSpaceOnDrivesL()
+    {
+    MPX_DEBUG1("CMPXDbHandler::CheckDiskSpaceOnDrivesL <--");
+
+    TInt count( iDbDrives.Count() );
+    for( TInt index=0; index<count; ++index )
+        {
+        iDbManager->CheckDiskSpaceL(iDbDrives[index]);
+        }
+    MPX_DEBUG1("CMPXDbHandler::CheckDiskSpaceOnDrivesL -->");
+    }
+
+#if defined (__MTP_PROTOCOL_SUPPORT)
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::SaveDeletedSongs
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::SaveDeletedSongs()
+    {
+    MPX_FUNC("CMPXDbHandler::SaveDeletedSongs");
+
+    TBool saveDeletedSongs(ETrue);
+    CRepository* cenrep(NULL);
+    MPX_TRAPD(error, cenrep = CRepository::NewL(KMPXMtpSettings));
+    if (!error)
+        {
+        cenrep->Get(KMPXMtpSaveDeletedRecordFlag, saveDeletedSongs);
+        delete cenrep;
+        MPX_DEBUG2("MTP indicated to save deleted songs? %d", saveDeletedSongs);
+        }
+
+    return saveDeletedSongs;
+    }
+
+#endif
+
+#ifdef RD_MULTIPLE_DRIVE
+
+// ----------------------------------------------------------------------------------------------------------
+// Retrieve all visible music folder locations
+// ----------------------------------------------------------------------------------------------------------
+//
+CDesCArrayFlat* CMPXDbHandler::GetMusicFoldersL()
+    {
+    MPX_FUNC("CMPXDbHandler::GetMusicFoldersL()");
+    TDriveList driveList;
+    TInt driveCount(0);
+    User::LeaveIfError(DriveInfo::GetUserVisibleDrives(iFs, driveList, driveCount));
+    MPX_DEBUG2 ("CMPXDbHandler::GetMusicFoldersL() - driveCount = %d", driveCount);
+
+    CDesCArrayFlat* folders = new (ELeave) CDesCArrayFlat(1); // granularity
+    CleanupStack::PushL(folders);
+
+    for (TInt i = EDriveA; i <= EDriveZ; i++)
+        {
+        if ((driveList[i]) && (!IsRemoteDrive(static_cast<TDriveNumber>(i))))
+            {
+            if (i == EDriveC)
+                {
+                // Append the default phone memory path to the list
+                // of music folders
+                TPtrC rootPath(PathInfo::PhoneMemoryRootPath());
+                folders->AppendL(rootPath);
+                MPX_DEBUG2("CMPXDbHandler::GetMusicFoldersL() - adding...%S", &rootPath);
+                }
+            else
+                {
+                // Get drive letter
+                TChar driveChar;
+                User::LeaveIfError(iFs.DriveToChar(i, driveChar));
+
+                // Append visible drive to list of music folders
+                TBuf<2> drive;
+                drive.Append(driveChar);
+                drive.Append(_L(":"));
+                folders->AppendL(drive);
+                MPX_DEBUG2 ("CMPXDbHandler::GetMusicFoldersL() - adding...%S", &drive);
+                }
+            }
+        }
+
+    CleanupStack::Pop(folders);
+    return folders;
+    }
+
+#endif // RD_MULTIPLE_DRIVE
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::AddCategoryItemL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddCategoryItemL(
+    TMPXGeneralCategory aCategory,
+    const TDesC& aName,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TBool& aItemExist
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED    
+      ,const TDesC& aAlbumArtist,
+    const TDesC& aGenre
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    )
+    {
+    MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
+
+    MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
+
+    TBool newRecord(EFalse);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED    
+    TUint32 id(0);   
+    //for AbstractAlbum, SetAbstractAlbum, associate songs with abstractalbum.
+    //only called with newRecord as EFalse
+    //increment songCount if id exist in AbstractAlbum table, otherwise do nothing.
+    if (aCategory == EMPXAbstractAlbum)
+        {     
+        id = iDbAbstractAlbum->AddItemL( aName, aAlbumArtist, aGenre, aDriveId, newRecord, (aCategory != EMPXGenre));     
+        }    
+    else
+        {
+        id = DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre));
+#else 
+    TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)));
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    if (newRecord && aItemChangedMessages)
+        {
+        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
+            aCategory, KDBPluginUid);
+        }
+    // when the added item's category is Genre or Composer,
+    // and it is NOT a new record,
+    // we should send the item number changed message
+    else if ( ( aCategory == EMPXGenre || aCategory == EMPXComposer ) &&
+    		!newRecord && aItemChangedMessages )
+        {
+        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
+            aCategory, KDBPluginUid);
+        }
+    aItemExist = !newRecord;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED      
+       }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
+
+    return id;
+    }
+
+TUint32 CMPXDbHandler::AddCategoryItemL(
+        TMPXGeneralCategory aCategory,
+        const TDesC& aName,
+        TUint32 aArtist,
+        const TDesC& aArt,
+        TInt aDriveId,
+        CMPXMessageArray* aItemChangedMessages,
+        TBool& aItemExist)
+	{
+    MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
+
+    MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
+
+    TBool newRecord(EFalse);
+
+    TUint32 id = 0;
+    if ( aArtist )
+        {
+        id = iDbAlbum->AddItemL(aName, aArtist, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
+        }
+    else
+        {
+        id = iDbArtist->AddItemL(aName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
+        }
+        
+    if (newRecord && aItemChangedMessages)
+        {
+        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
+            aCategory, KDBPluginUid);
+        }
+    // when the added item's category is Artist, and it is NOT a new record,
+    // we should send the item number changed message
+    else if (  aCategory == EMPXArtist &&
+            !newRecord && aItemChangedMessages )
+        {
+        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
+            aCategory, KDBPluginUid);
+        }
+    aItemExist = !newRecord;
+    MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
+
+    return id;
+	}
+
+void CMPXDbHandler::UpdateCategoryItemL(
+		TMPXGeneralCategory aCategory,
+		TUint32 aCategoryId,
+		const CMPXMedia& aMedia,
+		TInt aDrive, 
+		CMPXMessageArray* aItemChangedMessages)
+	{
+	switch(aCategory)
+	    {
+	    case EMPXAlbum:
+            iDbAlbum->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
+	        break;
+	        
+	    case EMPXArtist:
+	        iDbArtist->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
+	        break;
+
+	    default:
+            DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
+	        break;
+	    }
+	}
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::DeleteSongForCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DeleteSongForCategoryL(
+    TMPXGeneralCategory aCategory,
+    TUint32 aCategoryId,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TBool& aItemExist)
+    {
+    MPX_FUNC("CMPXDbHandler::DeleteSongForCategoryL");
+    DbCategoryL(aCategory)->DecrementSongsForCategoryL(aCategoryId, aDriveId,
+        aItemChangedMessages, aItemExist);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::HandlePlayCountModifiedL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::HandlePlayCountModifiedL(
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::HandlePlayCountModifiedL");
+
+    TUint32 plId(iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist));
+
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, plId, EMPXItemModified,
+        EMPXSong, KDBPluginUid, plId);
+
+    // Force the deprecated ID attribute
+    aItemChangedMessages[aItemChangedMessages.Count() - 1]->
+        SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, plId);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// CMPXDbHandler::HandlePlaybackTimeModifiedL
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbHandler::HandlePlaybackTimeModifiedL(
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbHandler::HandlePlaybackTimeModifiedL");
+
+    TUint32 plId(iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist));
+
+    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, plId, EMPXItemModified,
+        EMPXSong, KDBPluginUid, plId);
+
+    // Force the deprecated ID attribute
+    aItemChangedMessages[aItemChangedMessages.Count() - 1]->
+        SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, plId);
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXDbHandler::IsRemoteDrive
+// ---------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::IsRemoteDrive(TDriveNumber aDrive)
+    {
+    return iDbManager->IsRemoteDrive(aDrive);
+    }
+
+TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
+    {
+    return GetPlaylistDurationL(aPlaylistId);
+    }
+void CMPXDbHandler::HandlePlaylistInfoL(
+    TUint32 aPlaylistId, 
+    TInt& aCount, 
+    TInt& aDuration)
+    {
+    MPX_FUNC("CMPXDbHandler::HandlePlaylistInfoL");
+    MPX_DEBUG2("CMPXDbHandler::HandlePlaylistInfoL(0x%x)", aPlaylistId);
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL(attributes);
+    attributes.AppendL(KMPXMediaGeneralId);    
+    attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralDuration));
+
+    CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
+    CleanupStack::PushL(mediaArray);    
+    
+    GetPlaylistSongsL(aPlaylistId, attributes.Array(), *mediaArray);
+    
+    aCount = mediaArray->Count();
+    for (TInt index = 0; index < aCount; ++index)
+        {
+        CMPXMedia* media((*mediaArray)[index]);
+        if (media->IsSupported(KMPXMediaGeneralDuration))
+            {
+            aDuration += media->ValueTObjectL<TInt>(KMPXMediaGeneralDuration);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(mediaArray);
+    CleanupStack::PopAndDestroy(&attributes);        
+    }
+
+TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
+	{
+	return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
+	}
+
+TBool CMPXDbHandler::HandleIsUnknownArtistL(TUint32 aArtistId)
+    {
+    return iDbArtist->IsUnknownArtistL(aArtistId);
+    }
+
+TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
+    {
+    return iDbMusic->ArtistForAlbumL(aAlbumId);
+    }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED   
+// ----------------------------------------------------------------------------------------------------------
+// CMPXDbHandler::HandleGetAlbumNameForSongL
+// ----------------------------------------------------------------------------------------------------------
+// 
+HBufC* CMPXDbHandler::HandleGetAlbumNameFromIdL(TUint32 aId)
+    {
+    return iDbAbstractAlbum->GetNameL(aId);
+    }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,2743 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interation with the music table.
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxcollectionpath.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxmediaaudiodefs.h>
+#include <mpxmediadrmdefs.h>
+#include <mpxmediamtpdefs.h>
+#include <mpxcollectiondbhgres.rsg>
+
+#include "mpxdbcommondef.h"
+#include "mpxdbcommonstd.h"
+#include "mpxdbcommonutil.h"
+#include "mpxresource.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxcollectiondbstd.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbutil.h"
+#include "mpxdbmanager.h"
+#include "mpxdbmusic.h"
+
+// CONSTANTS
+
+// This is what KNullDesC album computes to for the hash
+// to-do: generate this Id through
+//        MPXDbUtil::GenerateUniqueIdL(EMPXAlbum, KNullDesC, EFalse)
+//        instead of hard-coding the number so if GenerateUniqueIdL
+//        is modified, this constant doesn't need to be redefined
+const TInt KUnknownAlbumID = 1770790356;
+// UniqueID column in Uris requests
+const TInt KColUniqueID = 0;
+// URI column in Uris requests
+const TInt KColUri = 1;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+_LIT( KAbstractAlbumExt, ".alb" );
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbMusic* CMPXDbMusic::NewL(
+    CMPXDbManager& aDbManager,
+    CMPXResource& aResource,
+    MMPXDbMusicObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbMusic::NewL");
+    CMPXDbMusic* self = CMPXDbMusic::NewLC(aDbManager, aResource, aObserver);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbMusic* CMPXDbMusic::NewLC(
+    CMPXDbManager& aDbManager,
+    CMPXResource& aResource,
+    MMPXDbMusicObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbMusic::NewLC");
+
+    CMPXDbMusic* self = new (ELeave) CMPXDbMusic(aDbManager, aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL(aResource);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbMusic::~CMPXDbMusic()
+    {
+    MPX_FUNC("CMPXDbMusic::~CMPXDbMusic");
+    delete iExtensionsDrm;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbMusic::CMPXDbMusic(
+    CMPXDbManager& aDbManager,
+    MMPXDbMusicObserver& aObserver) :
+    CMPXDbTable(aDbManager),
+    iObserver(aObserver)
+    {
+    MPX_FUNC("CMPXDbMusic::CMPXDbMusic");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::ConstructL(
+    CMPXResource& aResource)
+    {
+    MPX_FUNC("CMPXDbMusic::ConstructL");
+
+    BaseConstructL();
+    iExtensionsDrm = aResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_DRM);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::AddSongL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbMusic::AddSongL(
+    const CMPXMedia& aMedia,
+    TInt aDrive,
+    CMPXMessageArray* aMessageArray)
+    {
+    MPX_FUNC("CMPXDbMusic::AddSongL");
+
+    TUint32 songId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
+        aMedia.ValueText(KMPXMediaGeneralUri), EFalse));
+
+    if (SongExistsL(songId))
+        {
+        // Delete the existing record first and start from scratch
+        DeleteSongL(songId, aDrive, ETrue);
+        }
+    // add the song
+    DoAddSongL(songId, aMedia, aDrive, aMessageArray);
+    
+    return songId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DoAddSongL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::DoAddSongL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    TInt aDrive,
+    CMPXMessageArray* aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbMusic::DoAddSongL");
+
+    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
+    CleanupStack::PushL(fields);
+    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
+    CleanupStack::PushL(values);
+
+    // add known fields
+    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicUniqueId, aSongId);
+    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicDel, 0);
+
+    TTime time;
+    time.HomeTime();
+    HBufC* timeAdded = MPXDbCommonUtil::TTimeToDesLC(time);
+    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicTimeAdded, *timeAdded);
+    CleanupStack::PopAndDestroy(timeAdded);
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    //update ContainEmbeddedArt
+    const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
+    if (albumArtFilename.Length() > 0)
+        {
+        MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicContainEmbeddedArt, 1);
+        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    // process the media parameter and construct the fields and values array
+    TBool visible(GenerateMusicFieldsValuesL(aSongId, aMedia, aItemChangedMessages,
+        NULL, *fields, *values, aDrive));
+
+    // create the fields and values strings
+    HBufC* fieldStr = MPXDbCommonUtil::StringFromArrayLC(*fields, KMCCommaSign);
+    HBufC* valueStr = MPXDbCommonUtil::StringFromArrayLC(*values, KMCCommaSign);
+
+    // execute the query
+    iDbManager.ExecuteQueryL(aDrive, KQueryMusicInsert, fieldStr, valueStr);
+
+    CleanupStack::PopAndDestroy(valueStr);
+    CleanupStack::PopAndDestroy(fieldStr);
+    CleanupStack::PopAndDestroy(values);
+    CleanupStack::PopAndDestroy(fields);
+
+    return visible;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateSongL
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::UpdateSongL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbMusic::UpdateSongL");
+    return DoUpdateSongL(aSongId, aMedia, &aItemChangedMessages);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DoUpdateSongL
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbMusic::DoUpdateSongL");
+
+    CMPXDbActiveTask::TChangeVisibility visible(CMPXDbActiveTask::ENotVisibile);
+    if (IsSupported(aMedia))
+        {
+        // retrieve the existing record
+        TInt oldSongId(0);
+        oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+        if ( oldSongId <= 0 )
+            {
+            oldSongId = aSongId;  
+            }
+        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetSong, oldSongId));
+        CleanupClosePushL(recordset);
+
+        if (recordset.Next() != KSqlAtRow)
+            {
+            User::Leave(KErrNotFound);
+            }
+
+        TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+          recordset.ColumnInt64(EMusicVolumeId)));
+        visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages,
+          recordset);
+
+        // Update Album table
+		if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist))
+			{
+			TUint32 albumId = recordset.ColumnInt64(EMusicAlbum);
+			iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages);
+			}
+            
+        // Update Artist table
+        if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) )
+            {
+            TUint32 artistId = recordset.ColumnInt64(EMusicArtist);
+            iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages);            
+            }
+        
+        CleanupStack::PopAndDestroy(&recordset);
+        }
+
+    return visible;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DoUpdateSongL
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    TInt aDrive,
+    CMPXMessageArray* aItemChangedMessages,
+    RSqlStatement& aRecordset)
+    {
+    MPX_FUNC("CMPXDbMusic::DoUpdateSongL");
+
+    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
+    CleanupStack::PushL(fields);
+    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
+    CleanupStack::PushL(values);
+
+    TInt oldSongId(0);
+    oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+    if ( oldSongId <= 0 )
+        {
+        oldSongId = aSongId;  
+        }
+    // process the media parameter and construct the fields and values array
+    CMPXDbActiveTask::TChangeVisibility visible(GenerateMusicFieldsValuesL(oldSongId, aMedia, aItemChangedMessages,
+        &aRecordset, *fields, *values, aDrive));
+
+    // construct the SET string
+    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
+    if (setStr->Length())
+        {
+        // execute the query
+        iDbManager.ExecuteQueryL(aDrive, KQueryMusicUpdate, setStr, oldSongId);
+        }
+
+    CleanupStack::PopAndDestroy(setStr);
+    CleanupStack::PopAndDestroy(values);
+    CleanupStack::PopAndDestroy(fields);
+
+    return visible;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DeleteSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::DeleteSongL(
+    TUint32 aSongId,
+    TInt aDrive,
+    TBool aDeleteRecord /* = EFalse */)
+    {
+    MPX_FUNC("CMPXDbMusic::DeleteSongL");
+
+    TPtrC query(aDeleteRecord ? KQueryMusicDelete() : KQueryMusicDeleteUpdate());
+    iDbManager.ExecuteQueryL(aDrive, query, aSongId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DeleteCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::DeleteCategoryL(
+    TMPXGeneralCategory aCategory,
+    TUint32 aCategoryId,
+    CDesCArray& /* aUriArray */,
+    CMPXMessageArray& /* aItemChangedMessages */,
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbMusic::DeleteCategoryL");
+    TPtrC ptr(MPXDbUtil::MusicFieldNameForCategoryL(aCategory));
+    iDbManager.ExecuteQueryL(aDrive, KQueryMusicDeleteForCategory, &ptr, aCategoryId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::CleanupL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::CleanupL()
+    {
+    MPX_FUNC("CMPXDbMusic::CleanupL");
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryMusicCleanup);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetNameL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbMusic::GetNameL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbMusic::GetNameL");
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetTitle, aSongId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
+
+    HBufC* title = MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex).AllocL();
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return title;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetUriL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbMusic::GetUriL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbMusic::GetUriL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetUri, aSongId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
+
+    // query fields
+    enum
+        {
+        EMusicUriLocation = 0,
+        EMusicUriVolId
+        };
+
+    TUint volId(recordset.ColumnInt64(EMusicUriVolId));
+    HBufC* fullUri = MPXDbCommonUtil::CreateFullPathL(
+        MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId),
+        MPXDbCommonUtil::GetColumnTextL(recordset, EMusicUriLocation));
+
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return fullUri;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetDriveL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::GetDriveL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbMusic::GetDriveL");
+    return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+        ExecuteIntQueryL(KQueryMusicVolume, aSongId));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongInfoL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbMusic::GetSongInfoL(
+    TUint32 aSongId,
+    TUint32& aArtistId,
+    TUint32& aAlbumId,
+    TUint32& aGenreId,
+    TUint32& aComposerId,
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    TUint32& aAbstractAlbumId,
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    TInt& aDriveId)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongInfoL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicInfo, aSongId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    aDriveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+        recordset.ColumnInt64(EMusicVolumeId));
+    aArtistId = recordset.ColumnInt64(EMusicArtist);
+    aAlbumId = recordset.ColumnInt64(EMusicAlbum);
+    aGenreId = recordset.ColumnInt64(EMusicGenre);
+    aComposerId = recordset.ColumnInt64(EMusicComposer);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    aAbstractAlbumId = recordset.ColumnInt64(EMusicAbstractAlbum);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    HBufC* uri = ConstructUriL(recordset, aSongId);
+
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return uri;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::GetSongL(
+    const CMPXMedia& aCriteria,
+    CMPXMedia*& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongL");
+
+    TUint32 songId(0);
+
+    // find song Id, title, URI, and general flags from its Id and/or URI. Do not use "aCriteria"
+    // because it may contain attributes other than Id and URI. We don't want to search the
+    // song by fields other than the ID and URI because other attributes for the song may have
+    // been changed in the collection since the song was added
+    CMPXMedia* criteria = CMPXMedia::NewL();
+    CleanupStack::PushL(criteria);
+    if (aCriteria.IsSupported(KMPXMediaGeneralId))
+        {
+        songId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+        criteria->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId);
+        }
+    else if (aCriteria.IsSupported(KMPXMediaGeneralUri))
+        {
+        criteria->SetTextValueL(KMPXMediaGeneralUri,
+            aCriteria.ValueText(KMPXMediaGeneralUri));
+        }
+
+    // get the criteria string
+    HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(songId, 0, EMPXItem, *criteria);
+
+    // execute the query
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicSong, criteriaStr));
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    if ((err = recordset.Next()) == KSqlAtRow)
+        {
+        RArray<TMPXAttribute> attributes;
+        CleanupClosePushL(attributes);
+        attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
+            EMPXMediaGeneralId | EMPXMediaGeneralTitle | EMPXMediaGeneralUri | EMPXMediaGeneralFlags));
+
+        aMedia = CMPXMedia::NewL();
+        CleanupStack::PushL(aMedia);
+
+        UpdateMediaL(recordset, attributes.Array(), *aMedia);
+
+        CleanupStack::Pop(aMedia);
+        CleanupStack::PopAndDestroy(&attributes);
+
+        err = KErrNone;
+        }
+    else
+        {
+        err = KErrNotFound;
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    CleanupStack::PopAndDestroy(criteriaStr);
+    CleanupStack::PopAndDestroy(criteria);
+
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetRecentlyPlayedSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetRecentlyPlayedSongsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetRecentlyPlayedSongsL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetRecentlyPlayed,
+        KMPXMaxRecentlyPlayedSongs);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetMostPlayedSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetMostPlayedSongsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetMostPlayedSongsL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetMostPlayed() : KQueryMusicGetMostPlayedNoCategories(),
+        KMPXMaxMostPlayedSongs);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetRecentlyAddedSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetRecentlyAddedSongsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetRecentlyAddedSongsL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetRecentlyAdded() : KQueryMusicGetRecentlyAddedNoCategories());
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::CountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::CountL()
+    {
+    MPX_FUNC("CMPXDbMusic::CountL");
+    return ExecuteSumQueryL(KQueryMusicCount);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetAlbumsForArtistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetAlbumsForArtistL(
+    TUint32 aArtistId,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetAlbumsForArtistL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicAlbum, aArtistId));
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        TUint32 albumId(recordset.ColumnInt64(KMPXTableDefaultIndex));
+
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+
+        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, albumId);
+        media->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+        media->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
+
+        aMediaArray.AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    if (err != KSqlAtEnd)
+        {
+        User::LeaveIfError(KErrCorrupt);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongL(
+    TInt aSongId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongL");
+    ExecuteMediaQueryL(aAttrs, aMedia, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetSong() : KQueryMusicGetSongNoCategories(), aSongId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetAllSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetAllSongsL(
+    TInt aDrive,
+    TInt aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetAllSongsL");
+    ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetAllSongsInfobyPl(), aPlaylistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetAllSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetAllSongsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetAllSongsL");
+
+    // do not execute the joins if no category name is required
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetAllSongs() : KQueryMusicGetAllSongsNoCategories());
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetAllSongsLimitedL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,  
+                                      CMPXMediaArray& aMediaArray, TInt aLimit)
+    {
+    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 );    
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsInBlockL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsInBlockL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray,
+    TPtrC aTitle, 
+    TUint aNumOfSongs, 
+    TBool aAsc)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsInBlockL");
+
+    if (aAsc)
+        { 
+        ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockAsc,
+                              aTitle, aNumOfSongs, ETrue, EAscQuery );    
+        }
+    else
+        {
+        ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockDsc,
+                           aTitle, aNumOfSongs, EFalse, EDscQuery );        
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsAtOffsetL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsAtOffsetL( CMPXMediaArray& aMediaArray,
+                                     const TArray<TMPXAttribute>& aAttrs,
+                                     TInt aOffset,
+                                     TInt aCount )
+    {
+    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL <--");   
+
+    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsAtOffset, 
+                       aCount, aOffset, EOffSetQuery );
+    
+    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL() -->"); 
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsForArtistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsForArtistL(
+    TUint aArtistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsForArtistL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetSongsForArtist() : KQueryMusicGetSongsForArtistNoCategories(),
+        aArtistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsForAlbumL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsForAlbumL(
+    TUint aAlbumId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsForAlbumL");
+
+    TPtrC query;
+    if (aAlbumId == KUnknownAlbumID)
+        {
+        query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForUnknownAlbum() :
+            KQueryMusicGetSongsForUnknownAlbumNoCategories());
+        }
+    else
+        {
+        query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForAlbum() :
+            KQueryMusicGetSongsForAlbumNoCategories());
+        }
+
+    ExecuteMediaQueryL(aAttrs, aMediaArray, query, aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsForArtistAndAlbumL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsForArtistAndAlbumL(
+    TUint aArtistId,
+    TUint aAlbumId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsForArtistAndAlbumL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetSongsForArtistAlbum() : KQueryMusicGetSongsForArtistAlbumNoCategories(),
+        aArtistId, aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsForGenreL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsForGenreL(
+    TUint aGenreId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsForGenreL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetSongsForGenre() : KQueryMusicGetSongsForGenreNoCategories(),
+        aGenreId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetSongsForComposerL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetSongsForComposerL(
+    TUint aComposerId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetSongsForComposerL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
+        KQueryMusicGetSongsForComposer() : KQueryMusicGetSongsForComposerNoCategories(),
+        aComposerId);
+    }
+
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetAllSongsForAbstractAlbumL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetAllSongsForAbstractAlbumL(
+    TInt aDrive,
+    TInt aAbstractAlbumId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::GetAllSongsL");
+    ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId);
+    }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::AllSongsDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::AllSongsDurationL()
+    {
+    MPX_FUNC("CMPXDbMusic::AllSongsDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationAll);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::ArtistDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::ArtistDurationL(
+    TUint aArtistId)
+    {
+    MPX_FUNC("CMPXDbMusic::ArtistDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationArtist, aArtistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::AlbumDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::AlbumDurationL(
+    TUint aAlbumId)
+    {
+    MPX_FUNC("CMPXDbMusic::AlbumDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationAlbum, aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::ArtistAlbumDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::ArtistAlbumDurationL(
+    TUint aArtistId,
+    TUint aAlbumId)
+    {
+    MPX_FUNC("CMPXDbMusic::ArtistAlbumDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationArtistAlbum, aArtistId, aAlbumId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GenreDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::GenreDurationL(
+    TUint aGenreId)
+    {
+    MPX_FUNC("CMPXDbMusic::GenreDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationGenre, aGenreId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::ComposerDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::ComposerDurationL(
+    TUint aComposerId)
+    {
+    MPX_FUNC("CMPXDbMusic::ComposerDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationComposer, aComposerId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::RecentlyPlayedDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::RecentlyPlayedDurationL()
+    {
+    MPX_FUNC("CMPXDbMusic::RecentlyPlayedDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationRecentlyPlayed, KMPXMaxRecentlyPlayedSongs);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::MostPlayedDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::MostPlayedDurationL()
+    {
+    MPX_FUNC("CMPXDbMusic::MostPlayedDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationMostPlayed, KMPXMaxMostPlayedSongs);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::RecentlyAddedDurationL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbMusic::RecentlyAddedDurationL()
+    {
+    MPX_FUNC("CMPXDbMusic::RecentlyAddedDurationL");
+    return ExecuteSumQueryL(KQueryMusicDurationRecentlyAdded);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::FindSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::FindSongsL(
+    TUint32 aGeneralId,
+    TUint32 aContainerId,
+    TMPXGeneralType aType,
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbMusic::FindSongsL");
+
+    // get the selection criteria string
+    HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(aGeneralId, aContainerId, aType,
+        aCriteria);
+
+    // construct the sort order depending on category. Albums are always sorted by track,
+    // then name, except for unknown album. Songs are sorted by name for unknown album.
+    // NULL track number is stored as KMaxTInt so that they will be sorted to the end
+    TPtrC sortOrder;
+    if ((aType == EMPXGroup) && (MPX_ITEM_CATEGORY(aGeneralId) == EMPXAlbum) &&
+        (aGeneralId != MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, KNullDesC, EFalse)))
+        {
+        sortOrder.Set(KQueryMusicFindAllSortOrderTrack);
+        }
+    else
+        {
+        sortOrder.Set(KQueryMusicFindAllSortOrderTitle);
+        }
+
+    // construct the query
+    HBufC* query = HBufC::NewLC(KQueryMusicFindAll().Length() + criteriaStr->Length() +
+        sortOrder.Length());
+    query->Des().Format(KQueryMusicFindAll, criteriaStr, &sortOrder);
+
+    // iterate the results and append media objects to the destination array
+    ExecuteMediaQueryL(aAttrs, aMediaArray, *query);
+
+    CleanupStack::PopAndDestroy(query);
+    CleanupStack::PopAndDestroy(criteriaStr);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetDriveTrackCount
+// ----------------------------------------------------------------------------
+//
+TUint CMPXDbMusic::GetDriveTrackCountL(TInt aDrive)
+    {
+    TUint count(0);
+    
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryMusicCount));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex));
+    CleanupStack::PopAndDestroy(&recordset);
+    
+    return count;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GetMusicUriArrayL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                    CDesCArray& aUriArr, TInt& aLastID)
+    {
+    MPX_FUNC("CMPXDbMusic::GetMusicUriArrayL");
+    
+    HBufC* query = NULL;
+    if(aFromID == 0)
+        {
+        query = HBufC::NewLC(KQueryMusicGetMusicUris().Length() + KMCIntegerLen);
+        query->Des().Format(KQueryMusicGetMusicUris, aRecords);
+        }
+    else
+        {
+        query = HBufC::NewLC(KQueryMusicGetMusicUrisFrom().Length() + 2*KMCIntegerLen);
+        query->Des().Format(KQueryMusicGetMusicUrisFrom, aFromID, aRecords);
+        }
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,*query));
+    
+    CleanupStack::PopAndDestroy(query);
+    
+    CleanupClosePushL(recordset);
+    
+    TInt lastID = 0;
+    TInt err(KErrNone);
+    while((err = recordset.Next()) == KSqlAtRow)
+        {
+        HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive,
+                MPXDbCommonUtil::GetColumnTextL(recordset, KColUri));
+        CleanupStack::PushL(fullPath);
+        aUriArr.AppendL(*fullPath);
+        CleanupStack::PopAndDestroy(fullPath);
+
+        lastID = recordset.ColumnInt(KColUniqueID);
+        }
+    CleanupStack::PopAndDestroy(&recordset);
+
+    aLastID = lastID;
+
+    if (err!= KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::ArtistForAlbumL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId)
+    {
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId));
+    
+    CleanupClosePushL(recordset);
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex);            
+    CleanupStack::PopAndDestroy(&recordset);    
+    
+    return artistId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::RefreshStartL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::RefreshStartL()
+    {
+    iRefresh = ETrue;
+    MPX_FUNC("CMPXDbMusic::RefreshStartL");
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::RefreshEndL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::RefreshEndL()
+    {
+    MPX_FUNC("CMPXDbMusic::RefreshEndL");
+    iRefresh = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::SongExistsL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::SongExistsL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbMusic::SongExistsL");
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicVolumeAll, aSongId));
+    TBool found = (recordset.Next() == KSqlAtRow);
+    recordset.Close();
+
+    return found;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::UpdateMediaL(
+    RSqlStatement& aMusicTable,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::UpdateMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        switch (aAttrs[i].ContentId())
+            {
+            case KMPXMediaIdGeneral:
+                {
+                UpdateMediaGeneralL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
+                break;
+                }
+            case KMPXMediaIdMusic:
+                {
+                UpdateMediaMusicL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
+                break;
+                }
+            case KMPXMediaIdDrm:
+                {
+                // DRM is set by drm helper
+                break;
+                }
+            case KMPXMediaIdMTP:
+                {
+                // Only attribute stored in db is MTP drm status
+                UpdateMediaMTPL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
+                break;
+                }
+            case KMPXMediaIdAudio:
+                {
+                UpdateMediaAudioL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
+                break;
+                }
+            default:
+                // Do not leave. If this plugin doesn't support
+                // the content id they want, just return what we have
+                break;
+            } // end switch
+        } // end for
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateMediaGeneralL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::UpdateMediaGeneralL(
+    RSqlStatement& aMusicTable,
+    const TUint aAttrId,
+    CMPXMedia& aMedia)
+    {
+    MPX_DEBUG1("-->CMPXDbMusic::UpdateMediaGeneralL");
+    MPX_DEBUG2("    aAttrId=%b", aAttrId);
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem );
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong );
+
+    // FIX ME, temporary always fetch item ID
+    //if (aAttrId & EMPXMediaGeneralId)
+    if (!aMedia.IsSupported(KMPXMediaGeneralId))
+        {
+        MPX_DEBUG1("    !aMedia.IsSupported(KMPXMediaGeneralId)");
+        TUint32 songId(aMusicTable.ColumnInt64(EMusicUniqueId));
+        TInt columnCount(aMusicTable.ColumnCount());
+        if(columnCount == 37 && aMusicTable.ColumnIndex(_L("PlUId"))==35)
+            {
+            TUint32 pListUId(aMusicTable.ColumnInt64(35));
+            aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId));
+        	}
+        else
+        	{
+        	aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId);
+        	}
+        MPX_DEBUG2("    SongId[%d]", songId);
+        }
+    // FIX ME temporary always fetch URI
+    if (aAttrId & EMPXMediaGeneralUri)
+        {
+        MPX_DEBUG1("    !aMedia.IsSupported(KMPXMediaGeneralUri)");
+        HBufC* uri = ConstructUriL(aMusicTable, (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+        CleanupStack::PushL(uri);
+        aMedia.SetTextValueL(KMPXMediaGeneralUri, *uri);
+        MPX_DEBUG2("    FullPath[%S]", uri);
+        CleanupStack::PopAndDestroy(uri);
+        }
+    if (aAttrId & EMPXMediaGeneralDrive)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralDrive");            
+        TDriveUnit driveUnit;
+        if (aMedia.IsSupported(KMPXMediaGeneralUri))
+            {
+            MPX_DEBUG1("        aMedia.IsSupported(KMPXMediaGeneralUri)");
+            driveUnit = aMedia.ValueText(KMPXMediaGeneralUri);
+            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);
+            }
+        else
+            {
+            MPX_DEBUG1("        !aMedia.IsSupported(KMPXMediaGeneralUri)");                
+            driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+                aMusicTable.ColumnInt64(EMusicVolumeId));
+            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);                
+            }
+
+        TPtrC driveName(driveUnit.Name());
+        aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveName);
+        MPX_DEBUG2("    Drive[%S]", &driveName);
+        }
+    if (aAttrId & EMPXMediaGeneralSize)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralSize");                        
+        // to-do: store this in the DB
+        }
+    if (aAttrId & EMPXMediaGeneralDuration)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralDuration");                                    
+        TInt32 duration(aMusicTable.ColumnInt(EMusicDuration));
+        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
+        MPX_DEBUG2("    Duration[%d]", duration);
+        }
+    if ((aAttrId & EMPXMediaGeneralTitle) && !aMedia.IsSupported(KMPXMediaGeneralTitle))
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralTitle");
+        TPtrC title(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicTitle));
+        aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
+        MPX_DEBUG2("    Title[%S]", &title);
+        }
+    if ( aAttrId & EMPXMediaGeneralDate)
+		{
+		MPX_DEBUG1("    EMPXMediaGeneralDate");
+		const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable,
+				EMusicTimeAdded));
+		if ( dateStr.Compare (KNullDesC)!= 0)
+			{
+			TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr));
+			aMedia.SetTObjectValueL<TInt64> (KMPXMediaGeneralDate,
+					dateTime.Int64 ());
+			}
+		MPX_DEBUG2("    Date[%S]", &dateStr);
+		}
+    if (aAttrId & EMPXMediaGeneralComment)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralComment");                        
+        TPtrC comment(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComment));
+        aMedia.SetTextValueL(KMPXMediaGeneralComment, comment);
+        MPX_DEBUG2("    Comment[%S]", &comment);
+        }
+    if (aAttrId & EMPXMediaGeneralMimeType)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralMimeType");                                    
+        TPtrC mimeType(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicMimeType));
+        aMedia.SetTextValueL(KMPXMediaGeneralMimeType, mimeType);
+        MPX_DEBUG2("    MimeType[%S]", &mimeType);
+        }
+    if (aAttrId & EMPXMediaGeneralSynchronized)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralSynchronized");                                                
+        TInt sync(aMusicTable.ColumnInt(EMusicSync));
+        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, sync);
+        MPX_DEBUG2("    Synchronized[%d]", sync);
+        }
+    if (aAttrId & EMPXMediaGeneralDeleted)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralDeleted");                                                            
+        TInt del(aMusicTable.ColumnInt(EMusicDeleted));
+        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralDeleted, del);
+        MPX_DEBUG2("    Deleted[%d]", del);
+        }
+    if (aAttrId & EMPXMediaGeneralModified)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralModified");
+        TInt mod(aMusicTable.ColumnInt(EMusicModified));
+        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralModified, mod);
+        MPX_DEBUG2("    Modified[%d]", mod);
+        }
+    if (aAttrId & EMPXMediaGeneralCount)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralCount");
+        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1);
+        }
+    if (aAttrId & EMPXMediaGeneralCollectionId)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralCollectionId");            
+        aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
+            TUid::Uid(KDBPluginUid));
+        }
+    if(aAttrId & EMPXMediaGeneralCopyright)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralCopyright");            
+        TPtrC copyright(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicCopyright));
+        aMedia.SetTextValueL(KMPXMediaGeneralCopyright, copyright);
+        MPX_DEBUG2("    Copyright[%S]", &copyright);
+        }
+    if (aAttrId & EMPXMediaGeneralFlags)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralFlags");            
+        TUint32 dbFlags(aMusicTable.ColumnInt64(EMusicDbFlag));
+        MPX_DEBUG2("        dbFlags=%b", dbFlags);
+        TDriveUnit driveUnit;
+        if (aMedia.IsSupported(KMPXMediaGeneralUri))
+            {
+            MPX_DEBUG1("        aMedia.IsSupported(KMPXMediaGeneralUri)");
+            TParsePtrC parse( aMedia.ValueText(KMPXMediaGeneralUri) );
+            if( parse.DrivePresent() )
+                {
+                driveUnit = parse.Drive();
+                }
+            else
+                {
+                driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+                     aMusicTable.ColumnInt64(EMusicVolumeId));    
+                }
+            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);
+            }
+        else
+            {
+            MPX_DEBUG1("        !aMedia.IsSupported(KMPXMediaGeneralUri)");                
+            driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+                aMusicTable.ColumnInt64(EMusicVolumeId));
+            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);                
+            }
+
+        TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo;  // 5 bits
+        aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
+
+        MPX_DEBUG2("    GeneralFlags[%b]", dbFlags | driveId);
+        MPX_DEBUG2("    DriveId[%u]", driveId);
+        }
+    if (aAttrId & EMPXMediaGeneralPlayCount)
+        {
+        MPX_DEBUG1("    EMPXMediaGeneralPlayCount");            
+        TUint32 playcount(aMusicTable.ColumnInt(EMusicPlayCount));
+        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralPlayCount, playcount);
+        MPX_DEBUG2("    PlayCount[%d]", playcount);
+        }
+        
+    MPX_DEBUG1("<--CMPXDbMusic::UpdateMediaGeneralL");
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateMediaMusicL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::UpdateMediaMusicL(
+    RSqlStatement& aMusicTable,
+    const TUint aAttrId,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::UpdateMediaMusicL");
+
+    if (aAttrId & EMPXMediaMusicAlbumArtFileName)
+        {
+        TPtrC art(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArt));
+            aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
+            MPX_DEBUG2("    Album Art File Name[%S]", &art);
+        }
+    if (aAttrId & EMPXMediaMusicArtist)
+        {
+        TPtrC artist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArtistName));
+        aMedia.SetTextValueL(KMPXMediaMusicArtist, artist);
+        MPX_DEBUG2("    Artist[%S]", &artist);
+        }
+    if (aAttrId & EMPXMediaMusicAlbum)
+        {
+        TPtrC album(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumName));
+        aMedia.SetTextValueL(KMPXMediaMusicAlbum, album);
+        MPX_DEBUG2("    Album[%S]", &album);
+        }
+    if ( aAttrId & EMPXMediaMusicYear)
+		{
+		const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable,
+				EMusicReleaseDate));
+		if ( dateStr.Compare (KNullDesC)!= 0)
+			{
+			TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr));
+			aMedia.SetTObjectValueL<TInt64> (KMPXMediaMusicYear,
+					dateTime.Int64 ());
+			MPX_DEBUG2("    Year[%d]", dateTime.Int64());
+			}
+		MPX_DEBUG2("    ReleaseDate[%S]", &dateStr);
+		}
+    if (aAttrId & EMPXMediaMusicAlbumTrack)
+        {
+        TInt32 track(aMusicTable.ColumnInt(EMusicAlbumTrack));
+        HBufC* hbuf = HBufC::NewLC(KMCIntegerLen);
+        if (track != KMaxTInt)
+            {
+            hbuf->Des().AppendFormat(_L("%d"), track);
+            }
+        aMedia.SetTextValueL(KMPXMediaMusicAlbumTrack, *hbuf);
+        MPX_DEBUG3("    Album Track[%S][%d]", hbuf, track);
+        CleanupStack::PopAndDestroy(hbuf);
+        }
+    if (aAttrId & EMPXMediaMusicGenre)
+        {
+        TPtrC genre(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicGenreName));
+        aMedia.SetTextValueL(KMPXMediaMusicGenre, genre);
+        MPX_DEBUG2("    Music Genre[%S]", &genre);
+        }
+    if (aAttrId & EMPXMediaMusicComposer)
+        {
+        TPtrC composer(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComposerName));
+        aMedia.SetTextValueL(KMPXMediaMusicComposer, composer);
+        MPX_DEBUG2("    Music Composer[%S]", &composer);
+        }
+    if (aAttrId & EMPXMediaMusicRating)
+        {
+        TUint32 rating(aMusicTable.ColumnInt(EMusicRating));
+        aMedia.SetTObjectValueL<TUint32>(KMPXMediaMusicRating, rating);
+        MPX_DEBUG2("    Music Rating[%d]", rating);
+        }
+    if (aAttrId & EMPXMediaMusicURL)
+        {
+        TPtrC url(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicUrl));
+        aMedia.SetTextValueL(KMPXMediaMusicURL, url);
+        MPX_DEBUG2("    Music URL[%S]", &url);
+        }
+    if (aAttrId & EMPXMediaMusicOriginalAlbumArtFileName)
+        {
+        // Always set original album art to be file path
+        // Maybe add a new column to db for future if services like rhapsody pushes jpgs to us
+        if (aMedia.IsSupported(KMPXMediaGeneralUri))
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+            {    
+            TUint32 abstractAlbumId(aMusicTable.ColumnInt64(EMusicAbstractAlbum));
+            TInt containEmbeddedArt = aMusicTable.ColumnInt( EMusicContainEmbeddedArt);
+            //embedded with art, no art
+            if (containEmbeddedArt || (!containEmbeddedArt && !abstractAlbumId)) //embedded with art case, no art
+                {
+                const TDesC& art(aMedia.ValueText(KMPXMediaGeneralUri));
+                aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, art);
+                MPX_DEBUG2("    Music Original Album Art FullPath[%S]", &art);
+                }
+            //for abstractalbum case, originalAlbumArt from AbstractAlbum table
+            else if ( abstractAlbumId )
+                {
+                HBufC* art = iObserver.HandleGetAlbumNameFromIdL(abstractAlbumId);
+                CleanupStack::PushL(art);
+                aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, *art);
+                MPX_DEBUG2("    Music Original Album Art FullPath[%S]", art);
+                CleanupStack::PopAndDestroy(art);
+                }
+            }
+#else
+            {
+            const TDesC& uri(aMedia.ValueText(KMPXMediaGeneralUri));
+            aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, uri);
+            MPX_DEBUG2("    Music Original Album Art FullPath[%S]", &uri);
+            }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+       else
+           {
+           HBufC* fullPath = ConstructUriL(aMusicTable, (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+           CleanupStack::PushL(fullPath);
+           aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, *fullPath);
+           MPX_DEBUG2("    Music Original Album Art FullPath[%S]", fullPath);
+           CleanupStack::PopAndDestroy(fullPath);
+           }
+      }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED    
+     if (aAttrId & EMPXMediaMusicAlbumArtist)
+        {
+        TPtrC albumartist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumArtist));
+        aMedia.SetTextValueL(KMPXMediaMusicAlbumArtist, albumartist);
+        MPX_DEBUG2("    Music AlbumArtist[%S]", &albumartist);
+        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateMediaAudioL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::UpdateMediaAudioL(
+    RSqlStatement& aMusicTable,
+    const TUint aAttrId,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::UpdateMediaAudioL");
+
+    if (aAttrId & EMPXMediaAudioBitrate)
+        {
+        TUint32 bitrate(aMusicTable.ColumnInt(EMusicBitRate));
+        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioBitrate, bitrate);
+        MPX_DEBUG2("    Bitrate[%d]", bitrate);
+        }
+    if (aAttrId & EMPXMediaAudioSamplerate)
+        {
+        TUint32 samplerate(aMusicTable.ColumnInt(EMusicSampleRate));
+        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioSamplerate, samplerate);
+        MPX_DEBUG2("    SampleRate[%d]", samplerate);
+        }
+    if (aAttrId & EMPXMediaAudioNumberOfChannels)
+        {
+        TUint32 numchannels(aMusicTable.ColumnInt(EMusicNumChannels));
+        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioNumberOfChannels, numchannels);
+        MPX_DEBUG2("    Num of Channels[%d]", numchannels);
+        }
+    if (aAttrId & EMPXMediaAudioCodec)
+        {
+        TUint32 codec(aMusicTable.ColumnInt(EMusicCodec));
+        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioAudioCodec, codec);
+        MPX_DEBUG2("    Audio Codec[%d]", codec);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateMediaMTPL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::UpdateMediaMTPL(
+    RSqlStatement& aMusicTable,
+    const TUint aAttrId,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::UpdateMediaMTPL");
+
+    if (aAttrId & KMPXMediaMTPDrmStatus.iAttributeId)
+        {
+        TUint32 val(aMusicTable.ColumnInt(EMusicMTPDrmStatus));
+        aMedia.SetTObjectValueL<TUint16>(KMPXMediaMTPDrmStatus, val);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GenerateMusicFieldsValuesL
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::GenerateMusicFieldsValuesL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    CMPXMessageArray* aItemChangedMessages,
+    RSqlStatement* aMusicTable,
+    CDesCArray& aFields,
+    CDesCArray& aValues,
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbMusic::GenerateMusicFieldsValuesL");
+
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+    TBool metaDataModified(EFalse);
+    const TArray<TMPXAttribute> attributes = aMedia.Attributes();
+
+    TBool addSongChangedMessage(ETrue);
+    CMPXMessage* songChangedMessage(NULL);
+    if (aItemChangedMessages)
+        {
+        songChangedMessage = CMPXMedia::NewL();
+        CleanupStack::PushL(songChangedMessage);
+        MPXDbCommonUtil::FillItemChangedMessageL(*songChangedMessage, aSongId,
+            aMusicTable ? EMPXItemModified : EMPXItemInserted, EMPXSong, KDBPluginUid);            
+        }
+
+    // NOTE: Attributes being processed here should be listed in IsSupported()
+    TInt attrCount(attributes.Count());
+    for (TInt i = 0; i < attrCount; ++i)
+        {
+        TUint attributeId(attributes[i].AttributeId());
+
+        switch (attributes[i].ContentId())
+            {
+            case KMPXMediaIdGeneral:
+                {
+                if (attributeId & EMPXMediaGeneralDeleted)
+                    {
+                    TBool deleted(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted));
+                    if (!aMusicTable || (deleted != aMusicTable->ColumnInt(EMusicDeleted)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDel, deleted);
+                        }
+                    MPX_DEBUG2("    Deleted[%d]", deleted);
+                    }
+
+                if (attributeId & EMPXMediaGeneralFlags)
+                    {
+                    TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
+                    TUint32 curFlag(0);
+                    if (aMusicTable)
+                        {
+                        curFlag = aMusicTable->ColumnInt64(EMusicDbFlag);
+                        }
+                    TUint32 oldFlag(curFlag);                        
+
+                    if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit)
+                        {
+                        // Set bits
+                        curFlag |= flag;
+                        }
+                    else
+                        {
+                        // Clear bits
+                        curFlag &= (~flag);
+                        }
+
+                    // The field is written ONLY if the flag value is changing
+                    if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0)
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag);
+                        visibleChange = CMPXDbActiveTask::EAllVisible;
+                        }
+                    MPX_DEBUG2("    GeneralFlags[%b]", curFlag);
+                    }
+
+                if (attributeId & EMPXMediaGeneralTitle)
+                    {
+                    TBool titleChanged(NULL == aMusicTable);
+
+                    const TDesC& title = aMedia.ValueText(KMPXMediaGeneralTitle);
+                    TPtrC truncatedTitle(title.Left(KMCMaxTextLen));
+                    if (aMusicTable)
+                        {
+                        // Title of the song has been changed
+                        if (truncatedTitle.Compare(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTitle)) != 0)
+                            {
+                            titleChanged = ETrue;
+                            }
+                        }
+
+                    if (titleChanged)
+                        {
+                        if ( title.Length() == 0 )
+                            {
+                            const TDesC& path = aMedia.ValueText( KMPXMediaGeneralUri );
+                            TParsePtrC parse( path );
+                            TPtrC truncatedParse( parse.Name().Left( KMCMaxTextLen ) );
+
+                            MPXDbCommonUtil::AppendValueL( aFields, aValues, KMCMusicName, truncatedParse );
+                            }
+                        else
+                            {
+                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, truncatedTitle);
+                            }
+                        visibleChange = CMPXDbActiveTask::EAllVisible;
+                        metaDataModified = ETrue;
+
+                        MPX_DEBUG2("    Title[%S]", &truncatedTitle);
+                        }
+                    }
+
+                if (attributeId & EMPXMediaGeneralMimeType)
+                    {
+                    const TDesC& mimeTypeText( aMedia.ValueText(KMPXMediaGeneralMimeType) );
+                    MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMimeType, mimeTypeText);
+                    MPX_DEBUG2("    MimeType[%S]", &mimeTypeText);
+                    }
+                    
+                if (attributeId & EMPXMediaGeneralUri)
+                    {
+                    const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
+                    const TDesC& uriTrunc(uri.Mid(KMCPathStartPos));
+
+                    TDriveUnit driveUnit(uri);
+                    TUint volId(MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
+
+                    if (!aMusicTable || ((uriTrunc != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicLocation)) ||
+                        (volId != aMusicTable->ColumnInt64(EMusicVolumeId))))
+                        {
+                        // only do the update something changed
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicVolumeId, volId);
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicLocation,
+                            uri.Mid(KMCPathStartPos));
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, DRMTypeL(uri));
+                        MPX_DEBUG3("    VolumeId[%u] Location[%S]", volId, &uri);
+
+                        if (!aMedia.IsSupported(KMPXMediaGeneralMimeType))
+                            {
+                            TBuf< KMaxDataTypeLength > mimeTypeText(MPXDbCommonUtil::GetMimeTypeForUriL(uri).Des());
+                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMimeType, mimeTypeText);
+                            MPX_DEBUG2("    MimeType[%S]", &mimeTypeText);
+                            }
+
+                        if (!aMusicTable && !aMedia.IsSupported(KMPXMediaGeneralTitle))
+                            {
+                            TParsePtrC parser(uri);
+                            TPtrC title = parser.Name();
+                            // use file name as song name
+                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, title);
+
+                            visibleChange = CMPXDbActiveTask::EAllVisible;
+                            MPX_DEBUG2("    Title[%S]", &title);
+                            }
+
+                        // URI of the song has been changed. This changes the Id of the song
+                        if (aMusicTable)
+                            {
+                            TUint32 newSongId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, uri, EFalse);
+                            if (aSongId != newSongId)
+                                {
+                                MPX_DEBUG3("    CurrentSongId[0x%x] changed to [0x%x]", aSongId, newSongId);
+                                if (songChangedMessage)
+                                    {
+                                    songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, newSongId);
+                                    songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aSongId);
+                                    }
+
+                                MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUniqueId, newSongId);
+                                }
+                            }
+                        }
+                    }
+
+                if (attributeId & EMPXMediaGeneralPlayCount)
+                    {
+                    TInt increment(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralPlayCount));
+                    TUint32 curCount(increment);
+                    if (aMusicTable)
+                        {
+                        curCount += aMusicTable->ColumnInt(EMusicPlayCount);
+                        }
+
+                    if (!aMusicTable || (curCount != aMusicTable->ColumnInt(EMusicPlayCount)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicPlayCount, curCount);
+
+                        // this needs to be visible in order for Recently Played and Most Played
+                        // playlists will be updated
+                        visibleChange = CMPXDbActiveTask::ESingleVisible;
+
+                        if (aItemChangedMessages)
+                            {
+                            iObserver.HandlePlayCountModifiedL(*aItemChangedMessages);
+                            }           
+                        addSongChangedMessage = EFalse;
+                        }
+                        
+                    MPX_DEBUG2("    PlayCount[%d]", curCount);
+                    }
+
+                if (attributeId & EMPXMediaGeneralLastPlaybackTime)
+                    {
+                    HBufC* time = MPXDbCommonUtil::TTimeToDesLC(
+                        TTime(aMedia.ValueTObjectL<TInt64>(KMPXMediaGeneralLastPlaybackTime)));
+                    if (!aMusicTable || (*time != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTimePlayed)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTimePlayed, *time);
+                        // this needs to be visible in order for Recently Played playlist to be updated
+                        visibleChange = CMPXDbActiveTask::ESingleVisible;
+
+                        if (aItemChangedMessages)
+                            {
+                            iObserver.HandlePlaybackTimeModifiedL(*aItemChangedMessages);
+                            }           
+                        addSongChangedMessage = EFalse;
+                        }
+                    MPX_DEBUG2("    PlaybackTime[%S]", time);
+                    CleanupStack::PopAndDestroy(time);
+                    }
+
+                if (attributeId & EMPXMediaGeneralDuration)
+                    {
+                    TInt duration(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralDuration));
+                    if (!aMusicTable || (duration != aMusicTable->ColumnInt(EMusicDuration)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDuration, duration);
+                        visibleChange = CMPXDbActiveTask::EAllVisible;
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Duration[%d]", duration);
+                    }
+
+                if (attributeId & EMPXMediaGeneralSynchronized)
+                    {
+                    TBool synced(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
+                    if (!aMusicTable || (synced != aMusicTable->ColumnInt(EMusicSync)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSync, synced);
+                        }
+                    MPX_DEBUG2("    Synchronized[%d]", synced);
+                    }
+
+                if (attributeId & EMPXMediaGeneralModified)
+                    {
+                    TBool modified(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralModified));
+                    if (!aMusicTable || (modified != aMusicTable->ColumnInt(EMusicModified)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, modified);
+                        }
+                    MPX_DEBUG2("    Modified[%d]", modified);
+                    }
+
+                if (attributeId & EMPXMediaGeneralComment)
+                    {
+                    TPtrC comment = aMedia.ValueText(KMPXMediaGeneralComment).Left(KMCMaxTextLen);
+                    if (!aMusicTable || (comment != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicComment)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComment, comment);
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Comment[%S]", &comment);
+                    }
+
+                if (attributeId & EMPXMediaGeneralCopyright)
+                    {
+                    const TDesC& copyright = aMedia.ValueText(KMPXMediaGeneralCopyright).
+                        Left(KMCMaxTextLen);
+                    if (!aMusicTable || (copyright != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicCopyright)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicCopyright, copyright);
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Copyright[%S]", &copyright);
+                    }
+                }
+                break;
+
+            case KMPXMediaIdMusic:
+                {
+                if (attributeId & EMPXMediaMusicAlbumTrack)
+                    {
+                    const TDesC& trackNumber = aMedia.ValueText(KMPXMediaMusicAlbumTrack);
+
+                    // KMaxTInt is used to represent null album track
+                    TInt track(KMaxTInt);
+                    if (trackNumber.Length())
+                        {
+                        TLex stringParser(trackNumber);
+
+                        if ((stringParser.Val(track) != KErrNone) ||
+                            (track == 0) || (track > 999))  // Limit track number to 3 characters
+                            {
+                            track = KMaxTInt;
+                            }
+                        }
+
+                    if (!aMusicTable || (track != aMusicTable->ColumnInt(EMusicAlbumTrack)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTrackNumber, track);
+                        visibleChange = CMPXDbActiveTask::EAllVisible;
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG3("    Album Track[%S][%d]", &trackNumber, track);
+                    }
+
+                if (attributeId & EMPXMediaMusicYear)
+                    {
+                    TInt64 int64(aMedia.ValueTObjectL<TInt64>(KMPXMediaMusicYear));
+
+                    TTime maxTime(0);
+                    maxTime += TTimeIntervalYears(9999);    // Limit years to 4 characters
+                    TTime time(int64);
+
+                    if (time > maxTime)
+                        {
+                        time = Time::NullTTime();
+                        }
+
+                    HBufC* timeStr = MPXDbCommonUtil::TTimeToDesLC(time);
+                    if (!aMusicTable || (*timeStr != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicReleaseDate)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicReleaseDate, *timeStr);
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Music Year[%S]", timeStr);
+                    CleanupStack::PopAndDestroy(timeStr);
+                    }
+
+                if (attributeId & EMPXMediaMusicRating)
+                    {
+                    TInt rating(aMedia.ValueTObjectL<TInt>(KMPXMediaMusicRating));
+                    if (!aMusicTable || (rating != aMusicTable->ColumnInt(EMusicRating)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicRating, rating);
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Rating[%d]", rating);
+                    }
+
+                if (attributeId & EMPXMediaMusicAlbumArtFileName)
+                    {
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED     
+                    TInt containEmbeddedArt(0);                   
+                    if (aMusicTable )
+                        {                        
+                        containEmbeddedArt = aMusicTable->ColumnInt(EMusicContainEmbeddedArt);                    
+                        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+                    const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED 
+                    TParsePtrC parse(albumArtFilename);
+                    TPtrC ext(parse.Ext());
+                          
+                    if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0))                    
+                        {
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+                        if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt)))
+                            {
+                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
+                            visibleChange = CMPXDbActiveTask::EAllVisible;
+                            metaDataModified = ETrue;              
+                            }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED                                       
+                        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED                                         
+                    MPX_DEBUG2("    Album Art Filename[%S]", &albumArtFilename);
+                    }
+
+                if (attributeId & EMPXMediaMusicURL)
+                    {
+                    const TDesC& url = aMedia.ValueText(KMPXMediaMusicURL).Left(KMCMaxTextLen);
+                    if (!aMusicTable || (url != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicUrl)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUrl, url);
+                        metaDataModified = ETrue;
+                        }
+
+                    MPX_DEBUG2("    Music URL[%S]", &url);
+                    }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED                    
+               if (attributeId & EMPXMediaMusicAlbumArtist)
+                    {
+                    const TDesC& albumartist = aMedia.ValueText(KMPXMediaMusicAlbumArtist);
+                    TPtrC truncatedAlbumartist(albumartist.Left(KMCMaxTextLen));
+                    
+                    if (!aMusicTable || (truncatedAlbumartist.Compare(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicAlbumArtist)) != 0))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbumArtist, truncatedAlbumartist);
+                        visibleChange = CMPXDbActiveTask::EAllVisible;
+                        metaDataModified = ETrue;
+                        }                
+                   }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED              
+                }
+                break;
+
+            case KMPXMediaIdAudio:
+                {
+                if (attributeId & EMPXMediaAudioSamplerate)
+                    {
+                    TInt samplerate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioSamplerate));
+                    if (!aMusicTable || (samplerate != aMusicTable->ColumnInt(EMusicSampleRate)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSampleRate, samplerate);
+                        metaDataModified = ETrue;
+                        }
+
+                    MPX_DEBUG2("    Sample Rate[%d]", samplerate);
+                    }
+
+                if (attributeId & EMPXMediaAudioBitrate)
+                    {
+                    TInt bitrate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioBitrate));
+                    if (!aMusicTable || (bitrate != aMusicTable->ColumnInt(EMusicBitRate)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicBitRate, bitrate);
+                        metaDataModified = ETrue;
+                        }
+                    MPX_DEBUG2("    Bitrate[%d]", bitrate);
+                    }
+
+                if (attributeId & EMPXMediaAudioNumberOfChannels)
+                    {
+                    TUint32 val = aMedia.ValueTObjectL<TUint32>(KMPXMediaAudioNumberOfChannels);
+                    if (!aMusicTable || (val != aMusicTable->ColumnInt(EMusicNumChannels)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicNumChannels, val);
+                        }
+                    MPX_DEBUG2("    Num of Channels[%d]", val);
+                    }
+                }
+                break;
+
+            case KMPXMediaIdDrm:
+                {
+                if (attributeId & EMPXMediaDrmType)
+                    {
+                    TInt drmType(aMedia.ValueTObjectL<TInt>(KMPXMediaDrmType));
+                    if (!aMusicTable || (drmType != aMusicTable->ColumnInt(EMusicDRM)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, drmType);
+                        }
+                    MPX_DEBUG2("    DRM type[%d]", drmType);
+                    }
+                    
+                if (attributeId & KMPXMediaDrmRightsStatus.iAttributeId)
+                    {
+                    if (aMusicTable)
+                        {
+                        TMPXMediaDrmRightsStatus status = 
+                                 aMedia.ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus);
+                        
+                        //.Set the db flag
+                        TUint32 curFlag(aMusicTable->ColumnInt64(EMusicDbFlag));
+                        TUint32 oldFlag(curFlag);
+                        
+                        if ((status != EMPXDrmRightsFull) && (status != EMPXDrmRightsRestricted))
+                            {
+                            // No rights
+                            curFlag |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid;
+                            }
+                        else
+                            {
+                            // Rights valid
+                            curFlag &= (KMPXMediaGeneralFlagsIsDrmLicenceInvalid ^ 0xFFFFFFFF);
+                            }
+                        
+                        // The field is written ONLY if the flag value is changing
+                        if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0)
+                        {
+                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag);
+                            visibleChange = CMPXDbActiveTask::EAllVisible;
+                        }
+                            
+                        MPX_DEBUG2("    Rights Status[%d]", curFlag);
+                        }
+                    }
+                    
+                break;
+                }
+
+            case KMPXMediaIdMTP:
+                {
+                if (attributeId & KMPXMediaMTPDrmStatus.iAttributeId)
+                    {
+                    TUint16 drmStatus(aMedia.ValueTObjectL<TUint16>(KMPXMediaMTPDrmStatus));
+                    if (!aMusicTable || (drmStatus != aMusicTable->ColumnInt(EMusicMTPDrmStatus)))
+                        {
+                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMTPDrmStatus, drmStatus);
+                        }
+                    MPX_DEBUG2("    MTP Drm Status[%d]", drmStatus);
+                    }
+                }
+                break;
+
+            default:
+                break;
+            } // end switch
+        } // end for
+
+    // get the current artist/album/genre/composer
+    // this is required because the recordset may be reused by the code below
+    TUint32 artistId(0);
+    TUint32 albumId(0);
+    TUint32 genreId(0);
+    TUint32 composerId(0);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    TUint32 abstractAlbumId(0);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+    if (aMusicTable)
+        {
+        artistId = aMusicTable->ColumnInt64(EMusicArtist);
+        albumId = aMusicTable->ColumnInt64(EMusicAlbum);
+        genreId = aMusicTable->ColumnInt64(EMusicGenre);
+        composerId = aMusicTable->ColumnInt64(EMusicComposer);
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        abstractAlbumId = aMusicTable->ColumnInt64(EMusicAbstractAlbum);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED        
+        }
+
+    // update the artist field
+    TUint32 id(0);
+    TUint32 artistIdForAlbum(artistId);
+    if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
+        aDrive, aItemChangedMessages, id, 0))
+        {
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
+        metaDataModified = (aMusicTable != NULL);
+        visibleChange = CMPXDbActiveTask::EAllVisible;
+        artistIdForAlbum = id;
+        }
+
+    // update the album field
+	if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId,
+		aDrive, aItemChangedMessages, id, artistIdForAlbum))
+        {
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id);
+        metaDataModified = (aMusicTable != NULL);
+        visibleChange = CMPXDbActiveTask::EAllVisible;
+        
+        //
+        // added to handle error EALU-73WDJN. If the album name of the last song
+        // in the album for the artist is changed to an existing album name from
+        // artist view, a change message needs to be sent in order for UI to
+        // correctly refresh.
+        //
+        // Fix for EDXU-7BBALS, remove check for HasOtherSongsInArtistAlbumL 
+        // Always send a Album Inserted message when Album change to get Artist updated
+        if (aItemChangedMessages)
+            {
+            // send album added m essage instead of album deleted or modified
+            // to avoid collection paths of other clients being modified
+            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId, 
+                    EMPXItemInserted, EMPXAlbum, KDBPluginUid);
+            }
+        }
+
+    // update the genre field
+    if (UpdateCategoryFieldL(EMPXGenre, aMedia, KMPXMediaMusicGenre, genreId,
+        aDrive, aItemChangedMessages, id))
+        {
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicGenre, id);
+        metaDataModified = (aMusicTable != NULL);
+        visibleChange = CMPXDbActiveTask::EAllVisible;
+        }
+
+    // update the composer field
+    if (UpdateCategoryFieldL(EMPXComposer, aMedia, KMPXMediaMusicComposer, composerId,
+        aDrive, aItemChangedMessages, id))
+        {
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComposer, id);
+        metaDataModified = (aMusicTable != NULL);
+        visibleChange = CMPXDbActiveTask::EAllVisible;
+        }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+    if ( aMedia.IsSupported (KMPXMediaMusicAlbumArtFileName))
+        {
+        const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);            
+        TParsePtrC parse( albumArtFilename );
+        TPtrC ext( parse.Ext() );
+        if (ext.CompareF(KAbstractAlbumExt)== 0)   
+            {
+            if (UpdateCategoryFieldL(EMPXAbstractAlbum, aMedia, KMPXMediaMusicAlbumArtFileName, abstractAlbumId,
+                aDrive, aItemChangedMessages, id))
+                {
+                MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAbstractAlbum, id);
+                metaDataModified = (aMusicTable != NULL);
+                visibleChange = CMPXDbActiveTask::EAllVisible;
+                }
+            }                       
+        }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+#if defined (__MTP_PROTOCOL_SUPPORT)
+    // Set Mod bit to ETrue if metadata has been updated and caller hasn't explicitly
+    // set/reset it
+    if (aMusicTable &&
+        !aMedia.IsSupported(KMPXMediaGeneralModified) &&
+        metaDataModified)
+        {
+        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, 1);
+        MPX_DEBUG1("    Modified[1]");
+        }
+#endif
+
+    if (aItemChangedMessages)
+        {
+      if (aFields.Count() && addSongChangedMessage)
+          {
+          aItemChangedMessages->AppendL(*songChangedMessage);
+          }
+        CleanupStack::PopAndDestroy(songChangedMessage);
+        }
+        
+    return visibleChange;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DRMTypeL
+// ----------------------------------------------------------------------------
+//
+TMCDrmType CMPXDbMusic::DRMTypeL(
+    const TDesC& aFile)
+    {
+    MPX_FUNC("CMPXDbMusic::DRMTypeL");
+
+    TMCDrmType drm(EMCDrmNone);
+    TInt pos(0);
+    TParsePtrC fullEntry(aFile);
+    TPtrC theExt = fullEntry.Ext();
+
+    if (iExtensionsDrm->Find(theExt, pos) == 0)
+        {
+        drm = MPXDbCommonUtil::GetDRMTypeL(aFile);
+        }
+
+    return drm;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::GenerateMusicMatchingCriteriaLC
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbMusic::GenerateMusicMatchingCriteriaLC(
+    TUint32 aGeneralId,
+    TUint32 aContainerId,
+    TMPXGeneralType aType,
+    const CMPXMedia& aCriteria)
+    {
+    MPX_FUNC("CMPXDbMusic::GenerateMusicMatchingCriteriaLC");
+
+    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
+    TInt criteriaCount(criteria.Count());
+
+    // construct an array of criteria strings
+    CDesCArrayFlat* sqlCriteria = new (ELeave) CDesCArrayFlat(criteriaCount);
+    CleanupStack::PushL(sqlCriteria);
+
+    // If EMPXMediaGeneralDeleted is not defined, always unset the deleted bit for matching
+    if (!aCriteria.IsSupported(KMPXMediaGeneralDeleted))
+        {
+        sqlCriteria->AppendL(KCriterionMusicNotDeleted);
+        }
+
+    TBool volumeAdded(EFalse);
+    for (TInt i = 0; i < criteriaCount; ++i)
+        {
+        const TMPXAttribute& criterion = criteria[i];
+
+        if (criterion == KMPXMediaGeneralId)
+            {
+            // Set the type if no type is specified
+            TInt category(MPX_ITEM_CATEGORY(aGeneralId));
+
+            if( aType == EMPXNoType )
+                {
+                aType = (category == EMPXCollection) ? EMPXItem : EMPXGroup;
+                }
+
+            TPtrC ptr;
+            if (aType == EMPXItem && (category == EMPXCollection))
+                {
+                ptr.Set(KCriterionMusicUniqueId);
+                }
+            else if (aType == EMPXGroup && (category == EMPXArtist))
+                {
+                ptr.Set(KCriterionMusicArtist);
+                }
+            else if (aType == EMPXGroup && (category == EMPXAlbum))
+                {
+                ptr.Set(KCriterionMusicAlbum);
+                }
+            else if (aType == EMPXGroup && (category == EMPXGenre))
+                {
+                ptr.Set(KCriterionMusicGenre);
+                }
+            else if (aType == EMPXGroup && (category == EMPXComposer))
+                {
+                ptr.Set(KCriterionMusicComposer);
+                }
+            else
+                {
+                User::Leave(KErrNotSupported);
+                }
+
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, ptr, aGeneralId);
+            }
+        else if (criterion == KMPXMediaGeneralContainerId)
+            {
+            TInt containerCategory(MPX_ITEM_CATEGORY(aContainerId));
+
+            if (aType == EMPXGroup && (containerCategory == EMPXArtist))
+                {
+                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria,
+                    KCriterionMusicArtist, aContainerId);
+                }
+            else if (aType == EMPXGroup && (containerCategory == EMPXAlbum))
+                {
+                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria,
+                    KCriterionMusicAlbum, aContainerId);
+                }
+            else
+                {
+                //User::Leave(KErrNotSupported);
+                }
+            }
+        else if (criterion == KMPXMediaGeneralTitle)
+            {
+            HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
+                aCriteria.ValueText(KMPXMediaGeneralTitle));
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicTitle, *title);
+            CleanupStack::PopAndDestroy(title);
+            }
+        else if (criterion == KMPXMediaGeneralUri)
+            {
+            // full URI from criteria
+            const TDesC& uri = aCriteria.ValueText(KMPXMediaGeneralUri);
+            TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
+                                                                uri, EFalse);
+            
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicUniqueId, itemId);
+            }
+        else if (criterion == KMPXMediaGeneralDrive)
+            {
+            if (!volumeAdded)
+                {
+                // validate the drive letter, TDriveUnit panics if given drive isn't between
+                // 'A' to 'Z'
+                TDriveUnit driveUnit(aCriteria.ValueText(KMPXMediaGeneralDrive));
+                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume,
+                    MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
+                volumeAdded = ETrue;
+                }
+            }
+        else if (criterion == KMPXMediaGeneralSynchronized)
+            {
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicSync,
+                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
+            }
+        else if (criterion == KMPXMediaGeneralDeleted)
+            {
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicDeleted,
+                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted));
+            }
+        else if (criterion == KMPXMediaGeneralModified)
+            {
+            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicModified,
+                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralModified));
+            }
+         else
+            {
+            // to-do: provide searching ability on the rest of the fields
+            }
+        }
+
+    // construct the final criteria string
+    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*sqlCriteria, KMCAndKeyword);
+
+    CleanupStack::Pop(criteriaStr);
+    CleanupStack::PopAndDestroy(sqlCriteria);
+    CleanupStack::PushL(criteriaStr);
+
+    return criteriaStr;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::ConstructUriL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbMusic::ConstructUriL(
+    RSqlStatement& aMusicTable,
+    TUint32 aMediaId)
+    {
+    MPX_FUNC("CMPXDbMusic::ConstructUriL");
+
+    TUint volId(aMusicTable.ColumnInt64(EMusicVolumeId));
+    TPtrC location(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicLocation));
+    if(!location.Length())
+        {
+        return GetUriL(aMediaId);
+        }
+    return MPXDbCommonUtil::CreateFullPathL(
+        MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId), location);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbMusic::CreateTableL");
+
+    // Create the table
+    User::LeaveIfError(aDatabase.Exec(KMusicCreateTable));
+
+    // Do not create any other indexes than the one on UniqueId
+    // as they only slow down the database overall
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::DropTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbMusic::DropTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbMusic::DropTableL");
+    User::LeaveIfError(aDatabase.Exec(KMusicDropTable));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbMusic::CheckTableL");
+    return DoCheckTable(aDatabase, KMusicCheckTable);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateCategoryFieldL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::UpdateCategoryFieldL(
+    TMPXGeneralCategory aCategory,
+    const CMPXMedia& aMedia,
+    const TMPXAttribute& aAttribute,
+    TUint32 aOldId,
+    TInt aDriveId,
+    CMPXMessageArray* aItemChangedMessages,
+    TUint32& aItemId)
+    {
+    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
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+                if(aCategory == EMPXAbstractAlbum)
+                    {
+                    if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong )
+                        {
+                        iObserver.AddCategoryItemL(aCategory, name, aDriveId,
+                            aItemChangedMessages, itemAdded, KNullDesC, KNullDesC);                                 
+                        }
+                    else
+                        {         
+                        TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
+                        //get AlbumArt, Genre for AbstractAlbum
+                        MPX_DEBUG2("    Music albumartist[%S]", &albumartist);            
+                        TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen));                               
+                        MPX_DEBUG2("    Music Genre[%S]", &genre);    
+                           
+                        // ignore the return value
+                        iObserver.AddCategoryItemL(aCategory, name, aDriveId,
+                          aItemChangedMessages, itemAdded, albumartist, genre);    
+                        }
+                    }
+                else
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+                    {
+                    // ignore the return value
+                    iObserver.AddCategoryItemL(aCategory, name, 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))
+                {
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED                                        
+                if(aCategory == EMPXAbstractAlbum)
+                    {              
+                    //get AlbumArt, Genre for AbstractAlbum
+                    TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
+                    MPX_DEBUG2("    Music albumartist[%S]", &albumartist);
+                    TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen));
+                    MPX_DEBUG2("    Music Genre[%S]", &genre);    
+                                           
+                    // ignore the return value
+                    iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId,
+                    aItemChangedMessages, itemAdded, albumartist, genre);      
+                    }
+               else
+#endif // ABSTRACTAUDIOALBUM_INCLUDED        
+                      {              
+                      // ignore the return value
+                      iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId,
+                            aItemChangedMessages, itemAdded);
+                      }
+                 updated = ETrue;
+                 }
+            }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+            //no need to delete old item for abstractalbum
+            if (aOldId && (aOldId != aItemId) && (aCategory != EMPXAbstractAlbum))
+#else
+            if (aOldId && (aOldId != aItemId))
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+            {
+            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;
+    }
+
+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
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::ExtraFieldsRequired(
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_DEBUG1("-->CMPXDbMusic::ExtraFieldsRequired");
+
+    // check if any extra fields are required
+    TUint defaultFields(EMPXMediaGeneralId |
+                        EMPXMediaGeneralType |
+                        EMPXMediaGeneralCategory |
+                        EMPXMediaGeneralTitle |
+                        EMPXMediaGeneralUri |
+                        EMPXMediaGeneralFlags);
+                        
+    TBool extraRequired(EFalse);
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        TUint attributeId(aAttrs[i].AttributeId()|defaultFields);
+        MPX_DEBUG2("    attribute content id 0x%x", aAttrs[i].ContentId());
+        MPX_DEBUG3("    attribute id %b, original attribute id %b", attributeId, aAttrs[i].AttributeId());
+
+        if (KMPXMediaIdGeneral != aAttrs[i].ContentId() ||
+            attributeId != defaultFields)
+            {
+            MPX_DEBUG1("    extraRequired YES");
+            extraRequired = ETrue;
+            break;
+            }
+        }
+
+    MPX_DEBUG2("<--CMPXDbMusic::ExtraFieldsRequired returns %d", extraRequired);
+    return extraRequired;
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Test if the given media contains supported attributes
+// ----------------------------------------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::IsSupported(
+  const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbMusic::IsSupported");                   
+
+    // this checklist should match the attributes processed in DoFillInDatabaseInfoL
+    return aMedia.IsSupported(KMPXMediaGeneralTitle) ||
+        aMedia.IsSupported(KMPXMediaGeneralUri) ||
+        aMedia.IsSupported(KMPXMediaGeneralComment) ||
+        aMedia.IsSupported(KMPXMediaGeneralSynchronized) ||
+        aMedia.IsSupported(KMPXMediaGeneralDeleted) ||
+        aMedia.IsSupported(KMPXMediaGeneralModified) ||
+        aMedia.IsSupported(KMPXMediaGeneralCopyright) ||
+        aMedia.IsSupported(KMPXMediaGeneralDuration) ||
+        aMedia.IsSupported(KMPXMediaGeneralFlags) ||
+        aMedia.IsSupported(KMPXMediaGeneralPlayCount) ||
+        aMedia.IsSupported(KMPXMediaGeneralLastPlaybackTime) ||
+        aMedia.IsSupported(KMPXMediaMusicAlbumTrack) ||
+        aMedia.IsSupported(KMPXMediaMusicYear) ||
+        aMedia.IsSupported(KMPXMediaMusicRating) ||
+        aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ||
+        aMedia.IsSupported(KMPXMediaMusicURL) ||
+        aMedia.IsSupported(KMPXMediaMusicArtist) ||
+        aMedia.IsSupported(KMPXMediaMusicAlbum) ||
+        aMedia.IsSupported(KMPXMediaMusicGenre) ||
+        aMedia.IsSupported(KMPXMediaMusicComposer) ||
+        aMedia.IsSupported(KMPXMediaAudioSamplerate) ||
+        aMedia.IsSupported(KMPXMediaAudioBitrate) ||
+        aMedia.IsSupported(KMPXMediaAudioNumberOfChannels) ||
+        aMedia.IsSupported(KMPXMediaDrmType) ||
+        aMedia.IsSupported(KMPXMediaDrmRightsStatus) ||
+        aMedia.IsSupported(KMPXMediaMTPDrmStatus)
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED        
+        ||aMedia.IsSupported(KMPXMediaMusicAlbumArtist)
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        ;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplaylist.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,1098 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interaction with the playlist tables.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <mpxlog.h>
+#include <mpxmediacontainerdefs.h>
+
+#include "mpxdbcommonutil.h"
+#include "mpxdbcommondef.h"
+#include "mpxdbcommonstd.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbmanager.h"
+#include "mpxdbutil.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbplaylistsongs.h"
+#include "mpxdbplaylist.h"
+
+// CONSTANTS
+// UniqueID column in Uris requests
+const TInt KColUniqueID = 0;
+// URI column in Uris requests
+const TInt KColUri = 1;
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylist* CMPXDbPlaylist::NewL(
+    CMPXDbManager& aDbManager,
+	MMPXDbPlaylistObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbPlaylist::NewL");
+
+    CMPXDbPlaylist* self = CMPXDbPlaylist::NewLC(aDbManager, aObserver);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylist* CMPXDbPlaylist::NewLC(
+    CMPXDbManager& aDbManager,
+	MMPXDbPlaylistObserver& aObserver)
+    {
+    MPX_FUNC("CMPXDbPlaylist::NewLC");
+
+	CMPXDbPlaylist* self = new (ELeave) CMPXDbPlaylist(aDbManager, aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylist::~CMPXDbPlaylist()
+    {
+    MPX_FUNC("CMPXDbPlaylist::~CMPXDbPlaylist");
+    delete iPlaylistSongs;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylist::CMPXDbPlaylist(
+    CMPXDbManager& aDbManager, 
+    MMPXDbPlaylistObserver& aObserver) :
+    CMPXDbTable(aDbManager),
+	iObserver(aObserver)
+    {
+    MPX_FUNC("CMPXDbPlaylist::CMPXDbPlaylist");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::ConstructL()
+    {
+    MPX_FUNC("CMPXDbPlaylist::ConstructL");
+
+    BaseConstructL();
+    iPlaylistSongs = CMPXDbPlaylistSongs::NewL(iDbManager);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::AddPlaylistL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlaylist::AddPlaylistL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::AddPlaylistL");
+
+    // make sure the playlist and the corresponding songs are deleted
+    TUint32 playlistId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist,
+        aMedia.ValueText(KMPXMediaGeneralUri), EFalse));
+    DeletePlaylistNoUriL(playlistId);
+
+    // add the playlist
+    return DoAddPlaylistL(aMedia, TDriveUnit(aMedia.ValueText(KMPXMediaGeneralUri)));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::AddSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::AddSongsL(
+    TUint32 aPlaylistId,
+    const CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlaylist::AddSongsL");
+
+    // get the drive ID of corresponding playlist
+    TInt drive(GetDriveIdL(aPlaylistId));
+
+    // add the songs
+    iPlaylistSongs->AddSongsL(aPlaylistId, aMediaArray, drive);
+
+    // update the time for the playlist
+    UpdatePlaylistTimeL(aPlaylistId, drive);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::UpdatePlaylistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::UpdatePlaylistL(
+    const CMPXMedia& aMedia,
+    CMPXMessage& aMessage,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistL");
+
+    TUint32 playlistId((aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+    DoUpdatePlaylistL(playlistId, aMedia, aDriveId, aMessage);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::UpdateSongL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylist::UpdateSongL(
+    const CMPXMedia& aMedia,
+    TBool aResetFlags,
+    CMPXMessageArray* aItemChangedMessages /* = NULL */)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdateSongL");
+
+    // find the song ID
+    TInt oldSongId(0);
+    TInt newSongId(0);
+    if (aMedia.IsSupported(KMPXMediaGeneralId))
+        {
+        oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
+        }
+    if (aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        newSongId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
+            aMedia.ValueText(KMPXMediaGeneralUri), EFalse);
+        }
+    if ( !aMedia.IsSupported( KMPXMediaGeneralId ) && !aMedia.IsSupported( KMPXMediaGeneralUri ))
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( newSongId <= 0 )
+        {
+        newSongId = oldSongId;
+        }
+
+    if ( oldSongId <= 0 )
+        {
+        oldSongId = newSongId;
+        }
+
+    // update the PlaylistSongs and PlaylistSongInfo tables first
+    TBool updated(EFalse);
+    TBool visible(iPlaylistSongs->UpdateSongL( oldSongId, aMedia, aResetFlags, updated ));
+    TBool bSongInPlaylists( EFalse );
+    if (updated)
+        {
+        UpdatePlaylistsForSongL( newSongId, aItemChangedMessages,bSongInPlaylists );
+        }
+
+    return visible;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DeleteSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DeleteSongL(
+    TUint32 aSongId,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
+    TBool bSongInPlaylists(EFalse);
+    // add item changed messages for all playlists that contain the song
+    UpdatePlaylistsForSongL (aSongId, &aItemChangedMessages, bSongInPlaylists);
+    if (bSongInPlaylists)
+        {
+        // delete the song from the PlaylistSongs and PlaylistSongInfo tables
+        iPlaylistSongs->DeleteSongL (aSongId);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DeleteSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DeleteSongL(
+    TUint32 aPlaylistId,
+    TUint32 aSongId,
+    TInt aOrdinal)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
+
+    // get playlist drive
+    TInt drive(GetDriveIdL(aPlaylistId));
+
+    // delete the song from the PlaylistSongs / PlaylistSongInfo tables
+    iPlaylistSongs->DeleteSongL(aPlaylistId, aSongId, aOrdinal, drive);
+
+    // update the time for the playlist
+    UpdatePlaylistTimeL(aPlaylistId, drive);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DeletePlaylistL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbPlaylist::DeletePlaylistL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeletePlaylistL");
+
+    // get the uri
+    HBufC* uri = GetUriL(aPlaylistId);
+    if (uri)
+        {
+        CleanupStack::PushL(uri);
+        TDriveUnit drive(*uri);
+
+        // delete the songs from the PlaylistSongs table
+        iPlaylistSongs->DeleteSongsL(aPlaylistId, drive);
+
+        // delete the playlist record from the Playlist table
+        iDbManager.ExecuteQueryL(drive, KQueryPlaylistDelete, aPlaylistId);
+
+        CleanupStack::Pop(uri);
+        }
+
+    return uri;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DeletePlaylistNoUriL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DeletePlaylistNoUriL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeletePlaylistNoUriL");
+
+    TInt drive(0);
+    MPX_TRAPD(err, drive = GetDriveIdL(aPlaylistId));
+    if (err != KErrNotFound)
+        {
+        User::LeaveIfError(err);
+
+        // delete the songs from the PlaylistSongs table
+        iPlaylistSongs->DeleteSongsL(aPlaylistId, drive);
+
+        // delete the playlist record from the Playlist table
+        iDbManager.ExecuteQueryL(drive, KQueryPlaylistDelete, aPlaylistId);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DeleteAllPlaylistsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DeleteAllPlaylistsL()
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteAllPlaylistsL");
+
+    // delete the songs from the PlaylistSongs table
+    iPlaylistSongs->DeleteAllSongsL();
+
+    // delete all playlists
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistDeleteAll);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::CountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylist::CountL()
+    {
+    MPX_FUNC("CMPXDbPlaylist::CountL");
+    return ExecuteSumQueryL(KQueryPlaylistCount);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetPlaylistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::GetPlaylistL(
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetPlaylistL");
+    ExecuteMediaQueryL(aAttrs, aMedia, KQueryPlaylistGet, aPlaylistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetAllPlaylistsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::GetAllPlaylistsL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetAllPlaylistsL");
+    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryPlaylistGetAll);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetNameL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbPlaylist::GetNameL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetNameL");
+
+    RSqlStatement recordset(GetPlaylistRecordL(aPlaylistId));
+    CleanupClosePushL(recordset);
+
+    HBufC* name(NULL);
+    TInt err(KErrNone);
+    if ((err = recordset.Next()) == KSqlAtRow)
+        {
+        name = MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistName).AllocL();
+        }
+    CleanupStack::PopAndDestroy(&recordset);
+
+    if (err != KSqlAtEnd)
+        {
+        User::LeaveIfError(err);
+        }
+
+    if (name == NULL)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
+    return name;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetUriL
+// ----------------------------------------------------------------------------
+//
+HBufC* CMPXDbPlaylist::GetUriL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetUriL");
+
+    RSqlStatement recordset(GetPlaylistRecordL(aPlaylistId));
+    CleanupClosePushL(recordset);
+
+    HBufC* uri(NULL);
+    TInt err(KErrNone);
+    if ((err = recordset.Next()) == KSqlAtRow)
+        {
+        uri = MPXDbCommonUtil::CreateFullPathL(
+            MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+            recordset.ColumnInt64(EPlaylistVolumeId)),
+            MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistUri));
+
+        }
+    CleanupStack::PopAndDestroy(&recordset);
+
+    if (err != KSqlAtEnd)
+        {
+        User::LeaveIfError(err);
+        }
+
+    if (uri == NULL)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
+
+    return uri;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetIdL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlaylist::GetIdL(
+    const TDesC& aUri)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetIdL");
+    HBufC* uri = MPXDbCommonUtil::ProcessPatternCharsLC( aUri );
+    TUint32 ret = ExecuteIntQueryL(
+        KQueryLikePlaylistId, uri->Mid( KMCPathStartPos ) );
+
+   	CleanupStack::PopAndDestroy( uri );
+
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::FindAllL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::FindAllL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlaylist::FindAllL");
+
+    // process the requested attributes
+    // the UniqueId is always requested
+    TBool titleRequested(EFalse);
+    TBool counterRequested(EFalse);
+
+    TInt viewingColumnCount(aAttrs.Count());
+    for (TInt i = 0; (i < viewingColumnCount) && !(titleRequested && counterRequested); ++i)
+        {
+        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
+            {
+            TUint attributeId(aAttrs[i].AttributeId());
+
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                titleRequested = ETrue;
+                }
+            if (attributeId & EMPXMediaGeneralCount)
+                {
+                counterRequested = ETrue;
+                }
+            }
+        }
+
+    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
+
+    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
+    TInt criteriaCount(criteria.Count());
+
+    // process the criteria and construct the criteria string
+    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(criteriaCount);
+    CleanupStack::PushL(criteriaArray);
+
+    TBool criteriaCounterSet(EFalse);
+    TInt criteriaCounter(0);
+
+    for (TInt i = 0; i < criteriaCount; ++i)
+        {
+        const TMPXAttribute& criterion = criteria[i];
+        if (type == EMPXItem && criterion == KMPXMediaGeneralId)
+            {
+            TUint32 itemId((aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+            if (MPX_ITEM_CATEGORY(itemId) != EMPXPlaylist)
+                {
+                User::Leave(KErrNotSupported);
+                }
+
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId, itemId);
+            }
+        else if (criterion == KMPXMediaGeneralTitle)
+            {
+            HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
+                aCriteria.ValueText(KMPXMediaGeneralTitle));
+            if( type == EMPXOtherType )
+                {
+                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTitle, *title);
+                }
+            else
+                {
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistLikeTitle, *title);
+                }
+            CleanupStack::PopAndDestroy(title);
+            }
+        else if (criterion == KMPXMediaGeneralUri)
+            {
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId,
+                MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist,
+                aCriteria.ValueText(KMPXMediaGeneralUri), EFalse));
+            }
+        else if (criterion == KMPXMediaGeneralDrive)
+            {
+            const TDesC& drive(aCriteria.ValueText(KMPXMediaGeneralDrive));
+            TDriveUnit driveUnit(drive);
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistVolumeId,
+                MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
+            }
+        else if (criterion == KMPXMediaGeneralSynchronized)
+            {
+            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistSync,
+                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
+            }
+        else if (criterion == KMPXMediaGeneralCount)
+            {
+            criteriaCounterSet = ETrue;
+            criteriaCounter = aCriteria.ValueTObjectL<TInt>(KMPXMediaGeneralCount);
+            }
+        }
+
+    // construct criteria string
+    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
+
+    HBufC* query(NULL);
+    if (criteriaStr->Length() > 0)
+        {
+        // construct and execute the query
+        query = HBufC::NewLC(KQueryPlaylistItems().Length() + criteriaStr->Length());
+        query->Des().Format(KQueryPlaylistItems, criteriaStr);
+        }
+    else
+        {
+        query = HBufC::NewLC(KQueryPlaylistGetAll().Length());
+        query->Des().Format(KQueryPlaylistGetAll);
+        }
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
+
+    CleanupStack::PopAndDestroy(query);
+    CleanupStack::PopAndDestroy(criteriaStr);
+    CleanupStack::PopAndDestroy(criteriaArray);
+
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        // Setup basic info - with first record of a group
+        TUint32 playlistId(recordset.ColumnInt64(EPlaylistUniqueId));
+        TUint32 volId(recordset.ColumnInt64(EPlaylistVolumeId));
+        TInt driveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
+
+        TBool valid(ETrue);
+        TInt songCount(-1);
+        if (criteriaCounterSet)
+            {
+            if (driveId >= 0)
+                {
+                //valid disk
+                songCount = iPlaylistSongs->CountL(playlistId, driveId);
+                }
+            valid = (criteriaCounter == songCount);
+            }
+
+        if (valid)
+            {
+            // start a new media object
+            CMPXMedia* media = CMPXMedia::NewL();
+            CleanupStack::PushL(media);
+
+            UpdateMediaL(recordset, aAttrs, *media);
+
+            aMediaArray.AppendL(*media);
+            CleanupStack::PopAndDestroy(media);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+
+    if (err != KSqlAtEnd)
+        {
+        User::LeaveIfError(err);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetDriveIdL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylist::GetDriveIdL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetDriveIdL");
+    return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
+        ExecuteIntQueryL(KQueryPlaylistDriveId, aPlaylistId));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::Songs
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylistSongs& CMPXDbPlaylist::Songs()
+    {
+    return *iPlaylistSongs;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetDrivePlaylistCount
+// ----------------------------------------------------------------------------
+//
+TUint CMPXDbPlaylist::GetDrivePlaylistCountL(TInt aDrive)
+    {
+    TUint count(0);
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryPlaylistFileCount));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() != KSqlAtRow)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex));
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return count;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetPlaylistUriArrayL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
+                                          CDesCArray& aUriArr, TInt& aLastID)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetPlaylistUriArrayL");
+
+    HBufC* query = NULL;
+    if(aFromID == 0)
+        {
+        query = HBufC::NewLC(KQueryPlaylistGetFileUris().Length()
+                            + KMCIntegerLen);
+        query->Des().Format(KQueryPlaylistGetFileUris, aRecords);
+        }
+    else
+        {
+        query = HBufC::NewLC(KQueryPlaylistGetFileUrisFrom().Length()
+                            + 2*KMCIntegerLen);
+        query->Des().Format(KQueryPlaylistGetFileUrisFrom, aFromID, aRecords);
+        }
+
+    RSqlStatement playlist_rs(iDbManager.ExecuteSelectQueryL(aDrive,*query));
+
+    CleanupStack::PopAndDestroy(query);
+
+    CleanupClosePushL(playlist_rs);
+
+    TInt lastID = 0;
+    TInt err(KErrNone);
+    while((err = playlist_rs.Next()) == KSqlAtRow)
+        {
+        HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive,
+                MPXDbCommonUtil::GetColumnTextL(playlist_rs, KColUri));
+        CleanupStack::PushL(fullPath);
+        aUriArr.AppendL(*fullPath);
+        CleanupStack::PopAndDestroy(fullPath);
+
+        lastID = playlist_rs.ColumnInt(KColUniqueID);
+        }
+    CleanupStack::PopAndDestroy(&playlist_rs);
+
+    aLastID = lastID;
+
+    if (err!= KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdateMediaL");
+
+    TBool countRequested(EFalse);
+	TBool durationRequested(EFalse);
+    TUint32 playlistId(aRecord.ColumnInt64(EPlaylistUniqueId));
+
+    TInt count(aAttrs.Count());
+    TUint32 volId(aRecord.ColumnInt64(EPlaylistVolumeId));
+    TInt driveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
+    for (TInt i = 0; i < count; ++i)
+        {
+        TInt contentId(aAttrs[i].ContentId());
+        TUint attributeId(aAttrs[i].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            if (attributeId & EMPXMediaGeneralId)
+                {
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId);
+                MPX_DEBUG2("    Playlist ID[%u]", playlistId);
+                }
+            if (attributeId & EMPXMediaGeneralCollectionId)
+                {
+                aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
+                    TUid::Uid(KDBPluginUid));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                TPtrC title(MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistName));
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
+                MPX_DEBUG2("    Title[%S]", &title);
+                }
+            if ((attributeId & EMPXMediaGeneralUri) ||
+                (attributeId & EMPXMediaGeneralDrive) ||
+                (attributeId & EMPXMediaGeneralFlags))
+                {
+
+                // LTAN-7GH6BZ, crash if eject memory card when adding song to existing playlist
+                // due to special timing issue, it is possible drive number is -1 and create a
+                // panic when use for TDriveUnit
+                MPX_DEBUG3("volId = %d, driveId = %d", volId, driveId);
+
+                // handle possibly delay from framework notification
+                if (driveId < 0)
+                    {
+                    MPX_DEBUG1("invalid driveId, leave with KErrNotReady");
+                    User::Leave(KErrNotReady);
+                    }
+
+                TDriveUnit driveUnit(driveId);
+
+                if (attributeId & EMPXMediaGeneralUri)
+                    {
+                    HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(driveUnit,
+                        MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistUri));
+                    CleanupStack::PushL(fullPath);
+                    aMedia.SetTextValueL(KMPXMediaGeneralUri, *fullPath);
+                    MPX_DEBUG2("    URI[%S]", fullPath);
+                    CleanupStack::PopAndDestroy(fullPath);
+                    }
+                if (attributeId & EMPXMediaGeneralDrive)
+                    {
+                    aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveUnit.Name());
+                    }
+                if (attributeId & EMPXMediaGeneralFlags)
+                    {
+                    TUint32 dbFlags(aRecord.ColumnInt64(EPlaylistDbFlag));
+                    TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo;  // 5 bits
+                    aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
+                    }
+                }
+            if (attributeId & EMPXMediaGeneralSynchronized)
+                {
+                aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized,
+                    aRecord.ColumnInt(EPlaylistSync));
+                }
+            if (attributeId & EMPXMediaGeneralCount)
+                {
+                // make sure the PlaylistSongs query is executed after all fields
+                // from the current record have been processed, otherwise the recordset
+                // may point to something else
+                countRequested = ETrue;
+                }
+            if (attributeId & EMPXMediaGeneralDate)
+                {
+                // convert the time from the internal DB string format
+                // to the int64 format used by TTime
+                aMedia.SetTObjectValueL<TInt64>(KMPXMediaGeneralDate,
+                    MPXDbCommonUtil::DesToTTimeL(
+                    MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistTime)).Int64());
+                }
+			if ( attributeId & EMPXMediaGeneralDuration )
+				{		        
+				// make sure the PlaylistSongs query is executed after all fields
+				// from the current record have been processed, otherwise the recordset
+				// may point to something else				
+
+				durationRequested = ETrue;
+				}
+            } // end if contentId == KMPXMediaIdGeneral
+        } // end for
+
+    TInt plSongCount(0);
+    TInt plSongDuration(0);
+    if (countRequested)
+        {
+        if (driveId >= 0)
+            {
+            //valid disk
+            iObserver.HandlePlaylistInfoL(playlistId, plSongCount, plSongDuration);
+            }
+        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
+        		plSongCount );
+        
+        MPX_DEBUG1("    EMPXMediaGeneralCount");
+		MPX_DEBUG2("	Count[%d]", plSongCount);				
+        }
+	if (durationRequested)
+		{
+        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, plSongDuration);
+		
+        MPX_DEBUG1("    EMPXMediaGeneralDuration");
+        MPX_DEBUG2("	Duration[%d]", plSongDuration);				
+		}
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetPlaylistRecordL
+// ----------------------------------------------------------------------------
+//
+RSqlStatement CMPXDbPlaylist::GetPlaylistRecordL(
+    TUint32 aPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetPlaylistRecordL");
+    return iDbManager.ExecuteSelectQueryL(KQueryPlaylistGet, aPlaylistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DoAddPlaylistL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlaylist::DoAddPlaylistL(
+    const CMPXMedia& aMedia,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DoAddPlaylistL");
+
+    const TDesC& playlistName(aMedia.ValueText(KMPXMediaGeneralTitle));
+    const TDesC& playlistUri(aMedia.ValueText(KMPXMediaGeneralUri));
+
+    TUint32 playlistId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist, playlistUri, EFalse));
+    const CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+    if( !mediaArray )
+        {
+        User::Leave( KErrNoMemory );
+        }
+    // add the songs to the PlaylistSongs table
+    TInt count(mediaArray->Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        iPlaylistSongs->AddSongL(playlistId, i, *mediaArray->AtL(i), aDriveId);
+        }
+
+    // determine the value of DbFlag
+    TUint dbflags(0);
+    if (aMedia.IsSupported(KMPXMediaGeneralFlags))
+        {
+        TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
+        if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit )
+            {
+            // Set flag
+            dbflags |= flag;
+            MPX_DEBUG2("    GeneralFlags[%b]", dbflags);
+            }
+        }
+
+    // add playlist record
+    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
+    HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(playlistName);
+    HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(playlistUri);
+    TPtrC uriPtr(uri->Mid(KMCPathStartPos));
+    TPtrC namePtr(name->Left(KMCMaxTextLen));
+
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistInsert, playlistId, &namePtr,
+        &uriPtr, MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), aDriveId),
+        dbflags, time);
+
+    CleanupStack::PopAndDestroy(uri);
+    CleanupStack::PopAndDestroy(name);
+    CleanupStack::PopAndDestroy(time);
+
+    return playlistId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DoUpdatePlaylistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DoUpdatePlaylistL(
+    TUint32 aPlaylistId,
+    const CMPXMedia& aMedia,
+    TInt aDriveId,
+    CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DoUpdatePlaylistL");
+
+    // construct the criteria array
+    const TArray<TMPXAttribute> attributes = aMedia.Attributes();
+
+    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(attributes.Count());
+    CleanupStack::PushL(criteriaArray);
+
+    TInt attrCount(attributes.Count());
+    for (TInt index = 0; index < attrCount; ++index)
+        {
+        TInt contentId(attributes[index].ContentId());
+        TUint attributeId(attributes[index].AttributeId());
+
+        switch(contentId)
+            {
+            case KMPXMediaIdGeneral:
+                {
+                if (attributeId & EMPXMediaGeneralTitle)
+                    {
+                    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTitle,
+                        aMedia.ValueText(KMPXMediaGeneralTitle));
+                    }
+                if (attributeId & EMPXMediaGeneralUri)
+                    {
+                    const TDesC& uri(aMedia.ValueText (KMPXMediaGeneralUri));
+
+                    // determine if we are changing URI of an existing playlist.
+                    // if so, update playlist URI + its Id
+                    TUint32 newId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist, uri, EFalse));
+
+                    if (aPlaylistId != newId)
+                        {
+                        aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, newId);
+                        aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aPlaylistId);
+
+                        // Change event handling for renaming a playlist should be like a song
+                        // The item focus should goto the new name of the playlist
+                        // to-do: this should be abstracted from the plugin. framework should
+                        //        have enough info to deal with this scenario, if not, add more
+                        //        info in the message passing back to framework
+                        aMessage.SetTObjectValueL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory,
+                            EMPXSong);
+
+                        // update the PlaylistSongs to reflect playlist id change
+                        iPlaylistSongs->UpdateSongsL(aPlaylistId, newId);
+
+                        // this takes care of processing the single quotes in the URI
+                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUri,
+                            uri.Mid(KMCPathStartPos));
+                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistVolumeId,
+                            MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(uri)));
+                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId,
+                            newId);
+                        }
+                    }
+                if (attributeId & EMPXMediaGeneralSynchronized)
+                    {
+                    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistSync,
+                        aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
+                    }
+                }
+                break;
+
+            default:
+                break;
+
+            } // end switch
+        } // end for
+
+    // update the time field to the current time
+    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
+    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTime, *time);
+    CleanupStack::PopAndDestroy(time);
+
+    // construct a string from all criteria
+    HBufC* criteria = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCCommaSign);
+
+    // execute the query
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistUpdate, criteria, aPlaylistId);
+
+    CleanupStack::PopAndDestroy(criteria);
+    CleanupStack::PopAndDestroy(criteriaArray);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::UpdatePlaylistsForSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::UpdatePlaylistsForSongL(
+    TUint32 aSongId,
+    CMPXMessageArray* aItemChangedMessages, TBool& aSongInPlaylists)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistsForSongL");
+
+    aSongInPlaylists = EFalse;
+    if (aItemChangedMessages)
+        {
+        // get all playlists for the song
+        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistGetForSong, aSongId));
+        CleanupClosePushL(recordset);
+
+        // ignore the errors
+        while (recordset.Next() == KSqlAtRow)
+            {
+            aSongInPlaylists = ETrue;
+            // add item changed messages for all of them
+            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages,
+                recordset.ColumnInt64(KMPXTableDefaultIndex), EMPXItemModified,
+                EMPXPlaylist, KDBPluginUid);
+            }
+
+        CleanupStack::PopAndDestroy(&recordset);
+        }
+    if (aSongInPlaylists)
+        {
+        // update the time for all playlists that contain this song
+        HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
+        iDbManager.ExecuteQueryL (KDbManagerAllDrives,
+                KQueryPlaylistUpdateTimeForSong, time, aSongId);
+        CleanupStack::PopAndDestroy (time);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::UpdatePlaylistTimeL(
+    TUint32 aPlaylistId,
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistTimeL");
+
+    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
+    iDbManager.ExecuteQueryL(aDrive, KQueryPlaylistUpdateTime, time, aPlaylistId);
+    CleanupStack::PopAndDestroy(time);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::GetDrivePlaylistDuration
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylist::GetDrivePlaylistDuration(TUint32 /*aPlaylistId*/)
+    {
+    return 0;
+    }
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbPlaylist::CreateTableL");
+
+    // create the table
+    User::LeaveIfError(aDatabase.Exec(KPlaylistCreateTable));
+
+    // create the index on the Name field
+    User::LeaveIfError(aDatabase.Exec(KPlaylistNameIndex));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::DropTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylist::DropTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DropTableL");
+    User::LeaveIfError(aDatabase.Exec(KPlaylistDropTable));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylist::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylist::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbPlaylist::CheckTableL");
+    return DoCheckTable(aDatabase, KPlaylistCheckTable);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplaylistsongs.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,846 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for interaction with the PlaylistSongs and
+*                PlaylistSongInfo tables.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <mpxlog.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxmediamusicdefs.h>
+#include "mpxdbcommonutil.h"
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbutil.h"
+#include "mpxdbpluginqueries.h"
+#include "mpxdbmanager.h"
+#include "mpxdbplaylistsongs.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylistSongs* CMPXDbPlaylistSongs::NewL(
+    CMPXDbManager& aDbManager)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::NewL");
+
+    CMPXDbPlaylistSongs* self = CMPXDbPlaylistSongs::NewLC(aDbManager);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylistSongs* CMPXDbPlaylistSongs::NewLC(
+    CMPXDbManager& aDbManager)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::NewLC");
+
+    CMPXDbPlaylistSongs* self = new (ELeave) CMPXDbPlaylistSongs(aDbManager);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylistSongs::~CMPXDbPlaylistSongs()
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::~CMPXDbPlaylistSongs");
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlaylistSongs::CMPXDbPlaylistSongs(
+    CMPXDbManager& aDbManager) :
+    CMPXDbTable(aDbManager)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::CMPXDbPlaylistSongs");
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase constructor.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::ConstructL()
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::ConstructL");
+    BaseConstructL();
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::AddSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::AddSongsL(
+    TUint32 aPlaylistId,
+    const CMPXMediaArray& aMediaArray,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::AddSongsL");
+
+    TInt count(aMediaArray.Count());
+    for (TInt index = 0; index < count; ++index)
+        {
+        AddSongL(aPlaylistId, *(aMediaArray[index]), aDriveId);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::AddSongL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlaylistSongs::AddSongL(
+    TUint32 aPlaylistId,
+    const CMPXMedia& aMedia,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::AddSongL");
+    TInt count(0);
+    if (aDriveId >= 0)
+    	{
+    	count = CountL(aPlaylistId, aDriveId);
+    	}
+    return AddSongL(aPlaylistId, count, aMedia, aDriveId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::AddSongL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlaylistSongs::AddSongL(
+    TUint32 aPlaylistId,
+    TInt aOrdinal,
+    const CMPXMedia& aMedia,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::AddSongL");
+
+    // the UniqueId field is AUTOINCREMENT and its value is going to be generated
+    // automatically by the database - no need to supply it here
+    TUint32 songId((aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
+
+    // insert PlaylistSongs record
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsInsert, aPlaylistId, songId, aOrdinal);
+
+    // if the song is not already in the PlaylistSongInfo table - add it
+    if (!SongInfoExistsL(aDriveId, songId))
+        {
+        // add a new song info record
+        HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(aMedia.ValueText(KMPXMediaGeneralUri));
+        HBufC* title = MPXDbCommonUtil::ProcessSingleQuotesLC(aMedia.ValueText(KMPXMediaGeneralTitle));
+
+        TUint32 dbFlag(0);
+        if (aMedia.IsSupported(KMPXMediaGeneralFlags))
+            {
+            dbFlag = (aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
+            dbFlag = dbFlag & (~KMPXMediaGeneralFlagsDriveInfo); // clear drive info
+            }
+
+        // add the URI without the drive letter
+        TPtrC uriPtr(uri->Mid(KMCPathStartPos));
+        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoInsert, songId, &uriPtr, title,
+            MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(*uri)), dbFlag);
+
+        CleanupStack::PopAndDestroy(title);
+        CleanupStack::PopAndDestroy(uri);
+        }
+
+    return songId;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::UpdateSongL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::UpdateSongL(
+    TUint32 aSongId,
+    const CMPXMedia& aMedia,
+    TBool aResetFlags,
+    TBool& aUpdated)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::UpdateSongL");
+
+    aUpdated = EFalse;
+    TBool visibleChange(EFalse);
+
+    // get the current record
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongInfoGet, aSongId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() == KSqlAtRow)
+        {
+        const TArray<TMPXAttribute> attributes = aMedia.Attributes();
+
+        // stores the current song ID, which may change during execution
+        TUint32 songId(aSongId);
+
+        TInt attrCount(attributes.Count());
+        for (TInt i = 0; i < attrCount; ++i)
+            {
+            TInt contentId(attributes[i].ContentId());
+            TUint attributeId(attributes[i].AttributeId());
+
+            switch(contentId)
+                {
+                case KMPXMediaIdGeneral:
+                    {
+                    if (attributeId & EMPXMediaGeneralTitle)
+                        {
+                        // existing title
+                        TPtrC title(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
+
+                        // compare with the old title
+                        if (title.Compare(MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistSongInfoTitle)) != 0)
+                            {
+                            HBufC* titleProc = MPXDbCommonUtil::ProcessSingleQuotesLC(title);
+
+                            // title has changed - update on all drives
+                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdateTitle,
+                                titleProc, songId);
+
+                            CleanupStack::PopAndDestroy(titleProc);
+
+                            visibleChange = ETrue;
+                            aUpdated = ETrue;
+                            MPX_DEBUG2("    Title[%S]", &title);
+                            }
+                        }
+
+                    if (attributeId & EMPXMediaGeneralUri)
+                        {
+                        const TDesC& uriOrig(aMedia.ValueText(KMPXMediaGeneralUri));
+                        songId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, uriOrig, EFalse);
+
+                        if (aSongId != songId)
+                            {
+                            // URI of the song has been changed. This changes the Id of the song and both the
+                            // PlaylistSongs and PlaylistSongInfo tables should be updated accordingly.
+
+                            HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(uriOrig);
+
+                            // use the URI without the drive letter
+                            TPtrC uriPtr(uri->Mid(KMCPathStartPos));
+
+                            // update the PlaylistSongInfo table on all drives
+                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdate, songId,
+                                &uriPtr, MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(*uri)), aSongId);
+
+                            // update the PlaylistSongs table on all drives
+                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdate, songId,
+                                aSongId);
+
+                            aUpdated = ETrue;
+                            MPX_DEBUG3("    CurrentSongId[0x%x] changed to [0x%x]", aSongId, songId);
+
+                            CleanupStack::PopAndDestroy(uri);
+                            }
+                        }
+
+                    if (attributeId & EMPXMediaGeneralFlags)
+                        {
+                        TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
+                        TUint32 curFlag(recordset.ColumnInt64(EPlaylistSongInfoDbFlag));
+
+                        if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit)
+                            {
+                            if (aResetFlags)
+                                {
+                                visibleChange = ETrue;
+                                curFlag = flag;
+                                }
+                            else
+                                {
+                                // Set flag, visible change is true only if the flag status is changing
+                                visibleChange = visibleChange || ((curFlag^flag) & 0x7FFFFFFF);
+                                curFlag |= flag;
+                                }
+                            }
+                        else
+                            {
+                            // Clear flag, visible change is true only if the flag status is changing
+                            visibleChange = visibleChange || (((curFlag^0xFFFFFFFF)^flag) & 0x7FFFFFFF);
+                            curFlag &= (~flag);
+                            }
+
+                        if (visibleChange)
+                            {
+                            // update the flags on all drives
+                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdateFlags,
+                                curFlag, songId);
+                            aUpdated = ETrue;
+                            }
+
+                        MPX_DEBUG2("    GeneralFlags[%b]", curFlag);
+                        }
+                    } // end case
+                } // end switch
+            } // end for
+        if ( aMedia.IsSupported( KMPXMediaMusicAlbumArtChanged ) )
+            {
+            if ( aMedia.ValueTObjectL<TInt>( KMPXMediaMusicAlbumArtChanged )== 1 )
+                {
+                aUpdated = ETrue;                        
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+    return visibleChange;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::UpdateSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::UpdateSongsL(
+    TUint32 aPlaylistId,
+    TUint32 aNewPlaylistId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::UpdateSongsL");
+
+    // update the PlaylistSongs table on all drives
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdatePlaylistId,
+        aNewPlaylistId, aPlaylistId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::ReorderSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::ReorderSongL(
+    const TMPXItemId& aPlaylistId,
+    const TMPXItemId& aSongId,
+    TUint aOriginalOrdinal,
+    TUint aNewOrdinal)
+    {
+    MPX_DEBUG1("-->CMPXDbPlaylistSongs::ReorderSongL");
+    MPX_DEBUG5("    playlist[0x%x, 0x%x], song[0x%x, 0x%x]",
+               aPlaylistId.iId1, aPlaylistId.iId2, aSongId.iId1, aSongId.iId2);
+
+    //
+    // Move the song up. The rest of the songs in between the old ordinal and new ordinal
+    // need to be moved down, i.e. their ordinals need to be incremented
+    //
+    if (aOriginalOrdinal > aNewOrdinal)
+        {
+        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsMoveSongUp,
+            aPlaylistId.iId2, aNewOrdinal, aOriginalOrdinal);
+        }
+
+    //
+    // Move the song down. The rest of the songs in between the old ordinal and new ordinal
+    // need to be moved up, i.e. their ordinals need to be decremented
+    //
+    else if (aOriginalOrdinal < aNewOrdinal)
+        {
+        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsMoveSongDown,
+            aPlaylistId.iId2, aNewOrdinal, aOriginalOrdinal);
+        }
+
+    //
+    // Change the ordinal of the song itself. If the ordinal is unchanged, no update is
+    // required
+    //
+    if (aOriginalOrdinal != aNewOrdinal)
+        {
+        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdateSongOrdinal,
+            aNewOrdinal, aSongId.iId1);
+        }
+
+    MPX_DEBUG1("<--CMPXDbPlaylistSongs::ReorderSongL");
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteSongL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::DeleteSongL");
+
+    // delete from the PlaylistSongs table on all drives
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsDelete, aSongId);
+
+    // delete from the PlaylistSongInfo table on all drives
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoDelete, aSongId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteSongL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteSongL(
+    TUint32 aPlaylistId,
+    TUint32 aSongId,
+    TInt aOrdinal,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
+
+    // get the number of instances for the song in the playlist
+    TInt count(SongInstanceCountL(aPlaylistId, aSongId));
+
+    if (1 == count)
+        {
+        // just one instance with this ID in the playlist
+        // delete it regardless of the ordinal
+        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteSong, aPlaylistId, aSongId);
+
+        // check how many instances of this song are left for all playlists
+        if (!SongCountL(aSongId))
+            {
+            // delete the PlaylistSongInfo record
+            iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoDelete, aSongId);
+            }
+        }
+    else if (count > 1)
+        {
+        // multiple songs with this id in the playlist
+        // try to delete the one with the specified ordinal
+        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteSongOrdinal, aPlaylistId,
+            aSongId, aOrdinal);
+        }
+    else
+        {
+        // no such song in the playlist
+        User::Leave(KErrCorrupt);
+        }
+    // adjust song ordinals for the songs after the deleted song
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsUpdateSongOrdinalAfterDelete,
+        aPlaylistId, aOrdinal);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteSongsL(
+    TUint32 aPlaylistId,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongsL");
+
+    // delete the records from the PlaylistSongs table
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeletePlaylist, aPlaylistId);
+
+    // delete the unused records from the PlaylistSongInfo table
+    CleanupSongInfoL(aDriveId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteSongsForCategoryL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteSongsForCategoryL(
+    TMPXGeneralCategory aCategory,
+    TUint32 aCategoryId,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongsForCategoryL");
+
+    // get the category field name in the Music table
+    TPtrC category = MPXDbUtil::MusicFieldNameForCategoryL(aCategory);
+
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteForCategory,
+        &category, aCategoryId);
+
+    // delete the unused records from the PlaylistSongInfo table
+    CleanupSongInfoL(aDriveId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteSongsForArtistAndAlbumL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteSongsForArtistAndAlbumL(
+    TUint32 aArtistId,
+    TUint32 aAlbumId,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteSongsForArtistAndAlbumL");
+
+    // delete the songs in the PlaylisSongs table
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteForArtistAlbum,
+        aArtistId, aAlbumId);
+
+    // delete the unused records from the PlaylistSongInfo table
+    CleanupSongInfoL(aDriveId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DeleteAllSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DeleteAllSongsL()
+    {
+    MPX_FUNC("CMPXDbPlaylist::DeleteAllSongsL");
+
+    // delete all records from the PlaylistSongs table, all drives
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsDeleteAll);
+
+    // delete all records from the PlaylistSongInfo table, all drives
+    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoDeleteAll);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::GetSongsL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::GetSongsL(
+    TUint32 aPlaylistId,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_DEBUG2("-->CMPXDbPlaylistSongs::GetSongsL(playlist 0x%x)", aPlaylistId);
+
+    RArray<TMPXAttribute> attributes;
+    CleanupClosePushL( attributes );
+
+    attributes.AppendL(KMPXMediaGeneralType);
+    attributes.AppendL(KMPXMediaGeneralCategory);
+    attributes.AppendL(KMPXMediaGeneralId);
+    
+    // cannot execute a joined query to the music table
+    // because the song records in the music table may be on a different drive
+    ExecuteMediaQueryL(attributes.Array(), aMediaArray, KQueryPlaylistSongsGetSongs, aPlaylistId);
+
+    CleanupStack::PopAndDestroy(&attributes);
+
+    MPX_DEBUG1("<--CMPXDbPlaylistSongs::GetSongsL");
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::GetSongsL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::GetSongsL(
+    TUint32 aPlaylistId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_DEBUG2("-->CMPXDbPlaylistSongs::GetSongsL(playlist 0x%x)", aPlaylistId);
+    TBool valid(EFalse);
+    
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSongsInfo,
+    		aPlaylistId));
+    CleanupClosePushL(recordset);
+
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        CMPXMedia* media = CMPXMedia::NewL();
+        CleanupStack::PushL(media);
+
+        UpdateMediaL(recordset, aAttrs, *media);
+
+        aMediaArray.AppendL(*media);
+        CleanupStack::PopAndDestroy(media);
+        }
+    CleanupStack::PopAndDestroy(&recordset);
+
+    if (err!= KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+    else
+    	{
+    	valid = ETrue;
+    	}
+
+    MPX_DEBUG1("<--CMPXDbPlaylistSongs::GetSongsL");
+    return valid;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::GetSongL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::GetSongL(
+    TUint32 aPlaylistId,
+    TUint32 aSongId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetSongL");
+
+    // get the song
+    TBool valid(EFalse);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSong,
+        aPlaylistId, aSongId));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() == KSqlAtRow)
+        {
+        // convert to media
+        UpdateMediaL(recordset, aAttrs, aMedia);
+        valid = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return valid;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::GetSongL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::GetSongL(
+    const TMPXItemId& aSongId,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia*& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::GetSongL");
+
+    // get the song
+    TBool valid(EFalse);
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSongInfo,
+        aSongId.iId1, aSongId.iId2));
+    CleanupClosePushL(recordset);
+
+    if (recordset.Next() == KSqlAtRow)
+        {
+        // convert to media
+        aMedia = CMPXMedia::NewL();
+        CleanupStack::PushL(aMedia);
+        UpdateMediaL(recordset, aAttrs, *aMedia);
+        CleanupStack::Pop(aMedia);
+        valid = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy(&recordset);
+
+    return valid;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::CountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylistSongs::CountL(
+    TUint32 aPlaylistId,
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylist::CountL");
+    return ExecuteSumExQueryL(KQueryPlaylistSongsCount, aPlaylistId, aDriveId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::UpdateMediaL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::UpdateMediaL(
+    RSqlStatement& aRecord,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlaylist::UpdateMediaL");
+
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+    aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(
+        aRecord.ColumnInt64(EPlaylistSongsUniqueId),
+        aRecord.ColumnInt64(EPlaylistSongsSongId)));
+
+/*
+    aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
+        aRecord.ColumnInt64(EPlaylistSongsSongId));
+*/
+    TInt count(aAttrs.Count());
+    for (TInt index = 0; index < count; ++index)
+        {
+        TInt contentId(aAttrs[index].ContentId());
+        TUint attributeId(aAttrs[index].AttributeId());
+
+        if (contentId == KMPXMediaIdGeneral)
+            {
+            if (attributeId & EMPXMediaGeneralCollectionId)
+                {
+                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralCollectionId,
+                    aRecord.ColumnInt64(EPlaylistSongsPlaylistId));
+                }
+            if (attributeId & EMPXMediaGeneralTitle)
+                {
+                TPtrC title(MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistSongsTitle));
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
+                MPX_DEBUG2("    Title[%S]", &title);
+                }
+            if (attributeId & EMPXMediaGeneralUri)
+                {
+                TUint volId(aRecord.ColumnInt64(EPlaylistSongsVolumeId));
+                HBufC* uri = MPXDbCommonUtil::CreateFullPathL(
+                    MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId),
+                    MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistSongsUri));
+                CleanupStack::PushL(uri);
+
+                aMedia.SetTextValueL(KMPXMediaGeneralUri, *uri);
+
+                MPX_DEBUG2("    URI[%S]", uri);
+                CleanupStack::PopAndDestroy(uri);
+                }
+            if (attributeId & EMPXMediaGeneralFlags)
+                {
+                // assuming song details shouldn't be available for this song
+                TUint32 dbFlags(aRecord.ColumnInt64(EPlaylistSongsDbFlag) |
+                                KMPXMediaGeneralFlagsIsMissingDetails);
+                TUint32 volId(aRecord.ColumnInt64(EPlaylistSongsVolumeId));
+                TDriveUnit driveUnit(EDriveC);
+                if (aMedia.IsSupported(KMPXMediaGeneralUri))
+                    {
+                    // ignore the return value
+                    MPXDbCommonUtil::GetDriveL(aMedia.ValueText(KMPXMediaGeneralUri), driveUnit);
+                    }
+                else
+                    {
+                    driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
+                    }
+
+                // the volume the playlist song is located on may be removed
+                if (~dbFlags & KMPXMediaGeneralFlagsIsInvalid)
+                    {
+                    if (((volId != 0) && (MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId) == KErrNotFound)) ||
+                        ((volId == 0) && (MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit) == 0)))
+                        {
+                        dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
+                        }
+                    }
+
+                TInt driveId(driveUnit & KMPXMediaGeneralFlagsDriveInfo);  // 5 bits
+                aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
+                MPX_DEBUG2("    GeneralFlags[%b]", dbFlags | driveId);
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::SongInstanceCountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylistSongs::SongInstanceCountL(
+    TUint32 aPlaylistId,
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::SongInstanceCountL");
+    return ExecuteSumQueryL(KQueryPlaylistSongsPlaylistSongCount, aPlaylistId, aSongId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::SongCountL
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlaylistSongs::SongCountL(
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::SongCountL");
+    return ExecuteSumQueryL(KQueryPlaylistSongsSongCount, aSongId);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::SongInfoExistsL
+// The song info record must be in the same database as the corresponding
+// PlaylistSongs record(s), otherwise when adding a duplicate of a song on a
+// different drive this method will return true and the song info record won't
+// be created.
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::SongInfoExistsL(
+    TInt aDriveId,
+    TUint32 aSongId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::SongInfoExistsL");
+
+    RSqlStatement recordset(
+        iDbManager.ExecuteSelectQueryL(aDriveId, KQueryPlaylistSongInfoExists, aSongId));
+    TBool exists(recordset.Next() == KSqlAtRow);
+    recordset.Close();
+    return exists;
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::CleanupSongInfoL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::CleanupSongInfoL(
+    TInt aDriveId)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::CleanupSongInfoL");
+    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoCleanup);
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::CreateTableL(
+    RSqlDatabase& aDatabase,
+    TBool /* aCorruptTable */)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::CreateTableL");
+
+    // create the PlaylistSongs table
+    User::LeaveIfError(aDatabase.Exec(KPlaylistSongsCreateTable));
+
+    // create the PlaylistSongInfo table
+    User::LeaveIfError(aDatabase.Exec(KPlaylistSongInfoCreateTable));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::DropTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlaylistSongs::DropTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::DropTableL");
+
+    // drop the PlaylistSongs table
+    User::LeaveIfError(aDatabase.Exec(KPlaylistSongsDropTable));
+
+    // drop the PlaylistSongInfo table
+    User::LeaveIfError(aDatabase.Exec(KPlaylistSongInfoDropTable));
+    }
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlaylistSongs::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlaylistSongs::CheckTableL(
+    RSqlDatabase& aDatabase)
+    {
+    MPX_FUNC("CMPXDbPlaylistSongs::CheckTableL");
+
+    // check the PlaylistSongs table
+    TBool check = DoCheckTable(aDatabase, KPlaylistSongsCheckTable);
+
+    // check the PlaylistSongInfo table
+    return check && DoCheckTable(aDatabase, KPlaylistSongInfoCheckTable);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,4482 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of collection DB Plugin interface
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32cmn.h>
+#include <StringLoader.h>
+#include <bautils.h>
+#include <data_caging_path_literals.hrh>
+
+#include <mpxcmn.h>
+#include <mpxuser.h>
+#include <mpxcollectionpluginobserver.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxmediaaudiodefs.h>
+#include <mpxmediacollectiondetaildefs.h>
+#include <mpxcommandgeneraldefs.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxmessagecontainerdefs.h>
+#include <mpxcollectioncommanddefs.h>
+#include <mpxcollectionmessagedefs.h>
+#include <mpxincrementalopendefs.h>
+#include <mpxcollectionopenlresultdef.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxdrmmediautility.h>
+#include <mpxmediadrmdefs.h>
+#include <mpxlog.h>
+#include <mpxcollectiondbhgres.rsg>
+#include <centralrepository.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif //RD_MULTIPLE_DRIVE
+
+#include "mpxresource.h"
+#include "mpxdbcommondef.h"
+#include "mpxdbcommonutil.h"
+
+#include "mpxdbhandler.h"
+#include "mpxdbutil.h"
+#include "mpxcollectiondbdef.h"
+#include "mpxdbplugin.h"
+
+// CONSTANTS
+const TInt KFirstFetchCount = 400;
+
+const TUid KCRUIDMusicPlayerFeatures = { 0x101FFCD0 };
+const TInt KMusicPlayerFeatures = 1;
+const TInt KDisablePodcasting = 0x08;
+
+const TInt KIncrementalDeleteCount = 400;
+
+const TInt KSQLErrGeneral = -311; // SQL General error. Don't want to include sql header here
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlugin* CMPXDbPlugin::NewL(
+    TAny* /*aInitParams*/)
+    {
+    MPX_FUNC("CMPXDbPlugin::NewL");
+
+    CMPXDbPlugin* self = new (ELeave) CMPXDbPlugin();
+    CleanupStack::PushL (self);
+    self->ConstructL ();
+    CleanupStack::Pop (self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlugin::~CMPXDbPlugin()
+    {
+    MPX_FUNC("CMPXDbPlugin::~CMPXDbPlugin");
+
+    iSelections.Reset();
+    iSelections.Close();
+    iFs.Close();
+    delete iDbHandler;
+    delete iDrmMediaUtility;
+    if (iResource)
+        {
+        iResource->Release();
+        }
+    iMusicLibraryMenuIds.Close();
+    delete iMusicLibraryMenuTitles;
+    delete iMusicLibraryTitles;
+    delete iAllSongsForArtistTitle;
+    delete iMusicMenuTitle;
+
+    if (iActiveTask)
+        {
+        iActiveTask->Cancel();
+        delete iActiveTask;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor.
+// ----------------------------------------------------------------------------
+//
+CMPXDbPlugin::CMPXDbPlugin()
+    {
+    MPX_FUNC("CMPXDbPlugin::CMPXDbPlugin");
+    }
+
+// ----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::ConstructL()
+    {
+    MPX_FUNC("CMPXDbPlugin::ConstructL");
+    iFirstDeleteStep = ETrue;
+    User::LeaveIfError(iFs.Connect());
+    iDrmMediaUtility = CMPXDrmMediaUtility::NewL();
+
+    TParse parse;
+    parse.Set( KMPXCollectionDbResourceFile, &KDC_APP_RESOURCE_DIR, NULL );
+    TFileName resFile(parse.FullName());
+    User::LeaveIfError(MPXUser::CompleteWithDllPath(resFile));
+    BaflUtils::NearestLanguageFile(iFs, resFile);
+    iResource = CMPXResource::NewL(resFile);
+
+    iDbHandler = CMPXDbHandler::NewL(iFs, *iResource);
+    iMusicLibraryMenuTitles = iResource->ReadMenuArrayL(R_MC_MENU_ITEMS_ARRAY, iMusicLibraryMenuIds);
+    iMusicLibraryTitles = iResource->ReadMenuArrayL(R_MC_TITLE_ITEMS_ARRAY, iMusicLibraryMenuIds );
+    iAllSongsForArtistTitle = iResource->ReadHBufCL(R_MC_ALL_SONGS_FOR_ARTIST);
+
+#ifdef __ENABLE_MUSIC_TEXT_ALIGNMENT
+    iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_MY_MUSIC_MENU_NSERIES);
+#else
+    iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MUS_TITLE_MUSIC_MENU);
+#endif // __ENABLE_MUSIC_TEXT_ALIGNMENT
+
+    iActiveTask = CMPXDbActiveTask::NewL(*this);
+
+    CRepository* cenrep(NULL);
+    TRAPD( err, cenrep = CRepository::NewL( KCRUIDMusicPlayerFeatures ) );
+    if( err == KErrNone )
+        {
+        TInt val(0);
+        cenrep->Get( KMusicPlayerFeatures, val );
+        iDisablePodcasting = val&KDisablePodcasting ? ETrue:EFalse;
+        delete cenrep;
+        }
+    else
+        {
+        iDisablePodcasting = EFalse;
+        }
+    iAllSongsValid = ETrue;
+    }
+
+// ----------------------------------------------------------------------------
+// Navigates to the given path
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::OpenL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& /*aAttrs*/,
+    CMPXFilter* aFilter)
+    {
+    MPX_FUNC("CMPXDbPlugin::OpenL");
+    MPX_DEBUG_PATH(aPath);
+    //Create a path object to be returned.
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
+    CleanupStack::PushL(path);
+    RArray<TMPXAttribute> openAttrs;
+    CleanupClosePushL(openAttrs);
+
+    RArray<TInt> supportedIds;
+    CleanupClosePushL(supportedIds);
+
+    // Replace the attributes requested by the client with the ones below.
+    // This will eventually have to be fixed
+    SetAttributesL(aPath, openAttrs, supportedIds);
+
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+    //Add returned path into media
+    entries->SetTObjectValueL<TInt>(KMPXMediaGeneralValue, (TInt)path);
+
+    TInt error(KErrNone);
+    TBool isASong(EFalse);
+    CMPXCollectionPath* newPath(NULL);
+
+    // Make sure we handle open the correct open mode
+    //
+    TMPXOpenMode openmode = aPath.OpenNextMode();
+    switch (openmode)
+        {
+        case EMPXOpenGroupOrPlaylist:
+            {
+            // Open By Path
+            MPX_TRAP(error, isASong = DoOpenL(aPath, openAttrs.Array(), *entries, aFilter));
+            break;
+            }
+
+        case EMPXOpenPlaylistOnly:
+            {
+            if (aPath.Count() > 0)
+                {
+                // Try to open
+                MPX_TRAP(error, newPath = DoOpenPlaylistL(aPath, openAttrs.Array()));
+                CleanupStack::PushL(newPath);
+                isASong = ETrue;
+                }
+            else // no items
+                {
+                MPX_TRAP(error, isASong = DoOpenL(aPath, openAttrs.Array(), *entries, aFilter));
+                }
+
+            break;
+            }
+
+        default:
+            // do nothing
+            break;
+        }
+
+    // generate the callback
+    if (isASong )
+        {
+        if (openmode == EMPXOpenGroupOrPlaylist)
+            {
+            iObs->HandleOpen(const_cast<CMPXCollectionPath*>(&aPath), error);
+            }
+        else  // openmode == EMPXOpenPlaylistOnly
+            {
+            iObs->HandleOpen(newPath, error);
+            }
+        }
+    else
+        {
+        entries->SetCObjectValueL(KMPXMediaGeneralContainerPath,
+            const_cast<CMPXCollectionPath*>(&aPath));
+        entries->Delete(KMPXMediaGeneralValue);
+        iObs->HandleOpen(entries, path, error);
+        }
+
+    if (newPath)
+        {
+        CleanupStack::PopAndDestroy(newPath);
+        }
+
+    CleanupStack::PopAndDestroy(entries);
+    CleanupStack::PopAndDestroy(&openAttrs);
+    CleanupStack::PopAndDestroy(path);
+    }
+
+// ----------------------------------------------------------------------------
+// Get the extended properties of the current file (async)
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::MediaL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    const TArray<TCapability>& /*aCaps*/,
+    CMPXAttributeSpecs* /*aSpecs*/)
+    {
+    MPX_FUNC("CMPXDbPlugin::MediaL");
+    MPX_DEBUG_PATH(aPath);
+
+    RArray<TInt> supportedIds;
+    CleanupClosePushL(supportedIds);
+    if (aPath.Selection().Count())
+        {
+        // it's a container if there are multiple selection, else it's not a container
+        supportedIds.AppendL(KMPXMediaIdContainer);
+        }
+    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
+
+    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
+    CleanupStack::PopAndDestroy(&supportedIds);
+    CleanupStack::PushL(entries);
+
+    DoMediaL(aPath, aAttrs, *entries);
+
+    // Also fetch collection details and set the path if required
+    DoHandleOtherMediaAttributesL(aAttrs, aPath, *entries);
+
+    iObs->HandleMedia(entries, KErrNone);
+    CleanupStack::PopAndDestroy(entries);
+    }
+
+// ----------------------------------------------------------------------------
+// Cancel outstanding request
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::CancelRequest()
+    {
+    MPX_FUNC("CMPXDbPlugin::CancelRequest");
+    iActiveTask->Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// Executes the given command on the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::CommandL(
+    TMPXCollectionCommand aCmd,
+    TInt aArg /* = 0 */)
+    {
+    MPX_FUNC("CMPXDbPlugin::CommandL");
+    MPX_DEBUG2("CMPXDbPlugin::CommandL %d", aCmd);
+    iAllSongsValid = ETrue;
+    switch (aCmd)
+        {
+        case EMcCmdRemoveAll:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdRemoveAll");
+            // Remove EVERYthing from the collection
+            iDbHandler->RemoveEntireCollectionL();
+            break;
+            }
+        case EMcCmdClose:
+        case EMcCloseCollection:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCloseCollection");
+            // Close the specified database
+            TRAP_IGNORE(iDbHandler->PreCloseCollectionL());
+ #ifdef RD_MULTIPLE_DRIVE
+            MPX_DEBUG1("Multiple drives closing databases");
+            if ( aArg <0)
+                {
+                DriveInfo::TDriveArray driveArray;
+                User::LeaveIfError ( DriveInfo::GetUserVisibleDrives( iFs, driveArray));
+                TInt count( driveArray.Count ());
+                for (TInt i=0; i<count; ++i)
+                    {
+                    MPX_DEBUG2("At drive %i", driveArray[i]);
+                    if (( driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
+                        {
+                        MPX_DEBUG2("Closing database %i", driveArray[i]);
+                        TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) );
+                        }
+                    }
+                }
+            else
+                {
+                iDbHandler->CloseDatabaseL(aArg);
+                }
+ #else
+            iDbHandler->CloseDatabaseL(aArg);
+ #endif // RD_MULTIPLE_DRIVE
+            iDbHandler->CollectionClosed();
+            break;
+            }
+        case EMcReOpenCollection:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcReOpenCollection");
+            // Open the specified database
+#ifdef RD_MULTIPLE_DRIVE
+            MPX_DEBUG1("Multiple drives opening databases");
+            DriveInfo::TDriveArray driveArray;
+            User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) );
+            TInt count( driveArray.Count() );
+            for( TInt i=0; i<count; ++i )
+                {
+                MPX_DEBUG2("At drive %i", driveArray[i]);
+                if( (driveArray[i] != EDriveC)  && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
+                    {
+                    TUint driveStatus(0);
+                    User::LeaveIfError( DriveInfo::GetDriveStatus(
+                        iFs, driveArray[i], driveStatus ) );
+                    if( driveStatus & DriveInfo::EDrivePresent )
+                        {
+                        MPX_DEBUG2("Opening database %i", driveArray[i]);
+                        TRAP_IGNORE( iDbHandler->OpenDatabaseL( driveArray[i] ) );
+                        }
+                    }
+                }
+#else
+            iDbHandler->OpenDatabaseL(aArg);
+#endif // RD_MULTIPLE_DRIVE
+            TRAP_IGNORE(iDbHandler->CollectionOpenedL());
+            break;
+            }
+        case EMcRefreshStarted:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcRefreshStarted");
+            iDbHandler->CheckDiskSpaceOnDrivesL();
+            // ask the handler to start a transaction
+            iDbHandler->RefreshStartL();
+            iRefreshing=ETrue;
+            break;
+            }
+        case EMcRefreshEnded:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcRefreshEnded");
+            iDbHandler->CheckDiskSpaceOnDrivesL();
+            // ask the handler to finalize the transaction
+            iDbHandler->RefreshEndL();
+            iRefreshing=EFalse;
+            break;
+            }
+         case EMcCmdReCreateDB:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdReCreateDB");
+            // Recreate all databases
+            iDbHandler->ReCreateDatabasesL();
+            break;
+            }
+         case EMcCmdDbCorrupted:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdDbCorrupted");
+            iDbHandler->SetDBCorruptedL(ETrue);
+            break;
+            }
+        case EMcCmdRefresh:
+        case EMcCmdCollectionInit:
+        case EMcCmdCollectionResyn:
+            {
+            // deprecated
+            break;
+            }
+        case EMcCmdMtpStart:
+            iDbHandler->CheckDiskSpaceOnDrivesL();
+            iMtpInUse = ETrue;
+            iDbHandler->MtpStartL();            
+            break;
+        case EMcCmdMtpEnd:
+            iDbHandler->CheckDiskSpaceOnDrivesL();
+            iMtpInUse = EFalse;
+            iDbHandler->MtpEndL();            
+            break;
+         default:
+            {
+            User::Leave(KErrNotSupported);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Executes the given command on the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::CommandL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::CommandL");
+
+    if (!aCmd.IsSupported(KMPXCommandGeneralId))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TMPXCommandId commandId = aCmd.ValueTObjectL<TMPXCommandId>(KMPXCommandGeneralId);
+
+    TBool syncOp(EFalse);
+    if (aCmd.IsSupported(KMPXCommandGeneralDoSync))
+        {
+        syncOp = aCmd.ValueTObjectL<TBool>(KMPXCommandGeneralDoSync);
+        }
+
+    // Handle this operation synchronously or asynchronously
+    //
+    if (!syncOp)
+        {
+        iActiveTask->StartL(commandId, aCmd);
+        }
+    else  // Sync operation
+        {
+        switch (commandId)
+            {
+            case KMPXCommandIdCollectionRetrieveUriForDeletion:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRetrieveUriForDeletion");
+                DoRetrieveUriForDeletionL(aCmd);
+                break;
+                }
+            case KMPXCommandIdCollectionRemove:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRemove");
+                if ( !iDbHandler->InTransaction() )
+                    {
+                    iDbHandler->BeginTransactionL();
+                    }
+
+                if (iFirstDeleteStep )
+                    {
+                    iFirstDeleteStep = EFalse;
+                    }
+                DoRemovePathL(aCmd);
+                break;
+                }
+            case KMPXCommandIdCollectionRemoveMedia:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRemoveMedia");
+                DoRemoveMediaL(aCmd);
+                break;
+                }
+            case KMPXCommandIdCollectionCleanupDeletedMedias:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionCleanupDeletedMedias");
+                CleanupDeletedRecordsL(aCmd);
+                break;
+                }
+            case KMPXCommandIdCollectionAdd:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectioAdd");
+                CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColAddMedia);
+                User::LeaveIfNull( media );
+                TUint32 id(DoAddL(*media));
+                aCmd.SetTObjectValueL<TMPXItemId>(KMPXCommandColAddRtnId, id);
+                break;
+                }
+            case KMPXCommandIdCollectionSet:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionSet");
+                CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColSetMedia);
+                User::LeaveIfNull( media );
+                DoSetL(*media);
+                break;
+                }
+            case KMPXCommandIdCollectionCompleteDelete:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionCompleteDelete");
+                DoHandleDeleteCompleteL(aCmd);
+                break;
+                }
+            case KMPXCommandIdReorderPlaylist:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdReorderPlaylist");
+                DoReorderPlaylistL(aCmd);
+                break;
+                }
+            case KMPXCommandIdUpdateRefreshTime:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime");
+                TTime curTime;
+                curTime.HomeTime();
+                iDbHandler->SetLastRefreshedTimeL(curTime);
+                break;
+                }
+            case KMPXCommandCollectionGetCount:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandCollectionGetCount");
+                DoGetCollectionCountL(aCmd);
+                break;
+                }
+            case KMPXCommandCollectionGetURIs:
+                {
+                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandCollectionGetURIs");
+                DoGetCollectionUriL(aCmd);
+                break;
+                }
+            default:
+                {
+                User::Leave(KErrNotSupported);
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Adds an item (song or playlist) to the collection
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::AddL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlugin::AddL");
+    DoAddL(aMedia);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove an item from the collection database using the given path
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::RemoveL(
+    const CMPXCollectionPath& aPath)
+    {
+    MPX_FUNC("CMPXDbPlugin::RemoveL(by path)");
+    MPX_DEBUG_PATH(aPath);
+
+    CMPXMessageArray* msgAry = CMPXMessageArray::NewL();
+    CleanupStack::PushL(msgAry);
+
+    // Return file path for deleted item(s)
+    CDesCArray* fp = DoRemoveL(aPath, *msgAry);
+
+    iObs->HandleRemove(*fp, KErrNone);
+    delete fp;
+
+    // Send Change Messages
+    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+    DoHandleChangeL(msgAry);
+    CleanupStack::PopAndDestroy(msgAry);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove an item from the collection database using the given media properties
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::RemoveL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlugin::RemoveL(by media)");
+    DoRemoveL(aMedia, EFalse);
+    }
+
+// ----------------------------------------------------------------------------
+// Sets/updates the media for an item in the collection
+// DEPRECATED for week 18
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::SetL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlugin::SetL");
+    DoSetL(aMedia);
+    }
+
+// ----------------------------------------------------------------------------
+// Find the items matching the media specifications
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::FindAllL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbPlugin::FindAllL");
+
+    CMPXMedia* entries = FindAllSyncL(aCriteria, aAttrs);
+
+    // notify client. if FindAllL leaves, framework will notify client of the error
+    iObs->HandleFindAll(entries, KErrNone);
+    delete entries;
+    }
+
+// ----------------------------------------------------------------------------
+// Find the items matching the media specifications
+// ----------------------------------------------------------------------------
+//
+CMPXMedia* CMPXDbPlugin::FindAllSyncL(
+    const CMPXMedia& aCriteria,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbPlugin::FindAllSyncL");
+
+    CMPXMedia* entries = iDbHandler->FindAllLC(aCriteria, aAttrs);
+
+    if (entries)
+        {
+        CMPXMediaArray* ary = entries->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        User::LeaveIfNull( ary );
+        DoSetDrmForArrayL( *ary, aAttrs );
+        }
+
+    CleanupStack::Pop(entries);
+    return entries;
+    }
+
+// ----------------------------------------------------------------------------
+// Get the list of supported capabilities
+// ----------------------------------------------------------------------------
+//
+TCollectionCapability CMPXDbPlugin::GetCapabilities()
+    {
+    // This one supports simple search
+    return EMcSearch;
+    }
+
+// ----------------------------------------------------------------------------
+// Get the list of supported capabilities
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::HandleStepL()
+    {
+    MPX_FUNC("CMPXDbPlugin::HandleStepL");
+
+    TBool done(ETrue);
+
+    switch (iActiveTask->GetTask())
+        {
+        case KMPXCommandIdCollectionSet:
+            {
+            done = DoSetAsyncL();
+            break;
+            }
+        case KMPXCommandIdCollectionAdd:
+            {
+            done = DoAddAsyncL();
+            break;
+            }
+        case KMPXCommandIdCollectionRemove:
+            {
+            DoRemovePathL(iActiveTask->GetCommand());
+            done = ETrue;
+            break;
+            }
+        case KMPXCommandIdCollectionRemoveMedia:
+            {
+            DoRemoveMediaL(iActiveTask->GetCommand());
+            done = ETrue;
+            break;
+            }
+        case KMPXCommandIdCollectionRetrieveUriForDeletion:
+            {
+            DoRetrieveUriForDeletionL(iActiveTask->GetCommand());
+            done = ETrue;
+            break;
+            }
+        case KMPXCommandIdCollectionCleanupDeletedMedias:
+            {
+            CleanupDeletedRecordsL(iActiveTask->GetCommand());
+            done = ETrue;
+            break;
+            }
+        case KMPXCommandIdCollectionCompleteDelete:
+            {
+            DoHandleDeleteCompleteL( iActiveTask->GetCommand() );
+            break;
+            }
+        case KMPXCommandIdUpdateRefreshTime:
+            {
+            MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime");
+            TTime curTime;
+            curTime.HomeTime();
+            iDbHandler->SetLastRefreshedTimeL(curTime);
+            break;
+            }
+        case KMPXCommandIdIncrementalOpenL:
+            {
+            DoIncrementalOpenL( iActiveTask->GetCommand() );
+            done = ETrue;
+            break;
+            }
+        default:
+            {
+            // Should never happen!
+            ASSERT(0);
+            break;
+            }
+        }
+    return done;
+    }
+
+// ----------------------------------------------------------------------------
+// Handler for async operations completed
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::HandleOperationCompleted(
+    TInt aErr)
+    {
+    MPX_FUNC("CMPXDbPlugin::HandleOperationCompleted");
+    TRAP_IGNORE(DoHandleOperationCompletedL(aErr));
+    }
+
+// ----------------------------------------------------------------------------
+// Process the OpenL command
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXFilter* aFilter )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenL");
+
+    TInt err( KErrNone );
+    CMPXMediaArray* array = CMPXMediaArray::NewL();
+    CleanupStack::PushL(array);
+
+//    TInt count(0);
+    TInt levels(aPath.Levels());
+    TBool isASong(EFalse);
+
+
+	if ( 1 == levels )
+	    {
+
+	    // Redirecting all open requests at level 1 to open albums 
+	    // due to UI changes that removed the library menu collection level.
+        TInt acount = array->Count();
+        MPX_DEBUG2(" array count11 [%d]", acount);
+        
+ 		CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
+		CleanupStack::PushL( path );
+		
+		path->AppendL(3); // Albums
+		TInt whatLevel = path->Levels();
+
+		MPX_DEBUG_PATH(*path);
+		
+		aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, path->Id(whatLevel - 1) );
+		
+      // Create a media which hold the pointer to the returned path
+        if (aEntries.IsSupported(KMPXMediaGeneralValue))
+            {
+            MPX_DEBUG1(" pointer to the returned path ");
+            CMPXMedia* pMedia = CMPXMedia::NewL();
+            CleanupStack::PushL(pMedia);
+            pMedia->SetTObjectValueL<TInt>(KMPXMediaGeneralValue,
+                                          aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue));
+            array->AppendL(*pMedia);
+            CleanupStack::PopAndDestroy(pMedia);
+            }
+		
+	
+        RArray<TMPXAttribute> openAttrs;
+        CleanupClosePushL(openAttrs);
+
+        RArray<TInt> supportedIds;
+        CleanupClosePushL(supportedIds);
+
+        SetAttributesL(*path, openAttrs, supportedIds);
+        openAttrs.AppendL(KMPXMediaArrayContents);
+        
+        CleanupStack::PopAndDestroy(&supportedIds);
+		
+		if( iAllSongsValid )
+		    {
+		    isASong = DoOpenBrowseAlbumL( *path, openAttrs.Array(), aEntries, array );
+		    }
+		CleanupStack::PopAndDestroy(&openAttrs);
+		CleanupStack::PopAndDestroy( path );
+
+        //Remove the first media
+        if ( array->Count() &&
+            (*array)[0]->IsSupported(KMPXMediaGeneralValue))
+            {
+            array->Remove(0);
+            }
+	    }
+    else if (levels >= 2)
+        {
+	    aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
+        // Create a media which hold the pointer to the returned path
+        if (aEntries.IsSupported(KMPXMediaGeneralValue))
+            {
+            CMPXMedia* pMedia = CMPXMedia::NewL();
+            CleanupStack::PushL(pMedia);
+            pMedia->SetTObjectValueL<TInt>(KMPXMediaGeneralValue,
+                                          aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue));
+            array->AppendL(*pMedia);
+            CleanupStack::PopAndDestroy(pMedia);
+            MPX_ASSERT(array->Count()==1);
+            }
+
+        // check the browse type
+        switch (aPath.Id(1).iId2)
+            {
+            case EBrowseAll:
+                {
+                TBool doIncremental(ETrue);
+                if( aFilter && aFilter->IsSupported( KMPXCollectionOpenLSupportsIncremental ) )
+                    {
+                    doIncremental =
+                         aFilter->ValueTObjectL<TBool>(KMPXCollectionOpenLSupportsIncremental);
+                    }
+
+                if( doIncremental )
+                    {
+                    TRAP( err, isASong = DoOpenIncrementalL( aPath, aAttrs, aEntries, array ) );
+                    }
+                else
+                    {
+                    TRAP( err, isASong = DoOpenBrowseAllL(aPath, aAttrs, aEntries, array) );
+                    }
+                break;
+                }
+
+            case EBrowseArtist:
+                {
+                if( iAllSongsValid )
+                    {
+                    isASong = DoOpenBrowseArtistL( aPath, aAttrs, aEntries, array );
+                    }
+                break;
+                }
+
+            case EBrowseAlbum:
+                {
+                if( iAllSongsValid )
+                    {
+                    isASong = DoOpenBrowseAlbumL( aPath, aAttrs, aEntries, array );
+                    }
+                break;
+                }
+
+            case EBrowsePlaylist:
+                {
+                if( iAllSongsValid )
+                    {
+                    isASong = DoOpenBrowsePlaylistL(aPath, aAttrs, aEntries, array);
+                    }
+
+                break;
+                }
+
+            case EBrowseGenre:
+                {
+                if( iAllSongsValid )
+                    {
+                    isASong = DoOpenBrowseGenreL( aPath, aAttrs, aEntries, array );
+                    }
+                break;
+                }
+
+            case EBrowseComposer:
+                {
+                if( iAllSongsValid )
+                    {
+                    isASong = DoOpenBrowseComposerL( aPath, aAttrs, aEntries, array );
+                    }
+                break;
+                }
+
+            default:
+                {
+                User::Leave(KErrArgument);
+                }
+            }
+        //Remove the first media
+        if ( array->Count() &&
+            (*array)[0]->IsSupported(KMPXMediaGeneralValue))
+            {
+            array->Remove(0);
+            }
+        }
+    else
+        {
+        User::Leave(KErrNotSupported);
+        }
+    aEntries.SetCObjectValueL(KMPXMediaArrayContents, array);
+    aEntries.SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+
+    CleanupStack::PopAndDestroy(array);
+
+    if( err == KSQLErrGeneral )
+        {
+        iAllSongsValid = EFalse;
+        User::Leave( KErrDiskFull );
+        }
+    else if( err != KErrNone )
+        {
+        User::Leave( err );
+        }
+    return isASong;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMPXDbPlugin::DoOpenIncrementalL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenIncrementalL( const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
+                                       CMPXMedia& aEntries, CMPXMediaArray* aArray)
+    {
+    TBool isASong(EFalse);
+
+    TInt levels(aPath.Levels());
+
+    if( levels == 2 )
+        {
+        // Remove the pPath dummy from the array
+        TInt pPath = aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+        aArray->Remove(0);
+        CMPXCollectionPath* p = (CMPXCollectionPath*) pPath;
+
+        RArray<TMPXItemId> ids;
+        CleanupClosePushL( ids );
+
+        iDbHandler->GetAllSongsLimitedL( aAttrs, *aArray, KFirstFetchCount );
+
+        TInt c( aArray->Count() );
+        for( TInt i=0; i<c; ++i )
+            {
+            TMPXItemId id = aArray->AtL(i)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
+            ids.Append( id );
+            }
+
+        // Rest are all blank items
+        CMPXMedia* entry = CMPXMedia::NewL();
+        CleanupStack::PushL(entry);
+        entry->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
+        entry->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
+        entry->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, KMPXInvalidItemId );
+
+        TInt count = iDbHandler->NumberOfItemsL(EMPXSong);
+        count-=c;
+        for( TInt i=0; i<count; ++i )
+            {
+            aArray->AppendL( *entry );
+            ids.Append( KMPXInvalidItemId );
+            }
+        CleanupStack::PopAndDestroy( entry );
+
+        // Set the "Supportes incremental Command" flag
+        //
+        aEntries.SetTObjectValueL( KMPXCollectionOpenLSupportsIncremental, ETrue );
+
+        TMPXOpenDataBlock block;
+        block.iOffset=KErrNotFound;
+        block.iSize=count;
+        aEntries.SetTObjectValueL<TMPXOpenDataBlock>( KMPXCollectionOpenLResultRange, block );
+
+        SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong,
+                iMusicLibraryTitles->MdcaPoint(EBrowseAll));
+
+        p->AppendL(ids.Array());
+        CleanupStack::PopAndDestroy( &ids );
+        }
+    else if( levels == 3 )
+        {
+        iDbHandler->GetSongL(aPath.Id(levels - 1).iId2, aAttrs, *aArray);
+        isASong = ETrue;
+        }
+
+
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowseAll
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowseAllL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseAllL");
+
+    TInt levels(aPath.Levels());
+    switch (levels)
+       {
+       // All songs
+       case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAllL_All);
+
+            iDbHandler->GetAllSongsL(aArray, aAttrs);
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong,
+                iMusicLibraryTitles->MdcaPoint(EBrowseAll));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAllL_All);
+            break;
+            }
+
+         // A Song in all songs
+         case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAllL_Song);
+
+            iDbHandler->GetSongL(aPath.Id(levels - 1).iId2, aAttrs, *aArray);
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAllL_Song);
+            break;
+            }
+
+         default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseAllL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        } // end switch(levels)
+
+    return (levels == 3);
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowseArtist
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowseArtistL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseArtistL");
+
+    TBool isASong(EFalse);
+    TInt levels(aPath.Levels());
+    TInt idIndex(levels - 1);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (levels)
+        {
+        // All artists
+        case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_All);
+
+            iDbHandler->GetAllArtistsL(aAttrs, aArray);
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXArtist,
+                iMusicLibraryTitles->MdcaPoint(EBrowseArtist));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_All);
+            break;
+            }
+
+        // All albums of an artist
+        case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllAlbums);
+            // get the albums
+            TInt id(aPath.Id(idIndex).iId2);
+            MPX_ASSERT(aArray->Count());
+            MPX_ASSERT((*aArray)[0]->IsSupported(KMPXMediaGeneralValue));
+            TInt pPath = (*aArray)[0]->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+            MPX_ASSERT(pPath);
+            iDbHandler->GetAlbumsMatchingArtistL(id, aAttrs, *aArray);
+            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXArtist, id);
+
+            TInt count = aArray->Count();
+            if ( count > 2 )
+                {
+                // Only show "all" item if there is more than 1 album
+                // count for "all" item
+                TInt total = 0;
+                for ( TInt i = 1; i < count; i++ )
+                {
+                TInt temp = (*aArray)[i]->ValueTObjectL<TInt>(KMPXMediaGeneralCount);
+                total += temp;
+                }
+            // Add "all" item under an artist
+            MPXDbCommonUtil::PrependMediaL(*aArray, *iAllSongsForArtistTitle, EMPXItem, EMPXAlbum,
+                aPath.Id(idIndex), 0, 0, 1);
+    
+                (*aArray)[1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, total);
+    
+            TMPXItemId allId = ((*aArray)[1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+            if (aArray->Count() > 2)
+                { // path media, all id  and at least one media
+                ((CMPXCollectionPath*)pPath)->InsertL(allId, 0);
+                }
+            else
+                { // only has all item
+                ((CMPXCollectionPath*)pPath)->AppendL(allId);
+                    }
+                }
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllAlbums);
+            break;
+            }
+
+        // All songs of an album for an artist or all songs for an artist
+        case 4:
+            {
+            // all songs for an artist
+            if (aPath.Id(3) == aPath.Id(2))
+                {
+                MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongs);
+
+                TInt id(aPath.Id(idIndex - 1).iId2);
+                iDbHandler->GetSongsMatchingArtistL(id, aAttrs, aArray);
+                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXSong, id);
+
+                MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongs);
+                }
+            // all songs of an album for an artist
+            else
+                {
+                MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongsForAlbum);
+                TUint32 artistId(aPath.Id(idIndex - 1).iId2);
+
+                if (selections.Count())
+                    {
+                    // Multiple albums
+                    const TInt count(aPath.Selection().Count());
+                    for (TInt i = 0; i < count; ++i)
+                        {
+                        iDbHandler->GetSongsMatchingArtistAndAlbumL(artistId, selections[i].iId2,
+                            aAttrs, aArray);
+                        }
+                    }
+                else
+                    {
+                    // One album
+                    iDbHandler->GetSongsMatchingArtistAndAlbumL(artistId, aPath.Id(idIndex).iId2,
+                        aAttrs, aArray);
+                    }
+
+                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum, aPath.Id(idIndex).iId2);
+                MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongsForAlbum);
+                }
+
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseArtistL: retrieved %d items", aArray->Count());
+
+            break;
+            }
+
+        // A Song in an album
+        case 5:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_Song);
+
+            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
+            isASong = ETrue;
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_Song);
+            break;
+            }
+
+        default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseArtistL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        } // end switch(level)
+
+    CleanupStack::PopAndDestroy(&selections);
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowseAlbum
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowseAlbumL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseAlbumL");
+
+    TBool isASong(EFalse);
+    TInt levels(aPath.Levels());
+    TInt idIndex(levels - 1);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (levels)
+        {
+        // All Albums
+        case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
+
+            TRAPD(err, iDbHandler->GetAllAlbumsL(aAttrs, aArray) );
+            // in error case, return empty list and append empty id to path 
+            // in order to increase one level 
+            if ( err != KErrNone )
+                {
+                TInt pPath(0);
+                if (aArray->Count())
+                    {
+                    CMPXMedia* pMedia = (*aArray)[0];
+                    if (pMedia->IsSupported(KMPXMediaGeneralValue))
+                        {
+                        pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
+                        MPX_ASSERT(pPath);
+                        }                   
+                    }
+
+                RArray<TMPXItemId> ids;
+                CleanupClosePushL(ids);
+            
+                // Append ids to the returned path
+                if (pPath)
+                    {
+                    ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
+                    }
+                CleanupStack::PopAndDestroy(&ids);
+                }
+            
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum,
+                iMusicLibraryTitles->MdcaPoint(EBrowseAlbum));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
+            break;
+            }
+
+        // All songs in one or multiple albums
+        case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_AllSongs);
+            if (selections.Count())
+                {
+                // Multiple albums
+                const TInt count(aPath.Selection().Count());
+                for (TInt i = 0; i < count; ++i)
+                    {
+                    iDbHandler->GetSongsMatchingAlbumL(selections[i].iId2, aAttrs, aArray);
+                    }
+                }
+            else
+                {
+                // One album
+                iDbHandler->GetSongsMatchingAlbumL(aPath.Id(idIndex).iId2, aAttrs, aArray);
+                }
+
+				// added for ganes
+                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum, iMusicLibraryTitles->MdcaPoint(EBrowseAlbumSong));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_AllSongs);
+            break;
+            }
+
+        // A song in an album
+        case 4:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_Song);
+
+            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
+            isASong = ETrue;
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_Song);
+            break;
+            }
+
+        default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseAlbumL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&selections);
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowsePlaylist
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowsePlaylistL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowsePlaylistL");
+
+    TBool isASong(EFalse);
+    TInt levels(aPath.Levels());
+    TInt idIndex(levels - 1);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (levels)
+         {
+         case 2:
+            {
+            // All playlists
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_All);
+
+            iDbHandler->GetAllPlaylistsL(aArray, aAttrs);
+            iDbHandler->GetAllSystemPlaylistNamesL(aArray);
+
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPlaylist,
+                iMusicLibraryTitles->MdcaPoint(EBrowsePlaylist));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_All);
+            break;
+            }
+
+         // All songs in a playlist
+         case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_AllSongs);
+
+            if (selections.Count())
+                {
+                const TInt count(aPath.Selection().Count());
+                for (TInt i = 0; i < count; ++i)
+                    {
+                    iDbHandler->GetSongsMatchingPlaylistL(selections[i].iId2, aAttrs, aArray);
+                    }
+                }
+            else
+                {
+                iDbHandler->GetSongsMatchingPlaylistL(aPath.Id (idIndex).iId2, aAttrs, aArray);
+                }
+
+            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist, aPath.Id(idIndex).iId2);
+
+            // populate EMPXMediaGeneralNonPermissibleActions
+            if (iDbHandler->IsAutoPlaylistL(aPath.Id(idIndex).iId2))
+                {
+                // set non-permissible actions to not writable and cacheable
+                aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                    KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache));
+                }
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_AllSongs);
+            break;
+            }
+
+         // Specific song in a playlist
+         case 4:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_Song);
+
+            iDbHandler->GetPlaylistSongL(aPath.Id(idIndex).iId2, aPath.Id(idIndex - 1).iId2,
+                aAttrs, *aArray);
+            isASong = ETrue;
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_Song);
+            break;
+            }
+
+         default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowsePlaylistL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+       }
+
+    CleanupStack::PopAndDestroy(&selections);
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowseGenre
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowseGenreL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseGenreL");
+
+    TBool isASong(EFalse);
+    TInt levels(aPath.Levels());
+    TInt idIndex(levels - 1);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (levels)
+        {
+        // All genres
+         case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_All);
+
+            iDbHandler->GetAllGenresL(aAttrs, aArray);
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXGenre,
+                iMusicLibraryTitles->MdcaPoint(EBrowseGenre));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_All);
+            break;
+            }
+
+        // All songs of a genre
+        case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_AllSongs);
+
+            if (selections.Count())
+                {
+                const TInt count(aPath.Selection().Count());
+                for (TInt i = 0; i < count; ++i)
+                    {
+                    iDbHandler->GetSongsMatchingGenreL(selections[i].iId2, aAttrs, aArray);
+                    }
+                }
+            else
+                {
+                iDbHandler->GetSongsMatchingGenreL(aPath.Id(idIndex).iId2, aAttrs, aArray);
+                }
+            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXGenre, aPath.Id(idIndex).iId2);
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_AllSongs);
+            break;
+            }
+
+        // Specific song in a genre
+        case 4:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_Song);
+
+            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
+            isASong = ETrue;
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_Song);
+            break;
+            }
+
+        default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseGenreL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&selections);
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Handles OpenL called for EBrowseComposer
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoOpenBrowseComposerL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray* aArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseComposerL");
+
+    TBool isASong(EFalse);
+    TInt levels(aPath.Levels());
+    TInt idIndex(levels - 1);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (levels)
+        {
+        // All composers
+        case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_All);
+
+            iDbHandler->GetAllComposersL(aAttrs, aArray);
+            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXComposer,
+                iMusicLibraryTitles->MdcaPoint(EBrowseComposer));
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_All);
+            break;
+            }
+
+        // All songs of a composer
+        case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_AllSongs);
+            if (selections.Count())
+                {
+                const TInt count(aPath.Selection().Count());
+                for (TInt i = 0; i < count; ++i)
+                    {
+                    iDbHandler->GetSongsMatchingComposerL(selections[i].iId2, aAttrs, aArray);
+                    }
+                }
+            else
+                {
+                iDbHandler->GetSongsMatchingComposerL(aPath.Id(idIndex).iId2, aAttrs, aArray);
+                }
+            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXComposer, aPath.Id(idIndex).iId2);
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_AllSongs);
+            break;
+            }
+
+        // Specific song of a composer
+        case 4:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_Song);
+
+            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
+            isASong = ETrue;
+
+            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_Song);
+            break;
+            }
+
+        default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseComposerL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&selections);
+    return isASong;
+    }
+
+// ----------------------------------------------------------------------------
+// Process the OpenL method with open mode EMPXOpenPlaylistOnly
+// ----------------------------------------------------------------------------
+//
+CMPXCollectionPath* CMPXDbPlugin::DoOpenPlaylistL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoOpenPlaylistL");
+
+    RArray<TMPXItemId> ids;
+    CleanupClosePushL(ids);
+
+    CMPXMedia* entries = CMPXMedia::NewL();
+    CleanupStack::PushL(entries);
+
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
+    CleanupStack::PushL(path);
+
+    // Go through the browse path
+    TInt levels(aPath.Levels());
+    if (levels == 2)
+        {
+        // Create a new collection path
+        CleanupStack::PopAndDestroy( path );
+        path = CMPXCollectionPath::NewL();
+        CleanupStack::PushL( path );
+
+        // Always return all songs here
+        ids.Reset();
+        ids.AppendL( KDBPluginUid );
+        path->AppendL(ids.Array());
+        path->SelectL((TMPXItemId) KDBPluginUid);
+
+        ids.Reset();
+        ids.AppendL(EBrowseAll);
+        path->AppendL(ids.Array());
+        path->SelectL((TMPXItemId) EBrowseAll);
+        path->Set(EMPXOpenPlaylistOnly);
+
+        // Get all item IDs
+        CMPXMediaArray* array = CMPXMediaArray::NewL();
+        CleanupStack::PushL(array);
+
+        DoOpenBrowseAllL(*path, aAttrs, *entries, array);
+
+        entries->SetCObjectValueL(KMPXMediaArrayContents, array);
+        entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+
+        CleanupStack::PopAndDestroy(array);
+
+        DoAppendLevelL(*path, *entries);
+        }
+    else if (levels > 2)
+        {
+        switch (aPath.Id(1).iId2)
+            {
+            case EBrowseAll:
+                {
+                path->Set(EMPXOpenPlaylistOnly);
+                // Returns the same path that we copied
+                break;
+                }
+            case EBrowseArtist:
+                {
+                if (levels == 3)
+                    {
+                    // return all songs of a particular artist (currently highlighted)
+                    path->Set(EMPXOpenGroupOrPlaylist);
+                    ids.Reset();
+                    ids.Append(aPath.Id(2));
+                    path->AppendL(ids.Array());
+                    path->SelectL(aPath.Id(2));
+                    path->Set(EMPXOpenPlaylistOnly);
+
+                    // Opens all songs of an artist and create the corresponding
+                    // Collection playlist by appending all songs of an artist to
+                    // the collection path
+                    //
+                    DoOpenL(*path, aAttrs, *entries, NULL);
+                    DoAppendLevelL(*path, *entries);
+                    }
+                else if (levels == 4)
+                    {
+                    // Open the album of an artist and create the corresponding
+                    // Collection playlist by appending all songs of an artist to
+                    // the collection path
+                    //
+                    path->Set(EMPXOpenPlaylistOnly);
+                    DoOpenL(*path, aAttrs, *entries, NULL);
+                    DoAppendLevelL(*path, *entries);
+                    }
+                else
+                    {
+                    // case is a song no need to open again!
+                    }
+
+                break;
+                }
+            // Playlist, album, genre and composer easier, only 2 levels deep
+            // plugin | category | category contents | songs of category
+            //
+            case EBrowsePlaylist:
+            case EBrowseAlbum:
+            case EBrowseGenre:
+            case EBrowseComposer:
+                {
+                if (!DoOpenL(aPath, aAttrs, *entries, NULL))
+                    {
+                    // If it is not at a song level
+                    // Append all entries to create collection path
+                    //
+                    path->Set(EMPXOpenPlaylistOnly);
+                    DoAppendLevelL( *path, *entries );
+                    }
+                break;
+                }
+            default:
+                {
+                User::Leave(KErrNotSupported);
+                }
+            }
+        }
+    else  // levels < 2
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    // Cleanup
+    CleanupStack::Pop(path);
+    CleanupStack::PopAndDestroy(entries);
+    CleanupStack::PopAndDestroy(&ids);
+
+    return path;
+    }
+
+// ----------------------------------------------------------------------------
+// Process the MediaL command
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoMediaL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoMediaL");
+
+    // Fetch Media for root level
+    //
+    if (aPath.Levels() == 1) //root
+        {
+        DoRootMediaL( aAttrs, aEntries );
+        }
+    // Ensure the database has been merged before attempting MediaL()
+    //
+    else
+        {
+        CMPXMediaArray* array = CMPXMediaArray::NewL();
+        CleanupStack::PushL(array);
+
+        switch (aPath.Id(1).iId2)
+            {
+            case EBrowseAll:
+                {
+                DoAllSongsMediaL(aPath, aAttrs, aEntries, *array);
+                break;
+                } // end case EBrowseAll
+
+            case EBrowseArtist:
+                {
+                DoArtistMediaL(aPath, aAttrs, aEntries, *array);
+                break;
+                } // end case EBrowseArtist
+
+            case EBrowseAlbum:
+                {
+                DoCategoryMediaL(aPath, aAttrs, EMPXAlbum, aEntries, *array);
+                break;
+                } // end case EBrowseAlbum
+
+            case EBrowsePlaylist:
+                {
+                DoCategoryMediaL(aPath, aAttrs, EMPXPlaylist, aEntries, *array);
+                break;
+                } // end case EBrowsePlaylist
+
+            case EBrowseGenre:
+                {
+                DoCategoryMediaL(aPath, aAttrs, EMPXGenre, aEntries, *array);
+                break;
+                } // end case EBrowseGenre
+
+            case EBrowseComposer:
+                {
+                DoCategoryMediaL(aPath, aAttrs, EMPXComposer, aEntries, *array);
+                break;
+                } // end case EBrowseComposer
+#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
+            case EBrowsePodcasts:
+                {
+                break;
+                }
+#endif
+            default:
+                {
+                User::Leave(KErrArgument);
+                }
+            } // end switch(aPath.id(1)
+
+        if (array->Count() > 0)
+            {
+            aEntries.SetCObjectValueL(KMPXMediaArrayContents, array);
+            aEntries.SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+            }
+        CleanupStack::PopAndDestroy(array);
+        }
+    // Else case cannot leave, because this will happen when we have no disk space to
+    // perform the merging. It should NOT leave.
+    //
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection media for root level
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRootMediaL(
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aMedia )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRootMediaL");
+
+    TInt count(aAttrs.Count());
+#ifndef __ENABLE_PODCAST_IN_MUSIC_MENU
+    aMedia.SetTObjectValueL<TMPXGeneralNonPermissibleActions> (
+            KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache) );
+#endif // __ENABLE_PODCAST_IN_MUSIC_MENU
+    for (TInt i = 0; i < count; ++i)
+        {
+        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
+            {
+            TUint att(aAttrs[i].AttributeId());
+            if (att & EMPXMediaGeneralTitle)
+                {
+                HBufC* title(iResource->ReadHBufCL(R_MPX_QTN_MUS_MUSIC));
+                CleanupStack::PushL(title);
+                aMedia.SetTextValueL(KMPXMediaGeneralTitle, *title);
+                CleanupStack::PopAndDestroy(title);
+                }
+            if (att & EMPXMediaGeneralSubTitle)
+                {
+                TInt numSongs(iDbHandler->NumberOfItemsL(EMPXSong));
+                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, numSongs);
+
+                HBufC* text(iResource->ReadHBufCL((1 == numSongs) ?
+                    R_MPX_QTN_MUS_MUSIC_ONE_SONG : R_MPX_QTN_MUS_MUSIC_NUM_SONGS));
+
+                CleanupStack::PushL(text);
+                aMedia.SetTextValueL(KMPXMediaGeneralSubTitle, *text);
+                CleanupStack::PopAndDestroy(text);
+                }
+            if (att & EMPXMediaGeneralIcon)
+                {
+/*                TIconInfo icon;
+                icon.bmpfile = KMPlayerDbPluginMbmFile;
+                icon.bitmapId = EMbmMpxdbpluginQgn_graf_mup_dlst_music;
+                icon.maskId = EMbmMpxdbpluginQgn_graf_mup_dlst_music_mask;
+                aMedia.SetTObjectValueL<TIconInfo>(KMPXMediaGeneralIcon, icon);
+*/
+// commented out for hb migration
+                }
+            } // if
+        } // for
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection media for all songs category
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoAllSongsMediaL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAllSongsMediaL");
+
+    TInt levels(aPath.Levels());
+
+    switch (levels)
+       {
+       // All songs
+       case 2:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoAllSongsMediaL_All);
+            DoRootCategoryMediaL(aAttrs, EBrowseAll, EMPXSong, aEntries);
+            MPX_PERF_END(CMPXDbPlugin_DoAllSongsMediaL_All);
+            break;
+            }
+
+         // A Song in all songs
+         case 3:
+            {
+            MPX_PERF_START(CMPXDbPlugin_DoAllSongsMediaL_Song);
+            GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
+            MPX_PERF_END(CMPXDbPlugin_DoAllSongsMediaL_Song);
+            break;
+            }
+
+         default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoAllSongsMediaL: Invalid levels[%d]", levels);
+            User::Leave(KErrNotSupported);
+            }
+        } // end switch(levels)
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection media for artists category
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoArtistMediaL (
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntries,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoArtistMediaL");
+
+    TInt levels(aPath.Levels());
+    TInt count(aPath.Selection().Count());
+
+     // All artists
+    if (levels == 2)
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_All);
+        DoRootCategoryMediaL(aAttrs, EBrowseArtist, EMPXArtist, aEntries);
+        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_All);
+        }
+    else if ((levels == 3) && count) // multiple artists selected
+        {
+        RArray<TMPXItemId> selections;
+        CleanupClosePushL(selections);
+        aPath.SelectionL(selections);
+
+        for (TInt i = 0; i < count; ++i)
+            {
+            CMPXMedia* artist = CMPXMedia::NewL();
+            CleanupStack::PushL(artist);
+            iDbHandler->GetCategoryL(selections[i].iId2, EMPXArtist, aAttrs, artist);
+            aMediaArray.AppendL(*artist);
+            CleanupStack::PopAndDestroy(artist);
+            }
+
+        CleanupStack::PopAndDestroy(&selections);
+        }
+    else if (levels == 3) // single artist selected
+        {
+        iDbHandler->GetCategoryL(aPath.Id(2).iId2, EMPXArtist, aAttrs, &aEntries);
+        }
+    else if (levels == 4 && (aPath.Id(3) == aPath.Id(2))) // all songs for an artist
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_AllSongs);
+        // Calculate duration directly with SQL
+        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
+            {
+            DoDurationL(aEntries, EMPXArtist, aPath.Id(2));
+            }
+
+        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_AllSongs);
+        }
+    else if ((levels == 4) && count) // multiple albums of an artist
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_AllAlbums);
+
+        RArray<TMPXItemId> selections;
+        CleanupClosePushL(selections);
+        aPath.SelectionL(selections);
+
+        for (TInt i = 0; i < count; ++i)
+            {
+            CMPXMedia* media = CMPXMedia::NewL();
+            CleanupStack::PushL(media);
+            iDbHandler->GetCategoryL(selections[i].iId2, EMPXAlbum, aAttrs, media);
+            aMediaArray.AppendL(*media);
+            CleanupStack::PopAndDestroy(media);
+            }
+
+        CleanupStack::PopAndDestroy(&selections);
+
+        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_AllAlbums);
+        }
+    else if (levels == 4) // one album of an artist
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_OneAlbum);
+        iDbHandler->GetCategoryL(aPath.Id(3).iId2, EMPXAlbum, aAttrs, &aEntries);
+
+        // Calculate duration
+        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
+            {
+            DoDurationL(aEntries, EMPXArtist, aPath.Id(2), EMPXAlbum, aPath.Id(3));
+            }
+
+        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_OneAlbum);
+        }
+     else if (levels == 5) // a song/songs in an album
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_Song);
+        GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
+        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_Song);
+        }
+    else
+        {
+        MPX_DEBUG2("CMPXDbPlugin_DoArtistMediaL: Invalid levels[%d]", levels);
+        User::Leave(KErrNotSupported);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection media for all songs category
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRootCategoryMediaL (
+    const TArray<TMPXAttribute>& aAttrs,
+    TMPXItemId aRootCategoryId,
+    TMPXGeneralCategory aCategory,
+    CMPXMedia& aEntries)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRootCategoryMediaL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
+            {
+            TUint att(aAttrs[i].AttributeId());
+            switch (att)
+                {
+                case EMPXMediaGeneralId:
+                    {
+                    aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aRootCategoryId);
+                    break;
+                    }
+                case EMPXMediaGeneralTitle:
+                    {
+                    aEntries.SetTextValueL(KMPXMediaGeneralTitle,
+                        iMusicLibraryMenuTitles->MdcaPoint(BrowseTypeForCategory(aCategory)));
+                    break;
+                    }
+                case EMPXMediaGeneralCount:
+                    {
+                    // count number of category
+                    aEntries.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
+                        iDbHandler->NumberOfItemsL(aCategory));
+                    break;
+                    }
+                case EMPXMediaGeneralDuration:
+                    {
+                    if (aCategory == EMPXSong)
+                        {
+                        DoDurationL(aEntries, EMPXSong);
+                        }
+                    break;
+                    }
+                default:
+                    // not supported
+                    break;
+                } // end switch
+            } // end if
+        } // end for
+
+    aEntries.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
+    aEntries.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, aCategory);
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection media for albums/playlists/genres/composers category
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoCategoryMediaL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    TMPXGeneralCategory aCategory,
+    CMPXMedia& aEntries,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoCategoryMediaL");
+
+    TInt levels(aPath.Levels());
+    TInt count(aPath.Selection().Count());
+
+    if (levels == 2) // all albums/playlists/genres/composers
+        {
+        MPX_PERF_START (CMPXDbPlugin_DoCategoryMediaL_All);
+        DoRootCategoryMediaL(aAttrs, aPath.Id(1).iId2, aCategory, aEntries);
+        MPX_PERF_END (CMPXDbPlugin_DoCategoryMediaL_All);
+        }
+    else if (levels == 3 && count) // multiple albums/playlists/genres/composers selected
+        {
+        RArray<TMPXItemId> selections;
+        CleanupClosePushL(selections);
+        aPath.SelectionL(selections);
+
+        for (TInt i = 0; i < count; ++i)
+            {
+            CMPXMedia* media = CMPXMedia::NewL();
+            CleanupStack::PushL(media);
+            iDbHandler->GetCategoryL(selections[i].iId2, aCategory, aAttrs, media);
+            aMediaArray.AppendL(*media);
+            CleanupStack::PopAndDestroy(media);
+            }
+
+        CleanupStack::PopAndDestroy(&selections);
+        }
+    else if (levels == 3) // all songs in an album/playlist/genre/composer
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoCategoryMediaL_Category);
+        TMPXItemId id = aPath.Id(2);
+        iDbHandler->GetCategoryL(id.iId2, aCategory, aAttrs, &aEntries);
+
+        // Calculate duration directly with SQL
+        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
+            {
+            DoDurationL(aEntries, aCategory, id);
+            }
+
+        TInt nonPermisAction( aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralNonPermissibleActions));
+        nonPermisAction |= EMPXCache;
+
+        aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                    KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions) nonPermisAction );
+
+        MPX_PERF_END(CMPXDbPlugin_DoCategoryMediaL_Category);
+        }
+    else if (levels == 4) // a song/songs in an album/playlist/genre/composer
+        {
+        MPX_PERF_START(CMPXDbPlugin_DoCategoryMediaL_Song);
+        GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
+        MPX_PERF_END(CMPXDbPlugin_DoCategoryMediaL_Song);
+        }
+    else
+        {
+        MPX_DEBUG2("CMPXDbPlugin__DoMediaL__EBrowseAlbum: Invalid levels[%d]", levels);
+        User::Leave(KErrNotSupported);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoSetMediaDrmL(
+    CMPXMedia& aMedia,
+    TUint aDrmAttributes,
+    const TDesC& aLocation)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoSetMediaDrmL");
+
+    iDrmMediaUtility->InitL(aLocation);
+    CleanupClosePushL(*iDrmMediaUtility);
+    const CMPXMedia* drmMedia(iDrmMediaUtility->GetMediaL(aDrmAttributes));
+
+    // Only get attributes if it's a DRM file
+    if (drmMedia)
+        {
+        if ((aDrmAttributes & EMPXMediaDrmType) &&
+            drmMedia->IsSupported(KMPXMediaDrmType))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmType,
+                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmType));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmRightsStatus) &&
+            drmMedia->IsSupported(KMPXMediaDrmRightsStatus))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmRightsStatus,
+                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsStatus));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmRightsType) &&
+            drmMedia->IsSupported(KMPXMediaDrmRightsType))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmRightsType,
+                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsType));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmCount) &&
+            drmMedia->IsSupported(KMPXMediaDrmCount))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmCount,
+                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmCount));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmProtected) &&
+            drmMedia->IsSupported(KMPXMediaDrmProtected))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmProtected,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmProtected));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmSendingAllowed) &&
+            drmMedia->IsSupported(KMPXMediaDrmSendingAllowed))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmSendingAllowed,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmSendingAllowed));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmCanSetAutomated) &&
+            drmMedia->IsSupported(KMPXMediaDrmCanSetAutomated))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmCanSetAutomated,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmCanSetAutomated));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmHasInfoUrl) &&
+            drmMedia->IsSupported(KMPXMediaDrmHasInfoUrl))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmHasInfoUrl,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasInfoUrl));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmHasPreviewUrl) &&
+            drmMedia->IsSupported(KMPXMediaDrmHasPreviewUrl))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmHasPreviewUrl,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasPreviewUrl));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmAboutToExpire) &&
+            drmMedia->IsSupported(KMPXMediaDrmAboutToExpire))
+            {
+            aMedia.SetTObjectValueL( KMPXMediaDrmAboutToExpire,
+                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmAboutToExpire));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmStartTime) &&
+            drmMedia->IsSupported(KMPXMediaDrmStartTime))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmStartTime,
+                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmStartTime));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmEndTime) &&
+            drmMedia->IsSupported(KMPXMediaDrmEndTime))
+            {
+            aMedia.SetTObjectValueL( KMPXMediaDrmEndTime,
+                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmEndTime));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmIntervalStartTime) &&
+            drmMedia->IsSupported(KMPXMediaDrmIntervalStartTime))
+            {
+            aMedia.SetTObjectValueL( KMPXMediaDrmIntervalStartTime,
+                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmIntervalStartTime));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmAccumulatedTime) &&
+            drmMedia->IsSupported(KMPXMediaDrmAccumulatedTime))
+            {
+            aMedia.SetTObjectValueL(KMPXMediaDrmAccumulatedTime,
+                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmAccumulatedTime));
+            }
+        if ((aDrmAttributes & EMPXMediaDrmInterval) &&
+            drmMedia->IsSupported(KMPXMediaDrmInterval))
+            {
+            aMedia.SetTObjectValueL( KMPXMediaDrmInterval,
+                drmMedia->ValueTObjectL<TTimeIntervalSeconds>(KMPXMediaDrmInterval));
+            }
+        }
+
+    CleanupStack::PopAndDestroy(iDrmMediaUtility);
+    }
+
+// ----------------------------------------------------------------------------
+// Add media objects to the array with attributes from song details
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::GetSongInfoL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXAttribute>& aAttrs,
+    CMPXMedia& aEntry,
+    CMPXMediaArray& aMediaArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::GetSongInfoL");
+
+    RArray<TInt> supportedIds;
+    CleanupClosePushL(supportedIds);
+    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
+
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    //
+    // If we are trying to locate a song from a playlist, we should read available song
+    // info from Playlist table first in case the song is located on a removable
+    // drive and the drive is not currently present. This is achieved by supplying
+    // playlist Id to GetSongMatchingSongIdL. When playlistId is 0, we are reading song
+    // info directly from Songs table. If playlistId is specified, GetSongMatchingSongIdL
+    // will populate song media from Playlist table and if Songs table for the drive
+    // exists, song media will be overwritten with info from Songs table.
+    //
+    TMPXItemId playlistId(0);
+    if (aPath.Id(1) == EBrowsePlaylist)
+        {
+        if (aPath.Levels() < 2)
+            {
+            User::Leave(KErrArgument);
+            }
+
+        playlistId = aPath.Id(aPath.Levels() - 2);
+        }
+
+    TInt countSelection(aPath.Selection().Count());
+    if (countSelection)
+        {
+        // We have a selection, iterate it
+        for (TInt selectionIndex = 0; selectionIndex < countSelection; ++selectionIndex)
+            {
+            CMPXMedia* newEntry = CMPXMedia::NewL(supportedIds.Array());
+            CleanupStack::PushL(newEntry);
+
+            DoGetSongInfoL(aAttrs, selections[selectionIndex].iId2, playlistId.iId2, *newEntry);
+
+            aMediaArray.AppendL(*newEntry);
+            CleanupStack::PopAndDestroy(newEntry);
+            }
+        }
+    else
+        {
+        // No selection, get the attributes for the one song
+        DoGetSongInfoL(aAttrs, aPath.Id(aPath.Levels() - 1).iId2, playlistId.iId2, aEntry);
+        }
+
+    CleanupStack::PopAndDestroy(&selections);
+    CleanupStack::PopAndDestroy(&supportedIds);
+    }
+
+// ----------------------------------------------------------------------------
+// Retrieves the attributes for a media object.
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoGetSongInfoL(
+    const TArray<TMPXAttribute>& aAttrs,
+    TInt aEntryId,
+    TInt aPlaylistId,
+    CMPXMedia& aEntry)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoGetSongInfoL");
+
+    if (aPlaylistId)
+        {
+        iDbHandler->GetPlaylistSongL(aEntryId, aPlaylistId, aAttrs, aEntry);
+        }
+    else
+        {
+        iDbHandler->GetSongL(aEntryId, aAttrs, aEntry);
+        }
+
+    const TDesC& location(aEntry.ValueText(KMPXMediaGeneralUri));
+
+    // Check DRM Only if we have a location
+    if (location != KNullDesC)
+        {
+        TUint drmAttributes(0);
+
+        // Compact the attribute set
+        TInt count(aAttrs.Count());
+        for (TInt i = 0; i < count; ++i)
+            {
+            if (aAttrs[i].ContentId() == KMPXMediaIdDrm)
+                {
+                drmAttributes |= aAttrs[i].AttributeId();
+                }
+            }
+
+        // Set the correct attributes to media, only if requested
+        if (drmAttributes)
+            {
+            DoSetMediaDrmL(aEntry, drmAttributes, location);
+            }
+        }
+
+    // Disable caching for any MediaL() returning song info.
+    TInt nonPermisAction( aEntry.ValueTObjectL<TInt>(KMPXMediaGeneralNonPermissibleActions));
+    nonPermisAction |= EMPXCache;
+
+    aEntry.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
+                KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions) nonPermisAction );
+    }
+
+// ----------------------------------------------------------------------------
+// Find the collection details
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoHandleOtherMediaAttributesL(
+    const TArray<TMPXAttribute>& aAttrs,
+    const CMPXCollectionPath& aPath,
+    CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoHandleOtherMediaAttributesL");
+
+    TInt count(aAttrs.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        if (aAttrs[i].ContentId() == KMPXMediaIdCollectionDetails)
+            {
+            TUint att(aAttrs[i].AttributeId());
+
+            if (att & EMPXMediaColDetailNumberOfItems)
+                {
+                aMedia.SetTObjectValueL(KMPXMediaColDetailNumberOfItems,
+                    iDbHandler->NumberOfItemsL(EMPXSong));
+                }
+            if (att & EMPXMediaColDetailDuration)
+                {
+                aMedia.SetTObjectValueL(KMPXMediaColDetailDuration,
+                    DoDurationL(aMedia, EMPXSong));
+                }
+            if (att & EMPXMediaColTotalSize)
+                {
+                // todo
+                TInt totalSize(0);
+                aMedia.SetTObjectValueL(KMPXMediaColDetailTotalSize, totalSize);
+                }
+            if (att & EMPXMediaLastRefreshed)
+                {
+                TTime lastRefreshed(iDbHandler->GetLastRefreshedTimeL());
+                aMedia.SetTObjectValueL(KMPXMediaColDetailLastRefreshed,
+                    lastRefreshed.Int64());
+                }
+            if (att & EMPXMediaColDetailDBCreated)
+                {
+                aMedia.SetTObjectValueL(KMPXMediaColDetailDBCreated,
+                    iDbHandler->DatabaseCreated());
+                }
+            if (att & EMPXMediaColDetailDBCorrupted)
+                {
+                aMedia.SetTObjectValueL(KMPXMediaColDetailDBCorrupted,
+                    iDbHandler->IsDBCorruptedL());
+                }
+            }
+        else if (aAttrs[i] == KMPXMediaGeneralPath)
+            {
+            aMedia.SetCObjectValueL(KMPXMediaGeneralPath,
+                const_cast<CMPXCollectionPath*>(&aPath));
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Remove an item from the collection database using the given path
+// ----------------------------------------------------------------------------
+//
+CDesCArray* CMPXDbPlugin::DoRemoveL(
+    const CMPXCollectionPath& aPath,
+    CMPXMessageArray& aChangeMsgArray)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveL");
+
+    if (aPath.Levels() <= 1)
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    // Return file path for deleted item(s)
+    //
+    CDesCArray* fp = new(ELeave) CDesCArrayFlat(1);
+    CleanupStack::PushL(fp);
+
+    // Ids of the selected items
+    RArray<TMPXItemId> selections;
+    CleanupClosePushL(selections);
+    aPath.SelectionL(selections);
+
+    switch (aPath.Id(1).iId2)
+        {
+        case EBrowseAll:
+            {
+            DoRemoveFromAllSongsL(aPath, selections.Array(), *fp, aChangeMsgArray);
+            }
+            break;
+
+        case EBrowseArtist:
+            {
+            DoRemoveFromArtistsL(aPath, selections.Array(), *fp, aChangeMsgArray);
+            }
+            break;
+
+        case EBrowseAlbum: // deliberate fall through
+        case EBrowseGenre: // deliberate fall through
+        case EBrowseComposer: // deliberate fall through
+            {
+            DoRemoveFromCategoriesL(aPath, selections.Array(),
+                CategoryForBrowseType(static_cast<TMCBrowseType>(aPath.Id(1).iId2)), *fp, aChangeMsgArray);
+            }
+            break;
+
+        case EBrowsePlaylist:
+            {
+            DoRemoveFromPlaylistsL(aPath, selections.Array(), *fp, aChangeMsgArray);
+            }
+            break;
+
+        default:
+            {
+            User::Leave(KErrArgument);
+            }
+        } // end switch (aPath.Id(1))
+
+    MPX_DEBUG2("CMPXDbPlugin::RemoveL itemId[%d]", aPath.Id(aPath.Levels() - 1).iId2);
+
+    CleanupStack::PopAndDestroy( &selections );
+    CleanupStack::Pop(fp);
+
+    return fp;
+    }
+
+// ----------------------------------------------------------------------------
+// Remove an item from the collection database using the given media properties
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveL(
+    const CMPXMedia& aMedia,
+    TBool aDeleteRecord)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveL(by media)");
+
+    // Return deleted file paths to caller
+    CDesCArray* fp = new(ELeave) CDesCArrayFlat(1);
+    CleanupStack::PushL(fp);
+
+    // a list of change event messages a result of the item being removed
+    CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
+    CleanupStack::PushL(itemChangedMessages);
+
+    TUint32 mediaId(0);
+
+    // Removing a container of items
+    //
+    if (aMedia.IsSupported(KMPXMediaArrayContents))
+        {
+        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing a container of items");
+        const CMPXMediaArray* media = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        if( !media )
+            {
+            User::Leave(KErrNoMemory);
+            }
+        const TInt mediaCount(media->Count());
+        for (TInt i = 0; i < mediaCount; ++i)
+            {
+            CMPXMedia* entry = media->AtL(i);
+            if (entry->IsSupported(KMPXMediaGeneralId))
+                {
+                mediaId = entry->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+                }
+            else if (entry->IsSupported(KMPXMediaGeneralUri))
+                {
+                const TDesC& uri = entry->ValueText(KMPXMediaGeneralUri);
+                mediaId = iDbHandler->GetSongIdMatchingUriL(uri);
+                }
+            else
+                {
+                // Unable to process this item
+                continue;
+                }
+
+            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
+            }
+        }
+    // Removing an item with known item id
+    //
+    else if (aMedia.IsSupported(KMPXMediaGeneralId))
+        {
+        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing an item by item id");
+        mediaId =  aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+
+        if (MPX_ITEM_CATEGORY(mediaId) != EMPXPlaylist)
+            {
+            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
+            }
+        else
+            {
+            iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
+            }
+        }
+    // Removing an item with known uri
+    //
+    else if (aMedia.IsSupported(KMPXMediaGeneralUri))
+        {
+        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing an item by uri");
+        TPtrC uri = aMedia.ValueText( KMPXMediaGeneralUri );
+
+        TMPXGeneralCategory category =
+            aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
+
+        if (category == EMPXSong)
+            {
+            mediaId = iDbHandler->GetSongIdMatchingUriL(uri);
+            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
+            }
+        else if (category == EMPXPlaylist)
+            {
+            mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri);
+            iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
+            }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED            
+        else if (category == EMPXAbstractAlbum )
+            {
+            mediaId = iDbHandler->GetAbstractAlbumIdMatchingUriL(uri);
+            iDbHandler->RemoveAbstractAlbumL(mediaId, *fp, *itemChangedMessages);            
+            }
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        else
+            {
+            // otherwise unable to process this item
+            }
+        }
+    else
+        {
+        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Unknown item for removal");
+        User::Leave(KErrNotSupported);
+        }
+
+    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+
+    // Removing an item always invalidates all songs.
+    //
+    MPXDbCommonUtil::AddItemChangedMessageL(*itemChangedMessages, EBrowseAll,
+                                            EMPXItemModified, EMPXCollection, KDBPluginUid);
+
+    DoHandleChangeL(itemChangedMessages);
+
+    CleanupStack::PopAndDestroy(itemChangedMessages);
+    CleanupStack::PopAndDestroy(fp);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove media by path through a command
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemovePathL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemovePathL(by command)");
+
+    TInt removeError(KErrNone);
+    TBool removeCompleted(ETrue);
+
+    if (!aCmd.IsSupported(KMPXCommandCollectionRemovePath) ||
+        !aCmd.IsSupported(KMPXCommandCollectionRemoveMediaCount))
+        {
+        removeError = KErrArgument;
+        }
+    else
+        {
+        CMPXCollectionPath* path =
+            aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCommandCollectionRemovePath);
+        CleanupStack::PushL(path);
+
+        // in order to support cancel delete for a category, we need to adjust path. If
+        // the path ends in a category, retrieve all songs under the selected category
+        // and append a new level with all songs under the selected category
+        DoAppendLevelL(*path);
+
+        CMPXCollectionPath* iterationPath = CMPXCollectionPath::NewL(*path);
+        CleanupStack::PushL(iterationPath);
+        iterationPath->ClearSelection();
+
+        // indices of the selected items
+        TArray<TInt> selectionIndices = path->Selection();
+        TInt count(selectionIndices.Count());
+
+        // number of media items to remove in this iteration
+        TInt removeCount = (aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionRemoveMediaCount));
+
+        // remove all in one shot if removeCount is 0 or negative
+        if (removeCount <= 0)
+            {
+            removeCount = count;
+            }
+
+        // If the given path contains multiple selections, remove the first n selected media
+        // and update the path so that client can use this path to call remove iteratively
+        // until all selections are processed
+        //
+        if (count)
+            {
+            for (TInt i = 0; i < removeCount; ++i)
+                {
+                TInt index(selectionIndices[i]);
+
+                MPX_DEBUG4(" path: selected item [index %d] [selectioncount %d] [remove count %d]", index, count, removeCount);
+
+                iterationPath->SelectL(index);
+                path->Remove(index);
+                }
+
+            aCmd.SetCObjectValueL(KMPXCommandCollectionRemovePath, path);
+
+            // indicate to the client that subsequent remove command is required
+            if ((count - removeCount) > 0)
+                {
+                removeCompleted = EFalse;
+                }
+            }
+
+        // Remove the media specified by the path
+        CDesCArray* fp(NULL);
+        TBool supressMsgs(EFalse);
+        CMPXMessageArray* msgAry(NULL);
+
+        if (aCmd.IsSupported(KMPXCommandCollectionRemoveSuppressMsgs) &&
+            aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveSuppressMsgs))
+            {
+            // Msgs are stored in the command
+            supressMsgs = ETrue;
+
+            CMPXMessageArray* msgs( aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionChangeMsgs) );
+            User::LeaveIfNull( msgs );
+            fp = DoRemoveL(*iterationPath, *msgs);
+            }
+        else
+            {
+            // Msgs will be sent after delete
+            msgAry = CMPXMessageArray::NewL();
+            CleanupStack::PushL(msgAry);
+            fp = DoRemoveL(*iterationPath, *msgAry);
+            }
+
+        CleanupStack::PushL(fp);
+        if (fp->MdcaCount() > removeCount)
+            {
+            removeError = KErrCorrupt;
+            }
+        CleanupStack::PopAndDestroy(fp);
+
+        if (!supressMsgs)
+            {
+            // Send Change Messages
+            iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+            DoHandleChangeL(msgAry);
+            CleanupStack::PopAndDestroy(msgAry);
+            }
+
+        // Cleanup
+        CleanupStack::PopAndDestroy(iterationPath);
+        CleanupStack::PopAndDestroy(path);
+        }
+
+    // mandatory return parameters
+    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveError, removeError);
+    aCmd.SetTObjectValueL<TBool>(KMPXCommandCollectionRemoveCompleted, removeCompleted);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove media by CMPXMedia through a command
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveMediaL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveMediaL(by command)");
+
+    TInt error(KErrArgument);
+
+    if (aCmd.IsSupported(KMPXCommandCollectionRemoveMedia))
+        {
+        CMPXMedia* media = aCmd.ValueCObjectL<CMPXMedia>(KMPXCommandCollectionRemoveMedia);
+        CleanupStack::PushL(media);
+
+        MPX_TRAP(error, DoRemoveL(*media,
+            aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveMediaDeleteRecord)));
+
+        CleanupStack::PopAndDestroy(media);
+        }
+
+    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveMediaError, error);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media/media items from All Songs view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveFromAllSongsL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXItemId>& aSelections,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveFromAllSongsL");
+
+    switch (aPath.Levels())
+        {
+        case 2:
+            {
+            // when the collection is removed, it's intended not to delete the files
+            iDbHandler->RemoveEntireCollectionL();
+            }
+            break;
+
+        case 3:
+            {
+            TInt count(aSelections.Count());
+            if (count)
+                {
+                for (TInt i = 0; i < count; ++i)
+                    {
+                    iDbHandler->RemoveSongL(aSelections[i].iId2, aUriArray, aItemChangedMessages);
+                    } // end for
+                }
+            else
+                {
+                iDbHandler->RemoveSongL(aPath.Id(aPath.Levels() - 1).iId2, aUriArray,
+                     aItemChangedMessages);
+                }
+            }
+            break;
+
+        default:
+            {
+            MPX_DEBUG2("CMPXDbPlugin_DoRemoveFromAllSongsL: Invalid levels[%d]", aPath.Levels());
+            User::Leave(KErrNotSupported);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media/media items from Artists view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveFromArtistsL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXItemId>& aSelections,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveFromArtistsL");
+
+    TInt levels(aPath.Levels());
+    if (levels == 2)
+        {
+        // when the collection is removed, it's intended not to delete the files
+        iDbHandler->RemoveEntireCollectionL();
+        }
+    else
+        {
+        TInt count(aSelections.Count());
+        if (count)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                RemoveFromArtistsL(aPath, aSelections[i].iId2, aUriArray, aItemChangedMessages);
+                }
+            }
+        else
+            {
+            RemoveFromArtistsL(aPath, aPath.Id(levels - 1).iId2, aUriArray, aItemChangedMessages);
+            }
+        }
+
+    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowseArtist: levels[%d]", levels);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media item from Artists view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::RemoveFromArtistsL(
+    const CMPXCollectionPath& aPath,
+    TUint32 aItemId,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::RemoveFromArtistsL");
+
+    switch (aPath.Levels())
+        {
+        case 3:
+            {
+            iDbHandler->RemoveSongsMatchingCategoryL(EMPXArtist, aItemId, aUriArray, aItemChangedMessages);
+            break;
+            }
+        case 4:
+            {
+            // remove the songs for the artist and album
+            iDbHandler->RemoveSongsMatchingArtistAndAlbumL(aPath.Id(aPath.Levels() - 2), aItemId,
+                aUriArray, aItemChangedMessages);
+            break;
+            }
+        case 5:
+            {
+            iDbHandler->RemoveSongL(aItemId, aUriArray, aItemChangedMessages);
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrArgument);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media/media items from Albums/Genres/Composers view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveFromCategoriesL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXItemId>& aSelections,
+    TMPXGeneralCategory aCategory,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveFromCategoriesL");
+
+    TInt levels(aPath.Levels());
+    if (levels == 2)
+        {
+        // when the collection is removed, it's intended not to delete the files
+        iDbHandler->RemoveEntireCollectionL();
+        }
+    else
+        {
+        TInt count(aSelections.Count());
+        if (count)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                RemoveFromCategoriesL(aPath, aSelections[i].iId2, aCategory,
+                    aUriArray, aItemChangedMessages);
+                }
+            }
+        else
+            {
+            RemoveFromCategoriesL(aPath, aPath.Id(levels - 1).iId2, aCategory,
+                aUriArray, aItemChangedMessages);
+            }
+        }
+
+    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowseAlbum: levels[%d]", levels);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media item from Albums/Genres/Composers view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::RemoveFromCategoriesL(
+    const CMPXCollectionPath& aPath,
+    TUint32 aItemId,
+    TMPXGeneralCategory aCategory,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::RemoveFromCategoriesL");
+
+    switch (aPath.Levels())
+        {
+        case 3:
+            {
+            iDbHandler->RemoveSongsMatchingCategoryL(aCategory, aItemId, aUriArray,
+                aItemChangedMessages);
+            break;
+            }
+        case 4:
+            {
+            iDbHandler->RemoveSongL(aItemId, aUriArray, aItemChangedMessages);
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrArgument);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Remove one or multiple media items from Playlists view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRemoveFromPlaylistsL(
+    const CMPXCollectionPath& aPath,
+    const TArray<TMPXItemId>& aSelections,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRemoveFromPlaylistsL");
+
+    TInt levels(aPath.Levels());
+
+    // all playlists
+    if (levels == 2)
+        {
+        // when the collection is removed, it's intended not to delete the files
+        iDbHandler->RemoveAllPlaylistsL();
+        }
+    else
+        {
+        TArray<TInt> selectionIndices = aPath.Selection();
+        TInt count(selectionIndices.Count());
+
+        // multiple selections
+        if (count)
+            {
+            for (TInt i = (count - 1); i >= 0; --i)
+                {
+                RemoveFromPlaylistsL(aPath, aSelections[i], selectionIndices[i],
+                    aUriArray, aItemChangedMessages);
+                }
+            }
+        // else no selection
+        else
+            {
+            RemoveFromPlaylistsL(aPath, aPath.IdOfIndex(aPath.Index()), aPath.Index(),
+                aUriArray, aItemChangedMessages);
+            }
+        }
+
+    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowsePlaylist: levels[%d]", levels);
+    }
+
+// ----------------------------------------------------------------------------
+// Remove a media item from Playlists view
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::RemoveFromPlaylistsL(
+    const CMPXCollectionPath& aPath,
+    const TMPXItemId& aItemId,
+    TInt aIndex,
+    CDesCArray& aUriArray,
+    CMPXMessageArray& aItemChangedMessages)
+    {
+    MPX_FUNC("CMPXDbPlugin::RemoveFromPlaylistsL");
+
+    switch (aPath.Levels())
+        {
+        case 3:
+            {
+            iDbHandler->RemovePlaylistL(aItemId.iId2, aUriArray, aItemChangedMessages);
+            break;
+            }
+        case 4:
+            {
+            if ( !iDbHandler->InTransaction() )
+                {
+                iDbHandler->BeginTransactionL();
+                }
+            iDbHandler->RemoveSongFromPlaylistL(aPath.Id(aPath.Levels() - 2).iId2, aItemId,
+                aIndex, aItemChangedMessages);
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrArgument);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Retrieve URIs associated with this file path for file deletion
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoRetrieveUriForDeletionL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoRetrieveUriForDeletionL");
+
+    // initialize mandatory return parameters
+    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrNone);
+
+    if (!aCmd.IsSupported(KMPXCommandCollectionRetrievePath))
+        {
+        aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrArgument);
+        }
+    else
+        {
+        CMPXCollectionPath* path = aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCommandCollectionRetrievePath);
+        CleanupStack::PushL(path);
+        if (iFirstDeleteStep )
+            {
+            iSelections.Reset( );
+        // in order to support cancel delete for a category, we need to adjust path. If
+        // the path ends in a category, retrieve all songs under the selected category
+        // and append a new level with all songs under the selected category
+        DoAppendLevelL(*path);
+
+        // Ids of the selected items
+            path->SelectionL(iSelections );
+
+        // single selection
+            if (iSelections.Count()== 0 )
+                {
+                iSelections.AppendL(path->Id (path->Levels()- 1 ) );
+                }
+            }
+
+        CDesCArray* fp = new(ELeave) CDesCArrayFlat(4);
+        CleanupStack::PushL(fp);
+
+        TInt count(iSelections.Count());
+        TInt itemCount = count > KIncrementalDeleteCount ? KIncrementalDeleteCount : count;
+        for (TInt i = 0; i < itemCount; ++i )
+            {
+            // do not report song URIs if collection path is for songs within a playlist, i.e.
+            // EBrowsePlaylist and level 4, because client should not be deleting those song
+            // files
+            if (path->Id(1) != EBrowsePlaylist || path->Levels() !=4)
+                {
+                HBufC * uri = iDbHandler->GetUriMatchingIdL (iSelections[0].iId2 );
+                CleanupStack::PushL(uri);
+                fp->AppendL(*uri);
+                CleanupStack::PopAndDestroy(uri);
+                }
+            iSelections.Remove(0);
+            }
+
+        aCmd.SetNoNewLCObjectL(KMPXCommandCollectionRetrieveMediaUriArray, fp);
+        if (iFirstDeleteStep)
+            {
+        aCmd.SetCObjectValueL(KMPXCommandCollectionRetrievePath, path);
+            }
+
+        CleanupStack::PopAndDestroy(fp);
+        CleanupStack::PopAndDestroy(path);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Cleanup deleted records
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::CleanupDeletedRecordsL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::CleanupDeletedRecordsL");
+
+    MPX_TRAPD(error, iDbHandler->CleanupDeletedRecordsL());
+    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionCleanupError, error);
+    }
+
+// ----------------------------------------------------------------------------
+// Find the duration
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlugin::DoDurationL(
+    CMPXMedia& aMedia,
+    TMPXGeneralCategory aFirstCat,
+    TMPXItemId aId,
+    TMPXGeneralCategory aSecondCat,
+    TMPXItemId aSubId)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoDurationL");
+
+    TInt duration(0);
+
+    switch (aFirstCat)
+        {
+        case EMPXSong:
+            {
+            duration = iDbHandler->GetAllSongsDurationL();
+            break;
+            }
+        case EMPXAlbum:
+            {
+            duration = iDbHandler->GetAlbumDurationL(aId.iId2);
+            break;
+            }
+        case EMPXComposer:
+            {
+            duration = iDbHandler->GetComposerDurationL(aId.iId2);
+            break;
+            }
+        case EMPXGenre:
+            {
+            duration = iDbHandler->GetGenreDurationL(aId.iId2);
+            break;
+            }
+        case EMPXArtist:
+            {
+            if (aSecondCat == EMPXAlbum)
+                {
+                duration = iDbHandler->GetArtistAlbumDurationL(aId.iId2, aSubId.iId2);
+                }
+            else
+                {
+                duration = iDbHandler->GetArtistDurationL(aId.iId2);
+                }
+            break;
+            }
+        case EMPXPlaylist:
+            {
+            duration = iDbHandler->GetPlaylistDurationL(aId.iId2);
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrNotSupported);
+            }
+        }
+
+    aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
+    return duration;
+    }
+
+// ----------------------------------------------------------------------------
+// Append a level to a collection path and set selection to the first item
+// ----------------------------------------------------------------------------
+//
+TInt CMPXDbPlugin::DoAppendLevelL(
+    CMPXCollectionPath& aPath,
+    CMPXMedia& aMedia )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAppendLevelL");
+
+    RArray<TMPXItemId> ids;
+    CleanupClosePushL(ids);
+
+    // Extract media array, and get all item ids
+    //
+    const CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+    if( !mediaArray )
+        {
+        User::Leave( KErrNoMemory );
+        }
+
+    TInt count(mediaArray->Count());
+    if (count >= 0)
+        {
+        for (TInt i = 0; i < count; ++i)
+            {
+            TMPXItemId id = mediaArray->AtL(i)->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
+            ids.AppendL(id);
+            }
+
+        // Put item id array into the path and select the first one
+        aPath.AppendL(ids.Array());
+        if (count > 0)
+            {
+            aPath.Set(0);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&ids);
+    return count;
+    }
+
+// ----------------------------------------------------------------------------
+// Append a level to a collection path and set selection to all songs under the
+// selected category/categories
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoAppendLevelL(
+    CMPXCollectionPath& aPath)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAppendLevelL");
+
+    TMPXItemId contextId(aPath.Id(1));
+    TInt levels(aPath.Levels());
+
+    if ((contextId == EBrowseAll) ||
+        (contextId == EBrowsePlaylist))
+        {
+        return;
+        }
+    else if (levels == 3 || (levels == 4 && contextId == EBrowseArtist))
+        {
+        // retrieve songs in the selected category
+        //
+        CMPXMediaArray* songs = CMPXMediaArray::NewL();
+        CleanupStack::PushL(songs);
+
+        RArray<TMPXAttribute> attributes;
+        CleanupClosePushL(attributes);
+        attributes.AppendL(KMPXMediaGeneralId);
+
+        // Ids of the selected items
+        RArray<TMPXItemId> selections;
+        CleanupClosePushL(selections);
+        aPath.SelectionL(selections);
+
+        // single selection
+        if (selections.Count() == 0)
+            {
+            selections.AppendL(aPath.Id(aPath.Levels() - 1));
+            }
+
+        TInt count(selections.Count());
+
+        // all songs for the selected artist
+        if (contextId == EBrowseArtist && levels == 3)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                iDbHandler->GetSongsMatchingArtistL(selections[i].iId2, attributes.Array(), songs);
+                }
+            if (songs->Count())
+                {
+                aPath.AppendL(selections.Array());
+                }
+            }
+
+        // all songs for the selected artist in the specified album
+        else if ((contextId == EBrowseArtist) && (levels == 4))
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                if (aPath.Id(2) == aPath.Id(3))
+                    {
+                    iDbHandler->GetSongsMatchingArtistL(aPath.Id(3).iId2,
+                        attributes.Array(), songs);
+                    }
+                else
+                    {
+                    iDbHandler->GetSongsMatchingArtistAndAlbumL(aPath.Id(aPath.Levels() - 2),
+                        selections[i].iId2, attributes.Array(), songs);
+                    }
+                }
+            }
+
+         // all songs for the selected album
+        else if (contextId == EBrowseAlbum && levels == 3)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                iDbHandler->GetSongsMatchingAlbumL(selections[i], attributes.Array(), songs);
+                }
+            }
+
+        // all songs for the selected genre
+        else if (contextId == EBrowseGenre && levels == 3)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                iDbHandler->GetSongsMatchingGenreL(selections[i], attributes.Array(), songs);
+                }
+            }
+
+        // all songs for the selected composer
+        else if (contextId == EBrowseComposer && levels == 3)
+            {
+            for (TInt i = 0; i < count; ++i)
+                {
+                iDbHandler->GetSongsMatchingComposerL(selections[i], attributes.Array(), songs);
+                }
+            }
+        else
+            {
+            // else do nothing
+            }
+
+        CleanupStack::PopAndDestroy(&selections);
+        CleanupStack::PopAndDestroy(&attributes);
+
+        // transform from CMPXMediaArray to RArray
+        RArray<TMPXItemId> songIds;
+        CleanupClosePushL(songIds);
+
+        TInt songCount(songs->Count());
+        for (TInt i = 0; i < songCount; ++i)
+            {
+            CMPXMedia* song = (*songs)[i];
+
+            if (song->IsSupported(KMPXMediaGeneralId))
+                {
+                songIds.AppendL(song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+                }
+            }
+
+        // modify the collection path. append another level with all songs under the selected
+        // category/categories selected
+        songCount = songIds.Count();
+
+        if (songCount)
+            {
+            aPath.ClearSelection();
+            aPath.AppendL(songIds.Array());
+
+            // select all
+            for (TInt i = 0; i < songCount; ++i)
+                {
+                aPath.SelectL(songIds[i]);
+                }
+            }
+
+        CleanupStack::PopAndDestroy(&songIds);
+        CleanupStack::PopAndDestroy(songs);
+        }
+    else
+        {
+        // do nothing
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Execute an Add task step
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoAddAsyncL()
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAddAsyncL");
+
+    TBool done(EFalse);
+    const CMPXMedia* task = (iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColAddMedia));
+    if( !task )
+        {
+        User::Leave(KErrNoMemory);
+        }
+
+    CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages();
+
+    if (!task->IsSupported(KMPXMediaGeneralType))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    // Group of items or a single item
+    //
+    if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
+        {
+        if (!task->IsSupported(KMPXMediaArrayContents))
+            {
+            User::Leave(KErrArgument);
+            }
+
+        CMPXMediaArray* ary = task->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        User::LeaveIfNull(ary);
+        TInt step( iActiveTask->GetStep() );
+        DoAddItemL( *ary->AtL(step), msgArray );
+
+        if (++step == ary->Count())
+            {
+            done = ETrue;
+            }
+        }
+    else // type == EMPXItem
+        {
+        TUint32 item = DoAddItemL( *task, msgArray );
+        iActiveTask->GetCommand().SetTObjectValueL<TMPXItemId>( KMPXCommandColAddRtnId, item);
+        done = ETrue;
+        }
+
+    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+    return done;
+    }
+
+// ----------------------------------------------------------------------------
+// Add an item to the collection
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlugin::DoAddL(
+    const CMPXMedia& aMedia)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAddL");
+
+    if (!aMedia.IsSupported(KMPXMediaGeneralType))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TUint32 itemId(0);
+    CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL();
+    CleanupStack::PushL(changeMsgAry);
+
+	// start a transaction here
+	if (!iDbHandler->InTransaction())
+		{
+		iDbHandler->BeginTransactionL();
+		}
+
+    // Group of items
+    if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
+        {
+        CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        User::LeaveIfNull( array );
+
+        TInt count(array->Count());
+        for (TInt i = 0; i < count; ++i)
+            {
+            // ETrue indicates we are batch committing the songs.
+            // This parameter is only used for the use case of adding
+            // thousands of songs at a time.
+            DoAddItemL(*array->AtL(i), *changeMsgAry, ETrue);
+            }
+        }
+    else // single item
+        {
+        itemId = DoAddItemL(aMedia, *changeMsgAry);
+        }
+
+	// end transaction here.
+	iDbHandler->EndTransactionL(KErrNone);
+
+    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+    DoHandleChangeL(changeMsgAry);
+    CleanupStack::PopAndDestroy(changeMsgAry);
+
+    return itemId;
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Add an item to the collection
+// ----------------------------------------------------------------------------------------------------------
+//
+TUint32 CMPXDbPlugin::DoAddItemL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aMessageArray,
+    TBool aBatchCommit)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoAddItemL");
+
+    TUint32 itemId(0);
+    if (!aMedia.IsSupported(KMPXMediaGeneralCategory))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    switch (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory))
+        {
+        case EMPXPlaylist:
+            {
+            if (!aMedia.IsSupported(KMPXMediaArrayContents))
+                {
+                User::Leave(KErrArgument);
+                }
+
+            if (aMedia.IsSupported(KMPXMediaGeneralId))
+                {
+                itemId = iDbHandler->AddSongToPlaylistL(aMedia);
+                MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemModified,
+                    EMPXPlaylist, KDBPluginUid);
+                }
+            else if (aMedia.IsSupported(KMPXMediaGeneralUri))
+                {
+                itemId = iDbHandler->AddPlaylistL(aMedia);
+                MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, EBrowsePlaylist, EMPXItemInserted,
+                    EMPXPlaylist, KDBPluginUid);
+                }
+            else
+                {
+                User::Leave(KErrArgument);
+                }
+            }
+            break;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+       case EMPXAbstractAlbum:
+            {
+            if (aMedia.IsSupported(KMPXMediaGeneralUri))
+                { 
+                   
+                itemId = iDbHandler->AddAbstractAlbumL(aMedia, &aMessageArray);
+            
+                if ( aMedia.IsSupported(KMPXMediaArrayContents))
+                    {
+                    //need to update songs information to music table           
+                    CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);                        
+                    if (array->Count())            
+                        {                  
+                        iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray);
+                        }
+                    }
+                }
+            else
+                {
+                User::Leave(KErrArgument);
+                }
+            }
+            break;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXSong:
+            {
+            // For the use case of adding thousands of songs at once,
+            // we do not create a new database transaction for each song; 
+            // Instead DoAddL() will batch 100 songs under a single transaction.
+            // This enhancement improves performance with MMC-based databases.
+            if (aBatchCommit)
+                {
+                itemId = iDbHandler->AddSongWithNoTransactionL(aMedia, &aMessageArray);
+                }
+            else
+                {
+                itemId = iDbHandler->AddSongL(aMedia, &aMessageArray);
+                }
+            
+            MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemInserted,
+                EMPXSong, KDBPluginUid);
+            }
+            break;
+
+        default:
+            {
+            User::Leave(KErrNotSupported);
+            }
+        }
+
+    return itemId;
+    }
+
+// ----------------------------------------------------------------------------
+// Update the collection from a media
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoSetL(
+    const CMPXMedia& aMedia )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoSetL");
+
+    if (!aMedia.IsSupported(KMPXMediaGeneralType))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+
+    CMPXMessageArray* changeMsgArray = CMPXMessageArray::NewL();
+    CleanupStack::PushL(changeMsgArray);
+
+    if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
+        {
+        if (!aMedia.IsSupported(KMPXMediaArrayContents))
+            {
+            User::Leave(KErrArgument);
+            }
+
+        CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        User::LeaveIfNull( array );
+        TInt count( array->Count() );
+        for (TInt i = 0; i < count; ++i)
+            {
+            visibleChange = (CMPXDbActiveTask::TChangeVisibility)(visibleChange | DoSetItemL(*array->AtL(i), *changeMsgArray));
+            }
+        }
+    else
+        {
+        visibleChange = DoSetItemL(aMedia, *changeMsgArray);
+        }
+
+    // Handle Change Events
+    if (visibleChange)
+        {
+        iActiveTask->SetVisibleChange(visibleChange);
+        DoHandleChangeL(changeMsgArray);
+        }
+    CleanupStack::PopAndDestroy(changeMsgArray);
+    }
+
+// ----------------------------------------------------------------------------
+// Execute a task step for async set
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbPlugin::DoSetAsyncL()
+    {
+    MPX_FUNC("CMPXDbPlugin::DoSetAsyncL");
+
+    TBool done(EFalse);
+    CMPXMedia* task = iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColSetMedia);
+    User::LeaveIfNull( task );
+
+    CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages();
+    CMPXDbActiveTask::TChangeVisibility visibleChange(iActiveTask->GetVisibleChange());
+
+    // Multiple steps can be in a transaction for faster response
+    if( !iDbHandler->InTransaction() )
+        {
+        iDbHandler->BeginTransactionL();
+        }
+
+    if (!task->IsSupported(KMPXMediaGeneralType))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
+        {
+        if (!task->IsSupported(KMPXMediaArrayContents))
+            {
+            User::Leave(KErrArgument);
+            }
+
+        // Multiple items
+        CMPXMediaArray* array = task->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        User::LeaveIfNull( array );
+        TInt step = iActiveTask->GetStep();
+        visibleChange = (CMPXDbActiveTask::TChangeVisibility)(visibleChange | DoSetItemL(*array->AtL(step), msgArray));
+
+        if (++step == array->Count())
+            {
+            done = ETrue;
+            }
+        }
+    else // Single item
+        {
+        visibleChange = DoSetItemL(*task, msgArray);
+        done = ETrue;
+        }
+    iActiveTask->SetVisibleChange(visibleChange);
+    return done;
+    }
+
+// ----------------------------------------------------------------------------
+// Update the collection from a media
+// ----------------------------------------------------------------------------
+//
+CMPXDbActiveTask::TChangeVisibility CMPXDbPlugin::DoSetItemL(
+    const CMPXMedia& aMedia,
+    CMPXMessageArray& aMessageArray )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoSetItemL");
+
+    TMPXGeneralCategory category = aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
+
+    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
+    switch (category)
+        {
+        case EMPXPlaylist:
+            {
+            if (aMedia.IsSupported(KMPXMediaArrayContents))
+                {
+                CMPXMessage* message = CMPXMedia::NewL();
+                CleanupStack::PushL(message);
+
+                iDbHandler->UpdatePlaylistSongsL(aMedia, *message);
+
+                aMessageArray.AppendL(message); // ownership xfer
+                CleanupStack::Pop(message);
+                }
+            else
+                {
+                iDbHandler->UpdatePlaylistL(aMedia, aMessageArray);
+                }
+
+            visibleChange = CMPXDbActiveTask::ESingleVisible;
+            }
+            break;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXAbstractAlbum:
+            {
+            visibleChange = iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray);
+            }
+            break;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXSong:
+            {
+            // a list of changed messages as a result of the song being updated
+            visibleChange = iDbHandler->UpdateSongL(aMedia, aMessageArray);
+            }
+            break;
+
+        default:
+            {
+            User::Leave(KErrNotSupported);
+            }
+            break;
+        }
+    return visibleChange; // ownership xfer
+    }
+
+// ----------------------------------------------------------------------------
+// Sets the drm properties for a list of medias
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoSetDrmForArrayL(
+    const CMPXMediaArray& mediaArray,
+    const TArray<TMPXAttribute>& aAttrs)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoSetDrmForArrayL");
+
+    TUint drmAttributes(0);
+
+    // Compact the attribute set
+    //
+    TInt attrCount(aAttrs.Count());
+    for (TInt i = 0; i < attrCount; ++i)
+        {
+        if (aAttrs[i].ContentId() == KMPXMediaIdDrm)
+            {
+            drmAttributes |= aAttrs[i].AttributeId();
+            }
+        }
+
+    // Fetch drm attributes for every item
+    //
+    if (drmAttributes)
+        {
+        TInt count(mediaArray.Count());
+        for (TInt i = 0; i < count; ++i)
+            {
+            if (mediaArray[i]->IsSupported(KMPXMediaGeneralUri))
+                {
+                DoSetMediaDrmL(*mediaArray[i], drmAttributes,
+                    mediaArray[i]->ValueText(KMPXMediaGeneralUri));
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Handle change events
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::HandleChangeL(
+    const CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbPlugin::HandleChange");
+
+    // check if message is filled
+    if (aMessage.IsSupported(KMPXMessageGeneralId))
+        {
+#if _DEBUG
+        PrintMessagesL(aMessage);
+#endif // _DEBUG
+        if(iRefreshing)
+            {
+            if (aMessage.IsSupported(KMPXMessageArrayContents))
+                {
+                const CMPXMessageArray* messageArray = aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents);
+                if(messageArray)
+                    {
+                    CMPXMessage& message = *((*messageArray)[0]);
+                    TMPXChangeEventType changeType( message.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
+                    TMPXGeneralCategory cat(message.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
+                    if(changeType == EMPXItemInserted && (cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast))
+                        {
+                        iObs->HandleMessage(aMessage);
+                        }
+                    }
+                }
+            else
+                {
+                TMPXChangeEventType changeType( aMessage.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
+                TMPXGeneralCategory cat(aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
+                if(changeType == EMPXItemInserted && (cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast))
+                    {
+                    iObs->HandleMessage(aMessage);
+                    }
+                }
+            }
+        else
+            {
+            if(!iMtpInUse)
+                {
+                iObs->HandleMessage(aMessage);
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Construct a CMPXMedia and call HandleChange
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoHandleChangeL(
+    CMPXMessageArray* aItemChangedMessages,
+    TMPXCommandId aCommandId )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoHandleChangeL");
+
+    if( (iActiveTask->GetVisibleChange() & CMPXDbActiveTask::EAllVisible)
+        && (aCommandId == KMPXCommandIdCollectionSet ||
+            aCommandId == KMPXCommandIdCollectionAdd ||
+            aCommandId == KMPXCommandIdCollectionRemove ||
+            aCommandId == KMPXCommandIdCollectionCompleteDelete ))
+        {
+        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, EBrowseAll,
+                                                 EMPXItemModified, EMPXCollection, KDBPluginUid);
+        }
+    // group change messages and send to collection client context
+    //
+    CMPXMessage* message = CMPXMessage::NewL();
+    CleanupStack::PushL(message);
+
+    message->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KMPXMessageIdItemChanged);
+    message->SetCObjectValueL(KMPXMessageArrayContents, aItemChangedMessages);
+    message->SetTObjectValueL<TInt>(KMPXMessageArrayCount, aItemChangedMessages->Count());
+
+    HandleChangeL(*message);
+
+    CleanupStack::PopAndDestroy(message);
+    }
+
+// ----------------------------------------------------------------------------
+// Handle completion of operation
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoHandleOperationCompletedL(
+    TInt aErr)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoHandleOperationCompletedL");
+
+    // Broadcase change messages
+    //
+    if (iActiveTask->GetVisibleChange())
+        {
+        DoHandleChangeL(&iActiveTask->GetChangeMessages(), iActiveTask->GetTask() );
+        }
+
+    // Callback to engine to signal completion
+    // NOTE: Collection server immediately completes the async message when
+    // Cancel is called, no need to callback to observer
+    if (aErr != KErrCancel)
+        {
+        if( iActiveTask->GetTask() == KMPXCommandIdCollectionAdd )
+            {
+            iObs->HandleCommandComplete( &iActiveTask->GetCommand(), aErr );
+            }
+        else
+            {
+            iObs->HandleCommandComplete(NULL, aErr);
+            }
+        }
+
+    if( iDbHandler->InTransaction() )
+        {
+        // Commit if cancelled
+        TInt err(aErr);
+        if( err == KErrCancel )
+            {
+            err = KErrNone;
+            }
+        iDbHandler->EndTransactionL( err );
+        }
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Complete a delete operation
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoHandleDeleteCompleteL(
+    CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoHandleDeleteCompleteL");
+    iFirstDeleteStep = ETrue;
+    iSelections.Reset();
+    if ( iDbHandler->InTransaction() )
+        {
+        // if it can reach this point in a transaction, there's no error
+        iDbHandler->EndTransactionL( KErrNone );
+        }
+
+    // Change messages
+    if (aCmd.IsSupported(KMPXCommandCollectionDeleteMsgArray))
+        {
+        CMPXMessageArray* msgs = aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionDeleteMsgArray);
+        User::LeaveIfNull( msgs );
+        iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
+        DoHandleChangeL(msgs, KMPXCommandIdCollectionCompleteDelete);
+        }
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Reorder a song in a playlist
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoReorderPlaylistL(
+    const CMPXCommand& aCmd)
+    {
+    MPX_FUNC("CMPXDbPlugin::DoReorderPlaylistL");
+
+    if (!aCmd.IsSupported(KMPXCommandReorderPlaylistId) ||
+        !aCmd.IsSupported(KMPXCommandReorderSongId) ||
+        !aCmd.IsSupported(KMPXCommandReorderOriginalOrdinal) ||
+        !aCmd.IsSupported(KMPXCommandReorderNewOrdinal))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    CMPXMessage* message = CMPXMedia::NewL();
+    CleanupStack::PushL(message);
+
+    iDbHandler->ReorderPlaylistL(
+        aCmd.ValueTObjectL<TMPXItemId>(KMPXCommandReorderPlaylistId),
+        aCmd.ValueTObjectL<TMPXItemId>(KMPXCommandReorderSongId),
+        aCmd.ValueTObjectL<TUint>(KMPXCommandReorderOriginalOrdinal),
+        aCmd.ValueTObjectL<TUint>(KMPXCommandReorderNewOrdinal),
+        *message);
+
+    HandleChangeL(*message);
+
+    CleanupStack::PopAndDestroy(message);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Get total songs and playlists count for a database
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoGetCollectionCountL( const CMPXCommand& aCmd )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoGetCollectionCountL");
+    if (!aCmd.IsSupported(KMPXCommandCollectionCountDrive) ||
+        !aCmd.IsSupported(KMPXCommandCollectionCountTable) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TInt count = 0;
+    TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionCountDrive);
+    TInt table = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionCountTable);
+    switch(table)
+        {
+        case EMPXCollectionCountTrack:
+            count = (TInt)iDbHandler->GetMusicCountL(drive);
+            break;
+        case EMPXCollectionCountPlaylist:
+            count = (TInt)iDbHandler->GetPlaylistCountL(drive);
+            break;
+        case EMPXCollectionCountTotal:
+            count = (TInt)iDbHandler->GetTotalCountL(drive);
+            break;
+        default:
+            User::Leave(KErrArgument);
+        }
+    ((CMPXMedia&)aCmd).SetTObjectValueL<TInt>(KMPXCommandCollectionCountValue, count);
+    }
+
+// ----------------------------------------------------------------------------------------------------------
+// Get URIs for all songs and file playlists in a database
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoGetCollectionUriL( const CMPXCommand& aCmd )
+    {
+    MPX_FUNC("CMPXDbPlugin::DoGetCollectionCountL");
+    if (!aCmd.IsSupported(KMPXCommandCollectionURIDrive) ||
+        !aCmd.IsSupported(KMPXCommandCollectionURITable) ||
+        !aCmd.IsSupported(KMPXCommandCollectionURIFromID) ||
+        !aCmd.IsSupported(KMPXCommandCollectionURIRecords) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIDrive);
+    TInt table = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURITable);
+    TInt fromID = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIFromID);
+    TInt recnum = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIRecords);
+
+    CDesCArray* uris = new(ELeave) CDesCArrayFlat(4);
+    CleanupStack::PushL(uris);
+    TInt lastID = 0;
+
+    switch(table)
+        {
+        case EMPXCollectionURITrack:
+            iDbHandler->GetMusicUriArrayL(drive, fromID, recnum, *uris, lastID);
+            break;
+        case EMPXCollectionURIPlaylist:
+            iDbHandler->GetPlaylistUriArrayL(drive, fromID, recnum, *uris, lastID);
+            break;
+        default:
+            User::Leave(KErrArgument);
+        }
+
+    ((CMPXMedia&)aCmd).SetNoNewLCObjectL(KMPXCommandCollectionURIList, uris);
+    ((CMPXMedia&)aCmd).SetTObjectValueL(KMPXCommandCollectionURILastID, lastID);
+    CleanupStack::PopAndDestroy(uris);
+    }
+
+
+// ----------------------------------------------------------------------------------------------------------
+// Perform one step of the incremental operation
+// ----------------------------------------------------------------------------------------------------------
+//
+void CMPXDbPlugin::DoIncrementalOpenL( const CMPXCommand& aCmd )
+    {
+    MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL <--");
+
+    TInt offset = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLOffset );
+    TInt numItems = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLNumItems );
+
+    TReadDirection direction(EReadUnknown);
+    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 );
+
+    // Switch on level and item selected
+    //
+    TInt levels( path->Levels() );
+    switch( levels )
+        {
+        case 3:  // levels of 3 top level is not stripped
+            {
+            switch( path->Id(1).iId2 )
+                {
+                case EBrowseAll:
+                    {
+                    CMPXMedia* results = CMPXMedia::NewL();
+                    CleanupStack::PushL( results );
+
+                    TMPXOpenDataBlock block;
+                    block.iOffset = offset;
+                    block.iSize = numItems;
+
+                    // Todo: this should come from the UI
+                    RArray<TMPXAttribute> attrs;
+                    CleanupClosePushL( attrs );
+                    attrs.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
+                                   EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
+                                   EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri));
+                    attrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+                                        EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
+
+                    // Array to read data from
+                    CMPXMediaArray* array = CMPXMediaArray::NewL();
+                    CleanupStack::PushL( array );
+
+                    // Do we have to use offset or can we use asc/dsc
+                    //
+                    if( direction == EReadUnknown )
+                        {
+                        iDbHandler->GetSongsAtOffsetL( array, attrs.Array(), offset, numItems );
+                        }
+                    else
+                        {
+                        iDbHandler->GetSongsInBlockL( array, attrs.Array(),
+                                                      aCmd.ValueText( KMPXCollectionCommandIdIncOpenLKeyItem ),
+                                                      numItems,
+                                                      direction );
+                        }
+
+                    TInt max( path->Count() );
+                    TInt count(0);
+                    TInt aryCount( array->Count() );
+                    // Update the collection path
+                    while( count<numItems && offset<max &&
+                           count<aryCount )
+                        {
+                        TMPXItemId id = array->AtL(count)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
+                        path->Update( offset, id );
+
+                        // Next items
+                        offset++;
+                        count++;
+                        }
+
+                    // Setup the results
+                    //
+                    results->SetCObjectValueL(KMPXMediaArrayContents, array);
+                    results->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
+                    CleanupStack::PopAndDestroy( array );
+                    CleanupStack::PopAndDestroy( &attrs );
+
+                    // Callback with results
+                    //
+                    results->SetTObjectValueL<TMPXOpenDataBlock>( KMPXCollectionOpenLResultRange, block );
+                    iObs->HandleOpen( results, path, KErrNone );
+                    CleanupStack::PopAndDestroy( results );
+                    break;
+                    }
+                default:
+                    User::Leave(KErrNotSupported);
+                    break;
+                }
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrNotSupported);
+            break;
+            }
+
+        }
+    CleanupStack::PopAndDestroy( path );
+
+    MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL -->");
+    }
+
+// ----------------------------------------------------------------------------
+// Maps a given browse type to a category ID.
+// ----------------------------------------------------------------------------
+//
+TMPXGeneralCategory CMPXDbPlugin::CategoryForBrowseType(
+    TMCBrowseType aBrowseType)
+    {
+    MPX_FUNC("CMPXDbPlugin::CategoryForBrowseType");
+
+    TMPXGeneralCategory cat(EMPXNoCategory);
+
+    switch (aBrowseType)
+        {
+        case EBrowseAll:
+            {
+            cat = EMPXSong;
+            break;
+            }
+        case EBrowseArtist:
+            {
+            cat = EMPXArtist;
+            break;
+            }
+        case EBrowseAlbum:
+            {
+            cat = EMPXAlbum;
+            break;
+            }
+        case EBrowsePlaylist:
+            {
+            cat = EMPXPlaylist;
+            break;
+            }
+        case EBrowseGenre:
+            {
+            cat = EMPXGenre;
+            break;
+            }
+        case EBrowseComposer:
+            {
+            cat = EMPXComposer;
+            break;
+            }
+#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
+        case EBrowsePodcasts:
+            {
+            cat = EMPXPodcast;
+            break;
+            }
+#endif
+        default:
+            {
+            // do nothing
+            break;
+            }
+        }
+
+    return cat;
+    }
+
+// ----------------------------------------------------------------------------
+// Maps a given category ID to a browse type.
+// ----------------------------------------------------------------------------
+//
+TMCBrowseType CMPXDbPlugin::BrowseTypeForCategory(
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("CMPXDbPlugin::BrowseTypeForCategory");
+
+    TMCBrowseType browseType(EBrowseComposer);
+
+    switch (aCategory)
+        {
+        case EMPXSong:
+            {
+            browseType = EBrowseAll;
+            break;
+            }
+        case EMPXArtist:
+            {
+            browseType = EBrowseArtist;
+            break;
+            }
+        case EMPXAlbum:
+            {
+            browseType = EBrowseAlbum;
+            break;
+            }
+        case EMPXPlaylist:
+            {
+            browseType = EBrowsePlaylist;
+            break;
+            }
+        case EMPXGenre:
+            {
+            browseType = EBrowseGenre;
+            break;
+            }
+        default:
+            {
+            // do nothing
+            break;
+            }
+        }
+
+    return browseType;
+    }
+
+// ----------------------------------------------------------------------------
+// Sets the type, category and title attributes in the specified media instance
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::SetMediaGeneralAttributesL(
+    CMPXMedia& aMedia,
+    TMPXGeneralType aType,
+    TMPXGeneralCategory aCategory,
+    const TDesC& aTitle)
+    {
+    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, aType);
+    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, aCategory);
+    aMedia.SetTextValueL(KMPXMediaGeneralTitle, aTitle);
+    }
+
+// ----------------------------------------------------------------------------
+// Sets the type, category and title attributes in the specified media instance
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::SetMediaGeneralAttributesL(
+    CMPXMedia& aMedia,
+    TMPXGeneralType aType,
+    TMPXGeneralCategory aCategory,
+    TInt aId)
+    {
+    MPX_FUNC("CMPXDbPlugin::SetMediaGeneralAttributesL");
+
+    HBufC* title = iDbHandler->GetNameMatchingIdL(aId);
+    CleanupStack::PushL(title);
+    SetMediaGeneralAttributesL(aMedia, aType, aCategory, *title);
+    CleanupStack::PopAndDestroy(title);
+    }
+
+// ----------------------------------------------------------------------------
+// Set the attribute list according to current path
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::SetAttributesL(
+    const CMPXCollectionPath& aPath,
+    RArray<TMPXAttribute>& aAttrs,
+    RArray<TInt>& aSupportedIds )
+    {
+    aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
+        EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
+        EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri) );
+
+    aSupportedIds.AppendL(KMPXMediaIdContainer);
+    aSupportedIds.AppendL(KMPXMediaIdGeneral);
+
+    TInt levels(aPath.Levels());
+    if ( 2 == levels )
+        {
+        // check the browse type
+        switch ( aPath.Id(1).iId2 )
+            {
+            case EBrowseAll:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
+                aSupportedIds.AppendL( KMPXMediaIdMusic );
+                break;
+                }
+            case EBrowseArtist:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+                                    EMPXMediaMusicAlbumArtFileName ) );
+                break;
+                }
+            case EBrowseAlbum:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+                    EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
+                aSupportedIds.AppendL( KMPXMediaIdMusic );
+                break;
+                }
+            case EBrowsePlaylist:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
+                    EMPXMediaGeneralCount | EMPXMediaGeneralDuration ) );
+                break;
+                }
+            case EBrowseGenre:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
+                break;
+                }
+            case EBrowseComposer:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
+                break;
+                }
+            default:
+                {
+                User::Leave(KErrArgument);
+                }
+            }
+        }
+    else if ( 3 == levels )
+        {
+        // check the browse type
+        switch ( aPath.Id(1).iId2 )
+            {
+            case EBrowseArtist:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) );
+                aSupportedIds.AppendL( KMPXMediaIdMusic );
+                break;
+                }
+            case EBrowseAlbum:
+                {
+
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+                    EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
+                aSupportedIds.AppendL( KMPXMediaIdMusic );
+                break;
+                }
+            case EBrowsePlaylist:
+            case EBrowseGenre:
+            case EBrowseComposer:
+                {
+                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+//                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );                    
+                //added ganes
+                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName | EMPXMediaMusicAlbum) );                    
+                aSupportedIds.AppendL( KMPXMediaIdMusic );
+                break;
+                }
+            }
+        }
+    else if ( (4 == levels) && (aPath.Id(1).iId2 == EBrowseArtist) )
+        {
+        aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
+            EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
+        aSupportedIds.AppendL( KMPXMediaIdMusic );
+        }
+    }
+
+#ifdef _DEBUG
+// ----------------------------------------------------------------------------
+// Print change events
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::PrintMessagesL(
+    const CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbPlugin::PrintMessages");
+
+    if (aMessage.IsSupported(KMPXMessageArrayContents))
+        {
+        const CMPXMessageArray* messageArray =
+            aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents);
+        if( !messageArray )
+            {
+            User::Leave( KErrNoMemory );
+            }
+
+        TInt count(messageArray->Count());
+        MPX_DEBUG2("%d messages:", count);
+
+        for (TInt i = 0; i < count; ++i)
+            {
+            PrintMessage(*((*messageArray)[i]));
+            }
+        }
+    else
+        {
+        PrintMessage(aMessage);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// Print one change event
+// ----------------------------------------------------------------------------
+//
+void CMPXDbPlugin::PrintMessage(
+    const CMPXMessage& aMessage)
+    {
+    MPX_FUNC("CMPXDbPlugin::PrintMessage");
+
+    if (aMessage.IsSupported(KMPXMessageGeneralId))
+        {
+        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageGeneralId);
+        MPX_DEBUG3("    message id[0x%x, 0x%x]", id.iId1, id.iId2);
+        }
+
+    if (aMessage.IsSupported(KMPXMessageCollectionId))
+        {
+        TUid uid = aMessage.ValueTObjectL<TUid>(KMPXMessageCollectionId);
+        MPX_DEBUG2("    uid [0x%x]", uid.iUid);
+        }
+
+    if (aMessage.IsSupported(KMPXMessageChangeEventType))
+        {
+        MPX_DEBUG2("    change event type [%d]",
+            aMessage.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType));
+        }
+
+    if (aMessage.IsSupported(KMPXMessageMediaGeneralCategory))
+        {
+        MPX_DEBUG2("    category [%d]",
+            aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
+        }
+
+    if (aMessage.IsSupported(KMPXMessageMediaGeneralId))
+        {
+        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId);
+        MPX_DEBUG3("    media id[0x%x, 0x%x]", id.iId1, id.iId2);
+        }
+
+    if (aMessage.IsSupported(KMPXMessageMediaDeprecatedId))
+        {
+        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaDeprecatedId);
+        MPX_DEBUG3("    deprecated id [0x%x, 0x%x]", id.iId1, id.iId2);
+        }
+    }
+
+#endif// _DEBUG
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbpluginproxy.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Standard proxy of the ECOM plugin
+*
+*/
+
+
+#include <implementationproxy.h>
+#include "mpxdbplugin.h"
+
+#if (!defined IMPLEMENTATION_PROXY_ENTRY)
+typedef TAny* TProxyNewLPtr;
+#define IMPLEMENTATION_PROXY_ENTRY(aUid,aFuncPtr) {{aUid},(TProxyNewLPtr)(aFuncPtr)}
+#endif
+
+// ----------------------------------------------------------------------------
+// The list of implementations
+// ----------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    { IMPLEMENTATION_PROXY_ENTRY(0x101FFC3A, CMPXDbPlugin::NewL) };
+
+// ----------------------------------------------------------------------------
+// The proxy of implementations
+// ----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount=sizeof(ImplementationTable)/sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbutil.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains utility functions for the DB plugin
+*
+*/
+
+
+// INCLUDE FILES
+#include <mpxlog.h>
+
+#include "mpxcollectiondbdef.h"
+#include "mpxdbutil.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// Filter out duplicated Ids
+// ----------------------------------------------------------------------------
+//
+void MPXDbUtil::FilterDuplicatedIdsL(
+    const TArray<TUint32>& aIds,
+    RArray<TUint32>& aFilteredIds)
+    {
+    MPX_FUNC("MPXDbUtil::FilterDuplicatedIdsL");
+
+    TInt count(aIds.Count());
+    for (TInt i = 0; i < count; ++i)
+        {
+        MPX_TRAPD(error, aFilteredIds.InsertInUnsignedKeyOrderL(aIds[i]));
+        if ((error != KErrNone) && (error != KErrAlreadyExists))
+            {
+            User::Leave(error);
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// MPXDbUtil::TableNameForCategoryL
+// ----------------------------------------------------------------------------
+//
+TPtrC MPXDbUtil::TableNameForCategoryL(
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("MPXDbUtil::TableNameForCategoryL");
+
+    TPtrC ptr;
+    switch (aCategory)
+        {
+        case EMPXPlaylist:
+            ptr.Set(KMCPlaylistTable);
+            break;
+        case EMPXArtist:
+            ptr.Set(KMCArtistTable);
+            break;
+        case EMPXAlbum:
+            ptr.Set(KMCAlbumTable);
+            break;
+        case EMPXGenre:
+            ptr.Set(KMCGenreTable);
+            break;
+        case EMPXComposer:
+            ptr.Set(KMCComposerTable);
+            break;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXAbstractAlbum:
+            ptr.Set(KMCAbstractAlbumTable);
+            break;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    return ptr;
+    }
+
+// ----------------------------------------------------------------------------
+// MPXDbUtil::MusicFieldNameForCategoryL
+// ----------------------------------------------------------------------------
+//
+TPtrC MPXDbUtil::MusicFieldNameForCategoryL(
+    TMPXGeneralCategory aCategory)
+    {
+    MPX_FUNC("MPXDbUtil::MusicFieldNameForCategoryL");
+
+    TPtrC ptr;
+    switch (aCategory)
+        {
+        case EMPXArtist:
+            ptr.Set(KMCMusicArtist);
+            break;
+        case EMPXAlbum:
+            ptr.Set(KMCMusicAlbum);
+            break;
+        case EMPXGenre:
+            ptr.Set(KMCMusicGenre);
+            break;
+        case EMPXComposer:
+            ptr.Set(KMCMusicComposer);
+            break;
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+        case EMPXAbstractAlbum:
+            ptr.Set(KMCMusicAbstractAlbum);
+            break;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+        default:
+            User::Leave(KErrNotSupported);
+        }
+
+    return ptr;
+    }
+
+// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/data/101FFC3E.RSS	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Resource file
-*
-*/
-
-
-#include <ecom/registryinfo.rh>
-#include <mpxcollectionplugin.hrh>
-#include "mpxpluginresource.hrh"
-
-/**
- * The opaque_data syntax is made up of three parts: 
- * a list of Uids for resolving the view plugin, feature flags, priority.
- * 
- * <p>uid1;uid2;uid3</p>
- *  uid*: Supported plugin types.
- *  E.g. if podcast plugin may support music plugin as well, KMPXColPluginMusic
- *
- * <t>uid</t>
- *  uid: plugin type uid.
- *  E.g. for music plugin will be: 0x101FFCDA
- *
- * <f>flags</f> [optional]
- *  flags: sum of the required feature flags
- *         Collection specific flags include:
- *                EMPXCollectionPluginFlagCacheable - Are media results cachable in the collection cache
- *         General flags include: 
- *                EMPXPluginFlagPreLoad - Should the plugin be pre loaded when the collection starts
- *                
- *
- * <i>priority</i> [optional]
- *  priority: a value of type TMPXCollectionPluginPriorities. This value determines
- *  the returning order when several plugins can support the same set of Uids. 
- *  Default value of this field is EMPXCollectionPluginPriorityNormal.
- *
- * <c>non-cacheable attributes</c> optional
- *  List of content IDs that cannot be cached in the collection cache.
- *  The list is a list of hexidecimal numbers, semicolon seperated
- *  For example, <c>0x101FFC45</c> not cache media objects w/ drm attributes
- *
- */
-
-RESOURCE REGISTRY_INFO theInfo
-    {
-    dll_uid = 0x101FFC3E;
-
-    interfaces = 
-        {
-        INTERFACE_INFO
-            {
-            interface_uid = KMPXCollectionPluginInterfaceUid;
-            implementations = 
-                {
-                IMPLEMENTATION_INFO
-                    {
-                    implementation_uid = 0x101FFC3A;
-                    version_no = 1;
-                    display_name = "";
-                    default_data = "audio/mp3;audio/x-mp3;audio/mp4;audio/3gpp;audio/3gpp2;audio/wav;audio/x-wav;audio/x-au;audio/au;audio/3gp;audio/mpeg;audio/aac;audio/x-ms-wma;x-caf-audio/x-ms-wma;audio/x-pn-realaudio;audio/x-realaudio;audio/vnd.rn-realaudio";
-                    opaque_data = "<s>*<e>.mp3;.aac;.3gp;.3gpp;.3g2;.3gpp2;.m4a;.wav;.mp4;.wma;.dcf;.odf;.asf;.m3u;.rm;.ra;.o4a;.dm;.3ga"
-                                  "<t>"EMPXCollectionPluginMusic"</t>"
-                                  "<i>"EMPXPluginPriorityNormal"</i>"
-                                  "<c>"EDRMContentId"</c>" // DRM
-                                  "<f>"EPreloadAndCache"</f>";
-                    }
-                };
-            }
-        };
-    }
-
-// End of file
--- a/mpserviceplugins/mpxsqlitedbplugin/data/mpxcollectiondbres.rss	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,292 +0,0 @@
-/*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This file contains all the resources for the Music Collection
-*
-*/
-
-
-//  INCLUDES
-#include <bldvariant.hrh>
-#include <badef.rh>
-#include <pathconfiguration.hrh>
-#include "mpxcollectiondb.hrh"
-
-
-STRUCT MENU_ITEM
-    {
-    LONG   id;
-    STRUCT name;
-    }
-
-STRUCT MENU_ITEM_ARRAY
-    {
-    STRUCT array_of_menu_items[];
-    }
-
-//  RESOURCE IDENTIFIER
-NAME    OAMC // 4 letter ID
-
-//  RESOURCE DEFINITIONS
-
-RESOURCE BA_RSS_SIGNATURE { }
-
-//----------------------------------------------------
-//
-//    r_mc_music_library_menu_items
-//    Menu items to be displayed in the music library view
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_ITEM_ARRAY r_mc_menu_items_array
-    {
-    array_of_menu_items =
-        {
-        MENU_ITEM {id = EBrowseAll;      name = LBUF {txt = qtn_mus_all_tracks;};},
-        MENU_ITEM {id = EBrowsePlaylist; name = LBUF {txt = qtn_mus_playlists;};},
-        MENU_ITEM {id = EBrowseArtist;   name = LBUF {txt = qtn_mus_artists;};},
-        MENU_ITEM {id = EBrowseAlbum;    name = LBUF {txt = qtn_mus_albums;};},
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU        
-        MENU_ITEM {id = EBrowsePodcasts; name = LBUF {txt = qtn_mus_podcasts;};},
-#endif
-        MENU_ITEM {id = EBrowseGenre;    name = LBUF {txt = qtn_mus_genres;};},
-        MENU_ITEM {id = EBrowseComposer; name = LBUF {txt = qtn_mus_composers;};}        
-        };
-    }
-
-RESOURCE TBUF { buf="MPXCOLLECTIONDBRES"; }
-
-//----------------------------------------------------
-//
-//    r_mc_music_library_title_items
-//    titles to be displayed in the music player
-//
-//    added album for ganes
-//----------------------------------------------------
-//
-RESOURCE MENU_ITEM_ARRAY r_mc_title_items_array
-    {
-    array_of_menu_items =
-        {
-        MENU_ITEM {id = EBrowseAll;      name = LBUF {txt = qtn_mus_title_all_tracks;};},
-        MENU_ITEM {id = EBrowsePlaylist; name = LBUF {txt = qtn_mus_title_pls;};},
-        MENU_ITEM {id = EBrowseArtist;   name = LBUF {txt = qtn_mus_title_artists;};},
-        MENU_ITEM {id = EBrowseAlbum;    name = LBUF {txt = qtn_mus_title_albums;};},
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU                
-        MENU_ITEM {id = EBrowsePodcasts; name = LBUF {txt = qtn_mus_podcasts;};},
-#endif        
-        MENU_ITEM {id = EBrowseGenre;    name = LBUF {txt = qtn_mus_title_genres;};},
-        MENU_ITEM {id = EBrowseComposer; name = LBUF {txt = qtn_mus_title_composers;};},     
-        MENU_ITEM {id = EBrowseAlbumSong;    name = LBUF {txt = qtn_mus_title_album;};}
-        };
-    }
-
-
-// ** DEFAULT MUSIC FOLDER STRINGS
-
-//----------------------------------------------------
-//
-//    r_mc_default_music_folders
-//
-//----------------------------------------------------
-//
-RESOURCE ARRAY r_mc_default_music_folders
-    {
-    items =
-        {
-        LBUF {txt = text_memory_card_root_path;},
-        LBUF {txt = text_phone_memory_root_path;}
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_mc_music_file_extensions
-//    file extensions which be scanned by music collection
-//
-//----------------------------------------------------
-//
-RESOURCE ARRAY r_mc_music_file_extensions
-    {
-    items =
-        {
-#if (defined __WMA || defined __WINDOWS_MEDIA)
-        LBUF {txt = ".wma";},
-#endif
-        LBUF {txt = ".mp3";},
-        LBUF {txt = ".m4a";},
-        LBUF {txt = ".aac";}
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_mc_file_extensions_mime
-//    file extensions which can be scanned by music
-//    collection, however, these files types must be
-//    checked whether their MIME types match as well
-//    because they can be DRM or video files
-//
-//----------------------------------------------------
-//
-RESOURCE ARRAY r_mc_file_extensions_mime
-    {
-    items =
-        {
-        LBUF {txt = "";},
-#ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
-        LBUF {txt = ".ra";},
-        LBUF {txt = ".rm";},
-#endif
-        LBUF {txt = ".mp4";},
-        LBUF {txt = ".3gpp";},
-        LBUF {txt = ".3gp";},
-        LBUF {txt = ".3gpp2";},
-        LBUF {txt = ".3g2";},
-        LBUF {txt = ".3ga";},
-        LBUF {txt = ".dcf";},
-        LBUF {txt = ".dm";},
-        LBUF {txt = ".odf";}
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_mc_file_extensions_drm
-//    file extensions which can be scanned by music
-//    collection, however, these files types must be
-//    checked which type of DRM is used
-//
-//----------------------------------------------------
-//
-RESOURCE ARRAY r_mc_file_extensions_drm
-    {
-    items =
-        {
-        LBUF {txt = "";},
-        LBUF {txt = ".dcf";},
-        LBUF {txt = ".dm";},
-        LBUF {txt = ".odf";},
-        LBUF {txt = ".o4a";}
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_mc_mime_types
-//    Mime types which be scanned by music collection
-//
-//----------------------------------------------------
-//
-RESOURCE ARRAY r_mc_mime_types
-    {
-    items =
-        {
-#ifdef __WMA
-        LBUF {txt = "audio/x-ms-wma";},
-#endif
-#ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
-        LBUF {txt = "audio/x-pn-realaudio";},
-        LBUF {txt = "audio/x-realaudio";},
-        LBUF {txt = "audio/vnd.rn-realaudio";},
-//        LBUF {txt = "application/vnd.rn-realmedia";}
-#endif
-        LBUF {txt = "audio/mpeg";},
-        LBUF {txt = "audio/aac";},
-        LBUF {txt = "audio/mp3";},
-        LBUF {txt = "audio/x-mp3";},
-        LBUF {txt = "audio/mp4";},
-        LBUF {txt = "audio/3gpp";},
-        LBUF {txt = "audio/m4a";},
-        LBUF {txt = "audio/3gpp2";},
-        LBUF {txt = "audio/mpeg4";}
-        };
-    }
-
-// ** All songs for an artist
-RESOURCE LBUF r_mc_all_songs_for_artist
-    {
-    txt = qtn_nmp_all_by;
-    }
-
-// ** Recently played
-RESOURCE LBUF r_mc_recently_played_playlist
-    {
-    txt = qtn_mus_pl_recently_played;
-    }
-
-// ** Most played
-RESOURCE LBUF r_mc_most_played_playlist
-    {
-    txt = qtn_mus_pl_most_played;
-    }
-
-// ** Recently added
-RESOURCE LBUF r_mc_recently_added_playlist
-    {
-    txt = qtn_mus_pl_recently_downloaded;
-    }
-
-// ---------------------------------------------------------------------------
-// r_mpx_qtn_mus_music_num_songs
-// Number of songs text
-// ---------------------------------------------------------------------------
-//
-RESOURCE LBUF r_mpx_qtn_mus_music_num_songs
-    {
-    txt = qtn_mus_music_num_songs;
-    }
-
-// ---------------------------------------------------------------------------
-// r_mpx_qtn_mus_music_one_song
-// One song text
-// ---------------------------------------------------------------------------
-//
-RESOURCE LBUF r_mpx_qtn_mus_music_one_song
-    {
-    txt = qtn_mus_music_one_song;
-    }
-
-// ---------------------------------------------------------------------------
-// r_mpx_qtn_mus_music
-// Collection Plugin Name
-// ---------------------------------------------------------------------------
-//
-RESOURCE LBUF r_mpx_qtn_mus_music
-    {
-    txt = qtn_mus_music;
-    }
-
-// ---------------------------------------------------------------------------
-// r_mpx_qtn_mus_title_music_menu
-// Music Menu Title
-// ---------------------------------------------------------------------------
-//
-RESOURCE LBUF r_mpx_qtn_mus_title_music_menu
-    {
-    txt = qtn_mus_title_music_menu;
-    }
-
-#ifdef __ENABLE_MUSIC_TEXT_ALIGNMENT
-// ---------------------------------------------------------------------------
-// r_mpx_qtn_mp_title_my_music_menu_nseries
-// My Music Menu Title
-// ---------------------------------------------------------------------------
-//
-RESOURCE LBUF r_mpx_qtn_mp_title_my_music_menu_nseries
-    {
-    txt = qtn_mp_title_my_music_menu_nseries;
-    }
-#endif //__ENABLE_MUSIC_TEXT_ALIGNMENT
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/group/bld.inf	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Build information file for project Collection DBMS plugin.
-*
-*/
-
-
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-// ../loc/mpxcollectiondb.loc	APP_LAYER_LOC_EXPORT_PATH(mpxcollectiondb.loc)
-
-PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
-OPTION TARGETFILE mpxdbplugin.mif
-OPTION HEADERFILE mpxdbplugin.mbg
-OPTION SOURCES -c8,8 qgn_graf_mup_dlst_music
-END
-
-
-PRJ_MMPFILES
-
-mpxsqlitedbplugin.mmp
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/group/iconlist.txt	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-/c8,8 qgn_graf_mup_dlst_music
--- a/mpserviceplugins/mpxsqlitedbplugin/group/mpxdbpluginicons.mk	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#
-# Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description:  Icons makefile for project mpxdbplugin
-#
-
-
-ifeq (WINS,$(findstring WINS,$(PLATFORM)))
-ZDIR=$(EPOCROOT)epoc32/release/$(PLATFORM)/$(CFG)/z
-else
-ZDIR=$(EPOCROOT)epoc32/data/z
-endif
-
-TARGETDIR=$(ZDIR)/resource/apps
-HEADERDIR=$(EPOCROOT)epoc32/include
-ICONTARGETFILENAME=$(TARGETDIR)/mpxdbplugin.mif
-HEADERFILENAME=$(HEADERDIR)/mpxdbplugin.mbg
-
-MAKMAKE : ;
-
-BLD : ;
-
-CLEAN : ;
-
-LIB : ;
-
-CLEANLIB : ;
-
-RESOURCE : 
-	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
-		/Ficonlist.txt
-
-FREEZE : ;
-
-SAVESPACE : ;
-
-RELEASABLES :
-	@echo $(HEADERFILENAME)&& \
-	@echo $(ICONTARGETFILENAME)
-
-FINAL : ;
--- a/mpserviceplugins/mpxsqlitedbplugin/group/mpxsqlitedbplugin.mmp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Collection file db plugin project specification
-*
-*/
-
-
-#include <bldvariant.hrh>
-#include <data_caging_paths.hrh>
-#include <platform_paths.hrh>
-
-TARGET          mpxsqlitedbplugin.dll
-TARGETTYPE      PLUGIN
-UID             0x10009D8D 0x101FFC3E
-
-VENDORID        VID_DEFAULT
-CAPABILITY      CAP_ECOM_PLUGIN
-
-VERSION 15.0
-
-MACRO __ENABLE_PODCAST_IN_MUSIC_MENU
-#define __ENABLE_PODCAST_IN_MUSIC_MENU
-//MACRO RD_MPX_COLLECTION_CACHE
-
-SOURCEPATH      ../src
-SOURCE          mpxdbplugin.cpp
-SOURCE          mpxdbpluginproxy.cpp
-SOURCE          mpxdbutil.cpp
-
-SOURCE          mpxcollectiondbmanager.cpp
-
-SOURCE          mpxdbcategory.cpp
-SOURCE          mpxdbmusic.cpp
-SOURCE          mpxdbplaylist.cpp
-SOURCE          mpxdbplaylistsongs.cpp
-SOURCE          mpxdbauxiliary.cpp
-SOURCE          mpxdbautoplaylist.cpp
-SOURCE          mpxdbhandler.cpp
-SOURCE          mpxdbartist.cpp
-SOURCE          mpxdbalbum.cpp
-SOURCE          mpxdbgenre.cpp
-SOURCE          mpxdbcomposer.cpp
-
-SOURCEPATH       ../data
-START RESOURCE  mpxcollectiondbres.rss
-HEADER
-TARGETPATH      APP_RESOURCE_DIR
-LANGUAGE_IDS 
-END
-
-SOURCEPATH      ../data
-START RESOURCE  101FFC3E.RSS
-TARGET          mpxsqlitedbplugin.rsc
-END
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-
-APP_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE   /epoc32/include/ecom
-SYSTEMINCLUDE   /epoc32/include/mmf/common
-
-LIBRARY         euser.lib
-LIBRARY         ecom.lib
-LIBRARY         efsrv.lib
-LIBRARY         estor.lib
-LIBRARY         sqldb.lib
-LIBRARY         bafl.lib
-LIBRARY         apmime.lib
-LIBRARY         sysutil.lib
-#ifdef __MTP_PROTOCOL_SUPPORT
-LIBRARY         centralrepository.lib
-#endif
-#ifdef RD_MULTIPLE_DRIVE
-LIBRARY         PlatformEnv.lib
-#endif //RD_MULTIPLE_DRIVE
-
-LIBRARY         mpxsqlitedbcommon.lib
-LIBRARY         mpxcommon.lib
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondb.hrh	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This file contains declarations for constants of Music
-*                Collection. The file can be included in C++ or resource file.
-*
-*/
-
-
-
-#ifndef MPXCOLLECTIONDB_HRH
-#define MPXCOLLECTIONDB_HRH
-
-enum TMCBrowseType
-    {
-    EBrowseAll = 0,
-    EBrowsePlaylist,
-    EBrowseArtist,
-    EBrowseAlbum,
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU            
-    EBrowsePodcasts,
-#endif    
-    EBrowseGenre,
-    EBrowseComposer,        
-    EBrowseAlbumSong //added for ganes
-    };
-
-#endif      // MPXCOLLECTIONDB_HRH
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbdef.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This header file contains macro definitions used by the
-*                database subsystem.
-*
-*/
-
-#ifndef MPXCOLLECTIONDBDEF_H
-#define MPXCOLLECTIONDBDEF_H
-
-// INCLUDES
-#include <mmfmeta.h>
-
-// CONSTANTS
-
-// ================================== DATABASE ================================
-
-// Db filename
-_LIT(KMCDbFile, "mpxv2_5.db");
-
-// Collection Db resource file
-_LIT(KMPXCollectionDbResourceFile,  "mpxcollectiondbres.rsc");
-
-// == TABLE NAMES =============================================================
-// The Auxiliary table stores general database metadata
-_LIT(KMCAuxiliaryTable,             "Auxiliary");
-// The Music table stores songs information
-_LIT(KMCMusicTable,                 "Music");
-// The Playlist table stores playlists information
-_LIT(KMCPlaylistTable,              "Playlist");
-// The PlaylistSongs table stores the song instances for each playlist
-_LIT(KMCPlaylistSongsTable,         "PlaylistSongs");
-// The PlaylistSongInfo table stores the songs that are included in playlists
-_LIT(KMCPlaylistSongInfoTable,      "PlaylistSongInfo");
-// The Artist table stores artist information
-_LIT(KMCArtistTable,                "Artist");
-// The Album table stores albums information
-_LIT(KMCAlbumTable,                 "Album");
-// The Genre table stores genres information
-_LIT(KMCGenreTable,                 "Genre");
-// The Composer table stores composers information
-_LIT(KMCComposerTable,              "Composer");
-
-// == Music TABLE FIELDS ======================================================
-_LIT(KMCMusicUniqueId,          "UniqueId");
-
-// From MMF (MmfMeta.h)
-#define KMCMusicName                KMMFMetaEntrySongTitle           // "title"
-#define KMCMusicArtist              KMMFMetaEntryArtist              // "artist"
-#define KMCMusicAlbum               KMMFMetaEntryAlbum               // "album"
-#define KMCMusicTrackNumber         KMMFMetaEntryAlbumTrack          // "albumtrack"
-#define KMCMusicGenre               KMMFMetaEntryGenre               // "genre"
-#define KMCMusicComposer            KMMFMetaEntryComposer            // "composer"
-#define KMCMusicComment             KMMFMetaEntryComment             // "comment"
-#define KMCMusicCopyright           KMMFMetaEntryCopyright           // "copyright"
-#define KMCMusicOrigArtist          KMMFMetaEntryOriginalArtist      // "originalartist"
-//end of MMF support data
-
-// NOTE: Location will store the path without drive letter
-_LIT(KMCMusicLocation,              "Location");
-_LIT(KMCMusicDuration,              "Duration");
-_LIT(KMCMusicReleaseDate,           "ReleaseDate");
-_LIT(KMCMusicTimeAdded,             "TimeAdded");
-_LIT(KMCMusicPlayCount,             "PlayCount");
-_LIT(KMCMusicTimePlayed,            "TimePlayed");
-_LIT(KMCMusicRating,                "Rating");
-_LIT(KMCMusicArt,                   "Art");
-_LIT(KMCMusicDbFlag,                "DbFlag");
-_LIT(KMCMusicSync,                  "Sync");
-_LIT(KMCMusicMod,                   "Modified");
-_LIT(KMCMusicDel,                   "Deleted");
-_LIT(KMCMusicUrl,                   "Url");
-_LIT(KMCMusicDRM,                   "DRM");
-_LIT(KMCMusicLastPlayPosition,      "LastPlayPosition");
-_LIT(KMCMusicSampleRate,            "SampleRate");
-_LIT(KMCMusicBitRate,               "BitRate");
-_LIT(KMCMusicVolumeId,              "VolumeId");
-
-// Number of channels: required by MTP to support Play4sure
-_LIT(KMCMusicNumChannels,           "NumChannels");
-
-// Audio Codec: required by MTP to support Play4sure
-_LIT(KMCMusicCodec,                 "Codec");
-_LIT(KMCMusicMimeType,              "MimeType");
-_LIT(KMCMusicMTPDrmStatus,          "MTPDrmStatus");
-
-// == Category TABLE FIELDS ===================================================
-_LIT(KMCCategoryUniqueId,           "UniqueId");
-_LIT(KMCCategoryName,               "Name");
-_LIT(KMCCategorySongCount,          "SongCount");
-
-// == Playlist TABLE FIELDS ===================================================
-_LIT(KMCPlaylistUniqueId,           "UniqueId");
-_LIT(KMCPlaylistName,               "Name");
-_LIT(KMCPlaylistUri,                "Uri");
-_LIT(KMCPlaylistVolumeId,           "VolumeId");
-_LIT(KMCPlaylistSync,               "Sync");
-_LIT(KMCPlaylistDbFlag,             "DbFlag");
-_LIT(KMCPlaylistTime,               "Time");
-
-// == PlaylistSongs TABLE FIELDS ==============================================
-_LIT(KMCPlaylistSongsUniqueId,      "UniqueId");
-_LIT(KMCPlaylistSongsSongId,        "SongId");
-_LIT(KMCPlaylistSongsPlaylistId,        "PlaylistId");
-_LIT(KMCPlaylistSongsOrdinal,   "Ordinal");
-
-// == PlaylistSongInfo TABLE FIELDS ===========================================
-_LIT(KMCPlaylistSongInfoSongId,     "SongId");
-_LIT(KMCPlaylistSongInfoUri,        "Uri");
-_LIT(KMCPlaylistSongInfoTitle,      "Title");
-_LIT(KMCPlaylistSongInfoVolumeId,   "VolumeId");
-_LIT(KMCPlaylistSongInfoDbFlag,     "DbFlag");
-
-// == Auxiliary TABLE FIELDS ==================================================
-// Version of database
-// The version integer looks like:
-// 31     23      15           0 bit
-// -----------------------------
-// |Major |Minor  |Build       |
-// -----------------------------
-_LIT(KMCAuxVersion,                 "Version");
-
-// Last time db was refreshed
-_LIT(KMCAuxTimeRefresh,             "TimeRefreshed");
-
-// Last time db was synced
-_LIT(KMCAuxTimeSync,                "TimeSynced");
-
-// Database Corrupted bit
-_LIT(KMCMusicCorruptDB,             "Corrupt");
-
-// Number of records that have been marked as deleted
-_LIT(KMCSavedDeletedRecordCount,    "SaveDeletedRecordCount");
-
-#endif // MPXCOLLECTIONDBDEF_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbmanager.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for managing all of music collection
-*                databases.
-*
-*/
-
-
-#ifndef MPXCOLLECTIONDBMANAGER_H
-#define MPXCOLLECTIONDBMANAGER_H
-
-// INCLUDES
-
-#include "mpxdbmanager.h"
-
-// CLASS DECLARATION
-
-/**
-* Database manager specialization for the collection plugin.
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXCollectionDbManager :
-    public CMPXDbManager
-    {
-    public: // Constructors and destructor
-
-        /**
-        * Two-phased constructor.
-        * @param aFs file server session
-        * @return The constructed object of CMPXDbManager
-        */
-        static CMPXCollectionDbManager* NewL(RFs& aFs);
-
-        /**
-        * Two-phased constructor.
-        * @param aFs file server session
-        * @return The constructed object of CMPXDbManager
-        */
-        static CMPXCollectionDbManager* NewLC(RFs& aFs);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXCollectionDbManager();
-
-    private:
-
-        /**
-        * C++ default constructor
-        * @param aFs file server session
-        */
-        CMPXCollectionDbManager(RFs& aFs);
-
-        /**
-        * The second phase constructor ConstructL to safely construct things
-        * that can leave
-        */
-        void ConstructL();
-    };
-
-#endif  // MPXCOLLECTIONDBMANAGER_H
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxcollectiondbstd.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2006,2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This header file contains constants definitions and type
-*                definition
-*
-*/
-
-
-#ifndef MPXCOLLECTIONDBSTD_H
-#define MPXCOLLECTIONDBSTD_H
-
-// CONSTANTS
-enum TMPXAutoPlaylistType
-    {
-    EMPXNoAutoPlaylist = -1,
-    EMPXRecentlyPlayedPlaylist,
-    EMPXMostPlayedPlaylist,
-    EMPXRecentlyAddedPlaylist,
-    EMPXAutoPlaylistCount
-    };
-
-const TInt KDBPluginUid = 0x101FFC3A;
-
-const TInt KMPXMaxRecentlyPlayedSongs = 20;
-const TInt KMPXMaxMostPlayedSongs = 20;
-const TInt KMPXRecentlyAddedInterval = 7;
-
-const TInt KMCMaxTextLen          = 255; // Maximum field size for categories is 255
-
-#endif // MPXCOLLECTIONDBSTD_H
-
-// End Of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbalbum.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for all category tables (Artist,
-*                Album, Genre, Composer).
-*
-*
-*/
-
-
-#ifndef MPXDBALBUM_H
-#define MPXDBALBUM_H
-
-// INCLUDES
-#include "mpxdbcategory.h"
-
-// CLASS DECLARATION
-
-class MMPXDbAlbumObserver
-    {
-    public:
-        virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0;    
-        virtual TUint32 HandleArtistForAlbumL( const TUint32 aId ) = 0;
-    };
-/**
-* Responsible for managing all music databases
-*
-* @lib MPXDbPlugin.lib
-*/
-
-class CMPXDbAlbum :
-    public CMPXDbCategory
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance.
-        */
-        static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance on the cleanup stack.
-        */
-        static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbAlbum();
-
-    public:
-
-        /**
-        * Add a category item. If the record already exists, its counter will
-        * be incremented.
-        * @param aName: This is the name to be entered into the row
-        * @param aDriveId: The Drive Id the name (category) belongs
-        * @param aNewRecord: indicates to the caller if a new record is created.
-        *        ETrue if a new row is created in the table; otherwise EFalse.
-        * @param aCaseSensitive indicates whether case sensitivity should be taken
-        *        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,
-            TBool aCaseSensitive = ETrue);
-
-        /**
-        * Decrement the number of songs for the item. If the count gets to 0, remove
-        * the item.
-        * @param aId: The ID of the category to delete.
-        * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
-        *                  drives may belong to the same album or artist; consequently, one
-        *                  row for each artist/album id and drive ID pair will exist in the
-        *                  lookup table with a count existing for each row that tracks the
-        *                  number number of songs on that drive with that album/artist.
-        * @param aItemChangedMessages if valid on return contains a deleted message if the
-        *                  category was deleted
-        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
-        *        EFalse otherwise
-		* @param aArtist: The ID of the artist
-        */
-        void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
-            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TUint32 aArtist);
-        
-		/**
-	* Gets the details for all category items.
-	* @param aAttrs attributes to be returned
-	* @param aMediaArray returns the requested attributes for all items
-	*/
-		void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
-			CMPXMediaArray& aMediaArray);
-
-		/**
-	* Update a category item. 
-	* @param aId: The ID of the category to update
-	* @param aMedia: The media data
-	* @param aDriveId: The Drive Id the name (category) belongs
-	* @param aItemChangedMessages: if valid on return contains a updated message if the
-    *        category was updated
-	*/
-		void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
-
-	public:
-		/**
-	* Get albums count for a specified artist
-	* @param aId: The ID of the artist
-	*/		
-	    TInt GetAlbumsCountForArtistL(TUint32 aArtistId);
-
-		/**
-	* Get songs count for a specified album and a specified artist
-	* @param aArtistId: The ID of the artist
-	* @param aAlbumId: The ID of the album
-	*/		
-		TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
-		
-    private:	
-        /**
-        * Updates the media with information from the table
-        * @param aRecord record containing the source fields
-        * @param aAttrs attributes to be returned
-        * @param aMedia returns the requested attributes
-        */
-        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-         /**
-        * Generate searching criteria for album table from the given criteria
-        * @param aMedia media data
-        * @param aFields fields of Album table
-        * @param aValues values of each field of Album table
-        * @return a string containing the selection criteria. The ownership is passed to the caller.
-        */
-		void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, 
-			CDesCArray& aFields, CDesCArray& aValues);
-
-
-		TBool IsUnknownArtistL(TUint32 aId);
-		
-		TUint32 ArtistForAlbumL(const TUint32 aId);
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-    private:
-
-        /**
-        * C++ constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        */
-        CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
-        /**
-        * Second phase constructor.
-        */
-        void ConstructL();
-
-    public:
-
-        /**
-        * Column indexes in the category tables
-        */
-        enum TAlbumColumns
-            {
-            EAlbumUniqueId = KMPXTableDefaultIndex,
-            EAlbumName,
-            EAlbumSongCount,
-            EAlbumArtist,
-            EAlbumArt,
-            EAlbumArtistName,
-            EAlbumFieldCount
-            };
-
-    private:    // Data
-        MMPXDbAlbumObserver& iObserver;
-    };
-#endif // MPXDBALBUM_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbartist.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for Artist table.
-*
-*
-*/
-
-
-#ifndef MPXDBARTIST_H
-#define MPXDBARTIST_H
-
-// INCLUDES
-#include "mpxdbcategory.h"
-
-// CLASS DECLARATION
-class MMPXDbArtistObserver
-    {
-    public:
-		virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aId) = 0;
-	};
-
-/**
-* Responsible for managing all music databases
-*
-* @lib MPXDbPlugin.lib
-*/
-
-class CMPXDbArtist :
-    public CMPXDbCategory
-    {
-    public:
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbArtist instance.
-        */
-        static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbArtist instance on the cleanup stack.
-        */
-        static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbArtist();
-       
-    public:
-        /**
-        * Add a category item. If the record already exists, its counter will
-        * be incremented.
-        * @param aName: This is the name to be entered into the row
-        * @param aDriveId: The Drive Id the name (category) belongs
-        * @param aNewRecord: indicates to the caller if a new record is created.
-        *        ETrue if a new row is created in the table; otherwise EFalse.
-        * @param aCaseSensitive indicates whether case sensitivity should be taken
-        *        into consideration when generating the unique row id
-        * @return The unique id of the row added.
-        */
-        TUint32 AddItemL(const TDesC& aName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
-            TBool aCaseSensitive = ETrue);
-        
-        /**
-        * Gets the details for all category items.
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray returns the requested attributes for all items
-        */
-        void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-        
-        /**
-        * Update a category item. 
-        * @param aId: The ID of the category to update
-        * @param aMedia: The media data
-        * @param aDriveId: The Drive Id the name (category) belongs
-        * @param aItemChangedMessages: if valid on return contains a updated message if the
-        *        category was updated
-        */
-        void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
-        
-        /*
-        * Checks if the specified artist item is unknown
-        * @param aId identifies the artist item
-        * @return ETrue if it is unknown, EFalse otherwise
-        */        
-        TBool IsUnknownArtistL(TUint32 aId);
-        
-    private:
-
-        /**
-        * Updates the media with information from the table
-        * @param aRecord record containing the source fields
-        * @param aAttrs attributes to be returned
-        * @param aMedia returns the requested attributes
-        */
-        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Generate searching criteria for artist table from the given criteria
-        * @param aMedia media data
-        * @param aFields fields of Artist table
-        * @param aValues values of each field of Artist table
-        * @return a string containing the selection criteria. The ownership is passed to the caller.
-        */
-        void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, 
-            CDesCArray& aFields, CDesCArray& aValues);
-       
-        /**
-        * Gets the Album counts for a Artist item
-        * @param aId identifies the Artist item
-        * @return value of the Album counts
-        */
-        TInt GetAlbumsCountL(TUint32 aId);
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-        
-    private:
-
-        /**
-        * C++ constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        */
-        CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
-
-        /**
-        * Second phase constructor.
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the category tables
-        */
-        enum TArtistColumns
-            {
-            EArtistUniqueId = KMPXTableDefaultIndex,
-            EArtistName,
-            EArtistSongCount,
-            EArtistArt,
-            EArtistFieldCount
-            };
-
-    private:    // Data
-        MMPXDbArtistObserver& iObserver;
-    };
-#endif // MPXDBARTIST_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbautoplaylist.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for the auto playlist functionality.
-*
-*/
-
-
-#ifndef MPXDBAUTOPLAYLIST_H
-#define MPXDBAUTOPLAYLIST_H
-
-// INCLUDES
-#include <e32base.h>
-#include <mpxattribute.h>
-
-// CLASS FORWARDS
-class CMPXMedia;
-class CMPXMediaArray;
-class CMPXDbManager;
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing the music table
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXDbAutoPlaylist :
-    public CBase
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @return new CMPXDbAutoPlaylist instance.
-        */
-        static CMPXDbAutoPlaylist* NewL(CMPXDbManager& aDbManager, RFs& aFs, CMPXResource& aResource);
-
-        /**
-        * Two-phased constructor.
-        * @return new CMPXDbAutoPlaylist instance on the cleanup stack.
-        */
-        static CMPXDbAutoPlaylist* NewLC(CMPXDbManager& aDbManager, RFs& aFs, CMPXResource& aResource);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbAutoPlaylist();
-
-    public:
-
-        /**
-        * Get the playlist ID of an auto-playlist by type
-        * @param aPlaylistType type of the auto-playlist
-        * @return auto playlist ID
-        * @leave KErrNotSupported if invalid playlist type
-        */
-        TUint32 AutoPlaylistIdL(TMPXAutoPlaylistType aPlaylistType);
-
-        /**
-        * Get the name of an auto playlist
-        * @param aPlaylistId identifies the playlist
-        * @return the name of the playlist
-        * @leave KErrNotSupported if invalid playlist ID
-        */
-        TPtrC AutoPlaylistNameL(TUint32 aPlaylistId);
-
-        /**
-        * Checks whether the playlist ID corresponds to an auto playlist or not.
-        * @param aPlaylistId identifies the playlist
-        * @return Auto playlist type or EMPXNoAutoPlaylist if not found
-        */
-        TMPXAutoPlaylistType AutoPlaylistTypeL(TUint32 aPlaylistId);
-
-        /**
-        * Get information on a specified playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aAttrs the attributes to include for the playlists found.
-        * @param aMedia returns the playlist information
-        * @leave KErrNotSupported if invalid playlist ID
-        */
-        void GetPlaylistL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Get information on all auto playlists
-        * @param aMediaArray returns information on all auto playlists
-        */
-        void GetAllPlaylistsL(CMPXMediaArray& aMediaArray);
-
-    private:
-        
-        /**
-        * Get count and duration information of the auto-playlist
-        * @param aType the type of the auto-playlist
-        * @param aCount reference to count to be returned
-        * @param aDuration reference to duration to be returned
-        */
-        void GetPlaylistDetailsL(TMPXAutoPlaylistType aType, TInt& aCount, TInt& aDuration);
-
-        /**
-        * Update the media with information about the auto-playlist
-        * @param aPlaylistId Id of the auto-playlist
-        * @param aAttrs the attributes to include for the playlist matching the
-        *        selection criteria
-        * @param aMedia the playlist details object
-        */
-        void UpdateMediaL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-    private:
-
-        /**
-        * C++ constructor
-        */
-        CMPXDbAutoPlaylist(CMPXDbManager& aDbManager);
-
-        /**
-        * Second phase constructor
-        */
-        void ConstructL(RFs& aFs, CMPXResource& aResource);
-
-    private:    // Data
-        TUint32             iRecentlyPlayedPlaylistId; // recently played playlist ID
-        TUint32             iMostPlayedPlaylistId;     // most played playlist ID
-        TUint32             iRecentlyAddedPlaylistId;  // recently added playlist ID
-
-        // owned
-        HBufC*              iRecentlyPlayedPlaylist;   // recently played playlist name
-        HBufC*              iMostPlayedPlaylist;       // most played playlist name
-        HBufC*              iRecentlyAddedPlaylist;    // recently added playlist name
-        CMPXDbManager&      iDbManager;
-    };
-
-#endif // MPXDBAUTOPLAYLIST_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbauxiliary.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for interacting with the Auxiliary
-*                table.
-*
-*/
-
-
-#ifndef MPXDBAUXILIARY_H
-#define MPXDBAUXILIARY_H
-
-// INCLUDES
-#include "mpxdbtable.h"
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing the playlist tables
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXDbAuxiliary :
-    public CMPXDbTable
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbManager instance.
-        */
-        static CMPXDbAuxiliary* NewL(CMPXDbManager& aDbManager);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbManager instance on the cleanup stack.
-        */
-        static CMPXDbAuxiliary* NewLC(CMPXDbManager& aDbManager);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbAuxiliary();
-
-    public:
-
-        /**
-        * Sets the last refreshed time in the auxiliary table.
-        * @param aTime the last refreshed time value
-        */
-        void SetLastRefreshedTimeL(TTime aTime);
-
-        /**
-        * Gets the last refreshed time from the auxiliary table.
-        * @return last refreshed time value
-        */
-        TTime LastRefreshedTimeL();
-
-        /**
-        * Sets the db corrupted flag in the auxiliary table.
-        * @param aCorrupted db corrupted flag value
-        */
-        void SetDBCorruptedL(TBool aCorrupted);
-
-        /**
-        * Gets the db corrupted flag value from the auxiliary table.
-        * @return db corrupted flag value
-        */
-        TBool DBCorruptedL();
-
-        /**
-        * Sets the save deleted record count value.
-        * @param aDrive drive identifier
-        * @param aValue new field value
-        *
-        */
-        void SetSaveDeletedRecordCountL(TInt aDrive,TUint32 aValue);
-
-        /**
-        * Gets the save deleted record count field value.
-        * @return field value
-        */
-        TUint32 SaveDeletedRecordCountL();
-
-        /**
-         * Gets the save deleted record count field value.
-         * @param aDrive drive identifier
-         * @return field value
-         */
-         TUint32 SaveDeletedRecordCountL(TInt aDrive);
-
-        /**
-        * Checks if all databases have been refreshed.
-        * @return EFalse if at least one database has not been refreshed.
-        */
-        TBool IsRefreshedL();
-
-        /**
-        * Get the auxilary id for a drive
-        * @param aDrive drive to get the volume id
-        * @return TInt id for the aux database
-        */
-        TInt IdL( TInt aDrive );
-
-        /**
-        * Set the auxilary id for a drive
-        * @param aDrive,
-        * @param aId
-        */
-        void SetIdL( TInt aDrive, TInt aId );
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void DropTableL(RSqlDatabase& aDatabase);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-    private:
-
-        /**
-        * C++ constructor
-        * @param aDbManager database manager to use for database interactions
-        */
-        CMPXDbAuxiliary(CMPXDbManager& aDbManager);
-
-        /**
-        * Safely construct things that can leave
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the auxiliary table
-        */
-        enum TAuxiliaryColumns
-            {
-            EAuxiliaryId = KMPXTableDefaultIndex,
-            EAuxiliaryVersion,
-            EAuxiliaryTimeRefreshed,
-            EAuxiliaryTimeSynced,
-            EAuxiliaryCorrupt,
-            EAuxiliarySavedDeletedRecordCount
-            };
-
-    };
-
-#endif // MPXDBAUXILIARY_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbcategory.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,268 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for all category tables (Artist,
-*                Album, Genre, Composer).
-*
-*
-*/
-
-
-#ifndef MPXDBCATEGORY_H
-#define MPXDBCATEGORY_H
-
-// INCLUDES
-#include "mpxdbtable.h"
-#include "mpxmediageneraldefs.h"
-#include "mpxmessage2.h"
-
-// CLASS FORWARDS
-class CMPXMedia;
-class CMPXMediaArray;
-class RSqlStatement;
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing all music databases
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXDbCategory :
-    public CMPXDbTable
-    {
-    protected:
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbCategory();
-
-
-    public:
-
-        /**
-        * Add a category item. If the record already exists, its counter will
-        * be incremented.
-        * @param aName: This is the name to be entered into the row
-        * @param aDriveId: The Drive Id the name (category) belongs
-        * @param aNewRecord: indicates to the caller if a new record is created.
-        *        ETrue if a new row is created in the table; otherwise EFalse.
-        * @param aCaseSensitive indicates whether case sensitivity should be taken
-        *        into consideration when generating the unique row id
-        * @return The unique id of the row added.
-        */
-        TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
-            TBool aCaseSensitive = ETrue);
-
-        /**
-        * Get the name field for a given ID.
-        * @param aId identifies the category item
-        * @return name that matches aId. Ownership is abandoned.
-        */
-        HBufC* GetNameL(TUint32 aId);
-
-        /**
-        * Gets the total number of items in the category table.
-        * @return number of items
-        */
-        TInt CountL();
-
-        /**
-        * Find record(s) matching the criteria
-        * @param aCriteria, selection criteria
-        * @param aAttrs, attributes for the matching record(s)
-        * @param aMediaArray returns the matching record(s)
-        */
-        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Decrement the number of songs for the item. If the count gets to 0, remove
-        * the item.
-        * @param aId: The ID of the category to delete.
-        * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
-        *                  drives may belong to the same album or artist; consequently, one
-        *                  row for each artist/album id and drive ID pair will exist in the
-        *                  lookup table with a count existing for each row that tracks the
-        *                  number number of songs on that drive with that album/artist.
-        * @param aItemChangedMessages if valid on return contains a deleted message if the
-        *                  category was deleted
-        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
-        *        EFalse otherwise
-        */
-        void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
-            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
-
-        /**
-        * Deletes a category.
-        * @param aId identifies the category
-        * @param aDriveId category drive
-        */
-        void DeleteCategoryL(TUint32 aId, TInt aDriveId);
-
-        /**
-        * Gets the details for multiple category items.
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray inout parameter, on input contains the IDs of the
-        *       category items to be returned, on exit contains the requested
-        *       attributes for these items
-        */
-        void GetCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Gets the details for all category items.
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray returns the requested attributes for all items
-        */
-        void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Gets details for one category item.
-        * @param aId identifies the category item
-        * @param aAttrs attributes to be returned
-        * @param aMedia returns the requested attributes for te item
-        * @leave KErrCorrupt if there are multiple items with the same ID
-        *        KErrNotFound if there is no item with the specified ID
-        */
-        void GetCategoryItemL(TUint32 aId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Gets details for the category items under a parent category item.
-        * This applies to albums for a given artist. The method panics if the
-        * category or parent category are invalid.
-        * @param aParentCategory identifies the parent category
-        * @param aParentId identifies the parent item
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray returns the requested attributes for all items
-        */
-        void GetSubCategoryItemsL(TMPXGeneralCategory aParentCategory, TUint32 aParentId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Checks if the specified category item exists.
-        * @param aDriveId drive to check or KDbManagerAllDrives
-        * @param aId identifies the category item
-        * @return ETrue if it exists, EFalse otherwise
-        */
-        TBool CategoryItemExistsL(TInt aDriveId, TUint32 aId);
-
-        /**
-        * Gets the CountSongs field for a category item
-        * @param aDriveId drive to check or KDbManagerAllDrives
-        * @param aId identifies the category item
-        * @return value of the CountSongs field.
-        */
-        TInt GetSongsCountL(TInt aDriveId, TUint32 aId);
-
-		/**
-	    * Update a category item. 
-	    * @param aId: The ID of the category to update
-	    * @param aMedia: The media data
-	    * @param aDriveId: The Drive Id the name (category) belongs
-	    * @param aItemChangedMessages: if valid on return contains a updated message if the
-        * category was updated
-        */
-		void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
-		
-    protected:
-
-        /**
-        * Updates the media with information from the table
-        * @param aRecord record containing the source fields
-        * @param aAttrs attributes to be returned
-        * @param aMedia returns the requested attributes
-        */
-        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Returns the category record for a given ID
-        * @param aId identifies the category item
-        * @return rowset
-        */
-        RSqlStatement GetCategoryRecordL(TUint32 aId);
-
-        /**
-        * Replaces the table placeholder in the string parameter with the
-        * category table name.
-        * @param aQuery raw query string
-        * @return processed query string, ownership is transferred.
-        */
-        HBufC* PreProcessStringLC(const TDesC& aQuery);
-
-        /**
-        * Processes a recordset by constructing media instances and adding them
-        * to the specified array.
-        * @param aAttrs attributes to be returned
-        * @param aRecordset recordset to be processed
-        * @param aMediaArray returns the media instances
-        */
-        void ProcessRecordsetL(const TArray<TMPXAttribute>& aAttrs,
-            RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void DropTableL(RSqlDatabase& aDatabase);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-    protected:
-
-        /**
-        * C++ constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        */
-        CMPXDbCategory(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
-
-        /**
-        * Second phase constructor.
-        */
-        void BaseConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the category tables
-        */
-        enum TCategoryColumns
-            {
-            ECategoryUniqueId = KMPXTableDefaultIndex,
-            ECategoryName,
-            ECategorySongCount
-            };
-
-    protected:
-
-        HBufC* iTableName;              // owned
-        TMPXGeneralCategory iCategory;
-
-    };
-
-#endif // MPXDBCATEGORY_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbcomposer.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for all category tables (Artist,
-*                Album, Genre, Composer).
-*
-*
-*/
-
-
-#ifndef MPXDBCOMPOSER_H
-#define MPXDBCOMPOSER_H
-
-// INCLUDES
-#include "mpxdbcategory.h"
-
-// CLASS FORWARDS
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing all music databases
-*
-* @lib MPXDbPlugin.lib
-*/
-
-class CMPXDbComposer :
-    public CMPXDbCategory
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance.
-        */
-        static CMPXDbComposer* NewL(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance on the cleanup stack.
-        */
-        static CMPXDbComposer* NewLC(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbComposer();
-
-    private:
-
-        /**
-        * C++ constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        */
-        CMPXDbComposer(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
-
-        /**
-        * Second phase constructor.
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the category tables
-        */
-        enum TComposerColumns
-            {
-            EComposerUniqueId = KMPXTableDefaultIndex,
-            EComposerName,
-            EComposerSongCount,
-            EAlbumFieldCount
-            };
-
-    private:    // Data
-
-    };
-#endif // MPXDBCOMPOSER_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbgenre.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for all category tables (Artist,
-*                Album, Genre, Composer).
-*
-*
-*/
-
-
-#ifndef MPXDBGENRE_H
-#define MPXDBGENRE_H
-
-// INCLUDES
-#include "mpxdbcategory.h"
-
-// CLASS FORWARDS
-class CMPXMedia;
-class CMPXMediaArray;
-class RSqlStatement;
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing all music databases
-*
-* @lib MPXDbPlugin.lib
-*/
-
-class CMPXDbGenre :
-    public CMPXDbCategory
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance.
-        */
-        static CMPXDbGenre* NewL(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        * @return New CMPXDbCategory instance on the cleanup stack.
-        */
-        static CMPXDbGenre* NewLC(CMPXDbManager& aDbManager,
-            TMPXGeneralCategory aCategory);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbGenre();
-
-    private:
-
-        /**
-        * C++ constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aCategory identifies the category
-        */
-        CMPXDbGenre(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
-
-        /**
-        * Second phase constructor.
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the category tables
-        */
-        enum TGenreColumns
-            {
-            EGenreUniqueId = KMPXTableDefaultIndex,
-            EGenreName,
-            EGenreSongCount,
-            EGenreFieldCount
-            };
-
-    private:    // Data
-
-    };
-#endif // MPXDBGENRE_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbhandler.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1059 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class provides the functions to manipulate the music collection
-*                database.
-*
-*/
-
-
-#ifndef MPXDBHANDLER_H
-#define MPXDBHANDLER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <f32file.h>
-
-#include <mpxattribute.h>
-#include <mpxmessage2.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxcollectionframeworkdefs.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxcollectionmessagedefs.h>
-
-#include "mpxcollectiondbstd.h"
-#include "mpxcollectiondb.hrh"
-#include "mpxdbactivetask.h"
-#include "mpxdbmusic.h"     // for MMPXDbMusicObserver
-#include "mpxdbartist.h"    // for MMPXDbArtistObserver
-#include "mpxdbalbum.h"     // for MMPXDbAlbumObserver
-#include "mpxdbplaylist.h"	// for MMPXDbPlaylistObserver
-
-// FORWARD DECLARATIONS
-class CMPXMedia;
-class CMPXMediaArray;
-class CMPXCollectionDbManager;
-class CMPXDbPlaylist;
-class CMPXDbCategory;
-class CMPXDbAuxiliary;
-class CMPXDbAutoPlaylist;
-class CMPXDbArtist;
-class CMPXDbAlbum;
-class CMPXDbGenre;
-class CMPXDbComposer;
-
-// CLASS DECLARATION
-
-/**
-*  Music collection database handler
-*
-*  @lib MPXDbPlugin.lib
-*/
-class CMPXDbHandler :
-    public CBase,
-    public MMPXDbMusicObserver,
-    public MMPXDbArtistObserver,
-    public MMPXDbAlbumObserver,
-	public MMPXDbPlaylistObserver
-    {
-    public:  // Constructors and destructor
-
-        /**
-        * Two-phased constructor.
-        * @param aFs file server session
-        * @return a new CMPXDbHandler instance
-        */
-        static CMPXDbHandler* NewL(RFs& aFs, CMPXResource& aResource);
-
-        /**
-        * Two-phased constructor.
-        * @param aFs file server session
-        * @return a new CMPXDbHandler instance
-        */
-        static CMPXDbHandler* NewLC(RFs& aFs, CMPXResource& aResource);
-
-        /**
-        * Destructor.
-        */
-        virtual ~CMPXDbHandler();
-
-    public:
-
-        /**
-        * Add a song to the music collection database
-        * @param aMedia media object which contains file path,
-        *           artist, composer, name(title), track, etc...
-        * @param aMessageArray change event message to notify client of the changes
-        * @return TUint32 id of the item added
-        */
-        TUint32 AddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL);
-
-        /**
-        * Add a song to the music collection without a database transaction; it
-        * is assumed the transaction is created at a higher leve
-        * @param aMedia media object which contains file path,
-        *           artist, composer, name(title), track, etc...
-        * @param aMessageArray change event message to notify client of the changes
-        * @return TUint32 id of the item added
-        */
-        TUint32 AddSongWithNoTransactionL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL);
-        
-        /**
-        * Add a playlist to the collection
-        * @param aMedia playlist media object with title and URI of the playlist.
-        * @return playlist Id of the playlist created
-        */
-        TUint32 AddPlaylistL(const CMPXMedia& aMedia);
-
-        /**
-        * Add songs to the specified playlist
-        * @param aMedia playlist media object with playlist Id.
-        * @return playlist Id of the playlist
-        */
-        TUint32 AddSongToPlaylistL(const CMPXMedia& aMedia);
-
-        /**
-        * Update song info for a song in the music collection database
-        * @param aMedia songDetails object  which contains file path,
-        *           artist, composer, name(title), track, etc...
-        * @param aItemChangedMessages a list of change events as a result of the
-        *           song update
-        * @return ETrue if UI visible change else EFalse
-        */
-        CMPXDbActiveTask::TChangeVisibility UpdateSongL(const CMPXMedia& aMedia,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Update playlist info in the music collection database
-        * @param aMedia playlist details object which contains file path,
-        *           timestamps etc.
-        * @param aMessageArray change event messages for the playlist update
-        */
-        void UpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
-
-        /**
-        * Update the songs for a playlist in the music collection database
-        * @param aMedia playlist details object which contains the playlist songs.
-        * @param aMessage change event message for the playlist update
-        */
-        void UpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage);
-
-        /**
-        * Reorder the specified song in the specified playlist
-        * @param aPlaylistId id of the playlist which contains the song to be reordered
-        * @param aSongId id of the song to be reordered
-        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
-        *        Ordinal starts from 0.
-        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
-        *        starts from 0.
-        * @param aMessage change event message for the playlist update
-        */
-        void ReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
-            TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage);
-
-        /**
-        * Remove all songs within music collection database
-        */
-        void RemoveEntireCollectionL();
-
-        /**
-        * Remove a song from the music collection database
-        * @param aSongId ID of the song to be removed
-        * @param aUriArray a descriptor array to contain the URI of the deleted file
-        * @param aItemChangedMessages a list of change events as a result of the song removal
-        * @param aDeleteRecord indicates whether the client has explictly requested
-        *                to delete the records from the database. If ETrue, records
-        *                associated with the media will be deleted from the database;
-        *                if EFalse, whether to mark the records as deleted or to delete
-        *                the records will be based on other deciding factors.
-        */
-        void RemoveSongL(TUint32 aSongId, CDesCArray& aUriArray,
-            CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord = EFalse);
-
-        /**
-        * Removes a category of songs from the music collection, and its
-        * corresponding category in the lookup table
-        * @param aCategory the category to remove
-        * @param aCategoryId ID of the category to remove
-        * @param aUriArray a descriptor array to contain the URI of the deleted songs
-        * @param aItemChangedMessages a list of change events as a result of the song removal
-        */
-        void RemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
-            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Removes songs from the music collection belonging to the
-        * specified artist and album as well as the actual category
-        * in the lookup table
-        * @param aArtistId id of the artist
-        * @param aAlbumId id of the album
-        * @param aUriArray a descriptor array to contain the URI of the deleted file(s)
-        * @param aItemChangedMessages a list of change events as a result of the song removal
-        */
-        void RemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId,
-            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Remove all playlists from the collection
-        */
-        void RemoveAllPlaylistsL();
-
-        /**
-        * Remove a playlist This will remove all the songs from the playlist
-        * @param aPlaylistId ID of the playlist to remove
-        * @param aUriArray a descriptor array to contain the URI of the deleted file
-        * @param aItemChangedMessages a list of change events as a result of the
-        *        playlist removal
-        */
-        void RemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Remove a song from the specified playlist.
-        * @param aPlaylistId ID of the playlist to remove the song from
-        * @param aSongId Id of the song in the playlist to be removed
-        * @param aOrdinal the ordinal of the song in the playlist. This uniquely
-        *        identifies which song in the playlist to be removed; whereas song
-        *        Id doesn't because duplicate tracks in the playlist are allowed.
-        *        The position is relative to zero, i.e. zero implies that the song
-        *        at the beginning of the playlist is to be removed.
-        * @param aItemChangedMessages a list of change events as a result of the
-        *        song removal
-        */
-        void RemoveSongFromPlaylistL(TUint32 aPlaylist, const TMPXItemId& aSongId,
-            TInt aOrdinal, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Delete records in all databases which have been marked as deleted
-        */
-        void CleanupDeletedRecordsL();
-
-        /**
-        * Get all songs from the music collection databasee
-        * @param aMediaArray Array to place all the songs' required info
-        * @param aAttrs required attributes
-        */
-        void GetAllSongsL(CMPXMediaArray* aMediaArray,
-            const TArray<TMPXAttribute>& aAttrs);
-
-        /**
-        * Get a limited number of songs from the music collection databasee
-        * @param aMediaArray Array to place all the songs' required info
-        * @param aAttrs required attributes
-        * @param aLimit maximum number of songs to retrieve
-        */
-        void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,
-                                 CMPXMediaArray& aMediaArray, TInt aLimit);
-
-        /**
-        * Get songs from the music collection database incrementally
-        * @param aMediaArray Array to place all the songs' required info
-        * @param aAttrs required attributes
-        * @param aTitle title to use as a key
-        * @param aNumOfSongs number of songs to read
-        * @param aAsc ascending or descending data read
-        */
-        void GetSongsInBlockL(CMPXMediaArray* aMediaArray,
-            const TArray<TMPXAttribute>& aAttrs,
-            TPtrC aTitle,
-            TUint aNumOfSongs,
-            TBool aAsc);
-
-
-        /**
-        * Get songs from the music collection starting at a particular offset
-        * ONLY use this as the first query to locate particular item. Should use
-        * GetSongsInBlockL() to fetch in blocks with a particular index
-        * @param aMediaArray Array to store the results
-        * @param aAttrs attributes to fetch
-        * @param aOffset offset to start reading
-        * @param aCount number of items to get
-        */
-        void GetSongsAtOffsetL( CMPXMediaArray* aMediaArray,
-                                const TArray<TMPXAttribute>& aAttrs,
-                                TInt aOffset,
-                                TInt aCount );
-
-        /**
-        * Get all the songs that match the given artist ID
-        * @param aArtistId ID of the artist to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching songs' required
-        *        attributes
-        */
-        void GetSongsMatchingArtistL(TUint aArtistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the songs that match the given album ID
-        * @param aAlbumId ID of the album to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching songs' required info
-        */
-        void GetSongsMatchingAlbumL(TUint aAlbumId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the songs that match the given artist and album ID
-        * @param aArtistId ID of the artist to match
-        * @param aAlbumId ID of the album to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching songs' required info
-        */
-        void GetSongsMatchingArtistAndAlbumL(TUint aArtistId, TUint aAlbumId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the songs that match the given genre ID
-        * @param aGenreId ID of the genre to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching songs' required info
-        */
-        void GetSongsMatchingGenreL(TUint aGenreId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the songs that match the given composer ID
-        * @param aComposerId ID of the composer to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching songs' required info
-        */
-        void GetSongsMatchingComposerL(TUint aComposerId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the songs that match the given playlist ID
-        * @param aPlaylistId ID of the playlist to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the required song info
-        */
-        void GetSongsMatchingPlaylistL(TUint aPlaylistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get the song info that matches the given song ID from Songs table.
-        * @param aSongId ID of the song
-        * @param aAttrs required attributes
-        * @param aMedia returns the song info
-        */
-        void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Appends the media object with the song information to the specified array.
-        * @param aSongId ID of the song
-        * @param aAttrs required attributes
-        * @param aMediaArray on return the song info is appended to this array
-        */
-        void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get the song info that matches the given song ID from Songs table.
-        * The song info will first be populated from Playlist table and
-        * if the Songs table exists in the drive where the song is located,
-        * song info will be overwritten from Songs table. This enables the
-        * support for displaying song title in a playlist when the drive
-        * where the song is located is not present.
-        * @aSongId ID of the song
-        * @aPlaylistId ID of the playlist the song belongs to.
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the required song info
-        * @leave KErrNotFound if the song could not be found in the
-        *       PlaylistSongs table
-        */
-        void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
-
-        /**
-        * Appends the a media object with the song information to the specified array.
-        * @param aSongId ID of the song
-        * @param aPlaylistId ID of the playlist
-        * @param aAttrs required attributes
-        * @param aMediaArray on return the song info is appended to this array
-        */
-        void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get the song ID of the song that matches the given URI
-        * @param aUri URI to match
-        * @return song ID
-        */
-        TUint32 GetSongIdMatchingUriL(const TDesC& aUri);
-
-        /**
-        * Get all the artist names from the music collection database sorted by name.
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the artists' required info
-        */
-        void GetAllArtistsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the album names from the music collection database sorted by name.
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the albums' required info
-        */
-        void GetAllAlbumsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the albums that match the given artist ID sorted by name.
-        * @param aArtistId ID of the artist to match
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the matching albums' required info
-        */
-        void GetAlbumsMatchingArtistL(TUint aArtistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get all the genre names from the collection
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the genres' required info
-        */
-        void GetAllGenresL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get all the composer names from the collection
-        * @param aAttrs required attributes
-        * @param aMediaArray Array to place all the composers' required info
-        */
-        void GetAllComposersL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get the playlist ID of the playlist that matches the given URI
-        * @param aUri URI to match
-        * @return playlist ID to return
-        */
-        TUint32 GetPlaylistIdMatchingUriL(const TDesC& aUri);
-
-        /**
-        * Checks if the specified ID corresponds to an auto playlist.
-        * @param aPlaylistId ID to be checked
-        * @return ETrue if it corresponds to an auto playlist, EFalse otherwise
-        */
-        TBool IsAutoPlaylistL(TUint32 aPlaylistId);
-
-        /**
-        * Get all the playlist names from the collection
-        * @param aMediaArray Array to place all the playlists' required info
-        * @param aAttrs required attributes
-        */
-        void GetAllPlaylistsL(CMPXMediaArray* aMediaArray,
-            const TArray<TMPXAttribute>& aAttrs);
-
-        /**
-        * Get all the system playlist names from the collection
-        * @param aMediaArray Array to place all the system playlists' required info
-        */
-        void GetAllSystemPlaylistNamesL(CMPXMediaArray* aMediaArray);
-
-        /**
-        * Get title from the Id
-        * @param Id to search for
-        * @return name matching the ID
-        */
-        HBufC* GetNameMatchingIdL(const TUint32 aId) const;
-
-        /**
-        * Get URI from the Id
-        * @param Id to search for
-        * @return URI matching the ID
-        * @leave KErrNotSupported if the ID refers to an invalid category
-        */
-        HBufC* GetUriMatchingIdL(const TUint32 aId) const;
-
-        /**
-        * Retrieve category record with information as specified in the given
-        * attributes
-        * @param aCategoryId Id of the record to be retrieved
-        * @param aCategory category type
-        * @param aAttrs information to return about the specified category
-        * @param aMedia returns the category information
-        */
-        void GetCategoryL(const TUint32 aCategoryId, TMPXGeneralCategory aCategory,
-                const TArray<TMPXAttribute>& aAttrs, CMPXMedia* aMedia);
-
-        /**
-        * Get the duration for all songs
-        * @return duration
-        */
-        TInt GetAllSongsDurationL();
-
-        /**
-        * Get the duration for all songs for a specified artist
-        * @param aArtistId identifies the artist
-        * @return duration
-        */
-        TInt GetArtistDurationL(TInt aArtistId);
-
-        /**
-        * Get the duration for all songs in a specified album
-        * @param aAlbumId identifies the album
-        * @return duration
-        */
-        TInt GetAlbumDurationL(TInt aAlbumId);
-
-        /**
-        * Get the duration for all songs for a specified artist and album
-        * @param aArtistId identifies the artist
-        * @param aAlbumId identifies the album
-        * @return duration
-        */
-        TInt GetArtistAlbumDurationL(TInt aArtistId, TInt aAlbumId);
-
-        /**
-        * Get the duration for all songs for a specified composer
-        * @param aComposerId identifies the composer
-        * @return duration
-        */
-        TInt GetComposerDurationL(TInt aComposerId);
-
-        /**
-        * Get the duration for all songs for a specified genre
-        * @param aGenreId identifies the genre
-        * @return duration
-        */
-        TInt GetGenreDurationL(TInt aGenreId);
-
-        /**
-        * Get the duration for all songs in a user playlist
-        * @param aPlaylistId identifies the playlist
-        * @return duration
-        */
-        TInt GetUserPlaylistDurationL(TInt aPlaylistId);
-
-        /**
-        * Get the duration for all songs for a specified playlist
-        * @param aPlaylistId identifies the playlist
-        * @return duration
-        */
-        TInt GetPlaylistDurationL(TInt aPlaylistId);
-
-        /**
-        * Fetch the total number of items in the specified category
-        * @param aCategory category to be queried
-        * @return number of items.
-        */
-        TInt NumberOfItemsL(TMPXGeneralCategory aCategory);
-
-        /**
-        * Find media(s) from the collection
-        * @param aCriteria selection criteria
-        * @param aAttrs attributes for the matching media
-        * @return matching media. Ownership is transferred.
-        * @leave KErrArgument if the criteria do not include a type
-        *           or category
-        */
-        CMPXMedia* FindAllLC(const CMPXMedia& aCriteria,
-            const TArray<TMPXAttribute>& aAttrs);
-
-        /**
-        * Set the last refreshed time
-        * @param aTime the updated last refresh time
-        */
-        void SetLastRefreshedTimeL(TTime aTime);
-
-        /**
-        * Get the last refreshed time
-        * @return last refreshed time
-        */
-        TTime GetLastRefreshedTimeL();
-
-        /**
-        * Set the db corrupted bit in the aux table for all drives
-        * @param aCorrupted flag indicating whether or not the db is corrupted
-        */
-        void SetDBCorruptedL(TBool aCorrupted);
-
-        /**
-        * Get the db corrupted bit in the aux table ( or of all drives )
-        * @return ETrue if database is corrupted, else EFalse
-        */
-        TBool IsDBCorruptedL();
-
-        /**
-        * Checks if the database has been created
-        * @return ETrue if file has been created
-        */
-        TBool DatabaseCreated();
-
-        /**
-        * Close and re-open the music collection database stored on the
-        * specified drive
-        * @param aDrive drive containing the music collection database to re-open
-        */
-        void OpenDatabaseL(TInt aDrive);
-
-        /**
-        * Close a database for a particular drive
-        * @param aDrive drive to close
-        */
-        void CloseDatabaseL(TInt aDrive);
-
-        /**
-        * Recreate all databases.
-        */
-        void ReCreateDatabasesL();
-
-        /**
-        * Starts a refresh operation.
-        */
-        void RefreshStartL();
-
-        /**
-        * Ends a refresh operation.
-        */
-        void RefreshEndL();
-        
-        /**
-        * Notification of mtp start
-        */
-        void MtpStartL();
-
-        /**
-        * Notification of mtp end
-        */
-        void MtpEndL();
-        /**
-        * Get total record count for music in db
-        * @param aDrive, specifies drive number for db selection
-        * @return count
-        */
-        TUint GetMusicCountL(TInt aDrive);
-
-        /**
-        * Get total record count for playlists in db
-        * @param aDrive, specifies drive number for db selection
-        * @return count
-        */
-        TUint GetPlaylistCountL(TInt aDrive);
-
-        /**
-        * Get total record count for music and playlists in db
-        * @param aDrive, specifies drive number for db selection
-        * @return count
-        */
-        TUint GetTotalCountL(TInt aDrive);
-
-        /**
-        * Get URIs for a given amount of songs
-        * @param aDrive, specifies drive number for db selection
-        * @param aFromID, specifies unique ID of last record retrieved
-        * @param aRecords, specifies the number of records to get
-        * @param aUriArr, will contain all URIs on return
-        * @param aLastID, will contain unique ID of a last record in the array
-        */
-        void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                               CDesCArray& aUriArr, TInt& aLastID);
-
-        /**
-        * Get URIs for a given amount of playlists
-        * @param aDrive, specifies drive number for db selection
-        * @param aFromID, specifies unique ID of last record retrieved
-        * @param aRecords, specifies the number of records to get
-        * @param aUriArr, will contain all URIs on return
-        * @param aLastID, will contain unique ID of a last record in the array
-        */
-        void GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                  CDesCArray& aUriArr, TInt& aLastID);
-
-        /**
-        * Starts a transaction on all open databases.
-        */
-        void BeginTransactionL();
-
-        /**
-        * Commits or rolls back a transaction.
-        * @param aError if error then rolls back the transaction and leaves
-        *               if KErrNone it commits the transaction
-        */
-        void EndTransactionL(TInt aError);
-
-        /**
-        * Checks if the database is currently in a transaction.
-        *
-        * @return ETrue if database is currently in a transaction, EFalse otherwise
-        */
-        TBool InTransaction();
-
-        /**
-         * Notifies the handler that the collection will be closed.
-         * It is called before closing the collection.
-         */
-        void PreCloseCollectionL();
-
-        /**
-         * Notifies the handler that the collection was closed.
-         */
-         void CollectionClosed();
-
-         /**
-         * Notifies the handler that the collection was opened.
-         */
-         void CollectionOpenedL();
-         
-         /**
-          * Checks if the spefified drive is a remove drive
-          */      
-         TBool IsRemoteDrive(TDriveNumber aDrive);
-         
-         /**
-          * Checks if there is a drive that has a low disk space
-          * @leave KErrDiskFull if the space on one of the drives is below the
-          *         critical level
-          */
-         void CheckDiskSpaceOnDrivesL();
-
-    private:
-
-        /**
-        * Add a song to the music collection database
-        * @param aMedia: media object which contains file path,
-        *           artist, composer, name(title), track, etc...
-        * @param aMessage change event message to notify client of the changes
-        * @return Id of the song added
-        * @leave KErrArgument if the media doe snot include the song URI
-        */
-        TUint32 DoAddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray);
-
-        /**
-        * Add a playlist to the collection
-        * @param aMedia playlist media object with title and URI of the playlist.
-        * @return ID of the playlist created
-        */
-        TUint32 DoAddPlaylistL(const CMPXMedia& aMedia);
-
-        /**
-        * Add songs to the specified playlist
-        * @param aMedia playlist media object with playlist Id.
-        * @return playlist Id of the playlist
-        */
-        TUint32 DoAddSongToPlaylistL(const CMPXMedia& aMedia);
-
-        /**
-        * Update song info for a song in the music collection database
-        * @param aMedia songDetails object  which contains file path,
-        *           artist, composer, name(title), track, etc...
-        * @param aItemChangedMessages a list of items changed
-        * @return ETrue if UI visible change
-        * @leave KErrNotSupported if the song ID could not be constructed
-        */
-        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(const CMPXMedia& aMedia,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Update playlist info in the music collection database
-        * @param aMedia playlist details object which contains file path,
-        *           timestamps etc...
-        * @param aMessage change event message for the playlist update
-        */
-        void DoUpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
-
-        /**
-        * Replace all songs for a playlist. This method is called when harvester
-        * scans an updated playlist. This will also be called if MTP wants to
-        * replace the contents of an existing playlist. The implementation deleted the
-        * existing songs first and then inserts the new ones.
-        * @param aMedia playlist and songs details object which contains file path,
-        *           timestamps etc...
-        * @param aMessage change event message for the playlist update
-        */
-        void DoUpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage);
-
-        /**
-        * Reorder the specified song in the specified playlist
-        * @param aPlaylistId id of the playlist which contains the song to be reordered
-        * @param aSongId id of the song to be reordered
-        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
-        *        Ordinal starts from 0.
-        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
-        *        starts from 0.
-        * @param aMessage change event message for the playlist update
-        */
-        void DoReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
-            TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage);
-
-        /**
-        * Deletes a song. In addition to deleting the song record from the music
-        * table takes care of updating the category and playlist tables.
-        * @param aSongId song to be deleted
-        * @param aUriArray on return contains the URIs of the song deleted.
-        * @param aItemChangedMessages on return contains changed messages for all
-        *        affected items
-        * @param aDeleteRecord ETrue if the record is to be deleted, EFalse if it is
-        *        to be marked as deleted.
-        */
-        void DoRemoveSongL(TUint32 aSongId, CDesCArray& aUriArray,
-            CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord);
-
-        /**
-         * Deletes the song  from the playlist tables
-         * @param aSongId song to be deleted
-         * @param aItemChangedMessages on return contains changed messages for all
-         *        affected items
-         */
-        void DoRemoveSongFromPlaylistL(TUint32 aSongId,CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Deletes all the songs for a given category. The implementation uses
-        * DoRemoveSongL for the business logic.
-        * @param aCategory category type (artist/album/genre/composer)
-        * @param aCategoryId identifies the category item
-        * @param aUriArray on return contains the URIs of the songs deleted.
-        * @param aItemChangedMessages on return contains changed messages for all
-        *        affected items
-        * @leave KErrNotSupported if invalid category
-        */
-        void DoRemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory,
-            TUint32 aCategoryId, CDesCArray& aUriArray,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Deletes all the songs for a given artist and album.
-        * The implementation uses DoRemoveSongL for the business logic.
-        * @param aArtistId identifies the artist
-        * @param aAlbumId identifies the album
-        * @param aUriArray on return contains the URIs of the songs deleted.
-        * @param aItemChangedMessages on return contains changed messages for all affected items
-        */
-        void DoRemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId,
-            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Deletes all the playlists in all databases. Note that the songs are not affected.
-        */
-        void DoRemoveAllPlaylistsL();
-
-        /**
-        * Deletes a specified playlist.
-        * @param aPlaylistId the playlist to be deleted.
-        * @param aUriArray on return contains the URIs of the items deleted.
-        * @param aItemChangedMessages on return contains changed messages for all
-        *        affected items
-        */
-        void DoRemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Deletes a song from a playlist.
-        * @param aPlaylistId identifies the playlist.
-        * @param aSongId song to be deleted.
-        * @param aOrdinal song ordinal in case there are multiple instances of the same
-        *        song in the playlist.
-        * @param aItemChangedMessages on return contains changed messages for all
-        *        affected items
-        */
-        void DoRemoveSongFromPlaylistL(TUint32 aPlaylistId, const TMPXItemId& aSongId,
-            TInt aOrdinal, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Deletes all song records marked as deleted.
-        */
-        void DoCleanupDeletedRecordsL();
-
-        /**
-        * Find items in the collection
-        * @param aCriteria selection criteria
-        * @param aAttrs attributes for the matching media
-        * @param aMediaArray returns the matching entries
-        */
-        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray* aMediaArray);
-
-        /**
-        * Find a song.
-        * @param aCriteria selection criteria
-        * @param aAttrs attributes for the matching media
-        * @param aMediaArray returns the matching entries
-        */
-        void FindSongL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Gets the songs for a specified playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray returns the matching entries
-        */
-        void GetPlaylistSongsL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Find an album
-        * @param aCriteria selection criteria
-        * @param aAttrs attributes to be returned
-        * @param aMediaArray returns the matching entries
-        */
-        void FindAlbumL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Extracts the playlist ID and drive ID from the media object.
-        * @param aMedia playlist information
-        * @param aPlaylistId returns the playlist ID
-        * @param aPlaylistDriveId returns the drive ID
-        * @leave KErrArgument if the media does not include the ID and URI
-        */
-        void ProcessPlaylistMediaL(CMPXMedia& aMedia, TUint32& aPlaylistId,
-            TInt& aPlaylistDriveId);
-
-        /**
-        * Updates all the song entries in the playlist media with extra
-        * information from the music table.
-        * @param aMedia inout, contains the playlist/songs information
-        * @leave KErrArgument if the song does not exist in the music table and
-        *        the media does not include a URI
-        */
-        void UpdatePlaylistSongInfoL(CMPXMedia& aMedia);
-
-        /**
-        * Makes sure all the folders specified in the array parameter are created,
-        * otherwise it tries to create them. Updates the iDbDrives member variable
-        * with the drives corresponding to the folders.
-        * @param aFolders contains all the folders to be processed
-        */
-        void ProcessMusicFoldersL(const CDesCArray& aFolders);
-
-        /**
-        * Returns the CMPXDbCategory instance associated with the specified
-        * category type
-        * @param aCategory category type
-        * @return corresponding CMPXDbCategory instance
-        * @leave KErrNotSupported if invalid category
-        */
-        CMPXDbCategory* DbCategoryL(TMPXGeneralCategory aCategory) const;
-
-        /**
-        * Verify the volume id for the databases
-        */
-        void VerifyVolumeIdL();
-
-
-#if defined (__MTP_PROTOCOL_SUPPORT)
-        /**
-        * Reads the "save deleted records" MTP flag from CenRep and returns
-        * the value.
-        * @return value of the "save deleted records" MTP flag
-        */
-        TBool SaveDeletedSongs();
-#endif
-
-#ifdef RD_MULTIPLE_DRIVE
-        /**
-        * Retrieve all visible music folder locations.
-        */
-        CDesCArrayFlat* GetMusicFoldersL();
-#endif // RD_MULTIPLE_DRIVE
-
-    private:    // From MMPXDbMusicObserver
-
-        /**
-        * @see MMPXDbMusicObserver
-        */
-        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory,
-            const TDesC& aName, TInt aDriveId,
-            CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
-
-		virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
-			TUint32 aArtist, const TDesC& aArt,
-			TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
-
-		virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, 
-			const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages);
-			
-        /**
-        * @see MMPXDbMusicObserver
-        */
-        virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory,
-            TUint32 aCategoryId, TInt aDriveId, CMPXMessageArray* aItemChangedMessages,
-            TBool& aItemExist);
-
-        /**
-        * @see MMPXDbMusicObserver
-        */
-        virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * @see MMPXDbMusicObserver
-        */
-        virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages);
-    private:    // From MMPXDbArtistObserver
-    /**
-    * @see MMPXDbArtistObser
-    */
-        virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aArtistId);
-
-    private:    // From MMPXDbAlbumObserver
-    /**
-    * @see MMPXDbAlbumObserver
-    */
-        virtual TBool HandleIsUnknownArtistL(TUint32 aArtistId);
-        virtual TUint32 HandleArtistForAlbumL(const TUint32 aAlbumId);
-        
-    private:	// From MMPXDbPlaylistObserver
-	/**
-	* @see MMPXDbPlaylistObserver
-	*/
-		virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId);
-
-    private:
-
-        /**
-        * C++ constructor.
-        * @param file session
-        */
-        CMPXDbHandler(RFs& aFs, CMPXResource& aResource);
-
-        /**
-        * Symbian 2nd phase constructor..
-        */
-        void ConstructL();
-
-    private:    // Data
-
-        // owned member variables
-        CMPXCollectionDbManager* iDbManager;
-        CMPXDbMusic* iDbMusic;
-        CMPXDbPlaylist* iDbPlaylist;
-        CMPXDbArtist* iDbArtist;
-        CMPXDbAlbum* iDbAlbum;
-        CMPXDbGenre* iDbGenre;
-        CMPXDbComposer* iDbComposer;
-        CMPXDbAuxiliary* iDbAuxiliary;
-
-        CMPXDbAutoPlaylist* iAutoPlaylist;
-
-        CDesCArrayFlat* iMimeTypes;         // MIME types supported
-        CDesCArrayFlat* iExtensions;        // file extensions supported
-        CDesCArrayFlat* iExtensionsMime;    // file extensions to check MIME
-        CDesCArrayFlat* iExtensionsDrm;     // file extensions to check DRM type
-        RArray<TInt> iDbDrives;
-
-        // not owned member variables
-        RFs& iFs;
-        CMPXResource& iResource;
-        TBool iOutOfDisk;                   // Are we in out of disk mode?
-        TBool iSynchronizeBasicTable;       // Basic music table was not updated during last refresh
-        TBool iCollectionOpen;              // Databases opened
-        TBool iRefresh;                     // Refresh operation currently performed
-        TBool iMtpInUse;                    // Flag for MTP operation
-        TInt  iOpOnDbCount;                 // Count to provide a min op amount in one transaction
-    };
-
-#endif      // MPXDBHANDLER_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbmusic.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,752 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for all music table functionality.
-*                The Music table contains one record for each song on the database
-*                drive.
-*
-*
-*/
-
-
-#ifndef MPXDBMUSIC_H
-#define MPXDBMUSIC_H
-
-// INCLUDES
-#include "mpxdbtable.h"
-#include "mpxdbcommonstd.h"
-#include "mpxdbactivetask.h"
-
-// CLASS FORWARDS
-class CMPXMedia;
-class CMPXMediaArray;
-
-// CLASS DECLARATION
-
-/**
-* Observer interface for handling the category ID functionality.
-* This is needed because the incoming CMPXMedia parameters in Add and Update methods
-* contain the names for the category items and the music table has to use IDs linking
-* to the category tables. Using this interface removes the dependency to the category
-* class.
-*
-* Note that this interface is only used when information is written to the Music table,
-* when information is retrieved the query takes care of also retrieving the names from
-* the corresponding category tables so the outgoing CMPXMedia will contain the correct
-* information.
-*/
-class MMPXDbMusicObserver
-    {
-    public:
-        /**
-        * Called when a new category item has to be added to a category table.
-        * @param aCategory category type
-        * @param aName name string
-        * @param aDrive drive to add the category to
-        * @param aItemChangedMessages changed mesages array to be updated or NULL
-        * @param aItemExist Out parameter, ETrue if the item already exist before the add,
-        *        EFalse otherwise
-        * @return the ID of the category item (new or existing)
-        */
-        virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
-            TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
-
-		// for Album and Artist table
-		virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
-			TUint32 aArtistId, 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
-        * the artist name changed for a song. The implementation is supposed to update the
-        * category record and add corresponding item changed messages to the array parameter.
-        * @param aCategory category type
-        * @param aCategoryId old category item ID
-        * @param aDrive drive the category item is on
-        * @param aItemChangedMessages changed mesages array to be updated or NULL
-        * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
-        *        EFalse otherwise
-        */
-        virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
-            TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
-
-        /**
-        * Called when the play count attribute of a song is changed. Should add an item changed
-        * message to the array.
-        * @param aItemChangedMessages array of item changed messages to add to
-        */
-        virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages) = 0;
-
-        /**
-        * Called when the playback time attribute of a song is changed. Should add an item changed
-        * message to the array.
-        * @param aItemChangedMessages array of item changed messages to add to
-        */
-        virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages) = 0;
-        
-        /**
-         * Called when category item is changed. Should add an item changed 
-         * message to the array.
-         * @param aCategory category type
-         * @param aCategoryId old category item ID
-         * @param aDrive drive the category item is on
-         * @param aMedia media data
-         * @param aItemChangedMessages changed mesages array to be updated or NULL
-         */
-		virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, 
-			const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0;
-    };
-
-/**
-* Responsible for managing the Music table
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXDbMusic :
-    public CMPXDbTable
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aObserver observer reference
-        * @return New CMPXDbMusic instance.
-        */
-        static CMPXDbMusic* NewL(CMPXDbManager& aDbManager, CMPXResource& aResource,
-            MMPXDbMusicObserver& aObserver);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @param aObserver observer reference
-        * @return New CMPXDbMusic instance on the cleanup stack.
-        */
-        static CMPXDbMusic* NewLC(CMPXDbManager& aDbManager, CMPXResource& aResource,
-            MMPXDbMusicObserver& aObserver);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbMusic();
-
-    public:
-
-        /**
-        * Add a song to the music table
-        * @param aMedia contains the song details
-        * @param aDrive drive to add the song to
-        * @param aMessageArray change event message to notify client of the changes
-        * @return The unique ID of the song added.
-        */
-        TUint32 AddSongL(const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aMessageArray=NULL);
-
-        /**
-        * Remove a song from the music table
-        * @param aSongId the ID of the song to be removed
-        * @param aDrive song drive
-        * @param aDeleteRecord indicates whether the client has explictly requested
-        *                to delete the records from the database. If ETrue, records
-        *                associated with the media will be deleted from the database;
-        *                if EFalse, whether to mark the records as deleted or to delete
-        *                the records will be based on other deciding factors.
-        */
-        void DeleteSongL(TUint32 aSongId, TInt aDrive, TBool aDeleteRecord = EFalse);
-
-        /**
-        * Remove songs matching a category from the music table
-        * @param aCategory the category to remove
-        * @param aCategoryId ID of the category to remove
-        * @param aUriArray on return will be filled with all the paths that were removed
-        * @param aItemChangedMessages a list of change events as a result of the song removal
-        * @param aDrive drive the category record is on
-        */
-        void DeleteCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
-            CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages, TInt aDrive);
-
-        /**
-        * Deletes all songs marked as deleted
-        */
-        void CleanupL();
-
-        /**
-        * Update song info for a song in the music table
-        * @param aSongId song ID
-        * @param aMedia media object which contains file path,
-        *                artist, composer, name(title), track, etc...
-        * @param aItemChangedMessages a list of change events as a result of the song removal
-        * @return ETrue if the change is visible in the UI
-        */
-        CMPXDbActiveTask::TChangeVisibility UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia,
-            CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Get the name of the song that matches the given song ID
-        * @param aSongId ID of the song
-        * @return Song name, ownership is transferred to the caller.
-        */
-        HBufC* GetNameL(TUint32 aSongId);
-
-        /**
-        * Get URI of the song
-        * @param aSongId ID of the song
-        * @return Song URI, ownership is transferred to the caller.
-        */
-        HBufC* GetUriL(TUint32 aSongId);
-
-        /**
-        * Get the drive of the song
-        * @param aSongId ID of the song
-        * @return Song drive
-        */
-        TInt GetDriveL(TUint32 aSongId);
-
-        /**
-        * Get the drive and category IDs for a specified song
-        * @param aSongId song to be retrieved
-        * @param aArtistId returns the artist ID
-        * @param aAlbumId returns the artist ID
-        * @param aGenreId returns the artist ID
-        * @param aComposerId returns the artist ID
-        * @param aDriveId returns the song drive
-        * @return song URI. The ownership is transferred.
-        */
-        HBufC* GetSongInfoL(TUint32 aSongId, TUint32& aArtistId, TUint32& aAlbumId,
-            TUint32& aGenreId, TUint32& aComposerId, TInt& aDriveId);
-
-        /**
-        * Get the song Id, title, URI, and general flags from the given song Id and/or URI
-        * @param aCriteria search the media by song Id and/or URI
-        * @param aMedia returns the song details
-        * @return error code KErrNotFound if unable to find the specified song in the
-        *          collection; otherwise KErrNone
-        */
-        TInt GetSongL(const CMPXMedia& aCriteria, CMPXMedia*& aMedia);
-
-        /**
-        * Get the most recently played songs. Returns a maximum of KMPXMaxRecentlyPlayedSongs
-        * songs.
-        * @param aAttrs attributes to include
-        * @param aMediaArray returns the songs' info
-        */
-        void GetRecentlyPlayedSongsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get the most played songs from the music table. Returns a maximum of
-        * KMPXMaxMostPlayedSongs songs.
-        * @param aAttrs attributes to include
-        * @param aMediaArray returns the songs' info
-        */
-        void GetMostPlayedSongsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get the recently added songs from the music table (7 days)
-        * @param aAttrs attributes to include
-        * @param aMediaArray returns the songs' info
-        */
-        void GetRecentlyAddedSongsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-       /**
-        * Get the total number of songs
-        * @return total number of songs
-        */
-        TInt CountL();
-
-        /**
-        * Get all the albums for a specified artist
-        * @param aArtistId artist ID
-        * @param aMediaArray returns the album(s) matching the artist
-        */
-        void GetAlbumsForArtistL(TUint32 aArtistId, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns details about the specified song.
-        * @param aSongId identifies the song
-        * @param aAttrs attributes to be retrieved
-        * @param aMedia returns the song information
-        */
-        void GetSongL(TInt aSongId, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
-        
-        /**
-        * Returns all songs in the playlist.
-        * @param aDrive identifies in db
-        * @param aPlaylistId identifies the playlist
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetAllSongsL(TInt aDrive,TInt aPlaylistId,const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns all songs in the database.
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetAllSongsL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get from all songs with a limit (first N items)
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        * @param aLimit maximum number of songs to retrieve
-        */
-        void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray, TInt aLimit);
-
-        /**
-        * Returns a block of songs as specified
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        * @param aTitle title of the song that marks the beginning of the block
-        * @param aNumOfSongs the number of songs in the block
-        * @param aAsc
-        */
-        void GetSongsInBlockL( const TArray<TMPXAttribute>& aAttrs,
-                               CMPXMediaArray& aMediaArray,
-                               TPtrC aTitle,
-                               TUint aNumOfSongs,
-                               TBool aAsc);
-
-
-        /**
-        * Get songs from the music collection starting at a particular offset
-        * ONLY use this as the first query to locate particular item. Should use
-        * GetSongsInBlockL() to fetch in blocks with a particular index
-        * @param aMediaArray Array to store the results
-        * @param aAttrs attributes to fetch
-        * @param aOffset offset to start reading
-        * @param aCount number of items to get
-        */
-        void GetSongsAtOffsetL( CMPXMediaArray& aMediaArray,
-                                const TArray<TMPXAttribute>& aAttrs,
-                                TInt aOffset,
-                                TInt aCount );
-
-        /**
-        * Returns all songs for a given artist.
-        * @param aArtistId artist to get the songs for
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetSongsForArtistL(TUint aArtistId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns all songs for a given album.
-        * @param aAlbumId album to get the songs for
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetSongsForAlbumL(TUint aAlbumId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns all songs for a given artist and album.
-        * @param aArtistId artist to get the songs for
-        * @param aAlbumId album to get the songs for
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetSongsForArtistAndAlbumL(TUint aArtistId, TUint aAlbumId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns all songs for a given genre.
-        * @param aGenreId genre to get the songs for
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetSongsForGenreL(TUint aGenreId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns all songs for a given composer.
-        * @param aComposerId composer to get the songs for
-        * @param aAttrs attributes to be retrieved
-        * @param aMediaArray returns the song attributes.
-        */
-        void GetSongsForComposerL(TUint aComposerId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns the duration of all songs.
-        * @return the duration value
-        */
-        TInt AllSongsDurationL();
-
-        /**
-        * Returns the duration for a specified artist.
-        * @param aArtistId artist to get the duration for
-        * @return the duration value
-        */
-        TInt ArtistDurationL(TUint aArtistId);
-
-        /**
-        * Returns the duration for a specified album.
-        * @param aAlbumId album to get the duration for
-        * @return the duration value
-        */
-        TInt AlbumDurationL(TUint aAlbumId);
-
-        /**
-        * Returns the duration for a specified artist and album.
-        * @param aArtistId artist to get the duration for
-        * @param aAlbumId album to get the duration for
-        * @return the duration value
-        */
-        TInt ArtistAlbumDurationL(TUint aArtistId, TUint aAlbumId);
-
-        /**
-        * Returns the duration for a specified genre.
-        * @param aGenreId genre to get the duration for
-        * @return the duration value
-        */
-        TInt GenreDurationL(TUint aGenreId);
-
-        /**
-        * Returns the duration for a specified composer.
-        * @param aComposerId composer to get the duration for
-        * @return the duration value
-        */
-        TInt ComposerDurationL(TUint aComposerId);
-
-        /**
-        * Returns the duration for the recently played songs.
-        * @return the duration value
-        */
-        TInt RecentlyPlayedDurationL();
-
-        /**
-        * Returns the duration for the most played songs.
-        * @return the duration value
-        */
-        TInt MostPlayedDurationL();
-
-        /**
-        * Returns the duration for the recently added songs.
-        * @return the duration value
-        */
-        TInt RecentlyAddedDurationL();
-
-        /**
-        * Find the songs for the selection criteria
-        * @param aGeneralId selection criteria (could be song/album/artist/genre/composer ID)
-        * @param aContainerId selection criteria (could be artist/album id)
-        * @param aType criteria type (EMPXItem or EMPXGroup)
-        * @param aCriteria selection criteria
-        * @param aAttrs the attributes to include for the artist(s) matching the
-        *        selection criteria
-        * @param aMediaArray returns the songs
-        */
-        void FindSongsL(TUint32 aGeneralId, TUint32 aContainerId, TMPXGeneralType aType,
-            const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Returns the track count for a given drive
-        * @param aDrive drive
-        * @return the count
-        */
-        TUint GetDriveTrackCountL(TInt aDrive);
-
-        /**
-        * Get URIs for a given number of tracks
-        * @param aDrive, specifies drive number for db selection
-        * @param aFromID, specifies unique ID of last record retrieved
-        * @param aRecords, specifies the number of records to get
-        * @param aUriArr, will contain all URIs on return
-        * @param aLastID, will contain unique ID of a last record in the array
-        */
-        void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                               CDesCArray& aUriArr, TInt& aLastID);
-
-        /**
-         * Get the ID of Artist which belongs to the specified Album
-		 * @param aId, the ID of Album
-         */
-        TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId);
-        
-        /**
-        * Signals the start of a refresh operation
-        */
-        void RefreshStartL();
-
-        /**
-        * Signals the end of a refresh operation
-        */
-        void RefreshEndL();
-
-    private:
-
-        /**
-        * Checks if the specified song exists.
-        * @param aId identifies the song
-        * @return ETrue if it exists, EFalse otherwise
-        */
-        TBool SongExistsL(TUint32 aSongId);
-
-        /**
-        * Update the media with information found in the Music table
-        * @param aMusicTable music table record
-        * @param aAttrs the attributes to include
-        * @param aMedia returns the song details
-        */
-        void UpdateMediaL(RSqlStatement& aMusicTable, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Update the media general attributes from the Music table
-        * @param aMusicTable music table view
-        * @param aAttrId the required attributes
-        * @param aMedia the media object to set
-        */
-        void UpdateMediaGeneralL(RSqlStatement& aMusicTable, const TUint aAttrId,
-            CMPXMedia& aMedia);
-
-        /**
-        * Update the media music attributes from the Music table
-        * @param aMusicTable music table view
-        * @param aAttrId the required attributes
-        * @param aMedia the media object to set
-        */
-        void UpdateMediaMusicL(RSqlStatement& aMusicTable, const TUint aAttrId,
-            CMPXMedia& aMedia);
-
-        /**
-        * Update the media audio attributes from the Music table
-        * @param aMusicTable music table view
-        * @param aAttrId the required attributes
-        * @param aMedia the media object to set
-        */
-        void UpdateMediaAudioL(RSqlStatement& aMusicTable, const TUint aAttrId,
-            CMPXMedia& aMedia);
-
-        /**
-        * Update the media MTP attributes from the Music table
-        * @param aMusicTable music table view
-        * @param aAttrId the required attributes
-        * @param aMedia the media object to set
-        */
-        void UpdateMediaMTPL(RSqlStatement& aMusicTable, const TUint aAttrId,
-            CMPXMedia& aMedia);
-
-        /**
-        * Adds a song to the Music table
-        * @param aSongId identifies the song
-        * @param aMedia contains the song attributes
-        * @param aDrive drive to add the song to
-        * @param aItemChangedMessages item changed messages to update
-        */
-        TBool DoAddSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive,
-            CMPXMessageArray* aItemChangedMessages);
-
-        /**
-        * Updates a song in the Music table
-        * @param aSongId identifies the song
-        * @param aMedia contains the song attributes
-        * @param aItemChangedMessages item changed messages to update or NULL
-        */
-        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia,
-            CMPXMessageArray* aItemChangedMessages);
-
-        /**
-        * Updates a song in the Music table
-        * @param aSongId identifies the song
-        * @param aMedia contains the song attributes
-        * @param aDrive drive to add the song to
-        * @param aItemChangedMessages item changed messages to update
-        * @param aRecordset current song record in the Music table.
-        *       Required to detect any field changes.
-        */
-        CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive,
-            CMPXMessageArray* aItemChangedMessages, RSqlStatement& aRecordset);
-
-        /**
-        * Get the DRM type of the given file
-        * @param aFile file
-        * @return DRM type.
-        */
-        TMCDrmType DRMTypeL(const TDesC& aFile);
-
-        /**
-        * Generate searching criteria for music table from the given criteria
-        * @param aGeneralId selection criteria (could be song/album/artist/genre/composer Id)
-        * @param aContainerId selection criteria (could be artist/album id)
-        * @param aType criteria type (EMPXItem or EMPXGroup)
-        * @param aCriteria input criteria
-        * @return a string containing the selection criteria. The ownership is passed to the caller.
-        */
-        HBufC* GenerateMusicMatchingCriteriaLC(TUint32 aGeneralId, TUint32 aContainerId,
-            TMPXGeneralType aType, const CMPXMedia& aCriteria);
-
-        /**
-        * Constructs the fields and corresponding values to be written into the music
-        * table for update and insert statements.
-        * @param aSongId identifies the song
-        * @param aMedia contains the new song attributes
-        * @param aItemChangedMessages item changed mesages to add to
-        * @param aMusicTable points to the existing record in the Music table for updates or NULL
-        *       for inserts
-        * @param aFields returns the field names to be updated
-        * @param aValues returns the field values to be updated
-        * @param aDrive drive the song is on
-        * @return ETrue if the change is visible in the UI
-        */
-        CMPXDbActiveTask::TChangeVisibility GenerateMusicFieldsValuesL(TUint32 aSongId, const CMPXMedia& aMedia,
-            CMPXMessageArray* aItemChangedMessages, RSqlStatement* aMusicTable,
-            CDesCArray& aFields, CDesCArray& aValues, TInt aDrive);
-
-        /**
-        * Generates the full URI from a music record.
-        * @param aMusicTable music table record
-        * @return Full URI string. The ownership is passed to the caller.
-        */
-        HBufC* ConstructUriL(RSqlStatement& aMusicTable, TUint32 aMediaId);
-
-        /**
-        * Checks if the specified category field (artist/album/genre/composer)
-        * will change and notifies the observer if so.
-        * @param aCategory identifies the category
-        * @param aMedia contains the new record attributes
-        * @param aAttribute corresponding attribute in the media parameter
-        * @param aColumnIndex column index in the recordset
-        * @param aMusicTable current record in the music table or NULL if this is an insert
-        * @param aDriveId drive ID the update is for
-        * @param aItemChangedMessages item changed messages to append to
-        * @param aItemId returns the category item ID
-        * @return ETrue if the field was modified
-        */
-        TBool UpdateCategoryFieldL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia,
-            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,
-        * EMPXMediaGeneralTitle, EMPXMediaGeneralUri, and EMPXMediaGeneralFlags
-        * @param aAttrs attributes to be checked
-        * @return ETrue if extra attributes are required
-        */
-        TBool ExtraFieldsRequired(const TArray<TMPXAttribute>& aAttrs);
-
-        /**
-        * Test whether the given media contains any supported attribute
-        * @param aMedia media to be tested
-        * @return ETrue if the media contains one or more supported attribute;
-        *  otherwise EFalse.
-        */
-		TBool IsSupported(const CMPXMedia& aMedia);
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void DropTableL(RSqlDatabase& aDatabase);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-    private:
-
-        /**
-        * C++ constructor
-        * @param aDbManager database manager to use for database interactions
-        */
-        CMPXDbMusic(CMPXDbManager& aDbManager, MMPXDbMusicObserver& aObserver);
-
-        /**
-        * Second phase constructor.
-        */
-        void ConstructL(CMPXResource& aResource);
-
-    private:
-
-        /**
-        * Column indexes in the music table
-        */
-		enum TMusicColumns
-			{
-			EMusicUniqueId = KMPXTableDefaultIndex,
-			EMusicDbFlag,
-			EMusicVolumeId,
-			EMusicTitle,
-			EMusicArtist,
-			EMusicArt,
-			EMusicDeleted,
-			EMusicLocation,
-			EMusicAlbumTrack,
-			EMusicPlayCount,
-			EMusicTimeAdded,
-			EMusicTimePlayed,
-			EMusicDuration,
-			EMusicSync,
-			EMusicModified,
-			EMusicAlbum,
-			EMusicGenre,
-			EMusicComposer,
-			EMusicReleaseDate,
-			EMusicRating,
-			EMusicComment,
-			EMusicCopyright,
-			EMusicUrl,
-			EMusicDRM,
-			EMusicLastPlayPosition,
-			EMusicSampleRate,
-			EMusicBitRate,
-			EMusicNumChannels,
-			EMusicCodec,
-			EMusicMimeType,
-			EMusicMTPDrmStatus,
-			EMusicArtistName,
-			EMusicAlbumName,
-			EMusicGenreName,
-			EMusicComposerName,
-			EMusicFieldCount
-			};
-
-         /*
-         * Unique ID for Queries with a lifetime
-         */
-         enum TMusicStatements
-             {
-             EOffsetQueryBasic = 0xabcd0001,
-             EAscQueryBasic = 0xabcd0002,
-             EDscQueryBasic = 0xabcd0003,
-             EOffSetQuery = 0xabcd0004,
-             EAscQuery = 0xabcd0005,
-             EDscQuery = 0xabcd0006
-             };
-
-    private:    // Data
-
-        // file extensions to check DRM type, owned
-        CDesCArrayFlat* iExtensionsDrm;
-        MMPXDbMusicObserver& iObserver;
-        TBool iRefresh;
-    };
-
-#endif // MPXDBMUSIC_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplaylist.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,335 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class manages the Playlist table and owns a
-*                CMPXPlaylistSongs instance for managing the PlaylistSongs and
-*                PlaylistSongInfo tables.
-*
-*                The Playlist table stores one record for each playlist.
-*
-*
-*/
-
-
-#ifndef MPXDBPLAYLIST_H
-#define MPXDBPLAYLIST_H
-
-// INCLUDES
-#include "mpxdbtable.h"
-
-// CLASS FORWARDS
-class RSqlStatement;
-class CMPXDbPlaylistSongs;
-class CMPXMedia;
-class CMPXMediaArray;
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing the playlist tables
-*
-* @lib MPXDbPlugin.lib
-*/
-class MMPXDbPlaylistObserver
-	{
-	public:
-		virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId) = 0;
-	};
-class CMPXDbPlaylist : public CMPXDbTable
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbPlaylist instance.
-        */
-        static CMPXDbPlaylist* NewL(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbManager instance on the cleanup stack.
-        */
-        static CMPXDbPlaylist* NewLC(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbPlaylist();
-
-    public:
-
-        /**
-        * Add a playlist to the playlist table.  If playlist already exists,
-        * it is updated.
-        * @param aMedia playlist media to be added to the collection
-        * @return The unique id of the playlist
-        */
-        TUint32 AddPlaylistL(const CMPXMedia& aMedia);
-
-        /**
-        * Add one or multiple songs to the playlist.
-        * @param aPlaylistId identifies the playlist
-        * @param aMediaArray contains the song information to be added
-        */
-        void AddSongsL(TUint32 aPlaylistId, const CMPXMediaArray& aMediaArray);
-
-        /**
-        * Update playlist info
-        * @param aMedia playlist object which contains playlist Id, file path,
-        *               timestamp, etc... to be updated in the playlist table
-        * @param aMessage change event message for the playlist updated
-        */
-        void UpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessage& aMessage, TInt aDriveId);
-
-        /**
-        * Update a playlist song
-        * @param aMedia song info
-        * @param aResetFlags indicates whether the song db flags should be reset or just updated
-        * @param aItemChangedMessages returns the change messages for the playlists updated
-        * @return ETrue if the change is visible in the UI
-        */
-        TBool UpdateSongL(const CMPXMedia& aMedia, TBool aResetFlags,
-            CMPXMessageArray* aItemChangedMessages = NULL);
-
-        /**
-        * Remove a playlist and return its URI
-        * @param aPlaylistId identifies the playlist
-        * @return HBufC containing the URI. Ownership is transferred.
-        */
-        HBufC* DeletePlaylistL(TUint32 aPlaylistId);
-
-        /**
-        * Remove a playlist
-        * @param aPlaylistId identifies the playlist
-        */
-        void DeletePlaylistNoUriL(TUint32 aPlaylistId);
-
-        /**
-        * Delete a song from the playlist tables.
-        * @param aSongId identifies the song
-        * @param aItemChangedMessages returns the item changed messages
-        */
-        void DeleteSongL(TUint32 aSongId, CMPXMessageArray& aItemChangedMessages);
-
-        /**
-        * Delete a song from the playlist tables.
-        * @param aPlaylistId identifies the playlist
-        * @param aSongId identifies the song
-        * @param aOrdinal song ordinal
-        */
-        void DeleteSongL(TUint32 aPlaylistId, TUint32 aSongId, TInt aOrdinal);
-
-        /**
-        * Remove all playlists.
-        */
-        void DeleteAllPlaylistsL();
-
-        /**
-        * Gets the total number of playlists.
-        * @return number of playlists
-        */
-        TInt CountL();
-
-        /**
-        * Get information on a specified playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aAttrs the attributes to include for the playlists found.
-        * @param aMedia returns the playlist information
-        */
-        void GetPlaylistL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Get all playlists
-        * @param aAttrs the attributes to include for the playlists found.
-        * @param aMediaArray returns the playlist information
-        */
-        void GetAllPlaylistsL(const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get the name of a playlist.
-        * @param aPlaylistId identifies the playlist
-        * @return name matching the specified playlist ID. Ownership is transferred.
-        */
-        HBufC* GetNameL(TUint32 aPlaylistId);
-
-        /**
-        * Get a playlist' uri
-        * @param aPlaylistId identifies the playlist
-        * @return URI matching the specified playlist ID. Ownership is transferred.
-        */
-        HBufC* GetUriL(TUint32 aPlaylistId);
-
-        /**
-        * Return the playlist ID for a specified URI.
-        * @param aUri URI of the playlistId
-        * @return playlist ID
-        */
-        TUint32 GetIdL(const TDesC& aUri);
-
-        /**
-        * Find playlist(s) which match(es) the selection criteria
-        * @param aCriteria selection criteria
-        * @param aAttrs the attributes to include for the playlist(s) matching the
-        *        selection criteria
-        * @param aMediaArray playlist(s) matching the selection criteria
-        */
-        void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMediaArray& aMediaArray);
-
-        /**
-        * Find the drive Id for a playlist
-        * @param aPlaylistId identifies the playlist
-        * @return corresponding drive id
-        */
-        TInt GetDriveIdL(TUint32 aPlaylistId);
-
-        /**
-        * Provides access to the songs for the current playlist.
-        * @return CMPXDbPlaylistSongs reference to be used to access the songs
-        */
-        CMPXDbPlaylistSongs& Songs();
-
-        /**
-        * Returns the playlist count for a given drive
-        * @param aDrive drive
-        * @return the count
-        */
-        TUint GetDrivePlaylistCountL(TInt aDrive);
-
-        /**
-        * Get URIs for a given number of playlists
-        * @param aDrive, specifies drive number for db selection
-        * @param aFromID, specifies unique ID of last record retrieved
-        * @param aRecords, specifies the number of records to get
-        * @param aUriArr, will contain all URIs on return
-        * @param aLastID, will contain unique ID of a last record in the array
-        */
-        void GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                  CDesCArray& aUriArr, TInt& aLastID);
-
-    private:
-
-        /**
-        * Update the media with information found in the Playlist table
-        * @param aRecord playlist table
-        * @param aAttrs the attributes to include for the playlist matching the
-        *        selection criteria
-        * @param aMedia returns playlist details
-        */
-        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Create playlist table view and have the current row point to aPlaylistId
-        * @param aPlaylistId ID of the playlist to match
-        * @return RSqlStatement with row pointing to selected aPlaylistId
-        * Function leaves with KErrNotFound if RSqlStatement is unable to initialize
-        * or row cannot be found
-        */
-        RSqlStatement GetPlaylistRecordL(TUint32 aPlaylistId);
-
-        /**
-        * Add a new playlist
-        * @param aMedia contains the playlist info
-        * @param aDriveId drive to add the playlist to
-        * @return ID of the new playlist
-        */
-        TUint32 DoAddPlaylistL(const CMPXMedia& aMedia, TInt aDriveId);
-
-        /**
-        * Update a playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aMedia contains the playlist info
-        * @param aDriveId drive to add the playlist to
-        * @param aMessage change event message for the playlist updated
-        */
-        void DoUpdatePlaylistL(TUint32 aPlaylistId, const CMPXMedia& aMedia, TInt aDriveId,
-            CMPXMessage& aMessage);
-
-        /**
-        * Sets the Time field for all playlists that contain the specified song to the
-        * current time
-        * @param aSongId identifies the song
-        * @param aItemChangedMessages if not NULL item changed messages are added for all
-        *           updated playlists
-        * @param aSongInPlaylists out parameter that flags if the song is part of a playlist or not
-        */
-        void UpdatePlaylistsForSongL(TUint32 aSongId, CMPXMessageArray* aItemChangedMessages,TBool &aSongInPlaylists);
-
-        /**
-        * Sets the Time field for a playlist to the current time.
-        * @param aPlaylistId identifies the playlist
-        * @param aDrive playlist drive
-        */
-        void UpdatePlaylistTimeL(TUint32 aPlaylistId, TInt aDrive);
-
-        TInt GetDrivePlaylistDuration(TUint32 aPlaylistId);
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void DropTableL(RSqlDatabase& aDatabase);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-     private:
-
-        /**
-        * C++ constructor
-        * @param aDbManager database manager to use for database interactions
-        */
-        CMPXDbPlaylist(CMPXDbManager& aDbManager, MMPXDbPlaylistObserver& aObserver);
-
-        /**
-        * Second phase constructor
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the playlist table
-        */
-        enum TPlaylistColumns
-            {
-            EPlaylistUniqueId = KMPXTableDefaultIndex,
-            EPlaylistVolumeId,
-            EPlaylistDbFlag,
-            EPlaylistSync,
-            EPlaylistName,
-            EPlaylistUri,
-            EPlaylistTime
-            };
-
-    private:    // Data
-
-        CMPXDbPlaylistSongs* iPlaylistSongs;
-		MMPXDbPlaylistObserver& iObserver;
-    };
-
-#endif // MPXDBPLAYLIST_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplaylistsongs.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,327 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for the functionality related to
-*                playlist songs. The class operates on two tables: PlaylistSongs
-*                and PlaylistSongInfo.
-*
-*                The PlaylistSongs table contains records for all song instances in
-*                playlists. For example if a playlist contains 7 songs, there will be 7
-*                corresponding records in the PlaylistSongs table, even if one song has
-*                multiple instances in the playlist.
-*
-*                The PlaylistSongInfo table contains one record for each song included
-*                in at least one playlist. Redundant song information is stored in this
-*                table to help with songs on different drives than the playlist.
-*
-*
-*/
-
-
-#ifndef MPXDBPLAYLISTSONGS_H
-#define MPXDBPLAYLISTSONGS_H
-
-// INCLUDES
-#include "mpxdbtable.h"
-
-// CLASS FORWARDS
-class CMPXMedia;
-class CMPXMediaArray;
-
-// CLASS DECLARATION
-
-/**
-* Responsible for managing the music table
-*
-* @lib MPXDbPlugin.lib
-*/
-class CMPXDbPlaylistSongs :
-    public CMPXDbTable
-    {
-    public:
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbPlaylistSongs instance.
-        */
-        static CMPXDbPlaylistSongs* NewL(CMPXDbManager& aDbManager);
-
-        /**
-        * Two-phased constructor.
-        * @param aDbManager database manager to use for database interactions
-        * @return New CMPXDbPlaylistSongs instance on the cleanup stack.
-        */
-        static CMPXDbPlaylistSongs* NewLC(CMPXDbManager& aDbManager);
-
-        /**
-        * Destructor
-        */
-        virtual ~CMPXDbPlaylistSongs();
-
-    public:
-
-        /**
-        * Add a song/songs to the given playlist
-        * @param aPlaylistId playlist id
-        * @param aMediaArray media array which contains the tracks to be added to the playlist
-        * @param aDriveId Drive Id of corresponding playlist
-        */
-        void AddSongsL(TUint32 aPlaylistId, const CMPXMediaArray& aMediaArray, TInt aDriveId);
-
-        /**
-        * Add a song to playlist songs table for the given playlist
-        * @param aPlaylistId id of the playlist to add the song to
-        * @param aDriveId drive the song is on
-        * @param aMedia song media to be added to the playlist songs table for the playlist
-        * @return song ID
-        */
-        TUint32 AddSongL(TUint32 aPlaylistId, const CMPXMedia& aMedia, TInt aDriveId);
-
-        /**
-        * Add a song to playlist songs table for the given playlist
-        * @param aPlaylistId id of the playlist to add the song to
-        * @param aOrdinal ordinal of the song to be added
-        * @param aDriveId drive the song is on
-        * @param aMedia song media to be added to the playlist songs table for the playlist
-        * @return song ID
-        */
-        TUint32 AddSongL(TUint32 aPlaylistId, TInt aOrdinal, const CMPXMedia& aMedia,
-            TInt aDriveId);
-
-        /**
-        * Update song info for a song in the playlist songs table
-        * @param aSongId identifies the song
-        * @param aMedia song information
-        * @param aResetFlags indicates whether the song db flags should be reset or just updated
-        * @param aUpdated returns ETrue if the song information has changed
-        */
-        TBool UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TBool aResetFlags,
-            TBool& aUpdated);
-
-        /**
-        * Update songs in a playlist to reflect playlist id change
-        * @param aPlaylistId identifies the songs in the playlist
-        * @param aNewPlaylistId specifies the new playlist id the songs should be associated with
-        */
-        void UpdateSongsL(TUint32 aPlaylistId, TUint32 aNewPlaylistId);
-
-        /**
-        * Reorder the song in the playlist
-        * @param aPlaylistId id of the playlist which contains the song to be reordered
-        * @param aSongId id of the song to be reordered
-        * @param aOriginalOrdinal the original ordinal of the song within the playlist.
-        *        Ordinal starts from 0.
-        * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
-        *        starts from 0.
-        */
-        void ReorderSongL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
-            TUint aOriginalOrdinal, TUint aNewOrdinal);
-
-        /**
-        * Remove the given song from all playlists
-        * @param aSongId ID of the song to remove
-        * @param aDriveId identifies the database to be updated
-        */
-        void DeleteSongL(TUint32 aSongId);
-
-        /**
-        * Remove a song from the playlist.
-        * @param aPlaylistId ID of the playlist to remove the song from
-        * @param aSongId Id of the song in the playlist to be removed
-        * @param aOrdinal the ordinal of the song in the playlist. This uniquely
-        *        identifies which song in the playlist to be removed; whereas song
-        *        ID doesn't because duplicate tracks in the playlist are allowed.
-        *        The position is relative to zero, i.e. zero implies that the song
-        *        at the beginning of the playlist is to be removed.
-        * @param aDriveId identifies the database to be updated
-        */
-        void DeleteSongL(TUint32 aPlaylistId, TUint32 aSongId, TInt aOrdinal, TInt aDriveId);
-
-        /**
-        * Remove all songs from the specified playlist
-        * @param aPlaylistId ID of the playlist.
-        * @param aDriveId identifies the database.
-        */
-        void DeleteSongsL(TUint32 aPlaylistId, TInt aDriveId);
-
-        /**
-        * Remove the songs for a given category from all playlists.
-        * @param aCategory identifies the category
-        * @param aCategoryId identifies the category item
-        * @param aDriveId identifies the database to be updated
-        */
-        void DeleteSongsForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
-            TInt aDriveId);
-
-        /**
-        * Remove the songs for a given category from all playlists.
-        * @param aCategory identifies the category
-        * @param aCategoryId identifies the category item
-        * @param aDriveId identifies the database to be updated
-        */
-        void DeleteSongsForArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId, TInt aDriveId);
-
-        /**
-        * Remove all songs from the playlist songs table
-        */
-        void DeleteAllSongsL();
-
-        /**
-        * Get ids of all songs in a playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aMediaArray returns songs' id
-        */
-        void GetSongsL(TUint32 aPlaylistId, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get ids of all songs in a playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aAttrs attributes to return
-        * @param aMediaArray returns songs' id
-        */
-        TBool GetSongsL( TUint32 aPlaylistId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
-
-        /**
-        * Get information on a song in a playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aSongId identifies the song
-        * @param aAttrs attributes to return
-        * @param aMedia returns song info
-        */
-        TBool GetSongL(TUint32 aPlaylistId, TUint32 aSongId,
-            const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
-
-        /**
-        * Get information on a song
-        * @param aSongId identifies the song
-        * @param aAttrs attributes to return
-        * @param aMedia returns song info
-        */
-        TBool GetSongL(const TMPXItemId& aSongId, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia*& aMedia);
-
-
-        /**
-        * Get the number of songs for a playlist
-        * @param aPlaylistId identifies the playlist
-        * @return number of songs
-        */
-        TInt CountL(TUint32 aPlaylistId);
-
-    private:
-
-        /**
-        * Update the media from the table
-        * @param aRecord playlist table view
-        * @param aAttrs the attributes to return
-        * @param aMedia updated with the playlist song info
-        */
-        void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
-            CMPXMedia& aMedia);
-
-        /**
-        * Get the number of instances of a song in a playlist
-        * @param aPlaylistId identifies the playlist
-        * @param aSongId identifies the song
-        * @return number of instances
-        */
-        TInt SongInstanceCountL(TUint32 aPlaylistId, TUint32 aSongId);
-
-        /**
-        * Get the number of instances of a song in the PlaylistSongs table.
-        * @param aSongId identifies the song
-        * @return number of instances
-        */
-        TInt SongCountL(TUint32 aSongId);
-
-        /**
-        * Checks if the specified song exists in the PlaylisySongInfo table.
-        * @param aDriveId drive to check or KDbManagerAllDrives
-        * @param aSongId identifies the song
-        * @return ETrue if it exists, EFalse otherwise
-        */
-        TBool SongInfoExistsL(TInt aDriveId, TUint32 aSongId);
-
-        /**
-        * Deletes all orphaned records in the PlaylistSongInfo table
-        * (songs not included in any playlist).
-        * @param aDriveId database to cleanup
-        */
-        void CleanupSongInfoL(TInt aDriveId);
-
-    private:    // from MMPXTable
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual void DropTableL(RSqlDatabase& aDatabase);
-
-        /**
-        * @see MMPXTable
-        */
-        virtual TBool CheckTableL(RSqlDatabase& aDatabase);
-
-    private:
-
-        /**
-        * C++ constructor
-        * @param aDbManager database manager to use for database interactions
-        */
-        CMPXDbPlaylistSongs(CMPXDbManager& aDbManager);
-
-        /**
-        * Safely construct things that can leave
-        */
-        void ConstructL();
-
-    private:
-
-        /**
-        * Column indexes in the playlist songs query
-        */
-        enum TPlaylistSongsColumns
-            {
-            EPlaylistSongsUniqueId = KMPXTableDefaultIndex,
-            EPlaylistSongsSongId,
-            EPlaylistSongsPlaylistId,
-            EPlaylistSongsOrdinal,
-            EPlaylistSongsVolumeId,
-            EPlaylistSongsDbFlag,
-            EPlaylistSongsUri,
-            EPlaylistSongsTitle
-            };
-
-        /**
-        * Column indexes in the playlist song info table
-        */
-        enum TPlaylistSongInfoColumns
-            {
-            EPlaylistSongInfoSongId = KMPXTableDefaultIndex,
-            EPlaylistSongInfoVolumeId,
-            EPlaylistSongInfoDbFlag,
-            EPlaylistSongInfoUri,
-            EPlaylistSongInfoTitle
-            };
-
-    };
-
-#endif // MPXDBPLAYLISTSONGS_H
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbplugin.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,794 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of collection Database Plugin interface
-*
-*/
-
-
-#ifndef MPXDBPLUGIN_H
-#define MPXDBPLUGIN_H
-
-// INCLUDES
-#include <badesca.h>
-#include <mpxcommonframeworkdefs.h>
-#include <mpxcollectionframeworkdefs.h>
-#include <mpxcollectionplugin.h>
-#include <mpxcollectionpath.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmessage2.h>
-
-#include "mpxdbactivetask.h"
-#include "mpxcollectiondb.hrh"
-
-// FORWARD DECLARATIONS
-class CMPXMedia;
-class CMPXDbHandler;
-class CMPXDrmMediaUtility;
-class CMPXMediaArray;
-class CMPXResource;
-struct TMPXOpenDataBlock;
-
-// CLASS DECLARATION
-
-/**
-* CMPXDbPlugin class
-* Implements the plugin interface.
-*
-* @lib MPXDbPlugin.lib
-*/
-NONSHARABLE_CLASS(CMPXDbPlugin) :
-    public CMPXCollectionPlugin,
-    public MMPXDbActiveTaskObserver
-    {
-public: // Constructors and destructor
-
-    /**
-    * Two-phased constructor
-    * @param aInitParams: initialization parameters
-    * @return object constructed
-    */
-    static CMPXDbPlugin* NewL (TAny* aInitParams);
-
-    /**
-    * Destructor
-    */
-    virtual ~CMPXDbPlugin();
-
-public: // from base classes
-
-    /**
-    * From CMPXCollectionPlugin
-    * Navigates to the given path. This method is serviced
-    * asynchronously and HandleOpenL is called upon completion
-    * @param aPath a path
-    * @param aAttrs attributes requested
-    * @param aFilter filter to apply or NULL if none
-    */
-    void OpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXFilter* aFilter);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Get the extended properties of the item referred to by the
-    * specified collection path.  This method is serviced asynchronously and
-    * HandleMediaL is called upon completion
-    * @param aPath a collection path referring to the item to retrieve the
-    *               extended properties for
-    * @param aAttrs array of attributes requested
-    * @param aCaps platsec capabilities of client requesting media; plug-in
-    *        should also verify its process capabilities (not yet supported)
-    * @aParam aSpecs specifications for attributes (not yet supported)
-    */
-    void MediaL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        const TArray<TCapability>& aCaps, CMPXAttributeSpecs* aSpecs);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Cancel outstanding request. Note*** CancelRequest is not currently
-    * implemented because all requests are processed synchronously
-    */
-    void CancelRequest();
-
-    /**
-    * From CMPXCollectionPlugin
-    * Executes the given TMPXCollectionCommand command on the collection
-    * @param aCmd a command
-    * @param aArg an argument
-    */
-    void CommandL (TMPXCollectionCommand aCmd, TInt aArg = 0);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Executes the given CMPXCommand command on the collection
-    * @param aCmd a command
-    */
-    void CommandL(CMPXCommand& aCmd);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Adds an item (song or playlist) to the collection
-    * @param aMedia Properties of the item
-    */
-    void AddL(const CMPXMedia& aMedia);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Remove an item from the collection database using the given path
-    * Note that the selection indices are hidden within the path
-    * @param aPath path to the item to be removed
-    *
-    */
-    void RemoveL(const CMPXCollectionPath& aPath);
-
-    /**
-    *  Remove item(s) from the collection database using the given media properties
-    *  @param aMedia Properties of the item(s) to be removed. May cantain a URI
-    *           or metadata. All item(s) matching the specified properties
-    *           will be removed.
-    */
-    void RemoveL(const CMPXMedia& aMedia);
-
-    /**
-    *  Sets/updates the specified media for an item in the collection.  Media
-    *  is identified by specifying an ID or URI.
-    *  @param aMedia new property values for the item
-    */
-    void SetL(const CMPXMedia& aMedia);
-
-    /**
-    * From CMPXCollectionPlugin
-    *  Find the items matching the media specifications.  This method is serviced
-    *  asynchronously and HandleFindAllL is called upon completion
-    *  @param aCriteria Properties of the item that is to be found
-    *  @param aAttrs Requested attributes to return
-    */
-    void FindAllL (const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs);
-
-    /**
-    *  From CMPXCollectionPlugin
-    *  Find the items matching the media specifications
-    *  @param aCriteria Properties of the item that is to be found
-    *  @param aAttrs Requested attributes to return
-    *  @return results of the search. Method abandons ownership of results.
-    */
-    CMPXMedia* FindAllSyncL(const CMPXMedia& aCriteria,
-        const TArray<TMPXAttribute>& aAttrs);
-
-    /**
-    * From CMPXCollectionPlugin
-    * Get the list of supported capabilities
-    * @return TCollectionCapability, bitmask of supported capabilities
-    */
-    TCollectionCapability GetCapabilities ();
-
-    /**
-    * From MMPXDbActiveTaskObserver
-    */
-    TBool HandleStepL();
-
-    /**
-    * From MMPXDbActiveTaskObserver
-    */
-    void HandleOperationCompleted(TInt aErr);
-
-private:
-    /**
-    * Constructor
-    */
-    CMPXDbPlugin();
-
-    /**
-    * Symbian 2nd phase constructor.
-    */
-    void ConstructL();
-
-    /**
-    * Process the OpenL command
-    * @param aPath a path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aFilter CMPXFilter Object
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntries, CMPXFilter* aFilter );
-
-    /**
-    * Process the OpenL(EBrowseAll) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowseAllL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process the OpenL(EBrowseArtist) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowseArtistL(const CMPXCollectionPath& aPath,
-        const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process the OpenL(EBrowseAlbum) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowseAlbumL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process the OpenL(EBrowsePlaylist) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowsePlaylistL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process the OpenL(EBrowseGenre) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowseGenreL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-       CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process the OpenL(EBrowseComposer) command
-    * @param aPath Path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries (Output parameter) collection items containing media properties
-    *                  of all items, returned if opening a group of items
-    * @param aArray (Output parameter) collection items
-    * @return ETrue if the open is for a song, EFalse otherwise
-    */
-    TBool DoOpenBrowseComposerL(const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Process an OpenL command with a EMPXOpenPlaylistOnly open mode
-    * @param aPath path that we want to open
-    * @param aAttrs default attributes to fetch
-    * @return CMPXCollectionPath* which is the new valid browse path
-    */
-    CMPXCollectionPath* DoOpenPlaylistL( const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs );
-
-    /**
-    * Process the MediaL command
-    * @param aPath a path
-    * @param aAttrs Requested attributes to return
-    * @param aEntries collection items containing media properties of all items, returned if opening a group of items
-    */
-    void DoMediaL (const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries);
-
-    /**
-    * Get the plugin title, subtitle, icons for this plugin
-    * @param aAttrs attributes to find
-    * @param aMedia media object
-    */
-    void DoRootMediaL(const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
-
-    /**
-    * Get the media under ALL SONGS category
-    * @param aPath path that leads to a media under ALL SONGS
-    * @param aAttrs attributes of media to find
-    * @param aEntries the media referred by the path
-    * @param aMediaArray media entries contained in the media referred by the path
-    */
-    void DoAllSongsMediaL(const CMPXCollectionPath& aPath,
-                            const TArray<TMPXAttribute>& aAttrs,
-                            CMPXMedia& aEntries,
-                            CMPXMediaArray& aMediaArray);
-
-    /**
-    * Get the media under ARTISTS category
-    * @param aPath path that leads to a media under ARTISTS
-    * @param aAttrs attributes of media to find
-    * @param aEntries the media referred by the path
-    * @param aMediaArray media entries contained in the media referred by the path
-    */
-    void DoArtistMediaL(const CMPXCollectionPath& aPath,
-                          const TArray<TMPXAttribute>& aAttrs,
-                          CMPXMedia& aEntries,
-                          CMPXMediaArray& aMediaArray);
-
-    /**
-    * Get the root media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
-    * @param aAttrs attributes of media to find
-    * @param aRootCategoryId Id of the root media in the category, i.e. all albums,
-    *        ...etc.
-    * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
-    *        EMPXGenre, or EMPXComposer
-    * @param aEntries the media referred by the path
-    */
-    void DoRootCategoryMediaL(const TArray<TMPXAttribute>& aAttrs,
-                               TMPXItemId aRootCategoryId,
-                               TMPXGeneralCategory aCategory,
-                               CMPXMedia& aEntries);
-
-    /**
-    * Get the media under album/playlist/genre/composer category
-    * @param aPath path that leads to a media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
-    * @param aAttrs attributes of media to find
-    * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
-    *        EMPXGenre, or EMPXComposer
-    * @param aEntries the media referred by the path
-    * @param aMediaArray medias contained in the media referred by the path
-    */
-    void DoCategoryMediaL(const CMPXCollectionPath& aPath,
-                           const TArray<TMPXAttribute>& aAttrs,
-                           TMPXGeneralCategory aCategory,
-                           CMPXMedia& aEntries,
-                           CMPXMediaArray& aMediaArray);
-
-    /**
-    * Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm
-    * @param aMedia, media to update
-    * @param aDrmAttributes, bitwise or of the flags we want
-    * @param aLocation, full file path including filename
-    */
-    void DoSetMediaDrmL(CMPXMedia& aMedia, TUint aDrmAttributes, const TDesC& aLocation);
-
-    /**
-    * Add media objects to the array with attributes from song details
-    * @param aPath a path
-    * @param aAttrs requested attributes
-    * @param aEntry media to contain information about the container if it contains
-    *        than one entry
-    * @param aMediaArray array to contain all the media objects added
-    */
-    void GetSongInfoL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
-        CMPXMedia& aEntry, CMPXMediaArray& aMediaArray);
-
-    /**
-    * Add media objects to the array with attributes from song details
-    * @param aAttrs requested attributes
-    * @param aEntryId song ID
-    * @param aPlaylistId corresponding playlist ID, if 0 the attributes will be read from
-    *        the songs table, otherwise they will be read from the playlist table.
-    * @param aEntry media to contain information about the container if it contains
-    *        than one entry
-    */
-    void DoGetSongInfoL(const TArray<TMPXAttribute>& aAttrs, TInt aEntryId, TInt aPlaylistId,
-        CMPXMedia& aEntry);
-
-    /**
-    * Get the collection details from the db
-    * @param aAttrs, attributes to find
-    * @param aMedia, media object
-    */
-    void DoHandleOtherMediaAttributesL(const TArray<TMPXAttribute>& aAttrs,
-        const CMPXCollectionPath& aPath, CMPXMedia& aMedia);
-
-    /**
-    * Remove an item from the collection database using the given path
-    * Note that the selection indices are hidden within the path
-    * @param aPath path to the item to be removed
-    * @param aChangeMsgArray array to store change messages
-    * @return an array of files associated with the removed media entries
-    */
-    CDesCArray* DoRemoveL(const CMPXCollectionPath& aPath,
-        CMPXMessageArray& aChangeMsgArray);
-
-    /**
-    * Remove an item/items from the collection database using the given media properties
-    * @param aMedia: Properties of the item that is to be removed. It may cantain URI only
-    *                or meta data, all of items matched properties will be removed.
-    * @param aDeleteRecord: indicates whether the client has explictly requested
-    *                to delete the records from the database. If ETrue, records
-    *                associated with the media will be deleted from the database;
-    *                if EFalse, whether to mark the records as deleted or to delete
-    *                the records will be based on other deciding factors.
-    */
-    void DoRemoveL(const CMPXMedia& aMedia, TBool aDeleteRecord);
-
-    /**
-    * Remove an item from the collection database using a command
-    * @param aCmd: remove command which contains collection path to the media(s) to be
-    *        removed. This method should be called until all the selected items are
-    *        removed. When that happens, EMPXCommandCompleted flag is set to ETrue.
-    *        see KMPXCommandIdCollectionRemove in mpxcollectioncommanddefs.h
-    */
-    void DoRemovePathL(CMPXCommand& aCmd);
-
-    /**
-    * Remove a media/medias from the collection database using a command
-    * @param aCmd: remove command which contains the media(s) to be removed. This
-    *        will delete the records from the database rather than marking them
-    *        as deleted. Designated caller is MTP.
-    */
-    void DoRemoveMediaL(CMPXCommand& aCmd);
-
-    /**
-    * Remove a media/medias from all songs view
-    * @param aPath, collection path that points to the media items to be removed
-    * @param aSelections, multiple media items selected. This array contains the id
-    *        of the selected media.
-    * @param aUriArray: a descriptor array containing the URI(s) of the deleted file(s)
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void DoRemoveFromAllSongsL(const CMPXCollectionPath& aPath,
-                               const TArray<TMPXItemId>& aSelections,
-                               CDesCArray& aUriArray,
-                               CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media/medias from artists view
-    * @param aPath, collection path that points to the media(s) to be removed
-    * @param aSelections, multiple media items selected. This array contains the id
-    *        of the selected media.
-    * @param aUriArray: a descriptor array to contain the URI of the deleted file
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void DoRemoveFromArtistsL(const CMPXCollectionPath& aPath,
-                              const TArray<TMPXItemId>& aSelections,
-                              CDesCArray& aUriArray,
-                              CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media/medias from artists view
-    * @param aPath, collection path that points to the media(s) to be removed
-    * @param aItemId media item to be removed.
-    * @param aUriArray: a descriptor array to contain the URI of the deleted file
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void RemoveFromArtistsL(const CMPXCollectionPath& aPath,
-                                TUint32 aItemId,
-                                CDesCArray& aUriArray,
-                                CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media entry/entries from albums/genres/composers view
-    * @param aPath, collection path that points to the media entry/entries to be removed
-    * @param aSelections, multiple media entries selected. This array contains the id
-    *        of the selected media.
-    * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
-    *        EMPXComposer
-    * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void DoRemoveFromCategoriesL(const CMPXCollectionPath& aPath,
-                                 const TArray<TMPXItemId>& aSelections,
-                                 TMPXGeneralCategory aCategory,
-                                 CDesCArray& aUriArray,
-                                 CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media entry from albums/genres/composers view
-    * @param aPath, collection path that points to the media entry/entries to be removed
-    * @param aItemId item ID to be removed.
-    * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
-    *        EMPXComposer
-    * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void RemoveFromCategoriesL(const CMPXCollectionPath& aPath,
-                                TUint32 aItemId,
-                                TMPXGeneralCategory aCategory,
-                                CDesCArray& aUriArray,
-                                CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media entry/entries from playlists view
-    * @param aPath, collection path that points to the media(s) to be removed
-    * @param aSelections, multiple medias selected. This array contains the id
-    *        of the selected media.
-    * @param aUriArray: a descriptor array to contain the URI of the deleted file
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void DoRemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
-                                const TArray<TMPXItemId>& aSelections,
-                                CDesCArray& aUriArray,
-                                CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Remove a media entry/entries from playlists view
-    * @param aPath, collection path that points to the media(s) to be removed
-    * @param aItemId item to be removed
-    * @param aIndex item index to be removed
-    * @param aUriArray: a descriptor array to contain the URI of the deleted file
-    * @param aItemChangedMessages: a list of change events as a result of the
-    *        song removals
-    */
-    void RemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
-                                const TMPXItemId& aItemId,
-                                TInt aIndex,
-                                CDesCArray& aUriArray,
-                                CMPXMessageArray& aItemChangedMessages);
-
-    /**
-    * Retrieves URIs associated with the path for file deletion
-    * @param aCmd, command to retrieve associated URIs for the given path. If
-    *        path ends with a particular artist/album/genre/composer, the path
-    *        will be updated to include all songs in that category. If path
-    *        ends with one or more medias in a particular playlist, an array
-    *        of 0 elements will be returned to avoid client deleting them from
-    *        the file system. see KMPXCommandIdCollectionRetrieveUriForDeletion
-    *        defined in mpxcollectioncommanddefs.h
-    */
-    void DoRetrieveUriForDeletionL(CMPXCommand& aCmd);
-
-    /**
-    * Deletes records which have been marked as deleted from the collection
-    * @param aCmd command to cleanup deleted medias.
-    *        see KMPXCommandIdCollectionCleanupDeletedRecords defined in
-    *        mpxcollectioncommanddefs.h
-    */
-    void CleanupDeletedRecordsL(CMPXCommand& aCmd);
-
-    /**
-    * Fetch the duration for a specific category
-    * @param aMedia a media object of which EMPXMediaGeneralDuration is to be
-    *        populated with the duration calculated in this method
-    * @param aFirstCat category of the 1st Id
-    * @param aId id for identifying which category to calculate the duration for
-    * @param aSecondCat category of the 2nd Id
-    * @param aSubId 2nd id for identifying which category to calculate the
-    *        duration for. For example, to calculate the duration of an album of
-    *        a particular artist, 1st Id provided will be the artist Id and the
-    *        2nd Id provided will be the album Id.
-    */
-    TInt DoDurationL(CMPXMedia& aMedia, TMPXGeneralCategory aFirstCat, TMPXItemId aId = 0,
-                      TMPXGeneralCategory aSecondCat = EMPXNoCategory, TMPXItemId aSubId = 0);
-
-    /**
-    * Append a collection level to the collection path
-    * @param aPath, path to append the level to
-    * @param aMedia, media to extract media ids from
-    * @note: Selection will be put on the first song in the collection path
-    */
-    TInt DoAppendLevelL(CMPXCollectionPath& aPath, CMPXMedia& aMedia);
-
-    /**
-    * Append a collection level to the collection path with all songs under the
-    * selected category/categories (e.g. artist/artist-album/album/genre/composer).
-    * Once the level is appended, all songs under the selected category/categories
-    * are selected.
-    * @param aPath, path to append the level to. Path remains unchanged if it's not
-    *        one of the following:
-    *        1) path ends at an artist or selected artists
-    *        2) path ends at an album of an artist or selected albums of an artist
-    *        3) path ends at an album or selected albums
-    *        4) path ends at a genre or selected genres
-    *        5) path ends at a composer or selected composers
-    */
-    void DoAppendLevelL(CMPXCollectionPath& aPath);
-
-    /**
-    * Execute a task step for an asynchronous add
-    */
-    TBool DoAddAsyncL();
-
-    /**
-    * Add a media object to the collection
-    * @param aMedia media to add
-    * @return TUint32 item id of the item added
-    */
-    TUint32 DoAddL(const CMPXMedia& aMedia);
-
-    /**
-    * Add an item into the collection
-    * @param aMedia media to add
-    * @param aMessageArray change message array
-    */
-    TUint32 DoAddItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray,
-                        TBool aBatchCommit = EFalse);
-
-    /**
-    * Set a media object to update the collection
-    * @param aMedia media can be an item or a list. The item is treated as a list
-    *               if it contains a media array
-    */
-    void DoSetL(const CMPXMedia& aMedia);
-
-    /**
-    * Execute a task step for an asynchronous set
-    */
-    TBool DoSetAsyncL();
-
-    /**
-    * Set an item media to update the collection
-    * @param aMedia media to update
-    * @param aMessageArray array to append change messages
-    * @return ETrue if the update is UI visible, EFalse otherwise
-    */
-    CMPXDbActiveTask::TChangeVisibility DoSetItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
-
-    /**
-    * Set the drm properties for an array of medias
-    * @param mediaArray CMPXMediaArray list of medias
-    * @param aAtts attribute list
-    */
-    void DoSetDrmForArrayL(const CMPXMediaArray& mediaArray,
-                            const TArray<TMPXAttribute>& aAttrs);
-
-    /**
-    * Send a change message
-    *
-    * @param aMessage: a change message to be sent
-    */
-    void HandleChangeL(const CMPXMessage& aMessage);
-
-    /**
-    * Construct a CMPXMedia from the array parameter and call HandleChange
-    *
-    * @param aItemChangedMessages: array in the change message to be sent
-    * @param aCommandid command that was executed
-    */
-    void DoHandleChangeL(CMPXMessageArray* aItemChangedMessages,
-                         TMPXCommandId aCommandId = 0 );
-
-    /**
-    * Returns the category for a given browse type.
-    *
-    * @param aBrowseType browse type
-    * @return Category ID
-    */
-    TMPXGeneralCategory CategoryForBrowseType(TMCBrowseType aBrowseType);
-
-    /**
-    * Returns the browse type for a given category ID.
-    *
-    * @param aCategory category ID
-    * @return Browse type
-    */
-    TMCBrowseType BrowseTypeForCategory(TMPXGeneralCategory aCategory);
-
-    /**
-    * Sets the type, category and title attributes in the specified media.
-    *
-    * @param aMedia media instance to be updated
-    * @param aType type attribute value
-    * @param aCategory category attribute value
-    * @param aTitle title attribute value
-    */
-    void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
-        TMPXGeneralCategory aCategory, const TDesC& aTitle);
-
-    /**
-    * Sets the type, category and title attributes in the specified media.
-    *
-    * @param aMedia media instance to be updated
-    * @param aType type attribute value
-    * @param aCategory category attribute value
-    * @param aId ID of the item to the title from
-    */
-    void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
-        TMPXGeneralCategory aCategory, TInt aId);
-
-    /**
-    * Leaving function to handle async op completion
-    * @param aErr error code
-    */
-    void DoHandleOperationCompletedL(TInt aErr);
-
-    /**
-    * Complete a delete operation
-    * Sends out change messages and compacts the database
-    */
-    void DoHandleDeleteCompleteL( CMPXCommand& aCmd );
-
-    /**
-    * Reorder a song in a playlist
-    * @param aCmd command to reoder a song in a playlist
-    *        see KMPXCommandIdReorderPlaylist defined in
-    *        mpxcollectioncommanddefs.h
-    */
-    void DoReorderPlaylistL( const CMPXCommand& aCmd );
-
-    /**
-    * Get total song and playlist count
-    * @param aCmd command to return count
-    *        see KMPXCommandCollectionGetCount defined in
-    *        mpxcollectioncommanddefs.h
-    */
-    void DoGetCollectionCountL( const CMPXCommand& aCmd );
-
-    /**
-    * Get an array of URIs for all songs and playlists in a given db
-    * @param aCmd command to return CDesCArray
-    *        see KMPXCommandCollectionGetURIs defined in
-    *        mpxcollectioncommanddefs.h
-    */
-    void DoGetCollectionUriL( const CMPXCommand& aCmd );
-
-    /**
-    * Perform 1 step of the incremental read operation
-    * @param aCmd Command to process
-    */
-    void DoIncrementalOpenL( const CMPXCommand& aCmd );
-
-    /**
-    * Open the all songs view incrementally
-    * @param aPath path that leads to a media under ALL SONGS
-    * @param aAttrs attributes of media to find
-    * @param aEntries the media referred by the path
-    * @param aMediaArray media entries contained in the media referred by the path
-    */
-    TBool DoOpenIncrementalL( const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
-                              CMPXMedia& aEntries, CMPXMediaArray* aArray);
-
-    /**
-    * Set the attribute list according to current path
-    * @param aPath a path
-    * @param aAttrs attributes array to be filled
-    * @param aSupportedIds array of supported content IDs to be filled
-    */
-    void SetAttributesL( const CMPXCollectionPath& aPath, RArray<TMPXAttribute>& aAttrs,
-                         RArray<TInt>& aSupportedIds );
-
-#ifdef _DEBUG
-    /**
-    * Prints messages for debugging
-    * @param aMessage: message(s) to be printed
-    */
-    void PrintMessagesL(const CMPXMessage& aMessage);
-
-    /**
-    * Prints a single message for debugging
-    * @param aMessage: a message to be printed
-    */
-    void PrintMessage(const CMPXMessage& aMessage);
-#endif // _DEBUG
-
-private:
-    // owned member variables
-    RFs                  iFs;
-    CMPXResource*        iResource;
-    CMPXDbHandler*       iDbHandler;
-    CMPXDrmMediaUtility* iDrmMediaUtility;
-    CDesCArrayFlat*      iMusicLibraryMenuTitles;      // titles for each of the menu items
-    CDesCArrayFlat*      iMusicLibraryTitles;          // titles for each of the category views
-    RArray<TInt>         iMusicLibraryMenuIds;         // music library item menu IDs
-    HBufC*               iAllSongsForArtistTitle;
-    HBufC*               iMusicMenuTitle;
-    TBool                iDisablePodcasting;
-    TBool                iMtpInUse;
-    TBool                iRefreshing;
-    CMPXDbActiveTask*    iActiveTask;
-    RArray<TMPXItemId>   iSelections;   //selected items in the path
-    TBool iFirstDeleteStep;
-    TBool iAllSongsValid;    //to indicate if there's enough space to get all songs information from collection DB.
-    };
-
-#endif   // MPXDBPLUGIN_H
-
-
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbpluginqueries.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,402 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  SQLite queries for MPX collection db
-*
-*/
-
-
-#ifndef MPXDBPLUGINQUERIES_H
-#define MPXDBPLUGINQUERIES_H
-
-// SQLite queries
-
-// == Music table queries =====================================================
-//
-_LIT(KMusicCreateTable, "CREATE TABLE Music("
-    L"UniqueId INTEGER PRIMARY KEY,"
-    L"DbFlag INTEGER,"
-    L"VolumeId INTEGER,"
-    L"Title TEXT COLLATE NOCASE,"
-    L"Artist INTEGER,"
-    L"Art TEXT,"
-    L"Deleted INTEGER DEFAULT 0,"
-    L"Location TEXT,"
-    L"AlbumTrack INTEGER,"
-    L"PlayCount INTEGER DEFAULT 0,"
-    L"TimeAdded TEXT,"
-    L"TimePlayed TEXT DEFAULT '',"
-    L"Duration INTEGER,"
-    L"Sync INTEGER DEFAULT 0,"
-    L"Modified INTEGER DEFAULT 0,"
-    L"Album INTEGER,"
-    L"Genre INTEGER,"
-    L"Composer INTEGER,"
-    L"ReleaseDate TEXT DEFAULT '',"
-    L"Rating INTEGER,"
-    L"Comment TEXT,"
-    L"Copyright TEXT,"
-    L"Url TEXT,"
-    L"DRM INTEGER,"
-    L"LastPlayPosition INTEGER DEFAULT 0,"
-    L"SampleRate INTEGER,"
-    L"BitRate INTEGER,"
-    L"NumChannels INTEGER,"
-    L"Codec INTEGER,"
-    L"MimeType TEXT,"
-    L"MTPDrmStatus INTEGER)");
-
-_LIT(KMusicDropTable,"DROP TABLE Music");
-_LIT(KMusicCheckTable,"SELECT UniqueId,Title,Location,Artist,Album,AlbumTrack,Genre,Composer,Duration,ReleaseDate,TimeAdded,PlayCount,TimePlayed,Rating,Comment,Copyright,Art,DbFlag,Sync,Modified,Deleted,Url,DRM,LastPlayPosition,SampleRate,BitRate,VolumeId,NumChannels,Codec,MimeType,MTPDrmStatus FROM Music");
-
-// indexes
-_LIT(KMusicDeletedIdIndex,"CREATE INDEX IndexMusicDeletedId ON Music(Deleted,UniqueId)");
-_LIT(KMusicDeletedTitleIndex,"CREATE INDEX IndexMusicDeletedTitle ON Music(Deleted,Title)");
-_LIT(KMusicDeletedArtistTitleIndex,"CREATE INDEX IndexMusicArtistDeletedTitle ON Music(Artist,Deleted,Title)");
-_LIT(KMusicDeletedAlbumTitleIndex,"CREATE INDEX IndexMusicAlbumDeletedTitle ON Music(Album,Deleted,Title)");
-_LIT(KMusicDeletedAlbumTrackTitleIndex,"CREATE INDEX IndexMusicAlbumDeletedTrackTitle ON Music(Album,Deleted,AlbumTrack,Title)");
-_LIT(KMusicDeletedGenreTitleIndex,"CREATE INDEX IndexMusicGenreDeletedTitle ON Music(Genre,Deleted,Title)");
-_LIT(KMusicDeletedComposerTitleIndex,"CREATE INDEX IndexMusicComposerDeletedTitle ON Music(Composer,Deleted,Title)");
-
-_LIT(KQueryMusicInsert, "INSERT INTO :dbname.Music(%S) VALUES(%S)");
-_LIT(KQueryMusicUpdate, "UPDATE :dbname.Music SET %S WHERE UniqueId=%u");
-_LIT(KQueryMusicDelete, "DELETE FROM :dbname.Music WHERE UniqueId=%u");
-_LIT(KQueryMusicDeleteUpdate, "UPDATE :dbname.Music SET Deleted=1 WHERE UniqueId=%u");
-_LIT(KQueryMusicDeleteForCategory, "UPDATE :dbname.Music SET Deleted=0 WHERE %S=%u");
-_LIT(KQueryMusicCleanup, "DELETE FROM :dbname.Music WHERE Deleted=1");
-
-// Note: The no categories queries below only retrieve a limited number of fields from the Music table
-//       as opposed to *. This is an optimization that matches the DBMS version of the plugin and assumes
-//       that the client only requests those fields. From the C++ code perspective there is no difference
-//       in processing as the five fields in question reside at the beginning of the table. If the client
-//       is modified to request more attributes then the queries below will have to be changed to return *.
-//
-//       As far as performance goes, the queries that only return six fields are a little faster than
-//       the ones that return *, for example, for a * query that takes 2.1 seconds the equivalent
-//       optimized query is faster by more than 100ms.
-
-_LIT(KQueryMusicGetSong, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.UniqueId=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId");
-
-// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
-// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
-// calculate column number from SELECT fields, first field is column 1 (not 0)
-/*
-_LIT(KQueryMusicGetAllSongs, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
-_LIT(KQueryMusicGetSongsForArtist, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
-_LIT(KQueryMusicGetSongsForAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.AlbumTrack, Music.Title");
-_LIT(KQueryMusicGetSongsForUnknownAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
-_LIT(KQueryMusicGetSongsForArtistAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.AlbumTrack, Music.Title");
-_LIT(KQueryMusicGetSongsForGenre, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Genre=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
-_LIT(KQueryMusicGetSongsForComposer, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Composer=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.Title");
-_LIT(KQueryMusicGetRecentlyPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.TimePlayed<>'' AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetMostPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.PlayCount<>0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetRecentlyAdded, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND (julianday(Music.TimeAdded)>julianday('now','-7 days')) AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY Music.TimeAdded DESC");
-*/
-_LIT(KQueryMusicGetAllSongs, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
-_LIT(KQueryMusicGetSongsForArtist, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
-_LIT(KQueryMusicGetSongsForAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 9, 4");
-_LIT(KQueryMusicGetSongsForUnknownAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
-_LIT(KQueryMusicGetSongsForArtistAlbum, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Artist=%u AND Music.Album=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 9, 4");
-_LIT(KQueryMusicGetSongsForGenre, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Genre=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
-_LIT(KQueryMusicGetSongsForComposer, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.Composer=%u AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 4");
-_LIT(KQueryMusicGetRecentlyPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.TimePlayed<>'' AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 12 DESC LIMIT %u");
-_LIT(KQueryMusicGetMostPlayed, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND Music.PlayCount<>0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetRecentlyAdded, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Music.Deleted=0 AND (julianday(Music.TimeAdded)>julianday('now','-7 days')) AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId ORDER BY 11 DESC");
-
-_LIT(KQueryMusicSong, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE %S");
-_LIT(KQueryMusicFindAll, "SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE %S AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId %S");
-
-// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
-// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
-// calculate column number from SELECT fields, first field is column 1 (not 0)
-/*
-_LIT(KQueryMusicFindAllSortOrderTrack, "ORDER BY Music.AlbumTrack,Music.Title");
-_LIT(KQueryMusicFindAllSortOrderTitle, "ORDER BY Music.Title");
-*/
-_LIT(KQueryMusicFindAllSortOrderTrack, "ORDER BY 9, 4");
-_LIT(KQueryMusicFindAllSortOrderTitle, "ORDER BY 4");
-
-// no categories queries
-_LIT(KQueryMusicGetSongNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryMusicGetAllSongsNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 ORDER BY Title");
-_LIT(KQueryMusicGetSongsForArtistNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Title");
-_LIT(KQueryMusicGetSongsForAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,AlbumTrack FROM :dbname.Music WHERE Deleted=0 AND Album=%u ORDER BY AlbumTrack,Title");
-_LIT(KQueryMusicGetSongsForUnknownAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Album=%u ORDER BY Title");
-_LIT(KQueryMusicGetSongsForArtistAlbumNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,AlbumTrack FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u ORDER BY AlbumTrack,Title");
-_LIT(KQueryMusicGetSongsForGenreNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Genre=%u ORDER BY Title");
-_LIT(KQueryMusicGetSongsForComposerNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location FROM :dbname.Music WHERE Deleted=0 AND Composer=%u ORDER BY Title");
-_LIT(KQueryMusicGetRecentlyPlayedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetMostPlayedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC, TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetRecentlyAddedNoCategories, "SELECT UniqueId,DbFlag,VolumeId,Title,0,'',0,Location,TimeAdded FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded)>julianday('now','-7 days')) ORDER BY TimeAdded DESC");
-
-_LIT(KQueryMusicGetSongsInBlockAsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title > :title ORDER BY 4 ASC LIMIT :limit");
-_LIT(KQueryMusicGetSongsInBlockDsc, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId AND Title < :title ORDER BY 4 DESC LIMIT :limit");
-_LIT(KQueryMusicGetSongsAtOffset, "SELECT Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT :limit OFFSET :offset");
-_LIT(KQueryMusicGetSongsLimited, "Select Music.UniqueId,Music.DbFlag,Music.VolumeId,Music.Title,Music.Artist,Music.Art,0,'',0,0,'','',0,0,0,0,0,0,0,0,'','','',0,0,0,0,0,0,'',0,Artist.Name FROM :dbname.Music,:dbname.Artist WHERE Deleted=0 AND Music.Artist=Artist.UniqueId ORDER BY 4 LIMIT %u");
-
-_LIT(KQueryMusicGetUri, "SELECT Location,VolumeId FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryMusicGetTitle, "SELECT Title FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryMusicGetMusicUris, "SELECT UniqueId,Location FROM :dbname.Music WHERE Deleted=0 ORDER BY UniqueId ASC LIMIT %u");
-_LIT(KQueryMusicGetMusicUrisFrom, "SELECT UniqueId,Location FROM :dbname.Music WHERE Deleted=0 AND UniqueId > %u ORDER BY UniqueId ASC LIMIT %u");
-
-_LIT(KQueryMusicCount, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0");
-_LIT(KQueryMusicAlbum, "SELECT DISTINCT Album FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Album");
-_LIT(KQueryMusicVolume, "SELECT VolumeId FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryMusicVolumeAll, "SELECT VolumeId FROM :dbname.Music WHERE UniqueId=%u");
-_LIT(KQueryMusicInfo, "SELECT * FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryOtherSongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND UniqueId<>%u AND Artist=%u AND Album=%u");
-
-_LIT(KQueryMusicDurationAll, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0");
-_LIT(KQueryMusicDurationArtist, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u");
-_LIT(KQueryMusicDurationAlbum, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Album=%u");
-_LIT(KQueryMusicDurationArtistAlbum, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u");
-_LIT(KQueryMusicDurationGenre, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Genre=%u");
-_LIT(KQueryMusicDurationComposer, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Composer=%u");
-_LIT(KQueryMusicDurationRecentlyPlayed, "SELECT sum(Duration) FROM (SELECT Duration,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u)");
-_LIT(KQueryMusicDurationMostPlayed, "SELECT sum(Duration) FROM (SELECT Duration,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC,TimePlayed DESC LIMIT %u)");
-_LIT(KQueryMusicDurationRecentlyAdded, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded) > julianday('now','-7 days'))");
-
-_LIT(KQueryMusicGetDurationRecentlyPlayed, "SELECT Duration,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND TimePlayed<>'' ORDER BY TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetDurationMostPlayed, "SELECT Duration,PlayCount,TimePlayed FROM :dbname.Music WHERE Deleted=0 AND PlayCount<>0 ORDER BY PlayCount DESC,TimePlayed DESC LIMIT %u");
-_LIT(KQueryMusicGetDurationRecentlyAdded, "SELECT Duration FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded) > julianday('now','-7 days'))");
-
-// Select songs information from music, playlistsongs and playlistsonginfo via playlistid order by playlistsongs's ordinal
-_LIT(KQueryMusicGetAllSongsbyPl,"select mu.UniqueId,mu.DbFlag,mu.VolumeId,mu.Title,mu.Artist,mu.Art,0,mu.Location,pl.UniqueId as PlUId, pl.ordinal from :dbname.music as mu,:pldbname.playlistsongs as pl where mu.Deleted=0 AND mu.uniqueid = pl.songid and pl.playlistid =%u ORDER BY 10");
-_LIT(KQueryMusicGetAllSongsInfobyPl,"SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name,pl.UniqueId as PlUId,pl.ordinal FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer,:pldbname.playlistsongs as pl WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId AND Music.UniqueId=pl .songid and pl .PlaylistId=%u ORDER BY 37");
-
-_LIT(KQuerySongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u");
-_LIT(KQueryMusicGetArtistForAlbum, "SELECT Artist FROM :dbname.Music,:dbname.Artist WHERE Music.Deleted=0 AND Music.Artist=Artist.UniqueId AND Music.Album=%u");
-
-// == Category table queries ==================================================
-//
-_LIT(KCategoryTablePlaceholder, "##table##");
-
-_LIT(KCategoryCreateTable,"CREATE TABLE ##table##("
-    L"UniqueId INTEGER PRIMARY KEY,"
-    L"Name TEXT COLLATE NOCASE,"
-    L"SongCount INTEGER)");
-
-_LIT(KCategoryDropTable,"DROP TABLE ##table##");
-_LIT(KCategoryCheckTable,"SELECT UniqueId,Name,SongCount FROM ##table##");
-_LIT(KCategoryNameIndex,"CREATE INDEX Index##table##Name ON ##table##(Name)");
-
-_LIT(KQueryCategoryInsert, "INSERT INTO :dbname.##table##(UniqueId,Name,SongCount) VALUES(%u,'%S',%u)");
-_LIT(KQueryCategoryDelete, "DELETE FROM :dbname.##table## WHERE UniqueId=%u");
-
-_LIT(KQueryCategoryCount, "SELECT count(*) FROM :dbname.##table##");
-_LIT(KQueryCategoryItem, "SELECT * FROM :dbname.##table## WHERE UniqueId=%u");
-_LIT(KQueryCategoryItemBySongId, "SELECT ##table##.* FROM :dbname.##table##,:dbname.Music WHERE Music.Deleted=0 AND Music.UniqueId=%u AND ##table##.UniqueId=Music.%S");
-_LIT(KQueryCategoryAll, "SELECT * FROM :dbname.##table## ORDER BY Name");
-_LIT(KQueryCategoryItems, "SELECT * FROM :dbname.##table## WHERE %S ORDER BY Name ASC");
-_LIT(KQueryCategorySongCount, "SELECT SongCount FROM :dbname.##table## WHERE UniqueId=%u");
-_LIT(KQueryCategorySubcategoryItems, "SELECT Album.* FROM :dbname.Album,:dbname.Music WHERE Music.Deleted=0 AND Music.Artist=%u AND Album.UniqueId=Music.Album ORDER BY Name");
-
-_LIT(KQueryCategoryIncrementSongCount, "UPDATE :dbname.##table## SET SongCount=SongCount+1 WHERE UniqueId=%u");
-_LIT(KQueryCategoryDecrementSongCount, "UPDATE :dbname.##table## SET SongCount=SongCount-1 WHERE UniqueId=%u");
-_LIT(KQueryCategoryGetSongCount, "SELECT SongCount FROM :dbname.##table## WHERE UniqueId=%u");
-
-// == Auxiliary table queries =================================================
-//
-_LIT(KAuxiliaryCreateTable, "CREATE TABLE Auxiliary("
-    L"Id INTEGER,"
-    L"Version TEXT,"
-    L"TimeRefreshed TEXT,"
-    L"TimeSynced TEXT,"
-    L"Corrupt INTEGER DEFAULT 0,"
-    L"SaveDeletedRecordCount INTEGER DEFAULT 0)");
-_LIT(KAuxiliaryDropTable,"DROP TABLE Auxiliary");
-_LIT(KAuxiliaryCheckTable, "SELECT Id,Version,TimeRefreshed,TimeSynced,Corrupt,SaveDeletedRecordCount FROM AUXILIARY");
-_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.4.0',%u)");
-
-_LIT(KQueryAuxiliarySetTime, "UPDATE :dbname.Auxiliary SET TimeRefreshed='%S', Corrupt=0");
-_LIT(KQueryAuxiliaryGetTime, "SELECT TimeRefreshed FROM :dbname.Auxiliary");
-_LIT(KQueryAuxiliarySetCorrupt, "UPDATE :dbname.Auxiliary SET Corrupt=%u");
-_LIT(KQueryAuxiliaryGetCorrupt, "SELECT Corrupt FROM :dbname.Auxiliary");
-_LIT(KQueryAuxiliaryGetCount, "SELECT SaveDeletedRecordCount FROM :dbname.Auxiliary");
-_LIT(KQueryAuxiliarySetCount, "UPDATE :dbname.Auxiliary SET SaveDeletedRecordCount=%u");
-_LIT(KQueryAuxiliaryGetId, "SELECT Id FROM :dbname.Auxiliary");
-_LIT(KQueryAuxiliarySetId, "UPDATE :dbname.Auxiliary SET Id=%u");
-
-// == Playlist table queries ==================================================
-//
-_LIT(KPlaylistCreateTable, "CREATE TABLE Playlist("
-    L"UniqueId INTEGER PRIMARY KEY,"
-    L"VolumeId INTEGER,"
-    L"DbFlag INTEGER,"
-    L"Sync INTEGER,"
-    L"Name TEXT COLLATE NOCASE,"
-    L"Uri TEXT,"
-    L"Time TEXT)");
-_LIT(KPlaylistDropTable,"DROP TABLE Playlist");
-_LIT(KPlaylistCheckTable, "SELECT UniqueId,Name,Uri,VolumeId,Sync,DbFlag,Time FROM Playlist");
-_LIT(KPlaylistNameIndex,"CREATE INDEX IndexPlaylistName ON Playlist(Name)");
-
-_LIT(KQueryPlaylistInsert, "INSERT INTO :dbname.Playlist(UniqueId,Name,Uri,VolumeId,Sync,DbFlag,Time) VALUES(%u,'%S','%S',%u,0,%u,'%S')");
-_LIT(KQueryPlaylistUpdate, "UPDATE :dbname.Playlist SET %S WHERE UniqueId=%u");
-_LIT(KQueryPlaylistUpdateTime, "UPDATE :dbname.Playlist SET Time='%S' WHERE UniqueId=%u");
-_LIT(KQueryPlaylistUpdateTimeForSong, "UPDATE :dbname.Playlist SET Time='%S' WHERE UniqueId IN (SELECT DISTINCT PlaylistId FROM :dbname.PlaylistSongs WHERE SongId=%u)");
-_LIT(KQueryPlaylistDeleteAll, "DELETE FROM :dbname.Playlist");
-_LIT(KQueryPlaylistDelete, "DELETE FROM :dbname.Playlist WHERE UniqueId=%u");
-
-_LIT(KQueryPlaylistCount, "SELECT count(*) FROM :dbname.Playlist");
-_LIT(KQueryPlaylistGetAll, "SELECT * FROM :dbname.Playlist ORDER BY Name ASC");
-_LIT(KQueryPlaylistGet, "SELECT * FROM :dbname.Playlist WHERE UniqueId=%u");
-_LIT(KQueryPlaylistDuration, "SELECT sum(Music.Duration) FROM :dbname.Music,:dbname.Playlist,:dbname.PlaylistSongs WHERE Music.UniqueId=PlaylistSongs.SongId AND PlaylistSongs.PlaylistId=%u");
-_LIT(KQueryPlaylistId, "SELECT UniqueId FROM :dbname.Playlist WHERE Uri='%S'");
-_LIT(KQueryLikePlaylistId, "SELECT UniqueId FROM :dbname.Playlist WHERE Uri LIKE '%%%%%S%%%%' ESCAPE '\\'");
-_LIT(KQueryPlaylistDriveId, "SELECT VolumeId FROM :dbname.Playlist WHERE UniqueId=%u");
-_LIT(KQueryPlaylistItems, "SELECT * FROM :dbname.Playlist WHERE %S ORDER BY Name ASC");
-_LIT(KQueryPlaylistGetForSong, "SELECT DISTINCT PlaylistId FROM :dbname.PlaylistSongs WHERE SongId=%u");
-_LIT(KQueryPlaylistFileCount, "SELECT count(*) FROM :dbname.Playlist WHERE Uri LIKE '%%.m3u'");
-//see "Efficient Use of Symbinan SQL How-To Document" for details about following queries:
-_LIT(KQueryPlaylistGetFileUris, "SELECT UniqueId,Uri FROM :dbname.Playlist WHERE Uri LIKE '%%%%.m3u' ORDER BY UniqueId ASC LIMIT %u");
-_LIT(KQueryPlaylistGetFileUrisFrom, "SELECT UniqueId,Uri FROM :dbname.Playlist WHERE Uri LIKE '%%%%.m3u' AND UniqueId > %u ORDER BY UniqueId ASC LIMIT %u");
-
-// == PlaylistSongs table queries =============================================
-//
-_LIT(KPlaylistSongsCreateTable, "CREATE TABLE PlaylistSongs("
-    L"UniqueId INTEGER PRIMARY KEY AUTOINCREMENT,"
-    L"SongId INTEGER,"
-    L"PlaylistId INTEGER,"
-    L"Ordinal INTEGER)");
-_LIT(KPlaylistSongsDropTable,"DROP TABLE PlaylistSongs");
-_LIT(KPlaylistSongsCheckTable, "SELECT UniqueId,SongId,PlaylistId,Ordinal FROM PlaylistSongs");
-
-_LIT(KQueryPlaylistSongsInsert, "INSERT INTO :dbname.PlaylistSongs(PlaylistId,SongId,Ordinal) VALUES(%u,%u,%u)");
-_LIT(KQueryPlaylistSongsUpdate, "UPDATE :dbname.PlaylistSongs SET SongId=%u WHERE SongId=%u");
-_LIT(KQueryPlaylistSongsUpdatePlaylistId, "UPDATE :dbname.PlaylistSongs SET PlaylistId=%u WHERE PlaylistId=%u");
-_LIT(KQueryPlaylistSongsDelete, "DELETE FROM :dbname.PlaylistSongs WHERE SongId=%u");
-_LIT(KQueryPlaylistSongsDeleteAll, "DELETE FROM :dbname.PlaylistSongs");
-_LIT(KQueryPlaylistSongsDeletePlaylist, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u");
-_LIT(KQueryPlaylistSongsDeleteSong, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u");
-_LIT(KQueryPlaylistSongsDeleteSongOrdinal, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u AND Ordinal=%u");
-_LIT(KQueryPlaylistSongsDeleteForCategory, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistSongs.SongId=Music.UniqueId AND Music.%S=%u");
-_LIT(KQueryPlaylistSongsDeleteForArtistAlbum, "DELETE FROM :dbname.PlaylistSongs WHERE PlaylistSongs.SongId=Music.UniqueId AND Music.Artist=%u AND Music.Album=%u");
-
-_LIT(KQueryPlaylistSongsCount, "SELECT count(*) FROM :dbname.PlaylistSongs WHERE PlaylistId=%u");
-_LIT(KQueryPlaylistSongsPlaylistSongCount, "SELECT count(*) FROM :dbname.PlaylistSongs WHERE PlaylistId=%u AND SongId=%u");
-_LIT(KQueryPlaylistSongsSongCount, "SELECT count(*) FROM :dbname.PlaylistSongs WHERE SongId=%u");
-_LIT(KQueryPlaylistSongsGetSongs, "SELECT UniqueId,SongId,Ordinal FROM :dbname.PlaylistSongs WHERE PlaylistId=%u ORDER BY Ordinal");
-
-// LTAN-79N8ND: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
-// Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
-// calculate column number from SELECT fields, first field is column 1 (not 0)
-//_LIT(KQueryPlaylistSongsGetSong, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.PlaylistId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId ORDER BY PlaylistSongs.Ordinal");
-_LIT(KQueryPlaylistSongsGetSong, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.PlaylistId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId ORDER BY 4");
-_LIT(KQueryPlaylistSongsGetSongsInfo, " SELECT PlaylistSongs.*,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.SongId=PlaylistSongInfo.SongId AND PlaylistSongs.PlaylistId=%u ORDER BY 4");
-
-_LIT(KQueryPlaylistSongsGetSongInfo, "SELECT PlaylistSongs.UniqueId,PlaylistSongs.SongId,PlaylistSongs.PlaylistId,PlaylistSongs.Ordinal,PlaylistSongInfo.VolumeId,PlaylistSongInfo.DbFlag,PlaylistSongInfo.Uri,PlaylistSongInfo.Title FROM :dbname.PlaylistSongs,:dbname.PlaylistSongInfo WHERE PlaylistSongs.UniqueId=%u AND PlaylistSongs.SongId=%u AND PlaylistSongs.SongId=PlaylistSongInfo.SongId");
-
-_LIT(KQueryPlaylistSongsUpdateSongOrdinalAfterDelete, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal-1 WHERE PlaylistId=%u AND Ordinal>%u");
-_LIT(KQueryPlaylistSongsUpdateSongOrdinal, "UPDATE :dbname.PlaylistSongs SET Ordinal=%u WHERE UniqueId=%u");
-_LIT(KQueryPlaylistSongsMoveSongUp, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal+1 WHERE PlaylistId=%u AND Ordinal>=%u AND Ordinal<%u");
-_LIT(KQueryPlaylistSongsMoveSongDown, "UPDATE :dbname.PlaylistSongs SET Ordinal=Ordinal-1 WHERE PlaylistId=%u AND Ordinal<=%u AND Ordinal>%u");
-
-// == PlaylistSongInfo table queries ==========================================
-//
-_LIT(KPlaylistSongInfoCreateTable, "CREATE TABLE PlaylistSongInfo("
-    L"SongId INTEGER PRIMARY KEY,"
-    L"VolumeId INTEGER,"
-    L"DbFlag INTEGER,"
-    L"Uri TEXT,"
-    L"Title TEXT COLLATE NOCASE)");
-_LIT(KPlaylistSongInfoDropTable,"DROP TABLE PlaylistSongInfo");
-_LIT(KPlaylistSongInfoCheckTable, "SELECT SongId,VolumeId,DbFlag,Uri,Title FROM PlaylistSongInfo");
-
-_LIT(KQueryPlaylistSongInfoInsert, "INSERT INTO :dbname.PlaylistSongInfo(SongId,Uri,Title,VolumeId,DbFlag) VALUES(%u,'%S','%S',%u,%u)");
-_LIT(KQueryPlaylistSongInfoDelete, "DELETE FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
-_LIT(KQueryPlaylistSongInfoDeleteAll, "DELETE FROM :dbname.PlaylistSongInfo");
-_LIT(KQueryPlaylistSongInfoCleanup, "DELETE FROM :dbname.PlaylistSongInfo WHERE SongId NOT IN (SELECT DISTINCT SongId FROM :dbname.PlaylistSongs)");
-_LIT(KQueryPlaylistSongInfoUpdateTitle, "UPDATE :dbname.PlaylistSongInfo SET Title='%S' WHERE SongId=%u");
-_LIT(KQueryPlaylistSongInfoUpdate, "UPDATE :dbname.PlaylistSongInfo SET SongId=%u,Uri='%S',VolumeId=%u WHERE SongId=%u");
-_LIT(KQueryPlaylistSongInfoUpdateFlags, "UPDATE :dbname.PlaylistSongInfo SET DbFlag=%u WHERE SongId=%u");
-
-_LIT(KQueryPlaylistSongInfoExists, "SELECT SongId FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
-_LIT(KQueryPlaylistSongInfoGet, "SELECT * FROM :dbname.PlaylistSongInfo WHERE SongId=%u");
-
-// == Criteria strings ========================================================
-//
-// Music criteria
-_LIT(KCriterionMusicUniqueId, "Music.UniqueId=%u");
-_LIT(KCriterionMusicNotDeleted, "Music.Deleted=0");
-_LIT(KCriterionMusicArtist, "Music.artist=%u");
-_LIT(KCriterionMusicAlbum, "Music.album=%u");
-_LIT(KCriterionMusicGenre, "Music.genre=%u");
-_LIT(KCriterionMusicComposer, "Music.composer=%u");
-// SQLite requires LIKE statement to include an ESCAPE clause if an escaped percentage
-// or underscore is to be used as regular search text instead of pattern matching
-// characters. See http://www.sqlite.org/lang_expr.html for an explanation. To supprt
-// partial title matching, our goal is to have the following statement as an example:
-//      SELECT * FROM Music WHERE title LIKE '%xyz%' ESCAPE '\'
-// To achieve this, we specify the format to be %%%%%S%%%%. The 1st percentage is the
-// escape character for string formatter to output the 2nd percentage sign. Similiarly
-// for the 3rd, 4th, 6th, 7th, 8th, and 9th. The 5th percentage instructs string formatter
-// to substitute a string, i.e. %S. After subsititution, we will have, for example, %%xyz%%.
-// Because this substituted string will be substituted again into a WHERE clause, we need
-// to escape the percentage signs in order to get %xyz% as the end result.
-_LIT(KCriterionMusicTitle, "Music.title LIKE '%%%%%S%%%%' ESCAPE '\\'");
-_LIT(KCriterionMusicVolume, "Music.VolumeId=%u");
-_LIT(KCriterionMusicLocation, "Music.Location='%S'");
-_LIT(KCriterionMusicSync, "Music.Sync=%u");
-_LIT(KCriterionMusicDeleted, "Music.Deleted=%u");
-_LIT(KCriterionMusicModified, "Music.Modified=%u");
-
-// Category criteria
-_LIT(KCriterionCategoryUniqueId, "##table##.UniqueId=%u");
-_LIT(KCriterionCategoryName, "##table##.Name LIKE '%%%%%S%%%%' ESCAPE '\\'");
-
-// Playlist criteria
-_LIT(KCriterionPlaylistUniqueId, "UniqueId=%u");
-_LIT(KCriterionPlaylistVolumeId, "VolumeId=%u");
-_LIT(KCriterionPlaylistTitle, "Name='%S'");
-_LIT(KCriterionPlaylistLikeTitle, "Name LIKE '%%%%%S%%%%' ESCAPE '\\'");
-_LIT(KCriterionPlaylistUri, "Uri='%S'");
-_LIT(KCriterionPlaylistSync, "Sync=%u");
-_LIT(KCriterionPlaylistTime, "Time='%S'");
-
-// PlaylistSongs criteria
-_LIT(KCriterionPlaylistSongId, "PlaylistSongs.SongId=%u");
-
-// == Album table queries ==========================================
-//
-_LIT(KAlbumCreateTable,"CREATE TABLE Album("
-    L"UniqueId INTEGER PRIMARY KEY,"
-    L"Name TEXT COLLATE NOCASE,"
-    L"SongCount INTEGER,"
-    L"Artist INTEGER,"
-	L"Art TEXT)");
-
-_LIT(KAlbumCheckTable,"SELECT UniqueId,Name,SongCount,Artist,Art FROM Album");
-
-_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,Name,SongCount,Artist,Art) VALUES(%u,'%S',%u,%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 2");
-
-// == Artist table queries ==========================================
-//
-_LIT(KArtistCreateTable,"CREATE TABLE Artist("
-    L"UniqueId INTEGER PRIMARY KEY,"
-    L"Name TEXT COLLATE NOCASE,"
-    L"SongCount INTEGER,"
-    L"Art TEXT)");
-
-_LIT(KArtistCheckTable,"SELECT UniqueId,Name,SongCount,Art FROM Artist");
-
-_LIT(KQueryArtistInsert, "INSERT INTO :dbname.Artist(UniqueId,Name,SongCount,Art) VALUES(%u,'%S',%u,'%S')");
-_LIT(KQueryArtistUpdate, "UPDATE :dbname.Artist SET %S WHERE UniqueId=%u");
-
-_LIT(KQueryArtistAll, "SELECT Artist.* FROM :dbname.Artist ORDER BY 2");
-
-#endif // MPXDBPLUGINQUERIES_H
--- a/mpserviceplugins/mpxsqlitedbplugin/inc/mpxdbutil.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  The class MPXDbUtil which contains utilities functions
-*
-*/
-
-
-#ifndef MPXDBUTIL_H
-#define MPXDBUTIL_H
-
-// INCLUDES
-#include <mpxmediageneraldefs.h>
-#include "mpxcollectiondbstd.h"
-
-// FORWARD DECLARATIONS
-class CMPXMedia;
-class CMPXMediaArray;
-
-// CLASS DECLARATION
-
-/**
-* This static class contains utilities functions used by Music Collection
-*
-* @lib MPXDbPlugin.lib
-*/
-class MPXDbUtil
-    {
-    public:
-        /**
-        * Filter out duplicated Ids in the array
-        * @param aIds array containing Ids to be filtered
-        * @param aFilteredIds filtered Ids without duplicates, generated from
-        *        the input array
-        */
-        static void FilterDuplicatedIdsL(const TArray<TUint32>& aIds,
-            RArray<TUint32>& aFilteredIds);
-
-        /**
-        * Returns the table name for a specified category
-        * @param aCategory identifies the category
-        * @return corresponding table name
-        */
-        static TPtrC TableNameForCategoryL(TMPXGeneralCategory aCategory);
-
-        /**
-        * Returns the music field name for a specified category
-        * @param aCategory identifies the category
-        * @return corresponding field name
-        */
-        static TPtrC MusicFieldNameForCategoryL(TMPXGeneralCategory aCategory);
-    };
-
-#endif // MPXDBUTIL_H
-
-// End of File
-
--- a/mpserviceplugins/mpxsqlitedbplugin/rom/mpxsqlitedbplugin.iby	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Image description file for project mpxsqlitedbplugin
-*
-*/
-
-
-
-#ifndef MPXSQLITEDBPLUGIN_IBY
-#define MPXSQLITEDBPLUGIN_IBY
-
-#include <data_caging_paths_for_iby.hrh>
-
-ECOM_PLUGIN( mpxsqlitedbplugin.dll, 0x101ffc3e.rsc )
-SCALABLE_IMAGE( APP_RESOURCE_DIR, APP_RESOURCE_DIR, mpxdbplugin )
-
-#endif // MPXSQLITEDBPLUGIN_IBY
--- a/mpserviceplugins/mpxsqlitedbplugin/rom/mpxsqlitedbpluginrsc.iby	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Image description file for project mpxsqlitedbplugin
-*
-*/
-
-
-
-#ifndef MPXSQLITEDBPLUGINRSC_IBY
-#define MPXSQLITEDBPLUGINRSC_IBY
-
-#include <data_caging_paths_for_iby.hrh>
-
-data=DATAZ_\APP_RESOURCE_DIR\mpxcollectiondbres.rsc     APP_RESOURCE_DIR\mpxcollectiondbres.rsc
-
-#endif // MPXSQLITEDBPLUGINRSC_IBY
--- a/mpserviceplugins/mpxsqlitedbplugin/rom/rom.pri	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-symbian {
-MP_IBY_DIR = $$section(PWD,":",1)
-
-BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/mpxsqlitedbplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(mpxsqlitedbplugin.iby)" \
-                             "$$MP_IBY_DIR/mpxsqlitedbpluginrsc.iby CORE_APP_LAYER_IBY_EXPORT_PATH(mpxsqlitedbpluginrsc.iby)"
-}
\ No newline at end of file
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxcollectiondbmanager.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is responsible for managing all of music collection
-*                databases.
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include "mpxcollectiondbdef.h"
-#include "mpxcollectiondbmanager.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXCollectionDbManager* CMPXCollectionDbManager::NewL(
-    RFs& aFs)
-    {
-    MPX_FUNC("CMPXCollectionDbManager::NewL");
-
-    CMPXCollectionDbManager* self = CMPXCollectionDbManager::NewLC(aFs);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXCollectionDbManager* CMPXCollectionDbManager::NewLC(
-    RFs& aFs)
-    {
-    MPX_FUNC("CMPXCollectionDbManager::NewLC");
-
-    CMPXCollectionDbManager* self = new (ELeave) CMPXCollectionDbManager(aFs);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXCollectionDbManager::~CMPXCollectionDbManager()
-    {
-    MPX_FUNC("CMPXCollectionDbManager::~CMPXCollectionDbManager");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXCollectionDbManager::CMPXCollectionDbManager(
-    RFs& aFs) :
-    CMPXDbManager(aFs)
-    {
-    MPX_FUNC("CMPXCollectionDbManager::CMPXCollectionDbManager");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXCollectionDbManager::ConstructL()
-    {
-    MPX_FUNC("CMPXCollectionDbManager::ConstructL");
-    CMPXDbManager::ConstructL(TFileName(KMCDbFile));
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbalbum.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,523 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the category tables:
-*                Artist, Album, Genre and Composer
-*
-*/
-
-
-// INCLUDE FILES
-#include <sqldb.h>
-
-#include <mpxlog.h>
-
-#include "mpxdbcommonutil.h"
-#include "mpxdbcommondef.h"
-#include "mpxdbmanager.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxmediamusicdefs.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbutil.h"
-#include "mpxdbalbum.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAlbum* CMPXDbAlbum::NewL(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbAlbumObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbAlbum::NewL");
-
-    CMPXDbAlbum* self = CMPXDbAlbum::NewLC(aDbManager, aCategory, aObserver);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAlbum* CMPXDbAlbum::NewLC(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbAlbumObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbAlbum::NewLC");
-
-    CMPXDbAlbum* self = new (ELeave) CMPXDbAlbum(aDbManager, aCategory, aObserver);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAlbum::~CMPXDbAlbum()
-    {
-    MPX_FUNC("CMPXDbAlbum::~CMPXDbAlbum");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAlbum::CMPXDbAlbum(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbAlbumObserver& aObserver) :
-    CMPXDbCategory(aDbManager, aCategory),
-    iObserver(aObserver)
-    {
-    MPX_FUNC("CMPXDbAlbum::CMPXDbAlbum");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::ConstructL()
-    {
-    MPX_FUNC("CMPXDbAlbum::ConstructL");
-
-    BaseConstructL();
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::AddItemL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbAlbum::AddItemL(
-    const TDesC& aName,
-    TUint32 aArtist,
-    const TDesC& aArt,
-    TInt aDriveId,
-    TBool& aNewRecord,
-    TBool aCaseSensitive)
-    {
-    MPX_FUNC("CMPXDbAlbum::AddItemL");
-    
-    // try to find the item first
-    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
-        aName, aCaseSensitive));
-    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
-
-    if (aNewRecord)
-        {      
-        // insert new
-        HBufC* query = PreProcessStringLC(KQueryAlbumInsert);
-        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
-		HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
-
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, aArtist, art);
-
-		CleanupStack::PopAndDestroy(art);
-        CleanupStack::PopAndDestroy(name);
-        CleanupStack::PopAndDestroy(query);
-        }
-    else
-        {
-        // retrieve the existing record
-        HBufC* query = NULL;
-        query = PreProcessStringLC(KQueryCategoryItem);
-        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
-        CleanupStack::PopAndDestroy(query);
-		
-        CleanupClosePushL(recordset);
-		
-        if (recordset.Next() != KSqlAtRow)
-            {
-            User::Leave(KErrNotFound);
-	    }
-
-        // Artist
-        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
-	    
-        // the current one is Unknown and the new one is Not Unknown.
-        if ( IsUnknownArtistL( artistId ) && !IsUnknownArtistL( aArtist ) )
-            {
-            _LIT( KFormatArtistId, "Artist=%d" );
-            HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
-            setStr->Des().Format( KFormatArtistId, aArtist );
-        
-            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
-            CleanupStack::PopAndDestroy(setStr);            
-            }
-	        
-        // Album Art
-        TPtrC art(KNullDesC);
-        art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt));
-	
-        // the current one is Unknown and the new one is Not Unknown
-        if ( art == KNullDesC && aArt != KNullDesC )
-            {
-            _LIT( KFormatArt, "Art=\'%S\'" );
-            HBufC* setStr = HBufC::NewLC(256);
-            setStr->Des().Format( KFormatArt, &aArt );
-            
-            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
-            CleanupStack::PopAndDestroy(setStr);		    
-            }
-		
-        CleanupStack::PopAndDestroy(&recordset);
-		
-        // increment the number of songs for the category
-        query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
-        CleanupStack::PopAndDestroy(query);
-        }
-
-    return rowId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::DecrementSongsForCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::DecrementSongsForCategoryL(
-    const TUint32 aId,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TBool& aItemExist,
-    const TUint32 aArtist)
-    {
-    MPX_FUNC("CMPXDbAlbum::DecrementSongsForCategoryL");
-
-    // if just one song uses this category. Use <= just in case
-    if (GetSongsCountL(aDriveId, aId) <= 1)
-        {
-        aItemExist = EFalse;
-        // delete the category
-        DeleteCategoryL(aId, aDriveId);
-
-        if (aItemChangedMessages)
-            {
-            // add the item changed message
-            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
-                iCategory, KDBPluginUid);
-            }
-        }
-    else
-        {
-        aItemExist = ETrue;
-        
-        // retrieve the existing record
-        HBufC* query = PreProcessStringLC(KQueryCategoryItem);
-        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId));
-        CleanupStack::PopAndDestroy(query);
-        
-        CleanupClosePushL(recordset);
-        
-        if (recordset.Next() != KSqlAtRow)
-            {
-            User::Leave(KErrNotFound);
-        }
-
-        TUint32 artistId = recordset.ColumnInt64(EAlbumArtist);
-        
-        CleanupStack::PopAndDestroy(&recordset);
-        
-        // the current artist is equal to deleted song's artist
-        if ( artistId == aArtist )
-            {
-            TUint32 newArtistId = ArtistForAlbumL(aId);
-            
-            _LIT( KFormatArtistId, "Artist=%d" );
-            HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen);
-            setStr->Des().Format(KFormatArtistId, newArtistId);
-        
-            iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
-            CleanupStack::PopAndDestroy(setStr);
-            
-            if (aItemChangedMessages)
-                {
-                // add the item changed message
-                MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
-                    iCategory, KDBPluginUid);
-                }
-            }
-
-        // decrement the number of songs for the category
-        query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
-        iDbManager.ExecuteQueryL(aDriveId, *query, aId);
-        CleanupStack::PopAndDestroy(query);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::GetAllCategoryItemsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::GetAllCategoryItemsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL");
-
-    HBufC* query = PreProcessStringLC(KQueryAlbumAll);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    CleanupClosePushL(recordset);
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::UpdateItemL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::UpdateItemL(
-    TUint32 aId, 
-    const CMPXMedia& aMedia, 
-    TInt aDriveId, 
-    CMPXMessageArray* aItemChangedMessages)
-	{
-	MPX_FUNC("CMPXDbAlbum::UpdateItemL");
-
-	CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EAlbumFieldCount);
-	CleanupStack::PushL(fields);
-	CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EAlbumFieldCount);
-	CleanupStack::PushL(values);
-
-	// process the media parameter and construct the fields and values array
-	GenerateAlbumFieldsValuesL(aMedia, *fields, *values);
-
-	// construct the SET string
-	HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
-
-    if (setStr->Length())
-        {
-        // execute the query
-        iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
-	    TInt oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;	
-	    MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
-            EMPXAlbum, KDBPluginUid, oldSongId );
-        }
-
-	CleanupStack::PopAndDestroy(setStr);
-	CleanupStack::PopAndDestroy(values);
-	CleanupStack::PopAndDestroy(fields);
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::GetAlbumsCountForArtistL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbAlbum::GetAlbumsCountForArtistL(TUint32 aArtistId)
-	{
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryCategorySubcategoryItems, aArtistId));
-
-    TInt prevId(0);
-    TInt count(0);
-	TInt err(KErrNone);
-	
-    while ((err = recordset.Next()) == KSqlAtRow)
-		{
-		TUint32 rowId(recordset.ColumnInt64(EAlbumUniqueId));
-        if (prevId == rowId)
-            {
-            continue;
-            }
-		
-		count++;
-		prevId = rowId;
-		}
-
-    if (err != KSqlAtEnd)
-        {
-        User::Leave(err);
-        }
-
-	return count;
-
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId)
-	{
-	MPX_FUNC("CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL");
-	
-	return ExecuteSumQueryL(KQuerySongsInArtistAlbum, aArtistId, aAlbumId);
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::UpdateMediaL(
-    RSqlStatement& aRecord,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbAlbum::UpdateMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-        TUint attributeId(aAttrs[i].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            if (attributeId & EMPXMediaGeneralId)
-                {
-                MPX_DEBUG1("    EMPXMediaGeneralId");
-                
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
-                    aRecord.ColumnInt64(EAlbumUniqueId));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                MPX_DEBUG1("    EMPXMediaGeneralTitle");
-                
-                TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) );
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
-                    MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName));
-                MPX_DEBUG2("	Album[%S]", &album );
-                }
-            if (attributeId & EMPXMediaGeneralCount)
-                {
-                MPX_DEBUG1("    EMPXMediaGeneralCount");
-
-				TInt songCount = GetSongsCountL(KDbManagerAllDrives,
-					aRecord.ColumnInt64(EAlbumUniqueId));
-                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
-				MPX_DEBUG2("	SongCount[%d]", songCount );
-                }
-            } // end if contentId == KMPXMediaIdGeneral
-		else if ( contentId == KMPXMediaIdMusic )
-			{
-			if (attributeId & EMPXMediaMusicArtist)
-				{				
-				MPX_DEBUG1("	EMPXMediaMusicArtist");
-
-				TPtrC artistName(KNullDesC);
-				
-				// if album is unknown, ignore arist name
-				if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
-					{
-					artistName.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName));
-					}
-				
-				aMedia.SetTextValueL(KMPXMediaMusicArtist, artistName);
-				MPX_DEBUG2("	Artist[%S]", &artistName);
-				}
-			if (attributeId & EMPXMediaMusicAlbumArtFileName)
-				{
-				MPX_DEBUG1("	EMPXMediaMusicAlbumArtFileName");
-
-				TPtrC art(KNullDesC);
-				
-				// if album is unknown, ignore album art name
-				if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
-					{
-					art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt));
-					}
-				
-				aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
-				MPX_DEBUG2("	Art[%S]", &art);
-				}
-			}
-		} // end for
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::GenerateAlbumFieldsValuesL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
-	{
-	if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
-		{
-		const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
-		MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
-		}
-		
-	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);	    
-	    }
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::IsUnknownArtistL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAlbum::IsUnknownArtistL(TUint32 aId)
-	{
-	return iObserver.HandleIsUnknownArtistL(aId);
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::ArtistForAlbumL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbAlbum::ArtistForAlbumL(const TUint32 aId)
-    {
-    return iObserver.HandleArtistForAlbumL(aId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbCategory::CreateTableL");
-
-    // create the table
-    HBufC* query = PreProcessStringLC(KAlbumCreateTable);
-    User::LeaveIfError(aDatabase.Exec(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    // do not create an index on the Name field
-    // as it only slows down the insert/update queries overall
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAlbum::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbCategory::CheckTableL");
-
-    HBufC* query = PreProcessStringLC(KAlbumCheckTable);
-    TBool check(DoCheckTable(aDatabase, *query));
-    CleanupStack::PopAndDestroy(query);
-
-    return check;
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbartist.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,375 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the Artist table
-*
-*
-*/
-
-
-// INCLUDE FILES
-#include <sqldb.h>
-
-#include <mpxlog.h>
-
-#include "mpxdbcommonutil.h"
-#include "mpxdbcommondef.h"
-#include "mpxmediamusicdefs.h"
-#include "mpxdbmanager.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbutil.h"
-#include "mpxdbartist.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbArtist* CMPXDbArtist::NewL(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbArtistObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbArtist::NewL");
-
-    CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory, aObserver);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbArtist* CMPXDbArtist::NewLC(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbArtistObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbArtist::NewLC");
-
-    CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory, aObserver);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbArtist::~CMPXDbArtist()
-    {
-    MPX_FUNC("CMPXDbArtist::~CMPXDbArtist");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbArtist::CMPXDbArtist(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory,
-    MMPXDbArtistObserver& aObserver) :
-    CMPXDbCategory(aDbManager, aCategory), 
-    iObserver(aObserver)
-    {
-    MPX_FUNC("CMPXDbArtist::CMPXDbArtist");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbArtist::ConstructL()
-    {
-    MPX_FUNC("CMPXDbArtist::ConstructL");
-
-    BaseConstructL();
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::AddItemL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbArtist::AddItemL(
-    const TDesC& aName,
-    const TDesC& aArt,
-    TInt aDriveId,
-    TBool& aNewRecord,
-    TBool aCaseSensitive)
-    {
-    MPX_FUNC("CMPXDbAlbum::AddItemL");
-    
-    // try to find the item first
-    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
-        aName, aCaseSensitive));
-    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
-
-    if (aNewRecord)
-        {      
-        // insert new
-        HBufC* query = PreProcessStringLC(KQueryArtistInsert);
-        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
-        HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
-
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, art);
-
-        CleanupStack::PopAndDestroy(art);
-        CleanupStack::PopAndDestroy(name);
-        CleanupStack::PopAndDestroy(query);
-        }
-    else
-        {
-        // retrieve the existing record
-        HBufC* query = NULL;
-        query = PreProcessStringLC(KQueryCategoryItem);
-        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
-        CleanupStack::PopAndDestroy(query);
-        
-        CleanupClosePushL(recordset);
-        
-        if (recordset.Next() != KSqlAtRow)
-            {
-            User::Leave(KErrNotFound);
-        }
-            
-        // Album Art
-        TPtrC art(KNullDesC);
-        art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt));
-    
-        // the current one is Unknown and the new one is Not Unknown
-        if ( art == KNullDesC && aArt != KNullDesC )
-            {
-            _LIT( KFormatArt, "Art=\'%S\'" );
-            HBufC* setStr = HBufC::NewLC(256);
-            setStr->Des().Format( KFormatArt, &aArt );
-            
-            iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId);
-            CleanupStack::PopAndDestroy(setStr);            
-            }
-        
-        CleanupStack::PopAndDestroy(&recordset);
-        
-        // increment the number of songs for the category
-        query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
-        CleanupStack::PopAndDestroy(query);
-        }
-
-    return rowId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::IsUnknownArtistL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbArtist::IsUnknownArtistL(TUint32 aId)
-    {
-	MPX_FUNC("CMPXDbArtist::IsUnknownArtistL");
-	
-    HBufC* name = GetNameL(aId);
-	
-	TInt ret = EFalse;
-	if (*name == KNullDesC)
-		{
-		ret = ETrue;
-		}
-	delete name;
-	
-	return ret;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbArtist::UpdateMediaL(
-    RSqlStatement& aRecord,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbArtist::UpdateMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-        TUint attributeId(aAttrs[i].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            if (attributeId & EMPXMediaGeneralId)
-                {
-                MPX_DEBUG1("	EMPXMediaGeneralId");
-				
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
-                    aRecord.ColumnInt64(EArtistUniqueId));
-				MPX_DEBUG2("	Id[%d]", aRecord.ColumnInt64(EArtistUniqueId));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                MPX_DEBUG1("	EMPXMediaGeneralTitle");
-				
-                TPtrC artist( MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName) );
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
-                    MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName));
-
-				MPX_DEBUG2("	Artist[%S]", &artist);
-                }
-            if (attributeId & EMPXMediaGeneralCount)
-                {
-//				TInt albumCount = GetAlbumsCountL(aRecord.ColumnInt64(EArtistUniqueId));
-//              aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,albumCount);
-//              MPX_DEBUG1("	EMPXMediaGeneralCount");
-//				MPX_DEBUG2("	AlbumCount[%d]", albumCount);
-				TInt songCount = aRecord.ColumnInt64(EArtistSongCount);
-				aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount); // mod by anjokela
-				
-                MPX_DEBUG1("	EMPXMediaGeneralCount");
-				MPX_DEBUG2("	SongCount[%d]", songCount);
-                }
-            } // end if contentId == KMPXMediaIdGeneral
-        else if ( contentId == KMPXMediaIdMusic )
-            {
-            if (attributeId & EMPXMediaMusicAlbumArtFileName)
-                {
-                MPX_DEBUG1("    EMPXMediaMusicAlbumArtFileName");
-                TPtrC art(KNullDesC);                
-                art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistArt));
-                aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
-                MPX_DEBUG2("    Art[%S]", &art);
-                }
-            }
-		} // end for
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::GenerateArtistFieldsValuesL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbArtist::GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
-    {
-    if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
-        {
-        const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
-        }
-    }
-	
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::GetAlbumsCountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbArtist::GetAlbumsCountL(TUint32 aId)
-    {
-    MPX_FUNC("CMPXDbArtist::GetAlbumsCountL");
-	
-	return iObserver.HandleGetAlbumsCountForArtistL(aId);
-    }
-	
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::GetAllCategoryItemsL
-// ----------------------------------------------------------------------------
-//	
-void CMPXDbArtist::GetAllCategoryItemsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbArtist::GetAllCategoryItemsL");
-    HBufC* query = PreProcessStringLC(KQueryArtistAll);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
-    CleanupStack::PopAndDestroy(query);
-    CleanupClosePushL(recordset);
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbArtist::UpdateItemL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbArtist::UpdateItemL(
-    TUint32 aId, 
-    const CMPXMedia& aMedia, 
-    TInt aDriveId, 
-    CMPXMessageArray* aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbAlbum::UpdateItemL");
-
-    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
-    CleanupStack::PushL(fields);
-    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
-    CleanupStack::PushL(values);
-
-    // process the media parameter and construct the fields and values array
-    GenerateArtistFieldsValuesL(aMedia, *fields, *values);
-
-    // construct the SET string
-    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
-
-    if (setStr->Length())
-        {
-        // execute the query
-        iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, aId);
-        TInt oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;   
-        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
-            EMPXArtist, KDBPluginUid, oldSongId );
-        }
-
-    CleanupStack::PopAndDestroy(setStr);
-    CleanupStack::PopAndDestroy(values);
-    CleanupStack::PopAndDestroy(fields);
-    }
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbArtist::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbCategory::CreateTableL");
-
-    // create the table
-    HBufC* query = PreProcessStringLC(KArtistCreateTable);
-    User::LeaveIfError(aDatabase.Exec(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    // do not create an index on the Name field
-    // as it only slows down the insert/update queries overall
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbArtist::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbCategory::CheckTableL");
-
-    HBufC* query = PreProcessStringLC(KArtistCheckTable);
-    TBool check(DoCheckTable(aDatabase, *query));
-    CleanupStack::PopAndDestroy(query);
-
-    return check;
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbautoplaylist.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,419 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for the auto playlist functionality.
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include <mpxcollectiondbres.rsg>
-#include <sqldb.h>
-
-#include "mpxresource.h"
-#include "mpxdbcommonutil.h"
-#include "mpxdbmanager.h"
-#include "mpxdbutil.h"
-#include "mpxcollectiondbdef.h"
-#include "mpxdbautoplaylist.h"
-#include "mpxdbpluginqueries.h"
-
-const TInt KMPXTableDefaultIndex = 0;
-const TInt32 KMPXRecentlyPlayedPlaylistId = 0x20000000;
-const TInt32 KMPXMostPlayedPlaylistId = 0x20000001;
-const TInt32 KMPXRecentlyAddedPlaylistId = 0x20000002;
-
-const TInt KPlaylistTitleSize = 32;
-_LIT( KMostPlayed, "Most played" );
-_LIT( KRecentlyPlayed, "Recently played" );
-_LIT( KRecentlyAdded, "Recently added" );
-
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAutoPlaylist* CMPXDbAutoPlaylist::NewL(
-    CMPXDbManager& aDbManager,
-    RFs& aFs,
-    CMPXResource& aResource)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::NewL");
-
-    CMPXDbAutoPlaylist* self = CMPXDbAutoPlaylist::NewLC(aDbManager, aFs, aResource);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAutoPlaylist* CMPXDbAutoPlaylist::NewLC(
-    CMPXDbManager& aDbManager,
-    RFs& aFs,
-    CMPXResource& aResource)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::NewLC");
-
-    CMPXDbAutoPlaylist* self = new (ELeave) CMPXDbAutoPlaylist(aDbManager);
-    CleanupStack::PushL(self);
-    self->ConstructL(aFs, aResource);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAutoPlaylist::~CMPXDbAutoPlaylist()
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::~CMPXDbAutoPlaylist");
-
-    delete iRecentlyPlayedPlaylist;
-    delete iMostPlayedPlaylist;
-    delete iRecentlyAddedPlaylist;
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAutoPlaylist::CMPXDbAutoPlaylist(CMPXDbManager& aDbManager)
-    : iDbManager(aDbManager)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::CMPXDbAutoPlaylist");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAutoPlaylist::ConstructL(
-    RFs& /*aFs*/,
-    CMPXResource& /*aResource*/)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::ConstructL");
-/*
-    iRecentlyPlayedPlaylist = aResource.ReadHBufCL(R_MC_RECENTLY_PLAYED_PLAYLIST);
-    iMostPlayedPlaylist = aResource.ReadHBufCL(R_MC_MOST_PLAYED_PLAYLIST);
-    iRecentlyAddedPlaylist = aResource.ReadHBufCL(R_MC_RECENTLY_ADDED_PLAYLIST);
-*/
-    iRecentlyPlayedPlaylist = HBufC::NewL(KPlaylistTitleSize);
-    iRecentlyPlayedPlaylist->Des().Append(KMostPlayed);
-    iMostPlayedPlaylist = HBufC::NewL(KPlaylistTitleSize);
-    iMostPlayedPlaylist->Des().Append(KRecentlyPlayed);
-    iRecentlyAddedPlaylist = HBufC::NewL(KPlaylistTitleSize);
-    iRecentlyAddedPlaylist->Des().Append(KRecentlyAdded);
-
-    iRecentlyPlayedPlaylistId = KMPXRecentlyPlayedPlaylistId;
-    iMostPlayedPlaylistId = KMPXMostPlayedPlaylistId;
-    iRecentlyAddedPlaylistId = KMPXRecentlyAddedPlaylistId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::AutoPlaylistIdL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbAutoPlaylist::AutoPlaylistIdL(
-    TMPXAutoPlaylistType aPlaylistType)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistIdL");
-
-    TUint32 id(0);
-    switch (aPlaylistType)
-        {
-        case EMPXRecentlyPlayedPlaylist:
-            {
-            id = iRecentlyPlayedPlaylistId;
-            }
-            break;
-
-        case EMPXMostPlayedPlaylist:
-            {
-            id = iMostPlayedPlaylistId;
-            }
-            break;
-
-        case EMPXRecentlyAddedPlaylist:
-            {
-            id = iRecentlyAddedPlaylistId;
-            }
-            break;
-
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    return id;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::AutoPlaylistNameL
-// ----------------------------------------------------------------------------
-//
-TPtrC CMPXDbAutoPlaylist::AutoPlaylistNameL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistNameL");
-
-    TPtrC ptr;
-    if (aPlaylistId == iRecentlyPlayedPlaylistId)
-        {
-        ptr.Set(*iRecentlyPlayedPlaylist);
-        }
-    else if (aPlaylistId == iMostPlayedPlaylistId)
-        {
-        ptr.Set(*iMostPlayedPlaylist);
-        }
-    else if (aPlaylistId == iRecentlyAddedPlaylistId)
-        {
-        ptr.Set(*iRecentlyAddedPlaylist);
-        }
-    else
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    return ptr;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::AutoPlaylistTypeL
-// ----------------------------------------------------------------------------
-//
-TMPXAutoPlaylistType CMPXDbAutoPlaylist::AutoPlaylistTypeL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::AutoPlaylistTypeL");
-
-    TMPXAutoPlaylistType type(EMPXNoAutoPlaylist);
-    if (aPlaylistId == iRecentlyPlayedPlaylistId)
-        {
-        type = EMPXRecentlyPlayedPlaylist;
-        }
-    else if (aPlaylistId == iMostPlayedPlaylistId)
-        {
-        type = EMPXMostPlayedPlaylist;
-        }
-    else if (aPlaylistId == iRecentlyAddedPlaylistId)
-        {
-        type = EMPXRecentlyAddedPlaylist;
-        }
-    else
-        {
-        // do nothing
-        }
-
-    return type;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::GetPlaylistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAutoPlaylist::GetPlaylistL(
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::GetPlaylistL");
-
-    if (EMPXNoAutoPlaylist == AutoPlaylistTypeL(aPlaylistId))
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    UpdateMediaL(aPlaylistId, aAttrs, aMedia);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::GetAllPlaylistsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAutoPlaylist::GetAllPlaylistsL(
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::GetAllPlaylistsL");
-
-    MPX_ASSERT(aMediaArray.Count());
-    MPX_ASSERT(aMediaArray[0]->IsSupported(KMPXMediaGeneralValue));
-    TInt pPath = aMediaArray[0]->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-    MPX_ASSERT(pPath);
-    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iMostPlayedPlaylist, EMPXItem,
-        EMPXPlaylist, iMostPlayedPlaylistId, EMPXWrite);
-    TInt count = aMediaArray.Count();
-    TMPXItemId id = aMediaArray[count-1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-    if (count==2)
-        { // the first playlist
-        if (((CMPXCollectionPath*)pPath)->Id()==KMPXInvalidItemId)
-            { // Remove top level with invalid id
-            ((CMPXCollectionPath*)pPath)->Back();
-            }
-        ((CMPXCollectionPath*)pPath)->AppendL(id);
-        }
-    else
-        { // append the end
-        ((CMPXCollectionPath*)pPath)->InsertL(id,
-                                              ((CMPXCollectionPath*)pPath)->Count());
-        }
-    TInt songCount = 0;
-    TInt duration = 0;
-    GetPlaylistDetailsL(EMPXMostPlayedPlaylist, songCount, duration);
-    aMediaArray[count-1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
-    aMediaArray[count-1]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-
-    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iRecentlyPlayedPlaylist, EMPXItem,
-        EMPXPlaylist, iRecentlyPlayedPlaylistId, EMPXWrite);
-    id = aMediaArray[count]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-    ((CMPXCollectionPath*)pPath)->InsertL(id, ((CMPXCollectionPath*)pPath)->Count());
-    songCount = 0;
-    duration = 0;
-    GetPlaylistDetailsL(EMPXRecentlyPlayedPlaylist, songCount, duration);
-	aMediaArray[count]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
-   	aMediaArray[count]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-
-    MPXDbCommonUtil::AppendMediaL(aMediaArray, *iRecentlyAddedPlaylist, EMPXItem,
-        EMPXPlaylist, iRecentlyAddedPlaylistId, EMPXWrite);
-    id = aMediaArray[count+1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-    ((CMPXCollectionPath*)pPath)->InsertL(id, ((CMPXCollectionPath*)pPath)->Count());
-    songCount = 0;
-	duration = 0;
-	GetPlaylistDetailsL(EMPXRecentlyAddedPlaylist, songCount, duration);
-	aMediaArray[count+1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount);
-	aMediaArray[count+1]->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::GetPlaylistDetails
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAutoPlaylist::GetPlaylistDetailsL(TMPXAutoPlaylistType aType, TInt& aCount, TInt& aDuration)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::GetPlaylistDetails");
-
-    HBufC* query = NULL;
-  
-    switch ( aType )
-    	{
-		case EMPXMostPlayedPlaylist:
-		    query = HBufC::NewLC(KQueryMusicGetDurationMostPlayed().Length() + KMCIntegerLen);
-		    query->Des().Format(KQueryMusicGetDurationMostPlayed(), KMPXMaxMostPlayedSongs);
-		    break;
-		case EMPXRecentlyPlayedPlaylist:
-		    query = HBufC::NewLC(KQueryMusicGetDurationRecentlyPlayed().Length() + KMCIntegerLen);
-		    query->Des().Format(KQueryMusicGetDurationRecentlyPlayed(), KMPXMaxRecentlyPlayedSongs);
-			break;
-		case EMPXRecentlyAddedPlaylist:
-		    query = HBufC::NewLC(KQueryMusicGetDurationRecentlyAdded().Length());
-		    query->Des().Append(KQueryMusicGetDurationRecentlyAdded());
-			break;
-		default:
-			User::Leave(KErrArgument);
-			break;
-		}
-    
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
-    CleanupClosePushL(recordset);
-
-    TInt sum(0);
-    TInt err(KErrNone);
-    while ((err = recordset.Next()) == KSqlAtRow)
-        {
-        aCount++;
-        sum += recordset.ColumnInt64(KMPXTableDefaultIndex);
-        }
-    
-    CleanupStack::PopAndDestroy(&recordset);
-    CleanupStack::PopAndDestroy(query);
-    
-    if (err != KSqlAtEnd)
-        {
-        User::Leave(KErrCorrupt);
-        }
-
-    aDuration = sum;
-    MPX_DEBUG3("    Count[%d], Duration[%d]", aCount, aDuration);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAutoPlaylist::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAutoPlaylist::UpdateMediaL(
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbAutoPlaylist::UpdateMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            TUint attributeId(aAttrs[i].AttributeId());
-
-            if (attributeId & EMPXMediaGeneralId)
-                {
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPlaylistId);
-                }
-            if (attributeId & EMPXMediaGeneralCollectionId )
-                {
-                aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
-                    TUid::Uid(KDBPluginUid));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                if (aPlaylistId == iRecentlyPlayedPlaylistId)
-                    {
-                    aMedia.SetTextValueL(KMPXMediaGeneralTitle, *iRecentlyPlayedPlaylist);
-                    }
-                 else if (aPlaylistId == iMostPlayedPlaylistId)
-                    {
-                    aMedia.SetTextValueL(KMPXMediaGeneralTitle,*iMostPlayedPlaylist);
-                    }
-                 else if (aPlaylistId == iRecentlyAddedPlaylistId)
-                    {
-                    aMedia.SetTextValueL(KMPXMediaGeneralTitle, *iRecentlyAddedPlaylist);
-                    }
-                 else
-                    {
-                    User::Leave(KErrArgument);
-                    }
-                }
-            if (attributeId & EMPXMediaGeneralSynchronized)
-                {
-                aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, EFalse);
-                }
-            if (attributeId & EMPXMediaGeneralNonPermissibleActions)
-                {
-                aMedia.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
-                }
-            // EMPXMediaGeneralCount, EMPXMediaGeneralDate, EMPXMediaGeneralDuration,
-            // EMPXMediaGeneralUri, EMPXMediaGeneralDrive, and EMPXMediaGeneralFlags
-            // attributes are not applicable for auto-playlists
-            } // end if contentId == KMPXMediaIdGeneral
-        } // end for
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbauxiliary.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,294 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interaction with the Auxiliary table.
-*
-*/
-
-
-// INCLUDE FILES
-#include <sqldb.h>
-#include <mpxlog.h>
-
-#include "mpxdbcommonutil.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbmanager.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbauxiliary.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAuxiliary* CMPXDbAuxiliary::NewL(
-    CMPXDbManager& aDbManager)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::NewL");
-
-    CMPXDbAuxiliary* self = CMPXDbAuxiliary::NewLC(aDbManager);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbAuxiliary* CMPXDbAuxiliary::NewLC(
-    CMPXDbManager& aDbManager)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::NewLC");
-
-    CMPXDbAuxiliary* self = new (ELeave) CMPXDbAuxiliary(aDbManager);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAuxiliary::~CMPXDbAuxiliary()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::~CMPXDbAuxiliary");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbAuxiliary::CMPXDbAuxiliary(
-    CMPXDbManager& aDbManager) :
-    CMPXDbTable(aDbManager)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::CMPXDbAuxiliary");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::ConstructL()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::ConstructL");
-    BaseConstructL();
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SetLastRefreshedTimeL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::SetLastRefreshedTimeL(
-    TTime aTime)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::SetLastRefreshedTimeL");
-
-    // update all databases
-    HBufC* time = MPXDbCommonUtil::TTimeToDesLC(aTime);
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryAuxiliarySetTime, time);
-    CleanupStack::PopAndDestroy(time);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::LastRefreshedTimeL
-// ----------------------------------------------------------------------------
-//
-TTime CMPXDbAuxiliary::LastRefreshedTimeL()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::LastRefreshedTimeL");
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::Leave(KErrCorrupt);
-        }
-
-    // read the time string and convert it to TTime
-    TTime time(MPXDbCommonUtil::DesToTTimeL(
-    	MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex)));
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return time;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SetDBCorruptedL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::SetDBCorruptedL(
-    TBool aCorrupt)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::SetDBCorruptedL");
-
-    // update all databases
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryAuxiliarySetCorrupt,
-        aCorrupt);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::DBCorruptedL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAuxiliary::DBCorruptedL()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::DBCorruptedL");
-    return (ExecuteSumQueryL(KQueryAuxiliaryGetCorrupt) > 0);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SetSaveDeletedRecordCountL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::SetSaveDeletedRecordCountL(TInt aDrive,
-    TUint32 aValue)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::SetSaveDeletedRecordCountL");
-
-    // update all databases
-    iDbManager.ExecuteQueryL(aDrive, KQueryAuxiliarySetCount, aValue);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SaveDeletedRecordCountL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbAuxiliary::SaveDeletedRecordCountL()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::SaveDeletedRecordCountL");
-    return ExecuteSumQueryL(KQueryAuxiliaryGetCount);
-    }
-
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SaveDeletedRecordCountL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbAuxiliary::SaveDeletedRecordCountL(TInt aDriveID)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::SaveDeletedRecordCountL ");
-    return ExecuteIntQueryL(aDriveID, KQueryAuxiliaryGetCount);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::IsRefreshedL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAuxiliary::IsRefreshedL()
-    {
-    MPX_FUNC("CMPXDbAuxiliary::IsRefreshedL");
-
-    TBool refreshed(ETrue);
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
-    CleanupClosePushL(recordset);
-
-    TInt count(0);
-    while (recordset.Next() == KSqlAtRow)
-        {
-        count++;
-
-        // read the time string and convert it to TTime
-        if (Time::NullTTime() == MPXDbCommonUtil::DesToTTimeL(
-        	MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex)))
-            {
-            refreshed = EFalse;
-            break;
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-    return refreshed && (count > 0);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::IdL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbAuxiliary::IdL( TInt aDrive )
-    {
-    MPX_DEBUG1("CMPXDbAuxiliary::IdL <--");
-    TInt id(0);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive, KQueryAuxiliaryGetId));
-    CleanupClosePushL( recordset );
-
-    while(recordset.Next() == KSqlAtRow )
-        {
-        id = recordset.ColumnInt(KMPXTableDefaultIndex);
-        }
-
-    CleanupStack::PopAndDestroy( &recordset );
-    MPX_DEBUG1("CMPXDbAuxiliary::IdL -->");
-    return id;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::SetIdL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::SetIdL( TInt aDrive, TInt aId )
-    {
-    MPX_DEBUG1("CMPXDbAuxiliary::SetIdL <--");
-    iDbManager.ExecuteQueryL(aDrive,KQueryAuxiliarySetId, aId);
-    MPX_DEBUG1("CMPXDbAuxiliary::SetIdL -->");
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool aCorruptTable)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::CreateTableL");
-
-    // create the table
-    User::LeaveIfError(aDatabase.Exec(KAuxiliaryCreateTable));
-
-    // insert the default record
-    // use the same length as '%u' is longer than '0' or '1'
-    HBufC* query = KQueryAuxiliaryInsert().AllocLC();
-    query->Des().Format(KQueryAuxiliaryInsert, aCorruptTable);
-    User::LeaveIfError(aDatabase.Exec(*query));
-    CleanupStack::PopAndDestroy(query);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::DropTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAuxiliary::DropTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::DropTableL");
-    User::LeaveIfError(aDatabase.Exec(KAuxiliaryDropTable));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAuxiliary::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAuxiliary::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbAuxiliary::CheckTableL");
-    return DoCheckTable(aDatabase, KAuxiliaryCheckTable);
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbcategory.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,690 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the category tables:
-*                Artist, Album, Genre and Composer
-*
-*/
-
-
-// INCLUDE FILES
-#include <sqldb.h>
-
-#include <mpxlog.h>
-
-#include "mpxdbcommonutil.h"
-#include "mpxdbcommondef.h"
-#include "mpxdbmanager.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbutil.h"
-#include "mpxdbcategory.h"
-
-// CONSTANTS
-
-// maximum number of table name entries per query
-const TInt KMaxTableNameCount = 2;
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbCategory::~CMPXDbCategory()
-    {
-    MPX_FUNC("CMPXDbCategory::~CMPXDbCategory");
-    delete iTableName;
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbCategory::CMPXDbCategory(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory) :
-    CMPXDbTable(aDbManager),
-    iCategory(aCategory)
-    {
-    MPX_FUNC("CMPXDbCategory::CMPXDbCategory");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::BaseConstructL()
-    {
-    MPX_FUNC("CMPXDbCategory::BaseConstructL");
-
-    CMPXDbTable::BaseConstructL();
-    iTableName = MPXDbUtil::TableNameForCategoryL(iCategory).AllocL();
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::AddItemL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbCategory::AddItemL(
-    const TDesC& aName,
-    TInt aDriveId,
-    TBool& aNewRecord,
-    TBool aCaseSensitive)
-    {
-    MPX_FUNC("CMPXDbCategory::AddItemL");
-
-    // try to find the item first
-    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
-        aName, aCaseSensitive));
-    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
-
-    if (aNewRecord)
-        {
-        // insert new
-        HBufC* query = PreProcessStringLC(KQueryCategoryInsert);
-        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
-
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1);
-
-        CleanupStack::PopAndDestroy(name);
-        CleanupStack::PopAndDestroy(query);
-        }
-    else
-        {
-        // increment the number of songs for the category
-        HBufC* query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
-        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
-        CleanupStack::PopAndDestroy(query);
-        }
-
-    return rowId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetNameL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbCategory::GetNameL(
-    TUint32 aId)
-    {
-    MPX_FUNC("CMPXDbCategory::GetNameL");
-
-    RSqlStatement recordset(GetCategoryRecordL(aId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::LeaveIfError(KErrNotFound);
-        }
-
-    HBufC* name = MPXDbCommonUtil::GetColumnTextL(recordset, ECategoryName).AllocL();
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return name;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::CountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbCategory::CountL()
-    {
-    MPX_FUNC("CMPXDbCategory::CountL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryCount);
-    TInt count(ExecuteSumQueryL(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::FindAllL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::FindAllL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbCategory::FindAllL");
-
-    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
-
-    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
-    TInt criteriaCount(criteria.Count());
-
-    // process the criteria and construct the criteria string
-    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(criteriaCount + 1);
-    CleanupStack::PushL(criteriaArray);
-
-    for (TInt i = 0; i < criteriaCount; ++i)
-        {
-        const TMPXAttribute& criterion = criteria[i];
-        if ((type == EMPXItem) && (criterion == KMPXMediaGeneralId))
-            {
-            TUint32 itemId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-            if (MPX_ITEM_CATEGORY(itemId) != iCategory)
-                {
-                User::Leave(KErrNotSupported);
-                }
-
-            HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, itemId);
-            CleanupStack::PopAndDestroy(critStr);
-            }
-        else if (criterion == KMPXMediaGeneralTitle)
-            {
-#ifdef RD_MPX_COLLECTION_CACHE
-           
-            if (aCriteria.ValueText(KMPXMediaGeneralTitle).Length() <= 0)
-                {
-                TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(
-                                    iDbManager.Fs(), iCategory, KNullDesC, EFalse);
-                HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
-                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, itemId);
-                CleanupStack::PopAndDestroy(critStr);
-                }
-            else
-                {
-
-#endif //RD_MPX_COLLECTION_CACHE
-                HBufC* critStr = PreProcessStringLC(KCriterionCategoryName);
-                HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
-                    aCriteria.ValueText(KMPXMediaGeneralTitle));
-                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, *critStr, *title);
-                CleanupStack::PopAndDestroy(2, critStr); // title & critStr
-#ifdef RD_MPX_COLLECTION_CACHE
-                }
-#endif //RD_MPX_COLLECTION_CACHE
-            }
-        else
-            {
-            // ignore attribute
-            }
-        }
-
-    // construct criteria string
-    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
-
-    // either get all items or items filtered based on criteria
-    HBufC* query = PreProcessStringLC(criteriaStr->Length() ?
-        KQueryCategoryItems() : KQueryCategoryAll());
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, criteriaStr));
-    CleanupStack::PopAndDestroy(3, criteriaArray); // query, criteriaStr, criteriaArray
-    CleanupClosePushL(recordset);
-
-    // process the results
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::DecrementSongsForCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::DecrementSongsForCategoryL(
-    const TUint32 aId,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TBool& aItemExist)
-    {
-    MPX_FUNC("CMPXDbCategory::DecrementSongsForCategoryL");
-
-    // if just one song uses this category. Use <= just in case
-    if (GetSongsCountL(aDriveId, aId) <= 1)
-        {
-        aItemExist = EFalse;
-        // delete the category
-        DeleteCategoryL(aId, aDriveId);
-
-        if (aItemChangedMessages)
-            {
-            // add the item changed message
-            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
-                iCategory, KDBPluginUid);
-            }
-        }
-    else
-        {
-        aItemExist = ETrue;
-        // decrement the number of songs for the category
-        HBufC* query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
-        iDbManager.ExecuteQueryL(aDriveId, *query, aId);
-        CleanupStack::PopAndDestroy(query);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::DeleteCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::DeleteCategoryL(
-    TUint32 aId,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbCategory::DeleteCategoryL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryDelete);
-    iDbManager.ExecuteQueryL(aDriveId, *query, aId);
-    CleanupStack::PopAndDestroy(query);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetCategoryItemsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::GetCategoryItemsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbCategory::GetCategoryItemsL");
-
-    // have to run one query to get all items as opposed to individual queries
-    // because of the sorting
-
-    // construct the unique ID criteria string
-    // (UniqueId = %u OR UniqueId = %u ...)
-    TInt count(aMediaArray.Count());
-    HBufC* criteria = HBufC::NewLC((2 * KCriterionCategoryUniqueId().Length() +
-        KMCIntegerLen + KMCOrKeyword().Length() + 2) * count);
-    TPtr ptr(criteria->Des());
-    ptr.Append(KMCOpenBracket);
-    for (TInt index = 0; index < count; ++index)
-        {
-        CMPXMedia* media = aMediaArray[index];
-
-        HBufC* critStr = PreProcessStringLC(KCriterionCategoryUniqueId);
-        HBufC* criterion = MPXDbCommonUtil::SqlCriterionLC(*critStr,
-            (media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId1);
-        ptr.Append(*criterion);
-        CleanupStack::PopAndDestroy(criterion);
-        CleanupStack::PopAndDestroy(critStr);
-
-        if (index < (count - 1))
-            {
-            ptr.Append(KMCOrKeyword);
-            }
-        }
-    ptr.Append(KMCCloseBracket);
-
-    // the array has to be reset as the items have to be returned in a different sort order
-    aMediaArray.Reset();
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryItems);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, criteria));
-
-    CleanupStack::PopAndDestroy(query);
-    CleanupStack::PopAndDestroy(criteria);
-
-    CleanupClosePushL(recordset);
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetAllCategoryItemsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::GetAllCategoryItemsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbCategory::GetAllCategoryItemsL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryAll);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    CleanupClosePushL(recordset);
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetCategoryItemL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::GetCategoryItemL(
-    TUint32 aId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbCategory::GetCategoryItemL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
-    ExecuteMediaQueryL(aAttrs, aMedia, *query, aId);
-    CleanupStack::PopAndDestroy(query);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetSubCategoryItemsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::GetSubCategoryItemsL(
-    TMPXGeneralCategory aParentCategory,
-    TUint32 aParentId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbCategory::GetSubCategoryItemsL");
-
-    // this is only valid for albums belonging to an artist
-    ASSERT((iCategory == EMPXAlbum) && (aParentCategory == EMPXArtist));
-
-    // to handle the UREL warning
-    (void)aParentCategory;
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryCategorySubcategoryItems, aParentId));
-    CleanupClosePushL(recordset);
-    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
-    CleanupStack::PopAndDestroy(&recordset);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::CategoryItemExistsL
-// The category records must be in the same database as the corresponding
-// Music record, otherwise when adding a duplicate of a song on a
-// different drive this method will return true and the category record won't
-// be created.
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbCategory::CategoryItemExistsL(
-    TInt aDriveId,
-    TUint32 aId)
-    {
-    MPX_FUNC("CMPXDbCategory::CategoryItemExistsL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
-    RSqlStatement recordset(
-        iDbManager.ExecuteSelectQueryL(aDriveId, *query, aId));
-
-    TBool exists(recordset.Next() == KSqlAtRow);
-
-    recordset.Close();
-    CleanupStack::PopAndDestroy(query);
-
-    return exists;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetSongsCountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbCategory::GetSongsCountL(
-    TInt aDriveId,
-    TUint32 aId)
-    {
-    MPX_FUNC("CMPXDbCategory::GetSongsCountL");
-
-    HBufC* query = PreProcessStringLC(KQueryCategoryGetSongCount);
-    RSqlStatement recordset(
-        iDbManager.ExecuteSelectQueryL(aDriveId, *query, aId));
-    CleanupClosePushL(recordset);
-
-    TInt err(KErrNone);
-    TInt ret(0);
-    while ((err = recordset.Next()) == KSqlAtRow)
-        {
-        ret += recordset.ColumnInt(KMPXTableDefaultIndex);
-        }
-
-    if (err != KSqlAtEnd)
-        {
-        User::Leave(err);
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-    CleanupStack::PopAndDestroy(query);
-
-    return ret;
-    }
-
-void CMPXDbCategory::UpdateItemL(
-    TUint32 /*aId*/, 
-    const CMPXMedia& /*aMedia*/, 
-    TInt /*aDriveId*/, 
-    CMPXMessageArray* /*aItemChangedMessages*/)
-	{
-	// nothing
-	}
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::UpdateMediaL(
-    RSqlStatement& aRecord,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbCategory::UpdateMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-        TUint attributeId(aAttrs[i].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            if (attributeId & EMPXMediaGeneralId)
-                {
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
-                    aRecord.ColumnInt64(ECategoryUniqueId));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
-                    MPXDbCommonUtil::GetColumnTextL(aRecord, ECategoryName));
-                }
-            if (attributeId & EMPXMediaGeneralCount)
-                {
-                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
-                    GetSongsCountL(KDbManagerAllDrives,
-                    aRecord.ColumnInt64(ECategoryUniqueId)));
-                }
-            } // end if contentId == KMPXMediaIdGeneral
-        } // end for
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::GetCategoryRecordL
-// ----------------------------------------------------------------------------
-//
-RSqlStatement CMPXDbCategory::GetCategoryRecordL(
-    TUint32 aId)
-    {
-    MPX_FUNC("CMPXDbCategory::GetCategoryRecordL");
-    HBufC* query = PreProcessStringLC(KQueryCategoryItem);
-    RSqlStatement statement(iDbManager.ExecuteSelectQueryL(*query, aId));
-    CleanupStack::PopAndDestroy(query);
-
-    return statement;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::PreProcessStringLC
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbCategory::PreProcessStringLC(
-    const TDesC& aQuery)
-    {
-    MPX_FUNC("CMPXDbCategory::PreProcessStringLC");
-
-    HBufC* query = HBufC::NewLC(aQuery.Length() + KMaxTableNameCount * (iTableName->Length() +
-        KCategoryTablePlaceholder().Length()));
-    TPtr queryPtr(query->Des());
-
-    // copy the query string
-    queryPtr = aQuery;
-
-    // replace all instances of the placeholder with the actual table name
-    TInt index(0);
-    while ((index = queryPtr.Find(KCategoryTablePlaceholder)) != KErrNotFound)
-        {
-        queryPtr.Replace(index, KCategoryTablePlaceholder().Length(), *iTableName);
-        }
-
-    return query;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::ProcessRecordsetL
-// Unknown item is stored in the database as NULL (name field). This ensures the
-// unknown item to be the 1st found record if it exists. This will save time in
-// searching for the unknown record among the results and avoid performing
-// descriptor comparison. If the 1st record is the unknown item, it won't be
-// appended to the array until all other records have been put in the array.
-//
-// NOTE: putting unknown item to the end of the array only takes place when title
-//       field is requested. normal sorting algorithm occurs if title isn't
-//       requested.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::ProcessRecordsetL(
-    const TArray<TMPXAttribute>& aAttrs,
-    RSqlStatement& aRecordset,
-    CMPXMediaArray& aMediaArray)
-    {
-    // populate the array
-    TBool firstRecord(ETrue);
-    CMPXMedia* unknownMedia(NULL);
-    TInt prevId(0);
-    TInt err(KErrNone);
-
-    TInt pPath(0);
-    if (aMediaArray.Count())
-        {
-        CMPXMedia* pMedia = aMediaArray[0];
-        if (pMedia->IsSupported(KMPXMediaGeneralValue))
-            { // Query excuted by OpenL
-            pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-            MPX_ASSERT(pPath);
-            }
-        }
-    RArray<TMPXItemId> ids;
-    CleanupClosePushL(ids);
-
-    while ((err = aRecordset.Next()) == KSqlAtRow)
-        {
-        TUint32 rowId(aRecordset.ColumnInt64(ECategoryUniqueId));
-        if (prevId == rowId)
-            {
-            continue;
-            }
-
-        prevId = rowId;
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-
-        UpdateMediaL(aRecordset, aAttrs, *media);
-
-        if (firstRecord &&
-            (MPXDbCommonUtil::GetColumnTextL(aRecordset, ECategoryName).Length() == 0))
-            {
-            unknownMedia = media;
-            }
-
-        if (!firstRecord || !unknownMedia)
-            {
-            if (media->IsSupported(KMPXMediaGeneralId) && pPath)
-                {
-                ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
-                }
-            aMediaArray.AppendL(*media);
-            CleanupStack::PopAndDestroy(media);
-            }
-
-        firstRecord = EFalse;
-        } // end while
-
-    if (err != KSqlAtEnd)
-        {
-        User::LeaveIfError(err);
-        }
-
-    if (unknownMedia)
-        {
-        if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
-            {
-            ids.AppendL(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
-            }
-        aMediaArray.AppendL(*unknownMedia);
-        CleanupStack::PopAndDestroy(unknownMedia);
-        }
-
-    // Append ids to the returned path
-    if (pPath)
-        {
-        ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
-        }
-    CleanupStack::PopAndDestroy(&ids);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbCategory::CreateTableL");
-
-    // create the table
-    HBufC* query = PreProcessStringLC(KCategoryCreateTable);
-    User::LeaveIfError(aDatabase.Exec(*query));
-    CleanupStack::PopAndDestroy(query);
-
-    // do not create an index on the Name field
-    // as it only slows down the insert/update queries overall
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::DropTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbCategory::DropTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbCategory::DropTableL");
-
-    HBufC* query = PreProcessStringLC(KCategoryDropTable);
-    User::LeaveIfError(aDatabase.Exec(*query));
-    CleanupStack::PopAndDestroy(query);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbCategory::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbCategory::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbCategory::CheckTableL");
-
-    HBufC* query = PreProcessStringLC(KCategoryCheckTable);
-    TBool check(DoCheckTable(aDatabase, *query));
-    CleanupStack::PopAndDestroy(query);
-
-    return check;
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbcomposer.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the category tables:
-*                Artist, Album, Genre and Composer
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include "mpxdbcomposer.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbComposer* CMPXDbComposer::NewL(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbComposer::NewL");
-
-    CMPXDbComposer* self = CMPXDbComposer::NewLC(aDbManager, aCategory);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbComposer* CMPXDbComposer::NewLC(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbComposer::NewLC");
-
-    CMPXDbComposer* self = new (ELeave) CMPXDbComposer(aDbManager, aCategory);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbComposer::~CMPXDbComposer()
-    {
-    MPX_FUNC("CMPXDbComposer::~CMPXDbComposer");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbComposer::CMPXDbComposer(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory) :
-    CMPXDbCategory(aDbManager, aCategory)
-    {
-    MPX_FUNC("CMPXDbComposer::CMPXDbComposer");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbComposer::ConstructL()
-    {
-    MPX_FUNC("CMPXDbComposer::ConstructL");
-
-    BaseConstructL();
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbgenre.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the category tables:
-*                Artist, Album, Genre and Composer
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include "mpxdbgenre.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbGenre* CMPXDbGenre::NewL(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbGenre::NewL");
-
-    CMPXDbGenre* self = CMPXDbGenre::NewLC(aDbManager, aCategory);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbGenre* CMPXDbGenre::NewLC(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbGenre::NewLC");
-
-    CMPXDbGenre* self = new (ELeave) CMPXDbGenre(aDbManager, aCategory);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbGenre::~CMPXDbGenre()
-    {
-    MPX_FUNC("CMPXDbGenre::~CMPXDbGenre");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbGenre::CMPXDbGenre(
-    CMPXDbManager& aDbManager,
-    TMPXGeneralCategory aCategory) :
-    CMPXDbCategory(aDbManager, aCategory)
-    {
-    MPX_FUNC("CMPXDbGenre::CMPXDbGenre");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbGenre::ConstructL()
-    {
-    MPX_FUNC("CMPXDbGenre::ConstructL");
-
-    BaseConstructL();
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbhandler.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2939 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This class is used by db plugin for all database related
-*                functionality. The main responsibilities are:
-*
-*/
-
-
-// INCLUDE FILES
-#include <bautils.h>
-#ifdef RD_MULTIPLE_DRIVE
-#include <driveinfo.h>
-#include <pathinfo.h>
-#endif //RD_MULTIPLE_DRIVE
-
-#include <mpxcollectiondbres.rsg>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxmediaaudiodefs.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxcollectionpath.h>
-#include <mpxlog.h>
-
-#include "mpxresource.h"
-#include "mpxdbcommonutil.h"
-
-#include "mpxdbutil.h"
-#include "mpxcollectiondbdef.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxcollectiondbmanager.h"
-#include "mpxdbplaylist.h"
-#include "mpxdbplaylistsongs.h"
-#include "mpxdbcategory.h"
-#include "mpxdbauxiliary.h"
-#include "mpxdbautoplaylist.h"
-#include "mpxdbhandler.h"
-#include "mpxdbartist.h"
-#include "mpxdbalbum.h"
-#include "mpxdbgenre.h"
-#include "mpxdbcomposer.h"
-
-// CONSTANTS
-_LIT(KMPXVirtualPlaylistExt, ".vir");
-static const TInt KMaxOpInTransaction = 100;
-
-const TInt KSqlDbCorrupted = -321;
-
-#if defined (__MTP_PROTOCOL_SUPPORT)
-
-#include <centralrepository.h>
-
-// MTP CenRep Key UID
-const TUid KMPXMtpSettings = {0x101FFC53};
-// MTP CenRep Key for Delete contents
-const TUint32 KMPXMtpSaveDeletedRecordFlag = 0x00000001;
-
-#endif
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbHandler* CMPXDbHandler::NewL(
-    RFs& aFs,
-    CMPXResource& aResource)
-    {
-    MPX_FUNC("CMPXDbHandler::NewL");
-    CMPXDbHandler* self = CMPXDbHandler::NewLC(aFs, aResource);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbHandler* CMPXDbHandler::NewLC(
-    RFs& aFs,
-    CMPXResource& aResource)
-    {
-    MPX_FUNC("CMPXDbHandler::NewLC");
-    CMPXDbHandler* self = new (ELeave) CMPXDbHandler(aFs, aResource);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbHandler::~CMPXDbHandler()
-    {
-    MPX_FUNC("CMPXDbHandler::~CMPXDbHandler");
-
-    delete iAutoPlaylist;
-
-    delete iDbMusic;
-    delete iDbPlaylist;
-    delete iDbArtist;
-    delete iDbAlbum;
-    delete iDbGenre;
-    delete iDbComposer;
-    delete iDbAuxiliary;
-    delete iDbManager;
-
-    delete iMimeTypes;
-    delete iExtensions;
-    delete iExtensionsMime;
-    delete iExtensionsDrm;
-
-    iDbDrives.Close();
-    }
-
-// ----------------------------------------------------------------------------
-// C++ default constructor can NOT contain any code, that might leave
-// ----------------------------------------------------------------------------
-//
-CMPXDbHandler::CMPXDbHandler(
-    RFs& aFs,
-    CMPXResource& aResource) :
-    iFs(aFs),
-    iResource(aResource)
-    {
-    MPX_FUNC("CMPXDbHandler::CMPXDbHandler");
-    }
-
-// ----------------------------------------------------------------------------
-// Symbian 2nd phase constructor can leave.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::ConstructL()
-    {
-    MPX_FUNC("CMPXDbHandler::ConstructL");
-
-    iMimeTypes = iResource.ReadDesCArrayL(R_MC_MIME_TYPES);
-    iExtensions = iResource.ReadDesCArrayL(R_MC_MUSIC_FILE_EXTENSIONS);
-    iExtensionsMime = iResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_MIME);
-    iExtensionsDrm = iResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_DRM);
-    
-    // make sure all databases are created and valid
-    iDbManager = CMPXCollectionDbManager::NewL(iFs);
-    
-    CDesCArrayFlat* musicFolders =
-#ifdef RD_MULTIPLE_DRIVE
-        GetMusicFoldersL();
-#else
-        iResource.ReadDesCArrayL(R_MC_DEFAULT_MUSIC_FOLDERS);
-#endif
-
-    // create the music folders and initialize iDbDrives
-    CleanupStack::PushL(musicFolders);
-    ProcessMusicFoldersL(*musicFolders);
-    CleanupStack::PopAndDestroy(musicFolders);
-
-    // Create the db infrastructure, 
-    //
-    iDbMusic = CMPXDbMusic::NewL(*iDbManager, iResource, *this);
-    iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this);
-    iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this);
-	iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this);
-    iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre);
-    iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer);
-    iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource);
-    iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager);
-
-    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
-    iCollectionOpen = ETrue;
-
-    // If KErrCorrupt is returned, a database file was found to be corrupted
-    // and was replaced with a new one.  The db plugin can ignore this error and continue
-    // because a new db file was successfully created in a subsequent retry.
-    if ((err != KErrNone) && (err != KErrCorrupt) && (err != KErrDiskFull))
-        {
-        // leave to signal the caller that there was an error why creating and opening
-        // one or more of the databases
-        User::Leave(err);
-        }
-    else if (err == KErrDiskFull)
-        {
-        iOutOfDisk = ETrue;
-        }
-    else
-        {
-        // do nothing
-        }
-
-    // Verify the volume ids of each drive matches the database
-    MPX_TRAP(err,VerifyVolumeIdL());
-    if ((err != KErrNone) && (err != KErrDiskFull))
-        {
-        // leave to signal the caller that there was an error why creating and opening
-        // one or more of the databases
-        User::Leave(err);
-        }
-    else if (err == KErrDiskFull)
-        {
-        iOutOfDisk = ETrue;
-        }
-
-//#ifdef _DEBUG
-//    iDbManager->PrintDatabaseL();    // PREQ2536 the files sqlrowsetutil.h and sqlrowsetutil.cpp has been removed
-//#endif
-
-    MPX_DEBUG2("CMPXDbHandler::ConstructL DbCount[%d]", iDbManager->DatabaseCount());
-    }
-
-// ----------------------------------------------------------------------------
-// Add song to collection
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::AddSongL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray* aMessageArray)
-    {
-    MPX_FUNC("CMPXDbHandler::AddSongL");
-
-    BeginTransactionL();
-    TUint32 songId(0);
-    MPX_TRAPD(err, songId = DoAddSongL(aMedia,aMessageArray));
-
-    if (iOutOfDisk && (err == KErrNotFound))
-        {
-        err = KErrDiskFull;
-        }
-    EndTransactionL(err);
-
-    return songId;
-    }
-
-// ----------------------------------------------------------------------------
-// Add song to collection with no database transaction
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::AddSongWithNoTransactionL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray* aMessageArray)
-    {
-    MPX_FUNC("CMPXDbHandler::AddSongWithNoTransactionL");
-
-    TUint32 songId(0);
-    MPX_TRAPD(err, songId = DoAddSongL(aMedia,aMessageArray));
-
-    if (iOutOfDisk && (err == KErrNotFound))
-        {
-        err = KErrDiskFull;
-        }
-    User::LeaveIfError(err);
-
-    return songId;
-    }
-
-// ----------------------------------------------------------------------------
-// Add playlist to collection
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::AddPlaylistL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::AddPlaylistL");
-
-    BeginTransactionL();
-    TUint32 playlistId(0);
-    MPX_TRAPD(err, playlistId = DoAddPlaylistL(aMedia));
-    EndTransactionL(err);
-
-    return playlistId;
-    }
-
-// ----------------------------------------------------------------------------
-// Add song to playlist
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::AddSongToPlaylistL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::AddSongToPlaylistL");
-
-    BeginTransactionL();
-    TUint32 playlistId(0);
-    MPX_TRAPD(err, playlistId = DoAddSongToPlaylistL(aMedia));
-    EndTransactionL(err);
-
-    return playlistId;
-    }
-
-// ----------------------------------------------------------------------------
-// Update a song in the collection
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::UpdateSongL");
-
-    BeginTransactionL();
-    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
-    MPX_TRAPD(err, visibleChange = DoUpdateSongL(aMedia, aItemChangedMessages));
-    EndTransactionL(err);
-    return visibleChange;
-    }
-
-// ----------------------------------------------------------------------------
-// Update a playlist in the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::UpdatePlaylistL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aMessageArray)
-    {
-    MPX_FUNC("CMPXDbHandler::UpdatePlaylistL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoUpdatePlaylistL(aMedia, aMessageArray));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Updates the playlist songs
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::UpdatePlaylistSongsL(
-    const CMPXMedia& aMedia,
-    CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbHandler::UpdatePlaylistSongsL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoUpdatePlaylistSongsL(aMedia, aMessage));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Reorder a song in a playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::ReorderPlaylistL(
-    const TMPXItemId& aPlaylistId,
-    const TMPXItemId& aSongId,
-    TUint aOriginalOrdinal,
-    TUint aNewOrdinal,
-    CMPXMessage& aMessage)
-    {
-    MPX_DEBUG5("-->CMPXDbHandler::ReorderPlaylistL(0x%x, 0x%x, %d, %d)",
-               aPlaylistId.iId2, aSongId.iId2, aOriginalOrdinal, aNewOrdinal);
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoReorderPlaylistL(aPlaylistId, aSongId, aOriginalOrdinal, aNewOrdinal, aMessage));
-    EndTransactionL(err);
-    MPX_DEBUG2("<--CMPXDbHandler::ReorderPlaylistL() error=%d", err);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove the entire music collection database
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveEntireCollectionL()
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveEntireCollectionL");
-    BeginTransactionL();
-    MPX_TRAPD(err, iDbManager->RecreateAllDatabasesL());
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Delete a song from collection
-// The function notifies collection model to perform deletion
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveSongL(
-    TUint32 aSongId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages,
-    TBool aDeleteRecord)
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveSongL");
-
-    MPX_TRAPD(err, DoRemoveSongL(aSongId, aUriArray, aItemChangedMessages, aDeleteRecord));
-
-    MPX_TRAP(err, DoRemoveSongFromPlaylistL(aSongId,aItemChangedMessages));
-
-    }
-
-// ----------------------------------------------------------------------------
-// Removes a category of songs from the music collection,
-// and its corresponding category in the lookup table
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveSongsMatchingCategoryL(
-    TMPXGeneralCategory aCategory,
-    TUint32 aCategoryId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingCategoryL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoRemoveSongsMatchingCategoryL(aCategory, aCategoryId, aUriArray, aItemChangedMessages));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Delete songs for the specified artist and album from collection
-// The function notifies collection model to perform deletion
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL(
-    TUint32 aArtistId,
-    TUint32 aAlbumId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoRemoveSongsMatchingArtistAndAlbumL(aArtistId, aAlbumId, aUriArray,
-        aItemChangedMessages));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove all playlists from collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveAllPlaylistsL()
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveAllPlaylistsL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoRemoveAllPlaylistsL());
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove specified playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemovePlaylistL(
-    TUint32 aPlaylistId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::RemovePlaylistL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoRemovePlaylistL(aPlaylistId, aUriArray, aItemChangedMessages));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove song from playlist songs table
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RemoveSongFromPlaylistL(
-    TUint32 aPlaylistId,
-    const TMPXItemId& aSongId,
-    TInt aOrdinal,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveSongFromPlaylistL");
-    MPX_DEBUG5("CMPXDbHandler::RemoveSongFromPlaylistL(playlist 0x%x, songId [0x%x,0x%x], ordinal %d)",
-        aPlaylistId, aSongId.iId1, aSongId.iId2, aOrdinal);
-
-    MPX_TRAPD(err, DoRemoveSongFromPlaylistL(aPlaylistId, aSongId, aOrdinal, aItemChangedMessages));
-    if ( err && InTransaction() )
-        {
-        // only end transaction if there's an error
-        EndTransactionL( err );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted
-// at the end of its session.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::CleanupDeletedRecordsL()
-    {
-    MPX_FUNC("CMPXDbHandler::CleanupDeletedRecordsL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, DoCleanupDeletedRecordsL());
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-//  Read all songs and cache them into an array ordered by song name
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllSongsL(
-    CMPXMediaArray* aMediaArray,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllSongsL");
-    iDbMusic->GetAllSongsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-//  Read a limited # of songs and cache them into an array ordered by song name
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,
-                                        CMPXMediaArray& aMediaArray, TInt aLimit)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllSongsLimitedL");
-    iDbMusic->GetAllSongsLimitedL( aAttrs, aMediaArray, aLimit );
-    }
-
-// ----------------------------------------------------------------------------
-//  Read all songs and cache them into an array ordered by song name
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsInBlockL(
-    CMPXMediaArray* aMediaArray,
-    const TArray<TMPXAttribute>& aAttrs,
-    TPtrC aTitle,
-    TUint aNumOfSongs,
-    TBool aAsc)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsInBlockL");
-    iDbMusic->GetSongsInBlockL(aAttrs, *aMediaArray, aTitle, aNumOfSongs, aAsc);
-    }
-
-// ----------------------------------------------------------------------------
-//  Read songs at a particular offset
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsAtOffsetL( CMPXMediaArray* aMediaArray,
-                                       const TArray<TMPXAttribute>& aAttrs,
-                                       TInt aOffset,
-                                       TInt aCount )
-    {
-    MPX_DEBUG1("CMPXDbHandler::GetSongsAtOffsetL <--");
-    iDbMusic->GetSongsAtOffsetL( *aMediaArray, aAttrs, aOffset, aCount );
-    }
-
-// ----------------------------------------------------------------------------
-// Get all songs matching the given artist ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingArtistL(
-    TUint aArtistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingArtistL");
-    iDbMusic->GetSongsForArtistL(aArtistId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all songs matching the given album ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingAlbumL(
-    TUint aAlbumId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingAlbumL");
-    iDbMusic->GetSongsForAlbumL(aAlbumId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Get all songs matching the given artist and album ID
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingArtistAndAlbumL(
-    TUint aArtistId,
-    TUint aAlbumId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingArtistAndAlbumL");
-    iDbMusic->GetSongsForArtistAndAlbumL(aArtistId, aAlbumId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all songs matching the given genre ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingGenreL(
-    TUint aGenreId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingGenreL");
-    iDbMusic->GetSongsForGenreL(aGenreId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all songs matching the given composer ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingComposerL(
-    TUint aComposerId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingComposerL");
-    iDbMusic->GetSongsForComposerL(aComposerId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all songs that belong to the given playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongsMatchingPlaylistL(
-    TUint aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongsMatchingPlaylistL");
-    GetPlaylistSongsL(aPlaylistId, aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get song matching the given song ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongL(
-    TUint32 aSongId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongL");
-    iDbMusic->GetSongL(aSongId, aAttrs, aMedia);
-    }
-
-// ----------------------------------------------------------------------------
-// GetSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetSongL(
-    TUint32 aSongId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongL");
-
-    CMPXMedia* media = CMPXMedia::NewL();
-    CleanupStack::PushL(media);
-
-    GetSongL(aSongId, aAttrs, *media);
-    aMediaArray.AppendL(*media);
-
-    CleanupStack::PopAndDestroy(media);
-    }
-
-// ----------------------------------------------------------------------------
-// Get song matching the given song ID and playlist ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetPlaylistSongL(
-    TUint32 aSongId,
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_DEBUG3("-->CMPXDbHandler::GetPlaylistSongL songId[0x%x] playlistId[0x%x]", aSongId, aPlaylistId);
-
-    // complete the song information from the Music table
-    MPX_TRAPD(err, iDbMusic->GetSongL(aSongId, aAttrs, aMedia));
-
-    //
-    // song not found in Music table
-    //
-    if (err == KErrNotFound)
-        {
-        //
-        // Leave with KErrNotFound if one of the following is true:
-        // 1) the requested song is in an auto playlist. Since auto-playlist isn't
-        //    stored in playlist tables, we won't be able to retrieve info elsewhere
-        // 2) the requested song is in a user playlist but we cannot find the song
-        //    info from playlist tables either
-        //
-        if (EMPXNoAutoPlaylist != iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) ||
-            !iDbPlaylist->Songs().GetSongL(aPlaylistId, aSongId, aAttrs, aMedia))
-            {
-            User::Leave(KErrNotFound);
-            }
-        }
-
-    //
-    // Unable to read information from Music table
-    //
-    else
-        {
-        // ignore the error if KErrNotFound
-        User::LeaveIfError(err);
-        }
-    MPX_DEBUG1("<--CMPXDbHandler::GetPlaylistSongL");
-    }
-
-// ----------------------------------------------------------------------------
-// GetPlaylistSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetPlaylistSongL(
-    TUint32 aSongId,
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistSongL");
-
-    CMPXMedia* media = CMPXMedia::NewL();
-    CleanupStack::PushL(media);
-
-    GetPlaylistSongL(aSongId, aPlaylistId, aAttrs, *media);
-    aMediaArray.AppendL(*media);
-
-    CleanupStack::PopAndDestroy(media);
-    }
-
-// ----------------------------------------------------------------------------
-// Get song matching the given URI
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::GetSongIdMatchingUriL(
-    const TDesC& aUri)
-    {
-    MPX_FUNC("CMPXDbHandler::GetSongIdMatchingUriL");
-    return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, aUri, EFalse);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all artists
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllArtistsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllArtistsL");
-    iDbArtist->GetAllCategoryItemsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all albums
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllAlbumsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllAlbumsL");
-    iDbAlbum->GetAllCategoryItemsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all albums for the given artist ID
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAlbumsMatchingArtistL(
-    TUint aArtistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAlbumsMatchingArtistL");
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL( attributes );
-        
-    TBool tryGetSongCount = EFalse;
-    TInt attrCount(aAttrs.Count());
-    TInt i = 0;
-    for (i = 0; i < attrCount; i++)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-        TUint attributeId(aAttrs[i].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral && attributeId & EMPXMediaGeneralCount)
-            {
-            MPX_DEBUG1("    EMPXMediaGeneralCount");
-            
-            attributes.Append(TMPXAttribute(KMPXMediaIdGeneral, attributeId & !EMPXMediaGeneralCount));
-                       
-            tryGetSongCount = ETrue;
-            break;
-            }
-        
-        attributes.Append(aAttrs[i]);
-        }
-    
-    for (TInt j = i+1; j < attrCount; j++)
-        {
-        attributes.Append(aAttrs[j]);
-        }
-    iDbAlbum->GetSubCategoryItemsL(EMPXArtist, aArtistId, attributes.Array(), aMediaArray);
-    CleanupStack::PopAndDestroy(&attributes);
-    
-    TInt pPath(0);
-    if (aMediaArray.Count())
-        {
-        CMPXMedia* pMedia = aMediaArray[0];
-        if (pMedia->IsSupported(KMPXMediaGeneralValue))
-            {
-            pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-            MPX_ASSERT(pPath);
-            }
-        }
-    
-    TInt albumCount(aMediaArray.Count());
-    if (albumCount)
-        {
-        if ( tryGetSongCount )
-            {
-            TInt startIndex = pPath ? 1 : 0;
-            
-            for (TInt i = startIndex; i < albumCount; i++)
-                {
-                CMPXMedia* media = aMediaArray[i];
-                TUint32 albumId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
-
-				TInt songCount = iDbAlbum->GetSongsCountInAlbumMatchingArtistL(aArtistId, albumId);
-
-                media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
-				MPX_DEBUG2("	SongCount[%d]", songCount );				
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Get all genres
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllGenresL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllGenresL");
-    iDbGenre->GetAllCategoryItemsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all composers
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllComposersL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllComposersL");
-    iDbComposer->GetAllCategoryItemsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get the playlist ID of the playlist that matches the given URI
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::GetPlaylistIdMatchingUriL(
-    const TDesC& aUri)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistIdMatchingUriL");
-    return iDbPlaylist->GetIdL(aUri);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::IsAutoPlaylistL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::IsAutoPlaylistL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbHandler::IsAutoPlaylistL");
-    return (iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) != EMPXNoAutoPlaylist);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all user playlist names
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllPlaylistsL(
-    CMPXMediaArray* aMediaArray,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllPlaylistsL");
-    iDbPlaylist->GetAllPlaylistsL(aAttrs, *aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all system playlist names
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetAllSystemPlaylistNamesL(
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllSystemPlaylistNamesL()");
-    iAutoPlaylist->GetAllPlaylistsL(*aMediaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Get the name of the row matching the given ID
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbHandler::GetNameMatchingIdL(
-    const TUint32 aId) const
-    {
-    MPX_FUNC("CMPXDbHandler::GetNameMatchingIdL()");
-
-    HBufC* name(NULL);
-    TMPXGeneralCategory category(MPX_ITEM_CATEGORY(aId));
-    switch (category)
-        {
-        case EMPXCollection:
-            {
-            // song name
-            name = iDbMusic->GetNameL(aId);
-            break;
-            }
-        case EMPXPlaylist:
-            {
-            // playlist name
-            if (iAutoPlaylist->AutoPlaylistTypeL(aId) != EMPXNoAutoPlaylist)
-                {
-                name = iAutoPlaylist->AutoPlaylistNameL(aId).AllocL();
-                }
-            else
-                {
-                name = iDbPlaylist->GetNameL(aId);
-                }
-            break;
-            }
-        default:
-            {
-            // category name
-            name = DbCategoryL(category)->GetNameL(aId);
-            break;
-            }
-        }
-
-    return name;
-    }
-
-// ----------------------------------------------------------------------------
-// Get the URI of the row matching the given ID
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbHandler::GetUriMatchingIdL(
-    const TUint32 aId) const
-    {
-    MPX_FUNC("CMPXDbHandler::GetUriMatchingIdL");
-
-    HBufC* uri(NULL);
-    switch (MPX_ITEM_CATEGORY(aId))
-        {
-        case EMPXCollection:
-            {
-            // song URI
-            uri = iDbMusic->GetUriL(aId);
-            break;
-            }
-        case EMPXPlaylist:
-            {
-            // playlist URI
-            uri = iDbPlaylist->GetUriL(aId);
-            break;
-            }
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    return uri;
-    }
-
-// ----------------------------------------------------------------------------
-// Get category
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetCategoryL(
-    const TUint32 aCategoryId,
-    TMPXGeneralCategory aCategory,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia* aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::GetCategoryL");
-
-    switch (aCategory)
-        {
-        case EMPXPlaylist:
-            {
-            if (iAutoPlaylist->AutoPlaylistTypeL(aCategoryId) != EMPXNoAutoPlaylist)
-                {
-                iAutoPlaylist->GetPlaylistL(aCategoryId, aAttrs, *aMedia);
-                }
-            else
-                {
-                iDbPlaylist->GetPlaylistL(aCategoryId, aAttrs, *aMedia);
-                }
-            break;
-            }
-        default:
-            {
-            DbCategoryL(aCategory)->GetCategoryItemL(aCategoryId, aAttrs, *aMedia);
-            break;
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for all songs
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetAllSongsDurationL()
-    {
-    MPX_FUNC("CMPXDbHandler::GetAllSongsDurationL");
-    return iDbMusic->AllSongsDurationL();
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for an artist
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetArtistDurationL(
-    TInt aArtistId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetArtistDurationL");
-    return iDbMusic->ArtistDurationL(aArtistId);
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for an album
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetAlbumDurationL(
-    TInt aAlbumId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetAlbumDurationL");
-    return iDbMusic->AlbumDurationL(aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for an artist/album combination
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetArtistAlbumDurationL(
-    TInt aArtistId,
-    TInt aAlbumId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetArtistAlbumDurationL");
-    return iDbMusic->ArtistAlbumDurationL(aArtistId, aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for a composer
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetComposerDurationL(
-    TInt aComposerId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetComposerDurationL");
-    return iDbMusic->ComposerDurationL(aComposerId);
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for a genre
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetGenreDurationL(
-    TInt aGenreId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetGenreDurationL");
-    return iDbMusic->GenreDurationL(aGenreId);
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for a user playlist
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetUserPlaylistDurationL(
-    TInt aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetUserPlaylistDurationL");
-
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL(attributes);
-    attributes.AppendL(KMPXMediaGeneralId);
-    attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralDuration));
-
-    CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
-    CleanupStack::PushL(mediaArray);
-
-    GetPlaylistSongsL(aPlaylistId, attributes.Array(), *mediaArray);
-
-    TInt duration(0);
-    TInt count(mediaArray->Count());
-    for (TInt index = 0; index < count; ++index)
-        {
-        CMPXMedia* media((*mediaArray)[index]);
-        if (media->IsSupported(KMPXMediaGeneralDuration))
-            {
-            duration += media->ValueTObjectL<TInt>(KMPXMediaGeneralDuration);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(mediaArray);
-    CleanupStack::PopAndDestroy(&attributes);
-
-    return duration;
-    }
-
-// ----------------------------------------------------------------------------
-//  Get the duration for a playlist
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::GetPlaylistDurationL(
-    TInt aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistDurationL");
-
-    TInt duration(0);
-
-    if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist))
-        {
-        duration = iDbMusic->RecentlyPlayedDurationL();
-        }
-    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist))
-        {
-        duration = iDbMusic->MostPlayedDurationL();
-        }
-    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyAddedPlaylist))
-        {
-        duration = iDbMusic->RecentlyAddedDurationL();
-        }
-    else
-        {
-        duration = GetUserPlaylistDurationL(aPlaylistId);
-        }
-
-    return duration;
-    }
-
-// ----------------------------------------------------------------------------
-// Find the number of items of a specified type
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbHandler::NumberOfItemsL(
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbHandler::NumberOfItemsL");
-
-    TInt count(0);
-    switch(aCategory)
-        {
-        case EMPXSong:
-            {
-            count = iDbMusic->CountL();
-            break;
-            }
-        case EMPXPlaylist:
-            {
-            // return the total number of playlists, including the system ones
-            count = iDbPlaylist->CountL() + EMPXAutoPlaylistCount;
-            break;
-            }
-        default:
-            {
-            count = DbCategoryL(aCategory)->CountL();
-            break;
-            }
-        }
-
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::FindAllLC
-// ----------------------------------------------------------------------------
-//
-CMPXMedia* CMPXDbHandler::FindAllLC(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbHandler::FindAllLC");
-
-    // leave if the given media doesn't contain the following attributes
-    if (!aCriteria.IsSupported(KMPXMediaGeneralType) ||
-        !aCriteria.IsSupported(KMPXMediaGeneralCategory))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    RArray<TInt> supportedIds;
-    CleanupClosePushL(supportedIds);
-    supportedIds.AppendL(KMPXMediaIdContainer);
-    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
-
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-
-    FindAllL(aCriteria, aAttrs, array);
-
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory,
-        aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory));
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-
-    CleanupStack::PopAndDestroy(array);
-    return entries;
-    }
-
-// ----------------------------------------------------------------------------
-// Set the last refreshed time into the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::SetLastRefreshedTimeL(
-    TTime aTime)
-    {
-    MPX_FUNC("CMPXDbHandler::SetLastRefreshedTimeL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, iDbAuxiliary->SetLastRefreshedTimeL(aTime));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Get the last refreshed time from the collection
-// ----------------------------------------------------------------------------
-//
-TTime CMPXDbHandler::GetLastRefreshedTimeL()
-    {
-    MPX_FUNC("CMPXDbHandler::GetLastRefreshedTimeL");
-    return iDbAuxiliary->LastRefreshedTimeL();
-    }
-
-// ----------------------------------------------------------------------------
-// Set the db corrupted state for all drives
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::SetDBCorruptedL(
-    TBool aCorrupted)
-    {
-    MPX_FUNC("CMPXDbHandler::SetDBCorruptedL");
-
-    BeginTransactionL();
-    MPX_TRAPD(err, iDbAuxiliary->SetDBCorruptedL(aCorrupted));
-    EndTransactionL(err);
-    }
-
-// ----------------------------------------------------------------------------
-// Gets the db corrupted state for all drives
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::IsDBCorruptedL()
-    {
-    MPX_FUNC("CMPXDbHandler::IsDBCorruptedL");
-    return iDbAuxiliary->DBCorruptedL();
-    }
-
-// ----------------------------------------------------------------------------
-// Have the databases been created?
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::DatabaseCreated()
-    {
-    MPX_FUNC("CMPXDbHandler::DatabaseCreatedL");
-
-    TBool AuxilaryDbIsRefreshed(EFalse);
-    TRAP_IGNORE(AuxilaryDbIsRefreshed = iDbAuxiliary->IsRefreshedL());
-    // If none of the databases were available, ie out of disk we return EFalse
-    return iDbManager->IsInitialized() && AuxilaryDbIsRefreshed;
-    }
-
-// ----------------------------------------------------------------------------
-// Open a database
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::OpenDatabaseL(
-    TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbHandler::OpenDatabaseL");
-    MPX_DEBUG2( "CMPXDbHandler::OpenDatabaseL: %i", aDrive);
-    iDbManager->OpenDatabaseL(aDrive);
-
-    // Verify the volume ID after a remount event
-    VerifyVolumeIdL();
-    }
-
-// ----------------------------------------------------------------------------
-// Close a database
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::CloseDatabaseL(
-    TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbHandler::CloseDatabaseL");
-    MPX_DEBUG2( "CMPXDbHandler::CloseDatabaseL drive: %i", aDrive );
-    iDbManager->CloseDatabaseL(aDrive);
-    }
-
-// ----------------------------------------------------------------------------
-// Re-create all databases
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::ReCreateDatabasesL()
-    {
-    MPX_FUNC("CMPXDbHandler::ReCreateDatabasesL");
-    iDbManager->RecreateAllDatabasesL();
-    }
-
-// ----------------------------------------------------------------------------
-// Set handler refresh status
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::RefreshStartL()
-    {
-    MPX_FUNC("CMPXDbHandler::RefreshStartL");
-
-    iOutOfDisk = EFalse;
-    // Re-open databases
-    // This is needed for the case where we were OOD before, but user
-    // has cleared some space but now try to refresh
-    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
-    iCollectionOpen = ETrue;
-    // Update (synchronize) music basic table if it's not
-    // in sync with music table
-    if(iSynchronizeBasicTable)
-        {
-        iDbMusic->RefreshEndL();
-        }
-    iSynchronizeBasicTable = ETrue;
-
-    if(err == KErrDiskFull)
-        {
-            iOutOfDisk = ETrue;
-        }
-
-    if(!iOutOfDisk)
-    {
-        MPX_TRAP(err,CheckDiskSpaceOnDrivesL());
-
-        if(err == KErrDiskFull)
-            {
-            iOutOfDisk = ETrue;
-            }
-    }
-    
-    iDbMusic->RefreshStartL();
-
-    BeginTransactionL();
-    iRefresh = ETrue;
-    }
-
-// ----------------------------------------------------------------------------
-// Re-set handler refresh status
-// ----------------------------------------------------------------------------
-//
-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);
-        }
-    iDbMusic->RefreshEndL();
-    //Update of music basic table fails when the collection is not open
-    //Next time the collection is opened the music basic table must be updated
-    if (iCollectionOpen )
-        {
-        iSynchronizeBasicTable = EFalse;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Notification of Mtp status change
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::MtpStartL()
-    {
-    iMtpInUse = ETrue;
-    iOpOnDbCount = 0;
-    iDbManager->BeginL();
-    }
-
-// ----------------------------------------------------------------------------
-// Notification of Mtp status change
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::MtpEndL()
-    {
-    iMtpInUse = EFalse;
-    iOpOnDbCount = 0;
-    iDbManager->CommitL();
-    }
-
-// ----------------------------------------------------------------------------
-// Get all records count for music
-// ----------------------------------------------------------------------------
-//
-TUint CMPXDbHandler::GetMusicCountL(TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbHandler::GetMusicCountL");
-    TUint total(0);
-
-    //music
-    total += iDbMusic->GetDriveTrackCountL(aDrive);
-
-    return total;
-    }
-
-// ----------------------------------------------------------------------------
-// Get all records count for playlists
-// ----------------------------------------------------------------------------
-//
-TUint CMPXDbHandler::GetPlaylistCountL(TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistCountL");
-    TUint total(0);
-
-    //playlist
-    total += iDbPlaylist->GetDrivePlaylistCountL(aDrive);
-
-    return total;
-    }
-
-// ----------------------------------------------------------------------------
-// Get all records count for music and playlists
-// ----------------------------------------------------------------------------
-//
-TUint CMPXDbHandler::GetTotalCountL(TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbHandler::GetTotalCountL");
-    TUint total(0);
-
-    //music
-    total += iDbMusic->GetDriveTrackCountL(aDrive);
-    //playlist
-    total += iDbPlaylist->GetDrivePlaylistCountL(aDrive);
-
-    return total;
-    }
-
-// ----------------------------------------------------------------------------
-// Get all records count for music and playlists
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                      CDesCArray& aUriArr, TInt& aLastID)
-    {
-    MPX_FUNC("CMPXDbHandler::GetMusicUriArrayL");
-
-    iDbMusic->GetMusicUriArrayL(aDrive,aFromID,aRecords,aUriArr,aLastID);
-    }
-
-// ----------------------------------------------------------------------------
-// Get all records count for music and playlists
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                         CDesCArray& aUriArr, TInt& aLastID)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistUriArrayL");
-
-    iDbPlaylist->GetPlaylistUriArrayL(aDrive,aFromID,aRecords,aUriArr,aLastID);
-    }
-
-// ----------------------------------------------------------------------------
-// Starts a transaction on all databases
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::BeginTransactionL()
-    {
-    MPX_FUNC("CMPXDbHandler::BeginTransactionL");
-
-    if(!iMtpInUse)
-        {
-        iDbManager->BeginL();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Ends a transaction on all databases
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::EndTransactionL(
-    TInt aError)
-    {
-    MPX_FUNC("CMPXDbHandler::EndTransactionL");
-
-    if(iMtpInUse)
-        {
-        if (aError)
-            {
-            iOpOnDbCount = 0;
-            iDbManager->RollbackL();
-            User::Leave(aError);
-            }
-        
-        if(iOpOnDbCount >= KMaxOpInTransaction)
-            {
-            MPX_DEBUG2("CMPXDbHandler::EndTransactionL - %d>KMaxOpInTransaction Commiting",iOpOnDbCount);
-            iOpOnDbCount = 0;
-            iDbManager->CommitL();
-            iDbManager->BeginL();
-            }        
-        }
-    else
-        {
-        if (aError)
-            {
-            MPX_DEBUG2("CMPXDbHandler::EndTransactionL - Rollback [%d]", aError);
-
-            iDbManager->RollbackL();
-            
-            // KSqlDbCorrupted indicates DB corrupted, need to recreate.
-            if ( aError != KSqlDbCorrupted )
-                {
-                User::Leave(aError);
-                }
-            }
-        else
-            {
-            iDbManager->CommitL();
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Checks if the database is currently in a transaction
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::InTransaction()
-    {
-    MPX_FUNC("CMPXDbHandler::InTransaction");
-    return iDbManager->InTransaction();
-    }
-
-// ----------------------------------------------------------------------------
-// Notifies the handler that the collection will be closed.
-// It is called before closing the collection.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::PreCloseCollectionL()
-    {
-    MPX_FUNC("CMPXDbHandler::PreCloseCollectionL");
-    // Complete pending transaction and set the latest refresh time
-    // before closing the databases if collection close event occurs
-    // before the end of the refresh operation
-    if(iRefresh)
-        {
-        EndTransactionL(KErrNone);
-        if (!iOutOfDisk)
-            {
-            // Write last refreshed time as current time
-            // This also sets corrupt = 0
-            TTime curTime;
-            curTime.HomeTime();
-            SetLastRefreshedTimeL(curTime);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Notifies the handler that the collection was closed.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::CollectionClosed()
-    {
-    MPX_FUNC("CMPXDbHandler::CollectionClosed");
-
-    iCollectionOpen = EFalse;
-    }
-
-// ----------------------------------------------------------------------------
-//Notifies the handler that the collection was opened.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::CollectionOpenedL()
-    {
-    MPX_FUNC("CMPXDbHandler::CollectionOpened");
-
-    iCollectionOpen = ETrue;
-    // Update (synchronize) music basic table if it's not
-    // in sync with music table
-    if(iSynchronizeBasicTable)
-        {
-        iDbMusic->RefreshEndL();
-        iSynchronizeBasicTable = EFalse;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Add song to collection
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::DoAddSongL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray* aMessageArray)
-    {
-    MPX_FUNC("CMPXDbHandler::DoAddSongL");
-
-    if (!aMedia.IsSupported(KMPXMediaGeneralUri))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    // add the song to the Music table
-    TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
-    TUint32 songId(iDbMusic->AddSongL(aMedia, drive,
-                                      iRefresh?NULL:aMessageArray));
-
-    // update the playlist tables
-    // make sure the song db flags are reset and not just updated
-    iDbPlaylist->UpdateSongL(aMedia, ETrue);
-    
-    if(iMtpInUse)
-        {
-        ++iOpOnDbCount;
-        }
-
-    return songId;
-    }
-
-// ----------------------------------------------------------------------------
-// Add playlist to collection
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::DoAddPlaylistL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::DoAddPlaylistL");
-
-    CMPXMedia* media = CMPXMedia::NewL(aMedia);
-    CleanupStack::PushL(media);
-
-    const TDesC& playlistUri = media->ValueText(KMPXMediaGeneralUri);
-
-    //
-    // client has asked to create a virtual playlist if file name is not specified
-    // in the URI. In this case, generate URI for virtual playlist specified as
-    // follows:
-    //          <dir path>\timestamp.vir
-    //
-    TParsePtrC parser(playlistUri);
-
-    if (!parser.NameOrExtPresent() ||
-        parser.IsNameWild() ||
-        parser.IsExtWild())
-        {
-        HBufC* newUri = HBufC::NewLC(parser.DriveAndPath().Length() + KMCMaxTextLen +
-            KMPXVirtualPlaylistExt().Length());
-
-        TPtr ptr = newUri->Des();
-        ptr.Append(parser.DriveAndPath());
-        TTime time;
-        time.HomeTime();
-        ptr.AppendNum(time.Int64());
-        ptr.Append(KMPXVirtualPlaylistExt);
-
-        // overwrite the old uri with the new one with full path and playlist
-        // playlist filename
-        media->SetTextValueL(KMPXMediaGeneralUri, *newUri);
-
-        CleanupStack::PopAndDestroy(newUri);
-
-        // set DbFlags to indicate that this is a virtual playlist
-        media->SetTObjectValueL<TUint>(KMPXMediaGeneralFlags,
-            KMPXMediaGeneralFlagsSetOrUnsetBit | KMPXMediaGeneralFlagsIsVirtual);
-        }
-
-    // complete the song attributes from the music table
-    UpdatePlaylistSongInfoL(*media);
-
-    // add playlist to the database
-    TUint32 playlistId = iDbPlaylist->AddPlaylistL(*media);
-
-    CleanupStack::PopAndDestroy(media);
-    return playlistId;
-    }
-
-// ----------------------------------------------------------------------------
-// Add song to playlist
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::DoAddSongToPlaylistL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::DoAddSongToPlaylistL");
-
-    CMPXMedia* media = CMPXMedia::NewL(aMedia);
-    CleanupStack::PushL(media);
-
-    // complete the song attributes from the music table
-    UpdatePlaylistSongInfoL(*media);
-
-    // add the songs to the playlist
-    TUint32 playlistId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-
-    CMPXMediaArray* ary( aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents) );
-    User::LeaveIfNull( ary );
-    iDbPlaylist->AddSongsL(playlistId,*ary);
-
-    CleanupStack::PopAndDestroy(media);
-    return playlistId;
-    }
-
-// ----------------------------------------------------------------------------
-// Update a song in the collection
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::DoUpdateSongL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::DoUpdateSongL");
-
-    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
-
-    TUint32 songId(0);
-
-    if (aMedia.IsSupported(KMPXMediaGeneralId))
-        {
-        songId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-        }
-    if (aMedia.IsSupported(KMPXMediaGeneralUri))
-        {
-        const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
-        songId = MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, uri, EFalse);
-        }
-    if (!songId)
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    // Update the Music table
-    TRAPD(err, visibleChange = iDbMusic->UpdateSongL(songId, aMedia, aItemChangedMessages));
-
-    // do not leave if song is not found in Music table
-    // leave for other errors such as disk full
-    if(err != KErrNone && err != KErrNotFound)
-        {
-        User::Leave(err);
-        }
-
-    // Update the Playlist table
-    TBool visible = EFalse;
-
-    TRAP( err, visible = iDbPlaylist->UpdateSongL(aMedia, EFalse, &aItemChangedMessages));
-
-    // do not leave if song is not found in Playlist table
-    // leave for other errors such as disk full
-    if(err != KErrNone && err != KErrNotFound)
-        {
-        User::Leave(err);
-        }
-
-    // make it visible if either table is updated
-    if (visible)
-        {
-        visibleChange = CMPXDbActiveTask::EAllVisible;
-        }
-
-    return visibleChange;
-    }
-
-// ----------------------------------------------------------------------------
-// Update a playlist in the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoUpdatePlaylistL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aMessageArray)
-    {
-    MPX_FUNC("CMPXDbHandler::DoUpdatePlaylistL");
-
-    TUint32 playlistId(0);
-    TInt drive(0);
-
-    CMPXMedia* media = CMPXMedia::NewL(aMedia);
-    CleanupStack::PushL(media);
-
-
-    ProcessPlaylistMediaL(*media, playlistId, drive);
-
-    CMPXMessage* m1 = CMPXMessage::NewL();
-    CleanupStack::PushL(m1);
-    CMPXMessage* m2 = CMPXMessage::NewL();
-    CleanupStack::PushL(m2);
-
-    // send 2 messages to notify the playlist change & to refresh the display (update playlist name)
-    MPXDbCommonUtil::FillItemChangedMessageL(*m1, playlistId, EMPXItemModified,
-            EMPXPlaylist, KDBPluginUid);
-
-    MPXDbCommonUtil::FillItemChangedMessageL(*m2, EBrowsePlaylist, EMPXItemModified,
-                EMPXPlaylist, KDBPluginUid);
-
-    iDbPlaylist->UpdatePlaylistL(*media, *m1, drive);
-
-    aMessageArray.AppendL(*m1);
-    aMessageArray.AppendL(*m2);
-
-
-    CleanupStack::PopAndDestroy(m2);
-    CleanupStack::PopAndDestroy(m1);
-    CleanupStack::PopAndDestroy(media);
-    }
-
-// ----------------------------------------------------------------------------
-// Update a playlist in the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoUpdatePlaylistSongsL(
-    const CMPXMedia& aMedia,
-    CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbHandler::DoUpdatePlaylistSongsL");
-
-    CMPXMedia* media = CMPXMedia::NewL(aMedia);
-    CleanupStack::PushL(media);
-
-    TUint32 playlistId(0);
-    TInt drive(0);
-
-    // get the playlist ID and drive ID
-    ProcessPlaylistMediaL(*media, playlistId, drive);
-    MPXDbCommonUtil::FillItemChangedMessageL(aMessage, playlistId, EMPXItemModified,
-        EMPXPlaylist, KDBPluginUid);
-
-    // complete the song attributes from the Music table
-    UpdatePlaylistSongInfoL(*media);
-
-    // delete existing songs for the playlist first
-    iDbPlaylist->Songs().DeleteSongsL(playlistId, drive);
-
-    // add new songs to the playlist
-    CMPXMediaArray* ary( media->Value<CMPXMediaArray>(KMPXMediaArrayContents ) );
-    User::LeaveIfNull( ary );
-    iDbPlaylist->AddSongsL(playlistId, *ary);
-
-    CleanupStack::PopAndDestroy(media);
-    }
-
-// ----------------------------------------------------------------------------
-// Reorder a song in a playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoReorderPlaylistL(
-    const TMPXItemId& aPlaylistId,
-    const TMPXItemId& aSongId,
-    TUint aOriginalOrdinal,
-    TUint aNewOrdinal,
-    CMPXMessage& aMessage)
-    {
-    MPX_DEBUG1("-->CMPXDbHandler::DoReorderPlaylistL()");
-
-    if (aOriginalOrdinal != aNewOrdinal)
-        {
-        iDbPlaylist->Songs().ReorderSongL(aPlaylistId, aSongId, aOriginalOrdinal, aNewOrdinal);
-
-        MPXDbCommonUtil::FillItemChangedMessageL(aMessage, aPlaylistId.iId2, EMPXItemModified,
-            EMPXPlaylist, KDBPluginUid);
-        }
-
-    MPX_DEBUG1("<--CMPXDbHandler::DoReorderPlaylistL()");
-    }
-
-// ----------------------------------------------------------------------------
-// Delete a song from collection
-// The function notifies collection model to perform deletion
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveSongL(
-    TUint32 aSongId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages,
-    TBool aDeleteRecord)
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemoveSongL");
-
-    // Get the song drive
-    TUint32 artistID(0);
-    TUint32 albumID(0);
-    TUint32 genreID(0);
-    TUint32 composerID(0);
-    TInt drive(0);
-
-    // Get information from the Music table first
-    HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, drive);
-
-    // add the URI to the return array
-    CleanupStack::PushL(uri);
-    aUriArray.AppendL(*uri);
-    CleanupStack::PopAndDestroy(uri);
-
-    // Update the category records
-    TBool categoryExist( EFalse );
-    iDbArtist->DecrementSongsForCategoryL(artistID, drive, &aItemChangedMessages, categoryExist);
-    iDbAlbum->DecrementSongsForCategoryL(albumID, drive, &aItemChangedMessages, categoryExist, artistID);
-    iDbGenre->DecrementSongsForCategoryL(genreID, drive, &aItemChangedMessages, categoryExist);
-    iDbComposer->DecrementSongsForCategoryL(composerID, drive, &aItemChangedMessages, categoryExist);
-
-    // Update the music table
-    TBool deleteRecord(ETrue);
-
-#if defined (__MTP_PROTOCOL_SUPPORT)
-    // Mark the song record as deleted if the following is true; otherwise, delete the
-    // song record.
-    //
-    // A client other than MTP has initiated this song deletion (aDeleteRecord is EFalse)
-    // and MTP has turned on its cenrep key to save deleted records and current number of
-    // saved deleted records has not exceeded its maximum, KMCMaxSavedDeletedRecords.
-    //
-    // Songs are marked as deleted in order to support auto-sync. MTP will delete these
-    // marked records at the end of each session via CleanupDeletedRecordsL.
-    //
-    // For performance consideration, if the number of saved records exceeds its maximum,
-    // song record will be deleted.
-    if (!aDeleteRecord && SaveDeletedSongs())
-        {
-        TUint32 savedDeletedRecordCount(iDbAuxiliary->SaveDeletedRecordCountL());
-        MPX_DEBUG2("Current number of saved deleted record count is %d", savedDeletedRecordCount);
-
-        if (savedDeletedRecordCount < KMCMaxSavedDeletedRecords)
-            {
-            deleteRecord = EFalse;
-            TUint32 savedDeletedDriveRecordCount(iDbAuxiliary->SaveDeletedRecordCountL(drive));
-            iDbAuxiliary->SetSaveDeletedRecordCountL(drive,++savedDeletedDriveRecordCount);
-            }
-        }
-#endif
-
-    // delete the song from the Music table
-    iDbMusic->DeleteSongL(aSongId, drive, deleteRecord);
-
-    // add the item changed message
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted,
-        EMPXSong, KDBPluginUid);
-        
-
-    if(iMtpInUse)
-        {
-        ++iOpOnDbCount;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Delete a song from playlist tables
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveSongFromPlaylistL(TUint32 aSongId,CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemoveSongFromPlaylistL");
-    // delete song from the playlist tables on all drives
-    iDbPlaylist->DeleteSongL(aSongId, aItemChangedMessages);
-    }
-
-// ----------------------------------------------------------------------------
-// Removes a category of songs from the music collection,
-// and its corresponding category in the lookup table
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveSongsMatchingCategoryL(
-    TMPXGeneralCategory aCategory,
-    TUint32 aCategoryId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemoveSongsMatchingCategoryL");
-
-    // get the songs for the specified category
-    CMPXMediaArray* songs = CMPXMediaArray::NewL();
-    CleanupStack::PushL(songs);
-
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL(attributes);
-    attributes.AppendL(KMPXMediaGeneralId);
-
-    switch (aCategory)
-        {
-        case EMPXArtist:
-            {
-            iDbMusic->GetSongsForArtistL(aCategoryId, attributes.Array(), *songs);
-            break;
-            }
-        case EMPXAlbum:
-            {
-            iDbMusic->GetSongsForAlbumL(aCategoryId, attributes.Array(), *songs);
-            break;
-            }
-        case EMPXGenre:
-            {
-            iDbMusic->GetSongsForGenreL(aCategoryId, attributes.Array(), *songs);
-            break;
-            }
-        case EMPXComposer:
-            {
-            iDbMusic->GetSongsForComposerL(aCategoryId, attributes.Array(), *songs);
-            break;
-            }
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    CleanupStack::PopAndDestroy(&attributes);
-
-    // iterate the songs and remove them one by one
-    // so records in the category tables can also be updated
-    TInt count(songs->Count());
-    for (TInt index = 0; index < count; ++index)
-        {
-        CMPXMedia* song = (*songs)[index];
-        if (song->IsSupported(KMPXMediaGeneralId))
-            {
-            DoRemoveSongL((song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2,
-                aUriArray, aItemChangedMessages, EFalse);
-            DoRemoveSongFromPlaylistL((song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2,aItemChangedMessages);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(songs);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Delete songs for the specified artist and album from collection
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveSongsMatchingArtistAndAlbumL(
-    TUint32 aArtistId,
-    TUint32 aAlbumId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::RemoveSongsMatchingArtistAndAlbumL");
-
-    // get the songs for the specified artist and album
-    CMPXMediaArray* songs = CMPXMediaArray::NewL();
-    CleanupStack::PushL(songs);
-
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL (attributes);
-    attributes.AppendL(KMPXMediaGeneralId);
-
-    iDbMusic->GetSongsForArtistAndAlbumL(aArtistId, aAlbumId, attributes.Array(), *songs);
-    CleanupStack::PopAndDestroy(&attributes);
-
-    // iterate the songs and remove them one by one
-    // so records in the category tables can also be updated
-    TInt count(songs->Count());
-    for (TInt index = 0; index < count; ++index)
-        {
-        CMPXMedia* song = (*songs)[index];
-        if (song->IsSupported(KMPXMediaGeneralId))
-            {
-            DoRemoveSongL( song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId),
-                aUriArray, aItemChangedMessages, EFalse);
-            DoRemoveSongFromPlaylistL(song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId),aItemChangedMessages);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(songs);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove all playlists from collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveAllPlaylistsL()
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemoveAllPlaylistsL");
-    iDbPlaylist->DeleteAllPlaylistsL();
-    }
-
-// ----------------------------------------------------------------------------
-// Remove specified playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemovePlaylistL(
-    TUint32 aPlaylistId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemovePlaylistL");
-
-    HBufC* uri(iDbPlaylist->DeletePlaylistL(aPlaylistId));
-    if (uri)
-        {
-        CleanupStack::PushL(uri);
-        aUriArray.AppendL(*uri);
-        CleanupStack::PopAndDestroy(uri);
-        }
-
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aPlaylistId, EMPXItemDeleted,
-        EMPXPlaylist, KDBPluginUid);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove song from playlist songs table
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoRemoveSongFromPlaylistL(
-    TUint32 aPlaylistId,
-    const TMPXItemId& aSongId,
-    TInt aOrdinal,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::DoRemoveSongFromPlaylistL");
-    MPX_DEBUG5("CMPXDbHandler::DoRemoveSongFromPlaylistL(playlist 0x%x, songId [0x%x,0x%x], ordinal %d)",
-        aPlaylistId, aSongId.iId1, aSongId.iId2, aOrdinal);
-
-    // delete the song
-    iDbPlaylist->DeleteSongL(aPlaylistId, aSongId.iId2, aOrdinal);
-
-    // Send a playlist modified message
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aPlaylistId, EMPXItemModified,
-        EMPXPlaylist, KDBPluginUid);
-
-    // Send a message on the song in the playlist that is deleted
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted,
-        EMPXSong, KDBPluginUid);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::DoCleanupDeletedRecordsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DoCleanupDeletedRecordsL()
-    {
-    MPX_FUNC("CMPXDbHandler::DoCleanupDeletedRecordsL");
-
-    // delete all marked records from the Music table
-    iDbMusic->CleanupL();
-
-    // reset the count in the Auxiliary table
-    iDbAuxiliary->SetSaveDeletedRecordCountL(KDbManagerAllDrives,0);
-    }
-
-// ----------------------------------------------------------------------------
-// FindAllL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::FindAllL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray* aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::FindAllL");
-
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL(attributes);
-    MPXUser::MergeAttributeL(aAttrs, attributes);
-
-    TMPXGeneralCategory category = aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
-    switch (category)
-        {
-        case EMPXPlaylist:
-            {
-            TUint32 playlistId(0);
-            if (aCriteria.IsSupported(KMPXMediaGeneralId))
-                {
-                playlistId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-                }
-
-            if (iAutoPlaylist->AutoPlaylistTypeL(playlistId) != EMPXNoAutoPlaylist)
-                {
-                CMPXMedia* media = CMPXMedia::NewL();
-                CleanupStack::PushL(media);
-
-                iAutoPlaylist->GetPlaylistL(playlistId, aAttrs, *media);
-
-                aMediaArray->AppendL(*media);
-                CleanupStack::PopAndDestroy(media);
-                }
-            else
-                {
-                iDbPlaylist->FindAllL(aCriteria, attributes.Array(), *aMediaArray);
-                }
-
-            break;
-            }
-        case EMPXSong:
-            {
-            FindSongL(aCriteria, attributes.Array(), *aMediaArray);
-            break;
-            }
-        default:
-            {
-            DbCategoryL(category)->FindAllL(aCriteria, attributes.Array(), *aMediaArray);
-            break;
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&attributes);
-    }
-
-// ----------------------------------------------------------------------------
-// Get song(s) from the music table that match the given criteria
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::FindSongL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbCollection::FindSongL");
-
-    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
-
-    TUint32 id(0);
-    if (aCriteria.IsSupported(KMPXMediaGeneralId))
-        {
-        id = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-        }
-
-    TUint32 containerId(0);
-    if (aCriteria.IsSupported(KMPXMediaGeneralContainerId))
-        {
-        containerId = aCriteria.ValueTObjectL<TUint32>(KMPXMediaGeneralContainerId);
-        }
-
-    //////////////////////////////////////////////////////////////////////
-    // Find songs in the specified playlist
-    //////////////////////////////////////////////////////////////////////
-    TMPXGeneralCategory cat(MPX_ITEM_CATEGORY(id));
-
-    if (type == EMPXGroup &&
-        (cat == EMPXPlaylist ||
-        MPX_ITEM_CATEGORY(containerId) == EMPXPlaylist))
-        {
-        TUint32 playlistId = (cat == EMPXPlaylist) ?
-            id : (containerId & KMCCategoryMask);
-
-        GetPlaylistSongsL(playlistId, aAttrs, aMediaArray);
-        }
-
-    //////////////////////////////////////////////////////////////////////
-    // Find a particular song in the specified playlist. This fills the
-    // song with info from Playlist table first then overwrites it with
-    // info from Songs table if Songs table where this song is located
-    // is present in order to support the display of song titles in a
-    // playlist when memory card is removed if the playlist refers to
-    // songs on the memory card. Caller of this scenario is OpenL/MediaL.
-    // When user attempts to play a track in an auto-playlist, we will
-    // find the song from Songs table directly since auto-playlists are
-    // not stored in the Playlist table. Auto-playlists are query-based,
-    // therefore, when memory card is removed, songs on the memory card
-    // will not be shown in the auto-playlist; hence they do not exhibit
-    // the same challenge as user created playlists.
-    //////////////////////////////////////////////////////////////////////
-    else if (type == EMPXItem &&
-        cat == EMPXCollection &&
-        MPX_ITEM_CATEGORY(containerId) == EMPXPlaylist)
-        {
-        if (iAutoPlaylist->AutoPlaylistTypeL(containerId) != EMPXNoAutoPlaylist)
-            {
-            // auto playlist song, get the song details from the music table
-            iDbMusic->FindSongsL(id, 0, type, aCriteria, aAttrs, aMediaArray);
-            }
-        else
-            {
-            GetPlaylistSongL(id, containerId, aAttrs, aMediaArray);
-            }
-        }
-
-    //////////////////////////////////////////////////////////////////////
-    // Find all songs, all songs in a particular album and/or artist, or
-    // a particular song
-    //////////////////////////////////////////////////////////////////////
-    else
-        {
-        iDbMusic->FindSongsL(id, containerId, type, aCriteria, aAttrs, aMediaArray);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Get song(s) in the specified playlist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::GetPlaylistSongsL(
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::GetPlaylistSongsL");
-    MPX_DEBUG2("CMPXDbHandler::GetPlaylistSongsL(0x%x)", aPlaylistId);
-
-    // check the auto playlists first
-    if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist))
-        {
-        iDbMusic->GetRecentlyPlayedSongsL(aAttrs, aMediaArray);
-        }
-    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist))
-        {
-        iDbMusic->GetMostPlayedSongsL(aAttrs, aMediaArray);
-        }
-    else if (aPlaylistId == iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyAddedPlaylist))
-        {
-        iDbMusic->GetRecentlyAddedSongsL(aAttrs, aMediaArray);
-        }
-    else
-        {
-        TInt attrCount(aAttrs.Count());
-        if ( attrCount > 1 || (attrCount == 1 && !(aAttrs[0] == KMPXMediaGeneralId)) )
-            {
-	        TInt plDrive(iDbPlaylist->GetDriveIdL(aPlaylistId));
-	        MPX_TRAPD(err, iDbMusic->GetAllSongsL(plDrive, aPlaylistId, aAttrs, aMediaArray));
-
-	        // song not found in Music table
-	        if (err == KErrNotFound)
-	            {
-	            //
-	            // Leave with KErrNotFound if one of the following is true:
-	            // 1) the requested song is in an auto playlist. Since auto-playlist isn't
-	            //    stored in playlist tables, we won't be able to retrieve info elsewhere
-	            // 2) the requested song is in a user playlist but we cannot find the song
-	            //    info from playlist tables either
-	            //
-	           if (EMPXNoAutoPlaylist != iAutoPlaylist->AutoPlaylistTypeL(aPlaylistId) ||
-	                !iDbPlaylist->Songs().GetSongsL(aPlaylistId, aAttrs, aMediaArray))
-	               {
-	               User::Leave(KErrNotFound);
-	               }
-	            }
-	        else
-	            {
-	            // ignore the error if KErrNotFound
-	            User::LeaveIfError(err);
-	            }
-            }
-        else
-            {
-            // get ids of the songs in the playlist
-            iDbPlaylist->Songs().GetSongsL(aPlaylistId, aMediaArray);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Find all albums or the albums for a specified artist
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::FindAlbumL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbHandler::FindAlbumL");
-
-    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
-
-    TUint32 id(0);
-    if (aCriteria.IsSupported(KMPXMediaGeneralId))
-        {
-        id = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-        }
-
-    if ((type == EMPXGroup) && (MPX_ITEM_CATEGORY(id) == EMPXArtist))
-        {
-        // get all the albums for the artist
-        GetAlbumsMatchingArtistL(id, aAttrs, aMediaArray);
-        }
-    else
-        {
-        // look up all albums from album table
-        iDbAlbum->FindAllL(aCriteria, aAttrs, aMediaArray);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Extracts the playlist ID and drive ID from a playlist media instance
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::ProcessPlaylistMediaL(
-    CMPXMedia& aMedia,
-    TUint32& aPlaylistId,
-    TInt& aPlaylistDriveId)
-    {
-    MPX_FUNC("CMPXDbHandler::ProcessPlaylistMediaL");
-
-    if (aMedia.IsSupported(KMPXMediaGeneralId))
-        {
-        aPlaylistId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-
-        if (aMedia.IsSupported(KMPXMediaGeneralUri))
-            {
-            // find drive id of the playlist
-            aPlaylistDriveId = TDriveUnit(aMedia.ValueText(KMPXMediaGeneralUri));
-            }
-        else
-            {
-            // Find drive Id(s) of corresponding Playlist Id
-            aPlaylistDriveId = iDbPlaylist->GetDriveIdL(aPlaylistId);
-            }
-        }
-    else if (aMedia.IsSupported(KMPXMediaGeneralUri))
-        {
-        const TDesC& playlistUri = aMedia.ValueText(KMPXMediaGeneralUri);
-        // find drive id of the playlist
-        aPlaylistDriveId = TDriveUnit(playlistUri);
-
-        // aMedia does not have an ID, make sure the add it
-        aPlaylistId = GetPlaylistIdMatchingUriL(playlistUri);
-        aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPlaylistId);
-        }
-    else
-        {
-        User::Leave(KErrArgument);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Makes sure that all songs in the specified playlist have the ID, title and URI attributes
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::UpdatePlaylistSongInfoL(
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbHandler::UpdatePlaylistSongInfoL");
-
-    CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-    User::LeaveIfNull(mediaArray);
-
-    // make sure each song has Id, Uri, and Title before they can be added to playlist
-    TInt count(mediaArray->Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        CMPXMedia* element = mediaArray->AtL(i);
-
-        // copy each song to deal w/ global heap issues
-        CMPXMedia* entry = CMPXMedia::NewL(*element);
-        CleanupStack::PushL(entry);
-
-        // song has everything, go to next song
-        if (entry->IsSupported(KMPXMediaGeneralUri) &&
-            entry->IsSupported(KMPXMediaGeneralId) &&
-            entry->IsSupported(KMPXMediaGeneralTitle))
-            {
-            // pop entry to maintain CleanupStack
-            CleanupStack::PopAndDestroy(entry);
-            continue;
-            }
-
-        // songs must contain (at minimum) an Uri or an Id
-        if (!entry->IsSupported(KMPXMediaGeneralUri) &&
-            !entry->IsSupported(KMPXMediaGeneralId))
-            {
-            User::Leave(KErrArgument);
-            }
-
-        // get Id
-        if (!entry->IsSupported(KMPXMediaGeneralId))
-            {
-            // fill in the ID if not present
-            TParsePtrC parser(entry->ValueText(KMPXMediaGeneralUri));
-            entry->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
-                MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, parser.FullName(), EFalse));
-            }
-
-        CMPXMedia* song(NULL);
-
-        // update songs info
-        TInt error(iDbMusic->GetSongL(*entry, song));
-        TBool result (ETrue);
-
-        // error can only be KErrNone or KErrNotFound
-        // from CMPXDbMusic::GetSongL
-        // if not found in Music, get info from PlaylistSongs (PlaylistSongs & PlaylistSongInfo) DB
-        if (error == KErrNotFound)
-            {
-            RArray<TMPXAttribute> attributes;
-            CleanupClosePushL(attributes);
-            attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
-                EMPXMediaGeneralId | EMPXMediaGeneralTitle | EMPXMediaGeneralUri | EMPXMediaGeneralFlags));
-
-            // this song doesn't exist in Music table. This song is either a broken link or
-            // is of an unsupported song type that exists in the file system. Broken links
-            // have already been marked as such during playlist import.
-            result = iDbPlaylist->Songs().GetSongL(entry->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId), attributes.Array(), song);
-            if (!result)
-                {
-                // song is a broken link
-                //TUint flags = KMPXMediaGeneralFlagsSetOrUnsetBit;
-                //flags |= KMPXMediaGeneralFlagsIsInvalid; // set flag
-                //t->SetTObjectValueL<TUint>( KMPXMediaGeneralFlags, flags );
-
-                if (entry->IsSupported(KMPXMediaGeneralUri))
-                    {
-                    // no valid Id but has Uri, just verify Title is present
-                    // this is the case if the song is a broken link or podcast
-                    if (!entry->IsSupported(KMPXMediaGeneralTitle))
-                        {
-                        // does not have Title, make up the Title from file name
-                        TParsePtrC parser(entry->ValueText(KMPXMediaGeneralUri));
-                        entry->SetTextValueL(KMPXMediaGeneralTitle, parser.Name());
-                        }
-                    }
-                else
-                    {
-                    // no valid Id & no Uri, bad argument
-                    User::Leave(KErrArgument);
-                    }
-                }
-            CleanupStack::PopAndDestroy(&attributes);
-            }
-
-        // update attributes
-        CleanupStack::PushL(song);
-
-        // song not found in Music or Playlist DB, update entry
-        if(error == KErrNotFound && !result)
-            {
-            mediaArray->InsertL(*entry,i);
-            }
-        else  // found in DB, replace entry
-            {
-            mediaArray->InsertL(*song,i);
-            }
-
-        // replace element in the array
-        CleanupStack::PopAndDestroy(song);
-        CleanupStack::PopAndDestroy(entry);
-        mediaArray->Remove(i+1);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::ProcessMusicFoldersL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::ProcessMusicFoldersL(
-    const CDesCArray& aFolders)
-    {
-    MPX_FUNC("CMPXDbHandler::ProcessMusicFoldersL");
-
-    TInt count(aFolders.MdcaCount());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TPtrC16 folder = aFolders.MdcaPoint(i);
-
-        // check if disk is inserted and act accordingly
-        TDriveUnit driveUnit(folder);
-        if (!iFs.IsValidDrive(driveUnit))
-            {
-            User::Leave(KErrArgument);
-            }
-
-        // 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);
-                    }
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::DbCategoryL
-// ----------------------------------------------------------------------------
-//
-CMPXDbCategory* CMPXDbHandler::DbCategoryL(
-    TMPXGeneralCategory aCategory) const
-    {
-    MPX_FUNC("CMPXDbHandler::DbCategoryL");
-
-    CMPXDbCategory* dbCategory(NULL);
-    switch (aCategory)
-        {
-        case EMPXArtist:
-            {
-            dbCategory = (CMPXDbCategory*)iDbArtist;
-            break;
-            }
-        case EMPXAlbum:
-            {
-            dbCategory = (CMPXDbCategory*)iDbAlbum;
-            break;
-            }
-        case EMPXGenre:
-            {
-            dbCategory = (CMPXDbCategory*)iDbGenre;
-            break;
-            }
-        case EMPXComposer:
-            {
-            dbCategory = (CMPXDbCategory*)iDbComposer;
-            break;
-            }
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    return dbCategory;
-    }
-
-// ----------------------------------------------------------------------------
-// Verifies that the volume ID of the database matches the drive
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::VerifyVolumeIdL()
-    {
-    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL <--");
-
-    TInt count( iDbDrives.Count() );
-    for( TInt i=0; i<count; ++i )
-        {
-        if( iDbManager->IsOpen( iDbDrives[i] ) )
-            {
-            TVolumeInfo volInfo;
-            iFs.Volume(volInfo, iDbDrives[i] );
-            TUint curId(volInfo.iUniqueID);
-
-            TInt volId = iDbAuxiliary->IdL( iDbDrives[i] );
-
-            // New database, no volume id set, mask out top bit because this is an uint
-            //
-            MPX_DEBUG3("CMPXDBHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
-            if( volId == 0 )
-                {
-                MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- New ID");
-                BeginTransactionL();
-                TRAPD( err, iDbAuxiliary->SetIdL( iDbDrives[i], curId&0x7FFFFFFF ) );
-                EndTransactionL( err );
-                
-                // KSqlDbCorrupted indicates DB corrupted, need to recreate.
-                if ( err == KSqlDbCorrupted )
-                    {
-                    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");     
-                    iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                    BeginTransactionL();
-                    TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                    EndTransactionL( err );
-                    }
-                }
-            // Unmatched volume id, mark db as corrupt and break
-            //
-            else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
-                {
-                MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -- ID match FAILED");
-                iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                BeginTransactionL();
-                TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                EndTransactionL( err );
-                }
-            }
-        }
-    MPX_DEBUG1("CMPXDbHandler::VerifyVolumeIdL -->");
-    }
-
-
-// ----------------------------------------------------------------------------
-// Checks if there is a drive that has a low disk space
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::CheckDiskSpaceOnDrivesL()
-    {
-    MPX_DEBUG1("CMPXDbHandler::CheckDiskSpaceOnDrivesL <--");
-
-    TInt count( iDbDrives.Count() );
-    for( TInt index=0; index<count; ++index )
-        {
-        iDbManager->CheckDiskSpaceL(iDbDrives[index]);
-        }
-    MPX_DEBUG1("CMPXDbHandler::CheckDiskSpaceOnDrivesL -->");
-    }
-
-#if defined (__MTP_PROTOCOL_SUPPORT)
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::SaveDeletedSongs
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::SaveDeletedSongs()
-    {
-    MPX_FUNC("CMPXDbHandler::SaveDeletedSongs");
-
-    TBool saveDeletedSongs(ETrue);
-    CRepository* cenrep(NULL);
-    MPX_TRAPD(error, cenrep = CRepository::NewL(KMPXMtpSettings));
-    if (!error)
-        {
-        cenrep->Get(KMPXMtpSaveDeletedRecordFlag, saveDeletedSongs);
-        delete cenrep;
-        MPX_DEBUG2("MTP indicated to save deleted songs? %d", saveDeletedSongs);
-        }
-
-    return saveDeletedSongs;
-    }
-
-#endif
-
-#ifdef RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------------------------------------
-// Retrieve all visible music folder locations
-// ----------------------------------------------------------------------------------------------------------
-//
-CDesCArrayFlat* CMPXDbHandler::GetMusicFoldersL()
-    {
-    MPX_FUNC("CMPXDbHandler::GetMusicFoldersL()");
-    TDriveList driveList;
-    TInt driveCount(0);
-    User::LeaveIfError(DriveInfo::GetUserVisibleDrives(iFs, driveList, driveCount));
-    MPX_DEBUG2 ("CMPXDbHandler::GetMusicFoldersL() - driveCount = %d", driveCount);
-
-    CDesCArrayFlat* folders = new (ELeave) CDesCArrayFlat(1); // granularity
-    CleanupStack::PushL(folders);
-
-    for (TInt i = EDriveA; i <= EDriveZ; i++)
-        {
-        if ((driveList[i]) && (!IsRemoteDrive(static_cast<TDriveNumber>(i))))
-            {
-            if (i == EDriveC)
-                {
-                // Append the default phone memory path to the list
-                // of music folders
-                TPtrC rootPath(PathInfo::PhoneMemoryRootPath());
-                folders->AppendL(rootPath);
-                MPX_DEBUG2("CMPXDbHandler::GetMusicFoldersL() - adding...%S", &rootPath);
-                }
-            else
-                {
-                // Get drive letter
-                TChar driveChar;
-                User::LeaveIfError(iFs.DriveToChar(i, driveChar));
-
-                // Append visible drive to list of music folders
-                TBuf<2> drive;
-                drive.Append(driveChar);
-                drive.Append(_L(":"));
-                folders->AppendL(drive);
-                MPX_DEBUG2 ("CMPXDbHandler::GetMusicFoldersL() - adding...%S", &drive);
-                }
-            }
-        }
-
-    CleanupStack::Pop(folders);
-    return folders;
-    }
-
-#endif // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::AddCategoryItemL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbHandler::AddCategoryItemL(
-    TMPXGeneralCategory aCategory,
-    const TDesC& aName,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TBool& aItemExist)
-    {
-    MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
-
-    MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
-
-    TBool newRecord(EFalse);
-    TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)));
-    if (newRecord && aItemChangedMessages)
-        {
-        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
-            aCategory, KDBPluginUid);
-        }
-    aItemExist = !newRecord;
-    MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
-
-    return id;
-    }
-
-TUint32 CMPXDbHandler::AddCategoryItemL(
-        TMPXGeneralCategory aCategory,
-        const TDesC& aName,
-        TUint32 aArtist,
-        const TDesC& aArt,
-        TInt aDriveId,
-        CMPXMessageArray* aItemChangedMessages,
-        TBool& aItemExist)
-	{
-    MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
-
-    MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
-
-    TBool newRecord(EFalse);
-
-    TUint32 id = 0;
-    if ( aArtist )
-        {
-        id = iDbAlbum->AddItemL(aName, aArtist, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
-        }
-    else
-        {
-        id = iDbArtist->AddItemL(aName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
-        }
-        
-    if (newRecord && aItemChangedMessages)
-        {
-        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
-            aCategory, KDBPluginUid);
-        }
-    aItemExist = !newRecord;
-    MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
-
-    return id;
-	}
-
-void CMPXDbHandler::UpdateCategoryItemL(
-		TMPXGeneralCategory aCategory,
-		TUint32 aCategoryId,
-		const CMPXMedia& aMedia,
-		TInt aDrive, 
-		CMPXMessageArray* aItemChangedMessages)
-	{
-	switch(aCategory)
-	    {
-	    case EMPXAlbum:
-            iDbAlbum->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
-	        break;
-	        
-	    case EMPXArtist:
-	        iDbArtist->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
-	        break;
-
-	    default:
-            DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
-	        break;
-	    }
-	}
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::DeleteSongForCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::DeleteSongForCategoryL(
-    TMPXGeneralCategory aCategory,
-    TUint32 aCategoryId,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TBool& aItemExist)
-    {
-    MPX_FUNC("CMPXDbHandler::DeleteSongForCategoryL");
-    DbCategoryL(aCategory)->DecrementSongsForCategoryL(aCategoryId, aDriveId,
-        aItemChangedMessages, aItemExist);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbHandler::HandlePlayCountModifiedL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbHandler::HandlePlayCountModifiedL(
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::HandlePlayCountModifiedL");
-
-    TUint32 plId(iAutoPlaylist->AutoPlaylistIdL(EMPXMostPlayedPlaylist));
-
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, plId, EMPXItemModified,
-        EMPXSong, KDBPluginUid, plId);
-
-    // Force the deprecated ID attribute
-    aItemChangedMessages[aItemChangedMessages.Count() - 1]->
-        SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, plId);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// CMPXDbHandler::HandlePlaybackTimeModifiedL
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbHandler::HandlePlaybackTimeModifiedL(
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbHandler::HandlePlaybackTimeModifiedL");
-
-    TUint32 plId(iAutoPlaylist->AutoPlaylistIdL(EMPXRecentlyPlayedPlaylist));
-
-    MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, plId, EMPXItemModified,
-        EMPXSong, KDBPluginUid, plId);
-
-    // Force the deprecated ID attribute
-    aItemChangedMessages[aItemChangedMessages.Count() - 1]->
-        SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, plId);
-    }
-
-
-// ---------------------------------------------------------------------------
-// CMPXDbHandler::IsRemoteDrive
-// ---------------------------------------------------------------------------
-//
-TBool CMPXDbHandler::IsRemoteDrive(TDriveNumber aDrive)
-    {
-    return iDbManager->IsRemoteDrive(aDrive);
-    }
-
-TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
-	{
-	return GetPlaylistDurationL(aPlaylistId);
-	}
-
-TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
-	{
-	return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
-	}
-
-TBool CMPXDbHandler::HandleIsUnknownArtistL(TUint32 aArtistId)
-    {
-    return iDbArtist->IsUnknownArtistL(aArtistId);
-    }
-
-TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
-    {
-    return iDbMusic->ArtistForAlbumL(aAlbumId);
-    }
-// End of file
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbmusic.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2567 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interation with the music table.
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxcollectionpath.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxmediaaudiodefs.h>
-#include <mpxmediadrmdefs.h>
-#include <mpxmediamtpdefs.h>
-#include <mpxcollectiondbres.rsg>
-
-#include "mpxdbcommondef.h"
-#include "mpxdbcommonstd.h"
-#include "mpxdbcommonutil.h"
-#include "mpxresource.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxcollectiondbstd.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbutil.h"
-#include "mpxdbmanager.h"
-#include "mpxdbmusic.h"
-
-// CONSTANTS
-
-// This is what KNullDesC album computes to for the hash
-// to-do: generate this Id through
-//        MPXDbUtil::GenerateUniqueIdL(EMPXAlbum, KNullDesC, EFalse)
-//        instead of hard-coding the number so if GenerateUniqueIdL
-//        is modified, this constant doesn't need to be redefined
-const TInt KUnknownAlbumID = 1770790356;
-// UniqueID column in Uris requests
-const TInt KColUniqueID = 0;
-// URI column in Uris requests
-const TInt KColUri = 1;
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbMusic* CMPXDbMusic::NewL(
-    CMPXDbManager& aDbManager,
-    CMPXResource& aResource,
-    MMPXDbMusicObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbMusic::NewL");
-    CMPXDbMusic* self = CMPXDbMusic::NewLC(aDbManager, aResource, aObserver);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbMusic* CMPXDbMusic::NewLC(
-    CMPXDbManager& aDbManager,
-    CMPXResource& aResource,
-    MMPXDbMusicObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbMusic::NewLC");
-
-    CMPXDbMusic* self = new (ELeave) CMPXDbMusic(aDbManager, aObserver);
-    CleanupStack::PushL(self);
-    self->ConstructL(aResource);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbMusic::~CMPXDbMusic()
-    {
-    MPX_FUNC("CMPXDbMusic::~CMPXDbMusic");
-    delete iExtensionsDrm;
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbMusic::CMPXDbMusic(
-    CMPXDbManager& aDbManager,
-    MMPXDbMusicObserver& aObserver) :
-    CMPXDbTable(aDbManager),
-    iObserver(aObserver)
-    {
-    MPX_FUNC("CMPXDbMusic::CMPXDbMusic");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::ConstructL(
-    CMPXResource& aResource)
-    {
-    MPX_FUNC("CMPXDbMusic::ConstructL");
-
-    BaseConstructL();
-    iExtensionsDrm = aResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_DRM);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::AddSongL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbMusic::AddSongL(
-    const CMPXMedia& aMedia,
-    TInt aDrive,
-    CMPXMessageArray* aMessageArray)
-    {
-    MPX_FUNC("CMPXDbMusic::AddSongL");
-
-    TUint32 songId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
-        aMedia.ValueText(KMPXMediaGeneralUri), EFalse));
-
-    if (SongExistsL(songId))
-        {
-        // Delete the existing record first and start from scratch
-        DeleteSongL(songId, aDrive, ETrue);
-        }
-    // add the song
-    DoAddSongL(songId, aMedia, aDrive, aMessageArray);
-    
-    return songId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DoAddSongL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::DoAddSongL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    TInt aDrive,
-    CMPXMessageArray* aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbMusic::DoAddSongL");
-
-    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
-    CleanupStack::PushL(fields);
-    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
-    CleanupStack::PushL(values);
-
-    // add known fields
-    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicUniqueId, aSongId);
-    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicDel, 0);
-
-    TTime time;
-    time.HomeTime();
-    HBufC* timeAdded = MPXDbCommonUtil::TTimeToDesLC(time);
-    MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicTimeAdded, *timeAdded);
-    CleanupStack::PopAndDestroy(timeAdded);
-
-    // process the media parameter and construct the fields and values array
-    TBool visible(GenerateMusicFieldsValuesL(aSongId, aMedia, aItemChangedMessages,
-        NULL, *fields, *values, aDrive));
-
-    // create the fields and values strings
-    HBufC* fieldStr = MPXDbCommonUtil::StringFromArrayLC(*fields, KMCCommaSign);
-    HBufC* valueStr = MPXDbCommonUtil::StringFromArrayLC(*values, KMCCommaSign);
-
-    // execute the query
-    iDbManager.ExecuteQueryL(aDrive, KQueryMusicInsert, fieldStr, valueStr);
-
-    CleanupStack::PopAndDestroy(valueStr);
-    CleanupStack::PopAndDestroy(fieldStr);
-    CleanupStack::PopAndDestroy(values);
-    CleanupStack::PopAndDestroy(fields);
-
-    return visible;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateSongL
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::UpdateSongL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbMusic::UpdateSongL");
-    return DoUpdateSongL(aSongId, aMedia, &aItemChangedMessages);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DoUpdateSongL
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    CMPXMessageArray* aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbMusic::DoUpdateSongL");
-
-    CMPXDbActiveTask::TChangeVisibility visible(CMPXDbActiveTask::ENotVisibile);
-    if (IsSupported(aMedia))
-        {
-        // retrieve the existing record
-        TInt oldSongId(0);
-        oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-        if ( oldSongId <= 0 )
-            {
-            oldSongId = aSongId;  
-            }
-        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetSong, oldSongId));
-        CleanupClosePushL(recordset);
-
-        if (recordset.Next() != KSqlAtRow)
-            {
-            User::Leave(KErrNotFound);
-            }
-
-        TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-          recordset.ColumnInt64(EMusicVolumeId)));
-        visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages,
-          recordset);
-
-        // Update Album table
-		if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist))
-			{
-			TUint32 albumId = recordset.ColumnInt64(EMusicAlbum);
-			iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages);
-			}
-            
-        // Update Artist table
-        if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) )
-            {
-            TUint32 artistId = recordset.ColumnInt64(EMusicArtist);
-            iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages);            
-            }
-        
-        CleanupStack::PopAndDestroy(&recordset);
-        }
-
-    return visible;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DoUpdateSongL
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    TInt aDrive,
-    CMPXMessageArray* aItemChangedMessages,
-    RSqlStatement& aRecordset)
-    {
-    MPX_FUNC("CMPXDbMusic::DoUpdateSongL");
-
-    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
-    CleanupStack::PushL(fields);
-    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount);
-    CleanupStack::PushL(values);
-
-    TInt oldSongId(0);
-    oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-    if ( oldSongId <= 0 )
-        {
-        oldSongId = aSongId;  
-        }
-    // process the media parameter and construct the fields and values array
-    CMPXDbActiveTask::TChangeVisibility visible(GenerateMusicFieldsValuesL(oldSongId, aMedia, aItemChangedMessages,
-        &aRecordset, *fields, *values, aDrive));
-
-    // construct the SET string
-    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
-    if (setStr->Length())
-        {
-        // execute the query
-        iDbManager.ExecuteQueryL(aDrive, KQueryMusicUpdate, setStr, oldSongId);
-        }
-
-    CleanupStack::PopAndDestroy(setStr);
-    CleanupStack::PopAndDestroy(values);
-    CleanupStack::PopAndDestroy(fields);
-
-    return visible;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DeleteSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::DeleteSongL(
-    TUint32 aSongId,
-    TInt aDrive,
-    TBool aDeleteRecord /* = EFalse */)
-    {
-    MPX_FUNC("CMPXDbMusic::DeleteSongL");
-
-    TPtrC query(aDeleteRecord ? KQueryMusicDelete() : KQueryMusicDeleteUpdate());
-    iDbManager.ExecuteQueryL(aDrive, query, aSongId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DeleteCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::DeleteCategoryL(
-    TMPXGeneralCategory aCategory,
-    TUint32 aCategoryId,
-    CDesCArray& /* aUriArray */,
-    CMPXMessageArray& /* aItemChangedMessages */,
-    TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbMusic::DeleteCategoryL");
-    TPtrC ptr(MPXDbUtil::MusicFieldNameForCategoryL(aCategory));
-    iDbManager.ExecuteQueryL(aDrive, KQueryMusicDeleteForCategory, &ptr, aCategoryId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::CleanupL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::CleanupL()
-    {
-    MPX_FUNC("CMPXDbMusic::CleanupL");
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryMusicCleanup);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetNameL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbMusic::GetNameL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbMusic::GetNameL");
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetTitle, aSongId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::LeaveIfError(KErrNotFound);
-        }
-
-    HBufC* title = MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex).AllocL();
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return title;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetUriL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbMusic::GetUriL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbMusic::GetUriL");
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetUri, aSongId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::LeaveIfError(KErrNotFound);
-        }
-
-    // query fields
-    enum
-        {
-        EMusicUriLocation = 0,
-        EMusicUriVolId
-        };
-
-    TUint volId(recordset.ColumnInt64(EMusicUriVolId));
-    HBufC* fullUri = MPXDbCommonUtil::CreateFullPathL(
-        MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId),
-        MPXDbCommonUtil::GetColumnTextL(recordset, EMusicUriLocation));
-
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return fullUri;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetDriveL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::GetDriveL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbMusic::GetDriveL");
-    return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-        ExecuteIntQueryL(KQueryMusicVolume, aSongId));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongInfoL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbMusic::GetSongInfoL(
-    TUint32 aSongId,
-    TUint32& aArtistId,
-    TUint32& aAlbumId,
-    TUint32& aGenreId,
-    TUint32& aComposerId,
-    TInt& aDriveId)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongInfoL");
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicInfo, aSongId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::Leave(KErrNotFound);
-        }
-
-    aDriveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-        recordset.ColumnInt64(EMusicVolumeId));
-    aArtistId = recordset.ColumnInt64(EMusicArtist);
-    aAlbumId = recordset.ColumnInt64(EMusicAlbum);
-    aGenreId = recordset.ColumnInt64(EMusicGenre);
-    aComposerId = recordset.ColumnInt64(EMusicComposer);
-    HBufC* uri = ConstructUriL(recordset, aSongId);
-
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return uri;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::GetSongL(
-    const CMPXMedia& aCriteria,
-    CMPXMedia*& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongL");
-
-    TUint32 songId(0);
-
-    // find song Id, title, URI, and general flags from its Id and/or URI. Do not use "aCriteria"
-    // because it may contain attributes other than Id and URI. We don't want to search the
-    // song by fields other than the ID and URI because other attributes for the song may have
-    // been changed in the collection since the song was added
-    CMPXMedia* criteria = CMPXMedia::NewL();
-    CleanupStack::PushL(criteria);
-    if (aCriteria.IsSupported(KMPXMediaGeneralId))
-        {
-        songId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-        criteria->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId);
-        }
-    else if (aCriteria.IsSupported(KMPXMediaGeneralUri))
-        {
-        criteria->SetTextValueL(KMPXMediaGeneralUri,
-            aCriteria.ValueText(KMPXMediaGeneralUri));
-        }
-
-    // get the criteria string
-    HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(songId, 0, EMPXItem, *criteria);
-
-    // execute the query
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicSong, criteriaStr));
-    CleanupClosePushL(recordset);
-
-    TInt err(KErrNone);
-    if ((err = recordset.Next()) == KSqlAtRow)
-        {
-        RArray<TMPXAttribute> attributes;
-        CleanupClosePushL(attributes);
-        attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
-            EMPXMediaGeneralId | EMPXMediaGeneralTitle | EMPXMediaGeneralUri | EMPXMediaGeneralFlags));
-
-        aMedia = CMPXMedia::NewL();
-        CleanupStack::PushL(aMedia);
-
-        UpdateMediaL(recordset, attributes.Array(), *aMedia);
-
-        CleanupStack::Pop(aMedia);
-        CleanupStack::PopAndDestroy(&attributes);
-
-        err = KErrNone;
-        }
-    else
-        {
-        err = KErrNotFound;
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-    CleanupStack::PopAndDestroy(criteriaStr);
-    CleanupStack::PopAndDestroy(criteria);
-
-    return err;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetRecentlyPlayedSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetRecentlyPlayedSongsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetRecentlyPlayedSongsL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetRecentlyPlayed,
-        KMPXMaxRecentlyPlayedSongs);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetMostPlayedSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetMostPlayedSongsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetMostPlayedSongsL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetMostPlayed() : KQueryMusicGetMostPlayedNoCategories(),
-        KMPXMaxMostPlayedSongs);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetRecentlyAddedSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetRecentlyAddedSongsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetRecentlyAddedSongsL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetRecentlyAdded() : KQueryMusicGetRecentlyAddedNoCategories());
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::CountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::CountL()
-    {
-    MPX_FUNC("CMPXDbMusic::CountL");
-    return ExecuteSumQueryL(KQueryMusicCount);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetAlbumsForArtistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetAlbumsForArtistL(
-    TUint32 aArtistId,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetAlbumsForArtistL");
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicAlbum, aArtistId));
-    CleanupClosePushL(recordset);
-
-    TInt err(KErrNone);
-    while ((err = recordset.Next()) == KSqlAtRow)
-        {
-        TUint32 albumId(recordset.ColumnInt64(KMPXTableDefaultIndex));
-
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-
-        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, albumId);
-        media->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-        media->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-
-        aMediaArray.AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-    if (err != KSqlAtEnd)
-        {
-        User::LeaveIfError(KErrCorrupt);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongL(
-    TInt aSongId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongL");
-    ExecuteMediaQueryL(aAttrs, aMedia, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetSong() : KQueryMusicGetSongNoCategories(), aSongId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetAllSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetAllSongsL(
-    TInt aDrive,
-    TInt aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetAllSongsL");
-    ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetAllSongsInfobyPl(), aPlaylistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetAllSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetAllSongsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetAllSongsL");
-
-    // do not execute the joins if no category name is required
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetAllSongs() : KQueryMusicGetAllSongsNoCategories());
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetAllSongsLimitedL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs,  
-                                      CMPXMediaArray& aMediaArray, TInt aLimit)
-    {
-    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 );    
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsInBlockL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsInBlockL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray,
-    TPtrC aTitle, 
-    TUint aNumOfSongs, 
-    TBool aAsc)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsInBlockL");
-
-    if (aAsc)
-        { 
-        ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockAsc,
-                              aTitle, aNumOfSongs, ETrue, EAscQuery );    
-        }
-    else
-        {
-        ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockDsc,
-                           aTitle, aNumOfSongs, EFalse, EDscQuery );        
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsAtOffsetL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsAtOffsetL( CMPXMediaArray& aMediaArray,
-                                     const TArray<TMPXAttribute>& aAttrs,
-                                     TInt aOffset,
-                                     TInt aCount )
-    {
-    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL <--");   
-
-    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsAtOffset, 
-                       aCount, aOffset, EOffSetQuery );
-    
-    MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL() -->"); 
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsForArtistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsForArtistL(
-    TUint aArtistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsForArtistL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetSongsForArtist() : KQueryMusicGetSongsForArtistNoCategories(),
-        aArtistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsForAlbumL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsForAlbumL(
-    TUint aAlbumId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsForAlbumL");
-
-    TPtrC query;
-    if (aAlbumId == KUnknownAlbumID)
-        {
-        query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForUnknownAlbum() :
-            KQueryMusicGetSongsForUnknownAlbumNoCategories());
-        }
-    else
-        {
-        query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForAlbum() :
-            KQueryMusicGetSongsForAlbumNoCategories());
-        }
-
-    ExecuteMediaQueryL(aAttrs, aMediaArray, query, aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsForArtistAndAlbumL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsForArtistAndAlbumL(
-    TUint aArtistId,
-    TUint aAlbumId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsForArtistAndAlbumL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetSongsForArtistAlbum() : KQueryMusicGetSongsForArtistAlbumNoCategories(),
-        aArtistId, aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsForGenreL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsForGenreL(
-    TUint aGenreId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsForGenreL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetSongsForGenre() : KQueryMusicGetSongsForGenreNoCategories(),
-        aGenreId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetSongsForComposerL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetSongsForComposerL(
-    TUint aComposerId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::GetSongsForComposerL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ?
-        KQueryMusicGetSongsForComposer() : KQueryMusicGetSongsForComposerNoCategories(),
-        aComposerId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::AllSongsDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::AllSongsDurationL()
-    {
-    MPX_FUNC("CMPXDbMusic::AllSongsDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationAll);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::ArtistDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::ArtistDurationL(
-    TUint aArtistId)
-    {
-    MPX_FUNC("CMPXDbMusic::ArtistDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationArtist, aArtistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::AlbumDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::AlbumDurationL(
-    TUint aAlbumId)
-    {
-    MPX_FUNC("CMPXDbMusic::AlbumDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationAlbum, aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::ArtistAlbumDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::ArtistAlbumDurationL(
-    TUint aArtistId,
-    TUint aAlbumId)
-    {
-    MPX_FUNC("CMPXDbMusic::ArtistAlbumDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationArtistAlbum, aArtistId, aAlbumId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GenreDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::GenreDurationL(
-    TUint aGenreId)
-    {
-    MPX_FUNC("CMPXDbMusic::GenreDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationGenre, aGenreId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::ComposerDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::ComposerDurationL(
-    TUint aComposerId)
-    {
-    MPX_FUNC("CMPXDbMusic::ComposerDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationComposer, aComposerId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::RecentlyPlayedDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::RecentlyPlayedDurationL()
-    {
-    MPX_FUNC("CMPXDbMusic::RecentlyPlayedDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationRecentlyPlayed, KMPXMaxRecentlyPlayedSongs);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::MostPlayedDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::MostPlayedDurationL()
-    {
-    MPX_FUNC("CMPXDbMusic::MostPlayedDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationMostPlayed, KMPXMaxMostPlayedSongs);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::RecentlyAddedDurationL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbMusic::RecentlyAddedDurationL()
-    {
-    MPX_FUNC("CMPXDbMusic::RecentlyAddedDurationL");
-    return ExecuteSumQueryL(KQueryMusicDurationRecentlyAdded);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::FindSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::FindSongsL(
-    TUint32 aGeneralId,
-    TUint32 aContainerId,
-    TMPXGeneralType aType,
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbMusic::FindSongsL");
-
-    // get the selection criteria string
-    HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(aGeneralId, aContainerId, aType,
-        aCriteria);
-
-    // construct the sort order depending on category. Albums are always sorted by track,
-    // then name, except for unknown album. Songs are sorted by name for unknown album.
-    // NULL track number is stored as KMaxTInt so that they will be sorted to the end
-    TPtrC sortOrder;
-    if ((aType == EMPXGroup) && (MPX_ITEM_CATEGORY(aGeneralId) == EMPXAlbum) &&
-        (aGeneralId != MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, KNullDesC, EFalse)))
-        {
-        sortOrder.Set(KQueryMusicFindAllSortOrderTrack);
-        }
-    else
-        {
-        sortOrder.Set(KQueryMusicFindAllSortOrderTitle);
-        }
-
-    // construct the query
-    HBufC* query = HBufC::NewLC(KQueryMusicFindAll().Length() + criteriaStr->Length() +
-        sortOrder.Length());
-    query->Des().Format(KQueryMusicFindAll, criteriaStr, &sortOrder);
-
-    // iterate the results and append media objects to the destination array
-    ExecuteMediaQueryL(aAttrs, aMediaArray, *query);
-
-    CleanupStack::PopAndDestroy(query);
-    CleanupStack::PopAndDestroy(criteriaStr);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetDriveTrackCount
-// ----------------------------------------------------------------------------
-//
-TUint CMPXDbMusic::GetDriveTrackCountL(TInt aDrive)
-    {
-    TUint count(0);
-    
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryMusicCount));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::Leave(KErrCorrupt);
-        }
-
-    count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex));
-    CleanupStack::PopAndDestroy(&recordset);
-    
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GetMusicUriArrayL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                    CDesCArray& aUriArr, TInt& aLastID)
-    {
-    MPX_FUNC("CMPXDbMusic::GetMusicUriArrayL");
-    
-    HBufC* query = NULL;
-    if(aFromID == 0)
-        {
-        query = HBufC::NewLC(KQueryMusicGetMusicUris().Length() + KMCIntegerLen);
-        query->Des().Format(KQueryMusicGetMusicUris, aRecords);
-        }
-    else
-        {
-        query = HBufC::NewLC(KQueryMusicGetMusicUrisFrom().Length() + 2*KMCIntegerLen);
-        query->Des().Format(KQueryMusicGetMusicUrisFrom, aFromID, aRecords);
-        }
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,*query));
-    
-    CleanupStack::PopAndDestroy(query);
-    
-    CleanupClosePushL(recordset);
-    
-    TInt lastID = 0;
-    TInt err(KErrNone);
-    while((err = recordset.Next()) == KSqlAtRow)
-        {
-        HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive,
-                MPXDbCommonUtil::GetColumnTextL(recordset, KColUri));
-        CleanupStack::PushL(fullPath);
-        aUriArr.AppendL(*fullPath);
-        CleanupStack::PopAndDestroy(fullPath);
-
-        lastID = recordset.ColumnInt(KColUniqueID);
-        }
-    CleanupStack::PopAndDestroy(&recordset);
-
-    aLastID = lastID;
-
-    if (err!= KSqlAtEnd)
-        {
-        User::Leave(KErrCorrupt);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::ArtistForAlbumL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId)
-    {
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId));
-    
-    CleanupClosePushL(recordset);
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::Leave(KErrNotFound);
-        }
-
-    TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex);            
-    CleanupStack::PopAndDestroy(&recordset);    
-    
-    return artistId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::RefreshStartL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::RefreshStartL()
-    {
-    iRefresh = ETrue;
-    MPX_FUNC("CMPXDbMusic::RefreshStartL");
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::RefreshEndL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::RefreshEndL()
-    {
-    MPX_FUNC("CMPXDbMusic::RefreshEndL");
-    iRefresh = EFalse;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::SongExistsL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::SongExistsL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbMusic::SongExistsL");
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicVolumeAll, aSongId));
-    TBool found = (recordset.Next() == KSqlAtRow);
-    recordset.Close();
-
-    return found;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::UpdateMediaL(
-    RSqlStatement& aMusicTable,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::UpdateMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        switch (aAttrs[i].ContentId())
-            {
-            case KMPXMediaIdGeneral:
-                {
-                UpdateMediaGeneralL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
-                break;
-                }
-            case KMPXMediaIdMusic:
-                {
-                UpdateMediaMusicL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
-                break;
-                }
-            case KMPXMediaIdDrm:
-                {
-                // DRM is set by drm helper
-                break;
-                }
-            case KMPXMediaIdMTP:
-                {
-                // Only attribute stored in db is MTP drm status
-                UpdateMediaMTPL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
-                break;
-                }
-            case KMPXMediaIdAudio:
-                {
-                UpdateMediaAudioL(aMusicTable, aAttrs[i].AttributeId(), aMedia);
-                break;
-                }
-            default:
-                // Do not leave. If this plugin doesn't support
-                // the content id they want, just return what we have
-                break;
-            } // end switch
-        } // end for
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateMediaGeneralL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::UpdateMediaGeneralL(
-    RSqlStatement& aMusicTable,
-    const TUint aAttrId,
-    CMPXMedia& aMedia)
-    {
-    MPX_DEBUG1("-->CMPXDbMusic::UpdateMediaGeneralL");
-    MPX_DEBUG2("    aAttrId=%b", aAttrId);
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem );
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong );
-
-    // FIX ME, temporary always fetch item ID
-    //if (aAttrId & EMPXMediaGeneralId)
-    if (!aMedia.IsSupported(KMPXMediaGeneralId))
-        {
-        MPX_DEBUG1("    !aMedia.IsSupported(KMPXMediaGeneralId)");
-        TUint32 songId(aMusicTable.ColumnInt64(EMusicUniqueId));
-        TInt columnCount(aMusicTable.ColumnCount());
-        if(columnCount == 37 && aMusicTable.ColumnIndex(_L("PlUId"))==35)
-            {
-            TUint32 pListUId(aMusicTable.ColumnInt64(35));
-            aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId));
-        	}
-        else
-        	{
-        	aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId);
-        	}
-        MPX_DEBUG2("    SongId[%d]", songId);
-        }
-    // FIX ME temporary always fetch URI
-    if (aAttrId & EMPXMediaGeneralUri)
-        {
-        MPX_DEBUG1("    !aMedia.IsSupported(KMPXMediaGeneralUri)");
-        HBufC* uri = ConstructUriL(aMusicTable, (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-        CleanupStack::PushL(uri);
-        aMedia.SetTextValueL(KMPXMediaGeneralUri, *uri);
-        MPX_DEBUG2("    FullPath[%S]", uri);
-        CleanupStack::PopAndDestroy(uri);
-        }
-    if (aAttrId & EMPXMediaGeneralDrive)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralDrive");            
-        TDriveUnit driveUnit;
-        if (aMedia.IsSupported(KMPXMediaGeneralUri))
-            {
-            MPX_DEBUG1("        aMedia.IsSupported(KMPXMediaGeneralUri)");
-            driveUnit = aMedia.ValueText(KMPXMediaGeneralUri);
-            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);
-            }
-        else
-            {
-            MPX_DEBUG1("        !aMedia.IsSupported(KMPXMediaGeneralUri)");                
-            driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-                aMusicTable.ColumnInt64(EMusicVolumeId));
-            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);                
-            }
-
-        TPtrC driveName(driveUnit.Name());
-        aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveName);
-        MPX_DEBUG2("    Drive[%S]", &driveName);
-        }
-    if (aAttrId & EMPXMediaGeneralSize)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralSize");                        
-        // to-do: store this in the DB
-        }
-    if (aAttrId & EMPXMediaGeneralDuration)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralDuration");                                    
-        TInt32 duration(aMusicTable.ColumnInt(EMusicDuration));
-        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-        MPX_DEBUG2("    Duration[%d]", duration);
-        }
-    if ((aAttrId & EMPXMediaGeneralTitle) && !aMedia.IsSupported(KMPXMediaGeneralTitle))
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralTitle");
-        TPtrC title(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicTitle));
-        aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
-        MPX_DEBUG2("    Title[%S]", &title);
-        }
-    if ( aAttrId & EMPXMediaGeneralDate)
-		{
-		MPX_DEBUG1("    EMPXMediaGeneralDate");
-		const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable,
-				EMusicTimeAdded));
-		if ( dateStr.Compare (KNullDesC)!= 0)
-			{
-			TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr));
-			aMedia.SetTObjectValueL<TInt64> (KMPXMediaGeneralDate,
-					dateTime.Int64 ());
-			}
-		MPX_DEBUG2("    Date[%S]", &dateStr);
-		}
-    if (aAttrId & EMPXMediaGeneralComment)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralComment");                        
-        TPtrC comment(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComment));
-        aMedia.SetTextValueL(KMPXMediaGeneralComment, comment);
-        MPX_DEBUG2("    Comment[%S]", &comment);
-        }
-    if (aAttrId & EMPXMediaGeneralMimeType)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralMimeType");                                    
-        TPtrC mimeType(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicMimeType));
-        aMedia.SetTextValueL(KMPXMediaGeneralMimeType, mimeType);
-        MPX_DEBUG2("    MimeType[%S]", &mimeType);
-        }
-    if (aAttrId & EMPXMediaGeneralSynchronized)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralSynchronized");                                                
-        TInt sync(aMusicTable.ColumnInt(EMusicSync));
-        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, sync);
-        MPX_DEBUG2("    Synchronized[%d]", sync);
-        }
-    if (aAttrId & EMPXMediaGeneralDeleted)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralDeleted");                                                            
-        TInt del(aMusicTable.ColumnInt(EMusicDeleted));
-        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralDeleted, del);
-        MPX_DEBUG2("    Deleted[%d]", del);
-        }
-    if (aAttrId & EMPXMediaGeneralModified)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralModified");
-        TInt mod(aMusicTable.ColumnInt(EMusicModified));
-        aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralModified, mod);
-        MPX_DEBUG2("    Modified[%d]", mod);
-        }
-    if (aAttrId & EMPXMediaGeneralCount)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralCount");
-        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1);
-        }
-    if (aAttrId & EMPXMediaGeneralCollectionId)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralCollectionId");            
-        aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
-            TUid::Uid(KDBPluginUid));
-        }
-    if(aAttrId & EMPXMediaGeneralCopyright)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralCopyright");            
-        TPtrC copyright(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicCopyright));
-        aMedia.SetTextValueL(KMPXMediaGeneralCopyright, copyright);
-        MPX_DEBUG2("    Copyright[%S]", &copyright);
-        }
-    if (aAttrId & EMPXMediaGeneralFlags)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralFlags");            
-        TUint32 dbFlags(aMusicTable.ColumnInt64(EMusicDbFlag));
-        MPX_DEBUG2("        dbFlags=%b", dbFlags);
-        TDriveUnit driveUnit;
-        if (aMedia.IsSupported(KMPXMediaGeneralUri))
-            {
-            MPX_DEBUG1("        aMedia.IsSupported(KMPXMediaGeneralUri)");
-            TParsePtrC parse( aMedia.ValueText(KMPXMediaGeneralUri) );
-            if( parse.DrivePresent() )
-                {
-                driveUnit = parse.Drive();
-                }
-            else
-                {
-                driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-                     aMusicTable.ColumnInt64(EMusicVolumeId));    
-                }
-            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);
-            }
-        else
-            {
-            MPX_DEBUG1("        !aMedia.IsSupported(KMPXMediaGeneralUri)");                
-            driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-                aMusicTable.ColumnInt64(EMusicVolumeId));
-            MPX_DEBUG2("        driveUnit=%d", (TInt)driveUnit);                
-            }
-
-        TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo;  // 5 bits
-        aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
-
-        MPX_DEBUG2("    GeneralFlags[%b]", dbFlags | driveId);
-        MPX_DEBUG2("    DriveId[%u]", driveId);
-        }
-    if (aAttrId & EMPXMediaGeneralPlayCount)
-        {
-        MPX_DEBUG1("    EMPXMediaGeneralPlayCount");            
-        TUint32 playcount(aMusicTable.ColumnInt(EMusicPlayCount));
-        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralPlayCount, playcount);
-        MPX_DEBUG2("    PlayCount[%d]", playcount);
-        }
-        
-    MPX_DEBUG1("<--CMPXDbMusic::UpdateMediaGeneralL");
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateMediaMusicL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::UpdateMediaMusicL(
-    RSqlStatement& aMusicTable,
-    const TUint aAttrId,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::UpdateMediaMusicL");
-
-    if (aAttrId & EMPXMediaMusicAlbumArtFileName)
-        {
-        TPtrC art(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArt));
-            aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
-            MPX_DEBUG2("    Album Art File Name[%S]", &art);
-        }
-    if (aAttrId & EMPXMediaMusicArtist)
-        {
-        TPtrC artist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArtistName));
-        aMedia.SetTextValueL(KMPXMediaMusicArtist, artist);
-        MPX_DEBUG2("    Artist[%S]", &artist);
-        }
-    if (aAttrId & EMPXMediaMusicAlbum)
-        {
-        TPtrC album(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumName));
-        aMedia.SetTextValueL(KMPXMediaMusicAlbum, album);
-        MPX_DEBUG2("    Album[%S]", &album);
-        }
-    if ( aAttrId & EMPXMediaMusicYear)
-		{
-		const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable,
-				EMusicReleaseDate));
-		if ( dateStr.Compare (KNullDesC)!= 0)
-			{
-			TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr));
-			aMedia.SetTObjectValueL<TInt64> (KMPXMediaMusicYear,
-					dateTime.Int64 ());
-			MPX_DEBUG2("    Year[%d]", dateTime.Int64());
-			}
-		MPX_DEBUG2("    ReleaseDate[%S]", &dateStr);
-		}
-    if (aAttrId & EMPXMediaMusicAlbumTrack)
-        {
-        TInt32 track(aMusicTable.ColumnInt(EMusicAlbumTrack));
-        HBufC* hbuf = HBufC::NewLC(KMCIntegerLen);
-        if (track != KMaxTInt)
-            {
-            hbuf->Des().AppendFormat(_L("%d"), track);
-            }
-        aMedia.SetTextValueL(KMPXMediaMusicAlbumTrack, *hbuf);
-        MPX_DEBUG3("    Album Track[%S][%d]", hbuf, track);
-        CleanupStack::PopAndDestroy(hbuf);
-        }
-    if (aAttrId & EMPXMediaMusicGenre)
-        {
-        TPtrC genre(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicGenreName));
-        aMedia.SetTextValueL(KMPXMediaMusicGenre, genre);
-        MPX_DEBUG2("    Music Genre[%S]", &genre);
-        }
-    if (aAttrId & EMPXMediaMusicComposer)
-        {
-        TPtrC composer(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComposerName));
-        aMedia.SetTextValueL(KMPXMediaMusicComposer, composer);
-        MPX_DEBUG2("    Music Composer[%S]", &composer);
-        }
-    if (aAttrId & EMPXMediaMusicRating)
-        {
-        TUint32 rating(aMusicTable.ColumnInt(EMusicRating));
-        aMedia.SetTObjectValueL<TUint32>(KMPXMediaMusicRating, rating);
-        MPX_DEBUG2("    Music Rating[%d]", rating);
-        }
-    if (aAttrId & EMPXMediaMusicURL)
-        {
-        TPtrC url(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicUrl));
-        aMedia.SetTextValueL(KMPXMediaMusicURL, url);
-        MPX_DEBUG2("    Music URL[%S]", &url);
-        }
-    if (aAttrId & EMPXMediaMusicOriginalAlbumArtFileName)
-        {
-        // Always set original album art to be file path
-        // Maybe add a new column to db for future if services like rhapsody pushes jpgs to us
-        if (aMedia.IsSupported(KMPXMediaGeneralUri))
-            {
-            const TDesC& uri(aMedia.ValueText(KMPXMediaGeneralUri));
-            aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, uri);
-            MPX_DEBUG2("    Music Original Album Art FullPath[%S]", &uri);
-            }
-        else
-            {
-            HBufC* fullPath = ConstructUriL(aMusicTable, (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-            CleanupStack::PushL(fullPath);
-            aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, *fullPath);
-            MPX_DEBUG2("    Music Original Album Art FullPath[%S]", fullPath);
-            CleanupStack::PopAndDestroy(fullPath);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateMediaAudioL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::UpdateMediaAudioL(
-    RSqlStatement& aMusicTable,
-    const TUint aAttrId,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::UpdateMediaAudioL");
-
-    if (aAttrId & EMPXMediaAudioBitrate)
-        {
-        TUint32 bitrate(aMusicTable.ColumnInt(EMusicBitRate));
-        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioBitrate, bitrate);
-        MPX_DEBUG2("    Bitrate[%d]", bitrate);
-        }
-    if (aAttrId & EMPXMediaAudioSamplerate)
-        {
-        TUint32 samplerate(aMusicTable.ColumnInt(EMusicSampleRate));
-        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioSamplerate, samplerate);
-        MPX_DEBUG2("    SampleRate[%d]", samplerate);
-        }
-    if (aAttrId & EMPXMediaAudioNumberOfChannels)
-        {
-        TUint32 numchannels(aMusicTable.ColumnInt(EMusicNumChannels));
-        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioNumberOfChannels, numchannels);
-        MPX_DEBUG2("    Num of Channels[%d]", numchannels);
-        }
-    if (aAttrId & EMPXMediaAudioCodec)
-        {
-        TUint32 codec(aMusicTable.ColumnInt(EMusicCodec));
-        aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioAudioCodec, codec);
-        MPX_DEBUG2("    Audio Codec[%d]", codec);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateMediaMTPL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::UpdateMediaMTPL(
-    RSqlStatement& aMusicTable,
-    const TUint aAttrId,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::UpdateMediaMTPL");
-
-    if (aAttrId & KMPXMediaMTPDrmStatus.iAttributeId)
-        {
-        TUint32 val(aMusicTable.ColumnInt(EMusicMTPDrmStatus));
-        aMedia.SetTObjectValueL<TUint16>(KMPXMediaMTPDrmStatus, val);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GenerateMusicFieldsValuesL
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::GenerateMusicFieldsValuesL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    CMPXMessageArray* aItemChangedMessages,
-    RSqlStatement* aMusicTable,
-    CDesCArray& aFields,
-    CDesCArray& aValues,
-    TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbMusic::GenerateMusicFieldsValuesL");
-
-    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
-    TBool metaDataModified(EFalse);
-    const TArray<TMPXAttribute> attributes = aMedia.Attributes();
-
-    TBool addSongChangedMessage(ETrue);
-    CMPXMessage* songChangedMessage(NULL);
-    if (aItemChangedMessages)
-        {
-        songChangedMessage = CMPXMedia::NewL();
-        CleanupStack::PushL(songChangedMessage);
-        MPXDbCommonUtil::FillItemChangedMessageL(*songChangedMessage, aSongId,
-            aMusicTable ? EMPXItemModified : EMPXItemInserted, EMPXSong, KDBPluginUid);            
-        }
-
-    // NOTE: Attributes being processed here should be listed in IsSupported()
-    TInt attrCount(attributes.Count());
-    for (TInt i = 0; i < attrCount; ++i)
-        {
-        TUint attributeId(attributes[i].AttributeId());
-
-        switch (attributes[i].ContentId())
-            {
-            case KMPXMediaIdGeneral:
-                {
-                if (attributeId & EMPXMediaGeneralDeleted)
-                    {
-                    TBool deleted(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted));
-                    if (!aMusicTable || (deleted != aMusicTable->ColumnInt(EMusicDeleted)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDel, deleted);
-                        }
-                    MPX_DEBUG2("    Deleted[%d]", deleted);
-                    }
-
-                if (attributeId & EMPXMediaGeneralFlags)
-                    {
-                    TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
-                    TUint32 curFlag(0);
-                    if (aMusicTable)
-                        {
-                        curFlag = aMusicTable->ColumnInt64(EMusicDbFlag);
-                        }
-                    TUint32 oldFlag(curFlag);                        
-
-                    if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit)
-                        {
-                        // Set bits
-                        curFlag |= flag;
-                        }
-                    else
-                        {
-                        // Clear bits
-                        curFlag &= (~flag);
-                        }
-
-                    // The field is written ONLY if the flag value is changing
-                    if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0)
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag);
-                        visibleChange = CMPXDbActiveTask::EAllVisible;
-                        }
-                    MPX_DEBUG2("    GeneralFlags[%b]", curFlag);
-                    }
-
-                if (attributeId & EMPXMediaGeneralTitle)
-                    {
-                    TBool titleChanged(NULL == aMusicTable);
-
-                    const TDesC& title = aMedia.ValueText(KMPXMediaGeneralTitle);
-                    TPtrC truncatedTitle(title.Left(KMCMaxTextLen));
-                    if (aMusicTable)
-                        {
-                        // Title of the song has been changed
-                        if (truncatedTitle.Compare(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTitle)) != 0)
-                            {
-                            titleChanged = ETrue;
-                            }
-                        }
-
-                    if (titleChanged)
-                        {
-                        if ( title.Length() == 0 )
-                            {
-                            const TDesC& path = aMedia.ValueText( KMPXMediaGeneralUri );
-                            TParsePtrC parse( path );
-                            TPtrC truncatedParse( parse.Name().Left( KMCMaxTextLen ) );
-
-                            MPXDbCommonUtil::AppendValueL( aFields, aValues, KMCMusicName, truncatedParse );
-                            }
-                        else
-                            {
-                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, truncatedTitle);
-                            }
-                        visibleChange = CMPXDbActiveTask::EAllVisible;
-                        metaDataModified = ETrue;
-
-                        MPX_DEBUG2("    Title[%S]", &truncatedTitle);
-                        }
-                    }
-
-                if (attributeId & EMPXMediaGeneralUri)
-                    {
-                    const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
-                    const TDesC& uriTrunc(uri.Mid(KMCPathStartPos));
-
-                    TDriveUnit driveUnit(uri);
-                    TUint volId(MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
-
-                    if (!aMusicTable || ((uriTrunc != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicLocation)) ||
-                        (volId != aMusicTable->ColumnInt64(EMusicVolumeId))))
-                        {
-                        // only do the update something changed
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicVolumeId, volId);
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicLocation,
-                            uri.Mid(KMCPathStartPos));
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, DRMTypeL(uri));
-
-                        const TDesC& mimeTypeText(MPXDbCommonUtil::GetMimeTypeForUriL(uri).Des());
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMimeType, mimeTypeText);
-
-                        MPX_DEBUG3("    VolumeId[%u] Location[%S]", volId, &uri);
-                        MPX_DEBUG2("    MimeType[%S]", &mimeTypeText);
-
-                        if (!aMusicTable && !aMedia.IsSupported(KMPXMediaGeneralTitle))
-                            {
-                            TParsePtrC parser(uri);
-                            TPtrC title = parser.Name();
-                            // use file name as song name
-                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, title);
-
-                            visibleChange = CMPXDbActiveTask::EAllVisible;
-                            MPX_DEBUG2("    Title[%S]", &title);
-                            }
-
-                        // URI of the song has been changed. This changes the Id of the song
-                        if (aMusicTable)
-                            {
-                            TUint32 newSongId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, uri, EFalse);
-                            if (aSongId != newSongId)
-                                {
-                                MPX_DEBUG3("    CurrentSongId[0x%x] changed to [0x%x]", aSongId, newSongId);
-                                if (songChangedMessage)
-                                    {
-                                    songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, newSongId);
-                                    songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aSongId);
-                                    }
-
-                                MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUniqueId, newSongId);
-                                }
-                            }
-                        }
-                    }
-
-                if (attributeId & EMPXMediaGeneralPlayCount)
-                    {
-                    TInt increment(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralPlayCount));
-                    TUint32 curCount(increment);
-                    if (aMusicTable)
-                        {
-                        curCount += aMusicTable->ColumnInt(EMusicPlayCount);
-                        }
-
-                    if (!aMusicTable || (curCount != aMusicTable->ColumnInt(EMusicPlayCount)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicPlayCount, curCount);
-
-                        // this needs to be visible in order for Recently Played and Most Played
-                        // playlists will be updated
-                        visibleChange = CMPXDbActiveTask::ESingleVisible;
-
-                        if (aItemChangedMessages)
-                            {
-                            iObserver.HandlePlayCountModifiedL(*aItemChangedMessages);
-                            }           
-                        addSongChangedMessage = EFalse;
-                        }
-                        
-                    MPX_DEBUG2("    PlayCount[%d]", curCount);
-                    }
-
-                if (attributeId & EMPXMediaGeneralLastPlaybackTime)
-                    {
-                    HBufC* time = MPXDbCommonUtil::TTimeToDesLC(
-                        TTime(aMedia.ValueTObjectL<TInt64>(KMPXMediaGeneralLastPlaybackTime)));
-                    if (!aMusicTable || (*time != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTimePlayed)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTimePlayed, *time);
-                        // this needs to be visible in order for Recently Played playlist to be updated
-                        visibleChange = CMPXDbActiveTask::ESingleVisible;
-
-                        if (aItemChangedMessages)
-                            {
-                            iObserver.HandlePlaybackTimeModifiedL(*aItemChangedMessages);
-                            }           
-                        addSongChangedMessage = EFalse;
-                        }
-                    MPX_DEBUG2("    PlaybackTime[%S]", time);
-                    CleanupStack::PopAndDestroy(time);
-                    }
-
-                if (attributeId & EMPXMediaGeneralDuration)
-                    {
-                    TInt duration(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralDuration));
-                    if (!aMusicTable || (duration != aMusicTable->ColumnInt(EMusicDuration)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDuration, duration);
-                        visibleChange = CMPXDbActiveTask::EAllVisible;
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Duration[%d]", duration);
-                    }
-
-                if (attributeId & EMPXMediaGeneralSynchronized)
-                    {
-                    TBool synced(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
-                    if (!aMusicTable || (synced != aMusicTable->ColumnInt(EMusicSync)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSync, synced);
-                        }
-                    MPX_DEBUG2("    Synchronized[%d]", synced);
-                    }
-
-                if (attributeId & EMPXMediaGeneralModified)
-                    {
-                    TBool modified(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralModified));
-                    if (!aMusicTable || (modified != aMusicTable->ColumnInt(EMusicModified)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, modified);
-                        }
-                    MPX_DEBUG2("    Modified[%d]", modified);
-                    }
-
-                if (attributeId & EMPXMediaGeneralComment)
-                    {
-                    TPtrC comment = aMedia.ValueText(KMPXMediaGeneralComment).Left(KMCMaxTextLen);
-                    if (!aMusicTable || (comment != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicComment)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComment, comment);
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Comment[%S]", &comment);
-                    }
-
-                if (attributeId & EMPXMediaGeneralCopyright)
-                    {
-                    const TDesC& copyright = aMedia.ValueText(KMPXMediaGeneralCopyright).
-                        Left(KMCMaxTextLen);
-                    if (!aMusicTable || (copyright != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicCopyright)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicCopyright, copyright);
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Copyright[%S]", &copyright);
-                    }
-                }
-                break;
-
-            case KMPXMediaIdMusic:
-                {
-                if (attributeId & EMPXMediaMusicAlbumTrack)
-                    {
-                    const TDesC& trackNumber = aMedia.ValueText(KMPXMediaMusicAlbumTrack);
-
-                    // KMaxTInt is used to represent null album track
-                    TInt track(KMaxTInt);
-                    if (trackNumber.Length())
-                        {
-                        TLex stringParser(trackNumber);
-
-                        if ((stringParser.Val(track) != KErrNone) ||
-                            (track == 0) || (track > 999))  // Limit track number to 3 characters
-                            {
-                            track = KMaxTInt;
-                            }
-                        }
-
-                    if (!aMusicTable || (track != aMusicTable->ColumnInt(EMusicAlbumTrack)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTrackNumber, track);
-                        visibleChange = CMPXDbActiveTask::EAllVisible;
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG3("    Album Track[%S][%d]", &trackNumber, track);
-                    }
-
-                if (attributeId & EMPXMediaMusicYear)
-                    {
-                    TInt64 int64(aMedia.ValueTObjectL<TInt64>(KMPXMediaMusicYear));
-
-                    TTime maxTime(0);
-                    maxTime += TTimeIntervalYears(9999);    // Limit years to 4 characters
-                    TTime time(int64);
-
-                    if (time > maxTime)
-                        {
-                        time = Time::NullTTime();
-                        }
-
-                    HBufC* timeStr = MPXDbCommonUtil::TTimeToDesLC(time);
-                    if (!aMusicTable || (*timeStr != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicReleaseDate)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicReleaseDate, *timeStr);
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Music Year[%S]", timeStr);
-                    CleanupStack::PopAndDestroy(timeStr);
-                    }
-
-                if (attributeId & EMPXMediaMusicRating)
-                    {
-                    TInt rating(aMedia.ValueTObjectL<TInt>(KMPXMediaMusicRating));
-                    if (!aMusicTable || (rating != aMusicTable->ColumnInt(EMusicRating)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicRating, rating);
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Rating[%d]", rating);
-                    }
-
-                if (attributeId & EMPXMediaMusicAlbumArtFileName)
-                    {
-                    const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
-                    if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
-                        visibleChange = CMPXDbActiveTask::EAllVisible;
-                        metaDataModified = ETrue;
-                        }
-
-                    MPX_DEBUG2("    Album Art Filename[%S]", &albumArtFilename);
-                    }
-
-                if (attributeId & EMPXMediaMusicURL)
-                    {
-                    const TDesC& url = aMedia.ValueText(KMPXMediaMusicURL).Left(KMCMaxTextLen);
-                    if (!aMusicTable || (url != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicUrl)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUrl, url);
-                        metaDataModified = ETrue;
-                        }
-
-                    MPX_DEBUG2("    Music URL[%S]", &url);
-                    }
-                }
-                break;
-
-            case KMPXMediaIdAudio:
-                {
-                if (attributeId & EMPXMediaAudioSamplerate)
-                    {
-                    TInt samplerate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioSamplerate));
-                    if (!aMusicTable || (samplerate != aMusicTable->ColumnInt(EMusicSampleRate)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSampleRate, samplerate);
-                        metaDataModified = ETrue;
-                        }
-
-                    MPX_DEBUG2("    Sample Rate[%d]", samplerate);
-                    }
-
-                if (attributeId & EMPXMediaAudioBitrate)
-                    {
-                    TInt bitrate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioBitrate));
-                    if (!aMusicTable || (bitrate != aMusicTable->ColumnInt(EMusicBitRate)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicBitRate, bitrate);
-                        metaDataModified = ETrue;
-                        }
-                    MPX_DEBUG2("    Bitrate[%d]", bitrate);
-                    }
-
-                if (attributeId & EMPXMediaAudioNumberOfChannels)
-                    {
-                    TUint32 val = aMedia.ValueTObjectL<TUint32>(KMPXMediaAudioNumberOfChannels);
-                    if (!aMusicTable || (val != aMusicTable->ColumnInt(EMusicNumChannels)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicNumChannels, val);
-                        }
-                    MPX_DEBUG2("    Num of Channels[%d]", val);
-                    }
-                }
-                break;
-
-            case KMPXMediaIdDrm:
-                {
-                if (attributeId & EMPXMediaDrmType)
-                    {
-                    TInt drmType(aMedia.ValueTObjectL<TInt>(KMPXMediaDrmType));
-                    if (!aMusicTable || (drmType != aMusicTable->ColumnInt(EMusicDRM)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, drmType);
-                        }
-                    MPX_DEBUG2("    DRM type[%d]", drmType);
-                    }
-                    
-                if (attributeId & KMPXMediaDrmRightsStatus.iAttributeId)
-                    {
-                    if (aMusicTable)
-                        {
-                        TMPXMediaDrmRightsStatus status = 
-                                 aMedia.ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus);
-                        
-                        //.Set the db flag
-                        TUint32 curFlag(aMusicTable->ColumnInt64(EMusicDbFlag));
-                        TUint32 oldFlag(curFlag);
-                        
-                        if ((status != EMPXDrmRightsFull) && (status != EMPXDrmRightsRestricted))
-                            {
-                            // No rights
-                            curFlag |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid;
-                            }
-                        else
-                            {
-                            // Rights valid
-                            curFlag &= (KMPXMediaGeneralFlagsIsDrmLicenceInvalid ^ 0xFFFFFFFF);
-                            }
-                        
-                        // The field is written ONLY if the flag value is changing
-                        if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0)
-                        {
-                            MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag);
-                            visibleChange = CMPXDbActiveTask::EAllVisible;
-                        }
-                            
-                        MPX_DEBUG2("    Rights Status[%d]", curFlag);
-                        }
-                    }
-                    
-                break;
-                }
-
-            case KMPXMediaIdMTP:
-                {
-                if (attributeId & KMPXMediaMTPDrmStatus.iAttributeId)
-                    {
-                    TUint16 drmStatus(aMedia.ValueTObjectL<TUint16>(KMPXMediaMTPDrmStatus));
-                    if (!aMusicTable || (drmStatus != aMusicTable->ColumnInt(EMusicMTPDrmStatus)))
-                        {
-                        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMTPDrmStatus, drmStatus);
-                        }
-                    MPX_DEBUG2("    MTP Drm Status[%d]", drmStatus);
-                    }
-                }
-                break;
-
-            default:
-                break;
-            } // end switch
-        } // end for
-
-    // get the current artist/album/genre/composer
-    // this is required because the recordset may be reused by the code below
-    TUint32 artistId(0);
-    TUint32 albumId(0);
-    TUint32 genreId(0);
-    TUint32 composerId(0);
-    if (aMusicTable)
-        {
-        artistId = aMusicTable->ColumnInt64(EMusicArtist);
-        albumId = aMusicTable->ColumnInt64(EMusicAlbum);
-        genreId = aMusicTable->ColumnInt64(EMusicGenre);
-        composerId = aMusicTable->ColumnInt64(EMusicComposer);
-        }
-
-    // update the artist field
-    TUint32 id(0);
-    TUint32 artistIdForAlbum(artistId);
-    if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
-        aDrive, aItemChangedMessages, id, 0))
-        {
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
-        metaDataModified = (aMusicTable != NULL);
-        visibleChange = CMPXDbActiveTask::EAllVisible;
-        artistIdForAlbum = id;
-        }
-
-    // update the album field
-	if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId,
-		aDrive, aItemChangedMessages, id, artistIdForAlbum))
-        {
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id);
-        metaDataModified = (aMusicTable != NULL);
-        visibleChange = CMPXDbActiveTask::EAllVisible;
-        
-        //
-        // added to handle error EALU-73WDJN. If the album name of the last song
-        // in the album for the artist is changed to an existing album name from
-        // artist view, a change message needs to be sent in order for UI to
-        // correctly refresh.
-        //
-        // Fix for EDXU-7BBALS, remove check for HasOtherSongsInArtistAlbumL 
-        // Always send a Album Inserted message when Album change to get Artist updated
-        if (aItemChangedMessages)
-            {
-            // send album added m essage instead of album deleted or modified
-            // to avoid collection paths of other clients being modified
-            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId, 
-                    EMPXItemInserted, EMPXAlbum, KDBPluginUid);
-            }
-        }
-
-    // update the genre field
-    if (UpdateCategoryFieldL(EMPXGenre, aMedia, KMPXMediaMusicGenre, genreId,
-        aDrive, aItemChangedMessages, id))
-        {
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicGenre, id);
-        metaDataModified = (aMusicTable != NULL);
-        visibleChange = CMPXDbActiveTask::EAllVisible;
-        }
-
-    // update the composer field
-    if (UpdateCategoryFieldL(EMPXComposer, aMedia, KMPXMediaMusicComposer, composerId,
-        aDrive, aItemChangedMessages, id))
-        {
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComposer, id);
-        metaDataModified = (aMusicTable != NULL);
-        visibleChange = CMPXDbActiveTask::EAllVisible;
-        }
-
-#if defined (__MTP_PROTOCOL_SUPPORT)
-    // Set Mod bit to ETrue if metadata has been updated and caller hasn't explicitly
-    // set/reset it
-    if (aMusicTable &&
-        !aMedia.IsSupported(KMPXMediaGeneralModified) &&
-        metaDataModified)
-        {
-        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, 1);
-        MPX_DEBUG1("    Modified[1]");
-        }
-#endif
-
-    if (aItemChangedMessages)
-        {
-      if (aFields.Count() && addSongChangedMessage)
-          {
-          aItemChangedMessages->AppendL(*songChangedMessage);
-          }
-        CleanupStack::PopAndDestroy(songChangedMessage);
-        }
-        
-    return visibleChange;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DRMTypeL
-// ----------------------------------------------------------------------------
-//
-TMCDrmType CMPXDbMusic::DRMTypeL(
-    const TDesC& aFile)
-    {
-    MPX_FUNC("CMPXDbMusic::DRMTypeL");
-
-    TMCDrmType drm(EMCDrmNone);
-    TInt pos(0);
-    TParsePtrC fullEntry(aFile);
-    TPtrC theExt = fullEntry.Ext();
-
-    if (iExtensionsDrm->Find(theExt, pos) == 0)
-        {
-        drm = MPXDbCommonUtil::GetDRMTypeL(aFile);
-        }
-
-    return drm;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::GenerateMusicMatchingCriteriaLC
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbMusic::GenerateMusicMatchingCriteriaLC(
-    TUint32 aGeneralId,
-    TUint32 aContainerId,
-    TMPXGeneralType aType,
-    const CMPXMedia& aCriteria)
-    {
-    MPX_FUNC("CMPXDbMusic::GenerateMusicMatchingCriteriaLC");
-
-    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
-    TInt criteriaCount(criteria.Count());
-
-    // construct an array of criteria strings
-    CDesCArrayFlat* sqlCriteria = new (ELeave) CDesCArrayFlat(criteriaCount);
-    CleanupStack::PushL(sqlCriteria);
-
-    // If EMPXMediaGeneralDeleted is not defined, always unset the deleted bit for matching
-    if (!aCriteria.IsSupported(KMPXMediaGeneralDeleted))
-        {
-        sqlCriteria->AppendL(KCriterionMusicNotDeleted);
-        }
-
-    TBool volumeAdded(EFalse);
-    for (TInt i = 0; i < criteriaCount; ++i)
-        {
-        const TMPXAttribute& criterion = criteria[i];
-
-        if (criterion == KMPXMediaGeneralId)
-            {
-            // Set the type if no type is specified
-            TInt category(MPX_ITEM_CATEGORY(aGeneralId));
-
-            if( aType == EMPXNoType )
-                {
-                aType = (category == EMPXCollection) ? EMPXItem : EMPXGroup;
-                }
-
-            TPtrC ptr;
-            if (aType == EMPXItem && (category == EMPXCollection))
-                {
-                ptr.Set(KCriterionMusicUniqueId);
-                }
-            else if (aType == EMPXGroup && (category == EMPXArtist))
-                {
-                ptr.Set(KCriterionMusicArtist);
-                }
-            else if (aType == EMPXGroup && (category == EMPXAlbum))
-                {
-                ptr.Set(KCriterionMusicAlbum);
-                }
-            else if (aType == EMPXGroup && (category == EMPXGenre))
-                {
-                ptr.Set(KCriterionMusicGenre);
-                }
-            else if (aType == EMPXGroup && (category == EMPXComposer))
-                {
-                ptr.Set(KCriterionMusicComposer);
-                }
-            else
-                {
-                User::Leave(KErrNotSupported);
-                }
-
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, ptr, aGeneralId);
-            }
-        else if (criterion == KMPXMediaGeneralContainerId)
-            {
-            TInt containerCategory(MPX_ITEM_CATEGORY(aContainerId));
-
-            if (aType == EMPXGroup && (containerCategory == EMPXArtist))
-                {
-                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria,
-                    KCriterionMusicArtist, aContainerId);
-                }
-            else if (aType == EMPXGroup && (containerCategory == EMPXAlbum))
-                {
-                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria,
-                    KCriterionMusicAlbum, aContainerId);
-                }
-            else
-                {
-                //User::Leave(KErrNotSupported);
-                }
-            }
-        else if (criterion == KMPXMediaGeneralTitle)
-            {
-            HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
-                aCriteria.ValueText(KMPXMediaGeneralTitle));
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicTitle, *title);
-            CleanupStack::PopAndDestroy(title);
-            }
-        else if (criterion == KMPXMediaGeneralUri)
-            {
-            // full URI from criteria
-            const TDesC& uri = aCriteria.ValueText(KMPXMediaGeneralUri);
-            TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
-                                                                uri, EFalse);
-            
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicUniqueId, itemId);
-            }
-        else if (criterion == KMPXMediaGeneralDrive)
-            {
-            if (!volumeAdded)
-                {
-                // validate the drive letter, TDriveUnit panics if given drive isn't between
-                // 'A' to 'Z'
-                TDriveUnit driveUnit(aCriteria.ValueText(KMPXMediaGeneralDrive));
-                MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume,
-                    MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
-                volumeAdded = ETrue;
-                }
-            }
-        else if (criterion == KMPXMediaGeneralSynchronized)
-            {
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicSync,
-                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
-            }
-        else if (criterion == KMPXMediaGeneralDeleted)
-            {
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicDeleted,
-                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted));
-            }
-        else if (criterion == KMPXMediaGeneralModified)
-            {
-            MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicModified,
-                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralModified));
-            }
-         else
-            {
-            // to-do: provide searching ability on the rest of the fields
-            }
-        }
-
-    // construct the final criteria string
-    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*sqlCriteria, KMCAndKeyword);
-
-    CleanupStack::Pop(criteriaStr);
-    CleanupStack::PopAndDestroy(sqlCriteria);
-    CleanupStack::PushL(criteriaStr);
-
-    return criteriaStr;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::ConstructUriL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbMusic::ConstructUriL(
-    RSqlStatement& aMusicTable,
-    TUint32 aMediaId)
-    {
-    MPX_FUNC("CMPXDbMusic::ConstructUriL");
-
-    TUint volId(aMusicTable.ColumnInt64(EMusicVolumeId));
-    TPtrC location(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicLocation));
-    if(!location.Length())
-        {
-        return GetUriL(aMediaId);
-        }
-    return MPXDbCommonUtil::CreateFullPathL(
-        MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId), location);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbMusic::CreateTableL");
-
-    // Create the table
-    User::LeaveIfError(aDatabase.Exec(KMusicCreateTable));
-
-    // Do not create any other indexes than the one on UniqueId
-    // as they only slow down the database overall
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::DropTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbMusic::DropTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbMusic::DropTableL");
-    User::LeaveIfError(aDatabase.Exec(KMusicDropTable));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbMusic::CheckTableL");
-    return DoCheckTable(aDatabase, KMusicCheckTable);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbMusic::UpdateCategoryFieldL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::UpdateCategoryFieldL(
-    TMPXGeneralCategory aCategory,
-    const CMPXMedia& aMedia,
-    const TMPXAttribute& aAttribute,
-    TUint32 aOldId,
-    TInt aDriveId,
-    CMPXMessageArray* aItemChangedMessages,
-    TUint32& aItemId)
-    {
-    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
-
-                // ignore the return value
-                iObserver.AddCategoryItemL(aCategory, name, 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))
-                {
-                // ignore the return value
-                iObserver.AddCategoryItemL(aCategory, KNullDesC, 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;
-    }
-
-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
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::ExtraFieldsRequired(
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_DEBUG1("-->CMPXDbMusic::ExtraFieldsRequired");
-
-    // check if any extra fields are required
-    TUint defaultFields(EMPXMediaGeneralId |
-                        EMPXMediaGeneralType |
-                        EMPXMediaGeneralCategory |
-                        EMPXMediaGeneralTitle |
-                        EMPXMediaGeneralUri |
-                        EMPXMediaGeneralFlags);
-                        
-    TBool extraRequired(EFalse);
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TUint attributeId(aAttrs[i].AttributeId()|defaultFields);
-        MPX_DEBUG2("    attribute content id 0x%x", aAttrs[i].ContentId());
-        MPX_DEBUG3("    attribute id %b, original attribute id %b", attributeId, aAttrs[i].AttributeId());
-
-        if (KMPXMediaIdGeneral != aAttrs[i].ContentId() ||
-            attributeId != defaultFields)
-            {
-            MPX_DEBUG1("    extraRequired YES");
-            extraRequired = ETrue;
-            break;
-            }
-        }
-
-    MPX_DEBUG2("<--CMPXDbMusic::ExtraFieldsRequired returns %d", extraRequired);
-    return extraRequired;
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Test if the given media contains supported attributes
-// ----------------------------------------------------------------------------------------------------------
-//
-TBool CMPXDbMusic::IsSupported(
-  const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbMusic::IsSupported");                   
-
-    // this checklist should match the attributes processed in DoFillInDatabaseInfoL
-    return aMedia.IsSupported(KMPXMediaGeneralTitle) ||
-        aMedia.IsSupported(KMPXMediaGeneralUri) ||
-        aMedia.IsSupported(KMPXMediaGeneralComment) ||
-        aMedia.IsSupported(KMPXMediaGeneralSynchronized) ||
-        aMedia.IsSupported(KMPXMediaGeneralDeleted) ||
-        aMedia.IsSupported(KMPXMediaGeneralModified) ||
-        aMedia.IsSupported(KMPXMediaGeneralCopyright) ||
-        aMedia.IsSupported(KMPXMediaGeneralDuration) ||
-        aMedia.IsSupported(KMPXMediaGeneralFlags) ||
-        aMedia.IsSupported(KMPXMediaGeneralPlayCount) ||
-        aMedia.IsSupported(KMPXMediaGeneralLastPlaybackTime) ||
-        aMedia.IsSupported(KMPXMediaMusicAlbumTrack) ||
-        aMedia.IsSupported(KMPXMediaMusicYear) ||
-        aMedia.IsSupported(KMPXMediaMusicRating) ||
-        aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ||
-        aMedia.IsSupported(KMPXMediaMusicURL) ||
-        aMedia.IsSupported(KMPXMediaMusicArtist) ||
-        aMedia.IsSupported(KMPXMediaMusicAlbum) ||
-        aMedia.IsSupported(KMPXMediaMusicGenre) ||
-        aMedia.IsSupported(KMPXMediaMusicComposer) ||
-        aMedia.IsSupported(KMPXMediaAudioSamplerate) ||
-        aMedia.IsSupported(KMPXMediaAudioBitrate) ||
-        aMedia.IsSupported(KMPXMediaAudioNumberOfChannels) ||
-        aMedia.IsSupported(KMPXMediaDrmType) ||
-        aMedia.IsSupported(KMPXMediaDrmRightsStatus) ||
-        aMedia.IsSupported(KMPXMediaMTPDrmStatus);
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplaylist.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1087 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interaction with the playlist tables.
-*
-*/
-
-
-// INCLUDE FILES
-#include <f32file.h>
-#include <mpxlog.h>
-#include <mpxmediacontainerdefs.h>
-
-#include "mpxdbcommonutil.h"
-#include "mpxdbcommondef.h"
-#include "mpxdbcommonstd.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbmanager.h"
-#include "mpxdbutil.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbplaylistsongs.h"
-#include "mpxdbplaylist.h"
-
-// CONSTANTS
-// UniqueID column in Uris requests
-const TInt KColUniqueID = 0;
-// URI column in Uris requests
-const TInt KColUri = 1;
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylist* CMPXDbPlaylist::NewL(
-    CMPXDbManager& aDbManager,
-	MMPXDbPlaylistObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbPlaylist::NewL");
-
-    CMPXDbPlaylist* self = CMPXDbPlaylist::NewLC(aDbManager, aObserver);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylist* CMPXDbPlaylist::NewLC(
-    CMPXDbManager& aDbManager,
-	MMPXDbPlaylistObserver& aObserver)
-    {
-    MPX_FUNC("CMPXDbPlaylist::NewLC");
-
-	CMPXDbPlaylist* self = new (ELeave) CMPXDbPlaylist(aDbManager, aObserver);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylist::~CMPXDbPlaylist()
-    {
-    MPX_FUNC("CMPXDbPlaylist::~CMPXDbPlaylist");
-    delete iPlaylistSongs;
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylist::CMPXDbPlaylist(
-    CMPXDbManager& aDbManager, 
-    MMPXDbPlaylistObserver& aObserver) :
-    CMPXDbTable(aDbManager),
-	iObserver(aObserver)
-    {
-    MPX_FUNC("CMPXDbPlaylist::CMPXDbPlaylist");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::ConstructL()
-    {
-    MPX_FUNC("CMPXDbPlaylist::ConstructL");
-
-    BaseConstructL();
-    iPlaylistSongs = CMPXDbPlaylistSongs::NewL(iDbManager);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::AddPlaylistL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlaylist::AddPlaylistL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::AddPlaylistL");
-
-    // make sure the playlist and the corresponding songs are deleted
-    TUint32 playlistId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist,
-        aMedia.ValueText(KMPXMediaGeneralUri), EFalse));
-    DeletePlaylistNoUriL(playlistId);
-
-    // add the playlist
-    return DoAddPlaylistL(aMedia, TDriveUnit(aMedia.ValueText(KMPXMediaGeneralUri)));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::AddSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::AddSongsL(
-    TUint32 aPlaylistId,
-    const CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlaylist::AddSongsL");
-
-    // get the drive ID of corresponding playlist
-    TInt drive(GetDriveIdL(aPlaylistId));
-
-    // add the songs
-    iPlaylistSongs->AddSongsL(aPlaylistId, aMediaArray, drive);
-
-    // update the time for the playlist
-    UpdatePlaylistTimeL(aPlaylistId, drive);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::UpdatePlaylistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::UpdatePlaylistL(
-    const CMPXMedia& aMedia,
-    CMPXMessage& aMessage,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistL");
-
-    TUint32 playlistId((aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-    DoUpdatePlaylistL(playlistId, aMedia, aDriveId, aMessage);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::UpdateSongL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylist::UpdateSongL(
-    const CMPXMedia& aMedia,
-    TBool aResetFlags,
-    CMPXMessageArray* aItemChangedMessages /* = NULL */)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdateSongL");
-
-    // find the song ID
-    TInt oldSongId(0);
-    TInt newSongId(0);
-    if (aMedia.IsSupported(KMPXMediaGeneralId))
-        {
-        oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
-        }
-    if (aMedia.IsSupported(KMPXMediaGeneralUri))
-        {
-        newSongId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
-            aMedia.ValueText(KMPXMediaGeneralUri), EFalse);
-        }
-    if ( !aMedia.IsSupported( KMPXMediaGeneralId ) && !aMedia.IsSupported( KMPXMediaGeneralUri ))
-        {
-        User::Leave( KErrArgument );
-        }
-
-    if ( newSongId <= 0 )
-        {
-        newSongId = oldSongId;
-        }
-
-    if ( oldSongId <= 0 )
-        {
-        oldSongId = newSongId;
-        }
-
-    // update the PlaylistSongs and PlaylistSongInfo tables first
-    TBool updated(EFalse);
-    TBool visible(iPlaylistSongs->UpdateSongL( oldSongId, aMedia, aResetFlags, updated ));
-    TBool bSongInPlaylists( EFalse );
-    if (updated)
-        {
-        UpdatePlaylistsForSongL( newSongId, aItemChangedMessages,bSongInPlaylists );
-        }
-
-    return visible;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DeleteSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DeleteSongL(
-    TUint32 aSongId,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
-    TBool bSongInPlaylists(EFalse);
-    // add item changed messages for all playlists that contain the song
-    UpdatePlaylistsForSongL (aSongId, &aItemChangedMessages, bSongInPlaylists);
-    if (bSongInPlaylists)
-        {
-        // delete the song from the PlaylistSongs and PlaylistSongInfo tables
-        iPlaylistSongs->DeleteSongL (aSongId);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DeleteSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DeleteSongL(
-    TUint32 aPlaylistId,
-    TUint32 aSongId,
-    TInt aOrdinal)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
-
-    // get playlist drive
-    TInt drive(GetDriveIdL(aPlaylistId));
-
-    // delete the song from the PlaylistSongs / PlaylistSongInfo tables
-    iPlaylistSongs->DeleteSongL(aPlaylistId, aSongId, aOrdinal, drive);
-
-    // update the time for the playlist
-    UpdatePlaylistTimeL(aPlaylistId, drive);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DeletePlaylistL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbPlaylist::DeletePlaylistL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeletePlaylistL");
-
-    // get the uri
-    HBufC* uri = GetUriL(aPlaylistId);
-    if (uri)
-        {
-        CleanupStack::PushL(uri);
-        TDriveUnit drive(*uri);
-
-        // delete the songs from the PlaylistSongs table
-        iPlaylistSongs->DeleteSongsL(aPlaylistId, drive);
-
-        // delete the playlist record from the Playlist table
-        iDbManager.ExecuteQueryL(drive, KQueryPlaylistDelete, aPlaylistId);
-
-        CleanupStack::Pop(uri);
-        }
-
-    return uri;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DeletePlaylistNoUriL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DeletePlaylistNoUriL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeletePlaylistNoUriL");
-
-    TInt drive(0);
-    MPX_TRAPD(err, drive = GetDriveIdL(aPlaylistId));
-    if (err != KErrNotFound)
-        {
-        User::LeaveIfError(err);
-
-        // delete the songs from the PlaylistSongs table
-        iPlaylistSongs->DeleteSongsL(aPlaylistId, drive);
-
-        // delete the playlist record from the Playlist table
-        iDbManager.ExecuteQueryL(drive, KQueryPlaylistDelete, aPlaylistId);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DeleteAllPlaylistsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DeleteAllPlaylistsL()
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteAllPlaylistsL");
-
-    // delete the songs from the PlaylistSongs table
-    iPlaylistSongs->DeleteAllSongsL();
-
-    // delete all playlists
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistDeleteAll);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::CountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylist::CountL()
-    {
-    MPX_FUNC("CMPXDbPlaylist::CountL");
-    return ExecuteSumQueryL(KQueryPlaylistCount);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetPlaylistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::GetPlaylistL(
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetPlaylistL");
-    ExecuteMediaQueryL(aAttrs, aMedia, KQueryPlaylistGet, aPlaylistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetAllPlaylistsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::GetAllPlaylistsL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetAllPlaylistsL");
-    ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryPlaylistGetAll);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetNameL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbPlaylist::GetNameL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetNameL");
-
-    RSqlStatement recordset(GetPlaylistRecordL(aPlaylistId));
-    CleanupClosePushL(recordset);
-
-    HBufC* name(NULL);
-    TInt err(KErrNone);
-    if ((err = recordset.Next()) == KSqlAtRow)
-        {
-        name = MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistName).AllocL();
-        }
-    CleanupStack::PopAndDestroy(&recordset);
-
-    if (err != KSqlAtEnd)
-        {
-        User::LeaveIfError(err);
-        }
-
-    if (name == NULL)
-        {
-        User::LeaveIfError(KErrNotFound);
-        }
-    return name;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetUriL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbPlaylist::GetUriL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetUriL");
-
-    RSqlStatement recordset(GetPlaylistRecordL(aPlaylistId));
-    CleanupClosePushL(recordset);
-
-    HBufC* uri(NULL);
-    TInt err(KErrNone);
-    if ((err = recordset.Next()) == KSqlAtRow)
-        {
-        uri = MPXDbCommonUtil::CreateFullPathL(
-            MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-            recordset.ColumnInt64(EPlaylistVolumeId)),
-            MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistUri));
-
-        }
-    CleanupStack::PopAndDestroy(&recordset);
-
-    if (err != KSqlAtEnd)
-        {
-        User::LeaveIfError(err);
-        }
-
-    if (uri == NULL)
-        {
-        User::LeaveIfError(KErrNotFound);
-        }
-
-    return uri;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetIdL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlaylist::GetIdL(
-    const TDesC& aUri)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetIdL");
-    HBufC* uri = MPXDbCommonUtil::ProcessPatternCharsLC( aUri );
-    TUint32 ret = ExecuteIntQueryL(
-        KQueryLikePlaylistId, uri->Mid( KMCPathStartPos ) );
-
-   	CleanupStack::PopAndDestroy( uri );
-
-    return ret;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::FindAllL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::FindAllL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlaylist::FindAllL");
-
-    // process the requested attributes
-    // the UniqueId is always requested
-    TBool titleRequested(EFalse);
-    TBool counterRequested(EFalse);
-
-    TInt viewingColumnCount(aAttrs.Count());
-    for (TInt i = 0; (i < viewingColumnCount) && !(titleRequested && counterRequested); ++i)
-        {
-        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
-            {
-            TUint attributeId(aAttrs[i].AttributeId());
-
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                titleRequested = ETrue;
-                }
-            if (attributeId & EMPXMediaGeneralCount)
-                {
-                counterRequested = ETrue;
-                }
-            }
-        }
-
-    TMPXGeneralType type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
-
-    const TArray<TMPXAttribute> criteria = aCriteria.Attributes();
-    TInt criteriaCount(criteria.Count());
-
-    // process the criteria and construct the criteria string
-    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(criteriaCount);
-    CleanupStack::PushL(criteriaArray);
-
-    TBool criteriaCounterSet(EFalse);
-    TInt criteriaCounter(0);
-
-    for (TInt i = 0; i < criteriaCount; ++i)
-        {
-        const TMPXAttribute& criterion = criteria[i];
-        if (type == EMPXItem && criterion == KMPXMediaGeneralId)
-            {
-            TUint32 itemId((aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-            if (MPX_ITEM_CATEGORY(itemId) != EMPXPlaylist)
-                {
-                User::Leave(KErrNotSupported);
-                }
-
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId, itemId);
-            }
-        else if (criterion == KMPXMediaGeneralTitle)
-            {
-            HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC(
-                aCriteria.ValueText(KMPXMediaGeneralTitle));
-            if( type == EMPXOtherType )
-                {
-                MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTitle, *title);
-                }
-            else
-                {
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistLikeTitle, *title);
-                }
-            CleanupStack::PopAndDestroy(title);
-            }
-        else if (criterion == KMPXMediaGeneralUri)
-            {
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId,
-                MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist,
-                aCriteria.ValueText(KMPXMediaGeneralUri), EFalse));
-            }
-        else if (criterion == KMPXMediaGeneralDrive)
-            {
-            const TDesC& drive(aCriteria.ValueText(KMPXMediaGeneralDrive));
-            TDriveUnit driveUnit(drive);
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistVolumeId,
-                MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit));
-            }
-        else if (criterion == KMPXMediaGeneralSynchronized)
-            {
-            MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistSync,
-                aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
-            }
-        else if (criterion == KMPXMediaGeneralCount)
-            {
-            criteriaCounterSet = ETrue;
-            criteriaCounter = aCriteria.ValueTObjectL<TInt>(KMPXMediaGeneralCount);
-            }
-        }
-
-    // construct criteria string
-    HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
-
-    HBufC* query(NULL);
-    if (criteriaStr->Length() > 0)
-        {
-        // construct and execute the query
-        query = HBufC::NewLC(KQueryPlaylistItems().Length() + criteriaStr->Length());
-        query->Des().Format(KQueryPlaylistItems, criteriaStr);
-        }
-    else
-        {
-        query = HBufC::NewLC(KQueryPlaylistGetAll().Length());
-        query->Des().Format(KQueryPlaylistGetAll);
-        }
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
-
-    CleanupStack::PopAndDestroy(query);
-    CleanupStack::PopAndDestroy(criteriaStr);
-    CleanupStack::PopAndDestroy(criteriaArray);
-
-    CleanupClosePushL(recordset);
-
-    TInt err(KErrNone);
-    while ((err = recordset.Next()) == KSqlAtRow)
-        {
-        // Setup basic info - with first record of a group
-        TUint32 playlistId(recordset.ColumnInt64(EPlaylistUniqueId));
-
-        TBool valid(ETrue);
-        TInt songCount(-1);
-        if (criteriaCounterSet)
-            {
-            songCount = iPlaylistSongs->CountL(playlistId);
-            valid = (criteriaCounter == songCount);
-            }
-
-        if (valid)
-            {
-            // start a new media object
-            CMPXMedia* media = CMPXMedia::NewL();
-            CleanupStack::PushL(media);
-
-            UpdateMediaL(recordset, aAttrs, *media);
-
-            aMediaArray.AppendL(*media);
-            CleanupStack::PopAndDestroy(media);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-
-    if (err != KSqlAtEnd)
-        {
-        User::LeaveIfError(err);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetDriveIdL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylist::GetDriveIdL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetDriveIdL");
-    return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
-        ExecuteIntQueryL(KQueryPlaylistDriveId, aPlaylistId));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::Songs
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylistSongs& CMPXDbPlaylist::Songs()
-    {
-    return *iPlaylistSongs;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetDrivePlaylistCount
-// ----------------------------------------------------------------------------
-//
-TUint CMPXDbPlaylist::GetDrivePlaylistCountL(TInt aDrive)
-    {
-    TUint count(0);
-
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryPlaylistFileCount));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() != KSqlAtRow)
-        {
-        User::Leave(KErrCorrupt);
-        }
-
-    count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex));
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetPlaylistUriArrayL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
-                                          CDesCArray& aUriArr, TInt& aLastID)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetPlaylistUriArrayL");
-
-    HBufC* query = NULL;
-    if(aFromID == 0)
-        {
-        query = HBufC::NewLC(KQueryPlaylistGetFileUris().Length()
-                            + KMCIntegerLen);
-        query->Des().Format(KQueryPlaylistGetFileUris, aRecords);
-        }
-    else
-        {
-        query = HBufC::NewLC(KQueryPlaylistGetFileUrisFrom().Length()
-                            + 2*KMCIntegerLen);
-        query->Des().Format(KQueryPlaylistGetFileUrisFrom, aFromID, aRecords);
-        }
-
-    RSqlStatement playlist_rs(iDbManager.ExecuteSelectQueryL(aDrive,*query));
-
-    CleanupStack::PopAndDestroy(query);
-
-    CleanupClosePushL(playlist_rs);
-
-    TInt lastID = 0;
-    TInt err(KErrNone);
-    while((err = playlist_rs.Next()) == KSqlAtRow)
-        {
-        HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive,
-                MPXDbCommonUtil::GetColumnTextL(playlist_rs, KColUri));
-        CleanupStack::PushL(fullPath);
-        aUriArr.AppendL(*fullPath);
-        CleanupStack::PopAndDestroy(fullPath);
-
-        lastID = playlist_rs.ColumnInt(KColUniqueID);
-        }
-    CleanupStack::PopAndDestroy(&playlist_rs);
-
-    aLastID = lastID;
-
-    if (err!= KSqlAtEnd)
-        {
-        User::Leave(KErrCorrupt);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::UpdateMediaL(
-    RSqlStatement& aRecord,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdateMediaL");
-
-    TBool countRequested(EFalse);
-	TBool durationRequested(EFalse);
-    TUint32 playlistId(aRecord.ColumnInt64(EPlaylistUniqueId));
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        TInt contentId(aAttrs[i].ContentId());
-        TUint attributeId(aAttrs[i].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            if (attributeId & EMPXMediaGeneralId)
-                {
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId);
-                MPX_DEBUG2("    Playlist ID[%u]", playlistId);
-                }
-            if (attributeId & EMPXMediaGeneralCollectionId)
-                {
-                aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
-                    TUid::Uid(KDBPluginUid));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                TPtrC title(MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistName));
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
-                MPX_DEBUG2("    Title[%S]", &title);
-                }
-            if ((attributeId & EMPXMediaGeneralUri) ||
-                (attributeId & EMPXMediaGeneralDrive) ||
-                (attributeId & EMPXMediaGeneralFlags))
-                {
-                TUint32 volId(aRecord.ColumnInt64(EPlaylistVolumeId));
-                TInt driveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
-
-                // LTAN-7GH6BZ, crash if eject memory card when adding song to existing playlist
-                // due to special timing issue, it is possible drive number is -1 and create a
-                // panic when use for TDriveUnit
-                MPX_DEBUG3("volId = %d, driveId = %d", volId, driveId);
-
-                // handle possibly delay from framework notification
-                if (driveId < 0)
-                    {
-                    MPX_DEBUG1("invalid driveId, leave with KErrNotReady");
-                    User::Leave(KErrNotReady);
-                    }
-
-                TDriveUnit driveUnit(driveId);
-
-                if (attributeId & EMPXMediaGeneralUri)
-                    {
-                    HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(driveUnit,
-                        MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistUri));
-                    CleanupStack::PushL(fullPath);
-                    aMedia.SetTextValueL(KMPXMediaGeneralUri, *fullPath);
-                    MPX_DEBUG2("    URI[%S]", fullPath);
-                    CleanupStack::PopAndDestroy(fullPath);
-                    }
-                if (attributeId & EMPXMediaGeneralDrive)
-                    {
-                    aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveUnit.Name());
-                    }
-                if (attributeId & EMPXMediaGeneralFlags)
-                    {
-                    TUint32 dbFlags(aRecord.ColumnInt64(EPlaylistDbFlag));
-                    TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo;  // 5 bits
-                    aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
-                    }
-                }
-            if (attributeId & EMPXMediaGeneralSynchronized)
-                {
-                aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized,
-                    aRecord.ColumnInt(EPlaylistSync));
-                }
-            if (attributeId & EMPXMediaGeneralCount)
-                {
-                // make sure the PlaylistSongs query is executed after all fields
-                // from the current record have been processed, otherwise the recordset
-                // may point to something else
-                countRequested = ETrue;
-                }
-            if (attributeId & EMPXMediaGeneralDate)
-                {
-                // convert the time from the internal DB string format
-                // to the int64 format used by TTime
-                aMedia.SetTObjectValueL<TInt64>(KMPXMediaGeneralDate,
-                    MPXDbCommonUtil::DesToTTimeL(
-                    MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistTime)).Int64());
-                }
-			if ( attributeId & EMPXMediaGeneralDuration )
-				{		        
-				// make sure the PlaylistSongs query is executed after all fields
-				// from the current record have been processed, otherwise the recordset
-				// may point to something else				
-
-				durationRequested = ETrue;
-				}
-            } // end if contentId == KMPXMediaIdGeneral
-        } // end for
-
-    if (countRequested)
-        {
-		TInt count = iPlaylistSongs->CountL(playlistId);
-        aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
-            count );
-        
-        MPX_DEBUG1("    EMPXMediaGeneralCount");
-		MPX_DEBUG2("	Count[%d]", count);				
-        }
-	if (durationRequested)
-		{
-		TInt duration = iObserver.HandlePlaylistDurationL(playlistId);		
-		aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-		
-		MPX_DEBUG1("    EMPXMediaGeneralDuration");
-		MPX_DEBUG2("	Duration[%d]", duration);				
-		}
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetPlaylistRecordL
-// ----------------------------------------------------------------------------
-//
-RSqlStatement CMPXDbPlaylist::GetPlaylistRecordL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetPlaylistRecordL");
-    return iDbManager.ExecuteSelectQueryL(KQueryPlaylistGet, aPlaylistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DoAddPlaylistL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlaylist::DoAddPlaylistL(
-    const CMPXMedia& aMedia,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DoAddPlaylistL");
-
-    const TDesC& playlistName(aMedia.ValueText(KMPXMediaGeneralTitle));
-    const TDesC& playlistUri(aMedia.ValueText(KMPXMediaGeneralUri));
-
-    TUint32 playlistId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist, playlistUri, EFalse));
-    const CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-    if( !mediaArray )
-        {
-        User::Leave( KErrNoMemory );
-        }
-    // add the songs to the PlaylistSongs table
-    TInt count(mediaArray->Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        iPlaylistSongs->AddSongL(playlistId, i, *mediaArray->AtL(i), aDriveId);
-        }
-
-    // determine the value of DbFlag
-    TUint dbflags(0);
-    if (aMedia.IsSupported(KMPXMediaGeneralFlags))
-        {
-        TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
-        if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit )
-            {
-            // Set flag
-            dbflags |= flag;
-            MPX_DEBUG2("    GeneralFlags[%b]", dbflags);
-            }
-        }
-
-    // add playlist record
-    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
-    HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(playlistName);
-    HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(playlistUri);
-    TPtrC uriPtr(uri->Mid(KMCPathStartPos));
-    TPtrC namePtr(name->Left(KMCMaxTextLen));
-
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistInsert, playlistId, &namePtr,
-        &uriPtr, MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), aDriveId),
-        dbflags, time);
-
-    CleanupStack::PopAndDestroy(uri);
-    CleanupStack::PopAndDestroy(name);
-    CleanupStack::PopAndDestroy(time);
-
-    return playlistId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DoUpdatePlaylistL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DoUpdatePlaylistL(
-    TUint32 aPlaylistId,
-    const CMPXMedia& aMedia,
-    TInt aDriveId,
-    CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DoUpdatePlaylistL");
-
-    // construct the criteria array
-    const TArray<TMPXAttribute> attributes = aMedia.Attributes();
-
-    CDesCArrayFlat* criteriaArray = new (ELeave) CDesCArrayFlat(attributes.Count());
-    CleanupStack::PushL(criteriaArray);
-
-    TInt attrCount(attributes.Count());
-    for (TInt index = 0; index < attrCount; ++index)
-        {
-        TInt contentId(attributes[index].ContentId());
-        TUint attributeId(attributes[index].AttributeId());
-
-        switch(contentId)
-            {
-            case KMPXMediaIdGeneral:
-                {
-                if (attributeId & EMPXMediaGeneralTitle)
-                    {
-                    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTitle,
-                        aMedia.ValueText(KMPXMediaGeneralTitle));
-                    }
-                if (attributeId & EMPXMediaGeneralUri)
-                    {
-                    const TDesC& uri(aMedia.ValueText (KMPXMediaGeneralUri));
-
-                    // determine if we are changing URI of an existing playlist.
-                    // if so, update playlist URI + its Id
-                    TUint32 newId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXPlaylist, uri, EFalse));
-
-                    if (aPlaylistId != newId)
-                        {
-                        aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, newId);
-                        aMessage.SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aPlaylistId);
-
-                        // Change event handling for renaming a playlist should be like a song
-                        // The item focus should goto the new name of the playlist
-                        // to-do: this should be abstracted from the plugin. framework should
-                        //        have enough info to deal with this scenario, if not, add more
-                        //        info in the message passing back to framework
-                        aMessage.SetTObjectValueL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory,
-                            EMPXSong);
-
-                        // update the PlaylistSongs to reflect playlist id change
-                        iPlaylistSongs->UpdateSongsL(aPlaylistId, newId);
-
-                        // this takes care of processing the single quotes in the URI
-                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUri,
-                            uri.Mid(KMCPathStartPos));
-                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistVolumeId,
-                            MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(uri)));
-                        MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistUniqueId,
-                            newId);
-                        }
-                    }
-                if (attributeId & EMPXMediaGeneralSynchronized)
-                    {
-                    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistSync,
-                        aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized));
-                    }
-                }
-                break;
-
-            default:
-                break;
-
-            } // end switch
-        } // end for
-
-    // update the time field to the current time
-    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
-    MPXDbCommonUtil::AddSqlCriterionL(*criteriaArray, KCriterionPlaylistTime, *time);
-    CleanupStack::PopAndDestroy(time);
-
-    // construct a string from all criteria
-    HBufC* criteria = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCCommaSign);
-
-    // execute the query
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistUpdate, criteria, aPlaylistId);
-
-    CleanupStack::PopAndDestroy(criteria);
-    CleanupStack::PopAndDestroy(criteriaArray);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::UpdatePlaylistsForSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::UpdatePlaylistsForSongL(
-    TUint32 aSongId,
-    CMPXMessageArray* aItemChangedMessages, TBool& aSongInPlaylists)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistsForSongL");
-
-    aSongInPlaylists = EFalse;
-    if (aItemChangedMessages)
-        {
-        // get all playlists for the song
-        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistGetForSong, aSongId));
-        CleanupClosePushL(recordset);
-
-        // ignore the errors
-        while (recordset.Next() == KSqlAtRow)
-            {
-            aSongInPlaylists = ETrue;
-            // add item changed messages for all of them
-            MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages,
-                recordset.ColumnInt64(KMPXTableDefaultIndex), EMPXItemModified,
-                EMPXPlaylist, KDBPluginUid);
-            }
-
-        CleanupStack::PopAndDestroy(&recordset);
-        }
-    if (aSongInPlaylists)
-        {
-        // update the time for all playlists that contain this song
-        HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
-        iDbManager.ExecuteQueryL (KDbManagerAllDrives,
-                KQueryPlaylistUpdateTimeForSong, time, aSongId);
-        CleanupStack::PopAndDestroy (time);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::UpdatePlaylistTimeL(
-    TUint32 aPlaylistId,
-    TInt aDrive)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdatePlaylistTimeL");
-
-    HBufC* time = MPXDbCommonUtil::CurrentTimeDesLC();
-    iDbManager.ExecuteQueryL(aDrive, KQueryPlaylistUpdateTime, time, aPlaylistId);
-    CleanupStack::PopAndDestroy(time);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::GetDrivePlaylistDuration
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylist::GetDrivePlaylistDuration(TUint32 /*aPlaylistId*/)
-    {
-    return 0;
-    }
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbPlaylist::CreateTableL");
-
-    // create the table
-    User::LeaveIfError(aDatabase.Exec(KPlaylistCreateTable));
-
-    // create the index on the Name field
-    User::LeaveIfError(aDatabase.Exec(KPlaylistNameIndex));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::DropTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylist::DropTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DropTableL");
-    User::LeaveIfError(aDatabase.Exec(KPlaylistDropTable));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylist::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylist::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbPlaylist::CheckTableL");
-    return DoCheckTable(aDatabase, KPlaylistCheckTable);
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplaylistsongs.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,832 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Responsible for interaction with the PlaylistSongs and
-*                PlaylistSongInfo tables.
-*
-*/
-
-
-// INCLUDE FILES
-#include <f32file.h>
-#include <mpxlog.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxmediageneraldefs.h>
-#include "mpxdbcommonutil.h"
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbutil.h"
-#include "mpxdbpluginqueries.h"
-#include "mpxdbmanager.h"
-#include "mpxdbplaylistsongs.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylistSongs* CMPXDbPlaylistSongs::NewL(
-    CMPXDbManager& aDbManager)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::NewL");
-
-    CMPXDbPlaylistSongs* self = CMPXDbPlaylistSongs::NewLC(aDbManager);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylistSongs* CMPXDbPlaylistSongs::NewLC(
-    CMPXDbManager& aDbManager)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::NewLC");
-
-    CMPXDbPlaylistSongs* self = new (ELeave) CMPXDbPlaylistSongs(aDbManager);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylistSongs::~CMPXDbPlaylistSongs()
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::~CMPXDbPlaylistSongs");
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlaylistSongs::CMPXDbPlaylistSongs(
-    CMPXDbManager& aDbManager) :
-    CMPXDbTable(aDbManager)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::CMPXDbPlaylistSongs");
-    }
-
-// ----------------------------------------------------------------------------
-// Second phase constructor.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::ConstructL()
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::ConstructL");
-    BaseConstructL();
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::AddSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::AddSongsL(
-    TUint32 aPlaylistId,
-    const CMPXMediaArray& aMediaArray,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::AddSongsL");
-
-    TInt count(aMediaArray.Count());
-    for (TInt index = 0; index < count; ++index)
-        {
-        AddSongL(aPlaylistId, *(aMediaArray[index]), aDriveId);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::AddSongL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlaylistSongs::AddSongL(
-    TUint32 aPlaylistId,
-    const CMPXMedia& aMedia,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::AddSongL");
-    return AddSongL(aPlaylistId, CountL(aPlaylistId), aMedia, aDriveId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::AddSongL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlaylistSongs::AddSongL(
-    TUint32 aPlaylistId,
-    TInt aOrdinal,
-    const CMPXMedia& aMedia,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::AddSongL");
-
-    // the UniqueId field is AUTOINCREMENT and its value is going to be generated
-    // automatically by the database - no need to supply it here
-    TUint32 songId((aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2);
-
-    // insert PlaylistSongs record
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsInsert, aPlaylistId, songId, aOrdinal);
-
-    // if the song is not already in the PlaylistSongInfo table - add it
-    if (!SongInfoExistsL(aDriveId, songId))
-        {
-        // add a new song info record
-        HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(aMedia.ValueText(KMPXMediaGeneralUri));
-        HBufC* title = MPXDbCommonUtil::ProcessSingleQuotesLC(aMedia.ValueText(KMPXMediaGeneralTitle));
-
-        TUint32 dbFlag(0);
-        if (aMedia.IsSupported(KMPXMediaGeneralFlags))
-            {
-            dbFlag = (aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
-            dbFlag = dbFlag & (~KMPXMediaGeneralFlagsDriveInfo); // clear drive info
-            }
-
-        // add the URI without the drive letter
-        TPtrC uriPtr(uri->Mid(KMCPathStartPos));
-        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoInsert, songId, &uriPtr, title,
-            MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(*uri)), dbFlag);
-
-        CleanupStack::PopAndDestroy(title);
-        CleanupStack::PopAndDestroy(uri);
-        }
-
-    return songId;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::UpdateSongL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::UpdateSongL(
-    TUint32 aSongId,
-    const CMPXMedia& aMedia,
-    TBool aResetFlags,
-    TBool& aUpdated)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::UpdateSongL");
-
-    aUpdated = EFalse;
-    TBool visibleChange(EFalse);
-
-    // get the current record
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongInfoGet, aSongId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() == KSqlAtRow)
-        {
-        const TArray<TMPXAttribute> attributes = aMedia.Attributes();
-
-        // stores the current song ID, which may change during execution
-        TUint32 songId(aSongId);
-
-        TInt attrCount(attributes.Count());
-        for (TInt i = 0; i < attrCount; ++i)
-            {
-            TInt contentId(attributes[i].ContentId());
-            TUint attributeId(attributes[i].AttributeId());
-
-            switch(contentId)
-                {
-                case KMPXMediaIdGeneral:
-                    {
-                    if (attributeId & EMPXMediaGeneralTitle)
-                        {
-                        // existing title
-                        TPtrC title(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
-
-                        // compare with the old title
-                        if (title.Compare(MPXDbCommonUtil::GetColumnTextL(recordset, EPlaylistSongInfoTitle)) != 0)
-                            {
-                            HBufC* titleProc = MPXDbCommonUtil::ProcessSingleQuotesLC(title);
-
-                            // title has changed - update on all drives
-                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdateTitle,
-                                titleProc, songId);
-
-                            CleanupStack::PopAndDestroy(titleProc);
-
-                            visibleChange = ETrue;
-                            aUpdated = ETrue;
-                            MPX_DEBUG2("    Title[%S]", &title);
-                            }
-                        }
-
-                    if (attributeId & EMPXMediaGeneralUri)
-                        {
-                        const TDesC& uriOrig(aMedia.ValueText(KMPXMediaGeneralUri));
-                        songId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, uriOrig, EFalse);
-
-                        if (aSongId != songId)
-                            {
-                            // URI of the song has been changed. This changes the Id of the song and both the
-                            // PlaylistSongs and PlaylistSongInfo tables should be updated accordingly.
-
-                            HBufC* uri = MPXDbCommonUtil::ProcessSingleQuotesLC(uriOrig);
-
-                            // use the URI without the drive letter
-                            TPtrC uriPtr(uri->Mid(KMCPathStartPos));
-
-                            // update the PlaylistSongInfo table on all drives
-                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdate, songId,
-                                &uriPtr, MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), TDriveUnit(*uri)), aSongId);
-
-                            // update the PlaylistSongs table on all drives
-                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdate, songId,
-                                aSongId);
-
-                            aUpdated = ETrue;
-                            MPX_DEBUG3("    CurrentSongId[0x%x] changed to [0x%x]", aSongId, songId);
-
-                            CleanupStack::PopAndDestroy(uri);
-                            }
-                        }
-
-                    if (attributeId & EMPXMediaGeneralFlags)
-                        {
-                        TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags));
-                        TUint32 curFlag(recordset.ColumnInt64(EPlaylistSongInfoDbFlag));
-
-                        if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit)
-                            {
-                            if (aResetFlags)
-                                {
-                                visibleChange = ETrue;
-                                curFlag = flag;
-                                }
-                            else
-                                {
-                                // Set flag, visible change is true only if the flag status is changing
-                                visibleChange = visibleChange || ((curFlag^flag) & 0x7FFFFFFF);
-                                curFlag |= flag;
-                                }
-                            }
-                        else
-                            {
-                            // Clear flag, visible change is true only if the flag status is changing
-                            visibleChange = visibleChange || (((curFlag^0xFFFFFFFF)^flag) & 0x7FFFFFFF);
-                            curFlag &= (~flag);
-                            }
-
-                        if (visibleChange)
-                            {
-                            // update the flags on all drives
-                            iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoUpdateFlags,
-                                curFlag, songId);
-                            aUpdated = ETrue;
-                            }
-
-                        MPX_DEBUG2("    GeneralFlags[%b]", curFlag);
-                        }
-                    } // end case
-                } // end switch
-            } // end for
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-    return visibleChange;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::UpdateSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::UpdateSongsL(
-    TUint32 aPlaylistId,
-    TUint32 aNewPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::UpdateSongsL");
-
-    // update the PlaylistSongs table on all drives
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdatePlaylistId,
-        aNewPlaylistId, aPlaylistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::ReorderSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::ReorderSongL(
-    const TMPXItemId& aPlaylistId,
-    const TMPXItemId& aSongId,
-    TUint aOriginalOrdinal,
-    TUint aNewOrdinal)
-    {
-    MPX_DEBUG1("-->CMPXDbPlaylistSongs::ReorderSongL");
-    MPX_DEBUG5("    playlist[0x%x, 0x%x], song[0x%x, 0x%x]",
-               aPlaylistId.iId1, aPlaylistId.iId2, aSongId.iId1, aSongId.iId2);
-
-    //
-    // Move the song up. The rest of the songs in between the old ordinal and new ordinal
-    // need to be moved down, i.e. their ordinals need to be incremented
-    //
-    if (aOriginalOrdinal > aNewOrdinal)
-        {
-        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsMoveSongUp,
-            aPlaylistId.iId2, aNewOrdinal, aOriginalOrdinal);
-        }
-
-    //
-    // Move the song down. The rest of the songs in between the old ordinal and new ordinal
-    // need to be moved up, i.e. their ordinals need to be decremented
-    //
-    else if (aOriginalOrdinal < aNewOrdinal)
-        {
-        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsMoveSongDown,
-            aPlaylistId.iId2, aNewOrdinal, aOriginalOrdinal);
-        }
-
-    //
-    // Change the ordinal of the song itself. If the ordinal is unchanged, no update is
-    // required
-    //
-    if (aOriginalOrdinal != aNewOrdinal)
-        {
-        iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsUpdateSongOrdinal,
-            aNewOrdinal, aSongId.iId1);
-        }
-
-    MPX_DEBUG1("<--CMPXDbPlaylistSongs::ReorderSongL");
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteSongL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::DeleteSongL");
-
-    // delete from the PlaylistSongs table on all drives
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsDelete, aSongId);
-
-    // delete from the PlaylistSongInfo table on all drives
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoDelete, aSongId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteSongL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteSongL(
-    TUint32 aPlaylistId,
-    TUint32 aSongId,
-    TInt aOrdinal,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongL");
-
-    // get the number of instances for the song in the playlist
-    TInt count(SongInstanceCountL(aPlaylistId, aSongId));
-
-    if (1 == count)
-        {
-        // just one instance with this ID in the playlist
-        // delete it regardless of the ordinal
-        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteSong, aPlaylistId, aSongId);
-
-        // check how many instances of this song are left for all playlists
-        if (!SongCountL(aSongId))
-            {
-            // delete the PlaylistSongInfo record
-            iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoDelete, aSongId);
-            }
-        }
-    else if (count > 1)
-        {
-        // multiple songs with this id in the playlist
-        // try to delete the one with the specified ordinal
-        iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteSongOrdinal, aPlaylistId,
-            aSongId, aOrdinal);
-        }
-    else
-        {
-        // no such song in the playlist
-        User::Leave(KErrCorrupt);
-        }
-    // adjust song ordinals for the songs after the deleted song
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsUpdateSongOrdinalAfterDelete,
-        aPlaylistId, aOrdinal);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteSongsL(
-    TUint32 aPlaylistId,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongsL");
-
-    // delete the records from the PlaylistSongs table
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeletePlaylist, aPlaylistId);
-
-    // delete the unused records from the PlaylistSongInfo table
-    CleanupSongInfoL(aDriveId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteSongsForCategoryL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteSongsForCategoryL(
-    TMPXGeneralCategory aCategory,
-    TUint32 aCategoryId,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongsForCategoryL");
-
-    // get the category field name in the Music table
-    TPtrC category = MPXDbUtil::MusicFieldNameForCategoryL(aCategory);
-
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteForCategory,
-        &category, aCategoryId);
-
-    // delete the unused records from the PlaylistSongInfo table
-    CleanupSongInfoL(aDriveId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteSongsForArtistAndAlbumL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteSongsForArtistAndAlbumL(
-    TUint32 aArtistId,
-    TUint32 aAlbumId,
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteSongsForArtistAndAlbumL");
-
-    // delete the songs in the PlaylisSongs table
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongsDeleteForArtistAlbum,
-        aArtistId, aAlbumId);
-
-    // delete the unused records from the PlaylistSongInfo table
-    CleanupSongInfoL(aDriveId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DeleteAllSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DeleteAllSongsL()
-    {
-    MPX_FUNC("CMPXDbPlaylist::DeleteAllSongsL");
-
-    // delete all records from the PlaylistSongs table, all drives
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongsDeleteAll);
-
-    // delete all records from the PlaylistSongInfo table, all drives
-    iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryPlaylistSongInfoDeleteAll);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::GetSongsL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::GetSongsL(
-    TUint32 aPlaylistId,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_DEBUG2("-->CMPXDbPlaylistSongs::GetSongsL(playlist 0x%x)", aPlaylistId);
-
-    RArray<TMPXAttribute> attributes;
-    CleanupClosePushL( attributes );
-
-    attributes.AppendL(KMPXMediaGeneralType);
-    attributes.AppendL(KMPXMediaGeneralCategory);
-    attributes.AppendL(KMPXMediaGeneralId);
-    
-    // cannot execute a joined query to the music table
-    // because the song records in the music table may be on a different drive
-    ExecuteMediaQueryL(attributes.Array(), aMediaArray, KQueryPlaylistSongsGetSongs, aPlaylistId);
-
-    CleanupStack::PopAndDestroy(&attributes);
-
-    MPX_DEBUG1("<--CMPXDbPlaylistSongs::GetSongsL");
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::GetSongsL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::GetSongsL(
-    TUint32 aPlaylistId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_DEBUG2("-->CMPXDbPlaylistSongs::GetSongsL(playlist 0x%x)", aPlaylistId);
-    TBool valid(EFalse);
-    
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSongsInfo,
-    		aPlaylistId));
-    CleanupClosePushL(recordset);
-
-    TInt err(KErrNone);
-    while ((err = recordset.Next()) == KSqlAtRow)
-        {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-
-        UpdateMediaL(recordset, aAttrs, *media);
-
-        aMediaArray.AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-        }
-    CleanupStack::PopAndDestroy(&recordset);
-
-    if (err!= KSqlAtEnd)
-        {
-        User::Leave(KErrCorrupt);
-        }
-    else
-    	{
-    	valid = ETrue;
-    	}
-
-    MPX_DEBUG1("<--CMPXDbPlaylistSongs::GetSongsL");
-    return valid;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::GetSongL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::GetSongL(
-    TUint32 aPlaylistId,
-    TUint32 aSongId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetSongL");
-
-    // get the song
-    TBool valid(EFalse);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSong,
-        aPlaylistId, aSongId));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() == KSqlAtRow)
-        {
-        // convert to media
-        UpdateMediaL(recordset, aAttrs, aMedia);
-        valid = ETrue;
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return valid;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::GetSongL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::GetSongL(
-    const TMPXItemId& aSongId,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia*& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::GetSongL");
-
-    // get the song
-    TBool valid(EFalse);
-    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPlaylistSongsGetSongInfo,
-        aSongId.iId1, aSongId.iId2));
-    CleanupClosePushL(recordset);
-
-    if (recordset.Next() == KSqlAtRow)
-        {
-        // convert to media
-        aMedia = CMPXMedia::NewL();
-        CleanupStack::PushL(aMedia);
-        UpdateMediaL(recordset, aAttrs, *aMedia);
-        CleanupStack::Pop(aMedia);
-        valid = ETrue;
-        }
-
-    CleanupStack::PopAndDestroy(&recordset);
-
-    return valid;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::CountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylistSongs::CountL(
-    TUint32 aPlaylistId)
-    {
-    MPX_FUNC("CMPXDbPlaylist::CountL");
-    return ExecuteSumQueryL(KQueryPlaylistSongsCount, aPlaylistId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::UpdateMediaL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::UpdateMediaL(
-    RSqlStatement& aRecord,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlaylist::UpdateMediaL");
-
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-    aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(
-        aRecord.ColumnInt64(EPlaylistSongsUniqueId),
-        aRecord.ColumnInt64(EPlaylistSongsSongId)));
-
-/*
-    aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
-        aRecord.ColumnInt64(EPlaylistSongsSongId));
-*/
-    TInt count(aAttrs.Count());
-    for (TInt index = 0; index < count; ++index)
-        {
-        TInt contentId(aAttrs[index].ContentId());
-        TUint attributeId(aAttrs[index].AttributeId());
-
-        if (contentId == KMPXMediaIdGeneral)
-            {
-            if (attributeId & EMPXMediaGeneralCollectionId)
-                {
-                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralCollectionId,
-                    aRecord.ColumnInt64(EPlaylistSongsPlaylistId));
-                }
-            if (attributeId & EMPXMediaGeneralTitle)
-                {
-                TPtrC title(MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistSongsTitle));
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle, title);
-                MPX_DEBUG2("    Title[%S]", &title);
-                }
-            if (attributeId & EMPXMediaGeneralUri)
-                {
-                TUint volId(aRecord.ColumnInt64(EPlaylistSongsVolumeId));
-                HBufC* uri = MPXDbCommonUtil::CreateFullPathL(
-                    MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId),
-                    MPXDbCommonUtil::GetColumnTextL(aRecord, EPlaylistSongsUri));
-                CleanupStack::PushL(uri);
-
-                aMedia.SetTextValueL(KMPXMediaGeneralUri, *uri);
-
-                MPX_DEBUG2("    URI[%S]", uri);
-                CleanupStack::PopAndDestroy(uri);
-                }
-            if (attributeId & EMPXMediaGeneralFlags)
-                {
-                // assuming song details shouldn't be available for this song
-                TUint32 dbFlags(aRecord.ColumnInt64(EPlaylistSongsDbFlag) |
-                                KMPXMediaGeneralFlagsIsMissingDetails);
-                TUint32 volId(aRecord.ColumnInt64(EPlaylistSongsVolumeId));
-                TDriveUnit driveUnit(EDriveC);
-                if (aMedia.IsSupported(KMPXMediaGeneralUri))
-                    {
-                    // ignore the return value
-                    MPXDbCommonUtil::GetDriveL(aMedia.ValueText(KMPXMediaGeneralUri), driveUnit);
-                    }
-                else
-                    {
-                    driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId);
-                    }
-
-                // the volume the playlist song is located on may be removed
-                if (~dbFlags & KMPXMediaGeneralFlagsIsInvalid)
-                    {
-                    if (((volId != 0) && (MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId) == KErrNotFound)) ||
-                        ((volId == 0) && (MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit) == 0)))
-                        {
-                        dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
-                        }
-                    }
-
-                TInt driveId(driveUnit & KMPXMediaGeneralFlagsDriveInfo);  // 5 bits
-                aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId);
-                MPX_DEBUG2("    GeneralFlags[%b]", dbFlags | driveId);
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::SongInstanceCountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylistSongs::SongInstanceCountL(
-    TUint32 aPlaylistId,
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::SongInstanceCountL");
-    return ExecuteSumQueryL(KQueryPlaylistSongsPlaylistSongCount, aPlaylistId, aSongId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::SongCountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlaylistSongs::SongCountL(
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::SongCountL");
-    return ExecuteSumQueryL(KQueryPlaylistSongsSongCount, aSongId);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::SongInfoExistsL
-// The song info record must be in the same database as the corresponding
-// PlaylistSongs record(s), otherwise when adding a duplicate of a song on a
-// different drive this method will return true and the song info record won't
-// be created.
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::SongInfoExistsL(
-    TInt aDriveId,
-    TUint32 aSongId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::SongInfoExistsL");
-
-    RSqlStatement recordset(
-        iDbManager.ExecuteSelectQueryL(aDriveId, KQueryPlaylistSongInfoExists, aSongId));
-    TBool exists(recordset.Next() == KSqlAtRow);
-    recordset.Close();
-    return exists;
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::CleanupSongInfoL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::CleanupSongInfoL(
-    TInt aDriveId)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::CleanupSongInfoL");
-    iDbManager.ExecuteQueryL(aDriveId, KQueryPlaylistSongInfoCleanup);
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::CreateTableL(
-    RSqlDatabase& aDatabase,
-    TBool /* aCorruptTable */)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::CreateTableL");
-
-    // create the PlaylistSongs table
-    User::LeaveIfError(aDatabase.Exec(KPlaylistSongsCreateTable));
-
-    // create the PlaylistSongInfo table
-    User::LeaveIfError(aDatabase.Exec(KPlaylistSongInfoCreateTable));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::DropTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlaylistSongs::DropTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::DropTableL");
-
-    // drop the PlaylistSongs table
-    User::LeaveIfError(aDatabase.Exec(KPlaylistSongsDropTable));
-
-    // drop the PlaylistSongInfo table
-    User::LeaveIfError(aDatabase.Exec(KPlaylistSongInfoDropTable));
-    }
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlaylistSongs::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlaylistSongs::CheckTableL(
-    RSqlDatabase& aDatabase)
-    {
-    MPX_FUNC("CMPXDbPlaylistSongs::CheckTableL");
-
-    // check the PlaylistSongs table
-    TBool check = DoCheckTable(aDatabase, KPlaylistSongsCheckTable);
-
-    // check the PlaylistSongInfo table
-    return check && DoCheckTable(aDatabase, KPlaylistSongInfoCheckTable);
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbplugin.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4406 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of collection DB Plugin interface
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32cmn.h>
-#include <StringLoader.h>
-#include <bautils.h>
-#include <data_caging_path_literals.hrh>
-
-#include <mpxcmn.h>
-#include <mpxuser.h>
-#include <mpxcollectionpluginobserver.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxmediaaudiodefs.h>
-#include <mpxmediacollectiondetaildefs.h>
-#include <mpxcommandgeneraldefs.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxmessagecontainerdefs.h>
-#include <mpxcollectioncommanddefs.h>
-#include <mpxcollectionmessagedefs.h>
-#include <mpxincrementalopendefs.h>
-#include <mpxcollectionopenlresultdef.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxdrmmediautility.h>
-#include <mpxmediadrmdefs.h>
-#include <mpxlog.h>
-#include <mpxcollectiondbres.rsg>
-//#include <mpxdbplugin.mbg>	// commented out when migrate to HB
-#include <centralrepository.h>
-
-#ifdef RD_MULTIPLE_DRIVE
-#include <driveinfo.h>
-#endif //RD_MULTIPLE_DRIVE
-
-#include "mpxresource.h"
-#include "mpxdbcommondef.h"
-#include "mpxdbcommonutil.h"
-
-#include "mpxdbhandler.h"
-#include "mpxdbutil.h"
-#include "mpxcollectiondbdef.h"
-#include "mpxdbplugin.h"
-
-// CONSTANTS
-const TInt KFirstFetchCount = 400;
-
-const TUid KCRUIDMusicPlayerFeatures = { 0x101FFCD0 };
-const TInt KMusicPlayerFeatures = 1;
-const TInt KDisablePodcasting = 0x80;
-
-const TInt KIncrementalDeleteCount = 400;
-
-const TInt KSQLErrGeneral = -311; // SQL General error. Don't want to include sql header here
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlugin* CMPXDbPlugin::NewL(
-    TAny* /*aInitParams*/)
-    {
-    MPX_FUNC("CMPXDbPlugin::NewL");
-
-    CMPXDbPlugin* self = new (ELeave) CMPXDbPlugin();
-    CleanupStack::PushL (self);
-    self->ConstructL ();
-    CleanupStack::Pop (self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlugin::~CMPXDbPlugin()
-    {
-    MPX_FUNC("CMPXDbPlugin::~CMPXDbPlugin");
-
-    iSelections.Reset();
-    iSelections.Close();
-    iFs.Close();
-    delete iDbHandler;
-    delete iDrmMediaUtility;
-    if (iResource)
-        {
-        iResource->Release();
-        }
-    iMusicLibraryMenuIds.Close();
-    delete iMusicLibraryMenuTitles;
-    delete iMusicLibraryTitles;
-    delete iAllSongsForArtistTitle;
-    delete iMusicMenuTitle;
-
-    if (iActiveTask)
-        {
-        iActiveTask->Cancel();
-        delete iActiveTask;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor.
-// ----------------------------------------------------------------------------
-//
-CMPXDbPlugin::CMPXDbPlugin()
-    {
-    MPX_FUNC("CMPXDbPlugin::CMPXDbPlugin");
-    }
-
-// ----------------------------------------------------------------------------
-// Symbian 2nd phase constructor can leave.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::ConstructL()
-    {
-    MPX_FUNC("CMPXDbPlugin::ConstructL");
-    iFirstDeleteStep = ETrue;
-    User::LeaveIfError(iFs.Connect());
-    iDrmMediaUtility = CMPXDrmMediaUtility::NewL();
-
-    TParse parse;
-    parse.Set( KMPXCollectionDbResourceFile, &KDC_APP_RESOURCE_DIR, NULL );
-    TFileName resFile(parse.FullName());
-    User::LeaveIfError(MPXUser::CompleteWithDllPath(resFile));
-    BaflUtils::NearestLanguageFile(iFs, resFile);
-    iResource = CMPXResource::NewL(resFile);
-
-    iDbHandler = CMPXDbHandler::NewL(iFs, *iResource);
-    iMusicLibraryMenuTitles = iResource->ReadMenuArrayL(R_MC_MENU_ITEMS_ARRAY, iMusicLibraryMenuIds);
-    iMusicLibraryTitles = iResource->ReadMenuArrayL(R_MC_TITLE_ITEMS_ARRAY, iMusicLibraryMenuIds );
-    iAllSongsForArtistTitle = iResource->ReadHBufCL(R_MC_ALL_SONGS_FOR_ARTIST);
-
-#ifdef __ENABLE_MUSIC_TEXT_ALIGNMENT
-    iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_MY_MUSIC_MENU_NSERIES);
-#else
-    iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MUS_TITLE_MUSIC_MENU);
-#endif // __ENABLE_MUSIC_TEXT_ALIGNMENT
-
-    iActiveTask = CMPXDbActiveTask::NewL(*this);
-
-    CRepository* cenrep(NULL);
-    TRAPD( err, cenrep = CRepository::NewL( KCRUIDMusicPlayerFeatures ) );
-    if( err == KErrNone )
-        {
-        TInt val(0);
-        cenrep->Get( KMusicPlayerFeatures, val );
-        iDisablePodcasting = val&KDisablePodcasting ? ETrue:EFalse;
-        delete cenrep;
-        }
-    else
-        {
-        iDisablePodcasting = EFalse;
-        }
-    iAllSongsValid = ETrue;
-    }
-
-// ----------------------------------------------------------------------------
-// Navigates to the given path
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::OpenL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& /*aAttrs*/,
-    CMPXFilter* aFilter)
-    {
-    MPX_FUNC("CMPXDbPlugin::OpenL");
-    MPX_DEBUG_PATH(aPath);
-    //Create a path object to be returned.
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
-    CleanupStack::PushL(path);
-    RArray<TMPXAttribute> openAttrs;
-    CleanupClosePushL(openAttrs);
-
-    RArray<TInt> supportedIds;
-    CleanupClosePushL(supportedIds);
-
-    // Replace the attributes requested by the client with the ones below.
-    // This will eventually have to be fixed
-    SetAttributesL(aPath, openAttrs, supportedIds);
-
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    //Add returned path into media
-    entries->SetTObjectValueL<TInt>(KMPXMediaGeneralValue, (TInt)path);
-
-    TInt error(KErrNone);
-    TBool isASong(EFalse);
-    CMPXCollectionPath* newPath(NULL);
-
-    // Make sure we handle open the correct open mode
-    //
-    TMPXOpenMode openmode = aPath.OpenNextMode();
-    switch (openmode)
-        {
-        case EMPXOpenGroupOrPlaylist:
-            {
-            // Open By Path
-            MPX_TRAP(error, isASong = DoOpenL(aPath, openAttrs.Array(), *entries, aFilter));
-            break;
-            }
-
-        case EMPXOpenPlaylistOnly:
-            {
-            if (aPath.Count() > 0)
-                {
-                // Try to open
-                MPX_TRAP(error, newPath = DoOpenPlaylistL(aPath, openAttrs.Array()));
-                CleanupStack::PushL(newPath);
-                isASong = ETrue;
-                }
-            else // no items
-                {
-                MPX_TRAP(error, isASong = DoOpenL(aPath, openAttrs.Array(), *entries, aFilter));
-                }
-
-            break;
-            }
-
-        default:
-            // do nothing
-            break;
-        }
-
-    // generate the callback
-    if (isASong )
-        {
-        if (openmode == EMPXOpenGroupOrPlaylist)
-            {
-            iObs->HandleOpen(const_cast<CMPXCollectionPath*>(&aPath), error);
-            }
-        else  // openmode == EMPXOpenPlaylistOnly
-            {
-            iObs->HandleOpen(newPath, error);
-            }
-        }
-    else
-        {
-        entries->SetCObjectValueL(KMPXMediaGeneralContainerPath,
-            const_cast<CMPXCollectionPath*>(&aPath));
-        entries->Delete(KMPXMediaGeneralValue);
-        iObs->HandleOpen(entries, path, error);
-        }
-
-    if (newPath)
-        {
-        CleanupStack::PopAndDestroy(newPath);
-        }
-
-    CleanupStack::PopAndDestroy(entries);
-    CleanupStack::PopAndDestroy(&openAttrs);
-    CleanupStack::PopAndDestroy(path);
-    }
-
-// ----------------------------------------------------------------------------
-// Get the extended properties of the current file (async)
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::MediaL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    const TArray<TCapability>& /*aCaps*/,
-    CMPXAttributeSpecs* /*aSpecs*/)
-    {
-    MPX_FUNC("CMPXDbPlugin::MediaL");
-    MPX_DEBUG_PATH(aPath);
-
-    RArray<TInt> supportedIds;
-    CleanupClosePushL(supportedIds);
-    if (aPath.Selection().Count())
-        {
-        // it's a container if there are multiple selection, else it's not a container
-        supportedIds.AppendL(KMPXMediaIdContainer);
-        }
-    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
-
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-
-    DoMediaL(aPath, aAttrs, *entries);
-
-    // Also fetch collection details and set the path if required
-    DoHandleOtherMediaAttributesL(aAttrs, aPath, *entries);
-
-    iObs->HandleMedia(entries, KErrNone);
-    CleanupStack::PopAndDestroy(entries);
-    }
-
-// ----------------------------------------------------------------------------
-// Cancel outstanding request
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::CancelRequest()
-    {
-    MPX_FUNC("CMPXDbPlugin::CancelRequest");
-    iActiveTask->Cancel();
-    }
-
-// ----------------------------------------------------------------------------
-// Executes the given command on the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::CommandL(
-    TMPXCollectionCommand aCmd,
-    TInt aArg /* = 0 */)
-    {
-    MPX_FUNC("CMPXDbPlugin::CommandL");
-    MPX_DEBUG2("CMPXDbPlugin::CommandL %d", aCmd);
-    iAllSongsValid = ETrue;
-    switch (aCmd)
-        {
-        case EMcCmdRemoveAll:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdRemoveAll");
-            // Remove EVERYthing from the collection
-            iDbHandler->RemoveEntireCollectionL();
-            break;
-            }
-        case EMcCmdClose:
-        case EMcCloseCollection:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCloseCollection");
-            // Close the specified database
-            TRAP_IGNORE(iDbHandler->PreCloseCollectionL());
- #ifdef RD_MULTIPLE_DRIVE
-            MPX_DEBUG1("Multiple drives closing databases");
-            if ( aArg <0)
-                {
-                DriveInfo::TDriveArray driveArray;
-                User::LeaveIfError ( DriveInfo::GetUserVisibleDrives( iFs, driveArray));
-                TInt count( driveArray.Count ());
-                for (TInt i=0; i<count; ++i)
-                    {
-                    MPX_DEBUG2("At drive %i", driveArray[i]);
-                    if (( driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
-                        {
-                        MPX_DEBUG2("Closing database %i", driveArray[i]);
-                        TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) );
-                        }
-                    }
-                }
-            else
-                {
-                iDbHandler->CloseDatabaseL(aArg);
-                }
- #else
-            iDbHandler->CloseDatabaseL(aArg);
- #endif // RD_MULTIPLE_DRIVE
-            iDbHandler->CollectionClosed();
-            break;
-            }
-        case EMcReOpenCollection:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcReOpenCollection");
-            // Open the specified database
-#ifdef RD_MULTIPLE_DRIVE
-            MPX_DEBUG1("Multiple drives opening databases");
-            DriveInfo::TDriveArray driveArray;
-            User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) );
-            TInt count( driveArray.Count() );
-            for( TInt i=0; i<count; ++i )
-                {
-                MPX_DEBUG2("At drive %i", driveArray[i]);
-                if( (driveArray[i] != EDriveC)  && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) 
-                    {
-                    TUint driveStatus(0);
-                    User::LeaveIfError( DriveInfo::GetDriveStatus(
-                        iFs, driveArray[i], driveStatus ) );
-                    if( driveStatus & DriveInfo::EDrivePresent )
-                        {
-                        MPX_DEBUG2("Opening database %i", driveArray[i]);
-                        TRAP_IGNORE( iDbHandler->OpenDatabaseL( driveArray[i] ) );
-                        }
-                    }
-                }
-#else
-            iDbHandler->OpenDatabaseL(aArg);
-#endif // RD_MULTIPLE_DRIVE
-            TRAP_IGNORE(iDbHandler->CollectionOpenedL());
-            break;
-            }
-        case EMcRefreshStarted:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcRefreshStarted");
-            iDbHandler->CheckDiskSpaceOnDrivesL();
-            // ask the handler to start a transaction
-            iDbHandler->RefreshStartL();
-            iRefreshing=ETrue;
-            break;
-            }
-        case EMcRefreshEnded:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcRefreshEnded");
-            iDbHandler->CheckDiskSpaceOnDrivesL();
-            // ask the handler to finalize the transaction
-            iDbHandler->RefreshEndL();
-            iRefreshing=EFalse;
-            break;
-            }
-         case EMcCmdReCreateDB:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdReCreateDB");
-            // Recreate all databases
-            iDbHandler->ReCreateDatabasesL();
-            break;
-            }
-         case EMcCmdDbCorrupted:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCmdDbCorrupted");
-            iDbHandler->SetDBCorruptedL(ETrue);
-            break;
-            }
-        case EMcCmdRefresh:
-        case EMcCmdCollectionInit:
-        case EMcCmdCollectionResyn:
-            {
-            // deprecated
-            break;
-            }
-        case EMcCmdMtpStart:
-            iDbHandler->CheckDiskSpaceOnDrivesL();
-            iMtpInUse = ETrue;
-            iDbHandler->MtpStartL();            
-            break;
-        case EMcCmdMtpEnd:
-            iDbHandler->CheckDiskSpaceOnDrivesL();
-            iMtpInUse = EFalse;
-            iDbHandler->MtpEndL();            
-            break;
-         default:
-            {
-            User::Leave(KErrNotSupported);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Executes the given command on the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::CommandL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::CommandL");
-
-    if (!aCmd.IsSupported(KMPXCommandGeneralId))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    TMPXCommandId commandId = aCmd.ValueTObjectL<TMPXCommandId>(KMPXCommandGeneralId);
-
-    TBool syncOp(EFalse);
-    if (aCmd.IsSupported(KMPXCommandGeneralDoSync))
-        {
-        syncOp = aCmd.ValueTObjectL<TBool>(KMPXCommandGeneralDoSync);
-        }
-
-    // Handle this operation synchronously or asynchronously
-    //
-    if (!syncOp)
-        {
-        iActiveTask->StartL(commandId, aCmd);
-        }
-    else  // Sync operation
-        {
-        switch (commandId)
-            {
-            case KMPXCommandIdCollectionRetrieveUriForDeletion:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRetrieveUriForDeletion");
-                DoRetrieveUriForDeletionL(aCmd);
-                break;
-                }
-            case KMPXCommandIdCollectionRemove:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRemove");
-                if ( !iDbHandler->InTransaction() )
-                    {
-                    iDbHandler->BeginTransactionL();
-                    }
-
-                if (iFirstDeleteStep )
-                    {
-                    iFirstDeleteStep = EFalse;
-                    }
-                DoRemovePathL(aCmd);
-                break;
-                }
-            case KMPXCommandIdCollectionRemoveMedia:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionRemoveMedia");
-                DoRemoveMediaL(aCmd);
-                break;
-                }
-            case KMPXCommandIdCollectionCleanupDeletedMedias:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionCleanupDeletedMedias");
-                CleanupDeletedRecordsL(aCmd);
-                break;
-                }
-            case KMPXCommandIdCollectionAdd:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectioAdd");
-                CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColAddMedia);
-                User::LeaveIfNull( media );
-                TUint32 id(DoAddL(*media));
-                aCmd.SetTObjectValueL<TMPXItemId>(KMPXCommandColAddRtnId, id);
-                break;
-                }
-            case KMPXCommandIdCollectionSet:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionSet");
-                CMPXMedia* media = aCmd.Value<CMPXMedia>(KMPXCommandColSetMedia);
-                User::LeaveIfNull( media );
-                DoSetL(*media);
-                break;
-                }
-            case KMPXCommandIdCollectionCompleteDelete:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdCollectionCompleteDelete");
-                DoHandleDeleteCompleteL(aCmd);
-                break;
-                }
-            case KMPXCommandIdReorderPlaylist:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdReorderPlaylist");
-                DoReorderPlaylistL(aCmd);
-                break;
-                }
-            case KMPXCommandIdUpdateRefreshTime:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime");
-                TTime curTime;
-                curTime.HomeTime();
-                iDbHandler->SetLastRefreshedTimeL(curTime);
-                break;
-                }
-            case KMPXCommandCollectionGetCount:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandCollectionGetCount");
-                DoGetCollectionCountL(aCmd);
-                break;
-                }
-            case KMPXCommandCollectionGetURIs:
-                {
-                MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandCollectionGetURIs");
-                DoGetCollectionUriL(aCmd);
-                break;
-                }
-            default:
-                {
-                User::Leave(KErrNotSupported);
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Adds an item (song or playlist) to the collection
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::AddL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlugin::AddL");
-    DoAddL(aMedia);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove an item from the collection database using the given path
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::RemoveL(
-    const CMPXCollectionPath& aPath)
-    {
-    MPX_FUNC("CMPXDbPlugin::RemoveL(by path)");
-    MPX_DEBUG_PATH(aPath);
-
-    CMPXMessageArray* msgAry = CMPXMessageArray::NewL();
-    CleanupStack::PushL(msgAry);
-
-    // Return file path for deleted item(s)
-    CDesCArray* fp = DoRemoveL(aPath, *msgAry);
-
-    iObs->HandleRemove(*fp, KErrNone);
-    delete fp;
-
-    // Send Change Messages
-    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-    DoHandleChangeL(msgAry);
-    CleanupStack::PopAndDestroy(msgAry);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove an item from the collection database using the given media properties
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::RemoveL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlugin::RemoveL(by media)");
-    DoRemoveL(aMedia, EFalse);
-    }
-
-// ----------------------------------------------------------------------------
-// Sets/updates the media for an item in the collection
-// DEPRECATED for week 18
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::SetL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlugin::SetL");
-    DoSetL(aMedia);
-    }
-
-// ----------------------------------------------------------------------------
-// Find the items matching the media specifications
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::FindAllL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbPlugin::FindAllL");
-
-    CMPXMedia* entries = FindAllSyncL(aCriteria, aAttrs);
-
-    // notify client. if FindAllL leaves, framework will notify client of the error
-    iObs->HandleFindAll(entries, KErrNone);
-    delete entries;
-    }
-
-// ----------------------------------------------------------------------------
-// Find the items matching the media specifications
-// ----------------------------------------------------------------------------
-//
-CMPXMedia* CMPXDbPlugin::FindAllSyncL(
-    const CMPXMedia& aCriteria,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbPlugin::FindAllSyncL");
-
-    CMPXMedia* entries = iDbHandler->FindAllLC(aCriteria, aAttrs);
-
-    if (entries)
-        {
-        CMPXMediaArray* ary = entries->Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        User::LeaveIfNull( ary );
-        DoSetDrmForArrayL( *ary, aAttrs );
-        }
-
-    CleanupStack::Pop(entries);
-    return entries;
-    }
-
-// ----------------------------------------------------------------------------
-// Get the list of supported capabilities
-// ----------------------------------------------------------------------------
-//
-TCollectionCapability CMPXDbPlugin::GetCapabilities()
-    {
-    // This one supports simple search
-    return EMcSearch;
-    }
-
-// ----------------------------------------------------------------------------
-// Get the list of supported capabilities
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::HandleStepL()
-    {
-    MPX_FUNC("CMPXDbPlugin::HandleStepL");
-
-    TBool done(ETrue);
-
-    switch (iActiveTask->GetTask())
-        {
-        case KMPXCommandIdCollectionSet:
-            {
-            done = DoSetAsyncL();
-            break;
-            }
-        case KMPXCommandIdCollectionAdd:
-            {
-            done = DoAddAsyncL();
-            break;
-            }
-        case KMPXCommandIdCollectionRemove:
-            {
-            DoRemovePathL(iActiveTask->GetCommand());
-            done = ETrue;
-            break;
-            }
-        case KMPXCommandIdCollectionRemoveMedia:
-            {
-            DoRemoveMediaL(iActiveTask->GetCommand());
-            done = ETrue;
-            break;
-            }
-        case KMPXCommandIdCollectionRetrieveUriForDeletion:
-            {
-            DoRetrieveUriForDeletionL(iActiveTask->GetCommand());
-            done = ETrue;
-            break;
-            }
-        case KMPXCommandIdCollectionCleanupDeletedMedias:
-            {
-            CleanupDeletedRecordsL(iActiveTask->GetCommand());
-            done = ETrue;
-            break;
-            }
-        case KMPXCommandIdCollectionCompleteDelete:
-            {
-            DoHandleDeleteCompleteL( iActiveTask->GetCommand() );
-            break;
-            }
-        case KMPXCommandIdUpdateRefreshTime:
-            {
-            MPX_DEBUG1("CMPXDbPlugin::CommandL - KMPXCommandIdUpdateRefreshTime");
-            TTime curTime;
-            curTime.HomeTime();
-            iDbHandler->SetLastRefreshedTimeL(curTime);
-            break;
-            }
-        case KMPXCommandIdIncrementalOpenL:
-            {
-            DoIncrementalOpenL( iActiveTask->GetCommand() );
-            done = ETrue;
-            break;
-            }
-        default:
-            {
-            // Should never happen!
-            ASSERT(0);
-            break;
-            }
-        }
-    return done;
-    }
-
-// ----------------------------------------------------------------------------
-// Handler for async operations completed
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::HandleOperationCompleted(
-    TInt aErr)
-    {
-    MPX_FUNC("CMPXDbPlugin::HandleOperationCompleted");
-    TRAP_IGNORE(DoHandleOperationCompletedL(aErr));
-    }
-
-// ----------------------------------------------------------------------------
-// Process the OpenL command
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXFilter* aFilter )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenL");
-
-    TInt err( KErrNone );
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-
-    TInt count(0);
-    TInt levels(aPath.Levels());
-    TBool isASong(EFalse);
-
-    aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aPath.Id(levels - 1));
-
-    if (1 == levels)
-        {
-        // return the "main menu"
-        count = iMusicLibraryMenuTitles->Count();
-        RArray<TMPXItemId> ids;
-        CleanupClosePushL(ids);
-
-        // due to ui changes, the order of main menu is changed
-        // since multiple clients hardcode indexes to each entry,
-        // the enum cannot be changed, instead we will have to
-        // manually change the display order to minimize the impact to
-        // external clients
-
-        // change from:
-        // all songs, playlist, artist, album, (podcast), genre, composer
-        // to:
-        // artist, album, playlist, all songs, (podcast), genre, composer
-        for (TInt i = EBrowseArtist; i <= EBrowseAlbum; ++i)
-            {
-            MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(i), EMPXGroup,
-                CategoryForBrowseType(static_cast<TMCBrowseType>(i)), iMusicLibraryMenuIds[i]);
-            ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[i]));
-            }
-        MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(1), EMPXGroup,
-            CategoryForBrowseType(static_cast<TMCBrowseType>(1)), iMusicLibraryMenuIds[1]);
-        ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[1]));
-        MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(0), EMPXGroup,
-            CategoryForBrowseType(static_cast<TMCBrowseType>(0)), iMusicLibraryMenuIds[0]);
-        ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[0]));
-
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
-        if( !iDisablePodcasting )
-            {
-            MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(EBrowsePodcasts), EMPXGroup,
-                CategoryForBrowseType(static_cast<TMCBrowseType>(EBrowsePodcasts)), iMusicLibraryMenuIds[EBrowsePodcasts]);
-            ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[EBrowsePodcasts]));
-            }
-#endif // __ENABLE_PODCAST_IN_MUSIC_MENU
-
-        // Genre and composer
-        for (TInt i = ( EBrowseGenre ); i < count; ++i)
-            {
-            MPXDbCommonUtil::AppendMediaL(*array, iMusicLibraryMenuTitles->MdcaPoint(i), EMPXGroup,
-                CategoryForBrowseType(static_cast<TMCBrowseType>(i)), iMusicLibraryMenuIds[i]);
-            ids.AppendL(TMPXItemId(iMusicLibraryMenuIds[i]));
-            }
-
-        TInt pPath = aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-        MPX_ASSERT(pPath);
-        ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
-        CleanupStack::PopAndDestroy(&ids);
-        SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXCollection, *iMusicMenuTitle);
-        aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-            KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
-        }
-    else if (levels >= 2)
-        {
-        // Create a media which hold the pointer to the returned path
-        if (aEntries.IsSupported(KMPXMediaGeneralValue))
-            {
-            CMPXMedia* pMedia = CMPXMedia::NewL();
-            CleanupStack::PushL(pMedia);
-            pMedia->SetTObjectValueL<TInt>(KMPXMediaGeneralValue,
-                                          aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue));
-            array->AppendL(*pMedia);
-            CleanupStack::PopAndDestroy(pMedia);
-            MPX_ASSERT(array->Count()==1);
-            }
-
-        // check the browse type
-        switch (aPath.Id(1).iId2)
-            {
-            case EBrowseAll:
-                {
-                TBool doIncremental(ETrue);
-                if( aFilter && aFilter->IsSupported( KMPXCollectionOpenLSupportsIncremental ) )
-                    {
-                    doIncremental =
-                         aFilter->ValueTObjectL<TBool>(KMPXCollectionOpenLSupportsIncremental);
-                    }
-
-                if( doIncremental )
-                    {
-                    TRAP( err, isASong = DoOpenIncrementalL( aPath, aAttrs, aEntries, array ) );
-                    }
-                else
-                    {
-                    TRAP( err, isASong = DoOpenBrowseAllL(aPath, aAttrs, aEntries, array) );
-                    }
-                break;
-                }
-
-            case EBrowseArtist:
-                {
-                if( iAllSongsValid )
-                    {
-                    isASong = DoOpenBrowseArtistL( aPath, aAttrs, aEntries, array );
-                    }
-                break;
-                }
-
-            case EBrowseAlbum:
-                {
-                if( iAllSongsValid )
-                    {
-                    isASong = DoOpenBrowseAlbumL( aPath, aAttrs, aEntries, array );
-                    }
-                break;
-                }
-
-            case EBrowsePlaylist:
-                {
-                if( iAllSongsValid )
-                    {
-                    isASong = DoOpenBrowsePlaylistL(aPath, aAttrs, aEntries, array);
-                    }
-
-                break;
-                }
-
-            case EBrowseGenre:
-                {
-                if( iAllSongsValid )
-                    {
-                    isASong = DoOpenBrowseGenreL( aPath, aAttrs, aEntries, array );
-                    }
-                break;
-                }
-
-            case EBrowseComposer:
-                {
-                if( iAllSongsValid )
-                    {
-                    isASong = DoOpenBrowseComposerL( aPath, aAttrs, aEntries, array );
-                    }
-                break;
-                }
-
-            default:
-                {
-                User::Leave(KErrArgument);
-                }
-            }
-        //Remove the first media
-        if ( array->Count() &&
-            (*array)[0]->IsSupported(KMPXMediaGeneralValue))
-            {
-            array->Remove(0);
-            }
-        }
-    else
-        {
-        User::Leave(KErrNotSupported);
-        }
-    aEntries.SetCObjectValueL(KMPXMediaArrayContents, array);
-    aEntries.SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-
-    CleanupStack::PopAndDestroy(array);
-
-    if( err == KSQLErrGeneral )
-        {
-        iAllSongsValid = EFalse;
-        User::Leave( KErrDiskFull );
-        }
-    else if( err != KErrNone )
-        {
-        User::Leave( err );
-        }
-    return isASong;
-    }
-
-
-// ----------------------------------------------------------------------------
-// CMPXDbPlugin::DoOpenIncrementalL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenIncrementalL( const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
-                                       CMPXMedia& aEntries, CMPXMediaArray* aArray)
-    {
-    TBool isASong(EFalse);
-
-    TInt levels(aPath.Levels());
-
-    if( levels == 2 )
-        {
-        // Remove the pPath dummy from the array
-        TInt pPath = aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-        aArray->Remove(0);
-        CMPXCollectionPath* p = (CMPXCollectionPath*) pPath;
-
-        RArray<TMPXItemId> ids;
-        CleanupClosePushL( ids );
-
-        iDbHandler->GetAllSongsLimitedL( aAttrs, *aArray, KFirstFetchCount );
-
-        TInt c( aArray->Count() );
-        for( TInt i=0; i<c; ++i )
-            {
-            TMPXItemId id = aArray->AtL(i)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-            ids.Append( id );
-            }
-
-        // Rest are all blank items
-        CMPXMedia* entry = CMPXMedia::NewL();
-        CleanupStack::PushL(entry);
-        entry->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-        entry->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-        entry->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, KMPXInvalidItemId );
-
-        TInt count = iDbHandler->NumberOfItemsL(EMPXSong);
-        count-=c;
-        for( TInt i=0; i<count; ++i )
-            {
-            aArray->AppendL( *entry );
-            ids.Append( KMPXInvalidItemId );
-            }
-        CleanupStack::PopAndDestroy( entry );
-
-        // Set the "Supportes incremental Command" flag
-        //
-        aEntries.SetTObjectValueL( KMPXCollectionOpenLSupportsIncremental, ETrue );
-
-        TMPXOpenDataBlock block;
-        block.iOffset=KErrNotFound;
-        block.iSize=count;
-        aEntries.SetTObjectValueL<TMPXOpenDataBlock>( KMPXCollectionOpenLResultRange, block );
-
-        SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong,
-                iMusicLibraryTitles->MdcaPoint(EBrowseAll));
-
-        p->AppendL(ids.Array());
-        CleanupStack::PopAndDestroy( &ids );
-        }
-    else if( levels == 3 )
-        {
-        iDbHandler->GetSongL(aPath.Id(levels - 1).iId2, aAttrs, *aArray);
-        isASong = ETrue;
-        }
-
-
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowseAll
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowseAllL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseAllL");
-
-    TInt levels(aPath.Levels());
-    switch (levels)
-       {
-       // All songs
-       case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAllL_All);
-
-            iDbHandler->GetAllSongsL(aArray, aAttrs);
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong,
-                iMusicLibraryTitles->MdcaPoint(EBrowseAll));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAllL_All);
-            break;
-            }
-
-         // A Song in all songs
-         case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAllL_Song);
-
-            iDbHandler->GetSongL(aPath.Id(levels - 1).iId2, aAttrs, *aArray);
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAllL_Song);
-            break;
-            }
-
-         default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseAllL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        } // end switch(levels)
-
-    return (levels == 3);
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowseArtist
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowseArtistL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseArtistL");
-
-    TBool isASong(EFalse);
-    TInt levels(aPath.Levels());
-    TInt idIndex(levels - 1);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (levels)
-        {
-        // All artists
-        case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_All);
-
-            iDbHandler->GetAllArtistsL(aAttrs, aArray);
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXArtist,
-                iMusicLibraryTitles->MdcaPoint(EBrowseArtist));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_All);
-            break;
-            }
-
-        // All albums of an artist
-        case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllAlbums);
-            // get the albums
-            TInt id(aPath.Id(idIndex).iId2);
-            MPX_ASSERT(aArray->Count());
-            MPX_ASSERT((*aArray)[0]->IsSupported(KMPXMediaGeneralValue));
-            TInt pPath = (*aArray)[0]->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
-            MPX_ASSERT(pPath);
-            iDbHandler->GetAlbumsMatchingArtistL(id, aAttrs, *aArray);
-            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXArtist, id);
-
-            TInt count = aArray->Count();
-            if ( count > 2 )
-                {
-                // Only show "all" item if there is more than 1 album
-                // count for "all" item
-                TInt total = 0;
-                for ( TInt i = 1; i < count; i++ )
-                {
-                TInt temp = (*aArray)[i]->ValueTObjectL<TInt>(KMPXMediaGeneralCount);
-                total += temp;
-                }
-            // Add "all" item under an artist
-            MPXDbCommonUtil::PrependMediaL(*aArray, *iAllSongsForArtistTitle, EMPXItem, EMPXAlbum,
-                aPath.Id(idIndex), 0, 0, 1);
-    
-                (*aArray)[1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, total);
-    
-            TMPXItemId allId = ((*aArray)[1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
-            if (aArray->Count() > 2)
-                { // path media, all id  and at least one media
-                ((CMPXCollectionPath*)pPath)->InsertL(allId, 0);
-                }
-            else
-                { // only has all item
-                ((CMPXCollectionPath*)pPath)->AppendL(allId);
-                    }
-                }
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllAlbums);
-            break;
-            }
-
-        // All songs of an album for an artist or all songs for an artist
-        case 4:
-            {
-            // all songs for an artist
-            if (aPath.Id(3) == aPath.Id(2))
-                {
-                MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongs);
-
-                TInt id(aPath.Id(idIndex - 1).iId2);
-                iDbHandler->GetSongsMatchingArtistL(id, aAttrs, aArray);
-                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXSong, id);
-
-                MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongs);
-                }
-            // all songs of an album for an artist
-            else
-                {
-                MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongsForAlbum);
-                TUint32 artistId(aPath.Id(idIndex - 1).iId2);
-
-                if (selections.Count())
-                    {
-                    // Multiple albums
-                    const TInt count(aPath.Selection().Count());
-                    for (TInt i = 0; i < count; ++i)
-                        {
-                        iDbHandler->GetSongsMatchingArtistAndAlbumL(artistId, selections[i].iId2,
-                            aAttrs, aArray);
-                        }
-                    }
-                else
-                    {
-                    // One album
-                    iDbHandler->GetSongsMatchingArtistAndAlbumL(artistId, aPath.Id(idIndex).iId2,
-                        aAttrs, aArray);
-                    }
-
-                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum, aPath.Id(idIndex).iId2);
-                MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_AllSongsForAlbum);
-                }
-
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseArtistL: retrieved %d items", aArray->Count());
-
-            break;
-            }
-
-        // A Song in an album
-        case 5:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseArtistL_Song);
-
-            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
-            isASong = ETrue;
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseArtistL_Song);
-            break;
-            }
-
-        default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseArtistL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        } // end switch(level)
-
-    CleanupStack::PopAndDestroy(&selections);
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowseAlbum
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowseAlbumL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseAlbumL");
-
-    TBool isASong(EFalse);
-    TInt levels(aPath.Levels());
-    TInt idIndex(levels - 1);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (levels)
-        {
-        // All Albums
-        case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
-
-            iDbHandler->GetAllAlbumsL(aAttrs, aArray);
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum,
-                iMusicLibraryTitles->MdcaPoint(EBrowseAlbum));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
-            break;
-            }
-
-        // All songs in one or multiple albums
-        case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_AllSongs);
-            if (selections.Count())
-                {
-                // Multiple albums
-                const TInt count(aPath.Selection().Count());
-                for (TInt i = 0; i < count; ++i)
-                    {
-                    iDbHandler->GetSongsMatchingAlbumL(selections[i].iId2, aAttrs, aArray);
-                    }
-                }
-            else
-                {
-                // One album
-                iDbHandler->GetSongsMatchingAlbumL(aPath.Id(idIndex).iId2, aAttrs, aArray);
-                }
-
-//            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum, aPath.Id(idIndex).iId2);
-// added for ganes
-                SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum, iMusicLibraryTitles->MdcaPoint(EBrowseAlbumSong));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_AllSongs);
-            break;
-            }
-
-        // A song in an album
-        case 4:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_Song);
-
-            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
-            isASong = ETrue;
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_Song);
-            break;
-            }
-
-        default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseAlbumL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&selections);
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowsePlaylist
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowsePlaylistL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowsePlaylistL");
-
-    TBool isASong(EFalse);
-    TInt levels(aPath.Levels());
-    TInt idIndex(levels - 1);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (levels)
-         {
-         case 2:
-            {
-            // All playlists
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_All);
-
-            iDbHandler->GetAllPlaylistsL(aArray, aAttrs);
-            iDbHandler->GetAllSystemPlaylistNamesL(aArray);
-
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPlaylist,
-                iMusicLibraryTitles->MdcaPoint(EBrowsePlaylist));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_All);
-            break;
-            }
-
-         // All songs in a playlist
-         case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_AllSongs);
-
-            if (selections.Count())
-                {
-                const TInt count(aPath.Selection().Count());
-                for (TInt i = 0; i < count; ++i)
-                    {
-                    iDbHandler->GetSongsMatchingPlaylistL(selections[i].iId2, aAttrs, aArray);
-                    }
-                }
-            else
-                {
-                iDbHandler->GetSongsMatchingPlaylistL(aPath.Id (idIndex).iId2, aAttrs, aArray);
-                }
-
-            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist, aPath.Id(idIndex).iId2);
-
-            // populate EMPXMediaGeneralNonPermissibleActions
-            if (iDbHandler->IsAutoPlaylistL(aPath.Id(idIndex).iId2))
-                {
-                // set non-permissible actions to not writable and cacheable
-                aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                    KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache));
-                }
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_AllSongs);
-            break;
-            }
-
-         // Specific song in a playlist
-         case 4:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowsePlaylistL_Song);
-
-            iDbHandler->GetPlaylistSongL(aPath.Id(idIndex).iId2, aPath.Id(idIndex - 1).iId2,
-                aAttrs, *aArray);
-            isASong = ETrue;
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowsePlaylistL_Song);
-            break;
-            }
-
-         default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowsePlaylistL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-       }
-
-    CleanupStack::PopAndDestroy(&selections);
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowseGenre
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowseGenreL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseGenreL");
-
-    TBool isASong(EFalse);
-    TInt levels(aPath.Levels());
-    TInt idIndex(levels - 1);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (levels)
-        {
-        // All genres
-         case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_All);
-
-            iDbHandler->GetAllGenresL(aAttrs, aArray);
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXGenre,
-                iMusicLibraryTitles->MdcaPoint(EBrowseGenre));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_All);
-            break;
-            }
-
-        // All songs of a genre
-        case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_AllSongs);
-
-            if (selections.Count())
-                {
-                const TInt count(aPath.Selection().Count());
-                for (TInt i = 0; i < count; ++i)
-                    {
-                    iDbHandler->GetSongsMatchingGenreL(selections[i].iId2, aAttrs, aArray);
-                    }
-                }
-            else
-                {
-                iDbHandler->GetSongsMatchingGenreL(aPath.Id(idIndex).iId2, aAttrs, aArray);
-                }
-            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXGenre, aPath.Id(idIndex).iId2);
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_AllSongs);
-            break;
-            }
-
-        // Specific song in a genre
-        case 4:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseGenreL_Song);
-
-            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
-            isASong = ETrue;
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseGenreL_Song);
-            break;
-            }
-
-        default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseGenreL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&selections);
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Handles OpenL called for EBrowseComposer
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoOpenBrowseComposerL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray* aArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenBrowseComposerL");
-
-    TBool isASong(EFalse);
-    TInt levels(aPath.Levels());
-    TInt idIndex(levels - 1);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (levels)
-        {
-        // All composers
-        case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_All);
-
-            iDbHandler->GetAllComposersL(aAttrs, aArray);
-            SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXComposer,
-                iMusicLibraryTitles->MdcaPoint(EBrowseComposer));
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_All);
-            break;
-            }
-
-        // All songs of a composer
-        case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_AllSongs);
-            if (selections.Count())
-                {
-                const TInt count(aPath.Selection().Count());
-                for (TInt i = 0; i < count; ++i)
-                    {
-                    iDbHandler->GetSongsMatchingComposerL(selections[i].iId2, aAttrs, aArray);
-                    }
-                }
-            else
-                {
-                iDbHandler->GetSongsMatchingComposerL(aPath.Id(idIndex).iId2, aAttrs, aArray);
-                }
-            SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXComposer, aPath.Id(idIndex).iId2);
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_AllSongs);
-            break;
-            }
-
-        // Specific song of a composer
-        case 4:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseComposerL_Song);
-
-            iDbHandler->GetSongL(aPath.Id(idIndex).iId2, aAttrs, *aArray);
-            isASong = ETrue;
-
-            MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseComposerL_Song);
-            break;
-            }
-
-        default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoOpenBrowseComposerL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&selections);
-    return isASong;
-    }
-
-// ----------------------------------------------------------------------------
-// Process the OpenL method with open mode EMPXOpenPlaylistOnly
-// ----------------------------------------------------------------------------
-//
-CMPXCollectionPath* CMPXDbPlugin::DoOpenPlaylistL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoOpenPlaylistL");
-
-    RArray<TMPXItemId> ids;
-    CleanupClosePushL(ids);
-
-    CMPXMedia* entries = CMPXMedia::NewL();
-    CleanupStack::PushL(entries);
-
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL(aPath);
-    CleanupStack::PushL(path);
-
-    // Go through the browse path
-    TInt levels(aPath.Levels());
-    if (levels == 2)
-        {
-        // Create a new collection path
-        CleanupStack::PopAndDestroy( path );
-        path = CMPXCollectionPath::NewL();
-        CleanupStack::PushL( path );
-
-        // Always return all songs here
-        ids.Reset();
-        ids.AppendL( KDBPluginUid );
-        path->AppendL(ids.Array());
-        path->SelectL((TMPXItemId) KDBPluginUid);
-
-        ids.Reset();
-        ids.AppendL(EBrowseAll);
-        path->AppendL(ids.Array());
-        path->SelectL((TMPXItemId) EBrowseAll);
-        path->Set(EMPXOpenPlaylistOnly);
-
-        // Get all item IDs
-        CMPXMediaArray* array = CMPXMediaArray::NewL();
-        CleanupStack::PushL(array);
-
-        DoOpenBrowseAllL(*path, aAttrs, *entries, array);
-
-        entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-        entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-
-        CleanupStack::PopAndDestroy(array);
-
-        DoAppendLevelL(*path, *entries);
-        }
-    else if (levels > 2)
-        {
-        switch (aPath.Id(1).iId2)
-            {
-            case EBrowseAll:
-                {
-                path->Set(EMPXOpenPlaylistOnly);
-                // Returns the same path that we copied
-                break;
-                }
-            case EBrowseArtist:
-                {
-                if (levels == 3)
-                    {
-                    // return all songs of a particular artist (currently highlighted)
-                    path->Set(EMPXOpenGroupOrPlaylist);
-                    ids.Reset();
-                    ids.Append(aPath.Id(2));
-                    path->AppendL(ids.Array());
-                    path->SelectL(aPath.Id(2));
-                    path->Set(EMPXOpenPlaylistOnly);
-
-                    // Opens all songs of an artist and create the corresponding
-                    // Collection playlist by appending all songs of an artist to
-                    // the collection path
-                    //
-                    DoOpenL(*path, aAttrs, *entries, NULL);
-                    DoAppendLevelL(*path, *entries);
-                    }
-                else if (levels == 4)
-                    {
-                    // Open the album of an artist and create the corresponding
-                    // Collection playlist by appending all songs of an artist to
-                    // the collection path
-                    //
-                    path->Set(EMPXOpenPlaylistOnly);
-                    DoOpenL(*path, aAttrs, *entries, NULL);
-                    DoAppendLevelL(*path, *entries);
-                    }
-                else
-                    {
-                    // case is a song no need to open again!
-                    }
-
-                break;
-                }
-            // Playlist, album, genre and composer easier, only 2 levels deep
-            // plugin | category | category contents | songs of category
-            //
-            case EBrowsePlaylist:
-            case EBrowseAlbum:
-            case EBrowseGenre:
-            case EBrowseComposer:
-                {
-                if (!DoOpenL(aPath, aAttrs, *entries, NULL))
-                    {
-                    // If it is not at a song level
-                    // Append all entries to create collection path
-                    //
-                    path->Set(EMPXOpenPlaylistOnly);
-                    DoAppendLevelL( *path, *entries );
-                    }
-                break;
-                }
-            default:
-                {
-                User::Leave(KErrNotSupported);
-                }
-            }
-        }
-    else  // levels < 2
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    // Cleanup
-    CleanupStack::Pop(path);
-    CleanupStack::PopAndDestroy(entries);
-    CleanupStack::PopAndDestroy(&ids);
-
-    return path;
-    }
-
-// ----------------------------------------------------------------------------
-// Process the MediaL command
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoMediaL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoMediaL");
-
-    // Fetch Media for root level
-    //
-    if (aPath.Levels() == 1) //root
-        {
-        DoRootMediaL( aAttrs, aEntries );
-        }
-    // Ensure the database has been merged before attempting MediaL()
-    //
-    else
-        {
-        CMPXMediaArray* array = CMPXMediaArray::NewL();
-        CleanupStack::PushL(array);
-
-        switch (aPath.Id(1).iId2)
-            {
-            case EBrowseAll:
-                {
-                DoAllSongsMediaL(aPath, aAttrs, aEntries, *array);
-                break;
-                } // end case EBrowseAll
-
-            case EBrowseArtist:
-                {
-                DoArtistMediaL(aPath, aAttrs, aEntries, *array);
-                break;
-                } // end case EBrowseArtist
-
-            case EBrowseAlbum:
-                {
-                DoCategoryMediaL(aPath, aAttrs, EMPXAlbum, aEntries, *array);
-                break;
-                } // end case EBrowseAlbum
-
-            case EBrowsePlaylist:
-                {
-                DoCategoryMediaL(aPath, aAttrs, EMPXPlaylist, aEntries, *array);
-                break;
-                } // end case EBrowsePlaylist
-
-            case EBrowseGenre:
-                {
-                DoCategoryMediaL(aPath, aAttrs, EMPXGenre, aEntries, *array);
-                break;
-                } // end case EBrowseGenre
-
-            case EBrowseComposer:
-                {
-                DoCategoryMediaL(aPath, aAttrs, EMPXComposer, aEntries, *array);
-                break;
-                } // end case EBrowseComposer
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
-            case EBrowsePodcasts:
-                {
-                break;
-                }
-#endif
-            default:
-                {
-                User::Leave(KErrArgument);
-                }
-            } // end switch(aPath.id(1)
-
-        if (array->Count() > 0)
-            {
-            aEntries.SetCObjectValueL(KMPXMediaArrayContents, array);
-            aEntries.SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-            }
-        CleanupStack::PopAndDestroy(array);
-        }
-    // Else case cannot leave, because this will happen when we have no disk space to
-    // perform the merging. It should NOT leave.
-    //
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection media for root level
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRootMediaL(
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aMedia )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRootMediaL");
-
-    TInt count(aAttrs.Count());
-#ifndef __ENABLE_PODCAST_IN_MUSIC_MENU
-    aMedia.SetTObjectValueL<TMPXGeneralNonPermissibleActions> (
-            KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions)(EMPXWrite | EMPXCache) );
-#endif // __ENABLE_PODCAST_IN_MUSIC_MENU
-    for (TInt i = 0; i < count; ++i)
-        {
-        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
-            {
-            TUint att(aAttrs[i].AttributeId());
-            if (att & EMPXMediaGeneralTitle)
-                {
-                HBufC* title(iResource->ReadHBufCL(R_MPX_QTN_MUS_MUSIC));
-                CleanupStack::PushL(title);
-                aMedia.SetTextValueL(KMPXMediaGeneralTitle, *title);
-                CleanupStack::PopAndDestroy(title);
-                }
-            if (att & EMPXMediaGeneralSubTitle)
-                {
-                TInt numSongs(iDbHandler->NumberOfItemsL(EMPXSong));
-                aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, numSongs);
-
-                HBufC* text(iResource->ReadHBufCL((1 == numSongs) ?
-                    R_MPX_QTN_MUS_MUSIC_ONE_SONG : R_MPX_QTN_MUS_MUSIC_NUM_SONGS));
-
-                CleanupStack::PushL(text);
-                aMedia.SetTextValueL(KMPXMediaGeneralSubTitle, *text);
-                CleanupStack::PopAndDestroy(text);
-                }
-            if (att & EMPXMediaGeneralIcon)
-                {
-/*                TIconInfo icon;
-                icon.bmpfile = KMPlayerDbPluginMbmFile;
-                icon.bitmapId = EMbmMpxdbpluginQgn_graf_mup_dlst_music;
-                icon.maskId = EMbmMpxdbpluginQgn_graf_mup_dlst_music_mask;
-                aMedia.SetTObjectValueL<TIconInfo>(KMPXMediaGeneralIcon, icon);
-*/
-// commented out for hb migration
-                }
-            } // if
-        } // for
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection media for all songs category
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoAllSongsMediaL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAllSongsMediaL");
-
-    TInt levels(aPath.Levels());
-
-    switch (levels)
-       {
-       // All songs
-       case 2:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoAllSongsMediaL_All);
-            DoRootCategoryMediaL(aAttrs, EBrowseAll, EMPXSong, aEntries);
-            MPX_PERF_END(CMPXDbPlugin_DoAllSongsMediaL_All);
-            break;
-            }
-
-         // A Song in all songs
-         case 3:
-            {
-            MPX_PERF_START(CMPXDbPlugin_DoAllSongsMediaL_Song);
-            GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
-            MPX_PERF_END(CMPXDbPlugin_DoAllSongsMediaL_Song);
-            break;
-            }
-
-         default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoAllSongsMediaL: Invalid levels[%d]", levels);
-            User::Leave(KErrNotSupported);
-            }
-        } // end switch(levels)
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection media for artists category
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoArtistMediaL (
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntries,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoArtistMediaL");
-
-    TInt levels(aPath.Levels());
-    TInt count(aPath.Selection().Count());
-
-     // All artists
-    if (levels == 2)
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_All);
-        DoRootCategoryMediaL(aAttrs, EBrowseArtist, EMPXArtist, aEntries);
-        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_All);
-        }
-    else if ((levels == 3) && count) // multiple artists selected
-        {
-        RArray<TMPXItemId> selections;
-        CleanupClosePushL(selections);
-        aPath.SelectionL(selections);
-
-        for (TInt i = 0; i < count; ++i)
-            {
-            CMPXMedia* artist = CMPXMedia::NewL();
-            CleanupStack::PushL(artist);
-            iDbHandler->GetCategoryL(selections[i].iId2, EMPXArtist, aAttrs, artist);
-            aMediaArray.AppendL(*artist);
-            CleanupStack::PopAndDestroy(artist);
-            }
-
-        CleanupStack::PopAndDestroy(&selections);
-        }
-    else if (levels == 3) // single artist selected
-        {
-        iDbHandler->GetCategoryL(aPath.Id(2).iId2, EMPXArtist, aAttrs, &aEntries);
-        }
-    else if (levels == 4 && (aPath.Id(3) == aPath.Id(2))) // all songs for an artist
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_AllSongs);
-        // Calculate duration directly with SQL
-        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
-            {
-            DoDurationL(aEntries, EMPXArtist, aPath.Id(2));
-            }
-
-        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_AllSongs);
-        }
-    else if ((levels == 4) && count) // multiple albums of an artist
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_AllAlbums);
-
-        RArray<TMPXItemId> selections;
-        CleanupClosePushL(selections);
-        aPath.SelectionL(selections);
-
-        for (TInt i = 0; i < count; ++i)
-            {
-            CMPXMedia* media = CMPXMedia::NewL();
-            CleanupStack::PushL(media);
-            iDbHandler->GetCategoryL(selections[i].iId2, EMPXAlbum, aAttrs, media);
-            aMediaArray.AppendL(*media);
-            CleanupStack::PopAndDestroy(media);
-            }
-
-        CleanupStack::PopAndDestroy(&selections);
-
-        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_AllAlbums);
-        }
-    else if (levels == 4) // one album of an artist
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_OneAlbum);
-        iDbHandler->GetCategoryL(aPath.Id(3).iId2, EMPXAlbum, aAttrs, &aEntries);
-
-        // Calculate duration
-        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
-            {
-            DoDurationL(aEntries, EMPXArtist, aPath.Id(2), EMPXAlbum, aPath.Id(3));
-            }
-
-        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_OneAlbum);
-        }
-     else if (levels == 5) // a song/songs in an album
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoArtistMediaL_Song);
-        GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
-        MPX_PERF_END(CMPXDbPlugin_DoArtistMediaL_Song);
-        }
-    else
-        {
-        MPX_DEBUG2("CMPXDbPlugin_DoArtistMediaL: Invalid levels[%d]", levels);
-        User::Leave(KErrNotSupported);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection media for all songs category
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRootCategoryMediaL (
-    const TArray<TMPXAttribute>& aAttrs,
-    TMPXItemId aRootCategoryId,
-    TMPXGeneralCategory aCategory,
-    CMPXMedia& aEntries)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRootCategoryMediaL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        if (aAttrs[i].ContentId() == KMPXMediaIdGeneral)
-            {
-            TUint att(aAttrs[i].AttributeId());
-            switch (att)
-                {
-                case EMPXMediaGeneralId:
-                    {
-                    aEntries.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, aRootCategoryId);
-                    break;
-                    }
-                case EMPXMediaGeneralTitle:
-                    {
-                    aEntries.SetTextValueL(KMPXMediaGeneralTitle,
-                        iMusicLibraryMenuTitles->MdcaPoint(BrowseTypeForCategory(aCategory)));
-                    break;
-                    }
-                case EMPXMediaGeneralCount:
-                    {
-                    // count number of category
-                    aEntries.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,
-                        iDbHandler->NumberOfItemsL(aCategory));
-                    break;
-                    }
-                case EMPXMediaGeneralDuration:
-                    {
-                    if (aCategory == EMPXSong)
-                        {
-                        DoDurationL(aEntries, EMPXSong);
-                        }
-                    break;
-                    }
-                default:
-                    // not supported
-                    break;
-                } // end switch
-            } // end if
-        } // end for
-
-    aEntries.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    aEntries.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, aCategory);
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection media for albums/playlists/genres/composers category
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoCategoryMediaL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    TMPXGeneralCategory aCategory,
-    CMPXMedia& aEntries,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoCategoryMediaL");
-
-    TInt levels(aPath.Levels());
-    TInt count(aPath.Selection().Count());
-
-    if (levels == 2) // all albums/playlists/genres/composers
-        {
-        MPX_PERF_START (CMPXDbPlugin_DoCategoryMediaL_All);
-        DoRootCategoryMediaL(aAttrs, aPath.Id(1).iId2, aCategory, aEntries);
-        MPX_PERF_END (CMPXDbPlugin_DoCategoryMediaL_All);
-        }
-    else if (levels == 3 && count) // multiple albums/playlists/genres/composers selected
-        {
-        RArray<TMPXItemId> selections;
-        CleanupClosePushL(selections);
-        aPath.SelectionL(selections);
-
-        for (TInt i = 0; i < count; ++i)
-            {
-            CMPXMedia* media = CMPXMedia::NewL();
-            CleanupStack::PushL(media);
-            iDbHandler->GetCategoryL(selections[i].iId2, aCategory, aAttrs, media);
-            aMediaArray.AppendL(*media);
-            CleanupStack::PopAndDestroy(media);
-            }
-
-        CleanupStack::PopAndDestroy(&selections);
-        }
-    else if (levels == 3) // all songs in an album/playlist/genre/composer
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoCategoryMediaL_Category);
-        TMPXItemId id = aPath.Id(2);
-        iDbHandler->GetCategoryL(id.iId2, aCategory, aAttrs, &aEntries);
-
-        // Calculate duration directly with SQL
-        if (MPXDbCommonUtil::AttributeExists(aAttrs, KMPXMediaGeneralDuration))
-            {
-            DoDurationL(aEntries, aCategory, id);
-            }
-
-        TInt nonPermisAction( aEntries.ValueTObjectL<TInt>(KMPXMediaGeneralNonPermissibleActions));
-        nonPermisAction |= EMPXCache;
-
-        aEntries.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                    KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions) nonPermisAction );
-
-        MPX_PERF_END(CMPXDbPlugin_DoCategoryMediaL_Category);
-        }
-    else if (levels == 4) // a song/songs in an album/playlist/genre/composer
-        {
-        MPX_PERF_START(CMPXDbPlugin_DoCategoryMediaL_Song);
-        GetSongInfoL(aPath, aAttrs, aEntries, aMediaArray);
-        MPX_PERF_END(CMPXDbPlugin_DoCategoryMediaL_Song);
-        }
-    else
-        {
-        MPX_DEBUG2("CMPXDbPlugin__DoMediaL__EBrowseAlbum: Invalid levels[%d]", levels);
-        User::Leave(KErrNotSupported);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoSetMediaDrmL(
-    CMPXMedia& aMedia,
-    TUint aDrmAttributes,
-    const TDesC& aLocation)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoSetMediaDrmL");
-
-    iDrmMediaUtility->InitL(aLocation);
-    CleanupClosePushL(*iDrmMediaUtility);
-    const CMPXMedia* drmMedia(iDrmMediaUtility->GetMediaL(aDrmAttributes));
-
-    // Only get attributes if it's a DRM file
-    if (drmMedia)
-        {
-        if ((aDrmAttributes & EMPXMediaDrmType) &&
-            drmMedia->IsSupported(KMPXMediaDrmType))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmType,
-                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmType));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmRightsStatus) &&
-            drmMedia->IsSupported(KMPXMediaDrmRightsStatus))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmRightsStatus,
-                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsStatus));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmRightsType) &&
-            drmMedia->IsSupported(KMPXMediaDrmRightsType))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmRightsType,
-                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmRightsType));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmCount) &&
-            drmMedia->IsSupported(KMPXMediaDrmCount))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmCount,
-                drmMedia->ValueTObjectL<TInt>(KMPXMediaDrmCount));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmProtected) &&
-            drmMedia->IsSupported(KMPXMediaDrmProtected))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmProtected,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmProtected));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmSendingAllowed) &&
-            drmMedia->IsSupported(KMPXMediaDrmSendingAllowed))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmSendingAllowed,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmSendingAllowed));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmCanSetAutomated) &&
-            drmMedia->IsSupported(KMPXMediaDrmCanSetAutomated))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmCanSetAutomated,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmCanSetAutomated));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmHasInfoUrl) &&
-            drmMedia->IsSupported(KMPXMediaDrmHasInfoUrl))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmHasInfoUrl,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasInfoUrl));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmHasPreviewUrl) &&
-            drmMedia->IsSupported(KMPXMediaDrmHasPreviewUrl))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmHasPreviewUrl,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmHasPreviewUrl));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmAboutToExpire) &&
-            drmMedia->IsSupported(KMPXMediaDrmAboutToExpire))
-            {
-            aMedia.SetTObjectValueL( KMPXMediaDrmAboutToExpire,
-                drmMedia->ValueTObjectL<TBool>(KMPXMediaDrmAboutToExpire));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmStartTime) &&
-            drmMedia->IsSupported(KMPXMediaDrmStartTime))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmStartTime,
-                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmStartTime));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmEndTime) &&
-            drmMedia->IsSupported(KMPXMediaDrmEndTime))
-            {
-            aMedia.SetTObjectValueL( KMPXMediaDrmEndTime,
-                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmEndTime));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmIntervalStartTime) &&
-            drmMedia->IsSupported(KMPXMediaDrmIntervalStartTime))
-            {
-            aMedia.SetTObjectValueL( KMPXMediaDrmIntervalStartTime,
-                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmIntervalStartTime));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmAccumulatedTime) &&
-            drmMedia->IsSupported(KMPXMediaDrmAccumulatedTime))
-            {
-            aMedia.SetTObjectValueL(KMPXMediaDrmAccumulatedTime,
-                drmMedia->ValueTObjectL<TInt64>(KMPXMediaDrmAccumulatedTime));
-            }
-        if ((aDrmAttributes & EMPXMediaDrmInterval) &&
-            drmMedia->IsSupported(KMPXMediaDrmInterval))
-            {
-            aMedia.SetTObjectValueL( KMPXMediaDrmInterval,
-                drmMedia->ValueTObjectL<TTimeIntervalSeconds>(KMPXMediaDrmInterval));
-            }
-        }
-
-    CleanupStack::PopAndDestroy(iDrmMediaUtility);
-    }
-
-// ----------------------------------------------------------------------------
-// Add media objects to the array with attributes from song details
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::GetSongInfoL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXAttribute>& aAttrs,
-    CMPXMedia& aEntry,
-    CMPXMediaArray& aMediaArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::GetSongInfoL");
-
-    RArray<TInt> supportedIds;
-    CleanupClosePushL(supportedIds);
-    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
-
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    //
-    // If we are trying to locate a song from a playlist, we should read available song
-    // info from Playlist table first in case the song is located on a removable
-    // drive and the drive is not currently present. This is achieved by supplying
-    // playlist Id to GetSongMatchingSongIdL. When playlistId is 0, we are reading song
-    // info directly from Songs table. If playlistId is specified, GetSongMatchingSongIdL
-    // will populate song media from Playlist table and if Songs table for the drive
-    // exists, song media will be overwritten with info from Songs table.
-    //
-    TMPXItemId playlistId(0);
-    if (aPath.Id(1) == EBrowsePlaylist)
-        {
-        if (aPath.Levels() < 2)
-            {
-            User::Leave(KErrArgument);
-            }
-
-        playlistId = aPath.Id(aPath.Levels() - 2);
-        }
-
-    TInt countSelection(aPath.Selection().Count());
-    if (countSelection)
-        {
-        // We have a selection, iterate it
-        for (TInt selectionIndex = 0; selectionIndex < countSelection; ++selectionIndex)
-            {
-            CMPXMedia* newEntry = CMPXMedia::NewL(supportedIds.Array());
-            CleanupStack::PushL(newEntry);
-
-            DoGetSongInfoL(aAttrs, selections[selectionIndex].iId2, playlistId.iId2, *newEntry);
-
-            aMediaArray.AppendL(*newEntry);
-            CleanupStack::PopAndDestroy(newEntry);
-            }
-        }
-    else
-        {
-        // No selection, get the attributes for the one song
-        DoGetSongInfoL(aAttrs, aPath.Id(aPath.Levels() - 1).iId2, playlistId.iId2, aEntry);
-        }
-
-    CleanupStack::PopAndDestroy(&selections);
-    CleanupStack::PopAndDestroy(&supportedIds);
-    }
-
-// ----------------------------------------------------------------------------
-// Retrieves the attributes for a media object.
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoGetSongInfoL(
-    const TArray<TMPXAttribute>& aAttrs,
-    TInt aEntryId,
-    TInt aPlaylistId,
-    CMPXMedia& aEntry)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoGetSongInfoL");
-
-    if (aPlaylistId)
-        {
-        iDbHandler->GetPlaylistSongL(aEntryId, aPlaylistId, aAttrs, aEntry);
-        }
-    else
-        {
-        iDbHandler->GetSongL(aEntryId, aAttrs, aEntry);
-        }
-
-    const TDesC& location(aEntry.ValueText(KMPXMediaGeneralUri));
-
-    // Check DRM Only if we have a location
-    if (location != KNullDesC)
-        {
-        TUint drmAttributes(0);
-
-        // Compact the attribute set
-        TInt count(aAttrs.Count());
-        for (TInt i = 0; i < count; ++i)
-            {
-            if (aAttrs[i].ContentId() == KMPXMediaIdDrm)
-                {
-                drmAttributes |= aAttrs[i].AttributeId();
-                }
-            }
-
-        // Set the correct attributes to media, only if requested
-        if (drmAttributes)
-            {
-            DoSetMediaDrmL(aEntry, drmAttributes, location);
-            }
-        }
-
-    // Disable caching for any MediaL() returning song info.
-    TInt nonPermisAction( aEntry.ValueTObjectL<TInt>(KMPXMediaGeneralNonPermissibleActions));
-    nonPermisAction |= EMPXCache;
-
-    aEntry.SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                KMPXMediaGeneralNonPermissibleActions, (TMPXGeneralNonPermissibleActions) nonPermisAction );
-    }
-
-// ----------------------------------------------------------------------------
-// Find the collection details
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoHandleOtherMediaAttributesL(
-    const TArray<TMPXAttribute>& aAttrs,
-    const CMPXCollectionPath& aPath,
-    CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoHandleOtherMediaAttributesL");
-
-    TInt count(aAttrs.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        if (aAttrs[i].ContentId() == KMPXMediaIdCollectionDetails)
-            {
-            TUint att(aAttrs[i].AttributeId());
-
-            if (att & EMPXMediaColDetailNumberOfItems)
-                {
-                aMedia.SetTObjectValueL(KMPXMediaColDetailNumberOfItems,
-                    iDbHandler->NumberOfItemsL(EMPXSong));
-                }
-            if (att & EMPXMediaColDetailDuration)
-                {
-                aMedia.SetTObjectValueL(KMPXMediaColDetailDuration,
-                    DoDurationL(aMedia, EMPXSong));
-                }
-            if (att & EMPXMediaColTotalSize)
-                {
-                // todo
-                TInt totalSize(0);
-                aMedia.SetTObjectValueL(KMPXMediaColDetailTotalSize, totalSize);
-                }
-            if (att & EMPXMediaLastRefreshed)
-                {
-                TTime lastRefreshed(iDbHandler->GetLastRefreshedTimeL());
-                aMedia.SetTObjectValueL(KMPXMediaColDetailLastRefreshed,
-                    lastRefreshed.Int64());
-                }
-            if (att & EMPXMediaColDetailDBCreated)
-                {
-                aMedia.SetTObjectValueL(KMPXMediaColDetailDBCreated,
-                    iDbHandler->DatabaseCreated());
-                }
-            if (att & EMPXMediaColDetailDBCorrupted)
-                {
-                aMedia.SetTObjectValueL(KMPXMediaColDetailDBCorrupted,
-                    iDbHandler->IsDBCorruptedL());
-                }
-            }
-        else if (aAttrs[i] == KMPXMediaGeneralPath)
-            {
-            aMedia.SetCObjectValueL(KMPXMediaGeneralPath,
-                const_cast<CMPXCollectionPath*>(&aPath));
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Remove an item from the collection database using the given path
-// ----------------------------------------------------------------------------
-//
-CDesCArray* CMPXDbPlugin::DoRemoveL(
-    const CMPXCollectionPath& aPath,
-    CMPXMessageArray& aChangeMsgArray)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveL");
-
-    if (aPath.Levels() <= 1)
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    // Return file path for deleted item(s)
-    //
-    CDesCArray* fp = new(ELeave) CDesCArrayFlat(1);
-    CleanupStack::PushL(fp);
-
-    // Ids of the selected items
-    RArray<TMPXItemId> selections;
-    CleanupClosePushL(selections);
-    aPath.SelectionL(selections);
-
-    switch (aPath.Id(1).iId2)
-        {
-        case EBrowseAll:
-            {
-            DoRemoveFromAllSongsL(aPath, selections.Array(), *fp, aChangeMsgArray);
-            }
-            break;
-
-        case EBrowseArtist:
-            {
-            DoRemoveFromArtistsL(aPath, selections.Array(), *fp, aChangeMsgArray);
-            }
-            break;
-
-        case EBrowseAlbum: // deliberate fall through
-        case EBrowseGenre: // deliberate fall through
-        case EBrowseComposer: // deliberate fall through
-            {
-            DoRemoveFromCategoriesL(aPath, selections.Array(),
-                CategoryForBrowseType(static_cast<TMCBrowseType>(aPath.Id(1).iId2)), *fp, aChangeMsgArray);
-            }
-            break;
-
-        case EBrowsePlaylist:
-            {
-            DoRemoveFromPlaylistsL(aPath, selections.Array(), *fp, aChangeMsgArray);
-            }
-            break;
-
-        default:
-            {
-            User::Leave(KErrArgument);
-            }
-        } // end switch (aPath.Id(1))
-
-    MPX_DEBUG2("CMPXDbPlugin::RemoveL itemId[%d]", aPath.Id(aPath.Levels() - 1).iId2);
-
-    CleanupStack::PopAndDestroy( &selections );
-    CleanupStack::Pop(fp);
-
-    return fp;
-    }
-
-// ----------------------------------------------------------------------------
-// Remove an item from the collection database using the given media properties
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveL(
-    const CMPXMedia& aMedia,
-    TBool aDeleteRecord)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveL(by media)");
-
-    // Return deleted file paths to caller
-    CDesCArray* fp = new(ELeave) CDesCArrayFlat(1);
-    CleanupStack::PushL(fp);
-
-    // a list of change event messages a result of the item being removed
-    CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
-    CleanupStack::PushL(itemChangedMessages);
-
-    TUint32 mediaId(0);
-
-    // Removing a container of items
-    //
-    if (aMedia.IsSupported(KMPXMediaArrayContents))
-        {
-        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing a container of items");
-        const CMPXMediaArray* media = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        if( !media )
-            {
-            User::Leave(KErrNoMemory);
-            }
-        const TInt mediaCount(media->Count());
-        for (TInt i = 0; i < mediaCount; ++i)
-            {
-            CMPXMedia* entry = media->AtL(i);
-            if (entry->IsSupported(KMPXMediaGeneralId))
-                {
-                mediaId = entry->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-                }
-            else if (entry->IsSupported(KMPXMediaGeneralUri))
-                {
-                const TDesC& uri = entry->ValueText(KMPXMediaGeneralUri);
-                mediaId = iDbHandler->GetSongIdMatchingUriL(uri);
-                }
-            else
-                {
-                // Unable to process this item
-                continue;
-                }
-
-            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
-            }
-        }
-    // Removing an item with known item id
-    //
-    else if (aMedia.IsSupported(KMPXMediaGeneralId))
-        {
-        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing an item by item id");
-        mediaId =  aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-
-        if (MPX_ITEM_CATEGORY(mediaId) != EMPXPlaylist)
-            {
-            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
-            }
-        else
-            {
-            iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
-            }
-        }
-    // Removing an item with known uri
-    //
-    else if (aMedia.IsSupported(KMPXMediaGeneralUri))
-        {
-        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Removing an item by uri");
-        TPtrC uri = aMedia.ValueText( KMPXMediaGeneralUri );
-
-        TMPXGeneralCategory category =
-            aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
-
-        if (category == EMPXSong)
-            {
-            mediaId = iDbHandler->GetSongIdMatchingUriL(uri);
-            iDbHandler->RemoveSongL(mediaId, *fp, *itemChangedMessages, aDeleteRecord);
-            }
-        else if (category == EMPXPlaylist)
-            {
-            mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri);
-            iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
-            }
-        else
-            {
-            // otherwise unable to process this item
-            }
-        }
-    else
-        {
-        MPX_DEBUG1("CMPXDbPlugin::RemoveL -- Unknown item for removal");
-        User::Leave(KErrNotSupported);
-        }
-
-    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-
-    // Removing an item always invalidates all songs.
-    //
-    MPXDbCommonUtil::AddItemChangedMessageL(*itemChangedMessages, EBrowseAll,
-                                            EMPXItemModified, EMPXCollection, KDBPluginUid);
-
-    DoHandleChangeL(itemChangedMessages);
-
-    CleanupStack::PopAndDestroy(itemChangedMessages);
-    CleanupStack::PopAndDestroy(fp);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove media by path through a command
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemovePathL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemovePathL(by command)");
-
-    TInt removeError(KErrNone);
-    TBool removeCompleted(ETrue);
-
-    if (!aCmd.IsSupported(KMPXCommandCollectionRemovePath) ||
-        !aCmd.IsSupported(KMPXCommandCollectionRemoveMediaCount))
-        {
-        removeError = KErrArgument;
-        }
-    else
-        {
-        CMPXCollectionPath* path =
-            aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCommandCollectionRemovePath);
-        CleanupStack::PushL(path);
-
-        // in order to support cancel delete for a category, we need to adjust path. If
-        // the path ends in a category, retrieve all songs under the selected category
-        // and append a new level with all songs under the selected category
-        DoAppendLevelL(*path);
-
-        CMPXCollectionPath* iterationPath = CMPXCollectionPath::NewL(*path);
-        CleanupStack::PushL(iterationPath);
-        iterationPath->ClearSelection();
-
-        // indices of the selected items
-        TArray<TInt> selectionIndices = path->Selection();
-        TInt count(selectionIndices.Count());
-
-        // number of media items to remove in this iteration
-        TInt removeCount = (aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionRemoveMediaCount));
-
-        // remove all in one shot if removeCount is 0 or negative
-        if (removeCount <= 0)
-            {
-            removeCount = count;
-            }
-
-        // If the given path contains multiple selections, remove the first n selected media
-        // and update the path so that client can use this path to call remove iteratively
-        // until all selections are processed
-        //
-        if (count)
-            {
-            for (TInt i = 0; i < removeCount; ++i)
-                {
-                TInt index(selectionIndices[i]);
-
-                MPX_DEBUG4(" path: selected item [index %d] [selectioncount %d] [remove count %d]", index, count, removeCount);
-
-                iterationPath->SelectL(index);
-                path->Remove(index);
-                }
-
-            aCmd.SetCObjectValueL(KMPXCommandCollectionRemovePath, path);
-
-            // indicate to the client that subsequent remove command is required
-            if ((count - removeCount) > 0)
-                {
-                removeCompleted = EFalse;
-                }
-            }
-
-        // Remove the media specified by the path
-        CDesCArray* fp(NULL);
-        TBool supressMsgs(EFalse);
-        CMPXMessageArray* msgAry(NULL);
-
-        if (aCmd.IsSupported(KMPXCommandCollectionRemoveSuppressMsgs) &&
-            aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveSuppressMsgs))
-            {
-            // Msgs are stored in the command
-            supressMsgs = ETrue;
-
-            CMPXMessageArray* msgs( aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionChangeMsgs) );
-            User::LeaveIfNull( msgs );
-            fp = DoRemoveL(*iterationPath, *msgs);
-            }
-        else
-            {
-            // Msgs will be sent after delete
-            msgAry = CMPXMessageArray::NewL();
-            CleanupStack::PushL(msgAry);
-            fp = DoRemoveL(*iterationPath, *msgAry);
-            }
-
-        CleanupStack::PushL(fp);
-        if (fp->MdcaCount() > removeCount)
-            {
-            removeError = KErrCorrupt;
-            }
-        CleanupStack::PopAndDestroy(fp);
-
-        if (!supressMsgs)
-            {
-            // Send Change Messages
-            iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-            DoHandleChangeL(msgAry);
-            CleanupStack::PopAndDestroy(msgAry);
-            }
-
-        // Cleanup
-        CleanupStack::PopAndDestroy(iterationPath);
-        CleanupStack::PopAndDestroy(path);
-        }
-
-    // mandatory return parameters
-    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveError, removeError);
-    aCmd.SetTObjectValueL<TBool>(KMPXCommandCollectionRemoveCompleted, removeCompleted);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove media by CMPXMedia through a command
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveMediaL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveMediaL(by command)");
-
-    TInt error(KErrArgument);
-
-    if (aCmd.IsSupported(KMPXCommandCollectionRemoveMedia))
-        {
-        CMPXMedia* media = aCmd.ValueCObjectL<CMPXMedia>(KMPXCommandCollectionRemoveMedia);
-        CleanupStack::PushL(media);
-
-        MPX_TRAP(error, DoRemoveL(*media,
-            aCmd.ValueTObjectL<TBool>(KMPXCommandCollectionRemoveMediaDeleteRecord)));
-
-        CleanupStack::PopAndDestroy(media);
-        }
-
-    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRemoveMediaError, error);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media/media items from All Songs view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveFromAllSongsL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXItemId>& aSelections,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveFromAllSongsL");
-
-    switch (aPath.Levels())
-        {
-        case 2:
-            {
-            // when the collection is removed, it's intended not to delete the files
-            iDbHandler->RemoveEntireCollectionL();
-            }
-            break;
-
-        case 3:
-            {
-            TInt count(aSelections.Count());
-            if (count)
-                {
-                for (TInt i = 0; i < count; ++i)
-                    {
-                    iDbHandler->RemoveSongL(aSelections[i].iId2, aUriArray, aItemChangedMessages);
-                    } // end for
-                }
-            else
-                {
-                iDbHandler->RemoveSongL(aPath.Id(aPath.Levels() - 1).iId2, aUriArray,
-                     aItemChangedMessages);
-                }
-            }
-            break;
-
-        default:
-            {
-            MPX_DEBUG2("CMPXDbPlugin_DoRemoveFromAllSongsL: Invalid levels[%d]", aPath.Levels());
-            User::Leave(KErrNotSupported);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media/media items from Artists view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveFromArtistsL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXItemId>& aSelections,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveFromArtistsL");
-
-    TInt levels(aPath.Levels());
-    if (levels == 2)
-        {
-        // when the collection is removed, it's intended not to delete the files
-        iDbHandler->RemoveEntireCollectionL();
-        }
-    else
-        {
-        TInt count(aSelections.Count());
-        if (count)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                RemoveFromArtistsL(aPath, aSelections[i].iId2, aUriArray, aItemChangedMessages);
-                }
-            }
-        else
-            {
-            RemoveFromArtistsL(aPath, aPath.Id(levels - 1).iId2, aUriArray, aItemChangedMessages);
-            }
-        }
-
-    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowseArtist: levels[%d]", levels);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media item from Artists view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::RemoveFromArtistsL(
-    const CMPXCollectionPath& aPath,
-    TUint32 aItemId,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::RemoveFromArtistsL");
-
-    switch (aPath.Levels())
-        {
-        case 3:
-            {
-            iDbHandler->RemoveSongsMatchingCategoryL(EMPXArtist, aItemId, aUriArray, aItemChangedMessages);
-            break;
-            }
-        case 4:
-            {
-            // remove the songs for the artist and album
-            iDbHandler->RemoveSongsMatchingArtistAndAlbumL(aPath.Id(aPath.Levels() - 2), aItemId,
-                aUriArray, aItemChangedMessages);
-            break;
-            }
-        case 5:
-            {
-            iDbHandler->RemoveSongL(aItemId, aUriArray, aItemChangedMessages);
-            break;
-            }
-        default:
-            {
-            User::Leave(KErrArgument);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media/media items from Albums/Genres/Composers view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveFromCategoriesL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXItemId>& aSelections,
-    TMPXGeneralCategory aCategory,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveFromCategoriesL");
-
-    TInt levels(aPath.Levels());
-    if (levels == 2)
-        {
-        // when the collection is removed, it's intended not to delete the files
-        iDbHandler->RemoveEntireCollectionL();
-        }
-    else
-        {
-        TInt count(aSelections.Count());
-        if (count)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                RemoveFromCategoriesL(aPath, aSelections[i].iId2, aCategory,
-                    aUriArray, aItemChangedMessages);
-                }
-            }
-        else
-            {
-            RemoveFromCategoriesL(aPath, aPath.Id(levels - 1).iId2, aCategory,
-                aUriArray, aItemChangedMessages);
-            }
-        }
-
-    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowseAlbum: levels[%d]", levels);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media item from Albums/Genres/Composers view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::RemoveFromCategoriesL(
-    const CMPXCollectionPath& aPath,
-    TUint32 aItemId,
-    TMPXGeneralCategory aCategory,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::RemoveFromCategoriesL");
-
-    switch (aPath.Levels())
-        {
-        case 3:
-            {
-            iDbHandler->RemoveSongsMatchingCategoryL(aCategory, aItemId, aUriArray,
-                aItemChangedMessages);
-            break;
-            }
-        case 4:
-            {
-            iDbHandler->RemoveSongL(aItemId, aUriArray, aItemChangedMessages);
-            break;
-            }
-        default:
-            {
-            User::Leave(KErrArgument);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Remove one or multiple media items from Playlists view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRemoveFromPlaylistsL(
-    const CMPXCollectionPath& aPath,
-    const TArray<TMPXItemId>& aSelections,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRemoveFromPlaylistsL");
-
-    TInt levels(aPath.Levels());
-
-    // all playlists
-    if (levels == 2)
-        {
-        // when the collection is removed, it's intended not to delete the files
-        iDbHandler->RemoveAllPlaylistsL();
-        }
-    else
-        {
-        TArray<TInt> selectionIndices = aPath.Selection();
-        TInt count(selectionIndices.Count());
-
-        // multiple selections
-        if (count)
-            {
-            for (TInt i = (count - 1); i >= 0; --i)
-                {
-                RemoveFromPlaylistsL(aPath, aSelections[i], selectionIndices[i],
-                    aUriArray, aItemChangedMessages);
-                }
-            }
-        // else no selection
-        else
-            {
-            RemoveFromPlaylistsL(aPath, aPath.IdOfIndex(aPath.Index()), aPath.Index(),
-                aUriArray, aItemChangedMessages);
-            }
-        }
-
-    MPX_DEBUG2("CMPXDbPlugin__RemoveL__EBrowsePlaylist: levels[%d]", levels);
-    }
-
-// ----------------------------------------------------------------------------
-// Remove a media item from Playlists view
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::RemoveFromPlaylistsL(
-    const CMPXCollectionPath& aPath,
-    const TMPXItemId& aItemId,
-    TInt aIndex,
-    CDesCArray& aUriArray,
-    CMPXMessageArray& aItemChangedMessages)
-    {
-    MPX_FUNC("CMPXDbPlugin::RemoveFromPlaylistsL");
-
-    switch (aPath.Levels())
-        {
-        case 3:
-            {
-            iDbHandler->RemovePlaylistL(aItemId.iId2, aUriArray, aItemChangedMessages);
-            break;
-            }
-        case 4:
-            {
-            if ( !iDbHandler->InTransaction() )
-                {
-                iDbHandler->BeginTransactionL();
-                }
-            iDbHandler->RemoveSongFromPlaylistL(aPath.Id(aPath.Levels() - 2).iId2, aItemId,
-                aIndex, aItemChangedMessages);
-            break;
-            }
-        default:
-            {
-            User::Leave(KErrArgument);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Retrieve URIs associated with this file path for file deletion
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoRetrieveUriForDeletionL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoRetrieveUriForDeletionL");
-
-    // initialize mandatory return parameters
-    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrNone);
-
-    if (!aCmd.IsSupported(KMPXCommandCollectionRetrievePath))
-        {
-        aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionRetrieveUriError, KErrArgument);
-        }
-    else
-        {
-        CMPXCollectionPath* path = aCmd.ValueCObjectL<CMPXCollectionPath>(KMPXCommandCollectionRetrievePath);
-        CleanupStack::PushL(path);
-        if (iFirstDeleteStep )
-            {
-            iSelections.Reset( );
-        // in order to support cancel delete for a category, we need to adjust path. If
-        // the path ends in a category, retrieve all songs under the selected category
-        // and append a new level with all songs under the selected category
-        DoAppendLevelL(*path);
-
-        // Ids of the selected items
-            path->SelectionL(iSelections );
-
-        // single selection
-            if (iSelections.Count()== 0 )
-                {
-                iSelections.AppendL(path->Id (path->Levels()- 1 ) );
-                }
-            }
-
-        CDesCArray* fp = new(ELeave) CDesCArrayFlat(4);
-        CleanupStack::PushL(fp);
-
-        TInt count(iSelections.Count());
-        TInt itemCount = count > KIncrementalDeleteCount ? KIncrementalDeleteCount : count;
-        for (TInt i = 0; i < itemCount; ++i )
-            {
-            // do not report song URIs if collection path is for songs within a playlist, i.e.
-            // EBrowsePlaylist and level 4, because client should not be deleting those song
-            // files
-            if (path->Id(1) != EBrowsePlaylist || path->Levels() !=4)
-                {
-                HBufC * uri = iDbHandler->GetUriMatchingIdL (iSelections[0].iId2 );
-                CleanupStack::PushL(uri);
-                fp->AppendL(*uri);
-                CleanupStack::PopAndDestroy(uri);
-                }
-            iSelections.Remove(0);
-            }
-
-        aCmd.SetNoNewLCObjectL(KMPXCommandCollectionRetrieveMediaUriArray, fp);
-        if (iFirstDeleteStep)
-            {
-        aCmd.SetCObjectValueL(KMPXCommandCollectionRetrievePath, path);
-            }
-
-        CleanupStack::PopAndDestroy(fp);
-        CleanupStack::PopAndDestroy(path);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Cleanup deleted records
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::CleanupDeletedRecordsL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::CleanupDeletedRecordsL");
-
-    MPX_TRAPD(error, iDbHandler->CleanupDeletedRecordsL());
-    aCmd.SetTObjectValueL<TInt>(KMPXCommandCollectionCleanupError, error);
-    }
-
-// ----------------------------------------------------------------------------
-// Find the duration
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlugin::DoDurationL(
-    CMPXMedia& aMedia,
-    TMPXGeneralCategory aFirstCat,
-    TMPXItemId aId,
-    TMPXGeneralCategory aSecondCat,
-    TMPXItemId aSubId)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoDurationL");
-
-    TInt duration(0);
-
-    switch (aFirstCat)
-        {
-        case EMPXSong:
-            {
-            duration = iDbHandler->GetAllSongsDurationL();
-            break;
-            }
-        case EMPXAlbum:
-            {
-            duration = iDbHandler->GetAlbumDurationL(aId.iId2);
-            break;
-            }
-        case EMPXComposer:
-            {
-            duration = iDbHandler->GetComposerDurationL(aId.iId2);
-            break;
-            }
-        case EMPXGenre:
-            {
-            duration = iDbHandler->GetGenreDurationL(aId.iId2);
-            break;
-            }
-        case EMPXArtist:
-            {
-            if (aSecondCat == EMPXAlbum)
-                {
-                duration = iDbHandler->GetArtistAlbumDurationL(aId.iId2, aSubId.iId2);
-                }
-            else
-                {
-                duration = iDbHandler->GetArtistDurationL(aId.iId2);
-                }
-            break;
-            }
-        case EMPXPlaylist:
-            {
-            duration = iDbHandler->GetPlaylistDurationL(aId.iId2);
-            break;
-            }
-        default:
-            {
-            User::Leave(KErrNotSupported);
-            }
-        }
-
-    aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration);
-    return duration;
-    }
-
-// ----------------------------------------------------------------------------
-// Append a level to a collection path and set selection to the first item
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbPlugin::DoAppendLevelL(
-    CMPXCollectionPath& aPath,
-    CMPXMedia& aMedia )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAppendLevelL");
-
-    RArray<TMPXItemId> ids;
-    CleanupClosePushL(ids);
-
-    // Extract media array, and get all item ids
-    //
-    const CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-    if( !mediaArray )
-        {
-        User::Leave( KErrNoMemory );
-        }
-
-    TInt count(mediaArray->Count());
-    if (count >= 0)
-        {
-        for (TInt i = 0; i < count; ++i)
-            {
-            TMPXItemId id = mediaArray->AtL(i)->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-            ids.AppendL(id);
-            }
-
-        // Put item id array into the path and select the first one
-        aPath.AppendL(ids.Array());
-        if (count > 0)
-            {
-            aPath.Set(0);
-            }
-        }
-
-    CleanupStack::PopAndDestroy(&ids);
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// Append a level to a collection path and set selection to all songs under the
-// selected category/categories
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoAppendLevelL(
-    CMPXCollectionPath& aPath)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAppendLevelL");
-
-    TMPXItemId contextId(aPath.Id(1));
-    TInt levels(aPath.Levels());
-
-    if ((contextId == EBrowseAll) ||
-        (contextId == EBrowsePlaylist))
-        {
-        return;
-        }
-    else if (levels == 3 || (levels == 4 && contextId == EBrowseArtist))
-        {
-        // retrieve songs in the selected category
-        //
-        CMPXMediaArray* songs = CMPXMediaArray::NewL();
-        CleanupStack::PushL(songs);
-
-        RArray<TMPXAttribute> attributes;
-        CleanupClosePushL(attributes);
-        attributes.AppendL(KMPXMediaGeneralId);
-
-        // Ids of the selected items
-        RArray<TMPXItemId> selections;
-        CleanupClosePushL(selections);
-        aPath.SelectionL(selections);
-
-        // single selection
-        if (selections.Count() == 0)
-            {
-            selections.AppendL(aPath.Id(aPath.Levels() - 1));
-            }
-
-        TInt count(selections.Count());
-
-        // all songs for the selected artist
-        if (contextId == EBrowseArtist && levels == 3)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                iDbHandler->GetSongsMatchingArtistL(selections[i].iId2, attributes.Array(), songs);
-                }
-            if (songs->Count())
-                {
-                aPath.AppendL(selections.Array());
-                }
-            }
-
-        // all songs for the selected artist in the specified album
-        else if ((contextId == EBrowseArtist) && (levels == 4))
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                if (aPath.Id(2) == aPath.Id(3))
-                    {
-                    iDbHandler->GetSongsMatchingArtistL(aPath.Id(3).iId2,
-                        attributes.Array(), songs);
-                    }
-                else
-                    {
-                    iDbHandler->GetSongsMatchingArtistAndAlbumL(aPath.Id(aPath.Levels() - 2),
-                        selections[i].iId2, attributes.Array(), songs);
-                    }
-                }
-            }
-
-         // all songs for the selected album
-        else if (contextId == EBrowseAlbum && levels == 3)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                iDbHandler->GetSongsMatchingAlbumL(selections[i], attributes.Array(), songs);
-                }
-            }
-
-        // all songs for the selected genre
-        else if (contextId == EBrowseGenre && levels == 3)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                iDbHandler->GetSongsMatchingGenreL(selections[i], attributes.Array(), songs);
-                }
-            }
-
-        // all songs for the selected composer
-        else if (contextId == EBrowseComposer && levels == 3)
-            {
-            for (TInt i = 0; i < count; ++i)
-                {
-                iDbHandler->GetSongsMatchingComposerL(selections[i], attributes.Array(), songs);
-                }
-            }
-        else
-            {
-            // else do nothing
-            }
-
-        CleanupStack::PopAndDestroy(&selections);
-        CleanupStack::PopAndDestroy(&attributes);
-
-        // transform from CMPXMediaArray to RArray
-        RArray<TMPXItemId> songIds;
-        CleanupClosePushL(songIds);
-
-        TInt songCount(songs->Count());
-        for (TInt i = 0; i < songCount; ++i)
-            {
-            CMPXMedia* song = (*songs)[i];
-
-            if (song->IsSupported(KMPXMediaGeneralId))
-                {
-                songIds.AppendL(song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
-                }
-            }
-
-        // modify the collection path. append another level with all songs under the selected
-        // category/categories selected
-        songCount = songIds.Count();
-
-        if (songCount)
-            {
-            aPath.ClearSelection();
-            aPath.AppendL(songIds.Array());
-
-            // select all
-            for (TInt i = 0; i < songCount; ++i)
-                {
-                aPath.SelectL(songIds[i]);
-                }
-            }
-
-        CleanupStack::PopAndDestroy(&songIds);
-        CleanupStack::PopAndDestroy(songs);
-        }
-    else
-        {
-        // do nothing
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Execute an Add task step
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoAddAsyncL()
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAddAsyncL");
-
-    TBool done(EFalse);
-    const CMPXMedia* task = (iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColAddMedia));
-    if( !task )
-        {
-        User::Leave(KErrNoMemory);
-        }
-
-    CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages();
-
-    if (!task->IsSupported(KMPXMediaGeneralType))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    // Group of items or a single item
-    //
-    if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
-        {
-        if (!task->IsSupported(KMPXMediaArrayContents))
-            {
-            User::Leave(KErrArgument);
-            }
-
-        CMPXMediaArray* ary = task->Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        User::LeaveIfNull(ary);
-        TInt step( iActiveTask->GetStep() );
-        DoAddItemL( *ary->AtL(step), msgArray );
-
-        if (++step == ary->Count())
-            {
-            done = ETrue;
-            }
-        }
-    else // type == EMPXItem
-        {
-        TUint32 item = DoAddItemL( *task, msgArray );
-        iActiveTask->GetCommand().SetTObjectValueL<TMPXItemId>( KMPXCommandColAddRtnId, item);
-        done = ETrue;
-        }
-
-    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-    return done;
-    }
-
-// ----------------------------------------------------------------------------
-// Add an item to the collection
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlugin::DoAddL(
-    const CMPXMedia& aMedia)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAddL");
-
-    if (!aMedia.IsSupported(KMPXMediaGeneralType))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    TUint32 itemId(0);
-    CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL();
-    CleanupStack::PushL(changeMsgAry);
-
-	// start a transaction here
-	if (!iDbHandler->InTransaction())
-		{
-		iDbHandler->BeginTransactionL();
-		}
-
-    // Group of items
-    if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
-        {
-        CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        User::LeaveIfNull( array );
-
-        TInt count(array->Count());
-        for (TInt i = 0; i < count; ++i)
-            {
-            // ETrue indicates we are batch committing the songs.
-            // This parameter is only used for the use case of adding
-            // thousands of songs at a time.
-            DoAddItemL(*array->AtL(i), *changeMsgAry, ETrue);
-            }
-        }
-    else // single item
-        {
-        itemId = DoAddItemL(aMedia, *changeMsgAry);
-        }
-
-	// end transaction here.
-	iDbHandler->EndTransactionL(KErrNone);
-
-    iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-    DoHandleChangeL(changeMsgAry);
-    CleanupStack::PopAndDestroy(changeMsgAry);
-
-    return itemId;
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Add an item to the collection
-// ----------------------------------------------------------------------------------------------------------
-//
-TUint32 CMPXDbPlugin::DoAddItemL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aMessageArray,
-    TBool aBatchCommit)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoAddItemL");
-
-    TUint32 itemId(0);
-    if (!aMedia.IsSupported(KMPXMediaGeneralCategory))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    switch (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory))
-        {
-        case EMPXPlaylist:
-            {
-            if (!aMedia.IsSupported(KMPXMediaArrayContents))
-                {
-                User::Leave(KErrArgument);
-                }
-
-            if (aMedia.IsSupported(KMPXMediaGeneralId))
-                {
-                itemId = iDbHandler->AddSongToPlaylistL(aMedia);
-                MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemModified,
-                    EMPXPlaylist, KDBPluginUid);
-                }
-            else if (aMedia.IsSupported(KMPXMediaGeneralUri))
-                {
-                itemId = iDbHandler->AddPlaylistL(aMedia);
-                MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, EBrowsePlaylist, EMPXItemInserted,
-                    EMPXPlaylist, KDBPluginUid);
-                }
-            else
-                {
-                User::Leave(KErrArgument);
-                }
-            }
-            break;
-
-        case EMPXSong:
-            {
-            // For the use case of adding thousands of songs at once,
-            // we do not create a new database transaction for each song; 
-            // Instead DoAddL() will batch 100 songs under a single transaction.
-            // This enhancement improves performance with MMC-based databases.
-            if (aBatchCommit)
-                {
-                itemId = iDbHandler->AddSongWithNoTransactionL(aMedia, &aMessageArray);
-                }
-            else
-                {
-                itemId = iDbHandler->AddSongL(aMedia, &aMessageArray);
-                }
-            
-            MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemInserted,
-                EMPXSong, KDBPluginUid);
-            }
-            break;
-
-        default:
-            {
-            User::Leave(KErrNotSupported);
-            }
-        }
-
-    return itemId;
-    }
-
-// ----------------------------------------------------------------------------
-// Update the collection from a media
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoSetL(
-    const CMPXMedia& aMedia )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoSetL");
-
-    if (!aMedia.IsSupported(KMPXMediaGeneralType))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
-
-    CMPXMessageArray* changeMsgArray = CMPXMessageArray::NewL();
-    CleanupStack::PushL(changeMsgArray);
-
-    if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
-        {
-        if (!aMedia.IsSupported(KMPXMediaArrayContents))
-            {
-            User::Leave(KErrArgument);
-            }
-
-        CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        User::LeaveIfNull( array );
-        TInt count( array->Count() );
-        for (TInt i = 0; i < count; ++i)
-            {
-            visibleChange = (CMPXDbActiveTask::TChangeVisibility)(visibleChange | DoSetItemL(*array->AtL(i), *changeMsgArray));
-            }
-        }
-    else
-        {
-        visibleChange = DoSetItemL(aMedia, *changeMsgArray);
-        }
-
-    // Handle Change Events
-    if (visibleChange)
-        {
-        iActiveTask->SetVisibleChange(visibleChange);
-        DoHandleChangeL(changeMsgArray);
-        }
-    CleanupStack::PopAndDestroy(changeMsgArray);
-    }
-
-// ----------------------------------------------------------------------------
-// Execute a task step for async set
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbPlugin::DoSetAsyncL()
-    {
-    MPX_FUNC("CMPXDbPlugin::DoSetAsyncL");
-
-    TBool done(EFalse);
-    CMPXMedia* task = iActiveTask->GetCommand().Value<CMPXMedia>(KMPXCommandColSetMedia);
-    User::LeaveIfNull( task );
-
-    CMPXMessageArray& msgArray = iActiveTask->GetChangeMessages();
-    CMPXDbActiveTask::TChangeVisibility visibleChange(iActiveTask->GetVisibleChange());
-
-    // Multiple steps can be in a transaction for faster response
-    if( !iDbHandler->InTransaction() )
-        {
-        iDbHandler->BeginTransactionL();
-        }
-
-    if (!task->IsSupported(KMPXMediaGeneralType))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    if (task->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
-        {
-        if (!task->IsSupported(KMPXMediaArrayContents))
-            {
-            User::Leave(KErrArgument);
-            }
-
-        // Multiple items
-        CMPXMediaArray* array = task->Value<CMPXMediaArray>(KMPXMediaArrayContents);
-        User::LeaveIfNull( array );
-        TInt step = iActiveTask->GetStep();
-        visibleChange = (CMPXDbActiveTask::TChangeVisibility)(visibleChange | DoSetItemL(*array->AtL(step), msgArray));
-
-        if (++step == array->Count())
-            {
-            done = ETrue;
-            }
-        }
-    else // Single item
-        {
-        visibleChange = DoSetItemL(*task, msgArray);
-        done = ETrue;
-        }
-    iActiveTask->SetVisibleChange(visibleChange);
-    return done;
-    }
-
-// ----------------------------------------------------------------------------
-// Update the collection from a media
-// ----------------------------------------------------------------------------
-//
-CMPXDbActiveTask::TChangeVisibility CMPXDbPlugin::DoSetItemL(
-    const CMPXMedia& aMedia,
-    CMPXMessageArray& aMessageArray )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoSetItemL");
-
-    TMPXGeneralCategory category = aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
-
-    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
-    switch (category)
-        {
-        case EMPXPlaylist:
-            {
-            if (aMedia.IsSupported(KMPXMediaArrayContents))
-                {
-                CMPXMessage* message = CMPXMedia::NewL();
-                CleanupStack::PushL(message);
-
-                iDbHandler->UpdatePlaylistSongsL(aMedia, *message);
-
-                aMessageArray.AppendL(message); // ownership xfer
-                CleanupStack::Pop(message);
-                }
-            else
-                {
-                iDbHandler->UpdatePlaylistL(aMedia, aMessageArray);
-                }
-
-            visibleChange = CMPXDbActiveTask::ESingleVisible;
-            }
-            break;
-
-        case EMPXSong:
-            {
-            // a list of changed messages as a result of the song being updated
-            visibleChange = iDbHandler->UpdateSongL(aMedia, aMessageArray);
-            }
-            break;
-
-        default:
-            {
-            User::Leave(KErrNotSupported);
-            }
-            break;
-        }
-    return visibleChange; // ownership xfer
-    }
-
-// ----------------------------------------------------------------------------
-// Sets the drm properties for a list of medias
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoSetDrmForArrayL(
-    const CMPXMediaArray& mediaArray,
-    const TArray<TMPXAttribute>& aAttrs)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoSetDrmForArrayL");
-
-    TUint drmAttributes(0);
-
-    // Compact the attribute set
-    //
-    TInt attrCount(aAttrs.Count());
-    for (TInt i = 0; i < attrCount; ++i)
-        {
-        if (aAttrs[i].ContentId() == KMPXMediaIdDrm)
-            {
-            drmAttributes |= aAttrs[i].AttributeId();
-            }
-        }
-
-    // Fetch drm attributes for every item
-    //
-    if (drmAttributes)
-        {
-        TInt count(mediaArray.Count());
-        for (TInt i = 0; i < count; ++i)
-            {
-            if (mediaArray[i]->IsSupported(KMPXMediaGeneralUri))
-                {
-                DoSetMediaDrmL(*mediaArray[i], drmAttributes,
-                    mediaArray[i]->ValueText(KMPXMediaGeneralUri));
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Handle change events
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::HandleChangeL(
-    const CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbPlugin::HandleChange");
-
-    // check if message is filled
-    if (aMessage.IsSupported(KMPXMessageGeneralId))
-        {
-#if _DEBUG
-        PrintMessagesL(aMessage);
-#endif // _DEBUG
-        if(iRefreshing)
-            {
-            if (aMessage.IsSupported(KMPXMessageArrayContents))
-                {
-                const CMPXMessageArray* messageArray = aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents);
-                if(messageArray)
-                    {
-                    CMPXMessage& message = *((*messageArray)[0]);
-                    TMPXChangeEventType changeType( message.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
-                    TMPXGeneralCategory cat(message.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
-                    if(changeType == EMPXItemInserted && (cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast))
-                        {
-                        iObs->HandleMessage(aMessage);
-                        }
-                    }
-                }
-            else
-                {
-                TMPXChangeEventType changeType( aMessage.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
-                TMPXGeneralCategory cat(aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
-                if(changeType == EMPXItemInserted && (cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast))
-                    {
-                    iObs->HandleMessage(aMessage);
-                    }
-                }
-            }
-        else
-            {
-            if(!iMtpInUse)
-                {
-                iObs->HandleMessage(aMessage);
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Construct a CMPXMedia and call HandleChange
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoHandleChangeL(
-    CMPXMessageArray* aItemChangedMessages,
-    TMPXCommandId aCommandId )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoHandleChangeL");
-
-    if( (iActiveTask->GetVisibleChange() & CMPXDbActiveTask::EAllVisible)
-        && (aCommandId == KMPXCommandIdCollectionSet ||
-            aCommandId == KMPXCommandIdCollectionAdd ||
-            aCommandId == KMPXCommandIdCollectionRemove ||
-            aCommandId == KMPXCommandIdCollectionCompleteDelete ))
-        {
-        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, EBrowseAll,
-                                                 EMPXItemModified, EMPXCollection, KDBPluginUid);
-        }
-    // group change messages and send to collection client context
-    //
-    CMPXMessage* message = CMPXMessage::NewL();
-    CleanupStack::PushL(message);
-
-    message->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KMPXMessageIdItemChanged);
-    message->SetCObjectValueL(KMPXMessageArrayContents, aItemChangedMessages);
-    message->SetTObjectValueL<TInt>(KMPXMessageArrayCount, aItemChangedMessages->Count());
-
-    HandleChangeL(*message);
-
-    CleanupStack::PopAndDestroy(message);
-    }
-
-// ----------------------------------------------------------------------------
-// Handle completion of operation
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoHandleOperationCompletedL(
-    TInt aErr)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoHandleOperationCompletedL");
-
-    // Broadcase change messages
-    //
-    if (iActiveTask->GetVisibleChange())
-        {
-        DoHandleChangeL(&iActiveTask->GetChangeMessages(), iActiveTask->GetTask() );
-        }
-
-    // Callback to engine to signal completion
-    // NOTE: Collection server immediately completes the async message when
-    // Cancel is called, no need to callback to observer
-    if (aErr != KErrCancel)
-        {
-        iObs->HandleCommandComplete(NULL, aErr);
-        }
-
-    if( iDbHandler->InTransaction() )
-        {
-        // Commit if cancelled
-        TInt err(aErr);
-        if( err == KErrCancel )
-            {
-            err = KErrNone;
-            }
-        iDbHandler->EndTransactionL( err );
-        }
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Complete a delete operation
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoHandleDeleteCompleteL(
-    CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoHandleDeleteCompleteL");
-    iFirstDeleteStep = ETrue;
-    iSelections.Reset();
-    if ( iDbHandler->InTransaction() )
-        {
-        // if it can reach this point in a transaction, there's no error
-        iDbHandler->EndTransactionL( KErrNone );
-        }
-
-    // Change messages
-    if (aCmd.IsSupported(KMPXCommandCollectionDeleteMsgArray))
-        {
-        CMPXMessageArray* msgs = aCmd.Value<CMPXMessageArray>(KMPXCommandCollectionDeleteMsgArray);
-        User::LeaveIfNull( msgs );
-        iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
-        DoHandleChangeL(msgs, KMPXCommandIdCollectionCompleteDelete);
-        }
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Reorder a song in a playlist
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoReorderPlaylistL(
-    const CMPXCommand& aCmd)
-    {
-    MPX_FUNC("CMPXDbPlugin::DoReorderPlaylistL");
-
-    if (!aCmd.IsSupported(KMPXCommandReorderPlaylistId) ||
-        !aCmd.IsSupported(KMPXCommandReorderSongId) ||
-        !aCmd.IsSupported(KMPXCommandReorderOriginalOrdinal) ||
-        !aCmd.IsSupported(KMPXCommandReorderNewOrdinal))
-        {
-        User::Leave(KErrArgument);
-        }
-
-    CMPXMessage* message = CMPXMedia::NewL();
-    CleanupStack::PushL(message);
-
-    iDbHandler->ReorderPlaylistL(
-        aCmd.ValueTObjectL<TMPXItemId>(KMPXCommandReorderPlaylistId),
-        aCmd.ValueTObjectL<TMPXItemId>(KMPXCommandReorderSongId),
-        aCmd.ValueTObjectL<TUint>(KMPXCommandReorderOriginalOrdinal),
-        aCmd.ValueTObjectL<TUint>(KMPXCommandReorderNewOrdinal),
-        *message);
-
-    HandleChangeL(*message);
-
-    CleanupStack::PopAndDestroy(message);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Get total songs and playlists count for a database
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoGetCollectionCountL( const CMPXCommand& aCmd )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoGetCollectionCountL");
-    if (!aCmd.IsSupported(KMPXCommandCollectionCountDrive) ||
-        !aCmd.IsSupported(KMPXCommandCollectionCountTable) )
-        {
-        User::Leave(KErrArgument);
-        }
-
-    TInt count = 0;
-    TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionCountDrive);
-    TInt table = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionCountTable);
-    switch(table)
-        {
-        case EMPXCollectionCountTrack:
-            count = (TInt)iDbHandler->GetMusicCountL(drive);
-            break;
-        case EMPXCollectionCountPlaylist:
-            count = (TInt)iDbHandler->GetPlaylistCountL(drive);
-            break;
-        case EMPXCollectionCountTotal:
-            count = (TInt)iDbHandler->GetTotalCountL(drive);
-            break;
-        default:
-            User::Leave(KErrArgument);
-        }
-    ((CMPXMedia&)aCmd).SetTObjectValueL<TInt>(KMPXCommandCollectionCountValue, count);
-    }
-
-// ----------------------------------------------------------------------------------------------------------
-// Get URIs for all songs and file playlists in a database
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoGetCollectionUriL( const CMPXCommand& aCmd )
-    {
-    MPX_FUNC("CMPXDbPlugin::DoGetCollectionCountL");
-    if (!aCmd.IsSupported(KMPXCommandCollectionURIDrive) ||
-        !aCmd.IsSupported(KMPXCommandCollectionURITable) ||
-        !aCmd.IsSupported(KMPXCommandCollectionURIFromID) ||
-        !aCmd.IsSupported(KMPXCommandCollectionURIRecords) )
-        {
-        User::Leave(KErrArgument);
-        }
-
-    TInt drive = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIDrive);
-    TInt table = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURITable);
-    TInt fromID = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIFromID);
-    TInt recnum = aCmd.ValueTObjectL<TInt>(KMPXCommandCollectionURIRecords);
-
-    CDesCArray* uris = new(ELeave) CDesCArrayFlat(4);
-    CleanupStack::PushL(uris);
-    TInt lastID = 0;
-
-    switch(table)
-        {
-        case EMPXCollectionURITrack:
-            iDbHandler->GetMusicUriArrayL(drive, fromID, recnum, *uris, lastID);
-            break;
-        case EMPXCollectionURIPlaylist:
-            iDbHandler->GetPlaylistUriArrayL(drive, fromID, recnum, *uris, lastID);
-            break;
-        default:
-            User::Leave(KErrArgument);
-        }
-
-    ((CMPXMedia&)aCmd).SetNoNewLCObjectL(KMPXCommandCollectionURIList, uris);
-    ((CMPXMedia&)aCmd).SetTObjectValueL(KMPXCommandCollectionURILastID, lastID);
-    CleanupStack::PopAndDestroy(uris);
-    }
-
-
-// ----------------------------------------------------------------------------------------------------------
-// Perform one step of the incremental operation
-// ----------------------------------------------------------------------------------------------------------
-//
-void CMPXDbPlugin::DoIncrementalOpenL( const CMPXCommand& aCmd )
-    {
-    MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL <--");
-
-    TInt offset = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLOffset );
-    TInt numItems = aCmd.ValueTObjectL<TInt>( KMPXCollectionCommandIdIncOpenLNumItems );
-
-    TReadDirection direction(EReadUnknown);
-    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 );
-
-    // Switch on level and item selected
-    //
-    TInt levels( path->Levels() );
-    switch( levels )
-        {
-        case 3:  // levels of 3 top level is not stripped
-            {
-            switch( path->Id(1).iId2 )
-                {
-                case EBrowseAll:
-                    {
-                    CMPXMedia* results = CMPXMedia::NewL();
-                    CleanupStack::PushL( results );
-
-                    TMPXOpenDataBlock block;
-                    block.iOffset = offset;
-                    block.iSize = numItems;
-
-                    // Todo: this should come from the UI
-                    RArray<TMPXAttribute> attrs;
-                    CleanupClosePushL( attrs );
-                    attrs.AppendL(TMPXAttribute(KMPXMediaIdGeneral,
-                                   EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
-                                   EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri));
-                    attrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-                                        EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
-
-                    // Array to read data from
-                    CMPXMediaArray* array = CMPXMediaArray::NewL();
-                    CleanupStack::PushL( array );
-
-                    // Do we have to use offset or can we use asc/dsc
-                    //
-                    if( direction == EReadUnknown )
-                        {
-                        iDbHandler->GetSongsAtOffsetL( array, attrs.Array(), offset, numItems );
-                        }
-                    else
-                        {
-                        iDbHandler->GetSongsInBlockL( array, attrs.Array(),
-                                                      aCmd.ValueText( KMPXCollectionCommandIdIncOpenLKeyItem ),
-                                                      numItems,
-                                                      direction );
-                        }
-
-                    TInt max( path->Count() );
-                    TInt count(0);
-                    TInt aryCount( array->Count() );
-                    // Update the collection path
-                    while( count<numItems && offset<max &&
-                           count<aryCount )
-                        {
-                        TMPXItemId id = array->AtL(count)->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-                        path->Update( offset, id );
-
-                        // Next items
-                        offset++;
-                        count++;
-                        }
-
-                    // Setup the results
-                    //
-                    results->SetCObjectValueL(KMPXMediaArrayContents, array);
-                    results->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-                    CleanupStack::PopAndDestroy( array );
-                    CleanupStack::PopAndDestroy( &attrs );
-
-                    // Callback with results
-                    //
-                    results->SetTObjectValueL<TMPXOpenDataBlock>( KMPXCollectionOpenLResultRange, block );
-                    iObs->HandleOpen( results, path, KErrNone );
-                    CleanupStack::PopAndDestroy( results );
-                    break;
-                    }
-                default:
-                    User::Leave(KErrNotSupported);
-                    break;
-                }
-            break;
-            }
-        default:
-            {
-            User::Leave(KErrNotSupported);
-            break;
-            }
-
-        }
-    CleanupStack::PopAndDestroy( path );
-
-    MPX_DEBUG1("CMPXDbPlugin::DoIncrementalOpenL -->");
-    }
-
-// ----------------------------------------------------------------------------
-// Maps a given browse type to a category ID.
-// ----------------------------------------------------------------------------
-//
-TMPXGeneralCategory CMPXDbPlugin::CategoryForBrowseType(
-    TMCBrowseType aBrowseType)
-    {
-    MPX_FUNC("CMPXDbPlugin::CategoryForBrowseType");
-
-    TMPXGeneralCategory cat(EMPXNoCategory);
-
-    switch (aBrowseType)
-        {
-        case EBrowseAll:
-            {
-            cat = EMPXSong;
-            break;
-            }
-        case EBrowseArtist:
-            {
-            cat = EMPXArtist;
-            break;
-            }
-        case EBrowseAlbum:
-            {
-            cat = EMPXAlbum;
-            break;
-            }
-        case EBrowsePlaylist:
-            {
-            cat = EMPXPlaylist;
-            break;
-            }
-        case EBrowseGenre:
-            {
-            cat = EMPXGenre;
-            break;
-            }
-        case EBrowseComposer:
-            {
-            cat = EMPXComposer;
-            break;
-            }
-#ifdef __ENABLE_PODCAST_IN_MUSIC_MENU
-        case EBrowsePodcasts:
-            {
-            cat = EMPXPodcast;
-            break;
-            }
-#endif
-        default:
-            {
-            // do nothing
-            break;
-            }
-        }
-
-    return cat;
-    }
-
-// ----------------------------------------------------------------------------
-// Maps a given category ID to a browse type.
-// ----------------------------------------------------------------------------
-//
-TMCBrowseType CMPXDbPlugin::BrowseTypeForCategory(
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("CMPXDbPlugin::BrowseTypeForCategory");
-
-    TMCBrowseType browseType(EBrowseComposer);
-
-    switch (aCategory)
-        {
-        case EMPXSong:
-            {
-            browseType = EBrowseAll;
-            break;
-            }
-        case EMPXArtist:
-            {
-            browseType = EBrowseArtist;
-            break;
-            }
-        case EMPXAlbum:
-            {
-            browseType = EBrowseAlbum;
-            break;
-            }
-        case EMPXPlaylist:
-            {
-            browseType = EBrowsePlaylist;
-            break;
-            }
-        case EMPXGenre:
-            {
-            browseType = EBrowseGenre;
-            break;
-            }
-        default:
-            {
-            // do nothing
-            break;
-            }
-        }
-
-    return browseType;
-    }
-
-// ----------------------------------------------------------------------------
-// Sets the type, category and title attributes in the specified media instance
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::SetMediaGeneralAttributesL(
-    CMPXMedia& aMedia,
-    TMPXGeneralType aType,
-    TMPXGeneralCategory aCategory,
-    const TDesC& aTitle)
-    {
-    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, aType);
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, aCategory);
-    aMedia.SetTextValueL(KMPXMediaGeneralTitle, aTitle);
-    }
-
-// ----------------------------------------------------------------------------
-// Sets the type, category and title attributes in the specified media instance
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::SetMediaGeneralAttributesL(
-    CMPXMedia& aMedia,
-    TMPXGeneralType aType,
-    TMPXGeneralCategory aCategory,
-    TInt aId)
-    {
-    MPX_FUNC("CMPXDbPlugin::SetMediaGeneralAttributesL");
-
-    HBufC* title = iDbHandler->GetNameMatchingIdL(aId);
-    CleanupStack::PushL(title);
-    SetMediaGeneralAttributesL(aMedia, aType, aCategory, *title);
-    CleanupStack::PopAndDestroy(title);
-    }
-
-// ----------------------------------------------------------------------------
-// Set the attribute list according to current path
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::SetAttributesL(
-    const CMPXCollectionPath& aPath,
-    RArray<TMPXAttribute>& aAttrs,
-    RArray<TInt>& aSupportedIds )
-    {
-    aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
-        EMPXMediaGeneralId | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
-        EMPXMediaGeneralTitle | EMPXMediaGeneralFlags | EMPXMediaGeneralUri) );
-
-    aSupportedIds.AppendL(KMPXMediaIdContainer);
-    aSupportedIds.AppendL(KMPXMediaIdGeneral);
-
-    TInt levels(aPath.Levels());
-    if ( 2 == levels )
-        {
-        // check the browse type
-        switch ( aPath.Id(1).iId2 )
-            {
-            case EBrowseAll:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
-                aSupportedIds.AppendL( KMPXMediaIdMusic );
-                break;
-                }
-            case EBrowseArtist:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-                                    EMPXMediaMusicAlbumArtFileName ) );
-                break;
-                }
-            case EBrowseAlbum:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );
-                aSupportedIds.AppendL( KMPXMediaIdMusic );
-                break;
-                }
-            case EBrowsePlaylist:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral,
-                    EMPXMediaGeneralCount | EMPXMediaGeneralDuration ) );
-                break;
-                }
-            case EBrowseGenre:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
-                break;
-                }
-            case EBrowseComposer:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
-                break;
-                }
-            default:
-                {
-                User::Leave(KErrArgument);
-                }
-            }
-        }
-    else if ( 3 == levels )
-        {
-        // check the browse type
-        switch ( aPath.Id(1).iId2 )
-            {
-            case EBrowseArtist:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralCount) );
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) );
-                aSupportedIds.AppendL( KMPXMediaIdMusic );
-                break;
-                }
-            case EBrowseAlbum:
-            case EBrowsePlaylist:
-            case EBrowseGenre:
-            case EBrowseComposer:
-                {
-                aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-//                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) );                    
-                //added ganes
-                    EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName | EMPXMediaMusicAlbum) );                    
-                aSupportedIds.AppendL( KMPXMediaIdMusic );
-                break;
-                }
-            }
-        }
-    else if ( (4 == levels) && (aPath.Id(1).iId2 == EBrowseArtist) )
-        {
-        aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
-            EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
-        aSupportedIds.AppendL( KMPXMediaIdMusic );
-        }
-    }
-
-#ifdef _DEBUG
-// ----------------------------------------------------------------------------
-// Print change events
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::PrintMessagesL(
-    const CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbPlugin::PrintMessages");
-
-    if (aMessage.IsSupported(KMPXMessageArrayContents))
-        {
-        const CMPXMessageArray* messageArray =
-            aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents);
-        if( !messageArray )
-            {
-            User::Leave( KErrNoMemory );
-            }
-
-        TInt count(messageArray->Count());
-        MPX_DEBUG2("%d messages:", count);
-
-        for (TInt i = 0; i < count; ++i)
-            {
-            PrintMessage(*((*messageArray)[i]));
-            }
-        }
-    else
-        {
-        PrintMessage(aMessage);
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// Print one change event
-// ----------------------------------------------------------------------------
-//
-void CMPXDbPlugin::PrintMessage(
-    const CMPXMessage& aMessage)
-    {
-    MPX_FUNC("CMPXDbPlugin::PrintMessage");
-
-    if (aMessage.IsSupported(KMPXMessageGeneralId))
-        {
-        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageGeneralId);
-        MPX_DEBUG3("    message id[0x%x, 0x%x]", id.iId1, id.iId2);
-        }
-
-    if (aMessage.IsSupported(KMPXMessageCollectionId))
-        {
-        TUid uid = aMessage.ValueTObjectL<TUid>(KMPXMessageCollectionId);
-        MPX_DEBUG2("    uid [0x%x]", uid.iUid);
-        }
-
-    if (aMessage.IsSupported(KMPXMessageChangeEventType))
-        {
-        MPX_DEBUG2("    change event type [%d]",
-            aMessage.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType));
-        }
-
-    if (aMessage.IsSupported(KMPXMessageMediaGeneralCategory))
-        {
-        MPX_DEBUG2("    category [%d]",
-            aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
-        }
-
-    if (aMessage.IsSupported(KMPXMessageMediaGeneralId))
-        {
-        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId);
-        MPX_DEBUG3("    media id[0x%x, 0x%x]", id.iId1, id.iId2);
-        }
-
-    if (aMessage.IsSupported(KMPXMessageMediaDeprecatedId))
-        {
-        TMPXItemId id = aMessage.ValueTObjectL<TMPXItemId>(KMPXMessageMediaDeprecatedId);
-        MPX_DEBUG3("    deprecated id [0x%x, 0x%x]", id.iId1, id.iId2);
-        }
-    }
-
-#endif// _DEBUG
-
-// End of file
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbpluginproxy.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Standard proxy of the ECOM plugin
-*
-*/
-
-
-#include <implementationproxy.h>
-#include "mpxdbplugin.h"
-
-#if (!defined IMPLEMENTATION_PROXY_ENTRY)
-typedef TAny* TProxyNewLPtr;
-#define IMPLEMENTATION_PROXY_ENTRY(aUid,aFuncPtr) {{aUid},(TProxyNewLPtr)(aFuncPtr)}
-#endif
-
-// ----------------------------------------------------------------------------
-// The list of implementations
-// ----------------------------------------------------------------------------
-//
-const TImplementationProxy ImplementationTable[] =
-    { IMPLEMENTATION_PROXY_ENTRY(0x101FFC3A, CMPXDbPlugin::NewL) };
-
-// ----------------------------------------------------------------------------
-// The proxy of implementations
-// ----------------------------------------------------------------------------
-//
-EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
-    {
-    aTableCount=sizeof(ImplementationTable)/sizeof(TImplementationProxy);
-    return ImplementationTable;
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitedbplugin/src/mpxdbutil.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Contains utility functions for the DB plugin
-*
-*/
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-
-#include "mpxcollectiondbdef.h"
-#include "mpxdbutil.h"
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Filter out duplicated Ids
-// ----------------------------------------------------------------------------
-//
-void MPXDbUtil::FilterDuplicatedIdsL(
-    const TArray<TUint32>& aIds,
-    RArray<TUint32>& aFilteredIds)
-    {
-    MPX_FUNC("MPXDbUtil::FilterDuplicatedIdsL");
-
-    TInt count(aIds.Count());
-    for (TInt i = 0; i < count; ++i)
-        {
-        MPX_TRAPD(error, aFilteredIds.InsertInUnsignedKeyOrderL(aIds[i]));
-        if ((error != KErrNone) && (error != KErrAlreadyExists))
-            {
-            User::Leave(error);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// MPXDbUtil::TableNameForCategoryL
-// ----------------------------------------------------------------------------
-//
-TPtrC MPXDbUtil::TableNameForCategoryL(
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("MPXDbUtil::TableNameForCategoryL");
-
-    TPtrC ptr;
-    switch (aCategory)
-        {
-        case EMPXPlaylist:
-            ptr.Set(KMCPlaylistTable);
-            break;
-        case EMPXArtist:
-            ptr.Set(KMCArtistTable);
-            break;
-        case EMPXAlbum:
-            ptr.Set(KMCAlbumTable);
-            break;
-        case EMPXGenre:
-            ptr.Set(KMCGenreTable);
-            break;
-        case EMPXComposer:
-            ptr.Set(KMCComposerTable);
-            break;
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    return ptr;
-    }
-
-// ----------------------------------------------------------------------------
-// MPXDbUtil::MusicFieldNameForCategoryL
-// ----------------------------------------------------------------------------
-//
-TPtrC MPXDbUtil::MusicFieldNameForCategoryL(
-    TMPXGeneralCategory aCategory)
-    {
-    MPX_FUNC("MPXDbUtil::MusicFieldNameForCategoryL");
-
-    TPtrC ptr;
-    switch (aCategory)
-        {
-        case EMPXArtist:
-            ptr.Set(KMCMusicArtist);
-            break;
-        case EMPXAlbum:
-            ptr.Set(KMCMusicAlbum);
-            break;
-        case EMPXGenre:
-            ptr.Set(KMCMusicGenre);
-            break;
-        case EMPXComposer:
-            ptr.Set(KMCMusicComposer);
-            break;
-        default:
-            User::Leave(KErrNotSupported);
-        }
-
-    return ptr;
-    }
-
-// End of File
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/group/bld.inf	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/group/bld.inf	Mon May 03 12:29:20 2010 +0300
@@ -22,7 +22,6 @@
 DEFAULT
 
 PRJ_EXPORTS
-// ../loc/mpxpodcastcollectiondb.loc	APP_LAYER_LOC_EXPORT_PATH(mpxpodcastcollectiondb.loc)
 
 PRJ_EXTENSIONS
 START EXTENSION s60/mifconv
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbhandler.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbhandler.h	Mon May 03 12:29:20 2010 +0300
@@ -469,6 +469,7 @@
         /**
         * Verify the volume id for the databases
         */
+        void VerifyVolumeIdL( TInt aDrive );
         void VerifyVolumeIdL();
 
         /**
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbpluginqueries.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/inc/mpxpodcastdbpluginqueries.h	Mon May 03 12:29:20 2010 +0300
@@ -16,7 +16,6 @@
 */
 
 
-
 #ifndef MPXPODCASTDBPLUGINQUERIES_H
 #define MPXPODCASTDBPLUGINQUERIES_H
 
@@ -67,7 +66,7 @@
 _LIT(KQueryPodcastCleanup, "DELETE FROM :dbname.Podcast WHERE Deleted=1");
 
 _LIT(KQueryPodcastGetTitle, "SELECT Title FROM :dbname.Podcast WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryPodcastVolume, "SELECT VolumeId FROM :dbname.Podcast WHERE Deleted=0 AND UniqueId=%u");
+_LIT(KQueryPodcastVolume, "SELECT VolumeId FROM :dbname.Podcast WHERE UniqueId=%u");
 _LIT(KQueryPodcastAllVolumeIds, "SELECT VolumeId FROM :dbname.Podcast WHERE Deleted=0");
 
 // LTAN-79N8ND/EVXG-7FABHC: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
@@ -95,7 +94,7 @@
 //       optimized query is faster by more than 100ms.
 
 // categories included
-_LIT(KQueryPodcastGetEpisode, "SELECT Podcast.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Podcast,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Podcast.Deleted=0 AND Podcast.UniqueId=%u AND Podcast.Album=Album.UniqueId AND Podcast.Artist=Artist.UniqueId AND Podcast.Genre=Genre.UniqueId AND Podcast.Composer=Composer.UniqueId");
+_LIT(KQueryPodcastGetEpisode, "SELECT Podcast.*,Artist.Name,Album.Name,Genre.Name,Composer.Name FROM :dbname.Podcast,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer WHERE Podcast.UniqueId=%u AND Podcast.Album=Album.UniqueId AND Podcast.Artist=Artist.UniqueId AND Podcast.Genre=Genre.UniqueId AND Podcast.Composer=Composer.UniqueId");
 
 // LTAN-79N8ND/EVXG-7FABHC: temporary fix.  Symbian 9.4 SQLite cannot resolve column number correctly,
 // Use column number instead of column name for ORDER BY, needed when FROM uses more than 1 table
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxdbpodcast.cpp	Mon May 03 12:29:20 2010 +0300
@@ -134,15 +134,25 @@
 
     TUint32 episodeId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection,
         aMedia.ValueText(KMPXMediaGeneralUri), EFalse));
-    if (EpisodeExistsL(episodeId))
+    if ( EpisodeExistsL( episodeId ))
         {
-        DoUpdateEpisodeL(episodeId, aMedia, NULL);
+        // Return deleted file paths to caller
+        CDesCArray* fp = new( ELeave ) CDesCArrayFlat( 1 );
+        CleanupStack::PushL( fp );
+
+        // a list of change event messages a result of the item being removed
+        CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL();
+        CleanupStack::PushL( itemChangedMessages );
+        
+        DeleteEpisodeL( episodeId, *fp, *itemChangedMessages, ETrue );
+        
+        CleanupStack::PopAndDestroy( itemChangedMessages );
+        CleanupStack::PopAndDestroy( fp );
         }
-    else
-        {
-        // add the song
-        DoAddEpisodeL(episodeId, aMedia, aDrive, NULL);
-        }
+    // add the song
+    DoAddEpisodeL(episodeId, aMedia, aDrive, NULL);
+
+    
 
     return episodeId;
     }
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Mon May 03 12:29:20 2010 +0300
@@ -795,7 +795,7 @@
     iDbManager->OpenDatabaseL(aDrive);
 
     // Verify the volume ID after a remount event
-    VerifyVolumeIdL();
+    VerifyVolumeIdL( aDrive );
     }
 
 // ----------------------------------------------------------------------------
@@ -1425,52 +1425,64 @@
 // Verifies that the volume ID of the database matches the drive
 // ----------------------------------------------------------------------------
 //
+void CMPXPodcastDbHandler::VerifyVolumeIdL( TInt aDrive )
+    {
+    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
+
+    if( iDbManager->IsOpen(aDrive) )
+        {
+        TVolumeInfo volInfo;
+        iFs.Volume(volInfo, aDrive );
+        TUint curId(volInfo.iUniqueID);
+
+        TInt volId = iDbAuxiliary->IdL( aDrive );
+
+        // New database, no volume id set, mask out top bit because this is an uint
+        //
+        MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
+        if( volId == 0 && (curId&0x7FFFFFFF) )
+            {
+            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID");
+            BeginTransactionL();
+            TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) );
+            EndTransactionL( err );
+
+            // KSqlDbCorrupted indicates DB corrupted, need to recreate.
+            if ( err == KSqlDbCorrupted )
+                {
+                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
+                iDbManager->RecreateDatabaseL( aDrive );
+                BeginTransactionL();
+                TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+                EndTransactionL( err );
+                }
+            }
+        // Unmatched volume id, mark db as corrupt
+        //
+        else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
+            {
+            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED");
+            iDbManager->RecreateDatabaseL( aDrive );
+            BeginTransactionL();
+            TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+            EndTransactionL( err );
+            }
+        }
+    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
+    }
+
+
+// ----------------------------------------------------------------------------
+// Verifies that the volume ID of the database matches the drive
+// ----------------------------------------------------------------------------
+//
 void CMPXPodcastDbHandler::VerifyVolumeIdL()
     {
     MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
-
     TInt count( iDbDrives.Count() );
     for( TInt i=0; i<count; ++i )
         {
-        if( iDbManager->IsOpen(iDbDrives[i]) )
-            {
-            TVolumeInfo volInfo;
-            iFs.Volume(volInfo, iDbDrives[i] );
-            TUint curId(volInfo.iUniqueID);
-
-            TInt volId = iDbAuxiliary->IdL( iDbDrives[i] );
-
-            // New database, no volume id set, mask out top bit because this is an uint
-            //
-            MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
-            if( volId == 0 )
-                {
-                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID");
-                BeginTransactionL();
-                TRAPD( err, iDbAuxiliary->SetIdL( iDbDrives[i], curId&0x7FFFFFFF ) );
-                EndTransactionL( err );
-
-                // KSqlDbCorrupted indicates DB corrupted, need to recreate.
-                if ( err == KSqlDbCorrupted )
-                    {
-                    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
-                    iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                    BeginTransactionL();
-                    TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                    EndTransactionL( err );
-                    }
-                }
-            // Unmatched volume id, mark db as corrupt
-            //
-            else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
-                {
-                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED");
-                iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                BeginTransactionL();
-                TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                EndTransactionL( err );
-                }
-            }
+        VerifyVolumeIdL(iDbDrives[i]);
         }
     MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
     }
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbplugin.cpp	Mon May 03 12:29:20 2010 +0300
@@ -738,6 +738,7 @@
     CMPXMediaArray* array = CMPXMediaArray::NewL();
     CleanupStack::PushL(array);
 
+//    TInt count(0);
     TInt levels(aPath.Levels());
     TBool isEpisode(EFalse);
 
@@ -2793,7 +2794,7 @@
     MPX_FUNC("CMPXPodcastDbPlugin::DoHandleChangeL");
 
     TMPXCommandId cmdId = iActiveTask->GetTask();
-    if((iActiveTask->GetVisibleChange() | CMPXDbActiveTask::EAllVisible)
+    if((iActiveTask->GetVisibleChange() & CMPXDbActiveTask::EAllVisible)
         && (cmdId == KMPXCommandIdCollectionSet ||
             cmdId == KMPXCommandIdCollectionAdd ||
             cmdId == KMPXCommandIdCollectionRemove ||
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpcollectionalbumartmanager.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection album art manager.
-*
-*/
-
-
-#ifndef MPCOLLECTIONALBUMARTMANAGER_H
-#define MPCOLLECTIONALBUMARTMANAGER_H
-
-#include <QObject>
-#include <QCache>
-#include <QIcon>
-#include <QList>
-
-class MpMpxCollectionData;
-class ThumbnailManager;
-
-class MpCollectionAlbumArtManager : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    explicit MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent=0 );
-    virtual ~MpCollectionAlbumArtManager();
-
-    const QIcon* albumArt( int index );
-    void cacheFirstScreen();
-    void cancel();
-
-signals:
-
-    void albumArtReady( int index );
-
-public slots:
-
-    void thumbnailReady( QPixmap pixmap, void *data, int id, int error );
-
-private:
-
-    MpMpxCollectionData             *mCollectionData;
-    ThumbnailManager                *mThumbnailManager;
-    QCache<int, QIcon>              mImageCache;
-    bool                            mCachingInProgress;
-
-    QIcon                           *mDefaultIcon;
-
-    QList<int>                      mRequestQueue;
-    bool                            mPendingRequest;
-    int                             mRequestId;
-
-};
-
-#endif // MPCOLLECTIONALBUMARTMANAGER_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpcollectioncontainer.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/inc/mpcollectioncontainer.h	Mon May 03 12:29:20 2010 +0300
@@ -41,7 +41,6 @@
 
     virtual void initialize() = 0;
     virtual void setDataModel( MpCollectionDataModel *dataModel );
-    virtual void orientationChange( Qt::Orientation orientation );
     void setViewMode( MpCommon::MpViewMode viewMode );
 
 signals:
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpcollectiondatamodel.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection abstract data model.
-*
-*/
-
-#ifndef MPCOLLECTIONDATAMODEL_H
-#define MPCOLLECTIONDATAMODEL_H
-
-#include <QAbstractListModel>
-
-class MpMpxCollectionData;
-class MpCollectionAlbumArtManager;
-
-
-class MpCollectionDataModel : public QAbstractListModel
-{
-    Q_OBJECT
-
-public:
-
-    explicit MpCollectionDataModel( MpMpxCollectionData *data, QObject *parent=0 );
-    virtual ~MpCollectionDataModel();
-
-    int rowCount(const QModelIndex &parent=QModelIndex()) const;
-    QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
-    Qt::DropActions supportedDropActions() const;
-    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
-    QStringList mimeTypes() const;
-    QMimeData *mimeData(const QModelIndexList &indexes) const;
-    bool dropMimeData(const QMimeData *data, Qt::DropAction action,
-                              int row, int column, const QModelIndex &parent);
-    
-    MpMpxCollectionData *collectionData();
-    
-signals:
-    void orderChanged( int containerId, int itemId, int itemOrdinal, int newOrdinal );
-
-public slots:
-
-    void updateAlbumArt( int index );
-    void refreshModel();
-
-private:
-
-    MpMpxCollectionData             *mCollectionData;
-	MpCollectionAlbumArtManager     *mAlbumArtManager;  // Own
-    int                             mRowCount;
-
-};
-
-#endif // MPCOLLECTIONDATAMODEL_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpcollectionview.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/inc/mpcollectionview.h	Mon May 03 12:29:20 2010 +0300
@@ -20,11 +20,10 @@
 
 #include <QObject>
 
-#include <hbview.h>
 #include <hbeffect.h>
 
+#include "mpviewbase.h"
 #include "mpmpxcollectionviewdefs.h"
-#include "mpviewbase.h"
 
 class QActionGroup;
 class HbMainWindow;
@@ -36,7 +35,6 @@
 class MpCollectionContainer;
 class MpCollectionDataModel;
 class MpEngine;
-class MpMpxFrameworkWrapper;
 class MpMpxCollectionData;
 class MpNowPlayingWidget;
 class MpSnapshotWidget;
@@ -57,8 +55,6 @@
     void deactivateView();
     void setDefaultView();
 
-    void orientationChange( Qt::Orientation orientation );
-
 signals:
 
     void command( int command );
@@ -134,7 +130,6 @@
 
     TCollectionContext              mCollectionContext;
 
-    MpMpxFrameworkWrapper           *mMpxWrapper;           // Own
     MpEngine                        *mMpEngine;             // Not own
     MpMpxCollectionData             *mCollectionData;       // Not own
 
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectiondata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection data.
-*
-*/
-
-#ifndef MPMPXCOLLECTIONDATA_H
-#define MPMPXCOLLECTIONDATA_H
-
-#include <QObject>
-
-#include "mpmpxcollectionviewdefs.h"
-
-class MpMpxCollectionDataPrivate;
-class CMPXMedia;
-
-
-class MpMpxCollectionData : public QObject
-{
-    Q_OBJECT
-
-    friend class MpMpxCollectionDataPrivate;
-
-public:
-
-    enum DataType {
-        Title,
-        Uri,
-        Duration,
-        Count,
-        Artist,
-        Album,
-        Genre,
-        Rating,
-        AlbumArtUri
-    };
-
-    explicit MpMpxCollectionData( QObject *parent=0 );
-    virtual ~MpMpxCollectionData();
-
-    TCollectionContext context() const;
-
-    int count() const;
-    QString collectionTitle() const;
-    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
-
-    bool isAutoPlaylist();
-    bool isAutoPlaylist( int index );
-    int itemCount( int index );
-    int containerId();
-    int itemId(int index);
-    void removeItem(int index);
-    bool testCachedItem( int itemId );
-    void insertCachedItem(int index);
-
-    void setMpxMedia( const CMPXMedia& entries );
-    const CMPXMedia& containerMedia();
-
-signals:
-
-    void contextChanged( TCollectionContext context );
-private:
-
-    Q_DISABLE_COPY(MpMpxCollectionData)
-    MpMpxCollectionDataPrivate *d_ptr;
-
-};
-
-#endif // MPMPXCOLLECTIONDATA_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectiondata_p.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection data - private implementation.
-*
-*/
-
-#ifndef MPMPXCOLLECTIONDATA_P_H
-#define MPMPXCOLLECTIONDATA_P_H
-
-#include <e32base.h>
-
-#include "mpmpxcollectiondata.h"
-#include "mpmpxcollectionviewdefs.h"
-
-class CMPXMedia;
-class CMPXMediaArray;
-
-
-class MpMpxCollectionDataPrivate
-{
-public:
-
-    explicit MpMpxCollectionDataPrivate( MpMpxCollectionData *wrapper );
-    virtual ~MpMpxCollectionDataPrivate();
-
-    TCollectionContext context() const;
-
-    int count() const;
-    QString collectionTitle() const;
-    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
-
-    bool isAutoPlaylist();
-    bool isAutoPlaylist( int index );
-    int itemCount( int index );
-    int containerId();
-    int itemId(int index);
-    void removeItem(int index);
-    bool testCachedItem( int itemId );
-    void insertCachedItem(int index);
-
-    void setMpxMedia( const CMPXMedia& entries );
-    const CMPXMedia& containerMedia();
-
-private:
-
-    void DoGetDataL( int index, MpMpxCollectionData::DataType type, QString& data ) const;
-    bool DoIsAutoPlaylistL();
-    bool DoIsAutoPlaylistL( int index );
-    int DoGetItemCountL( int index );
-    int DoGetContainerIdL();
-    int DoGetItemIdL( int index );
-    void DoRemoveItemL( int index );
-    bool DoTestCachedItemL( int itemId );
-    
-    void SetCollectionContextL();
-    void DoSetMpxMediaL( const CMPXMedia& entries );
-
-private:
-
-    MpMpxCollectionData     *q_ptr;
-
-    CMPXMedia               *iContainerMedia;       // Owned
-    CMPXMediaArray          *iMediaArray;           // Not owned
-
-    TCollectionContext      iContext;
-    
-    CMPXMedia               *iCachedRemovedItem; //Owned
-
-};
-
-#endif // MPMPXCOLLECTIONDATA_P_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxcollectionviewdefs.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection view common definitions.
-*
-*/
-
-#ifndef MPMPXCOLLECTIONVIEWDEFS_H
-#define MPMPXCOLLECTIONVIEWDEFS_H
-
-#include <QMetaType>
-
-// Context of collection view.
-// It's the exact location within collection navigation.
-enum TCollectionContext {
-    ECollectionContextUnknown = 0,
-    ECollectionContextAllSongs,
-    ECollectionContextAlbums,
-    ECollectionContextAlbumSongs,
-    ECollectionContextPlaylists,
-    ECollectionContextPlaylistSongs,
-    ECollectionContextGenres,
-    ECollectionContextGenreSongs
-};
-// Register so type can be used in signal and slot connection
-Q_DECLARE_METATYPE(TCollectionContext)
-
-#endif  // MPMPXCOLLECTIONVIEWDEFS_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxframeworkwrapper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities.
-*
-*/
-
-#ifndef MPMPXFRAMEWORKWRAPPER_H
-#define MPMPXFRAMEWORKWRAPPER_H
-
-#include <QObject>
-
-#include "mpmpxcollectionviewdefs.h"
-#include "mpcommondefs.h"
-
-class MpMpxFrameworkWrapperPrivate;
-class MpMpxCollectionData;
-class QStringList;
-
-
-class MpMpxFrameworkWrapper : public QObject
-{
-    Q_OBJECT
-
-    friend class MpMpxFrameworkWrapperPrivate;
-
-public:
-
-    explicit MpMpxFrameworkWrapper( 
-        MpCommon::MpViewMode viewMode=MpCommon::DefaultView, QObject *parent=0 );
-    virtual ~MpMpxFrameworkWrapper();
-
-    void openCollection( TCollectionContext context );
-    void openCollectionItem( int index );
-    void back();
-    void findPlaylists( QStringList &playlists );
-    void createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData = 0  );
-    void saveToPlaylist( int playlistIndex, QList<int> &selection );
-    void saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData );    
-    void renamePlaylist( QString &newName, int index );
-    void renamePlaylist( QString &newName );
-    void deleteSongs( QList<int> &selection );
-    void setShuffle( bool active );
-    
-    void previewItem( int index );
-    void openIsolatedCollection( TCollectionContext context );
-    void releaseIsolatedCollection();
-    
-    MpMpxCollectionData *collectionData();
-    
-signals:
-
-    void collectionPlaylistOpened();
-    void playlistSaved( bool success );
-    void songsDeleted( bool success );
-    void playlistsRenamed( bool success );
-    
-    void isolatedCollectionOpened( MpMpxCollectionData* collectionData );
-
-public slots:
-
-    void reopenCollection();
-    void reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal );
-
-private:
-
-    Q_DISABLE_COPY( MpMpxFrameworkWrapper )
-    MpMpxFrameworkWrapperPrivate *d_ptr;
-
-};
-
-#endif // MPMPXFRAMEWORKWRAPPER_H
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxframeworkwrapper_p.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities - private implementation.
-*
-*/
-
-#ifndef MPMPXFRAMEWORKWRAPPER_P_H
-#define MPMPXFRAMEWORKWRAPPER_P_H
-
-#include <e32base.h>
-#include <mpxcollectionobserver.h>
-#include <mpxcollectionuihelperobserver.h>
-
-#include "mpmpxisolatedcollectionhelper.h" //MMpMpxIsolatedCollectionHelperObserver
-#include "mpmpxcollectionviewdefs.h"
-#include "mpcommondefs.h"
-
-class MMPXCollectionUtility;
-class MMPXCollectionUiHelper;
-class CMPXCollectionOpenUtility;
-class MMPXPlaybackUtility;
-class MMPXHarvesterUtility;
-class MpMpxCollectionData;
-class MpMpxFrameworkWrapper;
-class QStringList;
-
-
-class MpMpxFrameworkWrapperPrivate : public MMPXCollectionObserver,
-                                     public MMPXCHelperObserver,
-                                     public MMpMpxIsolatedCollectionHelperObserver
-{
-public:
-
-    explicit MpMpxFrameworkWrapperPrivate( MpMpxFrameworkWrapper *wrapper );
-    virtual ~MpMpxFrameworkWrapperPrivate();
-
-    void init( MpCommon::MpViewMode viewMode );
-    void openCollection( TCollectionContext context );
-    void openCollectionItem( int index );
-    void reopenCollection();
-    void back();
-    void findPlaylists( QStringList &playlists );
-    void createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData *collectionData );
-    void saveToPlaylist( int playlistIndex, QList<int> &selection );
-    void saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData );    
-    void deleteSongs( QList<int> &selection );
-    void renamePlaylist( QString &newName, int index );
-    void renamePlaylist( QString &newName );
-    void setShuffle( bool active );
-    void previewItem( int index );
-    void openIsolatedCollection( TCollectionContext context );
-    void releaseIsolatedCollection();
-    void reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal );
-
-    MpMpxCollectionData *collectionData();
-
-private:
-
-
-    void HandleOpenL( const CMPXMedia& aEntries,
-                     TInt aIndex,TBool aComplete,TInt aError );
-    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
-    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
-    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
-    void HandleOperationCompleteL( TCHelperOperation aOperation, TInt aErr, void* aArgument );
-    void HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError );
-    
-    void DoInitL();
-    void DoOpenCollectionL( TCollectionContext aContext );
-    void DoOpenCollectionItemL( TInt aIndex );
-    void DoIncrementalOpenL();
-    void DoReopenCollectionL();
-    void DoBackL();
-    void DoFindPlaylistsL( QStringList &playlists );
-    void DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData );
-    void DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData );
-    void DoSaveToPlaylistL( int playlistIndex, QList<int> &selection );
-    
-    void DoDeleteSongsL( QList<int> &selection );
-    void DoRenamePlaylistL( QString &newName, int index );
-    void DoRenamePlaylistL( QString &newname );
-    void DoRenamePlaylistL( TMPXItemId id, QString &newName );
-    void DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData );
-    void DoSetShuffleL( bool active );
-    void DoPreviewItemL( int index );
-    void DoOpenIsolatedCollectionL( TCollectionContext context );
-    void DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal );
-    void DoHandleCollectionMessageL( const CMPXMessage& aMsg );
-
-    void PreparePlaylistMediaL( CMPXMedia& aMedia, QList<int> &selection, MpMpxCollectionData *collectionData );
-
-private:
-
-    MpMpxFrameworkWrapper            *q_ptr;
-
-    MMPXCollectionUtility            *iCollectionUtility;
-    MMPXCollectionUiHelper           *iCollectionUiHelper;
-    CMPXCollectionOpenUtility        *iIncrementalOpenUtil;
-    CMpMpxIsolatedCollectionHelper   *iIsolatedCollectionHelper;
-    MMPXPlaybackUtility              *iPlaybackUtility;
-    MpMpxCollectionData              *iCollectionData;         // Owned
-    MpMpxCollectionData              *iIsolatedCollectionData; // Owned
-    TBool                            iFirstIncrementalOpen;
-    CMPXMedia                        *iUserPlaylists;          // Owned
-    TInt                             iNumItemsAdded;
-    MpCommon::MpViewMode             iViewMode;
-
-};
-
-#endif // MPMPXFRAMEWORKWRAPPER_P_H
-
--- a/mpviewplugins/mpcollectionviewplugin/inc/mpmpxisolatedcollectionhelper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
-* Copyright ( c ) 2009 Nokia Corporation and/or its subsidiary( -ies ).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: isolated collection helper.
-*
-*/
-
-#ifndef CMPMPXISOLATEDCOLLECTIONHELPER_H
-#define CMPMPXISOLATEDCOLLECTIONHELPER_H
-
-#include <mpxcollectionobserver.h>
-
-class CMPXCollectionOpenUtility;
-class CMPXCollectionPath;
-
-/*!
-    \class MpMpxIsolatedCollectionHelperObserver
-    \brief Observer interface for class CMpMpxIsolatedCollectionHelper
-
-    This is a helper class to open an insolated collection.
-*/
-class MMpMpxIsolatedCollectionHelperObserver
-{
-public:
-
-    virtual void HandleIsolatedOpenL( const CMPXMedia& aEntries, 
-            TInt aError ) = 0;
-};
-
-class CMpMpxIsolatedCollectionHelper : public CBase,
-                                      public MMPXCollectionObserver
-{
-public:
-
-    static CMpMpxIsolatedCollectionHelper* NewL( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-    static CMpMpxIsolatedCollectionHelper* NewLC( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-    virtual ~CMpMpxIsolatedCollectionHelper();
-    void OpenCollectionL( CMPXCollectionPath& aPath );
-    
-private:
-    CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-    void ConstructL();
-    void HandleOpenL( const CMPXMedia& aEntries,
-                     TInt aIndex,TBool aComplete,TInt aError );
-    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError );
-    void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
-    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
-
-private:
-    MMpMpxIsolatedCollectionHelperObserver* iObserver;
-    CMPXCollectionOpenUtility*              iIncrementalOpenUtil; //owned
-    TBool                                   iFirstIncrementalOpen;
-
-};
-
-#endif // CMPMPXISOLATEDCOLLECTIONHELPER_H
-    
-//EOF
--- a/mpviewplugins/mpcollectionviewplugin/mpcollectionviewplugin.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/mpcollectionviewplugin.pro	Mon May 03 12:29:20 2010 +0300
@@ -31,17 +31,11 @@
      ../../inc
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
 
-LIBS += -lestor.dll \
-    -lthumbnailmanagerqt.dll \
-    -lmpxplaybackutility.dll \
-    -lmpxcollectionutility.dll \
-    -lmpxharvesterutility.dll \
-    -lmpxcommon.dll \
-    -lmpxviewframeworkqt.dll \
-    -lmpxcollectionhelper.dll \
+LIBS += -lmpxviewframeworkqt.dll \
     -lmpnowplayingbanner.dll  \
     -lmpsettingsmanager \
-    -lmpengine
+    -lmpengine \
+    -lmpdata.dll
     
 symbian:TARGET.EPOCALLOWDLLDATA	= 1
 
@@ -56,14 +50,7 @@
     	   src/mpcollectioncontaineralbums.cpp \
     	   src/mpcollectioncontainerplaylists.cpp \
     	   src/mpcollectioncontainergenres.cpp \
-    	   src/mpcollectiondatamodel.cpp \
-    	   src/mpcollectionalbumartmanager.cpp \
-           src/mpmpxisolatedcollectionhelper.cpp \
-           src/mpmpxframeworkwrapper.cpp \
-           src/mpmpxframeworkwrapper_p.cpp \
-           src/mpmpxcollectiondata.cpp \
-           src/mpmpxcollectiondata_p.cpp \
-           src/mpsnapshotwidget.cpp
+         src/mpsnapshotwidget.cpp
 
 HEADERS = ../../inc/mpviewbase.h \
           inc/mpcollectionviewplugin.h \
@@ -76,14 +63,6 @@
     	  inc/mpcollectioncontaineralbums.h \
     	  inc/mpcollectioncontainerplaylists.h  \
     	  inc/mpcollectioncontainergenres.h  \
-    	  inc/mpcollectiondatamodel.h \
-    	  inc/mpcollectionalbumartmanager.h \
-          inc/mpmpxcollectionviewdefs.h \
-          inc/mpmpxframeworkwrapper.h \
-          inc/mpmpxisolatedcollectionhelper.h \
-          inc/mpmpxframeworkwrapper_p.h \
-          inc/mpmpxcollectiondata.h \
-          inc/mpmpxcollectiondata_p.h  \
-          inc/mpsnapshotwidget.h
+        inc/mpsnapshotwidget.h
        
 RESOURCES += resources/mpcollectionviewresources.qrc
--- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectionalbumartmanager.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-
-
-
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection album art manager.
-*
-*/
-
-#include <thumbnailmanager_qt.h>
-
-#include "mpcollectionalbumartmanager.h"
-#include "mpmpxcollectiondata.h"
-#include "mptrace.h"
-
-const int KInitCacheSize = 10;
-const int KMaxCacheSize = 50;
-
-/*!
-    \class MpCollectionAlbumArtManager
-    \brief Music Player collection album art manager.
-
-    Collection album art manager provides access to album art needed for
-    display in certain collection views. It hides interface to the thumbnail
-    manager and also implements a caching mechanism for performance reasons.
-*/
-
-/*!
-    \fn void albumArtReady( int index )
-
-    This signal is emitted when album art for \a index is ready.
-
-    \sa getAlbumArt()
- */
-
-/*!
-    \fn void albumCacheReady()
-
-    This signal is emitted when album art cache is ready.
-
-    \sa cacheAlbumArt()
- */
-
-/*!
- Constructs the album art manager.
- */
-MpCollectionAlbumArtManager::MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent )
-    : QObject(parent),
-      mCollectionData(data),
-      mThumbnailManager(0),
-      mCachingInProgress(false),
-      mDefaultIcon(0),
-      mPendingRequest(false)
-{
-    TX_ENTRY
-    mThumbnailManager = new ThumbnailManager(this);
-    mThumbnailManager->setMode(ThumbnailManager::Default);
-    mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
-    mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailSmall);
-
-    connect( mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-             this, SLOT(thumbnailReady(QPixmap, void *, int, int)) );
-
-    mImageCache.setMaxCost(KMaxCacheSize);
-    mDefaultIcon = new QIcon(":/icons/default_album.png");
-    TX_EXIT
-}
-
-/*!
- Destructs the album art manager.
- */
-MpCollectionAlbumArtManager::~MpCollectionAlbumArtManager()
-{
-    TX_ENTRY
-    cancel();
-    delete mThumbnailManager;
-    delete mDefaultIcon;
-    TX_EXIT
-}
-
-/*!
- Returns the album art for the given \a index. If the album art is not
- available in its cache, an asynchronous request is made to the thumbnail manager
- and default icon is returned.
-
- \sa signal albumArtReady
- */
-const QIcon* MpCollectionAlbumArtManager::albumArt( int index )
-{
-    TX_ENTRY_ARGS("index=" << index);
-    QIcon *icon = mImageCache[index];
-    if ( !icon ) {
-        icon = mDefaultIcon;
-        if ( !mRequestQueue.contains(index) ) {
-            // Icon was not found in cache. If the item has AlbumArtUri, request it
-            // through ThumbnailManager interface.
-            QString albumArtUri = mCollectionData->itemData(index, MpMpxCollectionData::AlbumArtUri);
-            if ( !albumArtUri.isEmpty() ) {
-                if ( !mPendingRequest ) {
-                    void *clientData = reinterpret_cast<void *>(index);
-                    mRequestId = mThumbnailManager->getThumbnail( albumArtUri, clientData );
-                    if ( mRequestId != -1 ) {
-                        mPendingRequest = true;
-                        TX_EXIT_ARGS("false - album art requested");
-                    }
-                    else {
-                        TX_EXIT_ARGS("Err: thumbnail manager returned (-1) for getThumbnail request!");
-                    }
-                }
-                else {
-                    mRequestQueue.append( index );
-                    TX_EXIT_ARGS("false - request queued");
-                }
-            }
-        }
-    }
-    return icon;
-}
-
-/*!
- Before providing the new data to the view (list, grid, etc.), we want
- to make sure that we have enough album arts for the first screen.
- */
-void MpCollectionAlbumArtManager::cacheFirstScreen()
-{
-    TX_ENTRY
-    int count = mCollectionData->count();
-    int initCount = ( count > KInitCacheSize ) ? KInitCacheSize : count;
-    for ( int i = 0; i < initCount; i++ ) {
-        albumArt(i);
-    }
-    if ( mPendingRequest ) {
-        mCachingInProgress = true;
-    }
-    TX_EXIT
-}
-
-/*!
- Cancels all outstanding album art requests.
-
- \sa getAlbumArt, cacheAlbumArt
- */
-void MpCollectionAlbumArtManager::cancel()
-{
-    TX_ENTRY
-    if ( mPendingRequest ) {
-        mThumbnailManager->cancelRequest(mRequestId);
-    }
-    mImageCache.clear();
-    mRequestQueue.clear();
-    mPendingRequest = false;
-    mCachingInProgress = false;
-    TX_EXIT
-}
-
-/*!
- Slot to be called when thumbnail bitmap generation or loading is complete.
- */
-void MpCollectionAlbumArtManager::thumbnailReady( QPixmap pixmap, void *data, int id, int error )
-{
-    int index = reinterpret_cast<int>(data);
-    TX_ENTRY_ARGS("index=" << index << ", id=" << id << ", error=" << error);
-    if ( !error && id == mRequestId && !pixmap.isNull() ) {
-        // Find the index
-        mImageCache.insert(index, new QIcon(pixmap));
-        TX_LOG_ARGS("Album art ready for index=" << index);
-        if ( !mCachingInProgress ) {
-            emit albumArtReady(index);
-        }
-    }
-    else {
-        TX_EXIT_ARGS("Err: thumbnail manager returned error for getThumbnail request!");
-    }
-
-    if ( mCachingInProgress ) {
-        if ( index >= (KInitCacheSize - 1) || !mRequestQueue.count() ) {
-            mCachingInProgress = false;
-            for ( int i = 0; i <= KInitCacheSize; ++i ) {
-                if ( mImageCache.contains(i) ) {
-                    emit albumArtReady(i);
-                }
-            }
-        }
-    }
-
-    mPendingRequest = false;
-    if ( mRequestQueue.count() ) {
-        int index = mRequestQueue.takeFirst();
-        QString albumArtUri = mCollectionData->itemData(index, MpMpxCollectionData::AlbumArtUri);
-        void *clientData = reinterpret_cast<void *>(index);
-        mRequestId = mThumbnailManager->getThumbnail( albumArtUri, clientData );
-        if ( mRequestId != -1 ) {
-            mPendingRequest = true;
-            TX_EXIT_ARGS("next album art requested");
-        }
-        else {
-            TX_EXIT_ARGS("Err: thumbnail manager returned (-1) for getThumbnail request!");
-        }
-    }
-    TX_EXIT
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainer.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainer.cpp	Mon May 03 12:29:20 2010 +0300
@@ -79,14 +79,6 @@
 }
 
 /*!
- Loads the correct layout based on the \a orientation.
- */
-void MpCollectionContainer::orientationChange( Qt::Orientation orientation )
-{
-    Q_UNUSED(orientation);
-}
-
-/*!
  Sets the view mode.
  */
 void MpCollectionContainer::setViewMode( MpCommon::MpViewMode viewMode )
--- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectiondatamodel.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,301 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection data model.
-*
-*/
-
-#include <QIcon>
-#include <QList>
-#include <qmimedata.h>
-#include <hbicon.h>
-#include <hbnamespace.h>
-
-#include "mpcollectiondatamodel.h"
-#include "mpcollectionalbumartmanager.h"
-#include "mpmpxcollectiondata.h"
-#include "mptrace.h"
-
-/*!
-    \class MpCollectionDataModel
-    \brief Music Player collection data model.
-
-    Collection data model implements the interface specified by HbAbstractDataModel,
-    which defines the standard interface that item models must use to be able to
-    interoperate with other components in the model/view architecture.
-
-    Every item of data that can be accessed via a model has an associated model
-    index.
-
-    Each item has a number of data elements associated with it and they can be
-    retrieved by specifying a role (see Qt::ItemDataRole) to the model's data
-    returned by itemData() function.
-
-    \sa HbAbstractDataModel
-*/
-
-/*!
-    \fn void orderChanged( int containerId, int itemId, int itemOrdinal, int newOrdinal )
-
-    This signal is emitted when a reorder operations is propagated to the 
-    model, indicates that the item with \a containerId , \a itemId is to 
-    be moved from \a itemOrdinal to \a newOrdinal.
- */
-
-/*!
- Constructs the collection data model.
- */
-MpCollectionDataModel::MpCollectionDataModel( MpMpxCollectionData *data, QObject *parent )
-    : QAbstractListModel(parent),
-      mCollectionData(data),
-      mRowCount(0)
-{
-    TX_ENTRY
-    mAlbumArtManager = new MpCollectionAlbumArtManager(mCollectionData);
-    connect( mAlbumArtManager, SIGNAL(albumArtReady(int)), this, SLOT(updateAlbumArt(int)) );
-    TX_EXIT
-}
-
-/*!
- Destructs the collection data model.
- */
-MpCollectionDataModel::~MpCollectionDataModel()
-{
-    TX_ENTRY
-    delete mAlbumArtManager;
-    TX_EXIT
-}
-
-/*!
- Returns the number of rows under the given \a parent.
-
- View will request for the row count immediately after a model is set.
- To prevent it from reading data while caching the album art for the first
- screen, return row count as zero.
-
- \reimp
- */
-int MpCollectionDataModel::rowCount( const QModelIndex &parent ) const
-{
-    TX_LOG
-    Q_UNUSED(parent);
-    return mRowCount;
-}
-
-/*!
- Returns the data stored for the item referred to by the \a index.
-
- \reimp
- */
-QVariant MpCollectionDataModel::data(const QModelIndex &index, int role) const
-{
-    TX_ENTRY
-    QVariant returnValue = QVariant();
-    if ( !index.isValid() ) {
-        return returnValue;
-    }
-
-    int row = index.row();
-    TX_LOG_ARGS("index=" << row << ", role=" << role);
-    TCollectionContext context = mCollectionData->context();
-    if ( role == Qt::DisplayRole ) {
-        QStringList display;
-        // Fetch the primary text, which is the title, if available.
-        QString primaryText;
-        primaryText = mCollectionData->itemData(row, MpMpxCollectionData::Title);
-        if ( !primaryText.isEmpty() ) {
-            display << primaryText;
-        }
-        else {
-            display << hbTrId("txt_mus_other_unknown4");
-        }
-
-        // Fetch the secondary text, which depends on the current context, if available.
-        QString secondaryText;
-        switch ( context ) {
-            case ECollectionContextAllSongs:
-            case ECollectionContextAlbums:
-            case ECollectionContextPlaylistSongs:
-                secondaryText = mCollectionData->itemData(row, MpMpxCollectionData::Artist);
-                if ( !secondaryText.isEmpty() ) {
-                    display << secondaryText;
-                }
-                else {
-                    display << hbTrId("txt_mus_other_unknown3");
-                }
-                break;
-            default:
-                break;
-        }
-        returnValue = display;
-    }
-    else if ( role == Qt::DecorationRole ) {
-        switch ( context ) {
-            case ECollectionContextAlbums:
-                const QIcon *icon = mAlbumArtManager->albumArt(row);
-                QVariant iconVariant(QVariant::Icon, icon);
-                returnValue = iconVariant;
-                break;
-        }
-    }
-    else if ( role == Hb::IndexFeedbackRole ) {
-        QString feedbackIndex;
-        feedbackIndex = mCollectionData->itemData(row, MpMpxCollectionData::Title);
-        returnValue = feedbackIndex;
-    }
-    TX_EXIT
-    return returnValue;
-}
-
-/*!
- \reimp
- */
-Qt::DropActions MpCollectionDataModel::supportedDropActions() const
-{
-    return Qt::MoveAction;
-}
-
-/*! 
- \reimp
-*/
-bool MpCollectionDataModel::removeRows(int row, int count, const QModelIndex &parent )
-{
-    if ( count > 1 ) {
-        return false;
-    }
-    beginRemoveRows ( parent, row, row);
-    //This call internally caches the item, to be inserted if it it drag and drop.
-    mCollectionData->removeItem(row);
-    mRowCount--;
-    endRemoveRows();
-    return true;
-}
-
-/*! 
- \reimp
-*/
-QStringList MpCollectionDataModel::mimeTypes() const
-{
-    QStringList types;
-    types << QLatin1String("application/x-mpcollectiondatamodelrowandids");
-    return types;
-}
-
-/*! 
- \reimp
-*/
-QMimeData *MpCollectionDataModel::mimeData(const QModelIndexList &indexes) const
-{
-    if (indexes.count() <= 0)
-        return 0;
-    QStringList types = mimeTypes();
-    if (types.isEmpty())
-        return 0;
-    QMimeData *data = new QMimeData();
-    QString format = types.at(0);
-    QByteArray encoded;
-    QDataStream stream(&encoded, QIODevice::WriteOnly);
-    stream << indexes.at(0).row();
-    stream << mCollectionData->containerId();
-    stream << mCollectionData->itemId( indexes.at(0).row() );
-    
-    data->setData(format, encoded);
-    return data;
-}
-
-/*! 
- \reimp
-*/
-bool MpCollectionDataModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
-                          int row, int column, const QModelIndex &parent)
-{
-    Q_UNUSED(column);
-    // check if the action is supported
-    if (!data || action != Qt::MoveAction ) {
-        return false;
-    }
-    // check if the format is supported
-    QStringList types = mimeTypes();
-    if (types.isEmpty()) {
-        return false;
-    }
-    QString format = types.at(0);
-    if (!data->hasFormat(format)) {
-        return false;
-    }
-    // decode and insert
-    QByteArray encoded = data->data(format);
-    QDataStream stream(&encoded, QIODevice::ReadOnly);
-    int rowFrom = -1;
-    int mpxContainerId = -1;
-    int mpxItemId = -1;
-    if (!stream.atEnd()) {
-        stream >> rowFrom;
-        stream >> mpxContainerId;
-        stream >> mpxItemId;
-    } 
-    if ( rowFrom == -1 || mpxContainerId == -1 || mpxItemId == -1  || 
-            !mCollectionData->testCachedItem( mpxItemId )) {
-        return false;
-    }    
-        
-    beginInsertRows( parent, row, row );
-    emit orderChanged( mpxContainerId, mpxItemId, rowFrom, row );
-    mCollectionData->insertCachedItem( row );
-    mRowCount++;
-    endInsertRows();
-    return true;
-}
-
-/*!
- Returns pointer to MpMpxCollectionData, which is the collection data.
- */
-MpMpxCollectionData *MpCollectionDataModel::collectionData()
-{
-    return mCollectionData;
-}
-
-/*!
- Slot to be called when album art for the \a index needs to be updated.
- */
-void MpCollectionDataModel::updateAlbumArt( int index )
-{
-    TX_ENTRY_ARGS("index=" << index);
-    if ( index >= 0 && index < mRowCount ) {
-        QModelIndex modelIndex = QAbstractItemModel::createIndex(index, 0);
-        emit dataChanged(modelIndex, modelIndex);
-    }
-    TX_EXIT
-}
-
-/*!
- Slot to be called when data has changed and model needs to be refreshed
- to reflect the new data.
- */
-void MpCollectionDataModel::refreshModel()
-{
-    TX_ENTRY
-    // Cancel all outstanding album art request first, then reset the model.
-    mAlbumArtManager->cancel();
-    mRowCount = mCollectionData->count();
-
-    TCollectionContext context = mCollectionData->context();
-    if ( context == ECollectionContextAlbums ) {
-        // Before providing the new data to the view (list, grid, etc.), we want
-        // to make sure that we have enough album arts for the first screen.
-        mAlbumArtManager->cacheFirstScreen();
-    }
-    reset();
-    TX_EXIT
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp	Mon May 03 12:29:20 2010 +0300
@@ -40,13 +40,13 @@
 #include "mpcollectioncontainer.h"
 #include "mpcollectiondatamodel.h"
 #include "mpengine.h"
-#include "mpmpxframeworkwrapper.h"
 #include "mpmpxcollectiondata.h"
 #include "mpnowplayingwidget.h"
 #include "mpcommondefs.h"
 #include "mptrace.h"
 #include "mpsnapshotwidget.h"
 #include "mpsettingsmanager.h"
+#include "mpcollectionlistcontainer.h"
 
 
 const char*MUSIC_COLLECTION_DOCML = ":/docml/musiccollection.docml";
@@ -55,9 +55,10 @@
 
 const int KMainToolBarAll = 0;
 const int KMainToolBarArtists = 1;
-const int KMainToolBarPlaylists = 2;
 
-//const int KPlaylistToolBarAdd = 0;
+const int KMainToolBarPlaylists = 3;
+
+const int KPlaylistToolBarAdd = 0;
 const int KPlaylistToolBarRemove = 1;
 const int KplaylistToolBarReorder = 2;
 
@@ -83,7 +84,6 @@
  */
 MpCollectionView::MpCollectionView()
     : mCollectionContext( ECollectionContextUnknown ),
-      mMpxWrapper( 0 ),
       mMpEngine( 0 ),
       mContainerFactory( 0 ),
       mCollectionContainer( 0 ),
@@ -91,6 +91,8 @@
       mActivated( false ),
       mNowPlayingBanner( 0 ),
       mBannerAttached( false ),
+	  mSoftKeyQuit( 0 ),
+      mSoftKeyBack( 0 ),
       mDocumentLoader( 0 ),
       mMainContainer( 0 ),
       mMainToolBar( 0 ),
@@ -129,7 +131,6 @@
     delete mCollectionDataModel;
     delete mCollectionContainer;
     delete mContainerFactory;
-    delete mMpxWrapper;
     delete mDocumentLoader;
     delete mMpTranslator;
     delete mCommonTranslator;
@@ -171,35 +172,33 @@
     mSoftKeyBack = new HbAction( Hb::BackAction, this );
     connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) );
 
-    mMpxWrapper = new MpMpxFrameworkWrapper( mViewMode );
-    connect( mMpxWrapper,
+    mMpEngine = MpEngine::instance();
+    
+    connect( mMpEngine,
             SIGNAL( collectionPlaylistOpened() ),
             this,
-            SLOT( startPlaybackView() ),
-            Qt::QueuedConnection );
-    connect( mMpxWrapper,
+            SLOT( startPlaybackView() ) );
+    connect( mMpEngine,
             SIGNAL( playlistSaved( bool ) ),
             this,
-            SLOT( playlistSaved( bool ) ),
-            Qt::QueuedConnection );
-    connect( mMpxWrapper,
+            SLOT( playlistSaved( bool ) ) );
+    connect( mMpEngine,
             SIGNAL( songsDeleted( bool ) ),
             this,
-            SLOT( songsDeleted( bool ) ),
-            Qt::QueuedConnection );
-    connect( mMpxWrapper,
+            SLOT( songsDeleted( bool ) ) );
+    connect( mMpEngine,
             SIGNAL( playlistsRenamed( bool ) ),
             this,
-            SLOT( playlistsRenamed( bool ) ),
-            Qt::QueuedConnection );
-    connect( mMpxWrapper,
+            SLOT( playlistsRenamed( bool ) ) );
+    connect( mMpEngine,
             SIGNAL( isolatedCollectionOpened( MpMpxCollectionData* ) ),
             this,
-            SLOT( handleIsolatedCollectionOpened( MpMpxCollectionData* ) ),
-            Qt::QueuedConnection );
+            SLOT( handleIsolatedCollectionOpened( MpMpxCollectionData* ) ) );
 
-    mCollectionData = mMpxWrapper->collectionData();
-    connect( mCollectionData, SIGNAL( contextChanged( TCollectionContext ) ), this, SLOT( setContext( TCollectionContext ) ) );
+    mCollectionData = mMpEngine->collectionData();
+    qRegisterMetaType<TCollectionContext>("TCollectionContext");
+    connect( mCollectionData, SIGNAL( contextChanged( TCollectionContext ) ), 
+             this, SLOT( setContext( TCollectionContext ) ), Qt::QueuedConnection );
     mCollectionDataModel = new MpCollectionDataModel( mCollectionData );
 
     mDocumentLoader = new MpCollectionDocumentLoader();
@@ -257,7 +256,6 @@
 
     mContainerFactory = new MpCollectionContainerFactory( this, mDocumentLoader );
 
-    mMpEngine = MpEngine::instance();
     connect( mMpEngine, SIGNAL( usbBlocked(bool) ),
              this, SLOT( handleUsbBlocked(bool) ) );
     connect( mMpEngine, SIGNAL( libraryAboutToRefresh() ),
@@ -286,7 +284,7 @@
     TX_ENTRY_ARGS( "mCollectionContext=" << mCollectionContext );
     if ( mCollectionContext == ECollectionContextUnknown ) {
         // Open 'All Songs' by default
-        mMpxWrapper->openCollection( ECollectionContextAllSongs );
+        mMpEngine->openCollection( ECollectionContextAllSongs );
     }
     else {
         // This true when returning from other views, e.g. playback view
@@ -320,7 +318,7 @@
     TX_ENTRY
     if ( mCollectionContext != ECollectionContextAllSongs ) {
         // Open 'All Songs' by default
-        mMpxWrapper->openCollection( ECollectionContextAllSongs );
+        mMpEngine->openCollection( ECollectionContextAllSongs );
     }
 
     if ( mBannerAttached ) {
@@ -331,25 +329,6 @@
 }
 
 /*!
- Loads the correct layout based on the \a orientation.
- */
-void MpCollectionView::orientationChange( Qt::Orientation orientation )
-{
-    if ( mCollectionContainer ) {
-        mCollectionContainer->orientationChange( orientation );
-    }
-
-    if ( mBannerAttached ) {
-        if ( orientation == Qt::Vertical ) {
-            setBannerVisibility( true );
-        }
-        else {
-            setBannerVisibility( false );
-        }
-    }
-}
-
-/*!
  Slot to be called when collection context is changed as a result of Open
  operation.
  */
@@ -381,7 +360,7 @@
 {
     TX_ENTRY
     if ( mCollectionContext != ECollectionContextAllSongs ) {
-        mMpxWrapper->openCollection( ECollectionContextAllSongs );
+        mMpEngine->openCollection( ECollectionContextAllSongs );
     }
     TX_EXIT
 }
@@ -393,7 +372,7 @@
 {
     TX_ENTRY
     if ( mCollectionContext != ECollectionContextAlbums ) {
-        mMpxWrapper->openCollection( ECollectionContextAlbums );
+        mMpEngine->openCollection( ECollectionContextAlbums );
     }
     TX_EXIT
 }
@@ -405,7 +384,7 @@
 {
     TX_ENTRY
     if ( mCollectionContext != ECollectionContextPlaylists) {
-        mMpxWrapper->openCollection( ECollectionContextPlaylists );
+        mMpEngine->openCollection( ECollectionContextPlaylists );
     }
     TX_EXIT
 }
@@ -417,7 +396,7 @@
 {
     TX_ENTRY
     if ( mCollectionContext != ECollectionContextGenres ) {
-        mMpxWrapper->openCollection( ECollectionContextGenres );
+        mMpEngine->openCollection( ECollectionContextGenres );
     }
     TX_EXIT
 }
@@ -467,7 +446,7 @@
         }
     }
     if ( doOpen ) {
-        mMpxWrapper->openCollectionItem( index );
+        mMpEngine->openCollectionItem( index );
     }
     TX_EXIT
 }
@@ -490,7 +469,7 @@
         case ECollectionContextAlbumSongs:
         case ECollectionContextPlaylistSongs:
         case ECollectionContextGenreSongs:
-            mMpxWrapper->back();
+            mMpEngine->back();
             break;
         default:
             doExit = true;
@@ -547,11 +526,12 @@
  Slot for container transition end.
  */
 void MpCollectionView::containerTransitionComplete( const HbEffect::EffectStatus &status )
-{
-    Q_UNUSED( status );
-    qobject_cast<QGraphicsView *>( mWindow )->scene()->removeItem( mSnapshot );
-    delete mSnapshot;
-    mSnapshot = 0;
+{    
+    if ( status.userData == "snapshot_effect" ) {
+        qobject_cast<QGraphicsView *>( mWindow )->scene()->removeItem( mSnapshot );
+        mSnapshot->deleteLater();
+        mSnapshot = 0;
+    }
 }
 
 /*!
@@ -559,7 +539,7 @@
  */
 void MpCollectionView::shufflePlayAll()
 {
-    mMpxWrapper->setShuffle( true );
+    mMpEngine->setShuffle( true );
     MpSettingsManager::setShuffle( true );
     int index = generateShuffleIndex();
     openIndex( index );
@@ -571,9 +551,7 @@
  */
 void MpCollectionView::refreshLibrary()
 {
-    if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-        mMpEngine->refreshLibrary();
-    }
+    mMpEngine->refreshLibrary();
 }
 
 /*!
@@ -629,9 +607,9 @@
         currentName = mCollectionData->collectionTitle();
         bool ok = false;
         QString newName;
-    newName = getText( hbTrId( "txt_mus_dialog_enter_name" ), currentName, ok );
-        if ( ok && ( currentName != newName ) && !mMpEngine->verifyUsbBlocking( true ) ) {
-            mMpxWrapper->renamePlaylist( newName );
+        newName = getText( hbTrId( "txt_mus_dialog_enter_name" ), currentName, ok );
+        if ( ok && ( currentName != newName ) ) {
+            mMpEngine->renamePlaylist( newName );
         }
     }
 }
@@ -645,7 +623,7 @@
     if ( success &&
             ( ECollectionContextPlaylists == mCollectionContext ||
             ECollectionContextPlaylistSongs == mCollectionContext ) ) {
-     mMpxWrapper->reopenCollection();
+        mMpEngine->reopenCollection();
     }
 }
 
@@ -656,7 +634,7 @@
 {
     // Update list if delete succeded or if delete interrupted by an USB MTP Event
     if ( success || mMpEngine->verifyUsbBlocking( true ) ) {
-        mMpxWrapper->reopenCollection();
+        mMpEngine->reopenCollection();
     }
 }
 /*!
@@ -665,7 +643,7 @@
 void MpCollectionView::playlistsRenamed( bool success )
 {
     if ( success ) {
-        mMpxWrapper->reopenCollection();
+        mMpEngine->reopenCollection();
     }
 }
 
@@ -674,12 +652,10 @@
  */
 void MpCollectionView::prepareToAddToPlaylist()
 {
-    TX_ENTRY
-    if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-        //We dismiss dialogs here since after open is complete we are triggering a dialog.
-        setOutstandingPopup( 0 );
-        mMpxWrapper->openIsolatedCollection( ECollectionContextAllSongs );
-    }
+    TX_ENTRY    
+    //We dismiss dialogs here since after open is complete we are triggering a dialog.
+    setOutstandingPopup( 0 );
+    mMpEngine->openIsolatedCollection( ECollectionContextAllSongs );
     TX_EXIT
 }
 
@@ -699,7 +675,7 @@
         }
     }
     //Playlist is saved asynchronosly by the default collection, it is OK to release now.
-    mMpxWrapper->releaseIsolatedCollection();
+    mMpEngine->releaseIsolatedCollection();
     TX_EXIT
 }
 
@@ -723,9 +699,7 @@
         for ( int i = 0; i < SelectedModelIndexes.size(); ++i ) {
             selection.append( SelectedModelIndexes.at( i ).row() );
         }
-        if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-            mMpxWrapper->saveToCurrentPlaylist( selection, collectionData );
-        }
+        mMpEngine->saveToCurrentPlaylist( selection, collectionData );
     }
     delete collectionDataModel;
 }
@@ -742,7 +716,7 @@
     QString newPlaylistName;
     bool ok;
     QStringList playlists;
-    mMpxWrapper->findPlaylists( playlists );
+    mMpEngine->findPlaylists( playlists );
     ok = queryNewPlaylistName(newPlaylistName , playlists);
     if ( ok ) {
         QModelIndexList SelectedModelIndexes;
@@ -756,9 +730,7 @@
             }
         }
         //Creating Playlist even when there is no selection.
-        if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-            mMpxWrapper->createPlaylist( newPlaylistName, selection, collectionData );
-        }
+        mMpEngine->createPlaylist( newPlaylistName, selection, collectionData );
     }
     delete collectionDataModel;
 }
@@ -782,7 +754,7 @@
     model->refreshModel();
     connect( model,
             SIGNAL( orderChanged( int, int, int, int ) ),
-            mMpxWrapper,
+            mMpEngine,
             SLOT( reorderPlaylist( int, int, int, int ) ) );
     listView->setModel( model );
     listView->setArrangeMode( true );
@@ -799,7 +771,7 @@
     connect( popup, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) );
     //Reopen the collection so the ordinals get fixed on the view list, if we
     //delete items the index will not match to the item on the collection.
-    connect( popup, SIGNAL( aboutToClose() ), mMpxWrapper, SLOT( reopenCollection() ) );
+    connect( popup, SIGNAL( aboutToClose() ), mMpEngine, SLOT( reopenCollection() ) );
     setOutstandingPopup(popup);
     popup->show();
 }
@@ -843,7 +815,11 @@
     TX_ENTRY_ARGS( "blocked=" << blocked );
     mUsbBlocked = blocked;
     
-    // Hide/Show usb blocked options
+    if ( mActivated && mUsbBlocked && mOutstandingPopup ) {
+        mOutstandingPopup->close();
+        mMpEngine->verifyUsbBlocking( true );        
+    }
+    
     updateMenu();
     if ( mCollectionContext == ECollectionContextPlaylistSongs ) {
          updateToolBar();
@@ -880,7 +856,7 @@
     else {
         //Update cache, even if collection is in background.
         //Library refreshing could be triggered at any point due USB connect./disconnect.
-        mMpxWrapper->reopenCollection();
+        mMpEngine->reopenCollection();
     }
     TX_EXIT
 }
@@ -896,40 +872,47 @@
         case ECollectionContextAllSongs:
         case ECollectionContextAlbumSongs:
             contextMenu = new HbMenu();
-            if ( !mUsbBlocked ) {
-                action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
-                action->setObjectName( "add" );
-                action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
-                action->setObjectName( "delete" );
-            }
+            action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
+            action->setObjectName( "play" );
+            action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
+            action->setObjectName( "add" );
+            action->setEnabled( !mUsbBlocked );
+            action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
+            action->setObjectName( "delete" );
+            action->setEnabled( !mUsbBlocked );
             break;
         case ECollectionContextAlbums:
             contextMenu = new HbMenu();
-            if ( !mUsbBlocked ) {
-                action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
-                action->setObjectName( "add" );
-                action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
-                action->setObjectName( "delete" );
-            }
+            action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
+            action->setObjectName( "open" );
+            action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
+            action->setObjectName( "add" );
+            action->setEnabled( !mUsbBlocked );
+            action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
+            action->setObjectName( "delete" );
+            action->setEnabled( !mUsbBlocked );
             break;
         case ECollectionContextPlaylists:
             if ( !mCollectionData->isAutoPlaylist( index ) ) {
                 contextMenu = new HbMenu();
-                if ( !mUsbBlocked ) {
-                    action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
-                    action->setObjectName("delete");
-                    action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) );
-                    action->setObjectName( "rename playlist" );
-                }
+                action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
+                action->setObjectName( "open" );
+                action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
+                action->setObjectName("delete");
+                action->setEnabled( !mUsbBlocked );
+                action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) );
+                action->setObjectName( "rename playlist" );
+                action->setEnabled( !mUsbBlocked );
             }
             break;
         case ECollectionContextPlaylistSongs:
             if ( !mCollectionData->isAutoPlaylist() ) {
                 contextMenu = new HbMenu();
-                if ( !mUsbBlocked ) {
-                    action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) );
-                    action->setObjectName( "delete" );
-                }
+                action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
+                action->setObjectName( "play" );
+                action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) );
+                action->setObjectName( "delete" );
+                action->setEnabled( !mUsbBlocked );
             }
             break;
         default:
@@ -940,24 +923,31 @@
         setOutstandingPopup( contextMenu );
         HbAction *selectedAction = mActivated ? contextMenu->exec( coords ) : 0;
         setOutstandingPopup( 0 );
-        if ( selectedAction && !mMpEngine->verifyUsbBlocking( true ) ) {
+        if ( selectedAction ) {
             QString objectName = selectedAction->objectName();
             QList<int> selection;
             selection.append( index );
-            if ( objectName == "add" ) {
-                launchAddToPlaylistDialog( selection );
-            }
-            else if ( objectName == "delete" ) {
-                requestDelete( selection );
+            if ( objectName == "open" || objectName == "play" ) {
+                QModelIndex modelIndex;
+                modelIndex = mCollectionDataModel->index(index);
+                qobject_cast<MpCollectionListContainer*>(mCollectionContainer)->itemActivated( modelIndex );
             }
-            else if ( objectName == "rename playlist" ) {
-                QString currentName;
-                currentName = mCollectionData->itemData( index, MpMpxCollectionData::Title );
-                bool ok = false;
-                QString newName;
-                newName = getText( hbTrId("txt_mus_dialog_enter_name" ), currentName, ok );
-                if ( ok && ( currentName != newName ) ) {
-                    mMpxWrapper->renamePlaylist( newName, index );   
+            else if ( !mMpEngine->verifyUsbBlocking( true ) ) {
+                if ( objectName == "add" ) {
+                    launchAddToPlaylistDialog( selection );
+                }
+                else if ( objectName == "delete" ) {
+                    requestDelete( selection );
+                }
+                else if ( objectName == "rename playlist" ) {
+                    QString currentName;
+                    currentName = mCollectionData->itemData( index, MpMpxCollectionData::Title );
+                    bool ok = false;
+                    QString newName;
+                    newName = getText( hbTrId("txt_mus_dialog_enter_name" ), currentName, ok );
+                    if ( ok && ( currentName != newName ) ) {
+                        mMpEngine->renamePlaylist( newName, index );   
+                    }
                 }
             }
         }
@@ -990,7 +980,7 @@
         setOutstandingPopup( contextMenu );
         if ( mActivated ? contextMenu->exec( coords ) : 0 ) {
             // Start the playback process. View will switch to playbackview.
-            mMpxWrapper->previewItem( index );
+            mMpEngine->previewItem( index );
         }
         setOutstandingPopup( 0 );
     }
@@ -1099,20 +1089,16 @@
         mPlaylistToolBar->addAction( action );
     }
 
-    if ( !mUsbBlocked ) {
-        int items = mCollectionData->count();
+    int items = mCollectionData->count();
+
+    //no use for add if usb blocked.
+    mPlaylistToolBar->actions()[KPlaylistToolBarAdd]->setEnabled( !mUsbBlocked );
 
-        mPlaylistToolBar->setEnabled( true );
-		
-        //no use for remove if there are no items.
-        mPlaylistToolBar->actions()[KPlaylistToolBarRemove]->setEnabled( items > 0 );
+    //no use for remove if there are no items or usb blocked.
+    mPlaylistToolBar->actions()[KPlaylistToolBarRemove]->setEnabled( items > 0 && !mUsbBlocked );
 
-        //no use for reorder if there is no more than 1 item.
-        mPlaylistToolBar->actions()[KplaylistToolBarReorder]->setEnabled( items > 1 );
-    }
-    else {
-        mPlaylistToolBar->setEnabled( false );
-    }
+    //no use for reorder if there is no more than 1 item or usb blocked.
+    mPlaylistToolBar->actions()[KplaylistToolBarReorder]->setEnabled( items > 1 && !mUsbBlocked );
 
     if ( toolBar() != mPlaylistToolBar ) {
         HbToolBar *tmpToolBar = takeToolBar();
@@ -1147,42 +1133,77 @@
 void MpCollectionView::updateMenu()
 {
     TX_ENTRY
-    HbMenu* myMenu = new HbMenu();
+    HbMenu *myMenu = new HbMenu();
+    HbAction *menuAction;
     if ( mViewMode == MpCommon::DefaultView ) {
         bool items = mCollectionData->count() != 0;
         switch ( mCollectionContext ) {
-            case ECollectionContextAllSongs:
-                if (items ) {
-                    connect( myMenu->addAction( hbTrId( "txt_mus_dblist_shuffle" ) ), SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
+            case ECollectionContextAllSongs:                
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_dblist_shuffle" ) ); 
+                if ( items ){
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
+                }
+                else {
+                    menuAction->setDisabled( true );
                 }
+                
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ); 
+                if ( items && !mUsbBlocked ) {
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
+                }
+                else {
+                    menuAction->setDisabled( true );
+                }
+                
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); 
                 if ( !mUsbBlocked ) {
-                    if (items ) {
-                        connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
-                    }
-                    connect( myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ), SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );                
+                }
+                else {
+                    menuAction->setDisabled( true );
                 }
                 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
                 break;
             case ECollectionContextAlbums:
                 //connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
                 // Todo: View as coverflow
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
                 if ( !mUsbBlocked ) {
-                    connect( myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ), SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
                 }
+                else {
+                    menuAction->setDisabled( true );
+                }
+                connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
                 break;
             case ECollectionContextAlbumSongs:
-                if ( items && !mUsbBlocked ) {
-                    connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ); 
+                if ( !mUsbBlocked ) {
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
+                }
+                else {
+                    menuAction->setDisabled( true );
                 }
                 break;
             case ECollectionContextPlaylists:
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
                 if ( !mUsbBlocked ) {
-                    connect( myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) ), SIGNAL( triggered() ), this, SLOT( prepareToAddToPlaylist() ) );
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( prepareToAddToPlaylist() ) );
                 }
+                else {
+                    menuAction->setDisabled( true );
+                }
+                connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
                 break;
             case ECollectionContextPlaylistSongs:
-                if ( !mCollectionData->isAutoPlaylist() && !mUsbBlocked ) {
-                    connect( myMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) ), SIGNAL( triggered() ), this, SLOT( renameCurrentPlaylistContainer() ) );
+                if ( !mCollectionData->isAutoPlaylist() ){
+                menuAction = myMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) );
+                    if ( !mUsbBlocked ) {
+                        connect( menuAction, SIGNAL( triggered() ), this, SLOT( renameCurrentPlaylistContainer() ) );
+                    }
+                    else {
+                        menuAction->setDisabled( true );
+                    }
                 }
                 break;
             default:
@@ -1190,8 +1211,29 @@
         }
     }
     else if ( mViewMode == MpCommon::FetchView ) {
-        if ( mCollectionContext == ECollectionContextAllSongs && !mUsbBlocked ) {
-            connect( myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ), SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
+        switch ( mCollectionContext ) {
+            case ECollectionContextAllSongs:                
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); 
+                if ( !mUsbBlocked ) {
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );                
+                }
+                else {
+                    menuAction->setDisabled( true );
+                }
+                break;
+            case ECollectionContextAlbums:
+                //connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
+                // Todo: View as coverflow
+                menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
+                if ( !mUsbBlocked ) {
+                    connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
+                }
+                else {
+                    menuAction->setDisabled( true );
+                }
+                break;
+            default:
+                break;
         }
     }
 
@@ -1264,7 +1306,7 @@
 void MpCollectionView::setBannerVisibility( bool visible )
 {
     bool ok = false;
-    if ( visible && ( hbInstance->allMainWindows()[0]->orientation() == Qt::Vertical ) ) {
+    if ( visible ) {
         mDocumentLoader->load( MUSIC_COLLECTION_DOCML, "showBanner", &ok );
         mNowPlayingBanner->show();
     }
@@ -1307,7 +1349,7 @@
     }
     QString newPlaylistName;
     QStringList playlists;
-    mMpxWrapper->findPlaylists( playlists );
+    mMpEngine->findPlaylists( playlists );
     HbListDialog dialog;
     dialog.setStringItems( playlists );
     dialog.setSelectionMode( HbAbstractItemView::SingleSelection );
@@ -1326,9 +1368,7 @@
             }
             else if ( dialog.selectedItems().count() ) {//this only works for SingleSelection
                 // User selected existing playlist, add songs and exit the loop.
-                if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-                    mMpxWrapper->saveToPlaylist( dialog.selectedItems().at( 0 ), selection );
-                }
+                mMpEngine->saveToPlaylist( dialog.selectedItems().at( 0 ), selection );                
                 break;
             }
             else {
@@ -1339,9 +1379,7 @@
         //querying for a new playlist name.
         if ( queryNewPlaylistName(newPlaylistName , playlists) ) {
             // user selected a new playlist, save and exit the loop.
-            if ( !mMpEngine->verifyUsbBlocking( true ) ) {
-                mMpxWrapper->createPlaylist( newPlaylistName, selection );
-            }
+            mMpEngine->createPlaylist( newPlaylistName, selection );
             break;
         }
         else if (!playlists.count()) {
@@ -1374,37 +1412,49 @@
             ( contextFrom == ECollectionContextGenres && contextTo == ECollectionContextGenreSongs ) ) {
         HbEffect::start( mSnapshot,
                 QString( "container" ),
-                QString( "slide_out_to_left" ) );
+                QString( "slide_out_to_left" ),
+                this,
+                "containerTransitionComplete",
+                QString( "snapshot_effect") );
 
         HbEffect::start( mMainContainer,
                 QString( "container" ),
                 QString( "slide_in_to_left_and_fade_in" ),
                 this,
-                "containerTransitionComplete" );
+                "containerTransitionComplete",
+                QString( "mainContainer_effect") );
     }
     else if( ( contextFrom == ECollectionContextAlbumSongs && contextTo == ECollectionContextAlbums ) ||
             ( contextFrom == ECollectionContextPlaylistSongs && contextTo == ECollectionContextPlaylists ) ||
             ( contextFrom == ECollectionContextGenreSongs && contextTo == ECollectionContextGenres ) ) {
         HbEffect::start( mSnapshot,
                 QString( "container" ),
-                QString( "slide_out_to_right" ) );
+                QString( "slide_out_to_right" ),
+                this,
+                "containerTransitionComplete",
+                QString( "snapshot_effect") );
 
         HbEffect::start( mMainContainer,
                 QString( "container" ),
                 QString( "slide_in_to_right_and_fade_in" ),
                 this,
-                "containerTransitionComplete" );
+                "containerTransitionComplete",
+                QString( "mainContainer_effect") );
     }
     else {
         HbEffect::start( mSnapshot,
                 QString( "container" ),
-                QString( "slide_out_to_top" ) );
+                QString( "slide_out_to_top" ),
+                this,
+                "containerTransitionComplete",
+                QString( "snapshot_effect") );
 
         HbEffect::start( mMainContainer,
                 QString( "container" ),
                 QString( "slide_in_to_top_and_fade_in" ),
                 this,
-                "containerTransitionComplete" );
+                "containerTransitionComplete",
+                QString( "mainContainer_effect") );
     }
 
 }
@@ -1469,8 +1519,8 @@
             break;
     }
 
-    if ( confirmation && !mMpEngine->verifyUsbBlocking( true ) ) {
-        mMpxWrapper->deleteSongs( selection );
+    if ( confirmation ) {
+        mMpEngine->deleteSongs( selection );
     }
 }
 
--- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectionviewplugin.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectionviewplugin.cpp	Mon May 03 12:29:20 2010 +0300
@@ -135,9 +135,8 @@
  */
 void MpCollectionViewPlugin::orientationChange( Qt::Orientation orientation )
 {
-    if ( mState == Activated ) {
-        mView->orientationChange(orientation);
-    }
+    TX_LOG
+    Q_UNUSED( orientation );
 }
 
 /*!
--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxcollectiondata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection data.
-*
-*/
-
-#include "mpmpxcollectiondata.h"
-#include "mpmpxcollectiondata_p.h"
-
-/*!
-    \class MpMpxCollectionData
-    \brief Music Player collection data.
-
-    Collection data provides access to collection data needed by the view.
-    Every item of data can be accessed via an index and its details by specifying
-    the data type of the selected data item.
-*/
-
-/*!
-    \enum MpMpxCollectionData::DataType
-
-    This enum defines available data types.
- */
-
-/*!
-    \fn void contextChanged( TCollectionContext context )
-
-    This signal is emitted when a new data set is available and the
-    collection context is changed.
-
-    \sa setMpxMedia()
- */
-
-/*!
- Constructs the collection data.
- */
-MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
-    : QObject(parent)
-{
-    d_ptr = new MpMpxCollectionDataPrivate(this);
-}
-
-/*!
- Destructs the collection data.
- */
-MpMpxCollectionData::~MpMpxCollectionData()
-{
-    delete d_ptr;
-}
-
-/*!
- Returns the current collection context.
- */
-TCollectionContext MpMpxCollectionData::context() const
-{
-    return d_ptr->context();
-}
-
-/*!
- Returns the number of data entries.
- */
-int MpMpxCollectionData::count() const
-{
-    return d_ptr->count();
-}
-
-/*!
- Returns the \a title of the collection data based on the current context.
- */
-QString MpMpxCollectionData::collectionTitle() const
-{
-    return d_ptr->collectionTitle();
-}
-
-/*!
- Returns the data for the specified \a index and \a type.
- */
-QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
-{
-    return d_ptr->itemData(index, type);
-}
-
-/*!
- Returns if the current container is of type 'Auto playlist'.
- */
-bool MpMpxCollectionData::isAutoPlaylist()
-{
-    return d_ptr->isAutoPlaylist();
-}
-
-/*!
- Returns if the item specified by \a index is of type 'Auto playlist'.
- */
-bool MpMpxCollectionData::isAutoPlaylist( int index )
-{
-    return d_ptr->isAutoPlaylist(index);
-}
-
-/*!
- Returns the count of the items contained within item specified by \a index.
- */
-int MpMpxCollectionData::itemCount( int index )
-{
-    return d_ptr->itemCount(index);
-}
-
-/*!
- Returns the current container id.
- */
-int MpMpxCollectionData::containerId()
-{
-    return d_ptr->containerId();
-}
-
-/*!
- Returns id of the item specified by \a index
- */
-int MpMpxCollectionData::itemId(int index)
-{
-    return d_ptr->itemId(index);
-}
-
-/*!
- Removes item specified by \a index, also internally caches the item for drag
- and drop operations.
- 
- \sa testCachedItem() insertCachedItem()
- */
-void MpMpxCollectionData::removeItem(int index)
-{
-    d_ptr->removeItem(index);
-}
-
-/*!
- Test wether the cached item matches \a itemId.
- \sa removeItem() insertCachedItem()
- */
-bool MpMpxCollectionData::testCachedItem( int itemId )
-{
-    return d_ptr->testCachedItem( itemId );
-}
-
-/*!
- Inserts the cached item in the location specified by \a index
- \sa removeItem() testCachedItem()
- */
-void MpMpxCollectionData::insertCachedItem(int index)
-{
-    return d_ptr->insertCachedItem( index );
-}
-
-/*!
- Sets the media \a entries from the MPX framework.
- Internal usage only from MpMpxFrameworkWrapper.
- */
-void MpMpxCollectionData::setMpxMedia( const CMPXMedia& entries )
-{
-    d_ptr->setMpxMedia(entries);
-}
-
-/*!
- Returns the container media from the MPX framework.
- Internal usage only from MpMpxFrameworkWrapper.
-
-
- \sa setMpxMedia()
- */
-const CMPXMedia& MpMpxCollectionData::containerMedia()
-{
-    return d_ptr->containerMedia();
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxcollectiondata_p.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,501 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection data - private implementation.
-*
-*/
-
-#include <thumbnaildata.h>
-#include <thumbnailobjectsource.h>
-
-#include <mpxmedia.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxmediaarray.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediamusicdefs.h>
-
-#include "mpmpxcollectiondata_p.h"
-#include "mptrace.h"
-
-_LIT( KSong, " song" );
-_LIT( KSongs, " songs" );
-
-/*!
-    \class MpMpxCollectionDataPrivate
-    \brief Music Player collection data - private implementation.
-
-    This is a private implementation of the collection data interface.
-*/
-
-/*!
- \internal
- */
-MpMpxCollectionDataPrivate::MpMpxCollectionDataPrivate( MpMpxCollectionData *wrapper )
-    : q_ptr( wrapper ),
-      iContainerMedia(0),
-      iMediaArray(0),
-      iContext( ECollectionContextUnknown ),
-      iCachedRemovedItem ( 0 )
-{
-    TX_LOG
-}
-
-/*!
- \internal
- */
-MpMpxCollectionDataPrivate::~MpMpxCollectionDataPrivate()
-{
-    TX_ENTRY
-    delete iContainerMedia;
-    delete iCachedRemovedItem;
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-TCollectionContext MpMpxCollectionDataPrivate::context() const
-{
-    return iContext;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::count() const
-{
-    if ( iMediaArray ) {
-        return iMediaArray->Count();
-    }
-    return 0;
-}
-
-/*!
- \internal
- */
-QString MpMpxCollectionDataPrivate::collectionTitle() const
-{
-    TX_ENTRY
-    QString title;
-    if ( iContainerMedia && iContainerMedia->IsSupported( KMPXMediaGeneralTitle ) ) {
-        const TDesC& titleText = iContainerMedia->ValueText( KMPXMediaGeneralTitle );
-        if ( titleText.Compare( KNullDesC ) != 0 ) {
-            title = QString::fromUtf16( titleText.Ptr(), titleText.Length() );
-        }
-    }
-    TX_EXIT_ARGS("title =" << title);
-    return title;
-}
-
-/*!
- \internal
- */
-QString MpMpxCollectionDataPrivate::itemData( int index, MpMpxCollectionData::DataType type ) const
-{
-    TX_ENTRY_ARGS("index=" << index << ", type=" << type);
-    QString data;
-    TRAPD(err, DoGetDataL(index, type, data));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return data;
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::isAutoPlaylist()
-{
-    TX_ENTRY
-    if ( iContext != ECollectionContextPlaylistSongs ) {
-        TX_EXIT
-        return false;
-    }
-
-    bool isAuto = false;
-    TRAPD(err, isAuto = DoIsAutoPlaylistL());
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("isAuto=" << isAuto);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return isAuto;
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::isAutoPlaylist( int index )
-{
-    TX_ENTRY_ARGS("index=" << index);
-    if ( iContext != ECollectionContextPlaylists ) {
-        TX_EXIT
-        return false;
-    }
-
-    bool isAuto = false;
-    TRAPD(err, isAuto = DoIsAutoPlaylistL(index));
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("isAuto=" << isAuto);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return isAuto;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::itemCount( int index )
-{
-    TX_ENTRY_ARGS("index=" << index);
-    int count = 0;
-    TRAPD(err, count = DoGetItemCountL(index));
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("count=" << count);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return count;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::containerId()
-{
-    int id = -1;
-    TRAPD( err, id = DoGetContainerIdL() );
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("id=" << id);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return id;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::itemId(int index)
-{
-    TX_ENTRY_ARGS("index=" << index);
-    int id = -1;
-    TRAPD(err, id = DoGetItemIdL(index));
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("id=" << id);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return id;
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::removeItem(int index)
-{
-    TX_ENTRY_ARGS("index=" << index);
-     TRAPD(err,  DoRemoveItemL(index));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::testCachedItem( int itemId )
-{
-    TX_ENTRY_ARGS( "itemId=" << itemId);
-    bool match = false;
-    TRAPD( err, match = DoTestCachedItemL( itemId ) );
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("match=" << match);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-    return match;
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::insertCachedItem(int index)
-{
-    TX_ENTRY_ARGS("index=" << index);
-    iMediaArray->Insert( iCachedRemovedItem, index );
-    iCachedRemovedItem = 0; //ownership tranferred above.
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::setMpxMedia( const CMPXMedia& entries )
-{
-    TX_ENTRY
-    TRAPD(err, DoSetMpxMediaL(entries));
-    if ( err == KErrNone ) {
-        TX_LOG_ARGS("Context changed: iContext=" << iContext);
-        emit q_ptr->contextChanged(iContext);
-    }
-    else {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::DoGetDataL( int index, MpMpxCollectionData::DataType type, QString& data ) const
-{
-    TX_ENTRY
-    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
-
-    TBuf<256> countBuf;
-    TBuf<20> temp;
-    TInt count = 0;
-    switch ( type ) {
-        case MpMpxCollectionData::Title:
-            if ( currentMedia->IsSupported( KMPXMediaGeneralTitle ) ) {
-                const TDesC& title = currentMedia->ValueText( KMPXMediaGeneralTitle );
-                if ( title.Compare( KNullDesC ) != 0 ) {
-                    data = QString::fromUtf16( title.Ptr(), title.Length() );
-                }
-            }
-            break;
-        case MpMpxCollectionData::Artist:
-            if ( currentMedia->IsSupported( KMPXMediaMusicArtist ) ) {
-                const TDesC& artist = currentMedia->ValueText( KMPXMediaMusicArtist );
-                if ( artist.Compare( KNullDesC ) != 0 ) {
-                    data = QString::fromUtf16( artist.Ptr(), artist.Length() );
-                }
-            }
-            break;
-        case MpMpxCollectionData::Count:
-            if ( currentMedia->IsSupported( KMPXMediaGeneralCount ) ) {
-                count = currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount );
-            }
-            temp.AppendNum( count );
-            //AknTextUtils::LanguageSpecificNumberConversion( temp );
-            countBuf.Append( temp );
-            countBuf.Append( (count > 1 ) ? KSongs() : KSong() );
-            data = QString::fromUtf16( countBuf.Ptr(), countBuf.Length() );
-            break;
-        case MpMpxCollectionData::AlbumArtUri:
-            if ( currentMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) {
-                const TDesC& album = currentMedia->ValueText( KMPXMediaMusicAlbumArtFileName );
-                if ( album.Compare( KNullDesC ) != 0 ) {
-                    data = QString::fromUtf16( album.Ptr(), album.Length() );
-                }
-            }
-            break;
-        case MpMpxCollectionData::Uri:
-            if ( currentMedia->IsSupported( KMPXMediaGeneralUri ) ) {
-                const TDesC& uri = currentMedia->ValueText( KMPXMediaGeneralUri );
-                if ( uri.Compare( KNullDesC ) != 0 ) {
-                    data = QString::fromUtf16( uri.Ptr(), uri.Length() );
-                }
-            }
-            break;
-        default:
-            break;
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::DoIsAutoPlaylistL()
-{
-    if ( iContainerMedia->IsSupported(KMPXMediaGeneralNonPermissibleActions) ) {
-        TMPXGeneralNonPermissibleActions attr(
-                iContainerMedia->ValueTObjectL<TMPXGeneralNonPermissibleActions>(
-                KMPXMediaGeneralNonPermissibleActions ) );
-        if ( attr & EMPXWrite ) {
-            return true;
-        }
-    }
-    return false;
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::DoIsAutoPlaylistL( int index )
-{
-    const CMPXMediaArray* containerArray = iContainerMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ));
-    CMPXMedia* media( containerArray->AtL(index) );
-
-    if ( media->IsSupported(KMPXMediaGeneralNonPermissibleActions) ) {
-        TMPXGeneralNonPermissibleActions attr(
-            media->ValueTObjectL<TMPXGeneralNonPermissibleActions>(
-                KMPXMediaGeneralNonPermissibleActions ) );
-        if ( attr & EMPXWrite ) {
-            return true;
-        }
-    }
-    return false;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::DoGetItemCountL( int index )
-{
-    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
-    int count = 0;
-    if ( currentMedia->IsSupported( KMPXMediaGeneralCount ) ) {
-        count = currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount );
-    }
-    return count;
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::DoGetContainerIdL()
-{
-    if ( !iContainerMedia->IsSupported( KMPXMediaGeneralId ) ) {
-        User::Leave(KErrNotFound);
-    }
-    return iContainerMedia->ValueTObjectL<TInt>( KMPXMediaGeneralId );
-}
-
-/*!
- \internal
- */
-int MpMpxCollectionDataPrivate::DoGetItemIdL( int index )
-{
-    CMPXMedia* currentMedia( iMediaArray->AtL( index ) );
-    if ( !currentMedia->IsSupported( KMPXMediaGeneralId ) ) {
-        User::Leave(KErrNotFound);
-    }
-    return currentMedia->ValueTObjectL<TInt>( KMPXMediaGeneralId );
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::DoRemoveItemL( int index )
-{
-    delete iCachedRemovedItem;
-    iCachedRemovedItem = 0;
-    iCachedRemovedItem = CMPXMedia::NewL( *iMediaArray->AtL( index ) );
-    iMediaArray->Remove( index );
-}
-
-/*!
- \internal
- */
-bool MpMpxCollectionDataPrivate::DoTestCachedItemL( int itemId )
-{
-    if ( !iCachedRemovedItem && !iCachedRemovedItem->IsSupported( KMPXMediaGeneralId ) ) {
-        User::Leave(KErrNotFound);
-    }
-    return ( itemId == iCachedRemovedItem->ValueTObjectL<TInt>( KMPXMediaGeneralId ) );
-}
-
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::SetCollectionContextL()
-{
-    TX_ENTRY
-    TMPXGeneralType containerType( EMPXNoType );
-    if ( iContainerMedia->IsSupported( KMPXMediaGeneralType ) ) {
-        containerType = iContainerMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType );
-    }
-
-    TMPXGeneralCategory containerCategory( EMPXNoCategory );
-    if( iContainerMedia->IsSupported( KMPXMediaGeneralCategory ) ) {
-        containerCategory = iContainerMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory );
-    }
-    TX_LOG_ARGS("type=" << containerType << ", category=" << containerCategory );
-
-    iContext = ECollectionContextUnknown;
-    if ( containerType == EMPXGroup ) {
-        switch (containerCategory) {
-            case EMPXSong:
-                iContext = ECollectionContextAllSongs;
-                break;
-            case EMPXAlbum:
-                iContext = ECollectionContextAlbums;
-                break;
-            case EMPXPlaylist:
-                iContext = ECollectionContextPlaylists;
-                break;
-            case EMPXGenre:
-                iContext = ECollectionContextGenres;
-                break;
-        }
-    }
-    else if ( containerType == EMPXItem ) {
-        switch (containerCategory) {
-            case EMPXAlbum:
-                iContext = ECollectionContextAlbumSongs;
-                break;
-            case EMPXPlaylist:
-                iContext = ECollectionContextPlaylistSongs;
-                break;
-            case EMPXGenre:
-                iContext = ECollectionContextGenreSongs;
-                break;
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxCollectionDataPrivate::DoSetMpxMediaL( const CMPXMedia& entries )
-{
-    TX_ENTRY
-    delete iContainerMedia;
-    iContainerMedia = 0;
-    iContainerMedia = CMPXMedia::NewL(entries);
-    iMediaArray = const_cast<CMPXMediaArray*>(iContainerMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
-    TX_LOG_ARGS("media count=" << iMediaArray->Count() );
-
-    SetCollectionContextL();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-const CMPXMedia& MpMpxCollectionDataPrivate::containerMedia()
-{
-    return *iContainerMedia;
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities.
-*
-*/
-
-#include "mpmpxframeworkwrapper.h"
-#include "mpmpxframeworkwrapper_p.h"
-
-/*!
-    \class MpMpxFrameworkWrapper
-    \brief Wrapper for mpx framework utilities.
-
-    MPX framework wrapper provides Qt style interface to the MPX framework
-    utilities. Its implementation is hidden using private class data pattern.
-*/
-
-/*!
-    \fn void collectionPlaylistOpened()
-
-    This signal is emitted when A new collection playlist is opened and 
-    playback is initialized.
-
- */
-
-/*!
-    \fn void playlistSaved( bool success )
-
-    This signal is emitted when playlist save operation is completed, it 
-    indicates the operation \a success .
-
- */
-
-/*!
-    \fn void songsDeleted( bool success )
-
-    This signal is emitted when song delete operation is completed, it 
-    indicates the operation \a success .
-
- */
-
-/*!
-    \fn void playlistsRenamed( bool success )
-
-    This signal is emitted when playlist rename operation is completed, it
-    indicates the operation  \a success .
-
- */
-
-/*!
-    \fn void isolatedCollectionOpened( MpMpxCollectionData* collectionData )
-
-    This signal is emitted when an isolated collection is opened on \a context
-
- */
- 
- 
- 
-/*!
- Constructs the utility wrapper.
- */
-MpMpxFrameworkWrapper::MpMpxFrameworkWrapper( MpCommon::MpViewMode viewMode, QObject *parent )
-    : QObject( parent )
-{
-    d_ptr = new MpMpxFrameworkWrapperPrivate( this );
-    d_ptr->init( viewMode );
-}
-
-/*!
- Destructs the utility wrapper.
- */
-MpMpxFrameworkWrapper::~MpMpxFrameworkWrapper()
-{
-    delete d_ptr;
-}
-
-/*!
- Opens the collection for the given \a context.
-
- \sa collectionOpened()
- */
-void MpMpxFrameworkWrapper::openCollection( TCollectionContext context )
-{
-    d_ptr->openCollection( context );
-}
-
-/*!
- Opens the collection at a specific \a index.
-
- \sa collectionOpened(), playlistOpened()
- */
-void MpMpxFrameworkWrapper::openCollectionItem( int index )
-{
-    d_ptr->openCollectionItem( index );
-}
-
-/*!
- Navigates back to the container of the current items.
-
- \sa collectionOpened()
- */
-void MpMpxFrameworkWrapper::back()
-{
-    d_ptr->back();
-}
-
-/*!
- Loads the user created \a playLists.
-
- */
-void MpMpxFrameworkWrapper::findPlaylists( QStringList &playlists )
-{
-    d_ptr->findPlaylists( playlists );
-}
-
-/*!
- Creates a new playlist with name \a playlistName and adds \a selection and optionally uses \a collectionData.
- */
-void MpMpxFrameworkWrapper::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
-{
-    d_ptr->createPlaylist( playlistName, selection, collectionData );
-}
-
-/*!
- Adds \a selection to the playlist specified in \a playlistIndex.
- */
-void MpMpxFrameworkWrapper::saveToPlaylist( int playlistIndex, QList<int> &selection )
-{
-    d_ptr->saveToPlaylist( playlistIndex, selection );
-}
-
-/*!
- Rename a playlist by \a index with \a name.
- */
-void MpMpxFrameworkWrapper::renamePlaylist( QString &newName, int index )
-{
-    d_ptr->renamePlaylist( newName, index );
-}
-
-/*!
- Adds \a selection to the current playlist from the specified \a collectionData.
- */
-void MpMpxFrameworkWrapper::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
-{
-    d_ptr->saveToCurrentPlaylist( selection, collectionData );
-}
-
-/*!
- Rename a playlist with \a name.
- */
-void MpMpxFrameworkWrapper::renamePlaylist( QString &newName )
-{
-    d_ptr->renamePlaylist( newName );
-}
-
-/*!
- Deletes \a selection from the collection.
- */
-void MpMpxFrameworkWrapper::deleteSongs( QList<int> &selection )
-{
-    d_ptr->deleteSongs( selection );
-}
-
-/*!
- Sets the suffle according to \a active.
- */
-void MpMpxFrameworkWrapper::setShuffle( bool active )
-{
-    d_ptr->setShuffle( active );
-}
-
-/*!
- Initiate a playback preview for the selected item.
- */
-void MpMpxFrameworkWrapper::previewItem( int index )
-{
-    d_ptr->previewItem( index );
-}
-
-
-/*!
- Opens the an isolated collection with \a context.
- \sa isolatedCollectionOpened()
- */
-void MpMpxFrameworkWrapper::openIsolatedCollection( TCollectionContext context )
-{
-       d_ptr->openIsolatedCollection( context );     
-}
-
-/*!
- Releases the resources used for the isolated collection.
- */
-void MpMpxFrameworkWrapper::releaseIsolatedCollection()
-{
-    d_ptr->releaseIsolatedCollection();
-}
-
-/*!
- Returns pointer to MpMpxCollectionData, which is the collection data.
- */
-MpMpxCollectionData *MpMpxFrameworkWrapper::collectionData()
-{
-    return d_ptr->collectionData();
-}
-
-/*!
- Slot to be called to reopen the collection in its current state.
-
- \sa collectionOpened()
- */
-void MpMpxFrameworkWrapper::reopenCollection()
-{
-    d_ptr->reopenCollection();
-}
-
-/*!
- Slot to be called to request a reorder operation , indicates that 
- the item with \a playlistId , \a songId is to be moved from 
- \a originalOrdinal to \a newOrdinal.
- */
-void MpMpxFrameworkWrapper::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
-{
-    d_ptr->reorderPlaylist( playlistId, songId, originalOrdinal, newOrdinal );
-}
-
-
--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxframeworkwrapper_p.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,942 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Wrapper for mpx framework utilities - private implementation.
-*
-*/
-
-#include <QStringList>
-
-#include <s32strm.h>
-#include <s32mem.h>
-#include <apgcli.h>
-#include <apacmdln.h>
-
-#include <mpxplaybackutility.h>
-#include <mpxcollectionutility.h>
-#include <mpxharvesterutility.h>
-#include <mpxcollectionpath.h>
-#include <mpxcollectionmessage.h>
-#include <mpxcollectionplaylist.h>
-#include <mpxmessagecontainerdefs.h>
-#include <mpxmediacollectiondetaildefs.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxcollectionplugin.hrh>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxcollectionmessagedefs.h>
-#include <mpxparameter.h>
-#include <mpxcollectionhelperfactory.h>
-#include <mpxcollectionuihelper.h>
-#include <mpxcollectionopenutility.h>
-#include <mpxmediaarray.h>
-#include <mpxmedia.h>
-#include <mpxlog.h>
-
-#include "mpmpxframeworkwrapper_p.h"
-#include "mpmpxframeworkwrapper.h"
-#include "mpmpxcollectiondata.h"
-#include "mpcommondefs.h"
-#include "mptrace.h"
-#include "mpsettingsmanager.h"
-
-const TInt KIncrementalDelayNone = 0;
-const TInt KIncrementalDelayHalfSecond = 1000000;
-const TInt KIncrementalFetchBlockSize = 40;
-
-const TInt KMPXChunkSize = 100;  // number of songs added in each chunk, IncAddL
-_LIT( KPlaylistPath, "C:\\Data\\Playlists\\" ); // Todo
-
-/*!
-    \class MpMpxFrameworkWrapperPrivate
-    \brief Wrapper for mpx framework utilities - private implementation.
-
-    This is a private implementation of the mpx framework wrapper utilties interface.
-*/
-
-/*!
- \internal
- */
-MpMpxFrameworkWrapperPrivate::MpMpxFrameworkWrapperPrivate( MpMpxFrameworkWrapper *wrapper )
-    : q_ptr( wrapper ),
-      iCollectionUtility( 0 ),
-      iCollectionUiHelper( 0 ),
-      iIncrementalOpenUtil( 0 ),
-      iIsolatedCollectionHelper( 0 ),
-      iPlaybackUtility( 0 ),
-      iCollectionData( 0 ),
-      iIsolatedCollectionData( 0 ),
-      iFirstIncrementalOpen( EFalse ),
-      iUserPlaylists( 0 )
-{
-    TX_LOG
-}
-
-/*!
- \internal
- */
-MpMpxFrameworkWrapperPrivate::~MpMpxFrameworkWrapperPrivate()
-{
-    TX_ENTRY
-    delete iCollectionData;
-    delete iIsolatedCollectionData;
-
-    if ( iCollectionUtility ) {
-        iCollectionUtility->Collection().CancelRequest();
-        iCollectionUtility->Close();
-    }
-
-    if ( iCollectionUiHelper ) {
-        iCollectionUiHelper->Close();
-    }
-
-    if ( iPlaybackUtility ) {
-        iPlaybackUtility->Close();
-    }
-
-    delete iIncrementalOpenUtil;
-    delete iIsolatedCollectionHelper;
-    delete iUserPlaylists;
-
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::init( MpCommon::MpViewMode viewMode )
-{
-
-    iViewMode = viewMode;
-    TRAPD( err, DoInitL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::openCollection( TCollectionContext context )
-{
-    TRAPD( err, DoOpenCollectionL( context ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::openCollectionItem( int index )
-{
-    TRAPD( err, DoOpenCollectionItemL( index ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::reopenCollection()
-{
-    TRAPD( err, DoReopenCollectionL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::back()
-{
-    TRAPD( err, DoBackL() );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::findPlaylists( QStringList &playlists )
-{
-    TRAPD( err, DoFindPlaylistsL( playlists ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
-{
-    TRAPD( err, DoCreatePlaylistL( playlistName, selection, collectionData ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::saveToPlaylist( int playlistIndex, QList<int> &selection )
-{
-    TRAPD( err, DoSaveToPlaylistL( playlistIndex, selection ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData )
-{
-    TRAPD( err, DoSaveToCurrentPlaylistL( selection, collectionData ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-} 
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::deleteSongs( QList<int> &selection )
-{
-    TRAPD( err, DoDeleteSongsL( selection ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString &newName, int index )
-{      
-    TRAPD( err, DoRenamePlaylistL( newName, index ) );
-    if ( err != KErrNone ) {
-    TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::renamePlaylist( QString &newName )
-{      
-    TRAPD( err, DoRenamePlaylistL( newName ) );
-    if ( err != KErrNone ) {
-    TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::setShuffle( bool active )
-{
-    TRAPD( err, DoSetShuffleL( active ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::previewItem( int index )
-{
-    TRAPD( err, DoPreviewItemL( index ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
- void MpMpxFrameworkWrapperPrivate::openIsolatedCollection( TCollectionContext context )
-{
-    TRAPD( err, DoOpenIsolatedCollectionL( context ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::releaseIsolatedCollection()
-{
-    delete iIsolatedCollectionHelper;
-    iIsolatedCollectionHelper = 0;
-    delete iIsolatedCollectionData;
-    iIsolatedCollectionData = 0;
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal )
-{
-    TRAPD( err, DoReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal ) );
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS( "Error: " << err << "; should never get here." );
-    }
-}
-
-/*!
- \internal
- */
-MpMpxCollectionData *MpMpxFrameworkWrapperPrivate::collectionData()
-{
-    return iCollectionData;
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleOpenL( 
-    const CMPXMedia& aEntries,
-    TInt aIndex,
-    TBool aComplete,
-    TInt aError )
-{
-    Q_UNUSED( aIndex );
-    TX_UNUSED( aComplete );
-    TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete );
-    if ( aError == KErrNone ) {
-        if ( iFirstIncrementalOpen ) {
-            iCollectionData->setMpxMedia( aEntries );
-            iFirstIncrementalOpen = EFalse;
-        }
-    }
-    else {
-        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleOpenL( 
-    const CMPXCollectionPlaylist& aPlaylist,
-    TInt aError )
-{
-    TX_ENTRY_ARGS( "aError=" << aError );
-
-    if ( aError == KErrNone ) {
-        if ( !iPlaybackUtility ) {
-            iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) );
-            if ( iViewMode == MpCommon::DefaultView ) {
-                iPlaybackUtility->SetL( EPbPropertyRandomMode, MpSettingsManager::shuffle() ? ETrue : EFalse );
-                iPlaybackUtility->SetL( EPbPropertyRepeatMode, MpSettingsManager::repeat() ? EPbRepeatAll : EPbRepeatOff );
-            }
-        }
-        iPlaybackUtility->InitL( aPlaylist, ETrue );
-        emit q_ptr->collectionPlaylistOpened();
-    }
-    else {
-        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMessage( 
-    CMPXMessage* aMsg,
-    TInt aErr )
-{
-    TX_ENTRY_ARGS( "aErr=" << aErr );
-    if ( aErr == KErrNone && aMsg )
-        {
-        TRAP_IGNORE( DoHandleCollectionMessageL( *aMsg ) );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleCollectionMediaL( 
-    const CMPXMedia& aMedia,
-    TInt aError )
-{
-    Q_UNUSED( aMedia );
-    Q_UNUSED( aError );
-}
-
-/*!
- \internal
- Handles the completion of any collection helper event.
- */
-void MpMpxFrameworkWrapperPrivate::HandleOperationCompleteL( 
-    TCHelperOperation aOperation,
-    TInt aErr,
-    void* aArgument )
-{
-    TX_ENTRY_ARGS( "aErr=" << aErr );
-    switch( aOperation ) {
-    case EDeleteOp:
-        emit q_ptr->songsDeleted( KErrNone == aErr );
-        break;
-    case EAddOp:
-        emit q_ptr->playlistSaved( KErrNone == aErr );
-        break;
-    case ERenameOp:
-        emit q_ptr->playlistsRenamed( KErrNone == aErr );
-        break;
-    default:
-        break;
-    }
-
-    if ( aArgument ) {
-        delete ( CBase* )aArgument;
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
-{
-    TX_ENTRY_ARGS( "aError=" << aError );
-    if ( aError == KErrNone ) {
-        if ( iIsolatedCollectionData ) {
-            delete iIsolatedCollectionData;
-            iIsolatedCollectionData = 0;
-        }  
-        iIsolatedCollectionData = new MpMpxCollectionData();
-        iIsolatedCollectionData->setMpxMedia( aEntries );
-        emit q_ptr->isolatedCollectionOpened( iIsolatedCollectionData );
-    }
-    else {
-        TX_LOG_ARGS( "Error: " << aError << "; should never get here." );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoInitL()
-{
-    TX_ENTRY
-    iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault );
-    iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL();
-    iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this );
-
-    iCollectionData = new MpMpxCollectionData();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoOpenCollectionL( 
-    TCollectionContext aContext )
-{
-    TX_ENTRY_ARGS( "aContext=" << aContext );
-
-    switch ( aContext ) {
-    case ECollectionContextAllSongs:
-        {
-        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL();
-        CleanupStack::PushL( cpath );
-        iCollectionUtility->Collection().OpenL( *cpath );
-        CleanupStack::PopAndDestroy( cpath );
-        break;
-        }
-    case ECollectionContextAlbums:
-        {
-        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
-        CleanupStack::PushL( cpath );
-        cpath->AppendL( 3 );
-        iCollectionUtility->Collection().OpenL( *cpath );
-        CleanupStack::PopAndDestroy( cpath );
-        break;
-        }
-    case ECollectionContextPlaylists:
-        {
-        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicPlaylistPathL();
-        CleanupStack::PushL( cpath );
-        iCollectionUtility->Collection().OpenL( *cpath );
-        CleanupStack::PopAndDestroy( cpath );
-        break;
-        }
-    case ECollectionContextGenres:
-        {
-        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL();
-        CleanupStack::PushL( cpath );
-        // Temp
-        cpath->AppendL( 5 );
-        iCollectionUtility->Collection().OpenL( *cpath );
-        CleanupStack::PopAndDestroy( cpath );
-        break;
-        }
-    default:
-        TX_LOG_ARGS( "Error: Unexpected context; should never get here." );
-        break;
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoOpenCollectionItemL( TInt aIndex )
-    {
-    TX_ENTRY_ARGS( "aIndex=" << aIndex );
-    iCollectionUtility->Collection().OpenL( aIndex );
-    TX_EXIT
-    }
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoIncrementalOpenL()
-{
-    TX_ENTRY
-    // Cancel any reads
-    iIncrementalOpenUtil->Stop();
-
-    // Start the read
-    iFirstIncrementalOpen = ETrue;
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    TArray<TMPXAttribute> ary = attrs.Array();
-    iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
-    iIncrementalOpenUtil->StartL( ary, KIncrementalFetchBlockSize,
-                                  KErrNotFound, CMPXCollectionOpenUtility::EFetchNormal );
-    iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
-    CleanupStack::PopAndDestroy( &attrs );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoReopenCollectionL()
-{
-    TX_ENTRY
-    CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( cpath );
-    cpath->Back();
-    iCollectionUtility->Collection().OpenL( *cpath );
-    CleanupStack::PopAndDestroy( cpath );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoBackL()
-{
-    TX_ENTRY
-    iCollectionUtility->Collection().BackL();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoFindPlaylistsL( QStringList &playlists )
-{
-    TX_ENTRY
-    delete iUserPlaylists;
-    iUserPlaylists = NULL;
-
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    attrs.Append( KMPXMediaGeneralId );
-    attrs.Append( KMPXMediaGeneralTitle );
-
-    CMPXMedia* criteria = CMPXMedia::NewL();
-    CleanupStack::PushL( criteria );
-    criteria->SetTObjectValueL<TMPXGeneralType>( 
-        KMPXMediaGeneralType, EMPXGroup );
-    criteria->SetTObjectValueL<TMPXGeneralCategory>( 
-        KMPXMediaGeneralCategory, EMPXPlaylist );
-
-    // Look up collection UID and set to criteria
-    RArray<TUid> ary;
-    CleanupClosePushL( ary );
-    ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
-    TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
-    CleanupStack::PopAndDestroy( &ary );
-
-    criteria->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection );
-
-    iUserPlaylists = iCollectionUtility->Collection().FindAllL( *criteria, attrs.Array() );
-    CleanupStack::PopAndDestroy( criteria );
-    CleanupStack::PopAndDestroy( &attrs );
-
-    if ( iUserPlaylists ) {
-        const CMPXMediaArray* mediaArray =
-            iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-        User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
-        TInt count = mediaArray->Count();
-        for ( TInt i = 0; i < count; i++ ) {
-            CMPXMedia* media( mediaArray->AtL( i ) );
-            const TDesC& titleText = media->ValueText( KMPXMediaGeneralTitle );
-            if ( titleText.Compare( KNullDesC ) != 0 ) {
-            playlists += QString::fromUtf16( titleText.Ptr(), titleText.Length() );
-            }
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData )
-{
-    TX_ENTRY_ARGS( "playlistName=" << playlistName );
-    CMPXMedia* tracks = CMPXMedia::NewL();
-    CleanupStack::PushL( tracks );
-
-    TPtrC ptr( reinterpret_cast<const TText*>( playlistName.constData() ) );
-    tracks->SetTextValueL( KMPXMediaGeneralTitle, ptr );
-    tracks->SetTextValueL( KMPXMediaGeneralUri, KPlaylistPath );
-    //if collection data is not provided we use the browsing collection.
-    PreparePlaylistMediaL( *tracks, selection, collectionData ? collectionData : iCollectionData );
-
-    iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
-    CleanupStack::PopAndDestroy( tracks );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData )
-{
-    TX_ENTRY_ARGS( "playlistId=" << int( playlistId ) );
-    
-    CMPXMedia* tracks = CMPXMedia::NewL();
-    CleanupStack::PushL( tracks );
-
-    RArray<TUid> ary;
-    CleanupClosePushL( ary );
-    ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) );
-    TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() );
-    CleanupStack::PopAndDestroy( &ary );
-
-    tracks->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, playlistId );
-    tracks->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection );
-    PreparePlaylistMediaL( *tracks, selection, collectionData );
-
-    iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize );
-    CleanupStack::PopAndDestroy( tracks );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoSaveToPlaylistL( int playlistIndex, QList<int> &selection )
-{
-    TX_ENTRY_ARGS( "playlistIndex=" << playlistIndex );
-
-    const CMPXMediaArray* mediaArray =  iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) );
-    CMPXMedia* media( mediaArray->AtL( playlistIndex ) );
-    TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-    DoSaveToPlaylistL( playlistId, selection, iCollectionData );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData )
-{
-    TX_ENTRY
-
-    const CMPXMedia& container = iCollectionData->containerMedia();
-    if ( container.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) != EMPXItem && 
-        container.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) != EMPXPlaylist) {
-        User::Leave( KErrArgument );
-    }
-    TMPXItemId playlistId( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-    DoSaveToPlaylistL( playlistId, selection, collectionData );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoDeleteSongsL( QList<int> &selection )
-{
-    int count = selection.count();
-    TX_ENTRY_ARGS( "selection count=" << count );
-
-    CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() );
-    CleanupStack::PushL( path );
-
-    for ( TInt i = 0; i < count; i++ ) {
-        path->SelectL( selection.at( i ) );
-    }
-    iCollectionUiHelper->DeleteL( *path, this );
-    CleanupStack::PopAndDestroy( path );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName, int index )
-{
-    TX_ENTRY
-    CMPXMediaArray *mediaArray;  
-    const CMPXMedia& container = iCollectionData->containerMedia();
-    mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
-    CMPXMedia* currentPlaylistMedia( mediaArray->AtL( index ) );
-    TMPXItemId id( currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-    DoRenamePlaylistL( id, newName );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName )
-{
-    TX_ENTRY
-    const CMPXMedia& container = iCollectionData->containerMedia();
-    TMPXItemId id( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-    DoRenamePlaylistL( id, newName );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoRenamePlaylistL( TMPXItemId id, QString &newName )
- {
-     CMPXMedia* media = CMPXMedia::NewL();
-     CleanupStack::PushL( media );
-     media->SetTObjectValueL<TMPXGeneralType>( 
-     KMPXMediaGeneralType, EMPXItem );
-     media->SetTObjectValueL<TMPXGeneralCategory>( 
-     KMPXMediaGeneralCategory, EMPXPlaylist );
-     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
-     TPtrC ptr( reinterpret_cast<const TText*>( newName.constData() ) );
-     media->SetTextValueL( KMPXMediaGeneralTitle, ptr );
-     iCollectionUiHelper->RenameL( *media, this );
-     CleanupStack::PopAndDestroy( media );
- }     
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoSetShuffleL( bool active )
-{
-    TX_ENTRY
-    if ( iPlaybackUtility ) {
-        iPlaybackUtility->SetL( EPbPropertyRandomMode, active );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoPreviewItemL( int index )
-{
-    TX_ENTRY
-    if ( !iPlaybackUtility ) {
-        iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) );
-    }
-
-    // Get the current path
-    CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( cpath );
-    MPX_DEBUG_PATH( *cpath );
-    cpath->Back();
-
-    CMPXMediaArray *mediaArray;
-    const CMPXMedia& container = iCollectionData->containerMedia();
-    mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
-    CMPXMedia* currentMedia( mediaArray->AtL( index ) );
-    TMPXItemId id( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-
-    cpath->AppendL( id ); // Top level items of songs
-    cpath->Set( 0 ); // Select 1st song
-
-    CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath );
-    CleanupStack::PushL( playList );
-    playList->SetToFirst();
-
-    iPlaybackUtility->InitL( *playList, ETrue );
-    emit q_ptr->collectionPlaylistOpened();
-
-    CleanupStack::PopAndDestroy( playList );
-    CleanupStack::PopAndDestroy( cpath );
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoOpenIsolatedCollectionL( TCollectionContext context )
-{
-
-    if ( ECollectionContextAllSongs == context ) {
-        CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL();
-        CleanupStack::PushL( cpath );
-        if ( !iIsolatedCollectionHelper ) {
-            iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( this );
-        }   
-        iIsolatedCollectionHelper->OpenCollectionL( *cpath );
-        CleanupStack::PopAndDestroy( cpath );
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal )
-{
-    iCollectionUiHelper->ReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal, this );           
-}
-
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::DoHandleCollectionMessageL( 
-    const CMPXMessage& aMsg )
-{
-    TX_ENTRY
-    TMPXMessageId id( aMsg.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
-    if ( KMPXMessageGeneral == id ) {
-        TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
-        TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
-        TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
-        TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data );
-
-        if ( event == TMPXCollectionMessage::EPathChanged &&
-             type == EMcPathChangedByOpen &&
-             data == EMcContainerOpened ) {
-            // Incremental Open when browsing to the next level
-            DoIncrementalOpenL();
-        }
-        else if ( event == TMPXCollectionMessage::EPathChanged &&
-                  type == EMcPathChangedByOpen &&
-                  data == EMcItemOpened ) {
-            // Opened a song
-            // This will result in HandleOpenL with CMPXCollectionPlaylist
-            iCollectionUtility->Collection().OpenL();
-        }
-    }
-    TX_EXIT
-}
-
-
-/*!
- \internal
- */
-void MpMpxFrameworkWrapperPrivate::PreparePlaylistMediaL( 
-        CMPXMedia& aMedia,
-        QList<int> &selection,
-        MpMpxCollectionData *collectionData )
-{
-    int count = selection.count();
-    TX_ENTRY_ARGS( "selection count=" << count );
-
-    const CMPXMedia& container = collectionData->containerMedia();
-    const CMPXMediaArray* containerArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    User::LeaveIfNull( const_cast<CMPXMediaArray*>( containerArray ) );
-    CMPXMediaArray* tracksArray( CMPXMediaArray::NewL() );
-    CleanupStack::PushL( tracksArray );
-
-    CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() );
-    CleanupStack::PushL( path );
-    TMPXItemId collectionId( path->Id( 0 ) );
-    CleanupStack::PopAndDestroy( path );
-
-    if ( collectionData->context() == ECollectionContextAlbums ) {
-        for ( TInt i = 0; i < count; i++ ) {
-            CMPXMedia* results;
-            CMPXMedia* album( containerArray->AtL( selection[i] ) );
-            // Fetch the songs for the selected album
-            TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-            CMPXMedia* findCriteria = CMPXMedia::NewL();
-            CleanupStack::PushL( findCriteria );
-            findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );
-            findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong );
-            findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, albumId );
-            RArray<TMPXAttribute> attrs;
-            CleanupClosePushL( attrs );
-            attrs.Append( TMPXAttribute( KMPXMediaIdGeneral,
-                                         EMPXMediaGeneralTitle |
-                                         EMPXMediaGeneralId ) );
-            attrs.Append( KMPXMediaMusicAlbumTrack );
-            results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array() );
-            CleanupStack::PopAndDestroy( &attrs );
-            CleanupStack::PopAndDestroy( findCriteria );
-            CleanupStack::PushL( results );
-            
-            const CMPXMediaArray* resultsArray = results->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-            User::LeaveIfNull( resultsArray );
-            for ( int j = 0 ; j < resultsArray->Count();j++ ) {
-                CMPXMedia* media( resultsArray->AtL( j ) );
-                CMPXMedia* entry = CMPXMedia::NewL();
-                CleanupStack::PushL( entry );
-                entry->SetTextValueL( KMPXMediaGeneralTitle,
-                    media->ValueText( KMPXMediaGeneralTitle ) );
-                entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
-                entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
-                entry->SetTObjectValueL( KMPXMediaGeneralId,
-                    media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-                entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
-                CleanupStack::Pop( entry );
-                tracksArray->AppendL( entry );
-            }
-            CleanupStack::PopAndDestroy( results );
-        }
-        
-    }
-    else {   
-        for ( TInt i = 0; i < count; i++ ) {
-            CMPXMedia* media( containerArray->AtL( selection.at( i ) ) );
-            CMPXMedia* entry = CMPXMedia::NewL();
-            CleanupStack::PushL( entry );
-            entry->SetTextValueL( KMPXMediaGeneralTitle,
-                media->ValueText( KMPXMediaGeneralTitle ) );
-            entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
-            entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
-            entry->SetTObjectValueL( KMPXMediaGeneralId,
-                media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
-            entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId );
-            CleanupStack::Pop( entry );
-            tracksArray->AppendL( entry );
-        }
-    }
-    aMedia.SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXItem );
-    aMedia.SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXPlaylist );
-    aMedia.SetCObjectValueL( KMPXMediaArrayContents, tracksArray );
-    aMedia.SetTObjectValueL( KMPXMediaArrayCount, tracksArray->Count() );
-
-    CleanupStack::PopAndDestroy( tracksArray );
-    TX_EXIT
-}
--- a/mpviewplugins/mpcollectionviewplugin/src/mpmpxisolatedcollectionhelper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: isolated collection helper.
-*
-*/
-
-
-#include <mpxcollectionhelperfactory.h>
-#include <mpxcollectionuihelper.h>
-#include <mpxcollectionopenutility.h>
-
-#include "mpmpxisolatedcollectionhelper.h"
-#include "mpxlog.h"
-
-
-
-const TInt KIncrementalDelayNone = 0;
-const TInt KIncrementalDelayHalfSecond = 1000000;
-const TInt KIncrementalFetchBlockSize = 20;
-const TInt KIncrementalNullOffset = 0;
-
-
-/*!
-    \class CMpMpxIsolatedCollectionHelper
-    \brief Helper class to open an isolated collection.
-
-    This is a helper class to open an insolated collection.
-*/
-
-/*!
- \internal
- Two-phased constructor.
- */
-CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
-        MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    {
-    CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-/*!
- \internal
- Two-phased constructor.
- */
-CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
-        MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    {
-    CMpMpxIsolatedCollectionHelper* self =
-            new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-/*!
- \internal
- Destructor
- */
-CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
-    {
-    delete iIncrementalOpenUtil;
-    }
-    
-
-/*!
- \internal
- Opens an isolated collection with the /a path.
- */
-void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath )
-    {
-    //Using incremental open to open the collection.
-    
-    // Cancel any reads
-    iIncrementalOpenUtil->Stop();
-
-    // Start the read
-    iFirstIncrementalOpen = ETrue;
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    TArray<TMPXAttribute> ary = attrs.Array();
-    iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
-    iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
-                                  KIncrementalNullOffset, CMPXCollectionOpenUtility::EFetchNormal );
-    iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
-    CleanupStack::PopAndDestroy( &attrs );
-    }
-
-/*!
- \internal
- c++ Contructor
- */
-CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    : iObserver( aObserver ),
-      iIncrementalOpenUtil( 0 ),
-      iFirstIncrementalOpen( EFalse )
-    {
-    }
-
-/*!
- \internal
- Leaving constructor
- */
-void CMpMpxIsolatedCollectionHelper::ConstructL()
-    {
-    iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
-
-    }
-
-
-/*!
- \internal
- reimp
- */
-void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
-    const CMPXMedia& aEntries,
-    TInt /*aIndex*/,
-    TBool /*aComplete*/,
-    TInt aError )
-    {
-    if ( iFirstIncrementalOpen )
-        {
-        iObserver->HandleIsolatedOpenL( aEntries, aError );
-        iFirstIncrementalOpen = EFalse;
-        }
-    }
-
-/*!
- \internal
-  reimp
- */
-void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
-    const CMPXCollectionPlaylist& /*aPlaylist*/,
-    TInt /*aError*/ )
-    {
-    }
-
-/*!
- \internal
-  reimp
- */
-void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage( 
-    CMPXMessage* /*aMsg*/,
-    TInt /*aErr*/ )
-    {
-    }
-
-/*!
- \internal
-  reimp
- */
-void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL( 
-    const CMPXMedia& /*aMedia*/,
-    TInt /*aError*/ )
-    {
-    }
-    
-//EOF
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/inc/unittest_mpcollectionalbumartmanager.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpcollectionalbumartmanager
-*
-*/
-
-#ifndef TESTMPCOLLECTIONALBUMARTMANAGER_H
-#define TESTMPCOLLECTIONALBUMARTMANAGER_H
-
-#include <QtTest/QtTest>
-#include <QIcon>
-
-class MpCollectionAlbumArtManager;
-class MpMpxCollectionData;
-
-class TestMpCollectionAlbumArtManager : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    TestMpCollectionAlbumArtManager();
-    virtual ~TestMpCollectionAlbumArtManager();
-
-signals:
-
-    void thumbnailReady( QPixmap pixmap, void *data, int id, int error );
-
-public slots:
-
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-
-    void testMemberCleanup();
-    void testAlbumArtNoCache();
-    void testAlbumArtNoCacheQueue();
-    void testAlbumArtCache();
-    void testAlbumArtNoUri();
-    void testAlbumArtFail();
-    void testCacheFirstScreenEmpty();
-    void testCacheFirstScreen();
-    void testCacheFirstScreenAllCached();
-    void testCancel();
-    void testThumbnailReadyCache();
-    void testThumbnailReadyCacheError();
-    void testThumbnailReadyAlbumArt();
-    void testThumbnailReadyAlbumArtError();
-
-private:
-
-    MpCollectionAlbumArtManager *mTest;
-    MpMpxCollectionData         *mStubData;
-    QIcon                       mIcon;
-
-};
-
-#endif  // TESTMPCOLLECTIONALBUMARTMANAGER_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/src/unittest_mpcollectionalbumartmanager.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,390 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpnowplayingbackend
-*
-*/
-
-#include <QSignalSpy>
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-#include <hbicon.h>
-
-#include "unittest_mpcollectionalbumartmanager.h"
-#include "stub/inc/thumbnailmanager_qt.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-
-// Do this so we can access all member variables.
-#define private public
-#include "mpcollectionalbumartmanager.h"
-#undef private
-
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestMpCollectionAlbumArtManager tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpcollectionalbumartmanager.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestMpCollectionAlbumArtManager::TestMpCollectionAlbumArtManager()
-    : mTest(0),
-      mStubData(0)
-{
-}
-
-TestMpCollectionAlbumArtManager::~TestMpCollectionAlbumArtManager()
-{
-    delete mTest;
-    delete mStubData;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestMpCollectionAlbumArtManager::initTestCase()
-{
-    mStubData = new MpMpxCollectionData();
-
-    // Create an icon (any icon will do) to help with testing.
-    mIcon = QIcon(":/icons/default_album.png");
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestMpCollectionAlbumArtManager::cleanupTestCase()
-{
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestMpCollectionAlbumArtManager::init()
-{
-    mTest = new MpCollectionAlbumArtManager(mStubData);
-    mStubData->mCount = 100;
-    mStubData->mItemDataReturn = true;
-}
-
-/*!
- Called after every testfunction.
- */
-void TestMpCollectionAlbumArtManager::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- Tests correct cleanup of member variables.
- */
-void TestMpCollectionAlbumArtManager::testMemberCleanup()
-{
-    cleanup();
-    ThumbnailManager::resetInitCounter();
-    init();
-    cleanup();
-    QCOMPARE(ThumbnailManager::getInitCounter(), 0);
-}
-
-/*!
- Tests albumArt() request when album art is not in local cache.
- Single request.
- */
-void TestMpCollectionAlbumArtManager::testAlbumArtNoCache()
-{
-    const QIcon* icon = mTest->albumArt(1);
-    // Verify that:
-    // - It returned default icon
-    // - A request has been made to thumbnail manager
-    QVERIFY(icon->isNull() == false);
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
-}
-
-/*!
- Tests albumArt() request when art is not in local cache.
- Request more than 1 to test request queue.
- */
-void TestMpCollectionAlbumArtManager::testAlbumArtNoCacheQueue()
-{
-    for ( int i = 0; i < 3; i++) {
-        const QIcon* icon = mTest->albumArt(i);
-        QVERIFY(icon->isNull() == false);
-    }
-    // Verify that:
-    // - Max number of requests were sent to thumbnail manager
-    // - A request has been queued
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
-}
-
-/*!
- Tests albumArt() request when art is in local cache.
- */
-void TestMpCollectionAlbumArtManager::testAlbumArtCache()
-{
-    mTest->mImageCache.insert(0, new QIcon(mIcon));
-
-    const QIcon* icon = mTest->albumArt(0);
-    // Verify that:
-    // - A valid icon has been returned
-    // - No request has been sent to thumbnail manager
-    QVERIFY(icon->isNull() == false);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
-}
-
-/*!
- Tests albumArt() request when item doesn't have AlbumArtUri.
- */
-void TestMpCollectionAlbumArtManager::testAlbumArtNoUri()
-{
-    mTest->mCollectionData->mItemDataReturn = false;
-    const QIcon* icon = mTest->albumArt(0);
-    // Verify that:
-    // - It returned default icon
-    // - There is no request pending from thumbnail manager
-    QVERIFY(icon->isNull() == false);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-}
-
-/*!
- Tests albumArt() request when thumbnail request fails.
- */
-void TestMpCollectionAlbumArtManager::testAlbumArtFail()
-{
-    mTest->mThumbnailManager->mGetThumbFails = true;
-    const QIcon* icon = mTest->albumArt(0);
-    // Verify that:
-    // - It returned default icon
-    // - There is no request pending from thumbnail manager
-    QVERIFY(icon->isNull() == false);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-}
-
-/*!
- Tests cacheFirstScreen() request with empty list.
- */
-void TestMpCollectionAlbumArtManager::testCacheFirstScreenEmpty()
-{
-    mTest->mCollectionData->mCount = 0;
-    mTest->cacheFirstScreen();
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mCachingInProgress, false);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
-}
-
-/*!
- Tests cacheFirstScreen() request with 1 item in the list.
- */
-void TestMpCollectionAlbumArtManager::testCacheFirstScreen()
-{
-    mTest->mCollectionData->mCount = 1;
-    mTest->cacheFirstScreen();
-    QCOMPARE(mTest->mCachingInProgress, true);
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
-}
-
-/*!
- Tests cacheFirstScreen() request with all items already in local cache.
- */
-void TestMpCollectionAlbumArtManager::testCacheFirstScreenAllCached()
-{
-    mTest->mCollectionData->mCount = 3;
-    mTest->mImageCache.insert(0, new QIcon(mIcon));
-    mTest->mImageCache.insert(1, new QIcon(mIcon));
-    mTest->mImageCache.insert(2, new QIcon(mIcon));
-    mTest->cacheFirstScreen();
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
-}
-
-/*!
- Tests cancel() request.
- */
-void TestMpCollectionAlbumArtManager::testCancel()
-{
-    // First send enough requests to trigger requests to be queued.
-    for ( int i = 0; i < 3; i++) {
-        const QIcon* icon = mTest->albumArt(i);
-        QVERIFY(icon->isNull() == false);
-    }
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
-
-    // Verify that:
-    // - All requests to thumbnail manager are cancelled
-    // - Queue is emptied
-    mTest->cancel();
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mThumbnailManager->mCancelCounter, 1);
-}
-
-/*!
- Tests thumbnailReady() slot.
- Tests completion of cacheFirstScreen() request.
- */
-void TestMpCollectionAlbumArtManager::testThumbnailReadyCache()
-{
-    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
-
-    // First send cacheAlbumArt() request with 3 items.
-    mTest->mCollectionData->mCount = 3;
-    mTest->cacheFirstScreen();
-    QCOMPARE(mTest->mCachingInProgress, true);
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-
-    // Emit thumbnailReady() signal for each request. Then verify that:
-    // - Test object emitted signal albumArtReady() for 3 items
-    // - 3 items are present in local cache
-    for ( int i = 0; i < 3; i++ ) {
-        void *clientData = reinterpret_cast<void *>(i);
-        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, 0);
-    }
-
-    QCOMPARE(spy.count(), 3);
-    QCOMPARE(mTest->mCachingInProgress, false);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mImageCache.count(), 3);
-    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-}
-
-/*!
- Tests thumbnailReady() slot.
- Tests completion of cacheFirstScreen() request with error code returned.
- */
-void TestMpCollectionAlbumArtManager::testThumbnailReadyCacheError()
-{
-    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
-
-    // First send cacheAlbumArt() request with 3 items.
-    mTest->mCollectionData->mCount = 3;
-    mTest->cacheFirstScreen();
-    QCOMPARE(mTest->mCachingInProgress, true);
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-
-    // Emit thumbnailReady() signal for each request with error. Then verify that:
-    // - Test object doesn't emit signal albumArtReady()
-    // - 0 item is present in local cache
-    for ( int i = 0; i < 3; i++ ) {
-        void *clientData = reinterpret_cast<void *>(i);
-        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, -1);
-    }
-    QCOMPARE(spy.count(), 0);
-    QCOMPARE(mTest->mCachingInProgress, false);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mImageCache.count(), 0);
-    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-}
-
-/*!
- Tests thumbnailReady() slot.
- Tests completion of albumArt() request with empty request queue.
- */
-void TestMpCollectionAlbumArtManager::testThumbnailReadyAlbumArt()
-{
-    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
-
-    // First send 3 albumArt() requests.
-    for ( int i = 0; i < 3; i++) {
-        const QIcon* icon = mTest->albumArt(i);
-        QVERIFY(icon->isNull() == false);
-    }
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-
-    // Emit thumbnailReady() signal for each request. Then verify that:
-    // - Test object emitted signal albumArtReady() 3 times
-    // - 3 items are present in local cache
-    for ( int i = 0; i < 3; i++ ) {
-        void *clientData = reinterpret_cast<void *>(i);
-        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, 0);
-    }
-    QCOMPARE(spy.count(), 3);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mImageCache.count(), 3);
-    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-}
-
-/*!
- Tests thumbnailReady() slot.
- Tests completion of albumArt() request with error code returned.
- This covers a case with no pending items in the queue.
- */
-void TestMpCollectionAlbumArtManager::testThumbnailReadyAlbumArtError()
-{
-    connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady(int)));
-
-    // First send 3 albumArt() requests.
-    for ( int i = 0; i < 3; i++) {
-        const QIcon* icon = mTest->albumArt(i);
-        QVERIFY(icon->isNull() == false);
-    }
-    QCOMPARE(mTest->mPendingRequest, true);
-    QCOMPARE(mTest->mRequestQueue.count(), 2);
-
-    // Emit thumbnailReady() signal for each request with error. Then verify that:
-    // - Test object doesn't emitted signal albumArtReady()
-    // - 0 items are present in local cache
-    for ( int i = 0; i < 3; i++ ) {
-        void *clientData = reinterpret_cast<void *>(i);
-        emit thumbnailReady(mIcon.pixmap(50,50), clientData, i+1, -1);
-    }
-    QCOMPARE(spy.count(), 0);
-    QCOMPARE(mTest->mPendingRequest, false);
-    QCOMPARE(mTest->mRequestQueue.count(), 0);
-    QCOMPARE(mTest->mImageCache.count(), 0);
-    disconnect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-        mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
-}
-
-// End of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/mpmpxcollectiondata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
-*
-*/
-
-#ifndef MPMPXCOLLECTIONDATA_H
-#define MPMPXCOLLECTIONDATA_H
-
-#include <QObject>
-
-#include "mpmpxcollectionviewdefs.h"
-
-
-class MpMpxCollectionData : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    enum DataType {
-        Title,
-        Artist,
-        Count,
-        AlbumArtUri
-    };
-
-    // Stub functions
-    explicit MpMpxCollectionData( QObject *parent=0 );
-    virtual ~MpMpxCollectionData();
-
-    TCollectionContext context() const;
-    int count() const;
-    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
-
-signals:
-
-    void contextChanged( TCollectionContext context );
-
-public:
-
-    TCollectionContext      mContext;
-    int                     mCount;
-    bool                    mItemDataReturn;
-
-};
-
-#endif // MPMPXCOLLECTIONDATA_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/inc/thumbnailmanager_qt.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: ThumbnailManager stub for testing MpCollectionAlbumArtManager
-*
-*/
-
-#ifndef THUMBNAILMANAGER_QT_H
-#define THUMBNAILMANAGER_QT_H
-
-#include <qobject>
-#include <QPixmap.h>
-
-
-/** default priority value */
-const int tnmWrapperPriorityIdle = -100;
-
-class ThumbnailManager : public QObject
-    {
-    Q_OBJECT
-
-public:
-
-
-    /** Thumbnail size. */
-    enum ThumbnailSize
-    {
-        /**
-         * Small thumbnail
-         */
-        ThumbnailSmall = 0,
-        /**
-         * Medium thumbnail
-         */
-        ThumbnailMedium,
-        /**
-         * Large thumbnail
-         */
-        ThumbnailLarge
-    };
-
-    /** Mode of thumbnail creation. */
-    enum ThumbnailMode
-        {
-        /**
-         * Default mode. This means that:
-         * - Thumbnail must be as large as requested (unless the actual object is smaller).
-         * - Smaller thumbnails may be up scaled to desired resolution.
-         * - Aspect ratio is maintained and thumbnails are not cropped. The
-         *   resulting thumbnail may smaller in either width or height if
-         *   the aspect ratio of the object does not match the aspect ratio
-         *   of the requested size.
-         */
-        Default = 0,
-
-        /**
-         * Allow thumbnails which are smaller than requested are. Thumbnail
-         * bitmaps are never up scaled if this flag is set.
-         */
-        AllowAnySize = 1,
-
-        /**
-         * New thumbnail images are not created if this flag is set. Only
-         * existing thumbnails may be returned. If a requested thumbnail does
-         * not exist null pixmap will be returned.
-         */
-        DoNotCreate = 2,
-
-        /**
-         * Thumbnail images are cropped to match requested aspect ratio. If
-         * this mode is set, the size of the resulting thumbnail always
-         * matches the requested size.
-         */
-        CropToAspectRatio = 4
-    };
-
-    /**  Quality versus speed preference setting */
-    enum QualityPreference
-    {
-        /**
-         * Prefer thumbnails in the highest quality possible disregarding
-         * any negative impact on performance.
-         */
-        OptimizeForQuality,
-
-        /**
-         * Get thumbnails as fast as possible, even if
-         * it means lower quality.
-         */
-        OptimizeForPerformance
-    };
-
-    // Test utility functions
-    static int getInitCounter();
-    static void resetInitCounter();
-
-    // Stub functions
-    ThumbnailManager( QObject* parentPtr = NULL );
-    virtual ~ThumbnailManager();
-    bool setMode( ThumbnailMode mode );
-    bool setQualityPreference( QualityPreference qualityPreference );
-    bool setThumbnailSize( ThumbnailSize thumbnailSize );
-    int getThumbnail( const QString& fileName, void * clientData = NULL,
-            int priority = tnmWrapperPriorityIdle );
-    bool cancelRequest( int id );
-
-signals:
-
-    void thumbnailReady( QPixmap , void * , int , int );
-
-public:
-
-    bool    mGetThumbFails;
-    int     mThumbnailReqCounter;
-    int     mCancelCounter;
-
-};
-
-#endif // THUMBNAILMANAGER_QT
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/src/mpmpxcollectiondata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
-*
-*/
-
-#include "mptrace.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-
-/*!
- Stub function.
- */
-MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
-    : QObject(parent),
-      mContext(ECollectionContextUnknown),
-      mCount(0),
-      mItemDataReturn(true)
-{
-}
-
-/*!
- Stub function.
- */
-MpMpxCollectionData::~MpMpxCollectionData()
-{
-}
-
-/*!
- Stub function.
- */
-TCollectionContext MpMpxCollectionData::context() const
-{
-    return mContext;
-}
-
-/*!
- Stub function.
- */
-int MpMpxCollectionData::count() const
-{
-    return mCount;
-}
-
-/*!
- Stub function.
- */
-QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
-{
-    if ( index < 0 || index > mCount ) {
-        TX_LOG_ARGS("index=" << index);
-        qFatal("MpMpxCollectionData::itemData called with index out of range");
-    }
-    QString data;
-    if ( !mItemDataReturn && (type != MpMpxCollectionData::Count) ) {
-        return data;
-    }
-    switch ( type ) {
-        case MpMpxCollectionData::Title:
-            data = QString("Title");
-            break;
-        case MpMpxCollectionData::Artist:
-            data = QString("Artist");
-            break;
-        case MpMpxCollectionData::Count:
-            data = QString("Count");
-            break;
-        case MpMpxCollectionData::AlbumArtUri:
-            data = QString("AlbumArtUri");
-            break;
-        default:
-            qFatal("MpMpxCollectionData::itemData called with unknown type");
-            break;
-    }
-    return data;
-}
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/stub/src/thumbnailmanager_qt.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: ThumbnailManager stub for testing MpCollectionAlbumArtManager
-*
-*/
-
-#include <qsize.h>
-#include "stub/inc/thumbnailmanager_qt.h"
-
-int gInitCounter = 0;
-
-/*!
- Returns gInitCounter.
- gInitCounter counts the number of constructor/destructor calls.
- */
-int ThumbnailManager::getInitCounter()
-{
-    return gInitCounter;
-}
-
-/*!
- Resets gInitCounter to zero.
- */
-void ThumbnailManager::resetInitCounter()
-{
-    gInitCounter = 0;
-}
-
-/*!
- Stub function.
- */
-ThumbnailManager::ThumbnailManager( QObject* parentPtr ) :
-QObject( parentPtr ),
-mGetThumbFails(false),
-mThumbnailReqCounter(0),
-mCancelCounter(0)
-{
-    gInitCounter++;
-}
-
-/*!
- Stub function.
- */
-ThumbnailManager::~ThumbnailManager()
-{
-    gInitCounter--;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setMode( ThumbnailMode mode )
-{
-    Q_UNUSED(mode);
-    return true;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setQualityPreference( QualityPreference
-    qualityPreference )
-{
-    Q_UNUSED(qualityPreference);
-    return true;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setThumbnailSize( ThumbnailSize thumbnailSize )
-{
-    Q_UNUSED(thumbnailSize);
-    return true;
-}
-
-/*!
- Stub function.
- */
-int ThumbnailManager::getThumbnail( const QString& fileName, void *clientData,
-        int priority )
-{
-    Q_UNUSED(fileName);
-    Q_UNUSED(priority);
-    Q_UNUSED(clientData);
-
-    if ( mGetThumbFails ) {
-        return -1;
-    }
-
-    mThumbnailReqCounter++;
-    return mThumbnailReqCounter;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::cancelRequest( int id )
-{
-    Q_UNUSED(id);
-    mCancelCounter++;
-    return true;
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectionalbumartmanager/unittest_mpcollectionalbumartmanager.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: Unit test for mpcollectionalbumartmanager
-#
-
-
-TEMPLATE = app
-CONFIG += qtestlib hb
-TARGET = 
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-    stub/inc \
-    ../../inc \
-    ../../../../inc
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
-
-LIBS += -lestor.dll \
-        -lfbscli.dll
-
-HEADERS += inc/unittest_mpcollectionalbumartmanager.h \
-           stub/inc/thumbnailmanager_qt.h \
-           stub/inc/mpmpxcollectiondata.h \
-           ../../inc/mpcollectionalbumartmanager.h \
-               
-SOURCES += src/unittest_mpcollectionalbumartmanager.cpp \
-           stub/src/thumbnailmanager_qt.cpp \
-           stub/src/mpmpxcollectiondata.cpp \
-           ../../src/mpcollectionalbumartmanager.cpp
-
-RESOURCES += ../../resources/mpcollectionviewresources.qrc
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/inc/unittest_helper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test helper for mpcollectiondatamodel
-*
-*/
-
-#ifndef TESTHELPER_H
-#define TESTHELPER_H
-
-#include <QAbstractListModel>
-
-class TestHelper : public QAbstractListModel
-{
-    Q_OBJECT
-
-public:
-
-    TestHelper(QObject *parent=0);
-    virtual ~TestHelper();
-
-    // These are dummy; We have to inherit from QAbstractListModel so that
-    // we can invoke the protected member QAbstractItemModel::createIndex()
-    int rowCount(const QModelIndex &parent=QModelIndex()) const;
-    QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
-
-    QModelIndex indexFor(int index);
-};
-
-#endif  // TESTHELPER_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/inc/unittest_mpcollectiondatamodel.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpcollectiondatamodel
-*
-*/
-
-#ifndef TESTMPCOLLECTIONDATAMODEL_H
-#define TESTMPCOLLECTIONDATAMODEL_H
-
-#include <QtTest/QtTest>
-
-class QTranslator;
-class MpCollectionDataModel;
-class MpMpxCollectionData;
-class TestHelper;
-
-class TestMpCollectionDataModel : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    TestMpCollectionDataModel();
-    virtual ~TestMpCollectionDataModel();
-
-signals:
-
-    void updateAlbumArt( int index );
-    void albumCacheReady();
-
-public slots:
-
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-
-    void testMemberCleanup();
-    void testRefreshModel();
-    void testRefreshModelZeroCount();
-    void testCollectionData();
-    void testDataAllSongs();
-    void testDataAllSongsNoData();
-    void testDataAlbums();
-    void testDataAlbumsNoData();
-    void testDataAlbumSongs();
-    void testDataAlbumSongsNoData();
-    void testDataPlaylists();
-    void testDataPlaylistsNoData();
-    void testDataPlaylistSongs();
-    void testDataPlaylistSongsNoData();
-    void testDataAnyOtherRole();
-    void testUpdateAlbumArt();
-
-private:
-
-    MpCollectionDataModel   *mTest;
-    TestHelper              *mHelper;
-    MpMpxCollectionData     *mStubData;
-    QTranslator             *mMpTranslator; // Own
-
-};
-
-#endif  // TESTMPCOLLECTIONDATAMODEL_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/src/unittest_helper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test helper for TestHelper
-*
-*/
-
-#include "unittest_helper.h"
-
-
-TestHelper::TestHelper(QObject *parent)
-    : QAbstractListModel(parent)
-{
-}
-
-TestHelper::~TestHelper()
-{
-}
-
-/*!
- Dummy function to satisfy QAbstractListModel inheritance.
- */
-int TestHelper::rowCount( const QModelIndex &parent ) const
-{
-    Q_UNUSED(parent);
-    return 0;
-}
-
-/*!
- Dummy function to satisfy QAbstractListModel inheritance.
- */
-QVariant TestHelper::data(const QModelIndex &index, int role) const
-{
-    Q_UNUSED(index);
-    Q_UNUSED(role);
-    return QVariant();
-}
-
-/*!
- Slot to be called when album art for the \a index needs to be updated.
- */
-QModelIndex TestHelper::indexFor(int index)
-{
-    return QAbstractItemModel::createIndex(index, 0);
-}
-
-// End of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/src/unittest_mpcollectiondatamodel.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,443 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpcollectiondatamodel
-*
-*/
-
-#include <QAbstractItemModel>
-#include <QSignalSpy>
-#include <QMetaType>
-#include <QTranslator>
-#include <QLocale>
-
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-#include <hbicon.h>
-
-#include "unittest_mpcollectiondatamodel.h"
-#include "unittest_helper.h"
-#include "stub/inc/mpcollectionalbumartmanager.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-
-// Do this so we can access all member variables.
-#define private public
-#include "mpcollectiondatamodel.h"
-#undef private
-
-// Init cache size defined in mpcollectiondatamodel.cpp
-const int KInitCacheSize = 11;
-
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestMpCollectionDataModel tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpcollectiondatamodel.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestMpCollectionDataModel::TestMpCollectionDataModel()
-    : mTest(0),
-      mHelper(0),
-      mStubData(0),
-      mMpTranslator(0)
-{
-}
-
-TestMpCollectionDataModel::~TestMpCollectionDataModel()
-{
-    delete mTest;
-    delete mHelper;
-    delete mStubData;
-    delete mMpTranslator;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestMpCollectionDataModel::initTestCase()
-{
-    QString lang = QLocale::system().name();
-    QString path = QString("z:/resource/qt/translations/");
-    bool translatorLoaded = false;
-
-    mMpTranslator = new QTranslator(this);
-    translatorLoaded = mMpTranslator->load(path + "musicplayer_" + lang);
-    if ( translatorLoaded ) {
-        qApp->installTranslator(mMpTranslator);
-    }
-
-    mStubData = new MpMpxCollectionData();
-    mHelper = new TestHelper();
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestMpCollectionDataModel::cleanupTestCase()
-{
-    delete mStubData;
-    mStubData = 0;
-    delete mHelper;
-    mHelper = 0;
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestMpCollectionDataModel::init()
-{
-    mTest = new MpCollectionDataModel(mStubData);
-    MpMpxCollectionData::resetItemDataCounter();
-    mTest->mCollectionData->mItemDataReturn = true;
-}
-
-/*!
- Called after every testfunction.
- */
-void TestMpCollectionDataModel::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- Tests correct cleanup of member variables.
- */
-void TestMpCollectionDataModel::testMemberCleanup()
-{
-    cleanup();
-    MpCollectionAlbumArtManager::resetInitCounter();
-    int count = MpMpxCollectionData::getInitCounter();
-    init();
-    cleanup();
-    QCOMPARE(MpCollectionAlbumArtManager::getInitCounter(), 0);
-    QCOMPARE(MpMpxCollectionData::getInitCounter(), count);
-}
-
-/*!
- Tests refreshModel() request.
- */
-void TestMpCollectionDataModel::testRefreshModel()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAlbums;
-    mTest->refreshModel();
-    // Verify that:
-    // - It sets correct row count
-    QCOMPARE(mTest->mRowCount, 100);
-    QCOMPARE(mTest->mAlbumArtManager->mCacheAlbumArtCount, 1);
-    // Stub QAbstractListModel to verify call to reset()
-}
-
-/*!
- Tests refreshModel() request with empty data model.
- */
-void TestMpCollectionDataModel::testRefreshModelZeroCount()
-{
-    mTest->mCollectionData->mCount = 0;
-    mTest->refreshModel();
-    // Verify that:
-    // - It sets correct row count
-    QCOMPARE(mTest->mRowCount, 0);
-}
-
-/*!
- Tests collectionData() request.
- */
-void TestMpCollectionDataModel::testCollectionData()
-{
-    QVERIFY(mTest->collectionData() == mStubData);
-}
-
-/*!
- Tests data() request for AllSongs context.
- */
-void TestMpCollectionDataModel::testDataAllSongs()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAllSongs;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), QString("Title"));
-    QCOMPARE(dataList.at(1), QString("Artist"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for AllSongs context with no data available.
- */
-void TestMpCollectionDataModel::testDataAllSongsNoData()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAllSongs;
-    mTest->mCollectionData->mItemDataReturn = false;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
-    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for Albums context.
- */
-void TestMpCollectionDataModel::testDataAlbums()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAlbums;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), QString("Title"));
-    QCOMPARE(dataList.at(1), QString("Artist"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
-}
-
-/*!
- Tests data() request for Albums context with no data available.
- */
-void TestMpCollectionDataModel::testDataAlbumsNoData()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAlbums;
-    mTest->mCollectionData->mItemDataReturn = false;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
-    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.userType(), QMetaType::type("QIcon"));
-}
-
-/*!
- Tests data() request for AlbumSongs context.
- */
-void TestMpCollectionDataModel::testDataAlbumSongs()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAlbumSongs;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 1);
-    QCOMPARE(dataList.at(0), QString("Title"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for AlbumSongs context with no data available.
- */
-void TestMpCollectionDataModel::testDataAlbumSongsNoData()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextAlbumSongs;
-    mTest->mCollectionData->mItemDataReturn = false;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 1);
-    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
-}
-
-/*!
- Tests data() request for Playlists context.
- */
-void TestMpCollectionDataModel::testDataPlaylists()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextPlaylists;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 1);
-    QCOMPARE(dataList.at(0), QString("Title"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for Playlists context with no data available.
- */
-void TestMpCollectionDataModel::testDataPlaylistsNoData()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextPlaylists;
-    mTest->mCollectionData->mItemDataReturn = false;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 1);
-    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
-}
-
-/*!
- Tests data() request for PlaylistSongs context.
- */
-void TestMpCollectionDataModel::testDataPlaylistSongs()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextPlaylistSongs;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), QString("Title"));
-    QCOMPARE(dataList.at(1), QString("Artist"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for PlaylistSongs context with no data available.
- */
-void TestMpCollectionDataModel::testDataPlaylistSongsNoData()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-    mTest->mCollectionData->mContext = ECollectionContextPlaylistSongs;
-    mTest->mCollectionData->mItemDataReturn = false;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::DisplayRole);
-    QCOMPARE(data.canConvert(QVariant::StringList), true);
-    QStringList dataList = data.toStringList();
-    QCOMPARE(dataList.count(), 2);
-    QCOMPARE(dataList.at(0), hbTrId("txt_mus_other_unknown4"));
-    QCOMPARE(dataList.at(1), hbTrId("txt_mus_other_unknown3"));
-
-    // Qt::DecorationRole
-    data = mTest->data(modelIndex, Qt::DecorationRole);
-    QCOMPARE(data.isNull(), true);
-}
-
-/*!
- Tests data() request for a role it doesn't support.
- Make sure it doesn't crash.
- */
-void TestMpCollectionDataModel::testDataAnyOtherRole()
-{
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-
-    QModelIndex modelIndex = mHelper->indexFor(1);
-
-    // Qt::DisplayRole
-    QVariant data = mTest->data(modelIndex, Qt::EditRole);
-    QCOMPARE(data.isValid(), false);
-}
-
-/*!
- Tests updateAlbumArt() slot.
- */
-void TestMpCollectionDataModel::testUpdateAlbumArt()
-{
-    connect( this, SIGNAL(updateAlbumArt(int)),
-        mTest->mAlbumArtManager, SIGNAL(albumArtReady(int)) );
-    qRegisterMetaType<QModelIndex>("QModelIndex");
-    QSignalSpy spy(mTest, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
-    mTest->mCollectionData->mCount = 100;
-    mTest->mRowCount = 100;
-
-    emit updateAlbumArt(15);
-    QCOMPARE(spy.count(), 1);
-
-    disconnect( this, SIGNAL(updateAlbumArt(int)),
-        mTest->mAlbumArtManager, SIGNAL(albumArtReady(int)) );
-}
-
-// End of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpcollectionalbumartmanager.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpCollectionAlbumArtManager stub for testing MpCollectionDataModel
-*
-*/
-
-
-#ifndef MPCOLLECTIONALBUMARTMANAGER_H
-#define MPCOLLECTIONALBUMARTMANAGER_H
-
-#include <QObject>
-#include <QIcon>
-
-class MpMpxCollectionData;
-
-class MpCollectionAlbumArtManager : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    // Test utility functions
-    static int getInitCounter();
-    static void resetInitCounter();
-
-    // Stub functions
-    explicit MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent=0 );
-    virtual ~MpCollectionAlbumArtManager();
-
-    const QIcon* albumArt( int index );
-    void cacheFirstScreen();
-    void cancel();
-
-signals:
-
-    void albumArtReady( int index );
-
-public:
-
-    QIcon       *mIcon;
-    int         mAlbumArtCount;
-    int         mCacheAlbumArtCount;
-
-};
-
-#endif // MPCOLLECTIONALBUMARTMANAGER_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/inc/mpmpxcollectiondata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
-*
-*/
-
-#ifndef MPMPXCOLLECTIONDATA_H
-#define MPMPXCOLLECTIONDATA_H
-
-#include <QObject>
-
-#include "mpmpxcollectionviewdefs.h"
-
-
-class MpMpxCollectionData : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    enum DataType {
-        Title,
-        Artist,
-        Count,
-        AlbumArtUri
-    };
-
-    // Test utility functions
-    static int getInitCounter();
-    static void resetInitCounter();
-    static int getItemDataCounter();
-    static void resetItemDataCounter();
-
-    // Stub functions
-    explicit MpMpxCollectionData( QObject *parent=0 );
-    virtual ~MpMpxCollectionData();
-
-    TCollectionContext context() const;
-    int count() const;
-    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
-
-signals:
-
-    void contextChanged( TCollectionContext context );
-
-public:
-
-    TCollectionContext      mContext;
-    int                     mCount;
-    bool                    mItemDataReturn;
-
-};
-
-#endif // MPMPXCOLLECTIONDATA_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/src/mpcollectionalbumartmanager.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-
-
-
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Player collection album art manager.
-*
-*/
-
-#include "stub/inc/mpcollectionalbumartmanager.h"
-
-int gAlbumInitCounter = 0;
-
-/*!
- Returns gAlbumInitCounter.
- gAlbumInitCounter counts the number of constructor/destructor calls.
- */
-int MpCollectionAlbumArtManager::getInitCounter()
-{
-    return gAlbumInitCounter;
-}
-
-/*!
- Resets gAlbumInitCounter to zero.
- */
-void MpCollectionAlbumArtManager::resetInitCounter()
-{
-    gAlbumInitCounter = 0;
-}
-
-/*!
- Stub function.
- */
-MpCollectionAlbumArtManager::MpCollectionAlbumArtManager( MpMpxCollectionData *data, QObject *parent )
-    : QObject(parent),
-      mIcon(0),
-      mAlbumArtCount(0),
-      mCacheAlbumArtCount(0)
-{
-    Q_UNUSED(data);
-    gAlbumInitCounter++;
-    mIcon = new QIcon(":/icons/default_album.png");
-}
-
-/*!
- Stub function.
- */
-MpCollectionAlbumArtManager::~MpCollectionAlbumArtManager()
-{
-    gAlbumInitCounter--;
-    delete mIcon;
-}
-
-/*!
- Stub function.
- */
-const QIcon* MpCollectionAlbumArtManager::albumArt( int index )
-{
-    Q_UNUSED(index);
-    mAlbumArtCount++;
-    return mIcon;
-}
-
-/*!
- Stub function.
- */
-void MpCollectionAlbumArtManager::cacheFirstScreen()
-{
-    mCacheAlbumArtCount++;
-}
-
-/*!
- Stub function.
- */
-void MpCollectionAlbumArtManager::cancel()
-{
-}
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/stub/src/mpmpxcollectiondata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing MpCollectionDataModel
-*
-*/
-
-#include "mptrace.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-
-
-int gInitCounter = 0;
-int gItemDataCount = 0;
-
-/*!
- Returns gInitCounter.
- gInitCounter counts the number of constructor/destructor calls.
- */
-int MpMpxCollectionData::getInitCounter()
-{
-    return gInitCounter;
-}
-
-/*!
- Resets gInitCounter to zero.
- */
-void MpMpxCollectionData::resetInitCounter()
-{
-    gInitCounter = 0;
-}
-
-/*!
- Returns gItemDataCount.
- gItemDataCount counts the number of itemData() calls.
- */
-int MpMpxCollectionData::getItemDataCounter()
-{
-    return gItemDataCount;
-}
-
-/*!
- Resets gItemDataCount to zero.
- */
-void MpMpxCollectionData::resetItemDataCounter()
-{
-    gItemDataCount = 0;
-}
-
-/*!
- Stub function.
- */
-MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
-    : QObject(parent),
-      mContext(ECollectionContextUnknown),
-      mCount(0),
-      mItemDataReturn(true)
-{
-    gInitCounter++;
-}
-
-/*!
- Stub function.
- */
-MpMpxCollectionData::~MpMpxCollectionData()
-{
-    gInitCounter--;
-}
-
-/*!
- Stub function.
- */
-TCollectionContext MpMpxCollectionData::context() const
-{
-    return mContext;
-}
-
-/*!
- Stub function.
- */
-int MpMpxCollectionData::count() const
-{
-    return mCount;
-}
-
-/*!
- Stub function.
- */
-QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
-{
-    if ( index < 0 || index > mCount ) {
-        TX_LOG_ARGS("index=" << index);
-        qFatal("MpMpxCollectionData::itemData called with index out of range");
-    }
-    gItemDataCount++;
-    QString data;
-    if ( !mItemDataReturn && (type != MpMpxCollectionData::Count) ) {
-        return data;
-    }
-    switch ( type ) {
-        case MpMpxCollectionData::Title:
-            data = QString("Title");
-            break;
-        case MpMpxCollectionData::Artist:
-            data = QString("Artist");
-            break;
-        case MpMpxCollectionData::Count:
-            data = QString("Count");
-            break;
-        case MpMpxCollectionData::AlbumArtUri:
-            data = QString("AlbumArtUri");
-            break;
-        default:
-            qFatal("MpMpxCollectionData::itemData called with unknown type");
-            break;
-    }
-    return data;
-}
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpcollectiondatamodel/unittest_mpcollectiondatamodel.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: Unit test for mpcollectiondatamodel
-#
-
-
-TEMPLATE = app
-CONFIG += qtestlib hb
-TARGET = 
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-    stub/inc \
-    ../../inc \
-    ../../../../inc
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
-
-LIBS += -lestor.dll \
-        -lfbscli.dll
-
-HEADERS += inc/unittest_mpcollectiondatamodel.h \
-           inc/unittest_helper.h \
-           stub/inc/mpcollectionalbumartmanager.h \
-           stub/inc/mpmpxcollectiondata.h \
-           ../../inc/mpcollectiondatamodel.h \
-               
-SOURCES += src/unittest_mpcollectiondatamodel.cpp \
-           src/unittest_helper.cpp \
-           stub/src/mpcollectionalbumartmanager.cpp \
-           stub/src/mpmpxcollectiondata.cpp \
-           ../../src/mpcollectiondatamodel.cpp
-
-RESOURCES += ../../resources/mpcollectionviewresources.qrc
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/inc/unittest_mpmpxcollectiondata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for MpMpxCollectionData
-*
-*/
-
-#ifndef TESTMPMPXCOLLECTIONDATA_H
-#define TESTMPMPXCOLLECTIONDATA_H
-
-#include <QtTest/QtTest>
-
-class MpMpxCollectionData;
-class MpMpxCollectionDataPrivate;
-
-class TestMpMpxCollectionData : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    TestMpMpxCollectionData();
-    virtual ~TestMpMpxCollectionData();
-
-
-public slots:
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-    void testConstructor();
-    void testContextRetrieval();
-    void testCount();
-    void testCollectionTitle();
-    void testItemData();
-    void testIsAutoPlaylist();
-    void testIsAutoPlaylistWithIndex();
-    void TestItemCountWithIndex();
-    void testSetCollectionContextL();
-    void testSetMpxMediaAllSongs();
-    
-    /*
-    TODO: test all the permutations for context on SetCollectionContextL
-    */
-private:
-
-
-
-    MpMpxCollectionData         *mTest;
-    MpMpxCollectionDataPrivate  *mTestPrivate;
-
-};
-
-#endif  // TESTMPMPXCOLLECTIONDATA_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/src/unittest_mpmpxcollectiondata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,592 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for MpMpxCollectionData
-*
-*/
-
-#include <QSignalSpy>
-#include <QMetaType>
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-
-#include <apacmdln.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxcollectionpath.h>
-
-#include <mpxcollectionuihelper.h>
-#include <mpxcollectionhelperfactory.h>
-
-
-#include "unittest_mpmpxcollectiondata.h"
-#include "mpcommondefs.h"
-
-
-// Do this so we can access all member variables.
-#define private public
-#include "mpmpxcollectiondata.h"
-#include "mpmpxcollectiondata_p.h"
-#undef private
-
-//This so we can test private functions
-#include "mpmpxcollectiondata_p.cpp"
-
-struct TTestAttrs
-    {
-    const wchar_t* GeneralTitle;
-    const wchar_t* MusicArtist;
-    const TInt GeneralCount;
-    const wchar_t* MusicAlbumArtFileName;
-    };
-    
-const TTestAttrs KAllSongsTestData[] =
-    {
-     { L"Title 1", L"Artist 1", 1, L"e:\\data\\images\\art1.jpg" }
-    ,{ L"Title 2", L"Artist 2", 1, L"e:\\data\\images\\art2.jpg" }
-    ,{ L"Title 3", L"Artist 3", 1, L"e:\\data\\images\\art3.jpg" }
-    ,{ L"Title 4", L"Artist 4", 1, L"e:\\data\\images\\art4.jpg" }
-    ,{ L"Title 5", L"Artist 5", 1, L"e:\\data\\images\\art5.jpg" }
-    ,{ L"Title 6", L"Artist 6", 1, L"e:\\data\\images\\art6.jpg" }
-    ,{ L"Title 7", L"Artist 7", 1, L"e:\\data\\images\\art7.jpg" }
-    ,{ L"Title 8", L"Artist 8", 1, L"e:\\data\\images\\art8.jpg" }
-    ,{ L"Title 9", L"Artist 9", 1, L"e:\\data\\images\\art9.jpg" }
-    ,{ L"Title 10", L"Artist 10", 1, L"e:\\data\\images\\art10.jpg" }
-    };
-    
-    
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestMpMpxCollectionData tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpmpxcollectiondata.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestMpMpxCollectionData::TestMpMpxCollectionData()
-    : mTest(0)
-{
-}
-
-TestMpMpxCollectionData::~TestMpMpxCollectionData()
-{
-    delete mTest;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestMpMpxCollectionData::initTestCase()
-{
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestMpMpxCollectionData::cleanupTestCase()
-{
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestMpMpxCollectionData::init()
-{
-    mTest = new MpMpxCollectionData();
-    mTestPrivate = mTest->d_ptr;
-}
-
-/*!
- Called after every testfunction.
- */
-void TestMpMpxCollectionData::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- Tests constructor. Good case.
- */
-void TestMpMpxCollectionData::testConstructor()
-{
-    QCOMPARE(mTestPrivate->iContext, ECollectionContextUnknown);
-}
-
-/*!
- Tests getter for context.
- */
-void TestMpMpxCollectionData::testContextRetrieval()
-{
-    QCOMPARE(mTest->context(), ECollectionContextUnknown);
-    mTestPrivate->iContext = ECollectionContextPlaylistSongs;
-    QCOMPARE(mTest->context(), ECollectionContextPlaylistSongs);
-}
-
-
-
-void TestMpMpxCollectionData::testCount()
-{
-    mTestPrivate->iMediaArray = NULL;
-    QCOMPARE(mTest->count(), 0);
-    
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);   
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-        mTestPrivate->iMediaArray = array;
-        QCOMPARE(mTest->count(), i);
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
-        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
-        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    mTestPrivate->iMediaArray = array;
-    QCOMPARE(mTest->count(), count);
-    CleanupStack::PopAndDestroy(array);
-}
-
-void TestMpMpxCollectionData::testCollectionTitle()
-{
-    mTestPrivate->iContainerMedia = NULL;
-    QCOMPARE(mTest->collectionTitle(), QString());   
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-        
-    mTestPrivate->iContainerMedia = entries;
-    QCOMPARE(mTest->collectionTitle(), QString());
-    
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
-
-    mTestPrivate->iContainerMedia = entries;
-    QCOMPARE(mTest->collectionTitle(), QString("All songs"));
-    mTestPrivate->iContainerMedia = NULL;
-    CleanupStack::PopAndDestroy(entries);
-}
-
-
-void TestMpMpxCollectionData::testItemData()
-{
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);   
-    mTestPrivate->iMediaArray = array;
-        
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
-        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
-        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-        mTestPrivate->iMediaArray = array;
-
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
-        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::Title), QString::fromUtf16( title.Ptr(), title.Length()));
-
-        const TDesC& artist = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist));
-        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::Artist), QString::fromUtf16( artist.Ptr(), artist.Length()));
-
-        //verification depends on language, just exercising the item.
-        QVERIFY(!mTest->itemData( i, MpMpxCollectionData::Count).isNull());
-
-        const TDesC& albumArtUri = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName));
-        QCOMPARE(mTest->itemData( i, MpMpxCollectionData::AlbumArtUri), QString::fromUtf16( albumArtUri.Ptr(), albumArtUri.Length()));
-
-    }
-    mTestPrivate->iMediaArray = array;
-
-    CMPXMedia* media = CMPXMedia::NewL();
-    CleanupStack::PushL(media);
-    array->AppendL(*media);
-    mTestPrivate->iMediaArray = array;
-    media->SetTextValueL(KMPXMediaGeneralTitle,KNullDesC );
-    media->SetTextValueL(KMPXMediaMusicArtist, KNullDesC);
-    media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 0);
-    media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, KNullDesC);
-    array->AppendL(*media);
-    CleanupStack::PopAndDestroy(media);
-    mTestPrivate->iMediaArray = array;
-    
-    //Media without attributes.
-    QVERIFY(mTest->itemData( count, MpMpxCollectionData::Title).isNull());
-    QVERIFY(mTest->itemData( count, MpMpxCollectionData::Artist).isNull());
-    //verification depends on language, just exercising the item.
-    QVERIFY(!mTest->itemData( count, MpMpxCollectionData::Count).isNull());
-    QVERIFY(mTest->itemData( count, MpMpxCollectionData::AlbumArtUri).isNull());
-    
-    //Media with empty attributes.
-    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::Title).isNull());
-    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::Artist).isNull());
-    //verification depends on language, just exercising the item.
-    QVERIFY(!mTest->itemData( count + 1, MpMpxCollectionData::Count).isNull());
-    QVERIFY(mTest->itemData( count + 1, MpMpxCollectionData::AlbumArtUri).isNull());
-
-    /*Test Attributes that are not implemented yet.
-        Uri,
-        Duration,
-        Album,
-        Genre,
-        Rating,
-    */
-    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Uri).isNull());
-    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Duration).isNull());
-    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Album).isNull());
-    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Genre).isNull());
-    QVERIFY(mTest->itemData( 0, MpMpxCollectionData::Rating).isNull());
-
-    CleanupStack::PopAndDestroy(array);
-    mTestPrivate->iMediaArray = NULL;
-}
-
-void TestMpMpxCollectionData::testIsAutoPlaylist()
-{
-    //if cotext is different than playlistsongs value returned should be false
-    QVERIFY(!mTest->isAutoPlaylist());
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("My Test Playlist Songs"));
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    CleanupStack::PopAndDestroy(array);
-    qRegisterMetaType<TCollectionContext>();
-    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
-    mTest->setMpxMedia(*entries);
-    QCOMPARE(spy.count(), 1);
-    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
-    QCOMPARE(context, ECollectionContextPlaylistSongs);
-    QVERIFY(!mTest->isAutoPlaylist());  
-    
-    entries->SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
-    mTest->setMpxMedia(*entries);
-    QCOMPARE(spy.count(), 2);
-    context = qvariant_cast<TCollectionContext>(spy.at(1).at(0));
-    QCOMPARE(context, ECollectionContextPlaylistSongs);
-    QVERIFY(mTest->isAutoPlaylist());  
-    CleanupStack::PopAndDestroy(entries);
-
-}
-
-void TestMpMpxCollectionData::testIsAutoPlaylistWithIndex()
-{
-    //if cotext is different than playlists value returned should be false
-    QVERIFY(!mTest->isAutoPlaylist(0));
-    
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
-        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
-        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
-        if (i%2) {
-            media->SetTObjectValueL<TMPXGeneralNonPermissibleActions>(
-                    KMPXMediaGeneralNonPermissibleActions, EMPXWrite);
-        }
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-
-    }
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("My Test Playlist container"));
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    CleanupStack::PopAndDestroy(array);
-        
-    qRegisterMetaType<TCollectionContext>();
-    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
-    mTest->setMpxMedia(*entries);
-    QCOMPARE(spy.count(), 1);
-    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
-    QCOMPARE(context, ECollectionContextPlaylists);
-    QVERIFY(!mTest->isAutoPlaylist( 0 ));
-    QVERIFY(mTest->isAutoPlaylist( 1 ));
-}
-
-
-void TestMpMpxCollectionData::TestItemCountWithIndex()
-{
-
-
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    
-    CMPXMedia* media = CMPXMedia::NewL();
-    CleanupStack::PushL(media);
-    //no attributes
-    array->AppendL(*media);
-    CleanupStack::PopAndDestroy(media);
-
-    CMPXMedia* media2 = CMPXMedia::NewL();
-    CleanupStack::PushL(media2);
-    media2->SetTObjectValueL<TInt>(KMPXMediaGeneralCount,0);
-    array->AppendL(*media2);
-    CleanupStack::PopAndDestroy(media2);
-
-    CMPXMedia* media3 = CMPXMedia::NewL();
-    CleanupStack::PushL(media3);
-    media3->SetTObjectValueL<TInt>(KMPXMediaGeneralCount,20);
-    array->AppendL(*media3);
-    CleanupStack::PopAndDestroy(media3);
-    
-    
-    mTestPrivate->iMediaArray=array;
-    QCOMPARE(mTest->itemCount(0),0);
-    QCOMPARE(mTest->itemCount(1),0);
-    QCOMPARE(mTest->itemCount(2),20);
-
-    mTestPrivate->iMediaArray=NULL;
-    CleanupStack::PopAndDestroy(array);
-}
-
-
-void TestMpMpxCollectionData::testSetCollectionContextL()
-{
-    
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-
-
-    
-    /* FROM MPXDBPLUGIN.CPP
-    // All Songs
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXSong ...
-    ...
-    // All artists  
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXArtist ...
-    ...            
-    // All albums of an artist
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXArtist ...
-    ...
-    // all songs for an artist
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXSong ...
-    ...        
-    // all songs of an album for an artist
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum ...
-    ...        
-    // All Albums
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum ...
-    ...
-    // All songs in one or multiple albums
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXAlbum ...
-    ...       
-    // All playlists
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXPlaylist ...
-    ...
-    // All songs in a playlist
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist ...
-    ...     
-    // All genres
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXGenre ...
-    ...            
-    // All songs of a genre
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXGenre ...
-    ...                    
-    // All composers
-    SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXComposer ...
-    ...
-    // All songs of a composer
-    SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXComposer ...
-    */
-    
-    // All Songs
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextAllSongs);
-    
-    // All artists  
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
-    
-    // All albums of an artist
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
-    
-    // all songs for an artist
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
-    
-    // all songs of an album for an artist
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbumSongs);
-    
-    // All Albums
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbums);
-
-    // All songs in one or multiple albums
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextAlbumSongs);
-    
-    // All playlists
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextPlaylists);
-    
-    // All songs in a playlist
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextPlaylistSongs);
-    
-    // All genres
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXGenre);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextGenres);//not in use and implementation could go away.
-    
-    // All songs of a genre
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXGenre);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextGenreSongs);///not in use and implementation could go away.
-    
-    // All composers
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXComposer);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
-    
-    // All songs of a composer
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXComposer);
-    mTestPrivate->iContainerMedia = entries;
-    mTestPrivate->SetCollectionContextL();
-    QCOMPARE(mTestPrivate->iContext,ECollectionContextUnknown);//not implemented because is not in use.
-    
-    
-    mTestPrivate->iContainerMedia = NULL;
-    CleanupStack::PopAndDestroy(entries);
-}
-
-
-void TestMpMpxCollectionData::testSetMpxMediaAllSongs()
-{
-
-
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
-        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
-        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
-   
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    CleanupStack::PopAndDestroy(array);
- 
-    qRegisterMetaType<TCollectionContext>();
-    QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext)));
-    mTest->setMpxMedia(*entries);
-    QCOMPARE(spy.count(), 1);
-    TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0));
-    QCOMPARE(context, ECollectionContextAllSongs);
-    CleanupStack::PopAndDestroy(entries);
-}
\ No newline at end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxcollectiondata/unittest_mpmpxcollectiondata.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-
-TEMPLATE = app
-CONFIG += qtestlib hb
-TARGET = 
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-    ../../inc \
-    ../../../../inc
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
-
-LIBS += -lestor.dll \
-        -lmpxcommon.dll
-
-HEADERS += inc/unittest_mpmpxcollectiondata.h \
-           ../../inc/mpmpxcollectiondata.h
-           
-SOURCES += src/unittest_mpmpxcollectiondata.cpp \
-           ../../src/mpmpxcollectiondata.cpp
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/inc/unittest_mpmpxframeworkwrapper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpmpxframeworkwrapper
-*
-*/
-
-#ifndef TESTMPMPXFRAMEWORKWRAPPER_H
-#define TESTMPMPXFRAMEWORKWRAPPER_H
-
-#include <QtTest/QtTest>
-
-class MpMpxFrameworkWrapper;
-class MpMpxFrameworkWrapperPrivate;
-class CMPXMedia;
-
-class TestMpMpxFrameworkWrapper : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    TestMpMpxFrameworkWrapper();
-    virtual ~TestMpMpxFrameworkWrapper();
-    //test utility functions
-    void loadTestData();
-    void loadPlaylists();
-    bool waitForSignal(QSignalSpy* spy, int timeoutms);  
-
-public slots:
-
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-
-    void testConstructor();
-    void testReleaseIsolatedCollection();
-    void testCollectionData();
-    void testHandleOpenEntries();
-    void testHandleOpenPlaylist();    
-    void testHandleOperationComplete();
-    void testHandleIsolatedOpen();
-    void testOpenCollection();  
-    void testDoIncrementalOpen();
-    void testReopenCollection();
-    void testOpenCollectionItem();  
-    void testGoBack();
-    void testFindPlaylists();
-    void testCreatePlaylist();
-    void testCreatePlaylistWithProvidedCollectionData();   
-    void testSaveToPlaylist();
-    void testSaveToCurrentPlaylist();
-    void testRenamePlaylist();
-    void testDeleteSongs();
-    void testSetShuffle();
-    void testScan();
-    void testCancelScan();
-    void testPreviewItem();
-    void testOpenIsolatedCollection();
-    void testHandleCollectionMessage();
-    void testPreparePlaylistMediaSongsContext();
-    void testPreparePlaylistMediaArtistAlbumsContext();
-
-private:
-
-    MpMpxFrameworkWrapper           *mTest;
-    MpMpxFrameworkWrapperPrivate    *mTestPrivate;
-    CMPXMedia                       *iMediaTestData;
-    CMPXMedia                       *iPlaylistsTestData;
-
-};
-
-#endif  // TESTMPMPXFRAMEWORKWRAPPER_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/src/unittest_mpmpxframeworkwrapper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1071 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for mpmpxframeworkwrapper
-*
-*/
-
-#include <QSignalSpy>
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-
-#include <mpxmedia.h>
-#include <mpxcollectionplaylist.h>
-
-#include "unittest_mpmpxframeworkwrapper.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-#include "stub/inc/mpxcollectionopenutility.h"
-#include "stub/inc/mpxcollectionuihelper.h"
-#include "stub/inc/mpxcollectionutility.h"
-#include "stub/inc/mpxplaybackutility.h"
-#include "stub/inc/mpxharvesterutility.h"
-#include "stub/inc/mpmpxisolatedcollectionhelper.h"
-#include "mpsettingsmanager.h"
-
-// Do this so we can access all member variables.
-#define private public
-#include "mpmpxframeworkwrapper.h"
-#include "mpmpxframeworkwrapper_p.h"
-#undef private
-
-//This so we can test private functions
-#include "mpmpxframeworkwrapper_p.cpp"
-
-//Test data
-struct TTestAttrs
-    {
-    const wchar_t* GeneralTitle;
-    const wchar_t* MusicArtist;
-    const TInt GeneralCount;
-    const wchar_t* MusicAlbumArtFileName;
-    };
-    
-const TTestAttrs KAllSongsTestData[] =
-    {
-     { L"Title 1", L"Artist 1", 1, L"e:\\data\\images\\art1.jpg" }
-    ,{ L"Title 2", L"Artist 2", 1, L"e:\\data\\images\\art2.jpg" }
-    ,{ L"Title 3", L"Artist 3", 1, L"e:\\data\\images\\art3.jpg" }
-    ,{ L"Title 4", L"Artist 4", 1, L"e:\\data\\images\\art4.jpg" }
-    ,{ L"Title 5", L"Artist 5", 1, L"e:\\data\\images\\art5.jpg" }
-    ,{ L"Title 6", L"Artist 6", 1, L"e:\\data\\images\\art6.jpg" }
-    ,{ L"Title 7", L"Artist 7", 1, L"e:\\data\\images\\art7.jpg" }
-    ,{ L"Title 8", L"Artist 8", 1, L"e:\\data\\images\\art8.jpg" }
-    ,{ L"Title 9", L"Artist 9", 1, L"e:\\data\\images\\art9.jpg" }
-    ,{ L"Title 10", L"Artist 10", 1, L"e:\\data\\images\\art10.jpg" }
-    };
-
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestMpMpxFrameworkWrapper tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpmpxframeworkwrapper.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestMpMpxFrameworkWrapper::TestMpMpxFrameworkWrapper()
-    : mTest(0),
-      iMediaTestData(0),
-      iPlaylistsTestData(0)
-{
-}
-
-TestMpMpxFrameworkWrapper::~TestMpMpxFrameworkWrapper()
-{
-    delete mTest;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestMpMpxFrameworkWrapper::initTestCase()
-{
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestMpMpxFrameworkWrapper::cleanupTestCase()
-{
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestMpMpxFrameworkWrapper::init()
-{
-    mTest = new MpMpxFrameworkWrapper();
-    mTestPrivate = mTest->d_ptr;
-}
-
-/*!
- Called after every testfunction.
- */
-void TestMpMpxFrameworkWrapper::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- Tests constructor.
- */
-void TestMpMpxFrameworkWrapper::testConstructor()
-{
-    QVERIFY(mTestPrivate->iCollectionUtility != 0);
-    QVERIFY(mTestPrivate->iCollectionUiHelper != 0);
-    QVERIFY(mTestPrivate->iIncrementalOpenUtil != 0);
-    QVERIFY(mTestPrivate->iCollectionData != 0);
-    QVERIFY(mTestPrivate->iHarvesterUtility != 0);
-    QCOMPARE(mTestPrivate->iHarvesterUtility->iCheckSystemEvents,TBool(ETrue));
-}
-
-/*!
- Tests collectionData
- */
-void TestMpMpxFrameworkWrapper::testReleaseIsolatedCollection()
-{  
-    mTestPrivate->iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( mTestPrivate );
-    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
-    mTest->releaseIsolatedCollection();
-    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
-    QVERIFY(mTestPrivate->iIsolatedCollectionData == 0);
-}
-
-/*!
- Tests collectionData
- */
-void TestMpMpxFrameworkWrapper::testCollectionData()
-{
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    MpMpxCollectionData *collectionData = mTest->collectionData();
-    QCOMPARE(collectionData->mContainerMedia->ValueTObjectL<TInt>(KMPXMediaArrayCount),iMediaTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount));
-}
-
-/*!
- Tests handleOpen when given entries. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testHandleOpenEntries()
-{
-    CMPXMedia* media = CMPXMedia::NewL();
-    
-    //Called with some error
-    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNotFound);
-    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(EFalse));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
-    
-    
-    //Called without error 
-    mTestPrivate->iFirstIncrementalOpen = EFalse;
-    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNone);
-    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(EFalse));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
-    
-    //Called without error 
-    mTestPrivate->iFirstIncrementalOpen = ETrue;
-    mTestPrivate->HandleOpenL(*media, 0, EFalse, KErrNone);
-    QCOMPARE(mTestPrivate->iCollectionData->mMediaSet, TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen, TBool(EFalse));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen, TBool(EFalse));
-}
-
-/*!
- Tests handleOpen when given a playlist. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testHandleOpenPlaylist()
-{
-    CMPXCollectionPlaylist* playlist = CMPXCollectionPlaylist::NewL();
-    CMPXMedia* media = CMPXMedia::NewL();
-
-    //Called with some error
-    QSignalSpy spy(mTest, SIGNAL(collectionPlaylistOpened()));
-    mTestPrivate->HandleOpenL(*playlist, KErrNotFound);
-    QCOMPARE(spy.count(), 0);
-    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
-    
-    //Called without error
-    QSignalSpy spy2( MpSettingsManager::instance(),SIGNAL(shuffleChanged(bool)));
-    MpSettingsManager::setRepeat(false);
-    MpSettingsManager::setShuffle(false);
-    if(waitForSignal(&spy2, 1000)){
-        bool shuffle = MpSettingsManager::shuffle();
-        TX_LOG_ARGS("shuffle changed to "<< shuffle);
-        bool repeat = MpSettingsManager::repeat();
-        TX_LOG_ARGS("repeat changed to "<< repeat);
-    }
-    mTestPrivate->HandleOpenL(*playlist, KErrNone);
-    QCOMPARE(spy.count(), 1);
-    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iRepeat, TInt(EPbRepeatOff));
-    
-    cleanup();
-    init();
-    QSignalSpy spy3(mTest, SIGNAL(collectionPlaylistOpened()));
-
-    //Called without error
-    spy2.clear();
-    MpSettingsManager::setRepeat(true);
-    MpSettingsManager::setShuffle(true);
-    
-    if(waitForSignal(&spy2, 1000)){
-        bool shuffle = MpSettingsManager::shuffle();
-        TX_LOG_ARGS("shuffle2 changed to "<< shuffle);
-        bool repeat = MpSettingsManager::repeat();
-        TX_LOG_ARGS("repeat2 changed to "<< repeat);
-    }
-    
-    mTestPrivate->HandleOpenL(*playlist, KErrNone);
-    QCOMPARE(spy3.count(), 1);
-    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iRepeat, TInt(EPbRepeatAll));
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
-       
-    //Called without error 
-    spy3.clear();
-    mTestPrivate->HandleOpenL(*playlist, KErrNone);
-    QCOMPARE(spy3.count(), 1);
-    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
-}
-
-/*!
- Tests handleOperationComplete. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testHandleOperationComplete()
-{
-    void* temp;
-    temp=0;
-    QSignalSpy spy(mTest, SIGNAL(songsDeleted(bool)));
-    mTestPrivate->HandleOperationCompleteL(EDeleteOp, KErrNone, temp);
-    mTestPrivate->HandleOperationCompleteL(EDeleteOp, KErrNotFound, temp);
-    QCOMPARE(spy.count(), 2);
-    bool result = qvariant_cast<bool>(spy.at(0).at(0));
-    QCOMPARE(result, true);
-    result = qvariant_cast<bool>(spy.at(1).at(0));
-    QCOMPARE(result, false);
-    
-    QSignalSpy spy2(mTest, SIGNAL(playlistSaved(bool)));
-    mTestPrivate->HandleOperationCompleteL(EAddOp, KErrNone, temp);
-    mTestPrivate->HandleOperationCompleteL(EAddOp, KErrNotFound, temp);
-    QCOMPARE(spy2.count(), 2);
-    result = qvariant_cast<bool>(spy2.at(0).at(0));
-    QCOMPARE(result, true);
-    result = qvariant_cast<bool>(spy2.at(1).at(0));
-    QCOMPARE(result, false);
-    
-    QSignalSpy spy3(mTest, SIGNAL(playlistsRenamed(bool)));
-    mTestPrivate->HandleOperationCompleteL(ERenameOp, KErrNone, temp);
-    mTestPrivate->HandleOperationCompleteL(ERenameOp, KErrNotFound, temp);
-    QCOMPARE(spy3.count(), 2);
-    result = qvariant_cast<bool>(spy2.at(0).at(0));
-    QCOMPARE(result, true);
-    result = qvariant_cast<bool>(spy2.at(1).at(0));
-    QCOMPARE(result, false);
-}
-
-/*!
- Tests HandleIsolatedOpen.
- */
-void TestMpMpxFrameworkWrapper::testHandleIsolatedOpen()
-{
-    loadTestData();
-    QSignalSpy spy(mTest, SIGNAL(isolatedCollectionOpened(MpMpxCollectionData*)));
-        
-    mTestPrivate->iIsolatedCollectionData = 0;
-    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNone ) ;
-    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(ETrue));
-    delete mTestPrivate->iIsolatedCollectionData;
-            
-    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
-    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNone ) ;
-    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(ETrue));
-    delete mTestPrivate->iIsolatedCollectionData;
-    
-    mTestPrivate->iIsolatedCollectionData = new MpMpxCollectionData();
-    mTestPrivate->HandleIsolatedOpenL( *iMediaTestData, KErrNotFound ) ;
-    QCOMPARE(mTestPrivate->iIsolatedCollectionData->mMediaSet, TBool(EFalse));
-
-    QCOMPARE(spy.count(), 2);
-}
-
-/*!
- Tests openCollection for different contexts.
- */
-void TestMpMpxFrameworkWrapper::testOpenCollection()
-{
-    
-    mTest->openCollection(ECollectionContextAllSongs);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 6);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
-    cleanup();
-    init();
-    mTest->openCollection(ECollectionContextAlbums);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 1);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
-    cleanup();
-    init();
-    mTest->openCollection(ECollectionContextPlaylists);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 4);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
-    cleanup();
-    init();
-    mTest->openCollection(ECollectionContextGenres);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iCountPath, 1);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 1);
-    cleanup();
-    init();
-    mTest->openCollection(ECollectionContextUnknown);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpenCount, 0);
-    
-}
-
-/*!
- Tests doIncrementalOpen. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testDoIncrementalOpen()
-{
-    mTestPrivate->DoIncrementalOpenL();
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
-}
-
-/*!
- Tests reopenCollection.
- */
-void TestMpMpxFrameworkWrapper::testReopenCollection()
-{
-    mTest->reopenCollection();
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));    
-}
-
-/*!
- Tests openCollection for a specific item.
- */
-void TestMpMpxFrameworkWrapper::testOpenCollectionItem()
-{
-    for(int index=0; index<10; index++){
-            mTest->openCollectionItem(index);
-            QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));
-            QCOMPARE(mTestPrivate->iCollectionUtility->iIndex,index);
-        }
-}
-
-/*!
- Tests goBack.
- */
-void TestMpMpxFrameworkWrapper::testGoBack()
-{
-    mTest->back();
-    QCOMPARE(mTestPrivate->iCollectionUtility->iBack, TBool(ETrue));
-}
-
-/*!
- Tests findPlaylists.
- */
-void TestMpMpxFrameworkWrapper::testFindPlaylists()
-{
-    QStringList testList;
-    loadPlaylists();
-    mTestPrivate->iCollectionUtility->setPlaylists(*iPlaylistsTestData);
-    mTest->findPlaylists(testList);
-    TInt count = iPlaylistsTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    QCOMPARE(count,testList.count());
-    for(TInt i=0; i < count; i++){
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
-        QCOMPARE(testList.at(i),QString::fromUtf16( title.Ptr(), title.Length() ));        
-    }
-}
-
-/*!
- Tests createPlaylist.
- */
-void TestMpMpxFrameworkWrapper::testCreatePlaylist()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    QString playListName("playlistname");
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    mTest->createPlaylist(playListName,selection);
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
-    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-    const TDesC& playlistTitle = TPtrC(reinterpret_cast<const TText*>(playListName.constData()));
-    const TDesC& playlistPath = TPtrC(KPlaylistPath);
-    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralTitle),playlistTitle);
-    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralUri), playlistPath);
-    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    QCOMPARE(count, selection.count());
-    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    for( TInt i = 0; i < count; i++ ){
-        CMPXMedia* track( testArray->AtL(i) );
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
-        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-    }
-}
-
-/*!
- Tests createPlaylist with a provided collection data.
- */
-void TestMpMpxFrameworkWrapper::testCreatePlaylistWithProvidedCollectionData()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    QString playListName("playlistname");
-    loadTestData();
-    
-    //test with a collection data different that the browsing collection.
-    MpMpxCollectionData *collectionData;
-    collectionData = new MpMpxCollectionData();
-    collectionData->setMpxMedia(*iMediaTestData);
-    mTest->createPlaylist(playListName,selection, collectionData);
-    delete collectionData;
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
-    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-    const TDesC& playlistTitle = TPtrC(reinterpret_cast<const TText*>(playListName.constData()));
-    const TDesC& playlistPath = TPtrC(KPlaylistPath);
-    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralTitle),playlistTitle);
-    QCOMPARE(testTracks->ValueText(KMPXMediaGeneralUri), playlistPath);
-    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    QCOMPARE(count, selection.count());
-    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    for( TInt i = 0; i < count; i++ ){
-        CMPXMedia* track( testArray->AtL(i) );
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
-        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-    }
-}
-
-/*!
- Tests saveToPlaylist.
- */
-void TestMpMpxFrameworkWrapper::testSaveToPlaylist()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    loadPlaylists();
-    mTestPrivate->iUserPlaylists =  CMPXMedia::NewL(*iPlaylistsTestData);
-    TInt countPlaylist = iPlaylistsTestData->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    for( TInt j = 0; j < countPlaylist; j++){
-        mTest->saveToPlaylist(j,selection);
-        QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
-        CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
-        QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-        QCOMPARE(testTracks->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId),TMPXItemId(j));
-        
-        QCOMPARE(testTracks->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId),TUid::Uid(EMPXCollectionPluginMusic));
-        TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-        QCOMPARE(count, selection.count());
-        CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-        for( TInt i = 0; i < count; i++ ){
-            CMPXMedia* track( testArray->AtL(i) );
-            const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
-            QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-            QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-            QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-        }
-    }
-}
-
-/*!
- Tests SaveToCurrentPlaylist.
- */
-void TestMpMpxFrameworkWrapper::testSaveToCurrentPlaylist()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    loadTestData();
-    
-    MpMpxCollectionData *testCollectionData = new MpMpxCollectionData();
-    testCollectionData->setMpxMedia(*iMediaTestData);
-    
-    //Reusing the same data, just setting some parameters to make it look like playlist tracks.
-    iMediaTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1234));
-    iMediaTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    iMediaTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    mTest->saveToCurrentPlaylist( selection, testCollectionData );
-    
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iIncAdd, TBool(ETrue));
-    CMPXMedia* testTracks = mTestPrivate->iCollectionUiHelper->iMedia;
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId),TMPXItemId(1234));
-    
-    QCOMPARE(testTracks->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId),TUid::Uid(EMPXCollectionPluginMusic));
-    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    QCOMPARE(count, selection.count());
-    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    for( TInt i = 0; i < count; i++ ){
-        CMPXMedia* track( testArray->AtL(i) );
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
-        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-    }
-
-}
-
-/*!
- Tests renamePlaylist.
- */
-void TestMpMpxFrameworkWrapper::testRenamePlaylist()
-{
-    
-    loadPlaylists();
-    mTestPrivate->iCollectionData->setMpxMedia(*iPlaylistsTestData);
-    QString newPlaylistName("New Playlist Name");
-    mTest->renamePlaylist(newPlaylistName,3);
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iValidRename, TBool(ETrue));
-    CMPXMediaArray *mediaArray;
-    mediaArray = const_cast<CMPXMediaArray*>(iPlaylistsTestData->Value<CMPXMediaArray>( KMPXMediaArrayContents ) );
-    CMPXMedia* currentPlaylistMedia( mediaArray->AtL( 3 ) );
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iPlaylistId, currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ));
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iRenameTitle, newPlaylistName);
-    
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    QString newPlaylistName2("New Playlist Name 2");
-    mTest->renamePlaylist(newPlaylistName2);
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iValidRename, TBool(ETrue));
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iRenameTitle, newPlaylistName2);
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iPlaylistId, TMPXItemId(1));
-}
-
-/*!
- Tests deleteSongs.
- */
-void TestMpMpxFrameworkWrapper::testDeleteSongs()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    mTest->deleteSongs(selection);
-    QCOMPARE(mTestPrivate->iCollectionUiHelper->iDelete, TBool(ETrue));
-}
-
-/*!
- Tests setShuffle.
- */
-void TestMpMpxFrameworkWrapper::testSetShuffle()
-{
-    
-    mTest->setShuffle(true);
-    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
-    mTestPrivate->iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
-    mTest->setShuffle(true);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
-    mTest->setShuffle(false);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
-    cleanup();
-    init();
-    mTest->setShuffle(false);
-    QVERIFY(mTestPrivate->iPlaybackUtility == 0);
-    mTestPrivate->iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(MpCommon::KMusicPlayerUid) );
-    mTest->setShuffle(false);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 0);
-    mTest->setShuffle(true);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iShuffle, 1);
-}
-
-/*!
- Tests scan
- */
-void TestMpMpxFrameworkWrapper::testScan()
-{
-    mTest->scan();
-    QCOMPARE(mTestPrivate->iHarvesterUtility->iScan, TBool(ETrue));
-}
-
-/*!
- Tests cancelScan
- */
-void TestMpMpxFrameworkWrapper::testCancelScan()
-{
-    mTestPrivate->iHarvesterUtility->iScan = ETrue;
-    mTest->cancelScan();
-    QCOMPARE(mTestPrivate->iHarvesterUtility->iScan, TBool(EFalse));
-    
-    mTestPrivate->iHarvesterUtility->iScan = ETrue;
-    mTestPrivate->iHarvesterUtility->iLeave = ETrue;
-    mTest->cancelScan();
-    QVERIFY(mTestPrivate->iHarvesterUtility != 0);
-    QCOMPARE(mTestPrivate->iHarvesterUtility->iCheckSystemEvents,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iHarvesterUtility->iScan, TBool(EFalse));
-}
-
-/*!
- Tests PreviewItem
- */
-void TestMpMpxFrameworkWrapper::testPreviewItem()
-{
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    QSignalSpy spy(mTest, SIGNAL(collectionPlaylistOpened()));
-    mTest->previewItem(1);
-    
-    // Playback utility should be created.
-    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
-    QCOMPARE(mTestPrivate->iPlaybackUtility->iPlay, TBool(ETrue));
-    QCOMPARE(spy.count(), 1);
-}
-
-/*!
- Tests OpenIsolatedCollection
- */
-void TestMpMpxFrameworkWrapper::testOpenIsolatedCollection()
-{
-
-    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
-    mTest->openIsolatedCollection( ECollectionContextAllSongs );
-    QVERIFY(mTestPrivate->iIsolatedCollectionHelper != 0);
-    QCOMPARE(dynamic_cast<MMpMpxIsolatedCollectionHelperObserver*>(mTestPrivate),mTestPrivate->iIsolatedCollectionHelper->iObserver);
-    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iCountPath, 6);
-    QCOMPARE(mTestPrivate->iIsolatedCollectionHelper->iOpenCount, 1);
-          
-    delete mTestPrivate->iIsolatedCollectionHelper;
-    mTestPrivate->iIsolatedCollectionHelper = 0;
-    mTest->openIsolatedCollection( ECollectionContextUnknown );
-    QVERIFY(mTestPrivate->iIsolatedCollectionHelper == 0);
-
-}
-
-
-
-/*!
- Tests handleCollectionMessage. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testHandleCollectionMessage()
-{
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMessageContentIdGeneral );
-    CMPXMedia* testMessage = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(testMessage);
-    testMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral);
-    
-    //Incremental open
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EPathChanged);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcPathChangedByOpen);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,EMcContainerOpened);
-    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse)); 
-    
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(ETrue));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
-    
-    //Refresh ended
-    cleanup();
-    init();
-    QSignalSpy spy(mTest, SIGNAL(scanEnded(void)));
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EBroadcastEvent);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcMsgRefreshEnd);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,0);
-    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse));   
-    QCOMPARE(spy.count(), 1);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, 0);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchDown);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, 0);
-    
-    //Opened a song
-    cleanup();
-    init();
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EPathChanged);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcPathChangedByOpen);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,EMcItemOpened);
-    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(ETrue));   
-        
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, 0);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchDown);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, 0);
-    
-    //Refresh started
-    cleanup();
-    init();
-    QSignalSpy spy2(mTest, SIGNAL(scanStarted(void)));
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralEvent,TMPXCollectionMessage::EBroadcastEvent);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralType,EMcMsgRefreshStart);
-    testMessage->SetTObjectValueL<TInt>(KMPXMessageGeneralData,0);
-    mTestPrivate->DoHandleCollectionMessageL(*testMessage);
-    QCOMPARE(mTestPrivate->iCollectionUtility->iOpen,TBool(EFalse));   
-    QCOMPARE(spy2.count(), 1);   
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDelay, 0);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStop,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iStart,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iFirstIncrementalOpen,TBool(EFalse));
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchDown);
-    QCOMPARE(mTestPrivate->iIncrementalOpenUtil->iChunkSize, 0);
-    
-    CleanupStack::PopAndDestroy(testMessage);
-    
-    //Items changed
-    cleanup();
-    init();
-    QSignalSpy spy3(mTest, SIGNAL(scanCountChanged( int )));
-    mTest->scan();
-    RArray<TInt> supportedIds2;
-    CleanupClosePushL( supportedIds2 );
-    supportedIds2.AppendL( KMPXMessageContentIdGeneral );
-    supportedIds2.AppendL( KMPXMessageIdContainer );
-    CMPXMedia* testMessage2 = CMPXMedia::NewL(supportedIds2.Array());
-    CleanupStack::PopAndDestroy(&supportedIds2);
-    CleanupStack::PushL(testMessage2);
-        
-    CMPXMessageArray* array = CMPXMessageArray::NewL();
-    CleanupStack::PushL(array);
-    //EMPXNoCategory, EMPXCollection, EMPXPlaylist, EMPXSong, EMPXPodcast three possible and two extra items
-    for (TInt i =0; i < 5; i++) {
-        RArray<TInt> supportedIds3;
-        CleanupClosePushL( supportedIds3 );
-        supportedIds2.AppendL( KMPXMessageContentIdGeneral );
-        CMPXMedia* media = CMPXMedia::NewL(supportedIds3.Array());
-        CleanupStack::PopAndDestroy(&supportedIds3);
-        CleanupStack::PushL(media);
-        media->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, EMPXItemInserted);
-        media->SetTObjectValueL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory, TMPXGeneralCategory(i));
-        media->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageIdItemChanged);
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    testMessage2->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageIdItemChanged); 
-    testMessage2->SetCObjectValueL(KMPXMessageArrayContents, array);
-    testMessage2->SetTObjectValueL<TInt>(KMPXMessageArrayCount, array->Count());
-    CleanupStack::PopAndDestroy(array);
-    mTestPrivate->DoHandleCollectionMessageL(*testMessage2);
-    CleanupStack::PopAndDestroy(testMessage2);
-    QCOMPARE(mTestPrivate->iNumItemsAdded, 3);
-    QCOMPARE(spy3.count(), 1);
-    TInt count = qvariant_cast<int>(spy3.at(0).at(0));
-    QCOMPARE(count, mTestPrivate->iNumItemsAdded);
-       
-}
-
-/*!
- Tests preparePlaylistMedia for track level. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testPreparePlaylistMediaSongsContext()
-{
-    QList<int> selection;
-    selection.append(1);
-    selection.append(3);
-    selection.append(5);
-    
-    loadTestData();
-    mTestPrivate->iCollectionData->setMpxMedia(*iMediaTestData);
-    CMPXMedia* testTracks = CMPXMedia::NewL();
-    CleanupStack::PushL( testTracks ); 
-    
-    mTestPrivate->PreparePlaylistMediaL(*testTracks,selection,mTestPrivate->iCollectionData);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-    TInt count = testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount);
-    QCOMPARE(count, selection.count());
-    CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    for( TInt i = 0; i < count; i++ ){
-        CMPXMedia* track( testArray->AtL(i) );
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[(2*i)+1].GeneralTitle));
-        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-    }
-    CleanupStack::PopAndDestroy( testTracks );
-}
-
-
-/*!
- Tests preparePlaylistMedia for artist albums level. Part of private implementation.
- */
-void TestMpMpxFrameworkWrapper::testPreparePlaylistMediaArtistAlbumsContext()
-{
-    
-    
-    //Loading Test Data.
-    
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* albumsTestData = CMPXMedia::NewL(supportedIds.Array());
-    CMPXMedia* albumOneTracksTestData = CMPXMedia::NewL(supportedIds.Array());
-    CMPXMedia* albumTwoTracksTestData = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(albumsTestData);
-    CleanupStack::PushL(albumOneTracksTestData);
-    CleanupStack::PushL(albumTwoTracksTestData);
-
-    {//Loading pseudo data for albums container
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    CMPXMedia* media1 = CMPXMedia::NewL();
-    CleanupStack::PushL(media1);
-    media1->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(0));
-    array->AppendL(*media1);
-    CleanupStack::PopAndDestroy(media1);
-    CMPXMedia* media2 = CMPXMedia::NewL();
-    CleanupStack::PushL(media2);
-    media2->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(1));
-    array->AppendL(*media2);
-    CleanupStack::PopAndDestroy(media2);
-    CMPXMedia* media3 = CMPXMedia::NewL();
-    CleanupStack::PushL(media3);
-    media3->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(2));
-    array->AppendL(*media3);
-    CleanupStack::PopAndDestroy(media3);
-    albumsTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    albumsTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    albumsTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
-    albumsTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    albumsTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(88));//any number
-    CleanupStack::PopAndDestroy(array);
-    }
-    
-    {//Loading pseudo data for album one
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count/2; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(i));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    albumOneTracksTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    albumOneTracksTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    albumOneTracksTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
-    albumOneTracksTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    albumOneTracksTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1));
-    CleanupStack::PopAndDestroy(array);
-    }
-    
-    {//Loading pseudo data for album two
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i = count/2; i < count; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, (i));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    albumTwoTracksTestData->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
-    albumTwoTracksTestData->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum);
-    albumTwoTracksTestData->SetCObjectValueL(KMPXMediaArrayContents, array);
-    albumTwoTracksTestData->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    albumTwoTracksTestData->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(2));
-    CleanupStack::PopAndDestroy(array);
-    }
-    
-    CMPXMediaArray* albumsTracksTestData = CMPXMediaArray::NewL();
-    
-    albumsTracksTestData->AppendL(CMPXMedia::NewL()); //empty, this album is not selected for the test case.
-    albumsTracksTestData->AppendL(*albumOneTracksTestData);
-    albumsTracksTestData->AppendL(*albumTwoTracksTestData);
-    CleanupStack::PopAndDestroy(albumTwoTracksTestData);
-    CleanupStack::PopAndDestroy(albumOneTracksTestData);
-        
-
-
-    QList<int> selection;
-    selection.append(1);
-    selection.append(2);
-       
-    mTestPrivate->iCollectionUtility->iAlbumSongs = albumsTracksTestData;
-    mTestPrivate->iCollectionData->setMpxMedia(*albumsTestData);
-    mTestPrivate->iCollectionData->mContext = ECollectionContextAlbums;
-
-    CMPXMedia* testTracks = CMPXMedia::NewL();
-    CleanupStack::PushL( testTracks ); 
-    
-    mTestPrivate->PreparePlaylistMediaL(*testTracks,selection,mTestPrivate->iCollectionData);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-    QCOMPARE(testTracks->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXPlaylist);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    QCOMPARE(count, testTracks->ValueTObjectL<TInt>(KMPXMediaArrayCount));
-    const CMPXMediaArray* testArray = testTracks->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    for( TInt i = 0; i < count; i++ ){
-        CMPXMedia* track( testArray->AtL(i) );
-        const TDesC& title = TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle));
-        QCOMPARE(track->ValueText( KMPXMediaGeneralTitle ), title);
-        QCOMPARE(TInt (track->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)),i);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType),EMPXItem);
-        QCOMPARE(track->ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory),EMPXSong);
-    }
-    CleanupStack::PopAndDestroy( testTracks );
-    CleanupStack::PopAndDestroy(albumsTestData);
-}
-
-
-
-/*!
- Used to load test data
- */
-void TestMpMpxFrameworkWrapper::loadTestData()
-{
-    if(iMediaTestData){
-        delete iMediaTestData;
-        iMediaTestData=0;
-    }
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    supportedIds.AppendL( KMPXMediaIdMusic );
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicArtist)));
-        media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, KAllSongsTestData[i].GeneralCount);
-        media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].MusicAlbumArtFileName)));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-    }
-    
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong);
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All songs"));
-   
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    entries->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,TMPXItemId(1));
-    CleanupStack::PopAndDestroy(array);
- 
-    iMediaTestData = CMPXMedia::NewL(*entries);
-    
-    CleanupStack::PopAndDestroy(entries);
-}
-
-/*!
- Used to load test playlists
- */
-void TestMpMpxFrameworkWrapper::loadPlaylists()
-{
-    if(iPlaylistsTestData){
-        delete iPlaylistsTestData;
-        iPlaylistsTestData=0;
-    }
-    
-    RArray<TInt> supportedIds;
-    CleanupClosePushL( supportedIds );
-    
-    supportedIds.AppendL( KMPXMediaIdGeneral );
-    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
-    CleanupStack::PopAndDestroy(&supportedIds);
-    CleanupStack::PushL(entries);
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL(array);
-    TInt count = sizeof(KAllSongsTestData)/sizeof(TTestAttrs);
-    for (TInt i =0; i < count; i++) {
-        CMPXMedia* media = CMPXMedia::NewL();
-        CleanupStack::PushL(media);
-        media->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(KAllSongsTestData[i].GeneralTitle)));
-        media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(i));
-        array->AppendL(*media);
-        CleanupStack::PopAndDestroy(media);
-        
-    }
-    
-    entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup);
-    entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXPlaylist);
-    entries->SetTextValueL(KMPXMediaGeneralTitle, _L("All playlists"));
-   
-    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
-    entries->SetTObjectValueL<TInt>(KMPXMediaArrayCount, array->Count());
-    CleanupStack::PopAndDestroy(array);
-    
-    iPlaylistsTestData = CMPXMedia::NewL(*entries);
-    
-    CleanupStack::PopAndDestroy(entries);
-}
-
-/*!
- Used to wait on spy signal
- */
-bool TestMpMpxFrameworkWrapper::waitForSignal(QSignalSpy* spy, int timeoutms) 
-{ 
-    QTime timer; 
-    timer.start(); 
-    while (spy->isEmpty() && timer.elapsed() < timeoutms) 
-    { 
-        QCoreApplication::processEvents(); 
-    } 
-    return !spy->isEmpty(); 
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpmpxcollectiondata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing mpmpxframeworkwrapper
-*
-*/
-
-#ifndef MPMPXCOLLECTIONDATA_H
-#define MPMPXCOLLECTIONDATA_H
-
-#include "mpmpxcollectionviewdefs.h"
-
-class CMPXMedia;
- 
-
-class MpMpxCollectionData 
-{
-
-public:
-
-    enum DataType {
-        Title,
-        Uri,
-        Duration,
-        Count,
-        Artist,
-        Album,
-        Genre,
-        Rating,
-        AlbumArtUri
-    };
-
-    // Stub functions
-     MpMpxCollectionData();
-    ~MpMpxCollectionData();
-
-    TCollectionContext context();
-    QString itemData( int index, MpMpxCollectionData::DataType type ) const;
-
-    void setMpxMedia( const CMPXMedia& entries );
-    const CMPXMedia& containerMedia();
-
-public:
-    CMPXMedia               *mContainerMedia;
-    TBool                   mMediaSet;
-    TCollectionContext      mContext;
-
-};
-
-#endif // MPMPXCOLLECTIONDATA_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpmpxisolatedcollectionhelper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
-* Copyright ( c ) 2009 Nokia Corporation and/or its subsidiary( -ies ).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: isolated collection helper stub for testing mpmpxframeworkwrapper.
-*
-*/
-
-#ifndef CMPMPXISOLATEDCOLLECTIONHELPER_H
-#define CMPMPXISOLATEDCOLLECTIONHELPER_H
-
-#include <e32base.h>
-class CMPXCollectionPath;
-class CMPXMedia;
-
-class MMpMpxIsolatedCollectionHelperObserver
-{
-public:
-
-    virtual void HandleIsolatedOpenL( const CMPXMedia& aEntries, 
-            TInt aError ) = 0;
-};
-
-class CMpMpxIsolatedCollectionHelper : public CBase
-{
-public:
-
-    static CMpMpxIsolatedCollectionHelper* NewL( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-    static CMpMpxIsolatedCollectionHelper* NewLC( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-    virtual ~CMpMpxIsolatedCollectionHelper();
-    void OpenCollectionL( CMPXCollectionPath& aPath );
-    
-private:
-    CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver );
-
-public:
-    MMpMpxIsolatedCollectionHelperObserver* iObserver;
-    TBool          iOpen;
-    TInt           iOpenCount;
-    TInt           iCountPath;
-
-};
-
-#endif // CMPMPXISOLATEDCOLLECTIONHELPER_H
-    
-//EOF
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionhelperfactory.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  mpxcollectionhelperfactory stub for testing mpmpxframeworkwrapper 
-*
-*/
-
-
-
-#ifndef MMPXCOLLECTIONHELPERFACTORY_H
-#define MMPXCOLLECTIONHELPERFACTORY_H
-
-#include <bautils.h>
-#include <mpxcollectionframeworkdefs.h>
-
-// FORWARD DECLARATIONS
-class MMPXCollectionUiHelper;
- 
-/**
- *  Factory stub class to construct collection helpers.
- */
-class CMPXCollectionHelperFactory : public CBase
-{
-
-public:
-    
-    // Stub functions
-    static MMPXCollectionUiHelper* NewCollectionUiHelperL(const TUid& aModeId = KMcModeDefault);
-
-    
-};
-       
-#endif // MMPXCOLLECTIONHELPERFACTORY_H
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionopenutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  mpxcollectionopenutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#ifndef C_CMPXCOLLECTIONOPENUTILITY_H
-#define C_CMPXCOLLECTIONOPENUTILITY_H
-
-#include <mpxcollectionobserver.h>
-#include <mpxcollectionframeworkdefs.h>
-#include <mpxcollectionopenlresultdef.h>
-
-
-class CMPXCollectionOpenUtility  
-{
-public:
-    
-    // Stub functions
-    enum TDirection
-        {
-        EFetchNormal,
-        EFetchUp,
-        EFetchDown
-        };
-     static CMPXCollectionOpenUtility* NewL( MMPXCollectionObserver* aObs, TUid aMode = KMcModeDefault );
-     CMPXCollectionOpenUtility();
-     ~CMPXCollectionOpenUtility();
-     void StartL( TArray<TMPXAttribute> aAttrs,
-                              TInt aChunkSize,
-                              TInt aOffset = 0,
-                              TDirection aDirection = EFetchNormal,
-                              TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute );
-     void Stop();
-     void SetDelay( TInt aDelay );
-public:
-     TInt       iDelay;
-     TInt       iChunkSize;
-     TBool      iStop;
-     TBool      iStart;
-     TDirection iDirection;
-    };
-
-#endif // C_CMPXCOLLECTIONOPENUTILITY_H
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionuihelper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
-*
-*/
-
-#ifndef MMPXCOLLECTIONUIHELPER_H
-#define MMPXCOLLECTIONUIHELPER_H
-
-#include <mpxmediageneraldefs.h>
-#include <mpxcommonframeworkdefs.h>
-#include <mpxmediageneraldefs.h>
-#include <QString.h>
-
-
-// FORWARD DECLARATIONS
-class CMPXCollectionPath;
-class CMPXMedia;
-class MMPXCHelperObserver;
-
-class MMPXCollectionUiHelper
-{
-public:
-    
-    // Stub functions
-    MMPXCollectionUiHelper();
-    ~MMPXCollectionUiHelper();
-    
-   void DeleteL( CMPXCollectionPath& aPath,
-                          MMPXCHelperObserver* aObserver );
-    CMPXCollectionPath* MusicMenuPathL();
-    CMPXCollectionPath* MusicAllSongsPathL();
-    CMPXCollectionPath* MusicPlaylistPathL(); 
-    void Close();
-    void IncAddL( const CMPXMedia& aMedia,
-                          MMPXCHelperObserver* aObserver=0,
-                          const TInt aSize=0 );
-    void RenameL( const CMPXMedia& aMedia,
-                              MMPXCHelperObserver* aObserver );
-    
-public:
-    
-    TBool           iIncAdd;
-    TBool           iDelete;
-    CMPXMedia       *iMedia;
-    TBool           iValidRename;
-    TMPXItemId      iPlaylistId;
-    QString         iRenameTitle;
-
-};
-
-
-#endif // MMPXCOLLECTIONUIHELPER_H
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxcollectionutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#ifndef MMPXCOLLECTIONUTILITY_H
-#define MMPXCOLLECTIONUTILITY_H
-
-#include <mpxcollectionframeworkdefs.h>
-#include <mpxcommonframeworkdefs.h>
-#include <mpxcollectionobserver.h>
-#include <mpxattribute.h>
-#include <mpxsearchcriteria.h>
-#include <mpxattributespecs.h>
-
-#include <badesca.h>
-
-
-//Forward declarations
-class CMPXCollectionPath;
-
-class MMPXCollection
-{
-public:
-    
-    // Stub functions interface
-    virtual void OpenL(TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
-    virtual void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault) = 0;   
-    virtual void OpenL(const CMPXCollectionPath& aPath,
-                       TMPXOpenMode aMode=EMPXOpenDefault) = 0;
-    virtual CMPXCollectionPath* PathL() = 0;
-    virtual void BackL() = 0;
-    virtual void CancelRequest() = 0;
-    virtual CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
-                                const TArray<TMPXAttribute>& aAttrs) = 0;
-   
-};
-
-class MMPXCollectionUtility : public MMPXCollection
-{
-public:
-
-    // Test utility functions
-    void setPlaylists( const CMPXMedia& entries );
-
-    // Stub functions
-    static MMPXCollectionUtility* NewL( MMPXCollectionObserver* aObs = NULL,
-                                        const TUid& aModeId = KMcModeDefault);
-    MMPXCollectionUtility();
-    ~MMPXCollectionUtility();
-    MMPXCollection& Collection();
-    TUid CollectionIDL(const TArray<TUid>& aUids);
-    void Close();
-    
-    //From MMPXCollection
-    void OpenL(TMPXOpenMode aMode=EMPXOpenDefault);
-    void OpenL(TInt aIndex,TMPXOpenMode aMode=EMPXOpenDefault);
-    void OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode=EMPXOpenDefault);
-    CMPXCollectionPath* PathL();
-    void BackL();
-    void CancelRequest();
-    CMPXMedia* FindAllL(const CMPXSearchCriteria& aCriteria,
-                                    const TArray<TMPXAttribute>& aAttrs);
-    
-public:
- 
-    TBool          iBack;
-    TBool          iOpen;
-    TInt           iOpenCount;
-    TInt           iCountPath;
-    int            iIndex;
-    CMPXMedia      *iPlaylists; //Owned
-    CMPXMediaArray *iAlbumSongs; //Owned
-};
-
-
-
-
-
-#endif      // MMPXCOLLECTIONUTILITY_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxharvesterutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Harvester Utility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#ifndef MMPXHARVESTERUTILITY_H
-#define MMPXHARVESTERUTILITY_H
-
-#include <bamdesca.h>
-
-
-class MMPXHarvesterUtility
-{
-
-public:
-    
-    //Stub Functions
-    MMPXHarvesterUtility();
-    ~MMPXHarvesterUtility();
-    void ScanL();
-    void CancelScanL();
-    void CheckForSystemEventsL();
-    void Close();
-    
-public:
-    TBool   iScan;
-    TBool   iCheckSystemEvents;
-    TBool   iLeave;
-  
-};
-
-//  Utility Factory class to create the utility
-
-class CMPXHarvesterFactory : CBase
-{
-public:
-    
-    //Factory stub function to create the utility
-
-    static MMPXHarvesterUtility* NewL();
-};
-
-
-#endif // MMPXHARVESTERUTILITY_H
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/inc/mpxplaybackutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxplaybackutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#ifndef MMPXPLAYBACKUTILITY_H
-#define MMPXPLAYBACKUTILITY_H
-
-#include <mpxplaybackframeworkdefs.h>
-#include <mpxcommonframeworkdefs.h>
-#include <badesca.h>
-#include <mpxattribute.h>
-#include <mpxattributespecs.h>
-
-//Forward declarations
-class CMPXCollectionPlaylist;
-
-class MMPXPlaybackUtility
-{
-public:
-
-    // Stub functions
-    MMPXPlaybackUtility();
-    ~MMPXPlaybackUtility();
-    static MMPXPlaybackUtility* UtilityL(const TUid& aModeId = KPbModeDefault);
-    void Close();
-    void InitL(const CMPXCollectionPlaylist& aPlaylist, TBool aPlay=ETrue);
-    void InitL(const TDesC& aUri, const TDesC8* aType=NULL);
-    void SetL(TMPXPlaybackProperty aProperty, TInt aValue);
-
-public:
-
-    TInt                    iShuffle;
-    TInt                    iRepeat;
-    TMPXPlaybackProperty    iProperty;
-    TBool                   iPlay;
-};
-
-#endif      // MMPXPLAYBACKUTILITY_H
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpmpxcollectiondata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MpMpxCollectionData stub for testing mpmpxframeworkwrapper
-*
-*/
-
-#include "mptrace.h"
-#include "stub/inc/mpmpxcollectiondata.h"
-#include <mpxmedia.h>
-
-
-/*!
- Stub function.
- */
-MpMpxCollectionData::MpMpxCollectionData()
-    :mContainerMedia(0),
-    mMediaSet(EFalse),
-    mContext (ECollectionContextUnknown)
-{   
-}
-
-/*!
- Stub function.
-*/
-MpMpxCollectionData::~MpMpxCollectionData()
-{   
-}
-
-/*!
- Stub function.
-*/
-TCollectionContext MpMpxCollectionData::context()
-{
-    return mContext;
-}
-
-/*!
- Stub function.
-*/
-QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
-{
-    Q_UNUSED(index);
-    if ( type == MpMpxCollectionData::Uri ) {
-        return QString("Uri");
-    }
-    else {
-        return QString();
-    }
-}
-/*!
- Stub function.
-*/
-void MpMpxCollectionData::setMpxMedia( const CMPXMedia& entries )
-{
-    delete mContainerMedia;
-    mContainerMedia = 0;
-    mContainerMedia = CMPXMedia::NewL(entries);
-    mMediaSet = ETrue;
-}
-
-/*!
- Stub function.
-*/
-const CMPXMedia& MpMpxCollectionData::containerMedia()
-{
-    return *mContainerMedia;
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpmpxisolatedcollectionhelper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: isolated collection helper stub for testing mpmpxframeworkwrapper.
-*
-*/
-
-
-#include <mpxcollectionpath.h>
-
-#include "stub/inc/mpmpxisolatedcollectionhelper.h"
-
-
-
-
-/*!
- \internal
- */
-CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
-        MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    {
-    CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-/*!
- \internal
- */
-CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
-        MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    {
-    CMpMpxIsolatedCollectionHelper* self =
-            new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
-    CleanupStack::PushL( self );
-    return self;
-    }
-
-/*!
- \internal
- */
-CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
-    {
-    }
-    
-
-/*!
- \internal
- */
-void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath )
-    {
-    iCountPath = aPath.Count();
-    iOpen = ETrue;
-    iOpenCount++;
-    }
-
-/*!
- \internal
- */
-CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
-    : iObserver( aObserver ),
-      iOpen(EFalse),
-      iOpenCount(0),
-      iCountPath(0)
-    {
-    }
-
-    
-//EOF
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionhelperfactory.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-
-
-#include <e32debug.h>
-
-#include "stub/inc/mpxcollectionhelperfactory.h"
-#include "stub/inc/mpxcollectionuihelper.h"
-
-
-/*!
- Stub function.
- */
-MMPXCollectionUiHelper* CMPXCollectionHelperFactory::NewCollectionUiHelperL(const TUid& aModeId)
-{
-    Q_UNUSED(aModeId);
-    return new MMPXCollectionUiHelper();
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionopenutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionopenutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-
-#include <e32debug.h>
-#include <Qt>
-
-#include "stub/inc/mpxcollectionopenutility.h"
-
-
-/*!
- Stub function.
-*/
-CMPXCollectionOpenUtility::CMPXCollectionOpenUtility():iDelay(0),
-                                                       iStart(EFalse),
-                                                       iStop(EFalse),
-                                                       iChunkSize(0),
-                                                       iDirection(EFetchDown)
-{
-    
-}
-
-/*!
- Stub function.
-*/   
-CMPXCollectionOpenUtility* CMPXCollectionOpenUtility::NewL(MMPXCollectionObserver* aObs, TUid aMode)
-{
-    Q_UNUSED(aObs);
-    Q_UNUSED(aMode);
-    CMPXCollectionOpenUtility* collectionOpenUtility = new CMPXCollectionOpenUtility();
-    return collectionOpenUtility;
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionOpenUtility::~CMPXCollectionOpenUtility()
-{
-    
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::Stop()
-{
-    iStop=ETrue;
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::SetDelay( TInt aDelay )
-{
-    iDelay = aDelay;
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::StartL( TArray<TMPXAttribute> aAttrs,
-                              TInt aChunkSize,
-                              TInt aOffset,
-                              TDirection aDirection,
-                              TMPXAttribute aKeyAttribute)
-{
-    Q_UNUSED(aAttrs);
-    Q_UNUSED(aOffset);
-    Q_UNUSED(aKeyAttribute);
-    iStart = ETrue;
-    iChunkSize = aChunkSize;
-    iDirection = aDirection;
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionuihelper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionuihelper stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#include <mpxmedia.h>
-#include <mpxmediacollectiondetaildefs.h>
-#include <mpxcollectionpath.h>
-#include <mpxcollectionplugin.hrh>
-#include <e32debug.h>
-
-#include "stub/inc/mpxcollectionuihelper.h"
-const TInt KMPXAllSongsViewIndex = 0;
-const TInt KMPXPlaylistViewIndex = 1;
-
-
-/*!
- Stub function.
-*/
-MMPXCollectionUiHelper::MMPXCollectionUiHelper():iIncAdd(EFalse),
-                                                 iDelete(EFalse),
-                                                 iValidRename(EFalse),
-                                                 iMedia(0)
-{   
-}
-
-/*!
- Stub function.
-*/
-MMPXCollectionUiHelper::~MMPXCollectionUiHelper()
-{   
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUiHelper::Close()
-{
-    delete this;
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUiHelper::IncAddL( const CMPXMedia& aMedia,
-                          MMPXCHelperObserver* aObserver,
-                          const TInt aSize)
-{
-    Q_UNUSED(aObserver);
-    Q_UNUSED(aSize);
-    iIncAdd = ETrue;
-    delete iMedia;
-    iMedia = 0;
-    iMedia = CMPXMedia::NewL(aMedia);
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUiHelper::RenameL( const CMPXMedia& aMedia,
-                              MMPXCHelperObserver* aObserver )
-{
-    Q_UNUSED(aObserver);
-    iValidRename = EFalse;
-    TMPXGeneralType mediaType =
-            aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
-
-    TMPXGeneralCategory mediaCategory =
-            aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
-    
-    if ( mediaType == EMPXItem && mediaCategory == EMPXPlaylist ){
-        iValidRename = ETrue;
-    }
-    iPlaylistId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
-    const TDesC& title = aMedia.ValueText(KMPXMediaGeneralTitle);
-    iRenameTitle = QString::fromUtf16(title.Ptr(), title.Length());
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUiHelper::DeleteL( CMPXCollectionPath& aPath,
-                          MMPXCHelperObserver* aObserver )
-{
-    Q_UNUSED(aPath);
-    Q_UNUSED(aObserver);
-    iDelete = ETrue;
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionPath* MMPXCollectionUiHelper::MusicMenuPathL()
-{
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL( path );
-    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
-    path->AppendL( KMPXPlaylistViewIndex );
-    //Fake some elements for the path to make it unique
-    for(TInt i=0; i<10; i++){
-        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
-    }
-    CleanupStack::Pop( path );
-        
-    return path;    
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionPath* MMPXCollectionUiHelper::MusicAllSongsPathL()
-{
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL( path );
-    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
-    path->AppendL( KMPXPlaylistViewIndex );
-    //Fake some elements for the path to make it unique
-    for(TInt i=0; i<5; i++){
-        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
-    }
-    CleanupStack::Pop( path );
-        
-    return path;    
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionPath* MMPXCollectionUiHelper::MusicPlaylistPathL()
-{
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL( path );
-    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
-    path->AppendL( KMPXPlaylistViewIndex );
-    //Fake some elements for the path to make it unique
-    for(TInt i=0; i<3; i++){
-        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
-    }
-    CleanupStack::Pop( path );
-        
-    return path;    
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxcollectionutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#include <mpxmedia.h>
-#include <mpxmessage.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxcollectionmessage.h>
-#include <mpxcollectionmessagedefs.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediacollectiondetaildefs.h>
-#include <mpxcollectionplugin.hrh>
-#include <mpxcollectionpath.h>
-#include "mptrace.h"
-#include <e32debug.h>
-
-#include "stub/inc/mpxcollectionutility.h"
-const TInt KMPXAllSongsViewIndex = 0;
-const TInt KMPXPlaylistViewIndex = 1;
-
-/*!
- Stub function.
-*/
-MMPXCollectionUtility::MMPXCollectionUtility():iBack(EFalse),
-                                               iOpen(EFalse),
-                                               iIndex(0),
-                                               iOpenCount(0),
-                                               iCountPath(0),
-                                               iPlaylists(0),
-                                               iAlbumSongs(0)
-{
-    
-}
-
-/*!
- Stub function.
-*/
-MMPXCollectionUtility::~MMPXCollectionUtility()
-{
-    if (iAlbumSongs)
-    {
-        delete iAlbumSongs;
-    }
-    if (iPlaylists)
-    {
-        delete iPlaylists;
-    }
-}
-
-/*!
- Stub function.
-*/
-MMPXCollectionUtility* MMPXCollectionUtility::NewL(MMPXCollectionObserver* aObs, const TUid& aModeId)
-{
-    Q_UNUSED(aObs);
-    Q_UNUSED(aModeId);
-    MMPXCollectionUtility* temp = new MMPXCollectionUtility();
-    return temp;
-}
-
-/*!
- Stub function.
-*/
-MMPXCollection& MMPXCollectionUtility::Collection()
-{ 
-    return *this;
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::Close()
-{
-    delete this;
-}
-
-/*!
- Stub function.
-*/
-CMPXMedia* MMPXCollectionUtility::FindAllL(const CMPXSearchCriteria& aCriteria,
-                                    const TArray<TMPXAttribute>& aAttrs)
-{
-    Q_UNUSED(aAttrs);
-    
-    // Find Playlists
-    if(aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
-       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXPlaylist == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory))
-        {
-        return CMPXMedia::NewL(*iPlaylists);
-        }
-    // Find Album with ID
-    else if (aCriteria.IsSupported(KMPXMediaGeneralType) && EMPXGroup == aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) &&
-       aCriteria.IsSupported(KMPXMediaGeneralCategory) && EMPXSong == aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) &&
-       aCriteria.IsSupported(KMPXMediaGeneralId) && iAlbumSongs &&
-       //it is assumed that album ID matches index on the media array, just to make test logic more simple.
-       TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) >= 0 && TUint32(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)) < iAlbumSongs->Count())
-        {
-        return CMPXMedia::NewL(*iAlbumSongs->AtL(aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
-        }
-    else
-        {
-        return NULL;
-        }
-
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::CancelRequest()
-{   
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::BackL()
-{
-    iBack = ETrue;
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionPath* MMPXCollectionUtility::PathL()
-{
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL( path );
-    path->AppendL( TUid::Uid(EMPXCollectionPluginMusic).iUid );
-    path->AppendL( KMPXPlaylistViewIndex );
-    //Fake some elements for the path
-    for(TInt i = 0; i < 10; i++){
-        path->InsertL(TUid::Uid(EMPXCollectionPluginMusic).iUid,0);
-    }
-    CleanupStack::Pop( path );
-        
-    return path;
-}
-
-/*!
- Stub function.
-*/
-TUid MMPXCollectionUtility::CollectionIDL(const TArray<TUid>& aUids)
-{ 
-    Q_UNUSED(aUids);
-    return TUid::Uid(EMPXCollectionPluginMusic);
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::OpenL(TMPXOpenMode aMode)
-{
-    Q_UNUSED(aMode);
-    iOpen = ETrue;
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::OpenL(TInt aIndex,TMPXOpenMode aMode)
-{
-    Q_UNUSED(aMode);
-    iIndex = aIndex;  
-    iOpen = ETrue;
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::OpenL(const CMPXCollectionPath& aPath, TMPXOpenMode aMode)
-{
-    Q_UNUSED(aMode);
-    iCountPath = aPath.Count();
-    iOpen = ETrue;
-    iOpenCount++;
-}
-
-/*!
- Stub function.
-*/
-void MMPXCollectionUtility::setPlaylists( const CMPXMedia& entries )
-{
-    delete iPlaylists;
-    iPlaylists = 0;
-    iPlaylists = CMPXMedia::NewL(entries);
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxharvesterutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Harvester Utility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-
-#include <e32base.h>
-#include "stub/inc/mpxharvesterutility.h"
-
-/*!
- Stub function.
-*/
-MMPXHarvesterUtility::MMPXHarvesterUtility():iCheckSystemEvents(EFalse),
-                                             iScan(EFalse),
-                                             iLeave(EFalse)
-{
-}
-
-/*!
- Stub function.
-*/
-MMPXHarvesterUtility::~MMPXHarvesterUtility()
-{
-}
-
-/*!
- Stub function.
-*/
-void MMPXHarvesterUtility::ScanL()
-{
-    iScan = ETrue;
-}
-
-/*!
- Stub function.
-*/
-void MMPXHarvesterUtility::CancelScanL()
-{
-    if(iLeave){
-        User::Leave(KErrNotFound);
-    }else{
-        iScan = EFalse;
-    }
-    
-}
-
-/*!
- Stub function.
-*/
-void MMPXHarvesterUtility::CheckForSystemEventsL()
-{
-    iCheckSystemEvents = ETrue;
-}
-
-/*!
- Stub function.
-*/
-void MMPXHarvesterUtility::Close()
-{
-    delete this;
-}
-
-/*!
- Stub function.
-*/
-MMPXHarvesterUtility* CMPXHarvesterFactory::NewL()
-{
-    return new MMPXHarvesterUtility();
-}
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/stub/src/mpxplaybackutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxplaybackutility stub for testing mpmpxframeworkwrapper
-*
-*/
-
-#include <Qt>
-#include <mpxcollectionplaylist.h>
-#include <mptrace.h>
-
-#include "stub/inc/mpxplaybackutility.h"
-
-/*!
- Stub function.
-*/
-MMPXPlaybackUtility::MMPXPlaybackUtility():iShuffle(-1),
-                                           iRepeat(-1),
-                                           iProperty(EPbPropertyVolume),
-                                           iPlay(EFalse)
-{
-}
-
-/*!
- Stub function.
-*/
-MMPXPlaybackUtility::~MMPXPlaybackUtility()
-{
-}
-
-/*!
- Stub function.
- */
-MMPXPlaybackUtility* MMPXPlaybackUtility::UtilityL(const TUid& aModeId)
-{
-    Q_UNUSED(aModeId);
-    static MMPXPlaybackUtility playbackUtilility;
-    return &playbackUtilility;
-}
-
-/*!
- Stub function.
-*/
-void MMPXPlaybackUtility::Close()
-{
-}
-
-/*!
- Stub function.
-*/
-void MMPXPlaybackUtility::InitL(const CMPXCollectionPlaylist& aPlaylist, TBool aPlay)
-{
-    Q_UNUSED(aPlaylist);
-    iPlay = aPlay;
-}
-
-/*!
- Stub function.
-*/
-void MMPXPlaybackUtility::InitL(const TDesC& aUri, const TDesC8* aType)
-{
-    Q_UNUSED(aUri);
-    Q_UNUSED(aType);
-    iPlay = ETrue;
-}
-
-
-/*!
- Stub function.
-*/
-void MMPXPlaybackUtility::SetL(TMPXPlaybackProperty aProperty, TInt aValue)
-{
-    iProperty = aProperty;
-    if(iProperty == EPbPropertyRandomMode){
-        iShuffle = aValue;
-        TX_LOG_ARGS("PbUtility shuffle set to "<< aValue);
-    }else if (iProperty == EPbPropertyRepeatMode){
-        iRepeat = aValue;
-        TX_LOG_ARGS("PbUtility repeat set to "<< aValue);
-    }    
-    
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxframeworkwrapper/unittest_mpmpxframeworkwrapper.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-# Contributors:
-# Description: Unit test for mpmpxframeworkwrapper
-TEMPLATE = app
-CONFIG += qtestlib \
-    hb
-TARGET = 
-
-TARGET.CAPABILITY = All -TCB
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-    ../../inc \
-    ../../../../inc
-
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-
-LIBS += -lestor.dll \
-    -lfbscli.dll \
-    -lmpxcommon.dll \
-    -lmpxcollectionutility.dll \
-    -lmpsettingsmanager
-
-HEADERS += inc/unittest_mpmpxframeworkwrapper.h \
-    ../../inc/mpmpxframeworkwrapper.h \
-    ../../inc/mpmpxframeworkwrapper_p.h \
-    stub/inc/mpmpxcollectiondata.h \
-    stub/inc/mpxcollectionopenutility.h \
-    stub/inc/mpxcollectionuihelper.h \
-    stub/inc/mpxcollectionutility.h \
-    stub/inc/mpxcollectionhelperfactory.h \
-    stub/inc/mpxharvesterutility.h \
-    stub/inc/mpxplaybackutility.h \
-    stub/inc/mpmpxisolatedcollectionhelper.h
-
-SOURCES += src/unittest_mpmpxframeworkwrapper.cpp \
-    ../../src/mpmpxframeworkwrapper.cpp \
-    stub/src/mpmpxcollectiondata.cpp \
-    stub/src/mpxcollectionopenutility.cpp \
-    stub/src/mpxcollectionuihelper.cpp \
-    stub/src/mpxcollectionutility.cpp \
-    stub/src/mpxcollectionhelperfactory.cpp \
-    stub/src/mpxharvesterutility.cpp \
-    stub/src/mpxplaybackutility.cpp \
-    stub/src/mpmpxisolatedcollectionhelper.cpp
-
-RESOURCES += ../../resources/mpcollectionviewresources.qrc
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/inc/unittest_mpmpxisolatedcollectionhelper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for CMpMpxIsolatedCollectionHelper
-*
-*/
-
-#ifndef TESTMPMPXISOLATEDCOLLECTIONHELPER_H
-#define TESTMPMPXISOLATEDCOLLECTIONHELPER_H
-
-#include <QtTest/QtTest>
-
-/* in our unit test usually this goes on the CPP file, but in this case we need it here to get
- the observer interface, and also the mpxcollectionopenutility stub before the tested class so 
- we get the stub instead of the normal mpxcollectionopenutility.*/
-#include "stub/inc/mpxcollectionopenutility.h"
-// Do this so we can access all member variables.
-#define private public
-#include "mpmpxisolatedcollectionhelper.h"
-#undef private
-
-class CMpMpxIsolatedCollectionHelper;
-class CMPXMedia;
-
-class TestCMpMpxIsolatedCollectionHelper : public QObject,
-                                                  MMpMpxIsolatedCollectionHelperObserver
-{
-    Q_OBJECT
-
-public:
-
-    TestCMpMpxIsolatedCollectionHelper();
-    virtual ~TestCMpMpxIsolatedCollectionHelper();
-
-private:
-    
-    void HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError );
-    
-public slots:
-
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-
-    void testConstructor();
-    void testOpenCollection();
-    void testHandleOpen();
-
-private:
-
-    CMpMpxIsolatedCollectionHelper  *mTest;
-    const CMPXMedia                 *iEntriesFromoOpenCallback; //not own
-    TInt                             iErrorFromoOpenCallback;
-    TInt                             iOpenCallbackCounter;
-
-};
-
-#endif  // TESTMPMPXISOLATEDCOLLECTIONHELPER_H
-
-
-
-
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/src/unittest_mpmpxisolatedcollectionhelper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for CMpMpxIsolatedCollectionHelper
-*
-*/
-
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-
-#include <mpxmedia.h>
-#include <mpxcollectionplaylist.h>
-#include <mpxcollectionpath.h>
-
-#include "unittest_mpmpxisolatedcollectionhelper.h"
-
-
-//This so we can test private functions
-#include "../../src/mpmpxisolatedcollectionhelper.cpp"
-
-
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestCMpMpxIsolatedCollectionHelper tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpmpxisolatedcollectionhelper.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestCMpMpxIsolatedCollectionHelper::TestCMpMpxIsolatedCollectionHelper()
-    : mTest( 0 ),
-      iEntriesFromoOpenCallback ( 0 ),
-      iErrorFromoOpenCallback( KErrNone ),
-      iOpenCallbackCounter( 0 )
-{
-}
-
-TestCMpMpxIsolatedCollectionHelper::~TestCMpMpxIsolatedCollectionHelper()
-{
-    delete mTest;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestCMpMpxIsolatedCollectionHelper::initTestCase()
-{
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestCMpMpxIsolatedCollectionHelper::cleanupTestCase()
-{
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestCMpMpxIsolatedCollectionHelper::init()
-{
-    mTest = CMpMpxIsolatedCollectionHelper::NewL( this );
-}
-
-/*!
- Called after every testfunction.
- */
-void TestCMpMpxIsolatedCollectionHelper::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- Tests constructor.
-*/
-void TestCMpMpxIsolatedCollectionHelper::testConstructor()
-{
-    QVERIFY(mTest->iIncrementalOpenUtil != 0);
-    QCOMPARE(mTest->iIncrementalOpenUtil->iMode , KMcModeIsolated);
-    QCOMPARE(mTest->iObserver , dynamic_cast<MMpMpxIsolatedCollectionHelperObserver*>(this));
-}
-
-/*!
- Tests OpenCollection.
- */
-void TestCMpMpxIsolatedCollectionHelper::testOpenCollection()
-{
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    mTest->OpenCollectionL(*path);
-    QCOMPARE(mTest->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
-    QCOMPARE(mTest->iIncrementalOpenUtil->iStop,TBool(ETrue));
-    QCOMPARE(mTest->iIncrementalOpenUtil->iStart,TBool(ETrue));
-    QCOMPARE(mTest->iFirstIncrementalOpen,TBool(ETrue));
-    QCOMPARE(mTest->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
-    QCOMPARE(mTest->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
-    QCOMPARE((int)mTest->iIncrementalOpenUtil->iPath, (int)path);
-    delete path;
-}
-
-/*!
- Tests HandleOpen.
- */
-void TestCMpMpxIsolatedCollectionHelper::testHandleOpen()
-{
-     iEntriesFromoOpenCallback = 0;
-     iErrorFromoOpenCallback = KErrArgument;
-     iOpenCallbackCounter = 0;
-     CMPXMedia *media = CMPXMedia::NewL();
-     mTest->iFirstIncrementalOpen = ETrue;
-     mTest->HandleOpenL(*media, 0, false, KErrNone);
-     QCOMPARE((int)iEntriesFromoOpenCallback,(int)media);
-     QCOMPARE(iErrorFromoOpenCallback,KErrNone);
-     QCOMPARE(iOpenCallbackCounter,1);
-}
- 
-/*!
- Used to keep track of the callback from teh isolated collection helper.
- */
-void TestCMpMpxIsolatedCollectionHelper::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
-{
-     iEntriesFromoOpenCallback = &aEntries;
-     iErrorFromoOpenCallback = aError;
-     iOpenCallbackCounter++;
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/inc/mpxcollectionopenutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  mpxcollectionopenutility stub for testing CMpMpxIsolatedCollectionHelper
-*
-*/
-
-
-#ifndef C_CMPXCOLLECTIONOPENUTILITY_H
-#define C_CMPXCOLLECTIONOPENUTILITY_H
-
-#include <mpxcollectionobserver.h>
-#include <mpxcollectionframeworkdefs.h>
-#include <mpxcollectionopenlresultdef.h>
-
-class CMPXCollectionPath;
-
-class CMPXCollectionOpenUtility  
-{
-public:
-    
-    // Stub functions
-    enum TDirection
-        {
-        EFetchNormal,
-        EFetchUp,
-        EFetchDown
-        };
-     static CMPXCollectionOpenUtility* NewL( MMPXCollectionObserver* aObs, TUid aMode = KMcModeDefault );
-     CMPXCollectionOpenUtility();
-     ~CMPXCollectionOpenUtility();
-     void StartL( const CMPXCollectionPath& aPath,
-                              TArray<TMPXAttribute> aAttrs,
-                              TInt aChunkSize,
-                              TInt aOffset = 0,
-                              TDirection aDirection = EFetchNormal,
-                              TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute );
-     void Stop();
-     void SetDelay( TInt aDelay );
-public:
-     TInt                      iDelay;
-     TInt                      iChunkSize;
-     TBool                     iStop;
-     TBool                     iStart;
-     TDirection                iDirection;
-     const CMPXCollectionPath *iPath; //not own
-     TUid                      iMode;
-    };
-
-#endif // C_CMPXCOLLECTIONOPENUTILITY_H
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/stub/src/mpxcollectionopenutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: mpxcollectionopenutility stub for testing CMpMpxIsolatedCollectionHelper
-*
-*/
-
-
-
-#include <e32debug.h>
-#include <Qt>
-
-#include "stub/inc/mpxcollectionopenutility.h"
-
-
-/*!
- Stub function.
-*/
-CMPXCollectionOpenUtility::CMPXCollectionOpenUtility():iDelay(0),
-                                                       iStart(EFalse),
-                                                       iStop(EFalse),
-                                                       iChunkSize(0),
-                                                       iDirection(EFetchDown),
-                                                       iMode(TUid::Null())
-{
-    
-}
-
-/*!
- Stub function.
-*/   
-CMPXCollectionOpenUtility* CMPXCollectionOpenUtility::NewL(MMPXCollectionObserver* aObs, TUid aMode)
-{
-    Q_UNUSED(aObs);
-    CMPXCollectionOpenUtility* collectionOpenUtility = new CMPXCollectionOpenUtility();
-    collectionOpenUtility->iMode = aMode;
-    return collectionOpenUtility;
-}
-
-/*!
- Stub function.
-*/
-CMPXCollectionOpenUtility::~CMPXCollectionOpenUtility()
-{
-    
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::Stop()
-{
-    iStop=ETrue;
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::SetDelay( TInt aDelay )
-{
-    iDelay = aDelay;
-}
-
-/*!
- Stub function.
-*/
-void CMPXCollectionOpenUtility::StartL( const CMPXCollectionPath& aPath,
-                              TArray<TMPXAttribute> aAttrs,
-                              TInt aChunkSize,
-                              TInt aOffset,
-                              TDirection aDirection,
-                              TMPXAttribute aKeyAttribute)
-{
-    Q_UNUSED(aAttrs);
-    Q_UNUSED(aOffset);
-    Q_UNUSED(aKeyAttribute);
-    iPath = &aPath;
-    iStart = ETrue;
-    iChunkSize = aChunkSize;
-    iDirection = aDirection;
-}
-
-//end of file
--- a/mpviewplugins/mpcollectionviewplugin/tsrc/unittest_mpmpxisolatedcollectionhelper/unittest_mpmpxisolatedcollectionhelper.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-# Contributors:
-# Description: Unit test for CMpMpxIsolatedCollectionHelper
-TEMPLATE = app
-CONFIG += qtestlib \
-    hb
-TARGET = 
-
-TARGET.CAPABILITY = All -TCB
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-    ../../inc \
-    ../../../../inc
-
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-
-LIBS += -lestor.dll \
-    -lfbscli.dll \
-    -lmpxcommon.dll \
-    -lmpxcollectionutility.dll
-
-HEADERS += inc/unittest_mpmpxisolatedcollectionhelper.h \
-    ../../inc/mpmpxisolatedcollectionhelper.h \
-    stub/inc/mpxcollectionopenutility.h
-
-SOURCES += src/unittest_mpmpxisolatedcollectionhelper.cpp \
-        stub/src/mpxcollectionopenutility.cpp
--- a/mpviewplugins/mpdetailsviewplugin/inc/mpdetailsview.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpdetailsviewplugin/inc/mpdetailsview.h	Mon May 03 12:29:20 2010 +0300
@@ -18,13 +18,14 @@
 #ifndef MPDETAILSVIEW_H
 #define MPDETAILSVIEW_H
 
-#include <hbview.h>
 #include <qpixmap>
 #include <qpointer.h>
 #include <QNetworkReply>
 #include <QDomDocument>
 #include <QMap>
 
+#include "mpviewbase.h"
+
 class QGraphicsWebView;
 class QNetworkAccessManager;
 
@@ -45,7 +46,7 @@
 class MpMpxDetailsFrameworkWrapper;
 
 //class declaration
-class MpDetailsView : public HbView
+class MpDetailsView : public MpViewBase
 {
     Q_OBJECT
     
--- a/mpviewplugins/mpdetailsviewplugin/mpdetailsviewplugin.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpdetailsviewplugin/mpdetailsviewplugin.pro	Mon May 03 12:29:20 2010 +0300
@@ -48,7 +48,8 @@
     	   src/mpmpxdetailsframeworkwrapper_p.cpp \
     	   src/mpsongdata.cpp
 
-HEADERS = inc/mpdetailsviewplugin.h \
+HEADERS = ../../inc/mpviewbase.h \
+        inc/mpdetailsviewplugin.h \
     	  inc/mpdetailsview.h \
     	  inc/mpmpxdetailsframeworkwrapper.h \
     	  inc/mpmpxdetailsframeworkwrapper_p.h \
--- a/mpviewplugins/mpdetailsviewplugin/src/mpdetailsview.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpdetailsviewplugin/src/mpdetailsview.cpp	Mon May 03 12:29:20 2010 +0300
@@ -210,7 +210,6 @@
             this, SLOT( thumbnailReady( QPixmap , void * , int , int  ) ) );
     mDefaultRecommendationAlbumArt = QPixmap( ":/detailsviewicons/defaultalbumart.png" );
     
-    setTitle( tr("Music") );
     // TODO: might need later
     setupMenu();
       
--- a/mpviewplugins/mpplaybackviewplugin/inc/mpmpxpbframeworkwrapper.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Framework wraper for Playback.
-*
-*/
-
-#ifndef MPMPXPBFRAMEWORKWRAPPER_H
-#define MPMPXPBFRAMEWORKWRAPPER_H
-
-#include <QObject>
-
-class MpMpxPbFrameworkWrapperPrivate;
-class MpPlaybackData;
-
-class MpMpxPbFrameworkWrapper : public QObject
-{
-    Q_OBJECT
-
-    friend class MpMpxPbFrameworkWrapperPrivate;
-
-public:
-
-    explicit MpMpxPbFrameworkWrapper( QObject *parent=0 );
-    virtual ~MpMpxPbFrameworkWrapper();
-
-    MpPlaybackData *playbackData();
-
-public slots:
-
-    void playPause();
-    void stop();
-    void skipForward();
-    void skipBackward();
-    void setPosition( int position );
-    void setShuffle( bool mode );
-    void setRepeat( bool mode );
-
-private:
-
-    Q_DISABLE_COPY(MpMpxPbFrameworkWrapper)
-    MpMpxPbFrameworkWrapperPrivate *d_ptr;
-
-};
-
-#endif  // MPMPXPBFRAMEWORKWRAPPER_H
--- a/mpviewplugins/mpplaybackviewplugin/inc/mpmpxpbframeworkwrapper_p.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Framework wraper for Playback - Private.
-*
-*/
-
-#ifndef MPMPXPBFRAMEWORKWRAPPER_P_H
-#define MPMPXPBFRAMEWORKWRAPPER_P_H
-
-#include <mpxplaybackobserver.h>
-#include <mpxcollectionobserver.h>
-
-class MMPXPlaybackUtility;
-class MMPXCollectionUtility;
-class MpMpxPbFrameworkWrapper;
-class CMPXMedia;
-class MpPlaybackData;
-
-
-class MpMpxPbFrameworkWrapperPrivate : public MMPXPlaybackObserver,
-                                       public MMPXPlaybackCallback,
-                                       public MMPXCollectionObserver
-{
-public:
-
-    explicit MpMpxPbFrameworkWrapperPrivate( MpMpxPbFrameworkWrapper *qq );
-    virtual ~MpMpxPbFrameworkWrapperPrivate();
-
-    void init();
-
-    void playPause();
-    void stop();
-    void skipForward();
-    void skipBackward();
-    void setPosition( int value );
-    void setShuffle( bool mode );
-    void setRepeat( bool mode );
-
-    MpPlaybackData *playbackData();
-
-    // From MMPXPlaybackObserver
-    void HandlePlaybackMessage( CMPXMessage *aMessage, TInt aError );
-
-    // From MMPXPlaybackCallback
-    void HandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError );
-    void HandleSubPlayerNamesL( TUid aPlayer, const MDesCArray *aSubPlayers,
-                                TBool aComplete, TInt aError );
-    void HandleMediaL( const CMPXMedia& aProperties, TInt aError );
-
-    // From MMPXCollectionObserver
-    void HandleCollectionMessage( CMPXMessage* aMessage, TInt aError );
-    void HandleOpenL( const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError);
-    void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError );
-    void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
-
-private:
-
-    void DoInitL();
-    void DoHandlePlaybackMessageL( const CMPXMessage& aMessage );
-    void ForceStopL();
-    void UpdateStateL();
-    void RetrieveSongDetailsL();
-
-private:
-
-    MpMpxPbFrameworkWrapper         *q_ptr;
-
-    MMPXPlaybackUtility             *iPlaybackUtility;     // Own
-    MMPXCollectionUtility           *iCollectionUtility;   // Own
-    CMPXMedia                       *iMedia;               // Own
-
-    MpPlaybackData                  *iPlaybackData;        // Own
-
-};
-
-#endif  // MPMPXPBFRAMEWORKWRAPPER_P_H
--- a/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackdata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Playback Data provider for playback view.
-*
-*/
-
-#ifndef MPPLAYBACKDATA_H
-#define MPPLAYBACKDATA_H
-
-#include <QObject>
-#include <QString>
-#include <QPixmap>
-
-//forward declartions
-class QIcon;
-class ThumbnailManager;
-
-//class declaration
-class MpPlaybackData : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    enum SimplifiedState {
-        Playing,
-        Paused,
-        Stopped
-    };
-
-    explicit MpPlaybackData( QObject *parent=0 );
-    virtual ~MpPlaybackData();
-
-    void setDuration( int duration );
-    int duration() const;
-    void setPosition( int position );
-    int position() const;
-
-    bool setTitle( const QString& title );
-    const QString& title() const;
-    bool setArtist( const QString& artist );
-    const QString& artist() const;
-    bool setAlbum( const QString& album );
-    const QString& album() const;
-    bool setUri( const QString& uri );
-    const QString& uri() const;
-
-    void setAlbumArtUri( const QString& albumArtUri );
-    void albumArt( QPixmap& pixmap ) const;
-
-    void setPlaybackState( const SimplifiedState state );
-    MpPlaybackData::SimplifiedState playbackState() const;
-
-    void commitPlaybackInfo();
-
-public slots:
-
-    void thumbnailReady( const QPixmap& pixmap, void *data, int id, int error );
-
-signals:
-
-    void durationChanged();
-    void positionChanged();
-    void albumArtReady();
-    void playbackStateChanged();
-    void playbackInfoChanged();
-
-private:
-
-    ThumbnailManager         *mThumbnailManager; //owned
-    int                      mReqId;
-
-    int                      mDuration;
-    int                      mPosition;
-    QString                  mTitle;
-    QString                  mAlbum;
-    QString                  mArtist;
-    QString                  mUri;
-    QPixmap                  mAlbumArt;
-    QPixmap                  mDefaultAlbumArt;
-    SimplifiedState          mPlaybackState;
-
-    Q_DISABLE_COPY(MpPlaybackData)
-};
-
-#endif // MPPLAYBACKDATA_H
--- a/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackview.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackview.h	Mon May 03 12:29:20 2010 +0300
@@ -23,7 +23,7 @@
 class HbAction;
 class HbIcon;
 class HbMainWindow;
-class MpMpxPbFrameworkWrapper;
+class MpEngine;
 class MpPlaybackData;
 class MpPlaybackWidget;
 class MpEqualizerWidget;
@@ -72,7 +72,7 @@
 
 private:
 
-    MpMpxPbFrameworkWrapper *mFrameworkWrapper; // Own
+    MpEngine                *mMpEngine;         // Own
     MpPlaybackData          *mPlaybackData;     // Not own
     MpPlaybackWidget        *mPlaybackWidget;   // Not own
     MpEqualizerWidget       *mEqualizerWidget;  // Own
--- a/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpplaybackviewplugin/inc/mpplaybackwidget.h	Mon May 03 12:29:20 2010 +0300
@@ -50,8 +50,6 @@
     void positionChanged();
     void albumArtChanged();
 
-    bool loadLayout( Qt::Orientation orientation );
-
 private slots:
 
     void handleSliderPressed();
@@ -61,7 +59,6 @@
 private:
 
     QString formatDuration( int seconds );
-    void composeAlbumCover( QPixmap& albumart );
 
 private:
 
@@ -75,7 +72,7 @@
     HbLabel                 *mAlbumArt;         // Not own
     HbProgressSlider        *mProgressBar;      // Not own
 
-    QPixmap                 mCompositePixmap;
+
 
     bool                    mProgreesBarDragging;
     int                     mDuration;
--- a/mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpplaybackviewplugin/mpplaybackviewplugin.pro	Mon May 03 12:29:20 2010 +0300
@@ -33,12 +33,12 @@
      
 LIBS += -lmpxplaybackutility.dll \
         -lmpxcommon.dll \
-        -lthumbnailmanagerqt.dll \
-        -lmpxcollectionutility.dll \
         -lestor.dll \
-	-lmpxviewframeworkqt.dll \
-	-laudioequalizerutility.dll \
-	-lmpsettingsmanager
+		-lmpxviewframeworkqt.dll \
+		-laudioequalizerutility.dll \
+		-lmpsettingsmanager \
+		-lmpengine \
+		-lmpdata.dll
 	
 symbian:
 {
@@ -50,11 +50,8 @@
 }
 
 HEADERS = ../../inc/mpviewbase.h \
-      inc/mpplaybackviewplugin.h \
+	  inc/mpplaybackviewplugin.h \
       inc/mpplaybackview.h \
-      inc/mpmpxpbframeworkwrapper.h \
-      inc/mpmpxpbframeworkwrapper_p.h \
-      inc/mpplaybackdata.h \
       inc/mpplaybackwidget.h \
       inc/mpequalizerwrapper.h \
       inc/mpequalizerwrapper_p.h \
@@ -62,10 +59,7 @@
 
 SOURCES += src/mpplaybackviewplugin.cpp \
        src/mpplaybackview.cpp \
-       src/mpplaybackdata.cpp \
        src/mpplaybackwidget.cpp \
-       src/mpmpxpbframeworkwrapper.cpp \
-       src/mpmpxpbframeworkwrapper_p.cpp \
        src/mpequalizerwrapper.cpp \
        src/mpequalizerwrapper_p.cpp \
        src/mpequalizerwidget.cpp
--- a/mpviewplugins/mpplaybackviewplugin/src/mpmpxpbframeworkwrapper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Framework wraper for Playback.
-*
-*/
-
-#include "mpmpxpbframeworkwrapper.h"
-#include "mpmpxpbframeworkwrapper_p.h"
-#include "mptrace.h"
-
-/*!
-    \class MpMpxPbFrameworkWrapper
-    \brief Wrapper for mpx framework utilities.
-
-    MPX framework wrapper provides Qt style interface to the MPX framework
-    utilities. Its implementation is hidden using private class data pattern.
-*/
-
-/*!
- Constructs the utility wrapper.
- */
-MpMpxPbFrameworkWrapper::MpMpxPbFrameworkWrapper( QObject *parent )
-    : QObject(parent)
-{
-    d_ptr = new MpMpxPbFrameworkWrapperPrivate(this );
-    d_ptr->init();
-}
-
-/*!
- Destructs the utility wrapper.
- */
-MpMpxPbFrameworkWrapper::~MpMpxPbFrameworkWrapper()
-{
-    delete d_ptr;
-}
-
-/*!
- Returns pointer to MpPlaybackData, which is the playback data.
- */
-MpPlaybackData *MpMpxPbFrameworkWrapper::playbackData()
-{
-    return d_ptr->playbackData();
-}
-
-/*!
- Slot to handle a play pause.
- */
-void MpMpxPbFrameworkWrapper::playPause()
-{
-    d_ptr->playPause();
-}
-
-/*!
- Slot to handle a stop.
- */
-void MpMpxPbFrameworkWrapper::stop()
-{
-    d_ptr->stop();
-}
-
-/*!
- Slot to handle a skeep forward.
- */
-void MpMpxPbFrameworkWrapper::skipForward()
-{
-    d_ptr->skipForward();
-}
-
-/*!
- Slot to handle a skeep backwards.
- */
-void MpMpxPbFrameworkWrapper::skipBackward()
-{
-    d_ptr->skipBackward();
-}
-
-/*!
- Slot to handle a request to change \a position.
- */
-void MpMpxPbFrameworkWrapper::setPosition( int position )
-{
-    d_ptr->setPosition( position );
-}
-
-/*!
- Slot to handle a request to change shuffle \a mode.
- */
-void MpMpxPbFrameworkWrapper::setShuffle( bool mode )
-{
-    d_ptr->setShuffle( mode );
-}
-
-/*!
- Slot to handle a request to change repeat \a mode.
- */
-void MpMpxPbFrameworkWrapper::setRepeat( bool mode )
-{
-    d_ptr->setRepeat( mode );
-}
-
--- a/mpviewplugins/mpplaybackviewplugin/src/mpmpxpbframeworkwrapper_p.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,487 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Framework wraper for Playback - Private.
-*
-*/
-
-#include <mpxplaybackutility.h>
-#include <mpxcollectionutility.h>
-#include <mpxmedia.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediamusicdefs.h>
-#include <mpxcommandgeneraldefs.h>
-#include <mpxplaybackmessage.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxplaybackmessagedefs.h>
-#include <mpxcollectionplaylist.h>
-#include <mpxcollectionplugin.hrh>
-#include <mpxcollectioncommanddefs.h>
-
-#include "mpmpxpbframeworkwrapper_p.h"
-#include "mpmpxpbframeworkwrapper.h"
-#include "mpplaybackdata.h"
-#include "mpcommondefs.h"
-#include "mptrace.h"
-
-/*!
-    \class MpMpxPbFrameworkWrapperPrivate
-    \brief Wrapper for mpx framework utilities - private implementation.
-
-    This is a private implementation of the mpx framework wrapper utilties interface.
-*/
-
-/*!
- \internal
- */
-MpMpxPbFrameworkWrapperPrivate::MpMpxPbFrameworkWrapperPrivate( MpMpxPbFrameworkWrapper *qq)
-    : q_ptr( qq ),
-      iPlaybackUtility(0),
-      iCollectionUtility(0),
-      iMedia(0),
-      iPlaybackData(0)
-{
-    TX_LOG
-}
-
-/*!
- \internal
- */
-MpMpxPbFrameworkWrapperPrivate::~MpMpxPbFrameworkWrapperPrivate()
-{
-    TX_ENTRY
-
-    if ( iPlaybackUtility ) {
-        TRAP_IGNORE( ForceStopL() );
-        iPlaybackUtility->Close();
-    }
-
-    if ( iCollectionUtility ) {
-        iCollectionUtility->Close();
-    }
-
-    delete iMedia;
-    delete iPlaybackData;
-
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::init()
-{
-    TRAPD(err, DoInitL());
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::playPause()
-{
-    TX_ENTRY
-    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdPlayPause));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::stop()
-{
-    TX_ENTRY
-    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdStop));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::skipForward()
-{
-    TX_ENTRY
-    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdNext));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::skipBackward()
-{
-    TX_ENTRY
-    TRAPD(err, iPlaybackUtility->CommandL(EPbCmdPrevious));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::setPosition( int value )
-{
-    TX_ENTRY_ARGS("value =" << value);
-    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyPosition, value));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::setShuffle( bool mode )
-{
-    TX_ENTRY_ARGS("mode =" << mode);
-    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyRandomMode, mode));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::setRepeat( bool mode )
-{
-    TX_ENTRY_ARGS("mode =" << mode);
-    TRAPD(err, iPlaybackUtility->SetL(EPbPropertyRepeatMode, mode ? EPbRepeatAll : EPbRepeatOff));
-    if ( err != KErrNone ) {
-        TX_LOG_ARGS("Error: " << err << "; should never get here.");
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-MpPlaybackData *MpMpxPbFrameworkWrapperPrivate::playbackData()
-{
-    return iPlaybackData;
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandlePlaybackMessage( CMPXMessage *aMessage, TInt aError )
-{
-    TX_ENTRY_ARGS("aError=" << aError);
-    if ( aError == KErrNone && aMessage ) {
-        TRAP_IGNORE( DoHandlePlaybackMessageL(*aMessage) );
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandlePropertyL(
-    TMPXPlaybackProperty aProperty,
-    TInt aValue,
-    TInt aError )
-{
-    TX_ENTRY_ARGS("aProperty=" << aProperty << "aValue=" << aValue << "aError=" << aError)
-    if ( KErrNone == aError ) {
-        switch ( aProperty  ) {
-            case EPbPropertyPosition:
-                TX_LOG_ARGS("EPbPropertyPosition")
-                iPlaybackData->setPosition(aValue);
-                break;
-            case EPbPropertyDuration:
-                TX_LOG_ARGS("EPbPropertyDuration")
-                iPlaybackData->setDuration(aValue);
-                break;
-            default:
-                break;
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleSubPlayerNamesL(
-    TUid aPlayer,
-    const MDesCArray *aSubPlayers,
-    TBool aComplete,
-    TInt aError )
-{
-    Q_UNUSED(aPlayer);
-    Q_UNUSED(aSubPlayers);
-    Q_UNUSED(aComplete);
-    Q_UNUSED(aError);
-    TX_LOG
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleMediaL(
-    const CMPXMedia& aProperties,
-    TInt aError )
-{
-    TX_ENTRY_ARGS("aError=" << aError);
-    if ( KErrNone != aError || !iPlaybackData ) {
-        TX_EXIT
-        return;
-    }
-
-    if ( iMedia ) {
-        delete iMedia;
-        iMedia = NULL;
-    }
-    iMedia = CMPXMedia::NewL( aProperties );
-
-    bool changed = false;
-    if ( aProperties.IsSupported( KMPXMediaGeneralTitle ) ) {
-        changed |= iPlaybackData->setTitle(
-            QString::fromUtf16(
-                aProperties.ValueText( KMPXMediaGeneralTitle ).Ptr(),
-                aProperties.ValueText( KMPXMediaGeneralTitle ).Length() ) );
-    }
-    if ( aProperties.IsSupported( KMPXMediaMusicArtist ) ) {
-        changed |= iPlaybackData->setArtist(
-            QString::fromUtf16(
-                aProperties.ValueText( KMPXMediaMusicArtist ).Ptr(),
-                aProperties.ValueText( KMPXMediaMusicArtist ).Length() ) );
-    }
-    if ( aProperties.IsSupported( KMPXMediaMusicAlbum ) ) {
-        changed |= iPlaybackData->setAlbum(
-            QString::fromUtf16(
-                aProperties.ValueText( KMPXMediaMusicAlbum ).Ptr(),
-                aProperties.ValueText( KMPXMediaMusicAlbum ).Length() ) );
-    }
-
-    if ( changed ) {
-        // This is required to propagate the playback info to UI at once.
-        iPlaybackData->commitPlaybackInfo();
-    }
-
-    if ( aProperties.IsSupported( KMPXMediaGeneralUri) ) {
-        iPlaybackData->setUri(
-            QString::fromUtf16(
-                aProperties.ValueText( KMPXMediaGeneralUri ).Ptr(),
-                aProperties.ValueText( KMPXMediaGeneralUri ).Length() ) );
-    }
-    if (aProperties.IsSupported(TMPXAttribute(KMPXMediaMusicAlbumArtFileName))) {
-        iPlaybackData->setAlbumArtUri(
-            QString::fromUtf16(
-                aProperties.ValueText(KMPXMediaMusicAlbumArtFileName).Ptr(),
-                aProperties.ValueText(KMPXMediaMusicAlbumArtFileName).Length()));
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleCollectionMessage(
-    CMPXMessage* aMessage, TInt aError )
-{
-
-    Q_UNUSED(aMessage);
-    Q_UNUSED(aError);
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleOpenL(
-    const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError)
-{
-    Q_UNUSED(aEntries);
-    Q_UNUSED(aIndex);
-    Q_UNUSED(aComplete);
-    Q_UNUSED(aError);
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleOpenL(
-    const CMPXCollectionPlaylist& aPlaylist, TInt aError )
-{
-    Q_UNUSED(aPlaylist);
-    Q_UNUSED(aError);
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::HandleCollectionMediaL(
-    const CMPXMedia& aMedia, TInt aError )
-{
-    Q_UNUSED(aMedia);
-    Q_UNUSED(aError);
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::DoInitL()
-{
-    TX_ENTRY
-    iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) );
-    iPlaybackUtility->AddObserverL( *this );
-    iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault );
-
-    iPlaybackData = new MpPlaybackData();
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::DoHandlePlaybackMessageL( const CMPXMessage& aMessage )
-{
-    TX_ENTRY
-    TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
-    if ( KMPXMessageGeneral == id ) {
-        TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
-        TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
-        TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
-        TX_LOG_ARGS("event=" << event << ", type=" << type << ", data=" << data);
-
-        switch ( event ) {
-            case TMPXPlaybackMessage::EStateChanged:
-                TX_LOG_ARGS("TMPXPlaybackMessage::EStateChanged")
-                UpdateStateL();
-                break;
-            case TMPXPlaybackMessage::EInitializeComplete:
-                TX_LOG_ARGS("TMPXPlaybackMessage::EInitializeComplete")
-                if ( data ) {
-                    // Play the track
-                    CMPXCommand *cmd( CMPXCommand::NewL() );
-                    CleanupStack::PushL( cmd );
-                    cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId,
-                            KMPXCommandIdPlaybackGeneral );
-                    cmd->SetTObjectValueL<TInt>(
-                            KMPXCommandPlaybackGeneralType,
-                            EPbCmdPlay );
-                    cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync,
-                            ETrue );
-                    cmd->SetTObjectValueL<TBool>(
-                            KMPXCommandPlaybackGeneralNoBuffer,
-                            ETrue );
-                    iPlaybackUtility->CommandL( *cmd );
-                    CleanupStack::PopAndDestroy( cmd );
-                }
-                break;
-            case TMPXPlaybackMessage::EPropertyChanged:
-                TX_LOG_ARGS("TMPXPlaybackMessage::EPropertyChanged")
-                TMPXPlaybackProperty property;
-                property = static_cast<TMPXPlaybackProperty>( type );
-                HandlePropertyL( property, data, KErrNone );
-                break;
-            case TMPXPlaybackMessage::EMediaChanged:
-                TX_LOG_ARGS("TMPXPlaybackMessage::EMediaChanged")
-                RetrieveSongDetailsL();
-                break;
-            default:
-                break;
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::ForceStopL()
-{
-    TX_ENTRY
-    if ( iPlaybackUtility ) {
-        // Stop the track
-        CMPXCommand *cmd( CMPXCommand::NewL() );
-        CleanupStack::PushL( cmd );
-        cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral );
-        cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, EPbCmdStop );
-        cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
-        cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue );
-        iPlaybackUtility->CommandL( *cmd );
-        CleanupStack::PopAndDestroy( cmd );
-
-        iPlaybackUtility->RemoveObserverL(*this);
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::UpdateStateL()
-{
-    TX_ENTRY
-    if ( !iPlaybackUtility->Source() ) {
-        TX_LOG_ARGS("There is no source")
-        iPlaybackData->setPlaybackState( MpPlaybackData::Stopped );
-    }
-    else {
-        switch ( iPlaybackUtility->StateL() ) {
-            case EPbStatePlaying:
-                TX_LOG_ARGS("EPbStatePlaying")
-                iPlaybackData->setPlaybackState( MpPlaybackData::Playing );
-                break;
-            case EPbStatePaused:
-                TX_LOG_ARGS("EPbStatePaused")
-                iPlaybackData->setPlaybackState( MpPlaybackData::Paused );
-                break;
-            case EPbStateStopped:
-                TX_LOG_ARGS("EPbStateStopped")
-                iPlaybackData->setPlaybackState( MpPlaybackData::Stopped );
-                break;
-            default:
-                break;
-        }
-    }
-    TX_EXIT
-}
-
-/*!
- \internal
- */
-void MpMpxPbFrameworkWrapperPrivate::RetrieveSongDetailsL()
-{
-    TX_ENTRY
-    MMPXSource *mediaSrc = iPlaybackUtility->Source();
-    User::LeaveIfNull( mediaSrc );
-    RArray<TMPXAttribute> requestedAttr;
-    CleanupClosePushL( requestedAttr );
-    requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralTitle ) );
-    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicArtist ) );
-    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbum ) );
-    requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralUri ) );
-    requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) );
-
-    mediaSrc->MediaL( requestedAttr.Array(), *this );
-    CleanupStack::PopAndDestroy( &requestedAttr );
-    TX_EXIT
-}
-
--- a/mpviewplugins/mpplaybackviewplugin/src/mpplaybackdata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,336 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Playback Data provider for playback view.
-*
-*/
-
-
-#include <qstring>
-#include <qpixmap>
-#include <thumbnailmanager_qt.h>
-
-#include "mpplaybackdata.h"
-#include "mptrace.h"
-
-const int KUndefined = -1;
-
-/*!
-    \class MpPlaybackData
-    \brief Music Player playback data.
-
-    Playback data provides access to current playing song data, and playback
-    properties, it is designed as an interface between the playback wrapper
-    and the UI, it also provides album art extraction.
-*/
-
-/*!
-    \fn void durationChanged()
-
-    This signal is emitted when duration changes.
- */
-
-/*!
-    \fn void positionChanged()
-
-    This signal is emitted when position changes.
- */
-
-/*!
-    \fn void albumArtReady()
-
-    This signal is emitted when album art is ready.
- */
-
-/*!
-    \fn void playbackStateChanged()
-
-    This signal is emitted when there is a *transition* on the playback state,
-    this is based on a simple state.
- */
-
-/*!
-    \fn void playbackInfoChanged()
-
-    This signal is emitted when playback info changes. This includes:
-    title, artist and album name.
- */
-
-
-
-/*!
-    Constructs a new MpPlaybackData.
- */
-MpPlaybackData::MpPlaybackData( QObject *parent )
-    : QObject(parent),
-      mThumbnailManager(0),
-      mReqId(KUndefined),
-      mDuration(0),
-      mPosition(0),
-      mAlbumArt(),
-      mPlaybackState(Stopped)
-{
-    TX_ENTRY
-    mThumbnailManager = new ThumbnailManager(this);
-    mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
-    mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
-    connect( mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
-             this, SLOT(thumbnailReady(QPixmap, void *, int, int)) );
-
-    mDefaultAlbumArt = QPixmap(":/playbackviewicons/defaultalbumart.png");
-    TX_EXIT
-}
-
-/*!
- Constructs a new MpPlaybackData.
- */
-MpPlaybackData::~MpPlaybackData()
-{
-    TX_ENTRY
-    delete mThumbnailManager;
-    TX_EXIT
-}
-
-/*!
- Sets the song \a duration.
-*/
-void MpPlaybackData::setDuration( int duration )
-{
-    TX_ENTRY_ARGS( "duration = " << duration )
-    mDuration = duration;
-    emit durationChanged();
-    TX_EXIT
-}
-
-/*!
- Returns the song duration.
-*/
-int MpPlaybackData::duration() const
-{
-    TX_LOG_ARGS( "mDuration = " << mDuration )
-    return mDuration;
-}
-
-/*!
- Sets the song \a position.
-*/
-void MpPlaybackData::setPosition( int position )
-{
-    TX_ENTRY_ARGS( "position = " << position )
-    mPosition = position;
-    emit positionChanged();
-    TX_EXIT
-}
-
-/*!
- Returns the song position.
-*/
-int MpPlaybackData::position() const
-{
-    TX_ENTRY_ARGS( "mPosition = " << mPosition )
-    return mPosition;
-}
-
-/*!
- Sets the song \a title, returns true if the value is new.
-*/
-bool MpPlaybackData::setTitle( const QString& title )
-{
-    TX_ENTRY_ARGS( "title = " << title )
-    bool change = false;
-    if ( title != mTitle ) {
-        change = true;
-        mTitle = title;
-    }
-    TX_EXIT
-    return change;
-}
-
-/*!
- Returns the song title.
-*/
-const QString& MpPlaybackData::title() const
-{
-    TX_ENTRY_ARGS( "mTitle = " << mTitle )
-    return mTitle;
-}
-
-/*!
- Sets the song \a artist, returns true if the value is new.
-*/
-bool MpPlaybackData::setArtist( const QString& artist )
-{
-    TX_ENTRY_ARGS( "artist = " << artist )
-    bool change = false;
-    if ( artist != mArtist ) {
-        change = true;
-        mArtist = artist;
-    }
-    TX_EXIT
-    return change;
-}
-
-/*!
- Returns the song artist.
-*/
-const QString& MpPlaybackData::artist() const
-{
-    TX_ENTRY_ARGS( "mArtist = " << mArtist )
-    return mArtist;
-}
-
-/*!
- Sets the song \a album, returns true if the value is new.
-*/
-bool MpPlaybackData::setAlbum( const QString& album )
-{
-    TX_ENTRY_ARGS( "album = " << album )
-    bool change = false;
-    if ( album != mAlbum ) {
-        change = true;
-        mAlbum = album;
-    }
-    TX_EXIT
-    return change;
-}
-
-/*!
- Returns the song album.
-*/
-const QString& MpPlaybackData::album() const
-{
-    TX_ENTRY_ARGS( "mAlbum = " << mAlbum )
-    return mAlbum;
-}
-
-/*!
- Sets the song \a uri, returns true if the value is new.
-*/
-bool MpPlaybackData::setUri( const QString& uri )
-{
-    TX_ENTRY_ARGS( "uri = " << uri )
-    bool change = false;
-    if ( uri != mUri ) {
-        change = true;
-        mUri = uri;
-    }
-    TX_EXIT
-    return change;
-}
-
-/*!
- Returns the song uri.
-*/
-const QString& MpPlaybackData::uri() const
-{
-    TX_ENTRY_ARGS( "mUri = " << mUri )
-    return mUri;
-}
-
-/*!
- Sets the song \a albumArtUri.
-*/
-void MpPlaybackData::setAlbumArtUri( const QString& albumArtUri )
-{
-    TX_ENTRY_ARGS( "albumArtUri = " << albumArtUri )
-    if ( !albumArtUri.isEmpty() ) {
-        bool ok = true;
-        if ( mReqId != KUndefined ) {
-            // There is already an outstanding request. Cancel it first.
-            bool ok = mThumbnailManager->cancelRequest(mReqId);
-        }
-        if ( ok ) {
-            mReqId = mThumbnailManager->getThumbnail( albumArtUri );
-            if ( mReqId == KUndefined ) {
-                // Request failed. Set default album art.
-                mAlbumArt = mDefaultAlbumArt;
-                emit albumArtReady();
-            }
-        }
-    }
-    else {
-        // No album art uri. Set default album art.
-        mAlbumArt = mDefaultAlbumArt;
-        emit albumArtReady();
-    }
-    TX_EXIT
-}
-
-/*!
- Returns the song album art on \a pixmap.
-*/
-void MpPlaybackData::albumArt( QPixmap& pixmap ) const
-{
-    TX_ENTRY
-    if ( mAlbumArt.isNull() ) {
-        pixmap = QPixmap();
-     }
-     else {
-        pixmap = mAlbumArt;
-     }
-    TX_EXIT
-}
-
-/*!
- Sets the playback \a state.
-*/
-void MpPlaybackData::setPlaybackState( const SimplifiedState state )
-{
-    TX_ENTRY_ARGS( "state = " << state )
-    if ( state != mPlaybackState ) {
-        mPlaybackState = state;
-        emit playbackStateChanged();
-    }
-    TX_EXIT
-}
-
-/*!
- Returns the playback state.
-*/
-MpPlaybackData::SimplifiedState MpPlaybackData::playbackState() const
-{
-    TX_LOG_ARGS( "mPlaybackState = " << mPlaybackState )
-    return mPlaybackState;
-}
-
-/*!
-
-*/
-void MpPlaybackData::commitPlaybackInfo()
-{
-    TX_ENTRY
-    emit playbackInfoChanged();
-    TX_EXIT
-}
-
-/*!
- Slot to handle the album art thumb.
-*/
-void MpPlaybackData::thumbnailReady(
-    const QPixmap& pixmap, void *data, int id, int error )
-{
-    TX_LOG_ARGS( "error = " << error << ", id = " << id )
-    Q_UNUSED(data);
-    if ( error == 0 && mReqId == id ) {
-        mReqId = KUndefined;
-        mAlbumArt = pixmap;
-        emit albumArtReady();
-    }
-    else {
-        mReqId = KUndefined;
-        mAlbumArt = mDefaultAlbumArt;
-        emit albumArtReady();
-    }
-    TX_EXIT
-}
-
--- a/mpviewplugins/mpplaybackviewplugin/src/mpplaybackview.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpplaybackviewplugin/src/mpplaybackview.cpp	Mon May 03 12:29:20 2010 +0300
@@ -28,7 +28,7 @@
 
 #include "mpplaybackview.h"
 #include "mpplaybackwidget.h"
-#include "mpmpxpbframeworkwrapper.h"
+#include "mpengine.h"
 #include "mpplaybackdata.h"
 #include "mpsettingsmanager.h"
 #include "mpcommondefs.h"
@@ -57,7 +57,7 @@
  Constructs the playback view.
  */
 MpPlaybackView::MpPlaybackView()
-    : mFrameworkWrapper( 0 ),
+    : mMpEngine( 0 ),
       mPlaybackData( 0 ),
       mPlaybackWidget( 0 ),
       mEqualizerWidget( new MpEqualizerWidget() ),
@@ -79,7 +79,6 @@
 MpPlaybackView::~MpPlaybackView()
 {
     TX_ENTRY
-    delete mFrameworkWrapper;
     delete mSoftKeyBack;
     delete mPlayIcon;
     delete mPauseIcon;
@@ -123,13 +122,13 @@
     mSoftKeyBack = new HbAction( Hb::BackAction, this );
     connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) );
 
-    mFrameworkWrapper = new MpMpxPbFrameworkWrapper();
-    mPlaybackData = mFrameworkWrapper->playbackData();
+    mMpEngine = MpEngine::instance();
+    mPlaybackData = mMpEngine->playbackData();
     connect( mPlaybackData, SIGNAL( playbackStateChanged() ),
              this, SLOT( playbackStateChanged() ) );
 
     mPlaybackWidget = new MpPlaybackWidget( mPlaybackData );
-    connect( mPlaybackWidget, SIGNAL( setPlaybackPosition( int ) ), mFrameworkWrapper, SLOT( setPosition( int ) ) );
+    connect( mPlaybackWidget, SIGNAL( setPlaybackPosition( int ) ), mMpEngine, SLOT( setPosition( int ) ) );
 
     setWidget( mPlaybackWidget );
     setupMenu();
@@ -190,10 +189,20 @@
 {
     TX_ENTRY
     // Stop the playback preview when returning to collection in fetch mode
-    if ( mViewMode == MpCommon::FetchView ) {
-        mFrameworkWrapper->stop();
+    switch ( mViewMode ) {
+        case MpCommon::EmbeddedView:
+            TX_LOG_ARGS( "MpCommon::EmbeddedView" )
+            mMpEngine->stop();
+            emit songSelected( "" );
+            break;
+        case MpCommon::FetchView:
+            TX_LOG_ARGS( "MpCommon::FetchView" )
+            mMpEngine->stop(); //Intentional fallthrough        
+        default: 
+            emit command( MpCommon::ActivateCollectionView );
+            break;
     }
-    emit command( MpCommon::ActivateCollectionView );
+    
     TX_EXIT
 }
 
@@ -253,7 +262,7 @@
  */
 void MpPlaybackView::toggleShuffle()
 {
-    mFrameworkWrapper->setShuffle( !mShuffle );
+    mMpEngine->setShuffle( !mShuffle );
     MpSettingsManager::setShuffle( !mShuffle );
 }
 
@@ -271,7 +280,7 @@
  */
 void MpPlaybackView::toggleRepeat()
 {
-    mFrameworkWrapper->setRepeat( !mRepeat );
+    mMpEngine->setRepeat( !mRepeat );
     MpSettingsManager::setRepeat( !mRepeat );
 }
 
@@ -290,7 +299,7 @@
 void MpPlaybackView::handleSongSelected()
 {
     TX_ENTRY
-    mFrameworkWrapper->stop();
+    mMpEngine->stop();
     emit songSelected( mPlaybackData->uri() );
     TX_EXIT
 }
@@ -324,23 +333,29 @@
     toolBar->setOrientation( Qt::Horizontal );
     QActionGroup *actionsGroup = new QActionGroup( toolBar );
 
-    if ( mViewMode == MpCommon::DefaultView ) {
+    if ( mViewMode == MpCommon::DefaultView || mViewMode == MpCommon::EmbeddedView ) {
         mShuffleOnIcon = new HbIcon( "qtg_mono_shuffle" );
         mShuffleOffIcon = new HbIcon( "qtg_mono_shuffle_off" );
         mShuffleAction = new HbAction( actionsGroup );
         mShuffle = MpSettingsManager::shuffle();
         mShuffleAction->setIcon( mShuffle ? *mShuffleOnIcon : *mShuffleOffIcon );
         mShuffleAction->setCheckable( false );
-
-        connect( mShuffleAction, SIGNAL( triggered( bool ) ),
-                 this, SLOT( toggleShuffle() ) );
+        
+        if ( mViewMode == MpCommon::DefaultView ) {
+            connect( mShuffleAction, SIGNAL( triggered( bool ) ),
+                         this, SLOT( toggleShuffle() ) );
+        }
+        else {
+            mShuffleAction->setEnabled( false );
+        }
+        
         toolBar->addAction( mShuffleAction );
 
         HbAction *action = new HbAction( actionsGroup );
         action->setIcon( HbIcon( "qtg_mono_previous" ) );
         action->setCheckable( false );
         connect( action, SIGNAL( triggered( bool ) ),
-                 mFrameworkWrapper, SLOT( skipBackward() ) );
+                 mMpEngine, SLOT( skipBackward() ) );
         toolBar->addAction( action );
 
         mPlayPauseAction = new HbAction( actionsGroup );
@@ -349,24 +364,28 @@
         mPlayPauseAction->setIcon( *mPlayIcon );
         mPlayPauseAction->setCheckable( false );
         connect( mPlayPauseAction, SIGNAL( triggered( bool ) ),
-                 mFrameworkWrapper, SLOT( playPause() ) );
+                 mMpEngine, SLOT( playPause() ) );
         toolBar->addAction( mPlayPauseAction );
 
         action = new HbAction( actionsGroup );
         action->setIcon( HbIcon( "qtg_mono_next" ) );
         action->setCheckable( false );
         connect( action, SIGNAL( triggered( bool ) ),
-                 mFrameworkWrapper, SLOT( skipForward() ) );
+                 mMpEngine, SLOT( skipForward() ) );
         toolBar->addAction( action );
 
         HbIcon icon( "qtg_mono_info" );
         action = new HbAction( actionsGroup );
         action->setIcon( icon );
         action->setCheckable( false );
-
-        connect( action, SIGNAL( triggered( bool ) ),
-                 this, SLOT( flip() ) );
-
+        //TODO: Remove once song details takes hostUid from engine
+        if ( mViewMode == MpCommon::DefaultView ) {
+            connect( action, SIGNAL( triggered( bool ) ),
+                     this, SLOT( flip() ) );
+        }
+        else {
+            action->setEnabled( false );
+        }
         toolBar->addAction( action );
     }
     else {
@@ -384,9 +403,11 @@
         mPlayPauseAction->setIcon( *mPlayIcon );
         mPlayPauseAction->setCheckable( false );
         connect( mPlayPauseAction, SIGNAL( triggered( bool ) ),
-                 mFrameworkWrapper, SLOT( playPause() ) );
+                 mMpEngine, SLOT( playPause() ) );
         toolBar->addAction( mPlayPauseAction );
     }
+    
+    
     TX_EXIT
 }
 
--- a/mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp	Mon May 03 12:29:20 2010 +0300
@@ -60,15 +60,13 @@
     mLayout->setMinimumSize( 0.0, 0.0 );
     setLayout( mLayout );
     bool widgetsOk = false;
-    bool layoutOk = false;
     mDocumentLoader = new HbDocumentLoader();
     HbMainWindow *mainWindow = hbInstance->allMainWindows()[0];
 
     if ( mDocumentLoader ) {
         mDocumentLoader->load( QString(":/playbackviewdocml/playbackwidget.docml"), &widgetsOk);
-        layoutOk = loadLayout( mainWindow->orientation() );
     }
-    if ( widgetsOk && layoutOk ) {
+    if ( widgetsOk ) {
         QGraphicsWidget *tmpWidgetPtr;
         tmpWidgetPtr = mDocumentLoader->findWidget(QString("playbackWidgetContainer"));
         tmpWidgetPtr->setParentItem(this);
@@ -90,12 +88,8 @@
     else {
         TX_LOG_ARGS("Error: invalid xml file.");
         Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget");
-        Q_ASSERT_X(layoutOk, "MpPlaybackWidget", "invalid xml file - layout");
     }
 
-    connect( mainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
-             this, SLOT(loadLayout(Qt::Orientation)) );
-
     connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) );
     connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) );
     connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) );
@@ -105,8 +99,7 @@
     connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) );
     connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) );
 
-    mCompositePixmap = QPixmap( 360, 360 );
-    mCompositePixmap.fill( Qt::transparent );
+
 
     TX_EXIT
 }
@@ -173,36 +166,14 @@
 void MpPlaybackWidget::albumArtChanged( )
 {
     TX_ENTRY
-    QPixmap pixmap;
-    mPlaybackData->albumArt( pixmap );
-    composeAlbumCover( pixmap );
+    HbIcon icon;
+    mPlaybackData->albumArt( icon );
 
-    QIcon qicon;
-    if ( !mCompositePixmap.isNull() ) {
-        qicon = QIcon( mCompositePixmap );
-    }
-    else {
-        qicon = QIcon( pixmap );
-    }
-    HbIcon icon( qicon );
+
     mAlbumArt->setIcon( icon );
     TX_EXIT
 }
 
-/*!
- Orientation change. Load layout based on the \a orientation.
- */
-bool MpPlaybackWidget::loadLayout( Qt::Orientation orientation )
-{
-    bool ret(false);
-    if ( orientation == Qt::Vertical ) {
-        mDocumentLoader->load(QString(":/playbackviewdocml/playbackwidget.docml"), "portrait", &ret);
-    }
-    else {
-        mDocumentLoader->load(QString(":/playbackviewdocml/playbackwidget.docml"), "landscape", & ret);
-    }
-    return ret;
-}
 
 /*!
  Slot to handle slider pressed.
@@ -262,17 +233,4 @@
     }
 }
 
-/*!
- Compose the album art.
- */
-void MpPlaybackWidget::composeAlbumCover( QPixmap& albumart )
-{
-    TX_ENTRY
-    mCompositePixmap.fill( Qt::transparent );
-    QPainter painter(&mCompositePixmap);
-    painter.setCompositionMode(QPainter::CompositionMode_Clear);
-    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
-    painter.fillRect(mCompositePixmap.rect(), Qt::transparent);
-    painter.drawPixmap(QRect(0, 0,360,360), albumart);
-    TX_EXIT
-}
+
--- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/inc/unittest_mpplaybackdata.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for MpPlaybackData
-*
-*/
-
-#ifndef TESTMPMPPLAYBACKDATA_H
-#define TESTMPMPPLAYBACKDATA_H
-
-#include <QtTest/QtTest>
-
-class MpPlaybackData;
-
-class TestMpPlaybackData : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    TestMpPlaybackData();
-    virtual ~TestMpPlaybackData();
-
-signals:
-
-
-public slots:
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-
-private slots:
-    void testConstructor();
-    void testSetDuration();
-    void testSetPosition();
-    void testSetTitle();
-    void testSetArtist();
-    void testSetAlbum();
-    void testSetUri();
-    void testSetAlbumArtUri();
-    void testThumbnailReady();
-    void testSetPlaybackState();
-    void testCommitPlaybackInfo();
-    
-//    void testDeactivateView();
-//    void testGetView();
-private:
-
-    MpPlaybackData          *mTest;
-
-};
-
-#endif  // TESTMPMPPLAYBACKDATA_H
--- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/src/unittest_mpplaybackdata.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,340 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Unit test for MpPlaybackData
-*
-*/
-
-#include <QSignalSpy>
-#include <qnamespace.h>
-#include <hbapplication.h>
-#include <hbmainwindow.h>
-#include <hbInstance.h>
-
-#include "unittest_mpplaybackdata.h"
-#include "stub/inc/thumbnailmanager_qt.h"
-
-
-// Do this so we can access all member variables.
-#define private public
-#include "mpplaybackdata.h"
-#undef private
-
-const int KUndefined = -1;
-
-/*!
- Make our test case a stand-alone executable that runs all the test functions.
- */
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-    TestMpPlaybackData tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\unittest_mpplaybackdata.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-TestMpPlaybackData::TestMpPlaybackData()
-    : mTest(0)
-{
-}
-
-TestMpPlaybackData::~TestMpPlaybackData()
-{
-    delete mTest;
-}
-
-/*!
- Called before the first testfunction is executed.
- */
-void TestMpPlaybackData::initTestCase()
-{
-}
-
-/*!
- Called after the last testfunction was executed.
- */
-void TestMpPlaybackData::cleanupTestCase()
-{
-}
-
-/*!
- Called before each testfunction is executed.
- */
-void TestMpPlaybackData::init()
-{
-    mTest = new MpPlaybackData();
-}
-
-/*!
- Called after every testfunction.
- */
-void TestMpPlaybackData::cleanup()
-{
-    delete mTest;
-    mTest = 0;
-}
-
-/*!
- testConstructor
- */
-void TestMpPlaybackData::testConstructor()
-{
-    QVERIFY(mTest->mThumbnailManager != 0);
-    QCOMPARE(mTest->mThumbnailManager->getInitCounter(), 1);
-    QVERIFY(mTest->mDuration == 0);
-    QVERIFY(mTest->mPosition == 0);
-    QVERIFY(!mTest->mDefaultAlbumArt);
-
-}
-
-/*!
- test setDuration and duration
- */
-void TestMpPlaybackData::testSetDuration()
-{
-    QSignalSpy spy(mTest, SIGNAL(durationChanged()));
-    for(int i= 0; i < 10; i++){
-        mTest->setDuration(i);
-        QCOMPARE(mTest->mDuration, i);
-        QCOMPARE(mTest->duration(),i);
-        QCOMPARE(spy.count(),i+1);
-    }
-}
-
-/*!
- test setPosition and position
- */
-void TestMpPlaybackData::testSetPosition()
-{
-    QSignalSpy spy(mTest, SIGNAL(positionChanged()));
-    for(int i= 0; i < 10; i++){
-        mTest->setPosition(i);
-        QCOMPARE(mTest->mPosition, i);
-        QCOMPARE(mTest->position(),i);
-        QCOMPARE(spy.count(),i+1);
-    }
-}
-
-/*!
- test setTitle and title
- */
-void TestMpPlaybackData::testSetTitle()
-{
-    bool changed;
-    
-    changed = mTest->setTitle(QString("Title 1"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mTitle, QString("Title 1"));
-    QCOMPARE(mTest->title(), QString("Title 1"));
-    changed = mTest->setTitle(QString("Title 1"));
-    QCOMPARE(changed, false);
-    QCOMPARE(mTest->title(), QString("Title 1"));
-    changed = mTest->setTitle(QString("Title 1"));
-    changed = mTest->setTitle(QString("Title 2"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mTitle, QString("Title 2"));
-    QCOMPARE(mTest->title(), QString("Title 2"));
-    
-}
-
-/*!
- test setArtist and artist
- */
-void TestMpPlaybackData::testSetArtist()
-{
-    bool changed;
-    
-    changed = mTest->setArtist(QString("Artist 1"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mArtist, QString("Artist 1"));
-    QCOMPARE(mTest->artist(), QString("Artist 1"));
-    changed = mTest->setArtist(QString("Artist 1"));
-    QCOMPARE(changed, false);
-    QCOMPARE(mTest->mArtist, QString("Artist 1"));
-    QCOMPARE(mTest->artist(), QString("Artist 1"));  
-    changed = mTest->setArtist(QString("Artist 2"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mArtist, QString("Artist 2"));
-    QCOMPARE(mTest->artist(), QString("Artist 2"));
-    
-}
-
-/*!
- test setAlbum and album
- */
-void TestMpPlaybackData::testSetAlbum()
-{
-    bool changed;
-    
-    changed = mTest->setAlbum(QString("Album 1"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mAlbum, QString("Album 1"));
-    QCOMPARE(mTest->album(), QString("Album 1"));
-    changed = mTest->setAlbum(QString("Album 1"));
-    QCOMPARE(changed, false);
-    QCOMPARE(mTest->mAlbum, QString("Album 1"));
-    QCOMPARE(mTest->album(), QString("Album 1"));
-    changed = mTest->setAlbum(QString("Album 2"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mAlbum, QString("Album 2"));
-    QCOMPARE(mTest->album(), QString("Album 2"));
-    
-}
-
-/*!
- test setUri and uri
- */
-void TestMpPlaybackData::testSetUri()
-{
-    bool changed;
-    
-    changed = mTest->setUri(QString("Uri 1"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mUri, QString("Uri 1"));
-    QCOMPARE(mTest->uri(), QString("Uri 1"));
-    changed = mTest->setUri(QString("Uri 1"));
-    QCOMPARE(changed, false);
-    QCOMPARE(mTest->mUri, QString("Uri 1"));
-    QCOMPARE(mTest->uri(), QString("Uri 1"));
-    changed = mTest->setUri(QString("Uri 2"));
-    QCOMPARE(changed, true);
-    QCOMPARE(mTest->mUri, QString("Uri 2"));
-    QCOMPARE(mTest->uri(), QString("Uri 2"));
-    
-}
-
-/*!
- test setAlbumArtUri
- */
-void TestMpPlaybackData::testSetAlbumArtUri()
-{
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady()));
-    //Empty string
-    mTest->setAlbumArtUri(QString(""));
-    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    //Request failed
-    mTest->mThumbnailManager->mGetThumbFails = true;
-    mTest->setAlbumArtUri(QString("AlbumArt"));
-    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    //Succesful requests
-    mTest->mThumbnailManager->mGetThumbFails = false;
-    for(int i = 1; i < 10; i++){
-        mTest->setAlbumArtUri(QString("AlbumArt"));
-        QCOMPARE(mTest->mReqId, i);
-        QCOMPARE(spy.count(),0);
-        mTest->mReqId = KUndefined;
-    }
-    
-    //Pending request
-    mTest->mReqId = 1;
-    for(int i = 1; i < 10; i++){
-        mTest->setAlbumArtUri(QString("AlbumArt"));
-        QCOMPARE(spy.count(),0);
-        QCOMPARE(mTest->mThumbnailManager->mCancelCounter, i);
-    }
-}
-
-/*!
- test ThumbnailReady and albumArt
- */
-void TestMpPlaybackData::testThumbnailReady()
-{
-    void* temp;
-    temp=0;
-    QSignalSpy spy(mTest, SIGNAL(albumArtReady()));
-    QPixmap albumArt(100,100);
-    QPixmap albumArt2;
-   
-    //Error
-    mTest->thumbnailReady(albumArt,temp,KUndefined,KUndefined);
-    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt); 
-    QCOMPARE(mTest->mReqId, KUndefined);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    //Wrong id
-    mTest->mReqId = 1;
-    mTest->thumbnailReady(albumArt,temp,KUndefined,0);
-    QCOMPARE(mTest->mAlbumArt, mTest->mDefaultAlbumArt); 
-    QCOMPARE(mTest->mReqId, KUndefined);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    //Update album art
-    mTest->mReqId = 1;
-    mTest->thumbnailReady(albumArt,temp,1,0);
-    QCOMPARE(mTest->mReqId, KUndefined);
-    QCOMPARE(spy.count(),1);
-    mTest->albumArt(albumArt2);
-    QCOMPARE(albumArt,albumArt2);
-}
-
-/*!
- test setPlaybackState and playbackState
- */
-void TestMpPlaybackData::testSetPlaybackState()
-{
-    QSignalSpy spy(mTest, SIGNAL(playbackStateChanged()));
-    
-    mTest->mPlaybackState = MpPlaybackData::Paused;
-    
-    mTest->setPlaybackState(MpPlaybackData::Playing);
-    QCOMPARE(mTest->playbackState(),MpPlaybackData::Playing);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    mTest->setPlaybackState(MpPlaybackData::Stopped);
-    QCOMPARE(mTest->playbackState(),MpPlaybackData::Stopped);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    mTest->setPlaybackState(MpPlaybackData::Paused);
-    QCOMPARE(mTest->playbackState(),MpPlaybackData::Paused);
-    QCOMPARE(spy.count(),1);
-    spy.clear();
-    
-    mTest->setPlaybackState(MpPlaybackData::Paused);
-    QCOMPARE(mTest->playbackState(),MpPlaybackData::Paused);
-    QCOMPARE(spy.count(),0);
-    
-}
-
-
-/*!
- test commitPlaybackInfo
- */
-void TestMpPlaybackData::testCommitPlaybackInfo()
-{
-    QSignalSpy spy(mTest, SIGNAL(playbackInfoChanged()));
-    
-    for(int i = 1; i < 10; i++){
-        mTest->commitPlaybackInfo();
-        QCOMPARE(spy.count(),i);
-    }
-}
-
-// End of file
--- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/stub/inc/thumbnailmanager_qt.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: ThumbnailManager stub for testing MpPlaybackData
-*
-*/
-
-#ifndef THUMBNAILMANAGER_QT_H
-#define THUMBNAILMANAGER_QT_H
-
-#include <qobject>
-#include <QPixmap.h>
-
-
-/** default priority value */
-const int tnmWrapperPriorityIdle = -100;
-
-class ThumbnailManager : public QObject
-    {
-    Q_OBJECT
-
-public:
-
-
-    /** Thumbnail size. */
-    enum ThumbnailSize
-    {
-        /**
-         * Small thumbnail
-         */
-        ThumbnailSmall = 0,
-        /**
-         * Medium thumbnail
-         */
-        ThumbnailMedium,
-        /**
-         * Large thumbnail
-         */
-        ThumbnailLarge
-    };
-
-    /** Mode of thumbnail creation. */
-    enum ThumbnailMode
-        {
-        /**
-         * Default mode. This means that:
-         * - Thumbnail must be as large as requested (unless the actual object is smaller).
-         * - Smaller thumbnails may be up scaled to desired resolution.
-         * - Aspect ratio is maintained and thumbnails are not cropped. The
-         *   resulting thumbnail may smaller in either width or height if
-         *   the aspect ratio of the object does not match the aspect ratio
-         *   of the requested size.
-         */
-        Default = 0,
-
-        /**
-         * Allow thumbnails which are smaller than requested are. Thumbnail
-         * bitmaps are never up scaled if this flag is set.
-         */
-        AllowAnySize = 1,
-
-        /**
-         * New thumbnail images are not created if this flag is set. Only
-         * existing thumbnails may be returned. If a requested thumbnail does
-         * not exist null pixmap will be returned.
-         */
-        DoNotCreate = 2,
-
-        /**
-         * Thumbnail images are cropped to match requested aspect ratio. If
-         * this mode is set, the size of the resulting thumbnail always
-         * matches the requested size.
-         */
-        CropToAspectRatio = 4
-    };
-
-    /**  Quality versus speed preference setting */
-    enum QualityPreference
-    {
-        /**
-         * Prefer thumbnails in the highest quality possible disregarding
-         * any negative impact on performance.
-         */
-        OptimizeForQuality,
-
-        /**
-         * Get thumbnails as fast as possible, even if
-         * it means lower quality.
-         */
-        OptimizeForPerformance
-    };
-
-    // Test utility functions
-    static int getInitCounter();
-    static void resetInitCounter();
-
-    // Stub functions
-    ThumbnailManager( QObject* parentPtr = NULL );
-    virtual ~ThumbnailManager();
-    bool setMode( ThumbnailMode mode );
-    bool setQualityPreference( QualityPreference qualityPreference );
-    bool setThumbnailSize( ThumbnailSize thumbnailSize );
-    int getThumbnail( const QString& fileName, void * clientData = NULL,
-            int priority = tnmWrapperPriorityIdle );
-    bool cancelRequest( int id );
-
-signals:
-
-    void thumbnailReady( QPixmap , void * , int , int );
-
-public:
-
-    bool    mGetThumbFails;
-    int     mThumbnailReqCounter;
-    int     mCancelCounter;
-
-};
-
-#endif // THUMBNAILMANAGER_QT
--- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/stub/src/thumbnailmanager_qt.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: ThumbnailManager stub for testing MpPlaybackData
-*
-*/
-
-#include <qsize.h>
-#include "stub/inc/thumbnailmanager_qt.h"
-
-int gInitCounter = 0;
-
-/*!
- Returns gInitCounter.
- gInitCounter counts the number of constructor/destructor calls.
- */
-int ThumbnailManager::getInitCounter()
-{
-    return gInitCounter;
-}
-
-/*!
- Resets gInitCounter to zero.
- */
-void ThumbnailManager::resetInitCounter()
-{
-    gInitCounter = 0;
-}
-
-/*!
- Stub function.
- */
-ThumbnailManager::ThumbnailManager( QObject* parentPtr ) :
-QObject( parentPtr ),
-mGetThumbFails(false),
-mThumbnailReqCounter(0),
-mCancelCounter(0)
-{
-    gInitCounter++;
-}
-
-/*!
- Stub function.
- */
-ThumbnailManager::~ThumbnailManager()
-{
-    gInitCounter--;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setMode( ThumbnailMode mode )
-{
-    Q_UNUSED(mode);
-    return true;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setQualityPreference( QualityPreference
-    qualityPreference )
-{
-    Q_UNUSED(qualityPreference);
-    return true;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::setThumbnailSize( ThumbnailSize thumbnailSize )
-{
-    Q_UNUSED(thumbnailSize);
-    return true;
-}
-
-/*!
- Stub function.
- */
-int ThumbnailManager::getThumbnail( const QString& fileName, void *clientData,
-        int priority )
-{
-    Q_UNUSED(fileName);
-    Q_UNUSED(priority);
-
-    if (clientData) {
-        // Delete this to prevent memory leak
-        int *data = (int *)clientData;
-        delete data;
-
-        data = 0;
-    }
-
-    if ( mGetThumbFails ) {
-        return -1;
-    }
-
-    mThumbnailReqCounter++;
-    return mThumbnailReqCounter;
-}
-
-/*!
- Stub function.
- */
-bool ThumbnailManager::cancelRequest( int id )
-{
-    Q_UNUSED(id);
-    mCancelCounter++;
-    return true;
-}
-
--- a/mpviewplugins/mpplaybackviewplugin/tsrc/unittest_mpplaybackdata/unittest_mpplaybackdata.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-TEMPLATE = app
-CONFIG += qtestlib hb
-TARGET = 
-
-DEPENDPATH += .
-INCLUDEPATH += . \
-	stub/inc \
-    ../../inc \
-    ../../../../inc
-
-
-    
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
-
-LIBS += -lestor.dll \
-    	-lfbscli.dll \
-				
-HEADERS += inc/unittest_mpplaybackdata.h \        
-           stub/inc/thumbnailmanager_qt.h \
-           ../../inc/mpplaybackdata.h 
-           
-               
-SOURCES += src/unittest_mpplaybackdata.cpp \
-		   ../../src/mpplaybackdata.cpp \
-           stub/src/thumbnailmanager_qt.cpp
--- a/mpviewplugins/mpsettingsviewplugin/inc/mpsettingsview.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/inc/mpsettingsview.h	Mon May 03 12:29:20 2010 +0300
@@ -18,7 +18,7 @@
 #ifndef MPSETTINGSVIEW_H
 #define MPSETTINGSVIEW_H
 
-#include <hbview.h>
+#include "mpviewbase.h"
 
 
 class HbAction;
@@ -26,7 +26,7 @@
 class MpSettingsAudioEffectsWidget;
 
 //class declaration
-class MpSettingsView : public HbView
+class MpSettingsView : public MpViewBase
 {
     Q_OBJECT
 
--- a/mpviewplugins/mpsettingsviewplugin/mpsettingsviewplugin.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/mpsettingsviewplugin.pro	Mon May 03 12:29:20 2010 +0300
@@ -39,7 +39,8 @@
 	
 symbian:TARGET.EPOCALLOWDLLDATA = 1
 
-HEADERS += inc/mpsettingsviewplugin.h \
+HEADERS += ../../inc/mpviewbase.h \
+      inc/mpsettingsviewplugin.h \
       inc/mpsettingsview.h \
       inc/mpsettingsaudioeffectswidget.h \
       inc/mpmpxasframeworkwrapper.h \
--- a/mpviewplugins/mpsettingsviewplugin/src/mpsettingsview.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/src/mpsettingsview.cpp	Mon May 03 12:29:20 2010 +0300
@@ -83,7 +83,6 @@
     }
 
     mWindow = mainWindow();
-    setTitle(hbTrId("txt_mus_title_music"));
     mSoftKeyBack = new HbAction(Hb::BackAction, this);
     mAudioEffectsWidget = new MpSettingsAudioEffectsWidget(this);
     mAudioEffectsWidget->initialize();
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/inc/unittest_mpmpxasframeworkwrapper.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/inc/unittest_mpmpxasframeworkwrapper.h	Mon May 03 12:29:20 2010 +0300
@@ -44,8 +44,10 @@
 private slots:
     void testConstructor();
     void testBalance();
+    void testLoudness();
     void testSetBalance();
-    void testPersistBalance();
+    void testSetLoudness();
+    
     
 private:
 
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/src/unittest_mpmpxasframeworkwrapper.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/src/unittest_mpmpxasframeworkwrapper.cpp	Mon May 03 12:29:20 2010 +0300
@@ -103,6 +103,12 @@
 {
     QVERIFY(mTestPrivate->iPlaybackUtility == 0);
     QVERIFY(mTestPrivate->iAudioEffectProperties != 0);
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoadFromFile, TBool(ETrue));
+    mTestPrivate->iAudioEffectProperties->iLeave = ETrue;
+    mTestPrivate->iAudioEffectProperties->LoadFromFileL();
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, 0);
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(EFalse));
+    
 }
 
 /*!
@@ -110,19 +116,22 @@
  */
 void TestMpMpxAsFrameworkWrapper::testBalance()
 {
-    for(TInt i = -10; i < 10; i++){
-        mTest->persistBalance(i);
-        QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, i);
-        QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
-        mTestPrivate->iAudioEffectProperties->iSaveToFile = EFalse;
-        QCOMPARE(mTest->balance(), i);
-        QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoadFromFile, TBool(ETrue));
-        mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
-    }
-    mTestPrivate->iAudioEffectProperties->iLeave = ETrue;
-    QCOMPARE(mTest->balance(),0);
+    QCOMPARE( mTest->balance(), 0 );
+    mTest->setBalance( -100 );
+    QCOMPARE( mTest->balance(), -100 );
+    mTest->setBalance( 100 );
+    QCOMPARE( mTest->balance(), 100 );
 }
 
+/*!
+ test loudness
+ */
+void TestMpMpxAsFrameworkWrapper::testLoudness()
+{
+    QCOMPARE(mTest->loudness(), false);
+    mTest->setLoudness(true);
+    QCOMPARE(mTest->loudness(), true);
+}
 
 /*!
  test setBalance
@@ -133,22 +142,34 @@
         mTest->setBalance(i);
         QVERIFY(mTestPrivate->iPlaybackUtility != 0);
         QCOMPARE(mTestPrivate->iPlaybackUtility->iProperty, EPbPropertyBalance);
-        QCOMPARE(mTestPrivate->iPlaybackUtility->iBalance, i);        
+        QCOMPARE(mTestPrivate->iPlaybackUtility->iBalance, i);   
+        QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, i);
+        QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
+        mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
+        
     }   
 }
 
 /*!
- test persistBalance
+ test setLoudness   
  */
-void TestMpMpxAsFrameworkWrapper::testPersistBalance()
-{
-    for(TInt i = -10; i < 10; i++){
-        mTest->persistBalance(i);
-        QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, i);
-        QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
-        mTestPrivate->iAudioEffectProperties->iSaveToFile = EFalse;
-    }   
+void TestMpMpxAsFrameworkWrapper::testSetLoudness()
+{   
+    mTest->setLoudness(true);
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iCommand, EPbApplyEffect );
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iEffectId, 0x101FFC02 );
+    mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
+    mTest->setLoudness(false);
+    QVERIFY(mTestPrivate->iPlaybackUtility != 0);
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(EFalse));
+    QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iCommand, EPbApplyEffect );
+    QCOMPARE(mTestPrivate->iPlaybackUtility->iEffectId, 0x101FFC02 );
+    mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
 }
-    
+
     
 // end of file
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxaudioeffectproperties.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxaudioeffectproperties.h	Mon May 03 12:29:20 2010 +0300
@@ -34,7 +34,9 @@
     
     // Stub functions
     TInt Balance();
+    TBool Loudness();
     void SetBalance(TInt aBalance);
+    void SetLoudness(TBool aLoudness);
     void Reset();
     void SaveToFileL();
     void LoadFromFileL();
@@ -42,6 +44,7 @@
 public:
     
     TInt    iBalance;
+    TBool   iLoudness;
     TBool   iLoadFromFile;
     TBool   iSaveToFile;
     TBool   iLeave;
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxplaybackutility.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/inc/mpxplaybackutility.h	Mon May 03 12:29:20 2010 +0300
@@ -36,10 +36,13 @@
     static MMPXPlaybackUtility* UtilityL(const TUid& aModeId = KPbModeDefault);
     void Close();
     void SetL(TMPXPlaybackProperty aProperty, TInt aValue);
+    void CommandL(TMPXPlaybackCommand aCmd, TInt aData=0);
 
 public:
     TInt                    iBalance;
+    TInt                    iEffectId;
     TMPXPlaybackProperty    iProperty;
+    TMPXPlaybackCommand     iCommand;
 
 };
 
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxaudioeffectproperties.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxaudioeffectproperties.cpp	Mon May 03 12:29:20 2010 +0300
@@ -26,9 +26,11 @@
  Stub function.
 */
 CMPXAudioEffectProperties::CMPXAudioEffectProperties():iBalance(0),
+                                                       iLoudness(EFalse),
                                                        iLoadFromFile(EFalse),
                                                        iSaveToFile(EFalse),
                                                        iLeave(EFalse)
+                                                       
 {
 }
 
@@ -50,6 +52,14 @@
 /*!
  Stub function.
 */
+TBool CMPXAudioEffectProperties::Loudness()
+{
+    return iLoudness;
+}
+
+/*!
+ Stub function.
+*/
 void CMPXAudioEffectProperties::SetBalance(TInt aBalance)
 {
     iBalance = aBalance;
@@ -58,10 +68,21 @@
 /*!
  Stub function.
 */
+void CMPXAudioEffectProperties::SetLoudness(TBool aLoudness)
+{
+    iLoudness = aLoudness;
+}
+
+/*!
+ Stub function.
+*/
 void CMPXAudioEffectProperties::Reset()
 {
     MPX_DEBUG1("CMPXAudioEffectProperties::Reset");
     iBalance = 0;
+    iLoudness = EFalse;
+    iLeave = EFalse;
+    iLoadFromFile = EFalse;
 }
 
 /*!
@@ -81,7 +102,7 @@
 {
     MPX_DEBUG1("CMPXAudioEffectProperties::LoadFromFileL <---");
     if(iLeave){
-        User::Leave(KErrNotFound);
+        Reset();
     }else{
         iLoadFromFile = ETrue;
     }
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxplaybackutility.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/stub/src/mpxplaybackutility.cpp	Mon May 03 12:29:20 2010 +0300
@@ -24,8 +24,9 @@
 /*!
  Stub function.
 */
-MMPXPlaybackUtility::MMPXPlaybackUtility():iProperty(EPbPropertyVolume),
-                                           iBalance(0)
+MMPXPlaybackUtility::MMPXPlaybackUtility():iBalance(0),
+                                            iProperty(EPbPropertyVolume)
+                                           
 {
 }
 
@@ -62,4 +63,13 @@
     iBalance = aValue;
 }
 
+/*!
+ Stub function.
+*/
+void MMPXPlaybackUtility::CommandL(TMPXPlaybackCommand aCmd, TInt aData)
+{
+    iCommand = aCmd;
+    iEffectId = aData;
+}
+
 //end of file
--- a/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/unittest_mpmpxasframeworkwrapper.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/unittest_mpmpxasframeworkwrapper.pro	Mon May 03 12:29:20 2010 +0300
@@ -22,7 +22,7 @@
 INCLUDEPATH += . \
     ../../inc \
     ../../../../inc \
-    
+    ../../../../mpserviceplugins/inc
 
     
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
--- a/musicfetcher/bwins/musicfetcheru.def	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-EXPORTS
-	?qt_metacast@MusicFetcher@@UAEPAXPBD@Z @ 1 NONAME ; void * MusicFetcher::qt_metacast(char const *)
-	?qt_metacall@MusicFetcher@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 2 NONAME ; int MusicFetcher::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?tr@MusicFetcher@@SA?AVQString@@PBD0@Z @ 3 NONAME ; class QString MusicFetcher::tr(char const *, char const *)
-	?contextTitle@MusicFetcher@@QBE?AVQString@@XZ @ 4 NONAME ; class QString MusicFetcher::contextTitle(void) const
-	?getStaticMetaObject@MusicFetcher@@SAABUQMetaObject@@XZ @ 5 NONAME ; struct QMetaObject const & MusicFetcher::getStaticMetaObject(void)
-	?staticMetaObject@MusicFetcher@@2UQMetaObject@@B @ 6 NONAME ; struct QMetaObject const MusicFetcher::staticMetaObject
-	??_EMusicFetcher@@UAE@I@Z @ 7 NONAME ; MusicFetcher::~MusicFetcher(unsigned int)
-	?itemSelected@MusicFetcher@@QAEXVQString@@@Z @ 8 NONAME ; void MusicFetcher::itemSelected(class QString)
-	?titleReady@MusicFetcher@@IAEXABVQString@@@Z @ 9 NONAME ; void MusicFetcher::titleReady(class QString const &)
-	??1MusicFetcher@@UAE@XZ @ 10 NONAME ; MusicFetcher::~MusicFetcher(void)
-	?trUtf8@MusicFetcher@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString MusicFetcher::trUtf8(char const *, char const *, int)
-	?trUtf8@MusicFetcher@@SA?AVQString@@PBD0@Z @ 12 NONAME ; class QString MusicFetcher::trUtf8(char const *, char const *)
-	?metaObject@MusicFetcher@@UBEPBUQMetaObject@@XZ @ 13 NONAME ; struct QMetaObject const * MusicFetcher::metaObject(void) const
-	?tr@MusicFetcher@@SA?AVQString@@PBD0H@Z @ 14 NONAME ; class QString MusicFetcher::tr(char const *, char const *, int)
-	??0MusicFetcher@@QAE@XZ @ 15 NONAME ; MusicFetcher::MusicFetcher(void)
-
--- a/musicfetcher/eabi/musicfetcheru.def	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-EXPORTS
-	_ZN12MusicFetcher10titleReadyERK7QString @ 1 NONAME
-	_ZN12MusicFetcher11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME
-	_ZN12MusicFetcher11qt_metacastEPKc @ 3 NONAME
-	_ZN12MusicFetcher12itemSelectedE7QString @ 4 NONAME
-	_ZN12MusicFetcher16staticMetaObjectE @ 5 NONAME DATA 16
-	_ZN12MusicFetcher19getStaticMetaObjectEv @ 6 NONAME
-	_ZN12MusicFetcherC1Ev @ 7 NONAME
-	_ZN12MusicFetcherC2Ev @ 8 NONAME
-	_ZN12MusicFetcherD0Ev @ 9 NONAME
-	_ZN12MusicFetcherD1Ev @ 10 NONAME
-	_ZN12MusicFetcherD2Ev @ 11 NONAME
-	_ZNK12MusicFetcher10metaObjectEv @ 12 NONAME
-	_ZNK12MusicFetcher12contextTitleEv @ 13 NONAME
-	_ZTI12MusicFetcher @ 14 NONAME
-	_ZTV12MusicFetcher @ 15 NONAME
-
--- a/musicfetcher/inc/musicfetcher.h	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Music Fetcher interface.
-*
-*/
-
-#ifndef MUSICFETCHER_H
-#define MUSICFETCHER_H
-
-#include <xqserviceprovider.h>
-#include <QStringList>
-
-// Forward declarations
-class GetMusicService;
-
-#if defined(BUILD_MUSICFETCHER_LIB)
-#define MUSICFETCHER_EXPORT Q_DECL_EXPORT
-#else
-#define MUSICFETCHER_EXPORT Q_DECL_IMPORT
-#endif
-
-/**
- *  MusicFetcher
- *
- */
-class MUSICFETCHER_EXPORT MusicFetcher : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    /**
-     * Constructor
-     */
-    MusicFetcher();
-
-    /**
-     * Destructor.
-     */
-    ~MusicFetcher();
-
-    QString contextTitle() const;
-
-public slots:
-    void itemSelected(QString songName);
-
-signals:
-    void titleReady(const QString& title);
-
-private:
-
-    GetMusicService *mService;
-    friend class GetMusicService;
-};
-
-/**
- *  GetMusicService
- *
- */
-class GetMusicService : public XQServiceProvider
-{
-    Q_OBJECT
-public:
-    GetMusicService( MusicFetcher *parent = 0 );
-    ~GetMusicService();
-    bool isActive();
-    void complete( QStringList filesList);
-    QString contextTitle() const;
-
-public slots:
-    void fetch(QString title);
-
-private:
-    void doComplete( QStringList filesList);
-
-private:
-    int mRequestIndex;
-    MusicFetcher* mServiceApp;
-    QString mTitle;
-};
-
-#endif // MUSICFETCHER_H
--- a/musicfetcher/musicfetcher.pro	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: Project file for Music Fetcher.
-#
-
-symbian:TARGET.UID3 = 0x10207C69
-
-TEMPLATE = lib
-CONFIG += hb
-TARGET = musicfetcher
-
-TARGET.CAPABILITY = CAP_GENERAL_DLL
-
-INCLUDEPATH += . \
-    	inc \
-    	../inc
-INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
-
-LIBS += -lxqservice
-
-symbian:TARGET.EPOCALLOWDLLDATA	= 1
-
-HEADERS += inc/musicfetcher.h
-
-SOURCES += src/musicfetcher.cpp
-    
-DEFINES += BUILD_MUSICFETCHER_LIB
-
-myDefInclude = "NOSTRICTDEF" \
-"$${LITERAL_HASH}if defined(WINS)"\
-"DEFFILE  bwins/musicfetcheru.def "\
-"$${LITERAL_HASH}else "\
-"DEFFILE  eabi/musicfetcheru.def "\
-"$${LITERAL_HASH}endif"
-MMP_RULES += myDefInclude
--- a/musicfetcher/rom/musicfetcher.iby	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
-#ifndef __MUSICFETCHER_IBY__
-#define __MUSICFETCHER_IBY__
-
-#include <bldvariant.hrh>
-
-file=ABI_DIR\BUILD_DIR\musicfetcher.dll          SHARED_LIB_DIR\musicfetcher.dll
-
-#endif
\ No newline at end of file
--- a/musicfetcher/rom/rom.pri	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-symbian {
-MP_IBY_DIR = $$section(PWD,":",1)
-
-BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/musicfetcher.iby CORE_APP_LAYER_IBY_EXPORT_PATH(musicfetcher.iby)"
-}
\ No newline at end of file
--- a/musicfetcher/src/musicfetcher.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include <hbapplication.h>
-#include <qstringlist.h>
-
-#include "musicfetcher.h"
-#include "mptrace.h"
-
-/*!
-    \class MusicFetcher
-    \brief Music fecther service.
-
-    Music fetcher implements fetching of music uris via service provider API.
-*/
-
-// ----------------------------------------------------------------------------
-// Constructs the music fetcher.
-// ----------------------------------------------------------------------------
-//
-MusicFetcher::MusicFetcher()
-{
-    TX_ENTRY
-    mService = new GetMusicService(this);
-    TX_EXIT
-}
-
-// ----------------------------------------------------------------------------
-// Destructs the music fetcher.
-// ----------------------------------------------------------------------------
-//
-MusicFetcher::~MusicFetcher()
-{
-    TX_ENTRY
-    delete mService;
-    TX_EXIT
-}
-
-// ----------------------------------------------------------------------------
-// Returns a string to show in music fetcher application title.
-// ----------------------------------------------------------------------------
-//
-QString MusicFetcher::contextTitle() const
-{
-    return mService->contextTitle();
-}
-
-// ----------------------------------------------------------------------------
-// Slot to be called when music item has been selected.
-// ----------------------------------------------------------------------------
-//
-void MusicFetcher::itemSelected(QString songName)
-{
-    TX_ENTRY_ARGS("songName: " << songName);
-    QStringList list;
-    list.append(songName);
-    mService->complete( list );
-}
-
-// ----------------------------------------------------------------------------
-// Constructs the music service.
-// ----------------------------------------------------------------------------
-//
-GetMusicService::GetMusicService(MusicFetcher* parent)
-    : XQServiceProvider(QLatin1String("Music Fetcher.com.nokia.services.media.Music"), parent),
-    mRequestIndex(0),
-    mServiceApp(parent)
-{
-    TX_ENTRY
-    publishAll();
-    TX_EXIT
-}
-
-// ----------------------------------------------------------------------------
-// Destructs the music service.
-// ----------------------------------------------------------------------------
-//
-GetMusicService::~GetMusicService()
-{
-    TX_LOG
-}
-
-// ----------------------------------------------------------------------------
-// Completes the service request.
-// ----------------------------------------------------------------------------
-//
-void GetMusicService::complete(QStringList filesList)
-{
-    doComplete(filesList);
-}
-
-// ----------------------------------------------------------------------------
-// Completes the service request.
-// ----------------------------------------------------------------------------
-//
-void GetMusicService::doComplete(QStringList filesList)
-{
-    if ( isActive() ) {
-        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
-        completeRequest(mRequestIndex, filesList);
-        mRequestIndex=0;
-    }
-}
-
-// ----------------------------------------------------------------------------
-// Returns title set by service client.
-// ----------------------------------------------------------------------------
-//
-QString GetMusicService::contextTitle() const
-{
-    return mTitle;
-}
-
-// ----------------------------------------------------------------------------
-// Returns indication whether service request still active.
-// ----------------------------------------------------------------------------
-//
-bool GetMusicService::isActive()
-{
-    return mRequestIndex > 0;
-}
-
-/*!
-    Music Fetcher service interface defined in service registration xml.
-    Service client needs to create a request using interface name
-    "com.nokia.services.media.Music" and set string to show in
-    opened views title as a request argument.
-
-    Example usage:
-    \code
-    XQApplicationManager appMgr;
-    XQAiwRequest* req = appMgr.create("com.nokia.services.media.Music",
-        "fetch(QString)", true);
-
-    if (req)
-    {
-        connect(req, SIGNAL(requestOk(const QVariant&)),
-            SLOT(handleRequestOk(const QVariant&)));
-        connect(req, SIGNAL(requestError(int,const QString&)),
-            SLOT(handleRequestError(int,const QString&)));
-
-        // Set argument for request (title for opened views)
-        QList<QVariant> args;
-        args << QVariant(QString("<title to show>"));
-        req->setArguments(args);
-
-        // Make the request
-        if (!req->send())
-        {
-            qDebug() <<  "Failed to send REQ";
-        }
-        delete req;
-    }
-    \endcode
- */
-void GetMusicService::fetch(QString title)
-{
-    TX_ENTRY_ARGS("title: " << title);
-    mTitle = title;
-    emit mServiceApp->titleReady(title);
-    mRequestIndex = setCurrentRequestAsync();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/bwins/musicservices.def	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,21 @@
+EXPORTS
+	?currentService@MusicServices@@QAE?AW4MusicService@1@XZ @ 1 NONAME ; enum MusicServices::MusicService MusicServices::currentService(void)
+	?trUtf8@MusicServices@@SA?AVQString@@PBD0@Z @ 2 NONAME ; class QString MusicServices::trUtf8(char const *, char const *)
+	?qt_metacast@MusicServices@@UAEPAXPBD@Z @ 3 NONAME ; void * MusicServices::qt_metacast(char const *)
+	?trUtf8@MusicServices@@SA?AVQString@@PBD0H@Z @ 4 NONAME ; class QString MusicServices::trUtf8(char const *, char const *, int)
+	?qt_metacall@MusicServices@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 5 NONAME ; int MusicServices::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?contextTitle@MusicServices@@QBE?AVQString@@XZ @ 6 NONAME ; class QString MusicServices::contextTitle(void) const
+	??0MusicServices@@QAE@XZ @ 7 NONAME ; MusicServices::MusicServices(void)
+	??_EMusicServices@@UAE@I@Z @ 8 NONAME ; MusicServices::~MusicServices(unsigned int)
+	?itemSelected@MusicServices@@QAEXVQString@@@Z @ 9 NONAME ; void MusicServices::itemSelected(class QString)
+	?playReady@MusicServices@@IAEXABVXQSharableFile@@@Z @ 10 NONAME ; void MusicServices::playReady(class XQSharableFile const &)
+	?tr@MusicServices@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString MusicServices::tr(char const *, char const *, int)
+	?tr@MusicServices@@SA?AVQString@@PBD0@Z @ 12 NONAME ; class QString MusicServices::tr(char const *, char const *)
+	?getStaticMetaObject@MusicServices@@SAABUQMetaObject@@XZ @ 13 NONAME ; struct QMetaObject const & MusicServices::getStaticMetaObject(void)
+	?serviceActive@MusicServices@@IAEXVTUid@@@Z @ 14 NONAME ; void MusicServices::serviceActive(class TUid)
+	?metaObject@MusicServices@@UBEPBUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const * MusicServices::metaObject(void) const
+	?setCurrentService@MusicServices@@QAEXW4MusicService@1@@Z @ 16 NONAME ; void MusicServices::setCurrentService(enum MusicServices::MusicService)
+	?staticMetaObject@MusicServices@@2UQMetaObject@@B @ 17 NONAME ; struct QMetaObject const MusicServices::staticMetaObject
+	??1MusicServices@@UAE@XZ @ 18 NONAME ; MusicServices::~MusicServices(void)
+	?playReady@MusicServices@@IAEXABVQString@@@Z @ 19 NONAME ; void MusicServices::playReady(class QString const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/eabi/musicservices.def	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,21 @@
+EXPORTS
+	_ZN13MusicServices11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME
+	_ZN13MusicServices11qt_metacastEPKc @ 2 NONAME
+	_ZN13MusicServices12itemSelectedE7QString @ 3 NONAME
+	_ZN13MusicServices13serviceActiveE4TUid @ 4 NONAME
+	_ZN13MusicServices14currentServiceEv @ 5 NONAME
+	_ZN13MusicServices16staticMetaObjectE @ 6 NONAME DATA 16
+	_ZN13MusicServices17setCurrentServiceENS_12MusicServiceE @ 7 NONAME
+	_ZN13MusicServices19getStaticMetaObjectEv @ 8 NONAME
+	_ZN13MusicServices9playReadyERK14XQSharableFile @ 9 NONAME
+	_ZN13MusicServices9playReadyERK7QString @ 10 NONAME
+	_ZN13MusicServicesC1Ev @ 11 NONAME
+	_ZN13MusicServicesC2Ev @ 12 NONAME
+	_ZN13MusicServicesD0Ev @ 13 NONAME
+	_ZN13MusicServicesD1Ev @ 14 NONAME
+	_ZN13MusicServicesD2Ev @ 15 NONAME
+	_ZNK13MusicServices10metaObjectEv @ 16 NONAME
+	_ZNK13MusicServices12contextTitleEv @ 17 NONAME
+	_ZTI13MusicServices @ 18 NONAME
+	_ZTV13MusicServices @ 19 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/inc/getmusicservice.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: GetMusic Service interface.
+*
+*/
+
+#ifndef GETMUSICSERVICE_H
+#define GETMUSICSERVICE_H
+
+#include <xqserviceprovider.h>
+#include <QStringList>
+
+// Forward declarations
+class MusicServices;
+
+/**
+ *  GetMusicService
+ *
+ */
+class GetMusicService : public XQServiceProvider
+{
+    Q_OBJECT
+public:
+    GetMusicService( MusicServices *parent = 0 );
+    ~GetMusicService();
+    bool isActive();
+    void complete( QStringList filesList );
+    QString contextTitle() const;
+
+public slots:
+    void fetch();
+
+private:
+    int             mRequestIndex;
+    MusicServices   *mServiceApp;
+    QString         mTitle;
+};
+
+
+
+#endif // GETMUSICSERVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/inc/musicservices.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Services interface.
+*
+*/
+
+#ifndef MUSICSERVICES_H
+#define MUSICSERVICES_H
+
+#include <xqserviceprovider.h>
+#include <QStringList>
+
+
+// Forward declarations
+class GetMusicService;
+class PlayMusicService;
+class XQSharableFile;
+
+#if defined(BUILD_MUSICSERVICES_LIB)
+#define MUSICSERVICES_EXPORT Q_DECL_EXPORT
+#else
+#define MUSICSERVICES_EXPORT Q_DECL_IMPORT
+#endif
+
+
+class MUSICSERVICES_EXPORT MusicServices : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    /*
+     * Enum reflecting the services provided 
+     */
+    enum MusicService
+    {
+        ENoService,
+        EUriFetcher,
+        EPlayback
+    };
+
+    MusicServices();
+    ~MusicServices();   
+    QString contextTitle() const;
+    MusicServices::MusicService currentService();
+    void setCurrentService( MusicServices::MusicService service );
+
+public slots:
+
+    void itemSelected( QString songName );
+
+signals:
+
+    void playReady( const QString& aFileName );
+    void playReady( const XQSharableFile& file );
+    void serviceActive( TUid hostUid );
+
+private:
+    
+    GetMusicService                 *mFetchService;
+    PlayMusicService                *mPlayService;
+    MusicServices::MusicService     mCurrentService;
+    
+    friend class GetMusicService;
+    friend class PlayMusicService;
+};
+
+#endif // MUSICSERVICES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/inc/playmusicservice.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: PlayMusic Service interface.
+*
+*/
+
+#ifndef PLAYMUSICSERVICE_H
+#define PLAYMUSICSERVICE_H
+
+#include <xqserviceprovider.h>
+#include <xqsharablefile.h>
+#include <QStringList>
+
+// Forward declarations
+class MusicServices;
+
+/**
+ *  PlayMusicService
+ *
+ */
+
+class PlayMusicService : public XQServiceProvider
+{
+    Q_OBJECT
+
+public:
+    
+    PlayMusicService( MusicServices* parent = 0);
+    ~PlayMusicService();
+    bool isActive();
+    void complete( QStringList filesList );
+    QString contextTitle() const;
+    
+public slots:
+    
+    bool view(const QString& file);
+    bool view(const XQSharableFile& file);
+    
+private:
+    int             mRequestIndex;
+    MusicServices   *mServiceApp;
+    QString         mTitle;
+};
+
+
+
+#endif // PLAYMUSICSERVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/musicservices.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Project file for Music Services.
+#
+
+symbian:TARGET.UID3 = 0x10207C69
+
+TEMPLATE = lib
+CONFIG += hb
+TARGET = musicservices
+
+TARGET.CAPABILITY = CAP_GENERAL_DLL
+
+INCLUDEPATH += . \
+    	inc \
+    	../inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
+
+LIBS += -lxqservice \
+        -lxqserviceutil
+
+symbian:TARGET.EPOCALLOWDLLDATA	= 1
+
+HEADERS += inc/musicservices.h \
+		   inc/getmusicservice.h \
+		   inc/playmusicservice.h 
+
+SOURCES += src/musicservices.cpp \
+		   src/getmusicservice.cpp \
+		   src/playmusicservice.cpp
+    
+DEFINES += BUILD_MUSICSERVICES_LIB
+
+myDefInclude = "NOSTRICTDEF" \
+"$${LITERAL_HASH}if defined(WINS)"\
+"DEFFILE  bwins/musicservices.def "\
+"$${LITERAL_HASH}else "\
+"DEFFILE  eabi/musicservices.def "\
+"$${LITERAL_HASH}endif"
+MMP_RULES += myDefInclude
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/rom/musicservices.iby	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __MUSICSERVICES_IBY__
+#define __MUSICSERVICES_IBY__
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\musicservices.dll          SHARED_LIB_DIR\musicservices.dll
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/rom/rom.pri	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+symbian {
+MP_IBY_DIR = $$section(PWD,":",1)
+
+BLD_INF_RULES.prj_exports += "$$MP_IBY_DIR/musicservices.iby CORE_APP_LAYER_IBY_EXPORT_PATH(musicservices.iby)"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/src/getmusicservice.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <hbapplication.h>
+#include <qstringlist.h>
+
+#include "musicservices.h"
+#include "getmusicservice.h"
+#include "mptrace.h"
+
+
+
+
+/*!
+ Constructs music fetcher service
+ */
+GetMusicService::GetMusicService( MusicServices* parent )
+    : XQServiceProvider( QLatin1String( "musicplayer.com.nokia.symbian.IMusicFetch" ), parent ),
+    mRequestIndex( 0 ),
+    mServiceApp( parent )
+{
+    TX_ENTRY
+    publishAll();
+    TX_EXIT
+}
+
+/*!
+ Destructs music fetcher service
+ */
+GetMusicService::~GetMusicService()
+{
+    TX_LOG
+}
+
+/*!
+ Returns whether current service is still active
+ */
+bool GetMusicService::isActive()
+{
+    return mRequestIndex > 0;
+}
+
+/*!
+ Completes current request 
+ */
+void GetMusicService::complete(QStringList filesList)
+{
+    if ( isActive() ) {
+        connect( this, SIGNAL( returnValueDelivered() ), qApp, SLOT( quit() ) );
+        completeRequest( mRequestIndex, filesList );
+        mRequestIndex = 0;
+    }
+}
+
+/*!
+ Returns title of calling application
+ */
+QString GetMusicService::contextTitle() const
+{
+    return mTitle;
+}
+
+
+/*!
+    Music Fetcher service interface defined in service registration xml.
+    Service client needs to create a request using interface name
+    "com.nokia.services.media.Music" and set string to show in
+    opened views title as a request argument.
+
+    Example usage:
+    \code
+    XQApplicationManager appMgr;
+    XQAiwRequest* req = appMgr.create("com.nokia.services.media.IMusicFetch",
+        "fetch(QString)", true);
+
+    if (req)
+    {
+        connect(req, SIGNAL(requestOk(const QVariant&)),
+            SLOT(handleRequestOk(const QVariant&)));
+        connect(req, SIGNAL(requestError(int,const QString&)),
+            SLOT(handleRequestError(int,const QString&)));
+
+        // Set argument for request (title for opened views)
+        QList<QVariant> args;
+        args << QVariant(QString("<title to show>"));
+        req->setArguments(args);
+
+        // Make the request
+        if (!req->send())
+        {
+            qDebug() <<  "Failed to send REQ";
+        }
+        delete req;
+    }
+    \endcode
+ */
+void GetMusicService::fetch()
+{
+    TX_ENTRY
+   //TODO: change to string constant when available
+    mTitle = requestInfo().info("WindowTitle").toString();
+    mServiceApp->setCurrentService( MusicServices::EUriFetcher );
+    TUid uid = TUid::Uid( requestInfo().clientSecureId() ); 
+    emit mServiceApp->serviceActive( uid );
+    connect(this, SIGNAL( clientDisconnected() ), qApp, SLOT( quit() ) );
+    mRequestIndex = setCurrentRequestAsync();
+ 
+    TX_EXIT
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/src/musicservices.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <hbapplication.h>
+#include <qstringlist.h>
+
+#include "musicservices.h"
+#include "getmusicservice.h"
+#include "playmusicservice.h"
+#include "mptrace.h"
+
+/*!
+    \class MusicServices
+    \brief Music services available.
+
+    MusicServices implements fetching of music URIs via service provider API and embedded playback.
+*/
+
+/*!
+    \fn void playReady( const QString& aFileName )
+
+    This signal is emitted when the play service has been loaded and playback of aFilenName should start
+
+ */
+
+/*!
+    \fn void playReady( const XQSharableFile& file )
+
+    This signal is emitted when the play service has been loaded and playback of file handle should start
+
+ */
+
+/*!
+    \fn void serviceActive()
+
+    This signal is emitted when the requested service has been detected and view initialization should continue
+
+ */
+
+/*!
+ Constructs music services
+ */
+MusicServices::MusicServices() : 
+        mCurrentService( MusicServices::ENoService )
+{
+    TX_ENTRY
+    mFetchService = new GetMusicService( this );
+    mPlayService = new PlayMusicService( this );
+    TX_EXIT
+}
+
+/*!
+ Destruct music services
+ */
+MusicServices::~MusicServices()
+{
+    TX_ENTRY
+    delete mFetchService;
+    delete mPlayService;
+    TX_EXIT
+}
+
+/*!
+ Gets current active service
+ */
+MusicServices::MusicService MusicServices::currentService()
+{
+    return mCurrentService;
+}
+
+/*!
+ Sets current active service
+ */
+void MusicServices::setCurrentService( MusicServices::MusicService service )
+{
+    mCurrentService = service;
+}
+
+/*!
+ Returns service context title
+ */
+QString MusicServices::contextTitle() const
+{
+
+    if( mCurrentService == MusicServices::EUriFetcher ) {
+        return mFetchService->contextTitle();
+    }
+    else if ( mCurrentService == MusicServices::EPlayback ) {
+        return mPlayService->contextTitle();
+    }
+    else {
+        Q_ASSERT_X(false, "MusicServices::contexTitle", "undefined service");
+        return QString();
+    }
+    
+    
+}
+
+/*!
+ Slot to be called when service is to be completed with selected item \songName
+ */
+void MusicServices::itemSelected( QString songName )
+{
+    TX_ENTRY_ARGS("songName: " << songName);
+    QStringList list;
+    list.append( songName );
+    if ( mCurrentService == MusicServices::EUriFetcher ) {
+        mFetchService->complete( list );
+    }
+    else if ( mCurrentService == MusicServices::EPlayback ) {
+        mPlayService->complete( list );
+    }
+    
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/src/playmusicservice.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <hbapplication.h>
+#include <qstringlist.h>
+
+#include "musicservices.h"
+#include "playmusicservice.h"
+#include "mptrace.h"
+
+
+
+
+/*!
+ Constructs play music service
+ */
+PlayMusicService::PlayMusicService( MusicServices* parent )
+: XQServiceProvider(QLatin1String("musicplayer.com.nokia.symbian.IFileView"), parent),
+  mRequestIndex( 0 ),
+  mServiceApp( parent )
+{
+    TX_ENTRY
+    publishAll();
+    TX_EXIT
+}
+
+/*!
+ Destructs play music service
+ */
+PlayMusicService::~PlayMusicService()
+{
+    TX_LOG
+}
+
+
+/*!
+ Returns whether current service is still active
+ */
+bool PlayMusicService::isActive()
+{
+    return mRequestIndex > 0;
+}
+
+/*!
+ Completes current request 
+ */
+void PlayMusicService::complete(QStringList filesList)
+{   TX_ENTRY_ARGS("EmbeddeddoComplete: ");
+    if ( isActive() ) {
+        TX_ENTRY_ARGS("EmbeddeddoComplete2: ");
+        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+        completeRequest(mRequestIndex, filesList);
+        mRequestIndex=0;
+    }
+}
+
+/*!
+ Returns title of calling application
+ */
+QString PlayMusicService::contextTitle() const
+{
+    return mTitle;
+}
+
+/*!
+    Embedded Playback service interface defined in service registration xml.
+
+    Example usage:
+    
+    QFile file("c:\\audio.mp3");
+
+    mReq = mAppMgr.create(file);
+    if (mReq == NULL)
+    {
+           // No handlers for the URI
+           return;
+     }
+    // By default operation is "view(QString)"
+
+    // Set function parameters
+   QList<QVariant> args;
+   args << file.fileName();
+   mReq->setArguments(args);
+   QString title("WindowTitle");
+   QVariant title2(QString("<app_name>View"));
+   XQRequestInfo info;
+   info.setInfo(title, title2);
+   mReq->setInfo(info);
+   // Send the request
+   bool res = mReq->send();
+   if  (!res) 
+   {
+       // Request failed. 
+      int error = mReq->lastError();
+
+      // Handle error
+   }
+ 
+   // If making multiple requests to same service, you can save the request as member variable
+   // In this example all done.
+   delete mReq;
+ */
+
+bool PlayMusicService::view(const QString& file)
+{
+    TX_ENTRY
+	QString uri(file);
+    uri.replace(QString("/"),QString("\\"));
+    mTitle = requestInfo().info("WindowTitle").toString();
+    mServiceApp->setCurrentService( MusicServices::EPlayback );
+    TUid uid = TUid::Uid(requestInfo().clientSecureId()); 
+    emit mServiceApp->serviceActive( uid );
+    emit mServiceApp->playReady( uri );
+    connect(this, SIGNAL( clientDisconnected() ), qApp, SLOT( quit() ) );
+    mRequestIndex = setCurrentRequestAsync();
+    
+    return true;
+    
+}
+
+/*!
+    Embedded Playback service interface defined in service registration xml.
+
+    Example usage:
+    
+   XQSharableFile sf;
+    if (!sf.open("c:\\audio.mp3"))
+    {
+        // Failed to open sharable file
+        return;
+    }
+
+    // Create request for the sharable file
+    mReq = mAppMgr.create(sf);
+    if (!mReq)
+    {
+         // No viewer app found for the file
+         // As we opened the handle, we need to close it !
+         sf.close(); 
+         return;  
+    }
+    // By default operation is "view(XQSharableFile)"
+
+    // Set function parameters
+    // Not only one sharable handle supported,  otherwise upon send EArgumentError error occurs
+    QList<QVariant> args;
+    args << qVariantFromValue(sf);  
+    mReq->setArguments(args);
+    QString title("WindowTitle");
+   QVariant title2(QString("<app_name>"));
+   XQRequestInfo info;
+   info.setInfo(title, title2);
+   mReq->setInfo(info);
+   // Send the request
+   bool res = mReq->send();
+   if  (!res) 
+   {
+       // Request failed. 
+      int error = mReq->lastError();
+      // Handle error
+   }
+
+    // As we opened the handle, we need to close it !
+    sf.close(); 
+
+   // If making multiple requests to same service, you can save the mReq as member variable
+   // In this example all done.
+   delete mReq;
+ */
+bool PlayMusicService::view(const XQSharableFile& file)
+{
+    TX_ENTRY
+    mTitle = requestInfo().info("WindowTitle").toString();
+    mServiceApp->setCurrentService( MusicServices::EPlayback );
+    TUid uid = TUid::Uid(requestInfo().clientSecureId()); 
+    emit mServiceApp->serviceActive( uid );
+    emit mServiceApp->playReady( file );
+    connect(this, SIGNAL( clientDisconnected() ), qApp, SLOT( quit() ) );
+    mRequestIndex = setCurrentRequestAsync();
+    return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/tsrc/unittest_musicservices/inc/unittest_musicservices.h	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MusicServices
+*
+*/
+
+#ifndef TESTMUSICSERVICES_H
+#define TESTMUSICSERVICES_H
+
+#include <QtTest/QtTest>
+
+/* in our unit test usually this goes on the CPP file, but in this case we need it here to get
+ the observer interface, and also the mpxcollectionopenutility stub before the tested class so 
+ we get the stub instead of the normal mpxcollectionopenutility.*/
+//#include "stub/inc/mpxcollectionopenutility.h"
+
+
+class MusicServices;
+
+
+class TestMusicServices : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    TestMusicServices();
+    virtual ~TestMusicServices();
+    
+public slots:
+
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+
+private slots:
+
+    void testConstructor();
+    void testCurrentService();
+    void testSetCurrentService();
+
+private:
+
+    MusicServices  *mTest;
+
+};
+
+#endif  // TESTmusicservices_H
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/tsrc/unittest_musicservices/src/unittest_musicservices.cpp	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Unit test for MusicServices
+*
+*/
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+
+
+#include "unittest_musicservices.h"
+
+// Do this so we can access all member variables.
+#define private public
+#include "musicservices.h"
+#include "getmusicservice.h"
+#include "playmusicservice.h"
+#undef private
+
+
+/*!
+ Make our test case a stand-alone executable that runs all the test functions.
+ */
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    HbMainWindow window;
+
+    TestMusicServices tv;
+
+    char *pass[3];
+    pass[0] = argv[0];
+    pass[1] = "-o";
+    pass[2] = "c:\\data\\unittest_musicservices.txt";
+
+    int res = QTest::qExec(&tv, 3, pass);
+
+    return res;
+}
+
+TestMusicServices::TestMusicServices()
+    : mTest( 0 )
+{
+}
+
+TestMusicServices::~TestMusicServices()
+{
+    delete mTest;
+}
+
+/*!
+ Called before the first testfunction is executed.
+ */
+void TestMusicServices::initTestCase()
+{
+}
+
+/*!
+ Called after the last testfunction was executed.
+ */
+void TestMusicServices::cleanupTestCase()
+{
+}
+
+/*!
+ Called before each testfunction is executed.
+ */
+void TestMusicServices::init()
+{
+    mTest = new MusicServices();
+}
+
+/*!
+ Called after every testfunction.
+ */
+void TestMusicServices::cleanup()
+{
+    delete mTest;
+    mTest = 0;
+}
+
+/*!
+ Tests constructor.
+*/
+void TestMusicServices::testConstructor()
+{
+    QVERIFY(mTest->mFetchService != 0);
+    QVERIFY(mTest->mPlayService != 0);
+    QCOMPARE(mTest->mCurrentService, MusicServices::ENoService);
+    QCOMPARE(mTest->mFetchService->mServiceApp, mTest);
+    QCOMPARE(mTest->mPlayService->mServiceApp, mTest);
+    QVERIFY(mTest->mFetchService->mRequestIndex == 0);
+    QVERIFY(mTest->mPlayService->mRequestIndex == 0);
+
+}
+
+void TestMusicServices::testCurrentService()
+{
+    mTest->mCurrentService = MusicServices::EUriFetcher;
+    QCOMPARE(mTest->currentService(), MusicServices::EUriFetcher);
+    mTest->mCurrentService = MusicServices::EPlayback;
+    QCOMPARE(mTest->currentService(), MusicServices::EPlayback);
+    mTest->mCurrentService = MusicServices::ENoService;
+    QCOMPARE(mTest->currentService(), MusicServices::ENoService);
+    
+}
+
+void TestMusicServices::testSetCurrentService()
+{
+    mTest->setCurrentService(MusicServices::EUriFetcher);
+    QCOMPARE(mTest->currentService(), MusicServices::EUriFetcher);
+    mTest->setCurrentService(MusicServices::EPlayback);
+    QCOMPARE(mTest->currentService(), MusicServices::EPlayback);
+    mTest->setCurrentService(MusicServices::ENoService);
+    QCOMPARE(mTest->currentService(), MusicServices::ENoService);
+    
+}
+
+
+
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/musicservices/tsrc/unittest_musicservices/unittest_musicservices.pro	Mon May 03 12:29:20 2010 +0300
@@ -0,0 +1,41 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description: Unit test for MusicServices
+
+TEMPLATE = app
+
+CONFIG += qtestlib \
+    hb
+TARGET = 
+
+DEFINES += BUILD_MUSICSERVICES_LIB
+
+TARGET.CAPABILITY = All -TCB
+
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../inc \
+    ../../../inc
+
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+LIBS += -lestor.dll \
+    -lfbscli.dll \
+    -lxqservice
+
+HEADERS += inc/unittest_musicservices.h \
+    ../../inc/musicservices.h \ 
+    ../../inc/getmusicservice.h \
+    ../../inc/playmusicservice.h 
+
+SOURCES += src/unittest_musicservices.cpp \
+        ../../src/musicservices.cpp \
+        ../../src/getmusicservice.cpp \
+    	../../src/playmusicservice.cpp  
--- a/qtmusicplayer.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/qtmusicplayer.pro	Mon May 03 12:29:20 2010 +0300
@@ -18,7 +18,8 @@
 
 symbian {
     include(app/rom/rom.pri)
-    include(musicfetcher/rom/rom.pri)
+    include(musicservices/rom/rom.pri)
+    include(mpdata/rom/rom.pri)
     include(mpengine/rom/rom.pri)
     include(utilities/mpsettingsmanager/rom/rom.pri)
     include(utilities/mpnowplayingbanner/rom/rom.pri)
@@ -29,26 +30,26 @@
     include(mpserviceplugins/audioeffects/rom/rom.pri)
     include(mpserviceplugins/localaudio/rom/rom.pri)
     include(mpserviceplugins/mpxsqlitedbcommon/rom/rom.pri)
-    include(mpserviceplugins/mpxsqlitedbplugin/rom/rom.pri)
+    include(mpserviceplugins/mpxsqlitedbhgplugin/rom/rom.pri)
     include(mpserviceplugins/mpxsqlitepodcastdbplugin/rom/rom.pri)
     include(mpserviceplugins/mpxinmemoryplugin/rom/rom.pri)
     include(mpserviceplugins/m3uplaylistplugin/rom/rom.pri)
     }
 
 SUBDIRS = utilities \
-          musicfetcher \
+          musicservices \
           app \
+          mpdata \
           mpengine \
           mpviewplugins 
 
 CONFIG += ordered
 
 BLD_INF_RULES.prj_mmpfiles += "./mpserviceplugins/audioeffects/group/mpxaudioeffectengine.mmp" \
-"./mpserviceplugins/localaudio/group/mpxlocalaudioplayback.mmp" \
-"./mpserviceplugins/mpxsqlitedbcommon/group/mpxsqlitedbcommon.mmp" \
-"./mpserviceplugins/mpxsqlitedbplugin/group/mpxsqlitedbplugin.mmp" \
-"./mpserviceplugins/mpxsqlitepodcastdbplugin/group/mpxsqlitepodcastdbplugin.mmp" \
-"./mpserviceplugins/mpxinmemoryplugin/group/mpxinmemoryplugin.mmp" \
-"./mpserviceplugins/m3uplaylistplugin/group/mpxm3uplaylistparsers.mmp" \
-"./mpserviceplugins/m3uplaylistplugin/group/mpxm3uplaylistplugin.mmp"
-
+    "./mpserviceplugins/localaudio/group/mpxlocalaudioplayback.mmp" \
+    "./mpserviceplugins/mpxsqlitedbcommon/group/mpxsqlitedbcommon.mmp" \
+    "./mpserviceplugins/mpxsqlitedbhgplugin/group/mpxsqlitedbhgplugin.mmp" \
+    "./mpserviceplugins/mpxsqlitepodcastdbplugin/group/mpxsqlitepodcastdbplugin.mmp" \
+    "./mpserviceplugins/mpxinmemoryplugin/group/mpxinmemoryplugin.mmp" \
+    "./mpserviceplugins/m3uplaylistplugin/group/mpxm3uplaylistparsers.mmp" \
+    "./mpserviceplugins/m3uplaylistplugin/group/mpxm3uplaylistplugin.mmp"
--- a/tsrc/mpfetchertestapp/inc/mpfetchertestappview.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/tsrc/mpfetchertestapp/inc/mpfetchertestappview.h	Mon May 03 12:29:20 2010 +0300
@@ -37,6 +37,10 @@
     void handleError(int errorCode, const QString& errorMessage);
     
     void fetchSong();
+    void playSong();
+    void viewSong();
+    void viewSongCaged();
+    
     
 private:
     void createLayout();
--- a/tsrc/mpfetchertestapp/mpfetchertestapp.pro	Fri Apr 16 14:56:30 2010 +0300
+++ b/tsrc/mpfetchertestapp/mpfetchertestapp.pro	Mon May 03 12:29:20 2010 +0300
@@ -29,6 +29,8 @@
 #    include(rom/rom.pri) # to include in image
     TARGET.UID2 = 0x100039CE 
     TARGET.UID3 = 0x10207C6A
+    TARGET.EPOCSTACKSIZE = 0x14000
+    TARGET.EPOCHEAPSIZE = 0x020000 0x1F00000
     TARGET.CAPABILITY = ALL -TCB
     INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE 
 }
--- a/tsrc/mpfetchertestapp/src/mpfetchertestappview.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/tsrc/mpfetchertestapp/src/mpfetchertestappview.cpp	Mon May 03 12:29:20 2010 +0300
@@ -16,6 +16,7 @@
 */
 
 #include <xqaiwrequest.h>
+#include <xqservicerequest.h>
 #include <QGraphicsLinearLayout>
 #include <hbpushbutton.h>
 #include <hblineedit.h>
@@ -119,6 +120,18 @@
                 connect(button, SIGNAL(clicked()), SLOT(fetchSong()));
                 bottomLayout->addItem(button);
             }
+            HbPushButton* playButton = new HbPushButton("Play song");
+            if (playButton)
+            {
+                connect(playButton, SIGNAL(clicked()), SLOT(viewSong()));
+                bottomLayout->addItem(playButton);
+            }
+            HbPushButton* viewButton = new HbPushButton("Play song caged");
+            if (viewButton)
+            {
+                connect(viewButton, SIGNAL(clicked()), SLOT(viewSongCaged()));
+                bottomLayout->addItem(viewButton);
+            }
             layout->addItem(bottomLayout);
         }
 
@@ -133,10 +146,14 @@
     mResultEdit->setText("");
     mErrorEdit->setText("");
     mErrorCodeEdit->setText("");
-
+    if(mReq){
+        delete mReq;
+        mReq = 0;
+    }
+    
     if (!mReq)
     {
-        mReq = mAppMgr.create("com.nokia.services.media.Music", "fetch(QString)", true);
+        mReq = mAppMgr.create("com.nokia.symbian.IMusicFetch", "fetch()", true);
 
         qDebug() <<  "MpFetcherTestAppView::fetchSong: mReq=" << mReq;
 
@@ -153,16 +170,159 @@
     }
 
     // Set arguments for request (application title)
+//    QList<QVariant> args;
+//    args << QVariant(QString("<app_name>"));
+//    mReq->setArguments(args);
+    QString title("WindowTitle");
+    QVariant title2(QString("app_name"));
+    XQRequestInfo info;
+    info.setInfo(title, title2);
+    mReq->setInfo(info);
+    // Make the request
+    if (!mReq->send())
+    {   
+        mErrorEdit->setText("Failed to send REQ");
+        qDebug() <<  "MpFetcherTestAppView::fetchSong: XQAiwRequest::send returned false";
+    }
+
+    qDebug() <<  "MpFetcherTestAppView::fetchSong END";
+}
+
+void MpFetcherTestAppView::playSong()
+{
+    qDebug() <<  "MpFetcherTestAppView::playSong START";
+
+    if(mReq){
+        delete mReq;
+        mReq = 0;
+    }
+    if (!mReq)
+    {
+        mReq = mAppMgr.create("com.nokia.symbian.IFileViewMusic", "playMedia(QString,QString)", true);
+
+        qDebug() <<  "MpFetcherTestAppView::playSong: mReq=" << mReq;
+
+        if (!mReq)
+        {
+            mErrorEdit->setText("Failed to create REQ");
+            return;
+        }
+        else
+        {
+            connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&)));
+            connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&)));
+        }
+    }
+
+    // Set arguments for request (application title)
     QList<QVariant> args;
-    args << QVariant(QString("<app_name>"));
+    args << QString("<app_name>");
+    args << mResultEdit->text();
+    
     mReq->setArguments(args);
 
     // Make the request
     if (!mReq->send())
     {
         mErrorEdit->setText("Failed to send REQ");
-        qDebug() <<  "MpFetcherTestAppView::fetchSong: XQAiwRequest::send returned false";
+        qDebug() <<  "MpFetcherTestAppView::playSong: XQAiwRequest::send returned false";
     }
 
-    qDebug() <<  "MpFetcherTestAppView::fetchSong END";
+    qDebug() <<  "MpFetcherTestAppView::playSong END";
+}
+
+void MpFetcherTestAppView::viewSong()
+{
+    
+    if(mReq){
+        delete mReq;
+        mReq = 0;
+    }
+    QFile file(mResultEdit->text());
+
+    mReq = mAppMgr.create(file);
+    if (mReq == NULL)
+    {
+           // No handlers for the URI
+           return;
+     }
+    // By default operation is "view(QString)"
+
+    // Set function parameters
+   QList<QVariant> args;
+   args << file.fileName();
+   mReq->setArguments(args);
+   QString title("WindowTitle");
+   QVariant title2(QString("<app_name>View"));
+   XQRequestInfo info;
+   info.setInfo(title, title2);
+   mReq->setInfo(info);
+   // Send the request
+   bool res = mReq->send();
+   if  (!res) 
+   {
+       // Request failed. 
+      int error = mReq->lastError();
+
+      // Handle error
+   }
+ 
+   // If making multiple requests to same service, you can save the request as member variable
+   // In this example all done.
+
+
 }
+
+void MpFetcherTestAppView::viewSongCaged()
+{
+    if(mReq){
+        delete mReq;
+        mReq = 0;
+    }
+    XQSharableFile sf;
+    // Open the file for sharing from own private  directory
+    // If you have handle available, just set it by "setHandle()" function
+    if (!sf.open(mResultEdit->text()))
+    {
+        // Failed to open sharable file
+        return;
+    }
+
+    // Create request for the sharable file
+    mReq = mAppMgr.create(sf);
+    if (!mReq)
+   {
+         // No viewer app found for the file
+         // As we opened the handle, we need to close it !
+         sf.close(); 
+         return;  
+   }
+    // By default operation is "view(XQSharableFile)"
+
+    // Set function parameters
+    // Not only one sharable handle supported,  otherwise upon send EArgumentError error occurs
+    QList<QVariant> args;
+    args << qVariantFromValue(sf);  
+    mReq->setArguments(args);
+    QString title("WindowTitle");
+   QVariant title2(QString("<app_name>Caged"));
+   XQRequestInfo info;
+   info.setInfo(title, title2);
+   mReq->setInfo(info);
+   // Send the request
+   bool res = mReq->send();
+   if  (!res) 
+   {
+       // Request failed. 
+      int error = mReq->lastError();
+      // Handle error
+   }
+
+    // As we opened the handle, we need to close it !
+    sf.close(); 
+
+   // If making multiple requests to same service, you can save the mReq as member variable
+   // In this example all done.
+
+
+}
Binary file utilities/mpsettingsmanager/conf/musicplayer.confml has changed
Binary file utilities/mpsettingsmanager/conf/musicplayer_10207C92.crml has changed
--- a/utilities/mpsettingsmanager/inc/mpsettingsmanagerdefs.h	Fri Apr 16 14:56:30 2010 +0300
+++ b/utilities/mpsettingsmanager/inc/mpsettingsmanagerdefs.h	Mon May 03 12:29:20 2010 +0300
@@ -19,10 +19,12 @@
 #define MPSETTINGSMANAGERDEFS_H
 
     // CenRep Keys
-    const qint32 KMPCenRepSettingsFeature           = {0x10207C92};
-    const qint32 KMPCenRepSettingShuffleKey         = {0x00000001};
-    const qint32 KMPCenRepSettingRepeatKey          = {0x00000002};
-    const qint32 KMPCenRepSettingFirstStartupKey    = {0x00000003};
-    const qint32 KMPCenRepSettingPresetIdKey        = {0x00000004};
+    const qint32 KMPCenRepSettingsFeature            = {0x10207C92};
+    const qint32 KMPCenRepSettingShuffleKey          = {0x00000001};
+    const qint32 KMPCenRepSettingRepeatKey           = {0x00000002};
+    const qint32 KMPCenRepSettingFirstStartupKey     = {0x00000003};
+    const qint32 KMPCenRepSettingPresetIdKey         = {0x00000004};
+    const qint32 KMPCenRepSettingRamdiskEnabled      = {0x00000005};
+    const qint32 KMPCenRepSettingRamdiskMaxDiskSpace = {0x00000006};
 
 #endif	// MPSETTINGSMANAGERDEFS_H