videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp
changeset 0 96612d01cf9f
child 15 cf5481c2bc0b
child 34 bbb98528c666
child 56 839377eedc2b
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32svr.h>
       
    20 #include <e32std.h>
       
    21 #include <StifParser.h>
       
    22 #include <Stiftestinterface.h>
       
    23 #include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroyPushL
       
    24 
       
    25 #include <e32cons.h>
       
    26 #include <mpxcollectionutility.h>
       
    27 #include <mpxmediacontainerdefs.h>
       
    28 #include <mpxmediageneraldefs.h>
       
    29 #include <mpxmediageneralextdefs.h>
       
    30 #include <mpxmessagegeneraldefs.h>
       
    31 #include <mpxcollectionmessagedefs.h>
       
    32 #include <mpxcollectionpath.h>
       
    33 #include <mpxmessage2.h>
       
    34 #include <mpxcollectionmessage.h>
       
    35 #include <mpxmessagecontainerdefs.h>
       
    36 #include <mpxmediabase.h>
       
    37 #include <mpxcommandgeneraldefs.h>
       
    38 #include <mpxcollectioncommanddefs.h>
       
    39 
       
    40 #include "VCXTestCommon.h"
       
    41 #include "VCXTestLog.h"
       
    42 #include "CIptvTestTimer.h"
       
    43 #include "CIptvTestActiveWait.h"
       
    44 #include "VCXTestStatsKeeper.h"
       
    45 
       
    46 #include "VCXMyVideosCollectionPluginTester.h"
       
    47 #include "VCXMyVideosTestDlWatcher.h"
       
    48 #include "VCXMyVideosTestCommon.h"
       
    49 
       
    50 #include "vcxmyvideoscollection.hrh"
       
    51 #include "vcxmyvideosmdsdb.h"
       
    52 #include "vcxmyvideosdefs.h"
       
    53 
       
    54 // CONSTANTS
       
    55 
       
    56 
       
    57 // ============================ MEMBER FUNCTIONS ===============================
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CVCXMyVideosCollectionPluginTester::NewL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
       
    64             MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
       
    65     {
       
    66     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
       
    67     CVCXMyVideosCollectionPluginTester* self = 
       
    68         new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestCommon, aStatsKeeper );
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop(self);
       
    72     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::NewL");
       
    73     return self;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
       
    81         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
       
    82         CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
       
    83  : iObserver( aObserver ), iTestCommon( aTestCommon ), iStats( aStatsKeeper )
       
    84     {
       
    85 
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester( )
       
    93     {
       
    94     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
       
    95 
       
    96     if( iProgressTimer )
       
    97         {
       
    98         iProgressTimer->CancelTimer();
       
    99         delete iProgressTimer;
       
   100         iProgressTimer = NULL;
       
   101         }
       
   102 
       
   103     delete iDlWatcher;
       
   104     iDlWatcher = NULL;
       
   105 
       
   106     if( iCollectionUtility )
       
   107         {
       
   108         iCollectionUtility->Close();
       
   109         }
       
   110     iCollectionUtility = NULL;
       
   111     
       
   112     delete iCollectionEntries;
       
   113     iCollectionEntries = NULL;
       
   114 
       
   115     if( iOldMediaArray )
       
   116         {
       
   117         iOldMediaArray->Reset();
       
   118         delete iOldMediaArray;
       
   119         iOldMediaArray = NULL;
       
   120         }
       
   121 
       
   122     if( iMediaArray )
       
   123         {
       
   124         iMediaArray->Reset();
       
   125         delete iMediaArray;
       
   126         iMediaArray = NULL;
       
   127         }
       
   128 
       
   129     iFs.Close();
       
   130 
       
   131     if( iActiveWait )
       
   132         {
       
   133         iActiveWait->Stop();
       
   134         delete iActiveWait;
       
   135         iActiveWait = NULL;
       
   136         }
       
   137 
       
   138     iRequestedMediaIds.Close();
       
   139 
       
   140     if( iFullMedia )
       
   141         {
       
   142         delete iFullMedia;
       
   143         iFullMedia = NULL;
       
   144         }
       
   145 
       
   146     iInsertedItemIds.Close();
       
   147     iDeletedItemIds.Close();
       
   148 
       
   149     delete iCurrentLevelName;
       
   150     iCurrentLevelName = NULL;
       
   151     
       
   152     iTransactions->CheckTransactions();
       
   153     delete iTransactions;
       
   154     iTransactions = NULL;
       
   155     
       
   156     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CVCXMyVideosCollectionPluginTester::ConstructL
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CVCXMyVideosCollectionPluginTester::ConstructL()
       
   164     {
       
   165     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
       
   166     iAutomaticContentRefresh = ETrue;
       
   167 
       
   168     iActiveWait = CIptvTestActiveWait::NewL();
       
   169     User::LeaveIfError( iFs.Connect() );
       
   170     
       
   171     iTransactions = CVCXMyVideosTestTransactions::NewL();
       
   172     iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
       
   173     iDlWatcher = CVCXMyVideosTestDlWatcher::NewL( iObserver, iStats );
       
   174     iUpdateDownloads = ETrue;
       
   175     iCurrentOpenedLevelIndex = -1;
       
   176     iProgressTimer = CIptvTestTimer::NewL( *this, 0 );
       
   177     iProgressTimer->After( 1000000 );
       
   178     
       
   179     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CVCXMyVideosCollectionPluginTester::ConstructL
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CVCXMyVideosCollectionPluginTester::OpenCollectionL( TUint32 aCollectionUid )
       
   187     {
       
   188     VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester::OpenCollectionL (%d)", this);
       
   189     
       
   190     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   191     CleanupStack::PushL( path );
       
   192     iCollectionUid = TUid::Uid( aCollectionUid );
       
   193     path->AppendL( aCollectionUid );
       
   194     
       
   195     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionActionId, _L("Open collection") ) );
       
   196     iCurrentActionHasResponse = EFalse;
       
   197     iCurrentActionId = KOpenCollectionActionId;
       
   198     SetRefreshStatus( ETrue );
       
   199     
       
   200     iCollectionUtility->Collection().OpenL( *path );
       
   201     
       
   202     CleanupStack::PopAndDestroy( path );
       
   203     
       
   204     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL");
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CVCXMyVideosCollectionPluginTester::OpenLevelL
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex )
       
   212     {
       
   213     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL");
       
   214 
       
   215     if( GetCurrentLevel() != 2 )
       
   216         {
       
   217         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
       
   218         User::Leave( KErrGeneral );
       
   219         }
       
   220 
       
   221     if( aIndex < 0 || aIndex > iMediaArray->Count() )
       
   222         {
       
   223         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error. Index (%d) out of bounds!", aIndex);
       
   224         User::Leave( KErrGeneral );
       
   225         }
       
   226 
       
   227     // Save the name of level
       
   228 
       
   229     CMPXMedia* media(NULL);
       
   230     media = (*iMediaArray)[aIndex];
       
   231 
       
   232     if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   233         {
       
   234         delete iCurrentLevelName;
       
   235         iCurrentLevelName = NULL;
       
   236         iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
       
   237         }
       
   238 
       
   239     // Open the level
       
   240     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionLevelActionId, _L("Open level") ) );
       
   241     iCurrentActionHasResponse = EFalse;
       
   242     iCurrentActionId = KOpenCollectionLevelActionId;
       
   243     
       
   244     iCollectionUtility->Collection().OpenL( aIndex );
       
   245     
       
   246     iCurrentOpenedLevelIndex = aIndex;
       
   247     SetRefreshStatus( ETrue );
       
   248     
       
   249     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenLevelL");
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CVCXMyVideosCollectionPluginTester::RefreshContentsL
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 void CVCXMyVideosCollectionPluginTester::RefreshContentsL()
       
   257     {
       
   258     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
       
   259 
       
   260     // No need to refresh if My Videos category is not open.
       
   261     if( GetCurrentLevel() != 3)
       
   262         {
       
   263         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
       
   264         return;
       
   265         }
       
   266 
       
   267     // Wait previous refresh to complete.
       
   268     if( IsRefreshing() )
       
   269         {
       
   270         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
       
   271         return;
       
   272         }
       
   273 
       
   274     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
       
   275     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
       
   276     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
       
   277 
       
   278     TRAP_IGNORE( iStats->ActionStartL( KRefreshCollectionActionId, _L("Refreshing collection") ) );
       
   279     iCurrentActionHasResponse = EFalse;
       
   280     iCurrentActionId = KRefreshCollectionActionId;
       
   281     iCollectionUtility->Collection().OpenL();
       
   282     SetRefreshStatus( ETrue );
       
   283 
       
   284     //VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RefreshContentsL");
       
   285     }
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL( TInt aStartIndex, TInt aEndIndex, TBool aSync )
       
   292     {
       
   293     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL");
       
   294 
       
   295     if ( iCollectionUid.iUid == 0 )
       
   296         {
       
   297         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error, collection must be opened!");
       
   298         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL");
       
   299         User::Leave( KErrNotReady );
       
   300         }
       
   301 
       
   302     if( IsRefreshing() )
       
   303         {
       
   304         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
       
   305         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL");
       
   306         return;
       
   307         }
       
   308     
       
   309     CMPXCommand* cmd( NULL );
       
   310     
       
   311     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediasByMpxId, aSync );    
       
   312     
       
   313     CMPXMediaArray* requestedMediaObjects = SelectMediasL( -1, aStartIndex, aEndIndex );
       
   314     CleanupStack::PushL( requestedMediaObjects );
       
   315 
       
   316     if( requestedMediaObjects )
       
   317         {
       
   318         cmd->SetCObjectValueL( KMPXMediaArrayContents, requestedMediaObjects );
       
   319         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
       
   320         }
       
   321 
       
   322     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Doing request.");
       
   323     iActionCount++;
       
   324     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Get medias by MPX ID") ) );
       
   325     iCurrentActionHasResponse = ETrue;
       
   326     iCollectionUtility->Collection().CommandL( *cmd );
       
   327 
       
   328     SetRefreshStatus( ETrue );
       
   329 
       
   330     CleanupStack::PopAndDestroy( requestedMediaObjects );
       
   331     CleanupStack::PopAndDestroy( cmd );
       
   332 
       
   333     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediasByMpxIdL");
       
   334     }
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 void CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL( TInt aDrive, TInt aIndex )
       
   341     {
       
   342     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
       
   343 
       
   344     if( GetCurrentLevel() < 2 )
       
   345         {
       
   346         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos category must be open!");
       
   347         User::Leave( KErrGeneral );
       
   348         }
       
   349 
       
   350     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
       
   351 
       
   352     RArray<TMPXAttribute> attrs;
       
   353     CleanupClosePushL(attrs);
       
   354     // Empty attributes to get all the details.
       
   355     CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
       
   356     CleanupStack::PushL( path );
       
   357     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
       
   358     path->SelectL( realIndex );
       
   359     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details") ) );
       
   360     iCurrentActionHasResponse = EFalse;
       
   361     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
       
   362     CleanupStack::PopAndDestroy( path );
       
   363     CleanupStack::PopAndDestroy( &attrs );
       
   364 
       
   365     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
       
   366     }
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL
       
   370 // -----------------------------------------------------------------------------
       
   371 //
       
   372 void CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL( TInt aDrive, TInt aIndex, TBool aSync )
       
   373     {
       
   374     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
       
   375 
       
   376     if( GetCurrentLevel() < 2 )
       
   377         {
       
   378         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos category must be open!");
       
   379         User::Leave( KErrGeneral );
       
   380         }
       
   381 
       
   382     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
       
   383     CMPXMedia* media = media = (*iCollectionMediaArray)[realIndex];
       
   384     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   385     
       
   386     CMPXCommand* cmd( NULL );
       
   387 
       
   388     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
       
   389     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
       
   390     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details by MPX ID") ) );
       
   391     iCollectionUtility->Collection().CommandL( *cmd );
       
   392     
       
   393     iCurrentActionHasResponse = EFalse;
       
   394     
       
   395     CleanupStack::PopAndDestroy( cmd );
       
   396 
       
   397     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // CVCXMyVideosCollectionPluginTester::CloseLevelL
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 void CVCXMyVideosCollectionPluginTester::CloseLevelL( )
       
   405     {
       
   406     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CloseLevelL");
       
   407 
       
   408     if( GetCurrentLevel() <= 1 )
       
   409         {
       
   410         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. Cannot go back from root level!");
       
   411         User::Leave( KErrGeneral );
       
   412         }
       
   413 
       
   414     iCurrentOpenedLevelIndex = -1;
       
   415 
       
   416     delete iCurrentLevelName;
       
   417     iCurrentLevelName = NULL;
       
   418 
       
   419     iCollectionUtility->Collection().BackL();
       
   420     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CloseLevelL");
       
   421     }
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 // CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 void CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL()
       
   428     {
       
   429     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL");
       
   430 
       
   431     if( GetCurrentLevel() > 0 )
       
   432         {
       
   433         if( iMediaArray )
       
   434             {
       
   435             if( !iQuietMode )
       
   436                 {
       
   437                 if( !iCurrentLevelName )
       
   438                     {
       
   439                     PrintMediasL( iMediaArray, ETrue, _L("Collection") );
       
   440                     }
       
   441                 else
       
   442                     {
       
   443                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
       
   444                     }
       
   445                 }
       
   446 
       
   447             // Update download states and info
       
   448             if( GetCurrentLevel() == 3 && iUpdateDownloads && iDownloadsStarted )
       
   449                 {
       
   450                 UpdateDownloadsL( iQuietMode );
       
   451                 }
       
   452             }
       
   453         else
       
   454             {
       
   455             VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL");
       
   456             }
       
   457         }
       
   458 
       
   459     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL");
       
   460     }
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CVcxMyVideosCollectionTester::UpdateDownloadsL
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 void CVCXMyVideosCollectionPluginTester::UpdateDownloadsL( TBool aQuietMode )
       
   467     {
       
   468     if( !iMediaArray || !iDlWatcher )
       
   469         {
       
   470         return;
       
   471         }
       
   472 
       
   473     if( !aQuietMode )
       
   474         VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateDownloadsL ---------->");
       
   475 
       
   476     iDlWatcher->PrepareCheck();
       
   477 
       
   478     // Print short info about downloads
       
   479     CMPXMedia* media( NULL );
       
   480 
       
   481     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
   482         {
       
   483         media = (*iMediaArray)[i];
       
   484 
       
   485         // If it's download then get info about it and update download watcher.
       
   486         if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
   487             {
       
   488             TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
   489 
       
   490             TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   491 
       
   492             HBufC* titleBuff = NULL;
       
   493             HBufC* urlBuff = NULL;
       
   494             HBufC* pathBuff = NULL;
       
   495 
       
   496             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   497                 {
       
   498                 const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   499                 pathBuff = url.AllocL();
       
   500                 CleanupStack::PushL( pathBuff );
       
   501                 }
       
   502 
       
   503             if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   504                 {
       
   505                 const TDesC& title = media->ValueText( KMPXMediaGeneralTitle );
       
   506                 titleBuff = title.AllocL();
       
   507                 CleanupStack::PushL( titleBuff );
       
   508                 }
       
   509 
       
   510             if( media->IsSupported( KVcxMediaMyVideosRemoteUrl ) )
       
   511                 {
       
   512                 const TDesC& url = media->ValueText( KVcxMediaMyVideosRemoteUrl );
       
   513                 urlBuff = url.AllocL();
       
   514                 CleanupStack::PushL( urlBuff );
       
   515                 }
       
   516 
       
   517             TInt progress = 0;
       
   518             if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
   519                 {
       
   520                 progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
       
   521                 }
       
   522 
       
   523             TUint32 downloadId = 0;
       
   524             if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
       
   525                 {
       
   526                 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
   527                 }
       
   528 
       
   529             TInt downloadError = 0;
       
   530             if( media->IsSupported( KVcxMediaMyVideosDownloadError ) )
       
   531                 {
       
   532                 downloadError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError );
       
   533                 }
       
   534 
       
   535             TInt globalError = 0;
       
   536             if( media->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) )
       
   537                 {
       
   538                 globalError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError );
       
   539                 }
       
   540 
       
   541             CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
       
   542 
       
   543             if( !dl )
       
   544                 {
       
   545                 // Tell dl watcher that dl has started. 
       
   546                 if( state != EVcxMyVideosDlStateNone )
       
   547                     {
       
   548                     iDlWatcher->StartDownloadL( *urlBuff, *pathBuff, downloadId, itemId.iId1, *titleBuff,
       
   549                             static_cast<TVcxMyVideosDownloadState>( state ), progress );
       
   550                     }
       
   551                 }
       
   552             else
       
   553                 {
       
   554                 // Update download. 
       
   555                     iDlWatcher->UpdateDownloadStateL( itemId.iId1, downloadId, 
       
   556                             static_cast<TVcxMyVideosDownloadState>( state ), progress, 
       
   557                             downloadError, globalError );
       
   558                     
       
   559                 }
       
   560             
       
   561             if( state == EVcxMyVideosDlStatePaused && iAutoResume )
       
   562                 {
       
   563                 if( dl && !dl->iWaitingResume )
       
   564                     {
       
   565                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Autoresuming the paused download. ---------->");
       
   566                     ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
       
   567                     iDlWatcher->SetDownloadResumedFlagL( itemId.iId1, downloadId );
       
   568                     dl->iWaitingPause = EFalse;
       
   569                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Resume ok ---------->");
       
   570                     }
       
   571                 }
       
   572 
       
   573             if( urlBuff )
       
   574                 {
       
   575                 CleanupStack::PopAndDestroy( urlBuff );
       
   576                 }
       
   577             if( titleBuff )
       
   578                 {                
       
   579                 CleanupStack::PopAndDestroy( titleBuff );
       
   580                 }
       
   581             if( pathBuff )
       
   582                 {                       
       
   583                 CleanupStack::PopAndDestroy( pathBuff );
       
   584                 }
       
   585             }
       
   586         }
       
   587 
       
   588     if( !aQuietMode )
       
   589         {
       
   590         iDlWatcher->PrintDownloads();
       
   591         }
       
   592 
       
   593     iDlWatcher->FinishCheckL();
       
   594     if( !aQuietMode )
       
   595         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateDownloadsL <----------");
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // CVcxMyVideosCollectionTester::CreateMpxCommandLC
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync )
       
   603     {
       
   604     CMPXCommand* cmd = CMPXCommand::NewL();
       
   605     CleanupStack::PushL( cmd );
       
   606 
       
   607     cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
       
   608     if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   609         {
       
   610         cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
       
   611         }
       
   612 
       
   613     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync );
       
   614 
       
   615     if( !aSync )
       
   616         {
       
   617         // Transaction id is used also tracking stats, so increment for every command.
       
   618         iTransactions->NextTransactionId();
       
   619 
       
   620         if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   621             {
       
   622             cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
       
   623             iTransactions->AddTransactionId( aMyVideosCommandId );
       
   624             }
       
   625         }
       
   626 
       
   627     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
       
   628 
       
   629     return cmd;
       
   630     }
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // CVcxMyVideosCollectionTester::SelectMediasL
       
   634 // -----------------------------------------------------------------------------
       
   635 //
       
   636 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex )
       
   637     {
       
   638     if( aStartIndex == -4 )
       
   639         {
       
   640         VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL");
       
   641         return NULL;
       
   642         }
       
   643 
       
   644     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   645     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex);
       
   646 
       
   647     if( !iMediaArray )
       
   648         {
       
   649         User::Leave( KErrNotReady );
       
   650         }
       
   651 
       
   652     iRequestedMediaIds.Reset();
       
   653 
       
   654     CMPXMediaArray* medias = CMPXMediaArray::NewL();
       
   655 
       
   656     // None
       
   657     if( aStartIndex > aEndIndex )
       
   658         {
       
   659         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos.");
       
   660         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   661         return medias;
       
   662         }
       
   663 
       
   664     CleanupStack::PushL( medias );
       
   665 
       
   666     if( aStartIndex >= 0 )
       
   667         {
       
   668         if( aEndIndex > iMediaArray->Count() )
       
   669             {
       
   670             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   671             User::Leave( KErrArgument );
       
   672             }
       
   673 
       
   674         TInt countToSelect = aEndIndex - aStartIndex;
       
   675         TInt indexOfVideoOnDrive = 0;
       
   676         
       
   677         for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
   678             {
       
   679             CMPXMedia* media = (*iMediaArray)[i];
       
   680 
       
   681             if( media )
       
   682                 {
       
   683                 TBool selectThis( EFalse );
       
   684                 
       
   685                 if( aDriveFilter != -1 )
       
   686                     {
       
   687                     // Drive specified, check path and index of video on the drive.
       
   688                     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
   689                     TInt drive( 0 );
       
   690                     User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
       
   691 
       
   692                     if( drive == aDriveFilter )
       
   693                         {
       
   694                         if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex )
       
   695                             {
       
   696                             selectThis = ETrue;
       
   697                             }
       
   698                         indexOfVideoOnDrive++;                        
       
   699                         }
       
   700                     }
       
   701                 else
       
   702                     {
       
   703                     // No drive specified, just index check.
       
   704                     if( i >= aStartIndex && i < aEndIndex )
       
   705                         {
       
   706                         selectThis = ETrue;
       
   707                         }
       
   708                     }
       
   709 
       
   710                 if( selectThis )
       
   711                     {
       
   712                     TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   713                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
   714                     iRequestedMediaIds.Append( mpxId.iId1 );
       
   715                     CMPXMedia* newMedia = CMPXMedia::NewL();
       
   716                     CleanupStack::PushL( newMedia );
       
   717                     newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   718                     newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   719                     medias->AppendL( *newMedia );
       
   720                     CleanupStack::PopAndDestroy( newMedia );
       
   721     
       
   722                     if( medias->Count() >= countToSelect )
       
   723                         {
       
   724                         break;
       
   725                         }
       
   726                     }
       
   727                 }
       
   728             }
       
   729         }
       
   730 
       
   731     // Invalid IDs
       
   732     if( aStartIndex == -1 )
       
   733         {
       
   734         for( TInt i = 0; i < aEndIndex; i++ )
       
   735             {
       
   736             TMPXItemId mpxId;
       
   737             mpxId.iId1 = i+66666;
       
   738             mpxId.iId2 = 0;
       
   739 
       
   740             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1);
       
   741 
       
   742             CMPXMedia* newMedia = CMPXMedia::NewL();
       
   743             CleanupStack::PushL( newMedia );
       
   744             newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   745             newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   746             medias->AppendL( *newMedia );
       
   747             CleanupStack::PopAndDestroy( newMedia );
       
   748             }
       
   749         }
       
   750 
       
   751     // Duplicate IDs
       
   752     if( aStartIndex == -2 )
       
   753         {
       
   754         if( aEndIndex > iMediaArray->Count() )
       
   755             {
       
   756             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   757             User::Leave( KErrArgument );
       
   758             }
       
   759 
       
   760         for( TInt i = 0; i < aEndIndex; i++ )
       
   761             {
       
   762             CMPXMedia* media = (*iMediaArray)[i];
       
   763 
       
   764             if( media )
       
   765                 {
       
   766                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   767 
       
   768                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1);
       
   769                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   770                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   771                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
   772                 CleanupStack::PushL( newMedia );
       
   773                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   774                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   775                 medias->AppendL( *newMedia );
       
   776                 medias->AppendL( *newMedia );
       
   777                 CleanupStack::PopAndDestroy( newMedia );
       
   778                 }
       
   779             }
       
   780         }
       
   781 
       
   782     // Every second ID
       
   783     if( aStartIndex == -3 )
       
   784         {
       
   785         if( aEndIndex > iMediaArray->Count() )
       
   786             {
       
   787             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   788             User::Leave( KErrArgument );
       
   789             }
       
   790 
       
   791         for( TInt i = 0; i < aEndIndex; i+=2 )
       
   792             {
       
   793             CMPXMedia* media = (*iMediaArray)[i];
       
   794 
       
   795             if( media )
       
   796                 {
       
   797                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   798 
       
   799                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
   800                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   801                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
   802                 CleanupStack::PushL( newMedia );
       
   803                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   804                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   805                 medias->AppendL( *newMedia );
       
   806                 CleanupStack::PopAndDestroy( newMedia );
       
   807                 }
       
   808             }
       
   809         }
       
   810 
       
   811     CleanupStack::Pop( medias );
       
   812 
       
   813     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   814     return medias;
       
   815     }
       
   816 
       
   817 // -----------------------------------------------------------------------------
       
   818 // CVcxMyVideosCollectionTester::UpdateOwnedMediaArray
       
   819 // -----------------------------------------------------------------------------
       
   820 //
       
   821 void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL()
       
   822     {
       
   823     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
   824 
       
   825     if ( !iCollectionEntries )
       
   826         {
       
   827         return;
       
   828         }
       
   829 
       
   830     if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) )
       
   831         {
       
   832         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!");
       
   833         User::Leave( KErrNotSupported );
       
   834         }
       
   835 
       
   836     // Get up to date list of all medias in collection.
       
   837     CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   838     
       
   839     // Delete array of old medias
       
   840     if( iOldMediaArray )
       
   841         {
       
   842         iOldMediaArray->Reset();
       
   843         delete iOldMediaArray;
       
   844         }
       
   845 
       
   846     // Update the old array and create new
       
   847     iOldMediaArray = iMediaArray;
       
   848     iMediaArray = CMPXMediaArray::NewL();
       
   849 
       
   850     TBool categories( EFalse );
       
   851     
       
   852     // Make copies of the medias.
       
   853     for( TInt i=0; i<medias->Count(); i++ )
       
   854         {
       
   855         CMPXMedia* media = (*medias)[i];
       
   856         
       
   857         TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   858         if( itemId.iId2 != 0 )
       
   859              {
       
   860              categories = ETrue;
       
   861              }
       
   862         
       
   863         // Ignore medias on ROM.
       
   864         TBool isOnRom( EFalse );
       
   865         
       
   866         if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   867             {
       
   868             const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   869             if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
   870                 {
       
   871                 isOnRom = ETrue;
       
   872                 }
       
   873             }
       
   874         
       
   875         if( !isOnRom )
       
   876             {
       
   877             iMediaArray->AppendL( *media );
       
   878             }
       
   879         }
       
   880     
       
   881     iMediaCount = iMediaArray->Count();
       
   882     
       
   883     // Update count of videos on ROM.
       
   884     if( !categories )
       
   885         {
       
   886         iVideosOnRomCount = 0;
       
   887 
       
   888         for( TInt i=0; i<medias->Count(); i++ )
       
   889             {
       
   890             CMPXMedia* media = (*medias)[i];            
       
   891             
       
   892             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   893                 {
       
   894                 const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   895                 if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
   896                     {
       
   897                     iVideosOnRomCount++;
       
   898                     }
       
   899                 }
       
   900             }
       
   901 
       
   902             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount);
       
   903         }
       
   904     
       
   905     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // CVcxMyVideosCollectionTester::GetChangedMedias
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias )
       
   913     {
       
   914     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   915 
       
   916     CMPXMediaArray* changedMedias = CMPXMediaArray::NewL();
       
   917 
       
   918     if( !aNewMedias )
       
   919         {
       
   920         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   921         return changedMedias;
       
   922         }
       
   923 
       
   924     CleanupStack::PushL( changedMedias );
       
   925 
       
   926     for( TInt i=0; i<aNewMedias->Count(); i++ )
       
   927         {
       
   928         CMPXMedia* media(NULL);
       
   929         media = (*aNewMedias)[i];
       
   930         
       
   931         if( !media )
       
   932             {
       
   933             continue;
       
   934             }
       
   935         
       
   936         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   937 
       
   938         CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId );
       
   939 
       
   940         TBool add( EFalse );
       
   941 
       
   942         // It's a new.
       
   943         if( !oldMedia )
       
   944             {
       
   945             add = ETrue;
       
   946             }
       
   947         // Check changes
       
   948         else
       
   949             {
       
   950             const TArray<TMPXAttribute> newAttributes = media->Attributes();
       
   951             const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
       
   952             if( newAttributes.Count() != oldAttributes.Count() )
       
   953                 {
       
   954                 add = ETrue;
       
   955                 }
       
   956             else
       
   957                 {
       
   958                 for( TInt e=0; e<newAttributes.Count(); e++ )
       
   959                     {
       
   960                     if( !oldMedia->Match( *media, newAttributes[e] ) )
       
   961                         {
       
   962                         add = ETrue;
       
   963                         break;
       
   964                         }
       
   965                     }
       
   966                 }
       
   967             }
       
   968 
       
   969         // Add a copy of the media.
       
   970         if( add )
       
   971             {
       
   972             changedMedias->AppendL( *media );
       
   973             }
       
   974         }
       
   975 
       
   976     CleanupStack::Pop( changedMedias );
       
   977 
       
   978     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   979     return changedMedias;
       
   980     }
       
   981 
       
   982 // -----------------------------------------------------------------------------
       
   983 // CVcxMyVideosCollectionTester::GetMediaByMpxId
       
   984 // -----------------------------------------------------------------------------
       
   985 //
       
   986 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId )
       
   987     {
       
   988     if( !aMedias )
       
   989         {
       
   990         return NULL;
       
   991         }
       
   992 
       
   993     for( TInt i=0; i<aMedias->Count(); i++ )
       
   994         {
       
   995         CMPXMedia* media = (*aMedias)[i];
       
   996         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   997 
       
   998         if( mpxId == aMpxId )
       
   999             {
       
  1000             return media;
       
  1001             }
       
  1002         }
       
  1003     return NULL;
       
  1004     }
       
  1005 
       
  1006 // -----------------------------------------------------------------------------
       
  1007 // CVcxMyVideosCollectionTester::SetRefreshStatus
       
  1008 // -----------------------------------------------------------------------------
       
  1009 //
       
  1010 void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection )
       
  1011     {
       
  1012     iRefreshingCollection = aRefreshingCollection;
       
  1013     }
       
  1014 
       
  1015 // -----------------------------------------------------------------------------
       
  1016 // CVcxMyVideosCollectionTester::CheckRequestMediaArrayL
       
  1017 // -----------------------------------------------------------------------------
       
  1018 //
       
  1019 void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds )
       
  1020     {
       
  1021     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1022 
       
  1023     // Print requested ids
       
  1024     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:");
       
  1025     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1026         {
       
  1027         VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] );
       
  1028         }
       
  1029 
       
  1030     // Print actual result ids and check for errors
       
  1031     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:");
       
  1032     for( TInt i = 0; i < aRequestResultMedias.Count(); i++ )
       
  1033         {
       
  1034         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i);
       
  1035         CMPXMedia* media = aRequestResultMedias[i];
       
  1036         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media");
       
  1037         if( media )
       
  1038             {
       
  1039             TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1040             VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 );
       
  1041             if( media->IsSupported( KVcxMediaMyVideosInt32Value ) )
       
  1042                 {
       
  1043                 TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
       
  1044                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result);
       
  1045                 if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) )
       
  1046                     {
       
  1047                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result);
       
  1048                     User::Leave( result );
       
  1049                     }
       
  1050                 }
       
  1051             }
       
  1052         else
       
  1053             {
       
  1054             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i);
       
  1055             }
       
  1056         }
       
  1057 
       
  1058     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks");
       
  1059     
       
  1060     // First check the counts match
       
  1061     if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() )
       
  1062         {
       
  1063         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!");
       
  1064         User::Leave( KErrCorrupt );
       
  1065         }
       
  1066     else
       
  1067     // Check that all requested ids are in the results
       
  1068     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1069         {
       
  1070         TMPXItemId mpxId;
       
  1071         mpxId.iId1 = aRequestedMediaIds[i];
       
  1072         mpxId.iId2 = 0;
       
  1073 
       
  1074         TBool found( EFalse );
       
  1075         for( TInt e = 0; e < aRequestResultMedias.Count(); e++ )
       
  1076             {
       
  1077             CMPXMedia* media2 = aRequestResultMedias[e];
       
  1078             if( media2 )
       
  1079                 {
       
  1080                 TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1081 
       
  1082                 if( mpxId == mpxId2 )
       
  1083                     {
       
  1084                     found = ETrue;
       
  1085                     }
       
  1086                 }
       
  1087             }
       
  1088 
       
  1089         if( !found )
       
  1090             {
       
  1091             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!");
       
  1092             User::Leave( KErrCorrupt );
       
  1093             }
       
  1094         }
       
  1095     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1096     }
       
  1097 
       
  1098 // -----------------------------------------------------------------------------
       
  1099 // CVcxMyVideosCollectionTester::PrintMediasL
       
  1100 // -----------------------------------------------------------------------------
       
  1101 //
       
  1102 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
       
  1103     {
       
  1104     if( aMediaArray == NULL )
       
  1105         {
       
  1106         aMediaArray = iMediaArray;
       
  1107         }
       
  1108     
       
  1109     TInt count(0);
       
  1110     TInt changedCount(0);
       
  1111 
       
  1112     CMPXMediaArray* medias( NULL );
       
  1113 
       
  1114     if( aCheckChanges )
       
  1115         {
       
  1116          medias = GetChangedMedias( aMediaArray );
       
  1117          changedCount = medias->Count();
       
  1118          count = aMediaArray->Count();
       
  1119          CleanupStack::PushL( medias );
       
  1120         }
       
  1121     else
       
  1122         {
       
  1123         medias = aMediaArray;
       
  1124         count = aMediaArray->Count();
       
  1125         }
       
  1126 
       
  1127     if( count == 0 )
       
  1128         {
       
  1129         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: <----------- %S - No Entries ----------->", &aTitle);
       
  1130         }
       
  1131     else if( changedCount == 0 )
       
  1132         {
       
  1133         VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, no changes ----------->", &aTitle, count );
       
  1134         }
       
  1135     else
       
  1136         {
       
  1137         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
       
  1138         }
       
  1139 
       
  1140     CMPXMedia* media(NULL);
       
  1141     for( TInt i = 0; i < medias->Count(); i++ )
       
  1142         {
       
  1143         media = (*medias)[i];
       
  1144         if( media )
       
  1145             PrintMPXMediaL( *media, ETrue );
       
  1146         }
       
  1147 
       
  1148     if( aCheckChanges )
       
  1149         {
       
  1150         medias->Reset();
       
  1151         CleanupStack::PopAndDestroy( medias );
       
  1152         }
       
  1153     }
       
  1154 
       
  1155 // -----------------------------------------------------------------------------
       
  1156 // CVcxMyVideosCollectionTester::PrintMPXMediaL
       
  1157 // -----------------------------------------------------------------------------
       
  1158 //
       
  1159 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
       
  1160     {
       
  1161     TMPXItemId itemId = *aMedia.Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1162 
       
  1163     if( !aPrintAllDetails )
       
  1164         {
       
  1165         TBuf<256> title;
       
  1166         if( aMedia.IsSupported( KMPXMediaGeneralTitle ) )
       
  1167             {
       
  1168             title = aMedia.ValueText( KMPXMediaGeneralTitle );
       
  1169             }
       
  1170 
       
  1171         // Category
       
  1172         if( itemId.iId2 != 0 )
       
  1173             {
       
  1174             TInt itemCount(0);
       
  1175             TInt newItemCount(0);
       
  1176             TBuf<256> newItemName;
       
  1177             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
       
  1178                 {
       
  1179                 newItemName = aMedia.ValueText( KVcxMediaMyVideosCategoryNewItemName );
       
  1180                 }
       
  1181             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
       
  1182                  {
       
  1183                  itemCount = *aMedia.Value<TUint32>( KVcxMediaMyVideosCategoryItemCount );
       
  1184                  }
       
  1185             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
       
  1186                  {
       
  1187                  newItemCount = *aMedia.Value<TUint32>( KVcxMediaMyVideosCategoryNewItemCount );
       
  1188                  }
       
  1189             VCXLOGLO5("KMPXMediaGeneralTitle: title: %S, medias: %d, new: %d, new media: %S", &title, itemCount, newItemCount, &newItemName);
       
  1190             }
       
  1191         // Media
       
  1192         else
       
  1193             {
       
  1194             TBuf<256> path;
       
  1195             if( aMedia.IsSupported( KMPXMediaGeneralUri ) )
       
  1196                 {
       
  1197                 const TDesC& localFilePath = aMedia.ValueText( KMPXMediaGeneralUri );
       
  1198                 if( localFilePath.Length() >= 256 )
       
  1199                     {
       
  1200                     path = localFilePath.Left( 255 );
       
  1201                     }
       
  1202                 else
       
  1203                     {
       
  1204                     path = localFilePath;
       
  1205                     }
       
  1206                 }
       
  1207             TInt64 size(0);
       
  1208             TInt origin(-1);
       
  1209             if( aMedia.IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
       
  1210                  {
       
  1211                  size = *aMedia.Value<TInt64>( KMPXMediaGeneralExtSizeInt64 );
       
  1212                  }
       
  1213             if( aMedia.IsSupported( KVcxMediaMyVideosOrigin ) )
       
  1214                 {
       
  1215                 origin = *aMedia.Value<TUint>( KVcxMediaMyVideosOrigin );
       
  1216                 }
       
  1217             VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
       
  1218             VCXLOGLO5("KMPXMediaGeneralTitle: title: %S, size: %d, origin: %d, path: %S", &title, size, origin, &path);
       
  1219             }
       
  1220 
       
  1221         return;
       
  1222         }
       
  1223 
       
  1224     // Print all details
       
  1225 
       
  1226     if( itemId.iId2 != 0 )
       
  1227         {
       
  1228         VCXLOGLO1("--------------------------- MEDIA CATEGORY -------------------------------");
       
  1229         }
       
  1230     else
       
  1231         {
       
  1232         VCXLOGLO1("--------------------------- MEDIA OBJECT -------------------------------");
       
  1233         }
       
  1234 
       
  1235     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
       
  1236 
       
  1237     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
       
  1238          {
       
  1239          TUint32 value = *aMedia.Value<TUint32>( KVcxMediaMyVideosCategoryItemCount );
       
  1240          VCXLOGLO2("KVcxMediaMyVideosCategoryItemCount: %d", value);
       
  1241          }
       
  1242 
       
  1243     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
       
  1244          {
       
  1245          TUint32 value = *aMedia.Value<TUint32>( KVcxMediaMyVideosCategoryNewItemCount );
       
  1246          VCXLOGLO2("KVcxMediaMyVideosCategoryNewItemCount: %d", value);
       
  1247          }
       
  1248 
       
  1249     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
       
  1250         {
       
  1251         const TDesC& itemName = aMedia.ValueText( KVcxMediaMyVideosCategoryNewItemName );
       
  1252         VCXLOGLO2("KVcxMediaMyVideosCategoryNewItemName: %S", &itemName);
       
  1253         }
       
  1254 
       
  1255     if( aMedia.IsSupported( KMPXMediaGeneralTitle ) )
       
  1256         {
       
  1257         const TDesC& title = aMedia.ValueText( KMPXMediaGeneralTitle );
       
  1258         VCXLOGLO2("KMPXMediaGeneralTitle: %S", &title);
       
  1259         }
       
  1260 
       
  1261     if( aMedia.IsSupported( KMPXMediaGeneralComment ) )
       
  1262         {
       
  1263         const TDesC& desc = aMedia.ValueText( KMPXMediaGeneralComment );
       
  1264         VCXLOGLO2("KMPXMediaGeneralComment: %S", &desc);
       
  1265         }
       
  1266 
       
  1267     if( aMedia.IsSupported( KMPXMediaGeneralUri ) )
       
  1268         {
       
  1269         const TDesC& localFilePath = aMedia.ValueText( KMPXMediaGeneralUri );
       
  1270         VCXLOGLO2("KMPXMediaGeneralUri: %S", &localFilePath);
       
  1271         }
       
  1272 
       
  1273     if( aMedia.IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
       
  1274          {
       
  1275          TInt64 value = *aMedia.Value<TInt64>( KMPXMediaGeneralExtSizeInt64 );
       
  1276          VCXLOGLO2("KMPXMediaGeneralExtSizeInt64 (bytes): %Ld", value);
       
  1277          }
       
  1278 
       
  1279     if( aMedia.IsSupported( KMPXMediaGeneralDate ) )
       
  1280         {
       
  1281         TInt64 value = *aMedia.Value<TInt64>( KMPXMediaGeneralDate );
       
  1282         TTime time ( value );
       
  1283         TBuf<60> timeStr;
       
  1284         _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B");
       
  1285         time.FormatL(timeStr, KDateTimeString);
       
  1286         VCXLOGLO2("KMPXMediaGeneralDate: %S", &timeStr);
       
  1287         }
       
  1288 
       
  1289     if( aMedia.IsSupported( KMPXMediaGeneralFlags ) )
       
  1290          {
       
  1291          TUint value = *aMedia.Value<TUint>( KMPXMediaGeneralFlags );
       
  1292 
       
  1293          if( value & EVcxMyVideosVideoNew )
       
  1294              {
       
  1295              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoNew");
       
  1296              }
       
  1297          if( value & EVcxMyVideosVideoScheduledDownload )
       
  1298              {
       
  1299              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoScheduledDownload");
       
  1300              }
       
  1301          if( value & EVcxMyVideosVideoDeleteWarning )
       
  1302              {
       
  1303              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoDeleteWarning");
       
  1304              }
       
  1305          if( value & EVcxMyVideosVideoProtected )
       
  1306              {
       
  1307              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoProtected");
       
  1308              }
       
  1309          if( value & EVcxMyVideosVideoDrmProtected )
       
  1310              {
       
  1311              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoDrmProtected");
       
  1312              }
       
  1313          if( value & EVcxMyVideosVideoMemoryCard )
       
  1314              {
       
  1315              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoMemoryCard");
       
  1316              }
       
  1317          if( value & EVcxMyVideosVideoPreview )
       
  1318              {
       
  1319              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoPreview");
       
  1320              }
       
  1321          if( value & EVcxMyVideosVideoRecPartiallyFailed )
       
  1322              {
       
  1323              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoRecPartiallyFailed");
       
  1324              }
       
  1325          if( value & EVcxMyVideosVideoRecFailed )
       
  1326              {
       
  1327              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosVideoRecFailed");
       
  1328              }
       
  1329          if( value & EVcxMyVideosServiceHasReadOnlyIap )
       
  1330              {
       
  1331              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosServiceHasReadOnlyIap");
       
  1332              }
       
  1333          if( value & EVcxMyVideosSilent )
       
  1334              {
       
  1335              VCXLOGLO1("KMPXMediaGeneralFlags: EVcxMyVideosSilent");
       
  1336              }
       
  1337          }
       
  1338 
       
  1339     if( aMedia.IsSupported( KMPXMediaGeneralCopyright ) )
       
  1340         {
       
  1341         const TDesC& copyright = aMedia.ValueText( KMPXMediaGeneralCopyright );
       
  1342         VCXLOGLO2("KMPXMediaGeneralCopyright: %S", &copyright);
       
  1343         }
       
  1344 
       
  1345     if( aMedia.IsSupported( KMPXMediaGeneralMimeType ) )
       
  1346         {
       
  1347         const TDesC& mimeType = aMedia.ValueText( KMPXMediaGeneralMimeType );
       
  1348         VCXLOGLO2("KMPXMediaGeneralMimeType: %S", &mimeType);
       
  1349         }
       
  1350 
       
  1351     if( aMedia.IsSupported( KVcxMediaMyVideosModifiedDate ) )
       
  1352         {
       
  1353         TInt64 value = *aMedia.Value<TInt64>( KVcxMediaMyVideosModifiedDate );
       
  1354         TTime time ( value );
       
  1355         TBuf<60> timeStr;
       
  1356         _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B");
       
  1357         time.FormatL(timeStr, KDateTimeString);
       
  1358         VCXLOGLO2("KVcxMediaMyVideosModifiedDate: %S", &timeStr);
       
  1359         }
       
  1360 
       
  1361     /* 
       
  1362           //10.
       
  1363     if ( aObject.Property( *iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound
       
  1364         && aFullDetails )
       
  1365         {
       
  1366         aVideo.SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate,
       
  1367                 static_cast<CMdETimeProperty*>(property)->Value().Int64() );
       
  1368         }
       
  1369       */
       
  1370 
       
  1371     if( aMedia.IsSupported( KVcxMediaMyVideosAgeProfile ) )
       
  1372         {
       
  1373         TUint value = *aMedia.Value<TUint>( KVcxMediaMyVideosAgeProfile );
       
  1374         VCXLOGLO2("KVcxMediaMyVideosAgeProfile: %d", value);
       
  1375         }
       
  1376 
       
  1377     if( aMedia.IsSupported( KVcxMediaMyVideosAudioLanguage ) )
       
  1378         {
       
  1379         const TDesC& value = aMedia.ValueText( KVcxMediaMyVideosAudioLanguage );
       
  1380         VCXLOGLO2("KVcxMediaMyVideosAudioLanguage: %S", &value);
       
  1381         }
       
  1382 
       
  1383     if( aMedia.IsSupported( KVcxMediaMyVideosAuthor ) )
       
  1384         {
       
  1385         const TDesC& value = aMedia.ValueText( KVcxMediaMyVideosAuthor );
       
  1386         VCXLOGLO2("KVcxMediaMyVideosAuthor: %S", &value);
       
  1387         }
       
  1388 
       
  1389     if( aMedia.IsSupported( KVcxMediaMyVideosOrigin ) )
       
  1390         {
       
  1391         TUint8 value = *aMedia.Value<TUint>( KVcxMediaMyVideosOrigin );
       
  1392         VCXLOGLO2("KVcxMediaMyVideosOrigin: %d", value);
       
  1393         }
       
  1394 
       
  1395     if( aMedia.IsSupported( KVcxMediaMyVideosDuration ) )
       
  1396         {
       
  1397         TReal32 value = *aMedia.Value<TReal32>( KVcxMediaMyVideosDuration );
       
  1398         VCXLOGLO2("KVcxMediaMyVideosDuration: %f", value);
       
  1399         }
       
  1400 
       
  1401     if( aMedia.IsSupported( KMPXMediaGeneralLastPlaybackPosition ) )
       
  1402         {
       
  1403         TReal32 value = *aMedia.Value<TReal32>( KMPXMediaGeneralLastPlaybackPosition );
       
  1404         VCXLOGLO2("KMPXMediaGeneralLastPlaybackPosition: %f", value);
       
  1405         }
       
  1406 
       
  1407     if( aMedia.IsSupported( KVcxMediaMyVideosRemoteUrl ) )
       
  1408         {
       
  1409         const TDesC& value = aMedia.ValueText( KVcxMediaMyVideosRemoteUrl );
       
  1410         VCXLOGLO2("KVcxMediaMyVideosRemoteUrl: %S", &value);
       
  1411         }
       
  1412 
       
  1413     if( aMedia.IsSupported( KMPXMediaGeneralDrive ) )
       
  1414         {
       
  1415         const TDesC& drive = aMedia.ValueText( KMPXMediaGeneralDrive );
       
  1416         VCXLOGLO2("KMPXMediaGeneralDrive: %S", &drive);
       
  1417         }
       
  1418 
       
  1419     if( aMedia.IsSupported( KMPXMediaGeneralCount ) )
       
  1420         {
       
  1421         TInt value = *aMedia.Value<TInt>( KMPXMediaGeneralCount );
       
  1422         VCXLOGLO2("KMPXMediaGeneralCount: %d", value);
       
  1423         }
       
  1424 
       
  1425     if( aMedia.IsSupported( KMPXMediaGeneralLastPlaybackPosition ) )
       
  1426         {
       
  1427         TInt value = *aMedia.Value<TInt>( KMPXMediaGeneralLastPlaybackPosition );
       
  1428         VCXLOGLO2("KMPXMediaGeneralLastPlaybackPosition: %d", value);
       
  1429         }
       
  1430 
       
  1431     if( aMedia.IsSupported( KMPXMediaGeneralLastPlaybackTime ) )
       
  1432         {
       
  1433         TInt64 value = *aMedia.Value<TInt64>( KMPXMediaGeneralLastPlaybackTime );
       
  1434         TTime time ( value );
       
  1435         TBuf<60> timeStr;
       
  1436         _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B");
       
  1437         time.FormatL(timeStr, KDateTimeString);
       
  1438         VCXLOGLO2("KMPXMediaGeneralLastPlaybackTime: %S", &timeStr);
       
  1439         }
       
  1440 
       
  1441     if( aMedia.IsSupported( KMPXMediaGeneralPlayCount ) )
       
  1442         {
       
  1443         TUint value = *aMedia.Value<TUint>( KMPXMediaGeneralPlayCount );
       
  1444         VCXLOGLO2("KMPXMediaGeneralPlayCount: %d", value);
       
  1445         }
       
  1446 
       
  1447     if( aMedia.IsSupported( KMPXMediaGeneralContainerPath ) )
       
  1448         {
       
  1449         const TDesC& value = aMedia.ValueText( KMPXMediaGeneralContainerPath );
       
  1450         VCXLOGLO2("KMPXMediaGeneralContainerPath: %S", &value);
       
  1451         }
       
  1452 
       
  1453     if( aMedia.IsSupported( KMPXMediaGeneralPath ) )
       
  1454         {
       
  1455         // Media collection path; CMPXCollectionPath
       
  1456         const TDesC& value = aMedia.ValueText( KMPXMediaGeneralPath );
       
  1457         VCXLOGLO2("KMPXMediaGeneralPath: %S", &value);
       
  1458         }
       
  1459     }
       
  1460 
       
  1461 // -----------------------------------------------------------------------------
       
  1462 // CVcxMyVideosCollectionTester::HandleCollectionMessage
       
  1463 // -----------------------------------------------------------------------------
       
  1464 //
       
  1465 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
       
  1466     {
       
  1467     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
       
  1468     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
       
  1469 
       
  1470     if( !aMessage )
       
  1471         {
       
  1472         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: aMessage is NULL");
       
  1473         aError = KErrGeneral;
       
  1474         }
       
  1475 
       
  1476     if( aError == KErrNone )
       
  1477         {
       
  1478         TInt err( KErrNone );
       
  1479 
       
  1480         TMPXMessageId messageId = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ));
       
  1481         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Message id: %d", messageId);
       
  1482 
       
  1483         TInt myVideosCmd = -1;
       
  1484         if ( messageId == KVcxCommandIdMyVideos )
       
  1485             {
       
  1486             myVideosCmd = aMessage->ValueTObjectL<TInt>( KVcxMediaMyVideosCommandId );
       
  1487             }
       
  1488 
       
  1489         if ( myVideosCmd != KVcxMessageMyVideosMessageArray )
       
  1490             {
       
  1491             TRAP( err, HandleSingleCollectionMessageL( aMessage ) );
       
  1492             }
       
  1493         else
       
  1494             {
       
  1495             if( err == KErrNone && aMessage->IsSupported( KMPXMessageArrayContents ) )
       
  1496                 {
       
  1497                 const CMPXMessageArray* messageArray =
       
  1498                         aMessage->Value<CMPXMessageArray>(KMPXMessageArrayContents);
       
  1499 
       
  1500                 TInt count = messageArray->Count();
       
  1501                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Message has array of %d messages.", count);
       
  1502 
       
  1503                 for( TInt i = 0; i < count; i++ )
       
  1504                     {
       
  1505                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Handling message at index: %d", i);
       
  1506                     TRAP( err, HandleSingleCollectionMessageL( (*messageArray)[i] ) );
       
  1507                     }
       
  1508                 }
       
  1509             else
       
  1510                 {
       
  1511                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: MY VIDEOS MESSAGE ARRAY WITHOUT ARRAY ARRIVED");
       
  1512                 err = KErrCorrupt;
       
  1513                 }
       
  1514             }
       
  1515 
       
  1516         if( err != KErrNone )
       
  1517             {
       
  1518             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error %d while handling messages!", err );
       
  1519             aError = err;
       
  1520             }
       
  1521         }
       
  1522 
       
  1523     if( aError != KErrNone )
       
  1524         {
       
  1525         SetRefreshStatus( EFalse );
       
  1526         iWaitingForItemChange = EFalse;
       
  1527         iActiveWait->Stop();
       
  1528         TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, aError ) );
       
  1529         }
       
  1530 
       
  1531     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
       
  1532     }
       
  1533 
       
  1534 // -----------------------------------------------------------------------------
       
  1535 // CVcxMyVideosCollectionTester::HandleSingleCollectionMessage
       
  1536 // -----------------------------------------------------------------------------
       
  1537 //
       
  1538 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
       
  1539     {
       
  1540     if( !aMessage || !aMessage->IsSupported( KMPXMessageGeneralId ) ) return;
       
  1541     
       
  1542     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");    
       
  1543     
       
  1544     TMPXMessageId messageId = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ));
       
  1545 
       
  1546     if( aMessage->IsSupported( KMPXMessageCollectionId ) )
       
  1547         {
       
  1548         TUid uid( *(aMessage->Value<TUid>( KMPXMessageCollectionId )) );
       
  1549         if( iCollectionUid != uid )
       
  1550             {
       
  1551             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Collection UIDs don't match: iCollectionUid %d, uid %d", iCollectionUid.iUid, uid.iUid);
       
  1552             VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
       
  1553             return;
       
  1554             }
       
  1555         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Collection UID: %d", uid.iUid);
       
  1556         }
       
  1557 
       
  1558     TUint32 transactionId( 0 );
       
  1559     if( aMessage->IsSupported( KVcxMediaMyVideosTransactionId ) )
       
  1560         {
       
  1561         transactionId = aMessage->ValueTObjectL<TUint32>( KVcxMediaMyVideosTransactionId );
       
  1562         iTransactions->TransactionResponse( transactionId );
       
  1563         }
       
  1564 
       
  1565     switch( messageId )
       
  1566         {
       
  1567         // Handle My Videos specific command results.
       
  1568         case KVcxCommandIdMyVideos:
       
  1569             {
       
  1570             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------");
       
  1571             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KVcxCommandIdMyVideos");
       
  1572             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------");
       
  1573             if ( aMessage->IsSupported( KVcxMediaMyVideosCommandId ) )
       
  1574                 {
       
  1575                 TInt myVideosCommandId = *(aMessage->Value<TInt>( KVcxMediaMyVideosCommandId ));
       
  1576 
       
  1577                 switch ( myVideosCommandId )
       
  1578                     {
       
  1579                     case KVcxMessageMyVideosGetMediasByMpxIdResp:
       
  1580                         {
       
  1581                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------------------");
       
  1582                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosGetMediasByMpxIdResp");
       
  1583                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------------------");
       
  1584 
       
  1585                         if( iActionCount <= 0 )
       
  1586                             {
       
  1587                             break;
       
  1588                             }
       
  1589                         iActionCount--;
       
  1590 
       
  1591                        // Update current entries
       
  1592                         delete iCollectionEntries;
       
  1593                         iCollectionEntries = NULL;
       
  1594                         iCollectionEntries = CMPXMedia::NewL( *aMessage );
       
  1595 
       
  1596                         UpdateOwnedMediaArrayL();
       
  1597 
       
  1598                         SetRefreshStatus( EFalse );
       
  1599 
       
  1600                         // add downloads to the requested ID array always and update downloads too.
       
  1601                         TBool backup = iUpdateDownloads;
       
  1602                         iUpdateDownloads = EFalse;
       
  1603                         ProcessCurrentEntriesL();
       
  1604                         iUpdateDownloads = backup;
       
  1605 
       
  1606                         // Check
       
  1607                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
       
  1608                         if( err != KErrNone )
       
  1609                             {
       
  1610                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
       
  1611                             }
       
  1612 
       
  1613                         // Inform observer
       
  1614                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
       
  1615                         
       
  1616                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1617                         if( actionErr == KErrAbort )
       
  1618                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1619                         
       
  1620                         }
       
  1621                         break;
       
  1622 
       
  1623                     // This is received when list is open already and the list contains new items
       
  1624                     case KVcxMessageMyVideosItemsAppended:
       
  1625                         {
       
  1626                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ------------------------------------------------------------");
       
  1627                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosItemsAppended");
       
  1628                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ------------------------------------------------------------");
       
  1629 
       
  1630                         if( !iCollectionEntries )
       
  1631                             {
       
  1632                             break;
       
  1633                             }
       
  1634 
       
  1635                         TInt before = iMediaCount;
       
  1636 
       
  1637                         UpdateOwnedMediaArrayL();
       
  1638 
       
  1639                         // New items were appended or removed
       
  1640                         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Items before: %d", before);
       
  1641                         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Items now: %d", iMediaArray->Count());
       
  1642 
       
  1643                         ProcessCurrentEntriesL();
       
  1644                         }
       
  1645                         break;
       
  1646 
       
  1647                     /**
       
  1648                     * Collection sends this message when media list fetching has ended
       
  1649                     * and no more KVcxMessageMyVideosItemsAppended will be sent.
       
  1650                     * If client has fetched items with KVcxCommandMyVideosGetMediasByMpxId,
       
  1651                     * it should refetch items when this event arrives.
       
  1652                     */
       
  1653                     case KVcxMessageMyVideosListComplete:
       
  1654                         {
       
  1655                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1656                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete");
       
  1657                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1658                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
       
  1659                         }
       
  1660                         break;
       
  1661 
       
  1662                     case KVcxMessageMyVideosMoveOrCopyStarted:
       
  1663                         {
       
  1664                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1665                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosMoveOrCopyStarted");
       
  1666                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1667 
       
  1668                         if( iActionCount <= 0 )
       
  1669                             {
       
  1670                             break;
       
  1671                             }
       
  1672                         iActionCount--;
       
  1673 
       
  1674                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
       
  1675                         
       
  1676                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Move/Copy started.") ) );
       
  1677                         }
       
  1678                         break;
       
  1679 
       
  1680                     case KVcxMessageMyVideosMoveResp:
       
  1681                         {
       
  1682                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------");
       
  1683                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosMoveResp");
       
  1684                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------");
       
  1685 
       
  1686                         if( iActionCount <= 0 )
       
  1687                             {
       
  1688                             break;
       
  1689                             }
       
  1690                         iActionCount--;
       
  1691 
       
  1692                         CMPXMedia* medias = CMPXMedia::NewL( *aMessage );
       
  1693                         CleanupStack::PushL( medias );
       
  1694                         CMPXMediaArray* results = medias->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
  1695 
       
  1696                         TRAPD( err, CheckRequestMediaArrayL( *results, iRequestedMediaIds ) );
       
  1697 
       
  1698                         if( err != KErrNone )
       
  1699                             {
       
  1700                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
       
  1701                             }
       
  1702                         else
       
  1703                             {
       
  1704                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMoveResp, KErrNone );
       
  1705                             }
       
  1706                         
       
  1707                         if( iCancelRequested )
       
  1708                             {
       
  1709                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
       
  1710                             iCancelRequested = EFalse;
       
  1711                             }                        
       
  1712 
       
  1713                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1714                         if( actionErr == KErrAbort )
       
  1715                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1716                         
       
  1717                         CleanupStack::PopAndDestroy( medias );
       
  1718                         }
       
  1719                         break;
       
  1720 
       
  1721                     case KVcxMessageMyVideosCopyResp:
       
  1722                         {
       
  1723                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------");
       
  1724                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosCopyResp");
       
  1725                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: -------------------------------------------------------");
       
  1726 
       
  1727                         if( iActionCount <= 0 )
       
  1728                             {
       
  1729                             break;
       
  1730                             }
       
  1731                         iActionCount--;
       
  1732 
       
  1733                         CMPXMedia* medias = CMPXMedia::NewL( *aMessage );
       
  1734                         CleanupStack::PushL( medias );
       
  1735                         CMPXMediaArray* results = medias->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
  1736 
       
  1737                         TRAPD( err, CheckRequestMediaArrayL( *results, iRequestedMediaIds ) );
       
  1738                         if( err != KErrNone )
       
  1739                             {
       
  1740                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
       
  1741                             }
       
  1742                         else
       
  1743                             {
       
  1744                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyResp, KErrNone );
       
  1745                             }
       
  1746 
       
  1747                         if( iCancelRequested )
       
  1748                             {
       
  1749                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
       
  1750                             iCancelRequested = EFalse;
       
  1751                             }                        
       
  1752                         
       
  1753                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1754                         if( actionErr == KErrAbort )
       
  1755                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1756                         
       
  1757                         CleanupStack::PopAndDestroy( medias );
       
  1758                         }
       
  1759                         break;
       
  1760 
       
  1761                     case KVcxMessageMyVideosDeleteStarted:
       
  1762                         {
       
  1763                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1764                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosDeleteStarted");
       
  1765                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1766 
       
  1767                         if( iActionCount <= 0 )
       
  1768                             {
       
  1769                             break;
       
  1770                             }
       
  1771                         iActionCount--;
       
  1772 
       
  1773                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
       
  1774                         
       
  1775                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Delete started.") ) );
       
  1776                         }
       
  1777                         break;
       
  1778 
       
  1779                     case KVcxMessageMyVideosDeleteResp:
       
  1780                         {
       
  1781                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1782                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosDeleteResp");
       
  1783                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
       
  1784 
       
  1785                         if( iActionCount <= 0 )
       
  1786                             {
       
  1787                             break;
       
  1788                             }
       
  1789                         iActionCount--;
       
  1790 
       
  1791                         CMPXMedia* medias = CMPXMedia::NewL( *aMessage );
       
  1792                         CleanupStack::PushL( medias );
       
  1793                         CMPXMediaArray* results = medias->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
  1794 
       
  1795                         TRAPD( err, CheckRequestMediaArrayL( *results, iRequestedMediaIds ) );
       
  1796 
       
  1797                         if( err != KErrNone )
       
  1798                             {
       
  1799                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
       
  1800                             }
       
  1801                         else
       
  1802                             {
       
  1803                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteResp, KErrNone );
       
  1804                             }
       
  1805 
       
  1806                         if( iCancelRequested )
       
  1807                             {
       
  1808                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
       
  1809                             iCancelRequested = EFalse;
       
  1810                             }
       
  1811                         
       
  1812                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1813                         if( actionErr == KErrAbort )
       
  1814                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1815                         
       
  1816                         CleanupStack::PopAndDestroy( medias );
       
  1817                         }
       
  1818                         break;
       
  1819 
       
  1820                     default:
       
  1821                         {
       
  1822                         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR. message %d has no handler!", myVideosCommandId );
       
  1823                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
       
  1824                         }
       
  1825                         break;
       
  1826                     }
       
  1827                 }
       
  1828             else
       
  1829                 {
       
  1830                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ERROR: KVcxCommandIdMyVideos NOT SUPPORTED!");
       
  1831                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
       
  1832                 }
       
  1833             }
       
  1834             break;
       
  1835 
       
  1836         // Handle general collection messages
       
  1837         case KMPXMessageGeneral:
       
  1838             {
       
  1839             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------");
       
  1840             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageGeneral");
       
  1841             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------");
       
  1842 
       
  1843             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, KErrNone );
       
  1844 
       
  1845             TInt event( *(aMessage->Value<TInt>( KMPXMessageGeneralEvent )) );
       
  1846             TInt type( *(aMessage->Value<TInt>( KMPXMessageGeneralType )) );
       
  1847             TInt data( *(aMessage->Value<TInt>( KMPXMessageGeneralData )) );
       
  1848 
       
  1849             VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: event: %d, type: %d, data: %d", event, type, data);
       
  1850 
       
  1851             // Next message will be EPathChanged, nothing to do here.
       
  1852             if ( event == TMPXCollectionMessage::ECollectionChanged )
       
  1853                 {
       
  1854                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: event ECollectionChanged.");
       
  1855                 }
       
  1856 
       
  1857             if ( event == TMPXCollectionMessage::EPathChanged )
       
  1858                 {
       
  1859                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: event EPathChanged");
       
  1860 
       
  1861                 // Collection or level changed, get entries for it.
       
  1862                 if( data == EMcContainerOpened )
       
  1863                     {
       
  1864                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: data EMcContainerOpened");
       
  1865                     TRAP_IGNORE( iCollectionUtility->Collection().OpenL() );
       
  1866                     }
       
  1867                 else if ( data == EMcItemOpened )
       
  1868                     {
       
  1869                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: data EMcItemOpened");
       
  1870                     }
       
  1871                 }
       
  1872             }
       
  1873             break;
       
  1874 
       
  1875         case KMPXMessageIdItemChanged:
       
  1876             {
       
  1877             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
       
  1878             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageIdItemChanged");
       
  1879             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
       
  1880 
       
  1881             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
       
  1882             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
       
  1883 
       
  1884 #if 1
       
  1885             // Check the IDs for categories
       
  1886             if( itemId.iId2 != 0 && ( itemId.iId1 != KVcxMvcCategoryIdAll &&
       
  1887                     itemId.iId1 != KVcxMvcCategoryIdDownloads &&
       
  1888                     itemId.iId1 != KVcxMvcCategoryIdTvRecordings &&
       
  1889                     itemId.iId1 != KVcxMvcCategoryIdCaptured &&
       
  1890                     itemId.iId1 != KVcxMvcCategoryIdOther ) )
       
  1891                 {
       
  1892                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrCorrupt );
       
  1893                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. INVALID ITEM ID.");
       
  1894                 break;
       
  1895                 }
       
  1896 #endif
       
  1897             // If event if for category, skip it if it's not for the open category.
       
  1898             if( iCurrentOpenedLevelIndex != -1 && itemId.iId2 > 0 && itemId.iId1 != iCurrentOpenedLevelIndex )
       
  1899                 {
       
  1900                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Not for open category. Skip.");
       
  1901                 break;
       
  1902                 }
       
  1903 
       
  1904             if( iWaitingForItemChange && itemId.iId2 == 0 )
       
  1905                 {
       
  1906                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
       
  1907                 iWaitingForItemChange = EFalse;
       
  1908                 iActiveWait->Stop();
       
  1909                 }
       
  1910 
       
  1911             TBool refreshNeeded( EFalse );
       
  1912 
       
  1913             TMPXChangeEventType changeEvent( *aMessage->Value<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
       
  1914             switch( changeEvent )
       
  1915                 {
       
  1916                 case EMPXItemInserted:
       
  1917                     {
       
  1918                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
       
  1919                     iInsertedItemIds.Append( itemId.iId1 );
       
  1920 
       
  1921                     refreshNeeded = ETrue;
       
  1922                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemInserted, KErrNone );
       
  1923                     
       
  1924                     TRAPD( actionErr, iStats->ActionEndL( KSideloadVideoActionId, KErrNone ) );
       
  1925                     if( actionErr == KErrAbort )
       
  1926                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1927                     
       
  1928                     }
       
  1929                     break;
       
  1930 
       
  1931                 case EMPXItemDeleted:
       
  1932                     {
       
  1933                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
       
  1934                     iDeletedItemIds.Append( itemId.iId1 );
       
  1935                     refreshNeeded = ETrue;
       
  1936                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemDeleted, KErrNone );
       
  1937                     
       
  1938                     TRAPD( actionErr, iStats->ActionEndL( KRemoveMediaActionId, KErrNone ) );
       
  1939                     if( actionErr == KErrAbort )
       
  1940                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1941                     }
       
  1942                     break;
       
  1943 
       
  1944                 case EMPXItemModified:
       
  1945                     {
       
  1946                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
       
  1947                     refreshNeeded = EFalse;
       
  1948                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
       
  1949                         {
       
  1950                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
       
  1951                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
       
  1952                             {
       
  1953                             VCXLOGLO1("CVcxMyVideosCollectionTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
       
  1954                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
       
  1955                             refreshNeeded = ETrue;
       
  1956                             }
       
  1957                         }
       
  1958                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemModified, KErrNone );
       
  1959                     }
       
  1960                     break;
       
  1961 
       
  1962                 default:
       
  1963                     {
       
  1964                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent UNKNOWN!");
       
  1965                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
       
  1966                     }
       
  1967                     break;
       
  1968                 }
       
  1969 
       
  1970             if( itemId.iId2 == 0 )
       
  1971                 {
       
  1972                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionItemChanged, KErrNone );
       
  1973                 }
       
  1974             else
       
  1975                 {
       
  1976                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrNone );
       
  1977                 }
       
  1978 
       
  1979             // Refresh if there's need and it's possible.
       
  1980             if( refreshNeeded  )
       
  1981                 {
       
  1982                 if( IsRefreshing() )
       
  1983                     {
       
  1984                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
       
  1985                     refreshNeeded = EFalse;
       
  1986                     }
       
  1987 
       
  1988                 // No automatic refresh
       
  1989                 if( !iAutomaticContentRefresh )
       
  1990                      {
       
  1991                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
       
  1992                      refreshNeeded = EFalse;
       
  1993                      }
       
  1994 
       
  1995                 // No need to refresh if My Videos category is not open.
       
  1996                 if( GetCurrentLevel() != 3 )
       
  1997                     {
       
  1998                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
       
  1999                     refreshNeeded = EFalse;
       
  2000                     }
       
  2001 
       
  2002                 if( refreshNeeded )
       
  2003                     {
       
  2004                     TRAP_IGNORE( RefreshContentsL() );
       
  2005                     }
       
  2006                 }
       
  2007             else
       
  2008                 {
       
  2009                 UpdateOwnedMediaArrayL();
       
  2010                 ProcessCurrentEntriesL();
       
  2011                 }
       
  2012             }
       
  2013             break;
       
  2014 
       
  2015         default:
       
  2016             {
       
  2017             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Unknown collection message, id: %d!", messageId);
       
  2018             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
       
  2019             }
       
  2020             break;
       
  2021         }
       
  2022 
       
  2023     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
       
  2024     }
       
  2025 
       
  2026 // -----------------------------------------------------------------------------
       
  2027 // CVcxMyVideosCollectionTester::HandleOpenL
       
  2028 // -----------------------------------------------------------------------------
       
  2029 //
       
  2030 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
       
  2031                                                 TInt aIndex,
       
  2032                                                 TBool aComplete,
       
  2033                                                 TInt aError )
       
  2034     {
       
  2035     VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester::HandleOpenL (%d)", this);
       
  2036     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aIndex: %d", aIndex);
       
  2037     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aComplete: %d", aComplete);
       
  2038     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
       
  2039     
       
  2040     SetRefreshStatus( EFalse );
       
  2041 
       
  2042     TRAPD( actionErr, iStats->ActionEndL( iCurrentActionId, aError ) );
       
  2043     if( actionErr == KErrAbort )
       
  2044         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2045     
       
  2046     iCurrentActionId = -1;
       
  2047     
       
  2048     if( aError == KErrNone )
       
  2049         {
       
  2050         // Update current entries
       
  2051         delete iCollectionEntries;
       
  2052         iCollectionEntries = NULL;
       
  2053         iCollectionEntries = CMPXMedia::NewL( aEntries );
       
  2054         
       
  2055         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
       
  2056 
       
  2057         UpdateOwnedMediaArrayL();
       
  2058 
       
  2059         // There could have been changes to the content during update.
       
  2060         // Check that entries are up to date.
       
  2061 
       
  2062         TBool reRefreshNeeded( EFalse );
       
  2063 
       
  2064         TInt foundInsertedItemCount(0);
       
  2065 
       
  2066         for( TInt e=0; e<iMediaCount; e++ )
       
  2067             {
       
  2068             CMPXMedia* media = (*iMediaArray)[e];
       
  2069             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  2070 
       
  2071             // Check that deleted items are not on the list.
       
  2072             for( TInt i=0; i<iDeletedItemIds.Count(); i++ )
       
  2073                 {
       
  2074                 if( itemId.iId1 == iDeletedItemIds[i] )
       
  2075                     {
       
  2076                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Current entries contain deleted  item. Refresh needed. ------->");
       
  2077                     reRefreshNeeded = ETrue;
       
  2078                     break;
       
  2079                     }
       
  2080                 }
       
  2081 
       
  2082             // Check that all inserted items are on the list.
       
  2083             for( TInt i=0; i<iInsertedItemIds.Count(); i++ )
       
  2084                 {
       
  2085                 if( itemId.iId1 == iInsertedItemIds[i] )
       
  2086                     {
       
  2087                     foundInsertedItemCount++;
       
  2088                     }
       
  2089                 }
       
  2090             }
       
  2091 
       
  2092         iInsertedItemIds.Reset();
       
  2093         iDeletedItemIds.Reset();
       
  2094 
       
  2095         if( !reRefreshNeeded && foundInsertedItemCount < iInsertedItemIds.Count() )
       
  2096             {
       
  2097             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Current entries does not contain all inserted items. Rerefresh needed. ------->");
       
  2098             reRefreshNeeded = ETrue;
       
  2099             }
       
  2100 
       
  2101         if( reRefreshNeeded )
       
  2102             {
       
  2103             TRAP_IGNORE( RefreshContentsL() );
       
  2104             }
       
  2105         else
       
  2106             {
       
  2107             // Print current entries and update downloads.
       
  2108             ProcessCurrentEntriesL();
       
  2109 
       
  2110             // Inform observer
       
  2111             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionOpened, aError );
       
  2112             }
       
  2113         }
       
  2114 
       
  2115     if( aError != KErrNone )
       
  2116         {
       
  2117         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionOpened, aError );
       
  2118         }
       
  2119 
       
  2120     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (entries)");
       
  2121     }
       
  2122 
       
  2123 // -----------------------------------------------------------------------------
       
  2124 // CVcxMyVideosCollectionTester::HandleOpenL
       
  2125 // -----------------------------------------------------------------------------
       
  2126 //
       
  2127 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
       
  2128                                                 TInt aError )
       
  2129     {
       
  2130     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
       
  2131     // Inform observer
       
  2132     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessagePlaylistOpened, aError );
       
  2133     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
       
  2134     }
       
  2135 
       
  2136 // -----------------------------------------------------------------------------
       
  2137 // CVcxMyVideosCollectionTester::HandleCollectionMediaL
       
  2138 // -----------------------------------------------------------------------------
       
  2139 //
       
  2140 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
       
  2141                                         TInt aError)
       
  2142     {
       
  2143     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
       
  2144     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
       
  2145 
       
  2146     TRAPD( actionErr, iStats->ActionEndL( KGetMediaFullDetailsActionId, aError ) );
       
  2147     if( actionErr == KErrAbort )
       
  2148         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2149 
       
  2150     if( iGettingFullDetailsForAllMedia )
       
  2151         {
       
  2152         iActiveWait->Stop();
       
  2153         }
       
  2154 
       
  2155     delete iFullMedia;
       
  2156     iFullMedia = NULL;
       
  2157     iFullMedia = aMedia.CopyL( aMedia );
       
  2158 
       
  2159     // Inform observer
       
  2160     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMedia, aError );
       
  2161     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
       
  2162     }
       
  2163 
       
  2164 // -----------------------------------------------------------------------------
       
  2165 // CVcxMyVideosCollectionTester::HandleCommandComplete
       
  2166 // -----------------------------------------------------------------------------
       
  2167 //
       
  2168 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
       
  2169                                                                 TInt aError )
       
  2170     {
       
  2171     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
       
  2172     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::HandleCommandComplete: aError: %d", aError);
       
  2173     
       
  2174     if( iCancelRequested && aError == KErrCancel )
       
  2175         {
       
  2176         aError = KErrNone;
       
  2177         }
       
  2178     
       
  2179     if( !iObserver )
       
  2180         {
       
  2181         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
       
  2182         return;
       
  2183         }
       
  2184     
       
  2185     if( aError == KErrNone )
       
  2186         {
       
  2187         TUint32 transactionId( 0 );
       
  2188         if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) )
       
  2189             {
       
  2190             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
       
  2191             iTransactions->TransactionResponse( transactionId );
       
  2192             if( !iCurrentActionHasResponse )
       
  2193                 {
       
  2194                 TRAPD( actionErr, iStats->ActionEndL( transactionId, aError ) );
       
  2195                 if( actionErr == KErrAbort )
       
  2196                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2197                 }
       
  2198             }
       
  2199         
       
  2200         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
       
  2201             {
       
  2202             TInt cmd = 0;
       
  2203             cmd = *aCommandResult->Value<TUint>( KMPXCommandGeneralId );
       
  2204             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::HandleCommandComplete: KMPXCommandGeneralId: %d", cmd);
       
  2205     
       
  2206             if( cmd == KVcxCommandIdMyVideos )
       
  2207                 {
       
  2208                 cmd = 0;
       
  2209                 cmd = *aCommandResult->Value<TUint>( KVcxMediaMyVideosCommandId );
       
  2210                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::HandleCommandComplete: KVcxMediaMyVideosCommandId: %d", cmd);
       
  2211                 }
       
  2212             }
       
  2213         
       
  2214         if( aCommandResult->IsSupported( KVcxMediaMyVideosCommandId ) )
       
  2215             {
       
  2216             TUint32 cmdId;
       
  2217             cmdId = aCommandResult->ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId );
       
  2218             
       
  2219             if ( cmdId == KVcxCommandMyVideosGetMediaFullDetailsByMpxId )
       
  2220                 {
       
  2221                 HandleCollectionMediaL( *(aCommandResult->Value<CMPXMedia>(
       
  2222                         KMPXCommandColAddMedia)), KErrNone );
       
  2223                 }
       
  2224             }
       
  2225 
       
  2226         if( aCommandResult->IsSupported( KVcxMediaMyVideosInt32Value ) )
       
  2227             {
       
  2228             TInt32 result = aCommandResult->ValueTObjectL<TUint32>( KVcxMediaMyVideosInt32Value );
       
  2229             
       
  2230             if( result != KErrNone && !( iCancelRequested && result == KErrCancel ) )
       
  2231                 {
       
  2232                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::HandleCommandComplete: KVcxMediaMyVideosInt32Value contains error: %d", result);
       
  2233                 aError = result;
       
  2234                 }
       
  2235             }
       
  2236         }
       
  2237     
       
  2238     if( !iWaitingForItemChange || aError != KErrNone )
       
  2239         {
       
  2240         SetRefreshStatus(  EFalse );
       
  2241         iWaitingForItemChange = EFalse;
       
  2242         
       
  2243         if( iActiveWait )
       
  2244             {
       
  2245             iActiveWait->Stop();
       
  2246             }
       
  2247 
       
  2248         if( aError == KErrNotFound )
       
  2249             {
       
  2250             // transaction ids and cancel download to accept -1 when file doesn't exist.
       
  2251             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandComplete, KErrNone ) );
       
  2252             }
       
  2253         else
       
  2254             {
       
  2255             // Inform observer
       
  2256             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandComplete, aError ) );
       
  2257             }
       
  2258         }
       
  2259 
       
  2260     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
       
  2261     }
       
  2262 
       
  2263 // -----------------------------------------------------------------------------
       
  2264 // CVcxMyVideosCollectionTester::GetMediaCount
       
  2265 // -----------------------------------------------------------------------------
       
  2266 //
       
  2267 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
       
  2268     {
       
  2269     TInt count = 0;
       
  2270     if( iMediaArray )
       
  2271         {
       
  2272         count = iMediaArray->Count();
       
  2273         }
       
  2274     return count;
       
  2275     }
       
  2276 
       
  2277 // ---------------------------------------------------------------------------
       
  2278 // CVCXMyVideosCollectionPluginTester::AddMediaL()
       
  2279 // ---------------------------------------------------------------------------
       
  2280 //
       
  2281 void CVCXMyVideosCollectionPluginTester::AddMediaL( CMPXMedia* aMedia, TBool aSync )
       
  2282     {
       
  2283     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::AddMediaL");
       
  2284 
       
  2285     TBool newCreated( EFalse );
       
  2286     if( aMedia )
       
  2287         {
       
  2288         PrintMPXMediaL( *aMedia, ETrue );
       
  2289         }
       
  2290     else
       
  2291         {
       
  2292         newCreated = ETrue;
       
  2293         aMedia = CMPXMedia::NewL();
       
  2294         CleanupStack::PushL( aMedia );
       
  2295         }
       
  2296 
       
  2297     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
       
  2298     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
       
  2299     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Add media") ) );
       
  2300     iCurrentActionHasResponse = EFalse;
       
  2301     iCollectionUtility->Collection().CommandL(*cmd);
       
  2302 
       
  2303     CleanupStack::PopAndDestroy( cmd );
       
  2304 
       
  2305     if( newCreated )
       
  2306         {
       
  2307         CleanupStack::PopAndDestroy( aMedia );
       
  2308         }
       
  2309 
       
  2310     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::AddMediaL");
       
  2311     }
       
  2312 
       
  2313 // -----------------------------------------------------------------------------
       
  2314 // CVCXMyVideosCollectionPluginTester::SetMediaL
       
  2315 // -----------------------------------------------------------------------------
       
  2316 //
       
  2317 void CVCXMyVideosCollectionPluginTester::SetMediaL( CMPXMedia* aMedia, TBool aSync )
       
  2318     {
       
  2319     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SetMediaL");
       
  2320 
       
  2321     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionSet, 0, aSync );
       
  2322     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
       
  2323 
       
  2324     PrintMPXMediaL( *aMedia, ETrue );
       
  2325 
       
  2326     iCollectionUtility->Collection().CommandL( *cmd );
       
  2327     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Set media") ) );
       
  2328     iCurrentActionHasResponse = EFalse;
       
  2329     CleanupStack::PopAndDestroy( cmd );
       
  2330     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
       
  2331     }
       
  2332 
       
  2333 // -----------------------------------------------------------------------------
       
  2334 // CVcxMyVideosCollectionTester::RemoveMediaL
       
  2335 // -----------------------------------------------------------------------------
       
  2336 //
       
  2337 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
       
  2338     {
       
  2339     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaL");
       
  2340 
       
  2341     CMPXMedia* media = NULL;
       
  2342 
       
  2343     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
       
  2344 
       
  2345     media = (*iCollectionMediaArray)[realIndex];
       
  2346     
       
  2347     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  2348     iTestCommon->EnsureFileIsNotInUse( localFilePath );
       
  2349     
       
  2350     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  2351 
       
  2352     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
       
  2353     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
       
  2354 
       
  2355     TRAP_IGNORE( iStats->ActionStartL( KRemoveMediaActionId, _L("Remove media") ) );
       
  2356     iCurrentActionHasResponse = EFalse;
       
  2357     iCollectionUtility->Collection().CommandL( *cmd );
       
  2358 
       
  2359     CleanupStack::PopAndDestroy( cmd );
       
  2360 
       
  2361     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaL");
       
  2362     }
       
  2363 
       
  2364 // -----------------------------------------------------------------------------
       
  2365 // CVcxMyVideosCollectionTester::RemoveMediaByMpxIdL
       
  2366 // -----------------------------------------------------------------------------
       
  2367 //
       
  2368 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
       
  2369     {
       
  2370     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
       
  2371 
       
  2372     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpx ID: %d", aMpxId);
       
  2373 
       
  2374     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
       
  2375     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
       
  2376 
       
  2377     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Remove media") ) );
       
  2378     iCurrentActionHasResponse = EFalse;
       
  2379     iCollectionUtility->Collection().CommandL( *cmd );
       
  2380     CleanupStack::PopAndDestroy( cmd );
       
  2381 
       
  2382     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
       
  2383     }
       
  2384 
       
  2385 // -----------------------------------------------------------------------------
       
  2386 // CVcxMyVideosCollectionTester::GetAllMediaFullDetailsL
       
  2387 // -----------------------------------------------------------------------------
       
  2388 //
       
  2389 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
       
  2390     {
       
  2391     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
       
  2392 
       
  2393     CMPXMediaArray* fullMedias = CMPXMediaArray::NewL();
       
  2394 
       
  2395     CleanupStack::PushL( fullMedias );
       
  2396 
       
  2397     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: media count: %d", iMediaArray->Count() );
       
  2398 
       
  2399     if( GetCurrentLevel() != 3 )
       
  2400         {
       
  2401         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: My videos category must be open!");
       
  2402         User::Leave( KErrGeneral );
       
  2403         }
       
  2404 
       
  2405     for( TInt i=0; i<iMediaArray->Count(); i++ )
       
  2406         {
       
  2407         RArray<TMPXAttribute> attrs;
       
  2408         CleanupClosePushL(attrs);
       
  2409         // Empty attributes to get all the details.
       
  2410         CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
       
  2411         CleanupStack::PushL( path );
       
  2412         path->SelectL( i );
       
  2413 
       
  2414         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Details for media at index: %d", i );
       
  2415 
       
  2416         iGettingFullDetailsForAllMedia = ETrue;
       
  2417         iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
       
  2418         CleanupStack::PopAndDestroy( path );
       
  2419         CleanupStack::PopAndDestroy( &attrs );
       
  2420 
       
  2421         iActiveWait->Start();
       
  2422         iGettingFullDetailsForAllMedia = EFalse;
       
  2423 
       
  2424         fullMedias->AppendL( iFullMedia->CopyL( *iFullMedia ) );
       
  2425         }
       
  2426 
       
  2427     PrintMediasL( fullMedias, EFalse, _L("FullMedias") );
       
  2428 
       
  2429     for( TInt i=0; i<fullMedias->Count(); i++ )
       
  2430         {
       
  2431         CMPXMedia* media = fullMedias->AtL(i);
       
  2432         }
       
  2433 
       
  2434     CleanupStack::PopAndDestroy( fullMedias );
       
  2435 
       
  2436     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
       
  2437     }
       
  2438 
       
  2439 // -----------------------------------------------------------------------------
       
  2440 // CVcxMyVideosCollectionTester::DeleteAllMediaFilesL
       
  2441 // -----------------------------------------------------------------------------
       
  2442 //
       
  2443 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
       
  2444     {
       
  2445     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
       
  2446 
       
  2447     RPointerArray<HBufC> fileList;
       
  2448     CleanupResetAndDestroyPushL( fileList );
       
  2449     
       
  2450     CMPXMedia* media = NULL;
       
  2451 
       
  2452     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  2453         {
       
  2454         media = (*iMediaArray)[i];
       
  2455 
       
  2456         if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  2457             {
       
  2458             const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  2459             fileList.Append( localFilePath.AllocL() );
       
  2460             }
       
  2461         }
       
  2462 
       
  2463     for( TInt i = 0; i < fileList.Count(); i++ )
       
  2464         {
       
  2465         VCXLOGLO3("Item: %d, Local file path: %S", i, fileList[i]);
       
  2466 
       
  2467         TInt err = iFs.Delete( *fileList[i] );
       
  2468         if( err != KErrNone )
       
  2469             {
       
  2470             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
       
  2471             }
       
  2472         }
       
  2473 
       
  2474     CleanupStack::PopAndDestroy( &fileList );
       
  2475 
       
  2476     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
       
  2477     }
       
  2478 
       
  2479 // -----------------------------------------------------------------------------
       
  2480 // CVcxMyVideosCollectionTester::DeleteFileOfMediaL
       
  2481 // -----------------------------------------------------------------------------
       
  2482 //
       
  2483 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
       
  2484     {
       
  2485     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
       
  2486 
       
  2487     CMPXMedia* media = NULL;
       
  2488 
       
  2489     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
       
  2490 
       
  2491     media = (*iCollectionMediaArray)[realIndex];
       
  2492     if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  2493         {
       
  2494         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  2495         VCXLOGLO2("Local file path: %S", &localFilePath);
       
  2496 
       
  2497         iTestCommon->EnsureFileIsNotInUse( localFilePath );
       
  2498         TInt err = iFs.Delete( localFilePath );
       
  2499         if( err != KErrNone )
       
  2500             {
       
  2501             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
       
  2502             }
       
  2503         }
       
  2504     else
       
  2505         {
       
  2506         VCXLOGLO2("Item: %d, KMPXMediaGeneralUri not supported!", aIndex);
       
  2507         }
       
  2508 
       
  2509     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
       
  2510     }
       
  2511 
       
  2512 // -----------------------------------------------------------------------------
       
  2513 // CVcxMyVideosCollectionTester::GetMediaL
       
  2514 // -----------------------------------------------------------------------------
       
  2515 //
       
  2516 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
       
  2517     {
       
  2518     CMPXMedia* media = NULL;
       
  2519 
       
  2520     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
       
  2521 
       
  2522     media = (*iCollectionMediaArray)[realIndex];
       
  2523     return media;
       
  2524     }
       
  2525 
       
  2526 // -----------------------------------------------------------------------------
       
  2527 // CVcxMyVideosCollectionTester::MoveMediasL
       
  2528 // -----------------------------------------------------------------------------
       
  2529 //
       
  2530 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
       
  2531     {
       
  2532     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::MoveMediasL");
       
  2533 
       
  2534     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
       
  2535     CleanupStack::PushL( medias );
       
  2536 
       
  2537     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosMove, aSync );
       
  2538     cmd->SetTObjectValueL( KVcxMediaMyVideosInt32Value, aDestDrive );
       
  2539     if( medias )
       
  2540         {
       
  2541         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2542         }
       
  2543     
       
  2544     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Move medias") ) );
       
  2545     iCurrentActionHasResponse = ETrue;
       
  2546     iCollectionUtility->Collection().CommandL( *cmd );
       
  2547 
       
  2548     CleanupStack::PopAndDestroy( cmd );
       
  2549     CleanupStack::PopAndDestroy( medias );
       
  2550 
       
  2551     iActionCount += 2;
       
  2552 
       
  2553     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::MoveMediasL");
       
  2554     }
       
  2555 
       
  2556 // -----------------------------------------------------------------------------
       
  2557 // CVcxMyVideosCollectionTester::CancelMoveL
       
  2558 // -----------------------------------------------------------------------------
       
  2559 //
       
  2560 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
       
  2561     {
       
  2562     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
       
  2563 
       
  2564     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
       
  2565     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel move or copy") ) );
       
  2566     iCurrentActionHasResponse = EFalse;
       
  2567     iCollectionUtility->Collection().CommandL( *cmd );
       
  2568     CleanupStack::PopAndDestroy( cmd );
       
  2569     
       
  2570     iCancelRequested = ETrue;
       
  2571 
       
  2572     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
       
  2573     }
       
  2574 
       
  2575 // -----------------------------------------------------------------------------
       
  2576 // CVcxMyVideosCollectionTester::CopyMediasL
       
  2577 // -----------------------------------------------------------------------------
       
  2578 //
       
  2579 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
       
  2580     {
       
  2581     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CopyMediasL");
       
  2582 
       
  2583     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
       
  2584     CleanupStack::PushL( medias );
       
  2585 
       
  2586     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCopy, aSync );
       
  2587     cmd->SetTObjectValueL( KVcxMediaMyVideosInt32Value, aDestDrive );
       
  2588     if( medias )
       
  2589         {
       
  2590         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2591         }
       
  2592     
       
  2593     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Copy medias") ) );
       
  2594     iCurrentActionHasResponse = ETrue;
       
  2595     iCollectionUtility->Collection().CommandL( *cmd );
       
  2596 
       
  2597     CleanupStack::PopAndDestroy( cmd );
       
  2598     CleanupStack::PopAndDestroy( medias );
       
  2599 
       
  2600     iActionCount += 2;
       
  2601 
       
  2602     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CopyMediasL");
       
  2603     }
       
  2604 
       
  2605 // -----------------------------------------------------------------------------
       
  2606 // CVcxMyVideosCollectionTester::DeleteMediasL
       
  2607 // -----------------------------------------------------------------------------
       
  2608 //
       
  2609 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
       
  2610     {
       
  2611     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasL");
       
  2612 
       
  2613     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
       
  2614     CleanupStack::PushL( medias );
       
  2615 
       
  2616     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
       
  2617     if( medias )
       
  2618         {
       
  2619         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2620         }
       
  2621     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2622     iCurrentActionHasResponse = ETrue;
       
  2623     iCollectionUtility->Collection().CommandL( *cmd );
       
  2624 
       
  2625     CleanupStack::PopAndDestroy( cmd );
       
  2626     CleanupStack::PopAndDestroy( medias );
       
  2627 
       
  2628     iActionCount += 2;
       
  2629 
       
  2630     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasL");
       
  2631     }
       
  2632 
       
  2633 
       
  2634 // -----------------------------------------------------------------------------
       
  2635 // CVcxMyVideosCollectionTester::DeleteMediasByMpxIdsL
       
  2636 // -----------------------------------------------------------------------------
       
  2637 //
       
  2638 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
       
  2639     {
       
  2640     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
       
  2641 
       
  2642     iRequestedMediaIds.Reset();
       
  2643     for( TInt i = 0; i < aMedias->Count(); i++ )
       
  2644         {
       
  2645         CMPXMedia* media = (*aMedias)[i];
       
  2646         TMPXItemId mpxId = *( media->Value<TMPXItemId>( KMPXMediaGeneralId ) );
       
  2647         iRequestedMediaIds.Append( mpxId.iId1 );
       
  2648         }
       
  2649         
       
  2650     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
       
  2651     if( aMedias )
       
  2652         {
       
  2653         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
       
  2654         }
       
  2655     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2656     iCurrentActionHasResponse = ETrue;
       
  2657     iCollectionUtility->Collection().CommandL( *cmd );
       
  2658 
       
  2659     CleanupStack::PopAndDestroy( cmd );
       
  2660 
       
  2661     iActionCount += 2;
       
  2662 
       
  2663     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
       
  2664     }
       
  2665 
       
  2666 // -----------------------------------------------------------------------------
       
  2667 // CVcxMyVideosCollectionTester::DeleteMediaByMpxIdL
       
  2668 // -----------------------------------------------------------------------------
       
  2669 //
       
  2670 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
       
  2671     {
       
  2672     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
       
  2673     
       
  2674     CMPXMediaArray* medias = CMPXMediaArray::NewL();
       
  2675     CleanupStack::PushL( medias );
       
  2676 
       
  2677     iRequestedMediaIds.Reset();
       
  2678     iRequestedMediaIds.Append( aMpxId.iId1 );
       
  2679     
       
  2680     CMPXMedia* newMedia = CMPXMedia::NewL();
       
  2681     CleanupStack::PushL( newMedia );
       
  2682     newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId );
       
  2683     newMedia->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
       
  2684     medias->AppendL( *newMedia );
       
  2685     CleanupStack::PopAndDestroy( newMedia );
       
  2686     
       
  2687     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
       
  2688     if( medias )
       
  2689         {
       
  2690         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2691         }
       
  2692     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2693     iCurrentActionHasResponse = ETrue;
       
  2694     iCollectionUtility->Collection().CommandL( *cmd );
       
  2695 
       
  2696     CleanupStack::PopAndDestroy( cmd );
       
  2697     CleanupStack::PopAndDestroy( medias );
       
  2698 
       
  2699     iActionCount += 2;
       
  2700 
       
  2701     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
       
  2702     }
       
  2703 
       
  2704 // -----------------------------------------------------------------------------
       
  2705 // CVcxMyVideosCollectionTester::CancelDeleteL
       
  2706 // -----------------------------------------------------------------------------
       
  2707 //
       
  2708 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
       
  2709     {
       
  2710     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
       
  2711 
       
  2712     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
       
  2713     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel delete") ) );
       
  2714     iCurrentActionHasResponse = EFalse;
       
  2715     iCollectionUtility->Collection().CommandL( *cmd );
       
  2716     CleanupStack::PopAndDestroy( cmd );
       
  2717 
       
  2718     iCancelRequested = ETrue;
       
  2719 
       
  2720     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL");
       
  2721     }
       
  2722 
       
  2723 // -----------------------------------------------------------------------------
       
  2724 // CVcxMyVideosCollectionTester::SetAutomaticRefresh
       
  2725 // -----------------------------------------------------------------------------
       
  2726 //
       
  2727 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
       
  2728     {
       
  2729     iAutomaticContentRefresh = aValue;
       
  2730     }
       
  2731 
       
  2732 // -----------------------------------------------------------------------------
       
  2733 // CVcxMyVideosCollectionTester::IsRefreshing
       
  2734 // -----------------------------------------------------------------------------
       
  2735 //
       
  2736 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
       
  2737     {
       
  2738     return iRefreshingCollection;
       
  2739     }
       
  2740 // -----------------------------------------------------------------------------
       
  2741 // CVcxMyVideosCollectionTester::SetQuietMode
       
  2742 // -----------------------------------------------------------------------------
       
  2743 //
       
  2744 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue )
       
  2745     {
       
  2746     iQuietMode = aValue;
       
  2747     }
       
  2748 
       
  2749 // -----------------------------------------------------------------------------
       
  2750 // CVcxMyVideosCollectionTester::StartDownloadL
       
  2751 // -----------------------------------------------------------------------------
       
  2752 //
       
  2753 void CVCXMyVideosCollectionPluginTester::StartDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
       
  2754         TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
       
  2755         CMPXMedia* aMedia )
       
  2756     {
       
  2757     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::StartDownloadL");
       
  2758 
       
  2759     iUpdateDownloads = ETrue;
       
  2760     iDownloadsStarted = ETrue;
       
  2761 
       
  2762     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
       
  2763 
       
  2764     CMPXMedia* startDownloadReq(NULL);
       
  2765     if( !aMedia )
       
  2766         {
       
  2767         startDownloadReq = CMPXMedia::NewL();
       
  2768         CleanupStack::PushL( startDownloadReq );
       
  2769         }
       
  2770     else
       
  2771         {
       
  2772         startDownloadReq = aMedia;
       
  2773         }
       
  2774 
       
  2775     //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
       
  2776     startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
       
  2777 
       
  2778     // read only iap needed?
       
  2779     TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
       
  2780 
       
  2781     startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
       
  2782 
       
  2783     VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: UserName: %S, Password: %S.", &aUserName, &aPassword);
       
  2784     
       
  2785     startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
       
  2786     startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
       
  2787     startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
       
  2788     startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
       
  2789     
       
  2790     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
       
  2791 
       
  2792     iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
       
  2793 
       
  2794     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2795     iCollectionUtility->Collection().CommandL( *cmd );
       
  2796 
       
  2797     if( !aMedia )
       
  2798         {
       
  2799         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2800         }
       
  2801 
       
  2802     CleanupStack::PopAndDestroy( cmd );
       
  2803 
       
  2804     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::StartDownloadL");
       
  2805     }
       
  2806 
       
  2807 // -----------------------------------------------------------------------------
       
  2808 // CVcxMyVideosCollectionTester::ResumeDownloadL
       
  2809 // -----------------------------------------------------------------------------
       
  2810 //
       
  2811 void CVCXMyVideosCollectionPluginTester::ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
       
  2812         TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
       
  2813         CMPXMedia* aMedia
       
  2814         )
       
  2815     {
       
  2816     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
       
  2817 
       
  2818     iUpdateDownloads = ETrue;
       
  2819     iDownloadsStarted = ETrue;
       
  2820 
       
  2821     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
       
  2822 
       
  2823     CMPXMedia* startDownloadReq(NULL);
       
  2824     if( !aMedia )
       
  2825         {
       
  2826         startDownloadReq = CMPXMedia::NewL();
       
  2827         CleanupStack::PushL( startDownloadReq );
       
  2828         }
       
  2829     else
       
  2830         {
       
  2831         startDownloadReq = aMedia;
       
  2832         }
       
  2833 
       
  2834     //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
       
  2835     startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
       
  2836 
       
  2837     // read only iap needed?
       
  2838     TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
       
  2839 
       
  2840     startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
       
  2841 
       
  2842     startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
       
  2843     startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
       
  2844     startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
       
  2845     startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
       
  2846 
       
  2847     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
       
  2848 
       
  2849     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
       
  2850     if( dl )
       
  2851         {
       
  2852         startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  2853 
       
  2854         TMPXItemId itemId;
       
  2855         itemId.iId1 = dl->iMpxId;
       
  2856         itemId.iId2 = 0;
       
  2857         startDownloadReq->SetTObjectValueL( KMPXMediaGeneralId, itemId );
       
  2858         
       
  2859         dl->iInformed = EFalse;
       
  2860         dl->iWaitingPause = EFalse;
       
  2861         }
       
  2862     else
       
  2863         {
       
  2864         startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, 6666 );
       
  2865         iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
       
  2866         }
       
  2867 
       
  2868     EnsureMediaFilesAreNotInUseL();
       
  2869     
       
  2870     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2871     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Resume download") ) );
       
  2872     iCurrentActionHasResponse = EFalse;
       
  2873     iCollectionUtility->Collection().CommandL( *cmd );
       
  2874 
       
  2875     if( !aMedia )
       
  2876         {
       
  2877         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2878         }
       
  2879 
       
  2880     CleanupStack::PopAndDestroy( cmd );
       
  2881 
       
  2882     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
       
  2883     }
       
  2884 
       
  2885 // -----------------------------------------------------------------------------
       
  2886 // CVcxMyVideosCollectionTester::ResumeAllDownloadsL
       
  2887 // -----------------------------------------------------------------------------
       
  2888 //
       
  2889 void CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL()
       
  2890     {
       
  2891     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
       
  2892 
       
  2893     iUpdateDownloads = ETrue;
       
  2894     iDownloadsStarted = ETrue;
       
  2895 
       
  2896     for( TInt i = 0; i < iDlWatcher->GetDownloadCount(); i++ )
       
  2897         {
       
  2898         CVCXMyVideosTestDownload* dl;
       
  2899         dl = iDlWatcher->GetDownloadByIndex( i );
       
  2900         if( dl && dl->iState == EVcxMyVideosDlStatePaused )
       
  2901             {
       
  2902             ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
       
  2903             }
       
  2904         }
       
  2905      
       
  2906     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
       
  2907     }
       
  2908 
       
  2909 // -----------------------------------------------------------------------------
       
  2910 // CVcxMyVideosCollectionTester::CancelDownloadL
       
  2911 // -----------------------------------------------------------------------------
       
  2912 //
       
  2913 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync )
       
  2914     {
       
  2915     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  2916 
       
  2917     if( !aDownload )
       
  2918         {
       
  2919         User::Leave( KErrArgument );
       
  2920         }
       
  2921 
       
  2922     iUpdateDownloads = ETrue;
       
  2923 
       
  2924     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
       
  2925 
       
  2926     CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
       
  2927     CleanupStack::PushL( cancelDownloadReq );
       
  2928 
       
  2929     cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aDownload->iMpxId, 0 ) );
       
  2930     cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownload->iDownloadId );
       
  2931     cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, aDownload->iPath->Des() );
       
  2932 
       
  2933     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
       
  2934     
       
  2935     iDlWatcher->CancelDownloadL( aDownload->iServiceId, aDownload->iContentId, *aDownload->iUrl );
       
  2936 
       
  2937     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2938     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
       
  2939     iCurrentActionHasResponse = EFalse;
       
  2940     iCollectionUtility->Collection().CommandL( *cmd );
       
  2941 
       
  2942     CleanupStack::PopAndDestroy( cancelDownloadReq );
       
  2943     CleanupStack::PopAndDestroy( cmd );
       
  2944 
       
  2945     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  2946     }
       
  2947 
       
  2948 // -----------------------------------------------------------------------------
       
  2949 // CVcxMyVideosCollectionTester::CancelDownloadL
       
  2950 // -----------------------------------------------------------------------------
       
  2951 //
       
  2952 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync )
       
  2953     {
       
  2954     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL (by IDs)");
       
  2955 
       
  2956     iUpdateDownloads = ETrue;
       
  2957 
       
  2958     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
       
  2959 
       
  2960     CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
       
  2961     CleanupStack::PushL( cancelDownloadReq );
       
  2962 
       
  2963     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByIndex(0);
       
  2964 
       
  2965     TPtrC downloadPath( aDownloadPath );
       
  2966 
       
  2967     if( aMpxId == -1 && dl )
       
  2968         {
       
  2969         aMpxId = dl->iMpxId;
       
  2970         }
       
  2971 
       
  2972     if( aDownloadId == -1 && dl )
       
  2973         {
       
  2974         aDownloadId = dl->iDownloadId;
       
  2975         }
       
  2976 
       
  2977     if( aDownloadPath == _L("NULL") && dl )
       
  2978         {
       
  2979         downloadPath.Set( *dl->iPath );
       
  2980         }
       
  2981 
       
  2982     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpxId: %d", aMpxId);
       
  2983     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadId: %d", aDownloadId);
       
  2984     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadPath: %S", &aDownloadPath);
       
  2985 
       
  2986     cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aMpxId, 0 ) );
       
  2987     cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownloadId );
       
  2988     cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, downloadPath );
       
  2989 
       
  2990     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
       
  2991 
       
  2992     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2993     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
       
  2994     iCurrentActionHasResponse = EFalse;
       
  2995     iCollectionUtility->Collection().CommandL( *cmd );
       
  2996 
       
  2997     CleanupStack::PopAndDestroy( cancelDownloadReq );
       
  2998     CleanupStack::PopAndDestroy( cmd );
       
  2999 
       
  3000     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  3001     }
       
  3002 
       
  3003 // -----------------------------------------------------------------------------
       
  3004 // CVcxMyVideosCollectionTester::PauseDownloadL
       
  3005 // -----------------------------------------------------------------------------
       
  3006 //
       
  3007 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync )
       
  3008     {
       
  3009     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3010 
       
  3011     iUpdateDownloads = ETrue;
       
  3012 
       
  3013     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
       
  3014     if( dl )
       
  3015         {
       
  3016         dl->iWaitingPause = ETrue;
       
  3017         }
       
  3018     else
       
  3019         {
       
  3020         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
       
  3021         User::Leave( KErrNotFound );
       
  3022         }
       
  3023     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
       
  3024 
       
  3025     cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  3026 
       
  3027     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  3028     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
       
  3029     iCurrentActionHasResponse = EFalse;
       
  3030     iCollectionUtility->Collection().CommandL( *cmd );
       
  3031 
       
  3032     CleanupStack::PopAndDestroy( cmd );
       
  3033     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3034     }
       
  3035 
       
  3036 // -----------------------------------------------------------------------------
       
  3037 // CVcxMyVideosCollectionTester::PauseDownloadL
       
  3038 // -----------------------------------------------------------------------------
       
  3039 //
       
  3040 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( const TDesC& aUrl, TBool aSync )
       
  3041     {
       
  3042     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3043 
       
  3044     iUpdateDownloads = ETrue;
       
  3045 
       
  3046     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
       
  3047 
       
  3048     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aUrl );
       
  3049     if( !dl )
       
  3050         {
       
  3051         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
       
  3052         User::Leave( KErrNotFound );
       
  3053         }
       
  3054     else
       
  3055         {
       
  3056         dl->iWaitingPause = ETrue;
       
  3057         }
       
  3058     
       
  3059 
       
  3060     cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  3061 
       
  3062     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  3063     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
       
  3064     iCurrentActionHasResponse = EFalse;
       
  3065     iCollectionUtility->Collection().CommandL( *cmd );
       
  3066 
       
  3067     CleanupStack::PopAndDestroy( cmd );
       
  3068     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3069     }
       
  3070 
       
  3071 // -----------------------------------------------------------------------------
       
  3072 // CVcxMyVideosCollectionTester::GetDownloadWatcher
       
  3073 // -----------------------------------------------------------------------------
       
  3074 //
       
  3075 CVCXMyVideosTestDlWatcher* CVCXMyVideosCollectionPluginTester::GetDownloadWatcher()
       
  3076     {
       
  3077     return iDlWatcher;
       
  3078     }
       
  3079 
       
  3080 // -----------------------------------------------------------------------------
       
  3081 // CVcxMyVideosCollectionTester::GetActiveDownloadCountL
       
  3082 // -----------------------------------------------------------------------------
       
  3083 //
       
  3084 TInt CVCXMyVideosCollectionPluginTester::GetActiveDownloadCountL()
       
  3085     {
       
  3086     TInt count = 0;
       
  3087 
       
  3088     CMPXMedia* media ( NULL );
       
  3089     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  3090         {
       
  3091         media = (*iMediaArray)[i];
       
  3092 
       
  3093         if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
  3094             {
       
  3095             TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
  3096 
       
  3097             if( state == EVcxMyVideosDlStateDownloading || ( state == EVcxMyVideosDlStatePaused && iAutoResume ) )
       
  3098                 {
       
  3099                 count++;
       
  3100                 }
       
  3101             }
       
  3102         }
       
  3103 
       
  3104     VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester:: Active downloads: %d", count);
       
  3105 
       
  3106     return count;
       
  3107     }
       
  3108 
       
  3109 // -----------------------------------------------------------------------------
       
  3110 // CVcxMyVideosCollectionTester::SetAutoResume
       
  3111 // -----------------------------------------------------------------------------
       
  3112 //
       
  3113 void CVCXMyVideosCollectionPluginTester::SetAutoResume( TBool aValue )
       
  3114     {
       
  3115     iAutoResume = aValue;
       
  3116     }
       
  3117 
       
  3118 // -----------------------------------------------------------------------------
       
  3119 // CVcxMyVideosCollectionTester::GetCurrentLevel
       
  3120 // -----------------------------------------------------------------------------
       
  3121 //
       
  3122 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
       
  3123     {
       
  3124     if ( iCollectionUtility )
       
  3125         {
       
  3126         CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
       
  3127         TInt levels = path->Levels();
       
  3128         delete path;
       
  3129         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: levels: %d", levels);
       
  3130         return levels;
       
  3131         }    
       
  3132     return KErrNotFound;    
       
  3133     }
       
  3134 
       
  3135 // -----------------------------------------------------------------------------
       
  3136 // CVcxMyVideosCollectionTester::GetCurrentOpenLevelIndex
       
  3137 // -----------------------------------------------------------------------------
       
  3138 //
       
  3139 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
       
  3140     {
       
  3141     return iCurrentOpenedLevelIndex;
       
  3142     }
       
  3143 
       
  3144 // -----------------------------------------------------------------------------
       
  3145 // CVcxMyVideosCollectionTester::GetLastFullMedia
       
  3146 // -----------------------------------------------------------------------------
       
  3147 //
       
  3148 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
       
  3149     {
       
  3150     return iFullMedia;
       
  3151     }
       
  3152 
       
  3153 // -----------------------------------------------------------------------------
       
  3154 // CVcxMyVideosCollectionTester::GetMediaIndexInCollectionL
       
  3155 // -----------------------------------------------------------------------------
       
  3156 //
       
  3157 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
       
  3158     {
       
  3159     if( aIndex >= iMediaArray->Count() )
       
  3160         {
       
  3161         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Index (%d) out of bounds.", aIndex);
       
  3162         User::Leave( KErrArgument );
       
  3163         }
       
  3164 
       
  3165     TInt foundIndex( KErrNotFound );
       
  3166     
       
  3167     if( aDrive == -1 )
       
  3168         {
       
  3169         // No drive specified.
       
  3170         foundIndex = aIndex;
       
  3171         }
       
  3172     else
       
  3173         {
       
  3174         // Get the index in iMediaArray for a video on aDrive at aIndex.
       
  3175         TInt indexOfMediaWithDrive(0);
       
  3176            
       
  3177         for( TInt i=0; i<iMediaArray->Count(); i++ )
       
  3178             {
       
  3179             CMPXMedia* media = (*iMediaArray)[i];
       
  3180     
       
  3181             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  3182                 {
       
  3183                 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  3184                 TInt drive(0);
       
  3185                 User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
       
  3186                
       
  3187                 if( drive == aDrive )
       
  3188                     {
       
  3189                     // We are at requested index for the drive. 
       
  3190                     if( indexOfMediaWithDrive == aIndex )
       
  3191                         {
       
  3192                         foundIndex = i;
       
  3193                         break;
       
  3194                         }
       
  3195                     indexOfMediaWithDrive++;
       
  3196                     }            
       
  3197                 }
       
  3198             }
       
  3199         }
       
  3200     
       
  3201     if( foundIndex == KErrNotFound )
       
  3202         {
       
  3203         VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: media not found with drive: %d, index: %d", aDrive, aIndex);
       
  3204         User::Leave( KErrNotFound );
       
  3205         }
       
  3206 
       
  3207     // Get the video index in My Videos collection, it's not always same because videos on ROM are ignored.  
       
  3208 
       
  3209     CMPXMedia* media = (*iMediaArray)[foundIndex];
       
  3210     
       
  3211     for( TInt i = 0; i < iCollectionMediaArray->Count(); i++ )
       
  3212         {
       
  3213         CMPXMedia* collMedia = (*iCollectionMediaArray)[i];
       
  3214         TMPXItemId itemId1 = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  3215         TMPXItemId itemId2 = *(collMedia->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  3216         
       
  3217         if( itemId1 == itemId2 )
       
  3218             {
       
  3219             foundIndex = i;
       
  3220             break;
       
  3221             }
       
  3222         }
       
  3223     
       
  3224     if( foundIndex == KErrNotFound )
       
  3225          {
       
  3226          VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: media not found in collection array. drive: %d, index: %d", aDrive, aIndex);
       
  3227          User::Leave( KErrNotFound );
       
  3228          }    
       
  3229     
       
  3230     return foundIndex;
       
  3231     }
       
  3232 
       
  3233 // -----------------------------------------------------------------------------
       
  3234 // CVcxMyVideosCollectionTester::GetVideoCountForDrive
       
  3235 // -----------------------------------------------------------------------------
       
  3236 //
       
  3237 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
       
  3238     {  
       
  3239     if( !iMediaArray || iMediaArray->Count() == 0 ) return 0;
       
  3240     
       
  3241     TInt count( 0 );
       
  3242     
       
  3243     for( TInt i=0; i<iMediaArray->Count(); i++ )
       
  3244         {
       
  3245         CMPXMedia* media = (*iMediaArray)[i];
       
  3246 
       
  3247         if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  3248             {
       
  3249             const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  3250             TInt drive(0);
       
  3251             User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
       
  3252            
       
  3253             if( drive == aDrive )
       
  3254                 {
       
  3255                 count++;
       
  3256                 }     
       
  3257             }
       
  3258         }
       
  3259     return count;
       
  3260     }
       
  3261 
       
  3262 // -----------------------------------------------------------------------------
       
  3263 // CVcxMyVideosCollectionTester::GetAllCollectionMedia
       
  3264 // -----------------------------------------------------------------------------
       
  3265 //
       
  3266 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
       
  3267     {
       
  3268     return iCollectionMediaArray;
       
  3269     }
       
  3270 
       
  3271 // -----------------------------------------------------------------------------
       
  3272 // CVcxMyVideosCollectionTester::EnsureMediaFilesAreNotInUseL
       
  3273 // -----------------------------------------------------------------------------
       
  3274 //
       
  3275 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
       
  3276     {
       
  3277     if( iMediaArray->Count() <= 0 ) return; 
       
  3278     
       
  3279     TInt retries = 200;
       
  3280     RFile64 file;
       
  3281     TInt error( KErrInUse );
       
  3282     
       
  3283     const TInt KEnsureMediasNotInUseID = 1234567;
       
  3284     
       
  3285     TRAP_IGNORE( iStats->ActionStartL( KEnsureMediasNotInUseID, _L("Ensure files.") ) );
       
  3286     
       
  3287     TBool filesLocked( ETrue );
       
  3288     // Check all files that they are not in use, retry few times.
       
  3289     while( --retries >= 0 && filesLocked ) 
       
  3290         {
       
  3291         filesLocked = EFalse;
       
  3292         
       
  3293         for( TInt i=0; i<iMediaArray->Count(); i++ )
       
  3294             {
       
  3295             CMPXMedia* media = (*iMediaArray)[i];
       
  3296             
       
  3297             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  3298                 {
       
  3299                 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  3300 
       
  3301                 error = file.Open( iFs, localFilePath, EFileShareExclusive );
       
  3302                 if( error == KErrInUse || error == KErrLocked )
       
  3303                     {
       
  3304                     filesLocked = ETrue;
       
  3305                     User::After( 1000000 * 5 ); // Wait
       
  3306                     break;
       
  3307                     }
       
  3308                 file.Close();
       
  3309                 }
       
  3310             }
       
  3311         }
       
  3312 
       
  3313     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
       
  3314         {
       
  3315         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, error ) );
       
  3316         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
       
  3317         User::Leave( error );
       
  3318         }
       
  3319     else
       
  3320         {
       
  3321         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, KErrNone ) );
       
  3322         }
       
  3323     
       
  3324     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
       
  3325     }
       
  3326     
       
  3327 // -----------------------------------------------------------------------------
       
  3328 // CVCXMyVideosCollectionPluginTester::TimerComplete
       
  3329 // -----------------------------------------------------------------------------
       
  3330 //
       
  3331 void CVCXMyVideosCollectionPluginTester::TimerComplete( TInt /* aTimerId */, TInt /* aError */ )
       
  3332     {
       
  3333     if( iProgressTimer )
       
  3334         {
       
  3335         iProgressTimer->After( 1000000 );
       
  3336         }
       
  3337 
       
  3338     if( !iMediaArray || !iDlWatcher )
       
  3339        {
       
  3340        return;
       
  3341        }
       
  3342 
       
  3343     if( iDownloadsStarted && iUpdateDownloads && GetCurrentLevel() == 3 )
       
  3344         {
       
  3345        // Print short info about downloads
       
  3346        CMPXMedia* media( NULL );
       
  3347 
       
  3348        VCXLOGLO2("CVCXMyVideosCollectionPluginTester::TimerComplete: medias: %d", iMediaArray->Count());
       
  3349        for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  3350            {
       
  3351            media = (*iMediaArray)[i];
       
  3352 
       
  3353            if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
  3354                {
       
  3355                TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
  3356 
       
  3357                TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  3358 
       
  3359                TInt progress = -1;
       
  3360                if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
  3361                    {
       
  3362                    progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
       
  3363                    }
       
  3364 
       
  3365                TUint32 downloadId = 0;
       
  3366                if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
       
  3367                    {
       
  3368                    downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
  3369                    }
       
  3370 
       
  3371                CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
       
  3372 
       
  3373                if( dl )
       
  3374                    {
       
  3375 //                   VCXLOGLO5("CVCXMyVideosCollectionPluginTester:: DL ID: %d, MPX ID: %d, state: %d, progress: %d", downloadId, itemId.iId1, state, progress );
       
  3376 //                   VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: serviceId: %d, contentId: %d", dl->iServiceId, dl->iContentId );
       
  3377                    iDlWatcher->UpdateDownloadProgressL( itemId.iId1, downloadId, progress );
       
  3378                    }
       
  3379                }
       
  3380            }
       
  3381         }
       
  3382     }
       
  3383 //  End of File