mmappcomponents/harvester/collectionmediator/src/mpxcollectionmediator.cpp
changeset 0 a2952bb97e68
child 15 d240f0a77280
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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:  mediator class to handle music specific collection requirements
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <bautils.h>
       
    21 #include <mpxlog.h>
       
    22 #include <mpxcollectionutility.h>
       
    23 #include <mpxcollectionpath.h>
       
    24 #include <mpxmedia.h>
       
    25 #include <mpxmediaarray.h>
       
    26 #include <mpxmediageneraldefs.h>
       
    27 #include <mpxmediaaudiodefs.h>
       
    28 #include <mpxmediamusicdefs.h>
       
    29 #include <mpxmediacontainerdefs.h>
       
    30 #include <mpxcommandgeneraldefs.h>
       
    31 #include <mpxcollectioncommanddefs.h>
       
    32 #include <mpxcollectionplugin.hrh>
       
    33 #include <centralrepository.h>            // to get podcasting cenrep key
       
    34 
       
    35 #include <data_caging_path_literals.hrh>
       
    36 #include <mpxmediator.rsg>
       
    37 #include "mpxcollectionmediator.h"
       
    38 #include "mpxmediatorobserver.h"
       
    39 #include "mpxmoveitemhelper.h"
       
    40 
       
    41 // CONSTANTS
       
    42 _LIT( KPodCastPath, "\\podcasts\\");
       
    43 
       
    44 _LIT( KMediatorResource, "mpxmediator.rsc" );
       
    45 
       
    46 const TUid KCRUIDHarvesterFeatures  = { 0x101FFCD2 };
       
    47 const TInt KDisablePodcasting = 5;
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Default Constructor
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CMPXCollectionMediator::CMPXCollectionMediator( MMPXCollection& aColUtil,
       
    54                                                 MMPXMediatorObserver* aObs ) :
       
    55                                                 iObserver( aObs )
       
    56     {
       
    57     iColUtil = &aColUtil;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Default Constructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CMPXCollectionMediator::CMPXCollectionMediator()
       
    65     {
       
    66 
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // 2nd Phase Constructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CMPXCollectionMediator::ConstructL()
       
    74     {
       
    75     User::LeaveIfError( iFs.Connect() );
       
    76 
       
    77     TParse parse;
       
    78     TFileName resFile;
       
    79     parse.Set( KMediatorResource, &KDC_APP_RESOURCE_DIR, NULL );
       
    80     resFile.Copy(parse.FullName());
       
    81     User::LeaveIfError( MPXUser::CompleteWithDllPath( resFile ) );
       
    82 
       
    83     BaflUtils::NearestLanguageFile(iFs, resFile);
       
    84     RResourceFile resourceFile;
       
    85     resourceFile.OpenL(iFs, resFile);
       
    86     resourceFile.ConfirmSignatureL(0);  // magic
       
    87 
       
    88     TResourceReader resReader;
       
    89 
       
    90     // Get the first podcast buf
       
    91     HBufC8* buf = resourceFile.AllocReadLC( R_GENRE_PODCAST );
       
    92     resReader.SetBuffer( buf );
       
    93     iPodCastBuf = resReader.ReadHBufCL();
       
    94     CleanupStack::PopAndDestroy( buf );
       
    95     buf = NULL;
       
    96 
       
    97     // Get the second podcast buf
       
    98     buf = resourceFile.AllocReadLC( R_GENRE_PODCAST_ENGLISH );
       
    99     resReader.SetBuffer( buf );
       
   100     iPodCastEngBuf = resReader.ReadHBufCL();
       
   101     CleanupStack::PopAndDestroy( buf );
       
   102 
       
   103     // Get the unknwon podcast buf
       
   104     buf = resourceFile.AllocReadLC( R_GENRE_UNKNOWN );
       
   105     resReader.SetBuffer( buf );
       
   106     iUnknownBuf = resReader.ReadHBufCL();
       
   107     CleanupStack::PopAndDestroy( buf );
       
   108 
       
   109     // Fetch the real implementation ID for collection plugins
       
   110     RArray<TUid> ary;
       
   111     CleanupClosePushL( ary );
       
   112 
       
   113     MMPXCollectionUtility* temp = MMPXCollectionUtility::NewL();
       
   114     CleanupClosePushL( *temp );
       
   115     ary.AppendL( TUid::Uid(EMPXCollectionPluginPodCast) );
       
   116     iPodCastCollectionID = temp->CollectionIDL( ary.Array() );
       
   117 
       
   118     ary.Reset();
       
   119     ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) );
       
   120     iMusicCollectionID = temp->CollectionIDL( ary.Array() );
       
   121     CleanupStack::PopAndDestroy( temp );
       
   122 
       
   123     CleanupStack::PopAndDestroy( &ary );
       
   124 
       
   125     resourceFile.Close();
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // Two-Phased Constructor
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C CMPXCollectionMediator* CMPXCollectionMediator::NewL(
       
   134                                                     MMPXCollection& aColUtil,
       
   135                                                     MMPXMediatorObserver* aObs )
       
   136     {
       
   137     CMPXCollectionMediator* self = CMPXCollectionMediator::NewLC( aColUtil,
       
   138                                                                   aObs );
       
   139     CleanupStack::Pop( self );
       
   140     return self;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // Two-Phased Constructor
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C CMPXCollectionMediator* CMPXCollectionMediator::NewL()
       
   148     {
       
   149     CMPXCollectionMediator* self = new( ELeave ) CMPXCollectionMediator();
       
   150     CleanupStack::PushL( self );
       
   151     self->ConstructL();
       
   152     CleanupStack::Pop( self );
       
   153     return self;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // Two-Phased Constructor
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C CMPXCollectionMediator* CMPXCollectionMediator::NewLC(
       
   161                                                     MMPXCollection& aColUtil,
       
   162                                                     MMPXMediatorObserver* aObs )
       
   163     {
       
   164     CMPXCollectionMediator* self = new( ELeave ) CMPXCollectionMediator
       
   165                                                                  ( aColUtil,
       
   166                                                                    aObs );
       
   167     CleanupStack::PushL( self );
       
   168     self->ConstructL();
       
   169     return self;
       
   170     }
       
   171 
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // Destructor
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 CMPXCollectionMediator::~CMPXCollectionMediator()
       
   178     {
       
   179     iFs.Close();
       
   180 
       
   181     delete iPodCastBuf;
       
   182     delete iPodCastEngBuf;
       
   183     delete iUnknownBuf;
       
   184     delete iMoveHelper;
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CMPXCollectionMediator::AddItemL()
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C void CMPXCollectionMediator::AddItemL( CMPXMedia*& aMedia )
       
   192     {
       
   193     ASSERT( iColUtil );
       
   194 
       
   195     // If this is a podcast, change the collection id
       
   196     if( IsPodcastL( *aMedia ) )
       
   197         {
       
   198         UpdatePathToPodcastL( *aMedia );
       
   199         }
       
   200 
       
   201     // Add it to the collection
       
   202     CMPXCommand* cmd = CMPXMedia::NewL();
       
   203     CleanupStack::PushL( cmd );
       
   204 
       
   205     cmd->SetTObjectValueL(KMPXCommandGeneralId, KMPXCommandIdCollectionAdd );
       
   206     cmd->SetTObjectValueL(KMPXCommandGeneralDoSync, ETrue );
       
   207     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia); // copied
       
   208 
       
   209     if (aMedia->IsSupported(KMPXMediaGeneralCollectionId))
       
   210         {
       
   211         TUid collectionId = aMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId);
       
   212         cmd->SetTObjectValueL(KMPXCommandGeneralCollectionId, collectionId.iUid);
       
   213         }
       
   214     else
       
   215         {
       
   216         User::Leave( KErrArgument );
       
   217         }
       
   218 
       
   219     iColUtil->CommandL(*cmd);
       
   220 
       
   221     TMPXItemId mediaId = cmd->ValueTObjectL<TMPXItemId>(KMPXCommandColAddRtnId);
       
   222     CleanupStack::PopAndDestroy(cmd);
       
   223 
       
   224     // put mediaId in aMedia
       
   225     aMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, mediaId);
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // CMPXCollectionMediator::AddItemL()
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 EXPORT_C void CMPXCollectionMediator::AddItemL( CMPXMediaArray& aMPArray )
       
   233     {
       
   234     ASSERT( iColUtil );
       
   235 
       
   236     // Check each media property and update as needed
       
   237     //
       
   238     CMPXMediaArray* musicArray = CMPXMediaArray::NewL();
       
   239     CleanupStack::PushL( musicArray );
       
   240     CMPXMediaArray* podcastArray = CMPXMediaArray::NewL();
       
   241     CleanupStack::PushL( podcastArray );
       
   242 
       
   243     TInt count( aMPArray.Count() );
       
   244     for( TInt i=0; i<count; ++i )
       
   245         {
       
   246         CMPXMedia* curMP = aMPArray.AtL(i);
       
   247 
       
   248         if( IsPodcastL( *curMP ) )
       
   249             {
       
   250             // Update path to be podcast and notify observer (if needed)
       
   251             //
       
   252             if( !curMP->IsSupported(KMPXMediaGeneralCollectionId) )
       
   253                 {
       
   254                 User::Leave( KErrArgument );
       
   255                 }
       
   256 
       
   257             const TUid& oldCol = curMP->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId );
       
   258 
       
   259             UpdatePathToPodcastL( *curMP );
       
   260             if( iObserver )
       
   261                 {
       
   262                 TRAP_IGNORE(iObserver->HandleMediatorPathUpdatedL( curMP, oldCol ) );
       
   263                 }
       
   264 
       
   265             // Add this to podcast collection
       
   266             curMP->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId,
       
   267                                            iPodCastCollectionID );
       
   268             // Make a copy reference
       
   269             podcastArray->AppendL(*curMP);
       
   270             }
       
   271         else
       
   272             {
       
   273             // Make a copy reference
       
   274             musicArray->AppendL(*curMP);
       
   275             }
       
   276         }
       
   277     // Package it as a CMPXMediaContainer class, then send to collection
       
   278     //
       
   279     if( musicArray->Count() )
       
   280         {
       
   281         RArray<TInt> contId;
       
   282         CleanupClosePushL( contId );
       
   283         contId.AppendL( KMPXMediaIdGeneral );
       
   284         contId.AppendL( KMPXMediaIdContainer );
       
   285 
       
   286         CMPXMedia* container = CMPXMedia::NewL( contId.Array() );
       
   287         CleanupStack::PushL( container );
       
   288         container->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType,
       
   289                                                       EMPXGroup );
       
   290         container->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory,
       
   291                                                           EMPXCollection );
       
   292 
       
   293         container->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents,
       
   294                                                      musicArray );
       
   295         container->SetTObjectValueL<TInt>(KMPXMediaArrayCount, musicArray->Count() );
       
   296 
       
   297         // Add remainder to music collection
       
   298         DoAddToCollectionL( container, iMusicCollectionID );
       
   299         CleanupStack::PopAndDestroy( container );
       
   300         CleanupStack::PopAndDestroy( &contId );
       
   301         contId.Close();
       
   302         }
       
   303     if( podcastArray->Count() )
       
   304         {
       
   305         RArray<TInt> contId;
       
   306         CleanupClosePushL( contId );
       
   307         contId.AppendL( KMPXMediaIdGeneral );
       
   308         contId.AppendL( KMPXMediaIdContainer );
       
   309 
       
   310         CMPXMedia* container = CMPXMedia::NewL( contId.Array() );
       
   311         CleanupStack::PushL( container );
       
   312         container->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType,
       
   313                                                       EMPXGroup );
       
   314         container->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory,
       
   315                                                           EMPXCollection );
       
   316 
       
   317         container->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents,
       
   318                                                      podcastArray );
       
   319         container->SetTObjectValueL<TInt>(KMPXMediaArrayCount, podcastArray->Count() );
       
   320 
       
   321         // Add remainder to podcast collection
       
   322         DoAddToCollectionL( container, iPodCastCollectionID );
       
   323         CleanupStack::PopAndDestroy( container );
       
   324         CleanupStack::PopAndDestroy( &contId );
       
   325         contId.Close();
       
   326         }
       
   327     CleanupStack::PopAndDestroy( podcastArray );
       
   328     CleanupStack::PopAndDestroy( musicArray );
       
   329     }
       
   330 
       
   331 // ---------------------------------------------------------------------------
       
   332 // CMPXCollectionMediator::SetItemL()
       
   333 // ---------------------------------------------------------------------------
       
   334 //
       
   335 EXPORT_C void CMPXCollectionMediator::SetItemL( CMPXMediaArray& aMPArray )
       
   336     {
       
   337     ASSERT( iColUtil );
       
   338 
       
   339     // Set each item
       
   340     //
       
   341     TInt count( aMPArray.Count() );
       
   342     for( TInt i=0; i<count; ++i )
       
   343         {
       
   344         CMPXMedia* prop = aMPArray.AtL(i);
       
   345         SetItemL( prop );
       
   346         }
       
   347     }
       
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // CMPXCollectionMediator::SetItemL()
       
   351 // ---------------------------------------------------------------------------
       
   352 //
       
   353 EXPORT_C void CMPXCollectionMediator::SetItemL( CMPXMedia*& aMedia )
       
   354     {
       
   355     ASSERT( iColUtil );
       
   356 
       
   357     // UI is only going to pass fields that were modified
       
   358     //
       
   359     if( IsPodcastL( *aMedia ) )
       
   360         {
       
   361         // Convert the collection id to "KPodCastCollection" UID
       
   362         //
       
   363         const TUid& oldCol = aMedia->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId );
       
   364 
       
   365         // No need to move it is already in podcast
       
   366         if( oldCol != iPodCastCollectionID )
       
   367             {
       
   368             TRAPD( err, DoMoveItemL( aMedia, iPodCastCollectionID ) );
       
   369 
       
   370             if( err == KErrNone )
       
   371                 {
       
   372                 if( iObserver )
       
   373                     {
       
   374                     iObserver->HandleMediatorPathUpdatedL( aMedia, oldCol );
       
   375                     }
       
   376                 }
       
   377             else
       
   378                 {
       
   379                 DoSetToCollectionL( aMedia, iPodCastCollectionID );
       
   380                 }
       
   381             }
       
   382         else
       
   383             {
       
   384             DoSetToCollectionL( aMedia, iPodCastCollectionID );
       
   385             }
       
   386         }
       
   387     else
       
   388         {
       
   389         // Update as usual
       
   390         //
       
   391         DoSetToCollectionL( aMedia,
       
   392                             aMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId) );
       
   393         }
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // CMPXCollectionMediator::SetItemL()
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 EXPORT_C void CMPXCollectionMediator::SetItemL(
       
   401                                        TArray<CMPXMedia*>& /*aArray*/,
       
   402                                        CMPXCollectionPath& /*aPath*/,
       
   403                                        RArray<TInt>& /*aIndices*/ )
       
   404     {
       
   405     // Not necessary for Increment 8 timeframe
       
   406     ASSERT( iColUtil );
       
   407     ASSERT( 0 );
       
   408     }
       
   409 
       
   410 // ---------------------------------------------------------------------------
       
   411 // CMPXCollectionMediator::CheckItemL()
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C void CMPXCollectionMediator::CheckItemL( CMPXMedia& aMedia )
       
   415     {
       
   416     MPX_DEBUG1( "CMPXCollectionMediator::CheckItemL <---" );
       
   417     if( IsPodcastL( aMedia ) )
       
   418         {
       
   419         MPX_DEBUG1( "CMPXCollectionMediator::CheckItemL - changing collection id" );
       
   420         UpdatePathToPodcastL( aMedia );
       
   421         }
       
   422     }
       
   423 
       
   424 // ---------------------------------------------------------------------------
       
   425 // CMPXCollectionMediator::MoveItemL()
       
   426 // ---------------------------------------------------------------------------
       
   427 //
       
   428 EXPORT_C  void CMPXCollectionMediator::MoveItemL(
       
   429                                         CMPXMedia*& aMedia,
       
   430                                         TUid  aOldCollection,
       
   431                                         TUid  aNewCollection )
       
   432     {
       
   433     ASSERT( iColUtil );
       
   434 
       
   435     // If we are moving from podcast collection -> local audio, we strip the
       
   436     // podcast genre
       
   437     //
       
   438     if( aNewCollection == iMusicCollectionID &&
       
   439         aOldCollection == iPodCastCollectionID )
       
   440         {
       
   441         aMedia->SetTextValueL(KMPXMediaMusicGenre,
       
   442                               *iUnknownBuf );
       
   443         DoSetToCollectionL( aMedia, iPodCastCollectionID );
       
   444         }
       
   445 
       
   446     // Do the actual move operation
       
   447     //
       
   448     DoMoveItemL( aMedia, aNewCollection );
       
   449     }
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // CMPXCollectionMediator::MoveItemL()
       
   453 // ---------------------------------------------------------------------------
       
   454 //
       
   455 EXPORT_C  void CMPXCollectionMediator::MoveItemL(
       
   456                                         CMPXMedia*& aMedia,
       
   457                                         TUid  aOldCollection,
       
   458                                         TUid  aNewCollection,
       
   459                                         MMPXMoveItemObserver* aObs  )
       
   460     {
       
   461     ASSERT( iColUtil );
       
   462 
       
   463     // If we are moving from podcast collection -> local audio, we strip the
       
   464     // podcast genre
       
   465     //
       
   466     if( aNewCollection == iMusicCollectionID &&
       
   467         aOldCollection == iPodCastCollectionID )
       
   468         {
       
   469         aMedia->SetTextValueL(KMPXMediaMusicGenre,
       
   470                               *iUnknownBuf );
       
   471         DoSetToCollectionL( aMedia, iPodCastCollectionID );
       
   472         }
       
   473 
       
   474     // Do the actual move operation
       
   475     //
       
   476     delete iMoveHelper;
       
   477     iMoveHelper = NULL;
       
   478     iMoveHelper = CMPXMoveItemHelper::NewL(aObs);
       
   479     iMoveHelper->FetchAndMoveItemL( *aMedia, aNewCollection );
       
   480     }
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // CMPXCollectionMediator::IsPodcast()
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 TBool CMPXCollectionMediator::IsPodcastL( CMPXMedia& aMedia )
       
   487     {
       
   488     MPX_DEBUG1( "CMPXCollectionMediator::IsPodcast <---" );
       
   489 
       
   490     ASSERT(aMedia.IsSupported(KMPXMediaGeneralCategory));
       
   491 
       
   492     TBool isPodCast( EFalse );
       
   493 
       
   494     // Get podcasting key
       
   495     TBool disablePodcast( EFalse );
       
   496     CRepository* repository = CRepository::NewL( KCRUIDHarvesterFeatures );
       
   497     repository->Get( KDisablePodcasting, disablePodcast );
       
   498     delete repository;
       
   499 
       
   500     if ( !disablePodcast )
       
   501         {
       
   502         const TDesC& genre = aMedia.ValueText(KMPXMediaMusicGenre);
       
   503         const TDesC& path = aMedia.ValueText(KMPXMediaGeneralUri);
       
   504         if ( aMedia.ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ) != EMPXPlaylist )
       
   505             {
       
   506             if( genre.Length() )
       
   507                 {
       
   508                 // Make everything lower case for easy comparison
       
   509                 //
       
   510                 HBufC* buf = genre.AllocL();
       
   511                 TPtr ptr = buf->Des();
       
   512                 ptr.LowerCase();
       
   513 
       
   514                 if( !ptr.CompareF( *iPodCastBuf ) ||
       
   515                     !ptr.CompareF( *iPodCastEngBuf ) )
       
   516                     {
       
   517                     isPodCast = ETrue;
       
   518                     }
       
   519                 delete buf;
       
   520                 }
       
   521             if( path.Length() ) // also check podcast
       
   522                 {
       
   523                 HBufC* buf = path.AllocL();
       
   524                 TPtr ptr = buf->Des();
       
   525                 ptr.LowerCase();
       
   526 
       
   527                 if( KErrNotFound != buf->Find( KPodCastPath ) )
       
   528                     {
       
   529                     isPodCast = ETrue;
       
   530                     }
       
   531                 delete buf;
       
   532                 }
       
   533             }
       
   534         }
       
   535     MPX_DEBUG2( "CMPXCollectionMediator::IsPodcast %i --->", isPodCast );
       
   536 
       
   537     return isPodCast;
       
   538     }
       
   539 
       
   540 // ---------------------------------------------------------------------------
       
   541 // CMPXCollectionMediator::UpdatePathToPodcastL()
       
   542 // ---------------------------------------------------------------------------
       
   543 //
       
   544 void CMPXCollectionMediator::UpdatePathToPodcastL( CMPXMedia& aMedia )
       
   545     {
       
   546     aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId,
       
   547                                   iPodCastCollectionID );
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CMPXCollectionMediator::DoMoveItemL()
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CMPXCollectionMediator::DoMoveItemL( CMPXMedia*& aMedia,
       
   555                                           TUid  aNewCollection )
       
   556     {
       
   557     CMPXMoveItemHelper* mHelper = CMPXMoveItemHelper::NewL(NULL);
       
   558     CleanupStack::PushL( mHelper );
       
   559     mHelper->FetchAndMoveItemSyncL( *aMedia, aNewCollection );
       
   560     CleanupStack::PopAndDestroy( mHelper );
       
   561     }
       
   562 
       
   563 // ---------------------------------------------------------------------------
       
   564 // Add an item to the collection
       
   565 // ---------------------------------------------------------------------------
       
   566 //
       
   567 void CMPXCollectionMediator::DoAddToCollectionL( CMPXMedia* aMedia,
       
   568                                                  TUid aCollectionId )
       
   569     {
       
   570     CMPXCommand* cmd = CMPXCommand::NewL();
       
   571     CleanupStack::PushL( cmd );
       
   572 
       
   573     cmd->SetTObjectValueL( KMPXCommandGeneralId, KMPXCommandIdCollectionAdd );
       
   574     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, ETrue );
       
   575     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, aCollectionId.iUid );
       
   576     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, aMedia );
       
   577 
       
   578     iColUtil->CommandL( *cmd );
       
   579     CleanupStack::PopAndDestroy( cmd );
       
   580     }
       
   581 
       
   582 // ---------------------------------------------------------------------------
       
   583 // Set an item to the collection
       
   584 // ---------------------------------------------------------------------------
       
   585 //
       
   586 void CMPXCollectionMediator::DoSetToCollectionL( CMPXMedia* aMedia,
       
   587                                                  TUid aCollectionId )
       
   588     {
       
   589     CMPXCommand* cmd = CMPXCommand::NewL();
       
   590     CleanupStack::PushL( cmd );
       
   591 
       
   592     cmd->SetTObjectValueL( KMPXCommandGeneralId, KMPXCommandIdCollectionSet );
       
   593     cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, ETrue );
       
   594     cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, aCollectionId.iUid );
       
   595     cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia );
       
   596 
       
   597     iColUtil->CommandL( *cmd );
       
   598     CleanupStack::PopAndDestroy( cmd );
       
   599     }
       
   600 
       
   601 // END OF FILE
       
   602