Revision: 201021 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:44:23 +0300
branchRCL_3
changeset 16 67eb01668b0e
parent 15 8f0df5c82986
child 18 baf439b22ddd
Revision: 201021 Kit: 2010123
inc/mpxvideoplayercustomviewmsgconsts.h
tsrc/testing/tools/builder.pl
tsrc/testing/tools/siscreator.pl
videocollection/hgmyvideos/conf/hgmyvideos.confml
videocollection/hgmyvideos/inc/vcxhgmyvideoscategorymodelhandler.h
videocollection/hgmyvideos/inc/vcxhgmyvideosmainview.h
videocollection/hgmyvideos/src/vcxhgmyvideoscategorylistimpl.cpp
videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp
videocollection/hgmyvideos/src/vcxhgmyvideosmainview.cpp
videocollection/mpxmyvideoscollection/download/inc/vcxmyvideosdownloadutil.h
videocollection/mpxmyvideoscollection/download/src/vcxmyvideosdownloadutil.cpp
videocollection/mpxmyvideoscollection/group/vcxmyvideoscollectionplugin.mmp
videocollection/mpxmyvideoscollection/inc/vcxmyvideosactivetask.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosalbum.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosalbums.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosasyncfileoperations.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideoscategories.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionplugin.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosdownloadcache.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdsalbums.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdscmdqueue.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdsdb.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosmessagelist.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosopenhandler.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideostimer.h
videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h
videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosalbum.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosalbums.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfilecopy.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfileoperations.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideoscategories.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionutil.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosdownloadcache.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosdrivemonitor.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsalbums.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosmdscmdqueue.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosmessagelist.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosopenhandler.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideostimer.cpp
videocollection/mpxmyvideoscollection/src/vcxmyvideosvideocache.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/conf/VcxMyVideosCollectionUtilTest.cfg
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/group/bld.inf
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/inc/VcxMyVideosCollectionUtilTest.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/src/VcxMyVideosCollectionUtilTestBlocks.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/conf/VcxMyVideosMdsDbTest.cfg
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/group/VcxMyVideosMdsDbTest.mmp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/VcxMyVideosMdsDbTest.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdeobjectquery.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdesessionimpl.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mpxmedia.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/myvideostesttrap.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosalbum.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideoscollectionutil.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosmdsalbums.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosmdscmdqueue.h
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobject.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobjectquery.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdequery.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdesessionimpl.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideoscollectionutil.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideosmdsalbums.cpp
videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideosmdscmdqueue.cpp
videoplayback/inc/mpxvideobaseplaybackview.h
videoplayback/inc/mpxvideopdlplaybackview.h
videoplayback/inc/mpxvideoplaybackcontrolscontroller.h
videoplayback/inc/mpxvideoplaybackuserinputhandler.h
videoplayback/videohelix/group/mpxvideohelixplayback.mmp
videoplayback/videohelix/inc/mpxvideodlmgrif.h
videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h
videoplayback/videohelix/inc/mpxvideoplaybackmode.h
videoplayback/videohelix/src/mpxvideodlmgrif.cpp
videoplayback/videohelix/src/mpxvideoplaybackmode.cpp
videoplayback/videohelix/src/mpxvideoplaybackstate.cpp
videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg
videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp
videoplayback/videohelix/tsrc/ut_videohelixtest/inc/dlmgr_stub.h
videoplayback/videohelix/tsrc/ut_videohelixtest/inc/videohelixtest.h
videoplayback/videohelix/tsrc/ut_videohelixtest/src/tnmgr_stub.cpp
videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp
videoplayback/videoplaybackcontrols/group/mpxvideoplaybackcontrols.mmp
videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp
videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp
videoplayback/videoplaybackviews/src/mpxvideopdlplaybackview.cpp
videoplayback/videoplaybackviews/src/mpxvideoplaybackuserinputhandler.cpp
videoplayerapp/mpxvideoplayer/inc/mpxvideoplayerappuiengine.h
videoplayerapp/mpxvideoplayer/sis/VideoPlayer.pkg
videoplayerapp/mpxvideoplayer/sis/VideoPlayer_stub.pkg
videoplayerapp/mpxvideoplayer/src/mpxvideoembeddedpdlhandler.cpp
videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappuiengine.cpp
--- a/inc/mpxvideoplayercustomviewmsgconsts.h	Tue May 25 12:44:54 2010 +0300
+++ b/inc/mpxvideoplayercustomviewmsgconsts.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,8 @@
 */
 
 
-// Version : %version: da1mmcf#3 %
+// Version : %version: da1mmcf#4 %
+
 
 #ifndef __MPXVIDEOPLAYERCUSTOMVIEWMSGCONSTS_H__
 #define __MPXVIDEOPLAYERCUSTOMVIEWMSGCONSTS_H__
@@ -31,5 +32,6 @@
 
 const TInt KMpxVideoPlaybackPdlReloading = 0x20024339;
 
+const TInt KMpxVideoPlaybackPdlReloadComplete = 0x2002433A;
 
 #endif // __MPXVIDEOPLAYERCUSTOMVIEWMSGCONSTS_H__
--- a/tsrc/testing/tools/builder.pl	Tue May 25 12:44:54 2010 +0300
+++ b/tsrc/testing/tools/builder.pl	Wed Jun 09 09:44:23 2010 +0300
@@ -1,3 +1,20 @@
+#
+# 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: 
+#
+
+
 use Cwd; # for cwd
 
 my $debug = 0;
--- a/tsrc/testing/tools/siscreator.pl	Tue May 25 12:44:54 2010 +0300
+++ b/tsrc/testing/tools/siscreator.pl	Wed Jun 09 09:44:23 2010 +0300
@@ -1,3 +1,20 @@
+#
+# 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: 
+#
+
+
 use warnings;
 use Cwd; # for cwd
 use File::Copy;
Binary file videocollection/hgmyvideos/conf/hgmyvideos.confml has changed
--- a/videocollection/hgmyvideos/inc/vcxhgmyvideoscategorymodelhandler.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/hgmyvideos/inc/vcxhgmyvideoscategorymodelhandler.h	Wed Jun 09 09:44:23 2010 +0300
@@ -126,7 +126,9 @@
          * Handles "ExtraItem" list item selection.
 		 *
 		 * @param aCategoryId  Selected category id
-		 * @param aItemType    On return, item type
+		 * @param aItemType    On return, item type. If both UID and URL were found,
+		 *                     UID type will be returned.
+		 *
 		 * @param aUid         On return, UID if selected item contains UID 
 		 * @param aUrl         On return, URL string if selected item contains URL
          */
--- a/videocollection/hgmyvideos/inc/vcxhgmyvideosmainview.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/hgmyvideos/inc/vcxhgmyvideosmainview.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 */
 
 
-// Version : %version: 17 %
+// Version : %version: 18 %
 
 #ifndef VCXHGMYVIDEOSMAINVIEW_H
 #define VCXHGMYVIDEOSMAINVIEW_H
@@ -167,6 +167,14 @@
          */
         void LaunchBrowserL( const TDesC& aUrl );        
         
+        /**
+         * Launches Ovi store.
+         *
+         * @param aAppUid Ovi Store Launcher application UID
+         * @param aMsg    command line arguments
+         */
+        void LaunchOviStoreL( const TUid aAppUid, const TDesC& aArgs = KNullDesC() );
+
     private: // Constructors
 
         /**
--- a/videocollection/hgmyvideos/src/vcxhgmyvideoscategorylistimpl.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/hgmyvideos/src/vcxhgmyvideoscategorylistimpl.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -194,9 +194,14 @@
                         
             iCategoryModel->HandleExtraItemSelectionL( categoryId, itemType, appUid, urlString );
             
-            if ( itemType == TVcxHgMyVideosCategoryItemTypeUid )
+            // ExtraItem1 is Ovi Store
+            if ( categoryId == KCategoryIdExtraItem1 )
                 {
-                iView.LaunchAppL( appUid );
+                iView.LaunchOviStoreL( appUid, urlString );
+                }
+            else if ( itemType == TVcxHgMyVideosCategoryItemTypeUid )
+                {
+                iView.LaunchAppL( appUid, urlString );
                 }
             else if ( itemType == TVcxHgMyVideosCategoryItemTypeUrl )
                 {
--- a/videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -1125,22 +1125,20 @@
     TBuf<KMyVideosTitleUrlMaxLength> urlString;
     TInt uidInt( 0 ) ;
     
-    // Try to get web link URL first.
+    // Try to get URL.
     TInt error = iModel.GetMyVideosCustomizationString( urlKey, urlString );
     if ( error == KErrNone && urlString.Size() > 0 )
         {
         aUrl = urlString;
         aItemType = TVcxHgMyVideosCategoryItemTypeUrl;
         }
-    else 
+
+    // Try to fetch application UID.
+    error = iModel.GetMyVideosCustomizationInt( uidKey, uidInt );
+    if ( error == KErrNone && uidInt != 0 )
         {
-        // If URL is not found try to fetch application UID.
-        error = iModel.GetMyVideosCustomizationInt( uidKey, uidInt );
-        if ( error == KErrNone && uidInt != 0 )
-            {
-            aUid = TUid::Uid( uidInt );
-            aItemType = TVcxHgMyVideosCategoryItemTypeUid;
-            }
+        aUid = TUid::Uid( uidInt );
+        aItemType = TVcxHgMyVideosCategoryItemTypeUid;
         }
     }
 
--- a/videocollection/hgmyvideos/src/vcxhgmyvideosmainview.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/hgmyvideos/src/vcxhgmyvideosmainview.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 */
 
 
-// Version : %version: 45 %
+// Version : %version: 46 %
 
 // INCLUDE FILES
 #include <bldvariant.hrh>
@@ -58,6 +58,10 @@
 
 _LIT( KBrowserProtocol, "4 " );
 
+// URL to Ovi Store videos. If Ovi Store Launcher is not installed, this
+// address will be opened to web browser.
+_LIT( KOviVideoStoreURL, "http://lr.ovi.mobi/store/video" );
+
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -863,3 +867,36 @@
     
     CleanupStack::PopAndDestroy( param );
     }
+
+// ------------------------------------------------------------------------------
+// CVcxHgMyVideosMainView::LaunchOviStoreL()
+// ------------------------------------------------------------------------------
+//
+void CVcxHgMyVideosMainView::LaunchOviStoreL( const TUid aAppUid, const TDesC& aArgs )
+    {
+    IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosMainView::LaunchOviStoreL() enter" );
+    RApaLsSession appArcSession;
+    User::LeaveIfError( appArcSession.Connect() );
+    CleanupClosePushL<RApaLsSession>( appArcSession );
+
+    TApaAppInfo appInfo;
+    TInt err = appArcSession.GetAppInfo( appInfo, aAppUid );
+    IPTVLOGSTRING2_LOW_LEVEL( "CVcxHgMyVideosMainView::LaunchOviStoreL() GetAppInfo() error = %d", err );
+
+    if ( KErrNone == err )
+        {
+        IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosMainView::LaunchOviStoreL() launch '%S' with arguments '%S'", &appInfo.iFullName, &aArgs );
+        RProcess process;
+        User::LeaveIfError( process.Create( appInfo.iFullName, aArgs ) );
+        process.Resume();
+        process.Close();
+        }
+    else
+        {
+        // Launcher not found, use browser until launcher is available
+        IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosMainView::LaunchOviStoreL() launcher not found, launch browser" );
+        LaunchBrowserL( KOviVideoStoreURL );
+        }
+
+    CleanupStack::PopAndDestroy( &appArcSession );
+    }
--- a/videocollection/mpxmyvideoscollection/download/inc/vcxmyvideosdownloadutil.h	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +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 the License "Eclipse Public License v1.0"
-* which accompanies 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 VCXMYVIDEOSDOWNLOADUTIL_H
-#define VCXMYVIDEOSDOWNLOADUTIL_H
-
-// INCLUDES
-
-#include <downloadmgrclient.h>
-#include <mpxmedia.h>
-#include <vcxmyvideosdefs.h>
-#include <ipvideo/vcxconnutilengineobserver.h>
-#include "vcxmyvideostimer.h"
-
-// FORWARD DECLARATIONS
-class CVcxConnectionUtility;
-class CMediatorEventProvider;
-class RFs;
-
-// CONSTANTS
-const TInt KVcxSubDirLevels     = 2;
-const TInt KVcxMaxSubDirLength  = 10;    
-const TInt KVcxMaxSubDirsLength = KVcxMaxSubDirLength * KVcxSubDirLevels;
-const TInt KVcxMaxItemsInDir    = 100;
-
-// CLASS DECLARATION
-
-NONSHARABLE_CLASS(MVcxMyVideosDownloadUtilObserver)
-    {
-    public:
-        /**
-        * Event handler which client must implement.
-        *
-        * @param aDownloadId           Download ID in Download Manager.
-        * @param aProgress             Download progress, 0-100.
-        * @param aDownloaded           Current file size, in bytes.
-        * @param aDownloadError        If download goes to failed state, this contains the reason code
-        *                              otherwise 0.
-        * @param aDownloadGlobalError  if download goes to failed state, this contains the global reason
-        *                              code, otherwise 0.
-        */
-        virtual void HandleDlEvent( TVcxMyVideosDownloadState aState,
-                TUint32 aDownloadId,
-                TInt aProgress,
-                TInt64 aDownloaded,
-                TInt32 aDownloadError,
-                TInt32 aDownloadGlobalError ) = 0;
-    };
-
-/**
-* Download related stuff.
-*
-* @lib mpxmyvideoscollectionplugin.dll
-*/
-NONSHARABLE_CLASS(CVcxMyVideosDownloadUtil) :
-    public CBase,
-    public MHttpDownloadMgrObserver,
-    public MVcxMyVideosTimerObserver,
-    public MConnUtilEngineObserver
-    {    
-    public: // Constructors and destructor
-
-        /**
-        * Two-phased constructor
-        * @param aObserver Observer
-        * @param aFs       File server session.
-        * @return          Object constructed
-        */
-        static CVcxMyVideosDownloadUtil* NewL ( MVcxMyVideosDownloadUtilObserver& aObserver, RFs& aFs );
-
-        /**
-        * Destructor
-        */
-        virtual ~CVcxMyVideosDownloadUtil();
-
-    public:
-        /**
-        * Starts download. New download ID is written to aDownload. If KVcxMediaMyVideosDownloadId
-        * != 0, then the existing download is resumed.
-        *
-        * @param aDownload download parameters
-        */
-        void StartDownloadL( CMPXMedia& aDownload );
-
-        /**
-        * Pauses download.
-        *
-        * @param aDownloadId Download ID.
-        * @return            System-wide error code.
-        */
-        TInt PauseDownload( TUint32 aDownloadId );
-
-        /**
-        * Returns download by download ID. Ownership is not moved.
-        *
-        * @param aDownloadId Download ID.
-        * @return            Download, or NULL if not found.
-        */
-        RHttpDownload* Download( TUint32 aDownloadId );
-
-        /**
-        * Returns download which has aFileName as EDlAttrDestFilename.
-        * Ownership is not moved.
-        *
-        * @param aFileName Filename.
-        * @return          Download, or NULL if not found.
-        */
-        RHttpDownload* Download( const TDesC& aFileName );
-        
-        /**
-        * Returns array to downloads.
-        */
-        const CDownloadArray& Downloads();
-
-        /**
-        * Deletes download from download manager using download id.
-        *
-        * @param aDeleteContent If ETrue, then content is deleted also.
-        * @return               System-wide error code.
-        */
-        TInt CancelDownload( TInt32 aId, TBool aDeleteContent );
-
-        /**
-        * Gets MPX/MDS version of the download state.
-        *
-        * @param aDownload       Download whose state is fetched.
-        * @param aDownloadState  On completion, the download state is written here.
-        */        
-        void GetDownloadState(
-                RHttpDownload& aDownload,
-                TVcxMyVideosDownloadState& aDownloadState );
-        
-        /**
-        * Returns download state.
-        *
-        * @param aDownload   Download
-        * @param aDownloaded How much the file has been downloaded in bytes.
-        * @param aAllowSilentReset if ETrue, silent flag is set to EFalse, in
-        *                          case dl size is not gotten ok.
-        * @return            Download progress, in percentages.
-        */        
-        TInt8 DownloadProgress( RHttpDownload& aDownload, TUint64& aDownloaded,
-                                TBool aAllowSilentReset );
-
-        
-        /**
-        * Checks that every download item in Download Manager has corresponding
-        * object in MPX/MDS (= aVideoList), if not, deletes the download.
-        */
-        void ClearOrphanDownloadsL( CMPXMedia& aVideoList );
-
-        /**
-        * Deletes download asynchronously.
-        *
-        * @param aDownloadId    Download to delete.
-        * @param aDeleteContent If ETrue, then the content file is also deleted.
-        */
-        void DeleteDownloadAsync( TInt32 aDownloadId, TBool aDeleteContent );
-
-        /**
-        * Creates path and filename for the new video download.
-        *
-        * @return The path. 
-        */
-        HBufC* CreateFilePathL( const CMPXMedia& aMedia );
-        
-        /**
-        * Notify via mediator, that one download has finished succesfully.
-        *
-        * @param aMsg Buffer that contains the data that is sent with event.
-        */
-        void NotifyDownloadCompleted( const TDesC8& aMsg );
-        
-        /**
-        * Notify via mediator, that count of new videos has decreased.
-        * 
-        * @param aMsg Buffer that constains the data that is sent with event.  
-        */
-        void NotifyNewVideosCountDecreased( const TDesC8& aMsg );
-        
-    public: // From MHttpDownloadMgrObserver 
-
-        /**
-         * Handler function for download events.
-         *
-         * @param aDownload download
-         * @aEvent aEvent event
-         */
-        void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
-
-    public: // from MConnUtilEngineObserver
-    
-        /**
-         * Roaming request from connectioutility.
-         * Download utility decides whether it allows 
-         * iap roaming and returns true or false based on decision.
-         *
-         * @return TBool
-         */
-        TBool RequestIsRoamingAllowedL();
-    
-        /**
-         * Iap change notification from connectiontutility
-         *
-         */
-        void  IapChangedL();              
-    
-    public: // from MVcxMyVideosTimer
-        /**
-        * Handle timer event.
-        *
-        * @param aTimer pointer to timer which expired.
-        */
-        void TimerExpired( CVcxMyVideosTimer* aTimer );
-            
-    private:
-        /**
-        * Constructor
-        *
-        * @param aObserver Observer
-        * @param aFs       File server session.
-        */
-        CVcxMyVideosDownloadUtil( MVcxMyVideosDownloadUtilObserver& aObserver, RFs& aFs );
-
-        /**
-        * Symbian 2nd phase constructor.
-        */
-        void ConstructL ();
-
-#ifdef _DEBUG
-        const TDesC& GetS60DlStateDes( TInt32 aState );
-        const TDesC& GetS60DlProgressDes( TInt32 aProgress );
-#endif
-
-        /**
-        * Signal via mediator event that there is ongoing downloads.
-        */
-        void NotifyDownloadStarted();
-
-        /**
-        * Check, is there running downloads. If not, notify via mediator
-        */
-        void NotifyIfNoActiveDownloads();
-
-        /**
-        * Counts active downloads.
-        * @return Active download count.
-        */
-        TInt32 ActiveDownloadCount();
-        
-        /**
-        * Creates filepath.
-        *
-        * @param aMedia    Media item whose path is created
-        * @param aPath     New path is written here.
-        * @param aCounter  Counter value which is inserted to filename. 
-        */
-        void GeneratePathL( const CMPXMedia& aMedia, TDes& aPath, TInt aCounter );
-
-        /**
-        * Finds a sub dir which has less than KVcxMaxItemsInDir items, if not
-        * found, creates one. The result is stored to iSubDir.
-        *
-        * @param aPath path
-        */
-        void FindSubDirL( const TDesC& aPath );
-
-        /**
-        * Calculates entries from the path.
-        *
-        * @param aPath Path.
-        * @returm      Entrycount on the path.
-        */
-        TInt FileCountL( const TDesC& aPath );
-        
-        /**
-        * Returns the drive section of the file path,
-        * according to preferred cenrep setting. If drive
-        * is locked or not present, the next available drive is
-        * tried. If no available drives found, system drive is used.
-        * Stores value to iPreferredMemoryDrivePath.
-        *
-        * @return   The drive section of the file path.
-        */
-        const TDesC& UsedMemoryDesL();
-
-        /**
-        * Stops iDownloadProgressTimer.
-        */
-        void StopProgressTimer();
-
-        /**
-        * Starts iDownloadProgressTimer.
-        */
-        void StartProgressTimer();
-
-    private: //data
-    
-        /**
-        * S60 Download manager client object.
-        */
-        RHttpDownloadMgr iDownloadManager;
-
-        /**
-        * Storage class for user name, used for 16->8 bit conversion.
-        * This is member variable to reduce stack usage.
-        */
-        TBuf8<KMaxDefAttrLength> iUserName;
-
-        /**
-        * Storage class for password, used for 16->8 bit conversion.
-        * This is member variable to reduce stack usage.
-        */
-        TBuf8<KMaxDefAttrLength> iPassword;
-
-        /**
-        * Storage class for url, used for 16->8 bit conversion.
-        * This is member variable to reduce stack usage.
-        */
-        TBuf8<KMaxUrlLength> iUrl;
-        
-        /**
-        * Observer of this class.
-        */
-        MVcxMyVideosDownloadUtilObserver& iObserver;
-
-        /**
-        * Used to delete download asynchronously, own.
-        */
-        CVcxMyVideosTimer* iDownloadDeleteTimer;
-
-        /**
-        * Used to update download progresses, own.
-        */
-        CVcxMyVideosTimer* iDownloadProgressTimer;
-
-        /**
-        * Downloads which are deleted asynchronously are stored here.
-        */
-        RArray<TInt32> iDownloadsToDelete;         
-
-        /**
-        * Delete content flags for async download delete are stored here.
-        */
-        RArray<TBool> iDeleteContent;
-        
-        /**
-        * connectionutility
-        */
-        CVcxConnectionUtility* iConnUtil;
-    
-        /**
-        * iMediatorEventProvider
-        */
-        CMediatorEventProvider* iMediatorEventProvider;
-
-        /**
-        * IAP currently set to Download Manager.
-        * is used to avoid new set if IAP is the same already.
-        */
-        TUint32 iCurrentIap;
-        
-        /**
-        * Used for storing the drive section of the path,
-        * c:, e:, etc.
-        */
-        TBuf<2> iUsedMemoryDrivePath;
-        
-        /**
-        * Drive used for downloading.
-        */
-        TInt iUsedDrive;
-        
-        /**
-        * Fileserver session.
-        */
-        RFs& iFs;
-        
-        /**
-        * SubDir is stored here.
-        */
-        TBuf<KVcxMaxSubDirsLength> iSubDir;
-        
-        /**
-        * Flag that tells do we really have a roaming situation.
-        */
-        TBool iRoamingOngoing;
-    };
-
-#endif   // VCXMYVIDEOSDOWNLOADUTIL_H
--- a/videocollection/mpxmyvideoscollection/download/src/vcxmyvideosdownloadutil.cpp	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1354 +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 the License "Eclipse Public License v1.0"
-* which accompanies 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 FILES
-#include <mpxlog.h>
-#include <utf.h>
-#include <mpxmediacontainerdefs.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxcollectionpluginobserver.h>
-#include <mpxmessagegeneraldefs.h>
-#include <mpxcommandgeneraldefs.h>
-#include <mpxcollectioncommanddefs.h>
-
-#include "vcxmyvideosdownloadutil.h" //this has to be before vcxconnectionutility.h
-#include <ipvideo/vcxconnectionutility.h>
-
-#include <vcxmyvideosdefs.h>
-#include <vcxmyvideosuids.h>
-#include <mpxmediageneraldefs.h>
-#include <MediatorEventProvider.h>
-#include <centralrepository.h>
-#include <bautils.h>
-#include "vcxmyvideosdrivemonitor.h"
-
-// CONSTANTS
-#ifdef _DEBUG
-_LIT(KVcxHttpDlCreatedDes, "DlCreated");
-_LIT(KVcxHttpDlInprogressDes, "DlInprogress");
-_LIT(KVcxHttpDlPausedDes, "DlPaused");
-_LIT(KVcxHttpDlCompletedDes, "DlCompleted");
-_LIT(KVcxHttpDlFailedDes, "DlFailed");
-_LIT(KVcxHttpDlMovedDes, "DlMoved");
-_LIT(KVcxHttpDlMediaRemovedDes, "DlMediaRemoved");
-_LIT(KVcxHttpDlMediaInsertedDes, "DlMediaInserted");
-_LIT(KVcxHttpDlPausableDes, "DlPausable");
-_LIT(KVcxHttpDlNonPausableDes, "DlNonPausable");
-_LIT(KVcxHttpDlDeletedDes, "DlDeleted");
-_LIT(KVcxHttpDlAlreadyRunningDes, "DlAlreadyRunning");
-_LIT(KVcxHttpDlDeletingDes, "DlDeleting");
-_LIT(KVcxHttpDlMultipleMOStartedDes, "DlMultipleMOStarted");
-_LIT(KVcxHttpDlMultipleMOCompletedDes, "DlMultipleMOCompleted");
-_LIT(KVcxHttpDlMultipleMOFailedDes, "DlMultipleMOFailed");
-
-_LIT(KVcxUnknownStateDes, "UnknownStateDes");
-
-
-_LIT(KVcxHttpProgNoneDes, "ProgNone");
-_LIT(KVcxHttpStartedDes, "Started");
-_LIT(KVcxHttpProgCreatingConnectionDes, "ProgCreatingConnection");
-_LIT(KVcxHttpProgConnectionNeededDes, "ProgConnectionNeeded");
-_LIT(KVcxHttpProgConnectedDes, "ProgConnected");
-_LIT(KVcxHttpProgConnectionSuspendedDes, "ProgConnectionSuspended");
-_LIT(KVcxHttpProgDisconnectedDes, "ProgDisconnected");
-_LIT(KVcxHttpProgDownloadStartedDes, "ProgDownloadStarted");
-_LIT(KVcxHttpContentTypeRequestedDes, "ContentTypeRequested");
-_LIT(KVcxHttpContentTypeReceivedDes, "ContentTypeReceived");
-_LIT(KVcxHttpProgSubmitIssuedDes, "ProgSubmitIssued");
-_LIT(KVcxHttpProgResponseHeaderReceivedDes, "ProgResponseHeaderReceived");
-_LIT(KVcxHttpProgResponseBodyReceivedDes, "ProgResponseBodyReceived");
-_LIT(KVcxHttpProgRedirectedPermanentlyDes, "ProgRedirectedPermanently");
-_LIT(KVcxHttpProgRedirectedTemporarilyDes, "ProgRedirectedTemporarily");
-_LIT(KVcxHttpProgDlNameChangedDes, "ProgDlNameChanged");
-_LIT(KVcxHttpProgContentTypeChangedDes, "ProgContentTypeChanged");
-_LIT(KVcxHttpProgCodDescriptorDownloadedDes, "ProgCodDescriptorDownloaded");
-_LIT(KVcxHttpProgCodDownloadStartedDes, "ProgCodDownloadStarted");
-_LIT(KVcxHttpProgCodDescriptorAcceptedDes, "ProgCodDescriptorAccepted");
-_LIT(KVcxHttpProgCodLoadEndDes, "ProgCodLoadEnd");
-_LIT(KVcxHttpProgSupportedMultiPartDes, "ProgSupportedMultiPart");
-_LIT(KVcxHttpProgMovingContentFileDes, "ProgMovingContentFile");
-_LIT(KVcxHttpProgContentFileMovedDes, "ProgContentFileMoved");
-_LIT(KVcxUnknownProgressDes, "UnknownProgress");
-#endif
-
-const TInt KMaxPathLength = 255;
-
-_LIT( KVcxExtensionDcf, ".dcf" );
-_LIT( KVcxExtensionOcf, ".odf" );
-_LIT( KVcxExtensionDm, ".dm" );
-_LIT( KVcxExtensionMp4, ".mp4" );
-_LIT( KVcxExtensionMpeg4, ".mpeg4" );
-_LIT( KVcxExtensionM4v, ".m4v" );
-_LIT( KVcxExtension3gpp, ".3gpp" );
-_LIT( KVcxExtension3gp, ".3gp" );
-_LIT( KVcxExtensionRm, ".rm" );
-_LIT( KVcxExtensionMpg4, ".mpg4" );
-_LIT( KVcxExtensionRmvb, ".rmvb" );
-_LIT( KVcxExtension3g2, ".3g2" );
-_LIT( KVcxExtensionWmv, ".wmv" );
-_LIT( KVcxExtensionAsf, ".asf" );
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadUtil* CVcxMyVideosDownloadUtil::NewL(
-    MVcxMyVideosDownloadUtilObserver& aObserver, RFs& aFs )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::NewL");
-
-    CVcxMyVideosDownloadUtil* self = new (ELeave) CVcxMyVideosDownloadUtil( aObserver, aFs );
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadUtil::~CVcxMyVideosDownloadUtil()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::~CVcxMyVideosDownloadUtil");
-    iDownloadManager.Disconnect(); //disconnects all downloads and puts them to pause
-    iDownloadManager.Close();
-    delete iDownloadDeleteTimer;
-    iDownloadsToDelete.Close();
-    iDeleteContent.Close();
-
-    if ( iConnUtil )
-        {
-        iConnUtil->RemoveObserver( this );
-        iConnUtil->DecreaseReferenceCount();
-        }
-
-    delete iMediatorEventProvider;
-    delete iDownloadProgressTimer;
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadUtil::CVcxMyVideosDownloadUtil(
-        MVcxMyVideosDownloadUtilObserver& aObserver, RFs& aFs )
-: iObserver( aObserver ), iFs( aFs )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::CVcxMyVideosDownloadUtil");
-    }
-
-// ----------------------------------------------------------------------------
-// Symbian 2nd phase constructor can leave.
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::ConstructL ()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::ConstructL");
-    
-    TUid uid = TUid::Uid( KVcxUidMyVideosMpxCollection );
-
-    iDownloadManager.ConnectL( uid, *this, ETrue );
-    
-    iDownloadDeleteTimer = CVcxMyVideosTimer::NewL( 0, *this );
-    iDownloadProgressTimer = CVcxMyVideosTimer::NewL( 0, *this );
-
-    iDownloadsToDelete.Reset();
-    iDeleteContent.Reset();
-
-    iConnUtil = CVcxConnectionUtility::InstanceL();
-    iConnUtil->RegisterObserverL( this ); 
-    
-    iMediatorEventProvider = CMediatorEventProvider::NewL();
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::StartDownloadL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::StartDownloadL( CMPXMedia& aDownload )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::StartDownloadL");
-    // Requesting a new connection, update state
-    iRoamingOngoing = EFalse;
-    TInt err( KErrNone );
-
-    TUint32 iap( 0 );
-    iap = *(aDownload.Value<TUint>( KVcxMediaMyVideosIapId ));
-
-    if( !iap )
-        {
-        // no iap gotten yet. Use connectionutility to get one
-        err = iConnUtil->GetIap( iap, EFalse );
-
-        if( err != KErrNone || iap == 0 )
-            {
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: failed to get IAP from connectionutility: %d", err);
-            User::Leave( KErrCancel );
-            }        
-        }
-
-    //if not set, the default is used from commsdb
-    
-    if ( iap != iCurrentIap )
-        {
-        err = iDownloadManager.SetIntAttribute( EDlMgrIap, iap );
-        }
-        
-    iCurrentIap = iap;
-
-    if ( err != KErrNone )
-        {
-        MPX_DEBUG2("CVcxMyVideosDownloadUtil:: failed to set IAP: %d", err);
-        }
-
-    TMPXItemId mpxId = aDownload.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-
-    MPX_DEBUG2( "URL      = %S", &(aDownload.ValueText( KVcxMediaMyVideosRemoteUrl )) );
-    MPX_DEBUG2( "Username = %S", &(aDownload.ValueText( KVcxMediaMyVideosUsername )) );
-    MPX_DEBUG2( "Password = %S", &(aDownload.ValueText( KVcxMediaMyVideosPassword )) );
-    MPX_DEBUG2( "Filename = %S", &(aDownload.ValueText( KMPXMediaGeneralUri )) );
-    MPX_DEBUG2( "IAP ID   = %d", *(aDownload.Value<TUint>( KVcxMediaMyVideosIapId )) );
-    MPX_DEBUG2( "MDS ID   = %d", mpxId.iId1 );
-    
-    iUrl.Copy( aDownload.ValueText( KVcxMediaMyVideosRemoteUrl ) );
-        
-    TInt32 downloadId = 0;
-    
-    // try to get download id from the download request
-    if ( aDownload.IsSupported(KVcxMediaMyVideosDownloadId) )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: dl id is supported");
-        downloadId = static_cast<TInt32>(
-            aDownload.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ));
-        if ( downloadId != 0 )
-            {
-            MPX_DEBUG1("CVcxMyVideosDownloadUtil:: dl id found -> resuming download");
-            } 
-        }
-        
-    if ( downloadId == 0 )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: creating download");
-        RHttpDownload& dl =  iDownloadManager.CreateDownloadL( iUrl );
-        dl.GetIntAttribute( EDlAttrId, downloadId );
-        }
-    
-    RHttpDownload* download = Download( downloadId );
-    
-    if ( !download )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: no download found");
-        User::Leave( KErrNotFound );
-        }
-            
-    CnvUtfConverter::ConvertFromUnicodeToUtf8(iUserName,
-            aDownload.ValueText( KVcxMediaMyVideosUsername ) );
-    CnvUtfConverter::ConvertFromUnicodeToUtf8(iPassword,
-            aDownload.ValueText( KVcxMediaMyVideosPassword ) );    
-    download->SetStringAttribute( EDlAttrDestFilename,
-            aDownload.ValueText( KMPXMediaGeneralUri ) );        
-    download->SetStringAttribute( EDlAttrUsername, iUserName );
-    download->SetStringAttribute( EDlAttrPassword, iPassword );
-    download->SetBoolAttribute( EDlAttrSilent, EFalse) ;
-    download->SetBoolAttribute( EDlAttrNoContentTypeCheck, ETrue );
-        
-    err = download->Start();
-
-    if ( err != KErrNone )
-        {
-        MPX_DEBUG2("CVcxMyVideosDownloadUtil:: could not start download: %d", err);
-        }
-
-    aDownload.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, downloadId );
-    
-    if( !err )
-        {
-        NotifyDownloadStarted();
-        StartProgressTimer();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::PauseDownload
-// ----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDownloadUtil::PauseDownload( TUint32 aDownloadId )
-    {
-    RHttpDownload* download = Download( aDownloadId );
-    
-    if ( !download )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: no download found");
-        return KErrNotFound;
-        }
-        
-    return download->Pause();    
-    }
-    
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::HandleDMgrEventL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::HandleDMgrEventL( RHttpDownload& aDownload,
-    THttpDownloadEvent aEvent )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::HandleDMgrEventL");
-
-    TInt32 downloadId;
-    aDownload.GetIntAttribute( EDlAttrId, downloadId );
-
-#ifdef _DEBUG
-
-    MPX_DEBUG4("CVcxMyVideosDownloadUtil::HandleDMgrEventL(DL ID: %d, %S, %S)",
-            downloadId,
-            &GetS60DlProgressDes(aEvent.iProgressState),
-            &GetS60DlStateDes(aEvent.iDownloadState));
-
-    if ( aEvent.iProgressState == EHttpContentTypeReceived )
-        {
-        const TInt debugBufMaxSize = 255;
-        TBuf<debugBufMaxSize> contentType;
-        aDownload.GetStringAttribute( EDlAttrContentType, contentType );
-        MPX_DEBUG2("CVcxMyVideosDownloadUtil:: Content type = %S", &contentType);
-        }
-#endif
-
-    TInt8 progress( 0 );
-    TUint64 downloaded( 0 );
-    
-    TInt32 remoteFileSize;
-    aDownload.GetIntAttribute( EDlAttrLength, remoteFileSize );
-    
-    if ( remoteFileSize > 0 )
-        {
-        TBool silent;
-        aDownload.GetBoolAttribute( EDlAttrSilent, silent );
-        TBool progressive;
-        aDownload.GetBoolAttribute( EDlAttrProgressive, progressive );        
-        if ( !silent && !progressive )
-            {
-            // remote file size received, we can set download to silent mode.
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: setting download %d to silent mode", downloadId);
-            aDownload.SetBoolAttribute( EDlAttrSilent, ETrue );
-            }
-
-        if ( silent && progressive )
-            {
-            aDownload.SetBoolAttribute( EDlAttrSilent, EFalse );
-            }
-            
-        progress = DownloadProgress( aDownload, downloaded, EFalse );
-        }
-        
-    TVcxMyVideosDownloadState state;
-    
-    switch ( aEvent.iDownloadState )
-        {
-        case EHttpDlPaused:
-            {
-            state = EVcxMyVideosDlStatePaused;
-            iObserver.HandleDlEvent( state, static_cast<TUint32>(downloadId),
-                    progress, downloaded, 0, 0 );
-            NotifyIfNoActiveDownloads();
-            StopProgressTimer();
-            }
-            break;
-            
-        case EHttpDlCompleted:
-        case EHttpDlMultipleMOCompleted:
-            state = EVcxMyVideosDlStateDownloaded;
-            iObserver.HandleDlEvent(
-                    state, static_cast<TUint32>(downloadId), progress, downloaded, 0, 0 );
-            DeleteDownloadAsync( downloadId, EFalse /* dont delete content */ );
-            StopProgressTimer();
-            break;
-            
-        case EHttpDlFailed:
-        case EHttpDlMultipleMOFailed:
-            {
-            TInt32 errorId;
-            TInt32 globalErrorId;
-            aDownload.GetIntAttribute( EDlAttrErrorId, errorId );
-            aDownload.GetIntAttribute( EDlAttrGlobalErrorId, globalErrorId );
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: DL error ID: %d", errorId);
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: DL global error ID: %d", globalErrorId);
-
-            state = EVcxMyVideosDlStateFailed;
-            iObserver.HandleDlEvent(
-                    state,
-                    static_cast<TUint32>(downloadId),
-                    progress,
-                    downloaded,
-                    errorId,
-                    globalErrorId );
-            NotifyIfNoActiveDownloads();
-            StopProgressTimer();
-            }
-            break;
-
-            
-        case EHttpDlCreated:            
-        case EHttpDlInprogress:           
-        case EHttpDlMultipleMOStarted:
-            iObserver.HandleDlEvent( EVcxMyVideosDlStateDownloading,
-                    static_cast<TUint32>(downloadId), progress, downloaded, 0, 0 );
-            StartProgressTimer();
-            break;       
-
-        /// Download is going to be deleted. Cancel or download complete will trigger this.
-        case EHttpDlDeleting:
-        /// Download is deleted from another client instance. Normally not received, included here just to be sure.
-        case EHttpDlDeleted:
-            {
-            NotifyIfNoActiveDownloads();
-            StopProgressTimer();
-            }
-            break;
-
-        /// download is moved from one client instance to another one.
-        case EHttpDlMoved:
-        /// MMC card or other storage media is removed from the phone.
-        case EHttpDlMediaRemoved:
-        /** MMC card or other storage media inserted and 
-        * downloaded content file found on it. 
-        * If MMC card inserted, but (partially) downloaded content file 
-        * is not found on it, download is failed with error reason
-        * EContentFileIntegrity. */
-        case EHttpDlMediaInserted:
-        /** Download process can be paused again. This event only occurs after
-        * EHttpDlNonPausable. */
-        case EHttpDlPausable:
-        /// Download process cannot be paused, or the content will be lost.
-        case EHttpDlNonPausable:
-        /// Download is started when it's already progressing
-        case EHttpDlAlreadyRunning:
-        /// Internally used download event. Do NOT deal with them
-        case EHttpDlCancelTransaction:
-
-        default:
-            break;
-        }
-
-    }
-
-// ---------------------------------------------------------
-// CVcxMyVideosDownloadUtil::Download
-// ---------------------------------------------------------
-//        
-RHttpDownload* CVcxMyVideosDownloadUtil::Download( TUint32 aDownloadId )
-    {
-    if ( aDownloadId == 0 )
-        {
-        return NULL;
-        }
-    
-    TInt count = iDownloadManager.CurrentDownloads().Count();
-    TInt i;
-    TInt32 downloadId;
-    
-    for ( i = 0; i < count; i++ )
-        {
-        iDownloadManager.CurrentDownloads()[i]->GetIntAttribute( EDlAttrId, downloadId );
-        if ( downloadId == aDownloadId )
-            {
-            return iDownloadManager.CurrentDownloads()[i];
-            }
-        }
-    
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: no download found with %d ID", aDownloadId);        
-    return NULL;
-    }
-
-// ---------------------------------------------------------
-// CVcxMyVideosDownloadUtil::Download
-// ---------------------------------------------------------
-//        
-RHttpDownload* CVcxMyVideosDownloadUtil::Download( const TDesC& aFileName )
-    {    
-    MPX_FUNC("CVcxMyVideosDownloadUtil::Download()");
-
-    TInt count = iDownloadManager.CurrentDownloads().Count();
-    TInt i;
-    
-    for ( i = 0; i < count; i++ )
-        {
-        const TInt KMaxFileNameLength = 256;
-        TBuf<KMaxFileNameLength> fileName;
-        iDownloadManager.CurrentDownloads()[i]->GetStringAttribute( EDlAttrDestFilename, fileName );
-
-        MPX_DEBUG3("CVcxMyVideosDownloadUtil:: download[%d] filename = %S", i, &fileName);        
-
-        if ( aFileName == fileName )
-            {
-            return iDownloadManager.CurrentDownloads()[i];
-            }
-        }
-    
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: no download found with %S filename", &aFileName);        
-    return NULL;
-    }
-
-// ---------------------------------------------------------
-// CVcxMyVideosDownloadUtil::Downloads
-// ---------------------------------------------------------
-//        
-const CDownloadArray& CVcxMyVideosDownloadUtil::Downloads()
-    {    
-    return iDownloadManager.CurrentDownloads();
-    }
-
-// ---------------------------------------------------------
-// CVcxMyVideosDownloadUtil::CancelDownload
-// ---------------------------------------------------------
-//
-TInt CVcxMyVideosDownloadUtil::CancelDownload( TInt32 aId, TBool aDeleteContent )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::CancelDownload");
-
-    if ( iDownloadManager.CurrentDownloads().Count() < 1 )
-        {
-        return KErrNotFound;
-        }
-    
-    RHttpDownload* download = Download( aId );
-    
-    if ( !download )
-        {
-        return KErrNotFound;
-        }
-
-    MPX_DEBUG1("CVcxMyVideosDownloadUtil:: setting download to non silent mode");
-    download->SetBoolAttribute( EDlAttrSilent, EFalse );
-
-    if ( aDeleteContent )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: deleting content");
-        download->Reset();
-        }
-
-    MPX_DEBUG1("CVcxMyVideosDownloadUtil:: deleting download from dl manager");
-    download->Delete();
-
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::RequestIsRoamingAllowedL
-// -----------------------------------------------------------------------------
-//    
-TBool CVcxMyVideosDownloadUtil::RequestIsRoamingAllowedL()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::RequestIsRoamingAllowedL");
-    iDownloadManager.Disconnect();
-    iRoamingOngoing = ETrue;
-    return ETrue;
-    }
-    
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::IapChangedL
-// -----------------------------------------------------------------------------
-// 
-void  CVcxMyVideosDownloadUtil::IapChangedL()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::IapChangedL");	
-    if ( !iRoamingOngoing )
-        {
-		// This is not roaming situation, must not call GetIap()
-        return;
-        }
-    iRoamingOngoing = EFalse;
-    TUint32 iap( 0 );
-    TInt err = iConnUtil->GetIap( iap, EFalse );
-    if ( err == KErrNone )
-        {
-        iDownloadManager.SetIntAttribute( EDlMgrIap, iap );
-        // Since download pause state is always result of download manager, not from user,
-        // we can resume all
-        iDownloadManager.StartAll();
-        }
-    else
-        {
-        MPX_DEBUG2("CVcxMyVideosDownloadUtil::IapChangedL failed to get IAP from connectionutility: %d", err); 
-        }
-    }   
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::GetDownloadState
-// Gets MPX/MDS version of the download state.
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::GetDownloadState(
-        RHttpDownload& aDownload,
-        TVcxMyVideosDownloadState& aDownloadState )
-    {
-    TInt32 dlStateInDlManager;
-    aDownload.GetIntAttribute( EDlAttrState, dlStateInDlManager );
-
-    switch( dlStateInDlManager )
-        {
-        case EHttpDlPaused:
-            aDownloadState = EVcxMyVideosDlStatePaused;
-            break;
-            
-        case EHttpDlCompleted:
-            aDownloadState = EVcxMyVideosDlStateDownloaded;
-            break;
-            
-        case EHttpDlFailed:
-            aDownloadState = EVcxMyVideosDlStateFailed;
-            break;
-            
-        case EHttpDlCreated:            
-        case EHttpDlInprogress:
-            aDownloadState = EVcxMyVideosDlStateDownloading;
-            break;
-            
-        default:
-            aDownloadState = EVcxMyVideosDlStateNone;
-            break;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::DownloadProgress
-// -----------------------------------------------------------------------------
-//
-TInt8 CVcxMyVideosDownloadUtil::DownloadProgress( RHttpDownload& aDownload, TUint64& aDownloaded,
-                                                   TBool aAllowSilentReset )
-    {
-    TInt64 downloaded;
-    TInt32 fullSize;
-
-    TBool isProgressive;
-    aDownload.GetBoolAttribute( EDlAttrProgressive, isProgressive );
-
-    if ( isProgressive )
-        {
-        // this doesn't work if download is in silent mode
-        // unless it is in progressive mode
-        TInt32 downloaded32;
-        aDownload.GetIntAttribute( EDlAttrDownloadedSize, downloaded32 );
-        downloaded  = downloaded32;
-        }
-    else
-        {
-        const TInt KMaxFileNameLength = 256;
-        TBuf<KMaxFileNameLength> fileName;
-        aDownload.GetStringAttribute( EDlAttrDestFilename, fileName );
-    
-        TEntry entry;
-        TInt err = iFs.Entry( fileName, entry );
-        
-        if ( err != KErrNone )
-            {
-            MPX_DEBUG1("CVcxMyVideosDownloadUtil:: Could not find file entry.");
-            aDownloaded = 0;
-            return 0;
-            }
-            
-        downloaded = entry.iSize;
-        }
-
-    aDownload.GetIntAttribute( EDlAttrLength, fullSize );
-    
-    if( aAllowSilentReset && fullSize == KErrNotFound )
-        {    
-        
-        TBool silent;
-        aDownload.GetBoolAttribute( EDlAttrSilent, silent ) ;
-        if ( silent )
-            {
-            // if file size has corrupted, remove silent mode so that
-            // HandleDlMgrEvent can refresh size. This happens, in case
-            // we resume dl which have to start from the beginning
-            aDownload.SetBoolAttribute( EDlAttrSilent, EFalse );            
-            }
-        }
-    TInt64 progress64( 0 );
-    aDownloaded = downloaded;
-    TInt64 fullsize64( fullSize );
-    
-    if ( fullsize64 > 0 )
-        {
-        progress64 = 100 * aDownloaded / fullsize64;
-        }
-    
-    return static_cast<TInt8>( progress64 );
-    }
-    
-#ifdef _DEBUG
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::GetS60DlStateDes
-// -----------------------------------------------------------------------------
-//
-const TDesC& CVcxMyVideosDownloadUtil::GetS60DlStateDes( TInt32 aState )
-    {
-    switch ( aState )
-        {
-        case EHttpDlCreated:
-            return KVcxHttpDlCreatedDes;
-            
-        case EHttpDlInprogress:
-            return KVcxHttpDlInprogressDes;
-            
-        case EHttpDlPaused:
-            return KVcxHttpDlPausedDes;
-            
-        case EHttpDlCompleted:
-            return KVcxHttpDlCompletedDes;
-            
-        case EHttpDlFailed:
-            return KVcxHttpDlFailedDes;
-            
-        case EHttpDlMoved:
-            return KVcxHttpDlMovedDes;
-            
-        case EHttpDlMediaRemoved:
-            return KVcxHttpDlMediaRemovedDes;
-            
-        case EHttpDlMediaInserted:
-            return KVcxHttpDlMediaInsertedDes;
-            
-        case EHttpDlPausable:
-            return KVcxHttpDlPausableDes;
-            
-        case EHttpDlNonPausable:
-            return KVcxHttpDlNonPausableDes;
-
-        case EHttpDlDeleted:
-            return KVcxHttpDlDeletedDes;
-            
-        case EHttpDlAlreadyRunning:
-            return KVcxHttpDlAlreadyRunningDes;
-
-        case EHttpDlDeleting:
-            return KVcxHttpDlDeletingDes;
-
-        case EHttpDlMultipleMOStarted:
-            return KVcxHttpDlMultipleMOStartedDes;
-            
-        case EHttpDlMultipleMOCompleted:
-            return KVcxHttpDlMultipleMOCompletedDes;
-            
-        case EHttpDlMultipleMOFailed:
-            return KVcxHttpDlMultipleMOFailedDes;
-            
-        default:
-            return KVcxUnknownStateDes;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::GetS60DlProgressDes
-// -----------------------------------------------------------------------------
-//
-const TDesC& CVcxMyVideosDownloadUtil::GetS60DlProgressDes( TInt32 aProgress )
-    {
-    switch ( aProgress )
-        {
-        case EHttpProgNone:
-            return KVcxHttpProgNoneDes;
-            
-        case EHttpStarted:
-            return KVcxHttpStartedDes;
-            
-        case EHttpProgCreatingConnection:
-            return KVcxHttpProgCreatingConnectionDes;
-            
-        case EHttpProgConnectionNeeded:
-            return KVcxHttpProgConnectionNeededDes;
-        
-        case EHttpProgConnected:
-            return KVcxHttpProgConnectedDes;
-            
-        case EHttpProgConnectionSuspended:
-            return KVcxHttpProgConnectionSuspendedDes;
-            
-        case EHttpProgDisconnected:
-            return KVcxHttpProgDisconnectedDes;
-            
-        case EHttpProgDownloadStarted:
-            return KVcxHttpProgDownloadStartedDes;
-            
-        case EHttpContentTypeRequested:
-            return KVcxHttpContentTypeRequestedDes;
-            
-        case EHttpContentTypeReceived:
-            return KVcxHttpContentTypeReceivedDes;
-            
-        case EHttpProgSubmitIssued:
-            return KVcxHttpProgSubmitIssuedDes;
-            
-        case EHttpProgResponseHeaderReceived:
-            return KVcxHttpProgResponseHeaderReceivedDes;
-            
-        case EHttpProgResponseBodyReceived:
-            return KVcxHttpProgResponseBodyReceivedDes;
-            
-        case EHttpProgRedirectedPermanently:
-            return KVcxHttpProgRedirectedPermanentlyDes;
-            
-        case EHttpProgRedirectedTemporarily:
-            return KVcxHttpProgRedirectedTemporarilyDes;
-            
-        case EHttpProgDlNameChanged:
-            return KVcxHttpProgDlNameChangedDes;
-        
-        case EHttpProgContentTypeChanged:
-            return KVcxHttpProgContentTypeChangedDes;
-            
-        case EHttpProgCodDescriptorDownloaded:
-            return KVcxHttpProgCodDescriptorDownloadedDes;
-            
-        case EHttpProgCodDownloadStarted:
-            return KVcxHttpProgCodDownloadStartedDes;
-            
-        case EHttpProgCodDescriptorAccepted:
-            return KVcxHttpProgCodDescriptorAcceptedDes;
-            
-        case EHttpProgCodLoadEnd:
-            return KVcxHttpProgCodLoadEndDes;
-            
-        case EHttpProgSupportedMultiPart:
-            return KVcxHttpProgSupportedMultiPartDes;
-            
-        case EHttpProgMovingContentFile:
-            return KVcxHttpProgMovingContentFileDes;
-            
-        case EHttpProgContentFileMoved:
-            return KVcxHttpProgContentFileMovedDes;
-            
-        default:
-            return KVcxUnknownProgressDes;
-        }
-    }
-#endif
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::DeleteDownloadAsync
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::DeleteDownloadAsync( TInt32 aDownloadId, TBool aDeleteContent )
-    {
-    iDownloadsToDelete.Append( aDownloadId );
-    iDeleteContent.Append( aDeleteContent );
-    if ( !iDownloadDeleteTimer->IsActive() )
-        {
-        iDownloadDeleteTimer->After( 0 );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::TimerExpired
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::TimerExpired( CVcxMyVideosTimer* aTimer )
-    {
-    if ( aTimer == iDownloadDeleteTimer )
-        {
-        for ( TInt i = 0; i < iDownloadsToDelete.Count(); i++ )
-            {
-            CancelDownload( iDownloadsToDelete[i], iDeleteContent[i] );
-            }
-        iDownloadsToDelete.Reset();
-        iDeleteContent.Reset();
-        return;
-        }
-
-    if ( aTimer == iDownloadProgressTimer )
-        {
-        const CDownloadArray& downloads = Downloads();
-        
-        TInt count( downloads.Count() );
-        TInt32 downloadId;
-        TInt8 progress( 0 );
-        TUint64 downloaded;
-        TVcxMyVideosDownloadState downloadState;
-        
-        for ( TInt i = 0; i < count; i++ )
-            {
-            GetDownloadState( *(downloads[i]), downloadState );
-            if ( downloadState == EVcxMyVideosDlStateDownloading || 
-                 downloadState == EVcxMyVideosDlStatePaused )
-                {
-                downloads[i]->GetIntAttribute( EDlAttrId, downloadId );
-                progress = DownloadProgress( *(downloads[i]), downloaded, 
-                                            ( downloadState == EVcxMyVideosDlStateDownloading ) );
-                iObserver.HandleDlEvent( downloadState,
-                    static_cast<TUint32>(downloadId), progress, downloaded, 0, 0 );
-                }
-            }
-        NotifyIfNoActiveDownloads(); // Handles connection lost etc. state updates correctly.
-        StartProgressTimer();
-        return;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::ClearOrphanDownloadsL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::ClearOrphanDownloadsL( CMPXMedia& aVideoList )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::ClearOrphanDownloadsL");
-    
-    const CDownloadArray& downloads = Downloads();
-
-    CMPXMediaArray* videoArray = aVideoList.Value<CMPXMediaArray>(
-                                KMPXMediaArrayContents);    
-    
-    TBool found;
-    TInt32 downloadId;
-
-    for ( TInt i = 0; i < downloads.Count(); i++ )
-        {
-        downloads[i]->GetIntAttribute( EDlAttrId, downloadId );
-        found = EFalse;
-        for ( TInt j = 0; j < videoArray->Count(); j++ )
-            {
-            if ( (*videoArray)[j]->IsSupported( KVcxMediaMyVideosDownloadId ))
-                {
-                if ( (*videoArray)[j]->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) ==
-                        downloadId )
-                    {
-                    found = ETrue;
-                    break;
-                    }
-                }
-            }
-        if ( !found )
-            {
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: download id (%d) not found from MPX/MDS, deleting download!", downloadId );
-            CancelDownload( downloadId, ETrue /* delete content */);
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::NotifyDownloadStarted
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::NotifyDownloadStarted()
-    {
-    iMediatorEventProvider->RaiseEvent( TUid::Uid( KVcxNsMpxMediatorDomain ),
-                                        TUid::Uid( KVcxNsMpxMediatorCategory ), 
-                                        KVcxNsMpxEventDownloadStarted ,
-                                        TVersion( KVcxNsMpxEventVersion, 0, 0 ),
-                                        KNullDesC8() );
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::NotifyIfNoActiveDownloads
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::NotifyIfNoActiveDownloads()
-    {
-    if ( !ActiveDownloadCount() )
-        {
-        iMediatorEventProvider->RaiseEvent( TUid::Uid( KVcxNsMpxMediatorDomain ),
-                                            TUid::Uid( KVcxNsMpxMediatorCategory ), 
-                                            KVcxNsMpxEventAllDownloadsEnded,
-                                            TVersion( KVcxNsMpxEventVersion, 0, 0 ),
-                                            KNullDesC8() );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::NotifyDownloadCompleted
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::NotifyDownloadCompleted( const TDesC8& aMsg )
-    {
-    iMediatorEventProvider->RaiseEvent( TUid::Uid( KVcxNsMpxMediatorDomain ),
-                                        TUid::Uid( KVcxNsMpxMediatorCategory ), 
-                                        KVcxNsMpxEventDownloadCompleted,
-                                        TVersion( KVcxNsMpxEventVersion, 0, 0 ),
-                                        aMsg );
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::NotifyNewVideosCountDecreased
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::NotifyNewVideosCountDecreased( const TDesC8& aMsg )
-    {
-    iMediatorEventProvider->RaiseEvent( TUid::Uid( KVcxNsMpxMediatorDomain ),
-                                        TUid::Uid( KVcxNsMpxMediatorCategory ), 
-                                        KVcxNsMpxEventNewVideosCountDecreased,
-                                        TVersion( KVcxNsMpxEventVersion, 0, 0 ),
-                                        aMsg );
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::ActiveDownloadCount
-// ----------------------------------------------------------------------------
-//
-TInt32 CVcxMyVideosDownloadUtil::ActiveDownloadCount()
-    {
-    const CDownloadArray& dlarray = Downloads();
-    
-    TInt32 dlCount( 0 );
-    
-    TVcxMyVideosDownloadState state;
-    
-    for ( TInt i = dlarray.Count() - 1; i >=0; i-- )
-        {
-        GetDownloadState( *(dlarray[i]), state );
-
-        if( state == EVcxMyVideosDlStateDownloading )
-            {
-            dlCount++;
-            }
-        }
-    return dlCount;
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::CreateFilePathL
-// ----------------------------------------------------------------------------
-//
-HBufC* CVcxMyVideosDownloadUtil::CreateFilePathL( const CMPXMedia& aMedia )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::CreateFilePathL");
-    
-    HBufC* path = HBufC::NewL( KMaxPathLength );
-    CleanupStack::PushL( path ); // 1->
-    
-    TPtr pathPtr( path->Des() );
-    
-    UsedMemoryDesL(); // generates new value to iUsedMemoryDrivePath
-    
-    iSubDir.Zero();
-        
-    TInt counter = 0;
-    GeneratePathL( aMedia, pathPtr, counter );
-        
-    while( BaflUtils::FileExists( iFs, pathPtr ) )
-        {
-        GeneratePathL( aMedia, pathPtr, ++counter );                
-        }
-
-    TText badChar( ' ' );
-    TInt badCharLoc( KErrNotFound );
-    while ( ! iFs.IsValidName( pathPtr, badChar ) )
-        {
-        if ( badChar != ' ' )
-            {
-            badCharLoc = pathPtr.LocateReverse( badChar );
-            if ( KErrNotFound != badCharLoc )
-                {
-                pathPtr[badCharLoc] = '_';
-                }
-            }
-        // Note, for some reason File Server's IsValidName() returns EFalse if there
-        // is question mark as last character of string, but fails to return the
-        // correct character in parameter badChar. Must get past that to avoid never
-        // ending loop. Reported to symbian with EJSI-7LZG8C.
-        else
-            {
-            for ( TInt i = 0; i < pathPtr.Length(); i++ )
-                {
-                if ( pathPtr[i] == '?' || pathPtr[i] == '*' )
-                    {
-                    pathPtr[i] = '_';
-                    }
-                }
-            }
-        }
-
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: path = %S", path);
-
-    CleanupStack::Pop( path ); // <-1
-    return path;
-    }
-    
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::GeneratePathL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::GeneratePathL( const CMPXMedia& aMedia, TDes& aPath, TInt aCounter )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::GeneratePathL");
-
-    _LIT( KBasePathNormal, "\\My Videos\\Downloads\\" );
-    _LIT( KBasePathSystemDrive, "\\Data\\My Videos\\Downloads\\" );
-    
-    aPath.Zero();
-    aPath = iUsedMemoryDrivePath;
-    
-    if ( iUsedDrive == iFs.GetSystemDrive() )
-        {
-        aPath.Append( KBasePathSystemDrive );
-        }
-    else
-        {
-        aPath.Append( KBasePathNormal );
-        }
-        
-    if ( iSubDir.Length() == 0 )
-        {
-        FindSubDirL( aPath ); // recalculates iSubDir
-        }
-        
-    aPath.Append( iSubDir );
-
-    TPtrC title( aMedia.ValueText( KMPXMediaGeneralTitle ) );
-    if ( title.Length() == 0 )
-        {
-        _LIT( KNameless, "Default");
-        aPath.Append( KNameless );
-        }
-    else
-        {
-        const TInt KVcxMaxCounterAndExtension( 12 ); // 6 + 6
-        TInt maxTitle = aPath.MaxLength() - aPath.Length() - KVcxMaxCounterAndExtension;
-        aPath.Append( title.Left( title.Length() <= maxTitle ? title.Length() : maxTitle ) );
-        }
-
-    //001-009
-    //010-099
-
-    if ( aCounter > 0 )
-        {    
-        if ( aCounter < 10 )
-            {
-            aPath.Append( _L("_(00") );
-            }
-        else if ( aCounter > 9 && aCounter < 100 )
-            {
-            aPath.Append( _L("_(0") );
-            }
-        TBuf<8> buf;
-        buf.Format( _L("%d)"), aCounter );
-        aPath.Append( buf );
-        }
-
-    // The algorithm is not final, this is the best we can do with current SW.
-    // See errors EJSI-7LZHLU, EJSI-7M2BW7, EJSI-7M2HMV.
-    //
-    TBool extFound( EFalse );
-    TInt extPos = aMedia.ValueText( KVcxMediaMyVideosRemoteUrl ).LocateReverse('.');
-    if ( extPos != KErrNotFound )
-        {
-        TPtrC extension( aMedia.ValueText( KVcxMediaMyVideosRemoteUrl ).Mid( extPos ) );
-        TInt extensionLength( KErrNotFound );
-        
-        if ( extension.FindF( KVcxExtensionDcf ) == 0 )
-            {
-            extensionLength = KVcxExtensionDcf().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionOcf ) == 0 )
-            {
-            extensionLength = KVcxExtensionOcf().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionDm ) == 0 )
-            {
-            extensionLength = KVcxExtensionDm().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionMp4 ) == 0 )
-            {
-            extensionLength = KVcxExtensionMp4().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionMpeg4 ) == 0 )
-            {
-            extensionLength = KVcxExtensionMpeg4().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionM4v ) == 0 )
-            {
-            extensionLength = KVcxExtensionM4v().Length();
-            }
-        else if ( extension.FindF( KVcxExtension3gpp ) == 0 )
-            {
-            extensionLength = KVcxExtension3gpp().Length();
-            }
-        else if ( extension.FindF( KVcxExtension3gp ) == 0 )
-            {
-            extensionLength = KVcxExtension3gp().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionRm ) == 0 )
-            {
-            extensionLength = KVcxExtensionRm().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionMpg4 ) == 0 )
-            {
-            extensionLength = KVcxExtensionMpg4().Length();
-            }
-        else if ( extension.FindF( KVcxExtensionRmvb ) == 0 )
-            {
-            extensionLength = KVcxExtensionRmvb().Length();
-            }
-        else if ( extension.FindF( KVcxExtension3g2 ) == 0 )
-            {
-            extensionLength = KVcxExtension3g2().Length();
-            }    
-        else if ( extension.FindF( KVcxExtensionWmv ) == 0 )
-            {
-            extensionLength = KVcxExtensionWmv().Length();
-            }    
-        else if ( extension.FindF( KVcxExtensionAsf ) == 0 )
-            {
-            extensionLength = KVcxExtensionAsf().Length();
-            }            
-
-        if ( extensionLength > 0 )
-            {
-            // Remove possible extra characters after actual extension.
-            if ( extension.Length() > extensionLength )
-                {
-                extension.Set( extension.Left( extensionLength ) );
-                }
-
-            extFound = ETrue;
-            aPath.Append( extension );
-            }
-        }
-
-    if ( ! extFound )
-        {
-        aPath.Append( KVcxExtensionMp4 );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::FindSubDirL
-// Finds subdir and stores it to iSubDir
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::FindSubDirL( const TDesC& aPath )
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::FindSubDirL");
-
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: aPath = %S", &aPath);
-
-    _LIT(KSubDirFormatterDes, "%d\\");
-
-    TBuf<KMaxPathLength> path;
-    TBuf<KVcxMaxSubDirsLength> foundSubDirs;
-    TBuf<KVcxMaxSubDirLength> currentSubDir;
-        
-    //search subdirs
-    TBool found;
-    TInt subDirCounter;
-    TInt fileCount = 0;
-    for ( TInt i = 0; i < KVcxSubDirLevels; i++ )
-        {
-        found         = EFalse;
-        subDirCounter = 1;
-        while( !found )
-            {
-            currentSubDir.Format( KSubDirFormatterDes, subDirCounter );
-            path.Zero();
-            path.Append( aPath ); 
-            path.Append( foundSubDirs ); 
-            path.Append( currentSubDir );        
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: testing path: %S", &path);
-            fileCount = FileCountL( path );
-            MPX_DEBUG2("CVcxMyVideosDownloadUtil:: file count = %d", fileCount);
-            if ( fileCount < KVcxMaxItemsInDir )
-                {
-                found = ETrue;
-                foundSubDirs.Append( currentSubDir );
-                }
-            else
-                {
-                subDirCounter++;
-                }
-            }
-        }
-    
-    iSubDir = foundSubDirs;       
-    
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: calling ensurepath for %S", &path);
-    BaflUtils::EnsurePathExistsL( iFs, path );
-    
-    MPX_DEBUG2("CVcxMyVideosDownloadUtil:: iSubDir = %S", &iSubDir);
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::FileCount
-// ----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDownloadUtil::FileCountL( const TDesC& aPath )
-    {
-    TInt count = 0; // return 0 in case of fail
-    
-    CDir* dir = NULL;
-    TInt err = iFs.GetDir( aPath, KEntryAttNormal | KEntryAttMatchMask, ESortBySize, dir );
-    if ( err != KErrNone )
-        {
-        MPX_DEBUG2("CVcxMyVideosDownloadUtil:: GetDir failed: %d", err);
-        }
-    else
-        {
-        count = dir->Count();
-        }
-    delete dir;
-    return count;
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::UsedMemoryDesL
-// ----------------------------------------------------------------------------
-//
-const TDesC& CVcxMyVideosDownloadUtil::UsedMemoryDesL()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadUtil::UsedMemoryDesL");
-
-    CVcxMyVideosDriveMonitor* driveMonitor = CVcxMyVideosDriveMonitor::NewL( iFs );
-    CleanupStack::PushL( driveMonitor ); // 1->
-    driveMonitor->GetUsedMemoryL( iUsedDrive );    
-    CleanupStack::PopAndDestroy( driveMonitor ); // <-1
-               
-    TInt driveChar = 'a' + iUsedDrive;
-    iUsedMemoryDrivePath.Zero();
-    iUsedMemoryDrivePath.Append( driveChar );
-    _LIT(KColon, ":"); 
-    iUsedMemoryDrivePath.Append( KColon );
-    return iUsedMemoryDrivePath;
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::StopProgressTimer
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::StopProgressTimer()
-    {
-    if ( ActiveDownloadCount() == 0 )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: stopped iDownloadProgressTimer");
-        iDownloadProgressTimer->Cancel();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadUtil::StartProgressTimer
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadUtil::StartProgressTimer()
-    {
-    if ( !iDownloadProgressTimer->IsActive() && ActiveDownloadCount() > 0 )
-        {
-        MPX_DEBUG1("CVcxMyVideosDownloadUtil:: started iDownloadProgressTimer");
-        iDownloadProgressTimer->After( 3000000 );
-        }
-    }
--- a/videocollection/mpxmyvideoscollection/group/vcxmyvideoscollectionplugin.mmp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/group/vcxmyvideoscollectionplugin.mmp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,6 @@
 
 
 
-
 #include <bldvariant.hrh>
 #include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
@@ -38,20 +37,17 @@
 SOURCE          vcxmyvideoscategories.cpp
 SOURCE          vcxmyvideosmessagelist.cpp
 SOURCE          vcxmyvideosasyncfileoperations.cpp
-SOURCE          vcxmyvideosdownloadcache.cpp
 SOURCE          vcxmyvideosdrivemonitor.cpp
 SOURCE          vcxmyvideosdriveinfo.cpp
 SOURCE          vcxmyvideosdrivemonitorevent.cpp
 SOURCE          vcxmyvideosactivetask.cpp
 SOURCE          vcxmyvideosopenhandler.cpp
+SOURCE          vcxmyvideosmdsalbums.cpp
+SOURCE          vcxmyvideosmdscmdqueue.cpp
+SOURCE          vcxmyvideosalbums.cpp
+SOURCE          vcxmyvideosalbum.cpp
 SOURCE          vcxmyvideosasyncfilecopy.cpp
 
-SOURCEPATH      ../download/src
-SOURCE          vcxmyvideosdownloadutil.cpp
-
-SOURCEPATH      ../src
-SOURCE          vcxmyvideostimer.cpp
-
 SOURCEPATH      ../data
 
 START RESOURCE  vcxmyvideoscollectionplugin.RSS
@@ -59,7 +55,6 @@
 END
 
 USERINCLUDE     ../inc
-USERINCLUDE     ../download/inc
 USERINCLUDE     ../../inc
 
 APP_LAYER_SYSTEMINCLUDE
@@ -73,10 +68,6 @@
 LIBRARY         flogger.lib
 LIBRARY         mdeclient.lib
 LIBRARY         efsrv.lib
-LIBRARY         downloadmgr.lib
 LIBRARY         charconv.lib
-LIBRARY         vcxconnectionutility.lib
-LIBRARY         mediatorclient.lib
 LIBRARY         centralrepository.lib
-LIBRARY         drmutility.lib
-LIBRARY         platformenv.lib
\ No newline at end of file
+LIBRARY         PlatformEnv.lib
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosactivetask.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosactivetask.h	Wed Jun 09 09:44:23 2010 +0300
@@ -28,11 +28,22 @@
 NONSHARABLE_CLASS( MVcxMyVideosActiveTaskObserver )
     {
 public:
+    
+    enum TStepResult
+        {
+        EMoreToCome,
+        EDone,
+        /**
+         * Observer is responsible for calling Done or ContinueStepping if returning this.
+         */
+        EStopStepping
+        };
+    
     /**
     * Handle the execution of a step
-    * @return ETrue if complete, EFalse if more to do
+    * @return TStepResult
     */
-    virtual TBool HandleStepL() = 0;
+    virtual TStepResult HandleStepL() = 0;
     /**
     * Handle the completion of the operation
     */
@@ -84,6 +95,30 @@
     */
     CMPXCommand& GetCommand();
 
+    /**
+    * Get the command for the current task.
+    * @return the current command, ownership does not move.
+    */        
+    CMPXMedia* Command();
+    
+    /**
+     * If observer returns EStopStepping from HandleStepL, then observer must call
+     * this or ContinueStepping when sub operation is finished.
+     * Can be used to run async operations.
+     */
+    void Done();
+
+    /**
+     * If observer returns EStopStepping from HandleStepL, then observer must call
+     * this or Done when sub operation is finished.
+     * Can be used to run async operations.
+     */
+    void ContinueStepping();
+
+    /**
+     * Add some functionality to CActive::Cancel
+     */
+    void Cancel();
 
 protected: // From base class
 
@@ -91,7 +126,7 @@
     * From CActive
     */
     void RunL();
-
+    
     /**
     * From CActive
     */
@@ -114,6 +149,13 @@
     */
     void ConstructL();
 
+public:
+    /**
+     * Set to ETrue when stepping is stopped.
+     * Cancel or Done has to be called.
+     */
+    TBool iStopped;
+
 private: // data
 
     CMPXCommand*  iCurCommand;  // Current Command
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosalbum.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,221 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Class representing album in My Videos collection.
+*/
+
+
+#ifndef CVCXMYVIDEOSALBUM_H
+#define CVCXMYVIDEOSALBUM_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+class CMPXMedia;
+class CVcxMyVideosCollectionPlugin;
+
+// CLASS DECLARATION
+
+/**
+ * Contains information about video which belongs to some album.
+ * These are stored to CVcxMyVideosAlbum::iVideoList.
+ */
+NONSHARABLE_CLASS(TVcxMyVideosAlbumVideo)
+    {
+    public:
+
+        /**
+         * Constructor.
+         */
+        TVcxMyVideosAlbumVideo();
+
+        /**
+        * = operator.
+        */        
+        TVcxMyVideosAlbumVideo& operator=( const TVcxMyVideosAlbumVideo& aVideo );
+    private:
+        
+        /**
+        * Set values.
+        */
+        void Set( TUint32 aMdsId, TUint32 aRelationMdsId, CMPXMedia* aVideo );
+
+    public:
+        TUint32    iMdsId;         //Video object ID in MDS.
+        TUint32    iRelationMdsId; //Relation ID in MDS, this is used when removing items from album.
+        CMPXMedia* iMedia;
+    };
+
+/**
+ * Contains list of videos belonging to an album. Videos can be searched, added and
+ * removed. Videos are kept in sorting order by MDS ID to speed up access. Pointers
+ * to media objects in collection cache are also stored to speed up access.
+ * Contains also logic for keeping album media attributes up to date.
+ */
+NONSHARABLE_CLASS(CVcxMyVideosAlbum) : public CBase
+    {    
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~CVcxMyVideosAlbum();
+
+    /**
+     * Two-phased constructor.
+     */
+    static CVcxMyVideosAlbum* NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    /**
+     * Two-phased constructor.
+     */
+    static CVcxMyVideosAlbum* NewLC( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    // new methods
+    
+    /**
+     * Sets up this album.
+     * 
+     * @param aAlbum  Media class to set from.
+     */
+    void SetL( /*CMPXMedia& aAlbum*/ );
+    
+    /**
+     * Sorts iVideoList by MDS ID.
+     */
+    void Sort();
+    
+    /**
+     * Checks if aMdsId belongs to this album. Checking is
+     * done using bisection method.
+     * 
+     * @param aMdsId  Id to check.
+     */
+    TBool BelongsToAlbum( TUint32 aMdsId );
+
+    /**
+     * Finds video from iVideoList. Uses bisection method, ie
+     * is fast.
+     * 
+     * @param aMdsId  Video to find.
+     * @param aVideo  If found, this is filled with data.
+     * @param aIndex  Position in iVideoList where from the video
+     *                was found.
+     * @return        System-wide error code. If != KErrNone, then
+     *                aVideo and aIndex won't contain valid data.
+     */
+    TInt Video( TUint32 aMdsId, TVcxMyVideosAlbumVideo& aVideo, TInt& aIndex );
+
+    /**
+     * Adds aVideo to this album. The id array is kept in ascending order.
+     * 
+     * @param aVideo  Video to add.
+     */
+    void AddL( TVcxMyVideosAlbumVideo aVideo );
+
+    /**
+     * Removes videos from this album.
+     * 
+     * @param aMdsIds Array containing IDs of the videos to remove.
+     */
+    void Remove( RArray<TUint32>& aMdsIds );
+
+    /**
+     * Removes aMdsId from this album.
+     * 
+     * @param aMdsId    ID to remove.
+     * @param aCompress If ETrue, then Compress is called to iVideoList.
+     *                  ETrue as default.
+     */
+    void Remove( TUint32 aMdsId, TBool aCompress = ETrue );
+    
+    /**
+     * Used for keeping RArray<TVcxMyVideosAlbumVideo> in integer order by
+     * TVcxMyVideosAlbumVideo::iMdsId.
+     * 
+     * @param aVideo1 Video to compare
+     * @param aVideo2 Video to compare
+     * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
+     *         aVideo2.
+     */
+    static TInt CompareVideosByMdsId( const TVcxMyVideosAlbumVideo& aVideo1,
+            const TVcxMyVideosAlbumVideo& aVideo2 );
+
+    /**
+     * Creates video list belonging to this album. Ownership goes to caller.
+     * 
+     * @return Media containing media array. Array items are videos.
+     */
+    CMPXMedia* CreateVideoListL();
+
+    /**
+     * Appends items from aFromVideoList to aToVideoList if they belong to
+     * this album.
+     * 
+     * @param aFromVideoList     From list.
+     * @param aToVideoList       To List.
+     * @param aNewItemStartIndex Start index of the copy. Items in aFromVideoList before this
+     *                           value are ignored.
+     */
+    void AppendToVideoListL( CMPXMedia& aFromVideoList,
+            CMPXMedia& aToVideoList, TInt aNewItemStartIndex );
+
+    /**
+     * Calculates KVcxMediaMyVideosCategoryItemCount, KVcxMediaMyVideosCategoryNewItemCount,
+     * KVcxMediaMyVideosCategoryNewItemName and KMPXMediaGeneralDate attributes to iMedia.
+     * 
+     * @param aStartIndex  Start position of the calculations in iVideoList.
+     *                     Can be used to update values when items are appended
+     *                     to old list, without calculating everything from scratch.
+     */
+    void CalculateAttributesL( TInt aStartIndex = 0 );
+    
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CVcxMyVideosAlbum( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private: //data
+    CVcxMyVideosCollectionPlugin& iCollection;
+    
+public: //data
+    
+    /**
+     * MDS ID of this album.
+     */
+    TUint32 iMdsId;
+
+    /**
+     * MPX media object representing this album in collection, not own.
+     * The item is owned by CVcxMyVideosAlbums::iAlbumList
+     */
+    CMPXMedia* iMedia;
+
+    /**
+     * Array containing info about videos belonging to this album.
+     */
+    RArray<TVcxMyVideosAlbumVideo> iVideoList;
+            
+    };
+
+#endif // CVCXMYVIDEOSALBUM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosalbums.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,366 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Albums related collection functionality.
+*/
+
+
+
+#ifndef VCXMYVIDEOSALBUMS_H
+#define VCXMYVIDEOSALBUMS_H
+
+// INCLUDES
+#include <mdequery.h>
+#include "vcxmyvideosmdsdb.h"
+#include "vcxmyvideosalbum.h"
+
+// FORWARD DECLARATIONS
+class CVcxMyVideosMdsDb;
+class CMPXMedia;
+class CVcxMyVideosCollectionPlugin;
+class CVcxMyVideosAlbum;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Albums related collection functionality.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosAlbums) : public CBase, public MVcxMyVideosMdsAlbumsObserver
+    {    
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor
+        * @return object constructed
+        */
+        static CVcxMyVideosAlbums* NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosAlbums();
+
+    public: // new methods
+
+        /**
+         * Returns album from iAlbums array by MDS ID. Ownership does not move.
+         * 
+         * @param aMdsId  MDS ID of the album to get.
+         * @param aPos    If given, then the position index in iAlbums is written here.
+         *                Ownership does not move.
+         * @return        Pointer to album or NULL if not found.
+         */
+        CVcxMyVideosAlbum* Album( TUint32 aMdsId, TInt* aPos = NULL );
+        
+        /**
+        * Creates iAlbumList if it doesn't exist yet. The list is populated
+        * from async callback, HandleGetAlbumsResp().
+        */
+        void CreateAlbumListL();
+                
+        /**
+         * Fetches MDS IDs from MDS for all videos belonging to albums.
+         * Ie fills iAlbums[*]->iVideoList[*].iMdsId (and iAlbums[*]->iVideoList[*].iRelationMdsId) fields.
+         * Causes several async calls to MDS. 
+         */
+        void GetAlbumContentIdsL();
+
+        /**
+         * Adds videos to album.
+         * 
+         * @param aCmd  See attribute usage from vcxmyvideosdefs.h.
+         */
+        void AddVideosToAlbumL( CMPXMedia* aCmd );
+
+        /**
+         * Removes videos from album.
+         * 
+         * @param aCmd  See attribute usage from vcxmyvideosdefs.h.
+         */
+        void RemoveVideosFromAlbumL( CMPXMedia* aCmd );
+
+        /**
+         * Adds album to MDS and to this class. KMPXMediaGeneralTitle
+         * should be set in aCmd. Upon completion, the KMPXMediaGeneralId
+         * attribute contains the new MPX item ID. Leaves if could
+         * not add to MDS.
+         * 
+         * @param aCmd  Command object received from collection client.
+         */
+        void AddAlbumL( CMPXMedia& aCmd );
+        
+        /**
+         * Removes albums from MDS. MDS delete events will clean up albums
+         * from this class.
+         * 
+         * @param aCmd  MPX command received from the client. Contains media array,
+         *              which contains medias with album IDs set to KMPXMediaGeneralId.
+         *              Ownership does not move. 
+         */
+        void RemoveAlbumsFromMdsOnlyL( CMPXMedia* aCmd );
+        
+        /**
+         * Removes albums from this object (iAlbumList and iAlbums).
+         * Called from MDS delete event. Album IDs which were removed are
+         * also removed from aAlbumIds array. After the call aAlbumIds
+         * will contain items which were not found and not deleted.
+         * Sends appropriate events to collection client.
+         * 
+         * @param aAlbumIds  Album IDs to be removed.
+         */
+        void RemoveAlbumsL( RArray<TUint32>& aAlbumIds );
+
+        /**
+         * Removes album from this class (iAlbumList and iAlbums).
+         * Adds event to message list but does not send it.
+         * 
+         * @param aMdsIds    Album MDS ID to be removed.
+         * @param aCompress  If ETrue, then iAlbums is compressed,
+         *                   otherwise not.
+         * @return           ETrue if album was found and removed.
+         */
+        TBool RemoveAlbumL( TUint32 aMdsId, TBool aCompress );
+        
+        /**
+         * Fetches albums from MDS. This is called from MDS insert event.
+         * 
+         * @param aAlbumIds  Album IDs to fetch.
+         */
+        void AddAlbumsFromMdsL( RArray<TUint32>& aAlbumIds );
+
+        /**
+         * Updates albums from MDS. This is called from MDS modify event.
+         * 
+         * @param aAlbumIds  Album IDs to update.
+         */
+        void UpdateAlbumsFromMdsL( RArray<TUint32>& aAlbumIds );
+
+        /**
+         * Updates album attributes, does not write to MDS. Adds
+         * modify event to iCollection.iMessageList if necessarry.
+         * 
+         * @param aAlbum  New values are read from this.
+         * @return        ETrue if album was modified, EFalse otherwise.
+         */
+        TBool UpdateAlbumL( const CMPXMedia& aAlbum );
+
+        /**
+         * Calculates and updates album media attributes.
+         */
+        void CalculateAttributesL();
+        
+        /**
+         * Called when video's New Video flag changes. Calculates
+         * album attributes for the affected albums. Adds events
+         * to iCollection.iMessageList but does not send them.
+         * 
+         * @param aMdsId  MDS ID of the changed video.
+         */
+        void NewVideoFlagChangedL( TUint32 aMdsId );
+
+        /**
+         * Called when video's title changes. Calculates
+         * album attributes for the affected albums. Adds events
+         * to iCollection.iMessageList but does not send them.
+         * 
+         * @param aMdsId  MDS ID of the changed video.
+         */
+        void VideoTitleChangedL( TUint32 aMdsId );
+        
+        /**
+         * Called when video is added or removed from cache. Adds changed
+         * album indexes to iChangedAlbums.
+         */
+        void VideoAddedOrRemovedFromCacheL( CMPXMedia& video );
+
+        /**
+         * Goes through iChangedAlbums and updates album attributes and adds
+         * changed events.
+         */
+        void UpdateChangedAlbumsL();
+
+protected:
+        
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Process albums arriving from MDS. Response to VcxMyVideosMdsAlbums::GetAlbumsL.
+         */
+        void HandleGetAlbumsRespL( CMPXMedia* aAlbumList );
+
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Process content ids arriving from MDS. Response to VcxMyVideosMdsAlbums::GetAlbumContentIdsL.
+         * 
+         * @param aAlbumId      ID of the album.
+         * @param aAlbumContent Array containing MDS object IDs. This array is the same which
+         *                      was given in GetAlbumContentIdsL call.
+         */
+        void HandleGetAlbumContentIdsRespL( TUint32 aAlbumId,
+                RArray<TVcxMyVideosAlbumVideo>& aAlbumContentIds );
+        
+        /**
+        * From MVcxMyVideosMdsAlbumsObserver.
+        * Response to VcxMyVideosMdsAlbums::GetAlbumsL.
+        * Sends insert events to collection clients.
+        * 
+        * @param aAlbumList  Pointer to same array which was given in GetAlbums call.
+        */
+        void HandleGetAlbumsResp( CMPXMedia* aAlbumList );
+ 
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Process content ids arriving from MDS. Response to CVcxMyVideosMdsAlbums::GetAlbumContentIdsL.
+         * 
+         * @param aAlbumId      ID of the album.
+         * @param aAlbumContent Array containing MDS object IDs. This array is the same which
+         *                      was given in GetAlbumContentL call.
+         */
+        void HandleGetAlbumContentIdsResp( TUint32 aAlbumId,
+                RArray<TVcxMyVideosAlbumVideo>& aAlbumContentIds );
+
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Process content videos arriving from MDS. Response to CVcxMyVideosMdsAlbums::GetAlbumContentVideosL.
+         * 
+         * @param aAlbumId    Album ID.
+         * @param aVideoList  Media containing media array, array items are videos.
+         * @param aError      Error code in case of failure.
+         * @param aFirstNewItemIndex The index of the first new item.
+         * @param aNewItemCount      How many new items since the last results.
+         * @param aComplete          ETrue is query is complete, EFalse if there is new to come.
+         */
+        void HandleGetAlbumContentVideosResp( TUint32 /*aAlbumId*/, CMPXMedia& /*aVideoList*/,
+                TInt /*aError*/, TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/, TBool /*aComplete*/ ) {}
+        
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Response to CVcxMyVideosMdsAlbums::AddVideosToAlbumL.
+         * 
+         * @param aCmd  Pointer to object which was given in AddVideosToAlbumL
+         *              function call. Ownership does not move.
+         * @param aItemArray  Item array which was tried to add to MDS.
+         */        
+        void HandleAddVideosToAlbumResp( CMPXMedia* aCmd,
+                RPointerArray<CMdEInstanceItem>& aItemArray );
+
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Response to CVcxMyVideosMdsAlbums::RemoveRelationsL.
+         */
+        void HandleRemoveRelationsResp( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults );
+
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Response to CVcxMyVideosMdsAlbums::RemoveAlbumsL.
+         */
+        void HandleRemoveAlbumsResp( CMPXMedia* aCmd,
+                RArray<TUint32>& aResultIds );
+
+        /**
+         * From MVcxMyVideosMdsAlbumsObserver.
+         * Relation events from MDS. This object is set as an observer at
+         * iCollection.ConstructL, CVcxMyVideosMdsDb::NewL(..,aAlbumsObserver,..).
+         */
+        void HandleRelationEvent( TObserverNotificationType aType,
+                const RArray<TMdERelation>& aRelationArray );
+        
+    private:
+
+        /**
+         * Fills in iAlbums array. This is called when iAlbumList is ready.
+         * Pointers to CVcxMyVideosVideoCache::iVideoList are not filled
+         * in yet.
+         */
+        void CreateAlbumsL();
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosAlbums( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+         * Leaving version of HandleAddVideosToAlbumResp.
+         */
+        void DoHandleAddVideosToAlbumRespL( CMPXMedia* aCmd,
+                RPointerArray<CMdEInstanceItem>& aItemArray );
+
+    public:
+
+        /**
+        * Album list. This is given to client when categorylevel items are requested. Own.
+        * If this is destroyed/edited, then pointers have to be updated in iAlbums.
+        */
+        CMPXMedia* iAlbumList;
+        
+        /**
+         * Array containing MDS IDs and pointers to album and video media items.
+         * Album media items are in iAlbumList and video media items are in
+         * CVcxMyVideosVideoCache::iVideoList.
+         */
+        RArray<CVcxMyVideosAlbum*> iAlbums;
+    
+        /**
+         * ETrue when iAlbumList is ready and iAlbums contains video IDs.
+         */
+        TBool iAlbumListIsComplete;
+        
+    private:
+        
+        /**
+         * Owner of this object.
+         */
+        CVcxMyVideosCollectionPlugin& iCollection;
+        
+        /**
+         * Used in MDS operations to store MDS video (or relation) IDs.
+         */
+        RArray<TUint32> iMdsOpTargetIds;
+        
+        /**
+         * Stores album video data during relation deletion. This is to
+         * avoid second search when resp arrives.
+         */
+        RArray<TVcxMyVideosAlbumVideo> iRemoveFromAlbumVideos;
+        
+        /**
+         * Used in MDS operations to store operation results. Is in sync with iMdsOpTargetIds. 
+         */
+        RArray<TInt> iMdsOpResults;
+
+        /**
+         * Used in MDS operations to store operation results. Is in sync with iMdsOpTargetIds. 
+         */
+        RArray<TUint32> iMdsOpResultsUint32;
+        
+        /**
+         * When videos are removed or added from cache, the indexes of the
+         * changed albums are stored here. Reason is to calculate new attributes
+         * only once per changed album.
+         */
+        RArray<TInt> iChangedAlbums;
+        
+    };
+
+#endif   // VCXMYVIDEOSALBUMS_H
+
+
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosasyncfileoperations.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosasyncfileoperations.h	Wed Jun 09 09:44:23 2010 +0300
@@ -27,10 +27,6 @@
 #include <mpxcollectionmessagedefs.h>
 #include <vcxmyvideosdefs.h>
 
-//#include "mpxdbactivetask.h" // change to <> when moved to s60 dir and remove temp .h-file
-
-#include "vcxmyvideosdownloadutil.h"
-
 // FORWARD DECLARATIONS
 class CVcxMyVideosCollectionPlugin;
 class CVcxMyVideosAsyncFileCopy;
@@ -84,17 +80,18 @@
         /**
         * Performs one Move or Copy operation. Called by HandleStep.
         *
-        * @return ETrue if operation was the last one, EFalse othewise.
+        * @return MVcxMyVideosActiveTaskObserver::EDone if was last operation,
+        *         MVcxMyVideosActiveTaskObserver::EMoreToCome otherwise.
         */
-        TBool HandleMoveOrCopyStepL();
+        MVcxMyVideosActiveTaskObserver::TStepResult HandleMoveOrCopyStepL();
 
         /**
         * Moves or copies video to another drive.
         *
         * @param aMdsId        MDS id of the item to be moved.
-        * @param aTargetDrive  Target drive.
+        * @param aMove         If ETrue, the source file is deleted.
         */
-        void MoveOrCopyVideoL( TUint32 aMdsId, TInt aTargetDrive );
+        void MoveOrCopyVideoL( TUint32 aMdsId );
                        
         /**
         * Generates and sends resp message for Move,Copy and Delete operations.
@@ -110,9 +107,10 @@
         /**
         * Performs one Delete operation. Called by HandleStep.
         *
-        * @return ETrue if operation was the last one, EFalse otherwise.
+        * @return MVcxMyVideosActiveTaskObserver::EDone if was last operation,
+        *         MVcxMyVideosActiveTaskObserver::EMoreToCome otherwise.
         */
-        TBool HandleDeleteStepL();
+        MVcxMyVideosActiveTaskObserver::TStepResult HandleDeleteStepL();
 
     private:
         
@@ -162,9 +160,8 @@
         * Does some sanity checks also.
         *
         * @param aMdsId        MDS ID of the video being moved/copied.
-        * @param aTargetDrive  Target drive.
         */
-        void InitSingleMoveOrCopyL( TUint32 aMdsId, TInt aTargetDrive );
+        void InitSingleMoveOrCopyL( TUint32 aMdsId );
 
     public:
 
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscategories.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscategories.h	Wed Jun 09 09:44:23 2010 +0300
@@ -231,8 +231,8 @@
         * @param aEventInfo      This is written to generated event's extra info attribute.
         * 
         */
-        void UpdateVideosCountL( CMPXMedia& aCategory, TInt aIncrement, TMPXAttributeData aCountAttribute,
-                TInt aEventInfo );
+        void UpdateVideosCountL( CMPXMedia& aCategory, TInt aIncrement,
+                TMPXAttributeData aCountAttribute, TInt aEventInfo );
 
         /**
         * aVideo is added(or removed) to aCategory. Updates category variables accordingly. 
@@ -277,7 +277,8 @@
         *                    Usefull if items are being deleted but are still on the
         *                    video list.
         */
-        void UpdateCategoryNewVideoNameAndDateL( TInt aOrigin, TBool& aModified, RArray<TUint32>& aIgnoredIds );
+        void UpdateCategoryNewVideoNameAndDateL( TInt aOrigin, TBool& aModified,
+                RArray<TUint32>& aIgnoredIds );
         
         /**
         * Goes through aVideoList and checks all videos which have new video
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionplugin.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionplugin.h	Wed Jun 09 09:44:23 2010 +0300
@@ -11,12 +11,11 @@
 *
 * Contributors:
 *
-* Description:    Implementation of My Videos MPX Collection Plugin interface*
+* Description:   Implementation of My Videos MPX Collection Plugin interface*
 */
 
 
 
-
 #ifndef VCXMYVIDEOSCOLLECTIONPLUGIN_H
 #define VCXMYVIDEOSCOLLECTIONPLUGIN_H
 
@@ -30,18 +29,17 @@
 #include "vcxmyvideosactivetask.h"
 
 #include "vcxmyvideosmdsdb.h"
-#include "vcxmyvideosdownloadutil.h"
 
 // FORWARD DECLARATIONS
 class CVcxMyVideosMdsDb;
 class CMPXResource;
 class CMPXMediaArray;
-class CVcxMyVideosDownloadUtil;
 class CVcxMyVideosVideoCache;
 class CVcxMyVideosCategories;
 class CVcxMyVideosMessageList;
 class CVcxMyVideosAsyncFileOperations;
 class CVcxMyVideosOpenHandler;
+class CVcxMyVideosAlbums;
 
 // CONSTANTS
 
@@ -55,13 +53,13 @@
 NONSHARABLE_CLASS(CVcxMyVideosCollectionPlugin) :
     public CMPXCollectionPlugin,
     public MVcxMyVideosMdsDbObserver,
-    public MVcxMyVideosActiveTaskObserver,
-    public MVcxMyVideosDownloadUtilObserver
+    public MVcxMyVideosActiveTaskObserver
     {    
     public: // Constructors and destructor
 
         friend class CVcxMyVideosOpenHandler;
         friend class CVcxMyVideosVideoCache;
+        friend class CVcxMyVideosAlbums;
         
         /**
         * Two-phased constructor
@@ -190,7 +188,7 @@
         /**
         * From MMPXDbActiveTaskObserver
         */
-        TBool HandleStepL();
+        MVcxMyVideosActiveTaskObserver::TStepResult HandleStepL();
 
         /**
         * From MMPXDbActiveTaskObserver
@@ -226,26 +224,12 @@
         * From MVcxMyVideosMdsDbObserver. Called when media is removed or inserted.
         */
         void HandleObjectPresentNotification();
-
+        
         /**
         * Leaving version of HandleObjectPresentNotification.
         */
         void DoHandleObjectPresentNotificationL();
-                
-        /**
-        * From CVcxMyVideosDownloadUtilObserver.
-        */
-        void HandleDlEvent( TVcxMyVideosDownloadState aState,
-                TUint32 aDownloadId, TInt aProgress, TInt64 aDownloaded,
-                TInt32 aError, TInt32 aGlobalError );
-
-        /**
-        * Leaving version of HandleDlEvent.
-        */
-        void DoHandleDlEventL( TVcxMyVideosDownloadState aState,
-                TUint32 aDownloadId, TInt aProgress, TInt64 aDownloaded,
-                TInt32 aError, TInt32 aGlobalError );
- 
+                 
     private:
         /**
         * Constructor
@@ -256,38 +240,6 @@
         * Symbian 2nd phase constructor.
         */
         void ConstructL ();
-
-        /**
-        * Synchronizes set of videos in cache with Download Manager.
-        * Download related attributes are set in cache if corresponding
-        * download is found.
-        *
-        * @param aItemsInCache  Array of MDS IDs. 
-        */
-        void SyncWithDownloadsL( RArray<TUint32>& aItemsInCache );
-
-        /**
-        * Synchronizes video with Download Manager.
-        *
-        * @aVideo       Video to synchronize.
-        * @aEventAdded  Set to ETrue if event was added to iMessageList, does not change the
-        *               value otherwise.
-        */
-        void SyncVideoWithDownloadsL( CMPXMedia& aVideo, TBool& aEventAdded,
-                TBool aAddEvent = ETrue );
-
-        /**
-        * Copies download attributes from aDownload to aVideo.
-        *
-        * @param aVideo        Video in cache.
-        * @param aDownload     Corresponding download in Download Manager.
-        * @param aSendMpxEvent ETrue if MPX item has been modified and caller should
-        *                      send the modification event.
-        */
-        void SyncVideoAndDownloadL(
-                CMPXMedia& aVideo,
-                RHttpDownload& aDownload,
-                TBool& aSendMpxEvent );
                         
         /**
         * Copies KVcxMediaMyVideosTransactionId field from aRequest to aResp.
@@ -318,24 +270,7 @@
         * fetching ongoing.
         */
         void RestartVideoListFetchingL();
-
-
-        /**
-        * Sets download ID to 0 and download state to none. Updates MDS and sends
-        * modified event.
-        *
-        * @param aDownloadId  Download ID of the MPX item.
-        */
-        void SetDownloadIdToZeroL( TUint aDownloadId );
-
-
-#ifdef _DEBUG
-        /**
-        * Returns download state as a descriptor.
-        */
-        const TDesC& DownloadState( TUint8 aDlState );
-#endif
-
+        
     public:
 
         /**
@@ -363,23 +298,6 @@
         void SendMyVideosMessageL( TUint32 aMessageId, CMPXCommand* aCommand = NULL );
 
         /**
-        * Synchronizes video list with Download Manager.
-        *
-        * @param aVideoList  Video list to synchronize.
-        * @param aStartPos   Items before aStartPos index are left out from synchronizing.
-        * @param aSendEvents If ETrue and modifications are done to the list, then
-        *                    MPX events are sent.
-        */
-        void SyncVideoListWithDownloadsL( CMPXMedia& aVideoList, 
-                TBool aSendEvents, TInt aStartPos = 0 );
-        
-        /**
-        * Returns reference to iDownloadUtil. If iDownloadUtil is NULL then
-        * it is created.
-        */
-        CVcxMyVideosDownloadUtil& DownloadUtilL();
-
-        /**
         * Sends messages to clients. If udeb version, adds messageid
         * parameter to the message for debugging purposes. May or may not
         * contain media list as parameter.
@@ -394,13 +312,13 @@
         * @return Reference to iCategories member.
         */
         CVcxMyVideosCategories& CategoriesL();
-        
+
         /**
-        * Notifies to mediator listeners that a download has completed.
+        * Creates iAlbums if its not created yet and returns reference to it.
         *
-        * @param aVideo Downloaded video.
+        * @return Reference to iAlbums member.
         */
-        void NotifyDownloadCompletedL( CMPXMedia& aVideo );
+        CVcxMyVideosAlbums& AlbumsL();
 
         /**
         * Notifies to mediator listeners that count of new videos has decreased.
@@ -435,7 +353,7 @@
         * Executes command in several small steps.
         */
         CVcxMyVideosActiveTask* iActiveTask;
-                
+                        
     private:
 
         /**
@@ -443,12 +361,12 @@
         * Own.
         */
         CVcxMyVideosCategories* iCategories;
-                            
+        
         /**
-        * Download util, own.
+        * Albums related functionality (except mds db operations). Own.
         */
-        CVcxMyVideosDownloadUtil* iDownloadUtil;
-                                                                        
+        CVcxMyVideosAlbums* iAlbums;
+
         /**
         * Target drive for Move operation.
         */
@@ -469,15 +387,6 @@
         */
         TBool iOrphanDownloadsCleared;
 
-                        
-#ifdef _DEBUG
-        /**
-        * Used for debugging that client receives all events.
-        */
-        TInt iTotalMessagesSent;
-        TInt iMessagesInArraySent;
-#endif
-
     };
 
 #endif   // VCXMYVIDEOSCOLLECTIONPLUGIN_H
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideoscollectionutil.h	Wed Jun 09 09:44:23 2010 +0300
@@ -11,17 +11,17 @@
 *
 * Contributors:
 *
-* Description: 
+* Description:
 *
 */
 
 
 
-
 #ifndef VCXMYVIDEOSCOLLECTIONUTIL_H
 #define VCXMYVIDEOSCOLLECTIONUTIL_H
 
 // INCLUDES
+#include <vcxmyvideosdefs.h>
 
 // FORWARD DECLARATIONS
 class CMPXMedia;
@@ -83,6 +83,15 @@
                 RArray<TUint32>& aMdsIds );
 
         /**
+        * Appends all items from aFromList to aToList. New items will point to
+        * same shared memory.
+        *
+        * @param aToList   List in which items are appended to.
+        * @param aFromList List in which items are copied from.
+        */
+        static void AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList );
+
+        /**
         * Converts drive letter to drive number.
         *
         * @param aDrive drive letter
@@ -118,6 +127,14 @@
         static TUint32 FlagsL( CMPXMedia& aVideo );
 
         /**
+         * Gets KMPXMediaGeneralDate (creation date) of aVideo.
+         * 
+         * @param aVideo  Media object to fetch parameter from.
+         * @return        Creation date, works with TTime.
+         */
+        static TInt64 CreationDateL( CMPXMedia& aVideo );
+
+        /**
         * Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
         *
         * @param aVideo  Media object to fetch parameter from.
@@ -139,7 +156,7 @@
         * @param aVideo  Media object to fetch parameter from.
         * @return        ID.
         */
-        static TMPXItemId IdL( CMPXMedia& aVideo );
+        static TMPXItemId IdL( const CMPXMedia& aVideo );
 
         /**
         * Gets KVcxMediaMyVideosDuration attribute of aVideo.
@@ -155,7 +172,7 @@
         * @return  KMPXMediaGeneralTitle value. If attribute is not supported,
         *          then KNullDesC is returned.
         */
-        static const TDesC& Title( CMPXMedia& aVideo );
+        static const TDesC& Title( const CMPXMedia& aVideo );
 
         /**
         * Gets KVcxMediaMyVideosRating attribute of the video.
@@ -207,6 +224,44 @@
         */
         static TInt Origin( TInt aCategoryId );
 
+        /**
+         * Gets KMPXMediaArrayContents attribute from aMedia. Leaves
+         * with KErrArgument is attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Pointer to media array.
+         */
+        static CMPXMediaArray* MediaArrayL( const CMPXMedia& aMedia );
+        
+        /**
+         * Gets KVcxMediaMyVideosInt32Value attribute from aMedia. Leaves
+         * with KErrArgument if attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Value of KVcxMediaMyVideosInt32Value attribute.
+         */
+        static TInt32 Int32ValueL( CMPXMedia& aMedia );
+
+        /**
+         * Gets KVcxMediaMyVideosUint32Value attribute from aMedia. Leaves
+         * with KErrArgument if attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Value of KVcxMediaMyVideosUint32Value attribute.
+         */
+        static TUint32 Uint32ValueL( CMPXMedia& aMedia );
+        
+        /**
+         * Gets KMPXMediaGeneralId attributes from aMediaArray and
+         * puts them to aIdArray. aIdArray is reset before adding.
+         * 
+         * @param aMediaArray  Media array containing media items which
+         *                     have KMPXMediaGeneralId attribute set.
+         * @param aIdArray     Array where to the IDs are written to.
+         */
+        static void GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
+                RArray<TUint32>& aIdArray );
+
 #ifdef _DEBUG
         /**
         * Prints process names which have file handle open to aFileName
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosdownloadcache.h	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +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 the License "Eclipse Public License v1.0"
-* which accompanies 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 cached MDS media items which are being downloaded.*
-*/
-
-
-
-
-#ifndef VCXMYVIDEOSDOWNLOADCACHE_H
-#define VCXMYVIDEOSDOWNLOADCACHE_H
-
-// INCLUDES
-
-// FORWARD DECLARATIONS
-class CMPXMedia;
-
-// CONSTANTS
-
-// CLASS DECLARATION
-
-/**
-* Used for storing download ids and media object pointers to circular buffers for fast access.
-*
-* @lib mpxmyvideoscollectionplugin.lib
-*/
-NONSHARABLE_CLASS(CVcxMyVideosDownloadCache) : public CBase
-    {    
-    public: // Constructors and destructor
-
-        /**
-        * Two-phased constructor
-        * @return   Object constructed
-        */
-        static CVcxMyVideosDownloadCache* NewL();
-
-        /**
-        * Destructor
-        */
-        virtual ~CVcxMyVideosDownloadCache();
- 
-    private:
-        /**
-        * Constructor
-        */
-        CVcxMyVideosDownloadCache();
-
-        /**
-        * Symbian 2nd phase constructor.
-        */
-        void ConstructL ();
-
-    public:                        
-        /**
-        * Tries to find item with aDownloadId from Download Cache.
-        *
-        * @param aDownloadId   Download ID in Download Manager.
-        * @return              Returns pointer to media object, NULL if not found.
-        *                      Ownership does not move.
-        */
-        CMPXMedia* Get( TUint32 aDownloadId );
-
-        /**
-        * Adds download ID and index pair to Download Cache.
-        *
-        * @param aDownloadId  Download ID in Download Manager
-        * @param aVideo       Pointer to video, ownership does not move.
-        */
-        void Add( TUint32 aDownloadId, CMPXMedia* aVideo );
-        
-        /**
-        * Deletes item from Download Cache
-        *
-        * @param aVideo  Video to remove.
-        */
-        void Delete( CMPXMedia* aVideo );
-                                          
-    private:
-   
-        /**
-        * Array used as circular buffer, contains download ids.
-        */
-        RArray<TUint32> iDownloadId;
-        
-        /**
-        * Array used as circular buffer, contains pointers to medias.
-        */
-        RPointerArray<CMPXMedia> iMedia;
-        
-        /**
-        * Current position of the circular buffers (iDownloadId and iMedia).
-        * Next item added is written to this position.
-        */
-        TInt iPos;
-
-    };
-
-#endif   // VCXMYVIDEOSVIDEOCACHE_H
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdsalbums.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,528 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Provides albums support from MDS*
+*/
+
+
+
+#ifndef VCXMYVIDEOSMDSALBUMS_H
+#define VCXMYVIDEOSMDSALBUMS_H
+
+// INCLUDES
+#include <mdequery.h>
+#include <mpxmedia.h>
+#include "vcxmyvideosalbum.h"
+#include "vcxmyvideosmdsdb.h"
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Provides albums support, uses MDS.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsAlbums) :
+        public CActive,
+        public MMdEQueryObserver,
+        public MMdERelationItemObserver
+#if 0
+        ,
+        public MMdERelationObserver
+#endif
+    {    
+    public: // Constructors and destructor
+        
+        friend class CVcxMyVideosMdsCmdQueue;
+        friend class CVcxMyVideosMdsDb;
+        
+        enum TVcxAsyncOperation
+            {
+            EVcxNone,
+            EVcxAddVideosToAlbum,
+            EVcxRemoveRelations,
+            EVcxRemoveAlbums
+            };
+        
+        /**
+        * Constructor.
+        * 
+        * @param aMdsDb    Owner of this object.
+        * @param aObserver Object which is listening album related events. If NULL, then
+        *                  no observer is set.
+        */
+        static CVcxMyVideosMdsAlbums* NewL( CVcxMyVideosMdsDb& aMdsDb,
+                MVcxMyVideosMdsAlbumsObserver* aObserver );
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsAlbums();
+
+    public: // new methods
+
+        /**
+         * From CActive.
+         * Cancels possible ongoing asynchronous request.
+         * 
+         * @param aType Defines what kind of request is cancelled.
+         */
+        void DoCancel( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+
+        /**
+         * Cancels queries.
+         *
+         * @param aType Defines what kind of request is cancelled.
+         */
+        void CancelQueries( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+        
+        /**
+        * Gets My Videos albums from MDS asynchronously.
+        * HandleGetAlbumsResp() callback function is called when ready.
+        * Utilizes CVcxMyVideosMdsCmdQueue.
+        *
+        * @param aAlbumList  Album list is written here. Caller owns this, ownership
+        *                    does not move.
+        * @param aClient     Response call is done to this object.
+        */
+        void GetAlbumsL( CMPXMedia* aAlbumList, MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album from MDS synchronously.
+         * 
+         * @param aId  MDS ID of the album to be fetched.
+         * @returm     MPX media containing album data. Ownership
+         *             moves to caller. NULL if not found.
+         */
+        CMPXMedia* GetAlbumL( TUint32 aId );
+
+        /**
+         * Gets album content IDs asynchronously.
+         * HandleGetAlbumContentIdsResp() callback function is called when ready.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aAlbumId      Album ID.
+         * @param aContentArray Item IDs which belog to aAlbum are written here. Caller must
+         *                      keep aContentArray available until HandleGetAlbumContentIdsResp
+         *                      has been called.
+        * @param aClient        Response call is done to this object.
+         */
+        void GetAlbumContentIdsL( TUint32 aAlbumId, RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Gets album content videos asynchronously.
+         * HandleGetAlbumContentVideosResp() callback function is called when ready.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         * 
+         * @param aAlbumId    Album ID.
+         * @param aVideoList  Media containing media array. Video media objects are added to media array.
+         *                    Caller must keep aVideoList available until callback has been called.
+         * @param aClient     Response call is done to this object.
+         */
+        void GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Adds videos to album asynchronously. HandleAddVideosToAlbumResp() callback function
+         * is called when operation finishes.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aMpxCmd    Media containing command parameters: album ID and video ID list.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosAddToAlbum command. Ownership does not move.
+         *                   
+         * @param aClient    Response call is done to this object.
+         */
+        void AddVideosToAlbumL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes relations asynchronously.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         * 
+         * @param aRelationIds  Relations which are removed.
+         * @param aResults      In sync with aRelationIds. Result codes, KErrNone if successful,
+         *                      KErrGeneral if failed.
+         * @param aClient       Response call is done to this object.
+         */
+        void RemoveRelationsL( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient );
+ 
+        /**
+         * Adds album to MDS. aAlbum should have KMPXMediaGeneralTitle attribute
+         * set. The MDS item ID of the created album is written to KMPXMediaGeneralId
+         * attribute.
+         * 
+         * @param aAlbum  Album which is added to database. 
+         */
+        void AddAlbumL( CMPXMedia& aAlbum );
+        
+        /**
+         * Removes albums asynchronously. HandleRemoveAlbumsResp() callback function
+         * is called when operation finishes.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aMpxCmd    Media containing command parameters: media array containing album IDs.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosRemoveAlbums command. Ownership does not move.
+         *                   
+         * @param aClient    Response call is done to this object.
+         */        
+        void RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Sets album attributes.
+         * 
+         * @param aVideo  Values from aVideo are written to MDS.
+         */
+        void SetAlbumL( CMPXMedia& aVideo );
+        
+    protected:
+        
+        /**
+        * From CActive.
+        * Called when operation completes.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * Actual implementation for cancelling.
+        */
+        void DoCancel();
+        
+    private:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
+                MVcxMyVideosMdsAlbumsObserver* aObserver );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Copies album data from aObject to aAlbum.
+        *
+        * @param aObject  MDS object to copy data from.
+        * @param aAlbum   MPX media to copy data to.
+        */
+        void Object2MediaL( CMdEObject& aObject, CMPXMedia& aAlbum );
+        
+        /**
+         * Copies album data from aAlbum to aObject.
+         * 
+         * @param aAlbum MPX media to copy data from.
+         * @param aObject MDS object to copy data to.
+         */
+        void Media2ObjectL( CMPXMedia& aAlbum, CMdEObject& aObject);
+
+        /**
+        * Gets various defintions from MDS and stores them to member variables.
+        */
+        void GetSchemaDefinitionsL();
+
+        /**
+        * Gets My Videos albums from MDS asynchronously.
+        * HandleGetAlbumsResp() callback function is called when ready.
+        *
+        * @param aAlbumList  Album list is written here. Caller owns this, ownership
+        *                    does not move.
+        * @param aClient     Callback is done to this object.
+        */
+        void DoGetAlbumsL( CMPXMedia* aAlbumList, MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album content IDs from MDS asynchronously.
+         * HandleGetAlbumContentIdsResp() callback function is called when ready.
+         *
+         * @param aAlbumId      Album ID.
+         * @param aContentArray Array containing MDS IDs which belong to aAlbum.
+         *                      Caller is responsible to keep array available
+         *                      until HandleGetAlbumContentResp has been called. 
+        * @param aClient        Callback is done to this object.
+         */
+        void DoGetAlbumContentIdsL( TUint32 aAlbumId,
+                RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album content videos from MDS asynchronously.
+         * HandleGetAlbumContentVideosResp() callback function is called when ready.
+         * 
+         * @param aAlbumId   Album ID.
+         * @param aVideoList Media containing empty media array. Videos are added to array. Caller
+         *                   must keep aVideoList available until HandleGetAlbumContentVideosResp
+         *                   is called.
+         * @param aClient    Callback is done to this object.
+         */
+        void DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Adds videos to album asynchronously. HandleAddVideosToAlbumResp() callback function
+         * is called when operation finishes.
+         * 
+         * @param aMpxCmd    Media containing command parameters: album ID and video ID list.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosAddToAlbum command. Ownership does not move.
+         * @param aClient    Response call is done to this object.
+         */
+        void DoAddVideosToAlbumL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes relations asynchronously.
+         * 
+         * @param aRelationIds  Relations which are removed.
+         * @param aResults      In sync with aRelationIds. Result codes, KErrNone if successful,
+         *                      KErrGeneral if failed.
+         * @param aClient       Response call is done to this object.
+         */
+        void DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes albums asynchronously.
+         * 
+         * @param aMpxCmd  Media containing command parameters: array with albums IDs.
+         * @param aClient  Response call is done to this object.
+         */
+        void DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+        * Handles album query responses.
+        * 
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        */
+        void HandleAlbumQueryCompletedL(CMdEQuery& aQuery, TInt aError);
+
+        /**
+        * Handles video query responses.
+        * 
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        * @param aFirstNewItemIndex Index of the first new item in the query.
+        * @param aNewItemCount      How many new items were added.
+        * @param aComplete          ETrue if query is complete, EFalse if new to come.
+        */
+        void HandleVideoQueryResultsL( CMdEQuery& aQuery, TInt aError,
+                TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete );
+
+        /**
+         * Handles relation query responses.
+         * 
+         * @param aQuery Query instance.
+         * @param aError  <code>KErrNone</code>, if the query was completed
+         *                successfully. Otherwise one of the system-wide error 
+         *                codes.
+         */
+        void HandleRelationQueryCompletedL( CMdEQuery& aQuery, TInt aError );
+
+        /**
+         * Called from RunL when video adding to album completes.
+         */
+        void HandleAddVideosToAlbumCompletedL();
+
+        /**
+         * Called from RunL when relations remove completes.
+         */
+        void HandleRemoveRelationsCompletedL();
+
+        /**
+         * Called from RunL when albums remove completes.
+         */
+        void HandleRemoveAlbumsCompletedL();
+
+        /**
+         * Registers observing to MDS session.
+         */
+        void SetObservingL();
+        
+    protected:
+
+        /**
+        * From MMdEQueryObserver.
+        * Called to notify the observer that new results have been received 
+        * in the query.
+        *
+        * @param aQuery              Query instance that received new results.
+        * @param aFirstNewItemIndex  Index of the first new item that was added
+        *                            to the result item array.
+        * @param aNewItemCount       Number of items added to the result item 
+        *                            array.
+        */
+        void HandleQueryNewResults(CMdEQuery& aQuery,
+                TInt aFirstNewItemIndex,
+                TInt aNewItemCount);
+
+        /**
+        * From MMdEQueryObserver.
+        * Called to notify the observer that the query has been completed,
+        * or that an error has occured.
+        *
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        */
+        void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
+
+        /**
+         * From MMdERelationItemObserver
+         */
+        void HandleRelationItemNotification(CMdESession& aSession, 
+                    TObserverNotificationType aType,
+                    const RArray<TMdERelation>& aRelationArray);
+
+        /**
+         * From MMdERelationObserver
+         */
+        void HandleRelationNotification(CMdESession& aSession, 
+                TObserverNotificationType aType,
+                const RArray<TItemId>& aRelationIdArray);
+        
+    private:
+        
+        /**
+         * Main class for Mds operations. Owns session to MDS.
+         */
+        CVcxMyVideosMdsDb& iMdsDb;
+        
+        /**
+         * Observer of albums related events. May be NULL.
+         * not own.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iObserver;
+        
+        /**
+        * Asynchronous album object fetching query is stored here. Own.
+        */
+        CMdEObjectQuery* iAlbumQuery;
+
+        /**
+        * Asynchronous video object fetching query is stored here. Own.
+        */
+        CMdEObjectQuery* iVideoQuery;
+
+        /**
+        * Asynchronous relation fetching query is stored here. Own.
+        */
+        CMdERelationQuery* iRelationQuery;
+                
+        /**
+        * The default namespace definition, not own.
+        */
+        CMdENamespaceDef* iNamespaceDef;
+        
+        /**
+        * Album object definition, not own.
+        */
+        CMdEObjectDef* iAlbumObjectDef;
+        
+        /**
+        * Album type property definition, not own.
+        */
+        CMdEPropertyDef* iTypePropertyDef;
+        
+        /**
+         * "Contains" relation definition, not own.
+         */
+        CMdERelationDef* iContainsRelationDef;
+        
+        /**
+        * Pointer to album list which is being fetched from MDS. Not own.
+        */
+        CMPXMedia* iAlbumList;
+
+        /**
+        * Pointer to video list which is being fetched from MDS. Not own.
+        */
+        CMPXMedia* iVideoList;
+
+        /**
+         * When doing some async operation to MDS, the album ID is stored here.
+         */
+        TUint32 iAlbumId;
+        
+        /**
+         * When fetching album content from MDS, the pointer to content array is stored here.
+         * Only MDS ID is filled to TVideo.
+         * Not own.
+         */
+        RArray<TVcxMyVideosAlbumVideo>* iAlbumContent;
+
+        /**
+         * The pending async operation ID is stored here.
+         */
+        TVcxAsyncOperation iAsyncOperation;
+
+        /**
+         * Used for storing items during async mds operations.
+         */
+        RPointerArray<CMdEInstanceItem> iItemArray;
+        
+        /**
+         * Used for storing result buffer during async mds operations.
+         */
+        RMdEDataBuffer iResultBuffer;
+
+        /**
+         * Used in async operations to store
+         * pointer to result array (which is owned by the user). 
+         */
+        RArray<TInt>* iResultArray;
+
+        /**
+         * Used in async operations to store
+         * pointer to result array (which is owned by the user). 
+         */
+        RArray<TUint32>* iResultArrayUint32;
+        
+        /**
+         * Used in async oprations (EVcxAddVideosToAlbum and EVcxRemoveVideosFromAlbum) to store
+         * pointer to item ID array (which is owned by the user). 
+         */
+        RArray<TUint32>* iIdArray;
+                
+        /**
+         * Used to store command parameters during async MDS operations. Not owned.
+         */
+        CMPXMedia* iMpxCmd;
+        
+        /**
+         * Used to store pointer to client who initiated the async operation.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iClient;
+
+    };
+
+#endif   // VCXMYVIDEOSMDSALBUMS_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdscmdqueue.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,330 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Queues commands to MDS.
+*/
+
+
+
+#ifndef VCXMYVIDEOSMDSCMDQUEUE_H
+#define VCXMYVIDEOSMDSCMDQUEUE_H
+
+// INCLUDES
+#include <vcxmyvideosdefs.h>
+#include "vcxmyvideosalbum.h"
+#include "vcxmyvideosmdsdb.h"
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* All MDS commands inherit this.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmd) : public CBase
+    {    
+    public:
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmd() {}
+        
+        /**
+        * Command type. Used for casting the pointer to correct type.
+        */
+        CVcxMyVideosMdsDb::TRequestType iCmdType;
+        
+        /**
+         * Pointer to client is stored here, used for performing response call.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iClient;    
+    };
+
+/**
+* Class which encapsulates GetVideoListL function parameters.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetVideoList) : public CVcxMyVideosMdsCmd
+    {    
+    public:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetVideoList() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetVideoList() {}
+
+    public:
+        /**
+        * Stored CreateVideoListL function parameters, see meanings from vcxmyvideosmdsdb.h file.
+        */
+        TVcxMyVideosSortingOrder iSortingOrder;
+        TBool                    iAscending;
+        TBool                    iFullDetails;
+        CMPXMedia**              iVideoList;
+    };
+
+/**
+* Class which stores GetAlbumsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbums) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbums() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbums() {}
+
+    public:
+        /**
+        * Stored GetAlbumsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        CMPXMedia* iAlbumList;
+    };
+
+/**
+* Class which stores GetAlbumContentIdsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbumContentIds) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbumContentIds() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbumContentIds() {}
+
+    public:
+        /**
+        * Stored GetAlbumContentL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        TUint32                         iAlbumId;        
+        RArray<TVcxMyVideosAlbumVideo>* iAlbumContent; //not own
+    };
+
+/**
+* Class which stores GetAlbumContentVideosL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbumContentVideos) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbumContentVideos() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbumContentVideos() {}
+
+    public:
+        /**
+        * Stored GetAlbumContentL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        TUint32    iAlbumId;        
+        CMPXMedia* iAlbumContentVideos; //not own
+    };
+
+/**
+* Class which stores AddVideosToAlbumL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdAddVideosToAlbum) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdAddVideosToAlbum() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdAddVideosToAlbum() {}
+
+    public:
+        /**
+        * Stored AddVideosToAlbumL function parameters, see meanings from vcxmyvideosdefs.h
+        * KVcxCommandMyVideosAddToAlbum command descriptions.
+        */
+        CMPXMedia* iMpxCmd;
+    };
+
+/**
+* Class which stores RemoveRelationsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdRemoveRelations) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdRemoveRelations() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdRemoveRelations() {}
+
+    public:
+        /**
+        * Stored RemoveRelationsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        RArray<TUint32>* iRelationIds; //not own
+        RArray<TUint32>* iResults;  //not own
+    };
+
+/**
+* Class which stores RemoveAlbumsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdRemoveAlbums) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdRemoveAlbums() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdRemoveAlbums() {}
+
+    public:
+        /**
+        * Stored RemoveAlbumsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        CMPXMedia* iMpxCmd; //not own
+    };
+
+/**
+* Queues MDS commands.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdQueue) : public CBase
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor
+        * @return object constructed
+        */
+        static CVcxMyVideosMdsCmdQueue* NewL( CVcxMyVideosMdsDb& aMdsDb );
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdQueue();
+
+    public: // new methods
+        
+        /**
+        * Executes command if queue is empty, otherwise adds it to queue.
+        * Ownership of aCmd moves to this object.
+        *
+        * @param aCmd  Command to execute.
+        */
+        void ExecuteCmdL( CVcxMyVideosMdsCmd* aCmd );
+        
+        /**
+        * Called when command finishes. Executes next command from the queue.
+        */
+        void CmdFinished();
+        
+        /**
+         * Removes commands from command queue.
+         * 
+         * @param aType Defines what kind of commands are removed from the command queue.
+         */
+        void Cancel( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+                        
+    private:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdQueue( CVcxMyVideosMdsDb& aMdsDb );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+        
+        /**
+        * Executes the command.
+        *
+        * @param aCmd  Command to execute, ownership does not move.
+        */
+        void DoExecuteCmdL( CVcxMyVideosMdsCmd* aCmd );
+                    
+    private:
+        
+        /**
+        * Owner of this object.
+        */
+        CVcxMyVideosMdsDb& iMdsDb;
+        
+        /**
+        * Command queue. Own.
+        */
+        RArray<CVcxMyVideosMdsCmd*> iQueue;
+        
+        /**
+        * Set to ETrue when command is started and to EFalse
+        * when command finishes.
+        */
+        TBool iCmdInProgress;
+    };
+
+#endif   // VCXMYVIDEOSMDSCMDQUEUE_H
+
+
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdsdb.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmdsdb.h	Wed Jun 09 09:44:23 2010 +0300
@@ -11,12 +11,11 @@
 *
 * Contributors:
 *
-* Description:    MPX My Videos collection plugins' MDS database class*
+* Description:   MPX My Videos collection plugins' MDS database class*
 */
 
 
 
-
 #ifndef VCXMYVIDEOSMDSDB_H
 #define VCXMYVIDEOSMDSDB_H
 
@@ -25,7 +24,13 @@
 #include <mdequery.h>
 #include <harvesterclient.h>
 #include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
 #include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+class CVcxMyVideosMdsAlbums;
+class CMPXMedia;
+class CVcxMyVideosMdsCmdQueue;
 
 const TUid KHarvesterPSShutdown = { 0x200009F5 } ;
 const TInt KMdSShutdown = 0x00000002; // values 1 = shutdown, 0 = restart, normal state
@@ -33,7 +38,144 @@
 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
 static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt);
 
-class CRepository;
+/**
+ *  MPX My Videos collection MDS database observer class.
+ *  Part of ECOM Plugin.
+ */
+NONSHARABLE_CLASS(MVcxMyVideosMdsDbObserver)
+    {        
+    public:
+    
+        /* 
+        
+        Defined in mpxcollectionmessagedefs.h:  
+        
+        enum TMPXChangeEventType
+            {
+            EMPXItemDeleted,      // item/playlist deleted
+            EMPXItemInserted,     // item/playlist added
+            EMPXItemModified      // item/playlist/artist/album/genre/composer modified
+            };
+        */
+        
+        /**
+        * Handler function for database events.
+        *
+        * @param aEvent Event type.
+        * @param aId    Array of IDs in database.
+        */
+        virtual void HandleMyVideosDbEvent( TMPXChangeEventType aEvent, RArray<TUint32>& aId ) = 0;
+
+        /**
+        * Handler function for video list fetching events. This callback is called as a response
+        * to CreateVideoList( aSync = EFalse ).
+        *
+        * @param aVideoList          List of videos fetched from MDS.
+        * @param aNewItemsStartIndex Start position for the new items added. If -1, then no new
+        *                            items were added.
+        * @param aComplete           ETrue if list is complete and no more items are expected,
+        *                            EFalse if there are more to come.
+        */
+        virtual void HandleCreateVideoListResp( CMPXMedia* aVideoList,
+                TInt aNewItemsStartIndex, TBool aComplete ) = 0;
+
+        /**
+        * Handler function for media remove/insert events. This is called every time
+        * media is removed or inserted (objects become present or non present).
+        */
+        virtual void HandleObjectPresentNotification() = 0;
+    };
+
+
+/**
+ *  MPX My Videos collection MDS albums related functionality observer class.
+ *  Part of ECOM Plugin.
+ */
+NONSHARABLE_CLASS(MVcxMyVideosMdsAlbumsObserver)
+    {        
+    public:
+            
+        /**
+        * This callback is called as a response to GetAlbumsL.
+        *
+        * @param aAlbumList List of albums fetched from MDS.
+        */
+        virtual void HandleGetAlbumsResp( CMPXMedia* aAlbumList ) = 0;
+
+        /**
+        * This callback is called as a response to GetAlbumContentIdsL.
+        *
+        * @param aAlbumId      Album ID which was fetched.
+        * @param aContentArray Array containing MDS object IDs. This array is the same which
+        *                      was given in GetAlbumContentIdsL call.
+        */
+        virtual void HandleGetAlbumContentIdsResp( TUint32 aAlbumId,
+                RArray<TVcxMyVideosAlbumVideo>& aContentArray ) = 0;
+
+        /**
+         * Called as a response to GetAlbumContentVideosL.
+         * 
+         * @param aAlbumId           ID of the album containing the result videos.
+         * @param aVideoList         Media containing array of videos.
+         * @param aError             Error code in case of failure.
+         * @param aFirstNewItemIndex Index of the first new item.
+         * @param aNewItemCount      How many new items in the query since the last results.
+         * @param aComplete          ETrue if query is complete, EFalse if there is more to come.
+         */
+        virtual void HandleGetAlbumContentVideosResp( TUint32 aAlbumId, CMPXMedia& aVideoList,
+                TInt aError, TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete ) = 0;
+
+        /**
+         * Called as a response to AddVideosToAlbumL. Results are written from aItemArray
+         * to aCmd (KVcxMediaMyVideosInt32Value attribute). KErrNone if operation was successful,
+         * KErrGeneral otherwise.
+         * 
+         * @param aCmd        Pointer to same object which was given in AddVideosToAlbumL function call.
+         * @param aItemArray  Array of relation items that were added to MDS.
+         */
+        virtual void HandleAddVideosToAlbumResp( CMPXMedia* aCmd,
+                RPointerArray<CMdEInstanceItem>& aItemArray ) = 0;
+
+        /**
+         * Called as a response to RemoveRelationsL.
+         * 
+         * @param aRelationIds  Relations which were tried to be removed.
+         * @param aResults      Result codes, in sync with aRelationIds. KErrNone if successful,
+         *                      KErrGeneral if failed.
+         */
+        virtual void HandleRemoveRelationsResp( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults ) = 0;
+
+        /**
+         * Called as a response to RemoveAlbumsL.
+         * 
+         * @param aCmd      Cmd which was given in RemoveAlbumsL call.
+         * @param aResults  Result IDs.
+         */
+        virtual void HandleRemoveAlbumsResp( CMPXMedia* aCmd,
+                RArray<TUint32>& aResultIds ) = 0;
+
+        /**
+         * Event handler function for relation delete events.
+         * 
+         * @param aType           Event type
+         * @param aRelationArray  Array containing relations.
+         */
+        virtual void HandleRelationEvent( TObserverNotificationType aType,
+                const RArray<TMdERelation>& aRelationArray ) = 0;
+
+#if 0
+        /**
+         * Event handler function for relation add events.
+         * 
+         * @param aType           Event type
+         * @param aRelationArray  Array containing relations.
+         */
+        virtual void HandleRelationIdEvent( TObserverNotificationType aType,
+                const RArray<TUint32>& aRelationIdArray ) = 0;
+#endif
+        
+    };
 
 /**
  * PSCW Listener Observer interface for signaling that MDS has Shutdown/restarted
@@ -105,57 +247,7 @@
 };
 
 /**
- *  MPX My Videos collection MDS database observer class.
- *  Part of ECOM Plugin.
- */
-NONSHARABLE_CLASS(MVcxMyVideosMdsDbObserver)
-    {
-
-    public:
-    
-        /* 
-        
-        Defined in mpxcollectionmessagedefs.h:  
-        
-        enum TMPXChangeEventType
-            {
-            EMPXItemDeleted,      // item/playlist deleted
-            EMPXItemInserted,     // item/playlist added
-            EMPXItemModified      // item/playlist/artist/album/genre/composer modified
-            };
-        */
-        
-        /**
-        * Handler function for database events.
-        *
-        * @param aEvent Event type.
-        * @param aId    Array of IDs in database.
-        */
-        virtual void HandleMyVideosDbEvent( TMPXChangeEventType aEvent, RArray<TUint32>& aId ) = 0;
-
-        /**
-        * Handler function for list fetching events. This callback is called as a response
-        * to CreateVideoList( aSync = EFalse ).
-        *
-        * @param aVideoList          List of videos fetched from MDS.
-        * @param aNewItemsStartIndex Start position for the new items added. If -1, then no new
-        *                            items were added.
-        * @param aComplete           ETrue if list is complete and no more items are expected,
-        *                            EFalse if there are more to come.
-        */
-        virtual void HandleCreateVideoListResp( CMPXMedia* aVideoList,
-                TInt aNewItemsStartIndex, TBool aComplete ) = 0;
-
-        /**
-        * Handler function for media remove/insert events. This is called every time
-        * media is removed or inserted (objects become present or non present).
-        */
-        virtual void HandleObjectPresentNotification() = 0;
-    };
-
-
-/**
- *  MPX My Videos collection ECOM plugins' MDS database class.
+ *  MPX My Videos collection ECOM plugin's MDS database class.
  */
 NONSHARABLE_CLASS(CVcxMyVideosMdsDb) :
                                 public CBase,
@@ -168,17 +260,34 @@
         
 public:
 
+    friend class CVcxMyVideosMdsAlbums;
+    friend class CVcxMyVideosMdsCmdQueue;
+
+    enum TRequestType
+        {
+        EAll,
+        EGetVideoList,
+        EGetAlbums,
+        EGetAlbumContentIds,
+        EGetAlbumContentVideos,
+        EAddVideosToAlbum,
+        ERemoveRelations,
+        ERemoveAlbums
+        };
+    
     /**
      * Two-phased constructor.
      * @param aObserver The db change observer.
      */
-    static CVcxMyVideosMdsDb* NewL( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs );
+    static CVcxMyVideosMdsDb* NewL( MVcxMyVideosMdsDbObserver* aObserver,
+            RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver = NULL );
 
     /**
      * Two-phased constructor.
      * @param aObserver The db change observer.
      */
-    static CVcxMyVideosMdsDb* NewLC( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs );
+    static CVcxMyVideosMdsDb* NewLC( MVcxMyVideosMdsDbObserver* aObserver,
+            RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver = NULL );
 
 
     /**
@@ -187,9 +296,30 @@
     virtual ~CVcxMyVideosMdsDb();
 
     /**
-    * Cancels possible ongoing asynchronous operation. 
+    * Cancels possible ongoing asynchronous operations.
+    * 
+    * @param aType What kind of requests are cancelled. 
     */
-    void Cancel();
+    void Cancel( TRequestType aType = EAll );
+
+    /**
+     * Creates list of videos from MDS. This function utilizes CVcxMyVideosMdsQueue, ie
+     * commands are put in queue if there are other commands pending.
+     *
+     * @param aSortingOrder Sorting order, see values from TSortingOrder.
+     * @param aAscending    Sort direction, if ETrue then ascending, else descending.
+     * @param aFullDetails  If ETrue, then all details will be filled to media objects,
+     *                      if EFalse, then only subset.
+     * @param aVideoList    Reference to pointer variable. Container type CMPXMedia class, contains
+     *                      CMPXMediaArray filled with CMPXMedia objects. If aVideoList
+     *                      pointer variable is NULL, then new medialist is created.
+     *                      If pointer variable already contains value, then the given medialist
+     *                      should have empty media array. New items are appended to it.
+     *                      Caller naturally owns the data.
+     *                      
+     */
+    void CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
+            TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList );
 
     /**
      * Add new video.
@@ -216,34 +346,17 @@
     void UpdateVideoL( CMPXMedia& aVideo );
 
     /**
-     * Create list of videos from MDS.
-     *
-     * @param aSortingOrder Sorting order, see values from TSortingOrder.
-     * @param aAscending    Sort direction, if ETrue then ascending, else descending.
-     * @param aFullDetails  If ETrue, then all details will be filled to media objects,
-     *                      if EFalse, then only subset.
-     * @param aVideoList    Reference to pointer variable. Container type CMPXMedia class, contains
-     *                      CMPXMediaArray filled with CMPXMedia objects. If aVideoList
-     *                      pointer variable is NULL, then new medialist is created.
-     *                      If pointer variable already contains value, then the given medialist
-     *                      should have empty media array. New items are appended to it.
-     *                      Caller naturally owns the data.
-     *                      
-     */
-    void CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
-            TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList );
-
-    /**
      * Get one video item from MDS and create a new media
      * object from it.
      *
      * @param aId          Video identifier in MDS database.
      * @param aFullDetails If ETrue, then all details are fetched, othewise only subset.
-     * @return             Pointer to media object, ownership moves.
+     * @return             Pointer to media object, ownership moves. NULL if
+     *                     not found.
      */
     CMPXMedia* CreateVideoL( TUint32 aId, TBool aFullDetails = ETrue );
 
-protected: // from base classes
+protected:
     
 // from MMdESessionObserver
 
@@ -301,6 +414,7 @@
 
 
 // from MMdEObjectObserver
+
     void HandleObjectNotification( CMdESession& aSession,
             TObserverNotificationType aType,
             const RArray<TItemId>& aObjectIdArray);
@@ -308,10 +422,10 @@
 // from MMdEObjectPresentObserver
     void HandleObjectPresentNotification(CMdESession& aSession, 
 			TBool aPresent, const RArray<TItemId>& aObjectIdArray);
-
+			
 // from MVcxMdsShutdownMonitorObserver
     void ShutdownNotification( TInt aShutdownState );
-    
+
 private:
 
     /**
@@ -319,17 +433,20 @@
      * @param aObserver The db change observer.
      * @param aFs      Session to file server.
      */
-    CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs );
+    CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver,
+            RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver = NULL );
 
     void ConstructL();
 
     /**
      * Gets object from MDS.
      *
-     * @param aId   The ID of the object to get.
-     * @return      The object if found, NULL otherwise.
+     * @param aId      The ID of the object to get.
+     * @param aIsVideo Set to ETrue if the object to be fetched is video. If set to
+     *                 EFalse, then the object is assumed to be album.
+     * @return         The object if found, NULL otherwise.
      */
-    CMdEObject* ObjectL( const TItemId aId );
+    CMdEObject* ObjectL( const TItemId aId, TBool aIsVideo = ETrue );
 
     /**
      * Read the video details from the given object to the media class.
@@ -383,6 +500,29 @@
             TInt aFirstNewItemIndex, TInt aNewItemCount);
 
     /**
+     * Creates list of videos from MDS.
+     *
+     * @param aSortingOrder Sorting order, see values from TSortingOrder.
+     * @param aAscending    Sort direction, if ETrue then ascending, else descending.
+     * @param aFullDetails  If ETrue, then all details will be filled to media objects,
+     *                      if EFalse, then only subset.
+     * @param aVideoList    Reference to pointer variable. Container type CMPXMedia class, contains
+     *                      CMPXMediaArray filled with CMPXMedia objects. If aVideoList
+     *                      pointer variable is NULL, then new medialist is created.
+     *                      If pointer variable already contains value, then the given medialist
+     *                      should have empty media array. New items are appended to it.
+     *                      Caller naturally owns the data.
+     *                      
+     */
+    void DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
+            TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList );
+
+    /**
+     * Handles query complete events asynchronously.
+     */
+    static TInt AsyncHandleQueryCompleted( TAny* aPtr );
+
+    /**
      * Sets Creation Date and Modified properties to object. Uses current date
      * value.
      * 
@@ -397,17 +537,17 @@
      * @param aObject Creation date is written here.
      */
     void SetCreationDateToObjectL( const CMPXMedia& aVideo, CMdEObject& aObject );
-    
+
     /**
      * Opens MDS session.
      */
     void OpenMdsSessionL();
-    
+
     /**
     * @return MDS session.
     */
     CMdESession& MdsSessionL();
-
+    
 public:
 
     /**
@@ -416,15 +556,25 @@
     */
     TBool iVideoListFetchingIsOngoing;
 
+    /**
+    * Album related functionality.
+    */
+    CVcxMyVideosMdsAlbums* iAlbums;
+        
 private: // data
 
     /**
+    * Command queue. Own.
+    */
+    CVcxMyVideosMdsCmdQueue* iCmdQueue;
+
+    /**
      * The MDS session object. Own.
      */
     CMdESession* iMdsSession;
 
     /**
-     * The error code of last iMDSSession operation. 
+     * The sessions error state.
      */
     TInt iMdsSessionError;
 
@@ -445,8 +595,8 @@
     TBool iFullDetails;
     
     /**
-     * The default namespace definition. Not own.
-     */
+    * The default namespace definition. Not own.
+    */
     CMdENamespaceDef* iNamespaceDef;
 
     /**
@@ -544,13 +694,7 @@
      * The Last Play Point property definition. Not own.
      */
     CMdEPropertyDef* iLastPlayPositionPropertyDef;
-
-    /**
-     * 17.
-     * The Download ID property definition. Not own.
-     */
-    CMdEPropertyDef* iDownloadIdPropertyDef;
-
+    
     /**
     * 18.
     * Rating property definition, not own.
@@ -605,17 +749,24 @@
     * The observer for db changes. Not own.
     */
     MVcxMyVideosMdsDbObserver* iMdsDbObserver;
-
+    
+    /**
+     * The observer for albums related database events. Not own.
+     */
+    MVcxMyVideosMdsAlbumsObserver* iAlbumsObserver;
+    
     /**
-     * Cenrep session.
+     * Used to handle complete events asynchronously.
+     * This avoids problems like deleting query objects in the
+     * handler or starting new query from the handler.
      */
-    CRepository* iRepository;
-    
+    CAsyncCallBack* iAsyncHandleQueryCompleteCaller;
+
     /**
     * Monitors Mds server shutdown states.
     */
     CVcxMdsShutdownMonitor* iMdsShutdownMonitor;
-    
+
     };
 
 #endif // VCXMYVIDEOSMDSDB_H
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmessagelist.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosmessagelist.h	Wed Jun 09 09:44:23 2010 +0300
@@ -98,7 +98,8 @@
         *                   from vcxmyvideosdefs.h for values.
         * @param aVideo     Video object which is in cache already.
         */
-        void AddEventL(const TMPXItemId& aId, TMPXChangeEventType aChange, TInt32 aExtraInfo = 0, CMPXMedia* aVideo = NULL );
+        void AddEventL(const TMPXItemId& aId, TMPXChangeEventType aChange,
+                TInt32 aExtraInfo = 0, CMPXMedia* aVideo = NULL );
 
         /**
         * Creates My Videos custom event and appends it to iMessageList.
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosopenhandler.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosopenhandler.h	Wed Jun 09 09:44:23 2010 +0300
@@ -11,11 +11,11 @@
 *
 * Contributors:
 *
-* Description:   Handles collection Open operation related functionality*
+* Description:  Handles collection Open operation related functionality
+*
 */
 
 
-
 #ifndef VCXMYVIDEOSOPENHANDLER_H
 #define VCXMYVIDEOSOPENHANDLER_H
 
@@ -23,13 +23,15 @@
 class MMPXCollectionPluginObserver;
 class CVcxMyVideosMdsDb;
 
+#include "vcxmyvideosmdsdb.h"
 /**
  */
-NONSHARABLE_CLASS( CVcxMyVideosOpenHandler ) : public CBase
+NONSHARABLE_CLASS( CVcxMyVideosOpenHandler ) : public CBase, public MVcxMyVideosMdsAlbumsObserver
     {
     friend class CVcxMyVideosVideoCache;
     
 public:
+    
     /**
     * Two-phased constructor
     */
@@ -52,18 +54,62 @@
     void OpenL( const CMPXCollectionPath& aPath );
 
     /**
-    * Leaving version of HandleCreateVideoListResp.
-    * Handler function for list fetching events. This callback is called as a response
-    * to iCache.CreateVideoListL().
-    *
-    * @param aVideoList           List of videos fetched from MDS.
-    * @param aNewItemsStartIndex  Start position for the new items added.
-    * @param aComplete            ETrue if list is complete and no more items are expected,
-    *                             EFalse if there are more to come.
-    */
+     * From MVcxMyVideosMdsAlbumsObserver.
+     */
+    void HandleAlbumOpenL();
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleGetAlbumsResp( CMPXMedia* /*aAlbumList*/ ) {}
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleGetAlbumContentIdsResp( TUint32 /*aAlbumId*/,
+            RArray<TVcxMyVideosAlbumVideo>& /*aContentArray*/ ) {}
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleAddVideosToAlbumResp( CMPXMedia* /*aCmd*/,
+            RPointerArray<CMdEInstanceItem>& /*aItemArray*/ ) {}
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleRemoveRelationsResp( RArray<TUint32>& /*aRelationIds*/,
+            RArray<TUint32>& /*aResults*/ ) {}
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleRemoveAlbumsResp( CMPXMedia* /*aCmd*/,
+            RArray<TUint32>& /*aResultIds*/ ) {}
+
+    /**
+     * From MVcxMyVideosMdsAlbumsObserver, no implementation.
+     */
+    void HandleRelationEvent( TObserverNotificationType /*aType*/,
+            const RArray<TMdERelation>& /*aRelationArray*/ ) {}
+    
+    /**
+     * Called as a response to GetAlbumContentVideosL.
+     * 
+     * @param aAlbumId           ID of the album containing the result videos.
+     * @param aVideoList         Media containing array of videos.
+     * @param aError             Error code in case of failure.
+     * @param aFirstNewItemIndex Index of the first new item.
+     * @param aNewItemCount      How many new items in the query since the last results.
+     * @param aComplete          ETrue if query is complete, EFalse if there is more to come.
+     */
+    void HandleGetAlbumContentVideosResp( TUint32 aAlbumId, CMPXMedia& aVideoList,
+            TInt aError, TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete );
+
+
     void DoHandleCreateVideoListRespL(
             CMPXMedia* aVideoList, TInt aNewItemsStartIndex, TBool aComplete );
-            
+
 private:
     /**
     * 2nd-phase Constructor
@@ -77,6 +123,35 @@
             CVcxMyVideosVideoCache& aCache,
             CVcxMyVideosMdsDb& aMds );
 
+    /**
+     * Opens category.
+     * 
+     * @param aCategoryId  Category to open.
+     */
+    void OpenCategoryL( TUint32 aCategoryId );
+
+    /**
+     * Leaving version of HandleGetAlbumContentVideosResp.
+     */
+    void HandleGetAlbumContentVideosRespL(
+            TUint32 aAlbumId, CMPXMedia& /*aVideoList*/, TInt aError,
+            TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/, TBool aComplete );
+public:
+
+    /**
+     * If album is opened when the album list is not yet complete,
+     * then the album ID which is tried to open is stored here.
+     * The open processing is continued when album list is received
+     * from MDS. There can't be several album opens pending since
+     * we do not call HandleOpen before we get the album list.
+     */
+    TUint32 iPendingAlbumOpenId;
+
+    /**
+     * for testing, temp
+     */
+    CMPXMedia* iAlbumVideoList;
+
 private: // data
 
     /**
@@ -108,6 +183,26 @@
     * This is in sync with iCategoryIdsBeingOpened.
     */
     RArray<CMPXMedia*> iVideoListsBeingOpened;
+
+    /**
+    * The album IDs being opened are stored here. These values are used
+    * to filter list when items arrive from MDS.
+    * This is in sync with iAlbumVideoListsBeingOpened.
+    */
+    RArray<TInt> iAlbumIdsBeingOpened;
+
+    /**
+    * Video lists for albums being opened are stored here.
+    * This is in sync with iAlbumIdsBeingOpened.
+    */
+    RArray<CMPXMedia*> iAlbumVideoListsBeingOpened;
+    
+    /**
+     * Path being opened is stored here for the HandleOpenL call.
+     * Not Own.
+     */
+    const CMPXCollectionPath* iPath;
+    
     };
 
 #endif // VCXMYVIDEOSACTIVETASK_H
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideostimer.h	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +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 the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:    Timer*
-*/
-
-
-
-
-#ifndef __CVCXMYVIDEOSTIMER_H__
-#define __CVCXMYVIDEOSTIMER_H__
-
-// INCLUDES
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CVcxMyVideosTimer;
-
-// CLASS DECLARATION
-/**
-*  This class specifies the function to be called when a timeout occurs.
-*  Used in conjunction with CVcxTimer class.
-*/
-class MVcxMyVideosTimerObserver
-    {
-    public: // New functions
-
-        /**
-        * The function to be called when a timeout occurs.
-        *
-        * @param aTimer Pointer to timer which expired.
-        */
-        virtual void TimerExpired(CVcxMyVideosTimer* aTimer) = 0;
-    };
-
-// CLASS DECLARATION
-/**
-* This class will notify an object after a specified timeout.
-*/
-NONSHARABLE_CLASS(CVcxMyVideosTimer) : public CTimer
-    {
-    public: // Constructors and destructors
-
-        /**
-        * Two-phased constructor.
-        * Creates a CVcxMyVideosTimer object using two phase construction,
-        * and returns a pointer to the created object.
-        *
-        * @param aPriority      Priority to use for this timer.
-        * @param aTimerObserver Object to notify of timeout event.
-        * @return               A pointer to the created instance of CVcxMyVideosTimer.
-        */
-        static CVcxMyVideosTimer* NewL( const TInt aPriority,
-            MVcxMyVideosTimerObserver& aTimerObserver );
-
-        /**
-        * Two-phased constructor.
-        * Creates a CVcxMyVideosTimer object using two phase construction,
-        * and returns a pointer to the created object.
-        *
-        * @param aPriority      Priority to use for this timer.
-        * @param aTimerObserver Object to notify of timeout event.
-        * @return               A pointer to the created instance of CVcxMyVideosTimer.
-        */
-        static CVcxMyVideosTimer* NewLC( const TInt aPriority,
-            MVcxMyVideosTimerObserver& aTimerObserver );
-
-        /**
-        * Destructor.
-        * Destroys the object and releases all memory objects.
-        */
-        virtual ~CVcxMyVideosTimer();
-
-    protected: // Functions from base classes
-
-        /**
-        * From CActive, RunL.
-        * Called when operation completes.
-        */
-        void RunL();
-
-    private: // Constructors and destructors
-
-        /**
-        * C++ default constructor.
-        * Performs the first phase of two phase construction.
-        *
-        * @param aPriority      Priority to use for this timer.
-        * @param aTimeOutNotify An observer to notify.
-        */
-        CVcxMyVideosTimer( const TInt aPriority,
-            MVcxMyVideosTimerObserver& aTimerObserver );
-
-        /**
-        * ConstructL.
-        * 2nd phase constructor.
-        */
-        void ConstructL();
-
-    private: // Data
-
-        /**
-        * The observer for this objects events.
-        */
-        MVcxMyVideosTimerObserver& iObserver;
-    };
-
-#endif // __CVCXMYVIDEOSTIMER_H__
-
-// End of File
\ No newline at end of file
--- a/videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h	Wed Jun 09 09:44:23 2010 +0300
@@ -11,12 +11,11 @@
 *
 * Contributors:
 *
-* Description:    Contains cached MDS media items*
+* Description:   Contains cached MDS media items*
 */
 
 
 
-
 #ifndef VCXMYVIDEOSVIDEOCACHE_H
 #define VCXMYVIDEOSVIDEOCACHE_H
 
@@ -26,7 +25,6 @@
 // FORWARD DECLARATIONS
 class CVcxMyVideosCollectionPlugin;
 class CMPXMedia;
-class CVcxMyVideosDownloadCache;
 class CRepository;
 
 // CONSTANTS
@@ -34,6 +32,140 @@
 // CLASS DECLARATION
 
 /**
+ * Contains information about video.
+ * These are stored to CVcxMyVideosVideoListIndex::iVideoArray.
+ */
+NONSHARABLE_CLASS(TVcxMyVideosVideo)
+    {
+    public:
+
+        /**
+         * Constructor.
+         */        
+        TVcxMyVideosVideo();
+        
+        /**
+        * = operator.
+        */        
+        TVcxMyVideosVideo& operator=( const TVcxMyVideosVideo& aVideo );
+    public:
+        
+        /**
+        * Set values.
+        * 
+        * @param aMdsId  MDS ID
+        * @param aPos    Position in CVcxMyVideosVideoCache::iVideoList
+        * @param aVideo  Pointer to CVcxMyVideosVideoCache::iVideoList item,
+        *                ownership does not move.
+        */
+        void Set( TUint32 aMdsId, TInt aPos, CMPXMedia* aVideo );
+
+    public:
+        TUint32    iMdsId; // Video object ID in MDS.
+        CMPXMedia* iVideo; // Pointer to CVcxMyVideosVideoCache::iVideoList item
+        TInt       iPos;   // Items position in CVcxMyVideosVideoCache::iVideoList
+    };
+
+/**
+* Used for keeping videos in MDS ID order for fast access.
+* (Indexes CVcxMyVideosVideoCache::iVideoList).
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosVideoListIndex) : public CBase
+    {    
+public: // Constructors and destructor
+
+    /**
+    * Two-phased constructor
+    * @return Object constructed
+    */
+    static CVcxMyVideosVideoListIndex* NewL();
+    
+    /**
+    * Destructor
+    */
+    virtual ~CVcxMyVideosVideoListIndex();
+
+public:
+    
+    /**
+     * Sets up iVideoArray from aVideoList. Sorting is also done.
+     * 
+     * @param aVideoList  Video list to use for constructing iVideoArray. 
+     */
+    void SetL( const CMPXMedia& aVideoList );
+    
+    /**
+     * Finds video by MDS ID from the index. Uses bisection method.
+     * 
+     * @param aVideo  The found video data is written here.
+     * @return        KErrNotFound if not found, index of the item in iVideoArray
+     *                otherwise.
+     */
+    TInt Find( TUint32 aMdsId, TVcxMyVideosVideo& aVideo );
+    
+    /**
+     * Removes video from index.
+     * 
+     * @param aMdsId     ID if the item to be removed.
+     * @param aCompress  If ETrue, compresses the video array.
+     * @return           KErrNotFound if not found, index of the removed item otherwise.
+     */
+    TInt Remove( TUint32 aMdsId, TBool aCompress = ETrue );
+    
+    /**
+     * Adds video to index. Keeps sorting order.
+     * 
+     * @param aVideo  Video to be added, ownership does not move.
+     * @param aPos    aVideo's position in CVcxMyVideosVideoCache::iVideoList.
+     */
+    void AddL( CMPXMedia* aVideo, TInt aPos );
+
+#ifdef _DEBUG
+    /**
+     * Returns reference to video array.
+     */
+    const RArray<TVcxMyVideosVideo>& VideoArray();
+#endif
+    
+private:
+    /**
+    * Constructor
+    */
+    CVcxMyVideosVideoListIndex();
+    
+    /**
+    * Symbian 2nd phase constructor.
+    */
+    void ConstructL ();
+
+    /**
+     * Sorts iVideoArray by MDS ID.
+     */
+    void Sort();
+    
+    /**
+     * Used for keeping RArray<TVcxMyVideosVideo> in integer order by
+     * TVcxMyVideosVideo::iMdsId.
+     * 
+     * @param aVideo1 Video to compare
+     * @param aVideo2 Video to compare
+     * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
+     *         aVideo2.
+     */
+    static TInt CompareVideosByMdsId( const TVcxMyVideosVideo& aVideo1,
+            const TVcxMyVideosVideo& aVideo2 );
+
+private:
+    
+    /**
+     * Video array which is kept in order by MDS ID.
+     */
+    RArray<TVcxMyVideosVideo> iVideoArray;
+    };
+
+/**
 * Used for storing MDS items to RAM for fast access.
 *
 * @lib mpxmyvideoscollectionplugin.lib
@@ -55,6 +187,19 @@
         */
         virtual ~CVcxMyVideosVideoCache();
  
+    public:
+        
+        /**
+         * @return  ETrue if iVideoList is complete. (All items have
+         *          been fetched from MDS.)
+         */
+        TBool IsComplete();
+        
+        /**
+         * Set to ETrue when all items have been fetched from MDS.
+         */
+        void SetComplete( TBool aComplete );
+
     private:
         /**
         * Constructor
@@ -179,7 +324,14 @@
         * @return        Position, KErrNotFound if item is not in iVideoList.
         */
         TInt PosOnVideoListL( CMPXMedia& aVideo );
-                 
+
+#ifdef _DEBUG
+        /**
+         * Checks that iVideoListIndex is correctly formed.
+         */
+        void CheckVideoListIndexL();
+#endif
+        
     public:            
         /**
         * Creates filtered video list from iVideoList. This is used for
@@ -225,16 +377,6 @@
         CMPXMedia* FindVideoByMdsIdL( TUint32 aMdsId, TInt& aPos );
         
         /**
-        * Tries to find media with matching download ID from iVideoList and iPartialVideoList.
-        * If aDownloadId is 0, then NULL is returned.
-        *
-        * @param aDownloadId ID to compare
-        * @return            Contains pointer to media if match found, NULL otherwise.
-        *                    Pointer ownership is not moved to the caller.
-        */
-        CMPXMedia* FindVideoByDownloadIdL( TUint aDownloadId );
-
-        /**
         * Gets medias from iVideoList and iPartialVideoList.
         *
         * @param aMdsIds  IDs of the items to fetch.
@@ -242,7 +384,7 @@
         *                 attribute contains the media items. Ownership
         *                 moves to caller.
         */
-        CMPXMedia* GetVideosL( RArray<TUint32> aMdsIds );
+        CMPXMedia* GetVideosL( RArray<TUint32>& aMdsIds );
 
         /**
         * Removes video from iVideoList (or from iPartialVideoList).
@@ -268,16 +410,19 @@
         * @param aMdsIds                   Array containing MDS IDs of the videos to be added.
         * @param aListFetchingWasCanceled  This is set to EFalse if video list fetching from mds
         *                                  had to be cancelled. EFalse otherwise. 
+        * @param aNonVideoIds              If argument given then Ids which were detected to not be
+        *                                  videos are written here. Caller owns the array, ownership
+        *                                  does not move.
         */
-        void AddVideosFromMdsL( RArray<TUint32>& aMdsIds, TBool& aListFetchingWasCanceled );
+        void AddVideosFromMdsL( RArray<TUint32>& aMdsIds, TBool& aListFetchingWasCanceled,
+                RArray<TUint32>* aNonVideoIds = NULL );
 
         /**
         * Deletes old and creates new iVideoList. After the function call iVideoList exists,
         * but it might not contain any media items yet, only empty array.
         * Media items are added to the list asynchronoysly in
         * VcxMyVideosColletionPlugin::HandleCreateVideoListResp(), called by
-        * VcxMyVideosMdsDb. When new items are added, they are synchronized with
-        * Download Manager. Once iVideoList is complete, iVideoListIsPartial
+        * VcxMyVideosMdsDb. Once iVideoList is complete, iVideoListIsPartial
         * is set to EFalse. During the video list fetching
         * VcxMyVideosMdsDb::iVideoListFetchingIsOngoing is ETrue.
         * If there is video list creation already ongoing
@@ -337,32 +482,34 @@
         * is removed.
         */
         RArray<CMPXMedia*> iPartialVideoList;
-
-        /**
-        * If ETrue then iVideoList does not contain all items from MDS.
-        */
-        TBool iVideoListIsPartial;
                                 
         /**
         * Sorting order which was used last time when list was queryed from MDS.
         */
         TVcxMyVideosSortingOrder iLastSortingOrder;
         
-    private:
-        
         /**
-        * Circular buffer containing download id and media object pointer pairs.
-        * Media object pointers are owned by iVideoList.
-        * Used to speed up access to media objects which are used regularly during the
-        * download.
+         * Set to ETrue when doing videolist fetching.
+         */
+        TBool iIsFetchingVideoList;
+    private:
+
+        /**
+        * If ETrue then iVideoList contains all items from MDS.
         */
-        CVcxMyVideosDownloadCache* iDownloadCache;
-
+        TBool iVideoListIsComplete;
+        
         /**
         * My Videos collection plugin, owner of this object.
         */
-        CVcxMyVideosCollectionPlugin& iCollection;        
-
+        CVcxMyVideosCollectionPlugin& iCollection;
+        
+        /**
+         * Index which keeps TVcxMyVidesVideo items indexed in MDS ID
+         * order for fast access.
+         */
+        CVcxMyVideosVideoListIndex* iVideoListIndex;
+        
         /**
         * Provides access to the sorting order key in cenrep. Own.
         */
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -79,6 +79,7 @@
 
     // Start the AO
     iStatus = KRequestPending;
+    MPX_DEBUG1("CVcxMyVideosActiveTask::StartL SetActive");
     SetActive();
     TRequestStatus* status = &iStatus;
     User::RequestComplete( status, KErrNone );
@@ -112,39 +113,98 @@
     }
 
 // ---------------------------------------------------------------------------
-// From CActive
+// Get the current media
 // ---------------------------------------------------------------------------
 //
-void CVcxMyVideosActiveTask::RunL()
+CMPXMedia* CVcxMyVideosActiveTask::Command()
     {
-    // ETrue is done, EFalse is more to do
-    //
-    if( iObserver.HandleStepL() )
-        {
-        iObserver.HandleOperationCompleted( KErrNone );
-        delete iCurCommand;
-        iCurCommand = NULL;
-        }
-    else
-        {
-        ++iCurStep;
-        iStatus = KRequestPending;
-        SetActive();
-        TRequestStatus* status = &iStatus;
-        User::RequestComplete( status, KErrNone );
-        }
+    return iCurCommand;
     }
 
 // ---------------------------------------------------------------------------
 // From CActive
 // ---------------------------------------------------------------------------
 //
+void CVcxMyVideosActiveTask::RunL()
+    {
+    MPX_DEBUG1("CVcxMyVideosActiveTask::RunL() start");
+
+    switch ( iObserver.HandleStepL() )
+        {
+        case MVcxMyVideosActiveTaskObserver::EDone:
+            Done();
+            break;
+
+        case MVcxMyVideosActiveTaskObserver::EMoreToCome:
+            ContinueStepping();
+            break;
+
+        //observer is responsible for calling Done, Cancel or ContinueStepping
+        case MVcxMyVideosActiveTaskObserver::EStopStepping:
+            MPX_DEBUG1("CVcxMyVideosActiveTask::RunL stopped stepping");
+            iStopped = ETrue;
+            break;
+        }
+    MPX_DEBUG1("CVcxMyVideosActiveTask::RunL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosActiveTask::Done
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::Done()
+    {
+    MPX_DEBUG1("CVcxMyVideosActiveTask::Done() start");
+
+    iObserver.HandleOperationCompleted( KErrNone );
+    delete iCurCommand;
+    iCurCommand = NULL;
+    iStopped = EFalse;
+
+    MPX_DEBUG1("CVcxMyVideosActiveTask::Done() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosActiveTask::ContinueStepping
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::ContinueStepping()
+    {
+    ++iCurStep;
+    iStatus = KRequestPending;
+    MPX_DEBUG1("CVcxMyVideosActiveTask::ContinueStepping SetActive");
+    SetActive();
+    iStopped = EFalse;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
+    }
+
+void CVcxMyVideosActiveTask::Cancel()
+    {
+    if ( iStopped && !IsActive() )
+        {
+        MPX_DEBUG1("CVcxMyVideosActiveTask:: was paused, calling DoCancel()");
+        DoCancel();
+        }
+    else
+        {
+        MPX_DEBUG1("CVcxMyVideosActiveTask:: wasn't paused, calling CActive::Cancel() normally");
+        CActive::Cancel();
+        }
+    }
+// ---------------------------------------------------------------------------
+// From CActive
+// ---------------------------------------------------------------------------
+//
 void CVcxMyVideosActiveTask::DoCancel()
     {
+    MPX_DEBUG1("CVcxMyVideosActiveTask::DoCancel() start");
     // Callback and cleanup
     iObserver.HandleOperationCompleted( KErrCancel );
     delete iCurCommand;
     iCurCommand = NULL;
+    iStopped = EFalse;
+    MPX_DEBUG1("CVcxMyVideosActiveTask::DoCancel() exit");
     }
 
 // ---------------------------------------------------------------------------
@@ -153,11 +213,15 @@
 //
 TInt CVcxMyVideosActiveTask::RunError( TInt aError )
     {
+    MPX_DEBUG1("CVcxMyVideosActiveTask::RunError() start");
+    
     // Callback and cleanup
     iObserver.HandleOperationCompleted( aError );
     delete iCurCommand;
     iCurCommand = NULL;
+    iStopped = EFalse;
 
+    MPX_DEBUG1("CVcxMyVideosActiveTask::RunError() exit");
     return KErrNone;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosalbum.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,334 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Class representing album in My Videos collection.
+*/
+
+#include <mpxlog.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediageneraldefs.h>
+#include "vcxmyvideosalbum.h"
+#include "vcxmyvideoscollectionplugin.h"
+#include "vcxmyvideosvideocache.h"
+#include "vcxmyvideoscollectionutil.h"
+
+
+// ---------------------------------------------------------------------------
+// TVcxMyVideosAlbumVideo::TVcxMyVideosAlbumVideo
+// ---------------------------------------------------------------------------
+//
+TVcxMyVideosAlbumVideo::TVcxMyVideosAlbumVideo()
+    {
+    Set( 0, 0, 0 );
+    }
+
+// ---------------------------------------------------------------------------
+// TVcxMyVideosAlbumVideo::operator=
+// ---------------------------------------------------------------------------
+//                
+TVcxMyVideosAlbumVideo& TVcxMyVideosAlbumVideo::operator=( const TVcxMyVideosAlbumVideo& aVideo )
+    {
+    Set( aVideo.iMdsId, aVideo.iRelationMdsId, aVideo.iMedia );
+    return *this;
+    }
+
+// ---------------------------------------------------------------------------
+// TVcxMyVideosAlbumVideo::Set
+// ---------------------------------------------------------------------------
+//            
+void TVcxMyVideosAlbumVideo::Set( TUint32 aMdsId, TUint32 aRelationMdsId, CMPXMedia* aVideo )
+    {
+    iMdsId         = aMdsId;
+    iRelationMdsId = aRelationMdsId;
+    iMedia         = aVideo;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::CVcxMyVideosAlbum
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbum::CVcxMyVideosAlbum( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
+: iCollection( aCollectionPlugin )
+    {
+    // No implementation required
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::~CVcxMyVideosAlbum
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbum::~CVcxMyVideosAlbum()
+    {
+    iVideoList.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::NewLC
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbum* CVcxMyVideosAlbum::NewLC( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
+    {
+    CVcxMyVideosAlbum* self = new (ELeave) CVcxMyVideosAlbum( aCollectionPlugin );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::NewL
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbum* CVcxMyVideosAlbum::NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
+    {
+    CVcxMyVideosAlbum* self = CVcxMyVideosAlbum::NewLC( aCollectionPlugin );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::ConstructL()
+    {
+    iVideoList.Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::Sort
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::Sort()
+    {
+    const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
+            CVcxMyVideosAlbum::CompareVideosByMdsId );
+
+    iVideoList.Sort( KOrderByMdsId );
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::SetL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::SetL( /*CMPXMedia& aAlbum*/ )
+    {
+    //TODO:
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::BelongsToAlbum
+// ---------------------------------------------------------------------------
+//
+TBool CVcxMyVideosAlbum::BelongsToAlbum( TUint32 aMdsId )
+    {
+    const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
+            CVcxMyVideosAlbum::CompareVideosByMdsId );
+    
+    TInt index;
+    TVcxMyVideosAlbumVideo video;
+    video.iMdsId = aMdsId;
+    TInt err = iVideoList.FindInOrder( video, index, KOrderByMdsId );
+    
+    if ( err != KErrNone )
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::Video
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosAlbum::Video( TUint32 aMdsId, TVcxMyVideosAlbumVideo& aVideo, TInt& aIndex )
+    {
+    const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
+            CVcxMyVideosAlbum::CompareVideosByMdsId );
+    
+    TVcxMyVideosAlbumVideo videoToFind;
+    videoToFind.iMdsId = aMdsId;
+    TInt err = iVideoList.FindInOrder( videoToFind, aIndex, KOrderByMdsId );
+
+    if ( err == KErrNone )
+        {
+        aVideo = iVideoList[aIndex];
+        }
+   
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::AddL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::AddL( TVcxMyVideosAlbumVideo aVideo )
+    {
+    const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
+            CVcxMyVideosAlbum::CompareVideosByMdsId );
+
+    iVideoList.InsertInOrderAllowRepeatsL( aVideo, KOrderByMdsId );
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::Remove
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::Remove( RArray<TUint32>& aMdsIds )
+    {
+    TInt count = aMdsIds.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        Remove( aMdsIds[i], EFalse /* don't compress */ );
+        }
+    iVideoList.Compress();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::Remove
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::Remove( TUint32 aMdsId, TBool aCompress )
+    {
+    const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
+            CVcxMyVideosAlbum::CompareVideosByMdsId );
+
+    TVcxMyVideosAlbumVideo video;
+    video.iMdsId = aMdsId;
+    TInt pos;
+    TInt err = iVideoList.FindInOrder( video, pos, KOrderByMdsId );
+    if ( err == KErrNone )
+        {
+        iVideoList.Remove( pos );
+        }
+    if ( aCompress )
+        {
+        iVideoList.Compress();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::CompareVideosByMdsId
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosAlbum::CompareVideosByMdsId( const TVcxMyVideosAlbumVideo& aVideo1,
+        const TVcxMyVideosAlbumVideo& aVideo2 )
+    {
+    if ( aVideo1.iMdsId == aVideo2.iMdsId )
+        {
+        return 0;
+        }
+
+    if ( aVideo1.iMdsId < aVideo2.iMdsId )
+        {
+        return -1;
+        }
+    return 1;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::CreateVideoListL
+// Creates album video list from iCollection.iCache->iVideoList.
+// ---------------------------------------------------------------------------
+//
+CMPXMedia* CVcxMyVideosAlbum::CreateVideoListL()
+    {
+    CMPXMedia* toVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+    CleanupStack::PushL( toVideoList );
+
+    AppendToVideoListL( *iCollection.iCache->iVideoList, *toVideoList, 0 );
+    
+    CleanupStack::Pop( toVideoList );
+
+    return toVideoList;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::CreateVideoListL
+// Appends to video list the items which belong to this album.
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::AppendToVideoListL( CMPXMedia& aFromVideoList,
+        CMPXMedia& aToVideoList, TInt aNewItemStartIndex )
+    {
+    if ( aNewItemStartIndex < 0 )
+        {
+        return;
+        }
+    
+    CMPXMediaArray* fromArray = aFromVideoList.Value<CMPXMediaArray>( KMPXMediaArrayContents ); 
+    CMPXMediaArray* toArray   = aToVideoList.Value<CMPXMediaArray>( KMPXMediaArrayContents ); 
+    TUint32 mdsId;
+    CMPXMedia* fromVideo;
+    TInt count = fromArray->Count();
+    for ( TInt i = aNewItemStartIndex; i < count; i++ )
+        {
+        fromVideo = fromArray->AtL( i );
+        mdsId = TVcxMyVideosCollectionUtil::IdL( *fromVideo ).iId1;
+        if ( BelongsToAlbum( mdsId ) )
+            {
+            CMPXMedia* toVideo = CMPXMedia::NewL( *fromVideo ); //share underlying memory
+            CleanupStack::PushL( toVideo );
+            toArray->AppendL( toVideo );
+            CleanupStack::Pop( toVideo );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosAlbum::CalculateAttributesL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbum::CalculateAttributesL( TInt aStartIndex )
+    {
+    TInt videoCount = 0;
+    TUint32 count = iVideoList.Count();
+    TInt newCount = 0;
+    CMPXMedia* video;
+    CMPXMedia* latestNewVideo = NULL;
+    TInt pos;
+    TUint32 flags;
+    TInt64 currentItemsCreationDate = 0;
+    TInt64 latestCreationDate = TVcxMyVideosCollectionUtil::CreationDateL( *iMedia );
+    for ( TInt i = aStartIndex; i < count; i++ )
+        {
+        video = iCollection.iCache->FindVideoByMdsIdL( iVideoList[i].iMdsId, pos );
+        if ( video )
+            {
+            videoCount++;
+            flags = TVcxMyVideosCollectionUtil::FlagsL( *video );
+            if ( flags & EVcxMyVideosVideoNew )
+                {
+                newCount++;
+                currentItemsCreationDate = TVcxMyVideosCollectionUtil::CreationDateL( *video );
+                if ( latestCreationDate < currentItemsCreationDate )
+                    {
+                    latestCreationDate = currentItemsCreationDate;
+                    latestNewVideo     = video;
+                    }
+                }
+            }
+        }
+    iMedia->SetTObjectValueL<TUint32>( KVcxMediaMyVideosCategoryItemCount, videoCount );
+    iMedia->SetTObjectValueL<TUint32>( KVcxMediaMyVideosCategoryNewItemCount, newCount );
+    if ( latestNewVideo )
+        {
+        iMedia->SetTextValueL( KVcxMediaMyVideosCategoryNewItemName,
+                TVcxMyVideosCollectionUtil::Title( *latestNewVideo ) );
+        }
+    iMedia->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, latestCreationDate );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosalbums.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,806 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Albums related collection functionality (except db operations).
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxcollectionpluginobserver.h>
+#include <mpxmediageneraldefs.h>
+#include "vcxmyvideosalbums.h"
+#include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideoscollectionplugin.h"
+#include "vcxmyvideosmdsdb.h"
+#include "vcxmyvideosmdsalbums.h"
+#include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosmessagelist.h"
+#include "vcxmyvideosopenhandler.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbums::CVcxMyVideosAlbums( CVcxMyVideosCollectionPlugin& aCollection )
+: iCollection( aCollection )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::ConstructL()
+    {
+    iAlbums.Reset();
+    iChangedAlbums.Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbums* CVcxMyVideosAlbums::NewL( CVcxMyVideosCollectionPlugin& aCollection )
+    {
+    CVcxMyVideosAlbums* self = new(ELeave) CVcxMyVideosAlbums( aCollection );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosAlbums::~CVcxMyVideosAlbums()
+    {
+    delete iAlbumList;
+    TInt count = iAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        delete iAlbums[i];
+        }
+    iAlbums.Close();
+    iMdsOpTargetIds.Close();
+    iMdsOpResults.Close();
+    iMdsOpResultsUint32.Close();
+    iRemoveFromAlbumVideos.Close();
+    iChangedAlbums.Close();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::CreateAlbumListL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::CreateAlbumListL()
+    {
+    if ( iAlbumList )
+        {
+        return;
+        }
+    iAlbumList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+    iCollection.iMyVideosMdsDb->iAlbums->GetAlbumsL( iAlbumList, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::CreateAlbumsL
+// Called when iAlbumList is ready, fills iAlbums.
+// Pointers to CVcxMyVideosVideoCache::iVideoList are not filled in yet.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::CreateAlbumsL()
+    {
+    CMPXMediaArray* albumArray = iAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+
+    TInt count = albumArray->Count();
+    CVcxMyVideosAlbum* album;
+    CMPXMedia* media;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        media = albumArray->AtL( i );
+        album = CVcxMyVideosAlbum::NewLC( iCollection );
+        album->iMdsId = TVcxMyVideosCollectionUtil::IdL( *media ).iId1;
+        album->iMedia = media;
+        iAlbums.AppendL( album );
+        CleanupStack::Pop( album );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::GetAlbumContentIdsL
+// Fetches MDS IDs for all albums.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::GetAlbumContentIdsL()
+    {
+    TInt count = iAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // These calls go to queue and responses arrive asynchronously
+        // to HandleGetAlbumContentIdsRespL.
+        iCollection.iMyVideosMdsDb->iAlbums->GetAlbumContentIdsL( iAlbums[i]->iMdsId,
+                iAlbums[i]->iVideoList, *this );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::Album
+// ----------------------------------------------------------------------------
+//
+CVcxMyVideosAlbum* CVcxMyVideosAlbums::Album( TUint32 aMdsId, TInt* aPos )
+    {
+    TInt count = iAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( iAlbums[i]->iMdsId == aMdsId )
+            {
+            if ( aPos )
+                {
+                *aPos = i;
+                }
+            return iAlbums[i];
+            }
+        }
+    return NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::AddVideosToAlbumL
+// Command from MPX client.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::AddVideosToAlbumL( CMPXMedia* aCmd )
+    {    
+    TInt albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
+    CVcxMyVideosAlbum* album = Album( albumId );
+    if ( album )
+        {
+        CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
+        TInt count = mediaArray->Count();
+        CMPXMedia* video;
+        TInt mdsId;
+        RArray<TUint32> uniqueVideoIds;
+        uniqueVideoIds.Reset();
+        CleanupClosePushL( uniqueVideoIds );
+        
+        for ( TInt i = 0; i < count; i++ )
+            {
+            video = mediaArray->AtL( i );
+            mdsId = TVcxMyVideosCollectionUtil::IdL( *video ).iId1;
+
+            // Mark duplicates as failed to aCmd (KErrAlreadyExists)
+            if ( uniqueVideoIds.Find( mdsId ) == KErrNotFound )
+                {
+                uniqueVideoIds.AppendL( mdsId );
+
+                // Mark videos which are already in album as failed to aCmd (KErrAlreadyExists)
+                if ( album->BelongsToAlbum( mdsId ) )
+                    {
+                    MPX_DEBUG3("CVcxMyVideosAlbums:: %d already belongs to %d album",
+                            mdsId, albumId );
+                    video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value, KErrAlreadyExists );
+                    }
+                else
+                    {
+                    video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value, KErrNone );
+                    }
+                }
+            else
+                {
+                MPX_DEBUG2("CVcxMyVideosAlbums:: %d already present in the aCmd, marking as KErrAlreadyExists", mdsId);
+                video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value, KErrAlreadyExists );
+                }
+
+            }
+        
+        CleanupStack::PopAndDestroy( &uniqueVideoIds );
+        }
+    
+    iCollection.iMyVideosMdsDb->iAlbums->AddVideosToAlbumL( aCmd, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::RemoveVideosFromAlbumL
+// Converts video mpx ids to relation ids and calls RemoveRelationsL.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::RemoveVideosFromAlbumL( CMPXMedia* aCmd )
+    {
+    TInt albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
+    CMPXMediaArray* array = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
+    TVcxMyVideosAlbumVideo video;
+    TInt index;
+    TInt error;
+    CMPXMedia* media;
+    TInt count = array->Count();
+    iMdsOpTargetIds.Reset();
+    iMdsOpTargetIds.Reserve( count );
+    iRemoveFromAlbumVideos.Reset();
+    iRemoveFromAlbumVideos.Reserve( count );
+    TVcxMyVideosAlbumVideo paddingVideo;
+    paddingVideo.iMdsId         = 0;
+    paddingVideo.iRelationMdsId = 0;
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        media = array->AtL( i );
+        error = Album( albumId )->Video(
+                TVcxMyVideosCollectionUtil::IdL( *media ).iId1, video, index );
+        if ( error == KErrNone )
+            {
+            iRemoveFromAlbumVideos.AppendL( video ); //store album video data now to avoid second search when response arrives
+            iMdsOpTargetIds.AppendL( video.iRelationMdsId );
+            }
+        else
+            {
+            iRemoveFromAlbumVideos.AppendL( paddingVideo ); //add dummy video to keep media array and iRemoveFromAlbumVideos in sync
+            }
+        }
+    iMdsOpResultsUint32.Reset();
+    iCollection.iMyVideosMdsDb->iAlbums->RemoveRelationsL(
+            iMdsOpTargetIds, iMdsOpResultsUint32, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::AddAlbumL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::AddAlbumL( CMPXMedia& aCmd )
+    {
+    if ( TVcxMyVideosCollectionUtil::Title( aCmd ).Length() > 255 )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    iCollection.iMyVideosMdsDb->iAlbums->AddAlbumL( aCmd );
+    
+    TUint32 mdsId = TVcxMyVideosCollectionUtil::IdL( aCmd ).iId1;
+    if ( !Album( mdsId ) )
+        {
+        CMPXMediaArray* albumArray = iAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+        albumArray->AppendL( aCmd );
+        
+        CVcxMyVideosAlbum* album = CVcxMyVideosAlbum::NewLC( iCollection );
+        album->iMdsId = mdsId;
+        album->iMedia = albumArray->AtL( albumArray->Count() - 1 );
+        iAlbums.AppendL( album );
+        CleanupStack::Pop( album );
+        
+        iCollection.iMessageList->AddEventL( TMPXItemId( mdsId, KVcxMvcMediaTypeAlbum ),
+                EMPXItemInserted, EVcxMyVideosListNoInfo, album->iMedia );
+        iCollection.iMessageList->SendL();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::RemoveAlbumsFromMdsOnlyL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::RemoveAlbumsFromMdsOnlyL( CMPXMedia* aCmd )
+    {
+    iCollection.iMyVideosMdsDb->iAlbums->RemoveAlbumsL( aCmd, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::RemoveAlbumsL
+// From MDS delete event.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::RemoveAlbumsL( RArray<TUint32>& aAlbumIds )
+    {
+    TInt count = aAlbumIds.Count();
+    for ( TInt i = count -1; i >= 0; i-- )
+        {
+        TBool removed = RemoveAlbumL( aAlbumIds[i], EFalse /* dont compress */);
+        if ( removed )
+            {
+            aAlbumIds.Remove( i );
+            }
+        }
+    iAlbums.Compress();
+    
+    iCollection.iMessageList->SendL();        
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::RemoveAlbumL
+// ----------------------------------------------------------------------------
+//
+TBool CVcxMyVideosAlbums::RemoveAlbumL( TUint32 aMdsId, TBool aCompress )
+    {
+    TInt pos;
+    CVcxMyVideosAlbum* album = Album( aMdsId, &pos );
+    if ( album )
+        {
+        CMPXMediaArray* albumArray = TVcxMyVideosCollectionUtil::MediaArrayL( *iAlbumList );
+        
+        iAlbums.Remove( pos );
+        albumArray->Remove( pos );
+        
+        MPX_DEBUG2("CVcxMyVideosAlbums:: removing album from pos %d", pos);
+        
+        if ( aCompress )
+            {
+            iAlbums.Compress();
+            }
+        iCollection.iMessageList->AddEventL( TMPXItemId( aMdsId, KVcxMvcMediaTypeAlbum ),
+                EMPXItemDeleted, EVcxMyVideosListNoInfo );
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::CalculateAttributesL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::CalculateAttributesL()
+    {
+    TInt count = iAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        iAlbums[i]->CalculateAttributesL();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::AddAlbumsFromMdsL
+// From MDS insert event, no need to fetch content since the album was just
+// created.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::AddAlbumsFromMdsL( RArray<TUint32>& /*aAlbumIds*/ )
+    {
+    //TODO: implement if we want to support albums which are added by someone else
+    //      than My Videos Collection.
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleGetAlbumsRespL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleGetAlbumsRespL( CMPXMedia* aAlbumList )
+    {
+    // aAlbumList = iAlbumList
+    CMPXMediaArray* array = aAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    TInt count = array->Count();
+    TMPXItemId mpxId;
+    CMPXMedia* album;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        album = array->AtL( i );
+        mpxId = TVcxMyVideosCollectionUtil::IdL( *album );
+        iCollection.iMessageList->AddEventL( mpxId, EMPXItemInserted, 0, album );
+        }
+    CreateAlbumsL(); //fills in iAlbums from iAlbumList
+    GetAlbumContentIdsL(); //fills iAlbums with MDS IDs of the videos asynchronously
+    iCollection.iMessageList->SendL();
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleGetAlbumContentIdsRespL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleGetAlbumContentIdsRespL( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& /*aAlbumContentIds*/ )
+    {    
+    //&aAlbumContent = iAlbums[x]->iVideoList
+    
+    CVcxMyVideosAlbum* album( Album( aAlbumId ) ); 
+    if ( album )
+        {
+        album->Sort(); //sorts iAlbum[x]->iVideoList by MDS ID.
+        }
+
+    //if last album -> album list is complete
+    if ( iAlbums[iAlbums.Count() -1]->iMdsId == aAlbumId )
+        {
+        MPX_DEBUG1("CVcxMyVideosAlbums:: content ids for last album arrived -> album list is complete" );
+        iAlbumListIsComplete = ETrue;
+
+        if ( iCollection.iOpenHandler->iPendingAlbumOpenId )
+            {
+            MPX_DEBUG1("CVcxMyVideosAlbums:: there was album open pending, calling HandleAlbumOpenL()" );
+
+            TRAPD( err, iCollection.iOpenHandler->HandleAlbumOpenL() );
+            if ( err != KErrNone )
+                {
+                MPX_DEBUG3("CVcxMyVideosAlbums:: HandleAlbumOpenL() left: %d, calling HandleOpen(NULL,%d)",
+                        err, err);
+                iCollection.iObs->HandleOpen( static_cast<CMPXMedia*>(NULL), err );
+                }
+            }
+        }
+    
+    
+#ifdef _DEBUG
+    if ( album )
+        {
+        TInt count = album->iVideoList.Count();
+
+        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: content ids for album %d arrived", aAlbumId);
+
+        for ( TInt i = 0; i < album->iVideoList.Count(); i++ )
+            {
+            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: mds id = %d", album->iVideoList[i].iMdsId );
+            }
+        }
+#endif
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleGetAlbumsResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleGetAlbumsResp( CMPXMedia* aAlbumList )
+    {
+    TRAP_IGNORE( HandleGetAlbumsRespL( aAlbumList ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleGetAlbumContentIdsResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleGetAlbumContentIdsResp( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& aAlbumContent )
+    {
+    TRAP_IGNORE( HandleGetAlbumContentIdsRespL( aAlbumId, aAlbumContent ) );    
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleAddVideosToAlbumResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleAddVideosToAlbumResp( CMPXMedia* aCmd,
+        RPointerArray<CMdEInstanceItem>& aItemArray )
+    {    
+    TRAPD( err, DoHandleAddVideosToAlbumRespL( aCmd, aItemArray ) );
+    
+    if ( err != KErrNone )
+        {
+        CMPXMedia* cmd = iCollection.iActiveTask->Command(); 
+        if ( cmd )
+            {
+            cmd->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value, err );
+            iCollection.iActiveTask->Done();
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::DoHandleAddVideosToAlbumResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::DoHandleAddVideosToAlbumRespL( CMPXMedia* aCmd,
+        RPointerArray<CMdEInstanceItem>& aItemArray )
+    {
+    MPX_DEBUG1("CVcxMyVideosAlbums::DoHandleAddVideosToAlbumResp() start");
+
+    TUint32 albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
+    CVcxMyVideosAlbum* album = Album( albumId );
+
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
+    
+    TVcxMyVideosAlbumVideo video;
+    RArray<CVcxMyVideosAlbum*> modifiedAlbums;
+    modifiedAlbums.Reset();
+    CleanupClosePushL( modifiedAlbums );
+
+    TInt mediaArrayCount  = mediaArray->Count();
+    TInt resultArrayCount = aItemArray.Count();
+    CMPXMedia* media;
+    TInt j = 0;
+    for ( TInt i = 0; i < mediaArrayCount; i++ )
+        {
+        if ( j > resultArrayCount - 1 )
+            {
+            MPX_DEBUG1("CVcxMyVideosAlbums:: result array already at end, skipping the rest");
+            break; //break from for loop
+            }
+
+        media = mediaArray->AtL( i );
+
+        // Skip items which were already failed (KErrAlreadyExists)
+        if ( TVcxMyVideosCollectionUtil::Int32ValueL( *media ) != KErrAlreadyExists )
+            {
+            video.iRelationMdsId = aItemArray[j]->Id(); 
+            MPX_DEBUG3( "CVcxMyVideosAlbums:: item result[%d] = %d (id)", j, video.iRelationMdsId );
+            if ( video.iRelationMdsId == KNoId )
+                {
+                media->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
+                        KErrGeneral );
+                }
+            else
+                {
+                media->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value, KErrNone );
+                video.iMdsId = TVcxMyVideosCollectionUtil::IdL( *media ).iId1;
+                if ( album )
+                    {
+                    album->AddL( video );
+                    if ( modifiedAlbums.Find( album ) == KErrNotFound )
+                        {
+                        modifiedAlbums.AppendL( album );
+                        }
+                    iCollection.iMessageList->AddEventL( TMPXItemId( albumId, KVcxMvcMediaTypeAlbum ),
+                            EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
+                    }
+                }
+            j++;
+            }
+        else
+            {
+            MPX_DEBUG2("CVcxMyVideosAlbums:: skipping already failed %d(KErrAlreadyExists) media array item",
+                    TVcxMyVideosCollectionUtil::IdL( *media ).iId1 );
+            }
+        }
+
+    TInt count = modifiedAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        modifiedAlbums[i]->CalculateAttributesL();
+        }
+    
+    CleanupStack::PopAndDestroy( &modifiedAlbums );
+    
+    iCollection.iActiveTask->Done();
+    iCollection.iMessageList->SendL();
+    
+    MPX_DEBUG1("CVcxMyVideosAlbums::DoHandleAddVideosToAlbumResp() exit");
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleRemoveRelationsResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleRemoveRelationsResp( RArray<TUint32>& /*aRelationIds*/,
+        RArray<TUint32>& aResults )
+    {
+    MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() start");
+    
+    // iRemoveFromAlbumVideos and mediaArray are in sync
+    
+    TRAP_IGNORE(
+    
+    CMPXMedia* cmd             = iCollection.iActiveTask->Command();
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *cmd );
+    TInt count                 = iRemoveFromAlbumVideos.Count();
+    CMPXMedia* video;
+    TInt relationId;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        video = mediaArray->AtL( i );
+        relationId = iRemoveFromAlbumVideos[i].iRelationMdsId;
+        if ( relationId != 0 && 
+                aResults.Find( relationId ) != KErrNotFound )
+            {
+            video->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrNone );
+            }
+        else
+            {
+            video->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
+            }
+        }
+    
+    );
+    
+    iRemoveFromAlbumVideos.Reset();
+    
+    iCollection.iActiveTask->Done();
+
+    MPX_DEBUG1("CVcxMyVideosAlbums::HandleRemoveRelationsResp() exit");
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleRemoveAlbumsResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleRemoveAlbumsResp( CMPXMedia* aCmd,
+        RArray<TUint32>& aResultIds )
+    {    
+    TRAP_IGNORE(
+    
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
+    TInt count = mediaArray->Count();
+    TUint32 mdsId;
+    CMPXMedia* album;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        album = mediaArray->AtL( i );
+        mdsId = TVcxMyVideosCollectionUtil::IdL( *album ).iId1;
+        if ( aResultIds.Find( mdsId ) != KErrNotFound )
+            {
+            album->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrNone );
+            }
+        else
+            {
+            album->SetTObjectValueL( KVcxMediaMyVideosInt32Value, KErrGeneral );
+            }
+        }
+    
+    );
+    
+    iCollection.iActiveTask->Done();
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::HandleRelationEvent
+// Only relation removed events are received here.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::HandleRelationEvent( TObserverNotificationType /*aType*/,
+        const RArray<TMdERelation>& aRelationArray )
+    {    
+    TRAP_IGNORE(
+
+    RArray<CVcxMyVideosAlbum*> modifiedAlbums;
+    modifiedAlbums.Reset();
+    CleanupClosePushL( modifiedAlbums );
+
+    TUint albumId;
+    CVcxMyVideosAlbum* album;
+    TInt count = aRelationArray.Count();
+    
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        albumId = aRelationArray[i].LeftObjectId();
+        
+        MPX_DEBUG3("CVcxMyVideosAlbums:: relation (%d,%d) deleted from MDS",
+                aRelationArray[i].LeftObjectId(), aRelationArray[i].RightObjectId() );
+        
+        if ( iAlbumListIsComplete )
+            {
+            album = Album( albumId );
+            if ( album )
+                {
+                if ( modifiedAlbums.Find( album ) == KErrNotFound )
+                    {
+                    modifiedAlbums.AppendL( album );
+                    }
+                album->Remove( aRelationArray[i].RightObjectId(), ETrue /* compress */ );
+                iCollection.iMessageList->AddEventL( TMPXItemId( albumId, KVcxMvcMediaTypeAlbum ),
+                        EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
+                }
+            }
+        else
+            {
+            //We are fetching albums already, we assume that it will be up to date.
+            //If that is not the case, then we should set some flag here and restart
+            //album fetching from scratch.
+            }
+        }
+    
+    count = modifiedAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        modifiedAlbums[i]->CalculateAttributesL();
+        }
+    
+    CleanupStack::PopAndDestroy( &modifiedAlbums );
+    
+    iCollection.iMessageList->SendL();
+    
+    );
+    }
+
+//HandleRelationIdEvent
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::UpdateAlbumL
+// Updates album attributes from aAlbum, if album is not found from memory,
+// nothing is done (no fetching from MDS).
+// This func is also called (by MDS modified event) when items are added or
+// removed from album.
+// ----------------------------------------------------------------------------
+//
+TBool CVcxMyVideosAlbums::UpdateAlbumL( const CMPXMedia& aAlbum )
+    {
+    TBool changed = EFalse;
+    
+    TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( aAlbum );
+    CVcxMyVideosAlbum* album = Album( mpxId.iId1 );
+
+    if ( album && album->iMedia )
+        {
+        CMPXMedia* media = album->iMedia;
+
+        if ( media->IsSupported( KMPXMediaGeneralTitle ) )
+            {
+            TPtrC newTitle( TVcxMyVideosCollectionUtil::Title( aAlbum ) );
+            TPtrC oldTitle( TVcxMyVideosCollectionUtil::Title( *media ) );
+
+            if ( newTitle != oldTitle )
+                {
+                media->SetTextValueL( KMPXMediaGeneralTitle, newTitle );
+                iCollection.iMessageList->AddEventL( mpxId, EMPXItemModified );
+                changed = ETrue;
+                }
+            }
+        // calculate attributes, in case that videos were removed or added to this album
+        album->CalculateAttributesL();
+        }
+        
+    return changed;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::NewVideoFlagChangedL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::NewVideoFlagChangedL( TUint32 aMdsId )
+    {    
+    TInt count = iAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( iAlbums[i]->BelongsToAlbum( aMdsId ) )
+            {
+            iAlbums[i]->CalculateAttributesL();
+            iCollection.iMessageList->AddEventL(
+                    TMPXItemId( iAlbums[i]->iMdsId, KVcxMvcMediaTypeAlbum ),
+                    EMPXItemModified, EVcxMyVideosListNoInfo );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::VideoTitleChangedL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::VideoTitleChangedL( TUint32 aMdsId )
+    {    
+    NewVideoFlagChangedL( aMdsId ); // same calculation works for this
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::VideoAddedOrRemovedFromCacheL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::VideoAddedOrRemovedFromCacheL( CMPXMedia& aVideo )
+    {
+    TInt count = iAlbums.Count();
+    TUint32 mdsId = TVcxMyVideosCollectionUtil::IdL( aVideo ).iId1;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( iAlbums[i]->BelongsToAlbum( mdsId ) )
+            {
+            if ( iChangedAlbums.Find( i ) == KErrNotFound )
+                {
+                iChangedAlbums.AppendL( i );
+                }
+            }
+        }    
+    }
+// ----------------------------------------------------------------------------
+// CVcxMyVideosAlbums::UpdateChangedAlbumsL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosAlbums::UpdateChangedAlbumsL()
+    {
+    TInt count = iChangedAlbums.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        iCollection.iMessageList->AddEventL(
+                TMPXItemId( iAlbums[iChangedAlbums[i]]->iMdsId, KVcxMvcMediaTypeAlbum ),
+                EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
+        iAlbums[iChangedAlbums[i]]->CalculateAttributesL();
+        }
+    iChangedAlbums.Reset();
+    }
+// END OF FILE
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfilecopy.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfilecopy.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -127,7 +127,7 @@
     User::LeaveIfError( error );
     User::LeaveIfError( iSourceFile.Size( iDataRemaining ) );
     User::LeaveIfError( iTargetFile.SetSize( iDataRemaining ) );
-    
+
     TInt suggestBlockSize;
     if ( iDataRemaining > KBigBufSize )
         {
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfileoperations.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosasyncfileoperations.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -34,7 +34,6 @@
 #include "vcxmyvideoscollectionplugin.h"
 #include "vcxmyvideoscollection.hrh"
 #include "vcxmyvideoscollectionutil.h"
-#include "vcxmyvideosdownloadutil.h"
 #include "vcxmyvideosvideocache.h"
 #include "vcxmyvideoscategories.h"
 #include "vcxmyvideosmessagelist.h"
@@ -63,7 +62,7 @@
 // ----------------------------------------------------------------------------
 //
 CVcxMyVideosAsyncFileOperations::~CVcxMyVideosAsyncFileOperations()
-    {        
+    {
     iOperationIdArray.Close();
     iOperationResult.Close();
     delete iFileCopier;
@@ -220,7 +219,8 @@
 // CVcxMyVideosAsyncFileOperations::HandleMoveOrCopyStepL
 // ----------------------------------------------------------------------------
 //
-TBool CVcxMyVideosAsyncFileOperations::HandleMoveOrCopyStepL()
+MVcxMyVideosActiveTaskObserver::TStepResult
+        CVcxMyVideosAsyncFileOperations::HandleMoveOrCopyStepL()
     {
     // Reset inactivity timer. This will prevent ThumbAGDaemon start running while
     // Move/copy is ongoing and failing the operation due to locked file handle.
@@ -228,20 +228,19 @@
     
     CMPXMedia& cmd = iCollection.iActiveTask->GetCommand();
     
-    TBool done;
-            
+    MVcxMyVideosActiveTaskObserver::TStepResult stepResult;
+        
     if ( iCurrentOperationIndex == 0 && !iFileCopier->CopyIsOngoing() )
         {
         InitMoveOrCopyOperationsL( cmd );        
         }
 
-    TRAPD( err, MoveOrCopyVideoL( iOperationIdArray[iCurrentOperationIndex],
-            iTargetDrive ));
+    TRAPD( err, MoveOrCopyVideoL( iOperationIdArray[iCurrentOperationIndex] ) );
 
     if ( iFileCopier->CopyIsOngoing() && err == KErrNone )
         {
         // copy didnt finish yet, lets do some more steps before jumping to next file
-        return EFalse;
+        return MVcxMyVideosActiveTaskObserver::EMoreToCome;
         }
         
     iOperationResult.AppendL( err );
@@ -252,7 +251,7 @@
     if ( iCurrentOperationIndex > (iOperationIdArray.Count() - 1) )
         {
         iCurrentOperationIndex = 0;
-        done                   = ETrue;
+        stepResult             = MVcxMyVideosActiveTaskObserver::EDone;
         if ( iIsMoveOperation )
             {
             SendOperationRespL( KVcxMessageMyVideosMoveResp );
@@ -264,10 +263,10 @@
         }
     else
         {
-        done = EFalse;
+        stepResult = MVcxMyVideosActiveTaskObserver::EMoreToCome;
         }
         
-    return done;
+    return stepResult;
     }
 
 // ----------------------------------------------------------------------------
@@ -329,7 +328,7 @@
 // ----------------------------------------------------------------------------
 //
 void CVcxMyVideosAsyncFileOperations::CancelOperationL( TInt aErr )
-    {    
+    {
     if ( iCollection.iActiveTask->IsActive() )
         {
         TInt mvCmdId = -1;
@@ -440,7 +439,7 @@
 // CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL
 // ----------------------------------------------------------------------------
 //
-void CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL( TUint32 aMdsId, TInt aTargetDrive )
+void CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL( TUint32 aMdsId )
     {
     if ( iFileCopier->CopyIsOngoing() )
         {
@@ -453,7 +452,7 @@
         }
         
     //New file copy starts -> do sanity checks and mds and collection preparations
-    InitSingleMoveOrCopyL( aMdsId, aTargetDrive );
+    InitSingleMoveOrCopyL( aMdsId );
             
     MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: copying: %S", &iSourcePath);
     MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: to     : %S", &iTargetPath);
@@ -471,7 +470,7 @@
 // CVcxMyVideosAsyncFileOperations::InitSingleMoveOrCopyL
 // ----------------------------------------------------------------------------
 //
-void CVcxMyVideosAsyncFileOperations::InitSingleMoveOrCopyL( TUint32 aMdsId, TInt aTargetDrive )
+void CVcxMyVideosAsyncFileOperations::InitSingleMoveOrCopyL( TUint32 aMdsId )
     {
     //get media from cache or mds
     TInt pos;
@@ -497,7 +496,7 @@
     CleanupStack::PushL( video ); // 1->
     
     // sanity checks
-    if ( video->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) != 0 )
+    if ( TVcxMyVideosCollectionUtil::DownloadIdL( *video ) != 0 )
         {
         MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: file is being downloaded, fail, leaving with KErrInUse code.");
         User::Leave( KErrInUse );
@@ -505,7 +504,7 @@
 
     iSourcePath = video->ValueText( KMPXMediaGeneralUri );
             
-    if ( !DriveHasEnoughFreeSpaceL( iSourcePath, aTargetDrive ) )
+    if ( !DriveHasEnoughFreeSpaceL( iSourcePath, iTargetDrive ) )
         {
         MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: target drive full -> skipping");
         User::Leave( KErrDiskFull );
@@ -522,14 +521,14 @@
     TInt sourceDrive;
     User::LeaveIfError( iCollection.iFs.CharToDrive( iSourcePath[0], sourceDrive ) );
 
-    if ( sourceDrive == aTargetDrive )
+    if ( sourceDrive == iTargetDrive )
         {
         MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: source and target drives are the same, leaving with KErrAlreadyExists.");
         CleanupStack::PopAndDestroy( video ); // <-1
         User::Leave( KErrAlreadyExists );
         }
     
-    GenerateTargetPathForMoveOrCopyL( iSourcePath, iTargetPath, aTargetDrive );
+    GenerateTargetPathForMoveOrCopyL( iSourcePath, iTargetPath, iTargetDrive );
 
     MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: target path = %S", &iTargetPath );
     
@@ -682,18 +681,24 @@
     if ( sourceDrive == systemDrive )
         {
         //remove *:\data\* from the path
-        TPtrC pathData( aSourcePath.Mid(3,4) );
+        const TInt dataWordStartPos = 3;
+        const TInt dataWordLength   = 4;
+        
+        TPtrC pathData( aSourcePath.Mid( dataWordStartPos, dataWordLength ) );
         MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: sourcePath.Mid(3,4)= %S", &pathData);
 
-        if ( aSourcePath.Mid(3,4) == KDataDes )
+        if ( pathData == KDataDes )
             {
             MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: source drive is system drive and 'data' exists in sourcePath");
             MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: not copying 'data' to the target path");
-            aTargetPath.Append( aSourcePath.Mid( 7 ) );
+            
+            const TInt skipDataWordPos = 7;
+            aTargetPath.Append( aSourcePath.Mid( skipDataWordPos ) );
             }
         else
             {
-            aTargetPath.Append( aSourcePath.Mid( 2 ) );
+            const TInt dontSkipDataWordPos = 2;
+            aTargetPath.Append( aSourcePath.Mid( dontSkipDataWordPos ) );
             }
         }    
     else if ( aTargetDrive == systemDrive )
@@ -718,7 +723,7 @@
 // CVcxMyVideosAsyncFileOperations::HandleDeleteStepL
 // ----------------------------------------------------------------------------
 //
-TBool CVcxMyVideosAsyncFileOperations::HandleDeleteStepL()
+MVcxMyVideosActiveTaskObserver::TStepResult CVcxMyVideosAsyncFileOperations::HandleDeleteStepL()
     {
     // Reset inactivity timer. This will prevent ThumbAGDaemon start running while
     // delete is ongoing and failing the operation due to locked file handle.
@@ -728,7 +733,7 @@
     
     //no sanity checks for array items, since we want to generate all events, even if there is nothing to delete
     
-    TBool done;
+    MVcxMyVideosActiveTaskObserver::TStepResult stepResult;
     
     TUint32 cmdId = cmd.ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId );    
         
@@ -774,16 +779,15 @@
     if ( iCurrentOperationIndex > (iOperationIdArray.Count() - 1) )
         {
         iCurrentOperationIndex = 0;
-        done                   = ETrue;
-
+        stepResult = MVcxMyVideosActiveTaskObserver::EDone;
         SendOperationRespL( KVcxMessageMyVideosDeleteResp );
         }
     else
         {
-        done = EFalse;
+        stepResult = MVcxMyVideosActiveTaskObserver::EMoreToCome;
         }
         
-    return done;
+    return stepResult;
     }
 
 
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideoscategories.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideoscategories.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -182,6 +182,8 @@
     CleanupClosePushL( newVideosIncrements ); // 2->
 
     TInt i;
+    videosIncrements.ReserveL( categoryCount );
+    newVideosIncrements.ReserveL( categoryCount );
     for ( i = 0; i < categoryCount; i++ )
         {
         videosIncrements.AppendL( 0 );
@@ -277,18 +279,20 @@
             {
             category = aCategoryArray.AtL( i );
 
-            UpdateVideosCountL( *category, aVideosIncrements[i], KVcxMediaMyVideosCategoryItemCount,
-                    EVcxMyVideosListNoInfo );
+            //codescanner warning: aVideosIncrements count is same as aCategoryArray count, so the range is checked
+            UpdateVideosCountL( *category, aVideosIncrements[i],
+                    KVcxMediaMyVideosCategoryItemCount, EVcxMyVideosListNoInfo );
 
             modified = ETrue;
             }
 
+        //codescanner warning: aNewVideosIncrements count is same as aCategoryArray count, so the range is checked
         if ( aNewVideosIncrements[i] != 0 )
             {
             category = aCategoryArray.AtL( i );
 
-            UpdateVideosCountL( *category, aNewVideosIncrements[i], KVcxMediaMyVideosCategoryNewItemCount,
-                    EVcxMyVideosListNoInfo );
+            UpdateVideosCountL( *category, aNewVideosIncrements[i],
+                    KVcxMediaMyVideosCategoryNewItemCount, EVcxMyVideosListNoInfo );
 
             modified = ETrue;
             }
@@ -444,16 +448,8 @@
         MPX_DEBUG1("CVcxMyVideosCategories:: video added");
         if ( TVcxMyVideosCollectionUtil::FlagsL( aVideo ) & EVcxMyVideosVideoNew )
             {
-            TInt64 newItemsDate( 0 );
-            if ( aVideo.IsSupported( KMPXMediaGeneralDate ) )
-                {
-                newItemsDate = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
-                }
-            TInt64 prevNewDate( 0 );
-            if ( aCategory.IsSupported( KMPXMediaGeneralDate ) )
-                {
-                prevNewDate = aCategory.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
-                }
+            TInt64 newItemsDate = TVcxMyVideosCollectionUtil::CreationDateL( aVideo );
+            TInt64 prevNewDate  = TVcxMyVideosCollectionUtil::CreationDateL( aCategory );
 
             if ( static_cast<TInt64>(newItemsDate) > static_cast<TInt64>(prevNewDate) )
                 {                    
@@ -550,11 +546,14 @@
         {
         case -1:
             return KVcxMyVideosAllVideosCategoryIndex;
-            
+                        
         case EVcxMyVideosOriginCapturedWithCamera:
             return KVcxMyVideosCapturedCategoryIndex;
                             
         case EVcxMyVideosOriginDownloaded:
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            return KVcxMyVideosDownloadsCategoryIndex;
+#endif
         case EVcxMyVideosOriginTvRecording:
         case EVcxMyVideosOriginSideLoaded:                
         case EVcxMyVideosOriginOther:
@@ -680,7 +679,8 @@
     prevNewVideoName.Set( iListArray->AtL( categoryIndex )->ValueText(
             KVcxMediaMyVideosCategoryNewItemName ) );
     CMPXMedia* newVideo;
-    currentNewVideoName.Set( CalculateNewVideoNameL( *videoList, aOrigin, aIgnoredIds, newVideo ) );
+    currentNewVideoName.Set( CalculateNewVideoNameL(
+            *videoList, aOrigin, aIgnoredIds, newVideo ) );
     if ( currentNewVideoName.CompareF( prevNewVideoName ) != 0 )
         {
         iListArray->AtL( categoryIndex )->SetTextValueL(
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionplugin.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -11,12 +11,11 @@
 *
 * Contributors:
 *
-* Description:    Implementation of My Videos collection Plugin interface*
+* Description:   Implementation of My Videos collection Plugin interface*
 */
 
 
 
-
 // INCLUDE FILES
 #include <e32cmn.h>
 #include <s32mem.h>
@@ -35,15 +34,14 @@
 #include "vcxmyvideoscollectionplugin.h"
 #include "vcxmyvideoscollection.hrh"
 #include "vcxmyvideoscollectionutil.h"
-#include "vcxmyvideosdownloadutil.h"
 #include "vcxmyvideosvideocache.h"
 #include "vcxmyvideoscategories.h"
 #include "vcxmyvideosmessagelist.h"
 #include "vcxmyvideosasyncfileoperations.h"
 #include "vcxmyvideosopenhandler.h"
+#include "vcxmyvideosmdsalbums.h"
+#include "vcxmyvideosalbums.h"
 
-const TInt KMaxFileDeleteAttempts = 4;
-const TInt KFileDeleteLoopDelay = 100000;
 
 // ============================ MEMBER FUNCTIONS ==============================
 
@@ -73,13 +71,13 @@
     MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: this = %x", this);
         
     delete iMyVideosMdsDb;
-    delete iDownloadUtil;
     delete iCache;
     delete iMessageList;
     delete iCategories;
     delete iAsyncFileOperations;
     delete iActiveTask;
     delete iOpenHandler;
+    delete iAlbums;
     iFs.Close();
     }
 
@@ -102,8 +100,11 @@
     MPX_FUNC("CVcxMyVideosCollectionPlugin::ConstructL");
     
     User::LeaveIfError( iFs.Connect() );
-        
+#ifdef VIDEO_COLLECTION_PLUGIN_TB92        
     iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs );    
+#else
+    iMyVideosMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs, &AlbumsL() );
+#endif
     iActiveTask    = CVcxMyVideosActiveTask::NewL( *this );
     iCache         = CVcxMyVideosVideoCache::NewL( *this );
     iMessageList   = CVcxMyVideosMessageList::NewL( *this );
@@ -132,7 +133,7 @@
     const TArray<TCapability>& /*aCaps*/,
     CMPXAttributeSpecs* /*aSpecs*/)
     {
-    MPX_FUNC("CMPXMyVideosDbPlugin::MediaL");
+    MPX_FUNC("CVcxMyVideosCollectionPlugin::MediaL");
     MPX_DEBUG_PATH(aPath);
     
     RArray<TInt> supportedIds;
@@ -165,7 +166,7 @@
 
     if ( ids.Count() == 0 )
         {
-        MPX_DEBUG1("CMPXMyVideosDbPlugin:: request didn't contain any items ids, aborting");
+        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: request didn't contain any items ids, aborting");
         
         iObs->HandleMedia( NULL, KErrArgument );
         CleanupStack::PopAndDestroy( &ids );          // <-2
@@ -181,27 +182,27 @@
     if ( videoInCache )
         {
         // 0 attributes means "get all" -> can't use cache
-        MPX_DEBUG2("CMPXMyVideosDbPlugin:: client is requesting %d attributes", aAttrs.Count());
+        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: client is requesting %d attributes", aAttrs.Count());
         if ( aAttrs.Count() > 0 )
             {
             TBool nonSupportedAttrCanBeFoundFromMds;
             if ( TVcxMyVideosCollectionUtil::AreSupported( *videoInCache, aAttrs,
                     nonSupportedAttrCanBeFoundFromMds ) )
                 {
-                MPX_DEBUG1("CMPXMyVideosDbPlugin:: all attributes found from cache");
+                MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: all attributes found from cache");
                 useCachedVideo = ETrue;
                 }
             else
                 {
-                MPX_DEBUG1("CMPXMyVideosDbPlugin:: all attributes NOT found from cache");
+                MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: all attributes NOT found from cache");
                 if ( !nonSupportedAttrCanBeFoundFromMds )
                     {
-                    MPX_DEBUG1("CMPXMyVideosDbPlugin:: none of the non cached attrs can be found from MDS -> use cached version");
+                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: none of the non cached attrs can be found from MDS -> use cached version");
                     useCachedVideo = ETrue;
                     }
                 else
                     {
-                    MPX_DEBUG1("CMPXMyVideosDbPlugin:: at least one of the non cached attributes can be found from MDS");
+                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: at least one of the non cached attributes can be found from MDS");
                     }
                 }
             }
@@ -211,16 +212,23 @@
 
     if ( useCachedVideo )
         {
-        MPX_DEBUG1("CMPXMyVideosDbPlugin:: using cached video");
+        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: using cached video");
         video = CMPXMedia::CopyL( *videoInCache );
         }
     else
         {
-        MPX_DEBUG1("CMPXMyVideosDbPlugin:: fetching from MDS");
+        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: fetching from MDS");
         video = iMyVideosMdsDb->CreateVideoL( ids[0].iId1, ETrue /* full details */ );    
         }
-        
-    iObs->HandleMedia( video, KErrNone );
+    
+    if ( video )
+        {
+        iObs->HandleMedia( video, KErrNone );
+        }
+    else
+        {
+        iObs->HandleMedia( NULL, KErrNotFound );    
+        }
     
     CleanupStack::PopAndDestroy( &ids );          // <-2
     CleanupStack::PopAndDestroy( &supportedIds ); // <-1
@@ -246,7 +254,7 @@
 void CVcxMyVideosCollectionPlugin::CommandL(
     CMPXCommand& aCmd)
     {
-    MPX_FUNC("CVcxMyVideosCollectionPlugin::CommandL 2");
+    MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() start");
 
     if ( !aCmd.IsSupported( KMPXCommandGeneralId ) )
         {
@@ -292,7 +300,20 @@
                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KMPXCommandIdCollectionSet arrived");
                 
                 CMPXMedia* video = aCmd.Value<CMPXMedia>( KMPXCommandColSetMedia );
-                SetVideoL( *video );
+                
+                TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( *video );
+                if ( mpxId.iId2 == KVcxMvcMediaTypeVideo )
+                    {
+                    SetVideoL( *video );
+                    }
+                else if ( mpxId.iId2 == KVcxMvcMediaTypeAlbum )
+                    {
+                    iMyVideosMdsDb->iAlbums->SetAlbumL( *video );
+                    }
+                else
+                    {
+                    User::Leave( KErrNotFound );
+                    }
                 }
                 break;
             
@@ -313,6 +334,13 @@
                         iActiveTask->Cancel();
                         }
                         break;
+                    
+                    case KVcxCommandMyVideosAddAlbum:
+                        {
+                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: sync KVcxCommandMyVideosAddAlbum arrived");
+                        AlbumsL().AddAlbumL( aCmd );
+                        }
+                        break;
                     }
                 }
                 break;
@@ -324,7 +352,7 @@
                 }
             }
         }
-            
+    MPX_DEBUG1("CVcxMyVideosCollectionPlugin::CommandL() exit");            
     }
 
 // ----------------------------------------------------------------------------
@@ -366,33 +394,6 @@
 //
 void CVcxMyVideosCollectionPlugin::SendMessages( CMPXMessage& aMessages )
     {
-#if _DEBUG
-    TRAP_IGNORE(
-
-    if ( aMessages.IsSupported( KMPXMessageArrayContents ) )
-        {
-        const CMPXMessageArray* messageArray =
-            aMessages.Value<CMPXMessageArray>(KMPXMessageArrayContents);
-            
-        for( TInt i = 0; i < messageArray->Count(); i++ )
-            {            
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: sending message ID: %d in array", ++iTotalMessagesSent);
-            messageArray->AtL( i )->SetTObjectValueL<TUint32>( KVcxMediaMyVideosMessageId, iTotalMessagesSent );
-            iMessagesInArraySent++;
-            }    
-
-        MPX_DEBUG3("CVcxMyVideosCollectionPlugin:: total messages sent (MSG ID): %d, messages in array sent: %d",
-            iTotalMessagesSent, iMessagesInArraySent);
-        }
-    else
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: NO ARRAY IN MESSAGE!!!");
-        return;
-        }
-
-    );
-#endif
-
     iObs->HandleMessage( aMessages );
     }
 
@@ -404,7 +405,6 @@
         TMPXChangeEventType aEvent,
         RArray<TUint32>& aId )
     {
-    //MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent");
     TRAPD( err, DoHandleMyVideosDbEventL( aEvent, aId ));
     if ( err != KErrNone )
         {
@@ -422,6 +422,10 @@
     {
     MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL");
     
+    RArray<TUint32> nonVideoIds;
+    nonVideoIds.Reset();
+    CleanupClosePushL( nonVideoIds );
+    
     switch ( aEvent )
         {
         case EMPXItemDeleted:
@@ -430,7 +434,10 @@
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items from MDS deleted, deleting from cache |" );
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------------'");
                         
-            iCache->RemoveL( aId );            
+            iCache->RemoveL( aId );
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            AlbumsL().RemoveAlbumsL( aId );
+#endif
             }
             break;
         
@@ -443,22 +450,33 @@
             if ( iMyVideosMdsDb->iVideoListFetchingIsOngoing )
                 {
                 MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: video list fetching is ongoing, ignoring add event");
+                CleanupStack::PopAndDestroy( &nonVideoIds );
                 return;
                 }
                 
             TBool videoListFetchingWasCancelled = EFalse;
-            
+
             // After the call, aId will contain only items which were actually inserted to cache.
             // We receive add events for all object types. When fetching the item from MDS we use
-            // video condition and only video objects are added to cache.
-            iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled );
+            // video condition and only video objects are added to cache. Items which were detected
+            // to not be videos are added to nonVideoIds.
+            iCache->AddVideosFromMdsL( aId, videoListFetchingWasCancelled, &nonVideoIds );
+
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+#if 0 //TODO: do this if we want to support albums which are being added by someone else than My Videos Collection
+            
+            //After the call nonVideoIds will contain only items which were actually added
+            //to albums.
+            AlbumsL().AddAlbumsFromMdsL( nonVideoIds );
+#endif
+#endif
+            
             if ( videoListFetchingWasCancelled )
                 {
                 RestartVideoListFetchingL();
                 }
-             
-            SyncWithDownloadsL( aId );
             }
+            
             break;
         
         case EMPXItemModified:
@@ -467,7 +485,11 @@
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() Items modified in MDS, updating cache |");
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin::DoHandleMyVideosDbEventL() --------------------------------------'");
             CMPXMedia* video;
-            for ( TInt i = 0; i < aId.Count(); i++ )
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            CMPXMedia* album;
+#endif
+            TInt count = aId.Count();
+            for ( TInt i = count - 1; i >= 0; i-- )
                 {
                 video = iMyVideosMdsDb->CreateVideoL( aId[i], ETrue /* full details */ );
                 
@@ -479,41 +501,75 @@
                     }
                 else
                     {
+#ifdef VIDEO_COLLECTION_PLUGIN_TB92
                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS");
+                    aId.Remove( i );
+#else
+                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: item was not found from videos, checking albums");
+                    album = iMyVideosMdsDb->iAlbums->GetAlbumL( aId[i] );
+                    
+                    if ( album )
+                        {
+                        CleanupStack::PushL( album ); // 1->
+                        iAlbums->UpdateAlbumL( *album ); // this will add event to iMessageList if necessarry
+                        CleanupStack::PopAndDestroy( album ); // <-1
+                        }
+                    else
+                        {
+                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: couldn't find the modified item from MDS");
+                        }
+                    aId.Remove( i );
+#endif
                     }
                 }
+            
             }
-            SyncWithDownloadsL( aId );
             break;
         }
-        
-    TInt pos;
-    for ( TInt i = 0; i < aId.Count(); i++ )
-        {
-        if ( aEvent == EMPXItemInserted )
+
+        TInt pos;
+        TInt count = aId.Count();
+        for ( TInt i = 0; i < count; i++ )
             {
-            // add item from cache to the message if we have it.
-            CMPXMedia* video = iCache->FindVideoByMdsIdL( aId[i], pos );
-            TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], 0), aEvent, 0, video ) );
+            if ( aEvent == EMPXItemInserted )
+                {
+                // add item from cache to the message if we have it.
+                CMPXMedia* video = iCache->FindVideoByMdsIdL( aId[i], pos );
+                TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo),
+                        aEvent, 0, video ) );
+                }
+            else
+                {
+                TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], KVcxMvcMediaTypeVideo),
+                        aEvent ) );
+                }
             }
-        else
-            {
-            TRAP_IGNORE( iMessageList->AddEventL( TMPXItemId( aId[i], 0), aEvent ) );
-            }
+
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+    //nonVideoIds are albums
+    count = nonVideoIds.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        TRAP_IGNORE( iMessageList->AddEventL(
+                TMPXItemId( nonVideoIds[i], KVcxMvcMediaTypeAlbum ), aEvent ) );
         }
-    
-    iMessageList->SendL();
+
+    iAlbums->UpdateChangedAlbumsL();
+#endif
+
+    CleanupStack::PopAndDestroy( &nonVideoIds );
+	iMessageList->SendL();
     }
     
 // ----------------------------------------------------------------------------
 // CVcxMyVideosCollectionPlugin::HandleStepL
 // ----------------------------------------------------------------------------
 //
-TBool CVcxMyVideosCollectionPlugin::HandleStepL()
+MVcxMyVideosActiveTaskObserver::TStepResult CVcxMyVideosCollectionPlugin::HandleStepL()
     {
     MPX_FUNC("CVcxMyVideosCollectionPlugin::HandleStepL");
 
-    TBool done(ETrue);
+    MVcxMyVideosActiveTaskObserver::TStepResult stepResult(MVcxMyVideosActiveTaskObserver::EDone);
 
     switch ( iActiveTask->GetTask() )
         {
@@ -532,8 +588,7 @@
             
             MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KMPXCommandIdCollectionSet out");
             
-            done = ETrue;
-            
+            stepResult = MVcxMyVideosActiveTaskObserver::EDone;            
             break;
             }
         case KVcxCommandIdMyVideos:
@@ -548,183 +603,7 @@
             TInt myVideosCmd( cmd.ValueTObjectL<TUint>( KVcxMediaMyVideosCommandId ) );
 
             switch ( myVideosCmd )
-                {
-                case KVcxCommandMyVideosStartDownload:
-                    {
-                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Handling KVcxCommandMyVideosStartDownload command.");
-                    
-                    CMPXMedia* video = CMPXMedia::NewL( *(iActiveTask->GetCommand().Value<CMPXMedia>(
-                            KMPXCommandColAddMedia)) );
-                    CleanupStack::PushL( video ); // 1->
-
-                    if ( !iCache->iVideoList )
-                        {
-                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iVideoListCache");
-                        iCache->iVideoListIsPartial = ETrue;
-                        iCache->iVideoList          = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
-                        }
-
-                    TBool resume = EFalse;
-                    
-                    if ( video->IsSupported( KVcxMediaMyVideosDownloadId ) )
-                        {
-                        TUint32 downloadId = video->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
-                        if ( downloadId != 0 )
-                            {
-                            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: download id %d given by the client -> this is download resume",
-                                    downloadId);
-                            resume = ETrue;
-                            
-                            // load the existing item to cache if its not there already
-                            }
-                        }
-                    
-                    if ( !resume )
-                        {    
-                        if ( !video->IsSupported( KVcxMediaMyVideosRemoteUrl ) )
-                            {
-                            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxMediaMyVideosRemoteUrl not supported -> leaving with KErrArgument");
-                            User::Leave( KErrArgument );
-                            }
-
-                        if ( video->ValueText( KVcxMediaMyVideosRemoteUrl ).Length() >
-                                KVcxMvcMaxUrlLength )
-                            {
-                            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: url longer than 1024 -> leaving with KErrArgument");
-                            User::Leave( KErrArgument );
-                            }
-                        
-                        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: starting download for url: %S", 
-                            &video->ValueText( KVcxMediaMyVideosRemoteUrl ) );
-
-                        video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, EVcxMyVideosOriginDownloaded );    
-                        video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState,
-                                static_cast<TUint8>(EVcxMyVideosDlStateDownloading) );
-                        video->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, EVcxMyVideosVideoNew );
-                            
-                        HBufC* fileName = DownloadUtilL().CreateFilePathL( *video );
-                        CleanupStack::PushL( fileName ); // 2->
-                        video->SetTextValueL( KMPXMediaGeneralUri, *fileName );
-                        CleanupStack::PopAndDestroy( fileName ); // <-2
-                        }
-
-                    TRAPD( err, DownloadUtilL().StartDownloadL( *video ) ); //download id is written to video object
-                    
-                    if ( err != KErrNone )
-                        {
-                        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: StartDownloadL left: %d", err);
-                        User::Leave( err );
-                        }
-                    
-                    if ( !resume )
-                        {    
-                        TUint32 newDownloadId = video->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); 
-                        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: new download ID: %d",
-                            newDownloadId);
-
-                        AddVideoToMdsAndCacheL( *video );
-                        }
-                    else
-                        {
-                        // clear old error codes from the dl item
-                        TInt pos;
-                        
-                        CMPXMedia* videoInCache = iCache->FindVideoByMdsIdL(
-                                TVcxMyVideosCollectionUtil::IdL( *video ), pos );
-                        if ( videoInCache )
-                            {
-                            videoInCache->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, 0 );
-                            videoInCache->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, 0 );
-                            }
-                        }
-                        
-                    CleanupStack::PopAndDestroy( video ); // <-1
-                    done = ETrue;
-                    }
-                    break;
-                    
-                case KVcxCommandMyVideosCancelDownload:
-                    {
-                    // Error code is returned to client if dl item was left to system.
-                    // If file delete fails, then mds item is also left to system.
-                    
-                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Handling KVcxCommandMyVideosCancelDownload command.");
-                    
-                    CMPXMedia* video = CMPXMedia::NewL( *(iActiveTask->GetCommand().Value<CMPXMedia>(
-                            KMPXCommandColAddMedia)) );
-                    CleanupStack::PushL( video ); // 1->
-
-                    if ( !video->IsSupported( KVcxMediaMyVideosDownloadId ) ||
-                            !video->IsSupported( KMPXMediaGeneralId ) ||
-                            !video->IsSupported( KMPXMediaGeneralUri ) )
-                        {
-                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: parameter missing, can't cancel dl, leaving with KErrArgument");
-                        User::Leave( KErrArgument );
-                        }
-
-                    TUint32 downloadId = video->ValueTObjectL<TUint32>(
-                            KVcxMediaMyVideosDownloadId );
-                    DownloadUtilL().CancelDownload( downloadId, ETrue /* remove file */ );
- 
-                    if ( BaflUtils::FileExists( iFs, video->ValueText( KMPXMediaGeneralUri ) ) )
-                        {
-                        TMPXItemId mpxItemId = video->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
-                        TInt err( KErrNone );
-                        
-                        for ( TInt i = 0; i < KMaxFileDeleteAttempts; i++ )
-                            {
-                            TRAP( err, AsyncFileOperationsL().DeleteVideoL( mpxItemId.iId1, ETrue ) );
-                                        
-                            if ( err == KErrInUse )
-                                {
-                                MPX_DEBUG1( "CVcxMyVideosCollectionPlugin:: file is already in use, waiting a moment and try again");
-                                User::After( KFileDeleteLoopDelay );
-                                }
-                            else
-                                {
-                                break;
-                                }
-                            }
-                        
-                        if ( err != KErrNone && err != KErrNotFound )
-                            {
-#ifdef _DEBUG                        
-                            if ( err == KErrInUse )
-                                {
-                                TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL(
-                                        video->ValueText( KMPXMediaGeneralUri ), iFs );
-                                }
-#endif
-							
-                            // Some error occured when cancelling download operation, dl item is however gone and file is left
-                            // -> change dl id to 0 and leave mpx collection item there. Report operation to client as a success.
-                            MPX_DEBUG1( "CVcxMyVideosCollectionPlugin:: dl item is gone from dl manager, file and mpx item are left, setting dl id to 0");
-                            TRAP_IGNORE( SetDownloadIdToZeroL( downloadId ) );
-                            }
-                        }
-                    
-                    CleanupStack::PopAndDestroy( video ); // <-1
-                    done = ETrue;
-                    }
-                    break;
-                                        
-                case KVcxCommandMyVideosPauseDownload:
-                    {
-                    CMPXMedia& cmd = iActiveTask->GetCommand();
-                    if ( !cmd.IsSupported( KVcxMediaMyVideosDownloadId ) )
-                        {
-                        User::Leave( KErrArgument );
-                        }
-                    else
-                        {
-                        TInt err = DownloadUtilL().PauseDownload(
-                                cmd.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) );
-                        User::LeaveIfError( err );
-                        }
-                    done = ETrue;
-                    }
-                    break;
-                
+                {                
                 case KVcxCommandMyVideosGetMediaFullDetailsByMpxId:
                     {
                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosGetMediaFullDetailsByMpxId received");
@@ -738,25 +617,21 @@
 
                     CMPXMedia* video = iMyVideosMdsDb->CreateVideoL(
                             mpxId.iId1, ETrue /* full details */ );
-
+                    
                     if ( !video )
                         {
-                        User::Leave( KErrGeneral );
+                        User::Leave( KErrNotFound );
                         }
                     
                     CleanupStack::PushL( video ); // 1->
-                    
-                    TBool eventsAdded;
-                    SyncVideoWithDownloadsL( *video, eventsAdded,
-                            EFalse /* dont add event to iMessageList */ );
-                    
+                                        
                     cmd.SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, video );
                     CleanupStack::PopAndDestroy( video ); // <-1
 
                     cmd.SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(
                             KVcxUidMyVideosMpxCollection));
                     
-                    done = ETrue;
+                    stepResult = MVcxMyVideosActiveTaskObserver::EDone;            
                     }
                     break;
                     
@@ -802,22 +677,18 @@
                     if ( !iCache->iVideoList )
                         {
                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: iVideoListCache = NULL -> creating new empty iCache->iVideoList");
-                        iCache->iVideoListIsPartial = ETrue;
+                        iCache->SetComplete( EFalse );
                         iCache->iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
                         }
 
                     TBool videoListFetchingWasCancelled = EFalse;
                         
-                    if ( iCache->iVideoListIsPartial )
+                    if ( !iCache->IsComplete() )
                         {                            
                         // Load items to cache
                         MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: loading requested items to iCache->iVideoList");
-
+                        
                         iCache->AddVideosFromMdsL( mdsIds, videoListFetchingWasCancelled );
-                        if ( mdsIds.Count() > 0 )
-                            {
-                            SyncWithDownloadsL( mdsIds );
-                            }
                         }
                     else
                         {
@@ -850,7 +721,7 @@
                     CleanupStack::PopAndDestroy( &mdsIds2 ); //  <-2
                     CleanupStack::PopAndDestroy( &mdsIds );  //  <-1
                         
-                    done = ETrue;
+                    stepResult = MVcxMyVideosActiveTaskObserver::EDone;            
                     }
                     break;
                 
@@ -858,16 +729,44 @@
                 case KVcxCommandMyVideosMove:
                     {
                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosMove or Copy step");
-                    done = AsyncFileOperationsL().HandleMoveOrCopyStepL();
+                    stepResult = AsyncFileOperationsL().HandleMoveOrCopyStepL();
                     }
                     break;
                     
                 case KVcxCommandMyVideosDelete:
                     {
                     MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: KVcxCommandMyVideosDelete step");
-                    done = AsyncFileOperationsL().HandleDeleteStepL();
+                    stepResult = AsyncFileOperationsL().HandleDeleteStepL();
                     }
                     break;
+                    
+                case KVcxCommandMyVideosAddToAlbum:
+                    iAlbums->AddVideosToAlbumL( &iActiveTask->GetCommand() );
+                    stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping;
+                    break;
+
+                case KVcxCommandMyVideosRemoveFromAlbum:
+                    iAlbums->RemoveVideosFromAlbumL( &iActiveTask->GetCommand() );
+                    stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping;
+                    break;
+                    
+                case KVcxCommandMyVideosAddAlbum:
+                    {
+                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KVcxCommandMyVideosAddAlbum arrived");
+                    AlbumsL().AddAlbumL( iActiveTask->GetCommand() );
+                    stepResult = MVcxMyVideosActiveTaskObserver::EDone;
+                    break;
+                    }
+
+                case KVcxCommandMyVideosRemoveAlbums:
+                    {
+                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: async KVcxCommandMyVideosRemoveAlbums arrived");
+                    AlbumsL().RemoveAlbumsFromMdsOnlyL( iActiveTask->Command() );
+                    stepResult = MVcxMyVideosActiveTaskObserver::EStopStepping;
+                    break;
+                    }
+
+                    
                 }
             }
             break;
@@ -878,7 +777,7 @@
             TMPXItemId mpxId = iActiveTask->GetCommand().ValueTObjectL<TMPXItemId>(
                     KMPXMediaGeneralId );
             AsyncFileOperationsL().DeleteVideoL( mpxId.iId1 );
-            done = ETrue;
+            stepResult = MVcxMyVideosActiveTaskObserver::EDone;            
             break;
             }
             
@@ -889,7 +788,7 @@
             break;
             }
         }
-    return done;
+    return stepResult;
     }
 
 
@@ -905,10 +804,14 @@
     if ( aErr != KErrNone )
         {
         MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: Leave or cancel happened during the operation: %d", aErr);
-        TRAPD( err, AsyncFileOperationsL().CancelOperationL( aErr ) ); // generates resp message for move,copy or delete operations
-        if ( err != KErrNone )
+        
+        if ( iAsyncFileOperations )
             {
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: failed to generate resp msg: %d", err);
+            TRAPD( err, AsyncFileOperationsL().CancelOperationL( aErr ) ); // generates resp message for move,copy or delete operations
+            if ( err != KErrNone )
+                {
+                MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: failed to generate resp msg: %d", err);
+                }
             }
         }
 
@@ -921,435 +824,6 @@
     }
 
 // ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::HandleDlEvent
-// From CVcxMyVideosDownloadUtilObserver
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::HandleDlEvent( TVcxMyVideosDownloadState aState,
-                TUint32 aDownloadId,
-                TInt aProgress,
-                TInt64 aDownloaded,
-                TInt32 aError,
-                TInt32 aGlobalError )
-    {
-    TRAPD( err, DoHandleDlEventL( aState, aDownloadId, aProgress,
-            aDownloaded, aError, aGlobalError ) );
-    if ( err != KErrNone )
-        {
-        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: DoHandleDlEventL left with error code: %d", err);
-        }
-    }
-    
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::DoHandleDlEventL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::DoHandleDlEventL( TVcxMyVideosDownloadState aState,
-                TUint32 aDownloadId,
-                TInt aProgress,
-                TInt64 aDownloaded,
-                TInt32 aError,
-                TInt32 aGlobalError )
-    {
-    MPX_FUNC("CVcxMyVideosCollectionPlugin::DoHandleDlEventL");
-    
-    CMPXMedia* video = iCache->FindVideoByDownloadIdL( aDownloadId );
-
-    MPX_DEBUG3("CVcxMyVideosCollectionPlugin:: dl event for download ID %d, pointer = %x) arrived.", aDownloadId, video);
-    
-    TBool sendEvent = EFalse;
-    if ( video )
-        {
-        TMPXItemId mpxId( TVcxMyVideosCollectionUtil::IdL( *video ) );
-        MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: MPX item (MDS ID %d) (DL ID %d) %S",
-                mpxId.iId1, aDownloadId, &TVcxMyVideosCollectionUtil::Title( *video ) );
-                
-        TUint8 currentState = TVcxMyVideosCollectionUtil::DownloadStateL( *video );
-        
-        if ( currentState == EVcxMyVideosDlStateDownloaded )
-            {
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: already in Downloaded state, discarding event");
-            return;
-            }
-            
-        if ( currentState != aState )
-            {
-            MPX_DEBUG5("CVcxMyVideosCollectionPlugin:: updating (mds id: %d) (dl id: %d) state: %S -> %S",
-                        mpxId.iId1, aDownloadId, &DownloadState( currentState ), &DownloadState( aState ) );
-            video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState, static_cast<TUint8>(aState) );
-            sendEvent = ETrue;
-
-            if ( aState == EVcxMyVideosDlStateDownloaded )
-                {
-                MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: downloaded state received -> setting download id to 0");
-                
-                //1. set download id to 0
-                video->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-                
-                //2. update drm flag
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-                RFile64 dlFile;
-#else
-                RFile dlFile;
-#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-                TInt err = dlFile.Open( iFs, video->ValueText( KMPXMediaGeneralUri ), EFileRead );
-                if ( err == KErrNone )
-                    {
-                    MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file opened ok for drm reading");
-                    CleanupClosePushL( dlFile ); // 1->
-                    DRM::CDrmUtility* drmUtil = DRM::CDrmUtility::NewLC(); // 2->
-                    if ( drmUtil->IsProtectedL( dlFile ) )
-                        {
-                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file is DRM protected, setting the property flag");
-                        TUint32 flags = video->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
-                        flags |= EVcxMyVideosVideoDrmProtected;
-                        video->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags );
-                        }
-                    else
-                        {
-                        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: file is not DRM protected");
-                        }
-                    CleanupStack::PopAndDestroy( drmUtil ); // <-2
-                    CleanupStack::PopAndDestroy( &dlFile ); // <-1
-                    }
-                else
-                    {
-                    MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: file didnt open for drm reading, %d", err);
-                    }
-                NotifyDownloadCompletedL( *video );
-                    
-                //3. Update file size using iCache->UpdateVideoL function since it changes item position and
-                //   sends category modified events if necessarry.
-                CMPXMedia* updateObject = CMPXMedia::NewL();
-                CleanupStack::PushL( updateObject ); // 1->
-                updateObject->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-                updateObject->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64,
-                        static_cast<TInt64>( aDownloaded ) );
-                // set current value to 0 to force event sending and video list position updating    
-                video->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, 0 );                
-#else
-                updateObject->SetTObjectValueL<TInt>( KMPXMediaGeneralSize,
-                        static_cast<TInt>( aDownloaded ) );
-                // set current value to 0 to force event sending and video list position updating    
-                video->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 0 );                
-#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-                iCache->UpdateVideoL( *updateObject );
-                CleanupStack::PopAndDestroy( updateObject ); // <-1                
-                // find video again since it might have been deleted in iCache->UpdateVideoL
-                TInt pos;
-                video = iCache->FindVideoByMdsIdL( mpxId.iId1, pos );
-
-                //file size and download id are saved to database
-                iMyVideosMdsDb->UpdateVideoL( *video );
-                sendEvent = EFalse; // MDS will send the event, this avoids duplicate
-                }
-                
-            if ( aState == EVcxMyVideosDlStateFailed )
-                {
-                video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosDownloadError, aError );
-                video->SetTObjectValueL<TInt32>( KVcxMediaMyVideosDownloadGlobalError,
-                        aGlobalError );
-                }            
-            }
-        else
-            {
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: state was already same(%S), skipping state update.", &DownloadState( currentState ));
-            }
- 
-        TInt8 currentProgress = video->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
-        if ( currentProgress != aProgress )
-            {
-            MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: (dl id: %d) progress: %d -> %d",
-                        aDownloadId, currentProgress, aProgress );
-
-            video->SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress,
-                    static_cast<TInt8>( aProgress ) );
-            // Don't send the update event for progress.
-            //sendEvent = ETrue;
-            }
-        else
-            {
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: progress was already same(%d), skipping progress update.", currentProgress);
-            }
-            
-        TInt64 currentFileSize = 0;
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-        if ( video->IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
-            {
-            currentFileSize = video->ValueTObjectL<TInt64>( KMPXMediaGeneralExtSizeInt64 );
-            }
-#else
-        if ( video->IsSupported( KMPXMediaGeneralSize ) )
-            {
-            currentFileSize = video->ValueTObjectL<TInt>( KMPXMediaGeneralSize );
-            }
-#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-        if ( currentFileSize != aDownloaded )
-            {
-            MPX_DEBUG4("CVcxMyVideosCollectionPlugin:: updating (dl id: %d) size: %ld -> %ld",
-                        aDownloadId, currentFileSize, aDownloaded );
-                        
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-            video->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, aDownloaded );
-#else
-            TInt newFileSize( aDownloaded );
-            video->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, newFileSize );
-#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-            //sendEvent = ETrue;
-            }
-        
-        if ( sendEvent )
-            {
-            iMessageList->AddEventL( mpxId, EMPXItemModified );
-            iMessageList->SendL();
-            }
-        }
-    else
-        {
-        if ( (aState != EVcxMyVideosDlStateDownloaded) && (aProgress < 100) &&
-                !iCache->iVideoListIsPartial )
-            {
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -----------------------------------------------------------------------.");
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Event for progressing download arrived, but the MPX/MDS item not found!|");
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> deleting download.                                                  |");
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -----------------------------------------------------------------------'");
-            
-            RHttpDownload* download = DownloadUtilL().Download( aDownloadId );
-            if ( download )
-                {
-                MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: Download ID (%d) not found from MPX/MDS, deleting download!",
-                        aDownloadId );                
-                DownloadUtilL().DeleteDownloadAsync( aDownloadId, ETrue );
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::SyncWithDownloadsL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::SyncWithDownloadsL(
-        RArray<TUint32>& aItemsInCache )
-    {
-    MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncWithDownloadsL()");
-    
-    TBool eventsAdded = EFalse;
-    for ( TInt i = 0; i < aItemsInCache.Count(); i++ )
-        {
-        TInt pos;
-        CMPXMedia* video = iCache->FindVideoByMdsIdL( aItemsInCache[i], pos );
-        if ( video )
-            {
-            SyncVideoWithDownloadsL( *video, eventsAdded );
-            }
-        }
-    if ( eventsAdded )
-        {
-        iMessageList->SendL();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL( CMPXMedia& aVideo,
-        TBool& aEventAdded, TBool aAddEvent )
-    {    
-    TInt downloadId( TVcxMyVideosCollectionUtil::DownloadIdL( aVideo ) );
-    
-    if ( downloadId )
-        {
-        RHttpDownload* download( DownloadUtilL().Download( downloadId ) );
-
-        if ( download )
-            {
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin::SyncVideoWithDownloadsL() item (DL ID: %d) found from dl manager", downloadId);
-    
-            TBool modified = EFalse;
-            SyncVideoAndDownloadL( aVideo, *download, modified );
-            if ( modified && aAddEvent )
-                {
-                iMessageList->AddEventL( TVcxMyVideosCollectionUtil::IdL( aVideo ),
-                        EMPXItemModified );
-                aEventAdded = ETrue;
-                }
-            }
-        else
-            {
-            //download id != 0 and it is not found from download manager -> we set download id to 0
-            MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: download id %d != 0 and no corresponding download found from Download Manager",
-                    downloadId);
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> setting download id to 0");
-            aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-            iMyVideosMdsDb->UpdateVideoL( aVideo ); // if video list fetching is ongoing, this will leave with KErrNotReady
-            }
-        }
-    }
- 
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL
-// ----------------------------------------------------------------------------
-//
-void  CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL(
-        CMPXMedia& aVideo,
-        RHttpDownload& aDownload,
-        TBool& aModified )
-    {
-    MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncVideoAndDownloadL()");
-        
-    aModified = EFalse;
-         
-    TBuf<KMaxUrlLength> downloadUrl;
-    aDownload.GetStringAttribute( EDlAttrReqUrl, downloadUrl );
-    if ( aVideo.ValueText( KVcxMediaMyVideosRemoteUrl ) 
-            != downloadUrl )
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: urls in MPX and DL Manager differ!");
-        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: remote url in MPX: %S",
-                &(aVideo.ValueText( KVcxMediaMyVideosRemoteUrl )));
-        MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: remote url in DL Manager: %S",
-                &downloadUrl);
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> updating MPX cache");
-        
-        aVideo.SetTextValueL( KVcxMediaMyVideosRemoteUrl, downloadUrl );
-        aModified = ETrue;
-        }
-    else
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: remote urls already same in dl manager and mpx");
-        }
-
-    // KVcxMediaMyVideosDownloadState
-    TVcxMyVideosDownloadState dlStateInDlManager;
-    DownloadUtilL().GetDownloadState( aDownload, dlStateInDlManager );
-    
-    TUint8 dlStateInMpxCache; 
-    if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadState ))
-        {
-        dlStateInMpxCache = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
-        }
-    else
-        {
-        dlStateInMpxCache = static_cast<TUint8>( EVcxMyVideosDlStateNone );
-        }
-
-    MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl state in dl manager: %S", &DownloadState( dlStateInDlManager ));
-    MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl state in mpx cache: %S", &DownloadState( dlStateInMpxCache ));
-    
-    if ( static_cast<TUint8>( dlStateInDlManager ) != dlStateInMpxCache )
-        {        
-        if ( dlStateInDlManager == EVcxMyVideosDlStateDownloaded )
-            {
-            // Download finished event has arrived when we weren't around, call event handler to get things right.
-            // Collection is updated and download is deleted from Download Manager.
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: Download is in Finished state and collection has download id != 0");
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: -> we have missed download finished event, lets generate it by ourselves.");
-            
-            TUint64 downloaded( 0 );
-            TUint8 progress( DownloadUtilL().DownloadProgress( aDownload, downloaded, EFalse ) );            
-            TUint32 downloadId( aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) );
-            HandleDlEvent( dlStateInDlManager, downloadId,
-                    progress, downloaded, KErrNone, KErrNone );
-            DownloadUtilL().DeleteDownloadAsync( downloadId, EFalse /* don't delete content */ );
-            }
-        else
-            {
-            MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: dl state in dl manager differs of mpx cache-> updating mpx cache");
-            aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState,
-                    static_cast<TUint8>( dlStateInDlManager ) );
-            aModified = ETrue;
-            }
-        }
-    else
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: download state already same in dl manager and mds");
-        }
-    
-    // KVcxMediaMyVideosDownloadProgress
-    TUint64 downloaded = 0;
-    TInt8 dlProgressInDlManager = DownloadUtilL().DownloadProgress(
-            aDownload, downloaded, EFalse );
-    
-    TInt8 dlProgressInMpxCache;
-    if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadProgress ) )
-        {
-        dlProgressInMpxCache = aVideo.ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
-        }
-    else
-        {
-        aVideo.SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress, 0 );
-        dlProgressInMpxCache = 0;
-        }
-
-    MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl progress in dl manager: %d", dlProgressInDlManager);
-    MPX_DEBUG2("CVcxMyVideosCollectionPlugin:: dl progress in mpx cache: %d", dlProgressInMpxCache);
-
-    if ( dlProgressInDlManager != dlProgressInMpxCache )
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: dl progress in dl manager differs of mpx cache-> updating mpx cache");
-        aVideo.SetTObjectValueL<TInt8>( KVcxMediaMyVideosDownloadProgress,
-                static_cast<TInt8>( dlProgressInDlManager ) );
-        aModified = ETrue;
-        }
-    else
-        {
-        MPX_DEBUG1("CVcxMyVideosCollectionPlugin:: download progress already same in dl manager and mds");
-        }        
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL( CMPXMedia& aVideoList,
-        TBool aSendEvents, TInt aStartPos )
-    {
-    MPX_FUNC("CVcxMyVideosCollectionPlugin::SyncVideoListWithDownloadsL");
-
-    CMPXMediaArray* videoArray = aVideoList.Value<CMPXMediaArray>(
-                                KMPXMediaArrayContents);    
-
-    CMPXMedia* video;
-    
-    TBool eventsAdded = EFalse;
-    for ( TInt i = aStartPos; i < videoArray->Count(); i++ )
-        {
-        video = (*videoArray)[i];        
-        SyncVideoWithDownloadsL( *video, eventsAdded, aSendEvents );        
-        }
-    if ( eventsAdded )
-        {
-        iMessageList->SendL();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::DownloadUtil
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadUtil& CVcxMyVideosCollectionPlugin::DownloadUtilL()
-    {
-    if ( !iDownloadUtil )
-        {
-        iDownloadUtil = CVcxMyVideosDownloadUtil::NewL( *this, iFs );        
-        }
-    
-    if ( !iOrphanDownloadsCleared )
-        {
-        if ( !iCache->iVideoListIsPartial )
-            {
-            iOrphanDownloadsCleared = ETrue;
-            iDownloadUtil->ClearOrphanDownloadsL( *iCache->iVideoList );
-            }
-        }
-    
-    return *iDownloadUtil;
-    }
-
-// ----------------------------------------------------------------------------
 // CVcxMyVideosCollectionPlugin::CategoriesL
 // ----------------------------------------------------------------------------
 //
@@ -1363,6 +837,20 @@
     }
 
 // ----------------------------------------------------------------------------
+// CVcxMyVideosCollectionPlugin::AlbumsL
+// TODO: Unecessarry func since we always load this
+// ----------------------------------------------------------------------------
+//
+CVcxMyVideosAlbums& CVcxMyVideosCollectionPlugin::AlbumsL()
+    {
+    if ( !iAlbums )
+        {
+        iAlbums = CVcxMyVideosAlbums::NewL( *this );
+        }
+    return *iAlbums;
+    }
+
+// ----------------------------------------------------------------------------
 // CVcxMyVideosCollectionPlugin::HandleCreateVideoListResp
 // ----------------------------------------------------------------------------
 //
@@ -1434,33 +922,6 @@
     }
 
 // ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::NotifyDownloadCompletedL( CMPXMedia& aVideo )
-    {
-    const TInt KMediaExtSize( 8 );
-    
-    HBufC8* buffer = HBufC8::NewL( KMediaExtSize );
-    CleanupStack::PushL( buffer );
-    TPtr8 des = buffer->Des();
-    
-    RDesWriteStream stream;
-    CleanupClosePushL( stream );
-    stream.Open( des );
-    
-    aVideo.ExternalizeL( stream );
-    
-    stream.CommitL();
-    
-    CleanupStack::PopAndDestroy( &stream );    
-    
-    DownloadUtilL().NotifyDownloadCompleted( *buffer );
-    
-    CleanupStack::PopAndDestroy( buffer );
-    }
-
-// ----------------------------------------------------------------------------
 // CVcxMyVideosCollectionPlugin::NotifyNewVideosCountDecreasedL
 // ----------------------------------------------------------------------------
 //
@@ -1481,9 +942,7 @@
     stream.CommitL();
     
     CleanupStack::PopAndDestroy( &stream );    
-    
-    DownloadUtilL().NotifyNewVideosCountDecreased( *buffer );
-    
+        
     CleanupStack::PopAndDestroy( buffer );
     }
 
@@ -1505,7 +964,7 @@
     ids.Reset();
     CleanupClosePushL( ids ); // 1->
     ids.AppendL( mpxId.iId1 );
-    HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache and sync with downloads
+    HandleMyVideosDbEvent( EMPXItemInserted, ids ); //this will fetch from mds to cache
     CleanupStack::PopAndDestroy( &ids ); // <-1
     }
 
@@ -1621,53 +1080,3 @@
     iMessageList->SendL();    
     }
 
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosCollectionPlugin::SetDownloadIdToZeroL( TUint aDownloadId )
-    {
-    CMPXMedia* video = iCache->FindVideoByDownloadIdL( aDownloadId );
-    if ( video )
-        {
-        video->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-        video->SetTObjectValueL<TUint8>( KVcxMediaMyVideosDownloadState,
-                static_cast<TUint8>( EVcxMyVideosDlStateNone ) );
-        iMyVideosMdsDb->UpdateVideoL( *video );
-        iMessageList->AddEventL( TVcxMyVideosCollectionUtil::IdL(
-                *video ), EMPXItemModified );
-        iMessageList->SendL();
-        }
-    }
-    
-#ifdef _DEBUG
-// ----------------------------------------------------------------------------
-// CVcxMyVideosCollectionPlugin::DownloadState
-// ----------------------------------------------------------------------------
-//
-const TDesC& CVcxMyVideosCollectionPlugin::DownloadState( TUint8 aDlState )
-    {
-    _LIT(KDlStateNoneDes, "None");
-    _LIT(KDlStateDownloadingDes, "Downloading");
-    _LIT(KDlStateFailedDes, "Failed");
-    _LIT(KDlStatePausedDes, "Paused");
-    _LIT(KDlStateDownloadedDes, "Downloaded");
-
-    switch ( aDlState )
-        {
-        case EVcxMyVideosDlStateNone:
-            return KDlStateNoneDes;
-        case EVcxMyVideosDlStateDownloading:
-            return KDlStateDownloadingDes;
-        case EVcxMyVideosDlStateFailed:
-            return KDlStateFailedDes;
-        case EVcxMyVideosDlStatePaused:
-            return KDlStatePausedDes;
-        case EVcxMyVideosDlStateDownloaded:
-            return KDlStateDownloadedDes;
-        default:
-            return KNullDesC;
-        }
-    }
-#endif
-
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionutil.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideoscollectionutil.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -11,13 +11,12 @@
 *
 * Contributors:
 *
-* Description: 
+* Description:
 *
 */
 
 
 
-
 // INCLUDE FILES
 #include <mpxmedia.h>
 #include <mpxmediaarray.h>
@@ -166,7 +165,25 @@
             }
         }
     }
-    
+
+// ---------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::AppendToListL
+// New items in aToList will point to same shared memory as items in aFromList.
+// ---------------------------------------------------------------------------
+//
+void TVcxMyVideosCollectionUtil::AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList )
+    {
+    CMPXMedia* media;
+    CMPXMediaArray* toArray   = aToList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    CMPXMediaArray* fromArray = aFromList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    TInt count = fromArray->Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        media = CMPXMedia::NewL( *(fromArray->AtL( i )) ); // points to same shared memory
+        toArray->AppendL( media ); //ownership moves
+        }
+    }
+
 // ---------------------------------------------------------------------------
 // This helper function converts drive letter to drive number
 // ---------------------------------------------------------------------------
@@ -213,7 +230,8 @@
             {
             aUniquePath  = aPath.Mid( 0, pos );
             }
-        counterDigits.Format(_L("%d"), counter++);
+        _LIT(KPercentD, "%d");
+        counterDigits.Format( KPercentD, counter++ );
         aUniquePath.Append( '_' );
         aUniquePath.Append( '(' );
         aUniquePath.AppendJustify( counterDigits, KMaxDigits, TAlign( ERight ), '0' );
@@ -236,12 +254,19 @@
     if ( aVideo.IsSupported( KVcxMediaMyVideosOrigin ) )
         {
         origin = aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin );                
-        if ( origin == EVcxMyVideosOriginSideLoaded ||
-                origin == EVcxMyVideosOriginDownloaded ||
-                origin == EVcxMyVideosOriginTvRecording )
+#ifdef VIDEO_COLLECTION_PLUGIN_TB92
+        if ( origin != EVcxMyVideosOriginCapturedWithCamera )
             {
             origin = EVcxMyVideosOriginOther;
             }
+#else
+        if ( origin != EVcxMyVideosOriginCapturedWithCamera &&
+				 origin != EVcxMyVideosOriginDownloaded
+				)
+            {
+            origin = EVcxMyVideosOriginOther;
+            }
+#endif
         }
     return origin;
     }
@@ -262,6 +287,21 @@
     }
 
 // ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::CreationDateL
+// ----------------------------------------------------------------------------
+//
+TInt64 TVcxMyVideosCollectionUtil::CreationDateL( CMPXMedia& aVideo )
+    {
+    TInt64 creationDate = 0;
+                            
+    if ( aVideo.IsSupported( KMPXMediaGeneralDate ) )
+        {
+        creationDate = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );                
+        }
+    return creationDate;
+    }
+
+// ----------------------------------------------------------------------------
 // TVcxMyVideosCollectionUtil::DownloadIdL
 // ----------------------------------------------------------------------------
 //
@@ -296,7 +336,7 @@
 // TVcxMyVideosCollectionUtil::IdL
 // ----------------------------------------------------------------------------
 //
-TMPXItemId TVcxMyVideosCollectionUtil::IdL( CMPXMedia& aVideo )
+TMPXItemId TVcxMyVideosCollectionUtil::IdL( const CMPXMedia& aVideo )
     {
     TMPXItemId id( 0, 0 );
                             
@@ -329,7 +369,7 @@
 // TVcxMyVideosCollectionUtil::Title
 // ----------------------------------------------------------------------------
 //
-const TDesC& TVcxMyVideosCollectionUtil::Title( CMPXMedia& aVideo )
+const TDesC& TVcxMyVideosCollectionUtil::Title( const CMPXMedia& aVideo )
     {                            
     if ( aVideo.IsSupported( KMPXMediaGeneralTitle ) )
         {
@@ -460,7 +500,63 @@
         }
     return KErrNotFound;
     }
-    
+
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::MediaArrayL
+// ----------------------------------------------------------------------------
+//
+CMPXMediaArray* TVcxMyVideosCollectionUtil::MediaArrayL( const CMPXMedia& aMedia )
+    {
+    if ( !aMedia.IsSupported( KMPXMediaArrayContents ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return aMedia.Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    }
+
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::Int32ValueL
+// ----------------------------------------------------------------------------
+//
+TInt32 TVcxMyVideosCollectionUtil::Int32ValueL( CMPXMedia& aMedia )
+    {
+    if ( !aMedia.IsSupported( KVcxMediaMyVideosInt32Value ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    return aMedia.ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
+    }
+
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::Uint32ValueL
+// ----------------------------------------------------------------------------
+//
+TUint32 TVcxMyVideosCollectionUtil::Uint32ValueL( CMPXMedia& aMedia )
+    {
+    if ( !aMedia.IsSupported( KVcxMediaMyVideosUint32Value ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    return aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosUint32Value );
+    }
+
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL
+// ----------------------------------------------------------------------------
+//
+void TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
+        RArray<TUint32>& aIdArray )
+    {
+    TInt count = aMediaArray.Count();
+    aIdArray.Reset();
+    aIdArray.ReserveL( count );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        aIdArray.AppendL( IdL( *aMediaArray.AtL( i ) ).iId1 );
+        }
+    }
+
 #ifdef _DEBUG
 // ----------------------------------------------------------------------------
 // TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL
@@ -502,7 +598,8 @@
 //
 void TVcxMyVideosCollectionUtil::GetProcessName( TInt aThreadId, TFullName& aProcessName )
     {
-  	TFindThread find(_L("*"));
+    _LIT(KAsterixDes, "*");
+  	TFindThread find( KAsterixDes );
   	while( find.Next( aProcessName ) == KErrNone )
         {
       	RThread thread;
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosdownloadcache.cpp	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +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 the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:    Download list cache. Circular buffer made for speeding up*
-*/
-
-
-
-
-// INCLUDE FILES
-#include <mpxlog.h>
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-#include <mpxmediageneraldefs.h>
-#include <mpxmediacontainerdefs.h>
-#include <vcxmyvideosdefs.h>
-#include <centralrepository.h>
-#include <collate.h>
-#include "vcxmyvideosdownloadcache.h"
-#include "vcxmyvideoscollectionplugin.h"
-#include "vcxmyvideosdownloadutil.h"
-#include "vcxmyvideoscollectionutil.h"
-#include "vcxmyvideoscategories.h"
-
-const TInt KVcxMvDownloadFindCacheSize = 20;
-
-// ============================ MEMBER FUNCTIONS ==============================
-
-// ----------------------------------------------------------------------------
-// Two-phased constructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadCache* CVcxMyVideosDownloadCache::NewL()
-    {
-    CVcxMyVideosDownloadCache* self = new (ELeave) CVcxMyVideosDownloadCache();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ----------------------------------------------------------------------------
-// Destructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadCache::~CVcxMyVideosDownloadCache()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadCache::~CVcxMyVideosDownloadCache");
-    
-    iDownloadId.Close();
-    iMedia.Close(); // pointers are not own
-    }
-
-// ----------------------------------------------------------------------------
-// Constructor.
-// ----------------------------------------------------------------------------
-//
-CVcxMyVideosDownloadCache::CVcxMyVideosDownloadCache()
-    {
-    MPX_FUNC("CVcxMyVideosDownloadCache::CVcxMyVideosDownloadCache");
-    }
-
-// ----------------------------------------------------------------------------
-// Symbian 2nd phase constructor can leave.
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadCache::ConstructL ()
-    {
-    iDownloadId.Reset();
-    iMedia.Reset();
-    for ( TInt i = 0; i < KVcxMvDownloadFindCacheSize; i++ )
-        {
-        iDownloadId.Append( 0 );
-        iMedia.Append( NULL );
-        }
-    }
-    
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadCache::Get
-// ----------------------------------------------------------------------------
-//
-CMPXMedia* CVcxMyVideosDownloadCache::Get( TUint32 aDownloadId )
-    {
-    for ( TInt i = 0; i < KVcxMvDownloadFindCacheSize; i++ )
-        {
-        if ( iDownloadId[i] == aDownloadId )
-            {
-            return iMedia[i];
-            }
-        }
-    return NULL;
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadCache::Add
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadCache::Add( TUint32 aDownloadId, CMPXMedia* aVideo )
-    {
-    iPos++;
-    iPos %= KVcxMvDownloadFindCacheSize;
-    iDownloadId[iPos] = aDownloadId;
-    iMedia[iPos]      = aVideo;    
-    }
-
-// ----------------------------------------------------------------------------
-// CVcxMyVideosDownloadCache::Delete
-// ----------------------------------------------------------------------------
-//
-void CVcxMyVideosDownloadCache::Delete( CMPXMedia* aVideo )
-    {
-    for ( TInt i = 0; i < KVcxMvDownloadFindCacheSize; i++ )
-        {
-        if ( iMedia[i] == aVideo )
-            {
-            iDownloadId[i] = 0;
-            iMedia[i]      = NULL;
-            }
-        }
-    }
-
-// End of file
-
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosdrivemonitor.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosdrivemonitor.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -155,46 +155,6 @@
         }
     }
 
-#if 0 // not used in mpx my videos collection
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::RegisterObserverL
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosDriveMonitor::RegisterObserverL( MVcxMyVideosDriveMonitorObserver* aObserver )
-    {
-    iObservers.AppendL( aObserver );
-
-    if ( !IsActive() )
-        {
-        iFs.NotifyChange( ENotifyDisk, iStatus );
-        SetActive();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::RemoveObserverL
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosDriveMonitor::RemoveObserverL( MVcxMyVideosDriveMonitorObserver* aObserver )
-    {
-    TInt i;
-    for ( i = 0; i < iObservers.Count(); i++ )
-        {
-        if ( aObserver == iObservers[i] )
-            {
-            iObservers.Remove( i );
-            iObservers.Compress();
-            break;
-            }
-        }
-        
-    if ( iObservers.Count() == 0 )
-        {
-        iFs.NotifyChangeCancel();
-        }    
-    }
-#endif
-
 /*
 N96 without memory card:
 26/09/2007	11:37:22	CIptvDriveMonitor:: drive[2]: type = EMediaNANDFlash
@@ -471,111 +431,6 @@
         }
     return KErrNotFound;
     }
-
-#if 0 // not used by mpx my videos collection
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::PhoneMemoryDriveL
-// -----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDriveMonitor::PhoneMemoryDriveL()
-    {
-    TInt drive;
-    User::LeaveIfError( drive = PhoneMemoryDrive() );
-    return drive;
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::PhoneMemoryDrive
-// -----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDriveMonitor::PhoneMemoryDrive()
-    {
-    TInt i;
-    for ( i = 0; i < iAvailableDrives.Count(); i++ )
-        {
-        if ( iAvailableDrives[i].iDrive == EDriveC )
-            {
-            return iAvailableDrives[i].iDrive;
-            }
-        }
-    return KErrNotFound;
-    }
-
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::FixedDriveL
-// -----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDriveMonitor::FixedDriveL( TBool aExcludeCDrive )
-    {
-    TInt drive;
-    User::LeaveIfError( drive = FixedDrive( aExcludeCDrive ) );
-    return drive;
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::FixedDrive
-// -----------------------------------------------------------------------------
-//
-TInt CVcxMyVideosDriveMonitor::FixedDrive( TBool aExcludeCDrive )
-    {
-    TInt i;
-    for ( i = 0; i < iAvailableDrives.Count(); i++ )
-        {
-        MPX_DEBUG2("CVcxMyVideosDriveMonitor:: iAvailableDrives[%d]", i);
-
-        if ( !(iAvailableDrives[i].iFlags & TVcxMyVideosDriveInfo::ERemovable) )
-            {
-            if ( iAvailableDrives[i].iDrive != EDriveC )
-                {
-                MPX_DEBUG2("CVcxMyVideosDriveMonitor:: FixedDrive() returning drive %d", iAvailableDrives[i].iDrive);
-                return iAvailableDrives[i].iDrive;
-                }
-            else
-                {
-                if ( !aExcludeCDrive )
-                    {
-                    MPX_DEBUG2("CVcxMyVideosDriveMonitor:: FixedDrive() returning drive %d", iAvailableDrives[i].iDrive);
-                    return iAvailableDrives[i].iDrive;
-                    }   
-                }
-            }
-        }
-    MPX_DEBUG1("CVcxMyVideosDriveMonitor:: FixedDrive() fixed drive not found");
-    return KErrNotFound;
-    }
-    
-// -----------------------------------------------------------------------------
-// CVcxMyVideosDriveMonitor::IsMmcInserted()
-// -----------------------------------------------------------------------------
-//
-TBool CVcxMyVideosDriveMonitor::IsMmcInserted()
-    {   
-    TInt drive = MemoryCardDrive();
-    
-    if ( drive == KErrNotFound )
-        {
-        return EFalse;
-        }
-        
-    TInt arrayPos = ArrayPos( drive );
-    
-    if ( arrayPos == KErrNotFound )
-        {
-        return EFalse;
-        }
-    
-    TUint32 flags = iAvailableDrives[arrayPos].iFlags;
-    
-    if ( (flags & TVcxMyVideosDriveInfo::ELocked) || (flags & TVcxMyVideosDriveInfo::EMediaNotPresent) )
-        {
-        return EFalse;
-        } 
-    
-    return ETrue;
-    }
-#endif
     
 // -----------------------------------------------------------------------------
 // CVcxMyVideosDriveMonitor::RunL()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsalbums.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,1080 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Provides albums support utilizing MDS.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include <mdesession.h>
+#include <mdeconstants.h>
+#include <mdequery.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediageneraldefs.h>
+#include "vcxmyvideosmdsalbums.h"
+#include "vcxmyvideosmdsdb.h"
+#include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosmdscmdqueue.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums::CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
+        MVcxMyVideosMdsAlbumsObserver* aObserver )
+: CActive( EPriorityStandard ), iMdsDb( aMdsDb ), iObserver(aObserver) 
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::ConstructL()
+    {
+    GetSchemaDefinitionsL();
+    SetObservingL();
+    CActiveScheduler::Add( this );    
+    }
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb,
+        MVcxMyVideosMdsAlbumsObserver* aObserver )
+    {
+    CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums()
+    {
+    CancelQueries();
+    delete iAlbumQuery;
+    delete iVideoQuery;
+    delete iRelationQuery;
+    iItemArray.Close();
+    iResultBuffer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::CancelQueries
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::CancelQueries( CVcxMyVideosMdsDb::TRequestType aType )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() start");
+
+    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbums )
+        {
+        if ( iAlbumQuery )
+            {
+            iAlbumQuery->Cancel();
+            }
+        }
+
+    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentIds )
+        {
+        if ( iRelationQuery )
+            {
+            iRelationQuery->Cancel();
+            }
+        }
+
+    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentVideos )
+        {
+        if ( iVideoQuery )
+            {
+            iVideoQuery->Cancel();
+            }
+        }
+
+    if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EAddVideosToAlbum
+            || aType == CVcxMyVideosMdsDb::ERemoveRelations
+            || aType == CVcxMyVideosMdsDb::ERemoveAlbums )
+        {
+        
+        // MDS does not offer cancel for these
+        //Cancel();
+        }
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// From CActive
+// CVcxMyVideosMdsAlbums::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoCancel()
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() start");
+
+    // MDS does not offer way to cancel these async requests
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::SetObservingL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::SetObservingL()
+    {
+    if ( iObserver )
+        {
+        //ENotifyAdd and ENotifyModify are not supported
+        iMdsDb.MdsSessionL().AddRelationItemObserverL( *this, NULL,
+                ENotifyRemove, iMdsDb.iNamespaceDef );
+
+#if 0
+        // We receive only IDs from here. We need to make query to get
+        // relation objects-> slow to use. We use the response from
+        // the add operation instead. This way we don't receive
+        // add events if someone else adds videos to our albums
+        // but the performance is the best possible.
+        iMdsDb.MdsSessionL().AddRelationObserverL( *this, NULL,
+                ENotifyAdd | ENotifyModify | ENotifyRemove );        
+#endif    
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumsL( CMPXMedia* aAlbumList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    CVcxMyVideosMdsCmdGetAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbums;
+    CleanupStack::PushL( cmd );
+    cmd->iCmdType   = CVcxMyVideosMdsDb::EGetAlbums;
+    cmd->iClient    = &aClient;
+    cmd->iAlbumList = aAlbumList;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
+    CleanupStack::Pop( cmd );
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumL
+// ---------------------------------------------------------------------------
+//
+CMPXMedia* CVcxMyVideosMdsAlbums::GetAlbumL( TUint32 aId )
+    {
+    CMdEObject* object = iMdsDb.ObjectL( aId, EFalse /* is not video, is album */);
+
+    if ( !object )
+        {
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: mds id %d not found from mds", aId);
+        return NULL;
+        }
+        
+    CleanupStack::PushL( object ); // 1->
+
+    CMPXMedia* album = CMPXMedia::NewL( );
+    CleanupStack::PushL( album ); // 2->
+
+    Object2MediaL( *object, *album );
+
+    CleanupStack::Pop( album );            // <-2
+    CleanupStack::PopAndDestroy( object ); // <-1
+
+    return album;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumsL( CMPXMedia* aAlbumList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() start");
+    
+    iAlbumList = aAlbumList; //store pointer to album list, we do not own this
+    iClient    = &aClient;
+    
+    delete iAlbumQuery;
+    iAlbumQuery = NULL;
+    
+    iAlbumQuery = iMdsDb.MdsSessionL().NewObjectQueryL( *iNamespaceDef, *iAlbumObjectDef, this );
+
+    CMdELogicCondition& rootCondition = iAlbumQuery->Conditions();
+    rootCondition.SetOperator( ELogicConditionOperatorOr );
+    rootCondition.AddObjectConditionL( *iAlbumObjectDef );
+    rootCondition.AddPropertyConditionL( *iTypePropertyDef,
+            TMdEIntRange( MdeConstants::Album::EAlbumUser, MdeConstants::Album::EAlbumUser,
+            EMdERangeTypeEqual ) );
+
+    iAlbumQuery->FindL();
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumContentIdsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumContentIdsL( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    CVcxMyVideosMdsCmdGetAlbumContentIds* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentIds;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType      = CVcxMyVideosMdsDb::EGetAlbumContentIds;
+    cmd->iClient       = &aClient;
+    cmd->iAlbumId      = aAlbumId;
+    cmd->iAlbumContent = &aContentArray;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
+    CleanupStack::Pop( cmd ); // <-1
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() start");
+        
+    delete iRelationQuery;
+    iRelationQuery = NULL;
+    
+    iClient       = &aClient;
+    iAlbumId      = aAlbumId;
+    iAlbumContent = &aContentArray;
+    
+    iRelationQuery = iMdsDb.MdsSessionL().NewRelationQueryL( *iNamespaceDef, this );
+
+    CMdELogicCondition& rootCondition = iRelationQuery->Conditions();
+
+    //relation left side contains and...
+    CMdERelationCondition& relationCondition =
+        rootCondition.AddRelationConditionL( *iContainsRelationDef, ERelationConditionSideLeft); // "AND"
+    
+    CMdELogicCondition& leftCondition = relationCondition.LeftL();
+    CMdELogicCondition& rightCondition = relationCondition.RightL();
+    
+    //...left side is album...
+    leftCondition.AddObjectConditionL( *iAlbumObjectDef );
+    //...and left id is aAlbumId..
+    leftCondition.AddObjectConditionL( aAlbumId );
+    
+    //Right side is video
+    rightCondition.AddObjectConditionL( *iMdsDb.iVideoObjectDef ); 
+    
+    iRelationQuery->FindL();
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumContentVideosL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() start");
+    
+    CVcxMyVideosMdsCmdGetAlbumContentVideos* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentVideos;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType            = CVcxMyVideosMdsDb::EGetAlbumContentVideos;
+    cmd->iClient             = &aClient;
+    cmd->iAlbumId            = aAlbumId;
+    cmd->iAlbumContentVideos = &aVideoList;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
+    CleanupStack::Pop( cmd ); // <-1
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() start");
+    
+    delete iVideoQuery;
+    iVideoQuery = NULL;
+
+    iClient    = &aClient;
+    iVideoList = &aVideoList;
+    iAlbumId   = aAlbumId;
+    
+    iVideoQuery = iMdsDb.MdsSessionL().NewObjectQueryL( *iNamespaceDef, *iMdsDb.iVideoObjectDef, this );
+    CMdELogicCondition& rootCondition = iVideoQuery->Conditions();
+    CMdERelationCondition& relationCondition = 
+            rootCondition.AddRelationConditionL( *iContainsRelationDef );
+
+    CMdELogicCondition& leftCondition = relationCondition.LeftL();
+    CMdELogicCondition& rightCondition = relationCondition.RightL();
+
+    //...left side is an album...
+    leftCondition.AddObjectConditionL( *iAlbumObjectDef );
+    //...and left id is aAlbumId..
+    leftCondition.AddObjectConditionL( aAlbumId );
+
+    //and queried object is on the right side of the relation
+    relationCondition.SetSide( ERelationConditionSideRight );
+    
+    const TInt maxItemsInQueryResult = 500;
+    iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL()
+    {
+    iNamespaceDef = &(iMdsDb.MdsSessionL().GetDefaultNamespaceDefL());
+    
+    _LIT( KVcxAlbumObjectName, "Album" );
+    iAlbumObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxAlbumObjectName ));
+
+    _LIT( KVcxTypePropertyName, "Type" );
+    iTypePropertyDef = &(iAlbumObjectDef->GetPropertyDefL( KVcxTypePropertyName ));
+
+    _LIT( KVcxContainsRelationName, "Contains" );
+    iContainsRelationDef =
+        &(iNamespaceDef->GetRelationDefL( KVcxContainsRelationName ));
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::Object2MediaL
+// For album objects only.
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::Object2MediaL(
+        CMdEObject& aObject,
+        CMPXMedia& aAlbum )
+    {    
+    aAlbum.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup );
+   
+    CMdEProperty* property = NULL;
+
+    // ID
+    TMPXItemId mpxId;
+    mpxId.iId1 = aObject.Id();
+    mpxId.iId2 = KVcxMvcMediaTypeAlbum;
+    aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
+    
+    // TITLE
+    if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
+        {
+        aAlbum.SetTextValueL( KMPXMediaGeneralTitle,
+                static_cast<CMdETextProperty*>(property)->Value());
+        }
+       
+    // CREATION DATE
+    if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
+        {
+        aAlbum.SetTObjectValueL<TInt64>( KMPXMediaGeneralDate,
+                static_cast<CMdETimeProperty*>(property)->Value().Int64() );
+        }
+              
+    // MODIFIED DATE
+    if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
+        {
+        aAlbum.SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate,
+                static_cast<CMdETimeProperty*>(property)->Value().Int64() );
+        }
+
+#if 0 //TODO
+    // ALBUM TYPE
+    if ( aObject.Property( *iTypePropertyDef, property, 0 ) != KErrNotFound )
+        {
+        aAlbum.SetTObjectValueL<TUint16>( KVcxMediaMyVideosAlbumType,
+                static_cast<CMdETUint16Property*>(property)->Value() );
+        }
+#endif
+
+    //TODO: usage count
+    
+    aAlbum.SetTObjectValueL( KMPXMediaGeneralType, EMPXGroup );
+    aAlbum.SetTObjectValueL( KMPXMediaGeneralCategory, EMPXNoCategory );
+    aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryItemCount, 0 );
+    aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryNewItemCount, 0 );
+
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::Media2ObjectL
+// Called by AddAlbumL()
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::Media2ObjectL(
+        CMPXMedia& aAlbum,
+        CMdEObject& aObject)
+    {
+    CMdEProperty* property;
+
+    // MDS ID
+    
+    // TITLE (NAME)
+    if ( aAlbum.IsSupported( KMPXMediaGeneralTitle ) )
+        {
+        if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
+            {
+            static_cast<CMdETextProperty*>(property)->SetValueL(
+                    aAlbum.ValueText( KMPXMediaGeneralTitle ) );
+            }
+        else
+            {
+            aObject.AddTextPropertyL(
+                    *iMdsDb.iTitlePropertyDef, aAlbum.ValueText( KMPXMediaGeneralTitle ) );
+            }
+        }
+        
+    // KMPXMediaGeneralDate ( creation date )
+    if ( aAlbum.IsSupported( KMPXMediaGeneralDate ) )
+        {
+        TInt64 creationDateInt64 = 0;
+        creationDateInt64 = aAlbum.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
+        TTime creationDate( creationDateInt64 );
+        if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
+            {
+            static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
+            }
+        else
+            {
+            aObject.AddTimePropertyL( *iMdsDb.iCreationDatePropertyDef, creationDate );
+            }
+        }
+        
+    // KVcxMediaMyVideosModifiedDate
+    if ( aAlbum.IsSupported( KVcxMediaMyVideosModifiedDate ) )
+        {
+        TInt64 modifiedDateInt64 = aAlbum.ValueTObjectL<TInt64>( KVcxMediaMyVideosModifiedDate );
+        TTime modifiedDate( modifiedDateInt64 );
+        if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
+            {
+            static_cast<CMdETimeProperty*>(property)->SetValueL( modifiedDate );
+            }
+        else
+            {
+            aObject.AddTimePropertyL( *iMdsDb.iLastModifiedDatePropertyDef, modifiedDate );
+            }
+        }        
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleQueryNewResults(CMdEQuery& aQuery,
+            TInt aFirstNewItemIndex,
+            TInt aNewItemCount )
+    {
+    if ( &aQuery == iVideoQuery )
+        {
+        TRAPD( err, HandleVideoQueryResultsL( aQuery, KErrNone,
+                aFirstNewItemIndex, aNewItemCount, EFalse /* completed */ ) );
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleQueryCompleted
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
+    {
+    if ( &aQuery == iAlbumQuery )
+        {
+        TRAPD( err, HandleAlbumQueryCompletedL( aQuery, aError ) );
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleAlbumQueryCompletedL() left: %d", err);
+            }
+        }
+    else if ( &aQuery == iVideoQuery )
+        {
+        TRAPD( err, HandleVideoQueryResultsL( aQuery, aError, 0, 0, ETrue /* completed */ ) );
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
+            }
+        }
+    else if ( &aQuery == iRelationQuery )
+        {
+        TRAPD( err, HandleRelationQueryCompletedL( aQuery, aError ) );
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleRelationQueryCompletedL() left: %d", err);
+            }
+        }
+
+    iMdsDb.iCmdQueue->CmdFinished();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() start");
+    
+    if ( aError != KErrNone )
+        {
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
+        return;
+        }
+    
+    CMPXMediaArray* array = iAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    
+    CMPXMedia* media;    
+    TInt count = iAlbumQuery->Count();
+    
+    iAlbumList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CMdEObject& object = iAlbumQuery->Result( i );
+
+        media = CMPXMedia::NewL();
+        CleanupStack::PushL( media ); // 1->
+
+        Object2MediaL( object, *media );
+        
+#ifdef _DEBUG
+        TBuf<KVcxMvcMaxTitleLength> title;
+        title = TVcxMyVideosCollectionUtil::Title( *media );
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
+#endif        
+
+        array->AppendL( media );
+
+        CleanupStack::Pop( media ); // <-1
+        }
+    
+    iClient->HandleGetAlbumsResp( iAlbumList );
+    iAlbumList = NULL;
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleVideoQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL( CMdEQuery& /*aQuery*/, TInt aError,
+    TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete  )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() start");
+    
+    if ( aComplete )
+        {
+        // error code given only if completed
+        if ( aError != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
+            }
+
+        iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList, 
+                aError, aFirstNewItemIndex, aNewItemCount, aComplete );
+        return;
+        }
+    
+    CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    
+    CMPXMedia* media;    
+    TInt count = iVideoQuery->Count();
+    
+    iVideoList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
+    
+    for ( TInt i = aFirstNewItemIndex; i < count; i++ )
+        {
+        CMdEObject& object = iVideoQuery->Result( i );
+
+        media = CMPXMedia::NewL();
+        CleanupStack::PushL( media ); // 1->
+
+        iMdsDb.Object2MediaL( object, *media );
+        
+#ifdef _DEBUG
+        TBuf<256> title;
+        title = TVcxMyVideosCollectionUtil::Title( *media );
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
+#endif        
+
+        array->AppendL( media );
+
+        CleanupStack::Pop( media ); // <-1
+        }
+    
+    iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList, 
+            aError, aFirstNewItemIndex, aNewItemCount, aComplete );
+    iVideoList = NULL;
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() start");
+    
+    if ( aError != KErrNone )
+        {
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums:: relation query failed with error: %d", aError);
+        return;
+        }
+            
+    TInt count = iRelationQuery->Count();
+    TVcxMyVideosAlbumVideo video;
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MPX_DEBUG4("Relation (id = %d): %d contains %d", iRelationQuery->Result( i ).Id(),
+                iRelationQuery->Result( i ).LeftObjectId(),
+                iRelationQuery->Result( i ).RightObjectId());
+        video.iMdsId         = iRelationQuery->Result( i ).RightObjectId();
+        video.iRelationMdsId = iRelationQuery->Result( i ).Id();
+        iAlbumContent->AppendL( video );
+        }
+    
+    iClient->HandleGetAlbumContentIdsResp( iAlbumId, *iAlbumContent );
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::AddVideosToAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::AddVideosToAlbumL( CMPXMedia* aCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() start");
+    
+    CVcxMyVideosMdsCmdAddVideosToAlbum* cmd = new (ELeave) CVcxMyVideosMdsCmdAddVideosToAlbum;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType  = CVcxMyVideosMdsDb::EAddVideosToAlbum;
+    cmd->iClient   = &aClient;
+    cmd->iMpxCmd   = aCmd;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //ownership moves
+    CleanupStack::Pop( cmd ); // <-1
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() exit");
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL
+// Called by iMdsDb.iCmdQueue
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL( CMPXMedia* aCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    iItemArray.Reset();
+    iResultBuffer.Close();
+    CMdERelation* relation;
+    CMPXMediaArray* videoArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
+    
+    TInt albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
+    
+    TInt count = videoArray->Count();
+    iItemArray.Reserve( count );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Filter already failed items out from the request (KErrAlreadyExists)
+        if ( TVcxMyVideosCollectionUtil::Int32ValueL( *videoArray->AtL( i ) ) 
+                != KErrAlreadyExists )
+            {
+            relation = iMdsDb.MdsSessionL().NewRelationL(
+                    *iContainsRelationDef, albumId,
+                    TVcxMyVideosCollectionUtil::IdL( *videoArray->AtL( i ) ) );
+            CleanupStack::PushL( relation );
+            iItemArray.AppendL( relation );
+            CleanupStack::Pop( relation );        
+            }
+        }
+    
+    iClient = &aClient;
+    iMpxCmd = aCmd;
+
+    iAsyncOperation = EVcxAddVideosToAlbum;
+
+    iMdsDb.MdsSessionL().AddItemsAsyncL( iItemArray, iStatus, iResultBuffer );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RemoveRelationsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RemoveRelationsL( RArray<TUint32>& aRelationIds,
+        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() start");
+    
+    CVcxMyVideosMdsCmdRemoveRelations* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveRelations;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType     = CVcxMyVideosMdsDb::ERemoveRelations;
+    cmd->iClient      = &aClient;
+    cmd->iRelationIds = &aRelationIds;
+    cmd->iResults     = &aResults;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
+    CleanupStack::Pop( cmd ); // <-1
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() exit");    
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoRemoveRelationsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
+        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() start");
+
+    iResultBuffer.Close();
+    
+    iClient            = &aClient;
+    iResultArrayUint32 = &aResults;
+    iIdArray           = &aRelationIds;
+    
+    iAsyncOperation = EVcxRemoveRelations;
+    
+    iMdsDb.MdsSessionL().RemoveRelationsAsyncL( *iIdArray, iStatus, iResultBuffer, iNamespaceDef );
+    SetActive();
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::AddAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::AddAlbumL( CMPXMedia& aAlbum )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() start");
+             
+    CMdEObject* object = iMdsDb.MdsSessionL().NewObjectLC(
+            *iAlbumObjectDef, KNullDesC ); // 1->
+
+    Media2ObjectL( aAlbum, *object );
+    iMdsDb.SetCreationAndModifiedDatesL( *object );
+
+    TUint32 mdsId;
+
+#ifdef _DEBUG
+    TRAPD( err, mdsId = iMdsDb.MdsSessionL().AddObjectL( *object ) );
+
+    if ( err != KErrNone )
+        {
+        MPX_DEBUG2( "CVcxMyVideosMdsAlbums:: iMdsDb.MdsSessionL().AddObjectL leaved with error: %d", err );
+        User::Leave( err );
+        }
+#else
+
+    mdsId = iMdsDb.MdsSessionL().AddObjectL( *object );
+
+#endif
+    
+    if ( mdsId == KNoId )
+        {
+        MPX_DEBUG1( "CVcxMyVideosMdsAlbums::AddAlbumL could not add new album" );
+        User::Leave( KErrGeneral );
+        }
+    
+    MPX_DEBUG2( "CVcxMyVideosMdsAlbums::AddAlbumL album created, mds id: %d", mdsId );
+
+    aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId( mdsId, KVcxMvcMediaTypeAlbum ) );
+    
+    CleanupStack::PopAndDestroy( object ); // <-1
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::SetAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::SetAlbumL( CMPXMedia& aVideo )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsDb::SetAlbumL() start");
+
+    TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( aVideo );
+
+    MPX_DEBUG2("CVcxMyVideosMdsAlbums::SetAlbumL updating object %d ", mpxId.iId1);
+    
+    CMdEObject* object =
+            iMdsDb.MdsSessionL().OpenObjectL( mpxId.iId1, *iAlbumObjectDef );
+    if ( !object )
+        {
+        // No object with this ID was found!
+        MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL no object found");
+        User::Leave( KErrNotFound );
+        }
+    else
+        {
+        MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL object found");
+        
+        if ( object->OpenForModifications() )
+            {
+            CleanupStack::PushL( object ); // 1->
+            
+            Media2ObjectL( aVideo, *object );
+            
+            iMdsDb.MdsSessionL().CommitObjectL( *object );
+
+            CleanupStack::PopAndDestroy( object );
+            }
+        else
+            {
+            // Object is already locked!
+            MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL object was locked!");
+            delete object;
+            User::Leave( KErrInUse );
+            }
+        }
+
+    MPX_DEBUG1("CVcxMyVideosMdsDb::SetAlbumL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RemoveAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() start");
+    
+    CVcxMyVideosMdsCmdRemoveAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveAlbums;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType  = CVcxMyVideosMdsDb::ERemoveAlbums;
+    cmd->iClient   = &aClient;
+    cmd->iMpxCmd   = aMpxCmd;
+    iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
+    CleanupStack::Pop( cmd ); // <-1
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() exit");    
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoRemoveAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() start");
+
+    iResultBuffer.Close();
+
+    iClient = &aClient;
+    iMpxCmd = aMpxCmd;
+    
+    RArray<TUint32> idArray;
+    CleanupClosePushL( idArray );
+
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aMpxCmd );
+
+    TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( *mediaArray, idArray );
+    
+    iAsyncOperation = EVcxRemoveAlbums;
+    
+    iMdsDb.MdsSessionL().RemoveObjectsAsyncL( idArray, iStatus, iResultBuffer, iNamespaceDef );
+    
+    CleanupStack::PopAndDestroy( &idArray );
+    SetActive();
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() exit");    
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RunL
+// From CActive.
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RunL()
+    {
+#ifdef _DEBUG
+    TInt status = iStatus.Int();
+    if ( status != KErrNone )
+        {
+        MPX_DEBUG2("CVcxMyVideosMdsAlbums::RunL() iStatus = %d", status);
+        }
+#endif
+    
+    switch ( iAsyncOperation )
+        {
+        case EVcxAddVideosToAlbum:
+            {
+            HandleAddVideosToAlbumCompletedL();
+            }
+            break;
+            
+        case EVcxRemoveRelations:
+            HandleRemoveRelationsCompletedL();
+            break;
+            
+        case EVcxRemoveAlbums:
+            HandleRemoveAlbumsCompletedL();
+            break;
+        }
+
+    iMdsDb.iCmdQueue->CmdFinished();
+    }
+
+//TODO: implement RunError
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL()
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() start");
+    
+    iMdsDb.MdsSessionL().DeserializeItemsL( iResultBuffer, iItemArray );
+    
+    iClient->HandleAddVideosToAlbumResp( iMpxCmd, iItemArray );
+    iResultBuffer.Close();
+    iItemArray.Close();    
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL()
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() start");
+    
+    iMdsDb.MdsSessionL().DeserializeIdsL( iResultBuffer, NULL, NULL, iResultArrayUint32 );
+
+#ifdef _DEBUG
+    TItemId result;
+    TInt count = iResultArrayUint32->Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        result = (*iResultArrayUint32)[i];
+        MPX_DEBUG3("relation remove result[%d] = %d", i, result);
+        }
+#endif
+    
+    iClient->HandleRemoveRelationsResp( *iIdArray, *iResultArrayUint32 );
+
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL()
+    {
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL() start");
+
+    RArray<TUint32> resultArray;
+    resultArray.Reset();
+    CleanupClosePushL( resultArray );
+    
+    iMdsDb.MdsSessionL().DeserializeIdsL( iResultBuffer, &resultArray, NULL, NULL  );
+
+#ifdef _DEBUG
+    TItemId result;
+    TInt count = resultArray.Count();
+
+    MPX_DEBUG2("CVcxMyVideosMdsAlbums:: remove albums result count = %d", count);
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        result = resultArray[i];
+        MPX_DEBUG3("CVcxMyVideosMdsAlbums:: remove albums result[%d] = %d", i, result);
+        }
+#endif
+
+    iClient->HandleRemoveAlbumsResp( iMpxCmd, resultArray );
+
+    CleanupStack::PopAndDestroy( &resultArray );
+    
+    MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRelationItemNotification
+// From MMdERelationItemObserver
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRelationItemNotification(CMdESession& /*aSession*/, 
+        TObserverNotificationType aType,
+        const RArray<TMdERelation>& aRelationArray)
+    {
+    if ( iObserver )
+        {
+        iObserver->HandleRelationEvent( aType, aRelationArray );
+        }
+    }
+
+#if 0
+// ----------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRelationNotification
+// From MMdERelationObserver
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRelationNotification(CMdESession& /*aSession*/, 
+        TObserverNotificationType aType,
+        const RArray<TItemId>& aRelationIdArray)
+    {    
+    switch ( aType )
+        {
+        case ENotifyAdd:
+            MPX_DEBUG1("CVcxMyVideosMdsAlbums:: relation ENotifyAdd");
+            if ( iObserver )
+                {
+                iObserver->HandleRelationIdEvent( aType, aRelationIdArray );
+                }
+            break;
+        case ENotifyModify:
+            MPX_DEBUG1("CVcxMyVideosMdsAlbums:: ENotifyModify");
+            break;
+        case ENotifyRemove:
+            //remove is handled at HandleRelationItemNotification
+            break;
+        }
+    }
+#endif
+
+// END OF FILE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosmdscmdqueue.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,231 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Queues commands to MDS.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include "vcxmyvideosmdscmdqueue.h"
+#include "vcxmyvideosmdsdb.h"
+#include "vcxmyvideosmdsalbums.h"
+
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue::CVcxMyVideosMdsCmdQueue( CVcxMyVideosMdsDb& aMdsDb )
+: iMdsDb( aMdsDb )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::ConstructL()
+    {
+    iQueue.Reset();    
+    }
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue* CVcxMyVideosMdsCmdQueue::NewL( CVcxMyVideosMdsDb& aMdsDb )
+    {
+    CVcxMyVideosMdsCmdQueue* self = new(ELeave) CVcxMyVideosMdsCmdQueue( aMdsDb );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue::~CVcxMyVideosMdsCmdQueue()
+    {
+    for ( TInt i = 0; i < iQueue.Count(); i++ )
+        {
+        delete iQueue[i];
+        }
+    iQueue.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::Cancel
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::Cancel( CVcxMyVideosMdsDb::TRequestType aType )
+    {
+    TInt count = iQueue.Count()-1;
+    for ( TInt i = count; i >= 0; i-- )
+        {
+        if ( iQueue[i]->iCmdType == aType || aType == CVcxMyVideosMdsDb::EAll )
+            {
+            delete iQueue[i];
+            iQueue[i] = NULL;
+            iQueue.Remove( i );
+            }
+        }    
+    iQueue.Compress();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::ExecuteCmdL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::ExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
+    {    
+    if ( iQueue.Count() == 0 && !iCmdInProgress )
+        {
+        DoExecuteCmdL( aCmd ); //ownership does not move
+        delete aCmd;
+        }
+    else
+        {
+        iQueue.AppendL( aCmd );
+        }    
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::CmdFinished
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::CmdFinished()
+    {
+    iCmdInProgress = EFalse;
+
+    TInt err( KErrGeneral );
+    while ( err != KErrNone )
+        {
+        if ( iQueue.Count() == 0 )
+            {
+            break;
+            }
+                            
+        TInt cmdIndexToExecute;
+        // Let other commads bypass EGetVideoList
+        if ( iQueue.Count() > 1 && iQueue[0]->iCmdType == CVcxMyVideosMdsDb::EGetVideoList )
+            {
+            cmdIndexToExecute = 1;
+            }
+        else
+            {
+            cmdIndexToExecute = 0;
+            }
+        TRAP( err, DoExecuteCmdL( iQueue[cmdIndexToExecute] ) ); //ownership does not move
+        delete iQueue[cmdIndexToExecute];
+        iQueue[cmdIndexToExecute] = NULL;
+        iQueue.Remove( cmdIndexToExecute );
+        iQueue.Compress();
+        
+#ifdef _DEBUG
+        if ( err != KErrNone )
+            {
+            MPX_DEBUG2("CVcxMyVideosMdsCmdQueue:: MDS cmd failed: %d", err);
+            }
+#endif
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::DoExecuteCmdL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::DoExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
+    {    
+    switch ( aCmd->iCmdType )
+        {
+        case CVcxMyVideosMdsDb::EGetVideoList:
+            {
+            CVcxMyVideosMdsCmdGetVideoList* cmd =
+                    static_cast<CVcxMyVideosMdsCmdGetVideoList*>( aCmd );
+            iMdsDb.DoCreateVideoListL( cmd->iSortingOrder,
+                    cmd->iAscending,
+                    cmd->iFullDetails,
+                    *cmd->iVideoList );
+            iCmdInProgress = ETrue;
+            }
+            break;
+        
+        case CVcxMyVideosMdsDb::EGetAlbums:
+            {
+            CVcxMyVideosMdsCmdGetAlbums* cmd = static_cast<CVcxMyVideosMdsCmdGetAlbums*>( aCmd );
+            iMdsDb.iAlbums->DoGetAlbumsL( cmd->iAlbumList, *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+
+        case CVcxMyVideosMdsDb::EGetAlbumContentIds:
+            {
+            CVcxMyVideosMdsCmdGetAlbumContentIds* cmd =
+                    static_cast<CVcxMyVideosMdsCmdGetAlbumContentIds*>( aCmd );
+            iMdsDb.iAlbums->DoGetAlbumContentIdsL( cmd->iAlbumId, *cmd->iAlbumContent,
+                    *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+
+        case CVcxMyVideosMdsDb::EGetAlbumContentVideos:
+            {
+            CVcxMyVideosMdsCmdGetAlbumContentVideos* cmd =
+                    static_cast<CVcxMyVideosMdsCmdGetAlbumContentVideos*>( aCmd );
+            iMdsDb.iAlbums->DoGetAlbumContentVideosL( cmd->iAlbumId, *cmd->iAlbumContentVideos,
+                    *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+            
+        case CVcxMyVideosMdsDb::EAddVideosToAlbum:
+            {
+            CVcxMyVideosMdsCmdAddVideosToAlbum* cmd =
+                    static_cast<CVcxMyVideosMdsCmdAddVideosToAlbum*>( aCmd );
+            iMdsDb.iAlbums->DoAddVideosToAlbumL( cmd->iMpxCmd,
+                    *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+
+        case CVcxMyVideosMdsDb::ERemoveRelations:
+            {
+            CVcxMyVideosMdsCmdRemoveRelations* cmd =
+                    static_cast<CVcxMyVideosMdsCmdRemoveRelations*>( aCmd );
+            iMdsDb.iAlbums->DoRemoveRelationsL( *cmd->iRelationIds, *cmd->iResults,
+                    *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+            
+        case CVcxMyVideosMdsDb::ERemoveAlbums:
+            {
+            CVcxMyVideosMdsCmdRemoveAlbums* cmd =
+                    static_cast<CVcxMyVideosMdsCmdRemoveAlbums*>( aCmd );
+            iMdsDb.iAlbums->DoRemoveAlbumsL( cmd->iMpxCmd, *cmd->iClient );
+            iCmdInProgress = ETrue;
+            }
+            break;
+
+        default:
+            break;
+        }    
+    }    
+// END OF FILE
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -11,12 +11,11 @@
 *
 * Contributors:
 *
-* Description:    MPX My Videos collection plugin's MDS database class*
+* Description:   MPX My Videos collection plugin's MDS database class*
 */
 
 
 
-
 //#include <harvesterclient.h>
 #include <mpxlog.h>
 #include <mdeconstants.h>
@@ -29,9 +28,11 @@
 #include <mpxmediageneralextdefs.h>
 #include <mpxmediaarray.h>
 #include <mpxmediavideodefs.h>
-#include <centralrepository.h>
 #include "vcxmyvideosmdsdb.h"
 #include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosmdsalbums.h"
+#include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosmdscmdqueue.h"
 
 _LIT( KVcxVideoObjectName, "Video" );
                                                               //1 (ID)
@@ -55,7 +56,6 @@
 _LIT( KVcxOriginPropertyName, "Origin" );                     //16
 _LIT( KVcxDurationPropertyName, "Duration" );                 //17
 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10
-_LIT( KVcxDownloadIdPropertyName, "DownloadID" );             //18
 _LIT( KVcxRatingPropertyName, "Rating" );                     //19
 _LIT( KVcxBitratePropertyName, "Bitrate" );                   //20
 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" );           //21
@@ -162,8 +162,9 @@
 // CVcxMyVideosMdsDb::CVcxMyVideosMdsDb
 // ---------------------------------------------------------------------------
 //
-CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
-: iFs( aFs ), iMdsDbObserver(aObserver) 
+CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver,
+        RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
+: iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) 
     {
     }
 
@@ -175,13 +176,22 @@
     {
     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL start" );
 
+    iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this );
+
     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
     
     OpenMdsSessionL();
 
+        
+    iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver );
+    
+    TCallBack callBack( AsyncHandleQueryCompleted, this );    
+    iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack,
+            CActive::EPriorityStandard );
+
     iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL(
             *this, KHarvesterPSShutdown, KMdSShutdown, EFalse );
-        
+
     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" );
     }
 
@@ -198,7 +208,6 @@
     delete iMdsSession;
     iMdsSession = NULL;
     iMdsSession = CMdESession::NewL( *this );
-    
     if ( !iMdsSession )
         {
         User::Leave( KErrGeneral );
@@ -222,6 +231,12 @@
         iMdsSession->AddObjectPresentObserverL( *this );
         
         GetSchemaDefinitionsL();
+        
+        if ( iAlbums )
+            {
+            iAlbums->GetSchemaDefinitionsL();
+            iAlbums->SetObservingL();
+            }
         }
     else
         {
@@ -243,7 +258,6 @@
     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." );
     MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() );
     MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" );
-    //iMdsDbObserver->HandleObjectPresentNotification();
 
     TObserverNotificationType type;
     if ( aPresent )
@@ -261,10 +275,11 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
+CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver,
+        RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
     {
     CVcxMyVideosMdsDb* self =
-            CVcxMyVideosMdsDb::NewLC( aObserver, aFs );
+            CVcxMyVideosMdsDb::NewLC( aObserver, aFs, aAlbumsObserver );
     CleanupStack::Pop( self );
     return self;
     }
@@ -273,10 +288,10 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC(
-        MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs )
+CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC( MVcxMyVideosMdsDbObserver* aObserver,
+        RFs& aFs, MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver )
     {
-    CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs );
+    CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs, aAlbumsObserver );
     CleanupStack::PushL( self );
     self->ConstructL();
     return self;
@@ -290,13 +305,15 @@
     {
     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() start" );
 
-    Cancel();
+    Cancel( EGetVideoList );
+
+    delete iAlbums;
+    delete iCmdQueue;
     delete iVideoQuery;
     delete iMdsSession;
     delete iActiveSchedulerWait;
-    delete iRepository;
+    delete iAsyncHandleQueryCompleteCaller;
     delete iMdsShutdownMonitor;
-
     MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() exit" );
     }
 
@@ -304,16 +321,26 @@
 // CVcxMyVideosMdsDb::Cancel
 // ---------------------------------------------------------------------------
 //
-void CVcxMyVideosMdsDb::Cancel()
+void CVcxMyVideosMdsDb::Cancel( TRequestType aType )
     {
     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() start");
     
-    if ( iVideoQuery )
+    iCmdQueue->Cancel( aType );
+    
+    if ( aType == EAll || aType == EGetVideoList )
         {
-        iVideoQuery->Cancel();
+        if ( iVideoQuery )
+            {
+            iVideoQuery->Cancel();
+            }
+        iVideoListFetchingIsOngoing = EFalse;
         }
-    iVideoListFetchingIsOngoing = EFalse;
 
+    if ( aType != EGetVideoList )
+        {
+        iAlbums->CancelQueries( aType );
+        }
+    
     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() exit");
     }
     
@@ -335,7 +362,7 @@
     
     object->AddUint8PropertyL( *iOriginPropertyDef,
             aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) );
-
+    
     CMdEProperty* property;
 
     //  Type can not be modified normally, so set it here
@@ -410,7 +437,7 @@
         MPX_DEBUG2( "CVcxMyVideosMdsDb:: MdsSessionL().RemoveObjectL left: %d", err );
         retValue = err;        
         }
-
+        
     MPX_DEBUG1( "CVcxMyVideosMdsDb::RemoveVideoL() exit" );        
     return retValue;
     }
@@ -429,7 +456,7 @@
     
     CMdEObject* object =
             MdsSessionL().OpenObjectL( mpxId.iId1, *iVideoObjectDef );
-    if ( object == NULL )
+    if ( !object )
         {
         // No object with this ID was found!
         MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found");
@@ -457,7 +484,6 @@
             User::Leave( KErrInUse );
             }
         }
-
     MPX_DEBUG1( "CVcxMyVideosMdsDb::UpdateVideoL() exit" );
     }
 
@@ -469,6 +495,27 @@
         TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
     {
     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() start" );
+    
+    CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList;
+    CleanupStack::PushL( cmd ); // 1->
+    cmd->iCmdType      = CVcxMyVideosMdsDb::EGetVideoList;
+    cmd->iSortingOrder = aSortingOrder;
+    cmd->iAscending    = aAscending;
+    cmd->iFullDetails  = aFullDetails;
+    cmd->iVideoList    = &aVideoList;
+
+    iCmdQueue->ExecuteCmdL( cmd ); //ownership moves
+    CleanupStack::Pop( cmd ); // <-1
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsDb::DoCreateVideoListL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder,
+        TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList )
+    {
+    MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" );
         
     if ( iVideoListFetchingIsOngoing )
         {
@@ -553,14 +600,13 @@
 
     iFullDetails = aFullDetails;
     
-    iVideoQuery->FindL(KMdEQueryDefaultMaxCount, 500);
+    const TInt maxItemsInQueryResult = 500;
+    iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
 
     aVideoList->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup );            
     aVideoList->SetTObjectValueL( KMPXMediaArrayCount, mediaArray->Count() );
 
     iVideoList = aVideoList; // lets store the pointer, ownership stays at observer
-
-    MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() exit" );
     }
 
 // ---------------------------------------------------------------------------
@@ -624,7 +670,6 @@
     
     iMdsDbObserver->HandleCreateVideoListResp( iVideoList, aFirstNewItemIndex,
             EFalse /* not complete yet */);
-
     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleQueryNewResults() exit");
     }
 
@@ -635,40 +680,48 @@
 // ---------------------------------------------------------------------------
 //
 void CVcxMyVideosMdsDb::HandleQueryCompleted(
-#if _DEBUG
-        CMdEQuery& aQuery,
-#else
         CMdEQuery& /*aQuery*/,
-#endif
         TInt /*aError*/)
     {
-    MPX_DEBUG1( "CVcxMyVideosMdsDb::HandleQueryCompleted() start" );
+    iAsyncHandleQueryCompleteCaller->CallBack();
+    }
 
-    if ( !iVideoList )
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsDb::AsyncHandleQueryCompleted
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( TAny* aThis )
+    {
+    MPX_FUNC( "CVcxMyVideosMdsDb::AsyncHandleQueryCompleted" );
+
+    CVcxMyVideosMdsDb* thisObj = static_cast<CVcxMyVideosMdsDb*>( aThis );
+    
+    if ( !thisObj->iVideoList )
         {
         MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen");
-        return;
+        return KErrNone;
         }
 
 #ifdef _DEBUG
-    CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    CMPXMediaArray* array = thisObj->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
 #endif
 
-    MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", aQuery.Count());
+    MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", thisObj->iVideoQuery->Count());
     MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count());
     
-    if (iActiveSchedulerWait->IsStarted())
+    if ( thisObj->iActiveSchedulerWait->IsStarted() )
         {
-        iActiveSchedulerWait->AsyncStop();
+        thisObj->iActiveSchedulerWait->AsyncStop();
         }
     
-    iVideoListFetchingIsOngoing = EFalse;
-    iMdsDbObserver->HandleCreateVideoListResp( iVideoList, KErrNotFound /* KErrNotFound = no new items */,
+    thisObj->iVideoListFetchingIsOngoing = EFalse;
+    thisObj->iMdsDbObserver->HandleCreateVideoListResp( thisObj->iVideoList, KErrNotFound /* KErrNotFound = no new items */,
             ETrue /* complete */);
-
-    MPX_DEBUG1( "CVcxMyVideosMdsDb::HandleQueryCompleted() exit" );
+    
+    thisObj->iVideoList = NULL; // not owned by us -> just clear
     
-    iVideoList = NULL; // not owned by us -> just clear
+    thisObj->iCmdQueue->CmdFinished();
+    return KErrNone;
     }
 
 // ---------------------------------------------------------------------------
@@ -681,21 +734,21 @@
 
     CMdEObject* object = ObjectL( aId );
 
-    CMPXMedia* video = NULL;
-
-    if ( object )
+    if ( !object )
         {
-        CleanupStack::PushL( object ); // 1->
+        MPX_DEBUG2("CVcxMyVideosMdsDb:: mds id %d not found from mds", aId);
+        return NULL;
+        }
+        
+    CleanupStack::PushL( object ); // 1->
 
-        video = CMPXMedia::NewL( );
-        CleanupStack::PushL( video ); // 2->
-
-        Object2MediaL( *object, *video, aFullDetails );
+    CMPXMedia* video = CMPXMedia::NewL( );
+    CleanupStack::PushL( video ); // 2->
 
-        CleanupStack::Pop( video );            // <-2
-        CleanupStack::PopAndDestroy( object ); // <-1
-        }
+    Object2MediaL( *object, *video, aFullDetails );
 
+    CleanupStack::Pop( video );            // <-2
+    CleanupStack::PopAndDestroy( object ); // <-1
     MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoL() exit" );
 
     return video;
@@ -719,7 +772,6 @@
 
         iMdsSessionError = aError;
         }
-        
     MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionOpened() exit" );
     }
 
@@ -770,10 +822,9 @@
 // CVcxMyVideosMdsDb::ObjectL
 // ---------------------------------------------------------------------------
 //
-CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId )
+CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo )
     {
     MPX_DEBUG1("CVcxMyVideosMdsDb::ObjectL start");
-
     //  If the id is not valid, just return NULL, because
     //  MdsSessionL().GetObjectL leaves in that case
     if ( aId == KNoId )
@@ -781,9 +832,16 @@
         return NULL;
         }
 
-    CMdEObject* object = NULL;
-    object = MdsSessionL().GetObjectL( aId, *iVideoObjectDef );
-
+    CMdEObject* object;
+    if ( aIsVideo )
+        {
+        object = MdsSessionL().GetObjectL( aId, *iVideoObjectDef );
+        }
+    else
+        {
+        object = MdsSessionL().GetObjectL( aId, *iAlbums->iAlbumObjectDef );
+        }
+    
     if ( object )
         {
         MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId );
@@ -968,10 +1026,20 @@
     if ( aObject.Property( *iOriginPropertyDef, property, 0 ) != KErrNotFound )
         {
         TUint8 origin = static_cast<CMdEUint8Property*>(property)->Value();
+#ifdef VIDEO_COLLECTION_PLUGIN_TB92
         if( origin != EVcxMyVideosOriginCapturedWithCamera )
             {
             origin = EVcxMyVideosOriginOther;
             }           
+#else
+        if ( origin != EVcxMyVideosOriginCapturedWithCamera &&
+				 origin != EVcxMyVideosOriginDownloaded
+				)
+            {
+            origin = EVcxMyVideosOriginOther;
+            }
+
+#endif
         aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, origin );
         }
 
@@ -992,18 +1060,7 @@
         
         aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos );
         }
-
-    //18. DOWNLOAD ID (BRIEF)
-    if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
-        {
-        aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId,
-                static_cast<CMdEUint32Property*>(property)->Value() );
-        }
-    else
-        {
-        aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-        }
-
+    
     //19. RATING (FULL)
     if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound
             && aFullDetails )
@@ -1136,10 +1193,8 @@
         }
 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
 
-#if 1
     // 6. KMPXMediaGeneralDate ( creation date )
     SetCreationDateToObjectL( aVideo, aObject );
-#endif
     
     // 7. KMPXMediaGeneralFlags (including DRM flag)
     if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) )
@@ -1336,6 +1391,7 @@
             
             static_cast<CMdEUint32Property*>(property)->SetValueL( flags );
             }
+        
         if ( aObject.Property( *iLastPlayPositionPropertyDef, property, 0 ) != KErrNotFound )
             {
             static_cast<CMdEReal32Property*>(property)->SetValueL( lastPlaybackPos );
@@ -1346,21 +1402,6 @@
             }
         }
     
-    // 18. DOWNLOAD ID
-    if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadId ) )
-        {
-        TUint32 dlId = aVideo.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
-        
-        if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound )
-            {
-            static_cast<CMdEUint32Property*>(property)->SetValueL( dlId );
-            }
-        else
-            {
-            aObject.AddUint32PropertyL( *iDownloadIdPropertyDef, dlId );
-            }
-        }
-
     // 19. RATING
     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
         {
@@ -1526,9 +1567,9 @@
     iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
             KVcxRatingPropertyName )); //19
     iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
-            KVcxBitratePropertyName )); //20
+                KVcxBitratePropertyName )); //20
     iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
-            KVcxAudioFourCcPropertyName )); //21
+                KVcxAudioFourCcPropertyName )); //21
     iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
             KVcxWidthPropertyName )); //22
     iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
@@ -1548,10 +1589,7 @@
 
     iAudioLanguagePropertyDef = &(iVideoObjectDef->GetPropertyDefL(
             KVcxAudioLanguagePropertyName )); //14
-
-    iDownloadIdPropertyDef = &(iVideoObjectDef->GetPropertyDefL(
-            KVcxDownloadIdPropertyName )); //18
-
+    
     }
 
 // ---------------------------------------------------------------------------
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosmessagelist.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosmessagelist.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -106,7 +106,7 @@
     MPX_DEBUG1("CVcxMyVideosMessageList:: ----------------------------------------------'" );
 #endif
     
-    if ( AlreadyInMessageListL( aId, aChange, aExtraInfo ) )
+    if ( aChange == EMPXItemModified && AlreadyInMessageListL( aId, aChange, aExtraInfo ) )
         {
         MPX_DEBUG1("CVcxMyVideosMessageList:: already in message list, skipping add");
         return;
@@ -130,7 +130,7 @@
         {
         message->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value, aExtraInfo );
         }
-        
+    
     MPX_DEBUG1("CVcxMyVideosMessageList:: appending to message array");
     
     iMessageArray->AppendL( message ); // ownership moves
@@ -189,6 +189,24 @@
                     {
                     extraInfo = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
                     }
+                    
+                if ( extraInfo == EVcxMyVideosVideoListOrderChanged &&
+                        aExtraInfo == 0 )
+                    {
+                    MPX_DEBUG1("CVcxMyVideosMessageList:: found similar message with EVcxMyVideosVideoListOrderChanged flag set, discarding this msg");
+                    return ETrue;
+                    }
+                
+                if ( aExtraInfo == EVcxMyVideosVideoListOrderChanged &&
+                       extraInfo == 0 )
+                    {
+                    MPX_DEBUG1("CVcxMyVideosMessageList:: Turning the EVcxMyVideosVideoListOrderChanged flag on to the previous message");
+                    MPX_DEBUG1("CVcxMyVideosMessageList:: and discarding this.");
+                    media->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value,
+                            EVcxMyVideosVideoListOrderChanged );
+                    return ETrue;
+                    }
+                     
                 if ( aExtraInfo == extraInfo )
                     {
                     return ETrue;
@@ -271,7 +289,7 @@
 //
 void CVcxMyVideosMessageList::SendL()
     {
-    MPX_FUNC("CVcxMyVideosMessageList::SendL()");
+    MPX_DEBUG1("CVcxMyVideosMessageList::SendL");
     
     if ( iMessageCount == 0 || !iMessageList )
         {
@@ -299,9 +317,7 @@
 
         iMessageList->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KVcxCommandIdMyVideos);
         iMessageList->SetTObjectValueL<TInt>(KVcxMediaMyVideosCommandId, KVcxMessageMyVideosMessageArray );
-        iMessageList->SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));        
-        //iMessageList->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, aChange);        
-        //iMessageList->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, TMPXItemId(0, 0) );
+        iMessageList->SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection));
         iMessageCount = 0;
         }
     }
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosopenhandler.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosopenhandler.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -11,11 +11,11 @@
 *
 * Contributors:
 *
-* Description:   Handles collection Open operation related functionality.*
+* Description:  Handles collection Open operation related functionality.
+*
 */
 
 
-
 // INCLUDE FILES
 #include <e32base.h>
 #include <mpxlog.h>
@@ -31,6 +31,8 @@
 #include "vcxmyvideoscategories.h"
 #include "vcxmyvideosmessagelist.h"
 #include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosalbums.h"
+#include "vcxmyvideosmdsalbums.h"
 
 // ============================ MEMBER FUNCTIONS =============================
 
@@ -52,6 +54,9 @@
 void CVcxMyVideosOpenHandler::ConstructL()
     {
     iCategoryIdsBeingOpened.Reset();
+    iVideoListsBeingOpened.Reset();
+    iAlbumIdsBeingOpened.Reset();
+    iAlbumVideoListsBeingOpened.Reset();
     }
 
 // ---------------------------------------------------------------------------
@@ -85,6 +90,16 @@
         iVideoListsBeingOpened[i] = NULL; 
         }
     iVideoListsBeingOpened.Close();
+
+    iAlbumIdsBeingOpened.Close();
+    
+    count = iAlbumVideoListsBeingOpened.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        delete iAlbumVideoListsBeingOpened[i];
+        iAlbumVideoListsBeingOpened[i] = NULL; 
+        }
+    iAlbumVideoListsBeingOpened.Close();    
     }
 
 // ---------------------------------------------------------------------------
@@ -99,114 +114,89 @@
     MPX_DEBUG1("CVcxMyVideosOpenHandler:: path before open:");
     MPX_DEBUG_PATH( aPath );
 
+    iPath = &aPath;
+    
+    const TInt categoryLevel = 1;
+    const TInt videosLevel   = 2;
+    const TInt playlistLevel = 3;
+    
     switch ( aPath.Levels() )
         {
-        case 1:
+        case categoryLevel:
             {
-            //we are at root level, return main level items (categories)
-            
-            // this is needed to update category counters
+            //we are at root level, return main level items (categories + albums)
+
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92            
+            iCollection.AlbumsL().CreateAlbumListL(); //async
+#endif
+
+            // This is needed to update category counters.
+            // Goes to queue if CreateAlbumListL command goes to execution
             TRAPD( err, iCache.CreateVideoListL() );
             
             if ( err != KErrNone )
                 {
-                MPX_DEBUG2("iCache->CreateVideoListL() left: %d. Returning categories anyway.", err);
+                MPX_DEBUG2("iCache->CreateVideoListL() left: %d. Returning categories and albums anyway.", err);
                 }
             
-            iCollection.CategoriesL().iList->
-                        SetTObjectValueL<TBool>( KVcxMediaMyVideosVideoListIsPartial,
-                        iCache.iVideoListIsPartial );
-
-            iCollection.iObs->HandleOpen( iCollection.CategoriesL().iList, KErrNone );
+            CMPXMedia* itemList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+            CleanupStack::PushL( itemList );
+            
+            itemList->SetTObjectValueL<TBool>( KVcxMediaMyVideosVideoListIsPartial,
+                !iCache.IsComplete() );
+                
+            TVcxMyVideosCollectionUtil::AppendToListL( *itemList, *iCollection.CategoriesL().iList );
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            TVcxMyVideosCollectionUtil::AppendToListL( *itemList, *iCollection.AlbumsL().iAlbumList );
+#endif
+            itemList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+            iCollection.iObs->HandleOpen( itemList, KErrNone );
+            CleanupStack::PopAndDestroy( itemList );
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: called HandleOpen for categories + albums");
             }
             break;
 
-        case 2:
+        case videosLevel:
             {
-            //we are at second level, return video list from some category
+            //we are at second level, return video list from some category or album
 
-            TInt categoryId = aPath.Id();
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+            iCollection.AlbumsL().CreateAlbumListL(); //async
+#endif
 
-            MPX_DEBUG2("CVcxMyVideosOpenHandler:: opening category %d", categoryId);
+            TMPXItemId categoryId( aPath.Id() );
             
-            if ( categoryId != KVcxMvcCategoryIdAll &&
-                 categoryId != KVcxMvcCategoryIdDownloads &&
-                 categoryId != KVcxMvcCategoryIdTvRecordings &&
-                 categoryId != KVcxMvcCategoryIdCaptured &&
-                 categoryId != KVcxMvcCategoryIdOther )
+            if ( ( categoryId.iId2 == KVcxMvcMediaTypeCategory ) ||
+                    ( categoryId.iId2 == KVcxMvcMediaTypeVideo ) && 
+                 (categoryId.iId1 == KVcxMvcCategoryIdAll ||
+                 categoryId.iId1 == KVcxMvcCategoryIdDownloads ||
+                 categoryId.iId1 == KVcxMvcCategoryIdTvRecordings ||
+                 categoryId.iId1 == KVcxMvcCategoryIdCaptured ||
+                 categoryId.iId1 == KVcxMvcCategoryIdOther) )
                 {
-                MPX_DEBUG2("CVcxMyVideosOpenHandler:: category ID not valid (%d) -> calling HandleOpen with KErrNotFound", categoryId);
-                iCollection.iObs->HandleOpen( static_cast<CMPXMedia*>(NULL), KErrNotFound );
+                MPX_DEBUG2("CVcxMyVideosOpenHandler:: opening category %d", categoryId.iId1 );
+                OpenCategoryL( categoryId.iId1 );
                 return;
                 }
-
-            TUint8 origin = static_cast<TUint8>( TVcxMyVideosCollectionUtil::Origin( categoryId ) );
-
-            iCache.CreateVideoListL(); // Causes async call to MDS, callbacks to DoHandleCreateVideoListRespL will happen.
-                                       // If iCache.iVideoList is complete and can be used (correct sorting order),
-                                       // then nothing is done.
-
-            if ( !iCache.iVideoListIsPartial )
+            else
                 {
-                MPX_DEBUG1("CVcxMyVideosOpenHandler:: videolist complete");
-
-                // iCache.iVideoList is complete
-                if ( categoryId == KVcxMvcCategoryIdAll )
+                MPX_DEBUG2("CVcxMyVideosOpenHandler:: opening album %d", categoryId.iId1 );
+                
+                iPendingAlbumOpenId = categoryId.iId1;
+                if ( iCollection.AlbumsL().iAlbumListIsComplete ) 
                     {
-                    MPX_DEBUG1("CVcxMyVideosOpenHandler:: KVcxMvcCategoryIdAll: calling HandleOpen(iCache.iVideoList)");
-                    iCollection.iObs->HandleOpen( iCache.iVideoList, KErrNone );                    
+                    HandleAlbumOpenL(); // iPendingAlbumOpenId goes to 0
+                    return;
                     }
                 else
                     {
-                    MPX_DEBUG1("CVcxMyVideosOpenHandler:: other than KVcxMvcCategoryIdAll: creating new category video list");
-                    CMPXMedia* videoList = iCache.CreateVideoListByOriginL( origin );
-                    MPX_DEBUG1("CVcxMyVideosOpenHandler:: calling HandleOpen(new list)");
-                    iCollection.iObs->HandleOpen( videoList, KErrNone );
-                    delete videoList;
-                    }
-                iCollection.iMessageList->AddEventL( KVcxMessageMyVideosListComplete );
-                iCollection.iMessageList->SendL();
-
-                // No append events will arrive anymore -> we create our own version of the
-                // video list.
-                iCache.ReCreateVideoListL();
-                }
-            else
-                {
-                MPX_DEBUG1("CVcxMyVideosOpenHandler:: video list incomplete");
-                // iCache.iVideoList is incomplete                
-
-                if ( categoryId == KVcxMvcCategoryIdAll )
-                    {
-                    MPX_DEBUG1("CVcxMyVideosOpenHandler:: KVcxMvcCategoryIdAll, calling HandleOpen");
-                    iCollection.iObs->HandleOpen( iCache.iVideoList, KErrNone  );
+                    // We will continue at HandleAlbumOpenL when album list arrives, iPendingAlbumOpenId is left != 0
+                    return;
                     }
-                else
-                    {   
-                    MPX_DEBUG1("CVcxMyVideosOpenHandler:: other than KVcxMvcCategoryIdAll");
+                }            
+            }
 
-                    TInt pos = iCategoryIdsBeingOpened.Find( categoryId );
-                    if ( pos == KErrNotFound )
-                        {
-                        MPX_DEBUG1("CVcxMyVideosOpenHandler:: category was not opened yet, creating list for it");
-                        iCategoryIdsBeingOpened.AppendL( categoryId ); 
-                        CMPXMedia* videoList = iCache.CreateVideoListByOriginL( origin );
-                        iVideoListsBeingOpened.AppendL( videoList );
-                        MPX_DEBUG1("CVcxMyVideosOpenHandler:: calling HandleOpen");
-                        iCollection.iObs->HandleOpen( iCache.iVideoList, KErrNone  );
-                        }
-                    else
-                        {
-                        MPX_DEBUG1("CVcxMyVideosOpenHandler:: category was already being opened, calling HandleOpen with that");                        
-                        iCollection.iObs->HandleOpen( iVideoListsBeingOpened[pos], KErrNone  );
-                        }
-                    }
-                }
-
-            }
-            break;
-
-        case 3:
+        case playlistLevel:
 			{
 			iCollection.iObs->HandleOpen(const_cast<CMPXCollectionPath*> (&aPath), KErrNone);
 			}
@@ -218,14 +208,95 @@
         } //switch
     }
 
+// ---------------------------------------------------------------------------
+// CVcxMyVideosOpenHandler::OpenCategoryL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosOpenHandler::OpenCategoryL( TUint32 aCategoryId )
+    {
+    TUint8 origin = static_cast<TUint8>( TVcxMyVideosCollectionUtil::Origin( aCategoryId ) );
+
+    iCache.CreateVideoListL(); // Causes async call to MDS, callbacks to DoHandleCreateVideoListRespL will follow.
+                               // If iCache.iVideoList is complete and can be used (correct sorting order),
+                               // then nothing is done.
+
+    if ( iCache.IsComplete() )
+        {
+        MPX_DEBUG1("CVcxMyVideosOpenHandler:: videolist complete");
+
+        // iCache.iVideoList is complete
+        if ( aCategoryId == KVcxMvcCategoryIdAll )
+            {
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: KVcxMvcCategoryIdAll: calling HandleOpen(iCache.iVideoList)");
+            iCache.iVideoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+            iCache.iVideoList->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
+                    EVcxMyVideosVideoListComplete );
+            iCollection.iObs->HandleOpen( iCache.iVideoList, KErrNone );                    
+            }
+        else
+            {
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: other than KVcxMvcCategoryIdAll: creating new category video list");
+            CMPXMedia* videoList = iCache.CreateVideoListByOriginL( origin );
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: calling HandleOpen(new list)");
+            videoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+            videoList->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
+                    EVcxMyVideosVideoListComplete );
+            iCollection.iObs->HandleOpen( videoList, KErrNone );
+            delete videoList;
+            }
+        iCollection.iMessageList->AddEventL( KVcxMessageMyVideosListComplete );
+        iCollection.iMessageList->SendL();
+
+        // No append events will arrive anymore -> we create our own version of the
+        // video list.
+        iCache.ReCreateVideoListL();
+        }
+    else
+        {
+        MPX_DEBUG1("CVcxMyVideosOpenHandler:: video list incomplete");
+        // iCache.iVideoList is incomplete                
+
+        if ( aCategoryId == KVcxMvcCategoryIdAll )
+            {
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: KVcxMvcCategoryIdAll, calling HandleOpen");
+            iCache.iVideoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+            iCollection.iObs->HandleOpen( iCache.iVideoList, KErrNone  );
+            }
+        else
+            {   
+            MPX_DEBUG1("CVcxMyVideosOpenHandler:: other than KVcxMvcCategoryIdAll");
+
+            TInt pos = iCategoryIdsBeingOpened.Find( aCategoryId );
+            if ( pos == KErrNotFound )
+                {
+                MPX_DEBUG1("CVcxMyVideosOpenHandler:: category was not opened yet, creating list for it");
+                iCategoryIdsBeingOpened.AppendL( aCategoryId ); 
+                CMPXMedia* videoList = iCache.CreateVideoListByOriginL( origin );
+                CleanupStack::PushL( videoList );
+                iVideoListsBeingOpened.AppendL( videoList );
+                CleanupStack::Pop( videoList );
+                MPX_DEBUG1("CVcxMyVideosOpenHandler:: calling HandleOpen");
+                videoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+                iCollection.iObs->HandleOpen( videoList, KErrNone  );
+                }
+            else
+                {
+                MPX_DEBUG1("CVcxMyVideosOpenHandler:: category was already being opened, calling HandleOpen with that");                        
+                iVideoListsBeingOpened[pos]->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+                iCollection.iObs->HandleOpen( iVideoListsBeingOpened[pos], KErrNone  );
+                }
+            }
+        }
+    }
+
 // ----------------------------------------------------------------------------
 // CVcxMyVideosOpenHandler::DoHandleCreateVideoListRespL
-// New items fetched from MDS. iCache.iVideoList = aVideoList.
+// New items fetched from MDS. iCollection.iCache->iVideoList = &aVideoList.
 // ----------------------------------------------------------------------------
 //
 void CVcxMyVideosOpenHandler::DoHandleCreateVideoListRespL(
         CMPXMedia* aVideoList, TInt aNewItemsStartIndex, TBool aComplete )
-    {
+    {    
     MPX_FUNC("CVcxMyVideosOpenHandler::DoHandleCreateVideoListRespL()");
 
     MPX_DEBUG2("CVcxMyVideosOpenHandler:: aComplete = %d", aComplete);
@@ -237,29 +308,36 @@
         }
 
     // Append new items to category video lists. All category is using iCache.iVideoList, thus no need to append to it.
-    TInt count = iCategoryIdsBeingOpened.Count();
-    for ( TInt i = 0; i < count; i++ )
+    TInt categoryCount = iCategoryIdsBeingOpened.Count();
+    for ( TInt i = 0; i < categoryCount; i++ )
         {
         iCache.AppendToListL( *iVideoListsBeingOpened[i], *aVideoList,
                 TVcxMyVideosCollectionUtil::Origin( iCategoryIdsBeingOpened[i] ),
                 aNewItemsStartIndex );
         }
-            
+
+    // Append new items to album video lists.
+    TInt albumCount = iAlbumVideoListsBeingOpened.Count();
+    for ( TInt i = 0; i < albumCount; i++ )
+        {
+        iCollection.iAlbums->Album( iAlbumIdsBeingOpened[i] )->AppendToVideoListL(
+                *aVideoList, *(iAlbumVideoListsBeingOpened[i]), aNewItemsStartIndex );
+        }
+
     if ( aComplete == 0 )
         {
         iCollection.iMessageList->AddEventL( KVcxMessageMyVideosItemsAppended );
 
         // Still fetching items
-        // Missing download fields filled from download manager
-        TRAP_IGNORE( iCollection.SyncVideoListWithDownloadsL( *(iCache.iVideoList),
-                EFalse /* dont send events */, aNewItemsStartIndex ); ); 
         iCollection.CategoriesL().UpdateCategoriesL( *aVideoList, aNewItemsStartIndex );
         }                           
     else
         {
         // End event arrived
         
-        iCache.iVideoListIsPartial = EFalse;
+        iCache.SetComplete( ETrue );
+        iCache.iIsFetchingVideoList = EFalse;
+        
 
         // Create modify event for All category.
         // This will cause client to make a new OpenL() call.
@@ -271,7 +349,7 @@
                 EVcxMyVideosVideoListOrderChanged );
         // We dont send here, the send is at the end of this function.
 
-        for ( TInt i = 0; i < count; i++ )
+        for ( TInt i = 0; i < categoryCount; i++ )
             {
             // Create modify event for other than All categories.
             // This will cause client to make a new OpenL() call.
@@ -288,14 +366,184 @@
         iVideoListsBeingOpened.Reset();
         iCategoryIdsBeingOpened.Reset();
 
-        // all category, lets delete our copy and start using new one, this gives the full ownership to client
+        for ( TInt i = 0; i < albumCount; i++ )
+            {
+            // Create modify event for albums.
+            // This will cause client to make a new OpenL() call.
+            // Also this causes collection framework to purge its possibly outdated
+            // (KVcxMessageMyVideosItemsAppended events don't update collection frameworks cache) cache.
+            MPX_DEBUG3("CVcxMyVideosOpenHandler:: adding modify event for album %d, extra info = %d",
+                    iAlbumIdsBeingOpened[i], EVcxMyVideosVideoListOrderChanged );
+            iCollection.iMessageList->AddEventL(
+                    TMPXItemId( iAlbumIdsBeingOpened[i], KVcxMvcMediaTypeAlbum ),
+                    EMPXItemModified, EVcxMyVideosVideoListOrderChanged );
+            // We dont send here, the send is at the end of this function.
+            delete iAlbumVideoListsBeingOpened[i]; // we can delete our copy, client has its own copy
+            iAlbumVideoListsBeingOpened[i] = NULL;
+            }
+        iAlbumVideoListsBeingOpened.Reset();
+        iAlbumIdsBeingOpened.Reset();
+        
+        // All category, lets delete our copy and start using new one, this gives the full
+        // ownership of the list to client. Video objects will continue to point to the same shared data.
         iCache.ReCreateVideoListL();
 
         iCollection.CategoriesL().UpdateCategoriesNewVideoNamesL();
 
+        iCollection.AlbumsL().CalculateAttributesL();
+        
         iCollection.iMessageList->AddEventL( KVcxMessageMyVideosListComplete );
         }
     iCollection.iMessageList->SendL();
     }
 
+// ----------------------------------------------------------------------------
+// CVcxMyVideosOpenHandler::HandleAlbumOpenL
+// Album list has been fetched already.
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosOpenHandler::HandleAlbumOpenL()
+    {
+    MPX_DEBUG1("CVcxMyVideosOpenHandler::HandleAlbumOpenL() start");
+    
+    CVcxMyVideosAlbum* album = iCollection.AlbumsL().Album( iPendingAlbumOpenId );
+    if ( album )
+        {
+        if ( iCollection.iCache->IsComplete() )
+            {
+            //videolist complete
+            CMPXMedia* videoList = album->CreateVideoListL();
+            CleanupStack::PushL( videoList ); // 1->
+            videoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+            videoList->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
+                    EVcxMyVideosVideoListComplete ); 
+            iCollection.iObs->HandleOpen( videoList, KErrNone );
+            CleanupStack::PopAndDestroy( videoList ); // <-1
+            iCollection.iMessageList->AddEventL( KVcxMessageMyVideosListComplete );
+            iCollection.iMessageList->SendL();
+            }
+        else
+            {
+            if ( iCollection.iCache->iIsFetchingVideoList )
+                {
+                MPX_DEBUG1("CVcxMyVideosOpenHandler:: videolist fetching already in progress -> use that to populate album");
+
+                // videolist incomplete and fetching already going on
+                TInt pos = iAlbumIdsBeingOpened.Find( iPendingAlbumOpenId );
+                if ( pos == KErrNotFound )
+                    {
+                    //store video list for append events
+                    CMPXMedia* videoList = album->CreateVideoListL();
+                    CleanupStack::PushL( videoList );
+                    iAlbumVideoListsBeingOpened.AppendL( videoList );
+                    CleanupStack::Pop( videoList );
+                    iAlbumIdsBeingOpened.AppendL( iPendingAlbumOpenId );
+                    videoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+                    iCollection.iObs->HandleOpen( videoList, KErrNone );
+                    }
+                else
+                    {
+                    //video list already stored
+                    iAlbumVideoListsBeingOpened[pos]->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+                    iCollection.iObs->HandleOpen( iAlbumVideoListsBeingOpened[pos],
+                            KErrNone );
+                    }
+                }
+            else
+                {
+                MPX_DEBUG1("CVcxMyVideosOpenHandler:: videolist partial and no fetching going on -> fetch the album videos separately");
+
+                delete iAlbumVideoList;
+                iAlbumVideoList = NULL;
+                iAlbumVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+                iCollection.iMyVideosMdsDb->iAlbums->GetAlbumContentVideosL( iPendingAlbumOpenId,
+                        *iAlbumVideoList, *this );
+                return;
+                }
+            }
+        }
+    else
+        {
+        MPX_DEBUG2("CVcxMyVideosOpenHandler:: album ID not valid (%d) -> calling HandleOpen with KErrNotFound",
+                iPendingAlbumOpenId);
+        iCollection.iObs->HandleOpen( static_cast<CMPXMedia*>(NULL), KErrNotFound );
+        }
+    iPendingAlbumOpenId = 0;
+
+    MPX_DEBUG1("CVcxMyVideosOpenHandler::HandleAlbumOpenL() exit");
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosResp
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosResp(
+        TUint32 aAlbumId, CMPXMedia& aVideoList, TInt aError,
+        TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete )
+    {
+    TRAPD( err, HandleGetAlbumContentVideosRespL( aAlbumId, aVideoList, aError,
+            aFirstNewItemIndex, aNewItemCount, aComplete ));
+    if ( err != KErrNone )
+        {
+        MPX_DEBUG2("CVcxMyVideosOpenHandler:: HandleGetAlbumContentVideosRespL leaved: %d", err);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosRespL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosRespL(
+        TUint32 aAlbumId, CMPXMedia& /*aVideoList*/, TInt aError,
+        TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/, TBool aComplete )
+    {
+    MPX_DEBUG1("CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosRespL() start");
+    
+    if ( aError != KErrNone )
+        {
+        MPX_DEBUG2("CVcxMyVideosOpenHandler:: error %d occured when fetching album videos", aError );        
+        }
+    
+    MPX_DEBUG3("CVcxMyVideosOpenHandler:: iPendingAlbumOpenId = %d, aAlbumId = %d", iPendingAlbumOpenId, aAlbumId );
+    
+    if ( iPendingAlbumOpenId == aAlbumId )
+        {
+        MPX_DEBUG2("CVcxMyVideosOpenHandler:: First videos for album %d arrived, calling HandleOpen()", aAlbumId);
+        
+        iAlbumVideoList->SetCObjectValueL( KMPXMediaGeneralContainerPath, iPath );
+        if ( aComplete )
+            {
+            iAlbumVideoList->SetTObjectValueL<TInt>( KVcxMediaMyVideosInt32Value,
+                    EVcxMyVideosVideoListComplete );
+            }
+        iCollection.iObs->HandleOpen( iAlbumVideoList, aError );
+        iPendingAlbumOpenId = 0;
+        }
+
+    if ( !aComplete )
+        {
+        iCollection.iMessageList->AddEventL( KVcxMessageMyVideosItemsAppended );
+
+        MPX_DEBUG3("CVcxMyVideosOpenHandler:: adding modify event for album %d, extra info = %d",
+                aAlbumId, EVcxMyVideosVideoListOrderChanged );
+        iCollection.iMessageList->AddEventL( TMPXItemId( aAlbumId, 2 ), EMPXItemModified,
+                EVcxMyVideosVideoListOrderChanged );
+        }
+    else
+        {
+        //TODO: should add album id
+        iCollection.AlbumsL().CalculateAttributesL();
+
+        iCollection.iMessageList->AddEventL( KVcxMessageMyVideosListComplete );
+
+        
+        delete iAlbumVideoList;
+        iAlbumVideoList = NULL;
+        }
+    
+    iCollection.iMessageList->SendL();
+    
+    MPX_DEBUG1("CVcxMyVideosOpenHandler::HandleGetAlbumContentVideosRespL() exit");
+    }
+
 // END OF FILE
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideostimer.cpp	Tue May 25 12:44:54 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +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 the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:    General purpose timer*
-*/
-
-
-
-
-
-// INCLUDE FILES
-#include "vcxmyvideostimer.h"
-
-// ========================= MEMBER FUNCTIONS ==================================
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::NewL()
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CVcxMyVideosTimer* CVcxMyVideosTimer::NewL(const TInt aPriority,
-                                      MVcxMyVideosTimerObserver& aTimerObserver)
-    {
-    CVcxMyVideosTimer* self = CVcxMyVideosTimer::NewLC(aPriority, aTimerObserver );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::NewLC()
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CVcxMyVideosTimer* CVcxMyVideosTimer::NewLC(const TInt aPriority,
-                                       MVcxMyVideosTimerObserver& aTimerObserver)
-    {
-    CVcxMyVideosTimer* self = new ( ELeave ) CVcxMyVideosTimer(aPriority, aTimerObserver);
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::CVcxMyVideosTimer()
-// C++ default constructor can NOT contain any code, that might leave.
-// -----------------------------------------------------------------------------
-//
-CVcxMyVideosTimer::CVcxMyVideosTimer(const TInt aPriority,
-                                MVcxMyVideosTimerObserver& aTimerObserver)
-: CTimer( aPriority ), iObserver( aTimerObserver )
-    {
-    // No implementation required
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::ConstructL()
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosTimer::ConstructL()
-    {
-    CTimer::ConstructL();
-    CActiveScheduler::Add( this );
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::~CVcxMyVideosTimer()
-// Destructor.
-// -----------------------------------------------------------------------------
-//
-CVcxMyVideosTimer::~CVcxMyVideosTimer()
-    {
-    // No implementation required
-    }
-
-// -----------------------------------------------------------------------------
-// CVcxMyVideosTimer::RunL()
-// Called when operation completes.
-// -----------------------------------------------------------------------------
-//
-void CVcxMyVideosTimer::RunL()
-    {
-    // Timer request has completed, so notify the timer's owner
-    if ( iStatus == KErrNone )
-        {
-        iObserver.TimerExpired( this );
-        }
-    }
-
-// End of File
--- a/videocollection/mpxmyvideoscollection/src/vcxmyvideosvideocache.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosvideocache.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:    Video list cache. Contains cached data from MDS.*
+* Description:   Video list cache. Contains cached data from MDS.*
 */
 
 
@@ -30,19 +30,230 @@
 #include <mpxmediavideodefs.h>
 #include "vcxmyvideosvideocache.h"
 #include "vcxmyvideoscollectionplugin.h"
-#include "vcxmyvideosdownloadutil.h"
 #include "vcxmyvideoscollectionutil.h"
 #include "vcxmyvideoscategories.h"
-#include "vcxmyvideosdownloadcache.h"
 #include "vcxmyvideosmessagelist.h"
 #include "vcxmyvideosopenhandler.h"
-
-//       If video list fetching is going on and at the same time add/delete events
-//       arrive from mds, what to do?
+#include "vcxmyvideosalbums.h"
 
 // ============================ MEMBER FUNCTIONS ==============================
 
 // ----------------------------------------------------------------------------
+// constructor.
+// ----------------------------------------------------------------------------
+//
+TVcxMyVideosVideo::TVcxMyVideosVideo()
+:iMdsId( 0 ), iVideo( NULL ), iPos( KErrNotFound )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// TVcxMyVideosVideo::operator=
+// ---------------------------------------------------------------------------
+//                
+TVcxMyVideosVideo& TVcxMyVideosVideo::operator=( const TVcxMyVideosVideo& aVideo )
+    {
+    Set( aVideo.iMdsId, aVideo.iPos, aVideo.iVideo );
+    return *this;
+    }
+
+// ----------------------------------------------------------------------------
+// TVcxMyVideosVideo::Set
+// ----------------------------------------------------------------------------
+//
+void TVcxMyVideosVideo::Set( TUint32 aMdsId, TInt aPos, CMPXMedia* aVideo )
+    {
+    iMdsId = aMdsId;
+    iPos   = aPos;
+    iVideo = aVideo;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::NewL
+// ----------------------------------------------------------------------------
+//
+CVcxMyVideosVideoListIndex* CVcxMyVideosVideoListIndex::NewL()
+    {
+    CVcxMyVideosVideoListIndex* self = new (ELeave) CVcxMyVideosVideoListIndex();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::CVcxMyVideosVideoListIndex
+// ----------------------------------------------------------------------------
+//
+CVcxMyVideosVideoListIndex::CVcxMyVideosVideoListIndex()
+    {
+    
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoListIndex::ConstructL ()
+    {
+    iVideoArray.Reset();
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex
+// ----------------------------------------------------------------------------
+//
+CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex()
+    {
+    iVideoArray.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoListIndex::SetL( const CMPXMedia& aVideoList )
+    {
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( aVideoList );
+    TInt count = mediaArray->Count();
+    iVideoArray.Reset();
+    iVideoArray.ReserveL( count );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        AddL( mediaArray->AtL( i ), i );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::Find
+// ----------------------------------------------------------------------------
+//
+TInt CVcxMyVideosVideoListIndex::Find( TUint32 aMdsId, TVcxMyVideosVideo& aVideo )
+    {
+    const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId(
+            CVcxMyVideosVideoListIndex::CompareVideosByMdsId );
+    
+    TInt index;
+    TVcxMyVideosVideo video;
+    video.iMdsId = aMdsId;
+    TInt err = iVideoArray.FindInOrder( video, index, KOrderByMdsId );
+    
+    if ( err != KErrNone )
+        {
+        return KErrNotFound;
+        }
+    
+    aVideo = iVideoArray[index];
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::Remove
+// ----------------------------------------------------------------------------
+//
+TInt CVcxMyVideosVideoListIndex::Remove( TUint32 aMdsId, TBool aCompress )
+    {
+    const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId(
+            CVcxMyVideosVideoListIndex::CompareVideosByMdsId );
+
+    TVcxMyVideosVideo video;
+    video.iMdsId = aMdsId;
+    TInt pos;
+    TInt posInVideoList;
+    TInt err = iVideoArray.FindInOrder( video, pos, KOrderByMdsId );
+    if ( err == KErrNone )
+        {
+        posInVideoList = iVideoArray[pos].iPos;
+        iVideoArray.Remove( pos );
+
+        // update all indexes which are bigger than posInVideoList
+        TInt count = iVideoArray.Count();
+        for ( TInt i = 0; i < count; i++ )
+            {
+            if ( iVideoArray[i].iPos > posInVideoList )
+                {
+                iVideoArray[i].iPos--;
+                }
+            }
+        }
+    
+    if ( aCompress )
+        {
+        iVideoArray.Compress();
+        }
+    
+    return err;
+    }
+    
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::AddL
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoListIndex::AddL( CMPXMedia* aVideo, TInt aPos )
+    {
+    TVcxMyVideosVideo video;
+    video.Set( TVcxMyVideosCollectionUtil::IdL( *aVideo ).iId1, aPos, aVideo );
+
+    const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId(
+            CVcxMyVideosVideoListIndex::CompareVideosByMdsId );
+
+    // update indexes
+    TInt count = iVideoArray.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( iVideoArray[i].iPos >= aPos )
+            {
+            iVideoArray[i].iPos++;
+            }
+        }
+
+    iVideoArray.InsertInOrderAllowRepeatsL( video, KOrderByMdsId );
+
+    }
+
+#ifdef _DEBUG
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::VideoArray
+// ----------------------------------------------------------------------------
+//
+const RArray<TVcxMyVideosVideo>& CVcxMyVideosVideoListIndex::VideoArray()
+    {
+    return iVideoArray;
+    }
+#endif
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::Sort
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoListIndex::Sort()
+    {
+    const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId(
+            CVcxMyVideosVideoListIndex::CompareVideosByMdsId );
+
+    iVideoArray.Sort( KOrderByMdsId );    
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoListIndex::CompareVideosByMdsId
+// ----------------------------------------------------------------------------
+//
+TInt CVcxMyVideosVideoListIndex::CompareVideosByMdsId( const TVcxMyVideosVideo& aVideo1,
+            const TVcxMyVideosVideo& aVideo2 )
+    {
+    if ( aVideo1.iMdsId == aVideo2.iMdsId )
+        {
+        return 0;
+        }
+
+    if ( aVideo1.iMdsId < aVideo2.iMdsId )
+        {
+        return -1;
+        }
+    return 1;    
+    }
+
+// ----------------------------------------------------------------------------
 // Two-phased constructor.
 // ----------------------------------------------------------------------------
 //
@@ -67,10 +278,8 @@
     MPX_FUNC("CVcxMyVideosVideoCache::~CVcxMyVideosVideoCache");
     
     delete iVideoList;
-    delete iDownloadCache;
-    delete iCenRep;
-    
     DeletePartialList();
+    delete iVideoListIndex;
     }
 
 // ----------------------------------------------------------------------------
@@ -93,10 +302,10 @@
     MPX_FUNC("CVcxMyVideosVideoCache::ConstructL");
 
     iVideoList          = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
-    iVideoListIsPartial = ETrue;
-
-    iDownloadCache = CVcxMyVideosDownloadCache::NewL();
+    SetComplete( EFalse );
+    
     iPartialVideoList.Reset();
+    iVideoListIndex = CVcxMyVideosVideoListIndex::NewL();
     }
 
 // ----------------------------------------------------------------------------------------------------------
@@ -219,7 +428,19 @@
         {
         return NULL;
         }
-        
+    
+    if ( IsComplete() )
+        {
+        TVcxMyVideosVideo video;
+        TInt pos = iVideoListIndex->Find( aMdsId, video );
+        if ( pos != KErrNotFound )
+            {
+            aPos = video.iPos;
+            MPX_DEBUG2("CVcxMyVideosVideoCache::FindVideoByMdsIdL found %d from index", aMdsId );
+            return video.iVideo;
+            }
+        }
+    
     CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>(
                                 KMPXMediaArrayContents);
    
@@ -260,76 +481,10 @@
     }
 
 // ----------------------------------------------------------------------------
-// CVcxMyVideosVideoCache::FindVideoByDownloadIdL
-// ----------------------------------------------------------------------------
-//
-CMPXMedia* CVcxMyVideosVideoCache::FindVideoByDownloadIdL( TUint aDownloadId )
-    {
-    MPX_FUNC("CVcxMyVideosVideoCache::FindVideoByDownloadIdL()");
-    
-    MPX_DEBUG2("CVcxMyVideosVideoCache:: looking for MPX item  with download ID %d from cache", aDownloadId);
-        
-    if ( aDownloadId == 0 )
-        {
-        MPX_DEBUG1("CVcxMyVideosVideoCache:: dl id == 0 -> NOT FOUND");
-        return NULL;
-        }
-    
-    if ( !iVideoList )
-        {
-        MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is NULL -> NOT FOUND");
-        return NULL;
-        }
-
-    CMPXMedia* video = iDownloadCache->Get( aDownloadId );
-    if ( video )
-        {
-        MPX_DEBUG1("CVcxMyVideosVideoCache:: found from Download Cache");
-        return video;
-        }
-
-    MPX_DEBUG1("CVcxMyVideosVideoCache:: not found from Download Cache");
-
-    CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>(
-                                KMPXMediaArrayContents);
-              
-    TUint32 downloadId;
-    TInt count = cachedVideoArray->Count();
-    for ( TInt i = 0; i < count; i++ )
-        {
-        downloadId = TVcxMyVideosCollectionUtil::DownloadIdL( *cachedVideoArray->AtL( i ) );
-        if ( downloadId == aDownloadId )
-            {
-            MPX_DEBUG1("CVcxMyVideosVideoCache:: found from iVideoList");
-            MPX_DEBUG1("CVcxMyVideosVideoCache:: adding to iDownloadCache");
-            iDownloadCache->Add( downloadId, (*cachedVideoArray)[i] );
-            return (*cachedVideoArray)[i];
-            }
-        }
-    
-    count = iPartialVideoList.Count();  
-    for ( TInt i = 0; i < count; i++ )
-        {
-        downloadId = TVcxMyVideosCollectionUtil::DownloadIdL( *(iPartialVideoList[i]) );
-        if ( downloadId ==  aDownloadId )
-            {
-            MPX_DEBUG1("CVcxMyVideosVideoCache:: found from iPartialVideoList");
-            MPX_DEBUG1("CVcxMyVideosVideoCache:: adding to iDownloadCache");
-            iDownloadCache->Add( downloadId, iPartialVideoList[i] );
-            return iPartialVideoList[i];
-            }       
-        }
-        
-    MPX_DEBUG1("CVcxMyVideosVideoCache:: NOT FOUND");
-    return NULL;
-    }
-
-
-// ----------------------------------------------------------------------------
 // CVcxMyVideosVideoCache::GetVideosL
 // ----------------------------------------------------------------------------
 //
-CMPXMedia* CVcxMyVideosVideoCache::GetVideosL( RArray<TUint32> aMdsIds )
+CMPXMedia* CVcxMyVideosVideoCache::GetVideosL( RArray<TUint32>& aMdsIds )
     {
     CMPXMessage* videoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
     CleanupStack::PushL( videoList ); // 1->
@@ -350,14 +505,14 @@
 // CVcxMyVideosVideoCache::AddVideosFromMdsL
 // Called when item inserted events arrive from mds or from
 // KVcxCommandMyVideosGetMediasByMpxId cmd handler.
-// Synchronizing with downloads is not done here, caller must take care of it.
 // If mpx item is already in cache, or MDS does not contain the item (or was not video item),
 // then it is removed from aMdsIds. Ie after this function call aMdsIds contains
-// only IDs which are actually added to cache.
+// only IDs which are actually added to cache. aNonVideoIds will contain IDs
+// which were not video objects.
 // ----------------------------------------------------------------------------
 //    
 void CVcxMyVideosVideoCache::AddVideosFromMdsL( RArray<TUint32>& aMdsIds,
-        TBool& aListFetchingWasCanceled )
+        TBool& aListFetchingWasCanceled, RArray<TUint32>* aNonVideoIds  )
     {
     MPX_FUNC("CVcxMyVideosVideoCache::AddVideosFromMdsL");
 
@@ -375,6 +530,8 @@
             {
             MPX_DEBUG2("CVcxMyVideosVideoCache:: MDSID(%d) not found from cache, ok", aMdsIds[j]);
             
+            //TODO: This doesnt work with new mds cmd queue. Cancel must be done if there is _any_ async req going on.
+            //      Maybe the fetching could be changed to asynchronous...
             if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing )
                 {
                 // If list fetching is not canceled, CreateVideoObjectL will leave with KErrNotReady.
@@ -405,13 +562,17 @@
                 }
             else
                 {
-                MPX_DEBUG2("CVcxMyVideosVideoCache:: video with %d ID not found from MDS -> skipping add to cache and deleting from id array", aMdsIds[j] );
+                MPX_DEBUG2("CVcxMyVideosVideoCache:: video with %d ID not found from MDS -> prob non video object, skipping add to cache", aMdsIds[j] );
+                if ( aNonVideoIds )
+                    {
+                    aNonVideoIds->AppendL( aMdsIds[j] );
+                    }
                 aMdsIds.Remove( j );
                 }
             }
         else
             {
-            MPX_DEBUG2("CVcxMyVideosVideoCache:: %d was already in cache -> skipping add, and deleting from id array", aMdsIds[j]);
+            MPX_DEBUG2("CVcxMyVideosVideoCache:: %d was already in cache -> skipping add", aMdsIds[j]);
             aMdsIds.Remove( j );
             }
         }
@@ -427,7 +588,7 @@
     {
     MPX_FUNC("CVcxMyVideosVideoCache::AddL");
     
-    if ( iVideoListIsPartial )
+    if ( !IsComplete() )
         {
         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is partial, adding to iPartialVideoList");
         return AddToPartialListL( aVideo );
@@ -578,21 +739,22 @@
     
     TVcxMyVideosSortingOrder sortingOrder = SortingOrderL();
         
-    if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing
+    if ( iIsFetchingVideoList
             && sortingOrder == iLastSortingOrder && !aForce )
         {
         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList creation is already ongoing, skipping");
         return;
         }
                    
-    if ( iVideoListIsPartial || (sortingOrder != iLastSortingOrder) || aForce )
+    if ( !IsComplete() || (sortingOrder != iLastSortingOrder) || aForce )
         {
         MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList was partial or in wrong order or aForce was ETrue, recreating");
 
-        if ( iCollection.iMyVideosMdsDb->iVideoListFetchingIsOngoing )
+        if ( iIsFetchingVideoList )
             {
             MPX_DEBUG1("CVcxMyVideosVideoCache:: video list fetching is ongoing, canceling it");
-            iCollection.iMyVideosMdsDb->Cancel();
+            iCollection.iMyVideosMdsDb->Cancel( CVcxMyVideosMdsDb::EGetVideoList );
+            iIsFetchingVideoList = EFalse;
             }
         
         ResetVideoListL();
@@ -618,8 +780,9 @@
                 EFalse /* brief list */,
                 iVideoList /* use existing */ );
 
+        iIsFetchingVideoList = ETrue;
         iLastSortingOrder   = sortingOrder;
-        iVideoListIsPartial = ETrue;
+        SetComplete( EFalse );
         }
     else
         {
@@ -648,7 +811,7 @@
     TBool changed = EFalse;
         
     // 1 MPX ID cant be changed
-    // 2 
+    // 2
     if ( aVideo.IsSupported( KMPXMediaGeneralTitle ) )
         {
         if ( videoInCache->ValueText( KMPXMediaGeneralTitle ) !=
@@ -682,30 +845,7 @@
 
         if ( videoInCache->ValueText( KMPXMediaGeneralUri ) !=
                aVideo.ValueText( KMPXMediaGeneralUri ) ) 
-            {
-#if 0 // this should be in mds, or mds should keep title empty if it is not set by client
-            TParse parse;
-            HBufC* oldTitle = HBufC::NewL( videoInCache->ValueText( KMPXMediaGeneralTitle ).Length() );
-            CleanupStack::PushL( oldTitle ); // 1->
-            oldTitle->Des() = videoInCache->ValueText( KMPXMediaGeneralTitle );
-            oldTitle->Des().LowerCase();
-            
-            parse.Set( videoInCache->ValueText( KMPXMediaGeneralUri ), NULL, NULL );
-            MPX_DEBUG2("CVcxMyVideosVideoCache:: title generated from old file name: %S", &parse.Name());
-            MPX_DEBUG2("CVcxMyVideosVideoCache:: old title (lower cased): %S", oldTitle);
-            if ( parse.Name() == *oldTitle )
-                {
-                // filename has been used as a title -> update title also to new filename
-                MPX_DEBUG1("CVcxMyVideosVideoCache:: filename has been used as a title -> changing title to new filename");
-                parse.Set( aVideo.ValueText( KMPXMediaGeneralUri ), NULL, NULL );
-                videoInCache->SetTextValueL( KMPXMediaGeneralTitle, parse.Name() );
-                
-                //updates sorting order and category attributes if necessarry
-                HandleVideoTitleModifiedL( videoInCache );
-                }
-            CleanupStack::PopAndDestroy( oldTitle ); // <-1
-#endif
-            
+            {            
             videoInCache->SetTextValueL( KMPXMediaGeneralUri,
                     aVideo.ValueText( KMPXMediaGeneralUri ) );
     
@@ -763,7 +903,7 @@
                         KMPXMediaGeneralId ).iId1, pos );
 
                 iCollection.CategoriesL().GenerateCategoryModifiedEventL(
-                        *videoInCache, ETrue /* flush */, EVcxMyVideosVideoListOrderChanged );
+                        *videoInCache, EFalse /* dont flush */, EVcxMyVideosVideoListOrderChanged );
                 }
 
             changed = ETrue;
@@ -783,7 +923,7 @@
         if ( aVideo.IsSupported( KMPXMediaGeneralLastPlaybackPosition ) )
             {
             newFlags &= ~EVcxMyVideosVideoNew;
-            MPX_DEBUG3("CVcxMyVideosVideoCache:: %x -> %x", oldFlags, newFlags);
+            MPX_DEBUG3("CVcxMyVideosVideoCache:: flags: %x -> %x", oldFlags, newFlags);
             }
 
         if ( oldFlags != newFlags )
@@ -804,13 +944,11 @@
                         oldFlags, newFlags,
                         origin,
                         modified );
-                
-                if ( !(newFlags & EVcxMyVideosVideoNew) && 
-                        origin == EVcxMyVideosOriginDownloaded )
-                    {
-                    MPX_DEBUG1("CVcxMyVideosVideoCache::UpdateVideoL - Count of new videos in Downloaded origin has decreased, sending mediator event to notification launcher");                   
-                    iCollection.NotifyNewVideosCountDecreasedL( *videoInCache );
-                    }
+
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+                iCollection.AlbumsL().NewVideoFlagChangedL(
+                        TVcxMyVideosCollectionUtil::IdL( *videoInCache ).iId1 );
+#endif
                 }
             changed = ETrue;
             }
@@ -947,23 +1085,7 @@
             changed = ETrue;
             }
         }
-    // 18
-    if ( aVideo.IsSupported( KVcxMediaMyVideosDownloadId ) )
-        {
-        TUint32 downloadIdInCache( TVcxMyVideosCollectionUtil::DownloadIdL( *videoInCache ) );
-        TUint32 downloadIdInNew( TVcxMyVideosCollectionUtil::DownloadIdL( aVideo ) );
-        if (  downloadIdInNew != downloadIdInCache )
-            {
-            videoInCache->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId,
-                    downloadIdInNew );
 
-            if ( downloadIdInNew == 0 )
-                {
-                iDownloadCache->Delete( videoInCache );
-                }
-            changed = ETrue;
-            }
-        }
     // 19
     if ( aVideo.IsSupported( KVcxMediaMyVideosRating ) )
         {
@@ -1001,10 +1123,6 @@
             videoInCache->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc,
                     AudioFourCcInNew );
 
-            if ( AudioFourCcInNew == 0 )
-                {
-                iDownloadCache->Delete( videoInCache );
-                }
             changed = ETrue;
             }
         }
@@ -1047,7 +1165,12 @@
             changed = ETrue;
             }
         }
-        
+    
+    if ( changed )
+        {
+        iCollection.iMessageList->SendL();
+        }
+    
     return changed;    
     }
 
@@ -1067,6 +1190,11 @@
     iCollection.CategoriesL().UpdateCategoryNewVideoNameAndDateL(
             *aVideoInCache, modified );
 
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+    iCollection.AlbumsL().VideoTitleChangedL(
+            TVcxMyVideosCollectionUtil::IdL( *aVideoInCache ).iId1 );
+#endif
+    
     TVcxMyVideosSortingOrder sortingOrder = SortingOrderL();
     if ( sortingOrder == EVcxMyVideosSortingName )
         {
@@ -1354,22 +1482,28 @@
         
     TInt pos = FindCorrectPositionL( aVideo, aSortingOrder );
 
-    CMPXMediaArray* cachedVideoArray = NULL;            
-    cachedVideoArray = iVideoList->Value<CMPXMediaArray>(
+    CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>(
             KMPXMediaArrayContents );
 
     if ( pos > (cachedVideoArray->Count() -1) )
         {
-        cachedVideoArray->AppendL( aVideo );                    
+        cachedVideoArray->AppendL( aVideo );
         }
     else
         {
         cachedVideoArray->InsertL( aVideo, pos );
         }
-        
+    iVideoListIndex->AddL( cachedVideoArray->AtL( pos ), pos );
+#ifdef _DEBUG
+    CheckVideoListIndexL();
+#endif
+    
     if ( aUpdateCategories )
         {
         iCollection.CategoriesL().VideoAddedL( aVideo );
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+        iCollection.AlbumsL().VideoAddedOrRemovedFromCacheL( aVideo );
+#endif
         }
 
     return KErrNone;
@@ -1407,6 +1541,7 @@
 
 // ----------------------------------------------------------------------------
 // CVcxMyVideosVideoCache::RemoveL
+// All removes end up here (except ResetVideoListL).
 // ----------------------------------------------------------------------------
 //
 TInt CVcxMyVideosVideoCache::RemoveL( TUint32 aMdsId, TBool aUpdateCategories )
@@ -1421,26 +1556,14 @@
         MPX_DEBUG1("CVcxMyVideosVideoCache:: RemoveL failed since the item wasn't on cache");
         return KErrNotFound;
         }
-
-    iDownloadCache->Delete( video );
-
-    TUint32 flags( 0 );
-	if ( video->IsSupported( KMPXMediaGeneralFlags ) )
-	    {
-		flags = video->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
-		}
-    
-    if ( ( flags & EVcxMyVideosVideoNew ) && 
-            TVcxMyVideosCollectionUtil::OriginL( *video ) == EVcxMyVideosOriginDownloaded )
-        {       
-        MPX_DEBUG1("CVcxMyVideosVideoCache::RemoveL - New video has been removed from Downloaded origin -> sending mediator event to notification launcher");
-        iCollection.NotifyNewVideosCountDecreasedL( *video );
-        }
     
     if ( aUpdateCategories &&
             pos != KErrNotFound /* no need to update if item is on iPartialVideoList*/ )
         {
         iCollection.CategoriesL().VideoRemovedL( *video );
+#ifndef VIDEO_COLLECTION_PLUGIN_TB92
+        iCollection.AlbumsL().VideoAddedOrRemovedFromCacheL( *video );
+#endif
         }
         
     if ( pos != KErrNotFound )
@@ -1450,6 +1573,10 @@
         
         MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iVideoList", aMdsId);
         cachedVideoArray->Remove( pos );
+        iVideoListIndex->Remove( aMdsId, ETrue /* compress */);
+#ifdef _DEBUG
+        CheckVideoListIndexL();
+#endif
         }
     else
         {
@@ -1483,7 +1610,7 @@
     {
     MPX_FUNC("CVcxMyVideosVideoCache::ResetVideoListL");
 
-    iCollection.iMyVideosMdsDb->Cancel();
+    iCollection.iMyVideosMdsDb->Cancel( CVcxMyVideosMdsDb::EGetVideoList );
 
     CMPXMediaArray* mediaArray =
             iVideoList->ValueCObjectL<CMPXMediaArray>( KMPXMediaArrayContents );
@@ -1521,11 +1648,7 @@
             }
         }
         
-    iVideoListIsPartial = ETrue;
-
-    delete iDownloadCache;
-    iDownloadCache = NULL;
-    iDownloadCache = CVcxMyVideosDownloadCache::NewL();
+    SetComplete( EFalse );
                 
     iCollection.CategoriesL().ResetVideoCountersL(); //this does not send events
     }
@@ -1563,11 +1686,92 @@
     delete iVideoList;
     iVideoList = NULL;
     iVideoList = newList;
+    
+    iVideoListIndex->SetL( *iVideoList );
+#ifdef _DEBUG
+    CheckVideoListIndexL();
+#endif
+    
     CleanupStack::Pop( newList ); // <-1
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoCache::IsComplete
+// ----------------------------------------------------------------------------
+//
+TBool CVcxMyVideosVideoCache::IsComplete()
+    {
+    return iVideoListIsComplete;
+    }
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoCache::SetComplete
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoCache::SetComplete( TBool aComplete )
+    {
+    if ( !iVideoListIsComplete && aComplete )
+        {
+        MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList turned to complete, setting up iVideoListIndex");
+        iVideoListIndex->SetL( *iVideoList );
+#ifdef _DEBUG
+        CheckVideoListIndexL();
+#endif
+        }
+    iVideoListIsComplete = aComplete;
+    }
 
-    delete iDownloadCache;
-    iDownloadCache = NULL;
-    iDownloadCache = CVcxMyVideosDownloadCache::NewL();
+#ifdef _DEBUG
+// ----------------------------------------------------------------------------
+// CVcxMyVideosVideoCache::SetComplete
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosVideoCache::CheckVideoListIndexL()
+    {
+    if ( !IsComplete() )
+        {
+        return;
+        }
+    
+    TInt pos;
+    TInt mdsId;
+    CMPXMedia* video;
+    CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *iVideoList );
+    TInt count = iVideoListIndex->VideoArray().Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        pos   = iVideoListIndex->VideoArray()[i].iPos;
+        mdsId = iVideoListIndex->VideoArray()[i].iMdsId;
+        video = iVideoListIndex->VideoArray()[i].iVideo;
+        
+        if ( pos < 0 || pos > mediaArray->Count() -1 )
+            {
+            MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iPos out of range -> Panic",
+                    i, pos );
+            _LIT( KVideoListIndexPosCorrupted, "iVideoListIndex pos");
+            User::Panic( KVideoListIndexPosCorrupted, KErrCorrupt ); 
+            }
+        
+        if ( mediaArray->AtL( pos ) != video )
+            {
+            MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iVideo != mediaArray->AtL( %d ) -> Panic",
+                    i, pos );
+            _LIT( KVideoListIndexVideoCorrupted, "iVideoListIndex video pointer");
+            User::Panic( KVideoListIndexVideoCorrupted, KErrCorrupt );
+            }
+        
+        if ( TVcxMyVideosCollectionUtil::IdL( *mediaArray->AtL( pos ) ).iId1 != 
+                mdsId )
+            {
+            MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iMdsId != MDSID in mediaArray->AtL( %d ) -> Panic",
+                    i, pos );
+            _LIT( KVideoListIndexMdsIdCorrupted, "iVideoListIndex MDS ID");
+            User::Panic( KVideoListIndexMdsIdCorrupted, KErrCorrupt );        
+            }
+        }
+    MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoListIndex check OK");
     }
+#endif
+
 // End of file
 
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/conf/VcxMyVideosCollectionUtilTest.cfg	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/conf/VcxMyVideosCollectionUtilTest.cfg	Wed Jun 09 09:44:23 2010 +0300
@@ -1,3 +1,8 @@
+
+[Define]
+EErrArgument -6
+[Enddefine]
+
 [Test]
 title CreateEmptyMediaList
 create VcxMyVideosCollectionUtilTest foobar
@@ -20,9 +25,26 @@
 [Endtest]
 
 [Test]
+title CopyFromListToList2
+create VcxMyVideosCollectionUtilTest foobar
+foobar CopyFromListToList2 5 3
+delete foobar
+[Endtest]
+
+[Test]
 title DriveLetter2DriveNumber
 create VcxMyVideosCollectionUtilTest foobar
-foobar DriveLetter2DriveNumber
+foobar DriveLetter2DriveNumber a:    0
+foobar DriveLetter2DriveNumber c     2
+foobar DriveLetter2DriveNumber E:    4
+foobar DriveLetter2DriveNumber Z     25
+foobar DriveLetter2DriveNumber z0rRo 25
+foobar DriveLetter2DriveNumber @         EErrArgument
+foobar DriveLetter2DriveNumber [         EErrArgument
+foobar DriveLetter2DriveNumber ?:        EErrArgument
+foobar DriveLetter2DriveNumber ä         EErrArgument
+foobar DriveLetter2DriveNumber " "       EErrArgument
+foobar DriveLetter2DriveNumber KNullDesC EErrArgument
 delete foobar
 [Endtest]
 
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/group/bld.inf	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/group/bld.inf	Wed Jun 09 09:44:23 2010 +0300
@@ -24,33 +24,18 @@
 PRJ_TESTEXPORTS
 // NOTE: If using ARS requirements all export operations should be done under this.
 // 'abld test export'
-
-PRJ_EXPORTS
 ../conf/vcxmyvideoscollectionutiltest.cfg       /epoc32/winscw/c/testframework/vcxmyvideoscollectionutiltest.cfg
 ../init/testframework.ini                       /epoc32/winscw/c/testframework/testframework.ini
 
 ../data/mmc/file.txt                            /epoc32/winscw/c/data/vcxmyvideoscollectionutiltest_file.txt
+../data/mmc/file.txt                            /epoc32/winscw/c/data/vcxmyvideoscollectionutiltest_file2
+
+PRJ_EXPORTS
 
 PRJ_TESTMMPFILES
-
-
+VcxMyVideosCollectionUtilTest.mmp
 
 PRJ_MMPFILES
-
-	VcxMyVideosCollectionUtilTest.mmp
 	
-// Specify the .mmp files required for building the important component
-// releasables.
-//
-// Specify "tidy" if the component you need to build doesn't need to be
-// released. Specify "ignore" if the MMP file exists but should be
-// ignored.
-// Example:
-/*
-\agnmodel\group\agnmodel.mmp
-#if defined(MARM)
-\agnmodel\group\agsvexe.mmp
-#endif
-*/
 
 //  End of File
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/inc/VcxMyVideosCollectionUtilTest.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/inc/VcxMyVideosCollectionUtilTest.h	Wed Jun 09 09:44:23 2010 +0300
@@ -142,6 +142,8 @@
         virtual TInt CreateEmptyMessageListL( CStifItemParser& aItem );        
 
         virtual TInt CopyFromListToListL( CStifItemParser& aItem );
+        
+        virtual TInt CopyFromListToListL2( CStifItemParser& aItem );
 
         virtual TInt DriveLetter2DriveNumberL( CStifItemParser& aItem );
 
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/src/VcxMyVideosCollectionUtilTestBlocks.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideoscollectionutiltest/src/VcxMyVideosCollectionUtilTestBlocks.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -22,6 +22,8 @@
 #include <vcxmyvideosdefs.h>
 #include <mpxmedia.h>
 #include <mpxattribute.h>
+#include <mpxmediaarray.h>
+#include <mpxmediacontainerdefs.h>
 #include <mpxmediageneraldefs.h>
 #include <mpxmediavideodefs.h>
 #include "VcxMyVideosCollectionUtilTest.h"
@@ -53,28 +55,7 @@
 // FORWARD DECLARATIONS
 //class ?FORWARD_CLASSNAME;
 
-// ============================= LOCAL FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// ?function_name ?description.
-// ?description
-// Returns: ?value_1: ?description
-//          ?value_n: ?description_line1
-//                    ?description_line2
-// -----------------------------------------------------------------------------
-//
-/*
-?type ?function_name(
-    ?arg_type arg,  // ?description
-    ?arg_type arg)  // ?description
-    {
-
-    ?code  // ?comment
-
-    // ?comment
-    ?code
-    }
-*/
+const TMPXAttributeData KMPXMediaFail={0xC0FFEE,0xBADBEEF};
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -106,6 +87,7 @@
         ENTRY( "CreateEmptyMediaList", CVcxMyVideosCollectionUtilTest::CreateEmptyMediaListL ),
         ENTRY( "CreateEmptyMessageList", CVcxMyVideosCollectionUtilTest::CreateEmptyMessageListL ),
         ENTRY( "CopyFromListToList", CVcxMyVideosCollectionUtilTest::CopyFromListToListL ),
+        ENTRY( "CopyFromListToList2", CVcxMyVideosCollectionUtilTest::CopyFromListToListL2 ),
         ENTRY( "DriveLetter2DriveNumber", CVcxMyVideosCollectionUtilTest::DriveLetter2DriveNumberL ),
         ENTRY( "MakeUniqueFileName", CVcxMyVideosCollectionUtilTest::MakeUniqueFileNameL ),
         ENTRY( "Origin", CVcxMyVideosCollectionUtilTest::OriginL ),
@@ -142,6 +124,9 @@
     {
     CMPXMedia* media = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
     delete media;
+    
+    // Only thing that can fail here is method call leaves. If we reach the end
+    // everyting has worked fine and we can return ok.
     return KErrNone;
     }
 
@@ -153,6 +138,9 @@
     {
     CMPXMedia* media = TVcxMyVideosCollectionUtil::CreateEmptyMessageListL();
     delete media;
+    
+    // Only thing that can fail here is method call leaves. If we reach the end
+    // everyting has worked fine and we can return ok.    
     return KErrNone;
     }
 
@@ -164,7 +152,13 @@
     {
     CMPXMedia* from = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
     CMPXMedia* to = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+    CMPXMedia* failList = CMPXMedia::NewL();
+    CMPXMedia* media( NULL );
+    TInt itemsToCopy( 0 );
+    TInt itemsCopied( 0 );
     RArray<TUint32> ids;
+    TMPXItemId idGet;
+    TInt retVal( KErrGeneral );
     
     TInt numberOfMedia;
     TInt wantedId;
@@ -175,26 +169,198 @@
     ids.Append( wantedId );
     
     // add stuff to be copied to "from" -list
+    CleanupStack::PushL( from );
+    CleanupStack::PushL( to );
+    CMPXMediaArray* fromMessageArray = from->Value<CMPXMediaArray>(
+            KMPXMediaArrayContents );
+    CleanupStack::PushL( fromMessageArray );
     
+    TVcxMyVideosCollectionUtil::CopyFromListToListL( *from, *to, ids );
+    
+    for(TInt i = 0; i < numberOfMedia; i++ )
+        {
+        media = CMPXMedia::NewL();
+        CleanupStack::PushL( media );
+        media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId,
+                TMPXItemId( i, i) );
+        media->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value,
+                42 );        
+        fromMessageArray->AppendL( media );
+        if( i == wantedId )
+            {
+            itemsToCopy++;
+            }
+        CleanupStack::Pop( media );
+        }
+    
+    TRAPD( err, TVcxMyVideosCollectionUtil::CopyFromListToListL( *from, *failList, ids ) );    
+    if( err != KErrArgument )    
+        {
+        CleanupStack::Pop( fromMessageArray );
+        CleanupStack::Pop( to );
+        CleanupStack::Pop( from );        
+        fromMessageArray->Reset();
+        delete failList;
+        delete from;
+        delete to; 
+        return retVal;
+        }
     
     TVcxMyVideosCollectionUtil::CopyFromListToListL( *from, *to, ids );
     
     // check that the "to" -list have the items it should have
+    CMPXMediaArray* toMessageArray = to->Value<CMPXMediaArray>(
+                KMPXMediaArrayContents );
+    CleanupStack::PushL( toMessageArray );
     
+    for( TInt i = 0; i < toMessageArray->Count(); i++ )
+        {        
+        idGet = TVcxMyVideosCollectionUtil::IdL( *(toMessageArray->operator[](i)) );
+        if( idGet.iId1 == wantedId )
+            {
+            itemsCopied++;
+            }
+        }    
+    
+    if( itemsCopied == itemsToCopy )
+        {
+        retVal = KErrNone;  
+        }
+    
+    CleanupStack::Pop( toMessageArray );
+    CleanupStack::Pop( fromMessageArray );
+    CleanupStack::Pop( to );
+    CleanupStack::Pop( from );
+    
+    toMessageArray->Reset();
+    fromMessageArray->Reset();
+    
+    delete failList;
     delete from;
-    delete to;
+    delete to;    
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosCollectionUtilTest::CopyFromListToListL2
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosCollectionUtilTest::CopyFromListToListL2( CStifItemParser& aItem )
+    {
+    RArray<CMPXMedia*> fromArray;
+    CMPXMedia* to = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
+    CMPXMedia* failList = CMPXMedia::NewL();
+    CMPXMedia* media( NULL );        
+    TInt itemsToCopy( 0 );
+    TInt itemsCopied( 0 );
+    RArray<TUint32> ids;
+    TMPXItemId idGet;
+    TInt retVal( KErrGeneral );
+    
+    TInt numberOfMedia;
+    TInt wantedId;
+    
+    aItem.GetNextInt( numberOfMedia );
+    aItem.GetNextInt( wantedId );
+    
+    ids.Append( wantedId );
+    
+    // add stuff to be copied to "from" -list    
+    CleanupStack::PushL( to );    
+    
+    TVcxMyVideosCollectionUtil::CopyFromListToListL( fromArray, *to, ids );
     
-    return KErrNone;
+    for(TInt i = 0; i < numberOfMedia; i++ )
+        {
+        media = CMPXMedia::NewL();
+        CleanupStack::PushL( media );
+        media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId,
+                TMPXItemId( i, i) );
+        media->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value,
+                42 );        
+        fromArray.AppendL( media );
+        if( i == wantedId )
+            {
+            itemsToCopy++;
+            }
+        CleanupStack::Pop( media );
+        }    
+    
+    TRAPD(err, TVcxMyVideosCollectionUtil::CopyFromListToListL( fromArray, *failList, ids ));
+    if( err != KErrArgument )    
+        {        
+        CleanupStack::Pop( to );
+        fromArray.Reset();
+        delete failList;
+        delete to; 
+        return retVal;
+        }
+    
+    TVcxMyVideosCollectionUtil::CopyFromListToListL( fromArray, *to, ids );
+    
+    // check that the "to" -list have the items it should have
+    CMPXMediaArray* toMessageArray = to->Value<CMPXMediaArray>(
+                KMPXMediaArrayContents );
+    CleanupStack::PushL( toMessageArray );
+    
+    for( TInt i = 0; i < toMessageArray->Count(); i++ )
+        {        
+        idGet = TVcxMyVideosCollectionUtil::IdL( *(toMessageArray->operator[](i)) );
+        if( idGet.iId1 == wantedId )
+            {
+            itemsCopied++;
+            }
+        }    
+    
+    if( itemsCopied == itemsToCopy )
+        {
+        retVal = KErrNone;  
+        }
+    
+    CleanupStack::Pop( toMessageArray );    
+    CleanupStack::Pop( to );
+        
+    toMessageArray->Reset();
+    
+    for( TInt i = 0; i < fromArray.Count(); i++ )
+        {
+        CMPXMedia* arrayMedia = fromArray[i];
+        delete arrayMedia;        
+        }
+    fromArray.Reset();    
+    delete failList;
+    delete to;    
+    return retVal;
     }
     
 // ---------------------------------------------------------------------------
 // This helper function converts drive letter to drive number
 // ---------------------------------------------------------------------------
 //
-TInt CVcxMyVideosCollectionUtilTest::DriveLetter2DriveNumberL( CStifItemParser& /*aItem*/ )
+TInt CVcxMyVideosCollectionUtilTest::DriveLetter2DriveNumberL( CStifItemParser& aItem )
     {
-    TVcxMyVideosCollectionUtil::DriveLetter2DriveNumber( _L("E:") );
-    return KErrNone;
+    TInt retVal( KErrNone ); 
+    TPtrC string;
+    TInt expectedValue( -1 );
+    
+    aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
+    
+    User::LeaveIfError( aItem.GetNextString( string ) );
+    User::LeaveIfError( aItem.GetNextInt( expectedValue ) );
+    
+    _LIT( KNullDescString, "KNullDesC" );
+    if ( string.Compare( KNullDescString ) == 0 )
+        {
+        string.Set( KNullDesC );
+        }
+  
+    TInt driveNumber = TVcxMyVideosCollectionUtil::DriveLetter2DriveNumber( string );
+    if (  driveNumber != expectedValue )
+        {
+        retVal = KErrGeneral;
+        }
+
+    return retVal;
     }
 
 // ---------------------------------------------------------------------------
@@ -203,12 +369,41 @@
 //
 TInt CVcxMyVideosCollectionUtilTest::MakeUniqueFileNameL( CStifItemParser& /*aItem*/ )
     {
+    TInt retVal( KErrNone );
     RFs fs;
     fs.Connect();
     TBuf<KMaxPath> path;
-    TVcxMyVideosCollectionUtil::MakeUniqueFileNameL( fs, _L("c://testframework//testframework.ini"), path );
+    _LIT( KFileName1,   "c:\\data\\vcxmyvideoscollectionutiltest_file.txt" );
+    _LIT( KFileName2,   "c:\\data\\vcxmyvideoscollectionutiltest_file2" );
+    _LIT( KInvalidFile, "c:\\data\\vcxmyvideoscollectionutiltest_DoesNotExist" );
+    
+    // File with filename extension 
+    TVcxMyVideosCollectionUtil::MakeUniqueFileNameL( fs, KFileName1, path );
+    if ( path.Length() <= KFileName1().Length() )
+        {
+        retVal = KErrGeneral;
+        }    
+    
+    // File without filename extension
+    TVcxMyVideosCollectionUtil::MakeUniqueFileNameL( fs, KFileName2, path );
+    if ( ( path.Find( KFileName2 ) == KErrNotFound ) ||
+         ( path.Length() <= KFileName2().Length() ) ) 
+        {
+        retVal = KErrGeneral;
+        }  
+    
+    // Non-existent file
+    TVcxMyVideosCollectionUtil::MakeUniqueFileNameL( fs, KInvalidFile, path );
+    if ( path.Compare( KInvalidFile ) != 0 )
+        {
+        retVal = KErrGeneral;
+        }
+
+    // Null descriptor
+    TVcxMyVideosCollectionUtil::MakeUniqueFileNameL( fs, KNullDesC, path );
+    
     fs.Close();
-    return KErrNone;
+    return retVal;
     }
 
 // ----------------------------------------------------------------------------
@@ -219,9 +414,17 @@
     {
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
+    TUint8 valueGet = TVcxMyVideosCollectionUtil::OriginL( *media );
+    valueGet = TVcxMyVideosCollectionUtil::OriginL( *media );
+    if( EVcxMyVideosOriginOther != valueGet )
+        {
+        retVal = KErrGeneral;
+        delete media;
+        return retVal;
+        }
     TUint8 valueSet = EVcxMyVideosOriginCapturedWithCamera;
     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, valueSet );
-    TUint8 valueGet = TVcxMyVideosCollectionUtil::OriginL( *media );
+    valueGet = TVcxMyVideosCollectionUtil::OriginL( *media );
     if( valueSet != valueGet )
         {
         retVal = KErrGeneral;
@@ -246,10 +449,17 @@
 TInt CVcxMyVideosCollectionUtilTest::FlagsL( CStifItemParser& /*aItem*/ )
     {
     CMPXMedia* media = CMPXMedia::NewL();
-    TInt retVal( KErrNone );
+    TInt retVal( KErrNone );    
     TUint32 flagsSet( 0xBEEF );
+    TUint32 flagsGet( TVcxMyVideosCollectionUtil::FlagsL( *media ) );
+    if( flagsGet != 0 )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flagsSet );
-    TUint32 flagsGet( TVcxMyVideosCollectionUtil::FlagsL( *media ) );
+    flagsGet= TVcxMyVideosCollectionUtil::FlagsL( *media );
     if( flagsSet != flagsGet )
         {
         retVal = KErrGeneral;
@@ -267,8 +477,15 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     TUint32 idSet( 0xBEEF );
+    TUint32 idGet( TVcxMyVideosCollectionUtil::DownloadIdL( *media ) );
+    if( 0 != idGet )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, idSet );
-    TUint32 idGet( TVcxMyVideosCollectionUtil::DownloadIdL( *media ) );
+    idGet = TVcxMyVideosCollectionUtil::DownloadIdL( *media );
     if( idSet != idGet )
         {
         retVal = KErrGeneral;
@@ -286,8 +503,15 @@
     CMPXMedia* media = CMPXMedia::NewL();    
     TInt retVal( KErrNone );
     TVcxMyVideosDownloadState stateSet = EVcxMyVideosDlStateFailed;
+    TVcxMyVideosDownloadState stateGet = TVcxMyVideosCollectionUtil::DownloadStateL( *media );    
+    if( EVcxMyVideosDlStateNone != stateGet )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadState, stateSet );
-    TVcxMyVideosDownloadState stateGet = TVcxMyVideosCollectionUtil::DownloadStateL( *media );    
+    stateGet = TVcxMyVideosCollectionUtil::DownloadStateL( *media );    
     if( stateSet != stateGet )
         {
         retVal = KErrGeneral;
@@ -305,8 +529,15 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     TMPXItemId idSet( 2, 7 );
+    TMPXItemId idGet = TVcxMyVideosCollectionUtil::IdL( *media );
+    if( (idGet.iId1 != 0) || (idGet.iId2 != 0) )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, idSet );
-    TMPXItemId idGet = TVcxMyVideosCollectionUtil::IdL( *media );;
+    idGet = TVcxMyVideosCollectionUtil::IdL( *media );
     if( idSet != idGet )
         {
         retVal = KErrGeneral;
@@ -324,8 +555,15 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     TReal32 durationSet( 150 );
+    TReal32 durationGet = TVcxMyVideosCollectionUtil::DurationL( *media );
+    if( -1 != durationGet )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, durationSet );
-    TReal32 durationGet = TVcxMyVideosCollectionUtil::DurationL( *media );;
+    durationGet = TVcxMyVideosCollectionUtil::DurationL( *media );
     if( durationSet != durationGet )
         {
         retVal = KErrGeneral;
@@ -343,8 +581,17 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     _LIT( valueSet, "TeamNinja" );
+    HBufC* valueGet = TVcxMyVideosCollectionUtil::Title( *media ).AllocL();
+    if( valueGet->Size() != 0  )
+        {
+        delete media;
+        delete valueGet;
+        retVal = KErrGeneral;
+        return retVal;
+        }
+    delete valueGet;
     media->SetTextValueL( KMPXMediaGeneralTitle, valueSet );
-    HBufC* valueGet = TVcxMyVideosCollectionUtil::Title( *media ).AllocL();
+    valueGet = TVcxMyVideosCollectionUtil::Title( *media ).AllocL();
     if( valueGet->CompareF( valueSet ) )
         {
         retVal = KErrGeneral;
@@ -363,8 +610,15 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     TUint8 valueSet( 21 );
+    TUint8 valueGet = TVcxMyVideosCollectionUtil::RatingL( *media );;
+    if( 0 != valueGet )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, valueSet );
-    TUint8 valueGet = TVcxMyVideosCollectionUtil::RatingL( *media );;
+    valueGet = TVcxMyVideosCollectionUtil::RatingL( *media );;
     if( valueSet != valueGet )
         {
         retVal = KErrGeneral;
@@ -382,8 +636,15 @@
     CMPXMedia* media = CMPXMedia::NewL();
     TInt retVal( KErrNone );
     TUint32 valueSet( 21 );
+    TUint32 valueGet = TVcxMyVideosCollectionUtil::AudioFourCcL( *media );;
+    if( 0 != valueGet )
+        {
+        delete media;
+        retVal = KErrGeneral;
+        return retVal;
+        }
     media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc, valueSet );
-    TUint32 valueGet = TVcxMyVideosCollectionUtil::AudioFourCcL( *media );;
+    valueGet = TVcxMyVideosCollectionUtil::AudioFourCcL( *media );;
     if( valueSet != valueGet )
         {
         retVal = KErrGeneral;
@@ -401,8 +662,14 @@
     TInt retVal( KErrNone );
     CMPXMedia* media = CMPXMedia::NewL();
     RArray<TMPXAttribute> attrs;
-    attrs.Append( KMPXMediaGeneralMimeType );
     TBool inMds( EFalse );
+    TVcxMyVideosCollectionUtil::AreSupported( *media, attrs.Array(), inMds );        
+    attrs.Append( KMPXMediaFail );
+    TVcxMyVideosCollectionUtil::AreSupported( *media, attrs.Array(), inMds );
+    attrs.Append( KMPXMediaVideoBitRate );
+    inMds = ETrue;    
+    TVcxMyVideosCollectionUtil::AreSupported( *media, attrs.Array(), inMds );
+    media->SetTObjectValueL<TUint16>( KMPXMediaVideoBitRate, 47 );
     TVcxMyVideosCollectionUtil::AreSupported( *media, attrs.Array(), inMds );
     delete media;
     return retVal;
@@ -415,8 +682,7 @@
 TInt CVcxMyVideosCollectionUtilTest::AttrBelongsToFullSetL( CStifItemParser& /*aItem*/ )
     {
     TInt retVal( KErrNone );
-    // TMPXAttribute attr;
-    // attr = KMPXMediaGeneralMimeType;
+
     if ( !( TVcxMyVideosCollectionUtil::AttrBelongsToFullSet( KMPXMediaGeneralComment ) &&
          TVcxMyVideosCollectionUtil::AttrBelongsToFullSet( KMPXMediaGeneralCopyright ) &&
          TVcxMyVideosCollectionUtil::AttrBelongsToFullSet( KMPXMediaGeneralMimeType ) &&
@@ -430,6 +696,12 @@
          TVcxMyVideosCollectionUtil::AttrBelongsToFullSet( KMPXMediaVideoArtist ) ) )
         {
         retVal = KErrGeneral;
+        return retVal;
+        }
+    
+    if( TVcxMyVideosCollectionUtil::AttrBelongsToFullSet( KMPXMediaFail ) )
+        {
+        retVal = KErrGeneral;
         }
         
     return retVal;
@@ -455,6 +727,12 @@
             != KErrNotFound ) )
         {
         retVal = KErrGeneral;
+        return retVal;
+        }
+    
+    if( TVcxMyVideosCollectionUtil::Origin( KCategoryIdExtraItem3 ) != KErrNotFound )
+        {
+        retVal = KErrGeneral;
         }
     
     return retVal;
@@ -513,22 +791,6 @@
     return retVal;
     }
 
-// -----------------------------------------------------------------------------
-// CVcxMyVideosCollectionUtilTest::?member_function
-// ?implementation_description
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-/*
-TInt CVcxMyVideosCollectionUtilTest::?member_function(
-   CItemParser& aItem )
-   {
-
-   ?code
-
-   }
-*/
-
 // ========================== OTHER EXPORTED FUNCTIONS =========================
 // None
 
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/conf/VcxMyVideosMdsDbTest.cfg	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/conf/VcxMyVideosMdsDbTest.cfg	Wed Jun 09 09:44:23 2010 +0300
@@ -6,9 +6,15 @@
 RemoveVideoL
 UpdateVideoL
 CreateVideoListL
+DoCreateVideoListL
 CreateVideoL
-
-
+HandleQueryNewResultsL
+HandleQueryCompletedL
+AsyncHandleQueryCompletedL
+HandleSessionErrorL
+HandleObjectNotificationL
+HandleObjectPresentNotificationL
+ShutdownNotificationL
 
 [Test]
 title Create & delete
@@ -41,7 +47,11 @@
 title Cancel
 create VcxMyVideosMdsDbTest test
 test CreateL
-test CancelL
+loop 10
+test CancelL LOOP_COUNTER
+test DoCreateVideoListL 4
+test CancelL LOOP_COUNTER
+endloop
 test DeleteL
 delete test
 [Endtest]
@@ -50,11 +60,26 @@
 title AddVideoL
 create VcxMyVideosMdsDbTest test
 test CreateL
-test AddVideoL 0 0
+test AddVideoL 0 0 0 0 0
+allownextresult -2
+test AddVideoL 0 -2 0 0 
 allownextresult -2
-test AddVideoL 0 -2
-allownextresult -2
-test AddVideoL 1 0
+test AddVideoL 1 0 0 0 0
+
+test AddVideoL 0 0 0 0 0 1 
+test AddVideoL 0 0 0 0 1 0
+test AddVideoL 0 0 0 0 1 1
+test AddVideoL 0 0 0 1 0 0
+test AddVideoL 0 0 0 1 0 1
+test AddVideoL 0 0 0 1 1 0
+test AddVideoL 0 0 0 1 1 1
+test AddVideoL 0 0 1 0 0 1
+test AddVideoL 0 0 1 0 1 0
+test AddVideoL 0 0 1 0 1 1
+test AddVideoL 0 0 1 1 0 0
+test AddVideoL 0 0 1 1 0 1
+test AddVideoL 0 0 1 1 1 0
+test AddVideoL 0 0 1 1 1 1
 test DeleteL
 delete test
 [Endtest]
@@ -81,6 +106,8 @@
 test UpdateVideoL 1 0
 allownextresult -2
 test UpdateVideoL 0 -2
+allownextresult -14
+test UpdateVideoL 0 0 1
 test DeleteL
 delete test
 [Endtest]
@@ -89,11 +116,12 @@
 title CreateVideoL
 create VcxMyVideosMdsDbTest test
 test CreateL
-test CreateVideoL 0 0
-allownextresult -1
-test CreateVideoL 1 0
+test CreateVideoL 0 0 1 2
+test CreateVideoL 1 0 1 3
 allownextresult -2
-test CreateVideoL 0 -2
+test CreateVideoL 0 -2 1 4
+test CreateVideoL 0  0 0 5
+test CreateVideoL 0  0 0 0
 test DeleteL
 delete test
 [Endtest]
@@ -102,23 +130,127 @@
 title CreateVideoListL
 create VcxMyVideosMdsDbTest test
 test CreateL
-test CreateVideoListL  0 0 0 0
-test CreateVideoListL  0 0 0 1
-test CreateVideoListL  0 0 1 0
-test CreateVideoListL  0 0 1 0
-test CreateVideoListL  0 1 0 0
-test CreateVideoListL  0 1 0 1
-test CreateVideoListL  0 1 1 0
-test CreateVideoListL  0 1 1 1
-test CreateVideoListL  1 0 0 0
-test CreateVideoListL  1 0 0 1
-test CreateVideoListL  1 0 1 0
-test CreateVideoListL  1 0 1 1
-test CreateVideoListL  1 1 0 0
-test CreateVideoListL  1 1 0 1
-test CreateVideoListL  1 1 1 0
-test CreateVideoListL  1 1 1 1
+test CreateVideoListL
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title DoCreateVideoListL
+create VcxMyVideosMdsDbTest test
+test CreateL
+loop 128
+test DoCreateVideoListL  LOOP_COUNTER
+test CancelL
+endloop
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title HandleQueryNewResultsL
+create VcxMyVideosMdsDbTest test
+test CreateL
+test HandleQueryNewResultsL 0 0 0 
+test DoCreateVideoListL 0 1
+test HandleQueryNewResultsL 0 0 0 
+test HandleQueryNewResultsL 0 0 1 
+test HandleQueryNewResultsL 0 1 0
+test HandleQueryNewResultsL 0 1 1
+test HandleQueryNewResultsL 1 0 0 
+test HandleQueryNewResultsL 1 0 1 
+test HandleQueryNewResultsL 1 1 0
+test HandleQueryNewResultsL 1 1 1
+test HandleQueryNewResultsL 0 0 0 1
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title HandleQueryCompletedL
+create VcxMyVideosMdsDbTest test
+test CreateL
+test HandleQueryCompletedL 0 0 
+test HandleQueryCompletedL 0 1
+test HandleQueryCompletedL 1 0
+test HandleQueryCompletedL 1 1 
+test DoCreateVideoListL 0 1
+test HandleQueryCompletedL 0 0 
+test HandleQueryCompletedL 0 1
+test HandleQueryCompletedL 1 0
+test HandleQueryCompletedL 1 1 
 test DeleteL
 delete test
 [Endtest]
 
+[Test]
+title AsyncHandleQueryCompletedL
+create VcxMyVideosMdsDbTest test
+test CreateL
+test AsyncHandleQueryCompletedL 0 0 
+test AsyncHandleQueryCompletedL 0 1
+test AsyncHandleQueryCompletedL 1 0
+test AsyncHandleQueryCompletedL 1 1 
+test DoCreateVideoListL 0 1
+test AsyncHandleQueryCompletedL 0 0 
+test AsyncHandleQueryCompletedL 0 1
+test AsyncHandleQueryCompletedL 1 0
+test AsyncHandleQueryCompletedL 1 1 
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title HandleSessionErrorL
+create VcxMyVideosMdsDbTest test
+test CreateL
+test HandleSessionErrorL 0
+test HandleSessionErrorL 1
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title HandleObjectNotificationL
+create VcxMyVideosMdsDbTest test
+test CreateL
+loop 10
+test HandleObjectNotificationL LOOP_COUNTER
+endloop
+test HandleObjectNotificationL 1 1
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title HandleObjectPresentNotification
+create VcxMyVideosMdsDbTest test
+test CreateL
+test HandleObjectPresentNotification 0
+test HandleObjectPresentNotification 1
+test HandleObjectPresentNotification 0 1
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title ShutdownNotificationL
+create VcxMyVideosMdsDbTest test
+test CreateL
+test ShutdownNotificationL 0
+test ShutdownNotificationL 1
+test ShutdownNotificationL 2
+test DeleteL
+delete test
+[Endtest]
+
+[Test]
+title MdsServerTerminated
+create VcxMyVideosMdsDbTest test
+test CreateL
+test ShutdownNotificationL 1
+allownextresult -15
+test AddVideoL 4
+test DeleteL
+delete test
+[Endtest]
\ No newline at end of file
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/group/VcxMyVideosMdsDbTest.mmp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/group/VcxMyVideosMdsDbTest.mmp	Wed Jun 09 09:44:23 2010 +0300
@@ -17,7 +17,7 @@
 *
 */
 
-// %version: 1 %
+// %version: 2 %
 
 #include <platform_paths.hrh>
 
@@ -60,6 +60,8 @@
 SOURCE          mdeitem.cpp
 SOURCE          mdeinstanceitem.cpp
 SOURCE          mdeorderrule.cpp
+SOURCE          vcxmyvideosmdscmdqueue.cpp
+SOURCE          vcxmyvideosmdsalbums.cpp
 
 SOURCEPATH      ../../../src
 SOURCE          vcxmyvideosmdsdb.cpp
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/VcxMyVideosMdsDbTest.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/VcxMyVideosMdsDbTest.h	Wed Jun 09 09:44:23 2010 +0300
@@ -32,8 +32,22 @@
 #include <vcxmyvideosdefs.h>
 
 //#include <mpxmedia.h>
+
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
 #include "vcxmyvideosmdsdb.h"
-#include "vcxmyvideosactivetask.h"
+#undef private
+#undef protected
+
 
 
 // MACROS
@@ -95,7 +109,7 @@
         * @param aEvent Event type.
         * @param aId    Array of IDs in database.
         */
-        void HandleMyVideosDbEvent( TMPXChangeEventType aEvent, RArray<TUint32>& aId ){};
+        void HandleMyVideosDbEvent( TMPXChangeEventType aEvent, RArray<TUint32>& aId );
 
         /**
         * Handler function for list fetching events. This callback is called as a response
@@ -108,7 +122,7 @@
         *                            EFalse if there are more to come.
         */
         void HandleCreateVideoListResp( CMPXMedia* aVideoList,
-                TInt aNewItemsStartIndex, TBool aComplete ){};
+                TInt aNewItemsStartIndex, TBool aComplete );
 
         /**
         * Handler function for media remove/insert events. This is called every time
@@ -188,9 +202,26 @@
         virtual TInt UpdateVideoL( CStifItemParser& aItem );
 
         virtual TInt CreateVideoListL( CStifItemParser& aItem );
+        
+        virtual TInt DoCreateVideoListL( CStifItemParser& aItem );
 
         virtual TInt CreateVideoL( CStifItemParser& aItem );
         
+        virtual TInt HandleQueryNewResultsL( CStifItemParser& aItem );
+
+        virtual TInt HandleQueryCompletedL( CStifItemParser& aItem );
+        
+        virtual TInt AsyncHandleQueryCompletedL( CStifItemParser& aItem );
+        
+        virtual TInt HandleSessionErrorL( CStifItemParser& aItem );
+        
+        virtual TInt HandleObjectNotificationL( CStifItemParser& aItem );
+
+        virtual TInt HandleObjectPresentNotification( CStifItemParser& aItem );
+
+        virtual TInt ShutdownNotificationL( CStifItemParser& aItem );        
+        
+        
         /**
          * Method used to log version of test class
          */
@@ -207,7 +238,11 @@
     public:
     
         TInt mdssessionerror,  mdssessionasyncerror,
-        mdsoperationleaves, mdsoperationreturns ;
+        mdsoperationleaves, mdsoperationreturns, mdeobjectopenresult,
+        querycountresult, propertynotdefined, propertyisnull, handledbeventleave ;
+        
+        
+        CMPXMedia* iVideoList;
         
     };
 
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdeobjectquery.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdeobjectquery.h	Wed Jun 09 09:44:23 2010 +0300
@@ -132,6 +132,8 @@
 	 * Speed optimization to drop freetexts from results.
 	 */
 	TBool iFreetextsInResult;
+	
+	mutable CMdEObject* iCMdEObject;
     };
 
 #endif  // __MDEOBJECTQUERY_H__
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdesessionimpl.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mdesessionimpl.h	Wed Jun 09 09:44:23 2010 +0300
@@ -26,11 +26,11 @@
 class CMdEDataBuffer;
 class CMdCSerializationBuffer;
 class CMdESessionStartupAO;
-class CMdESessionAsyncHandler;
+class CMdeSessionStartTimer;
 
 class RMdESessionAsyncRequest
 	{
-		friend class CMdESessionAsyncHandler;
+		friend class CMdeSessionStartTimer;
 	private:
 		enum TRequestType
 		{
@@ -53,13 +53,13 @@
 		TRequestStatus* iRequestStatus;
 	};
 
-NONSHARABLE_CLASS(CMdESessionAsyncHandler) : public CTimer
+NONSHARABLE_CLASS(CMdeSessionStartTimer) : public CTimer
 {
 public:
 	
-	static CMdESessionAsyncHandler* NewL(MMdESessionObserver& aObserver);
+	static CMdeSessionStartTimer* NewL(MMdESessionObserver& aObserver);
 	
-	~CMdESessionAsyncHandler();
+	~CMdeSessionStartTimer();
 		
 private:
 	
@@ -67,7 +67,7 @@
 
 	void ConstructL();
 	
-	CMdESessionAsyncHandler(MMdESessionObserver& aObserver);
+	CMdeSessionStartTimer(MMdESessionObserver& aObserver);
 
 private:
 	RArray<RMdESessionAsyncRequest> iRequests;
@@ -630,7 +630,7 @@
 		
 		RPointerArray<CMdENamespaceDef> iNamespaceDefs;
 		
-//		CMdESessionAsyncHandler* iAsyncHandler;
+//		CMdeSessionStartTimer* iAsyncHandler;
 
 		TUint32 iNextQueryId;
 		
@@ -644,7 +644,7 @@
 			};
 		TSessionState iSessionState;
 		
-		CMdESessionAsyncHandler* iTimer;
+		CMdeSessionStartTimer* iTimer;
 	};
 
 #endif  // __MDESESSIONIMPL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/mpxmedia.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   MPX My Videos collection plugins' MDS database class*
+*/
+
+
+
+#include <platform/mw/mpxmedia.h>
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/myvideostesttrap.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies 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 MYVIDEOSTESTTRAP_H_
+
+#include <e32cmn.h>
+#undef TRAPD
+#undef TRAP_IGNORE
+
+#define TRAPD(_r, _s)                                       \
+    TInt _r;                                                \
+    {                                                       \
+    _r = 0;                                                 \
+    { TRAP_INSTRUMENTATION_START; }                         \
+    try {                                                   \
+        __WIN32SEHTRAP                                      \
+        TTrapHandler* ____t = User::MarkCleanupStack();     \
+        _s;                                                 \
+        User::UnMarkCleanupStack(____t);                    \
+        { TRAP_INSTRUMENTATION_NOLEAVE; }                   \
+        __WIN32SEHUNTRAP                                    \
+        }                                                   \
+    catch (XLeaveException& l)                              \
+        {                                                   \
+        _r = l.GetReason();                                 \
+        { TRAP_INSTRUMENTATION_LEAVE(_r); }                 \
+        }                                                   \
+                                                            \
+    __CALL_EMPTY_FUNCTION                                   \
+    { TRAP_INSTRUMENTATION_END; }                           \
+    }
+
+#define TRAP_IGNORE(_s)                                     \
+    {                                                       \
+    { TRAP_INSTRUMENTATION_START; }                         \
+    try {                                                   \
+        __WIN32SEHTRAP                                      \
+        TTrapHandler* ____t = User::MarkCleanupStack();     \
+        _s;                                                 \
+        User::UnMarkCleanupStack(____t);                    \
+        { TRAP_INSTRUMENTATION_NOLEAVE; }                   \
+        __WIN32SEHUNTRAP                                    \
+        }                                                   \
+    catch (XLeaveException& l)                              \
+        {                                                   \
+        l.GetReason();                                      \
+        { TRAP_INSTRUMENTATION_LEAVE(l.Reason()); }         \
+        }                                                   \
+                                                            \
+    __CALL_EMPTY_FUNCTION                                   \
+    { TRAP_INSTRUMENTATION_END; }                           \
+    }
+
+
+
+
+#define MYVIDEOSTESTTRAP_H_
+
+
+#endif /* MYVIDEOSTESTTRAP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosalbum.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,230 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Class representing album in My Videos collection.
+*/
+
+
+#ifndef CVCXMYVIDEOSALBUM_H
+#define CVCXMYVIDEOSALBUM_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+
+typedef TInt TVcxMyVideosAlbumVideo;
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
+
+class CMPXMedia;
+class CVcxMyVideosCollectionPlugin;
+
+// CLASS DECLARATION
+
+/**
+ * Contains information about video which belongs to some album.
+ * These are stored to CVcxMyVideosAlbum::iVideoList.
+ */
+//
+//NONSHARABLE_CLASS(TVcxMyVideosAlbumVideo)
+//    {
+//    public:
+//
+//        /**
+//         * Constructor.
+//         */
+//        TVcxMyVideosAlbumVideo();
+//
+//        /**
+//        * = operator.
+//        */        
+//        TVcxMyVideosAlbumVideo& operator=( const TVcxMyVideosAlbumVideo& aVideo );
+//
+//        /**
+//        * Set values.
+//        */
+//        void Set( TUint32 aMdsId, TUint32 aRelationMdsId, CMPXMedia* aVideo );
+//
+//        TUint32    iMdsId;         //Video object ID in MDS.
+//        TUint32    iRelationMdsId; //Relation ID in MDS, this is used when removing items from album.
+//        CMPXMedia* iMedia;
+//    };
+
+/**
+ * Contains list of videos belonging to an album. Videos can be searched, added and
+ * removed. Videos are kept in sorting order by MDS ID to speed up access. Pointers
+ * to media objects in collection cache are also stored to speed up access.
+ * Contains also logic for keeping album media attributes up to date.
+ */
+NONSHARABLE_CLASS(CVcxMyVideosAlbum) : public CBase
+    {    
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~CVcxMyVideosAlbum();
+
+    /**
+     * Two-phased constructor.
+     */
+    static CVcxMyVideosAlbum* NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    /**
+     * Two-phased constructor.
+     */
+    static CVcxMyVideosAlbum* NewLC( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    // new methods
+    
+    /**
+     * Sets up this album.
+     * 
+     * @param aAlbum  Media class to set from.
+     */
+    void SetL( /*CMPXMedia& aAlbum*/ );
+    
+    /**
+     * Sorts iVideoList by MDS ID.
+     */
+    void Sort();
+    
+    /**
+     * Checks if aMdsId belongs to this album. Checking is
+     * done using bisection method.
+     * 
+     * @param aMdsId  Id to check.
+     */
+    TBool BelongsToAlbum( TUint32 aMdsId );
+
+    /**
+     * Finds video from iVideoList. Uses bisection method, ie
+     * is fast.
+     * 
+     * @param aMdsId  Video to find.
+     * @param aVideo  If found, this is filled with data.
+     * @param aIndex  Position in iVideoList where from the video
+     *                was found.
+     * @return        System-wide error code. If != KErrNone, then
+     *                aVideo and aIndex won't contain valid data.
+     */
+    TInt Video( TUint32 aMdsId, TVcxMyVideosAlbumVideo& aVideo, TInt& aIndex );
+
+    /**
+     * Adds aVideo to this album. The id array is kept in ascending order.
+     * 
+     * @param aVideo  Video to add.
+     */
+    void AddL( TVcxMyVideosAlbumVideo aVideo );
+
+    /**
+     * Removes videos from this album.
+     * 
+     * @param aMdsIds Array containing IDs of the videos to remove.
+     */
+    void Remove( RArray<TUint32>& aMdsIds );
+
+    /**
+     * Removes aMdsId from this album.
+     * 
+     * @param aMdsId    ID to remove.
+     * @param aCompress If ETrue, then Compress is called to iVideoList.
+     *                  ETrue as default.
+     */
+    void Remove( TUint32 aMdsId, TBool aCompress = ETrue );
+    
+    /**
+     * Used for keeping RArray<TVcxMyVideosAlbumVideo> in integer order by
+     * TVcxMyVideosAlbumVideo::iMdsId.
+     * 
+     * @param aVideo1 Video to compare
+     * @param aVideo2 Video to compare
+     * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
+     *         aVideo2.
+     */
+    static TInt CompareVideosByMdsId( const TVcxMyVideosAlbumVideo& aVideo1,
+            const TVcxMyVideosAlbumVideo& aVideo2 );
+
+    /**
+     * Creates video list belonging to this album. Ownership goes to caller.
+     * 
+     * @return Media containing media array. Array items are videos.
+     */
+    CMPXMedia* CreateVideoListL();
+
+    /**
+     * Appends items from aFromVideoList to aToVideoList if they belong to
+     * this album.
+     * 
+     * @param aFromVideoList     From list.
+     * @param aToVideoList       To List.
+     * @param aNewItemStartIndex Start index of the copy. Items in aFromVideoList before this
+     *                           value are ignored.
+     */
+    void AppendToVideoListL( CMPXMedia& aFromVideoList,
+            CMPXMedia& aToVideoList, TInt aNewItemStartIndex );
+
+    /**
+     * Calculates KVcxMediaMyVideosCategoryItemCount, KVcxMediaMyVideosCategoryNewItemCount,
+     * KVcxMediaMyVideosCategoryNewItemName and KMPXMediaGeneralDate attributes to iMedia.
+     * 
+     * @param aStartIndex  Start position of the calculations in iVideoList.
+     *                     Can be used to update values when items are appended
+     *                     to old list, without calculating everything from scratch.
+     */
+    void CalculateAttributesL( TInt aStartIndex = 0 );
+    
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CVcxMyVideosAlbum( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+    CVcxMyVideosCollectionPlugin& iCollection;
+    
+    /**
+     * MDS ID of this album.
+     */
+    TUint32 iMdsId;
+
+    /**
+     * MPX media object representing this album in collection, not own.
+     * The item is owned by CVcxMyVideosAlbums::iAlbumList
+     */
+    CMPXMedia* iMedia;
+
+    /**
+     * Array containing info about videos belonging to this album.
+     */
+    RArray<TVcxMyVideosAlbumVideo> iVideoList;
+            
+    };
+
+#endif // CVCXMYVIDEOSALBUM_H
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideoscollectionutil.h	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideoscollectionutil.h	Wed Jun 09 09:44:23 2010 +0300
@@ -22,11 +22,14 @@
 #define VCXMYVIDEOSCOLLECTIONUTIL_H
 
 // INCLUDES
+#include <vcxmyvideosdefs.h>
 
 // FORWARD DECLARATIONS
 class CMPXMedia;
 class RFs;
 
+#include "myvideostesttrap.h"
+
 // CONSTANTS
 
 // CLASS DECLARATION
@@ -83,6 +86,15 @@
                 RArray<TUint32>& aMdsIds );
 
         /**
+        * Appends all items from aFromList to aToList. New items will point to
+        * same shared memory.
+        *
+        * @param aToList   List in which items are appended to.
+        * @param aFromList List in which items are copied from.
+        */
+        static void AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList );
+
+        /**
         * Converts drive letter to drive number.
         *
         * @param aDrive drive letter
@@ -118,6 +130,14 @@
         static TUint32 FlagsL( CMPXMedia& aVideo );
 
         /**
+         * Gets KMPXMediaGeneralDate (creation date) of aVideo.
+         * 
+         * @param aVideo  Media object to fetch parameter from.
+         * @return        Creation date, works with TTime.
+         */
+        static TInt64 CreationDateL( CMPXMedia& aVideo );
+
+        /**
         * Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
         *
         * @param aVideo  Media object to fetch parameter from.
@@ -139,7 +159,7 @@
         * @param aVideo  Media object to fetch parameter from.
         * @return        ID.
         */
-        static TMPXItemId IdL( CMPXMedia& aVideo );
+        static TMPXItemId IdL( const CMPXMedia& aVideo );
 
         /**
         * Gets KVcxMediaMyVideosDuration attribute of aVideo.
@@ -155,7 +175,7 @@
         * @return  KMPXMediaGeneralTitle value. If attribute is not supported,
         *          then KNullDesC is returned.
         */
-        static const TDesC& Title( CMPXMedia& aVideo );
+        static const TDesC& Title( const CMPXMedia& aVideo );
 
         /**
         * Gets KVcxMediaMyVideosRating attribute of the video.
@@ -207,6 +227,44 @@
         */
         static TInt Origin( TInt aCategoryId );
 
+        /**
+         * Gets KMPXMediaArrayContents attribute from aMedia. Leaves
+         * with KErrArgument is attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Pointer to media array.
+         */
+        static CMPXMediaArray* MediaArrayL( const CMPXMedia& aMedia );
+        
+        /**
+         * Gets KVcxMediaMyVideosInt32Value attribute from aMedia. Leaves
+         * with KErrArgument if attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Value of KVcxMediaMyVideosInt32Value attribute.
+         */
+        static TInt32 Int32ValueL( CMPXMedia& aMedia );
+
+        /**
+         * Gets KVcxMediaMyVideosUint32Value attribute from aMedia. Leaves
+         * with KErrArgument if attribute is not supported.
+         * 
+         * @param aMedia  Media where from the attribute is fetched.
+         * @return        Value of KVcxMediaMyVideosUint32Value attribute.
+         */
+        static TUint32 Uint32ValueL( CMPXMedia& aMedia );
+        
+        /**
+         * Gets KMPXMediaGeneralId attributes from aMediaArray and
+         * puts them to aIdArray. aIdArray is reset before adding.
+         * 
+         * @param aMediaArray  Media array containing media items which
+         *                     have KMPXMediaGeneralId attribute set.
+         * @param aIdArray     Array where to the IDs are written to.
+         */
+        static void GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
+                RArray<TUint32>& aIdArray );
+
 #ifdef _DEBUG
         /**
         * Prints process names which have file handle open to aFileName
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosmdsalbums.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,541 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Provides albums support from MDS*
+*/
+
+
+
+#ifndef VCXMYVIDEOSMDSALBUMS_H
+#define VCXMYVIDEOSMDSALBUMS_H
+
+// INCLUDES
+#include <mdequery.h>
+#include <mpxmedia.h>
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class MVcxMyVideosMdsAlbumsObserver;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Provides albums support, uses MDS.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsAlbums) :
+        public CActive,
+        public MMdEQueryObserver,
+        public MMdERelationItemObserver
+#if 0
+        ,
+        public MMdERelationObserver
+#endif
+    {    
+    public: // Constructors and destructor
+        
+        friend class CVcxMyVideosMdsCmdQueue;
+        friend class CVcxMyVideosMdsDb;
+        
+        enum TVcxAsyncOperation
+            {
+            EVcxNone,
+            EVcxAddVideosToAlbum,
+            EVcxRemoveRelations,
+            EVcxRemoveAlbums
+            };
+        
+        /**
+        * Constructor.
+        * 
+        * @param aMdsDb    Owner of this object.
+        * @param aObserver Object which is listening album related events. If NULL, then
+        *                  no observer is set.
+        */
+        static CVcxMyVideosMdsAlbums* NewL( CVcxMyVideosMdsDb& aMdsDb,
+                MVcxMyVideosMdsAlbumsObserver* aObserver );
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsAlbums();
+
+    public: // new methods
+
+        /**
+         * From CActive.
+         * Cancels possible ongoing asynchronous request.
+         * 
+         * @param aType Defines what kind of request is cancelled.
+         */
+        void DoCancel( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+
+        /**
+         * Cancels queries.
+         *
+         * @param aType Defines what kind of request is cancelled.
+         */
+        void CancelQueries( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+        
+        /**
+        * Gets My Videos albums from MDS asynchronously.
+        * HandleGetAlbumsResp() callback function is called when ready.
+        * Utilizes CVcxMyVideosMdsCmdQueue.
+        *
+        * @param aAlbumList  Album list is written here. Caller owns this, ownership
+        *                    does not move.
+        * @param aClient     Response call is done to this object.
+        */
+        void GetAlbumsL( CMPXMedia* aAlbumList, MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album from MDS synchronously.
+         * 
+         * @param aId  MDS ID of the album to be fetched.
+         * @returm     MPX media containing album data. Ownership
+         *             moves to caller. NULL if not found.
+         */
+        CMPXMedia* GetAlbumL( TUint32 aId );
+
+        /**
+         * Gets album content IDs asynchronously.
+         * HandleGetAlbumContentIdsResp() callback function is called when ready.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aAlbumId      Album ID.
+         * @param aContentArray Item IDs which belog to aAlbum are written here. Caller must
+         *                      keep aContentArray available until HandleGetAlbumContentIdsResp
+         *                      has been called.
+        * @param aClient        Response call is done to this object.
+         */
+        void GetAlbumContentIdsL( TUint32 aAlbumId, RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Gets album content videos asynchronously.
+         * HandleGetAlbumContentVideosResp() callback function is called when ready.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         * 
+         * @param aAlbumId    Album ID.
+         * @param aVideoList  Media containing media array. Video media objects are added to media array.
+         *                    Caller must keep aVideoList available until callback has been called.
+         * @param aClient     Response call is done to this object.
+         */
+        void GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Adds videos to album asynchronously. HandleAddVideosToAlbumResp() callback function
+         * is called when operation finishes.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aMpxCmd    Media containing command parameters: album ID and video ID list.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosAddToAlbum command. Ownership does not move.
+         *                   
+         * @param aClient    Response call is done to this object.
+         */
+        void AddVideosToAlbumL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes relations asynchronously.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         * 
+         * @param aRelationIds  Relations which are removed.
+         * @param aResults      In sync with aRelationIds. Result codes, KErrNone if successful,
+         *                      KErrGeneral if failed.
+         * @param aClient       Response call is done to this object.
+         */
+        void RemoveRelationsL( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient );
+ 
+        /**
+         * Adds album to MDS. aAlbum should have KMPXMediaGeneralTitle attribute
+         * set. The MDS item ID of the created album is written to KMPXMediaGeneralId
+         * attribute.
+         * 
+         * @param aAlbum  Album which is added to database. 
+         */
+        void AddAlbumL( CMPXMedia& aAlbum );
+        
+        /**
+         * Removes albums asynchronously. HandleRemoveAlbumsResp() callback function
+         * is called when operation finishes.
+         * Utilizes CVcxMyVideosMdsCmdQueue.
+         *
+         * @param aMpxCmd    Media containing command parameters: media array containing album IDs.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosRemoveAlbums command. Ownership does not move.
+         *                   
+         * @param aClient    Response call is done to this object.
+         */        
+        void RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Sets album attributes.
+         * 
+         * @param aVideo  Values from aVideo are written to MDS.
+         */
+        void SetAlbumL( CMPXMedia& aVideo );
+        
+    protected:
+        
+        /**
+        * From CActive.
+        * Called when operation completes.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * Actual implementation for cancelling.
+        */
+        void DoCancel();
+        
+    private:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
+                MVcxMyVideosMdsAlbumsObserver* aObserver );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Copies album data from aObject to aAlbum.
+        *
+        * @param aObject  MDS object to copy data from.
+        * @param aAlbum   MPX media to copy data to.
+        */
+        void Object2MediaL( CMdEObject& aObject, CMPXMedia& aAlbum );
+        
+        /**
+         * Copies album data from aAlbum to aObject.
+         * 
+         * @param aAlbum MPX media to copy data from.
+         * @param aObject MDS object to copy data to.
+         */
+        void Media2ObjectL( CMPXMedia& aAlbum, CMdEObject& aObject);
+
+        /**
+        * Gets various defintions from MDS and stores them to member variables.
+        */
+        void GetSchemaDefinitionsL();
+
+        /**
+        * Gets My Videos albums from MDS asynchronously.
+        * HandleGetAlbumsResp() callback function is called when ready.
+        *
+        * @param aAlbumList  Album list is written here. Caller owns this, ownership
+        *                    does not move.
+        * @param aClient     Callback is done to this object.
+        */
+        void DoGetAlbumsL( CMPXMedia* aAlbumList, MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album content IDs from MDS asynchronously.
+         * HandleGetAlbumContentIdsResp() callback function is called when ready.
+         *
+         * @param aAlbumId      Album ID.
+         * @param aContentArray Array containing MDS IDs which belong to aAlbum.
+         *                      Caller is responsible to keep array available
+         *                      until HandleGetAlbumContentResp has been called. 
+        * @param aClient        Callback is done to this object.
+         */
+        void DoGetAlbumContentIdsL( TUint32 aAlbumId,
+                RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Gets album content videos from MDS asynchronously.
+         * HandleGetAlbumContentVideosResp() callback function is called when ready.
+         * 
+         * @param aAlbumId   Album ID.
+         * @param aVideoList Media containing empty media array. Videos are added to array. Caller
+         *                   must keep aVideoList available until HandleGetAlbumContentVideosResp
+         *                   is called.
+         * @param aClient    Callback is done to this object.
+         */
+        void DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+         * Adds videos to album asynchronously. HandleAddVideosToAlbumResp() callback function
+         * is called when operation finishes.
+         * 
+         * @param aMpxCmd    Media containing command parameters: album ID and video ID list.
+         *                   Results are also written to this object. See media structure and
+         *                   used attributes from vcxmyvideosdef.c file,
+         *                   KVcxCommandMyVideosAddToAlbum command. Ownership does not move.
+         * @param aClient    Response call is done to this object.
+         */
+        void DoAddVideosToAlbumL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes relations asynchronously.
+         * 
+         * @param aRelationIds  Relations which are removed.
+         * @param aResults      In sync with aRelationIds. Result codes, KErrNone if successful,
+         *                      KErrGeneral if failed.
+         * @param aClient       Response call is done to this object.
+         */
+        void DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
+                RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient );
+        
+        /**
+         * Removes albums asynchronously.
+         * 
+         * @param aMpxCmd  Media containing command parameters: array with albums IDs.
+         * @param aClient  Response call is done to this object.
+         */
+        void DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
+                MVcxMyVideosMdsAlbumsObserver& aClient );
+
+        /**
+        * Handles album query responses.
+        * 
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        */
+        void HandleAlbumQueryCompletedL(CMdEQuery& aQuery, TInt aError);
+
+        /**
+        * Handles video query responses.
+        * 
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        * @param aFirstNewItemIndex Index of the first new item in the query.
+        * @param aNewItemCount      How many new items were added.
+        * @param aComplete          ETrue if query is complete, EFalse if new to come.
+        */
+        void HandleVideoQueryResultsL( CMdEQuery& aQuery, TInt aError,
+                TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete );
+
+        /**
+         * Handles relation query responses.
+         * 
+         * @param aQuery Query instance.
+         * @param aError  <code>KErrNone</code>, if the query was completed
+         *                successfully. Otherwise one of the system-wide error 
+         *                codes.
+         */
+        void HandleRelationQueryCompletedL( CMdEQuery& aQuery, TInt aError );
+
+        /**
+         * Called from RunL when video adding to album completes.
+         */
+        void HandleAddVideosToAlbumCompletedL();
+
+        /**
+         * Called from RunL when relations remove completes.
+         */
+        void HandleRemoveRelationsCompletedL();
+
+        /**
+         * Called from RunL when albums remove completes.
+         */
+        void HandleRemoveAlbumsCompletedL();
+
+        /**
+         * Registers observing to MDS session.
+         */
+        void SetObservingL();
+        
+    protected:
+
+        /**
+        * From MMdEQueryObserver.
+        * Called to notify the observer that new results have been received 
+        * in the query.
+        *
+        * @param aQuery              Query instance that received new results.
+        * @param aFirstNewItemIndex  Index of the first new item that was added
+        *                            to the result item array.
+        * @param aNewItemCount       Number of items added to the result item 
+        *                            array.
+        */
+        void HandleQueryNewResults(CMdEQuery& aQuery,
+                TInt aFirstNewItemIndex,
+                TInt aNewItemCount);
+
+        /**
+        * From MMdEQueryObserver.
+        * Called to notify the observer that the query has been completed,
+        * or that an error has occured.
+        *
+        * @param aQuery  Query instance.
+        * @param aError  <code>KErrNone</code>, if the query was completed
+        *                successfully. Otherwise one of the system-wide error 
+        *                codes.
+        */
+        void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
+
+        /**
+         * From MMdERelationItemObserver
+         */
+        void HandleRelationItemNotification(CMdESession& aSession, 
+                    TObserverNotificationType aType,
+                    const RArray<TMdERelation>& aRelationArray);
+
+        /**
+         * From MMdERelationObserver
+         */
+        void HandleRelationNotification(CMdESession& aSession, 
+                TObserverNotificationType aType,
+                const RArray<TItemId>& aRelationIdArray);
+        
+    private:
+        
+        /**
+         * Main class for Mds operations. Owns session to MDS.
+         */
+        CVcxMyVideosMdsDb& iMdsDb;
+        
+        /**
+         * Observer of albums related events. May be NULL.
+         * not own.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iObserver;
+        
+        /**
+        * Asynchronous album object fetching query is stored here. Own.
+        */
+        CMdEObjectQuery* iAlbumQuery;
+
+        /**
+        * Asynchronous video object fetching query is stored here. Own.
+        */
+        CMdEObjectQuery* iVideoQuery;
+
+        /**
+        * Asynchronous relation fetching query is stored here. Own.
+        */
+        CMdERelationQuery* iRelationQuery;
+                
+        /**
+        * The default namespace definition, not own.
+        */
+        CMdENamespaceDef* iNamespaceDef;
+        
+        /**
+        * Album object definition, not own.
+        */
+        CMdEObjectDef* iAlbumObjectDef;
+        
+        /**
+        * Album type property definition, not own.
+        */
+        CMdEPropertyDef* iTypePropertyDef;
+        
+        /**
+         * "Contains" relation definition, not own.
+         */
+        CMdERelationDef* iContainsRelationDef;
+        
+        /**
+        * Pointer to album list which is being fetched from MDS. Not own.
+        */
+        CMPXMedia* iAlbumList;
+
+        /**
+        * Pointer to video list which is being fetched from MDS. Not own.
+        */
+        CMPXMedia* iVideoList;
+
+        /**
+         * When doing some async operation to MDS, the album ID is stored here.
+         */
+        TUint32 iAlbumId;
+        
+        /**
+         * When fetching album content from MDS, the pointer to content array is stored here.
+         * Only MDS ID is filled to TVideo.
+         * Not own.
+         */
+        RArray<TVcxMyVideosAlbumVideo>* iAlbumContent;
+
+        /**
+         * The pending async operation ID is stored here.
+         */
+        TVcxAsyncOperation iAsyncOperation;
+
+        /**
+         * Used for storing items during async mds operations.
+         */
+        RPointerArray<CMdEInstanceItem> iItemArray;
+        
+        /**
+         * Used for storing result buffer during async mds operations.
+         */
+        //RMdEDataBuffer iResultBuffer;
+
+        /**
+         * Used in async operations to store
+         * pointer to result array (which is owned by the user). 
+         */
+        RArray<TInt>* iResultArray;
+
+        /**
+         * Used in async operations to store
+         * pointer to result array (which is owned by the user). 
+         */
+        RArray<TUint32>* iResultArrayUint32;
+        
+        /**
+         * Used in async oprations (EVcxAddVideosToAlbum and EVcxRemoveVideosFromAlbum) to store
+         * pointer to item ID array (which is owned by the user). 
+         */
+        RArray<TUint32>* iIdArray;
+                
+        /**
+         * Used to store command parameters during async MDS operations. Not owned.
+         */
+        CMPXMedia* iMpxCmd;
+        
+        /**
+         * Used to store pointer to client who initiated the async operation.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iClient;
+
+    };
+
+#endif   // VCXMYVIDEOSMDSALBUMS_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/inc/vcxmyvideosmdscmdqueue.h	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,343 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Queues commands to MDS.
+*/
+
+
+
+#ifndef VCXMYVIDEOSMDSCMDQUEUE_H
+#define VCXMYVIDEOSMDSCMDQUEUE_H
+
+// INCLUDES
+#include <vcxmyvideosdefs.h>
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
+// FORWARD DECLARATIONS
+class CMPXMedia;
+class MVcxMyVideosMdsAlbumsObserver;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* All MDS commands inherit this.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmd) : public CBase
+    {    
+    public:
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmd() {}
+        
+        /**
+        * Command type. Used for casting the pointer to correct type.
+        */
+        CVcxMyVideosMdsDb::TRequestType iCmdType;
+        
+        /**
+         * Pointer to client is stored here, used for performing response call.
+         */
+        MVcxMyVideosMdsAlbumsObserver* iClient;    
+    };
+
+/**
+* Class which encapsulates GetVideoListL function parameters.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetVideoList) : public CVcxMyVideosMdsCmd
+    {    
+    public:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetVideoList() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetVideoList() {}
+
+    public:
+        /**
+        * Stored CreateVideoListL function parameters, see meanings from vcxmyvideosmdsdb.h file.
+        */
+        TVcxMyVideosSortingOrder iSortingOrder;
+        TBool                    iAscending;
+        TBool                    iFullDetails;
+        CMPXMedia**              iVideoList;
+    };
+
+/**
+* Class which stores GetAlbumsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbums) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbums() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbums() {}
+
+    public:
+        /**
+        * Stored GetAlbumsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        CMPXMedia* iAlbumList;
+    };
+
+/**
+* Class which stores GetAlbumContentIdsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbumContentIds) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbumContentIds() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbumContentIds() {}
+
+    public:
+        /**
+        * Stored GetAlbumContentL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        TUint32                         iAlbumId;        
+        RArray<TVcxMyVideosAlbumVideo>* iAlbumContent; //not own
+    };
+
+/**
+* Class which stores GetAlbumContentVideosL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdGetAlbumContentVideos) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdGetAlbumContentVideos() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdGetAlbumContentVideos() {}
+
+    public:
+        /**
+        * Stored GetAlbumContentL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        TUint32    iAlbumId;        
+        CMPXMedia* iAlbumContentVideos; //not own
+    };
+
+/**
+* Class which stores AddVideosToAlbumL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdAddVideosToAlbum) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdAddVideosToAlbum() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdAddVideosToAlbum() {}
+
+    public:
+        /**
+        * Stored AddVideosToAlbumL function parameters, see meanings from vcxmyvideosdefs.h
+        * KVcxCommandMyVideosAddToAlbum command descriptions.
+        */
+        CMPXMedia* iMpxCmd;
+    };
+
+/**
+* Class which stores RemoveRelationsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdRemoveRelations) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdRemoveRelations() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdRemoveRelations() {}
+
+    public:
+        /**
+        * Stored RemoveRelationsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        RArray<TUint32>* iRelationIds; //not own
+        RArray<TUint32>* iResults;  //not own
+    };
+
+/**
+* Class which stores RemoveAlbumsL function arguments.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdRemoveAlbums) : public CVcxMyVideosMdsCmd
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdRemoveAlbums() {}
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdRemoveAlbums() {}
+
+    public:
+        /**
+        * Stored RemoveAlbumsL function parameters, see meanings from vcxmyvideosmdsalbums.h file.
+        */
+        CMPXMedia* iMpxCmd; //not own
+    };
+
+/**
+* Queues MDS commands.
+*
+* @lib mpxmyvideoscollectionplugin.lib
+*/
+NONSHARABLE_CLASS(CVcxMyVideosMdsCmdQueue) : public CBase
+    {    
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor
+        * @return object constructed
+        */
+        static CVcxMyVideosMdsCmdQueue* NewL( CVcxMyVideosMdsDb& aMdsDb );
+
+        /**
+        * Destructor
+        */
+        virtual ~CVcxMyVideosMdsCmdQueue();
+
+    public: // new methods
+        
+        /**
+        * Executes command if queue is empty, otherwise adds it to queue.
+        * Ownership of aCmd moves to this object.
+        *
+        * @param aCmd  Command to execute.
+        */
+        void ExecuteCmdL( CVcxMyVideosMdsCmd* aCmd );
+        
+        /**
+        * Called when command finishes. Executes next command from the queue.
+        */
+        void CmdFinished();
+        
+        /**
+         * Removes commands from command queue.
+         * 
+         * @param aType Defines what kind of commands are removed from the command queue.
+         */
+        void Cancel( CVcxMyVideosMdsDb::TRequestType aType = CVcxMyVideosMdsDb::EAll );
+                        
+    private:
+
+        /**
+        * Constructor
+        */
+        CVcxMyVideosMdsCmdQueue( CVcxMyVideosMdsDb& aMdsDb );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+        
+        /**
+        * Executes the command.
+        *
+        * @param aCmd  Command to execute, ownership does not move.
+        */
+        void DoExecuteCmdL( CVcxMyVideosMdsCmd* aCmd );
+                    
+    private:
+        
+        /**
+        * Owner of this object.
+        */
+        CVcxMyVideosMdsDb& iMdsDb;
+        
+        /**
+        * Command queue. Own.
+        */
+        RArray<CVcxMyVideosMdsCmd*> iQueue;
+        
+        /**
+        * Set to ETrue when command is started and to EFalse
+        * when command finishes.
+        */
+        TBool iCmdInProgress;
+    };
+
+#endif   // VCXMYVIDEOSMDSCMDQUEUE_H
+
+
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 1 %
+// Version : %version: 6 %
 
 // [INCLUDE FILES] - do not remove
 #include <e32svr.h>
@@ -35,7 +35,20 @@
 #include <mpxmediavideodefs.h>
 #include <centralrepository.h>
 
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
 #include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
 #include "vcxmyvideoscollectionutil.h"
 
 
@@ -103,7 +116,7 @@
 //
 void CVcxMyVideosMdsDbTest::Delete() 
     {
-
+    delete iVideoList;
     }
 
 // -----------------------------------------------------------------------------
@@ -124,7 +137,16 @@
         ENTRY( "RemoveVideoL", CVcxMyVideosMdsDbTest::RemoveVideoL ),
         ENTRY( "UpdateVideoL", CVcxMyVideosMdsDbTest::UpdateVideoL ),
         ENTRY( "CreateVideoListL", CVcxMyVideosMdsDbTest::CreateVideoListL ),
-        ENTRY( "CreateVideoL", CVcxMyVideosMdsDbTest::CreateVideoL )
+        ENTRY( "DoCreateVideoListL", CVcxMyVideosMdsDbTest::DoCreateVideoListL ),
+        ENTRY( "CreateVideoL", CVcxMyVideosMdsDbTest::CreateVideoL ),
+        ENTRY( "HandleQueryNewResultsL", CVcxMyVideosMdsDbTest::HandleQueryNewResultsL ),
+        ENTRY( "HandleQueryCompletedL", CVcxMyVideosMdsDbTest::HandleQueryCompletedL ),
+        ENTRY( "AsyncHandleQueryCompletedL", CVcxMyVideosMdsDbTest::AsyncHandleQueryCompletedL ),
+        ENTRY( "HandleSessionErrorL", CVcxMyVideosMdsDbTest::HandleSessionErrorL ),
+        ENTRY( "HandleObjectNotificationL", CVcxMyVideosMdsDbTest::HandleObjectNotificationL ),
+        ENTRY( "HandleObjectPresentNotification", CVcxMyVideosMdsDbTest::HandleObjectPresentNotification ),
+        ENTRY( "ShutdownNotificationL", CVcxMyVideosMdsDbTest::ShutdownNotificationL ),
+
         };
 
     const TInt count = sizeof( KFunctions ) / 
@@ -153,7 +175,7 @@
     return KErrNone;
     }
 
-TInt CVcxMyVideosMdsDbTest::DeleteL( CStifItemParser& aItem )
+TInt CVcxMyVideosMdsDbTest::DeleteL( CStifItemParser& )
     {
     delete iMdsDb;
     return KErrNone;
@@ -161,82 +183,80 @@
 
 TInt CVcxMyVideosMdsDbTest::CancelL( CStifItemParser& aItem )
     {
-    iMdsDb->Cancel();
+    TInt type = NextIntOrZero( aItem );
+    iMdsDb->Cancel( ( CVcxMyVideosMdsDb::TRequestType ) type );
     return KErrNone;
     }
 
 TInt CVcxMyVideosMdsDbTest::AddVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TBool setMimeType   = NextIntOrZero( aItem ) ;
+    propertynotdefined  = NextIntOrZero( aItem );
+    propertyisnull      = NextIntOrZero( aItem );
+    TBool setAttrs      = NextIntOrZero( aItem ) ;
     
     CMPXMedia* media  = CMPXMedia::NewL();
-    
+    CleanupStack::PushL( media );
     TUint32 mdsId;
     
-    //1. MPX ID, set by collection
-    //2
-    media->SetTextValueL( KMPXMediaGeneralTitle, _L("KMPXMediaGeneralTitle") );
-    //3
-    media->SetTextValueL( KMPXMediaGeneralComment, _L("KMPXMediaGeneralComment") );
-    //4
     media->SetTextValueL( KMPXMediaGeneralUri, _L("c:\\data\\videos\\addtest1.mp4") );
-    //5
-    media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
-    //6 Creation date
-    TTime time;
-    time.HomeTime();
-    media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, time.Int64() );
-    //7
-    TUint32 flags = EVcxMyVideosVideoDrmProtected || EVcxMyVideosVideoNew;
-    media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags );
-    //8
-    media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") ); 
-    //9
-    media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );
     
-    //10
-    TInt lastPlaybackPos( 13232 );
-    media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, lastPlaybackPos );
-    //11
-    media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, time.Int64() );    
-    //12
-    media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
-    //13
-    media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
-    //14
-    media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
-    //15
-    media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
-    //16
-    TReal32 duration( 1212 );
-    media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, duration );
-    //17
-    media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-    //18
-    media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
+    if ( setAttrs )
+        {
+        media->SetTextValueL( KMPXMediaGeneralTitle, _L("KMPXMediaGeneralTitle") );
+        media->SetTextValueL( KMPXMediaGeneralComment, _L("KMPXMediaGeneralComment") );
+        media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
+        media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, 1465324313154 );
+        media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, 10 );
+        media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") );    
+        media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, 13232 );
+        media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, 1465324313154 );
+        media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
+        media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
+        media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
+        media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
+        media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, 1212 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
+        media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
+        media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
+        media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoBitRate, 1235 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoWidth, 15 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoHeight, 12 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc, 0 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc, 0 );
+        media->SetTextValueL( KMPXMediaVideoArtist, _L("artist") );
+        media->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, 123456 );
+        }
 
-    media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
-    
-    media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
+    if ( setMimeType )
+        {
+        media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );    
+        }
     
     iMdsDb->AddVideoL( *media, mdsId );
     
-    delete media;
+    CleanupStack::PopAndDestroy( media );
+    
     return KErrNone;
     }
 
 TInt CVcxMyVideosMdsDbTest::RemoveVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
-    
-    TInt id;
-    aItem.GetNextInt( id );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TInt id             = NextIntOrZero( aItem );
+
     return iMdsDb->RemoveVideo( id );
     }
 
 TInt CVcxMyVideosMdsDbTest::UpdateVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    mdeobjectopenresult = NextIntOrZero( aItem );
     
     CMPXMedia* media  = CMPXMedia::NewL();
     CleanupStack::PushL(media);
@@ -292,30 +312,63 @@
     return KErrNone;
     }
 
-TInt CVcxMyVideosMdsDbTest::CreateVideoListL( CStifItemParser& aItem )
+TInt CVcxMyVideosMdsDbTest::CreateVideoListL( CStifItemParser& )
+    {    
+    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) 0;
+
+    CMPXMedia* videoList( NULL );
+    CMPXMedia* localvideoList( NULL );
+    CMPXMediaArray* mediaArray( NULL );
+                        
+   
+    iMdsDb->CreateVideoListL( sortingorder, 0, 0, videoList );
+    
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::DoCreateVideoListL( CStifItemParser& aItem )
     {
-    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) NextIntOrZero( aItem );
-    TBool ascending                       = NextIntOrZero( aItem );
-    TBool fullDetails                     = NextIntOrZero( aItem );
-    TBool docreate                        = NextIntOrZero( aItem );
+    TBool bitmask = NextIntOrZero( aItem );
+    TBool storelist = NextIntOrZero( aItem );
     
+    TBool ascending                       = bitmask & 0x01;
+    TBool fullDetails                     = bitmask & 0x02;
+    TBool docreate                        = bitmask & 0x04;
+    TBool fetchongoing                    = bitmask & 0x08;
+    
+    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) ( bitmask >> 4 );
+
     CMPXMedia* videoList( NULL );
+    CMPXMedia* localvideoList( NULL );
     CMPXMediaArray* mediaArray( NULL );
                         
     if ( docreate )
         {
-        videoList = CMPXMedia::NewL();
-        CleanupStack::PushL( videoList );
+        localvideoList = CMPXMedia::NewL();
+        CleanupStack::PushL( localvideoList );
         mediaArray = CMPXMediaArray::NewL();
-        videoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
         CleanupStack::PushL( mediaArray );
+        localvideoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
+        CleanupStack::PopAndDestroy( mediaArray );
+        
+        videoList = localvideoList;
         }
     
-    iMdsDb->CreateVideoListL( sortingorder, ascending, fullDetails, videoList );
+    if ( fetchongoing )
+        {
+        iMdsDb->DoCreateVideoListL( sortingorder, ascending, fullDetails, videoList );
+        iMdsDb->iVideoListFetchingIsOngoing = fetchongoing;
+        }
+    
+    iMdsDb->DoCreateVideoListL( sortingorder, ascending, fullDetails, videoList );
     
     if ( docreate )
         {
-        CleanupStack::PopAndDestroy( videoList );
+        CleanupStack::PopAndDestroy( localvideoList );
+        }
+    else if ( storelist )
+        {
+        iVideoList = videoList;
         }
     else
         {
@@ -327,20 +380,110 @@
 
 TInt CVcxMyVideosMdsDbTest::CreateVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TBool fulldetails   = NextIntOrZero( aItem );
+    TUint32 id          = NextIntOrZero( aItem );
     
-    TUint32 aId;
-    TBool aFullDetails = ETrue;
-    CMPXMedia* media = iMdsDb->CreateVideoL( aId, aFullDetails );
+    CMPXMedia* media ( NULL );
+    media = iMdsDb->CreateVideoL( id, fulldetails );
     delete media;
     return KErrNone;
     }
 
+TInt CVcxMyVideosMdsDbTest::HandleQueryNewResultsL( CStifItemParser& aItem )
+    {
+    querycountresult        = NextIntOrZero( aItem );
+    propertyisnull          = NextIntOrZero( aItem );
+    propertynotdefined      = NextIntOrZero( aItem );
+    handledbeventleave      = NextIntOrZero( aItem );
+    
+    TInt firstnewitemindex  = NextIntOrZero( aItem );
+    TInt newitemcount       = NextIntOrZero( aItem );
+
+    
+    iMdsDb->HandleQueryNewResults( *(CMdEQuery*) NULL, firstnewitemindex, newitemcount );
+
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleQueryCompletedL( CStifItemParser&  )
+    {
+    CMdEQuery* query ( NULL );
+    iMdsDb->HandleQueryCompleted( *query, 0 );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::AsyncHandleQueryCompletedL( CStifItemParser&  aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    TInt b = NextIntOrZero( aItem );
+    TInt ret = CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( iMdsDb );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleSessionErrorL( CStifItemParser& aItem )
+    {
+    iMdsDb->iVideoListFetchingIsOngoing = NextIntOrZero( aItem );
+    TUint32 err = NextIntOrZero( aItem );
+    
+    CMdESession* cmdesession ( NULL );
+    iMdsDb->HandleSessionError( *cmdesession, err );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleObjectNotificationL( CStifItemParser& aItem )
+    {
+    TInt notificationtype = NextIntOrZero( aItem );
+    handledbeventleave    = NextIntOrZero( aItem );
+    
+    RArray<TItemId> ids;
+    ids.Append( 0 );
+    ids.Append( 1 );
+    ids.Append( 2 );
+    
+    iMdsDb->HandleObjectNotification( *(CMdESession*)0, ( TObserverNotificationType )notificationtype, ids );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleObjectPresentNotification( CStifItemParser& aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    CMdESession* cmdesession ( NULL );
+    RArray<TItemId> ids;
+    ids.Append( 0 );
+    ids.Append( 1 );
+    ids.Append( 2 );
+    handledbeventleave = NextIntOrZero(aItem);
+    iMdsDb->HandleObjectPresentNotification( *cmdesession, a, ids );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::ShutdownNotificationL( CStifItemParser& aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    iMdsDb->ShutdownNotification( a );
+    return KErrNone;
+    }
 
 void CVcxMyVideosMdsDbTest::PrepareMdsL(  CStifItemParser& aItem  ) 
     {
     mdsoperationreturns = NextIntOrZero( aItem );
-    
-    mdsoperationleaves = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
     }
 
+void CVcxMyVideosMdsDbTest::HandleMyVideosDbEvent( TMPXChangeEventType , RArray<TUint32>&  )
+    {
+    if ( handledbeventleave )
+        {
+        User::Leave( handledbeventleave );
+        }
+    }
+
+void CVcxMyVideosMdsDbTest::HandleCreateVideoListResp( CMPXMedia* aVideoList, TInt aNewItemsStartIndex, TBool aComplete )
+    {
+    if ( handledbeventleave )
+        {
+        User::Leave( handledbeventleave );
+        }
+    }
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobject.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobject.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -23,6 +23,8 @@
 #include <mdenamespacedef.h>
 #include <mdesession.h>
 
+#include "VcxMyVideosMdsDbTest.h"
+
 //////////////////////////////
 //                          //
 //        TMdEObject        //
@@ -173,12 +175,19 @@
 
 EXPORT_C TInt CMdEObject::Property(const CMdEPropertyDef& aDef, CMdEProperty*& aProperty, TInt aStartAt) const
     {
+    if ( test->propertynotdefined )
+        {
+        return KErrNotFound;
+        }
     if( !iProperty )
         {
         iProperty = new CMdEProperty();
         }
     
-    aProperty = iProperty;
+    if ( test->propertyisnull )
+        {
+        aProperty = NULL;
+        }
     }
     
 EXPORT_C CMdEProperty& CMdEObject::AddBoolPropertyL(CMdEPropertyDef& aDef, TBool aValue)
@@ -296,6 +305,14 @@
 
 EXPORT_C TBool CMdEObject::OpenForModifications() const
 	{
+    if ( test->mdeobjectopenresult )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
 	}
 
 void CMdEObject::ClearObject( TBool aClearFlags )
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobjectquery.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdeobjectquery.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -39,10 +39,18 @@
 
 CMdEObjectQuery::~CMdEObjectQuery()
 	{
+    delete iCMdEObject;
 	}
 
 EXPORT_C CMdEObject& CMdEObjectQuery::Result(TInt aIndex) const
     {
+    if ( !iCMdEObject ) 
+        {
+        const TPtrC ptr = KNullDesC();
+        iCMdEObject = CMdEObject::NewL( * ( CMdEObjectDef*  )NULL,ptr, 0 );
+        }
+    
+    return *iCMdEObject;
     }
 
 EXPORT_C CMdEObjectDef& CMdEObjectQuery::ObjectDef() const
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdequery.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdequery.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -17,12 +17,13 @@
 
 
 #include "mdequery.h"
-
 #include "mdeorderrule.h"
 #include "mdeinstanceitem.h"
 #include "mdelogiccondition.h"
 #include "mdenamespacedef.h"
 
+#include "VcxMyVideosMdsDbTest.h"
+
 
 CMdEQuery::CMdEQuery(TQueryType aType, CMdESession& aSession, CMdENamespaceDef& aNamespaceDef)
         : iQueryId( 0 ), iSession(aSession), iNamespaceDef(aNamespaceDef), iType(aType), 
@@ -114,6 +115,7 @@
 
 EXPORT_C TInt CMdEQuery::Count() const
     {
+    return test->querycountresult;
     }
 
 EXPORT_C CMdEItem& CMdEQuery::ResultItem(TInt aIndex) const
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdesessionimpl.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/mdesessionimpl.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -41,31 +41,31 @@
 // for CleanupResetAndDestroyPushL
 #include <mmf/common/mmfcontrollerpluginresolver.h>
 
-CMdESessionAsyncHandler* CMdESessionAsyncHandler::NewL(MMdESessionObserver& aObserver)
+CMdeSessionStartTimer* CMdeSessionStartTimer::NewL(MMdESessionObserver& aObserver)
     {
-    CMdESessionAsyncHandler* self = new CMdESessionAsyncHandler( aObserver );
+    CMdeSessionStartTimer* self = new CMdeSessionStartTimer( aObserver );
     CleanupStack::PushL(self);
     self->ConstructL();
     CleanupStack::Pop(self);
     return self;
     }
 
-void CMdESessionAsyncHandler::ConstructL()
+void CMdeSessionStartTimer::ConstructL()
     {
     CTimer::ConstructL();
     }   
 
-CMdESessionAsyncHandler::~CMdESessionAsyncHandler()
+CMdeSessionStartTimer::~CMdeSessionStartTimer()
 	{
 	Cancel();
 	}		
 
-void CMdESessionAsyncHandler::RunL()
+void CMdeSessionStartTimer::RunL()
 	{
 	iObserver.HandleSessionOpened(*(CMdESession*) 0  ,test->mdssessionasyncerror);
 	}
 
-CMdESessionAsyncHandler::CMdESessionAsyncHandler(MMdESessionObserver& aObserver)
+CMdeSessionStartTimer::CMdeSessionStartTimer(MMdESessionObserver& aObserver)
 	: CTimer( CActive::EPriorityStandard ), iObserver( aObserver )
 	{
 	CActiveScheduler::Add(this);
@@ -75,7 +75,7 @@
 	: iSessionStartupAO( NULL ), iSessionObserver(&aObserver), 
 	  iSchemaBuffer( NULL ), iNextQueryId( 0 )
 	{
-    iTimer = CMdESessionAsyncHandler::NewL( aObserver );
+    iTimer = CMdeSessionStartTimer::NewL( aObserver );
     
     iTimer->After( 1000 );
 	}
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideoscollectionutil.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideoscollectionutil.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -94,6 +94,12 @@
     }
     
 // ---------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::AppendToListL
+// New items in aToList will point to same shared memory as items in aFromList.
+// ---------------------------------------------------------------------------
+//
+void TVcxMyVideosCollectionUtil::AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList )
+    {}
 // This helper function converts drive letter to drive number
 // ---------------------------------------------------------------------------
 //
@@ -127,6 +133,11 @@
     }
 
 // ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::CreationDateL
+// ----------------------------------------------------------------------------
+//
+TInt64 TVcxMyVideosCollectionUtil::CreationDateL( CMPXMedia& aVideo )
+    {}
 // TVcxMyVideosCollectionUtil::DownloadIdL
 // ----------------------------------------------------------------------------
 //
@@ -146,7 +157,7 @@
 // TVcxMyVideosCollectionUtil::IdL
 // ----------------------------------------------------------------------------
 //
-TMPXItemId TVcxMyVideosCollectionUtil::IdL( CMPXMedia& aVideo )
+TMPXItemId TVcxMyVideosCollectionUtil::IdL( const CMPXMedia& aVideo )
     {
     }
 
@@ -165,7 +176,7 @@
 // TVcxMyVideosCollectionUtil::Title
 // ----------------------------------------------------------------------------
 //
-const TDesC& TVcxMyVideosCollectionUtil::Title( CMPXMedia& aVideo )
+const TDesC& TVcxMyVideosCollectionUtil::Title( const CMPXMedia& aVideo )
     {                            
     }
 
@@ -211,6 +222,31 @@
     {
     }
     
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::MediaArrayL
+// ----------------------------------------------------------------------------
+//
+CMPXMediaArray* TVcxMyVideosCollectionUtil::MediaArrayL( const CMPXMedia& aMedia )
+    {}
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::Int32ValueL
+// ----------------------------------------------------------------------------
+//
+TInt32 TVcxMyVideosCollectionUtil::Int32ValueL( CMPXMedia& aMedia )
+    {}
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::Uint32ValueL
+// ----------------------------------------------------------------------------
+//
+TUint32 TVcxMyVideosCollectionUtil::Uint32ValueL( CMPXMedia& aMedia )
+    {}
+// ----------------------------------------------------------------------------
+// TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL
+// ----------------------------------------------------------------------------
+//
+void TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
+        RArray<TUint32>& aIdArray )
+    {}
 #ifdef _DEBUG
 // ----------------------------------------------------------------------------
 // TVcxMyVideosCollectionUtil::PrintOpenFileHandlesL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideosmdsalbums.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,366 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Provides albums support utilizing MDS.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include <mdesession.h>
+#include <mdeconstants.h>
+#include <mdequery.h>
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediageneraldefs.h>
+#include "vcxmyvideosmdsalbums.h"
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
+#include "vcxmyvideoscollectionutil.h"
+#include "vcxmyvideosmdscmdqueue.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums::CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
+        MVcxMyVideosMdsAlbumsObserver* aObserver )
+: CActive( EPriorityStandard ), iMdsDb( aMdsDb ), iObserver(aObserver) 
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::ConstructL()
+    {
+    GetSchemaDefinitionsL();
+    SetObservingL();
+    CActiveScheduler::Add( this );    
+    }
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb,
+        MVcxMyVideosMdsAlbumsObserver* aObserver )
+    {
+    CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums()
+    {
+    CancelQueries();
+    delete iAlbumQuery;
+    delete iVideoQuery;
+    delete iRelationQuery;
+    iItemArray.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::CancelQueries
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::CancelQueries( CVcxMyVideosMdsDb::TRequestType aType )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From CActive
+// CVcxMyVideosMdsAlbums::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::SetObservingL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::SetObservingL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumsL( CMPXMedia* aAlbumList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumL
+// ---------------------------------------------------------------------------
+//
+CMPXMedia* CVcxMyVideosMdsAlbums::GetAlbumL( TUint32 aId )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumsL( CMPXMedia* aAlbumList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumContentIdsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumContentIdsL( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL( TUint32 aAlbumId,
+        RArray<TVcxMyVideosAlbumVideo>& aContentArray,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetAlbumContentVideosL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::Object2MediaL
+// For album objects only.
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::Object2MediaL(
+        CMdEObject& aObject,
+        CMPXMedia& aAlbum )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::Media2ObjectL
+// Called by AddAlbumL()
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::Media2ObjectL(
+        CMPXMedia& aAlbum,
+        CMdEObject& aObject)
+    {      
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleQueryNewResults(CMdEQuery& aQuery,
+            TInt aFirstNewItemIndex,
+            TInt aNewItemCount )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleQueryCompleted
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleVideoQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL( CMdEQuery& /*aQuery*/, TInt aError,
+    TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete  )
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::AddVideosToAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::AddVideosToAlbumL( CMPXMedia* aCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL
+// Called by iMdsDb.iCmdQueue
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL( CMPXMedia* aCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RemoveRelationsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RemoveRelationsL( RArray<TUint32>& aRelationIds,
+        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {  
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoRemoveRelationsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
+        RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::AddAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::AddAlbumL( CMPXMedia& aAlbum )
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::SetAlbumL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::SetAlbumL( CMPXMedia& aVideo )
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RemoveAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient )
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::DoRemoveAlbumsL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
+        MVcxMyVideosMdsAlbumsObserver& aClient )
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::RunL
+// From CActive.
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::RunL()
+    {}
+
+//TODO: implement RunError
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL()
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL()
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL()
+    {}
+
+// ----------------------------------------------------------------------------
+// CVcxMyVideosMdsAlbums::HandleRelationItemNotification
+// From MMdERelationItemObserver
+// ----------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsAlbums::HandleRelationItemNotification(CMdESession& /*aSession*/, 
+        TObserverNotificationType aType,
+        const RArray<TMdERelation>& aRelationArray)
+    {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/vcxmyvideosmdscmdqueue.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* 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 the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Queues commands to MDS.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include "vcxmyvideosmdscmdqueue.h"
+
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
+#include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue::CVcxMyVideosMdsCmdQueue( CVcxMyVideosMdsDb& aMdsDb )
+: iMdsDb( aMdsDb )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::ConstructL()
+    {}
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue* CVcxMyVideosMdsCmdQueue::NewL( CVcxMyVideosMdsDb& aMdsDb )
+    {
+    CVcxMyVideosMdsCmdQueue* self = new(ELeave) CVcxMyVideosMdsCmdQueue( aMdsDb );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosMdsCmdQueue::~CVcxMyVideosMdsCmdQueue()
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::Cancel
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::Cancel( CVcxMyVideosMdsDb::TRequestType aType )
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::ExecuteCmdL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::ExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
+    {}
+    
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::CmdFinished
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::CmdFinished()
+    {}
+
+// ---------------------------------------------------------------------------
+// CVcxMyVideosMdsCmdQueue::DoExecuteCmdL
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosMdsCmdQueue::DoExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
+    {}    
+// END OF FILE
--- a/videoplayback/inc/mpxvideobaseplaybackview.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/inc/mpxvideobaseplaybackview.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 22 %
+// Version : %version: 23 %
 
 
 // This file defines the API for VideoBasePlaybackView.dll
@@ -287,6 +287,10 @@
 
         TBool IsMultiItemPlaylist();
 
+        virtual void SendWindowCommandL( TMPXVideoPlaybackCommand aCmd );
+
+        virtual void HandlePdlReloadComplete();
+
     private:
 
         /**
@@ -352,8 +356,6 @@
 
         void HandleRealOneBitmapTimeoutL();
 
-        void SendWindowCommandL( TMPXVideoPlaybackCommand aCmd );
-
         TBool IsInMemoryPlugin();
 
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
--- a/videoplayback/inc/mpxvideopdlplaybackview.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/inc/mpxvideopdlplaybackview.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 7 %
+// Version : %version: 8 %
 
 
 // This file defines the API for VideoPlaybackView.dll
@@ -75,6 +75,10 @@
 
         void HandleInitializingStateL( TMPXPlaybackState aLastState );
 
+        void SendWindowCommandL( TMPXVideoPlaybackCommand aCmd );
+
+        void HandlePdlReloadComplete();
+
     private:
 
         CMPXVideoPdlPlaybackView();
@@ -91,6 +95,7 @@
 
         TMPXPlaybackPdDownloadState         iPdlState;
         TInt                                iDownloadSize;
+        TBool                               iUserInputsBlocked;
 };
 
 #endif  // __VIDEOPDLPLAYBACKVIEW_H__
--- a/videoplayback/inc/mpxvideoplaybackcontrolscontroller.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/inc/mpxvideoplaybackcontrolscontroller.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 17 %
+// Version : %version: 18 %
 
 
 #ifndef MPXVIDEOPLAYBACKCONTROLSCONTROLLER_H_
@@ -374,6 +374,7 @@
         TFileName                               iBitmapFileName;
 
         TBool                                   iTvOutConnected;
+        TBool                                   iShowControls;
         TBool                                   iRNFormat;
 
 #ifdef RD_TACTILE_FEEDBACK
--- a/videoplayback/inc/mpxvideoplaybackuserinputhandler.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/inc/mpxvideoplaybackuserinputhandler.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version:  8 %
+// Version : %version:  9 %
 
 
 #ifndef MPXVIDEOPLAYBACKUSERINPUTHANDLER_H_
@@ -44,13 +44,12 @@
 class CMPXVideoPlaybackUserInputHandler : public CBase,
                                           public MRemConCoreApiTargetObserver
 {
-
     public: // Constructors and destructor
 
         /**
         * Two-phased constructor.
         */
-        IMPORT_C static CMPXVideoPlaybackUserInputHandler* NewL(CMPXVideoPlaybackContainer* iContainer );
+        IMPORT_C static CMPXVideoPlaybackUserInputHandler* NewL( CMPXVideoPlaybackContainer* iContainer );
 
         /**
         * Destructor.
@@ -62,7 +61,7 @@
         /**
         * C++ default constructor.
         */
-        CMPXVideoPlaybackUserInputHandler(CMPXVideoPlaybackContainer* iContainer);
+        CMPXVideoPlaybackUserInputHandler( CMPXVideoPlaybackContainer* iContainer );
 
         /**
         * Symbian 2nd phase constructor.
@@ -77,11 +76,11 @@
 
         void ProcessKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
 
-	    void ProcessMediaKey(TRemConCoreApiOperationId aOperationId,
-                             TRemConCoreApiButtonAction aButtonAct);
+        void ProcessMediaKey( TRemConCoreApiOperationId aOperationId,
+                              TRemConCoreApiButtonAction aButtonAct );
 
-	    void DoHandleMediaKey(TRemConCoreApiOperationId aOperationId,
-                               TRemConCoreApiButtonAction aButtonAct);
+        void DoHandleMediaKey( TRemConCoreApiOperationId aOperationId,
+                               TRemConCoreApiButtonAction aButtonAct );
 
         // From MRemConCoreApiTargetObserver
         /**
@@ -91,20 +90,26 @@
         */
         virtual void MrccatoPlay(
                 TRemConCoreApiPlaybackSpeed aSpeed,
-                TRemConCoreApiButtonAction aButtonAct);
+                TRemConCoreApiButtonAction aButtonAct );
 
         virtual void MrccatoCommand(
                 TRemConCoreApiOperationId aOperationId,
-                TRemConCoreApiButtonAction aButtonAct);
+                TRemConCoreApiButtonAction aButtonAct );
 
         /**
         * Setter method for iForeground
         * @param aForeground - the value to be set
         * @return void
         */
-        void SetForeground(TBool aForeground);
+        void SetForeground( TBool aForeground );
 
-	private:
+        /*
+         *  Function will block all user inputs until the new PDL command is received
+         *  @param aBlockInputs - the value to be set
+         */
+        void BlockPdlUserInputs( TBool aBlockInputs );
+
+    private:
         /**
         * Handles volume repeat timer timout
         * @return TInt
@@ -117,33 +122,36 @@
         */
         void HandleVolumeRepeatL();
 
-        void HandleFastForward(TRemConCoreApiButtonAction aButtonAct);
+        void HandleFastForward( TRemConCoreApiButtonAction aButtonAct );
 
-        void HandleRewind(TRemConCoreApiButtonAction aButtonAct);
+        void HandleRewind( TRemConCoreApiButtonAction aButtonAct );
 
-        void HandleVolumeUp(TRemConCoreApiButtonAction aButtonAct);
+        void HandleVolumeUp( TRemConCoreApiButtonAction aButtonAct );
 
-        void HandleVolumeDown(TRemConCoreApiButtonAction aButtonAct);
+        void HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct );
 
-        void ReRoutePointerEventL(CCoeControl* aControl,
-                                  const TPointerEvent& aPointerEvent,
-                                  TMPXVideoControlType aMPXControl);
+        void ReRoutePointerEventL( CCoeControl* aControl,
+                                   const TPointerEvent& aPointerEvent,
+                                   TMPXVideoControlType aMPXControl );
+
+        TBool IsUserInputAllowed();
 
     private:
 
-        TMPXVideoUserInputType                  iProcessingInputType; 	// the type of input being processed
+        TMPXVideoUserInputType                  iProcessingInputType;     // the type of input being processed
         TUint                                   iLastPressedKeyCode;     // keycode of last key that sent EEventKeyDown
         TInt                                    iLastPressedKeyScanCode; // scancode of last key that sent EEventKeyDown
         TRemConCoreApiOperationId               iLastMediaKeyPressed;    // Id of last mediakey thats sent a button-press
 
-        CRemConInterfaceSelector*               iInterfaceSelector; 		// Side volume key, owned
+        CRemConInterfaceSelector*               iInterfaceSelector;         // Side volume key, owned
         CRemConCoreApiTarget*                   iCoreTarget;            // Owned by CRemConInterfaceSelector
 
         CPeriodic*                              iVolumeRepeatTimer;     // owned
         TBool                                   iVolumeRepeatUp;
         TBool                                   iForeground;
+        TBool                                   iBlockPdlInputs;
 
-        CMPXVideoPlaybackContainer*             iContainer;	        // not owned
+        CMPXVideoPlaybackContainer*             iContainer;            // not owned
         CCoeControl*                            iActiveControlPtr;  // not owned
         TMPXVideoControlType                    iActiveControlType;
 };
--- a/videoplayback/videohelix/group/mpxvideohelixplayback.mmp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/group/mpxvideohelixplayback.mmp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
  *
 */
 
-// Version : %version: 15 %
+// Version : %version: 16 %
 
 
 
@@ -85,4 +85,6 @@
 LIBRARY accpolicy.lib
 #endif
 
+MACRO    USE_S60_DOWNLOAD_MANAGER
+
 // End of File
--- a/videoplayback/videohelix/inc/mpxvideodlmgrif.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/inc/mpxvideodlmgrif.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,8 +15,10 @@
 *
 */
 
-// Version : %version: 9 %
 
+// Version : %version: 12 %
+
+#ifdef USE_S60_DOWNLOAD_MANAGER 
 
 #ifndef __MPXVIDEODLMGRIF_H__
 #define __MPXVIDEODLMGRIF_H__
@@ -135,6 +137,15 @@
          */
         TBool IsDownloadPaused();
 
+        /*
+         *  UpdateDownloadSizeL
+         *
+         *  For DRM protected clips, the download size will be updated using the file handle
+         *
+         *  @since S60 9.2
+         */
+        void UpdateDownloadSizeL();
+
     private:
         /*
          *  CMPDownloadMgrInterface
@@ -220,8 +231,6 @@
 
         void ConvertDMgrStatetoMpxState( TInt32 dmgrState );
 
-        void UpdateDownloadSizeL();
-
         //
         //  Private Members
         //  Not Owned Data
@@ -251,4 +260,6 @@
 
 #endif __MPXVIDEODLMGRIF_H__
 
+#endif // USE_S60_DOWNLOAD_MANAGER 
+
 // End of file
--- a/videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 28 %
+// Version : %version: 29 %
 
 
 #ifndef _CMPXVIDEOPLAYBACKCONTROLLER_H_
@@ -290,7 +290,9 @@
         friend class CMPXProgressiveDLPlaybackMode;
 
         friend class CMPXVideoSeeker;
+#ifdef USE_S60_DOWNLOAD_MANAGER 
         friend class CMPXVideoDlMgrIf;
+#endif // USE_S60_DOWNLOAD_MANAGER 
         friend class CMPXVideoAccessoryObserver;
         friend class CMpxVideoPlayerUtility;
         friend class CMPXVideoPosterFrameSetter;
--- a/videoplayback/videohelix/inc/mpxvideoplaybackmode.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/inc/mpxvideoplaybackmode.h	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 16 %
+// Version : %version: 19 %
 
 
 #ifndef _CMPXVIDEOPLAYBACKMODE_H_
@@ -29,7 +29,9 @@
 #include <e32base.h>
 
 #include "mpxhelixplaybackplugindefs.h"
+#ifdef USE_S60_DOWNLOAD_MANAGER 
 #include "mpxvideodlmgrif.h"
+#endif
 #include "mpxvideo_debug.h"
 
 //
@@ -79,7 +81,6 @@
         virtual void OpenFile64L( const RFile64& aMediaFile );
 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
 
-
     protected:
         /*
          *  C++ default constructor
@@ -92,15 +93,12 @@
          */
         virtual void ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr );
 
-
     protected:
         //
         //  Data
         //
         CMPXVideoPlaybackController*        iVideoPlaybackCtlr;   // not owned
-        
         CMPXVideoPosterFrameSetter*         iPosterFrameSetter;
-
 };
 
 /*******************************************************/
@@ -170,21 +168,49 @@
         static CMPXVideoPlaybackMode* NewL( CMPXVideoPlaybackController* aVideoPlaybackCtlr );
         virtual ~CMPXProgressiveDLPlaybackMode();
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+
         inline virtual TInt GetMode();
         void ConnectToDownloadL( CMPXCommand& aCmd );
         void HandleOpenComplete();
         void GetPdlStatusL( CMPXCommand& aCmd );
         void UpdateSeekPosition( TInt64& aPosition );
         inline TBool IsDownloadPaused();
+        void OpenFileL( const RFile& aMediaFile );
+
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+        void OpenFile64L( const RFile64& aMediaFile );
+#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+
+#endif // USE_S60_DOWNLOAD_MANAGER 
 
     private:
-
         void ConstructL( CMPXVideoPlaybackController* aVideoPlaybackCtlr );
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
     private:
-        CMPXVideoDlMgrIf*  iDlMgrIf;   // owned
+        CMPXVideoDlMgrIf*  iDlMgrIf;   // owned		
+#endif // USE_S60_DOWNLOAD_MANAGER 
+
 };
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+
+inline
+TInt CMPXProgressiveDLPlaybackMode::GetMode()
+{
+    MPX_DEBUG(_L("CMPXProgressiveDLPlaybackMode::GetMode()"));
+    return EMPXVideoProgressiveDownload;
+}
+
+inline
+TBool CMPXProgressiveDLPlaybackMode::IsDownloadPaused()
+{
+    return iDlMgrIf->IsDownloadPaused();
+}
+
+#endif // USE_S60_DOWNLOAD_MANAGER 
+
 // INLINE METHODS
 
 inline
@@ -217,22 +243,10 @@
 }
 
 inline
-TInt CMPXProgressiveDLPlaybackMode::GetMode()
-{
-    MPX_DEBUG(_L("CMPXProgressiveDLPlaybackMode::GetMode()"));
-    return EMPXVideoProgressiveDownload;
-}
-
-inline
 TBool CMPXVideoPlaybackMode::IsDownloadPaused()
 {
     return EFalse;
 }
 
-inline
-TBool CMPXProgressiveDLPlaybackMode::IsDownloadPaused()
-{
-    return iDlMgrIf->IsDownloadPaused();
-}
 
 #endif  //_CMPXVIDEOPLAYBACKMODE_H_
--- a/videoplayback/videohelix/src/mpxvideodlmgrif.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/src/mpxvideodlmgrif.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 23 %
+// Version : %version: 25 %
 
 
 #include <MMFROPCustomCommandConstants.h>
@@ -95,7 +95,6 @@
     }
 }
 
-
 void CMPXVideoDlMgrIf::ConnectToDownloadL( CMPXCommand& aCmd )
 {
     MPX_ENTER_EXIT(_L("CMPXVideoDlMgrIf::ConnectToDownloadL()"));
@@ -120,13 +119,14 @@
     //
     //  A new download id has been sent.  Reset member variables
     //
-    iMoveNeeded    = EFalse;
-    iCurrentDl     = NULL;
-    iDlId          = downloadId;
-    iPlayerOpened  = EFalse;
-    iDlTotalSize   = 0;
+    iMoveNeeded       = EFalse;
+    iCurrentDl        = NULL;
+    iDownloadState    = EPbDlStateDownloadCompleted;
+    iDlId             = downloadId;
+    iPlayerOpened     = EFalse;
+    iDlTotalSize      = 0;
     iDownloadProgress = 0;
-    iCodDownload   = EFalse;
+    iCodDownload      = EFalse;
 
     if ( iDlMgrConnected )
     {
@@ -414,11 +414,6 @@
                 //
                 error = HandleCustomCommand( EMMFROPControllerSetDownloadSize, iDownloadProgress );
             }
-
-            //
-            //  Update download size for DRM protected clips
-            //
-            MPX_TRAPD( updateError, UpdateDownloadSizeL() );
         }
     }
 }
@@ -658,9 +653,19 @@
 //
 TReal CMPXVideoDlMgrIf::GetDownloadRatio()
 {
-    TReal downloadRatio = (TReal)iDownloadProgress / (TReal)iDlTotalSize;
+    TReal downloadRatio = 0.0;
+    
+    if ( iDownloadState == EPbDlStateDownloadCompleted )
+    {
+        downloadRatio = 100.0;
+    }
+    else
+    {
+        downloadRatio = (TReal)iDownloadProgress / (TReal)iDlTotalSize;
+    }
+    
     MPX_DEBUG(_L("CMPXVideoDlMgrIf::GetDownloadRatio(%f)"), downloadRatio);
-
+    
     return downloadRatio;
 }
 
@@ -671,9 +676,7 @@
 TBool CMPXVideoDlMgrIf::IsDownloadPaused()
 {
     TBool paused = ( iDownloadState == EPbDlStateDownloadPaused );
-
-    MPX_DEBUG(_L("CMPXVideoDlMgrIf::GetDownloadRatio(%d)"), paused);
-
+    MPX_DEBUG(_L("CMPXVideoDlMgrIf::IsDownloadPaused(%d)"), paused);
     return paused;
 }
 
--- a/videoplayback/videohelix/src/mpxvideoplaybackmode.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/src/mpxvideoplaybackmode.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 29 %
+// Version : %version: 32 %
 
 
 //
@@ -70,7 +70,7 @@
 CMPXVideoPlaybackMode::~CMPXVideoPlaybackMode()
 {
     MPX_DEBUG(_L("CMPXVideoPlaybackMode::~CMPXVideoPlaybackMode()"));
-    
+
     if ( iPosterFrameSetter )
     {
         delete iPosterFrameSetter;
@@ -223,6 +223,12 @@
             MPX_TRAPD( err,
                 iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ) );
         }
+        else if ( iVideoPlaybackCtlr->IsKeyLocked() && 
+                  iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
+        {
+            // playback not allowed for the clip having video if keylock is true
+            // Let playAllowed remain false
+        }
         else
         {
             playAllowed = ETrue;
@@ -287,7 +293,7 @@
 //  ------------------------------------------------------------------------------------------------
 void CMPXVideoPlaybackMode::HandleFrameReady(TInt /*aError*/)
 {
-    MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleFrameReady()"));        
+    MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleFrameReady()"));
 }
 //************************************************************************************************//
 //          CMPXLocalPlaybackMode
@@ -311,7 +317,7 @@
 void CMPXLocalPlaybackMode::HandleSetPosterFrame()
 {
     MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleSetPosterFrame()"));
-         
+
     // create poster frame setter if it does not already exist
     if ( ! iPosterFrameSetter )
     {
@@ -321,13 +327,13 @@
     if ( iPosterFrameSetter )
     {
         iPosterFrameSetter->RequestPosterFrame();
-    }    
+    }
 }
 
 void CMPXLocalPlaybackMode::HandleFrameReady(TInt aError)
 {
-    MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleFrameReady()"));      
-    
+    MPX_DEBUG(_L("CMPXLocalPlaybackMode::HandleFrameReady()"));
+
     iPosterFrameSetter->HandlePosterFrameReady(aError);
 }
 
@@ -423,6 +429,12 @@
             MPX_TRAPD(err,
                       iVideoPlaybackCtlr->iState->SendErrorToViewL( KMPXVideoCallOngoingError ));
         }
+        else if ( iVideoPlaybackCtlr->IsKeyLocked() && 
+                  iVideoPlaybackCtlr->iFileDetails->iVideoEnabled )
+        {
+            // playback not allowed for the clip having video if keylock is true
+            // Let playAllowed remain false
+        }
         else
         {
             MPX_TRAPD( err,
@@ -557,23 +569,31 @@
 {
     iVideoPlaybackCtlr = aVideoPlaybackCtlr;
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
     //
     //  Create the Download Mgr Interface
     //
     iDlMgrIf = CMPXVideoDlMgrIf::NewL( iVideoPlaybackCtlr );
+#endif // USE_S60_DOWNLOAD_MANAGER 
+
 }
 
 CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()
 {
     MPX_DEBUG(_L("CMPXProgressiveDLPlaybackMode::~CMPXProgressiveDLPlaybackMode()"));
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
     if ( iDlMgrIf )
     {
         delete iDlMgrIf;
         iDlMgrIf = NULL;
     }
+#endif // USE_S60_DOWNLOAD_MANAGER 
+
 }
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+
 //  ------------------------------------------------------------------------------------------------
 //    CMPXProgressiveDLPlaybackMode::ConnectToDownloadL()
 //  ------------------------------------------------------------------------------------------------
@@ -637,4 +657,30 @@
         KErrNone );
 }
 
+//  ------------------------------------------------------------------------------------------------
+//    CMPXProgressiveDLPlaybackMode::OpenFileL()
+//  ------------------------------------------------------------------------------------------------
+void CMPXProgressiveDLPlaybackMode::OpenFileL( const RFile& aMediaFile )
+{
+    MPX_ENTER_EXIT(_L("CMPXProgressiveDLPlaybackMode::OpenFileL()"));
+
+    iDlMgrIf->UpdateDownloadSizeL();
+    CMPXVideoPlaybackMode::OpenFileL( aMediaFile );
+}
+
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+//  ------------------------------------------------------------------------------------------------
+//    CMPXProgressiveDLPlaybackMode::OpenFile64L()
+//  ------------------------------------------------------------------------------------------------
+void CMPXProgressiveDLPlaybackMode::OpenFile64L( const RFile64& aMediaFile )
+{
+    MPX_ENTER_EXIT(_L("CMPXProgressiveDLPlaybackMode::OpenFile64L( RFile64 )"));
+
+    iDlMgrIf->UpdateDownloadSizeL();
+    CMPXVideoPlaybackMode::OpenFile64L( aMediaFile );
+}
+#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+
+#endif // USE_S60_DOWNLOAD_MANAGER
+
 // End of file
--- a/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 43 %
+// Version : %version: 44 %
 
 
 //
@@ -1795,7 +1795,7 @@
 
     if ( aError == KErrNone )
     {
-        if ( iVideoPlaybackCtlr->iAppInForeground )
+        if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
         {
             iVideoPlaybackCtlr->ChangeState( EMPXVideoPlaying );
 
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg	Wed Jun 09 09:44:23 2010 +0300
@@ -54,6 +54,7 @@
 
 ERFile 1
 ERFile64 0
+EMPXVideoLocal 0
 
 [Enddefine]
 
@@ -883,3 +884,32 @@
 delete test
 pause 1000
 [Endtest]
+
+[Test]
+title 61.  InitialiseL link via 32-bit file handle
+create videohelixtest test
+test InitializeStreamingWithSdpFileHandleL ERFile 60000 10 sdp_test.sdp KErrNone KErrNone KErrNone
+waittestclass test
+delete test
+pause 1000
+[Endtest] 
+
+[Test]
+title 62.  InitialiseL link via 64-bit file handle
+create videohelixtest test
+test InitializeStreamingWithSdpFileHandleL ERFile64 60000 10 sdp_test.sdp KErrNone KErrNone KErrNone
+waittestclass test
+delete test
+pause 1000
+[Endtest]
+
+[Test]
+title 63. Retrieve FileName and playback mode -- Custom Commands EPbCmdInitView
+create videohelixtest test
+test Initialize 60000 10 vhpp_test.3gp KErrNone KErrNone KErrNone
+waittestclass test
+test RetrieveFileNameAndModeL vhpp_test.3gp EMPXVideoLocal
+pause 1000
+delete test
+pause 1000
+[Endtest] 
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 9 %
+// Version : %version: 10 %
 
 
 
@@ -93,4 +93,6 @@
 LIBRARY         hwrmlightclient.lib   // Lights control
 LIBRARY         fbscli.lib
 
+MACRO           USE_S60_DOWNLOAD_MANAGER
+
 // End of File
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/inc/dlmgr_stub.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/inc/dlmgr_stub.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,8 +15,9 @@
  *
 */
 
-// Version : %version: 4 %
+// Version : %version: 5 %
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
 
 #ifndef __RHTTPDOWNLOADMGRAPIEXT_H__
 #define __RHTTPDOWNLOADMGRAPIEXT_H__
@@ -188,3 +189,4 @@
 
 #endif // __RHTTPDOWNLOADMGRAPIEXT_H__
 
+#endif // USE_S60_DOWNLOAD_MANAGER 
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/inc/videohelixtest.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/inc/videohelixtest.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
  *
 */
 
-// Version : %version: 14 %
+// Version : %version: e003sa33#15 %
 
 
 #ifndef __VHPPTESTCASE_H__
@@ -172,6 +172,8 @@
         virtual TInt InitializeWithPositionL( CStifItemParser& aItem );
         virtual TInt InitializeLinkWithPositionL( CStifItemParser& aItem );
         virtual TInt InitializeHandleWithPositionL( CStifItemParser& aItem );
+        virtual TInt InitializeStreamingWithSdpFileHandleL( CStifItemParser& aItem  );
+        virtual TInt RetrieveFileNameAndModeL( CStifItemParser& aItem );
 
         // ---------------------------------------------------------------------
         //  Helper Functions
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/src/tnmgr_stub.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/src/tnmgr_stub.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version:  1 %
+// Version : %version:  2 %
 
 #include <fbs.h>
 #include "tnmgr_stub.h"
@@ -42,7 +42,7 @@
     MPX_ENTER_EXIT(_L("CThumbnailManager::CThumbnailManager() - stub impl"));
 }
 
-TThumbnailRequestId CThumbnailManager::SetThumbnailL( CThumbnailObjectSource& aObjectSource )
+TThumbnailRequestId CThumbnailManager::SetThumbnailL( CThumbnailObjectSource& /* aObjectSource */ )
 {   
     MPX_ENTER_EXIT(_L("CThumbnailManager::SetThumbnailL() - stub impl"));
     return 0;
@@ -63,7 +63,7 @@
     return self;
 }
 
-CThumbnailObjectSource::CThumbnailObjectSource( CFbsBitmap*  aBitmap, const TDesC& aUri )
+CThumbnailObjectSource::CThumbnailObjectSource( CFbsBitmap*  /* aBitmap */ , const TDesC& /* aUri */ )
 {
 }
 
--- a/videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 23 %
+// Version : %version: e003sa33#24.1.1 %
 
 
 // [INCLUDE FILES] - do not remove
@@ -42,6 +42,7 @@
 #include "mpxmediavideodefs.h"
 #include "mpxvideo_debug.h"
 #include "mpxvideoplayerutility_stub.h"
+#include "mpxhelixplaybackplugindefs.h"
 
 #ifdef __WINSCW__
     _LIT( KVideoTestPath, "c:\\data\\Videos\\" );
@@ -118,7 +119,10 @@
 
         ENTRY ("InitializeWithPositionL", CVHPPTestClass::InitializeWithPositionL),
         ENTRY ("InitializeLinkWithPositionL", CVHPPTestClass::InitializeLinkWithPositionL),
-        ENTRY ("InitializeHandleWithPositionL", CVHPPTestClass::InitializeHandleWithPositionL)
+        ENTRY ("InitializeHandleWithPositionL", CVHPPTestClass::InitializeHandleWithPositionL),
+        ENTRY ( "InitializeStreamingWithSdpFileHandleL", 
+        		CVHPPTestClass::InitializeStreamingWithSdpFileHandleL ),
+        ENTRY ( "RetrieveFileNameAndModeL", CVHPPTestClass::RetrieveFileNameAndModeL )        
 
         //
         //  ADD NEW ENTRIES HERE
@@ -1142,6 +1146,10 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::ConnectToDownloadL()"));
     iLog->Log(_L("CVHPPTestClass::ConnectToDownloadL()"));
 
+    TInt err = KErrNone;
+    
+#ifdef USE_S60_DOWNLOAD_MANAGER       
+    
     iDlMgrTester = CDlMgrTestClass::NewL();
     iDlMgrTester->AddStifObserver( this );
 
@@ -1152,7 +1160,7 @@
     //
     //   Read in the download id and filename
     //
-    TInt err = aItem.GetNextInt( dlId );
+    err = aItem.GetNextInt( dlId );
 
     if ( err == KErrNone )
     {
@@ -1188,7 +1196,17 @@
             CleanupStack::PopAndDestroy( cmd );
         }
     }
-
+    
+#else // USE_S60_DOWNLOAD_MANAGER    
+     
+	// suppress build warning
+    MPX_DEBUG(_L("CVHPPTestClass::ConnectToDownloadL() : parsing type = %d"), aItem.ParsingType()); 
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER
+    
     return err;
 }
 
@@ -1202,6 +1220,8 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::SendPdlCustomCommandL"),
                    _L("aCustomCmd = %d"), aCustomCmd );
 
+#ifdef USE_S60_DOWNLOAD_MANAGER     
+
     CMPXCommand* cmd = CMPXCommand::NewL();
     CleanupStack::PushL( cmd );
 
@@ -1212,6 +1232,14 @@
     iPlaybackPlugin->CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
+	
+#else // USE_S60_DOWNLOAD_MANAGER     
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER
+
 }
 
 // -----------------------------------------------------------------------------
@@ -1224,6 +1252,8 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::PauseDownloadL()"));
     iLog->Log(_L("CVHPPTestClass::PauseDownloadL()"));
 
+#ifdef USE_S60_DOWNLOAD_MANAGER   
+    
     TCallbackEvent* event = new TCallbackEvent;
 
     event->iEvent = EPDownloadStateChanged;
@@ -1233,7 +1263,14 @@
     AddExpectedEvent( event );
 
     iDlMgrTester->PauseDownload();
-
+    
+#else // USE_S60_DOWNLOAD_MANAGER    
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER 
+    
     return KErrNone;
 }
 
@@ -1247,9 +1284,13 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::ResumeDownloadL()"));
     iLog->Log(_L("CVHPPTestClass::ResumeDownloadL()"));
 
+    TInt err = KErrNone;
+    
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+    
     TInt dlSize;
 
-    TInt err = aItem.GetNextInt( dlSize );
+    err = aItem.GetNextInt( dlSize );
 
     if ( err == KErrNone )
     {
@@ -1273,7 +1314,17 @@
 
         iDlMgrTester->ResumeDownload();
     }
-
+    
+#else // USE_S60_DOWNLOAD_MANAGER    
+     
+	// suppress build warning
+    MPX_DEBUG(_L("CVHPPTestClass::ResumeDownloadL() : parsing type = %d"), aItem.ParsingType()); 
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER 
+    
     return err;
 }
 
@@ -1287,6 +1338,8 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::CancelDownloadL()"));
     iLog->Log(_L("CVHPPTestClass::CancelDownloadL()"));
 
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+    
     TCallbackEvent* event = new TCallbackEvent;
 
     event->iEvent = EPDownloadStateChanged;
@@ -1297,6 +1350,13 @@
 
     iDlMgrTester->CancelDownload();
 
+#else // USE_S60_DOWNLOAD_MANAGER    
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER 
+    
     return KErrNone;
 }
 
@@ -1310,6 +1370,10 @@
     MPX_ENTER_EXIT(_L("CVHPPTestClass::RetrievePdlStatusL()"));
     iLog->Log(_L("CVHPPTestClass::RetrievePdlStatusL()"));
 
+    TInt err = KErrNone;
+    
+#ifdef USE_S60_DOWNLOAD_MANAGER 
+    
     TInt pdlState;
     TInt expectedPdlState;
     TInt downloadedBytes;
@@ -1320,7 +1384,7 @@
     //
     //   Read in the expected download data
     //
-    TInt err = aItem.GetNextInt( expectedPdlState );
+    err = aItem.GetNextInt( expectedPdlState );
 
     if ( err == KErrNone )
     {
@@ -1368,6 +1432,16 @@
         CleanupStack::PopAndDestroy( cmd );
     }
 
+#else // USE_S60_DOWNLOAD_MANAGER 
+     
+	// suppress build warning
+    MPX_DEBUG(_L("CVHPPTestClass::RetrievePdlStatusL() : parsing type = %d"), aItem.ParsingType()); 
+	
+	// Signal TestScripter to continue from waittestclass
+    Signal();
+	
+#endif // USE_S60_DOWNLOAD_MANAGER 
+    
     return err;
 }
 
@@ -1548,6 +1622,8 @@
 void
 CVHPPTestClass::ProcessEvent( TCallbackEvent* aCallback )
 {
+    MPX_ENTER_EXIT(_L("CVHPPTestClass::ProcessEvent"));
+    
     if ( iExpectedCallbackArray->Count() > 0 )
     {
         TCallbackEvent* expectedCallback = (*iExpectedCallbackArray)[0];
@@ -2352,4 +2428,164 @@
     return err;
 }
 
+TInt
+CVHPPTestClass::InitializeStreamingWithSdpFileHandleL( CStifItemParser& aItem )
+{
+    MPX_ENTER_EXIT(_L("CVHPPTestClass::InitializeStreamingWithSdpFileHandleL()"));
+    iLog->Log(_L("CVHPPTestClass::InitializeStreamingWithSdpFileHandleL()"));
+
+    TInt duration;
+    TInt volumeSteps;
+    TInt fileHandle32;
+    
+    TInt err = aItem.GetNextInt( fileHandle32 );
+    
+    if ( err == KErrNone )
+    {        
+    
+#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+        //
+        // set RFile as default if the 64-bit flag is not defined
+        //
+        fileHandle32 = ETrue;
+#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+        
+        err = aItem.GetNextInt( duration );
+    
+        if ( err == KErrNone )
+        {
+            //
+            //  We will always get an Init Complete message out
+            //
+            TCallbackEvent* event = new TCallbackEvent;
+    
+            event->iEvent = EPInitialised;
+            event->iData  = duration;
+            event->iError = KErrNone;
+    
+            AddExpectedEvent( event );
+    
+            // 
+            // read number of volume steps
+            //
+            err = aItem.GetNextInt( volumeSteps );
+            
+            if ( err == KErrNone )
+            {        
+                //
+                // set volume steps
+                //
+                SetVolumeSteps( volumeSteps );
+               
+                TBuf<120> fullPath;
+                err = ReadFileInitializationParameters( aItem, fullPath );
+
+                if ( err == KErrNone )
+                {
+					PreparePluginL();
+					
+					MPX_DEBUG( _L("Initialize the Plugin:  link = %S"), &fullPath );
+					iLog->Log( _L("Initialize the Plugin:  link = %S"), &fullPath );
+					
+					//
+					//  Extract the streaming link from the ram file and
+					//  Initalize the Plugin with the file handle and an access point
+					//
+					RFs fs;
+					TInt error = fs.Connect();
+					
+					if ( fileHandle32 )
+					{
+						RFile file;
+						error = file.Open( fs, fullPath, EFileRead | EFileShareAny );
+						
+						MPX_DEBUG( _L("Initialize the Plugin:  file open error = %d"),
+								error );   
+						
+						User::LeaveIfError( error );
+				  
+						iPlaybackPlugin->InitStreamingL( file, 11 );
+						file.Close();
+					}
+    #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+					else
+					{
+						RFile64 file64;
+						error = file64.Open( fs, fullPath, EFileRead | EFileShareAny  );
+						
+						MPX_DEBUG( _L("Initialize the Plugin:  file open error = %d"),
+								error );
+						
+						User::LeaveIfError( error );
+						
+						iPlaybackPlugin->InitStreaming64L( file64, 11 );
+						file64.Close();
+					}
+#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+					
+					fs.Close();
+                }
+            } 
+        } 
+    } 
+    return err;
+}
+
+TInt
+CVHPPTestClass::RetrieveFileNameAndModeL( CStifItemParser& aItem )
+{
+    MPX_ENTER_EXIT( _L("CVHPPTestClass::RetrieveFileNameAndModeL()") );
+    iLog->Log( _L("CVHPPTestClass::RetrieveFileNameAndModeL()") );
+
+    TBuf<120>	fullPath;
+    TPtrC		fileName;
+    TInt		err;
+    
+    err = aItem.GetNextString( fileName );
+
+    if ( err == KErrNone )
+    {
+        //
+        //  Build the full path to the file
+        //
+        fullPath.Append( KVideoTestPath );
+        fullPath.Append( fileName );
+        
+        TInt mode;
+        err = aItem.GetNextInt( mode);
+        
+        if ( err == KErrNone )
+        {
+ 			CMPXCommand* cmd = CMPXCommand::NewL();
+			CleanupStack::PushL( cmd );
+	
+			cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
+			cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId,
+										 KMPXMediaIdVideoPlayback );
+			cmd->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand, EPbCmdInitView );
+			
+			iPlaybackPlugin->CommandL( *cmd );
+			
+			TPtrC clipName( cmd->ValueText( KMPXMediaVideoPlaybackFileName ) );
+			TMPXVideoMode  playbackMode = (TMPXVideoMode) cmd->ValueTObjectL<TInt>( KMPXMediaVideoMode );
+	
+			MPX_DEBUG( _L("    Expected Data:  filename = %S, playbackmode= %d" ),
+				 &fullPath, mode );
+			
+			MPX_DEBUG( _L("    Retrieved Data: filename = %S, playbackmode= %d"),
+				 &clipName, playbackMode );
+			
+			if ( fullPath.Compare( clipName) != 0 || mode != playbackMode )
+			{
+			    err = KErrGeneral;
+				MPX_DEBUG( _L("    err = %d"), err );
+			}
+			
+			CleanupStack::PopAndDestroy( cmd );
+        }
+    }
+
+    return err;
+}
+
 //  EOF
--- a/videoplayback/videoplaybackcontrols/group/mpxvideoplaybackcontrols.mmp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videoplaybackcontrols/group/mpxvideoplaybackcontrols.mmp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 11 %
+// Version : %version: 12 %
 
 
 
@@ -82,5 +82,6 @@
 LIBRARY             bmpanim.lib
 LIBRARY             flogger.lib
 LIBRARY             playbackhelper.lib
+LIBRARY             centralrepository.lib // For display backlight timeout value
 
 //End of file
--- a/videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 41 %
+// Version : %version: 42 %
 
 
 // INCLUDE FILES
@@ -42,6 +42,8 @@
 #include <mpxvideoplaybackcontrols.rsg>
 #include <mpxvideoplaybackcontrols.mbg>
 
+#include <avkondomainpskeys.h>
+
 #ifdef RD_TACTILE_FEEDBACK
 #include <touchfeedback.h>
 #endif //RD_TACTILE_FEEDBACK
@@ -115,6 +117,7 @@
 
     iFileDetails = aDetails;
     iTvOutConnected = iFileDetails->iTvOutConnected;
+    iShowControls  = ETrue;
 
     iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
 
@@ -328,6 +331,15 @@
         {
             MPX_DEBUG(_L("    [EMPXControlCmdHandleBackgroundEvent]"));
 
+            TBool keylock( EFalse );
+            RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
+
+            // Don't show controls when key is locked 
+            if ( keylock )
+            {
+                iShowControls = EFalse;
+            }
+
             ResetDisappearingTimers( EMPXTimerReset );
 
             for ( TInt i = 0 ; i < iControls.Count() ; i++ )
@@ -340,6 +352,7 @@
         case EMPXControlCmdHandleForegroundEvent:
         {
             MPX_DEBUG(_L("    [EMPXControlCmdHandleForegroundEvent]"));
+            iShowControls = ETrue;
             UpdateControlsVisibility();
             break;
         }
@@ -1263,13 +1276,16 @@
     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ShowControls()"),
                    _L("iState = %d"), iState );
 
-    CloseMediaDetailsViewer();
-
-    ResetDisappearingTimers( EMPXTimerReset );
+    if ( iShowControls )
+    {
+        CloseMediaDetailsViewer();
 
-    for ( TInt i = 0 ; i < iControls.Count() ; i++ )
-    {
-        iControls[i]->SetVisibility( iState );
+        ResetDisappearingTimers( EMPXTimerReset );
+
+        for ( TInt i = 0 ; i < iControls.Count() ; i++ )
+        {
+            iControls[i]->SetVisibility( iState );
+        }
     }
 }
 
--- a/videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 79 %
+// Version : %version: 80 %
 
 
 //  Include Files
@@ -368,6 +368,11 @@
             iMediaRequested = EFalse;
             break;
         }
+        case KMpxVideoPlaybackPdlReloadComplete:
+        {
+            HandlePdlReloadComplete();
+            break;
+        }
         case EMPXPbvCmdRealOneBitmapTimeout:
         {
             HandleRealOneBitmapTimeoutL();
@@ -2282,4 +2287,13 @@
     }
 }
 
+// -------------------------------------------------------------------------------------------------
+//   CMPXVideoBasePlaybackView::HandlePdlReloadComplete()
+// -------------------------------------------------------------------------------------------------
+//
+void CMPXVideoBasePlaybackView::HandlePdlReloadComplete()
+{
+    MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePdlReloadComplete()"));
+}
+
 // EOF
--- a/videoplayback/videoplaybackviews/src/mpxvideopdlplaybackview.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videoplaybackviews/src/mpxvideopdlplaybackview.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version: 24 %
+// Version : %version: 25 %
 
 
 //  Include Files
@@ -34,6 +34,7 @@
 #include "mpxvideopdlplaybackview.h"
 #include "mpxvideoplaybackcontainer.h"
 #include "mpxvideoplaybackviewfiledetails.h"
+#include "mpxvideoplaybackuserinputhandler.h"
 #include <mpxvideoplaybackdefs.h>
 #include "mpxvideo_debug.h"
 
@@ -208,7 +209,7 @@
         //  The download size and downloaded bytes will be set to 100 so
         //  the download progress bar will show 100%
         //
-        if ( iPdlState == EPbDlStateNotDownloading )
+        if ( iPdlState == EPbDlStateNotDownloading || iPdlState == EPbDlStateDownloadCompleted )
         {
             iDownloadSize   = 100;
             downloadedBytes = 100;
@@ -449,6 +450,49 @@
     //  For PDL view, reset the container and controls for new download
     //
     DoHandleInitializingStateL( aLastState );
+    
+    //
+    //  User inputs should not be blocked since the new download is initializing
+    //
+    iUserInputsBlocked = EFalse;
+    iContainer->UserInputHandler()->BlockPdlUserInputs( iUserInputsBlocked );
+}
+
+// -------------------------------------------------------------------------------------------------
+//   CMPXVideoPdlPlaybackView::SendWindowCommandL()
+// -------------------------------------------------------------------------------------------------
+//
+void CMPXVideoPdlPlaybackView::SendWindowCommandL( TMPXVideoPlaybackCommand aCmd )
+{
+    MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::SendWindowCommandL()"),
+                   _L("aCmd = %d"), aCmd );
+
+    CMPXVideoBasePlaybackView::SendWindowCommandL( aCmd );
+
+    if ( aCmd == EPbCmdHandleBackground && ! IsAppInFrontL() )
+    {
+        //
+        //  Block all inputs when PDL view is sent to full background
+        //  Commands will be enabled when new command is received from LWP
+        //
+        iUserInputsBlocked = ETrue;
+        iContainer->UserInputHandler()->BlockPdlUserInputs( iUserInputsBlocked );
+    }
+}
+
+// -------------------------------------------------------------------------------------------------
+//   CMPXVideoPdlPlaybackView::HandlePdlReloadComplete()
+// -------------------------------------------------------------------------------------------------
+//
+void CMPXVideoPdlPlaybackView::HandlePdlReloadComplete()
+{
+    MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::HandlePdlReloadComplete()"));
+    
+    //
+    //  User inputs should not be blocked since the new PDL command is complete
+    //
+    iUserInputsBlocked = EFalse;
+    iContainer->UserInputHandler()->BlockPdlUserInputs( iUserInputsBlocked );
 }
 
 // EOF
--- a/videoplayback/videoplaybackviews/src/mpxvideoplaybackuserinputhandler.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayback/videoplaybackviews/src/mpxvideoplaybackuserinputhandler.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,8 @@
 *
 */
 
-// Version : %version: 18 %
+
+// Version : %version: 19 %
 
 
 // INCLUDE FILES
@@ -51,8 +52,6 @@
 #include "mpxvideo_debug.h"
 
 
-
-
 // ======== MEMBER FUNCTIONS =======================================================================
 
 // -------------------------------------------------------------------------------------------------
@@ -61,7 +60,10 @@
 //
 CMPXVideoPlaybackUserInputHandler::CMPXVideoPlaybackUserInputHandler(
         CMPXVideoPlaybackContainer* aContainer)
-   : iContainer(aContainer)
+   : iProcessingInputType(EMpxVideoNone),
+     iForeground(ETrue),
+     iBlockPdlInputs(EFalse),
+     iContainer(aContainer)
 {
 }
 
@@ -98,9 +100,6 @@
 
     // not detrimental if Media Keys dont work - so ignore any errors here
     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
-
-    iProcessingInputType = EMpxVideoNone;
-    iForeground = ETrue;
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -117,7 +116,6 @@
         delete iVolumeRepeatTimer;
     }
 
-
     if ( iInterfaceSelector )
     {
         delete iInterfaceSelector;
@@ -238,7 +236,6 @@
     }
 }
 
-
 // -------------------------------------------------------------------------------------------------
 // CMPXVideoPlaybackUserInputHandler::HandleRewind()
 // -------------------------------------------------------------------------------------------------
@@ -302,7 +299,6 @@
     }
 }
 
-
 // -------------------------------------------------------------------------------------------------
 // CMPXVideoPlaybackUserInputHandler::HandleVolumeDown()
 // -------------------------------------------------------------------------------------------------
@@ -347,7 +343,6 @@
     }
 }
 
-
 // -------------------------------------------------------------------------------------------------
 // CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent()
 // -------------------------------------------------------------------------------------------------
@@ -365,7 +360,7 @@
     {
         case EMpxVideoNone:
         {
-            if ( aPointerEvent.iType == TPointerEvent::EButton1Down && iForeground )
+            if ( aPointerEvent.iType == TPointerEvent::EButton1Down && IsUserInputAllowed() )
             {
                 iProcessingInputType = EMpxVideoTouch;
 
@@ -411,7 +406,7 @@
                 if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
                 {
                     //
-                    //  Reroute button up event to active control and end current 
+                    //  Reroute button up event to active control and end current
                     //  control processing
                     //
                     ReRoutePointerEventL( iActiveControlPtr, aPointerEvent, iActiveControlType );
@@ -459,7 +454,7 @@
     {
         case EMpxVideoNone:
         {
-            if ( aType == EEventKeyDown && iForeground )
+            if ( aType == EEventKeyDown && IsUserInputAllowed() )
             {
                 iProcessingInputType = EMpxVideoKeyboard;
                 iLastPressedKeyCode = aKeyEvent.iCode;
@@ -504,7 +499,7 @@
     {
         case EMpxVideoNone:
         {
-            if ( iForeground )
+            if ( IsUserInputAllowed() )
             {
                 if ( aButtonAct == ERemConCoreApiButtonPress )
                 {
@@ -598,5 +593,28 @@
     }
 }
 
+// -------------------------------------------------------------------------------------------------
+//   CMPXVideoPlaybackUserInputHandler::BlockPdlUserInputs()
+// -------------------------------------------------------------------------------------------------
+//
+void CMPXVideoPlaybackUserInputHandler::BlockPdlUserInputs( TBool aBlockInputs )
+{
+    MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::BlockPdlUserInputs(%d)"), aBlockInputs);
+
+    iBlockPdlInputs = aBlockInputs;
+}
+
+// -------------------------------------------------------------------------------------------------
+//   CMPXVideoPlaybackUserInputHandler::IsUserInputAllowed()
+// -------------------------------------------------------------------------------------------------
+//
+TBool CMPXVideoPlaybackUserInputHandler::IsUserInputAllowed()
+{
+    TBool allowInput = ( iForeground && ! iBlockPdlInputs );
+
+    MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::IsUserInputAllowed(%d)"), allowInput);
+
+    return allowInput;
+}
 
 // EOF
--- a/videoplayerapp/mpxvideoplayer/inc/mpxvideoplayerappuiengine.h	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayerapp/mpxvideoplayer/inc/mpxvideoplayerappuiengine.h	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,8 @@
 *
 */
 
-// Version : %version: e92_33 %
+
+// Version : %version: da1mmcf#34 %
 
 
 #ifndef CMPXVIDEOPLAYERAPPUIENGINE_H
@@ -225,10 +226,10 @@
 
         void ClosePlaybackPluginL();
 
-        void SignalViewPdlReloadingL();
-        
+        void SendMessageToPdlViewL( TInt aMsg );
+
         /*
-         *  Activates an active object to finish the 
+         *  Activates an active object to finish the
          *  initialization of the standalone application
          */
         void ActivateLateConstructTimerL();
@@ -299,16 +300,16 @@
        void InitializePlaylistL( const CMPXCollectionPlaylist& aPlaylist, TBool aPlay );
 
         /*
-         *  Provides the static function for the callback to 
+         *  Provides the static function for the callback to
          *  finish the standalone application construction
          *  Called by CPeriodic iConstructTimer
          *  @param aPtr Pointer to callback class
          *  @return KErrNone
          */
         static TInt LateConstructCallback( TAny* aPtr );
-        
+
         /*
-         *  Called to finalize the standalone 
+         *  Called to finalize the standalone
          *  application initialization.
          */
         virtual void DoLateConstructL();
--- a/videoplayerapp/mpxvideoplayer/sis/VideoPlayer.pkg	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayerapp/mpxvideoplayer/sis/VideoPlayer.pkg	Wed Jun 09 09:44:23 2010 +0300
@@ -20,7 +20,7 @@
 &EN
 
 ; Header
-#{"Video Player"},(0x200159B2),9,20,2, TYPE=SA, RU
+#{"Video Player"},(0x200159B2),9,20,21, TYPE=SA, RU
 
 ; Supports Series 60 v5.0
 ;[0x1028315F], 0, 0, 0, {"Series60ProductID"}
--- a/videoplayerapp/mpxvideoplayer/sis/VideoPlayer_stub.pkg	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayerapp/mpxvideoplayer/sis/VideoPlayer_stub.pkg	Wed Jun 09 09:44:23 2010 +0300
@@ -20,7 +20,7 @@
 &EN
 
 ;Header
-#{"Video Player"},(0x200159B2),9,20,2, TYPE=SA
+#{"Video Player"},(0x200159B2),9,20,21, TYPE=SA
 
 ;Localised Vendor name
 %{"Nokia"}
--- a/videoplayerapp/mpxvideoplayer/src/mpxvideoembeddedpdlhandler.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayerapp/mpxvideoplayer/src/mpxvideoembeddedpdlhandler.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-// Version : %version:  ou1cpsw#14 %
+// Version : %version:  15 %
 
 
 #include <mpxcommand.h>
@@ -33,6 +33,7 @@
 #include "mpxvideoembeddedpdlhandler.h"
 #include "mpxvideoplayerappuiengine.h"
 #include "mpxvideoplayerconstants.h"
+#include "mpxvideoplayercustomviewmsgconsts.h"
 #include <mpxvideoplaybackdefs.h>
 #include "mpxvideo_debug.h"
 
@@ -100,6 +101,7 @@
         if ( ( aDlId == iDownloadId ) && ( ! aFileName.Compare( *iDownloadFileName ) ) )
         {
             iAppUiEngine->PlaybackUtilityL().CommandL( EPbCmdPlay );
+            iAppUiEngine->SendMessageToPdlViewL( KMpxVideoPlaybackPdlReloadComplete );
         }
         else
         {
@@ -107,9 +109,7 @@
             //  New download received, close old playback plugin
             //
             iAppUiEngine->ClosePlaybackPluginL();
-
-            iAppUiEngine->SignalViewPdlReloadingL();
-
+            iAppUiEngine->SendMessageToPdlViewL( KMpxVideoPlaybackPdlReloading );
             StartNewDownloadL( aDlId, aFileName );
         }
     }
--- a/videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappuiengine.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappuiengine.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,8 @@
 *
 */
 
-// Version : %version: e92_71 %
+
+// Version : %version: da1mmcf#72 %
 
 
 #include <eikon.hrh>
@@ -907,7 +908,7 @@
 
 
 // -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
 //
 void CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()
@@ -930,7 +931,7 @@
 }
 
 // -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
 //
 TBool CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL( TApaCommand aCommand,
@@ -964,7 +965,7 @@
 }
 
 // -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
 //
 void CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()
@@ -1119,19 +1120,19 @@
 }
 
 // -------------------------------------------------------------------------------------------------
-//   CMpxVideoPlayerAppUiEngine::SignalViewPdlReloadingL()
+//   CMpxVideoPlayerAppUiEngine::SendMessageToPdlViewL()
 // -------------------------------------------------------------------------------------------------
 //
-void CMpxVideoPlayerAppUiEngine::SignalViewPdlReloadingL()
+void CMpxVideoPlayerAppUiEngine::SendMessageToPdlViewL( TInt aMsg )
 {
-    MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SignalViewPdlReloadingL"));
+    MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SendMessageToPdlViewL"));
 
     if ( iViewUtility->ActiveViewType() == TUid::Uid( KMpxPlaybackPluginTypeUid ) )
     {
         //
         //  The display window must be removed before closing the playback plugin
         //
-        iAppUi->View()->HandleCommandL( KMpxVideoPlaybackPdlReloading );
+        iAppUi->View()->HandleCommandL( aMsg );
     }
 }
 
@@ -1142,13 +1143,13 @@
 void CMpxVideoPlayerAppUiEngine::ActivateLateConstructTimerL()
 {
     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateLateConstructTimerL()"));
-	
+
     if ( !iConstructTimer )
     {
         const TTimeIntervalMicroSeconds32 timeout  = 250000; // 250 ms
-    
+
         TCallBack callback ( CMpxVideoPlayerAppUiEngine::LateConstructCallback, this );
-    
+
         iConstructTimer = CPeriodic::NewL( CActive::EPriorityIdle );
 
         iConstructTimer->Start( timeout, 0, callback );
@@ -1162,9 +1163,9 @@
 TInt CMpxVideoPlayerAppUiEngine::LateConstructCallback( TAny* aPtr )
 {
     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::LateConstructCallback()"));
-    
+
     TRAP_IGNORE( static_cast<CMpxVideoPlayerAppUiEngine*>(aPtr)->DoLateConstructL() );
-    
+
     return KErrNone;
 }
 
@@ -1176,8 +1177,8 @@
 {
     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoLateConstructL()"));
 
-    iConstructTimer->Cancel(); 
-        
+    iConstructTimer->Cancel();
+
     PlaybackUtilityL();
 }