mmappcomponents/collectionhelper/inc/mpxcollectionuihelperimp.h
changeset 0 a2952bb97e68
child 2 7a9a8e73f54b
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:  Collection Ui helper implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPX_COLLECTION_UI_HELPER_H
       
    20 #define CMPX_COLLECTION_UI_HELPER_H
       
    21 
       
    22 #include <mpxcollectionobserver.h>
       
    23 #include <mpxcollectionpath.h>
       
    24 #include <mpxtaskqueueobserver.h>
       
    25 #include <mpxcollectionuihelperobserver.h>
       
    26 #include "mpxcollectionuihelper.h"
       
    27 #include "mpxmediatorobserver.h"
       
    28 #include "mpxmoveobserver.h"
       
    29 #include "mpxharvesterutilityobserver.h"
       
    30 
       
    31 // FOWARD DECLARATION
       
    32 class MMPXCollectionUtility;
       
    33 class CMPXCollectionMediator;
       
    34 class MMPXHarvesterUtility;
       
    35 class CMPXMedia;
       
    36 class TMPXCollectionMessage;
       
    37 class CMPXActiveTaskQueue;
       
    38 class CMPXDeleteHelper;
       
    39 
       
    40 /**
       
    41  *  CMPXCollectionUiHelper
       
    42  *
       
    43  *  Implementation of the collection ui helper interface
       
    44  *  for system specific changes
       
    45  *
       
    46  *  @lib collectionhelper.lib
       
    47  *  @since S60 3.0
       
    48  */
       
    49 NONSHARABLE_CLASS( CMPXCollectionUiHelperImp ): public CBase,
       
    50                                           public MMPXCollectionUiHelper,
       
    51                                           public MMPXMediatorObserver,
       
    52                                           public MMPXHarvesterUtilityObserver,
       
    53                                           public MMPXCollectionObserver,
       
    54                                           public MMPXTaskQueueObserver,
       
    55                                           public MMPXMoveItemObserver,
       
    56                                           public MMPXCHelperObserver
       
    57 
       
    58     {
       
    59 public:
       
    60 
       
    61     /**
       
    62     * Standard 2-phased constructor
       
    63     * @param aModeId collection mode id. see mpxcollectionutility.h
       
    64     *        for details.
       
    65     * @return new instance of the collection ui helper
       
    66     */
       
    67     static CMPXCollectionUiHelperImp* NewL(const TUid& aModeId);
       
    68 
       
    69     /**
       
    70     * Standard 2-phased constructor
       
    71     * @param aModeId collection mode id. see mpxcollectionutility.h
       
    72     *        for details.
       
    73     * @return new instance of the collection ui helper
       
    74     */
       
    75     static CMPXCollectionUiHelperImp* NewLC(const TUid& aModeId);
       
    76 
       
    77     /**
       
    78     * Virtual Destructor
       
    79     */
       
    80     virtual ~CMPXCollectionUiHelperImp();
       
    81 
       
    82 protected:
       
    83 
       
    84     /**
       
    85     * From MMPXCollectionUiHelper
       
    86     *
       
    87     * This is an async call to create a playlist or add songs to
       
    88     * a saved playlist. In the case of creating a new playlist,
       
    89     * no physical playlist files will be created. This type of
       
    90     * playlists is referred to as virtual playlists. In the case
       
    91     * of adding songs to a saved playlist, if the playlist
       
    92     * corresponds to a playlist file, the playlist file is NOT
       
    93     * updated.
       
    94     *
       
    95     * Upon completion of this request, HandleAddCompletedL is called.
       
    96     *
       
    97     * To add a playlist to the collection, the media provided MUST
       
    98     * contain the following attributes:
       
    99     *    KMPXMediaGeneralType:
       
   100     *       must be EMPXItem
       
   101     *
       
   102     *    KMPXMediaGeneralCategory:
       
   103     *       must be EMPXPlaylist
       
   104     *
       
   105     *    KMPXMediaGeneralUri:
       
   106     *       This is the path where the playlist should be located.
       
   107     *       e.g. c:\data\playlists\ or e:\playlists\. When the playlist
       
   108     *       is successfully added to the collection, its URI will be
       
   109     *       generated. If client is interested its URI, client can
       
   110     *       perform a search based on the returned Id of the playlist.
       
   111     *       Currently only supporting local path, i.e. the path provided
       
   112     *       must contain starts with a drive letter.
       
   113     *
       
   114     *    KMPXMediaGeneralTitle:
       
   115     *       Title of the playlist is NOT enforced be unique within the
       
   116     *       music collection.
       
   117     *
       
   118     *    KMPXMediaArrayCount:
       
   119     *    KMPXMediaArrayContents:
       
   120     *       This playlist can be an empty playlist. If this is the case,
       
   121     *       KMPXMediaArrayContents will be a CMPXMediaArray that doesn't
       
   122     *       contain any media and KMPXMediaArrayCount will be 0.
       
   123     *
       
   124     *       Each CMPXMedia contained in the media array represents
       
   125     *       a song. Each song must contain the following attributes:
       
   126     *           KMPXMediaGeneralType:
       
   127     *               must be EMPXItem
       
   128     *
       
   129     *           KMPXMediaGeneralCategory:
       
   130     *               must be EMPXSong
       
   131     *
       
   132     *       For songs that already exist in the collection, client
       
   133     *       must provide either KMPXMediaGeneralId or KMPXMediaGeneralUri.
       
   134     *
       
   135     *       For songs that do not exist in the collection, client must
       
   136     *       provide KMPXMediaGeneralUri and its metadata. These songs
       
   137     *       will be added to the music collection when the playlist is
       
   138     *       added. These songs added to the collection are NOT registered
       
   139     *       with Harvester; hence, during next scan/refresh, these songs
       
   140     *       will be scanned and updated in the collection unnecessarily
       
   141     *       and cause scan/refresh performance degradation. If any
       
   142     *       metadata of these songs is changed in the collection before
       
   143     *       next scan/refresh, it will be lost after scan/refresh.
       
   144     *
       
   145     *       WARNING:
       
   146     *       Client must add the songs to the collection prior to adding
       
   147     *       the playlist.
       
   148     *
       
   149     *    WARNING:
       
   150     *    This playlist is NOT registered with Harvester. If client
       
   151     *    creates a physical playlist file, Harvester will re-parse
       
   152     *    and update the playlist in the collection during the next
       
   153     *    scan/refresh unnecessarily and cause scan/refresh performance
       
   154     *    degradation. If this playlist is edited, the physical
       
   155     *    playlist file is NOT updated to reflect the changes.
       
   156     *
       
   157     *    If the playlist is successfully added to the collection,
       
   158     *    the media returned in the callback will contain the Id
       
   159     *    of the playlist.
       
   160     *
       
   161     * To add songs to a saved playlist, the media provided MUST
       
   162     * contain the following attributes:
       
   163     *    KMPXMediaGeneralType:
       
   164     *       must be EMPXItem
       
   165     *
       
   166     *    KMPXMediaGeneralCategory:
       
   167     *       must be EMPXPlaylist
       
   168     *
       
   169     *    This playlist must already exist in the collection, client
       
   170     *    must provide either KMPXMediaGeneralId or KMPXMediaGeneralUri
       
   171     *    for locating which playlist to add the songs to.
       
   172     *
       
   173     *    KMPXMediaArrayCount:
       
   174     *       indicates the number of songs to be added to the playlist
       
   175     *
       
   176     *    KMPXMediaArrayContents:
       
   177     *       This contains an array of songs to be added/appended
       
   178     *       to the playlist. Each media in the array represents
       
   179     *       a song. Each song must contain the following attributes:
       
   180     *           KMPXMediaGeneralType:
       
   181     *               must be EMPXItem
       
   182     *
       
   183     *           KMPXMediaGeneralCategory:
       
   184     *               must be EMPXSong
       
   185     *
       
   186     *       These songs must already exist in the collection. Client
       
   187     *       must provide either KMPXMediaGeneralId or KMPXMediaGeneralUri.
       
   188     *
       
   189     * This method will leave with KErrArgument if any mandatory
       
   190     * is missing.
       
   191     *
       
   192     * @param aMedia, a media to be added to the system
       
   193     * @param aObserver, an observer for callback when
       
   194     *        operation is compelte. Leaves with KErrArgument if
       
   195     *        observer provided is NULL. The Id of playlist will
       
   196     *        be accessible via the KMPXMediaGeneralId of the media
       
   197     *        returned in the callback.
       
   198     *
       
   199     */
       
   200     void AddL( const CMPXMedia& aMedia,
       
   201                MMPXCHelperObserver* aObserver );
       
   202    
       
   203     
       
   204     /**
       
   205     * From MMPXCollectionUiHelper    
       
   206     *
       
   207     * This is exactly the same as AddL except that songs in aMedia
       
   208     * is added incrementally (in chunks).
       
   209     * It should accept the same input and the same output as if AddL
       
   210     * is used.
       
   211     * @param aMedia, a media to be added to the system
       
   212     * @param aObserver, an observer for callback when
       
   213     *        operation is compelte. Leaves with KErrArgument if
       
   214     *        observer provided is NULL. The Id of playlist will
       
   215     *        be accessible via the KMPXMediaGeneralId of the media
       
   216     *        returned in the callback.
       
   217     * @param aSize, the number of songs to be added in each chunk
       
   218     */
       
   219     void IncAddL( const CMPXMedia& aMedia,
       
   220                   MMPXCHelperObserver* aObserver,
       
   221                   const TInt aSize );
       
   222 
       
   223     /**
       
   224     * From MMPXCollectionUiHelper
       
   225     *
       
   226     * Asynchronously updates a media in the collection. For performance
       
   227     * consideration, it is recommended that client only sets the attribute
       
   228     * that needs to be updated.
       
   229     *
       
   230     * @param aMedia, media to be updated.
       
   231     *
       
   232     *        To update a song in the collection, the media provided MUST
       
   233     *        contain the following attributes:
       
   234     *           KMPXMediaGeneralType:
       
   235     *               must be EMPXItem
       
   236     *
       
   237     *           KMPXMediaGeneralCategory:
       
   238     *               must be EMPXSong
       
   239     *
       
   240     *           KMPXMediaGeneralId or KMPXMediaGeneralUri:
       
   241     *               for identifying which song to update
       
   242     *
       
   243     *        Additionally, this media should provide one or more of the
       
   244     *        following attributes for update:
       
   245     *               KMPXMediaGeneralTitle
       
   246     *               KMPXMediaGeneralComment
       
   247     *               KMPXMediaGeneralSynchronized
       
   248     *               KMPXMediaGeneralDeleted
       
   249     *               KMPXMediaGeneralModified
       
   250     *               KMPXMediaGeneralCopyright
       
   251     *               KMPXMediaGeneralDuration
       
   252     *               KMPXMediaGeneralFlags
       
   253     *               KMPXMediaGeneralPlayCount
       
   254     *               KMPXMediaGeneralLastPlaybackTime
       
   255     *           KMPXMediaIdMusic:
       
   256     *               KMPXMediaMusicArtist
       
   257     *               KMPXMediaMusicAlbum
       
   258     *               KMPXMediaMusicAlbumTrack
       
   259     *               KMPXMediaMusicGenre
       
   260     *               KMPXMediaMusicComposer
       
   261     *               KMPXMediaMusicYear
       
   262     *               KMPXMediaMusicRating
       
   263     *               KMPXMediaMusicAlbumArtFileName
       
   264     *               KMPXMediaMusicURL
       
   265     *           KMPXMediaIdAudio:
       
   266     *               KMPXMediaAudioSamplerate
       
   267     *               KMPXMediaAudioBitrate
       
   268     *               KMPXMediaAudioNumberOfChannels
       
   269     *           KMPXMediaIdDrm:
       
   270     *               KMPXMediaDrmType
       
   271     *           KMPXMediaIdMTP:
       
   272     *               KMPXMediaMTPDrmStatus
       
   273     *
       
   274     *        To update a playlist in the collection, the media provided MUST
       
   275     *        contain the following attributes:
       
   276     *           KMPXMediaGeneralType:
       
   277     *               must be EMPXItem
       
   278     *
       
   279     *           KMPXMediaGeneralCategory:
       
   280     *               must be EMPXPlaylist
       
   281     *
       
   282     *           KMPXMediaGeneralId or KMPXMediaGeneralUri:
       
   283     *               for identifying which playlist to update
       
   284     *
       
   285     *        If the media contains KMPXMediaArrayContents attribute, the
       
   286     *        content of the playlist will be overwritten with the new media
       
   287     *        array. If this attribute contains a CMPXMediaArray of 0 element,
       
   288     *        all songs in this playlist will be removed from the playlist
       
   289     *        (songs will remain in the collection and file system).
       
   290     *        e.g.
       
   291     *        1) "Playlist" originally contains "Song1", "Song2", and "Song3".
       
   292     *           If KMPXMediaArrayContents contains a CMPXMediaArray that
       
   293     *           contains "Song3" and "Song4", "Playlist" will be updated to
       
   294     *           contain "Song3" and "Song4".
       
   295     *        2) "Playlist" originally contains "Song1", "Song2", and "Song3".
       
   296     *           If KMPXMediaArrayContents contains a CMPXMediaArray that
       
   297     *           contains 0 element, "Playlist" will be updated so that it
       
   298     *           doesn't contain any songs. "Song1", "Song2", and "Song3"
       
   299     *           will remain in the collection.
       
   300     *
       
   301     *       If the media contains any of the following attributes, the
       
   302     *       playlist will be updated accordingly:
       
   303     *               KMPXMediaGeneralTitle
       
   304     *               KMPXMediaGeneralSynchronized
       
   305     *               KMPXMediaGeneralDeleted (DEPRECATED)
       
   306     *               KMPXMediaGeneralModified (DEPRECATED)
       
   307     *
       
   308     *       NOTE: If a client wishes to change the playlist title and modify
       
   309     *             its contents (i.e. the songs it includes), client needs to
       
   310     *             perform two separate SetL operations; one to update the
       
   311     *             playlist title providing KMPXMediaGeneralTitle attribute
       
   312     *             and the other to update its contents by providing
       
   313     *             KMPXMediaArrayContents.
       
   314     *
       
   315     * @param aObserver, an observer for callback when operation is complete.
       
   316     *        KErrArgument if NULL.
       
   317     */
       
   318     void SetL( CMPXMedia*& aMedia,
       
   319                MMPXCHelperObserver* aObserver );
       
   320 
       
   321     /**
       
   322     * From MMPXCollectionUiHelper
       
   323     *
       
   324     * Asynchronously updates a list of medias in the collection. This is
       
   325     * NOT currently implemented.
       
   326     *
       
   327     * @param aMediaArray, list of medias
       
   328     * @param aPath, collection path
       
   329     * @param aIndices, array of indicies to collection path
       
   330     */
       
   331     void SetL( TArray<CMPXMedia*>& aMediaArray,
       
   332                CMPXCollectionPath& aPath,
       
   333                RArray<TInt>& aIndices);
       
   334 
       
   335     /**
       
   336     * From MMPXCollectionUiHelper
       
   337     *
       
   338     * Asynchronously renames a media. This method will be DEPRECATED as client
       
   339     * can use SetL to update the title of a song or a playlist.
       
   340     *
       
   341     * @param aMedia media to be renamed
       
   342     *
       
   343     *        Currently only supporting renaming of a playlist. This media
       
   344     *        MUST contain the following attributes:
       
   345     *           KMPXMediaGeneralType:
       
   346     *               must be EMPXItem
       
   347     *
       
   348     *           KMPXMediaGeneralCategory:
       
   349     *               must be EMPXPlaylist
       
   350     *
       
   351     *           KMPXMediaGeneralId:
       
   352     *               for identifying which playlist to rename
       
   353     *
       
   354     *           KMPXMediaGeneralTitle:
       
   355     *               new title of the playlist
       
   356     *
       
   357     *        This method will leave with KErrArgument if any mandatory is
       
   358     *        missing. URI of the playlist remains unchanged when its title
       
   359     *        is changed.
       
   360     *
       
   361     * @param aObserver an observer for callback when operation is complete.
       
   362     *        KErrArgument if NULL.
       
   363     */
       
   364     void RenameL( const CMPXMedia& aMedia,
       
   365                   MMPXCHelperObserver* aObserver );
       
   366 
       
   367     /**
       
   368     * From MMPXCollectionUiHelper
       
   369     *
       
   370     * Asynchronously deletes a media or medias based on the collection path.
       
   371     * If this collection path refers to multiple medias, the referred medias
       
   372     * are deleted one by one. If the media correlates to a file in the file
       
   373     * system, the correlating file is deleted from the file system. If the
       
   374     * file is in use, operation will proceed to the next media and upon
       
   375     * operation completion, KErrInUse is returned via callback.
       
   376     * If the file has already been deleted from the file system, operation
       
   377     * will also proceed to the next media as normal.
       
   378     *
       
   379     * This operation is cancelable via Cancel(),
       
   380     *
       
   381     * @param aPath collection path to the media to be removed
       
   382     * @param aObserver an observer for callback when operation is complete.
       
   383     *        KErrArgument if NULL.
       
   384     */
       
   385     void DeleteL( CMPXCollectionPath& aPath,
       
   386                   MMPXCHelperObserver* aObserver );
       
   387 
       
   388     /**
       
   389     * From MMPXCollectionUiHelper
       
   390     *
       
   391     * Move an item from one collection to another
       
   392     *
       
   393     * @param aMedia media to be moved.
       
   394     * @param aNewCollection uid of the collection defined in collectionplugins.hrh
       
   395     * @param aObserver observer for the event. if aObs is NULL, sync, not NULL async.
       
   396     */
       
   397     void MoveL( CMPXMedia*& aMedia,
       
   398                 TUid aNewCollection,
       
   399                 MMPXCHelperObserver* aObserver = NULL );  //lint !e1735
       
   400 
       
   401     /**
       
   402     * From MMPXCollectionUiHelper
       
   403     * Open the collection in embedded mode with a Media Object
       
   404     * @param aHostId Host Process UID to identify this embedded instance
       
   405     * @param aMedia Media Object to open
       
   406     * @param aObserver observer to handle errors
       
   407     * @param aPluginInfo additional argument to pass to the plugin resolver
       
   408     */
       
   409     void OpenL( const TUid& aHostId, CMPXMedia& aMedia,
       
   410                 MMPXCHelperEmbeddedOpenObserver* aObserver,
       
   411                 TInt aPluginInfo = 0 );  //lint !e1735
       
   412 
       
   413     /**
       
   414     * From MMPXCollectionUiHelper
       
   415     * Open the collection in embedded mode with a File Handle
       
   416     * @param aHostId Host Process UID to identify this embedded instance
       
   417     * @param aFile File handle that we have to process
       
   418     * @param aObserver observer to handle errors
       
   419 
       
   420     */
       
   421     void OpenL( const TUid& aHostId, const TDesC& aFile,
       
   422                 MMPXCHelperEmbeddedOpenObserver* aObserver,
       
   423                 TInt aPluginInfo = 0 );  //lint !e1735
       
   424 
       
   425     /**
       
   426     * From MMPXCollectionUiHelper
       
   427     * Open the collection in embedded mode with a File Handle
       
   428     * @param aFile File handle that we have to process
       
   429     * @param aObserver, observer to the open operation
       
   430     */
       
   431     void OpenL( RFile& aFile, MMPXCHelperEmbeddedOpenObserver* aObserver );
       
   432 
       
   433     /**
       
   434     * From MMPXCollectionUiHelper
       
   435     * Queries about the playlist file extension of the currently selected playlist
       
   436     * plugin
       
   437     * @return file extension of the playlist type which includes the period
       
   438     */
       
   439     HBufC* PlaylistFileExtensionLC();
       
   440 
       
   441     /**
       
   442     * From MMPXCollectionUiHelper
       
   443     * Export the specified playlist to a file
       
   444     * @param aPlaylistId, id of the playlist to be exported
       
   445     * @param aDestinationDriveAndPath, specifies where the playlist file should
       
   446     *        be created. If the file already exists, it will be overwritten.
       
   447     * @param aObs observer for the callback. URI of the exported playlist
       
   448     *        will be returned as a HBufC* which client takes over the
       
   449     *        ownership
       
   450     */
       
   451     void ExportPlaylistL(TMPXItemId aPlaylistId,
       
   452                          const TDesC& aDestinationDriveAndPath,
       
   453                          MMPXCHelperObserver* aObserver);
       
   454 
       
   455     /**
       
   456     * From MMPXCollectionUiHelper
       
   457     * Reorder a song in the playlist
       
   458     * @param aPlaylistId id of the playlist which contains the song to be reordered
       
   459     * @param aSongId id of the song to be reordered
       
   460     * @param aOriginalOrdinal the original ordinal of the song within the playlist.
       
   461     *        Ordinal starts from 0.
       
   462     * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
       
   463     *        starts from 0.
       
   464     * @param aObs observer for the callback
       
   465     */
       
   466     void ReorderPlaylistL(const TMPXItemId& aPlaylistId,
       
   467                           const TMPXItemId& aSongId,
       
   468                           TUint aOriginalOrdinal,
       
   469                           TUint aNewOrdinal,
       
   470                           MMPXCHelperObserver* aObserver);
       
   471 
       
   472     /**
       
   473     * From MMPXCollectionUiHelper
       
   474     * Gets the collection path to the main music menu
       
   475     * Call OpenL() with this path to open music menu
       
   476     * @return CMPXCollectionPath*, ownership transferred
       
   477     */
       
   478     CMPXCollectionPath* MusicMenuPathL();
       
   479 
       
   480     /**
       
   481     * From MMPXCollectionUiHelper
       
   482     * Gets the collection path to the podcast menu
       
   483     * Call OpenL() with this path to open podcast menu
       
   484     * @return CMPXCollectionPath*, ownership transferred
       
   485     */
       
   486     CMPXCollectionPath* PodCastMenuPathL();
       
   487 
       
   488     /**
       
   489     * From MMPXCollectionUiHelper
       
   490     * Gets the collection path to the main all songs view
       
   491     * Call OpenL() with this path to open music all songs view
       
   492     * @return CMPXCollectionPath*, ownership transferred
       
   493     */
       
   494     CMPXCollectionPath* MusicAllSongsPathL();
       
   495 
       
   496     /**
       
   497     * From MMPXCollectionUiHelper
       
   498     * Gets the collection path to the music playlist
       
   499     * Call OpenL() with this path to open music playlist menu
       
   500     * @return CMPXCollectionPath*, ownership transferred
       
   501     */
       
   502     CMPXCollectionPath* MusicPlaylistPathL();
       
   503 
       
   504     /**
       
   505     * From MMPXCollectionUiHelper
       
   506     * Gets the collection path to the music playlist
       
   507     * Call OpenL() with this path to open music playlist menu
       
   508     * @param aPlaylistType type of auto playlist
       
   509     * @return CMPXCollectionPath*, ownership transferred
       
   510     */
       
   511     CMPXCollectionPath* MusicPlaylistPathL(TMPXAutoPlaylistType aPlaylistType);
       
   512 
       
   513     /**
       
   514     * From MMPXCollectionUiHelper
       
   515     * Creates a default playlist path to open. Hardcoded to Music Collection / All songs
       
   516     * @return CollectionPath*, ownership transferred.
       
   517     */
       
   518     CMPXCollectionPath* CreateDefaultPlaylistPathLC();
       
   519 
       
   520     /**
       
   521     * From MMPXCollectionUiHelper
       
   522     * Cancels current async request
       
   523     * NOTE: Currently only Cancelling DeleteL() is supported
       
   524     */
       
   525     void Cancel();
       
   526 
       
   527     /**
       
   528     * From MMPXCollectionUiHelper
       
   529     * Frees this object
       
   530     */
       
   531     void Close();
       
   532 
       
   533     /**
       
   534     * From MMPXCollectionUiHelper
       
   535     * Test if the specified title exists in the specified category
       
   536     * @param aCategory specifies the category for testing
       
   537     * @param aTitle specifies the title for testing
       
   538     * @return ETrue if the specified title exists in the specified
       
   539     *         category; otherwise, EFalse
       
   540     */
       
   541     TBool TitleExistsL( TMPXGeneralCategory aCategory, 
       
   542                         const TDesC& aTitle, TMPXGeneralType aType = EMPXItem );
       
   543 
       
   544     /**
       
   545     * From MMPXCollectionUiHelper
       
   546     * Returns the file name used for virtual playlist handling
       
   547     * @return the file name to be used to externalize collection path for the playlist
       
   548     *         that needs to be handled. ownership transfered
       
   549     */
       
   550     HBufC* ExternalCollectionPathHandlingFileNameLC();
       
   551 
       
   552 private: // from base class
       
   553 
       
   554     /**
       
   555     * From MMPXMediatorObserver
       
   556     * @param aMedia, properties of the object
       
   557     * @param aOldPath, old collection path
       
   558     */
       
   559     void HandleMediatorPathUpdatedL( CMPXMedia*& aMedia,
       
   560                                      TUid  aOldPath  );
       
   561 
       
   562     /**
       
   563     * From MMPXHarvesterUtilityObserver
       
   564     * Handles completion of playlist export
       
   565     * @param aMedia, media that has been exported to a playlist file
       
   566     * @param aErr, error encountered during playlist export
       
   567     */
       
   568     void HandlePlaylistExportCompletedL( CMPXMedia* aMedia, TInt aErr );
       
   569 
       
   570     /**
       
   571     * From MMPXHarvesterUtilityObserver
       
   572     * Handles completion of playlist import
       
   573     * @param aMedia, media imported from a playlist file.
       
   574     * @param aErr, error encountered during playlist import
       
   575     */
       
   576     void HandlePlaylistImportCompletedL( CMPXMedia* aMedia, TInt aErr );
       
   577 
       
   578     /**
       
   579     * From MMPXHarvesterUtilityObserver
       
   580     * Handle asynchronous file addition by file name
       
   581     * @param aMedia, media added to the system
       
   582     * @param aErr, error encountered during AddL operation
       
   583     */
       
   584     void HandleFileAddCompletedL( CMPXMedia* aMedia, TInt aErr );
       
   585 
       
   586     /**
       
   587     * From MMPXHarvesterUtilityObserver
       
   588     * Handle asynchronous file addition by file name
       
   589     * @param aMedia, media imported from file
       
   590     * @param aErr, error encountered during the operation
       
   591     */
       
   592     void HandleFileImportCompletedL( CMPXMedia* aMedia, TInt aErr  );
       
   593 
       
   594     /**
       
   595     * From MMPXHarvesterUtilityObserver
       
   596     * Handle file delete completion
       
   597     * @param aErr, error encountered during delete operation
       
   598     */
       
   599     void HandleDeleteCompletedL( TInt aErr );
       
   600 
       
   601     /**
       
   602     * From MMPXHarvesterUtilityObserver
       
   603     * Handle media retrieving completion
       
   604     * @param aErr, error encountered during delete operation
       
   605     */
       
   606     void HandleFileGetMediaCompletedL( CMPXMedia* aMedia, TInt aErr  );
       
   607 
       
   608     /**
       
   609     * From MMPXCollectionMediaObserver
       
   610     *  Handle extended media properties
       
   611     *
       
   612     *  @param aMedia media
       
   613     *  @param aError error code
       
   614     */
       
   615     void HandleCollectionMediaL(const CMPXMedia& aMedia,
       
   616                                 TInt aError);
       
   617 
       
   618     /**
       
   619     * From MMPXCollectionObserver
       
   620     *  Handle collection message
       
   621     *  @param aMessage collection message
       
   622     *  @param aErr error
       
   623     */
       
   624     void HandleCollectionMessage(CMPXMessage* aMsg, TInt aErr);
       
   625 
       
   626     /**
       
   627     * From MMPXCollectionObserver
       
   628     *  Handles the collection entries being opened. Typically called
       
   629     *  when client has Open()'d a folder
       
   630     *
       
   631     *  @param aEntries collection entries opened
       
   632     *  @param aIndex focused entry
       
   633     *  @param aComplete ETrue no more entries. EFalse more entries
       
   634     *                   expected
       
   635     *  @param aError error code
       
   636     */
       
   637     void HandleOpenL(const CMPXMedia& aEntries,
       
   638                      TInt aIndex,TBool aComplete,TInt aError);
       
   639 
       
   640     /**
       
   641     * From MMPXCollectionObserver
       
   642     *  Handles the item being opened. Typically called
       
   643     *  when client has Open()'d an item. Client typically responds by
       
   644     *  'playing' the item via the playlist
       
   645     *
       
   646     *  @param aPlaylist collection playlist
       
   647     *  @param aError error code
       
   648     */
       
   649     void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError);
       
   650 
       
   651     /**
       
   652     * From MMPXMoveItemObserver
       
   653     * @param aErr, error for the operation
       
   654     */
       
   655     void HandleMoveCompleteL( TInt aErr );
       
   656 
       
   657     /**
       
   658     * From MMPXCHelperObserver
       
   659     *  Handle callback for delete operation
       
   660     *  @param aOperation operation type that is completed
       
   661     *  @param aErr error code for the operation
       
   662     *  @param aArgument a pointer to any data to retun
       
   663     */
       
   664     void HandleOperationCompleteL( TCHelperOperation aOperation,
       
   665                                    TInt aErr,
       
   666                                    void* aArgument );
       
   667 
       
   668     /**
       
   669     * From MMPXTaskQueueObserver
       
   670     * Execute a task
       
   671     * @param aTask task number
       
   672     * @param aParamData, parameter
       
   673     * @param aPtrData, any object
       
   674     * @param aBuf, buffer containing externalized parameters for the task.
       
   675     * @param aCallback call back function pointer
       
   676     * @param aCObject1 object 1 owned by task queue
       
   677     * @param aCObject2 object 2 owned by task queue
       
   678     */
       
   679     void ExecuteTask(TInt aTask,
       
   680                      TInt aParamData,
       
   681                      TAny* aPtrData,
       
   682                      const CBufBase& aBuf,
       
   683                      TAny* aCallback,
       
   684                      CBase* aCObject1,
       
   685                      CBase* aCObject2);
       
   686 
       
   687     /**
       
   688     * @see MMPXTaskQueueObserver
       
   689     */
       
   690     void HandleTaskError(
       
   691         TInt aTask,
       
   692         TAny* aPtrData,
       
   693         TAny* aCallback,
       
   694         TInt aError);
       
   695 
       
   696 private:
       
   697 
       
   698     /**
       
   699     * Constructor
       
   700     */
       
   701     CMPXCollectionUiHelperImp();
       
   702 
       
   703     /**
       
   704     * 2nd-phase constructor
       
   705     *  @param aModeId collection mode id
       
   706     */
       
   707     void ConstructL(const TUid& aModeId);
       
   708 
       
   709    /**
       
   710     * Execute a task
       
   711     * @param aTask task number
       
   712     * @param aBuf, externalized parameters for the task
       
   713     * @param aCallback, callback for the task
       
   714     */
       
   715     void ExecuteTaskL(TInt aTask, const CBufBase& aBuf, TAny* aCallback);
       
   716 
       
   717     /**
       
   718     * Completes the current task
       
   719     *
       
   720     * @param aTask task number
       
   721     * @param aError error code
       
   722     */
       
   723     void CompleteTask(TInt aTask, TInt aError);
       
   724 
       
   725     /**
       
   726     * Notify client of the task results
       
   727     *
       
   728     * @param aTask task number
       
   729     * @param aError error code
       
   730     */
       
   731     void NotifyClientL(TInt aTask, TInt aError);
       
   732 
       
   733     /**
       
   734     * Cleanup before processing the next task
       
   735     */
       
   736     void Cleanup();
       
   737 
       
   738     /**
       
   739     * Performs AddL task from the task queue
       
   740     */
       
   741     void DoAddL();
       
   742              
       
   743     /**
       
   744     * Performs IncAddMedialL task from the task queue
       
   745     */
       
   746     void DoIncAddMediaL();
       
   747     
       
   748     /**
       
   749     * Performs IncAppendMedialL task from the task queue
       
   750     */
       
   751     void DoIncAppendMediaL();
       
   752     
       
   753     /**
       
   754     * Performs SetL task from the task queue
       
   755     */
       
   756     void DoSetL();
       
   757 
       
   758     /**
       
   759     * Performs RenameL task from the task queue
       
   760     */
       
   761     void DoRenameL();
       
   762 
       
   763     /**
       
   764     * Export the specified playlist to a file
       
   765     * @param aPlaylistId, id of the playlist to be exported
       
   766     * @param aDestinationDriveAndPath, specifies where the playlist file should
       
   767     *        be created. If the file already exists, it will be overwritten.
       
   768     */
       
   769     void DoExportPlaylistL(TMPXItemId aPlaylistId,
       
   770                            const TDesC& aDestinationDriveAndPath);
       
   771 
       
   772     /**
       
   773     * Reorder a song in the playlist
       
   774     * @param aCommand command to reorder a song in the playlist
       
   775     */
       
   776     void DoReorderPlaylistL(CMPXCommand& aCommand);
       
   777 
       
   778     /**
       
   779     * Fill in details for the playlist itself for playlist export
       
   780     * @param aMedia, a playlist media whose information is to be
       
   781     *        filled.
       
   782     */
       
   783     void FillInPlaylistDetailsL(CMPXMedia& aMedia);
       
   784 
       
   785     /**
       
   786     * Handles completion of playlist export
       
   787     * @param aMedia, media that has been exported to a playlist file
       
   788     * @param aErr, error encountered during playlist export
       
   789     */
       
   790     void DoHandlePlaylistExportCompletedL( CMPXMedia* aMedia, TInt aErr );
       
   791 
       
   792     /**
       
   793     *  Looks for collection Id from the given URI through its extension.
       
   794     *  This method is able to determine the collection Id without the media
       
   795     *  being in the harvester's database.
       
   796     *  @param aUri URI of a media
       
   797     *  @return collection Id. KErrNotFound if unable to find a collection
       
   798     *          that supports the type of extension
       
   799     */
       
   800     TInt FindCollectionIdL(const TDesC& aUri);
       
   801 
       
   802 
       
   803 private:
       
   804 
       
   805     // tasks
       
   806     enum TMPXCollectionUiHelperTask
       
   807         {
       
   808         ETaskNone,
       
   809         ETaskAddMedia,
       
   810         ETaskAppendMedia,
       
   811         ETaskSetMedia,
       
   812         ETaskRemoveMedia,
       
   813         ETaskRenameMedia,
       
   814         ETaskExportPlaylist,
       
   815         ETaskReorderPlaylist,
       
   816         ETaskIncAddMedia,
       
   817         ETaskIncAppendMedia,
       
   818         ETaskIncFinish
       
   819         };
       
   820 
       
   821 private: // data
       
   822 
       
   823     MMPXCollectionUtility*              iCollection;
       
   824     CMPXCollectionMediator*             iMediator;
       
   825     MMPXHarvesterUtility*               iHarvester;
       
   826     CMPXActiveTaskQueue*                iTaskQueue;
       
   827     TInt                                iTask;
       
   828 
       
   829     CMPXDeleteHelper*                   iDeleteHelper;
       
   830 
       
   831     // parameters for async commands
       
   832     CMPXMedia*                          iMedia;
       
   833     
       
   834     // parameters used for incremental adding of songs
       
   835     CMPXMedia*                          iInputMedia;
       
   836     TInt                                iRemainder;
       
   837     TInt                                iTotalChunkNumber;
       
   838     TInt                                iChunkNumber;  // used as ID of current chunk
       
   839     TInt                                iChunkSize;
       
   840     TInt                                iArrayIndex;
       
   841 
       
   842     
       
   843     MMPXCHelperEmbeddedOpenObserver*    iOpenObserver; // not owned, transient
       
   844 
       
   845     MMPXCHelperObserver*                iHelperObserver;  // not owned, transient
       
   846     // Embedded Mode handling
       
   847     TUid                                iEmbeddedModeID;
       
   848     TInt                                iEmbeddedPluginInfo;
       
   849     TBool                               iInitialized;  // collection db merging
       
   850     TBool                               iIncAdding;  // Incremental adding guard
       
   851     };
       
   852 
       
   853 #endif // CMPX_COLLECTION_UI_HELPER_H