videocollection/videocollectionwrapper/src/videocollectionclient.cpp
changeset 30 4f111d64a341
child 34 bbb98528c666
equal deleted inserted replaced
2:dec420019252 30:4f111d64a341
       
     1 /*
       
     2 * Copyright (c) 2009 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:   VideoCollectionClient class implementation
       
    15 * 
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <QObject>
       
    20 #include <centralrepository.h>
       
    21 #include <mpxcollectionutility.h>
       
    22 #include <mpxcollectionpath.h>
       
    23 #include <mpxmediageneraldefs.h>
       
    24 #include <mpxmessagegeneraldefs.h>
       
    25 #include <mpxmessage2.h>
       
    26 #include <mpxcollectionmessagedefs.h>
       
    27 #include <mpxcollectionmessage.h>
       
    28 #include <mpxmessagecontainerdefs.h>
       
    29 #include <mpxmediacontainerdefs.h>
       
    30 #include <mpxcommandgeneraldefs.h>
       
    31 #include <mpxcollectioncommanddefs.h>
       
    32 #include <vcxmyvideosuids.h>
       
    33 
       
    34 #include "videodatasignalreceiver.h"
       
    35 #include "videocollectionclient.h"
       
    36 #include "videocollectionlistener.h"
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // VideoCollectionClient()
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 VideoCollectionClient::VideoCollectionClient() :
       
    43 mCollectionUtility(0),
       
    44 mCollectionOpenStatus(ECollectionNotOpen),  
       
    45 mCollectionListener(0),
       
    46 mOpenCategoryAlbum(0,9),
       
    47 mCollectionPathLevel(VideoCollectionClient::ELevelInvalid)
       
    48 {
       
    49 
       
    50 }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // initialize()
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 int VideoCollectionClient::initialize()
       
    57 {
       
    58     if(mCollectionUtility && mCollectionListener)
       
    59     {
       
    60         // already initialized
       
    61         return 0;
       
    62     }
       
    63     if(!mCollectionListener)
       
    64     {
       
    65         mCollectionListener = new VideoCollectionListener(*this);
       
    66         if(!mCollectionListener)
       
    67         {
       
    68             return -1;
       
    69         }
       
    70     }
       
    71     if(!mCollectionUtility)
       
    72     {
       
    73         TRAPD( error, mCollectionUtility = MMPXCollectionUtility::NewL( mCollectionListener, KMcModeDefault ) );
       
    74         if(error)
       
    75         {
       
    76             delete mCollectionListener;
       
    77             mCollectionListener = 0;
       
    78             return error;
       
    79         }
       
    80     }
       
    81     return 0;
       
    82 }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // ~VideoCollectionClient()
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 VideoCollectionClient::~VideoCollectionClient()
       
    89 {
       
    90     if (mCollectionUtility)
       
    91     {
       
    92         // closing deallocates collection utility pointer
       
    93         mCollectionUtility->Close();
       
    94     }
       
    95     delete mCollectionListener;
       
    96 }
       
    97 
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // setVideoModelObserver
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 int VideoCollectionClient::connectCollectionSignalReceiver(
       
   104                                             VideoDataSignalReceiver *signalReceiver)
       
   105 {
       
   106     if(!mCollectionListener || !signalReceiver)
       
   107     {   
       
   108         return -1;
       
   109     }
       
   110 
       
   111 
       
   112     if(!QObject::connect(mCollectionListener, SIGNAL(newVideoList(CMPXMediaArray*)),
       
   113                        signalReceiver, SLOT(newVideoListSlot(CMPXMediaArray*)),
       
   114                        Qt::DirectConnection))
       
   115     {
       
   116         return -1;
       
   117     }
       
   118     
       
   119     if(!QObject::connect(mCollectionListener, SIGNAL(videoListAppended(CMPXMediaArray*)),
       
   120                            signalReceiver, SLOT(appendVideoListSlot(CMPXMediaArray*)),
       
   121                            Qt::DirectConnection))
       
   122     {
       
   123         return -1;
       
   124     }
       
   125     
       
   126     if(!QObject::connect(mCollectionListener, SIGNAL(newVideoAvailable(CMPXMedia*)),
       
   127                        signalReceiver, SLOT(newVideoAvailableSlot(CMPXMedia*)),
       
   128                        Qt::DirectConnection))
       
   129     {
       
   130         return -1;
       
   131     }
       
   132     
       
   133     if(!QObject::connect(mCollectionListener, SIGNAL(videoDeleted(TMPXItemId)),
       
   134                        signalReceiver, SLOT(videoDeletedSlot(TMPXItemId)),
       
   135                        Qt::DirectConnection))
       
   136     {
       
   137         return -1;
       
   138     }
       
   139     
       
   140     if(!QObject::connect(mCollectionListener, SIGNAL(videoDeleteCompleted(int, QList<TMPXItemId>*)),
       
   141                        signalReceiver, SLOT(videoDeleteCompletedSlot(int, QList<TMPXItemId>*)),
       
   142                        Qt::DirectConnection))
       
   143     {
       
   144         return -1;
       
   145     }
       
   146     
       
   147     if(!QObject::connect(mCollectionListener, SIGNAL(videoDetailsCompleted(TMPXItemId)),
       
   148                        signalReceiver, SLOT(videoDetailsCompletedSlot(TMPXItemId)),
       
   149                        Qt::DirectConnection))
       
   150     {
       
   151         return -1;
       
   152     }
       
   153     return 0;
       
   154 }
       
   155 
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // categoryIds
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void VideoCollectionClient::getCategoryIds(int& id, int& type)
       
   162 {
       
   163     id = mOpenCategoryAlbum.iId1; //unique id
       
   164     type = mOpenCategoryAlbum.iId2; //category or album
       
   165 }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // getCollectionLevel
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 int VideoCollectionClient::getCollectionLevel()
       
   172 {
       
   173     return mCollectionPathLevel;
       
   174 }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // getOpenStatus
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 int VideoCollectionClient::getOpenStatus()
       
   181 {
       
   182 	return mCollectionOpenStatus;
       
   183 }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // setOpenStatus
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void VideoCollectionClient::setOpenStatus(int status)
       
   190 {
       
   191     mCollectionOpenStatus = status;
       
   192     if(mCollectionOpenStatus == ECollectionOpened)
       
   193     {
       
   194         startOpenCurrentState();
       
   195     }
       
   196 }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // startOpenCollection
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 int VideoCollectionClient::startOpenCollection(int level)
       
   203 {
       
   204     if(!mCollectionUtility)
       
   205     {
       
   206         return -1;
       
   207     }
       
   208     
       
   209 	if((mCollectionOpenStatus == ECollectionOpening) && (getCollectionLevel() == level))
       
   210     {
       
   211         // allready opening/opened
       
   212         return 0;
       
   213     }
       
   214     mCollectionOpenStatus = ECollectionNotOpen;
       
   215     TRAPD(error, startOpenCollectionL(level));
       
   216     return error;
       
   217 }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // startOpenCurrentState
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 int VideoCollectionClient::startOpenCurrentState()
       
   224 {
       
   225     int error = -1;
       
   226     if(mCollectionUtility && mCollectionOpenStatus == ECollectionOpened)
       
   227     {
       
   228         TRAP(error, mCollectionUtility->Collection().OpenL());
       
   229     }
       
   230     return error;
       
   231 }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // deleteFile
       
   235 // -----------------------------------------------------------------------------
       
   236 int VideoCollectionClient::deleteVideos(QList<TMPXItemId> *mediaIds)
       
   237 {  
       
   238     if(!mCollectionUtility || !mediaIds)
       
   239     {
       
   240         return -1;
       
   241     }    
       
   242     TRAPD(error, deleteVideosL(*mediaIds));
       
   243     return error;    
       
   244 }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // openMedia
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 int VideoCollectionClient::openVideo(TMPXItemId &mediaId)
       
   251 {
       
   252     if(!mCollectionUtility)
       
   253     {
       
   254         return -1;
       
   255     } 
       
   256     
       
   257     TInt error;
       
   258     if (getCollectionLevel() == VideoCollectionClient::ELevelVideos)
       
   259     {
       
   260     	TRAP(error, openVideoL(mediaId));
       
   261     }
       
   262     else
       
   263     {
       
   264     	TRAP(error, openCategoryL(mediaId));
       
   265     }
       
   266     return error;
       
   267 }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // back
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 int VideoCollectionClient::back()
       
   274 {
       
   275     if(!mCollectionUtility)
       
   276     {
       
   277         return -1;
       
   278     } 
       
   279     TRAPD(error, backL());
       
   280     return error;
       
   281 }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // fetchMpxMediaByMpxId
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 int VideoCollectionClient::fetchMpxMediaByMpxId(TMPXItemId &mpxId)
       
   288 {
       
   289     if(!mCollectionUtility)
       
   290     {
       
   291         return -1;
       
   292     }
       
   293    
       
   294     TRAPD(error, fetchMpxMediaByMpxIdL(mpxId));
       
   295     return error;
       
   296 }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // getVideoDetails
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 int VideoCollectionClient::getVideoDetails(TMPXItemId &mediaId)
       
   303 {
       
   304     if(!mCollectionUtility)
       
   305     {
       
   306         return -1;
       
   307     }
       
   308     
       
   309     TRAPD(error, getVideoDetailsL(mediaId));
       
   310    
       
   311     return error;
       
   312 }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // addNewCollection
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 int VideoCollectionClient::addNewCollection(QString name, QString thumbnail, QList<TMPXItemId> mediaIds)
       
   319 {
       
   320     if(!mCollectionUtility)
       
   321     {
       
   322         return -1;
       
   323     }
       
   324     
       
   325     TRAPD(error, addNewCollectionL(name, thumbnail, mediaIds));
       
   326     
       
   327     return error;
       
   328 }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // startOpenCollectionL
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 void VideoCollectionClient::startOpenCollectionL(int level)
       
   335 {
       
   336     if(!mCollectionUtility)
       
   337     {
       
   338         User::Leave(KErrGeneral);
       
   339     }
       
   340     CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
       
   341     CleanupStack::PushL( collectionPath );
       
   342   
       
   343     collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
       
   344     if (level == VideoCollectionClient::ELevelVideos)
       
   345     {
       
   346     	collectionPath->AppendL( KVcxMvcCategoryIdAll );
       
   347     	
       
   348 		mOpenCategoryAlbum.iId1 = KVcxMvcCategoryIdAll;
       
   349     	mOpenCategoryAlbum.iId2 = 1;
       
   350     	
       
   351     	mCollectionPathLevel = VideoCollectionClient::ELevelVideos;
       
   352     }
       
   353     else
       
   354     {
       
   355     	mOpenCategoryAlbum.iId1 = 0;
       
   356     	mOpenCategoryAlbum.iId2 = 9;
       
   357     	
       
   358     	mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
       
   359     }
       
   360     mCollectionUtility->Collection().OpenL( *collectionPath );
       
   361     CleanupStack::PopAndDestroy( collectionPath );  
       
   362     mCollectionListener->setRequestNewMediaArray(true);
       
   363     mCollectionOpenStatus = ECollectionOpening;
       
   364 }
       
   365 
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // deleteVideosL
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 void VideoCollectionClient::deleteVideosL(QList<TMPXItemId> &mediaIds)
       
   372 {
       
   373     if(!mCollectionUtility || mediaIds.count() == 0)
       
   374     {
       
   375         User::Leave(KErrGeneral);
       
   376     }
       
   377     CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
       
   378     CleanupStack::PushL( mediasToDelete );
       
   379     
       
   380     CMPXMedia* media = NULL;
       
   381 
       
   382     TMPXItemId currentId;
       
   383     foreach(currentId, mediaIds)
       
   384     {
       
   385         media = CMPXMedia::NewL();
       
   386         CleanupStack::PushL( media );
       
   387         media->SetTObjectValueL( KMPXMediaGeneralId, currentId );
       
   388         mediasToDelete->AppendL( *media );
       
   389         CleanupStack::PopAndDestroy( media );
       
   390     }
       
   391     
       
   392     CMPXCommand* cmd = CMPXMedia::NewL();
       
   393     CleanupStack::PushL( cmd );
       
   394 
       
   395     cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
       
   396     cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosDelete );    
       
   397     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse );
       
   398     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, 
       
   399                            TUid::Uid( KVcxUidMyVideosMpxCollection ) );
       
   400     cmd->SetCObjectValueL( KMPXMediaArrayContents, mediasToDelete );
       
   401 
       
   402     mCollectionUtility->Collection().CommandL( *cmd );
       
   403 
       
   404     CleanupStack::PopAndDestroy( cmd );  
       
   405     CleanupStack::PopAndDestroy( mediasToDelete ); 
       
   406 }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // openVideoL
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 void VideoCollectionClient::openVideoL(TMPXItemId &videoId)
       
   413 {
       
   414     if(!mCollectionUtility)
       
   415     {
       
   416         User::Leave(KErrGeneral);
       
   417     } 
       
   418     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   419     CleanupStack::PushL( path );
       
   420     path->AppendL( KVcxUidMyVideosMpxCollection );
       
   421     path->AppendL( KVcxMvcCategoryIdAll );
       
   422     path->AppendL( TMPXItemId( videoId, 0 ) );
       
   423     path->SelectL( TMPXItemId( videoId, 0 ) );
       
   424       
       
   425     mCollectionUtility->Collection().OpenL( *path );
       
   426     CleanupStack::PopAndDestroy( path );  
       
   427 }
       
   428 
       
   429 // -----------------------------------------------------------------------------
       
   430 // openCategoryL
       
   431 // -----------------------------------------------------------------------------
       
   432 //
       
   433 void VideoCollectionClient::openCategoryL(TMPXItemId &id)
       
   434 {    
       
   435     if(!mCollectionUtility)
       
   436     {
       
   437         User::Leave(KErrGeneral);
       
   438     } 
       
   439     CMPXCollectionPath* collectionPath = CMPXCollectionPath::NewL();
       
   440     CleanupStack::PushL( collectionPath );
       
   441   
       
   442     collectionPath->AppendL( KVcxUidMyVideosMpxCollection );
       
   443     collectionPath->AppendL( id );
       
   444     mCollectionUtility->Collection().OpenL( *collectionPath );
       
   445     CleanupStack::PopAndDestroy( collectionPath );  
       
   446     mCollectionListener->setRequestNewMediaArray(true);
       
   447     
       
   448 	mOpenCategoryAlbum.iId1 = id;
       
   449 	mOpenCategoryAlbum.iId2 = 1;
       
   450     
       
   451 	mCollectionPathLevel = VideoCollectionClient::ELevelVideos;
       
   452     
       
   453     mCollectionOpenStatus = ECollectionOpening;
       
   454 }
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // backL
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 void VideoCollectionClient::backL()
       
   461 {
       
   462     if(!mCollectionUtility)
       
   463     {
       
   464         User::Leave(KErrGeneral);
       
   465     } 
       
   466     
       
   467     if (getCollectionLevel() > 2 )
       
   468     {
       
   469     	mCollectionUtility->Collection().BackL();
       
   470     	mCollectionOpenStatus = ECollectionOpening;
       
   471     	mCollectionListener->setRequestNewMediaArray(true);
       
   472     	mOpenCategoryAlbum.iId1 = 0;
       
   473     	mOpenCategoryAlbum.iId2 = 9;
       
   474     	
       
   475     	mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
       
   476     }
       
   477 }
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 // getVideoDetailsL
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 void VideoCollectionClient::getVideoDetailsL(TMPXItemId &videoId)
       
   484 {
       
   485     if(!mCollectionUtility)
       
   486     {
       
   487         User::Leave(KErrGeneral);
       
   488     }
       
   489     CMPXCommand* cmd = CMPXCommand::NewL();
       
   490     CleanupStack::PushL( cmd );
       
   491     
       
   492     cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
       
   493     cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediaFullDetailsByMpxId );
       
   494     cmd->SetTObjectValueL( KMPXMediaGeneralId, videoId );
       
   495     mCollectionUtility->Collection().CommandL( *cmd );
       
   496     
       
   497     CleanupStack::PopAndDestroy( cmd );  
       
   498 }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // addNewCollectionL
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 void VideoCollectionClient::addNewCollectionL(QString name, QString thumbnail, QList<TMPXItemId> mediaIds)
       
   505 {
       
   506     if(!mCollectionUtility)
       
   507     {
       
   508         User::Leave(KErrGeneral);
       
   509     }
       
   510     
       
   511     CMPXCommand* cmd = CMPXCommand::NewL();
       
   512     CleanupStack::PushL( cmd );
       
   513     
       
   514     cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
       
   515     cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, -1 );
       
   516     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, ETrue );
       
   517     cmd->SetTObjectValueL( KMPXMediaGeneralTitle, name );
       
   518     cmd->SetTObjectValueL( KMPXMediaGeneralThumbnail1, thumbnail );
       
   519     
       
   520     // TODO real command id missing, uncomment only after the collection supports adding collections
       
   521 //    mCollectionUtility->Collection().CommandL( *cmd );
       
   522     
       
   523     CleanupStack::PopAndDestroy( cmd );
       
   524     
       
   525     if(mediaIds.size() > 0) {
       
   526         cmd = CMPXCommand::NewL();
       
   527         CleanupStack::PushL( cmd );
       
   528         CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL();
       
   529         CleanupStack::PushL( idMediaArray );
       
   530         
       
   531         cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
       
   532         cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, -1 );
       
   533         cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
       
   534                                        TUid::Uid( KVcxUidMyVideosMpxCollection ) );
       
   535         
       
   536         // TODO need to add the mpxid of the newly created collection here.
       
   537         
       
   538         TMPXItemId mediaId;
       
   539         foreach(mediaId, mediaIds) {
       
   540             CMPXMedia* media = CMPXMedia::NewL();
       
   541             CleanupStack::PushL( media );
       
   542             media->SetTObjectValueL( KMPXMessageMediaGeneralId, mediaId );
       
   543             idMediaArray->AppendL( *media );
       
   544             CleanupStack::PopAndDestroy( media );
       
   545         }
       
   546         
       
   547         cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray );
       
   548         cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() );
       
   549         
       
   550         // TODO real command id missing, only uncomment after collection supports adding collections.
       
   551 //        mCollectionUtility->Collection().CommandL( *cmd );
       
   552         
       
   553         CleanupStack::PopAndDestroy( idMediaArray );
       
   554         CleanupStack::PopAndDestroy( cmd );
       
   555     }
       
   556 }
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // fetchMpxMediaByMpxIdL
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void VideoCollectionClient::fetchMpxMediaByMpxIdL(TMPXItemId &aMpxId)
       
   563 {
       
   564     if(!mCollectionUtility)
       
   565     {
       
   566         User::Leave(KErrGeneral);
       
   567     }
       
   568 
       
   569     CMPXCommand* cmd = CMPXCommand::NewL();
       
   570     CleanupStack::PushL( cmd );
       
   571     cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos );
       
   572     cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosGetMediasByMpxId );
       
   573     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId,
       
   574                                    TUid::Uid( KVcxUidMyVideosMpxCollection ) );
       
   575    
       
   576     CMPXMediaArray* idMediaArray = CMPXMediaArray::NewL();
       
   577     CleanupStack::PushL( idMediaArray );
       
   578     CMPXMedia* media = CMPXMedia::NewL();
       
   579     CleanupStack::PushL( media );
       
   580     media->SetTObjectValueL( KMPXMessageMediaGeneralId, aMpxId );
       
   581     idMediaArray->AppendL( *media );
       
   582     cmd->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, idMediaArray );
       
   583     cmd->SetTObjectValueL( KMPXMediaArrayCount, idMediaArray->Count() );
       
   584     mCollectionUtility->Collection().CommandL( *cmd );
       
   585    
       
   586     CleanupStack::PopAndDestroy( media );  
       
   587     CleanupStack::PopAndDestroy( idMediaArray );  
       
   588     CleanupStack::PopAndDestroy( cmd );  
       
   589 }
       
   590 
       
   591