videocollection/mpxmyvideoscollection/tsrc/ut_collectionplugintest/src/ut_collectionplugintestBlocks.cpp
branchRCL_3
changeset 70 375929f879c2
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Video Playback User Input Handler Test class for STIF unit testing
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 1 %
       
    19 
       
    20 
       
    21 
       
    22 // [INCLUDE FILES] - do not remove
       
    23 #include <e32svr.h>
       
    24 #include <e32std.h>
       
    25 #include <w32std.h>
       
    26 #include <coeaui.h>
       
    27 #include <aknutils.h>
       
    28 #include <aknviewappui.h>
       
    29 #include <StifParser.h>
       
    30 #include <Stiftestinterface.h>
       
    31 
       
    32 #include "ut_collectionplugintest.h"
       
    33 
       
    34 #include "mpxlog.h"
       
    35 #include <vcxmyvideosuids.h>
       
    36 #include <vcxmyvideosdefs.h>
       
    37 #include <mpxcommandgeneraldefs.h>
       
    38 #include <mpxcollectioncommanddefs.h>
       
    39 #include <mpxmediageneraldefs.h>
       
    40 #include <mpxmediacontainerdefs.h>
       
    41 #include <mpxmessagecontainerdefs.h>
       
    42 #include <mpxmessagegeneraldefs.h>
       
    43 
       
    44 #include <mpxcollectionplugin.h>
       
    45 #include <mpxcollectionpath.h>
       
    46 #include <mpxcollectionmessagedefs.h>
       
    47 #include <vcxmyvideosdefs.h>
       
    48 #include "vcxmyvideosactivetask.h"
       
    49 #include "vcxmyvideosmdsdb.h"
       
    50 #include "vcxmyvideosvideocache_stub.h"
       
    51 
       
    52 #define private public
       
    53 #include "vcxmyvideoscollectionplugin.h"
       
    54 #undef private
       
    55 
       
    56 _LIT( KTestModuleName, "CollectionPluginTest" );
       
    57 _LIT( KLogLocation, "In %S" );
       
    58 
       
    59 const TInt KInvalidId( -100 );
       
    60 const TInt KSelectAll( -2 );
       
    61 
       
    62 enum EMPXMediaAttribute
       
    63     {
       
    64     ETestMediaGeneralId = 1,
       
    65     ETestMediaTitle
       
    66     };
       
    67 
       
    68 enum EStubs
       
    69     {
       
    70     EActiveTask = 1,
       
    71     EAlbums,
       
    72     EAsyncFileOperations,
       
    73     ECategories,
       
    74     EMDSDB,
       
    75     EMessageList,
       
    76     EOpenHandler,
       
    77     EVideoCache
       
    78     };
       
    79 
       
    80 // ============================= LOCAL FUNCTIONS ===============================
       
    81 
       
    82 // ============================ MEMBER FUNCTIONS ===============================
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCollectionPluginTest::Delete
       
    86 // Delete here all resources allocated and opened from test methods.
       
    87 // Called from destructor.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CCollectionPluginTest::Delete()
       
    91 {
       
    92     if( iCollection )
       
    93         {
       
    94         delete iCollection;
       
    95         iCollection = NULL;
       
    96         }
       
    97     
       
    98     if( iPath )
       
    99         {
       
   100         delete iPath;
       
   101         iPath = NULL;
       
   102         }
       
   103     
       
   104     if( iMessageList )
       
   105         {
       
   106         iMessageList->Reset();
       
   107         delete iMessageList;
       
   108         iMessageList = NULL;
       
   109         }
       
   110     
       
   111     if( iMedia )
       
   112         {
       
   113         delete iMedia;
       
   114         iMedia = NULL;
       
   115         }
       
   116 
       
   117     if( iCommand )
       
   118         {
       
   119         delete iCommand;
       
   120         iCommand = NULL;
       
   121         }
       
   122     
       
   123     iAttrs.Close();
       
   124 }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 //   CCollectionPluginTest::CreateL
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CCollectionPluginTest::CreateL()
       
   131 {
       
   132     TInt arguments( 0 );
       
   133     iCollection = CVcxMyVideosCollectionPlugin::NewL( &arguments );
       
   134     iCollection->SetObserver( *this );
       
   135     iMessageList = CMPXMediaArray::NewL();
       
   136     iPath = CMPXCollectionPath::NewL();
       
   137 }
       
   138 
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CCollectionPluginTest::RunMethodL
       
   142 // Run specified method. Contains also table of test mothods and their names.
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CCollectionPluginTest::RunMethodL( CStifItemParser& aItem )
       
   146 {
       
   147     static TStifFunctionInfo const KFunctions[] =
       
   148     {
       
   149         // Copy this line for every implemented function.
       
   150         // First string is the function name used in TestScripter script file.
       
   151         // Second is the actual implementation member function.
       
   152         ENTRY( "CreateNewMedia", CCollectionPluginTest::CreateNewMediaL ),
       
   153         ENTRY( "SetMediaAttribute", CCollectionPluginTest::SetMediaAttributeL ),
       
   154         ENTRY( "AddMediaToCache", CCollectionPluginTest::AddMediaToCacheL ),
       
   155         ENTRY( "RemoveMediaFromCache", CCollectionPluginTest::RemoveMediaFromCacheL ),
       
   156         ENTRY( "CheckMediaCount", CCollectionPluginTest::CheckMediaCountL ),
       
   157         ENTRY( "OpenL", CCollectionPluginTest::OpenL ),
       
   158         ENTRY( "SelectPath", CCollectionPluginTest::SelectPathL ),
       
   159         ENTRY( "SelectPathId", CCollectionPluginTest::SelectPathIdL ),
       
   160         ENTRY( "InsertToPath", CCollectionPluginTest::InsertToPathL ),
       
   161         ENTRY( "SelectAttributes", CCollectionPluginTest::SelectAttributesL ),
       
   162         ENTRY( "MediaL", CCollectionPluginTest::MediaL ),
       
   163         ENTRY( "CancelRequest", CCollectionPluginTest::CancelRequest ),
       
   164         ENTRY( "CommandL", CCollectionPluginTest::CommandL ),
       
   165         ENTRY( "FindAllL", CCollectionPluginTest::FindAllL ),
       
   166         ENTRY( "FindAllSyncL", CCollectionPluginTest::FindAllSyncL ),
       
   167         ENTRY( "GetCapabilities", CCollectionPluginTest::GetCapabilities ),
       
   168         ENTRY( "AddL", CCollectionPluginTest::AddL ),
       
   169         ENTRY( "RemoveL", CCollectionPluginTest::RemoveL ),
       
   170         ENTRY( "SetL", CCollectionPluginTest::SetL ),
       
   171         ENTRY( "HandleStepL", CCollectionPluginTest::HandleStepL ),
       
   172         ENTRY( "CreateNewCmd", CCollectionPluginTest::CreateNewCmdL ),
       
   173         ENTRY( "CheckCurrentCmd", CCollectionPluginTest::CheckCurrentCmdL ),
       
   174         ENTRY( "SetNewCmd", CCollectionPluginTest::SetNewCmdL ),
       
   175         ENTRY( "SetVideoListFetching", CCollectionPluginTest::SetVideoListFetchingL ),
       
   176         ENTRY( "CancelCacheListFetching", CCollectionPluginTest::CancelCacheListFetchingL ),
       
   177         ENTRY( "HandleMyVideosDbEvent", CCollectionPluginTest::HandleMyVideosDbEvent ),
       
   178         ENTRY( "HandleCreateVideoListResp", CCollectionPluginTest::HandleCreateVideoListResp ),
       
   179         ENTRY( "HandleObjectPresentNotification", CCollectionPluginTest::HandleObjectPresentNotificationL ),
       
   180         ENTRY( "AddVideoToMdsAndCacheL", CCollectionPluginTest::AddVideoToMdsAndCacheL ),
       
   181         ENTRY( "SetVideoL", CCollectionPluginTest::SetVideoL ),
       
   182         ENTRY( "SendMyVideosMessageL", CCollectionPluginTest::SendMyVideosMessageL ),
       
   183         ENTRY( "SendMessages", CCollectionPluginTest::SendMessages ),
       
   184         ENTRY( "CategoriesL", CCollectionPluginTest::CategoriesL ),
       
   185         ENTRY( "NotifyNewVideosCountDecreasedL", CCollectionPluginTest::NotifyNewVideosCountDecreasedL ),
       
   186         ENTRY( "DeleteStub", CCollectionPluginTest::DeleteStubL ),
       
   187         ENTRY( "AlbumsL", CCollectionPluginTest::AlbumsL ),
       
   188     };
       
   189 
       
   190     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
   191 
       
   192     return RunInternalL( KFunctions, count, aItem );
       
   193 }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // 
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 void CCollectionPluginTest::LogMethod( TPtrC aMethod )
       
   200     {
       
   201     // Print to UI
       
   202     TBuf< 64 > buffer;
       
   203     buffer.Format( KLogLocation, &aMethod );
       
   204     TestModuleIf().Printf( 0, KTestModuleName, buffer );
       
   205     // Print to log file
       
   206     iLog->Log( buffer );
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 //  CCollectionPluginTest::SetMessageResponse
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 TInt CCollectionPluginTest::DeleteStubL( CStifItemParser& aItem )
       
   214     {
       
   215     TInt error( KErrNone );
       
   216     TInt stub( KErrNotFound );
       
   217     aItem.GetNextInt( stub );
       
   218     
       
   219     switch( stub )
       
   220         {
       
   221         case EActiveTask:
       
   222             TRAP( error, delete iCollection->iActiveTask );
       
   223             break;
       
   224         case EAlbums:
       
   225             TRAP( error, delete iCollection->iAlbums );
       
   226             break;
       
   227         case EAsyncFileOperations:
       
   228             TRAP( error, delete iCollection->iAsyncFileOperations );
       
   229             break;
       
   230         case ECategories:
       
   231             TRAP( error, delete iCollection->iCategories );
       
   232             break;
       
   233         case EMDSDB:
       
   234             TRAP( error, delete iCollection->iMyVideosMdsDb );
       
   235             break;
       
   236         case EMessageList:
       
   237             TRAP( error, delete iCollection->iMessageList );
       
   238             break;
       
   239         case EOpenHandler:
       
   240             TRAP( error, delete iCollection->iOpenHandler );
       
   241             break;
       
   242         case EVideoCache:
       
   243             TRAP( error, delete iCollection->iCache );
       
   244             break;
       
   245         default:
       
   246             break;
       
   247         }
       
   248     
       
   249     return error;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 //  CCollectionPluginTest::CheckMessageResponse
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 TInt CCollectionPluginTest::CheckCurrentCmdL( CStifItemParser& aItem )
       
   257     {
       
   258     TInt error( KErrNone );
       
   259     
       
   260     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   261     
       
   262     // CMD ID
       
   263     TUint32 cmdId( 0 );
       
   264     TPtrC cmdIdStr;
       
   265     if( aItem.GetNextString( cmdIdStr ) == KErrNone )
       
   266         {
       
   267         TLex lex( cmdIdStr );
       
   268         lex.Val( cmdId, EHex );
       
   269         }
       
   270     
       
   271     // MV CMD ID
       
   272     TInt cmdMV( KErrNotFound );
       
   273     if( cmdId == KVcxCommandIdMyVideos )
       
   274         {
       
   275         aItem.GetNextInt( cmdMV );
       
   276         }
       
   277     
       
   278     if( iCollection->iActiveTask->iCurCommand == NULL && !cmdId )
       
   279         {
       
   280         return KErrNone;
       
   281         }
       
   282     
       
   283     TMPXCommandId commandId = iCollection->iActiveTask->iCurCommand->ValueTObjectL<TMPXCommandId>( KMPXCommandGeneralId );
       
   284     if( commandId != cmdId )
       
   285         {
       
   286         error = KErrCorrupt;
       
   287         }
       
   288 
       
   289     if( commandId == KVcxCommandIdMyVideos )
       
   290         {
       
   291         TInt currCmdMV = iCollection->iActiveTask->iCurCommand->ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId );
       
   292         if( currCmdMV != cmdMV )
       
   293             {
       
   294             error = KErrCorrupt;
       
   295             }
       
   296         }
       
   297     
       
   298     return error;
       
   299     }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 //  CCollectionPluginTest::CreateNewMediaL
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 TInt CCollectionPluginTest::CreateNewMediaL( CStifItemParser& /*aItem*/ )
       
   306     {    
       
   307     delete iMedia;
       
   308     iMedia = NULL;
       
   309     iMedia = CMPXMedia::NewL(); // NULL;
       
   310     return KErrNone;
       
   311     }
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 //  CCollectionPluginTest::CreateNewMediaL
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 TInt CCollectionPluginTest::SetMediaAttributeL( CStifItemParser& aItem )
       
   318     {
       
   319     CleanupStack::PushL( iMedia );
       
   320     
       
   321     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   322     TInt attribute( KErrNotFound );
       
   323     aItem.GetNextInt( attribute );
       
   324     switch( attribute )
       
   325         {
       
   326         case ETestMediaGeneralId:
       
   327             {
       
   328             TInt mediaId( 0 );
       
   329             aItem.GetNextInt( mediaId );
       
   330             TInt mediaType( KVcxMvcMediaTypeVideo );
       
   331             aItem.GetNextInt( mediaType );
       
   332             TMPXItemId mpxId( mediaId, mediaType );
       
   333             iMedia->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
       
   334             }
       
   335             break;
       
   336             
       
   337         case ETestMediaTitle:
       
   338             {
       
   339             TPtrC value;
       
   340             aItem.GetNextString( value );
       
   341             iMedia->SetTextValueL( KMPXMediaGeneralTitle, value );                
       
   342             }
       
   343             break;
       
   344         default:
       
   345             break;
       
   346         }
       
   347     CleanupStack::Pop( iMedia );
       
   348     
       
   349     return KErrNone;
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 //  CCollectionPluginTest::CreateNewCmdL
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 TInt CCollectionPluginTest::CreateNewCmdL( CStifItemParser& aItem )
       
   357     {
       
   358     TInt error( KErrNone );
       
   359     
       
   360     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   361 
       
   362     // COMMAND SYNC
       
   363     TInt paramSync( 0 );
       
   364     aItem.GetNextInt( paramSync );
       
   365     
       
   366     // CMD ID
       
   367     TUint32 cmdId( 0 );
       
   368     TPtrC cmdIdStr;
       
   369     if( aItem.GetNextString( cmdIdStr ) == KErrNone )
       
   370         {
       
   371         TLex lex( cmdIdStr );
       
   372         User::LeaveIfError( lex.Val( cmdId, EHex ) );
       
   373         }
       
   374     
       
   375     // MV CMD ID
       
   376     TInt cmdMV( KErrNotFound );
       
   377     if( cmdId == KVcxCommandIdMyVideos )
       
   378         {
       
   379         aItem.GetNextInt( cmdMV );
       
   380         }
       
   381 
       
   382     delete iCommand;
       
   383     iCommand = NULL;
       
   384     iCommand = CreateMpxCommandLC( cmdId, cmdMV, paramSync );
       
   385     
       
   386     switch( cmdId )
       
   387         {
       
   388         case KMPXCommandIdCollectionAdd: // SYNC
       
   389             {
       
   390             iCommand->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, iMedia );
       
   391             }
       
   392             break;
       
   393         
       
   394         case KMPXCommandIdCollectionSet: // SYNC
       
   395             {
       
   396             iCommand->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, iMedia );
       
   397             }
       
   398             break;
       
   399         
       
   400         case KMPXCommandIdCollectionRemoveMedia:
       
   401             {
       
   402             TMPXItemId itemId = iMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   403             iCommand->SetTObjectValueL( KMPXMediaGeneralId, itemId );
       
   404             }
       
   405             break;
       
   406         default:
       
   407             break;
       
   408         }
       
   409 
       
   410     switch( cmdMV )
       
   411         {
       
   412         case KVcxCommandMyVideosGetMediaFullDetailsByMpxId:
       
   413             {
       
   414             TMPXItemId itemId = iMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   415             iCommand->SetTObjectValueL( KMPXMediaGeneralId, itemId );
       
   416             }
       
   417             break;
       
   418         case KVcxCommandMyVideosGetMediasByMpxId:
       
   419             {
       
   420             CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
       
   421             CleanupStack::PushL( mediaArray );
       
   422 
       
   423             TInt id( 0 );
       
   424             
       
   425             while( aItem.GetNextInt( id ) == KErrNone )
       
   426                 {
       
   427                 CMPXMedia* item = CMPXMedia::NewL();
       
   428                 CleanupStack::PushL( item ); 
       
   429                 TMPXItemId itemId;
       
   430                 itemId.iId1 = id;
       
   431                 itemId.iId2 = KVcxMvcMediaTypeVideo;
       
   432                 item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
       
   433                 mediaArray->AppendL( *item );
       
   434                 CleanupStack::PopAndDestroy( item );
       
   435                 }
       
   436             if( id != KErrNotFound )
       
   437                 {
       
   438                 iCommand->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
       
   439                 }
       
   440             CleanupStack::Pop( mediaArray );
       
   441             }
       
   442             break;
       
   443         case KVcxCommandMyVideosMove:
       
   444         case KVcxCommandMyVideosCopy:
       
   445         case KVcxCommandMyVideosDelete:
       
   446         case KVcxCommandMyVideosCancelMoveOrCopy: // SYNC
       
   447         case KVcxCommandMyVideosCancelDelete: // SYNC
       
   448         case KVcxCommandMyVideosAddAlbum: // SYNC
       
   449         case KVcxCommandMyVideosAddToAlbum: // ASYNC
       
   450         case KVcxCommandMyVideosRemoveFromAlbum: // ASYNC
       
   451             {
       
   452             if( iMedia )
       
   453                 {
       
   454                 iCommand->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, iMedia );
       
   455                 }
       
   456             }
       
   457             break;
       
   458         default:
       
   459             break;
       
   460         }
       
   461     
       
   462     CleanupStack::Pop( iCommand );
       
   463     
       
   464     return error;
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 //   CCollectionPluginTest::
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 TInt CCollectionPluginTest::SetNewCmdL( CStifItemParser& /*aItem*/ )
       
   472     {
       
   473     LogMethod(_L("SetNewCmdL"));
       
   474     TRAPD( error, iCollection->iActiveTask->SetNewCommandL( *iCommand ) );
       
   475     return error;
       
   476     }
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 //   CCollectionPluginTest::SetListCacheFetching
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 TInt CCollectionPluginTest::CancelCacheListFetchingL( CStifItemParser& aItem )
       
   483     {
       
   484     LogMethod(_L("CancelCacheListFetchingL"));
       
   485     TInt value( KErrNotFound );
       
   486     aItem.GetNextInt( value );
       
   487     TBool enabled( value );
       
   488     TRAPD( error, iCollection->iCache->iCancelListFetching = enabled );
       
   489     return error;
       
   490     }
       
   491 
       
   492 // -----------------------------------------------------------------------------
       
   493 //  CCollectionPluginTest::AddMediaToCacheL
       
   494 // -----------------------------------------------------------------------------
       
   495 //
       
   496 TInt CCollectionPluginTest::AddMediaToCacheL( CStifItemParser& /*aItem*/ )
       
   497     {
       
   498     CMPXMediaArray* cache = iCollection->iCache->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   499     TRAPD( error, cache->AppendL( *iMedia ) );
       
   500     iCollection->iCache->iVideoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, cache);
       
   501     return error;
       
   502     }
       
   503 
       
   504 // -----------------------------------------------------------------------------
       
   505 //   CCollectionPluginTest::
       
   506 // -----------------------------------------------------------------------------
       
   507 //
       
   508 /*
       
   509 TInt CCollectionPluginTest::AddMediaToCacheL( CStifItemParser& aItem )
       
   510     {
       
   511     LogMethod(_L("AddMediaToCache"));
       
   512     
       
   513     TInt err( 0 );
       
   514     
       
   515     CMPXMedia* media = CMPXMedia::NewL();
       
   516     TInt mediaId( 0 );
       
   517     aItem.GetNextInt( mediaId );
       
   518     TMPXItemId mpxId( mediaId, 0 );
       
   519     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
       
   520     
       
   521     CMPXMediaArray* medias = iCollection->iCache->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   522     medias->AppendL(*media);
       
   523     delete media;
       
   524     
       
   525     return err;
       
   526     }*/
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 //   CCollectionPluginTest::
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 TInt CCollectionPluginTest::RemoveMediaFromCacheL( CStifItemParser& aItem )
       
   533     {
       
   534     LogMethod(_L("RemoveMediaFromCache"));
       
   535     
       
   536     TInt err = ( -1 );
       
   537     
       
   538     TInt mediaId( 0 );
       
   539     aItem.GetNextInt( mediaId );
       
   540     
       
   541     CMPXMediaArray* medias = iCollection->iCache->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   542     for ( TInt i = 0; i < medias->Count(); i++ )
       
   543         {
       
   544         CMPXMedia* media = (*medias)[i];    
       
   545         TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
       
   546         if( itemId.iId1 == mediaId )
       
   547             {
       
   548             medias->Remove(i);
       
   549             err = KErrNone;
       
   550             break;
       
   551             }
       
   552         }
       
   553     
       
   554     return err;
       
   555     }
       
   556 
       
   557 // -----------------------------------------------------------------------------
       
   558 //   CCollectionPluginTest::
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 TInt CCollectionPluginTest::OpenL( CStifItemParser& aItem )
       
   562     {
       
   563     LogMethod(_L("OpenL"));
       
   564 
       
   565     aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   566     TInt32 collectionId( KErrNotFound );
       
   567     TPtrC collectionIdStr;
       
   568     if( aItem.GetNextString( collectionIdStr ) == KErrNone )
       
   569         {
       
   570         TLex lex( collectionIdStr );
       
   571         lex.Val( collectionId, EHex );
       
   572         }
       
   573     
       
   574     CleanupStack::PushL( iPath );
       
   575     
       
   576     iPath->Reset();
       
   577     
       
   578     switch( collectionId )
       
   579         {
       
   580         case KErrNotFound:
       
   581             break;
       
   582         case KInvalidId:
       
   583             iPath->AppendL( TMPXItemId::InvalidId() );
       
   584             break;
       
   585         case 0:
       
   586             iPath->AppendL( KVcxUidMyVideosMpxCollection );
       
   587             break;
       
   588         default:
       
   589             iPath->AppendL( collectionId );
       
   590             break;
       
   591         }
       
   592     
       
   593     TMPXItemId item(1, 1);
       
   594     iPath->AppendL(item);
       
   595 
       
   596     RArray<TMPXAttribute> attrs;
       
   597     CMPXFilter* filter = CMPXFilter::NewL();
       
   598     
       
   599     TRAPD( error, iCollection->OpenL( *iPath, attrs.Array(), filter ) );
       
   600     
       
   601     CleanupStack::Pop( iPath );
       
   602     attrs.Reset();
       
   603     attrs.Close();
       
   604     delete filter;
       
   605     return error; // error;
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 //   CCollectionPluginTest::InsertToPathL
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 TInt CCollectionPluginTest::InsertToPathL( CStifItemParser& aItem )
       
   613     {
       
   614     LogMethod(_L("InsertToPathL"));
       
   615     
       
   616     //aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   617     TInt id( KErrNotFound );
       
   618     TInt type( KErrNotFound );
       
   619 
       
   620     aItem.GetNextInt( id );
       
   621     aItem.GetNextInt( type );
       
   622     TMPXItemId itemId( id, type );
       
   623     CleanupStack::PushL( iPath );
       
   624     TRAPD( error, iPath->InsertL(itemId, iPath->Count()-1) );   
       
   625     CleanupStack::Pop( iPath );
       
   626     
       
   627     return error;
       
   628     }
       
   629 
       
   630 // -----------------------------------------------------------------------------
       
   631 //   CCollectionPluginTest::SelectPathL
       
   632 // -----------------------------------------------------------------------------
       
   633 //
       
   634 TInt CCollectionPluginTest::SelectPathL( CStifItemParser& aItem )
       
   635     {
       
   636     LogMethod(_L("SelectPathL"));
       
   637     
       
   638     CleanupStack::PushL( iPath );
       
   639     
       
   640     //aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   641     TInt index( KErrNotFound );
       
   642     aItem.GetNextInt( index );
       
   643     
       
   644     TInt pathcount = iPath->Count();
       
   645     
       
   646     TInt error( KErrNotFound );
       
   647     switch( index )
       
   648         {
       
   649         case KSelectAll:
       
   650             TRAP( error, iPath->SelectAllL() );
       
   651             break;
       
   652         case KErrNotFound:
       
   653             TRAP( error, iPath->DeselectAll() );
       
   654             break;
       
   655         case KInvalidId:
       
   656             TRAP( error, iPath->SelectL( TMPXItemId::InvalidId() ) );
       
   657             break;
       
   658         default:
       
   659             TRAP( error, iPath->SelectL( index ) );
       
   660             break;
       
   661         }
       
   662     
       
   663     CleanupStack::Pop( iPath );
       
   664     
       
   665     return error;
       
   666     }
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 //   CCollectionPluginTest::SelectPathL
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 TInt CCollectionPluginTest::SelectPathIdL( CStifItemParser& aItem )
       
   673     {
       
   674     LogMethod(_L("SelectPathL"));
       
   675     CleanupStack::PushL( iPath );
       
   676     TInt id( KErrNotFound );
       
   677     aItem.GetNextInt( id );
       
   678     TInt pathcount = iPath->Count();
       
   679     TMPXItemId itemId( id, KVcxMvcMediaTypeVideo );
       
   680     TRAPD( error, iPath->SelectL( itemId ) );
       
   681     CleanupStack::Pop( iPath );
       
   682     return error;
       
   683     }
       
   684 
       
   685 // -----------------------------------------------------------------------------
       
   686 //   CCollectionPluginTest::SelectPathL
       
   687 // -----------------------------------------------------------------------------
       
   688 //
       
   689 TInt CCollectionPluginTest::SelectAttributesL( CStifItemParser& aItem )
       
   690     {
       
   691     LogMethod(_L("SelectAttributesL"));
       
   692     
       
   693     //aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
       
   694     iAttrs.Reset();
       
   695     TInt attr( KErrNotFound );
       
   696     aItem.GetNextInt( attr );
       
   697     switch( attr )
       
   698         {
       
   699         case ETestMediaGeneralId:
       
   700             iAttrs.AppendL( KMPXMediaGeneralId );
       
   701             break;
       
   702         default:
       
   703             break;
       
   704         }        
       
   705     
       
   706     return KErrNone;
       
   707     }
       
   708 
       
   709 // -----------------------------------------------------------------------------
       
   710 //   CCollectionPluginTest::
       
   711 // -----------------------------------------------------------------------------
       
   712 //
       
   713 TInt CCollectionPluginTest::MediaL( CStifItemParser& /*aItem*/ )
       
   714     {
       
   715     LogMethod(_L("MediaL"));
       
   716     
       
   717     RArray<TCapability> caps;
       
   718     CleanupClosePushL(caps);
       
   719     caps.AppendL(ECapability_None);
       
   720     /*if (aCaps.HasCapability(ECapabilityDRM))
       
   721         {
       
   722         caps.AppendL(ECapabilityDRM);
       
   723         }*/
       
   724     // else add further "relevant" capabilities here
       
   725 
       
   726     // Add "none" capability, if no caps listed
       
   727     /*if (caps.Count() == 0)
       
   728         {
       
   729         caps.AppendL(ECapability_None);
       
   730         }*/
       
   731     
       
   732     CMPXMedia* specs = CMPXMedia::NewL();
       
   733     
       
   734     TRAPD( error, iCollection->MediaL( *iPath, iAttrs.Array(), caps.Array(), specs ) );
       
   735     delete specs;
       
   736     CleanupStack::PopAndDestroy(&caps);
       
   737     return error;
       
   738     }
       
   739 
       
   740 // -----------------------------------------------------------------------------
       
   741 //   CCollectionPluginTest::
       
   742 // -----------------------------------------------------------------------------
       
   743 //
       
   744 TInt CCollectionPluginTest::CheckMediaCountL( CStifItemParser& aItem )
       
   745     {
       
   746     LogMethod(_L("CheckMediaCount"));
       
   747     
       
   748     TInt err( 0 );
       
   749     
       
   750     TInt expected( 0 );
       
   751     aItem.GetNextInt( expected );
       
   752     
       
   753     CMPXMediaArray* medias = iCollection->iCache->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
       
   754     if( medias->Count() != expected )
       
   755         {
       
   756         err = KErrCorrupt;
       
   757         }
       
   758     
       
   759     return err;
       
   760     }
       
   761 
       
   762 // -----------------------------------------------------------------------------
       
   763 //   CCollectionPluginTest::
       
   764 // -----------------------------------------------------------------------------
       
   765 //
       
   766 TInt CCollectionPluginTest::CancelRequest( CStifItemParser& /*aItem*/ )
       
   767     {
       
   768     LogMethod(_L("CancelRequest"));
       
   769 	
       
   770     iCollection->CancelRequest();
       
   771     
       
   772     return KErrNone;
       
   773     }
       
   774 
       
   775 // -----------------------------------------------------------------------------
       
   776 //   CCollectionPluginTest::
       
   777 // -----------------------------------------------------------------------------
       
   778 //
       
   779 TInt CCollectionPluginTest::CommandL( CStifItemParser& aItem )
       
   780     {
       
   781     LogMethod(_L("CommandL"));
       
   782     CreateNewCmdL( aItem );
       
   783     TRAPD( error, iCollection->CommandL( *iCommand ) );
       
   784     
       
   785 #ifndef _DEBUG
       
   786     // KMPXCommandIdCollectionAdd leaves with KErrNotSupported if the build is not udeb
       
   787     // and it cannot be checked with STIF, so here's a solution 
       
   788     
       
   789     TMPXCommandId cmdId = iCollection->iActiveTask->iCurCommand->ValueTObjectL<TMPXCommandId>( KMPXCommandGeneralId );
       
   790     if( cmdId == KMPXCommandIdCollectionAdd && error == KErrNotSupported )
       
   791         {
       
   792         error = KErrNone;
       
   793         }
       
   794 #endif
       
   795     
       
   796     return error;
       
   797     }
       
   798 
       
   799 // -----------------------------------------------------------------------------
       
   800 // CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC
       
   801 // -----------------------------------------------------------------------------
       
   802 //
       
   803 CMPXCommand* CCollectionPluginTest::CreateMpxCommandLC( TInt aCommandGeneralId, 
       
   804                                                         TInt aMyVideosCommandId, 
       
   805                                                         TInt aSync )
       
   806     {
       
   807     CMPXCommand* cmd = CMPXCommand::NewL();
       
   808     CleanupStack::PushL( cmd );
       
   809 
       
   810     if( aCommandGeneralId != 0 )
       
   811         {
       
   812         cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
       
   813         if( aCommandGeneralId == KVcxCommandIdMyVideos && aMyVideosCommandId != KErrNotFound )
       
   814             {
       
   815             cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
       
   816             }
       
   817         }
       
   818     
       
   819     if( aSync != KErrNotFound )
       
   820         {
       
   821         TBool asyncBool( aSync );
       
   822         cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, asyncBool );
       
   823         }
       
   824 
       
   825     /*
       
   826     if( !aSync )
       
   827         {
       
   828         iTransactions->NextTransactionId();
       
   829 
       
   830         if( aCommandGeneralId == KVcxCommandIdMyVideos )
       
   831             {
       
   832             cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
       
   833             iTransactions->AddTransactionId( aMyVideosCommandId );
       
   834             }
       
   835         }
       
   836 
       
   837     VCXLOGLO2("CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC: collectionId: 0x%x", iCollectionUid.iUid);
       
   838     */
       
   839     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
       
   840 
       
   841     return cmd;
       
   842     }
       
   843 
       
   844 // -----------------------------------------------------------------------------
       
   845 //   CCollectionPluginTest::
       
   846 // -----------------------------------------------------------------------------
       
   847 //
       
   848 TInt CCollectionPluginTest::FindAllL( CStifItemParser& /*aItem*/ )
       
   849     {
       
   850     LogMethod(_L("FindAllL"));
       
   851     TInt error( 0 );
       
   852     CMPXMedia* media = CMPXMedia::NewL();
       
   853     RArray<TMPXAttribute> array;
       
   854     TRAP( error, iCollection->FindAllL(*media, array.Array()) );
       
   855     delete media;
       
   856     array.Close();
       
   857     return error;
       
   858     }
       
   859 
       
   860 // -----------------------------------------------------------------------------
       
   861 //   CCollectionPluginTest::
       
   862 // -----------------------------------------------------------------------------
       
   863 //
       
   864 TInt CCollectionPluginTest::FindAllSyncL( CStifItemParser& /*aItem*/ )
       
   865     {
       
   866     LogMethod(_L("FindAllSyncL"));
       
   867     TInt error( 0 );
       
   868     CMPXMedia* media = CMPXMedia::NewL();
       
   869     RArray<TMPXAttribute> array;
       
   870     TRAP( error, iCollection->FindAllSyncL( *media, array.Array() ) );
       
   871     delete media;
       
   872     array.Close();
       
   873     
       
   874     return error;
       
   875     }
       
   876 
       
   877 // -----------------------------------------------------------------------------
       
   878 //   CCollectionPluginTest::
       
   879 // -----------------------------------------------------------------------------
       
   880 //
       
   881 TInt CCollectionPluginTest::GetCapabilities( CStifItemParser& /*aItem*/ )
       
   882     {
       
   883     LogMethod(_L("GetCapabilities"));
       
   884 
       
   885     TInt error( 0 );
       
   886     TCollectionCapability cap;
       
   887     cap = iCollection->GetCapabilities();
       
   888     if( cap != EMcSearch )
       
   889         {
       
   890         error = KErrCorrupt;
       
   891         }
       
   892     return error;
       
   893     }
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 //   CCollectionPluginTest::
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 TInt CCollectionPluginTest::AddL( CStifItemParser& /*aItem*/ )
       
   900     {
       
   901     LogMethod(_L("AddL"));
       
   902     CMPXMedia* media = CMPXMedia::NewL();
       
   903     TRAPD( error, iCollection->AddL( *media ) );
       
   904     delete media;
       
   905     return error;
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 //   CCollectionPluginTest::
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 TInt CCollectionPluginTest::RemoveL( CStifItemParser& /*aItem*/ )
       
   913     {
       
   914     LogMethod(_L("RemoveL"));
       
   915     CMPXMedia* media = CMPXMedia::NewL();
       
   916     TRAPD( error, iCollection->RemoveL( *media ) );
       
   917     delete media;
       
   918     return error;;
       
   919     }
       
   920 
       
   921 // -----------------------------------------------------------------------------
       
   922 //   CCollectionPluginTest::
       
   923 // -----------------------------------------------------------------------------
       
   924 //
       
   925 TInt CCollectionPluginTest::SetL( CStifItemParser& /*aItem*/ )
       
   926     {
       
   927     LogMethod(_L("SetL"));
       
   928     CMPXMedia* media = CMPXMedia::NewL();
       
   929     TRAPD( error, iCollection->SetL( *media ) ); // SetL is obsolete, so just set a null media
       
   930     delete media;
       
   931     return error;
       
   932     }
       
   933 
       
   934 // -----------------------------------------------------------------------------
       
   935 //   CCollectionPluginTest::
       
   936 // -----------------------------------------------------------------------------
       
   937 //
       
   938 TInt CCollectionPluginTest::HandleStepL( CStifItemParser& /*aItem*/ )
       
   939     {
       
   940     LogMethod(_L("HandleStepL"));
       
   941     TRAPD( error, iCollection->iActiveTask->RunL() );
       
   942     return error;
       
   943     }
       
   944 
       
   945 // -----------------------------------------------------------------------------
       
   946 //   CCollectionPluginTest::
       
   947 // -----------------------------------------------------------------------------
       
   948 //
       
   949 TInt CCollectionPluginTest::SetVideoListFetchingL( CStifItemParser& aItem )
       
   950     {
       
   951     TInt value( KErrNotFound );
       
   952     aItem.GetNextInt( value );
       
   953     TBool enabled( value );
       
   954     TRAPD( error, iCollection->iMyVideosMdsDb->iVideoListFetchingIsOngoing = enabled );
       
   955     return error;
       
   956     }
       
   957 
       
   958 // -----------------------------------------------------------------------------
       
   959 //   CCollectionPluginTest::
       
   960 // -----------------------------------------------------------------------------
       
   961 //
       
   962 TInt CCollectionPluginTest::HandleMyVideosDbEvent( CStifItemParser& aItem )
       
   963     {
       
   964     LogMethod(_L("HandleMyVideosDbEvent"));
       
   965 
       
   966     //CVcxMyVideosCollectionPlugin::HandleMyVideosDbEvent(
       
   967     //        TMPXChangeEventType aEvent,
       
   968     //        RArray<TUint32>& aId )
       
   969     
       
   970     TMPXChangeEventType event;
       
   971     
       
   972     TInt eventEnum( 0 );
       
   973     aItem.GetNextInt( eventEnum );
       
   974     switch( eventEnum )
       
   975         {
       
   976         case 1:
       
   977             event = EMPXItemDeleted;
       
   978             break;
       
   979         case 2:
       
   980             event = EMPXItemInserted;
       
   981             break;
       
   982         case 3:
       
   983             event = EMPXItemModified;
       
   984             break;
       
   985         default:
       
   986             break;
       
   987         }
       
   988 
       
   989     //RArray<TUint32> ids;
       
   990     RArray<TItemId> ids;
       
   991     TInt id( 0 );
       
   992     while( aItem.GetNextInt( id ) == KErrNone )
       
   993         {
       
   994         ids.Append( id );
       
   995         }
       
   996 
       
   997     TRAPD( error, iCollection->HandleMyVideosDbEvent( event, ids, 0 ) );
       
   998     
       
   999     return error;
       
  1000     }
       
  1001 
       
  1002 // -----------------------------------------------------------------------------
       
  1003 //   CCollectionPluginTest::
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 TInt CCollectionPluginTest::HandleCreateVideoListResp( CStifItemParser& aItem )
       
  1007     {
       
  1008     LogMethod(_L("HandleCreateVideoListResp"));
       
  1009 
       
  1010     TInt complete( 0 );
       
  1011     aItem.GetNextInt( complete );
       
  1012 
       
  1013     TBool isComplete( (complete > 0 ) ? ETrue : EFalse );
       
  1014     
       
  1015     TInt startIndex( 0 );
       
  1016     aItem.GetNextInt( startIndex );
       
  1017     
       
  1018     CMPXMedia* media = CMPXMedia::NewL();
       
  1019     TRAPD( error, iCollection->HandleCreateVideoListResp(media, startIndex, isComplete) );
       
  1020     delete media;
       
  1021     return error;
       
  1022     }
       
  1023 
       
  1024 // -----------------------------------------------------------------------------
       
  1025 //   CCollectionPluginTest::
       
  1026 // -----------------------------------------------------------------------------
       
  1027 //
       
  1028 TInt CCollectionPluginTest::HandleObjectPresentNotificationL( CStifItemParser& aItem )
       
  1029     {
       
  1030     LogMethod(_L("HandleObjectPresentNotification"));
       
  1031 
       
  1032     TInt cacheLeave( 0 );
       
  1033     aItem.GetNextInt( cacheLeave );
       
  1034     iCollection->iCache->iLeaveOnReset = (cacheLeave > 0) ? ETrue : EFalse;    
       
  1035     TRAPD( error, iCollection->HandleObjectPresentNotification() );
       
  1036     return error;
       
  1037     }
       
  1038 
       
  1039 // -----------------------------------------------------------------------------
       
  1040 //   CCollectionPluginTest::
       
  1041 // -----------------------------------------------------------------------------
       
  1042 //
       
  1043 TInt CCollectionPluginTest::AddVideoToMdsAndCacheL( CStifItemParser& /*aItem*/ )
       
  1044     {
       
  1045     LogMethod(_L("AddVideoToMdsAndCacheL"));
       
  1046     TRAPD( error, iCollection->AddVideoToMdsAndCacheL( *iMedia ) );
       
  1047     return error;
       
  1048     }
       
  1049 
       
  1050 // -----------------------------------------------------------------------------
       
  1051 //   CCollectionPluginTest::
       
  1052 // -----------------------------------------------------------------------------
       
  1053 //
       
  1054 TInt CCollectionPluginTest::SetVideoL( CStifItemParser& aItem )
       
  1055     {
       
  1056     LogMethod(_L("SetVideoL"));
       
  1057 
       
  1058     TInt mpxid( 0 );
       
  1059     aItem.GetNextInt( mpxid );
       
  1060 
       
  1061     TInt type( 0 );
       
  1062     aItem.GetNextInt( type );
       
  1063     
       
  1064     TMPXItemId mpxId( mpxid, type );
       
  1065     
       
  1066     CMPXMedia* media = CMPXMedia::NewL();
       
  1067     CleanupStack::PushL( media );
       
  1068     media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
       
  1069     TRAPD( error, iCollection->SetVideoL( *media ) );
       
  1070     CleanupStack::PopAndDestroy( media );
       
  1071     return error;
       
  1072     }
       
  1073 
       
  1074 // -----------------------------------------------------------------------------
       
  1075 //   CCollectionPluginTest::
       
  1076 // -----------------------------------------------------------------------------
       
  1077 //
       
  1078 TInt CCollectionPluginTest::SendMyVideosMessageL( CStifItemParser& aItem )
       
  1079     {
       
  1080     LogMethod(_L("SendMyVideosMessageL"));
       
  1081 
       
  1082     //void CVcxMyVideosCollectionPlugin::SendMyVideosMessageL(
       
  1083     //        TUint32 aMessageId, CMPXCommand* aCommand )
       
  1084     
       
  1085     TInt msgId( 0 );
       
  1086     aItem.GetNextInt( msgId );
       
  1087     
       
  1088     CMPXCommand* cmd = NULL;
       
  1089     TInt createCommand( KErrNone );
       
  1090     aItem.GetNextInt( createCommand );
       
  1091     if( createCommand != KErrNone )
       
  1092         {
       
  1093         cmd = CMPXCommand::NewL();
       
  1094         }
       
  1095     
       
  1096     iCollection->SendMyVideosMessageL( (TUint32)msgId, cmd );
       
  1097     
       
  1098     if( cmd )
       
  1099         {
       
  1100         delete cmd;
       
  1101         }
       
  1102     
       
  1103     return KErrNone;
       
  1104     }
       
  1105 
       
  1106 // -----------------------------------------------------------------------------
       
  1107 //   CCollectionPluginTest::
       
  1108 // -----------------------------------------------------------------------------
       
  1109 //
       
  1110 TInt CCollectionPluginTest::SendMessages( CStifItemParser& /*aItem*/ )
       
  1111     {
       
  1112     LogMethod(_L("SendMessages"));
       
  1113     
       
  1114     CMPXMessage* msg = CMPXMessage::NewL();
       
  1115     /*
       
  1116     CleanupStack::PushL( msg );
       
  1117 
       
  1118     CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
       
  1119     CleanupStack::PushL( mediaArray );
       
  1120 
       
  1121     TInt msgId( 0 );
       
  1122     
       
  1123     while( aItem.GetNextInt( msgId ) == KErrNone )
       
  1124         {
       
  1125         CMPXMessage* message = CMPXMessage::NewL();
       
  1126         CleanupStack::PushL( message ); 
       
  1127     
       
  1128         // Set message attributes
       
  1129         //
       
  1130         TMPXItemId itemId;
       
  1131         itemId.iId1 = KVcxCommandIdMyVideos;
       
  1132         message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, itemId );
       
  1133         message->SetTObjectValueL<TInt>( KVcxMediaMyVideosCommandId, msgId );
       
  1134         mediaArray->AppendL( *message );
       
  1135         CleanupStack::PopAndDestroy( message );
       
  1136         }
       
  1137     //msg->SetCObjectValueL( KMPXMediaArrayContents, mediaArray );
       
  1138     msg->SetCObjectValueL( KMPXMessageArrayContents, mediaArray );
       
  1139     CleanupStack::PopAndDestroy( mediaArray );
       
  1140     CleanupStack::Pop( msg );
       
  1141     */
       
  1142     iCollection->SendMessages( *msg );
       
  1143     delete msg;
       
  1144     return KErrNone;
       
  1145     }
       
  1146 
       
  1147 // -----------------------------------------------------------------------------
       
  1148 //   CCollectionPluginTest::
       
  1149 // -----------------------------------------------------------------------------
       
  1150 //
       
  1151 TInt CCollectionPluginTest::CategoriesL( CStifItemParser& aItem )
       
  1152     {
       
  1153     LogMethod(_L("CategoriesL"));
       
  1154 
       
  1155     TInt error( 0 );
       
  1156     TInt deleteCategories( 0 );
       
  1157     aItem.GetNextInt( deleteCategories );
       
  1158     if( deleteCategories )
       
  1159         {
       
  1160         delete iCollection->iCategories;
       
  1161         }
       
  1162     TRAP( error, iCollection->CategoriesL() );
       
  1163     
       
  1164     return error;
       
  1165     }
       
  1166 
       
  1167 // -----------------------------------------------------------------------------
       
  1168 //   CCollectionPluginTest::
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 TInt CCollectionPluginTest::NotifyNewVideosCountDecreasedL( CStifItemParser& /*aItem*/ )
       
  1172     {
       
  1173     LogMethod(_L("NotifyNewVideosCountDecreasedL"));
       
  1174 
       
  1175     TInt error( 0 );
       
  1176     CMPXMedia* media = CMPXMedia::NewL();
       
  1177     TRAP( error, iCollection->NotifyNewVideosCountDecreasedL( *media ) );
       
  1178     delete media;
       
  1179     return error;
       
  1180     }
       
  1181 
       
  1182 // -----------------------------------------------------------------------------
       
  1183 //   CCollectionPluginTest::
       
  1184 // -----------------------------------------------------------------------------
       
  1185 //
       
  1186 void CCollectionPluginTest::HandleMessage(CMPXMessage* aMsg, TInt /*aError*/)
       
  1187     {
       
  1188     // LOOK! WE HANDLE!
       
  1189     // TODO: lisää messagearray
       
  1190     
       
  1191     if ( aMsg->IsSupported( KMPXMessageArrayContents ) )
       
  1192         {
       
  1193         const CMPXMessageArray* messageArray = 
       
  1194                 aMsg->Value<CMPXMessageArray>(KMPXMessageArrayContents);
       
  1195             
       
  1196         for( TInt i = 0; i < messageArray->Count(); i++ )
       
  1197             {
       
  1198             iMessageList->AppendL(*(messageArray->AtL( i )));
       
  1199             }
       
  1200         }
       
  1201     else
       
  1202         {
       
  1203         iMessageList->AppendL( *aMsg );
       
  1204         }
       
  1205     }
       
  1206 
       
  1207 // -----------------------------------------------------------------------------
       
  1208 //   CCollectionPluginTest::
       
  1209 // -----------------------------------------------------------------------------
       
  1210 //
       
  1211 void CCollectionPluginTest::HandleOpen( CMPXMedia* /*aMedia*/, TInt /*aErr*/ )
       
  1212     {
       
  1213     // LOOK! WE HANDLE!
       
  1214     }
       
  1215 
       
  1216 // -----------------------------------------------------------------------------
       
  1217 //   CCollectionPluginTest::
       
  1218 // -----------------------------------------------------------------------------
       
  1219 //
       
  1220 void CCollectionPluginTest::HandleOpen(CMPXCollectionPath* /*aPath*/, TInt /*aErr*/ )
       
  1221     {
       
  1222     // LOOK! WE HANDLE!
       
  1223     }
       
  1224 
       
  1225 // -----------------------------------------------------------------------------
       
  1226 //   CCollectionPluginTest::
       
  1227 // -----------------------------------------------------------------o------------
       
  1228 //
       
  1229 void CCollectionPluginTest::HandleOpen(
       
  1230         CMPXMedia* /*aMedia*/, 
       
  1231         const CMPXCollectionPath* /*aPath*/, 
       
  1232         TInt /*aErr*/)
       
  1233     {
       
  1234     TInt a = 0;
       
  1235     a = a+1;
       
  1236     // LOOK! WE HANDLE!
       
  1237     }
       
  1238 
       
  1239 // -----------------------------------------------------------------------------
       
  1240 //   CCollectionPluginTest::
       
  1241 // -----------------------------------------------------------------------------
       
  1242 //
       
  1243 void CCollectionPluginTest::HandleMedia( CMPXMedia* /*aMedia*/, TInt /*aError*/ )
       
  1244     {
       
  1245     TInt a = 0;
       
  1246     a = a+1;
       
  1247     // LOOK! WE HANDLE!
       
  1248     }
       
  1249 
       
  1250 // -----------------------------------------------------------------------------
       
  1251 //   CCollectionPluginTest::
       
  1252 // -----------------------------------------------------------------------------
       
  1253 //
       
  1254 void CCollectionPluginTest::HandleCommandComplete( CMPXCommand* /*aCommandResult*/, 
       
  1255                                                    TInt /*aError*/)
       
  1256     {
       
  1257     // LOOK! WE HANDLE!
       
  1258     Signal();
       
  1259     }
       
  1260 
       
  1261 // -----------------------------------------------------------------------------
       
  1262 //   CCollectionPluginTest::
       
  1263 // -----------------------------------------------------------------------------
       
  1264 //
       
  1265 void CCollectionPluginTest::HandleRemove( const CDesCArray& /*aUriArray*/, TInt /*aError*/ )
       
  1266     {
       
  1267     // LOOK! WE HANDLE!
       
  1268     }
       
  1269 
       
  1270 // -----------------------------------------------------------------------------
       
  1271 //   CCollectionPluginTest::
       
  1272 // -----------------------------------------------------------------------------
       
  1273 //
       
  1274 void CCollectionPluginTest::HandleFindAll( CMPXMedia* /*aMedia*/, TInt /*aError*/ )
       
  1275     {
       
  1276     // LOOK! WE HANDLE!
       
  1277     }
       
  1278 
       
  1279 // -----------------------------------------------------------------------------
       
  1280 //   CCollectionPluginTest::
       
  1281 // -----------------------------------------------------------------------------
       
  1282 //
       
  1283 TInt CCollectionPluginTest::AlbumsL( CStifItemParser& aItem )
       
  1284     {
       
  1285     LogMethod(_L("AlbumsL"));
       
  1286     
       
  1287     TInt error( 0 );
       
  1288     TInt deleteAlbums( 0 );
       
  1289     aItem.GetNextInt( deleteAlbums );
       
  1290     if( deleteAlbums )
       
  1291         {
       
  1292         delete iCollection->iAlbums;
       
  1293         }
       
  1294 
       
  1295     // Just check that iCollection->AlbumsL() doesn't leave
       
  1296     TRAP( error, iCollection->AlbumsL() );
       
  1297     
       
  1298     return error;
       
  1299     }
       
  1300 
       
  1301 //  [End of File] - Do not remove