videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp
branchRCL_3
changeset 57 befca0ec475f
parent 56 839377eedc2b
equal deleted inserted replaced
56:839377eedc2b 57:befca0ec475f
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:   ?Description*
    15 */
    15 */
       
    16 
    16 
    17 
    17 // INCLUDE FILES
    18 // INCLUDE FILES
    18 #include <e32svr.h>
    19 #include <e32svr.h>
    19 #include <e32std.h>
    20 #include <e32std.h>
    20 #include <StifParser.h>
    21 #include <StifParser.h>
    34 #include <mpxmessagecontainerdefs.h>
    35 #include <mpxmessagecontainerdefs.h>
    35 #include <mpxmediabase.h>
    36 #include <mpxmediabase.h>
    36 #include <mpxcommandgeneraldefs.h>
    37 #include <mpxcommandgeneraldefs.h>
    37 #include <mpxcollectioncommanddefs.h>
    38 #include <mpxcollectioncommanddefs.h>
    38 
    39 
    39 #include "VCXMyVideosTestUtils.h"
    40 #include "VCXTestCommon.h"
    40 #include "VCXTestLog.h"
    41 #include "VCXTestLog.h"
    41 #include "CVcxTestActiveWait.h"
    42 #include "CIptvTestTimer.h"
       
    43 #include "CIptvTestActiveWait.h"
       
    44 #include "VCXTestStatsKeeper.h"
    42 
    45 
    43 #include "VCXMyVideosCollectionPluginTester.h"
    46 #include "VCXMyVideosCollectionPluginTester.h"
    44 #include "VCXMyVideosTestUtils.h"
    47 #include "VCXMyVideosTestDlWatcher.h"
    45 #include "VCXMyVideosTestCommon.h"
    48 #include "VCXMyVideosTestCommon.h"
    46 
    49 
    47 #include "vcxmyvideoscollection.hrh"
    50 #include "vcxmyvideoscollection.hrh"
    48 #include "vcxmyvideosmdsdb.h"
    51 #include "vcxmyvideosmdsdb.h"
    49 #include "vcxmyvideosdefs.h"
    52 #include "vcxmyvideosdefs.h"
    56 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    57 // CVCXMyVideosCollectionPluginTester::NewL
    60 // CVCXMyVideosCollectionPluginTester::NewL
    58 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    59 //
    62 //
    60 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
    63 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
    61             MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXMyVideosTestUtils* aTestUtils )
    64             MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
    62     {
    65     {
    63     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
    66     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
    64     CVCXMyVideosCollectionPluginTester* self = 
    67     CVCXMyVideosCollectionPluginTester* self = 
    65         new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestUtils );
    68         new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestCommon, aStatsKeeper );
    66     CleanupStack::PushL(self);
    69     CleanupStack::PushL(self);
    67     self->ConstructL();
    70     self->ConstructL();
    68     CleanupStack::Pop(self);
    71     CleanupStack::Pop(self);
    69     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::NewL");
    72     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::NewL");
    70     return self;
    73     return self;
    74 // CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester
    77 // CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester
    75 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    76 //
    79 //
    77 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
    80 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
    78         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
    81         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
    79         CVCXMyVideosTestUtils* aTestUtils ) :
    82         CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
    80 iObserver( aObserver ), 
    83  : iObserver( aObserver ), iTestCommon( aTestCommon ), iStats( aStatsKeeper )
    81 iTestUtils( aTestUtils ),
       
    82 iCurrentLevelName( NULL ),
       
    83 iAutomaticContentRefresh( ETrue),
       
    84 iCurrentOpenedLevelIndex( -1 )
       
    85     {
    84     {
    86 
    85 
    87     }
    86     }
    88 
    87 
    89 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    92 //
    91 //
    93 CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester( )
    92 CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester( )
    94     {
    93     {
    95     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
    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;
    96 
   105 
    97     if( iCollectionUtility )
   106     if( iCollectionUtility )
    98         {
   107         {
    99         iCollectionUtility->Close();
   108         iCollectionUtility->Close();
   100         }
   109         }
   110         iOldMediaArray = NULL;
   119         iOldMediaArray = NULL;
   111         }
   120         }
   112 
   121 
   113     if( iMediaArray )
   122     if( iMediaArray )
   114         {
   123         {
   115         PrintMediasL( iMediaArray, EFalse, _L("Items") );
       
   116         iMediaArray->Reset();
   124         iMediaArray->Reset();
   117         delete iMediaArray;
   125         delete iMediaArray;
   118         iMediaArray = NULL;
   126         iMediaArray = NULL;
   119         }
   127         }
   120 
   128 
   121     if( iMediaArrayCopy )
       
   122         {
       
   123         iMediaArrayCopy->Reset();
       
   124         delete iMediaArrayCopy;
       
   125         iMediaArrayCopy = NULL;
       
   126         }
       
   127 
       
   128     iFs.Close();
   129     iFs.Close();
   129 
   130 
   130     if( iActiveWait )
   131     if( iActiveWait )
   131         {
   132         {
   132         iActiveWait->Stop();
   133         iActiveWait->Stop();
   150     
   151     
   151     iTransactions->CheckTransactions();
   152     iTransactions->CheckTransactions();
   152     delete iTransactions;
   153     delete iTransactions;
   153     iTransactions = NULL;
   154     iTransactions = NULL;
   154     
   155     
   155     iAlbumNames.ResetAndDestroy();
       
   156     iAlbumNames.Close();
       
   157     
       
   158     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
   156     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
   159     }
   157     }
   160 
   158 
   161 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   162 // CVCXMyVideosCollectionPluginTester::ConstructL
   160 // CVCXMyVideosCollectionPluginTester::ConstructL
   163 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   164 //
   162 //
   165 void CVCXMyVideosCollectionPluginTester::ConstructL()
   163 void CVCXMyVideosCollectionPluginTester::ConstructL()
   166     {
   164     {
   167     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
   165     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
   168     
   166     iAutomaticContentRefresh = ETrue;
   169 
   167 
   170     iActiveWait = CVcxTestActiveWait::NewL();
   168     iActiveWait = CIptvTestActiveWait::NewL();
   171     User::LeaveIfError( iFs.Connect() );
   169     User::LeaveIfError( iFs.Connect() );
   172     
   170     
   173     iTransactions = CVCXMyVideosTestTransactions::NewL();
   171     iTransactions = CVCXMyVideosTestTransactions::NewL();
   174     iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
   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 );
   175     
   178     
   176     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
   179     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
   177     }
   180     }
   178 
   181 
   179 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   187     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
   190     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
   188     CleanupStack::PushL( path );
   191     CleanupStack::PushL( path );
   189     iCollectionUid = TUid::Uid( aCollectionUid );
   192     iCollectionUid = TUid::Uid( aCollectionUid );
   190     path->AppendL( aCollectionUid );
   193     path->AppendL( aCollectionUid );
   191     
   194     
       
   195     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionActionId, _L("Open collection") ) );
       
   196     iCurrentActionHasResponse = EFalse;
       
   197     iCurrentActionId = KOpenCollectionActionId;
   192     SetRefreshStatus( ETrue );
   198     SetRefreshStatus( ETrue );
   193     
   199     
   194     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::OpenCollectionL: collectionId: 0x%x", aCollectionUid);
       
   195     
       
   196     iCollectionUtility->Collection().OpenL( *path );
   200     iCollectionUtility->Collection().OpenL( *path );
   197     iCurrentOpenedLevelIndex = -1;
       
   198     
   201     
   199     CleanupStack::PopAndDestroy( path );
   202     CleanupStack::PopAndDestroy( path );
   200     
   203     
   201     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL");
   204     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL");
   202     }
   205     }
   203 
   206 
   204 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   205 // CVCXMyVideosCollectionPluginTester::OpenLevelL
   208 // CVCXMyVideosCollectionPluginTester::OpenLevelL
   206 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   207 //
   210 //
   208 void CVCXMyVideosCollectionPluginTester::OpenLevelL( const TDesC& aLevelName )
   211 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex )
   209     {
   212     {
   210     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL (by name)");
   213     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL");
   211 
   214 
   212     if( GetCurrentLevel() != 2 )
   215     if( GetCurrentLevel() != 2 )
   213         {
   216         {
   214         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
   217         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
   215         User::Leave( KErrGeneral );
   218         User::Leave( KErrGeneral );
   216         }
   219         }
   217 
   220 
   218     CMPXMedia* media;
   221     if( aIndex < 0 || aIndex > iMediaArray->Count() )
   219 
   222         {
   220     int levelIndex(-1);
   223         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error. Index (%d) out of bounds!", aIndex);
   221     
   224         User::Leave( KErrGeneral );
   222     // From last to first
   225         }
   223     for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
   226 
   224         {
   227     // Save the name of level
   225         media = (*iMediaArray)[i];
   228 
   226         
   229     CMPXMedia* media(NULL);
   227         if( media->IsSupported( KMPXMediaGeneralTitle ) )
   230     media = (*iMediaArray)[aIndex];
   228             {
   231 
   229             if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aLevelName ) == KErrNone )
   232     if( media->IsSupported( KMPXMediaGeneralTitle ) )
   230                 {
   233         {
   231                 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
   234         delete iCurrentLevelName;
   232                 VCXLOGLO3("CVCXMyVideosCollectionPluginTester::OpenLevelL: mpx id1: %d, id2: %d", itemId.iId1, itemId.iId2);
   235         iCurrentLevelName = NULL;
   233                 
   236         iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
   234                 levelIndex = i;
   237         }
   235                 delete iCurrentLevelName;
   238 
   236                 iCurrentLevelName = NULL;
       
   237                 iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
       
   238                 break;
       
   239                 }
       
   240             }
       
   241         }
       
   242     
       
   243     if( levelIndex == -1 )
       
   244         {
       
   245         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:::OpenLevelL: Couldn't find the level!");
       
   246         User::Leave( KErrNotFound );
       
   247         }
       
   248     
       
   249     // Open the level
   239     // Open the level
   250     iCollectionUtility->Collection().OpenL( levelIndex );
   240     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionLevelActionId, _L("Open level") ) );
   251     
   241     iCurrentActionHasResponse = EFalse;
   252     iCurrentOpenedLevelIndex = levelIndex;
   242     iCurrentActionId = KOpenCollectionLevelActionId;
   253     SetRefreshStatus( ETrue );
   243     
   254     
       
   255     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:::OpenLevelL (by name)");
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CVCXMyVideosCollectionPluginTester::OpenLevelL
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex )
       
   263     {
       
   264     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL");
       
   265 
       
   266     if( GetCurrentLevel() != 2 )
       
   267         {
       
   268         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
       
   269         User::Leave( KErrGeneral );
       
   270         }
       
   271 
       
   272     if( aIndex >= 0 || aIndex < iMediaArray->Count() )
       
   273         {
       
   274         CMPXMedia* media(NULL);
       
   275         media = (*iMediaArray)[aIndex];
       
   276 
       
   277         if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   278             {
       
   279             delete iCurrentLevelName;
       
   280             iCurrentLevelName = NULL;
       
   281             iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
       
   282             }
       
   283         }
       
   284     else
       
   285         {
       
   286         VCXLOGLO1("CVCXMyVideosCollectionPluginTester::OpenLevelL: level index is invalid. Opening..");
       
   287         }
       
   288 
       
   289     // Open the level
       
   290     iCollectionUtility->Collection().OpenL( aIndex );
   244     iCollectionUtility->Collection().OpenL( aIndex );
   291     
   245     
   292     iCurrentOpenedLevelIndex = aIndex;
   246     iCurrentOpenedLevelIndex = aIndex;
   293     SetRefreshStatus( ETrue );
   247     SetRefreshStatus( ETrue );
   294     
   248     
   301 //
   255 //
   302 void CVCXMyVideosCollectionPluginTester::RefreshContentsL()
   256 void CVCXMyVideosCollectionPluginTester::RefreshContentsL()
   303     {
   257     {
   304     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   258     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   305 
   259 
   306 #if 0
       
   307     // No need to refresh if My Videos category is not open.
   260     // No need to refresh if My Videos category is not open.
   308     if( GetCurrentLevel() != 3)
   261     if( GetCurrentLevel() != 3)
   309         {
   262         {
   310         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
   263         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
   311         return;
   264         return;
   312         }
   265         }
   313 #endif 
       
   314 
   266 
   315     // Wait previous refresh to complete.
   267     // Wait previous refresh to complete.
   316     if( IsRefreshing() )
   268     if( IsRefreshing() )
   317         {
   269         {
   318         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
   270         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
   321 
   273 
   322     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   274     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   323     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
   275     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
   324     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   276     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   325 
   277 
       
   278     TRAP_IGNORE( iStats->ActionStartL( KRefreshCollectionActionId, _L("Refreshing collection") ) );
       
   279     iCurrentActionHasResponse = EFalse;
       
   280     iCurrentActionId = KRefreshCollectionActionId;
   326     iCollectionUtility->Collection().OpenL();
   281     iCollectionUtility->Collection().OpenL();
   327     SetRefreshStatus( ETrue );
   282     SetRefreshStatus( ETrue );
   328 
   283 
   329     //VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   284     //VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   330     }
   285     }
   362         {
   317         {
   363         cmd->SetCObjectValueL( KMPXMediaArrayContents, requestedMediaObjects );
   318         cmd->SetCObjectValueL( KMPXMediaArrayContents, requestedMediaObjects );
   364         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
   319         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
   365         }
   320         }
   366 
   321 
       
   322     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Doing request.");
   367     iActionCount++;
   323     iActionCount++;
       
   324     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Get medias by MPX ID") ) );
       
   325     iCurrentActionHasResponse = ETrue;
   368     iCollectionUtility->Collection().CommandL( *cmd );
   326     iCollectionUtility->Collection().CommandL( *cmd );
   369 
   327 
   370     SetRefreshStatus( ETrue );
   328     SetRefreshStatus( ETrue );
   371 
   329 
   372     CleanupStack::PopAndDestroy( requestedMediaObjects );
   330     CleanupStack::PopAndDestroy( requestedMediaObjects );
   396     // Empty attributes to get all the details.
   354     // Empty attributes to get all the details.
   397     CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
   355     CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
   398     CleanupStack::PushL( path );
   356     CleanupStack::PushL( path );
   399     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
   357     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
   400     path->SelectL( realIndex );
   358     path->SelectL( realIndex );
   401 
   359     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details") ) );
       
   360     iCurrentActionHasResponse = EFalse;
   402     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
   361     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
   403     CleanupStack::PopAndDestroy( path );
   362     CleanupStack::PopAndDestroy( path );
   404     CleanupStack::PopAndDestroy( &attrs );
   363     CleanupStack::PopAndDestroy( &attrs );
   405 
   364 
   406     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
   365     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
   426     
   385     
   427     CMPXCommand* cmd( NULL );
   386     CMPXCommand* cmd( NULL );
   428 
   387 
   429     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
   388     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
   430     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
   389     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
       
   390     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details by MPX ID") ) );
   431     iCollectionUtility->Collection().CommandL( *cmd );
   391     iCollectionUtility->Collection().CommandL( *cmd );
       
   392     
       
   393     iCurrentActionHasResponse = EFalse;
   432     
   394     
   433     CleanupStack::PopAndDestroy( cmd );
   395     CleanupStack::PopAndDestroy( cmd );
   434 
   396 
   435     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
   397     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
   436     }
   398     }
   479                 else
   441                 else
   480                     {
   442                     {
   481                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
   443                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
   482                     }
   444                     }
   483                 }
   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                 }
   484             
   560             
   485             UpdateAlbumsListL();
   561             if( state == EVcxMyVideosDlStatePaused && iAutoResume )
   486             }
   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
   487         else
   948         else
   488             {
   949             {
   489             VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL");
   950             const TArray<TMPXAttribute> newAttributes = media->Attributes();
   490             }
   951             const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
   491         }
   952             if( newAttributes.Count() != oldAttributes.Count() )
   492 
   953                 {
   493     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL");
   954                 add = ETrue;
   494     }
   955                 }
   495 
   956             else
   496 // -----------------------------------------------------------------------------
   957                 {
   497 // CVCXMyVideosCollectionPluginTester::PrintMediasL
   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
   498 // -----------------------------------------------------------------------------
  1100 // -----------------------------------------------------------------------------
   499 //
  1101 //
   500 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
  1102 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
   501     {
  1103     {
   502     if( aMediaArray == NULL )
  1104     if( aMediaArray == NULL )
   533     else
  1135     else
   534         {
  1136         {
   535         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
  1137         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
   536         }
  1138         }
   537 
  1139 
   538     CMPXMedia* media;
  1140     CMPXMedia* media(NULL);
   539     for( TInt i = 0; i < medias->Count(); i++ )
  1141     for( TInt i = 0; i < medias->Count(); i++ )
   540         {
  1142         {
   541         media = (*medias)[i];
  1143         media = (*medias)[i];
   542         if( media )
  1144         if( media )
   543             PrintMPXMediaL( *media, ETrue );
  1145             PrintMPXMediaL( *media, ETrue );
   549         CleanupStack::PopAndDestroy( medias );
  1151         CleanupStack::PopAndDestroy( medias );
   550         }
  1152         }
   551     }
  1153     }
   552 
  1154 
   553 // -----------------------------------------------------------------------------
  1155 // -----------------------------------------------------------------------------
   554 // CVCXMyVideosCollectionPluginTester::PrintMPXMediaL
  1156 // CVcxMyVideosCollectionTester::PrintMPXMediaL
   555 // -----------------------------------------------------------------------------
  1157 // -----------------------------------------------------------------------------
   556 //
  1158 //
   557 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
  1159 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
   558     {
  1160     {
   559     TMPXItemId itemId = *aMedia.Value<TMPXItemId>( KMPXMediaGeneralId );
  1161     TMPXItemId itemId = *aMedia.Value<TMPXItemId>( KMPXMediaGeneralId );
   565             {
  1167             {
   566             title = aMedia.ValueText( KMPXMediaGeneralTitle );
  1168             title = aMedia.ValueText( KMPXMediaGeneralTitle );
   567             }
  1169             }
   568 
  1170 
   569         // Category
  1171         // Category
   570         if( itemId.iId2 != KVcxMvcMediaTypeVideo )
  1172         if( itemId.iId2 != 0 )
   571             {
  1173             {
   572             TInt itemCount(0);
  1174             TInt itemCount(0);
   573             TInt newItemCount(0);
  1175             TInt newItemCount(0);
   574             TBuf<256> newItemName;
  1176             TBuf<256> newItemName;
   575             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
  1177             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
   619         return;
  1221         return;
   620         }
  1222         }
   621 
  1223 
   622     // Print all details
  1224     // Print all details
   623 
  1225 
   624     if( itemId.iId2 == KVcxMvcMediaTypeCategory )
  1226     if( itemId.iId2 != 0 )
   625         {
  1227         {
   626         VCXLOGLO1("--------------------------- CATEGORY -------------------------------");
  1228         VCXLOGLO1("--------------------------- MEDIA CATEGORY -------------------------------");
   627         }
  1229         }
   628     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
  1230     else
   629         {
  1231         {
   630         VCXLOGLO1("--------------------------- Album ----------------------------------");
  1232         VCXLOGLO1("--------------------------- MEDIA OBJECT -------------------------------");
   631         }
       
   632     else if( itemId.iId2 == KVcxMvcMediaTypeVideo )
       
   633         {
       
   634         VCXLOGLO1("--------------------------- VIDEO -------------------------------");
       
   635         }
       
   636     else 
       
   637         {
       
   638         VCXLOGLO1("--------------------------- UNKNOWN! -------------------------------");
       
   639         }
  1233         }
   640 
  1234 
   641     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
  1235     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
   642 
  1236 
   643     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
  1237     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
   863         VCXLOGLO2("KMPXMediaGeneralPath: %S", &value);
  1457         VCXLOGLO2("KMPXMediaGeneralPath: %S", &value);
   864         }
  1458         }
   865     }
  1459     }
   866 
  1460 
   867 // -----------------------------------------------------------------------------
  1461 // -----------------------------------------------------------------------------
   868 // CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL
  1462 // CVcxMyVideosCollectionTester::HandleCollectionMessage
   869 // -----------------------------------------------------------------------------
       
   870 //
       
   871 void CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL()
       
   872     {
       
   873     CMPXMedia* media;
       
   874     
       
   875     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
   876         {
       
   877         media = (*iMediaArray)[i];
       
   878         
       
   879         if( media )
       
   880             {
       
   881             TMPXItemId itemId = *media->Value<TMPXItemId>( KMPXMediaGeneralId );
       
   882                         
       
   883             if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
   884                 {
       
   885                 int albumIndex(-1);
       
   886                 for( TInt e = 0; e < iAlbumIds.Count(); e++ )
       
   887                     {
       
   888                     if( iAlbumIds[e] == itemId )
       
   889                         {
       
   890                         albumIndex = e;
       
   891                         }
       
   892                     }
       
   893                 
       
   894                 TBuf<256> title;
       
   895                 if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   896                     {
       
   897                     title = media->ValueText( KMPXMediaGeneralTitle );
       
   898                     
       
   899                     if( albumIndex == -1 )
       
   900                         {
       
   901                         HBufC* titleBuff = title.AllocL();
       
   902                         iAlbumNames.Append( titleBuff );
       
   903                         iAlbumIds.Append( itemId );
       
   904                         }
       
   905                     else
       
   906                         {
       
   907                         if( iAlbumNames[albumIndex]->Compare( title )!= KErrNone )
       
   908                             {
       
   909                             iAlbumNames[albumIndex]->Des().SetLength( 0 );
       
   910                             iAlbumNames[albumIndex]->ReAlloc( title.Length() );
       
   911                             iAlbumNames[albumIndex]->Des().Copy( title );
       
   912                             }
       
   913                         }
       
   914                     }
       
   915                 }
       
   916             }
       
   917         }
       
   918     }
       
   919 
       
   920 // -----------------------------------------------------------------------------
       
   921 // CVCXMyVideosCollectionPluginTester::GetAlbumIdL
       
   922 // -----------------------------------------------------------------------------
       
   923 //
       
   924 TMPXItemId CVCXMyVideosCollectionPluginTester::GetAlbumIdL( const TDesC& aAlbumName )
       
   925     {
       
   926     // Get the last album with the name.
       
   927     for( TInt i = iAlbumNames.Count()-1; i >= 0; i-- )
       
   928         {
       
   929         if( iAlbumNames[i]->Des() == aAlbumName && i < iAlbumIds.Count() )
       
   930             {
       
   931             VCXLOGLO3("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: returning album id1: %d, id2: %d", iAlbumIds[i].iId1, iAlbumIds[i].iId2);
       
   932             return iAlbumIds[i];
       
   933             }
       
   934         }
       
   935     
       
   936     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: could not find album '%S'", &aAlbumName);
       
   937     User::Leave( KErrNotFound );
       
   938     
       
   939     return TMPXItemId::InvalidId();
       
   940     }
       
   941 
       
   942 // -----------------------------------------------------------------------------
       
   943 // CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC
       
   944 // -----------------------------------------------------------------------------
       
   945 //
       
   946 CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync )
       
   947     {
       
   948     CMPXCommand* cmd = CMPXCommand::NewL();
       
   949     CleanupStack::PushL( cmd );
       
   950 
       
   951     cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
       
   952     if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   953         {
       
   954         cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
       
   955         }
       
   956 
       
   957     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync );
       
   958 
       
   959     if( !aSync )
       
   960         {
       
   961         iTransactions->NextTransactionId();
       
   962 
       
   963         if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   964             {
       
   965             cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
       
   966             iTransactions->AddTransactionId( aMyVideosCommandId );
       
   967             }
       
   968         }
       
   969 
       
   970     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC: collectionId: 0x%x", iCollectionUid.iUid);
       
   971     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
       
   972 
       
   973     return cmd;
       
   974     }
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // CVCXMyVideosCollectionPluginTester::SelectMediasL
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex )
       
   981     {
       
   982     if( aStartIndex == -4 )
       
   983         {
       
   984         VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL");
       
   985         return NULL;
       
   986         }
       
   987 
       
   988     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   989     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex);
       
   990 
       
   991     CMPXMediaArray* iSourceMedias;
       
   992     
       
   993     if( !iUseCopiedMedias )
       
   994         {
       
   995         if( !iMediaArray )
       
   996             {
       
   997             User::Leave( KErrNotReady );
       
   998             }
       
   999         iSourceMedias = iMediaArray;
       
  1000         }
       
  1001     else
       
  1002         {
       
  1003         if( !iMediaArrayCopy )
       
  1004             {
       
  1005             User::Leave( KErrNotReady );
       
  1006             }
       
  1007         iSourceMedias = iMediaArrayCopy;
       
  1008         }
       
  1009 
       
  1010     iRequestedMediaIds.Reset();
       
  1011 
       
  1012     CMPXMediaArray* medias = CMPXMediaArray::NewL();
       
  1013 
       
  1014     // None
       
  1015     if( aStartIndex > aEndIndex )
       
  1016         {
       
  1017         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos.");
       
  1018         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
  1019         return medias;
       
  1020         }
       
  1021 
       
  1022     CleanupStack::PushL( medias );
       
  1023 
       
  1024     if( aStartIndex >= 0 )
       
  1025         {
       
  1026         if( aEndIndex > iSourceMedias->Count() )
       
  1027             {
       
  1028             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
  1029             User::Leave( KErrArgument );
       
  1030             }
       
  1031 
       
  1032         TInt countToSelect = aEndIndex - aStartIndex;
       
  1033         TInt indexOfVideoOnDrive = 0;
       
  1034         
       
  1035         for( TInt i = 0; i < iSourceMedias->Count(); i++ )
       
  1036             {
       
  1037             CMPXMedia* media = (*iSourceMedias)[i];
       
  1038 
       
  1039             if( media )
       
  1040                 {
       
  1041                 TBool selectThis( EFalse );
       
  1042                 
       
  1043                 if( aDriveFilter != -1 )
       
  1044                     {
       
  1045                     // Drive specified, check path and index of video on the drive.
       
  1046                     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
  1047                     TInt drive( 0 );
       
  1048                     User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
       
  1049 
       
  1050                     if( drive == aDriveFilter )
       
  1051                         {
       
  1052                         if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex )
       
  1053                             {
       
  1054                             selectThis = ETrue;
       
  1055                             }
       
  1056                         indexOfVideoOnDrive++;                        
       
  1057                         }
       
  1058                     }
       
  1059                 else
       
  1060                     {
       
  1061                     // No drive specified, just index check.
       
  1062                     if( i >= aStartIndex && i < aEndIndex )
       
  1063                         {
       
  1064                         selectThis = ETrue;
       
  1065                         }
       
  1066                     }
       
  1067 
       
  1068                 if( selectThis )
       
  1069                     {
       
  1070                     TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1071                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
  1072                     iRequestedMediaIds.Append( mpxId.iId1 );
       
  1073                     CMPXMedia* newMedia = CMPXMedia::NewL();
       
  1074                     CleanupStack::PushL( newMedia );
       
  1075                     newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
  1076                     newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
  1077                     medias->AppendL( *newMedia );
       
  1078                     CleanupStack::PopAndDestroy( newMedia );
       
  1079     
       
  1080                     if( medias->Count() >= countToSelect )
       
  1081                         {
       
  1082                         break;
       
  1083                         }
       
  1084                     }
       
  1085                 }
       
  1086             }
       
  1087         }
       
  1088 
       
  1089     // Invalid IDs
       
  1090     if( aStartIndex == -1 )
       
  1091         {
       
  1092         for( TInt i = 0; i < aEndIndex; i++ )
       
  1093             {
       
  1094             TMPXItemId mpxId;
       
  1095             mpxId.iId1 = i+66666;
       
  1096             mpxId.iId2 = 0;
       
  1097 
       
  1098             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1);
       
  1099 
       
  1100             CMPXMedia* newMedia = CMPXMedia::NewL();
       
  1101             CleanupStack::PushL( newMedia );
       
  1102             newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
  1103             newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
  1104             medias->AppendL( *newMedia );
       
  1105             CleanupStack::PopAndDestroy( newMedia );
       
  1106             }
       
  1107         }
       
  1108 
       
  1109     // Duplicate IDs
       
  1110     if( aStartIndex == -2 )
       
  1111         {
       
  1112         if( aEndIndex > iSourceMedias->Count() )
       
  1113             {
       
  1114             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
  1115             User::Leave( KErrArgument );
       
  1116             }
       
  1117 
       
  1118         for( TInt i = 0; i < aEndIndex; i++ )
       
  1119             {
       
  1120             CMPXMedia* media = (*iSourceMedias)[i];
       
  1121 
       
  1122             if( media )
       
  1123                 {
       
  1124                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1125 
       
  1126                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1);
       
  1127                 iRequestedMediaIds.Append( mpxId.iId1 );
       
  1128                 iRequestedMediaIds.Append( mpxId.iId1 );
       
  1129                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
  1130                 CleanupStack::PushL( newMedia );
       
  1131                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
  1132                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
  1133                 medias->AppendL( *newMedia );
       
  1134                 medias->AppendL( *newMedia );
       
  1135                 CleanupStack::PopAndDestroy( newMedia );
       
  1136                 }
       
  1137             }
       
  1138         }
       
  1139 
       
  1140     // Every second ID
       
  1141     if( aStartIndex == -3 )
       
  1142         {
       
  1143         if( aEndIndex > iSourceMedias->Count() )
       
  1144             {
       
  1145             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
  1146             User::Leave( KErrArgument );
       
  1147             }
       
  1148 
       
  1149         for( TInt i = 0; i < aEndIndex; i+=2 )
       
  1150             {
       
  1151             CMPXMedia* media = (*iSourceMedias)[i];
       
  1152 
       
  1153             if( media )
       
  1154                 {
       
  1155                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1156 
       
  1157                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
  1158                 iRequestedMediaIds.Append( mpxId.iId1 );
       
  1159                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
  1160                 CleanupStack::PushL( newMedia );
       
  1161                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
  1162                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
  1163                 medias->AppendL( *newMedia );
       
  1164                 CleanupStack::PopAndDestroy( newMedia );
       
  1165                 }
       
  1166             }
       
  1167         }
       
  1168 
       
  1169     CleanupStack::Pop( medias );
       
  1170 
       
  1171     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
  1172     return medias;
       
  1173     }
       
  1174 
       
  1175 // -----------------------------------------------------------------------------
       
  1176 // CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL
       
  1177 // -----------------------------------------------------------------------------
       
  1178 //
       
  1179 void CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL( TBool aUseCopiedMedias )
       
  1180     {
       
  1181     if( aUseCopiedMedias )
       
  1182         {
       
  1183         CreateCopyOfCurrentMediasL();
       
  1184         }
       
  1185     
       
  1186     iUseCopiedMedias = aUseCopiedMedias;
       
  1187     }
       
  1188 
       
  1189 // -----------------------------------------------------------------------------
       
  1190 // CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL
       
  1191 // -----------------------------------------------------------------------------
       
  1192 //
       
  1193 void CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL()
       
  1194     {
       
  1195     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL");
       
  1196     
       
  1197     if( !iMediaArray )
       
  1198         {
       
  1199         User::Leave( KErrNotReady );
       
  1200         }
       
  1201     
       
  1202     if( iMediaArrayCopy )
       
  1203         {
       
  1204         iMediaArrayCopy->Reset();
       
  1205         delete iMediaArrayCopy;
       
  1206         iMediaArrayCopy = NULL;
       
  1207         }
       
  1208     
       
  1209     iMediaArrayCopy = CMPXMediaArray::NewL();
       
  1210     
       
  1211     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  1212         {
       
  1213         CMPXMedia* media = (*iMediaArray)[i];
       
  1214 
       
  1215         if( media )
       
  1216             {
       
  1217             TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1218 
       
  1219             CMPXMedia* newMedia = CMPXMedia::NewL();
       
  1220             CleanupStack::PushL( newMedia );
       
  1221             newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
  1222             newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
  1223             iMediaArrayCopy->AppendL( *newMedia );
       
  1224             CleanupStack::PopAndDestroy( newMedia );
       
  1225             }
       
  1226         }
       
  1227 
       
  1228     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL");
       
  1229     }
       
  1230 
       
  1231 // -----------------------------------------------------------------------------
       
  1232 // CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArray
       
  1233 // -----------------------------------------------------------------------------
       
  1234 //
       
  1235 void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL()
       
  1236     {
       
  1237     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
  1238 
       
  1239     if ( !iCollectionEntries )
       
  1240         {
       
  1241         return;
       
  1242         }
       
  1243 
       
  1244     if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) )
       
  1245         {
       
  1246         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!");
       
  1247         User::Leave( KErrNotSupported );
       
  1248         }
       
  1249 
       
  1250     // Get up to date list of all medias in collection.
       
  1251     CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
  1252     
       
  1253     // Delete array of old medias
       
  1254     if( iOldMediaArray )
       
  1255         {
       
  1256         iOldMediaArray->Reset();
       
  1257         delete iOldMediaArray;
       
  1258         }
       
  1259 
       
  1260     // Update the old array and create new
       
  1261     iOldMediaArray = iMediaArray;
       
  1262     iMediaArray = CMPXMediaArray::NewL();
       
  1263 
       
  1264     TBool categories( EFalse );
       
  1265     
       
  1266     // Make copies of the medias.
       
  1267     for( TInt i=0; i<medias->Count(); i++ )
       
  1268         {
       
  1269         CMPXMedia* media = (*medias)[i];
       
  1270         
       
  1271         TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  1272 
       
  1273         if( itemId.iId2 != KVcxMvcMediaTypeVideo )
       
  1274              {
       
  1275              categories = ETrue;
       
  1276              }
       
  1277         
       
  1278         // Ignore medias on ROM.
       
  1279         TBool isOnRom( EFalse );
       
  1280         
       
  1281         if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  1282             {
       
  1283             const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
  1284             if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
  1285                 {
       
  1286                 isOnRom = ETrue;
       
  1287                 }
       
  1288             }
       
  1289         
       
  1290         if( !isOnRom )
       
  1291             {
       
  1292             iMediaArray->AppendL( *media );
       
  1293             }
       
  1294         }
       
  1295     
       
  1296     iMediaCount = iMediaArray->Count();
       
  1297     
       
  1298     // Update count of videos on ROM.
       
  1299     if( !categories )
       
  1300         {
       
  1301         iVideosOnRomCount = 0;
       
  1302 
       
  1303         for( TInt i=0; i<medias->Count(); i++ )
       
  1304             {
       
  1305             CMPXMedia* media = (*medias)[i];            
       
  1306             
       
  1307             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
  1308                 {
       
  1309                 const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
  1310                 if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
  1311                     {
       
  1312                     iVideosOnRomCount++;
       
  1313                     }
       
  1314                 }
       
  1315             }
       
  1316 
       
  1317             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount);
       
  1318         }
       
  1319     
       
  1320     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
  1321     }
       
  1322 
       
  1323 // -----------------------------------------------------------------------------
       
  1324 // CVCXMyVideosCollectionPluginTester::GetChangedMedias
       
  1325 // -----------------------------------------------------------------------------
       
  1326 //
       
  1327 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias )
       
  1328     {
       
  1329     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
  1330 
       
  1331     CMPXMediaArray* changedMedias = CMPXMediaArray::NewL();
       
  1332 
       
  1333     if( !aNewMedias )
       
  1334         {
       
  1335         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
  1336         return changedMedias;
       
  1337         }
       
  1338 
       
  1339     CleanupStack::PushL( changedMedias );
       
  1340 
       
  1341     for( TInt i=0; i<aNewMedias->Count(); i++ )
       
  1342         {
       
  1343         CMPXMedia* media(NULL);
       
  1344         media = (*aNewMedias)[i];
       
  1345         
       
  1346         if( !media )
       
  1347             {
       
  1348             continue;
       
  1349             }
       
  1350         
       
  1351         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1352 
       
  1353         CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId );
       
  1354 
       
  1355         TBool add( EFalse );
       
  1356 
       
  1357         // It's a new.
       
  1358         if( !oldMedia )
       
  1359             {
       
  1360             add = ETrue;
       
  1361             }
       
  1362         // Check changes
       
  1363         else
       
  1364             {
       
  1365             const TArray<TMPXAttribute> newAttributes = media->Attributes();
       
  1366             const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
       
  1367             if( newAttributes.Count() != oldAttributes.Count() )
       
  1368                 {
       
  1369                 add = ETrue;
       
  1370                 }
       
  1371             else
       
  1372                 {
       
  1373                 for( TInt e=0; e<newAttributes.Count(); e++ )
       
  1374                     {
       
  1375                     if( !oldMedia->Match( *media, newAttributes[e] ) )
       
  1376                         {
       
  1377                         add = ETrue;
       
  1378                         break;
       
  1379                         }
       
  1380                     }
       
  1381                 }
       
  1382             }
       
  1383 
       
  1384         // Add a copy of the media.
       
  1385         if( add )
       
  1386             {
       
  1387             changedMedias->AppendL( *media );
       
  1388             }
       
  1389         }
       
  1390 
       
  1391     CleanupStack::Pop( changedMedias );
       
  1392 
       
  1393     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
  1394     return changedMedias;
       
  1395     }
       
  1396 
       
  1397 // -----------------------------------------------------------------------------
       
  1398 // CVCXMyVideosCollectionPluginTester::GetMediaByMpxId
       
  1399 // -----------------------------------------------------------------------------
       
  1400 //
       
  1401 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId )
       
  1402     {
       
  1403     if( !aMedias )
       
  1404         {
       
  1405         return NULL;
       
  1406         }
       
  1407 
       
  1408     for( TInt i=0; i<aMedias->Count(); i++ )
       
  1409         {
       
  1410         CMPXMedia* media = (*aMedias)[i];
       
  1411         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1412 
       
  1413         if( mpxId == aMpxId )
       
  1414             {
       
  1415             return media;
       
  1416             }
       
  1417         }
       
  1418     return NULL;
       
  1419     }
       
  1420 
       
  1421 // -----------------------------------------------------------------------------
       
  1422 // CVCXMyVideosCollectionPluginTester::SetRefreshStatus
       
  1423 // -----------------------------------------------------------------------------
       
  1424 //
       
  1425 void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection )
       
  1426     {
       
  1427     iRefreshingCollection = aRefreshingCollection;
       
  1428     }
       
  1429 
       
  1430 // -----------------------------------------------------------------------------
       
  1431 // CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL
       
  1432 // -----------------------------------------------------------------------------
       
  1433 //
       
  1434 void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds )
       
  1435     {
       
  1436     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1437 
       
  1438     // Print requested ids
       
  1439     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:");
       
  1440     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1441         {
       
  1442         VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] );
       
  1443         }
       
  1444 
       
  1445     // Print actual result ids and check for errors
       
  1446     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:");
       
  1447     for( TInt i = 0; i < aRequestResultMedias.Count(); i++ )
       
  1448         {
       
  1449         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i);
       
  1450         CMPXMedia* media = aRequestResultMedias[i];
       
  1451         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media");
       
  1452         if( media )
       
  1453             {
       
  1454             TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1455             VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 );
       
  1456             if( media->IsSupported( KVcxMediaMyVideosInt32Value ) )
       
  1457                 {
       
  1458                 TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
       
  1459                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result);
       
  1460                 if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) )
       
  1461                     {
       
  1462                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result);
       
  1463                     User::Leave( result );
       
  1464                     }
       
  1465                 }
       
  1466             }
       
  1467         else
       
  1468             {
       
  1469             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i);
       
  1470             }
       
  1471         }
       
  1472 
       
  1473     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks");
       
  1474     
       
  1475     // First check the counts match
       
  1476     if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() )
       
  1477         {
       
  1478         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!");
       
  1479         User::Leave( KErrCorrupt );
       
  1480         }
       
  1481     else
       
  1482     // Check that all requested ids are in the results
       
  1483     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1484         {
       
  1485         TMPXItemId mpxId;
       
  1486         mpxId.iId1 = aRequestedMediaIds[i];
       
  1487         mpxId.iId2 = 0;
       
  1488 
       
  1489         TBool found( EFalse );
       
  1490         for( TInt e = 0; e < aRequestResultMedias.Count(); e++ )
       
  1491             {
       
  1492             CMPXMedia* media2 = aRequestResultMedias[e];
       
  1493             if( media2 )
       
  1494                 {
       
  1495                 TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1496 
       
  1497                 if( mpxId == mpxId2 )
       
  1498                     {
       
  1499                     found = ETrue;
       
  1500                     }
       
  1501                 }
       
  1502             }
       
  1503 
       
  1504         if( !found )
       
  1505             {
       
  1506             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!");
       
  1507             User::Leave( KErrCorrupt );
       
  1508             }
       
  1509         }
       
  1510     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1511     }
       
  1512 
       
  1513 // -----------------------------------------------------------------------------
       
  1514 // CVCXMyVideosCollectionPluginTester::HandleCollectionMessage
       
  1515 // -----------------------------------------------------------------------------
  1463 // -----------------------------------------------------------------------------
  1516 //
  1464 //
  1517 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1465 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1518     {
  1466     {
  1519     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1467     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1582 
  1530 
  1583     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1531     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1584     }
  1532     }
  1585 
  1533 
  1586 // -----------------------------------------------------------------------------
  1534 // -----------------------------------------------------------------------------
  1587 // CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage
  1535 // CVcxMyVideosCollectionTester::HandleSingleCollectionMessage
  1588 // -----------------------------------------------------------------------------
  1536 // -----------------------------------------------------------------------------
  1589 //
  1537 //
  1590 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
  1538 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
  1591     {
  1539     {
  1592     if( !aMessage || !aMessage->IsSupported( KMPXMessageGeneralId ) ) return;
  1540     if( !aMessage || !aMessage->IsSupported( KMPXMessageGeneralId ) ) return;
  1642 
  1590 
  1643                        // Update current entries
  1591                        // Update current entries
  1644                         delete iCollectionEntries;
  1592                         delete iCollectionEntries;
  1645                         iCollectionEntries = NULL;
  1593                         iCollectionEntries = NULL;
  1646                         iCollectionEntries = CMPXMedia::NewL( *aMessage );
  1594                         iCollectionEntries = CMPXMedia::NewL( *aMessage );
  1647                         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
  1648 
  1595 
  1649                         UpdateOwnedMediaArrayL();
  1596                         UpdateOwnedMediaArrayL();
  1650 
  1597 
  1651                         SetRefreshStatus( EFalse );
  1598                         SetRefreshStatus( EFalse );
  1652 
  1599 
       
  1600                         // add downloads to the requested ID array always and update downloads too.
       
  1601                         TBool backup = iUpdateDownloads;
       
  1602                         iUpdateDownloads = EFalse;
  1653                         ProcessCurrentEntriesL();
  1603                         ProcessCurrentEntriesL();
       
  1604                         iUpdateDownloads = backup;
  1654 
  1605 
  1655                         // Check
  1606                         // Check
  1656                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
  1607                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
  1657                         if( err != KErrNone )
  1608                         if( err != KErrNone )
  1658                             {
  1609                             {
  1659                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
  1610                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
  1660                             }
  1611                             }
  1661 
  1612 
  1662                         // Inform observer
  1613                         // Inform observer
  1663                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
  1614                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
       
  1615                         
       
  1616                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1617                         if( actionErr == KErrAbort )
       
  1618                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1664                         
  1619                         
  1665                         }
  1620                         }
  1666                         break;
  1621                         break;
  1667 
  1622 
  1668                     // This is received when list is open already and the list contains new items
  1623                     // This is received when list is open already and the list contains new items
  1696                     * it should refetch items when this event arrives.
  1651                     * it should refetch items when this event arrives.
  1697                     */
  1652                     */
  1698                     case KVcxMessageMyVideosListComplete:
  1653                     case KVcxMessageMyVideosListComplete:
  1699                         {
  1654                         {
  1700                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1655                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1701                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete ------>");
  1656                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete");
  1702                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1657                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1703                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
  1658                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
  1704                         }
  1659                         }
  1705                         break;
  1660                         break;
  1706 
  1661 
  1715                             break;
  1670                             break;
  1716                             }
  1671                             }
  1717                         iActionCount--;
  1672                         iActionCount--;
  1718 
  1673 
  1719                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
  1674                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
       
  1675                         
       
  1676                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Move/Copy started.") ) );
  1720                         }
  1677                         }
  1721                         break;
  1678                         break;
  1722 
  1679 
  1723                     case KVcxMessageMyVideosMoveResp:
  1680                     case KVcxMessageMyVideosMoveResp:
  1724                         {
  1681                         {
  1750                         if( iCancelRequested )
  1707                         if( iCancelRequested )
  1751                             {
  1708                             {
  1752                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1709                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1753                             iCancelRequested = EFalse;
  1710                             iCancelRequested = EFalse;
  1754                             }                        
  1711                             }                        
       
  1712 
       
  1713                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1714                         if( actionErr == KErrAbort )
       
  1715                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1755                         
  1716                         
  1756                         CleanupStack::PopAndDestroy( medias );
  1717                         CleanupStack::PopAndDestroy( medias );
  1757                         }
  1718                         }
  1758                         break;
  1719                         break;
  1759 
  1720 
  1787                             {
  1748                             {
  1788                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1749                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1789                             iCancelRequested = EFalse;
  1750                             iCancelRequested = EFalse;
  1790                             }                        
  1751                             }                        
  1791                         
  1752                         
       
  1753                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1754                         if( actionErr == KErrAbort )
       
  1755                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1756                         
  1792                         CleanupStack::PopAndDestroy( medias );
  1757                         CleanupStack::PopAndDestroy( medias );
  1793                         }
  1758                         }
  1794                         break;
  1759                         break;
  1795 
  1760 
  1796                     case KVcxMessageMyVideosDeleteStarted:
  1761                     case KVcxMessageMyVideosDeleteStarted:
  1804                             break;
  1769                             break;
  1805                             }
  1770                             }
  1806                         iActionCount--;
  1771                         iActionCount--;
  1807 
  1772 
  1808                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
  1773                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
       
  1774                         
       
  1775                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Delete started.") ) );
  1809                         }
  1776                         }
  1810                         break;
  1777                         break;
  1811 
  1778 
  1812                     case KVcxMessageMyVideosDeleteResp:
  1779                     case KVcxMessageMyVideosDeleteResp:
  1813                         {
  1780                         {
  1839                         if( iCancelRequested )
  1806                         if( iCancelRequested )
  1840                             {
  1807                             {
  1841                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1808                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1842                             iCancelRequested = EFalse;
  1809                             iCancelRequested = EFalse;
  1843                             }
  1810                             }
       
  1811                         
       
  1812                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1813                         if( actionErr == KErrAbort )
       
  1814                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1844                         
  1815                         
  1845                         CleanupStack::PopAndDestroy( medias );
  1816                         CleanupStack::PopAndDestroy( medias );
  1846                         }
  1817                         }
  1847                         break;
  1818                         break;
  1848 
  1819 
  1907             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageIdItemChanged");
  1878             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageIdItemChanged");
  1908             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
  1879             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
  1909 
  1880 
  1910             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
  1881             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
  1911             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
  1882             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
  1912        
  1883 
  1913             if( iWaitingForItemChange && itemId.iId2 == KVcxMvcMediaTypeVideo )
  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 )
  1914                 {
  1905                 {
  1915                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
  1906                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
  1916                 iWaitingForItemChange = EFalse;
  1907                 iWaitingForItemChange = EFalse;
  1917                 iActiveWait->Stop();
  1908                 iActiveWait->Stop();
  1918                 }
  1909                 }
  1924                 {
  1915                 {
  1925                 case EMPXItemInserted:
  1916                 case EMPXItemInserted:
  1926                     {
  1917                     {
  1927                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
  1918                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
  1928                     iInsertedItemIds.Append( itemId.iId1 );
  1919                     iInsertedItemIds.Append( itemId.iId1 );
       
  1920 
  1929                     refreshNeeded = ETrue;
  1921                     refreshNeeded = ETrue;
       
  1922                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemInserted, KErrNone );
  1930                     
  1923                     
  1931                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
  1924                     TRAPD( actionErr, iStats->ActionEndL( KSideloadVideoActionId, KErrNone ) );
  1932                         {
  1925                     if( actionErr == KErrAbort )
  1933                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoInserted, KErrNone );
  1926                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1934                         }
  1927                     
  1935                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1936                         {
       
  1937                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryInserted, KErrNone );
       
  1938                         }
       
  1939                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1940                         {
       
  1941                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumInserted, KErrNone );
       
  1942                         }
       
  1943                     }
  1928                     }
  1944                     break;
  1929                     break;
  1945 
  1930 
  1946                 case EMPXItemDeleted:
  1931                 case EMPXItemDeleted:
  1947                     {
  1932                     {
  1948                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
  1933                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
  1949                     iDeletedItemIds.Append( itemId.iId1 );
  1934                     iDeletedItemIds.Append( itemId.iId1 );
  1950                     refreshNeeded = ETrue;
  1935                     refreshNeeded = ETrue;
       
  1936                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemDeleted, KErrNone );
  1951                     
  1937                     
  1952                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
  1938                     TRAPD( actionErr, iStats->ActionEndL( KRemoveMediaActionId, KErrNone ) );
  1953                         {
  1939                     if( actionErr == KErrAbort )
  1954                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoDeleted, KErrNone );
  1940                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1955                         }
       
  1956                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1957                         {
       
  1958                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryDeleted, KErrNone );
       
  1959                         }
       
  1960                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1961                         {
       
  1962                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumDeleted, KErrNone );
       
  1963                         }
       
  1964                     }
  1941                     }
  1965                     break;
  1942                     break;
  1966 
  1943 
  1967                 case EMPXItemModified:
  1944                 case EMPXItemModified:
  1968                     {
  1945                     {
  1969                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
  1946                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
  1970                     refreshNeeded = EFalse;
  1947                     refreshNeeded = EFalse;
  1971                     
       
  1972                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
  1948                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
  1973                         {
  1949                         {
  1974                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
  1950                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
  1975                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
  1951                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
  1976                             {
  1952                             {
  1977                             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
  1953                             VCXLOGLO1("CVcxMyVideosCollectionTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
  1978                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
  1954                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
  1979                             refreshNeeded = ETrue;
  1955                             refreshNeeded = ETrue;
  1980                             }
  1956                             }
  1981                         }
  1957                         }
  1982                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
  1958                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemModified, KErrNone );
  1983                         {
       
  1984                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoModified, KErrNone );
       
  1985                         }
       
  1986                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1987                         {
       
  1988                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryModified, KErrNone );
       
  1989                         }
       
  1990                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1991                         {
       
  1992                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumModified, KErrNone );
       
  1993                         }
       
  1994                     }
  1959                     }
  1995                     break;
  1960                     break;
  1996 
  1961 
  1997                 default:
  1962                 default:
  1998                     {
  1963                     {
  2000                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
  1965                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
  2001                     }
  1966                     }
  2002                     break;
  1967                     break;
  2003                 }
  1968                 }
  2004 
  1969 
       
  1970             if( itemId.iId2 == 0 )
       
  1971                 {
       
  1972                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionItemChanged, KErrNone );
       
  1973                 }
       
  1974             else
       
  1975                 {
       
  1976                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrNone );
       
  1977                 }
       
  1978 
  2005             // Refresh if there's need and it's possible.
  1979             // Refresh if there's need and it's possible.
  2006             if( refreshNeeded  )
  1980             if( refreshNeeded  )
  2007                 {
  1981                 {
  2008                 if( IsRefreshing() )
  1982                 if( IsRefreshing() )
  2009                     {
  1983                     {
  2015                 if( !iAutomaticContentRefresh )
  1989                 if( !iAutomaticContentRefresh )
  2016                      {
  1990                      {
  2017                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
  1991                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
  2018                      refreshNeeded = EFalse;
  1992                      refreshNeeded = EFalse;
  2019                      }
  1993                      }
  2020 #if 0
  1994 
  2021                 // No need to refresh if My Videos category is not open.
  1995                 // No need to refresh if My Videos category is not open.
  2022                 if( GetCurrentLevel() != 3 )
  1996                 if( GetCurrentLevel() != 3 )
  2023                     {
  1997                     {
  2024                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
  1998                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
  2025                     refreshNeeded = EFalse;
  1999                     refreshNeeded = EFalse;
  2026                     }
  2000                     }
  2027 #endif
       
  2028 
  2001 
  2029                 if( refreshNeeded )
  2002                 if( refreshNeeded )
  2030                     {
  2003                     {
  2031                     TRAP_IGNORE( RefreshContentsL() );
  2004                     TRAP_IGNORE( RefreshContentsL() );
  2032                     }
  2005                     }
  2049 
  2022 
  2050     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
  2023     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
  2051     }
  2024     }
  2052 
  2025 
  2053 // -----------------------------------------------------------------------------
  2026 // -----------------------------------------------------------------------------
  2054 // CVCXMyVideosCollectionPluginTester::HandleOpenL
  2027 // CVcxMyVideosCollectionTester::HandleOpenL
  2055 // -----------------------------------------------------------------------------
  2028 // -----------------------------------------------------------------------------
  2056 //
  2029 //
  2057 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
  2030 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
  2058                                                 TInt aIndex,
  2031                                                 TInt aIndex,
  2059                                                 TBool aComplete,
  2032                                                 TBool aComplete,
  2063     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aIndex: %d", aIndex);
  2036     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aIndex: %d", aIndex);
  2064     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aComplete: %d", aComplete);
  2037     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aComplete: %d", aComplete);
  2065     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2038     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2066     
  2039     
  2067     SetRefreshStatus( EFalse );
  2040     SetRefreshStatus( EFalse );
       
  2041 
       
  2042     TRAPD( actionErr, iStats->ActionEndL( iCurrentActionId, aError ) );
       
  2043     if( actionErr == KErrAbort )
       
  2044         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2045     
       
  2046     iCurrentActionId = -1;
  2068     
  2047     
  2069     if( aError == KErrNone )
  2048     if( aError == KErrNone )
  2070         {
  2049         {
  2071         // Update current entries
  2050         // Update current entries
  2072         delete iCollectionEntries;
  2051         delete iCollectionEntries;
  2073         iCollectionEntries = NULL;
  2052         iCollectionEntries = NULL;
  2074         iCollectionEntries = CMPXMedia::NewL( aEntries );
  2053         iCollectionEntries = CMPXMedia::NewL( aEntries );
  2075         
  2054         
  2076         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
  2055         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
  2077         
  2056 
  2078         UpdateOwnedMediaArrayL();
  2057         UpdateOwnedMediaArrayL();
  2079 
  2058 
  2080         // There could have been changes to the content during update.
  2059         // There could have been changes to the content during update.
  2081         // Check that entries are up to date.
  2060         // Check that entries are up to date.
  2082 
  2061 
  2083         TBool reRefreshNeeded( EFalse );
  2062         TBool reRefreshNeeded( EFalse );
  2084 
  2063 
  2085         TInt foundInsertedItemCount(0);
  2064         TInt foundInsertedItemCount(0);
  2086 
  2065 
  2087         for( TInt e = 0; e < iMediaCount; e++ )
  2066         for( TInt e=0; e<iMediaCount; e++ )
  2088             {
  2067             {
  2089             CMPXMedia* media = (*iMediaArray)[e];
  2068             CMPXMedia* media = (*iMediaArray)[e];
  2090             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
  2069             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
  2091 
  2070 
  2092             // Check that deleted items are not on the list.
  2071             // Check that deleted items are not on the list.
  2140 
  2119 
  2141     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (entries)");
  2120     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (entries)");
  2142     }
  2121     }
  2143 
  2122 
  2144 // -----------------------------------------------------------------------------
  2123 // -----------------------------------------------------------------------------
  2145 // CVCXMyVideosCollectionPluginTester::HandleOpenL
  2124 // CVcxMyVideosCollectionTester::HandleOpenL
  2146 // -----------------------------------------------------------------------------
  2125 // -----------------------------------------------------------------------------
  2147 //
  2126 //
  2148 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
  2127 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
  2149                                                 TInt aError )
  2128                                                 TInt aError )
  2150     {
  2129     {
  2153     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessagePlaylistOpened, aError );
  2132     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessagePlaylistOpened, aError );
  2154     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
  2133     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
  2155     }
  2134     }
  2156 
  2135 
  2157 // -----------------------------------------------------------------------------
  2136 // -----------------------------------------------------------------------------
  2158 // CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL
  2137 // CVcxMyVideosCollectionTester::HandleCollectionMediaL
  2159 // -----------------------------------------------------------------------------
  2138 // -----------------------------------------------------------------------------
  2160 //
  2139 //
  2161 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
  2140 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
  2162                                         TInt aError)
  2141                                         TInt aError)
  2163     {
  2142     {
  2164     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2143     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2165     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2144     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
       
  2145 
       
  2146     TRAPD( actionErr, iStats->ActionEndL( KGetMediaFullDetailsActionId, aError ) );
       
  2147     if( actionErr == KErrAbort )
       
  2148         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  2166 
  2149 
  2167     if( iGettingFullDetailsForAllMedia )
  2150     if( iGettingFullDetailsForAllMedia )
  2168         {
  2151         {
  2169         iActiveWait->Stop();
  2152         iActiveWait->Stop();
  2170         }
  2153         }
  2177     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMedia, aError );
  2160     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMedia, aError );
  2178     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2161     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2179     }
  2162     }
  2180 
  2163 
  2181 // -----------------------------------------------------------------------------
  2164 // -----------------------------------------------------------------------------
  2182 // CVCXMyVideosCollectionPluginTester::HandleCommandComplete
  2165 // CVcxMyVideosCollectionTester::HandleCommandComplete
  2183 // -----------------------------------------------------------------------------
  2166 // -----------------------------------------------------------------------------
  2184 //
  2167 //
  2185 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
  2168 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
  2186                                                                 TInt aError )
  2169                                                                 TInt aError )
  2187     {
  2170     {
  2204         TUint32 transactionId( 0 );
  2187         TUint32 transactionId( 0 );
  2205         if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) )
  2188         if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) )
  2206             {
  2189             {
  2207             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
  2190             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
  2208             iTransactions->TransactionResponse( transactionId );
  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                 }
  2209             }
  2198             }
  2210         
  2199         
  2211         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
  2200         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
  2212             {
  2201             {
  2213             TInt cmd = 0;
  2202             TInt cmd = 0;
  2270 
  2259 
  2271     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
  2260     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
  2272     }
  2261     }
  2273 
  2262 
  2274 // -----------------------------------------------------------------------------
  2263 // -----------------------------------------------------------------------------
  2275 // CVCXMyVideosCollectionPluginTester::GetMediaCount
  2264 // CVcxMyVideosCollectionTester::GetMediaCount
  2276 // -----------------------------------------------------------------------------
  2265 // -----------------------------------------------------------------------------
  2277 //
  2266 //
  2278 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
  2267 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
  2279     {
  2268     {
  2280     TInt count = 0;
  2269     TInt count = 0;
  2305         CleanupStack::PushL( aMedia );
  2294         CleanupStack::PushL( aMedia );
  2306         }
  2295         }
  2307 
  2296 
  2308     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
  2297     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
  2309     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
  2298     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
  2310 
  2299     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Add media") ) );
       
  2300     iCurrentActionHasResponse = EFalse;
  2311     iCollectionUtility->Collection().CommandL(*cmd);
  2301     iCollectionUtility->Collection().CommandL(*cmd);
  2312 
  2302 
  2313     CleanupStack::PopAndDestroy( cmd );
  2303     CleanupStack::PopAndDestroy( cmd );
  2314 
  2304 
  2315     if( newCreated )
  2305     if( newCreated )
  2332     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
  2322     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
  2333 
  2323 
  2334     PrintMPXMediaL( *aMedia, ETrue );
  2324     PrintMPXMediaL( *aMedia, ETrue );
  2335 
  2325 
  2336     iCollectionUtility->Collection().CommandL( *cmd );
  2326     iCollectionUtility->Collection().CommandL( *cmd );
  2337     
  2327     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Set media") ) );
       
  2328     iCurrentActionHasResponse = EFalse;
  2338     CleanupStack::PopAndDestroy( cmd );
  2329     CleanupStack::PopAndDestroy( cmd );
  2339     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
  2330     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
  2340     }
  2331     }
  2341 
  2332 
  2342 // -----------------------------------------------------------------------------
  2333 // -----------------------------------------------------------------------------
  2343 // CVCXMyVideosCollectionPluginTester::RemoveMediaL
  2334 // CVcxMyVideosCollectionTester::RemoveMediaL
  2344 // -----------------------------------------------------------------------------
  2335 // -----------------------------------------------------------------------------
  2345 //
  2336 //
  2346 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
  2337 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
  2347     {
  2338     {
  2348     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2339     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2352     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2343     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2353 
  2344 
  2354     media = (*iCollectionMediaArray)[realIndex];
  2345     media = (*iCollectionMediaArray)[realIndex];
  2355     
  2346     
  2356     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2347     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2357     iTestUtils->EnsureFileIsNotInUse( localFilePath );
  2348     iTestCommon->EnsureFileIsNotInUse( localFilePath );
  2358     
  2349     
  2359     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
  2350     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
  2360 
  2351 
  2361     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2352     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2362     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
  2353     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
  2363 
  2354 
       
  2355     TRAP_IGNORE( iStats->ActionStartL( KRemoveMediaActionId, _L("Remove media") ) );
       
  2356     iCurrentActionHasResponse = EFalse;
  2364     iCollectionUtility->Collection().CommandL( *cmd );
  2357     iCollectionUtility->Collection().CommandL( *cmd );
  2365 
  2358 
  2366     CleanupStack::PopAndDestroy( cmd );
  2359     CleanupStack::PopAndDestroy( cmd );
  2367 
  2360 
  2368     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2361     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2369     }
  2362     }
  2370 
  2363 
  2371 // -----------------------------------------------------------------------------
  2364 // -----------------------------------------------------------------------------
  2372 // CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL
  2365 // CVcxMyVideosCollectionTester::RemoveMediaByMpxIdL
  2373 // -----------------------------------------------------------------------------
  2366 // -----------------------------------------------------------------------------
  2374 //
  2367 //
  2375 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
  2368 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
  2376     {
  2369     {
  2377     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2370     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2379     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpx ID: %d", aMpxId);
  2372     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpx ID: %d", aMpxId);
  2380 
  2373 
  2381     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2374     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2382     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
  2375     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
  2383 
  2376 
       
  2377     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Remove media") ) );
       
  2378     iCurrentActionHasResponse = EFalse;
  2384     iCollectionUtility->Collection().CommandL( *cmd );
  2379     iCollectionUtility->Collection().CommandL( *cmd );
  2385     CleanupStack::PopAndDestroy( cmd );
  2380     CleanupStack::PopAndDestroy( cmd );
  2386 
  2381 
  2387     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2382     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2388     }
  2383     }
  2389 
  2384 
  2390 // -----------------------------------------------------------------------------
  2385 // -----------------------------------------------------------------------------
  2391 // CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL
  2386 // CVcxMyVideosCollectionTester::GetAllMediaFullDetailsL
  2392 // -----------------------------------------------------------------------------
  2387 // -----------------------------------------------------------------------------
  2393 //
  2388 //
  2394 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
  2389 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
  2395     {
  2390     {
  2396     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2391     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2440 
  2435 
  2441     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2436     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2442     }
  2437     }
  2443 
  2438 
  2444 // -----------------------------------------------------------------------------
  2439 // -----------------------------------------------------------------------------
  2445 // CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL
  2440 // CVcxMyVideosCollectionTester::DeleteAllMediaFilesL
  2446 // -----------------------------------------------------------------------------
  2441 // -----------------------------------------------------------------------------
  2447 //
  2442 //
  2448 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
  2443 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
  2449     {
  2444     {
  2450     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2445     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2480 
  2475 
  2481     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2476     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2482     }
  2477     }
  2483 
  2478 
  2484 // -----------------------------------------------------------------------------
  2479 // -----------------------------------------------------------------------------
  2485 // CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL
  2480 // CVcxMyVideosCollectionTester::DeleteFileOfMediaL
  2486 // -----------------------------------------------------------------------------
  2481 // -----------------------------------------------------------------------------
  2487 //
  2482 //
  2488 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
  2483 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
  2489     {
  2484     {
  2490     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2485     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2497     if( media->IsSupported( KMPXMediaGeneralUri ) )
  2492     if( media->IsSupported( KMPXMediaGeneralUri ) )
  2498         {
  2493         {
  2499         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2494         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2500         VCXLOGLO2("Local file path: %S", &localFilePath);
  2495         VCXLOGLO2("Local file path: %S", &localFilePath);
  2501 
  2496 
  2502         iTestUtils->EnsureFileIsNotInUse( localFilePath );
  2497         iTestCommon->EnsureFileIsNotInUse( localFilePath );
  2503         TInt err = iFs.Delete( localFilePath );
  2498         TInt err = iFs.Delete( localFilePath );
  2504         if( err != KErrNone )
  2499         if( err != KErrNone )
  2505             {
  2500             {
  2506             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
  2501             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
  2507             }
  2502             }
  2513 
  2508 
  2514     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2509     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2515     }
  2510     }
  2516 
  2511 
  2517 // -----------------------------------------------------------------------------
  2512 // -----------------------------------------------------------------------------
  2518 // CVCXMyVideosCollectionPluginTester::GetMediaL
  2513 // CVcxMyVideosCollectionTester::GetMediaL
  2519 // -----------------------------------------------------------------------------
  2514 // -----------------------------------------------------------------------------
  2520 //
  2515 //
  2521 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
  2516 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
  2522     {
  2517     {
  2523     CMPXMedia* media = NULL;
  2518     CMPXMedia* media = NULL;
  2524 
  2519 
  2525     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2520     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2526 
  2521 
  2527     media = (*iCollectionMediaArray)[realIndex];
  2522     media = (*iCollectionMediaArray)[realIndex];
  2528 
       
  2529     return media;
  2523     return media;
  2530     }
  2524     }
  2531 
  2525 
  2532 // -----------------------------------------------------------------------------
  2526 // -----------------------------------------------------------------------------
  2533 // CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL
  2527 // CVcxMyVideosCollectionTester::MoveMediasL
  2534 // -----------------------------------------------------------------------------
       
  2535 //
       
  2536 TInt CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL( const TDesC& aName )
       
  2537     {
       
  2538     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
       
  2539     CMPXMedia* media = NULL;
       
  2540     
       
  2541     TInt index = -1;
       
  2542     
       
  2543     if( !iMediaArray )
       
  2544         {
       
  2545         User::Leave( KErrNotReady );
       
  2546         }
       
  2547     
       
  2548     // From last to first
       
  2549     for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
       
  2550         {
       
  2551         media = (*iMediaArray)[i];
       
  2552         
       
  2553         if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
  2554             {
       
  2555             if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aName ) == KErrNone )
       
  2556                 {
       
  2557                 index = i;
       
  2558                 break;
       
  2559                 }
       
  2560             }
       
  2561         }
       
  2562     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
       
  2563     return index;
       
  2564     }
       
  2565 
       
  2566 // -----------------------------------------------------------------------------
       
  2567 // CVCXMyVideosCollectionPluginTester::MoveMediasL
       
  2568 // -----------------------------------------------------------------------------
  2528 // -----------------------------------------------------------------------------
  2569 //
  2529 //
  2570 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2530 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2571     {
  2531     {
  2572     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2532     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2579     if( medias )
  2539     if( medias )
  2580         {
  2540         {
  2581         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2541         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2582         }
  2542         }
  2583     
  2543     
       
  2544     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Move medias") ) );
       
  2545     iCurrentActionHasResponse = ETrue;
  2584     iCollectionUtility->Collection().CommandL( *cmd );
  2546     iCollectionUtility->Collection().CommandL( *cmd );
  2585 
  2547 
  2586     CleanupStack::PopAndDestroy( cmd );
  2548     CleanupStack::PopAndDestroy( cmd );
  2587     CleanupStack::PopAndDestroy( medias );
  2549     CleanupStack::PopAndDestroy( medias );
  2588 
  2550 
  2590 
  2552 
  2591     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2553     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2592     }
  2554     }
  2593 
  2555 
  2594 // -----------------------------------------------------------------------------
  2556 // -----------------------------------------------------------------------------
  2595 // CVCXMyVideosCollectionPluginTester::CancelMoveL
  2557 // CVcxMyVideosCollectionTester::CancelMoveL
  2596 // -----------------------------------------------------------------------------
  2558 // -----------------------------------------------------------------------------
  2597 //
  2559 //
  2598 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
  2560 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
  2599     {
  2561     {
  2600     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2562     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2601 
  2563 
  2602     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
  2564     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
  2603 
  2565     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel move or copy") ) );
       
  2566     iCurrentActionHasResponse = EFalse;
  2604     iCollectionUtility->Collection().CommandL( *cmd );
  2567     iCollectionUtility->Collection().CommandL( *cmd );
  2605     CleanupStack::PopAndDestroy( cmd );
  2568     CleanupStack::PopAndDestroy( cmd );
  2606     
  2569     
  2607     iCancelRequested = ETrue;
  2570     iCancelRequested = ETrue;
  2608 
  2571 
  2609     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2572     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2610     }
  2573     }
  2611 
  2574 
  2612 // -----------------------------------------------------------------------------
  2575 // -----------------------------------------------------------------------------
  2613 // CVCXMyVideosCollectionPluginTester::CopyMediasL
  2576 // CVcxMyVideosCollectionTester::CopyMediasL
  2614 // -----------------------------------------------------------------------------
  2577 // -----------------------------------------------------------------------------
  2615 //
  2578 //
  2616 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2579 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2617     {
  2580     {
  2618     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2581     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2625     if( medias )
  2588     if( medias )
  2626         {
  2589         {
  2627         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2590         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2628         }
  2591         }
  2629     
  2592     
       
  2593     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Copy medias") ) );
       
  2594     iCurrentActionHasResponse = ETrue;
  2630     iCollectionUtility->Collection().CommandL( *cmd );
  2595     iCollectionUtility->Collection().CommandL( *cmd );
  2631 
  2596 
  2632     CleanupStack::PopAndDestroy( cmd );
  2597     CleanupStack::PopAndDestroy( cmd );
  2633     CleanupStack::PopAndDestroy( medias );
  2598     CleanupStack::PopAndDestroy( medias );
  2634 
  2599 
  2636 
  2601 
  2637     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2602     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2638     }
  2603     }
  2639 
  2604 
  2640 // -----------------------------------------------------------------------------
  2605 // -----------------------------------------------------------------------------
  2641 // CVCXMyVideosCollectionPluginTester::DeleteMediasL
  2606 // CVcxMyVideosCollectionTester::DeleteMediasL
  2642 // -----------------------------------------------------------------------------
  2607 // -----------------------------------------------------------------------------
  2643 //
  2608 //
  2644 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
  2609 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
  2645     {
  2610     {
  2646     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2611     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2651     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2616     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2652     if( medias )
  2617     if( medias )
  2653         {
  2618         {
  2654         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2619         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2655         }
  2620         }
  2656 
  2621     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2622     iCurrentActionHasResponse = ETrue;
  2657     iCollectionUtility->Collection().CommandL( *cmd );
  2623     iCollectionUtility->Collection().CommandL( *cmd );
  2658 
  2624 
  2659     CleanupStack::PopAndDestroy( cmd );
  2625     CleanupStack::PopAndDestroy( cmd );
  2660     CleanupStack::PopAndDestroy( medias );
  2626     CleanupStack::PopAndDestroy( medias );
  2661 
  2627 
  2664     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2630     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2665     }
  2631     }
  2666 
  2632 
  2667 
  2633 
  2668 // -----------------------------------------------------------------------------
  2634 // -----------------------------------------------------------------------------
  2669 // CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL
  2635 // CVcxMyVideosCollectionTester::DeleteMediasByMpxIdsL
  2670 // -----------------------------------------------------------------------------
  2636 // -----------------------------------------------------------------------------
  2671 //
  2637 //
  2672 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
  2638 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
  2673     {
  2639     {
  2674     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2640     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2684     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2650     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2685     if( aMedias )
  2651     if( aMedias )
  2686         {
  2652         {
  2687         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
  2653         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
  2688         }
  2654         }
  2689 
  2655     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2656     iCurrentActionHasResponse = ETrue;
  2690     iCollectionUtility->Collection().CommandL( *cmd );
  2657     iCollectionUtility->Collection().CommandL( *cmd );
  2691 
  2658 
  2692     CleanupStack::PopAndDestroy( cmd );
  2659     CleanupStack::PopAndDestroy( cmd );
  2693 
  2660 
  2694     iActionCount += 2;
  2661     iActionCount += 2;
  2695 
  2662 
  2696     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2663     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2697     }
  2664     }
  2698 
  2665 
  2699 // -----------------------------------------------------------------------------
  2666 // -----------------------------------------------------------------------------
  2700 // CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL
  2667 // CVcxMyVideosCollectionTester::DeleteMediaByMpxIdL
  2701 // -----------------------------------------------------------------------------
  2668 // -----------------------------------------------------------------------------
  2702 //
  2669 //
  2703 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
  2670 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
  2704     {
  2671     {
  2705     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2672     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2720     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2687     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2721     if( medias )
  2688     if( medias )
  2722         {
  2689         {
  2723         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2690         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2724         }
  2691         }
  2725     
  2692     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
       
  2693     iCurrentActionHasResponse = ETrue;
  2726     iCollectionUtility->Collection().CommandL( *cmd );
  2694     iCollectionUtility->Collection().CommandL( *cmd );
  2727 
  2695 
  2728     CleanupStack::PopAndDestroy( cmd );
  2696     CleanupStack::PopAndDestroy( cmd );
  2729     CleanupStack::PopAndDestroy( medias );
  2697     CleanupStack::PopAndDestroy( medias );
  2730 
  2698 
  2732 
  2700 
  2733     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2701     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2734     }
  2702     }
  2735 
  2703 
  2736 // -----------------------------------------------------------------------------
  2704 // -----------------------------------------------------------------------------
  2737 // CVCXMyVideosCollectionPluginTester::CancelDeleteL
  2705 // CVcxMyVideosCollectionTester::CancelDeleteL
  2738 // -----------------------------------------------------------------------------
  2706 // -----------------------------------------------------------------------------
  2739 //
  2707 //
  2740 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
  2708 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
  2741     {
  2709     {
  2742     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2710     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2743 
  2711 
  2744     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
  2712     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
  2745 
  2713     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel delete") ) );
       
  2714     iCurrentActionHasResponse = EFalse;
  2746     iCollectionUtility->Collection().CommandL( *cmd );
  2715     iCollectionUtility->Collection().CommandL( *cmd );
  2747     CleanupStack::PopAndDestroy( cmd );
  2716     CleanupStack::PopAndDestroy( cmd );
  2748 
  2717 
  2749     iCancelRequested = ETrue;
  2718     iCancelRequested = ETrue;
  2750 
  2719 
  2751     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2720     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2752     }
  2721     }
  2753 
  2722 
  2754 // -----------------------------------------------------------------------------
  2723 // -----------------------------------------------------------------------------
  2755 // CVCXMyVideosCollectionPluginTester::CreateAlbumL
  2724 // CVcxMyVideosCollectionTester::SetAutomaticRefresh
  2756 // -----------------------------------------------------------------------------
  2725 // -----------------------------------------------------------------------------
  2757 //
  2726 //
  2758 void CVCXMyVideosCollectionPluginTester::CreateAlbumL( const TDesC& aName, TBool aSync, TBool aInvalidCmd )
  2727 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
  2759     {
  2728     {
  2760     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateAlbumL");
  2729     iAutomaticContentRefresh = aValue;
  2761 
  2730     }
  2762     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddAlbum, aSync );
  2731 
  2763 
  2732 // -----------------------------------------------------------------------------
  2764     if( !aInvalidCmd )
  2733 // CVcxMyVideosCollectionTester::IsRefreshing
  2765         {
  2734 // -----------------------------------------------------------------------------
  2766         cmd->SetTextValueL( KMPXMediaGeneralTitle, aName );
  2735 //
  2767         }
  2736 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
  2768 
  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.");
  2769     iCollectionUtility->Collection().CommandL( *cmd );
  2795     iCollectionUtility->Collection().CommandL( *cmd );
       
  2796 
       
  2797     if( !aMedia )
       
  2798         {
       
  2799         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2800         }
       
  2801 
  2770     CleanupStack::PopAndDestroy( cmd );
  2802     CleanupStack::PopAndDestroy( cmd );
  2771 
  2803 
  2772     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateAlbumL");
  2804     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::StartDownloadL");
  2773     }
  2805     }
  2774 
  2806 
  2775 // -----------------------------------------------------------------------------
  2807 // -----------------------------------------------------------------------------
  2776 // CVCXMyVideosCollectionPluginTester::DeleteAlbumsL
  2808 // CVcxMyVideosCollectionTester::ResumeDownloadL
  2777 // -----------------------------------------------------------------------------
  2809 // -----------------------------------------------------------------------------
  2778 //
  2810 //
  2779 void CVCXMyVideosCollectionPluginTester::DeleteAlbumsL( RArray<TPtrC>& aAlbumNames )
  2811 void CVCXMyVideosCollectionPluginTester::ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
  2780     {
  2812         TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
  2781     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
  2813         CMPXMedia* aMedia
  2782 
  2814         )
  2783     CMPXMediaArray* array = CMPXMediaArray::NewL();
  2815     {
  2784     CleanupStack::PushL( array );
  2816     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
  2785     
  2817 
  2786     for( int i = 0; i < aAlbumNames.Count(); i++ )
  2818     iUpdateDownloads = ETrue;
  2787         {
  2819     iDownloadsStarted = ETrue;
  2788         TMPXItemId albumId;
  2820 
  2789         TRAPD(err, albumId = GetAlbumIdL( aAlbumNames[i] ));
  2821     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
  2790         if( err == KErrNone )
  2822 
  2791             {
  2823     CMPXMedia* startDownloadReq(NULL);
  2792             CMPXMedia* album = CMPXMedia::NewL();
  2824     if( !aMedia )
  2793             CleanupStack::PushL( album );
  2825         {
  2794             album->SetTObjectValueL( KMPXMediaGeneralId, albumId );
  2826         startDownloadReq = CMPXMedia::NewL();
  2795             array->AppendL( *album );
  2827         CleanupStack::PushL( startDownloadReq );
  2796             CleanupStack::PopAndDestroy( album );
  2828         }
  2797             }
  2829     else
  2798         }
  2830         {
  2799     
  2831         startDownloadReq = aMedia;
  2800     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
  2832         }
  2801     
  2833 
  2802     cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
  2834     //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
  2803 
  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;
  2804     iCollectionUtility->Collection().CommandL( *cmd );
  2873     iCollectionUtility->Collection().CommandL( *cmd );
  2805     
  2874 
       
  2875     if( !aMedia )
       
  2876         {
       
  2877         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2878         }
       
  2879 
  2806     CleanupStack::PopAndDestroy( cmd );
  2880     CleanupStack::PopAndDestroy( cmd );
  2807     CleanupStack::PopAndDestroy( array );
  2881 
  2808     
  2882     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
  2809     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
  2883     }
  2810     }
  2884 
  2811 
  2885 // -----------------------------------------------------------------------------
  2812 // -----------------------------------------------------------------------------
  2886 // CVcxMyVideosCollectionTester::ResumeAllDownloadsL
  2813 // CVCXMyVideosCollectionPluginTester::DeleteAllAlbumL
  2887 // -----------------------------------------------------------------------------
  2814 // -----------------------------------------------------------------------------
  2888 //
  2815 //
  2889 void CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL()
  2816 void CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL()
  2890     {
  2817     {
  2891     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
  2818     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
  2892 
  2819 
  2893     iUpdateDownloads = ETrue;
  2820     CMPXMediaArray* array = CMPXMediaArray::NewL();
  2894     iDownloadsStarted = ETrue;
  2821     CleanupStack::PushL( array );
  2895 
  2822     CMPXMedia* album;
  2896     for( TInt i = 0; i < iDlWatcher->GetDownloadCount(); i++ )
  2823     
  2897         {
  2824     for( TInt i = 0; i < iAlbumIds.Count(); i++ )
  2898         CVCXMyVideosTestDownload* dl;
  2825         {
  2899         dl = iDlWatcher->GetDownloadByIndex( i );
  2826         // don't remove photos albums
  2900         if( dl && dl->iState == EVcxMyVideosDlStatePaused )
  2827         if( iAlbumIds[i].iId1 > 2 )
  2901             {
  2828             {
  2902             ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
  2829             album = CMPXMedia::NewL();
  2903             }
  2830             CleanupStack::PushL( album );
  2904         }
  2831             album->SetTObjectValueL( KMPXMediaGeneralId, iAlbumIds[i] );
  2905      
  2832             array->AppendL( *album );
  2906     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
  2833             CleanupStack::PopAndDestroy( album );
  2907     }
  2834             }
  2908 
  2835         }
  2909 // -----------------------------------------------------------------------------
  2836     
  2910 // CVcxMyVideosCollectionTester::CancelDownloadL
  2837     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
  2911 // -----------------------------------------------------------------------------
  2838     
  2912 //
  2839     cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
  2913 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync )
  2840 
  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;
  2841     iCollectionUtility->Collection().CommandL( *cmd );
  2940     iCollectionUtility->Collection().CommandL( *cmd );
  2842     
  2941 
       
  2942     CleanupStack::PopAndDestroy( cancelDownloadReq );
  2843     CleanupStack::PopAndDestroy( cmd );
  2943     CleanupStack::PopAndDestroy( cmd );
  2844     CleanupStack::PopAndDestroy( array );
  2944 
  2845     
  2945     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
  2846     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
  2946     }
  2847     }
  2947 
  2848 
  2948 // -----------------------------------------------------------------------------
  2849 // -----------------------------------------------------------------------------
  2949 // CVcxMyVideosCollectionTester::CancelDownloadL
  2850 // CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL
  2950 // -----------------------------------------------------------------------------
  2851 // -----------------------------------------------------------------------------
  2951 //
  2852 //
  2952 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync )
  2853 void CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
  2953     {
  2854     {
  2954     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL (by IDs)");
  2855     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
  2955 
  2856     
  2956     iUpdateDownloads = ETrue;
  2857     TMPXItemId albumId = GetAlbumIdL( aAlbumName );
  2957 
  2858     
  2958     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
  2859     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
  2959 
  2860     CleanupStack::PushL( medias );
  2960     CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
  2861 
  2961     CleanupStack::PushL( cancelDownloadReq );
  2862     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddToAlbum, EFalse );
  2962 
  2863     if( medias )
  2963     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByIndex(0);
  2864         {
  2964 
  2865         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2965     TPtrC downloadPath( aDownloadPath );
  2866         }
  2966 
  2867 
  2967     if( aMpxId == -1 && dl )
  2868     cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
  2968         {
  2869     
  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;
  2870     iCollectionUtility->Collection().CommandL( *cmd );
  2995     iCollectionUtility->Collection().CommandL( *cmd );
  2871 
  2996 
       
  2997     CleanupStack::PopAndDestroy( cancelDownloadReq );
  2872     CleanupStack::PopAndDestroy( cmd );
  2998     CleanupStack::PopAndDestroy( cmd );
  2873     CleanupStack::PopAndDestroy( medias );
  2999 
  2874     
  3000     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
  2875     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
  3001     }
  2876     }
  3002 
  2877 
  3003 // -----------------------------------------------------------------------------
  2878 // -----------------------------------------------------------------------------
  3004 // CVcxMyVideosCollectionTester::PauseDownloadL
  2879 // CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL
  3005 // -----------------------------------------------------------------------------
  2880 // -----------------------------------------------------------------------------
  3006 //
  2881 //
  3007 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync )
  2882 void CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
  3008     {
  2883     {
  3009     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
  2884     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
  3010 
  2885     
  3011     iUpdateDownloads = ETrue;
  2886     TMPXItemId albumId = GetAlbumIdL( aAlbumName );
  3012 
  2887     
  3013     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
  2888     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
  3014     if( dl )
  2889     CleanupStack::PushL( medias );
  3015         {
  2890 
  3016         dl->iWaitingPause = ETrue;
  2891     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveFromAlbum, EFalse );
  3017         }
  2892     if( medias )
  3018     else
  2893         {
  3019         {
  2894         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  3020         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
  2895         }
  3021         User::Leave( KErrNotFound );
  2896 
  3022         }
  2897     cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
  3023     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
  2898     
  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;
  2899     iCollectionUtility->Collection().CommandL( *cmd );
  3030     iCollectionUtility->Collection().CommandL( *cmd );
  2900 
  3031 
  2901     CleanupStack::PopAndDestroy( cmd );
  3032     CleanupStack::PopAndDestroy( cmd );
  2902     CleanupStack::PopAndDestroy( medias );
  3033     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
  2903     
  3034     }
  2904     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
  3035 
  2905     }
  3036 // -----------------------------------------------------------------------------
  2906 
  3037 // CVcxMyVideosCollectionTester::PauseDownloadL
  2907 // -----------------------------------------------------------------------------
  3038 // -----------------------------------------------------------------------------
  2908 // CVCXMyVideosCollectionPluginTester::RenameAlbumL
  3039 //
  2909 // -----------------------------------------------------------------------------
  3040 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( const TDesC& aUrl, TBool aSync )
  2910 //
  3041     {
  2911 void CVCXMyVideosCollectionPluginTester::RenameAlbumL( const TDesC& aAlbumName, const TDesC& aNewAlbumName )
  3042     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
  2912     {
  3043 
  2913     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RenameAlbumL");
  3044     iUpdateDownloads = ETrue;
  2914     
  3045 
  2915     TMPXItemId itemId = GetAlbumIdL( aAlbumName );
  3046     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
  2916     CMPXMedia *media = CMPXMedia::NewL();
  3047 
  2917     CleanupStack::PushL( media );
  3048     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aUrl );
  2918     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
  3049     if( !dl )
  2919     media->SetTextValueL( KMPXMediaGeneralTitle, aNewAlbumName );
  3050         {
  2920     SetMediaL( media, ETrue );
  3051         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
  2921     CleanupStack::PopAndDestroy( media );
  3052         User::Leave( KErrNotFound );
  2922     
  3053         }
  2923     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RenameAlbumL");
  3054     else
  2924     }
  3055         {
  2925 
  3056         dl->iWaitingPause = ETrue;
  2926 // -----------------------------------------------------------------------------
  3057         }
  2927 // CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh
  3058     
  2928 // -----------------------------------------------------------------------------
  3059 
  2929 //
  3060     cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
  2930 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
  3061 
  2931     {
  3062     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
  2932     iAutomaticContentRefresh = aValue;
  3063     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
  2933     }
  3064     iCurrentActionHasResponse = EFalse;
  2934 
  3065     iCollectionUtility->Collection().CommandL( *cmd );
  2935 // -----------------------------------------------------------------------------
  3066 
  2936 // CVCXMyVideosCollectionPluginTester::IsRefreshing
  3067     CleanupStack::PopAndDestroy( cmd );
  2937 // -----------------------------------------------------------------------------
  3068     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
  2938 //
  3069     }
  2939 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
  3070 
  2940     {
  3071 // -----------------------------------------------------------------------------
  2941     return iRefreshingCollection;
  3072 // CVcxMyVideosCollectionTester::GetDownloadWatcher
  2942     }
  3073 // -----------------------------------------------------------------------------
  2943 
  3074 //
  2944 // -----------------------------------------------------------------------------
  3075 CVCXMyVideosTestDlWatcher* CVCXMyVideosCollectionPluginTester::GetDownloadWatcher()
  2945 // CVCXMyVideosCollectionPluginTester::SetQuietMode
  3076     {
  2946 // -----------------------------------------------------------------------------
  3077     return iDlWatcher;
  2947 //
  3078     }
  2948 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue )
  3079 
  2949     {
  3080 // -----------------------------------------------------------------------------
  2950     iQuietMode = aValue;
  3081 // CVcxMyVideosCollectionTester::GetActiveDownloadCountL
  2951     }
  3082 // -----------------------------------------------------------------------------
  2952 
  3083 //
  2953 // -----------------------------------------------------------------------------
  3084 TInt CVCXMyVideosCollectionPluginTester::GetActiveDownloadCountL()
  2954 // CVCXMyVideosCollectionPluginTester::GetCurrentLevel
  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
  2955 // -----------------------------------------------------------------------------
  3120 // -----------------------------------------------------------------------------
  2956 //
  3121 //
  2957 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
  3122 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
  2958     {
  3123     {
  2959     if ( iCollectionUtility )
  3124     if ( iCollectionUtility )
  2966         }    
  3131         }    
  2967     return KErrNotFound;    
  3132     return KErrNotFound;    
  2968     }
  3133     }
  2969 
  3134 
  2970 // -----------------------------------------------------------------------------
  3135 // -----------------------------------------------------------------------------
  2971 // CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex
  3136 // CVcxMyVideosCollectionTester::GetCurrentOpenLevelIndex
  2972 // -----------------------------------------------------------------------------
  3137 // -----------------------------------------------------------------------------
  2973 //
  3138 //
  2974 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
  3139 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
  2975     {
  3140     {
  2976     return iCurrentOpenedLevelIndex;
  3141     return iCurrentOpenedLevelIndex;
  2977     }
  3142     }
  2978 
  3143 
  2979 // -----------------------------------------------------------------------------
  3144 // -----------------------------------------------------------------------------
  2980 // CVCXMyVideosCollectionPluginTester::GetLastFullMedia
  3145 // CVcxMyVideosCollectionTester::GetLastFullMedia
  2981 // -----------------------------------------------------------------------------
  3146 // -----------------------------------------------------------------------------
  2982 //
  3147 //
  2983 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
  3148 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
  2984     {
  3149     {
  2985     return iFullMedia;
  3150     return iFullMedia;
  2986     }
  3151     }
  2987 
  3152 
  2988 // -----------------------------------------------------------------------------
  3153 // -----------------------------------------------------------------------------
  2989 // CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL
  3154 // CVcxMyVideosCollectionTester::GetMediaIndexInCollectionL
  2990 // -----------------------------------------------------------------------------
  3155 // -----------------------------------------------------------------------------
  2991 //
  3156 //
  2992 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
  3157 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
  2993     {
  3158     {
  2994     if( aIndex >= iMediaArray->Count() )
  3159     if( aIndex >= iMediaArray->Count() )
  3026                         {
  3191                         {
  3027                         foundIndex = i;
  3192                         foundIndex = i;
  3028                         break;
  3193                         break;
  3029                         }
  3194                         }
  3030                     indexOfMediaWithDrive++;
  3195                     indexOfMediaWithDrive++;
  3031                     }
  3196                     }            
  3032                 }
  3197                 }
  3033             }
  3198             }
  3034         }
  3199         }
  3035     
  3200     
  3036     if( foundIndex == KErrNotFound )
  3201     if( foundIndex == KErrNotFound )
  3064     
  3229     
  3065     return foundIndex;
  3230     return foundIndex;
  3066     }
  3231     }
  3067 
  3232 
  3068 // -----------------------------------------------------------------------------
  3233 // -----------------------------------------------------------------------------
  3069 // CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive
  3234 // CVcxMyVideosCollectionTester::GetVideoCountForDrive
  3070 // -----------------------------------------------------------------------------
  3235 // -----------------------------------------------------------------------------
  3071 //
  3236 //
  3072 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
  3237 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
  3073     {  
  3238     {  
  3074     if( !iMediaArray || iMediaArray->Count() == 0 ) return 0;
  3239     if( !iMediaArray || iMediaArray->Count() == 0 ) return 0;
  3093         }
  3258         }
  3094     return count;
  3259     return count;
  3095     }
  3260     }
  3096 
  3261 
  3097 // -----------------------------------------------------------------------------
  3262 // -----------------------------------------------------------------------------
  3098 // CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia
  3263 // CVcxMyVideosCollectionTester::GetAllCollectionMedia
  3099 // -----------------------------------------------------------------------------
  3264 // -----------------------------------------------------------------------------
  3100 //
  3265 //
  3101 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
  3266 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
  3102     {
  3267     {
  3103     return iCollectionMediaArray;
  3268     return iCollectionMediaArray;
  3104     }
  3269     }
  3105 
  3270 
  3106 // -----------------------------------------------------------------------------
  3271 // -----------------------------------------------------------------------------
  3107 // CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL
  3272 // CVcxMyVideosCollectionTester::EnsureMediaFilesAreNotInUseL
  3108 // -----------------------------------------------------------------------------
  3273 // -----------------------------------------------------------------------------
  3109 //
  3274 //
  3110 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
  3275 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
  3111     {
  3276     {
  3112     CMPXMediaArray* iSourceMedias;
  3277     if( iMediaArray->Count() <= 0 ) return; 
  3113     
       
  3114     if( !iUseCopiedMedias )
       
  3115         {
       
  3116         if( !iMediaArray )
       
  3117             {
       
  3118             User::Leave( KErrNotReady );
       
  3119             }
       
  3120         iSourceMedias = iMediaArray;
       
  3121         }
       
  3122     else
       
  3123         {
       
  3124         if( !iMediaArrayCopy )
       
  3125             {
       
  3126             User::Leave( KErrNotReady );
       
  3127             }
       
  3128         iSourceMedias = iMediaArrayCopy;
       
  3129         }
       
  3130     
       
  3131     if( iSourceMedias->Count() <= 0 ) return; 
       
  3132     
  3278     
  3133     TInt retries = 200;
  3279     TInt retries = 200;
  3134     RFile64 file;
  3280     RFile64 file;
  3135     TInt error( KErrNone );
  3281     TInt error( KErrInUse );
       
  3282     
       
  3283     const TInt KEnsureMediasNotInUseID = 1234567;
       
  3284     
       
  3285     TRAP_IGNORE( iStats->ActionStartL( KEnsureMediasNotInUseID, _L("Ensure files.") ) );
  3136     
  3286     
  3137     TBool filesLocked( ETrue );
  3287     TBool filesLocked( ETrue );
  3138     // Check all files that they are not in use, retry few times.
  3288     // Check all files that they are not in use, retry few times.
  3139     while( --retries >= 0 && filesLocked ) 
  3289     while( --retries >= 0 && filesLocked ) 
  3140         {
  3290         {
  3141         filesLocked = EFalse;
  3291         filesLocked = EFalse;
  3142         
  3292         
  3143         for( TInt i=0; i<iSourceMedias->Count(); i++ )
  3293         for( TInt i=0; i<iMediaArray->Count(); i++ )
  3144             {
  3294             {
  3145             CMPXMedia* media = (*iSourceMedias)[i];
  3295             CMPXMedia* media = (*iMediaArray)[i];
  3146             
  3296             
  3147             if( media->IsSupported( KMPXMediaGeneralUri ) )
  3297             if( media->IsSupported( KMPXMediaGeneralUri ) )
  3148                 {
  3298                 {
  3149                 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  3299                 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  3150 
  3300 
  3151                 TInt err = file.Open( iFs, localFilePath, EFileShareExclusive );
  3301                 error = file.Open( iFs, localFilePath, EFileShareExclusive );
  3152                 if( err == KErrInUse || err == KErrLocked )
  3302                 if( error == KErrInUse || error == KErrLocked )
  3153                     {
  3303                     {
  3154                     error = err;
       
  3155                     filesLocked = ETrue;
  3304                     filesLocked = ETrue;
  3156                     User::After( 1000000 * 5 ); // Wait
  3305                     User::After( 1000000 * 5 ); // Wait
  3157                     break;
  3306                     break;
  3158                     }
  3307                     }
  3159                 file.Close();
  3308                 file.Close();
  3160                 }
  3309                 }
  3161             }
  3310             }
  3162         
       
  3163             if(!filesLocked)
       
  3164                 {
       
  3165                 error = KErrNone;
       
  3166                 }
       
  3167         }
  3311         }
  3168 
  3312 
  3169     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
  3313     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
  3170         {
  3314         {
       
  3315         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, error ) );
  3171         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
  3316         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
  3172         User::Leave( error );
  3317         User::Leave( error );
  3173         }
  3318         }
       
  3319     else
       
  3320         {
       
  3321         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, KErrNone ) );
       
  3322         }
  3174     
  3323     
  3175     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
  3324     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
  3176     }
  3325     }
  3177 
  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     }
  3178 //  End of File
  3383 //  End of File