videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp
changeset 15 cf5481c2bc0b
parent 0 96612d01cf9f
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
     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:   ?Description*
    14 * Description:
    15 */
    15 */
    16 
       
    17 
    16 
    18 // INCLUDE FILES
    17 // INCLUDE FILES
    19 #include <e32svr.h>
    18 #include <e32svr.h>
    20 #include <e32std.h>
    19 #include <e32std.h>
    21 #include <StifParser.h>
    20 #include <StifParser.h>
    35 #include <mpxmessagecontainerdefs.h>
    34 #include <mpxmessagecontainerdefs.h>
    36 #include <mpxmediabase.h>
    35 #include <mpxmediabase.h>
    37 #include <mpxcommandgeneraldefs.h>
    36 #include <mpxcommandgeneraldefs.h>
    38 #include <mpxcollectioncommanddefs.h>
    37 #include <mpxcollectioncommanddefs.h>
    39 
    38 
    40 #include "VCXTestCommon.h"
    39 #include "VCXMyVideosTestUtils.h"
    41 #include "VCXTestLog.h"
    40 #include "VCXTestLog.h"
    42 #include "CIptvTestTimer.h"
    41 #include "CVcxTestActiveWait.h"
    43 #include "CIptvTestActiveWait.h"
       
    44 #include "VCXTestStatsKeeper.h"
       
    45 
    42 
    46 #include "VCXMyVideosCollectionPluginTester.h"
    43 #include "VCXMyVideosCollectionPluginTester.h"
    47 #include "VCXMyVideosTestDlWatcher.h"
    44 #include "VCXMyVideosTestUtils.h"
    48 #include "VCXMyVideosTestCommon.h"
    45 #include "VCXMyVideosTestCommon.h"
    49 
    46 
    50 #include "vcxmyvideoscollection.hrh"
    47 #include "vcxmyvideoscollection.hrh"
    51 #include "vcxmyvideosmdsdb.h"
    48 #include "vcxmyvideosmdsdb.h"
    52 #include "vcxmyvideosdefs.h"
    49 #include "vcxmyvideosdefs.h"
    59 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    60 // CVCXMyVideosCollectionPluginTester::NewL
    57 // CVCXMyVideosCollectionPluginTester::NewL
    61 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    62 //
    59 //
    63 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
    60 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
    64             MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
    61             MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXMyVideosTestUtils* aTestUtils )
    65     {
    62     {
    66     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
    63     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
    67     CVCXMyVideosCollectionPluginTester* self = 
    64     CVCXMyVideosCollectionPluginTester* self = 
    68         new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestCommon, aStatsKeeper );
    65         new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestUtils );
    69     CleanupStack::PushL(self);
    66     CleanupStack::PushL(self);
    70     self->ConstructL();
    67     self->ConstructL();
    71     CleanupStack::Pop(self);
    68     CleanupStack::Pop(self);
    72     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::NewL");
    69     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::NewL");
    73     return self;
    70     return self;
    77 // CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester
    74 // CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester
    78 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    79 //
    76 //
    80 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
    77 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
    81         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
    78         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
    82         CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
    79         CVCXMyVideosTestUtils* aTestUtils ) :
    83  : iObserver( aObserver ), iTestCommon( aTestCommon ), iStats( aStatsKeeper )
    80 iObserver( aObserver ), 
       
    81 iTestUtils( aTestUtils ),
       
    82 iCurrentLevelName( NULL ),
       
    83 iAutomaticContentRefresh( ETrue),
       
    84 iCurrentOpenedLevelIndex( -1 )
    84     {
    85     {
    85 
    86 
    86     }
    87     }
    87 
    88 
    88 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    91 //
    92 //
    92 CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester( )
    93 CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester( )
    93     {
    94     {
    94     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
    95     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
    95 
       
    96     if( iProgressTimer )
       
    97         {
       
    98         iProgressTimer->CancelTimer();
       
    99         delete iProgressTimer;
       
   100         iProgressTimer = NULL;
       
   101         }
       
   102 
       
   103     delete iDlWatcher;
       
   104     iDlWatcher = NULL;
       
   105 
    96 
   106     if( iCollectionUtility )
    97     if( iCollectionUtility )
   107         {
    98         {
   108         iCollectionUtility->Close();
    99         iCollectionUtility->Close();
   109         }
   100         }
   119         iOldMediaArray = NULL;
   110         iOldMediaArray = NULL;
   120         }
   111         }
   121 
   112 
   122     if( iMediaArray )
   113     if( iMediaArray )
   123         {
   114         {
       
   115         PrintMediasL( iMediaArray, EFalse, _L("Items") );
   124         iMediaArray->Reset();
   116         iMediaArray->Reset();
   125         delete iMediaArray;
   117         delete iMediaArray;
   126         iMediaArray = NULL;
   118         iMediaArray = NULL;
   127         }
   119         }
   128 
   120 
       
   121     if( iMediaArrayCopy )
       
   122         {
       
   123         iMediaArrayCopy->Reset();
       
   124         delete iMediaArrayCopy;
       
   125         iMediaArrayCopy = NULL;
       
   126         }
       
   127 
   129     iFs.Close();
   128     iFs.Close();
   130 
   129 
   131     if( iActiveWait )
   130     if( iActiveWait )
   132         {
   131         {
   133         iActiveWait->Stop();
   132         iActiveWait->Stop();
   151     
   150     
   152     iTransactions->CheckTransactions();
   151     iTransactions->CheckTransactions();
   153     delete iTransactions;
   152     delete iTransactions;
   154     iTransactions = NULL;
   153     iTransactions = NULL;
   155     
   154     
       
   155     iAlbumNames.ResetAndDestroy();
       
   156     iAlbumNames.Close();
       
   157     
   156     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
   158     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
   157     }
   159     }
   158 
   160 
   159 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   160 // CVCXMyVideosCollectionPluginTester::ConstructL
   162 // CVCXMyVideosCollectionPluginTester::ConstructL
   161 // -----------------------------------------------------------------------------
   163 // -----------------------------------------------------------------------------
   162 //
   164 //
   163 void CVCXMyVideosCollectionPluginTester::ConstructL()
   165 void CVCXMyVideosCollectionPluginTester::ConstructL()
   164     {
   166     {
   165     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
   167     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
   166     iAutomaticContentRefresh = ETrue;
   168     
   167 
   169 
   168     iActiveWait = CIptvTestActiveWait::NewL();
   170     iActiveWait = CVcxTestActiveWait::NewL();
   169     User::LeaveIfError( iFs.Connect() );
   171     User::LeaveIfError( iFs.Connect() );
   170     
   172     
   171     iTransactions = CVCXMyVideosTestTransactions::NewL();
   173     iTransactions = CVCXMyVideosTestTransactions::NewL();
   172     iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
   174     iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
   173     iDlWatcher = CVCXMyVideosTestDlWatcher::NewL( iObserver, iStats );
       
   174     iUpdateDownloads = ETrue;
       
   175     iCurrentOpenedLevelIndex = -1;
       
   176     iProgressTimer = CIptvTestTimer::NewL( *this, 0 );
       
   177     iProgressTimer->After( 1000000 );
       
   178     
   175     
   179     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
   176     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
   180     }
   177     }
   181 
   178 
   182 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   190     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
   187     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
   191     CleanupStack::PushL( path );
   188     CleanupStack::PushL( path );
   192     iCollectionUid = TUid::Uid( aCollectionUid );
   189     iCollectionUid = TUid::Uid( aCollectionUid );
   193     path->AppendL( aCollectionUid );
   190     path->AppendL( aCollectionUid );
   194     
   191     
   195     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionActionId, _L("Open collection") ) );
       
   196     iCurrentActionHasResponse = EFalse;
       
   197     iCurrentActionId = KOpenCollectionActionId;
       
   198     SetRefreshStatus( ETrue );
   192     SetRefreshStatus( ETrue );
   199     
   193     
       
   194     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::OpenCollectionL: collectionId: 0x%x", aCollectionUid);
       
   195     
   200     iCollectionUtility->Collection().OpenL( *path );
   196     iCollectionUtility->Collection().OpenL( *path );
       
   197     iCurrentOpenedLevelIndex = -1;
   201     
   198     
   202     CleanupStack::PopAndDestroy( path );
   199     CleanupStack::PopAndDestroy( path );
   203     
   200     
   204     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL");
   201     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL");
   205     }
   202     }
   206 
   203 
   207 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   208 // CVCXMyVideosCollectionPluginTester::OpenLevelL
   205 // CVCXMyVideosCollectionPluginTester::OpenLevelL
   209 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   210 //
   207 //
   211 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex )
   208 void CVCXMyVideosCollectionPluginTester::OpenLevelL( const TDesC& aLevelName )
   212     {
   209     {
   213     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL");
   210     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL (by name)");
   214 
   211 
   215     if( GetCurrentLevel() != 2 )
   212     if( GetCurrentLevel() != 2 )
   216         {
   213         {
   217         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
   214         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
   218         User::Leave( KErrGeneral );
   215         User::Leave( KErrGeneral );
   219         }
   216         }
   220 
   217 
   221     if( aIndex < 0 || aIndex > iMediaArray->Count() )
   218     CMPXMedia* media;
   222         {
   219 
   223         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error. Index (%d) out of bounds!", aIndex);
   220     int levelIndex(-1);
       
   221     
       
   222     // From last to first
       
   223     for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
       
   224         {
       
   225         media = (*iMediaArray)[i];
       
   226         
       
   227         if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   228             {
       
   229             if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aLevelName ) == KErrNone )
       
   230                 {
       
   231                 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   232                 VCXLOGLO3("CVCXMyVideosCollectionPluginTester::OpenLevelL: mpx id1: %d, id2: %d", itemId.iId1, itemId.iId2);
       
   233                 
       
   234                 levelIndex = i;
       
   235                 delete iCurrentLevelName;
       
   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
       
   250     iCollectionUtility->Collection().OpenL( levelIndex );
       
   251     
       
   252     iCurrentOpenedLevelIndex = levelIndex;
       
   253     SetRefreshStatus( ETrue );
       
   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!");
   224         User::Leave( KErrGeneral );
   269         User::Leave( KErrGeneral );
   225         }
   270         }
   226 
   271 
   227     // Save the name of level
   272     if( aIndex >= 0 || aIndex < iMediaArray->Count() )
   228 
   273         {
   229     CMPXMedia* media(NULL);
   274         CMPXMedia* media(NULL);
   230     media = (*iMediaArray)[aIndex];
   275         media = (*iMediaArray)[aIndex];
   231 
   276 
   232     if( media->IsSupported( KMPXMediaGeneralTitle ) )
   277         if( media->IsSupported( KMPXMediaGeneralTitle ) )
   233         {
   278             {
   234         delete iCurrentLevelName;
   279             delete iCurrentLevelName;
   235         iCurrentLevelName = NULL;
   280             iCurrentLevelName = NULL;
   236         iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
   281             iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
       
   282             }
       
   283         }
       
   284     else
       
   285         {
       
   286         VCXLOGLO1("CVCXMyVideosCollectionPluginTester::OpenLevelL: level index is invalid. Opening..");
   237         }
   287         }
   238 
   288 
   239     // Open the level
   289     // Open the level
   240     TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionLevelActionId, _L("Open level") ) );
       
   241     iCurrentActionHasResponse = EFalse;
       
   242     iCurrentActionId = KOpenCollectionLevelActionId;
       
   243     
       
   244     iCollectionUtility->Collection().OpenL( aIndex );
   290     iCollectionUtility->Collection().OpenL( aIndex );
   245     
   291     
   246     iCurrentOpenedLevelIndex = aIndex;
   292     iCurrentOpenedLevelIndex = aIndex;
   247     SetRefreshStatus( ETrue );
   293     SetRefreshStatus( ETrue );
   248     
   294     
   255 //
   301 //
   256 void CVCXMyVideosCollectionPluginTester::RefreshContentsL()
   302 void CVCXMyVideosCollectionPluginTester::RefreshContentsL()
   257     {
   303     {
   258     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   304     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   259 
   305 
       
   306 #if 0
   260     // No need to refresh if My Videos category is not open.
   307     // No need to refresh if My Videos category is not open.
   261     if( GetCurrentLevel() != 3)
   308     if( GetCurrentLevel() != 3)
   262         {
   309         {
   263         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
   310         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
   264         return;
   311         return;
   265         }
   312         }
       
   313 #endif 
   266 
   314 
   267     // Wait previous refresh to complete.
   315     // Wait previous refresh to complete.
   268     if( IsRefreshing() )
   316     if( IsRefreshing() )
   269         {
   317         {
   270         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
   318         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refresh already active.");
   273 
   321 
   274     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   322     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   275     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
   323     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
   276     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   324     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
   277 
   325 
   278     TRAP_IGNORE( iStats->ActionStartL( KRefreshCollectionActionId, _L("Refreshing collection") ) );
       
   279     iCurrentActionHasResponse = EFalse;
       
   280     iCurrentActionId = KRefreshCollectionActionId;
       
   281     iCollectionUtility->Collection().OpenL();
   326     iCollectionUtility->Collection().OpenL();
   282     SetRefreshStatus( ETrue );
   327     SetRefreshStatus( ETrue );
   283 
   328 
   284     //VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   329     //VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RefreshContentsL");
   285     }
   330     }
   317         {
   362         {
   318         cmd->SetCObjectValueL( KMPXMediaArrayContents, requestedMediaObjects );
   363         cmd->SetCObjectValueL( KMPXMediaArrayContents, requestedMediaObjects );
   319         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
   364         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
   320         }
   365         }
   321 
   366 
   322     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Doing request.");
       
   323     iActionCount++;
   367     iActionCount++;
   324     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Get medias by MPX ID") ) );
       
   325     iCurrentActionHasResponse = ETrue;
       
   326     iCollectionUtility->Collection().CommandL( *cmd );
   368     iCollectionUtility->Collection().CommandL( *cmd );
   327 
   369 
   328     SetRefreshStatus( ETrue );
   370     SetRefreshStatus( ETrue );
   329 
   371 
   330     CleanupStack::PopAndDestroy( requestedMediaObjects );
   372     CleanupStack::PopAndDestroy( requestedMediaObjects );
   354     // Empty attributes to get all the details.
   396     // Empty attributes to get all the details.
   355     CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
   397     CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
   356     CleanupStack::PushL( path );
   398     CleanupStack::PushL( path );
   357     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
   399     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
   358     path->SelectL( realIndex );
   400     path->SelectL( realIndex );
   359     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details") ) );
   401 
   360     iCurrentActionHasResponse = EFalse;
       
   361     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
   402     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
   362     CleanupStack::PopAndDestroy( path );
   403     CleanupStack::PopAndDestroy( path );
   363     CleanupStack::PopAndDestroy( &attrs );
   404     CleanupStack::PopAndDestroy( &attrs );
   364 
   405 
   365     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
   406     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsL");
   385     
   426     
   386     CMPXCommand* cmd( NULL );
   427     CMPXCommand* cmd( NULL );
   387 
   428 
   388     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
   429     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
   389     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
   430     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
   390     TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details by MPX ID") ) );
       
   391     iCollectionUtility->Collection().CommandL( *cmd );
   431     iCollectionUtility->Collection().CommandL( *cmd );
   392     
       
   393     iCurrentActionHasResponse = EFalse;
       
   394     
   432     
   395     CleanupStack::PopAndDestroy( cmd );
   433     CleanupStack::PopAndDestroy( cmd );
   396 
   434 
   397     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
   435     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
   398     }
   436     }
   441                 else
   479                 else
   442                     {
   480                     {
   443                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
   481                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
   444                     }
   482                     }
   445                 }
   483                 }
   446 
   484             
   447             // Update download states and info
   485             UpdateAlbumsListL();
   448             if( GetCurrentLevel() == 3 && iUpdateDownloads && iDownloadsStarted )
       
   449                 {
       
   450                 UpdateDownloadsL( iQuietMode );
       
   451                 }
       
   452             }
   486             }
   453         else
   487         else
   454             {
   488             {
   455             VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL");
   489             VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL");
   456             }
   490             }
   458 
   492 
   459     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL");
   493     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL");
   460     }
   494     }
   461 
   495 
   462 // -----------------------------------------------------------------------------
   496 // -----------------------------------------------------------------------------
   463 // CVcxMyVideosCollectionTester::UpdateDownloadsL
   497 // CVCXMyVideosCollectionPluginTester::PrintMediasL
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 void CVCXMyVideosCollectionPluginTester::UpdateDownloadsL( TBool aQuietMode )
       
   467     {
       
   468     if( !iMediaArray || !iDlWatcher )
       
   469         {
       
   470         return;
       
   471         }
       
   472 
       
   473     if( !aQuietMode )
       
   474         VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateDownloadsL ---------->");
       
   475 
       
   476     iDlWatcher->PrepareCheck();
       
   477 
       
   478     // Print short info about downloads
       
   479     CMPXMedia* media( NULL );
       
   480 
       
   481     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
   482         {
       
   483         media = (*iMediaArray)[i];
       
   484 
       
   485         // If it's download then get info about it and update download watcher.
       
   486         if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
   487             {
       
   488             TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
   489 
       
   490             TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   491 
       
   492             HBufC* titleBuff = NULL;
       
   493             HBufC* urlBuff = NULL;
       
   494             HBufC* pathBuff = NULL;
       
   495 
       
   496             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   497                 {
       
   498                 const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   499                 pathBuff = url.AllocL();
       
   500                 CleanupStack::PushL( pathBuff );
       
   501                 }
       
   502 
       
   503             if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   504                 {
       
   505                 const TDesC& title = media->ValueText( KMPXMediaGeneralTitle );
       
   506                 titleBuff = title.AllocL();
       
   507                 CleanupStack::PushL( titleBuff );
       
   508                 }
       
   509 
       
   510             if( media->IsSupported( KVcxMediaMyVideosRemoteUrl ) )
       
   511                 {
       
   512                 const TDesC& url = media->ValueText( KVcxMediaMyVideosRemoteUrl );
       
   513                 urlBuff = url.AllocL();
       
   514                 CleanupStack::PushL( urlBuff );
       
   515                 }
       
   516 
       
   517             TInt progress = 0;
       
   518             if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
   519                 {
       
   520                 progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
       
   521                 }
       
   522 
       
   523             TUint32 downloadId = 0;
       
   524             if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
       
   525                 {
       
   526                 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
   527                 }
       
   528 
       
   529             TInt downloadError = 0;
       
   530             if( media->IsSupported( KVcxMediaMyVideosDownloadError ) )
       
   531                 {
       
   532                 downloadError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError );
       
   533                 }
       
   534 
       
   535             TInt globalError = 0;
       
   536             if( media->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) )
       
   537                 {
       
   538                 globalError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError );
       
   539                 }
       
   540 
       
   541             CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
       
   542 
       
   543             if( !dl )
       
   544                 {
       
   545                 // Tell dl watcher that dl has started. 
       
   546                 if( state != EVcxMyVideosDlStateNone )
       
   547                     {
       
   548                     iDlWatcher->StartDownloadL( *urlBuff, *pathBuff, downloadId, itemId.iId1, *titleBuff,
       
   549                             static_cast<TVcxMyVideosDownloadState>( state ), progress );
       
   550                     }
       
   551                 }
       
   552             else
       
   553                 {
       
   554                 // Update download. 
       
   555                     iDlWatcher->UpdateDownloadStateL( itemId.iId1, downloadId, 
       
   556                             static_cast<TVcxMyVideosDownloadState>( state ), progress, 
       
   557                             downloadError, globalError );
       
   558                     
       
   559                 }
       
   560             
       
   561             if( state == EVcxMyVideosDlStatePaused && iAutoResume )
       
   562                 {
       
   563                 if( dl && !dl->iWaitingResume )
       
   564                     {
       
   565                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Autoresuming the paused download. ---------->");
       
   566                     ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
       
   567                     iDlWatcher->SetDownloadResumedFlagL( itemId.iId1, downloadId );
       
   568                     dl->iWaitingPause = EFalse;
       
   569                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Resume ok ---------->");
       
   570                     }
       
   571                 }
       
   572 
       
   573             if( urlBuff )
       
   574                 {
       
   575                 CleanupStack::PopAndDestroy( urlBuff );
       
   576                 }
       
   577             if( titleBuff )
       
   578                 {                
       
   579                 CleanupStack::PopAndDestroy( titleBuff );
       
   580                 }
       
   581             if( pathBuff )
       
   582                 {                       
       
   583                 CleanupStack::PopAndDestroy( pathBuff );
       
   584                 }
       
   585             }
       
   586         }
       
   587 
       
   588     if( !aQuietMode )
       
   589         {
       
   590         iDlWatcher->PrintDownloads();
       
   591         }
       
   592 
       
   593     iDlWatcher->FinishCheckL();
       
   594     if( !aQuietMode )
       
   595         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateDownloadsL <----------");
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // CVcxMyVideosCollectionTester::CreateMpxCommandLC
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync )
       
   603     {
       
   604     CMPXCommand* cmd = CMPXCommand::NewL();
       
   605     CleanupStack::PushL( cmd );
       
   606 
       
   607     cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
       
   608     if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   609         {
       
   610         cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
       
   611         }
       
   612 
       
   613     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync );
       
   614 
       
   615     if( !aSync )
       
   616         {
       
   617         // Transaction id is used also tracking stats, so increment for every command.
       
   618         iTransactions->NextTransactionId();
       
   619 
       
   620         if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   621             {
       
   622             cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
       
   623             iTransactions->AddTransactionId( aMyVideosCommandId );
       
   624             }
       
   625         }
       
   626 
       
   627     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
       
   628 
       
   629     return cmd;
       
   630     }
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // CVcxMyVideosCollectionTester::SelectMediasL
       
   634 // -----------------------------------------------------------------------------
       
   635 //
       
   636 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex )
       
   637     {
       
   638     if( aStartIndex == -4 )
       
   639         {
       
   640         VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL");
       
   641         return NULL;
       
   642         }
       
   643 
       
   644     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   645     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex);
       
   646 
       
   647     if( !iMediaArray )
       
   648         {
       
   649         User::Leave( KErrNotReady );
       
   650         }
       
   651 
       
   652     iRequestedMediaIds.Reset();
       
   653 
       
   654     CMPXMediaArray* medias = CMPXMediaArray::NewL();
       
   655 
       
   656     // None
       
   657     if( aStartIndex > aEndIndex )
       
   658         {
       
   659         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos.");
       
   660         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   661         return medias;
       
   662         }
       
   663 
       
   664     CleanupStack::PushL( medias );
       
   665 
       
   666     if( aStartIndex >= 0 )
       
   667         {
       
   668         if( aEndIndex > iMediaArray->Count() )
       
   669             {
       
   670             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   671             User::Leave( KErrArgument );
       
   672             }
       
   673 
       
   674         TInt countToSelect = aEndIndex - aStartIndex;
       
   675         TInt indexOfVideoOnDrive = 0;
       
   676         
       
   677         for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
   678             {
       
   679             CMPXMedia* media = (*iMediaArray)[i];
       
   680 
       
   681             if( media )
       
   682                 {
       
   683                 TBool selectThis( EFalse );
       
   684                 
       
   685                 if( aDriveFilter != -1 )
       
   686                     {
       
   687                     // Drive specified, check path and index of video on the drive.
       
   688                     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
       
   689                     TInt drive( 0 );
       
   690                     User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
       
   691 
       
   692                     if( drive == aDriveFilter )
       
   693                         {
       
   694                         if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex )
       
   695                             {
       
   696                             selectThis = ETrue;
       
   697                             }
       
   698                         indexOfVideoOnDrive++;                        
       
   699                         }
       
   700                     }
       
   701                 else
       
   702                     {
       
   703                     // No drive specified, just index check.
       
   704                     if( i >= aStartIndex && i < aEndIndex )
       
   705                         {
       
   706                         selectThis = ETrue;
       
   707                         }
       
   708                     }
       
   709 
       
   710                 if( selectThis )
       
   711                     {
       
   712                     TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   713                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
   714                     iRequestedMediaIds.Append( mpxId.iId1 );
       
   715                     CMPXMedia* newMedia = CMPXMedia::NewL();
       
   716                     CleanupStack::PushL( newMedia );
       
   717                     newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   718                     newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   719                     medias->AppendL( *newMedia );
       
   720                     CleanupStack::PopAndDestroy( newMedia );
       
   721     
       
   722                     if( medias->Count() >= countToSelect )
       
   723                         {
       
   724                         break;
       
   725                         }
       
   726                     }
       
   727                 }
       
   728             }
       
   729         }
       
   730 
       
   731     // Invalid IDs
       
   732     if( aStartIndex == -1 )
       
   733         {
       
   734         for( TInt i = 0; i < aEndIndex; i++ )
       
   735             {
       
   736             TMPXItemId mpxId;
       
   737             mpxId.iId1 = i+66666;
       
   738             mpxId.iId2 = 0;
       
   739 
       
   740             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1);
       
   741 
       
   742             CMPXMedia* newMedia = CMPXMedia::NewL();
       
   743             CleanupStack::PushL( newMedia );
       
   744             newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   745             newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   746             medias->AppendL( *newMedia );
       
   747             CleanupStack::PopAndDestroy( newMedia );
       
   748             }
       
   749         }
       
   750 
       
   751     // Duplicate IDs
       
   752     if( aStartIndex == -2 )
       
   753         {
       
   754         if( aEndIndex > iMediaArray->Count() )
       
   755             {
       
   756             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   757             User::Leave( KErrArgument );
       
   758             }
       
   759 
       
   760         for( TInt i = 0; i < aEndIndex; i++ )
       
   761             {
       
   762             CMPXMedia* media = (*iMediaArray)[i];
       
   763 
       
   764             if( media )
       
   765                 {
       
   766                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   767 
       
   768                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1);
       
   769                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   770                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   771                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
   772                 CleanupStack::PushL( newMedia );
       
   773                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   774                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   775                 medias->AppendL( *newMedia );
       
   776                 medias->AppendL( *newMedia );
       
   777                 CleanupStack::PopAndDestroy( newMedia );
       
   778                 }
       
   779             }
       
   780         }
       
   781 
       
   782     // Every second ID
       
   783     if( aStartIndex == -3 )
       
   784         {
       
   785         if( aEndIndex > iMediaArray->Count() )
       
   786             {
       
   787             VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
       
   788             User::Leave( KErrArgument );
       
   789             }
       
   790 
       
   791         for( TInt i = 0; i < aEndIndex; i+=2 )
       
   792             {
       
   793             CMPXMedia* media = (*iMediaArray)[i];
       
   794 
       
   795             if( media )
       
   796                 {
       
   797                 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   798 
       
   799                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
       
   800                 iRequestedMediaIds.Append( mpxId.iId1 );
       
   801                 CMPXMedia* newMedia = CMPXMedia::NewL();
       
   802                 CleanupStack::PushL( newMedia );
       
   803                 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
       
   804                 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
       
   805                 medias->AppendL( *newMedia );
       
   806                 CleanupStack::PopAndDestroy( newMedia );
       
   807                 }
       
   808             }
       
   809         }
       
   810 
       
   811     CleanupStack::Pop( medias );
       
   812 
       
   813     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
       
   814     return medias;
       
   815     }
       
   816 
       
   817 // -----------------------------------------------------------------------------
       
   818 // CVcxMyVideosCollectionTester::UpdateOwnedMediaArray
       
   819 // -----------------------------------------------------------------------------
       
   820 //
       
   821 void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL()
       
   822     {
       
   823     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
   824 
       
   825     if ( !iCollectionEntries )
       
   826         {
       
   827         return;
       
   828         }
       
   829 
       
   830     if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) )
       
   831         {
       
   832         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!");
       
   833         User::Leave( KErrNotSupported );
       
   834         }
       
   835 
       
   836     // Get up to date list of all medias in collection.
       
   837     CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   838     
       
   839     // Delete array of old medias
       
   840     if( iOldMediaArray )
       
   841         {
       
   842         iOldMediaArray->Reset();
       
   843         delete iOldMediaArray;
       
   844         }
       
   845 
       
   846     // Update the old array and create new
       
   847     iOldMediaArray = iMediaArray;
       
   848     iMediaArray = CMPXMediaArray::NewL();
       
   849 
       
   850     TBool categories( EFalse );
       
   851     
       
   852     // Make copies of the medias.
       
   853     for( TInt i=0; i<medias->Count(); i++ )
       
   854         {
       
   855         CMPXMedia* media = (*medias)[i];
       
   856         
       
   857         TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   858         if( itemId.iId2 != 0 )
       
   859              {
       
   860              categories = ETrue;
       
   861              }
       
   862         
       
   863         // Ignore medias on ROM.
       
   864         TBool isOnRom( EFalse );
       
   865         
       
   866         if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   867             {
       
   868             const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   869             if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
   870                 {
       
   871                 isOnRom = ETrue;
       
   872                 }
       
   873             }
       
   874         
       
   875         if( !isOnRom )
       
   876             {
       
   877             iMediaArray->AppendL( *media );
       
   878             }
       
   879         }
       
   880     
       
   881     iMediaCount = iMediaArray->Count();
       
   882     
       
   883     // Update count of videos on ROM.
       
   884     if( !categories )
       
   885         {
       
   886         iVideosOnRomCount = 0;
       
   887 
       
   888         for( TInt i=0; i<medias->Count(); i++ )
       
   889             {
       
   890             CMPXMedia* media = (*medias)[i];            
       
   891             
       
   892             if( media->IsSupported( KMPXMediaGeneralUri ) )
       
   893                 {
       
   894                 const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
       
   895                 if( url.FindC( _L("z:" ) ) != KErrNotFound )
       
   896                     {
       
   897                     iVideosOnRomCount++;
       
   898                     }
       
   899                 }
       
   900             }
       
   901 
       
   902             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount);
       
   903         }
       
   904     
       
   905     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // CVcxMyVideosCollectionTester::GetChangedMedias
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias )
       
   913     {
       
   914     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   915 
       
   916     CMPXMediaArray* changedMedias = CMPXMediaArray::NewL();
       
   917 
       
   918     if( !aNewMedias )
       
   919         {
       
   920         VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   921         return changedMedias;
       
   922         }
       
   923 
       
   924     CleanupStack::PushL( changedMedias );
       
   925 
       
   926     for( TInt i=0; i<aNewMedias->Count(); i++ )
       
   927         {
       
   928         CMPXMedia* media(NULL);
       
   929         media = (*aNewMedias)[i];
       
   930         
       
   931         if( !media )
       
   932             {
       
   933             continue;
       
   934             }
       
   935         
       
   936         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   937 
       
   938         CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId );
       
   939 
       
   940         TBool add( EFalse );
       
   941 
       
   942         // It's a new.
       
   943         if( !oldMedia )
       
   944             {
       
   945             add = ETrue;
       
   946             }
       
   947         // Check changes
       
   948         else
       
   949             {
       
   950             const TArray<TMPXAttribute> newAttributes = media->Attributes();
       
   951             const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
       
   952             if( newAttributes.Count() != oldAttributes.Count() )
       
   953                 {
       
   954                 add = ETrue;
       
   955                 }
       
   956             else
       
   957                 {
       
   958                 for( TInt e=0; e<newAttributes.Count(); e++ )
       
   959                     {
       
   960                     if( !oldMedia->Match( *media, newAttributes[e] ) )
       
   961                         {
       
   962                         add = ETrue;
       
   963                         break;
       
   964                         }
       
   965                     }
       
   966                 }
       
   967             }
       
   968 
       
   969         // Add a copy of the media.
       
   970         if( add )
       
   971             {
       
   972             changedMedias->AppendL( *media );
       
   973             }
       
   974         }
       
   975 
       
   976     CleanupStack::Pop( changedMedias );
       
   977 
       
   978     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
       
   979     return changedMedias;
       
   980     }
       
   981 
       
   982 // -----------------------------------------------------------------------------
       
   983 // CVcxMyVideosCollectionTester::GetMediaByMpxId
       
   984 // -----------------------------------------------------------------------------
       
   985 //
       
   986 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId )
       
   987     {
       
   988     if( !aMedias )
       
   989         {
       
   990         return NULL;
       
   991         }
       
   992 
       
   993     for( TInt i=0; i<aMedias->Count(); i++ )
       
   994         {
       
   995         CMPXMedia* media = (*aMedias)[i];
       
   996         TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
   997 
       
   998         if( mpxId == aMpxId )
       
   999             {
       
  1000             return media;
       
  1001             }
       
  1002         }
       
  1003     return NULL;
       
  1004     }
       
  1005 
       
  1006 // -----------------------------------------------------------------------------
       
  1007 // CVcxMyVideosCollectionTester::SetRefreshStatus
       
  1008 // -----------------------------------------------------------------------------
       
  1009 //
       
  1010 void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection )
       
  1011     {
       
  1012     iRefreshingCollection = aRefreshingCollection;
       
  1013     }
       
  1014 
       
  1015 // -----------------------------------------------------------------------------
       
  1016 // CVcxMyVideosCollectionTester::CheckRequestMediaArrayL
       
  1017 // -----------------------------------------------------------------------------
       
  1018 //
       
  1019 void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds )
       
  1020     {
       
  1021     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1022 
       
  1023     // Print requested ids
       
  1024     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:");
       
  1025     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1026         {
       
  1027         VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] );
       
  1028         }
       
  1029 
       
  1030     // Print actual result ids and check for errors
       
  1031     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:");
       
  1032     for( TInt i = 0; i < aRequestResultMedias.Count(); i++ )
       
  1033         {
       
  1034         VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i);
       
  1035         CMPXMedia* media = aRequestResultMedias[i];
       
  1036         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media");
       
  1037         if( media )
       
  1038             {
       
  1039             TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1040             VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 );
       
  1041             if( media->IsSupported( KVcxMediaMyVideosInt32Value ) )
       
  1042                 {
       
  1043                 TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
       
  1044                 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result);
       
  1045                 if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) )
       
  1046                     {
       
  1047                     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result);
       
  1048                     User::Leave( result );
       
  1049                     }
       
  1050                 }
       
  1051             }
       
  1052         else
       
  1053             {
       
  1054             VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i);
       
  1055             }
       
  1056         }
       
  1057 
       
  1058     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks");
       
  1059     
       
  1060     // First check the counts match
       
  1061     if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() )
       
  1062         {
       
  1063         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!");
       
  1064         User::Leave( KErrCorrupt );
       
  1065         }
       
  1066     else
       
  1067     // Check that all requested ids are in the results
       
  1068     for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
       
  1069         {
       
  1070         TMPXItemId mpxId;
       
  1071         mpxId.iId1 = aRequestedMediaIds[i];
       
  1072         mpxId.iId2 = 0;
       
  1073 
       
  1074         TBool found( EFalse );
       
  1075         for( TInt e = 0; e < aRequestResultMedias.Count(); e++ )
       
  1076             {
       
  1077             CMPXMedia* media2 = aRequestResultMedias[e];
       
  1078             if( media2 )
       
  1079                 {
       
  1080                 TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId );
       
  1081 
       
  1082                 if( mpxId == mpxId2 )
       
  1083                     {
       
  1084                     found = ETrue;
       
  1085                     }
       
  1086                 }
       
  1087             }
       
  1088 
       
  1089         if( !found )
       
  1090             {
       
  1091             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!");
       
  1092             User::Leave( KErrCorrupt );
       
  1093             }
       
  1094         }
       
  1095     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
       
  1096     }
       
  1097 
       
  1098 // -----------------------------------------------------------------------------
       
  1099 // CVcxMyVideosCollectionTester::PrintMediasL
       
  1100 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
  1101 //
   499 //
  1102 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
   500 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
  1103     {
   501     {
  1104     if( aMediaArray == NULL )
   502     if( aMediaArray == NULL )
  1135     else
   533     else
  1136         {
   534         {
  1137         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
   535         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
  1138         }
   536         }
  1139 
   537 
  1140     CMPXMedia* media(NULL);
   538     CMPXMedia* media;
  1141     for( TInt i = 0; i < medias->Count(); i++ )
   539     for( TInt i = 0; i < medias->Count(); i++ )
  1142         {
   540         {
  1143         media = (*medias)[i];
   541         media = (*medias)[i];
  1144         if( media )
   542         if( media )
  1145             PrintMPXMediaL( *media, ETrue );
   543             PrintMPXMediaL( *media, ETrue );
  1151         CleanupStack::PopAndDestroy( medias );
   549         CleanupStack::PopAndDestroy( medias );
  1152         }
   550         }
  1153     }
   551     }
  1154 
   552 
  1155 // -----------------------------------------------------------------------------
   553 // -----------------------------------------------------------------------------
  1156 // CVcxMyVideosCollectionTester::PrintMPXMediaL
   554 // CVCXMyVideosCollectionPluginTester::PrintMPXMediaL
  1157 // -----------------------------------------------------------------------------
   555 // -----------------------------------------------------------------------------
  1158 //
   556 //
  1159 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
   557 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
  1160     {
   558     {
  1161     TMPXItemId itemId = *aMedia.Value<TMPXItemId>( KMPXMediaGeneralId );
   559     TMPXItemId itemId = *aMedia.Value<TMPXItemId>( KMPXMediaGeneralId );
  1167             {
   565             {
  1168             title = aMedia.ValueText( KMPXMediaGeneralTitle );
   566             title = aMedia.ValueText( KMPXMediaGeneralTitle );
  1169             }
   567             }
  1170 
   568 
  1171         // Category
   569         // Category
  1172         if( itemId.iId2 != 0 )
   570         if( itemId.iId2 != KVcxMvcMediaTypeVideo )
  1173             {
   571             {
  1174             TInt itemCount(0);
   572             TInt itemCount(0);
  1175             TInt newItemCount(0);
   573             TInt newItemCount(0);
  1176             TBuf<256> newItemName;
   574             TBuf<256> newItemName;
  1177             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
   575             if( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
  1221         return;
   619         return;
  1222         }
   620         }
  1223 
   621 
  1224     // Print all details
   622     // Print all details
  1225 
   623 
  1226     if( itemId.iId2 != 0 )
   624     if( itemId.iId2 == KVcxMvcMediaTypeCategory )
  1227         {
   625         {
  1228         VCXLOGLO1("--------------------------- MEDIA CATEGORY -------------------------------");
   626         VCXLOGLO1("--------------------------- CATEGORY -------------------------------");
  1229         }
   627         }
  1230     else
   628     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
  1231         {
   629         {
  1232         VCXLOGLO1("--------------------------- MEDIA OBJECT -------------------------------");
   630         VCXLOGLO1("--------------------------- Album ----------------------------------");
       
   631         }
       
   632     else if( itemId.iId2 == KVcxMvcMediaTypeVideo )
       
   633         {
       
   634         VCXLOGLO1("--------------------------- VIDEO -------------------------------");
       
   635         }
       
   636     else 
       
   637         {
       
   638         VCXLOGLO1("--------------------------- UNKNOWN! -------------------------------");
  1233         }
   639         }
  1234 
   640 
  1235     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
   641     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
  1236 
   642 
  1237     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
   643     if( aMedia.IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
  1457         VCXLOGLO2("KMPXMediaGeneralPath: %S", &value);
   863         VCXLOGLO2("KMPXMediaGeneralPath: %S", &value);
  1458         }
   864         }
  1459     }
   865     }
  1460 
   866 
  1461 // -----------------------------------------------------------------------------
   867 // -----------------------------------------------------------------------------
  1462 // CVcxMyVideosCollectionTester::HandleCollectionMessage
   868 // CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL
       
   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
  1463 // -----------------------------------------------------------------------------
  1515 // -----------------------------------------------------------------------------
  1464 //
  1516 //
  1465 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1517 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
  1466     {
  1518     {
  1467     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1519     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1530 
  1582 
  1531     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1583     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMessage");
  1532     }
  1584     }
  1533 
  1585 
  1534 // -----------------------------------------------------------------------------
  1586 // -----------------------------------------------------------------------------
  1535 // CVcxMyVideosCollectionTester::HandleSingleCollectionMessage
  1587 // CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage
  1536 // -----------------------------------------------------------------------------
  1588 // -----------------------------------------------------------------------------
  1537 //
  1589 //
  1538 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
  1590 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
  1539     {
  1591     {
  1540     if( !aMessage || !aMessage->IsSupported( KMPXMessageGeneralId ) ) return;
  1592     if( !aMessage || !aMessage->IsSupported( KMPXMessageGeneralId ) ) return;
  1595 
  1647 
  1596                         UpdateOwnedMediaArrayL();
  1648                         UpdateOwnedMediaArrayL();
  1597 
  1649 
  1598                         SetRefreshStatus( EFalse );
  1650                         SetRefreshStatus( EFalse );
  1599 
  1651 
  1600                         // add downloads to the requested ID array always and update downloads too.
       
  1601                         TBool backup = iUpdateDownloads;
       
  1602                         iUpdateDownloads = EFalse;
       
  1603                         ProcessCurrentEntriesL();
  1652                         ProcessCurrentEntriesL();
  1604                         iUpdateDownloads = backup;
       
  1605 
  1653 
  1606                         // Check
  1654                         // Check
  1607                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
  1655                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
  1608                         if( err != KErrNone )
  1656                         if( err != KErrNone )
  1609                             {
  1657                             {
  1610                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
  1658                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, err );
  1611                             }
  1659                             }
  1612 
  1660 
  1613                         // Inform observer
  1661                         // Inform observer
  1614                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
  1662                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
  1615                         
       
  1616                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1617                         if( actionErr == KErrAbort )
       
  1618                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1619                         
  1663                         
  1620                         }
  1664                         }
  1621                         break;
  1665                         break;
  1622 
  1666 
  1623                     // This is received when list is open already and the list contains new items
  1667                     // This is received when list is open already and the list contains new items
  1651                     * it should refetch items when this event arrives.
  1695                     * it should refetch items when this event arrives.
  1652                     */
  1696                     */
  1653                     case KVcxMessageMyVideosListComplete:
  1697                     case KVcxMessageMyVideosListComplete:
  1654                         {
  1698                         {
  1655                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1699                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1656                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete");
  1700                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete ------>");
  1657                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1701                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
  1658                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
  1702                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
  1659                         }
  1703                         }
  1660                         break;
  1704                         break;
  1661 
  1705 
  1670                             break;
  1714                             break;
  1671                             }
  1715                             }
  1672                         iActionCount--;
  1716                         iActionCount--;
  1673 
  1717 
  1674                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
  1718                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
  1675                         
       
  1676                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Move/Copy started.") ) );
       
  1677                         }
  1719                         }
  1678                         break;
  1720                         break;
  1679 
  1721 
  1680                     case KVcxMessageMyVideosMoveResp:
  1722                     case KVcxMessageMyVideosMoveResp:
  1681                         {
  1723                         {
  1707                         if( iCancelRequested )
  1749                         if( iCancelRequested )
  1708                             {
  1750                             {
  1709                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1751                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1710                             iCancelRequested = EFalse;
  1752                             iCancelRequested = EFalse;
  1711                             }                        
  1753                             }                        
  1712 
       
  1713                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1714                         if( actionErr == KErrAbort )
       
  1715                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1716                         
  1754                         
  1717                         CleanupStack::PopAndDestroy( medias );
  1755                         CleanupStack::PopAndDestroy( medias );
  1718                         }
  1756                         }
  1719                         break;
  1757                         break;
  1720 
  1758 
  1748                             {
  1786                             {
  1749                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1787                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1750                             iCancelRequested = EFalse;
  1788                             iCancelRequested = EFalse;
  1751                             }                        
  1789                             }                        
  1752                         
  1790                         
  1753                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1754                         if( actionErr == KErrAbort )
       
  1755                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1756                         
       
  1757                         CleanupStack::PopAndDestroy( medias );
  1791                         CleanupStack::PopAndDestroy( medias );
  1758                         }
  1792                         }
  1759                         break;
  1793                         break;
  1760 
  1794 
  1761                     case KVcxMessageMyVideosDeleteStarted:
  1795                     case KVcxMessageMyVideosDeleteStarted:
  1769                             break;
  1803                             break;
  1770                             }
  1804                             }
  1771                         iActionCount--;
  1805                         iActionCount--;
  1772 
  1806 
  1773                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
  1807                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
  1774                         
       
  1775                         TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Delete started.") ) );
       
  1776                         }
  1808                         }
  1777                         break;
  1809                         break;
  1778 
  1810 
  1779                     case KVcxMessageMyVideosDeleteResp:
  1811                     case KVcxMessageMyVideosDeleteResp:
  1780                         {
  1812                         {
  1806                         if( iCancelRequested )
  1838                         if( iCancelRequested )
  1807                             {
  1839                             {
  1808                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1840                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
  1809                             iCancelRequested = EFalse;
  1841                             iCancelRequested = EFalse;
  1810                             }
  1842                             }
  1811                         
       
  1812                         TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
       
  1813                         if( actionErr == KErrAbort )
       
  1814                             iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  1815                         
  1843                         
  1816                         CleanupStack::PopAndDestroy( medias );
  1844                         CleanupStack::PopAndDestroy( medias );
  1817                         }
  1845                         }
  1818                         break;
  1846                         break;
  1819 
  1847 
  1878             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageIdItemChanged");
  1906             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KMPXMessageGeneralId: KMPXMessageIdItemChanged");
  1879             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
  1907             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------");
  1880 
  1908 
  1881             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
  1909             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
  1882             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
  1910             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
  1883 
  1911        
  1884 #if 1
  1912             if( iWaitingForItemChange && itemId.iId2 == KVcxMvcMediaTypeVideo )
  1885             // Check the IDs for categories
       
  1886             if( itemId.iId2 != 0 && ( itemId.iId1 != KVcxMvcCategoryIdAll &&
       
  1887                     itemId.iId1 != KVcxMvcCategoryIdDownloads &&
       
  1888                     itemId.iId1 != KVcxMvcCategoryIdTvRecordings &&
       
  1889                     itemId.iId1 != KVcxMvcCategoryIdCaptured &&
       
  1890                     itemId.iId1 != KVcxMvcCategoryIdOther ) )
       
  1891                 {
       
  1892                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrCorrupt );
       
  1893                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. INVALID ITEM ID.");
       
  1894                 break;
       
  1895                 }
       
  1896 #endif
       
  1897             // If event if for category, skip it if it's not for the open category.
       
  1898             if( iCurrentOpenedLevelIndex != -1 && itemId.iId2 > 0 && itemId.iId1 != iCurrentOpenedLevelIndex )
       
  1899                 {
       
  1900                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Not for open category. Skip.");
       
  1901                 break;
       
  1902                 }
       
  1903 
       
  1904             if( iWaitingForItemChange && itemId.iId2 == 0 )
       
  1905                 {
  1913                 {
  1906                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
  1914                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
  1907                 iWaitingForItemChange = EFalse;
  1915                 iWaitingForItemChange = EFalse;
  1908                 iActiveWait->Stop();
  1916                 iActiveWait->Stop();
  1909                 }
  1917                 }
  1915                 {
  1923                 {
  1916                 case EMPXItemInserted:
  1924                 case EMPXItemInserted:
  1917                     {
  1925                     {
  1918                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
  1926                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
  1919                     iInsertedItemIds.Append( itemId.iId1 );
  1927                     iInsertedItemIds.Append( itemId.iId1 );
  1920 
       
  1921                     refreshNeeded = ETrue;
  1928                     refreshNeeded = ETrue;
  1922                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemInserted, KErrNone );
       
  1923                     
  1929                     
  1924                     TRAPD( actionErr, iStats->ActionEndL( KSideloadVideoActionId, KErrNone ) );
  1930                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
  1925                     if( actionErr == KErrAbort )
  1931                         {
  1926                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1932                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoInserted, KErrNone );
  1927                     
  1933                         }
       
  1934                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1935                         {
       
  1936                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryInserted, KErrNone );
       
  1937                         }
       
  1938                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1939                         {
       
  1940                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumInserted, KErrNone );
       
  1941                         }
  1928                     }
  1942                     }
  1929                     break;
  1943                     break;
  1930 
  1944 
  1931                 case EMPXItemDeleted:
  1945                 case EMPXItemDeleted:
  1932                     {
  1946                     {
  1933                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
  1947                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
  1934                     iDeletedItemIds.Append( itemId.iId1 );
  1948                     iDeletedItemIds.Append( itemId.iId1 );
  1935                     refreshNeeded = ETrue;
  1949                     refreshNeeded = ETrue;
  1936                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemDeleted, KErrNone );
       
  1937                     
  1950                     
  1938                     TRAPD( actionErr, iStats->ActionEndL( KRemoveMediaActionId, KErrNone ) );
  1951                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
  1939                     if( actionErr == KErrAbort )
  1952                         {
  1940                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
  1953                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoDeleted, KErrNone );
       
  1954                         }
       
  1955                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1956                         {
       
  1957                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryDeleted, KErrNone );
       
  1958                         }
       
  1959                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1960                         {
       
  1961                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumDeleted, KErrNone );
       
  1962                         }
  1941                     }
  1963                     }
  1942                     break;
  1964                     break;
  1943 
  1965 
  1944                 case EMPXItemModified:
  1966                 case EMPXItemModified:
  1945                     {
  1967                     {
  1946                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
  1968                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
  1947                     refreshNeeded = EFalse;
  1969                     refreshNeeded = EFalse;
       
  1970                     
  1948                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
  1971                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
  1949                         {
  1972                         {
  1950                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
  1973                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
  1951                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
  1974                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
  1952                             {
  1975                             {
  1953                             VCXLOGLO1("CVcxMyVideosCollectionTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
  1976                             VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
  1954                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
  1977                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
  1955                             refreshNeeded = ETrue;
  1978                             refreshNeeded = ETrue;
  1956                             }
  1979                             }
  1957                         }
  1980                         }
  1958                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemModified, KErrNone );
  1981                     if( itemId.iId2 == KVcxMvcMediaTypeVideo)
       
  1982                         {
       
  1983                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoModified, KErrNone );
       
  1984                         }
       
  1985                     else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
       
  1986                         {
       
  1987                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryModified, KErrNone );
       
  1988                         }
       
  1989                     else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
       
  1990                         {
       
  1991                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumModified, KErrNone );
       
  1992                         }
  1959                     }
  1993                     }
  1960                     break;
  1994                     break;
  1961 
  1995 
  1962                 default:
  1996                 default:
  1963                     {
  1997                     {
  1965                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
  1999                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMessageError, KErrCorrupt );
  1966                     }
  2000                     }
  1967                     break;
  2001                     break;
  1968                 }
  2002                 }
  1969 
  2003 
  1970             if( itemId.iId2 == 0 )
       
  1971                 {
       
  1972                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionItemChanged, KErrNone );
       
  1973                 }
       
  1974             else
       
  1975                 {
       
  1976                 iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrNone );
       
  1977                 }
       
  1978 
       
  1979             // Refresh if there's need and it's possible.
  2004             // Refresh if there's need and it's possible.
  1980             if( refreshNeeded  )
  2005             if( refreshNeeded  )
  1981                 {
  2006                 {
  1982                 if( IsRefreshing() )
  2007                 if( IsRefreshing() )
  1983                     {
  2008                     {
  1989                 if( !iAutomaticContentRefresh )
  2014                 if( !iAutomaticContentRefresh )
  1990                      {
  2015                      {
  1991                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
  2016                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
  1992                      refreshNeeded = EFalse;
  2017                      refreshNeeded = EFalse;
  1993                      }
  2018                      }
  1994 
  2019 #if 0
  1995                 // No need to refresh if My Videos category is not open.
  2020                 // No need to refresh if My Videos category is not open.
  1996                 if( GetCurrentLevel() != 3 )
  2021                 if( GetCurrentLevel() != 3 )
  1997                     {
  2022                     {
  1998                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
  2023                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
  1999                     refreshNeeded = EFalse;
  2024                     refreshNeeded = EFalse;
  2000                     }
  2025                     }
       
  2026 #endif
  2001 
  2027 
  2002                 if( refreshNeeded )
  2028                 if( refreshNeeded )
  2003                     {
  2029                     {
  2004                     TRAP_IGNORE( RefreshContentsL() );
  2030                     TRAP_IGNORE( RefreshContentsL() );
  2005                     }
  2031                     }
  2022 
  2048 
  2023     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
  2049     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage");
  2024     }
  2050     }
  2025 
  2051 
  2026 // -----------------------------------------------------------------------------
  2052 // -----------------------------------------------------------------------------
  2027 // CVcxMyVideosCollectionTester::HandleOpenL
  2053 // CVCXMyVideosCollectionPluginTester::HandleOpenL
  2028 // -----------------------------------------------------------------------------
  2054 // -----------------------------------------------------------------------------
  2029 //
  2055 //
  2030 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
  2056 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
  2031                                                 TInt aIndex,
  2057                                                 TInt aIndex,
  2032                                                 TBool aComplete,
  2058                                                 TBool aComplete,
  2036     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aIndex: %d", aIndex);
  2062     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aIndex: %d", aIndex);
  2037     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aComplete: %d", aComplete);
  2063     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aComplete: %d", aComplete);
  2038     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2064     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2039     
  2065     
  2040     SetRefreshStatus( EFalse );
  2066     SetRefreshStatus( EFalse );
  2041 
       
  2042     TRAPD( actionErr, iStats->ActionEndL( iCurrentActionId, aError ) );
       
  2043     if( actionErr == KErrAbort )
       
  2044         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2045     
       
  2046     iCurrentActionId = -1;
       
  2047     
  2067     
  2048     if( aError == KErrNone )
  2068     if( aError == KErrNone )
  2049         {
  2069         {
  2050         // Update current entries
  2070         // Update current entries
  2051         delete iCollectionEntries;
  2071         delete iCollectionEntries;
  2052         iCollectionEntries = NULL;
  2072         iCollectionEntries = NULL;
  2053         iCollectionEntries = CMPXMedia::NewL( aEntries );
  2073         iCollectionEntries = CMPXMedia::NewL( aEntries );
  2054         
  2074         
  2055         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
  2075         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
  2056 
  2076         
  2057         UpdateOwnedMediaArrayL();
  2077         UpdateOwnedMediaArrayL();
  2058 
  2078 
  2059         // There could have been changes to the content during update.
  2079         // There could have been changes to the content during update.
  2060         // Check that entries are up to date.
  2080         // Check that entries are up to date.
  2061 
  2081 
  2062         TBool reRefreshNeeded( EFalse );
  2082         TBool reRefreshNeeded( EFalse );
  2063 
  2083 
  2064         TInt foundInsertedItemCount(0);
  2084         TInt foundInsertedItemCount(0);
  2065 
  2085 
  2066         for( TInt e=0; e<iMediaCount; e++ )
  2086         for( TInt e = 0; e < iMediaCount; e++ )
  2067             {
  2087             {
  2068             CMPXMedia* media = (*iMediaArray)[e];
  2088             CMPXMedia* media = (*iMediaArray)[e];
  2069             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
  2089             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
  2070 
  2090 
  2071             // Check that deleted items are not on the list.
  2091             // Check that deleted items are not on the list.
  2119 
  2139 
  2120     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (entries)");
  2140     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (entries)");
  2121     }
  2141     }
  2122 
  2142 
  2123 // -----------------------------------------------------------------------------
  2143 // -----------------------------------------------------------------------------
  2124 // CVcxMyVideosCollectionTester::HandleOpenL
  2144 // CVCXMyVideosCollectionPluginTester::HandleOpenL
  2125 // -----------------------------------------------------------------------------
  2145 // -----------------------------------------------------------------------------
  2126 //
  2146 //
  2127 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
  2147 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
  2128                                                 TInt aError )
  2148                                                 TInt aError )
  2129     {
  2149     {
  2132     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessagePlaylistOpened, aError );
  2152     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessagePlaylistOpened, aError );
  2133     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
  2153     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleOpenL (playlist)");
  2134     }
  2154     }
  2135 
  2155 
  2136 // -----------------------------------------------------------------------------
  2156 // -----------------------------------------------------------------------------
  2137 // CVcxMyVideosCollectionTester::HandleCollectionMediaL
  2157 // CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL
  2138 // -----------------------------------------------------------------------------
  2158 // -----------------------------------------------------------------------------
  2139 //
  2159 //
  2140 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
  2160 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
  2141                                         TInt aError)
  2161                                         TInt aError)
  2142     {
  2162     {
  2143     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2163     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2144     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2164     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
  2145 
       
  2146     TRAPD( actionErr, iStats->ActionEndL( KGetMediaFullDetailsActionId, aError ) );
       
  2147     if( actionErr == KErrAbort )
       
  2148         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2149 
  2165 
  2150     if( iGettingFullDetailsForAllMedia )
  2166     if( iGettingFullDetailsForAllMedia )
  2151         {
  2167         {
  2152         iActiveWait->Stop();
  2168         iActiveWait->Stop();
  2153         }
  2169         }
  2160     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMedia, aError );
  2176     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionMedia, aError );
  2161     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2177     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
  2162     }
  2178     }
  2163 
  2179 
  2164 // -----------------------------------------------------------------------------
  2180 // -----------------------------------------------------------------------------
  2165 // CVcxMyVideosCollectionTester::HandleCommandComplete
  2181 // CVCXMyVideosCollectionPluginTester::HandleCommandComplete
  2166 // -----------------------------------------------------------------------------
  2182 // -----------------------------------------------------------------------------
  2167 //
  2183 //
  2168 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
  2184 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
  2169                                                                 TInt aError )
  2185                                                                 TInt aError )
  2170     {
  2186     {
  2187         TUint32 transactionId( 0 );
  2203         TUint32 transactionId( 0 );
  2188         if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) )
  2204         if( aCommandResult->IsSupported( KVcxMediaMyVideosTransactionId ) )
  2189             {
  2205             {
  2190             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
  2206             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
  2191             iTransactions->TransactionResponse( transactionId );
  2207             iTransactions->TransactionResponse( transactionId );
  2192             if( !iCurrentActionHasResponse )
       
  2193                 {
       
  2194                 TRAPD( actionErr, iStats->ActionEndL( transactionId, aError ) );
       
  2195                 if( actionErr == KErrAbort )
       
  2196                     iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
       
  2197                 }
       
  2198             }
  2208             }
  2199         
  2209         
  2200         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
  2210         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
  2201             {
  2211             {
  2202             TInt cmd = 0;
  2212             TInt cmd = 0;
  2259 
  2269 
  2260     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
  2270     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::HandleCommandComplete");
  2261     }
  2271     }
  2262 
  2272 
  2263 // -----------------------------------------------------------------------------
  2273 // -----------------------------------------------------------------------------
  2264 // CVcxMyVideosCollectionTester::GetMediaCount
  2274 // CVCXMyVideosCollectionPluginTester::GetMediaCount
  2265 // -----------------------------------------------------------------------------
  2275 // -----------------------------------------------------------------------------
  2266 //
  2276 //
  2267 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
  2277 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
  2268     {
  2278     {
  2269     TInt count = 0;
  2279     TInt count = 0;
  2294         CleanupStack::PushL( aMedia );
  2304         CleanupStack::PushL( aMedia );
  2295         }
  2305         }
  2296 
  2306 
  2297     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
  2307     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
  2298     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
  2308     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
  2299     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Add media") ) );
  2309 
  2300     iCurrentActionHasResponse = EFalse;
       
  2301     iCollectionUtility->Collection().CommandL(*cmd);
  2310     iCollectionUtility->Collection().CommandL(*cmd);
  2302 
  2311 
  2303     CleanupStack::PopAndDestroy( cmd );
  2312     CleanupStack::PopAndDestroy( cmd );
  2304 
  2313 
  2305     if( newCreated )
  2314     if( newCreated )
  2322     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
  2331     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
  2323 
  2332 
  2324     PrintMPXMediaL( *aMedia, ETrue );
  2333     PrintMPXMediaL( *aMedia, ETrue );
  2325 
  2334 
  2326     iCollectionUtility->Collection().CommandL( *cmd );
  2335     iCollectionUtility->Collection().CommandL( *cmd );
  2327     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Set media") ) );
  2336     
  2328     iCurrentActionHasResponse = EFalse;
       
  2329     CleanupStack::PopAndDestroy( cmd );
  2337     CleanupStack::PopAndDestroy( cmd );
  2330     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
  2338     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
  2331     }
  2339     }
  2332 
  2340 
  2333 // -----------------------------------------------------------------------------
  2341 // -----------------------------------------------------------------------------
  2334 // CVcxMyVideosCollectionTester::RemoveMediaL
  2342 // CVCXMyVideosCollectionPluginTester::RemoveMediaL
  2335 // -----------------------------------------------------------------------------
  2343 // -----------------------------------------------------------------------------
  2336 //
  2344 //
  2337 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
  2345 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
  2338     {
  2346     {
  2339     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2347     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2343     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2351     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
  2344 
  2352 
  2345     media = (*iCollectionMediaArray)[realIndex];
  2353     media = (*iCollectionMediaArray)[realIndex];
  2346     
  2354     
  2347     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2355     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2348     iTestCommon->EnsureFileIsNotInUse( localFilePath );
  2356     iTestUtils->EnsureFileIsNotInUse( localFilePath );
  2349     
  2357     
  2350     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
  2358     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
  2351 
  2359 
  2352     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2360     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2353     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
  2361     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
  2354 
  2362 
  2355     TRAP_IGNORE( iStats->ActionStartL( KRemoveMediaActionId, _L("Remove media") ) );
       
  2356     iCurrentActionHasResponse = EFalse;
       
  2357     iCollectionUtility->Collection().CommandL( *cmd );
  2363     iCollectionUtility->Collection().CommandL( *cmd );
  2358 
  2364 
  2359     CleanupStack::PopAndDestroy( cmd );
  2365     CleanupStack::PopAndDestroy( cmd );
  2360 
  2366 
  2361     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2367     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaL");
  2362     }
  2368     }
  2363 
  2369 
  2364 // -----------------------------------------------------------------------------
  2370 // -----------------------------------------------------------------------------
  2365 // CVcxMyVideosCollectionTester::RemoveMediaByMpxIdL
  2371 // CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL
  2366 // -----------------------------------------------------------------------------
  2372 // -----------------------------------------------------------------------------
  2367 //
  2373 //
  2368 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
  2374 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
  2369     {
  2375     {
  2370     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2376     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2372     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpx ID: %d", aMpxId);
  2378     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpx ID: %d", aMpxId);
  2373 
  2379 
  2374     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2380     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
  2375     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
  2381     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
  2376 
  2382 
  2377     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Remove media") ) );
       
  2378     iCurrentActionHasResponse = EFalse;
       
  2379     iCollectionUtility->Collection().CommandL( *cmd );
  2383     iCollectionUtility->Collection().CommandL( *cmd );
  2380     CleanupStack::PopAndDestroy( cmd );
  2384     CleanupStack::PopAndDestroy( cmd );
  2381 
  2385 
  2382     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2386     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL");
  2383     }
  2387     }
  2384 
  2388 
  2385 // -----------------------------------------------------------------------------
  2389 // -----------------------------------------------------------------------------
  2386 // CVcxMyVideosCollectionTester::GetAllMediaFullDetailsL
  2390 // CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL
  2387 // -----------------------------------------------------------------------------
  2391 // -----------------------------------------------------------------------------
  2388 //
  2392 //
  2389 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
  2393 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
  2390     {
  2394     {
  2391     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2395     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2435 
  2439 
  2436     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2440     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL");
  2437     }
  2441     }
  2438 
  2442 
  2439 // -----------------------------------------------------------------------------
  2443 // -----------------------------------------------------------------------------
  2440 // CVcxMyVideosCollectionTester::DeleteAllMediaFilesL
  2444 // CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL
  2441 // -----------------------------------------------------------------------------
  2445 // -----------------------------------------------------------------------------
  2442 //
  2446 //
  2443 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
  2447 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
  2444     {
  2448     {
  2445     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2449     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2475 
  2479 
  2476     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2480     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL");
  2477     }
  2481     }
  2478 
  2482 
  2479 // -----------------------------------------------------------------------------
  2483 // -----------------------------------------------------------------------------
  2480 // CVcxMyVideosCollectionTester::DeleteFileOfMediaL
  2484 // CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL
  2481 // -----------------------------------------------------------------------------
  2485 // -----------------------------------------------------------------------------
  2482 //
  2486 //
  2483 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
  2487 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
  2484     {
  2488     {
  2485     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2489     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2492     if( media->IsSupported( KMPXMediaGeneralUri ) )
  2496     if( media->IsSupported( KMPXMediaGeneralUri ) )
  2493         {
  2497         {
  2494         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2498         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
  2495         VCXLOGLO2("Local file path: %S", &localFilePath);
  2499         VCXLOGLO2("Local file path: %S", &localFilePath);
  2496 
  2500 
  2497         iTestCommon->EnsureFileIsNotInUse( localFilePath );
  2501         iTestUtils->EnsureFileIsNotInUse( localFilePath );
  2498         TInt err = iFs.Delete( localFilePath );
  2502         TInt err = iFs.Delete( localFilePath );
  2499         if( err != KErrNone )
  2503         if( err != KErrNone )
  2500             {
  2504             {
  2501             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
  2505             VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: delete error: %d", err);
  2502             }
  2506             }
  2508 
  2512 
  2509     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2513     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL");
  2510     }
  2514     }
  2511 
  2515 
  2512 // -----------------------------------------------------------------------------
  2516 // -----------------------------------------------------------------------------
  2513 // CVcxMyVideosCollectionTester::GetMediaL
  2517 // CVCXMyVideosCollectionPluginTester::GetMediaL
  2514 // -----------------------------------------------------------------------------
  2518 // -----------------------------------------------------------------------------
  2515 //
  2519 //
  2516 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
  2520 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
  2517     {
  2521     {
  2518     CMPXMedia* media = NULL;
  2522     CMPXMedia* media = NULL;
  2522     media = (*iCollectionMediaArray)[realIndex];
  2526     media = (*iCollectionMediaArray)[realIndex];
  2523     return media;
  2527     return media;
  2524     }
  2528     }
  2525 
  2529 
  2526 // -----------------------------------------------------------------------------
  2530 // -----------------------------------------------------------------------------
  2527 // CVcxMyVideosCollectionTester::MoveMediasL
  2531 // CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL
       
  2532 // -----------------------------------------------------------------------------
       
  2533 //
       
  2534 TInt CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL( const TDesC& aName )
       
  2535     {
       
  2536     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
       
  2537     CMPXMedia* media = NULL;
       
  2538     
       
  2539     TInt index = -1;
       
  2540     
       
  2541     if( !iMediaArray )
       
  2542         {
       
  2543         User::Leave( KErrNotReady );
       
  2544         }
       
  2545     
       
  2546     // From last to first
       
  2547     for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
       
  2548         {
       
  2549         media = (*iMediaArray)[i];
       
  2550         
       
  2551         if( media->IsSupported( KMPXMediaGeneralTitle ) )
       
  2552             {
       
  2553             if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aName ) == KErrNone )
       
  2554                 {
       
  2555                 index = i;
       
  2556                 break;
       
  2557                 }
       
  2558             }
       
  2559         }
       
  2560     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
       
  2561     return index;
       
  2562     }
       
  2563 
       
  2564 // -----------------------------------------------------------------------------
       
  2565 // CVCXMyVideosCollectionPluginTester::MoveMediasL
  2528 // -----------------------------------------------------------------------------
  2566 // -----------------------------------------------------------------------------
  2529 //
  2567 //
  2530 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2568 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2531     {
  2569     {
  2532     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2570     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2539     if( medias )
  2577     if( medias )
  2540         {
  2578         {
  2541         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2579         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2542         }
  2580         }
  2543     
  2581     
  2544     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Move medias") ) );
       
  2545     iCurrentActionHasResponse = ETrue;
       
  2546     iCollectionUtility->Collection().CommandL( *cmd );
  2582     iCollectionUtility->Collection().CommandL( *cmd );
  2547 
  2583 
  2548     CleanupStack::PopAndDestroy( cmd );
  2584     CleanupStack::PopAndDestroy( cmd );
  2549     CleanupStack::PopAndDestroy( medias );
  2585     CleanupStack::PopAndDestroy( medias );
  2550 
  2586 
  2552 
  2588 
  2553     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2589     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::MoveMediasL");
  2554     }
  2590     }
  2555 
  2591 
  2556 // -----------------------------------------------------------------------------
  2592 // -----------------------------------------------------------------------------
  2557 // CVcxMyVideosCollectionTester::CancelMoveL
  2593 // CVCXMyVideosCollectionPluginTester::CancelMoveL
  2558 // -----------------------------------------------------------------------------
  2594 // -----------------------------------------------------------------------------
  2559 //
  2595 //
  2560 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
  2596 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
  2561     {
  2597     {
  2562     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2598     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2563 
  2599 
  2564     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
  2600     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
  2565     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel move or copy") ) );
  2601 
  2566     iCurrentActionHasResponse = EFalse;
       
  2567     iCollectionUtility->Collection().CommandL( *cmd );
  2602     iCollectionUtility->Collection().CommandL( *cmd );
  2568     CleanupStack::PopAndDestroy( cmd );
  2603     CleanupStack::PopAndDestroy( cmd );
  2569     
  2604     
  2570     iCancelRequested = ETrue;
  2605     iCancelRequested = ETrue;
  2571 
  2606 
  2572     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2607     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
  2573     }
  2608     }
  2574 
  2609 
  2575 // -----------------------------------------------------------------------------
  2610 // -----------------------------------------------------------------------------
  2576 // CVcxMyVideosCollectionTester::CopyMediasL
  2611 // CVCXMyVideosCollectionPluginTester::CopyMediasL
  2577 // -----------------------------------------------------------------------------
  2612 // -----------------------------------------------------------------------------
  2578 //
  2613 //
  2579 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2614 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
  2580     {
  2615     {
  2581     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2616     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2588     if( medias )
  2623     if( medias )
  2589         {
  2624         {
  2590         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2625         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2591         }
  2626         }
  2592     
  2627     
  2593     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Copy medias") ) );
       
  2594     iCurrentActionHasResponse = ETrue;
       
  2595     iCollectionUtility->Collection().CommandL( *cmd );
  2628     iCollectionUtility->Collection().CommandL( *cmd );
  2596 
  2629 
  2597     CleanupStack::PopAndDestroy( cmd );
  2630     CleanupStack::PopAndDestroy( cmd );
  2598     CleanupStack::PopAndDestroy( medias );
  2631     CleanupStack::PopAndDestroy( medias );
  2599 
  2632 
  2601 
  2634 
  2602     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2635     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CopyMediasL");
  2603     }
  2636     }
  2604 
  2637 
  2605 // -----------------------------------------------------------------------------
  2638 // -----------------------------------------------------------------------------
  2606 // CVcxMyVideosCollectionTester::DeleteMediasL
  2639 // CVCXMyVideosCollectionPluginTester::DeleteMediasL
  2607 // -----------------------------------------------------------------------------
  2640 // -----------------------------------------------------------------------------
  2608 //
  2641 //
  2609 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
  2642 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
  2610     {
  2643     {
  2611     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2644     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2616     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2649     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2617     if( medias )
  2650     if( medias )
  2618         {
  2651         {
  2619         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2652         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2620         }
  2653         }
  2621     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
  2654 
  2622     iCurrentActionHasResponse = ETrue;
       
  2623     iCollectionUtility->Collection().CommandL( *cmd );
  2655     iCollectionUtility->Collection().CommandL( *cmd );
  2624 
  2656 
  2625     CleanupStack::PopAndDestroy( cmd );
  2657     CleanupStack::PopAndDestroy( cmd );
  2626     CleanupStack::PopAndDestroy( medias );
  2658     CleanupStack::PopAndDestroy( medias );
  2627 
  2659 
  2630     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2662     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasL");
  2631     }
  2663     }
  2632 
  2664 
  2633 
  2665 
  2634 // -----------------------------------------------------------------------------
  2666 // -----------------------------------------------------------------------------
  2635 // CVcxMyVideosCollectionTester::DeleteMediasByMpxIdsL
  2667 // CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL
  2636 // -----------------------------------------------------------------------------
  2668 // -----------------------------------------------------------------------------
  2637 //
  2669 //
  2638 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
  2670 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
  2639     {
  2671     {
  2640     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2672     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2650     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2682     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2651     if( aMedias )
  2683     if( aMedias )
  2652         {
  2684         {
  2653         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
  2685         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
  2654         }
  2686         }
  2655     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
  2687 
  2656     iCurrentActionHasResponse = ETrue;
       
  2657     iCollectionUtility->Collection().CommandL( *cmd );
  2688     iCollectionUtility->Collection().CommandL( *cmd );
  2658 
  2689 
  2659     CleanupStack::PopAndDestroy( cmd );
  2690     CleanupStack::PopAndDestroy( cmd );
  2660 
  2691 
  2661     iActionCount += 2;
  2692     iActionCount += 2;
  2662 
  2693 
  2663     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2694     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL");
  2664     }
  2695     }
  2665 
  2696 
  2666 // -----------------------------------------------------------------------------
  2697 // -----------------------------------------------------------------------------
  2667 // CVcxMyVideosCollectionTester::DeleteMediaByMpxIdL
  2698 // CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL
  2668 // -----------------------------------------------------------------------------
  2699 // -----------------------------------------------------------------------------
  2669 //
  2700 //
  2670 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
  2701 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
  2671     {
  2702     {
  2672     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2703     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2687     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2718     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosDelete, aSync );
  2688     if( medias )
  2719     if( medias )
  2689         {
  2720         {
  2690         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2721         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
  2691         }
  2722         }
  2692     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
  2723     
  2693     iCurrentActionHasResponse = ETrue;
       
  2694     iCollectionUtility->Collection().CommandL( *cmd );
  2724     iCollectionUtility->Collection().CommandL( *cmd );
  2695 
  2725 
  2696     CleanupStack::PopAndDestroy( cmd );
  2726     CleanupStack::PopAndDestroy( cmd );
  2697     CleanupStack::PopAndDestroy( medias );
  2727     CleanupStack::PopAndDestroy( medias );
  2698 
  2728 
  2700 
  2730 
  2701     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2731     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL");
  2702     }
  2732     }
  2703 
  2733 
  2704 // -----------------------------------------------------------------------------
  2734 // -----------------------------------------------------------------------------
  2705 // CVcxMyVideosCollectionTester::CancelDeleteL
  2735 // CVCXMyVideosCollectionPluginTester::CancelDeleteL
  2706 // -----------------------------------------------------------------------------
  2736 // -----------------------------------------------------------------------------
  2707 //
  2737 //
  2708 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
  2738 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
  2709     {
  2739     {
  2710     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2740     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2711 
  2741 
  2712     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
  2742     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
  2713     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel delete") ) );
  2743 
  2714     iCurrentActionHasResponse = EFalse;
       
  2715     iCollectionUtility->Collection().CommandL( *cmd );
  2744     iCollectionUtility->Collection().CommandL( *cmd );
  2716     CleanupStack::PopAndDestroy( cmd );
  2745     CleanupStack::PopAndDestroy( cmd );
  2717 
  2746 
  2718     iCancelRequested = ETrue;
  2747     iCancelRequested = ETrue;
  2719 
  2748 
  2720     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2749     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL");
  2721     }
  2750     }
  2722 
  2751 
  2723 // -----------------------------------------------------------------------------
  2752 // -----------------------------------------------------------------------------
  2724 // CVcxMyVideosCollectionTester::SetAutomaticRefresh
  2753 // CVCXMyVideosCollectionPluginTester::CreateAlbumL
       
  2754 // -----------------------------------------------------------------------------
       
  2755 //
       
  2756 void CVCXMyVideosCollectionPluginTester::CreateAlbumL( const TDesC& aName, TBool aSync, TBool aInvalidCmd )
       
  2757     {
       
  2758     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateAlbumL");
       
  2759 
       
  2760     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddAlbum, aSync );
       
  2761 
       
  2762     if( !aInvalidCmd )
       
  2763         {
       
  2764         cmd->SetTextValueL( KMPXMediaGeneralTitle, aName );
       
  2765         }
       
  2766 
       
  2767     iCollectionUtility->Collection().CommandL( *cmd );
       
  2768     CleanupStack::PopAndDestroy( cmd );
       
  2769 
       
  2770     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateAlbumL");
       
  2771     }
       
  2772 
       
  2773 // -----------------------------------------------------------------------------
       
  2774 // CVCXMyVideosCollectionPluginTester::DeleteAlbumsL
       
  2775 // -----------------------------------------------------------------------------
       
  2776 //
       
  2777 void CVCXMyVideosCollectionPluginTester::DeleteAlbumsL( RArray<TPtrC>& aAlbumNames )
       
  2778     {
       
  2779     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
       
  2780 
       
  2781     CMPXMediaArray* array = CMPXMediaArray::NewL();
       
  2782     CleanupStack::PushL( array );
       
  2783     
       
  2784     for( int i = 0; i < aAlbumNames.Count(); i++ )
       
  2785         {
       
  2786         TMPXItemId albumId;
       
  2787         TRAPD(err, albumId = GetAlbumIdL( aAlbumNames[i] ));
       
  2788         if( err == KErrNone )
       
  2789             {
       
  2790             CMPXMedia* album = CMPXMedia::NewL();
       
  2791             CleanupStack::PushL( album );
       
  2792             album->SetTObjectValueL( KMPXMediaGeneralId, albumId );
       
  2793             array->AppendL( *album );
       
  2794             CleanupStack::PopAndDestroy( album );
       
  2795             }
       
  2796         }
       
  2797     
       
  2798     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
       
  2799     
       
  2800     cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
       
  2801 
       
  2802     iCollectionUtility->Collection().CommandL( *cmd );
       
  2803     
       
  2804     CleanupStack::PopAndDestroy( cmd );
       
  2805     CleanupStack::PopAndDestroy( array );
       
  2806     
       
  2807     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
       
  2808     }
       
  2809 
       
  2810 // -----------------------------------------------------------------------------
       
  2811 // CVCXMyVideosCollectionPluginTester::DeleteAllAlbumL
       
  2812 // -----------------------------------------------------------------------------
       
  2813 //
       
  2814 void CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL()
       
  2815     {
       
  2816     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
       
  2817 
       
  2818     CMPXMediaArray* array = CMPXMediaArray::NewL();
       
  2819     CleanupStack::PushL( array );
       
  2820     CMPXMedia* album;
       
  2821     
       
  2822     for( TInt i = 0; i < iAlbumIds.Count(); i++ )
       
  2823         {
       
  2824         // TODO: removing photos albums causes fails in opening albums.  
       
  2825         if( iAlbumIds[i].iId1 > 2 )
       
  2826             {
       
  2827             album = CMPXMedia::NewL();
       
  2828             CleanupStack::PushL( album );
       
  2829             album->SetTObjectValueL( KMPXMediaGeneralId, iAlbumIds[i] );
       
  2830             array->AppendL( *album );
       
  2831             CleanupStack::PopAndDestroy( album );
       
  2832             }
       
  2833         }
       
  2834     
       
  2835     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
       
  2836     
       
  2837     cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
       
  2838 
       
  2839     iCollectionUtility->Collection().CommandL( *cmd );
       
  2840     
       
  2841     CleanupStack::PopAndDestroy( cmd );
       
  2842     CleanupStack::PopAndDestroy( array );
       
  2843     
       
  2844     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
       
  2845     }
       
  2846 
       
  2847 // -----------------------------------------------------------------------------
       
  2848 // CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL
       
  2849 // -----------------------------------------------------------------------------
       
  2850 //
       
  2851 void CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
       
  2852     {
       
  2853     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
       
  2854     
       
  2855     TMPXItemId albumId = GetAlbumIdL( aAlbumName );
       
  2856     
       
  2857     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
       
  2858     CleanupStack::PushL( medias );
       
  2859 
       
  2860     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddToAlbum, EFalse );
       
  2861     if( medias )
       
  2862         {
       
  2863         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2864         }
       
  2865 
       
  2866     cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
       
  2867     
       
  2868     iCollectionUtility->Collection().CommandL( *cmd );
       
  2869 
       
  2870     CleanupStack::PopAndDestroy( cmd );
       
  2871     CleanupStack::PopAndDestroy( medias );
       
  2872     
       
  2873     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
       
  2874     }
       
  2875 
       
  2876 // -----------------------------------------------------------------------------
       
  2877 // CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL
       
  2878 // -----------------------------------------------------------------------------
       
  2879 //
       
  2880 void CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
       
  2881     {
       
  2882     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
       
  2883     
       
  2884     TMPXItemId albumId = GetAlbumIdL( aAlbumName );
       
  2885     
       
  2886     CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
       
  2887     CleanupStack::PushL( medias );
       
  2888 
       
  2889     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveFromAlbum, EFalse );
       
  2890     if( medias )
       
  2891         {
       
  2892         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
       
  2893         }
       
  2894 
       
  2895     cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
       
  2896     
       
  2897     iCollectionUtility->Collection().CommandL( *cmd );
       
  2898 
       
  2899     CleanupStack::PopAndDestroy( cmd );
       
  2900     CleanupStack::PopAndDestroy( medias );
       
  2901     
       
  2902     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
       
  2903     }
       
  2904 
       
  2905 // -----------------------------------------------------------------------------
       
  2906 // CVCXMyVideosCollectionPluginTester::RenameAlbumL
       
  2907 // -----------------------------------------------------------------------------
       
  2908 //
       
  2909 void CVCXMyVideosCollectionPluginTester::RenameAlbumL( const TDesC& aAlbumName, const TDesC& aNewAlbumName )
       
  2910     {
       
  2911     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RenameAlbumL");
       
  2912     
       
  2913     TMPXItemId itemId = GetAlbumIdL( aAlbumName );
       
  2914     CMPXMedia *media = CMPXMedia::NewL();
       
  2915     CleanupStack::PushL( media );
       
  2916     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
       
  2917     media->SetTextValueL( KMPXMediaGeneralTitle, aNewAlbumName );
       
  2918     SetMediaL( media, ETrue );
       
  2919     CleanupStack::PopAndDestroy( media );
       
  2920     
       
  2921     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RenameAlbumL");
       
  2922     }
       
  2923 
       
  2924 // -----------------------------------------------------------------------------
       
  2925 // CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh
  2725 // -----------------------------------------------------------------------------
  2926 // -----------------------------------------------------------------------------
  2726 //
  2927 //
  2727 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
  2928 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
  2728     {
  2929     {
  2729     iAutomaticContentRefresh = aValue;
  2930     iAutomaticContentRefresh = aValue;
  2730     }
  2931     }
  2731 
  2932 
  2732 // -----------------------------------------------------------------------------
  2933 // -----------------------------------------------------------------------------
  2733 // CVcxMyVideosCollectionTester::IsRefreshing
  2934 // CVCXMyVideosCollectionPluginTester::IsRefreshing
  2734 // -----------------------------------------------------------------------------
  2935 // -----------------------------------------------------------------------------
  2735 //
  2936 //
  2736 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
  2937 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
  2737     {
  2938     {
  2738     return iRefreshingCollection;
  2939     return iRefreshingCollection;
  2739     }
  2940     }
  2740 // -----------------------------------------------------------------------------
  2941 
  2741 // CVcxMyVideosCollectionTester::SetQuietMode
  2942 // -----------------------------------------------------------------------------
       
  2943 // CVCXMyVideosCollectionPluginTester::SetQuietMode
  2742 // -----------------------------------------------------------------------------
  2944 // -----------------------------------------------------------------------------
  2743 //
  2945 //
  2744 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue )
  2946 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue )
  2745     {
  2947     {
  2746     iQuietMode = aValue;
  2948     iQuietMode = aValue;
  2747     }
  2949     }
  2748 
  2950 
  2749 // -----------------------------------------------------------------------------
  2951 // -----------------------------------------------------------------------------
  2750 // CVcxMyVideosCollectionTester::StartDownloadL
  2952 // CVCXMyVideosCollectionPluginTester::GetCurrentLevel
  2751 // -----------------------------------------------------------------------------
       
  2752 //
       
  2753 void CVCXMyVideosCollectionPluginTester::StartDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
       
  2754         TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
       
  2755         CMPXMedia* aMedia )
       
  2756     {
       
  2757     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::StartDownloadL");
       
  2758 
       
  2759     iUpdateDownloads = ETrue;
       
  2760     iDownloadsStarted = ETrue;
       
  2761 
       
  2762     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
       
  2763 
       
  2764     CMPXMedia* startDownloadReq(NULL);
       
  2765     if( !aMedia )
       
  2766         {
       
  2767         startDownloadReq = CMPXMedia::NewL();
       
  2768         CleanupStack::PushL( startDownloadReq );
       
  2769         }
       
  2770     else
       
  2771         {
       
  2772         startDownloadReq = aMedia;
       
  2773         }
       
  2774 
       
  2775     //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
       
  2776     startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
       
  2777 
       
  2778     // read only iap needed?
       
  2779     TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
       
  2780 
       
  2781     startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
       
  2782 
       
  2783     VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: UserName: %S, Password: %S.", &aUserName, &aPassword);
       
  2784     
       
  2785     startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
       
  2786     startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
       
  2787     startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
       
  2788     startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
       
  2789     
       
  2790     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
       
  2791 
       
  2792     iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
       
  2793 
       
  2794     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2795     iCollectionUtility->Collection().CommandL( *cmd );
       
  2796 
       
  2797     if( !aMedia )
       
  2798         {
       
  2799         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2800         }
       
  2801 
       
  2802     CleanupStack::PopAndDestroy( cmd );
       
  2803 
       
  2804     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::StartDownloadL");
       
  2805     }
       
  2806 
       
  2807 // -----------------------------------------------------------------------------
       
  2808 // CVcxMyVideosCollectionTester::ResumeDownloadL
       
  2809 // -----------------------------------------------------------------------------
       
  2810 //
       
  2811 void CVCXMyVideosCollectionPluginTester::ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
       
  2812         TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
       
  2813         CMPXMedia* aMedia
       
  2814         )
       
  2815     {
       
  2816     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
       
  2817 
       
  2818     iUpdateDownloads = ETrue;
       
  2819     iDownloadsStarted = ETrue;
       
  2820 
       
  2821     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
       
  2822 
       
  2823     CMPXMedia* startDownloadReq(NULL);
       
  2824     if( !aMedia )
       
  2825         {
       
  2826         startDownloadReq = CMPXMedia::NewL();
       
  2827         CleanupStack::PushL( startDownloadReq );
       
  2828         }
       
  2829     else
       
  2830         {
       
  2831         startDownloadReq = aMedia;
       
  2832         }
       
  2833 
       
  2834     //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
       
  2835     startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
       
  2836 
       
  2837     // read only iap needed?
       
  2838     TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
       
  2839 
       
  2840     startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
       
  2841 
       
  2842     startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
       
  2843     startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
       
  2844     startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
       
  2845     startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
       
  2846 
       
  2847     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
       
  2848 
       
  2849     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
       
  2850     if( dl )
       
  2851         {
       
  2852         startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  2853 
       
  2854         TMPXItemId itemId;
       
  2855         itemId.iId1 = dl->iMpxId;
       
  2856         itemId.iId2 = 0;
       
  2857         startDownloadReq->SetTObjectValueL( KMPXMediaGeneralId, itemId );
       
  2858         
       
  2859         dl->iInformed = EFalse;
       
  2860         dl->iWaitingPause = EFalse;
       
  2861         }
       
  2862     else
       
  2863         {
       
  2864         startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, 6666 );
       
  2865         iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
       
  2866         }
       
  2867 
       
  2868     EnsureMediaFilesAreNotInUseL();
       
  2869     
       
  2870     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2871     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Resume download") ) );
       
  2872     iCurrentActionHasResponse = EFalse;
       
  2873     iCollectionUtility->Collection().CommandL( *cmd );
       
  2874 
       
  2875     if( !aMedia )
       
  2876         {
       
  2877         CleanupStack::PopAndDestroy( startDownloadReq );
       
  2878         }
       
  2879 
       
  2880     CleanupStack::PopAndDestroy( cmd );
       
  2881 
       
  2882     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
       
  2883     }
       
  2884 
       
  2885 // -----------------------------------------------------------------------------
       
  2886 // CVcxMyVideosCollectionTester::ResumeAllDownloadsL
       
  2887 // -----------------------------------------------------------------------------
       
  2888 //
       
  2889 void CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL()
       
  2890     {
       
  2891     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
       
  2892 
       
  2893     iUpdateDownloads = ETrue;
       
  2894     iDownloadsStarted = ETrue;
       
  2895 
       
  2896     for( TInt i = 0; i < iDlWatcher->GetDownloadCount(); i++ )
       
  2897         {
       
  2898         CVCXMyVideosTestDownload* dl;
       
  2899         dl = iDlWatcher->GetDownloadByIndex( i );
       
  2900         if( dl && dl->iState == EVcxMyVideosDlStatePaused )
       
  2901             {
       
  2902             ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
       
  2903             }
       
  2904         }
       
  2905      
       
  2906     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
       
  2907     }
       
  2908 
       
  2909 // -----------------------------------------------------------------------------
       
  2910 // CVcxMyVideosCollectionTester::CancelDownloadL
       
  2911 // -----------------------------------------------------------------------------
       
  2912 //
       
  2913 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync )
       
  2914     {
       
  2915     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  2916 
       
  2917     if( !aDownload )
       
  2918         {
       
  2919         User::Leave( KErrArgument );
       
  2920         }
       
  2921 
       
  2922     iUpdateDownloads = ETrue;
       
  2923 
       
  2924     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
       
  2925 
       
  2926     CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
       
  2927     CleanupStack::PushL( cancelDownloadReq );
       
  2928 
       
  2929     cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aDownload->iMpxId, 0 ) );
       
  2930     cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownload->iDownloadId );
       
  2931     cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, aDownload->iPath->Des() );
       
  2932 
       
  2933     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
       
  2934     
       
  2935     iDlWatcher->CancelDownloadL( aDownload->iServiceId, aDownload->iContentId, *aDownload->iUrl );
       
  2936 
       
  2937     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2938     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
       
  2939     iCurrentActionHasResponse = EFalse;
       
  2940     iCollectionUtility->Collection().CommandL( *cmd );
       
  2941 
       
  2942     CleanupStack::PopAndDestroy( cancelDownloadReq );
       
  2943     CleanupStack::PopAndDestroy( cmd );
       
  2944 
       
  2945     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  2946     }
       
  2947 
       
  2948 // -----------------------------------------------------------------------------
       
  2949 // CVcxMyVideosCollectionTester::CancelDownloadL
       
  2950 // -----------------------------------------------------------------------------
       
  2951 //
       
  2952 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync )
       
  2953     {
       
  2954     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL (by IDs)");
       
  2955 
       
  2956     iUpdateDownloads = ETrue;
       
  2957 
       
  2958     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
       
  2959 
       
  2960     CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
       
  2961     CleanupStack::PushL( cancelDownloadReq );
       
  2962 
       
  2963     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByIndex(0);
       
  2964 
       
  2965     TPtrC downloadPath( aDownloadPath );
       
  2966 
       
  2967     if( aMpxId == -1 && dl )
       
  2968         {
       
  2969         aMpxId = dl->iMpxId;
       
  2970         }
       
  2971 
       
  2972     if( aDownloadId == -1 && dl )
       
  2973         {
       
  2974         aDownloadId = dl->iDownloadId;
       
  2975         }
       
  2976 
       
  2977     if( aDownloadPath == _L("NULL") && dl )
       
  2978         {
       
  2979         downloadPath.Set( *dl->iPath );
       
  2980         }
       
  2981 
       
  2982     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpxId: %d", aMpxId);
       
  2983     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadId: %d", aDownloadId);
       
  2984     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadPath: %S", &aDownloadPath);
       
  2985 
       
  2986     cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aMpxId, 0 ) );
       
  2987     cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownloadId );
       
  2988     cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, downloadPath );
       
  2989 
       
  2990     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
       
  2991 
       
  2992     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  2993     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
       
  2994     iCurrentActionHasResponse = EFalse;
       
  2995     iCollectionUtility->Collection().CommandL( *cmd );
       
  2996 
       
  2997     CleanupStack::PopAndDestroy( cancelDownloadReq );
       
  2998     CleanupStack::PopAndDestroy( cmd );
       
  2999 
       
  3000     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
       
  3001     }
       
  3002 
       
  3003 // -----------------------------------------------------------------------------
       
  3004 // CVcxMyVideosCollectionTester::PauseDownloadL
       
  3005 // -----------------------------------------------------------------------------
       
  3006 //
       
  3007 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync )
       
  3008     {
       
  3009     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3010 
       
  3011     iUpdateDownloads = ETrue;
       
  3012 
       
  3013     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
       
  3014     if( dl )
       
  3015         {
       
  3016         dl->iWaitingPause = ETrue;
       
  3017         }
       
  3018     else
       
  3019         {
       
  3020         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
       
  3021         User::Leave( KErrNotFound );
       
  3022         }
       
  3023     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
       
  3024 
       
  3025     cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  3026 
       
  3027     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  3028     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
       
  3029     iCurrentActionHasResponse = EFalse;
       
  3030     iCollectionUtility->Collection().CommandL( *cmd );
       
  3031 
       
  3032     CleanupStack::PopAndDestroy( cmd );
       
  3033     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3034     }
       
  3035 
       
  3036 // -----------------------------------------------------------------------------
       
  3037 // CVcxMyVideosCollectionTester::PauseDownloadL
       
  3038 // -----------------------------------------------------------------------------
       
  3039 //
       
  3040 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( const TDesC& aUrl, TBool aSync )
       
  3041     {
       
  3042     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3043 
       
  3044     iUpdateDownloads = ETrue;
       
  3045 
       
  3046     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
       
  3047 
       
  3048     CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aUrl );
       
  3049     if( !dl )
       
  3050         {
       
  3051         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
       
  3052         User::Leave( KErrNotFound );
       
  3053         }
       
  3054     else
       
  3055         {
       
  3056         dl->iWaitingPause = ETrue;
       
  3057         }
       
  3058     
       
  3059 
       
  3060     cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
       
  3061 
       
  3062     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
       
  3063     TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
       
  3064     iCurrentActionHasResponse = EFalse;
       
  3065     iCollectionUtility->Collection().CommandL( *cmd );
       
  3066 
       
  3067     CleanupStack::PopAndDestroy( cmd );
       
  3068     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
       
  3069     }
       
  3070 
       
  3071 // -----------------------------------------------------------------------------
       
  3072 // CVcxMyVideosCollectionTester::GetDownloadWatcher
       
  3073 // -----------------------------------------------------------------------------
       
  3074 //
       
  3075 CVCXMyVideosTestDlWatcher* CVCXMyVideosCollectionPluginTester::GetDownloadWatcher()
       
  3076     {
       
  3077     return iDlWatcher;
       
  3078     }
       
  3079 
       
  3080 // -----------------------------------------------------------------------------
       
  3081 // CVcxMyVideosCollectionTester::GetActiveDownloadCountL
       
  3082 // -----------------------------------------------------------------------------
       
  3083 //
       
  3084 TInt CVCXMyVideosCollectionPluginTester::GetActiveDownloadCountL()
       
  3085     {
       
  3086     TInt count = 0;
       
  3087 
       
  3088     CMPXMedia* media ( NULL );
       
  3089     for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  3090         {
       
  3091         media = (*iMediaArray)[i];
       
  3092 
       
  3093         if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
  3094             {
       
  3095             TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
  3096 
       
  3097             if( state == EVcxMyVideosDlStateDownloading || ( state == EVcxMyVideosDlStatePaused && iAutoResume ) )
       
  3098                 {
       
  3099                 count++;
       
  3100                 }
       
  3101             }
       
  3102         }
       
  3103 
       
  3104     VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester:: Active downloads: %d", count);
       
  3105 
       
  3106     return count;
       
  3107     }
       
  3108 
       
  3109 // -----------------------------------------------------------------------------
       
  3110 // CVcxMyVideosCollectionTester::SetAutoResume
       
  3111 // -----------------------------------------------------------------------------
       
  3112 //
       
  3113 void CVCXMyVideosCollectionPluginTester::SetAutoResume( TBool aValue )
       
  3114     {
       
  3115     iAutoResume = aValue;
       
  3116     }
       
  3117 
       
  3118 // -----------------------------------------------------------------------------
       
  3119 // CVcxMyVideosCollectionTester::GetCurrentLevel
       
  3120 // -----------------------------------------------------------------------------
  2953 // -----------------------------------------------------------------------------
  3121 //
  2954 //
  3122 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
  2955 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
  3123     {
  2956     {
  3124     if ( iCollectionUtility )
  2957     if ( iCollectionUtility )
  3131         }    
  2964         }    
  3132     return KErrNotFound;    
  2965     return KErrNotFound;    
  3133     }
  2966     }
  3134 
  2967 
  3135 // -----------------------------------------------------------------------------
  2968 // -----------------------------------------------------------------------------
  3136 // CVcxMyVideosCollectionTester::GetCurrentOpenLevelIndex
  2969 // CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex
  3137 // -----------------------------------------------------------------------------
  2970 // -----------------------------------------------------------------------------
  3138 //
  2971 //
  3139 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
  2972 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
  3140     {
  2973     {
  3141     return iCurrentOpenedLevelIndex;
  2974     return iCurrentOpenedLevelIndex;
  3142     }
  2975     }
  3143 
  2976 
  3144 // -----------------------------------------------------------------------------
  2977 // -----------------------------------------------------------------------------
  3145 // CVcxMyVideosCollectionTester::GetLastFullMedia
  2978 // CVCXMyVideosCollectionPluginTester::GetLastFullMedia
  3146 // -----------------------------------------------------------------------------
  2979 // -----------------------------------------------------------------------------
  3147 //
  2980 //
  3148 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
  2981 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
  3149     {
  2982     {
  3150     return iFullMedia;
  2983     return iFullMedia;
  3151     }
  2984     }
  3152 
  2985 
  3153 // -----------------------------------------------------------------------------
  2986 // -----------------------------------------------------------------------------
  3154 // CVcxMyVideosCollectionTester::GetMediaIndexInCollectionL
  2987 // CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL
  3155 // -----------------------------------------------------------------------------
  2988 // -----------------------------------------------------------------------------
  3156 //
  2989 //
  3157 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
  2990 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
  3158     {
  2991     {
  3159     if( aIndex >= iMediaArray->Count() )
  2992     if( aIndex >= iMediaArray->Count() )
  3229     
  3062     
  3230     return foundIndex;
  3063     return foundIndex;
  3231     }
  3064     }
  3232 
  3065 
  3233 // -----------------------------------------------------------------------------
  3066 // -----------------------------------------------------------------------------
  3234 // CVcxMyVideosCollectionTester::GetVideoCountForDrive
  3067 // CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive
  3235 // -----------------------------------------------------------------------------
  3068 // -----------------------------------------------------------------------------
  3236 //
  3069 //
  3237 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
  3070 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
  3238     {  
  3071     {  
  3239     if( !iMediaArray || iMediaArray->Count() == 0 ) return 0;
  3072     if( !iMediaArray || iMediaArray->Count() == 0 ) return 0;
  3258         }
  3091         }
  3259     return count;
  3092     return count;
  3260     }
  3093     }
  3261 
  3094 
  3262 // -----------------------------------------------------------------------------
  3095 // -----------------------------------------------------------------------------
  3263 // CVcxMyVideosCollectionTester::GetAllCollectionMedia
  3096 // CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia
  3264 // -----------------------------------------------------------------------------
  3097 // -----------------------------------------------------------------------------
  3265 //
  3098 //
  3266 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
  3099 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
  3267     {
  3100     {
  3268     return iCollectionMediaArray;
  3101     return iCollectionMediaArray;
  3269     }
  3102     }
  3270 
  3103 
  3271 // -----------------------------------------------------------------------------
  3104 // -----------------------------------------------------------------------------
  3272 // CVcxMyVideosCollectionTester::EnsureMediaFilesAreNotInUseL
  3105 // CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL
  3273 // -----------------------------------------------------------------------------
  3106 // -----------------------------------------------------------------------------
  3274 //
  3107 //
  3275 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
  3108 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
  3276     {
  3109     {
  3277     if( iMediaArray->Count() <= 0 ) return; 
  3110     if( iMediaArray->Count() <= 0 ) return; 
  3279     TInt retries = 200;
  3112     TInt retries = 200;
  3280     RFile64 file;
  3113     RFile64 file;
  3281     TInt error( KErrInUse );
  3114     TInt error( KErrInUse );
  3282     
  3115     
  3283     const TInt KEnsureMediasNotInUseID = 1234567;
  3116     const TInt KEnsureMediasNotInUseID = 1234567;
  3284     
       
  3285     TRAP_IGNORE( iStats->ActionStartL( KEnsureMediasNotInUseID, _L("Ensure files.") ) );
       
  3286     
  3117     
  3287     TBool filesLocked( ETrue );
  3118     TBool filesLocked( ETrue );
  3288     // Check all files that they are not in use, retry few times.
  3119     // Check all files that they are not in use, retry few times.
  3289     while( --retries >= 0 && filesLocked ) 
  3120     while( --retries >= 0 && filesLocked ) 
  3290         {
  3121         {
  3310             }
  3141             }
  3311         }
  3142         }
  3312 
  3143 
  3313     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
  3144     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
  3314         {
  3145         {
  3315         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, error ) );
       
  3316         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
  3146         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
  3317         User::Leave( error );
  3147         User::Leave( error );
  3318         }
  3148         }
  3319     else
       
  3320         {
       
  3321         TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, KErrNone ) );
       
  3322         }
       
  3323     
  3149     
  3324     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
  3150     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
  3325     }
  3151     }
  3326     
  3152 
  3327 // -----------------------------------------------------------------------------
       
  3328 // CVCXMyVideosCollectionPluginTester::TimerComplete
       
  3329 // -----------------------------------------------------------------------------
       
  3330 //
       
  3331 void CVCXMyVideosCollectionPluginTester::TimerComplete( TInt /* aTimerId */, TInt /* aError */ )
       
  3332     {
       
  3333     if( iProgressTimer )
       
  3334         {
       
  3335         iProgressTimer->After( 1000000 );
       
  3336         }
       
  3337 
       
  3338     if( !iMediaArray || !iDlWatcher )
       
  3339        {
       
  3340        return;
       
  3341        }
       
  3342 
       
  3343     if( iDownloadsStarted && iUpdateDownloads && GetCurrentLevel() == 3 )
       
  3344         {
       
  3345        // Print short info about downloads
       
  3346        CMPXMedia* media( NULL );
       
  3347 
       
  3348        VCXLOGLO2("CVCXMyVideosCollectionPluginTester::TimerComplete: medias: %d", iMediaArray->Count());
       
  3349        for( TInt i = 0; i < iMediaArray->Count(); i++ )
       
  3350            {
       
  3351            media = (*iMediaArray)[i];
       
  3352 
       
  3353            if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
       
  3354                {
       
  3355                TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
       
  3356 
       
  3357                TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
  3358 
       
  3359                TInt progress = -1;
       
  3360                if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
  3361                    {
       
  3362                    progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
       
  3363                    }
       
  3364 
       
  3365                TUint32 downloadId = 0;
       
  3366                if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
       
  3367                    {
       
  3368                    downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
  3369                    }
       
  3370 
       
  3371                CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
       
  3372 
       
  3373                if( dl )
       
  3374                    {
       
  3375 //                   VCXLOGLO5("CVCXMyVideosCollectionPluginTester:: DL ID: %d, MPX ID: %d, state: %d, progress: %d", downloadId, itemId.iId1, state, progress );
       
  3376 //                   VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: serviceId: %d, contentId: %d", dl->iServiceId, dl->iContentId );
       
  3377                    iDlWatcher->UpdateDownloadProgressL( itemId.iId1, downloadId, progress );
       
  3378                    }
       
  3379                }
       
  3380            }
       
  3381         }
       
  3382     }
       
  3383 //  End of File
  3153 //  End of File