mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbplugin/inc/mpxdbplugin.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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:  Implementation of collection Database Plugin interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MPXDBPLUGIN_H
       
    20 #define MPXDBPLUGIN_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <badesca.h>
       
    24 #include <mpxcommonframeworkdefs.h>
       
    25 #include <mpxcollectionframeworkdefs.h>
       
    26 #include <mpxcollectionplugin.h>
       
    27 #include <mpxcollectionpath.h>
       
    28 #include <mpxmediageneraldefs.h>
       
    29 #include <mpxmessage2.h>
       
    30 
       
    31 #include "mpxdbactivetask.h"
       
    32 #include "mpxcollectiondb.hrh"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CMPXMedia;
       
    36 class CMPXDbHandler;
       
    37 class CMPXDrmMediaUtility;
       
    38 class CMPXMediaArray;
       
    39 class CMPXResource;
       
    40 struct TMPXOpenDataBlock;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 * CMPXDbPlugin class
       
    46 * Implements the plugin interface.
       
    47 *
       
    48 * @lib MPXDbPlugin.lib
       
    49 */
       
    50 NONSHARABLE_CLASS(CMPXDbPlugin) :
       
    51     public CMPXCollectionPlugin,
       
    52     public MMPXDbActiveTaskObserver
       
    53     {
       
    54 public: // Constructors and destructor
       
    55 
       
    56     /**
       
    57     * Two-phased constructor
       
    58     * @param aInitParams: initialization parameters
       
    59     * @return object constructed
       
    60     */
       
    61     static CMPXDbPlugin* NewL (TAny* aInitParams);
       
    62 
       
    63     /**
       
    64     * Destructor
       
    65     */
       
    66     virtual ~CMPXDbPlugin();
       
    67 
       
    68 public: // from base classes
       
    69 
       
    70     /**
       
    71     * From CMPXCollectionPlugin
       
    72     * Navigates to the given path. This method is serviced
       
    73     * asynchronously and HandleOpenL is called upon completion
       
    74     * @param aPath a path
       
    75     * @param aAttrs attributes requested
       
    76     * @param aFilter filter to apply or NULL if none
       
    77     */
       
    78     void OpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
    79         CMPXFilter* aFilter);
       
    80 
       
    81     /**
       
    82     * From CMPXCollectionPlugin
       
    83     * Get the extended properties of the item referred to by the
       
    84     * specified collection path.  This method is serviced asynchronously and
       
    85     * HandleMediaL is called upon completion
       
    86     * @param aPath a collection path referring to the item to retrieve the
       
    87     *               extended properties for
       
    88     * @param aAttrs array of attributes requested
       
    89     * @param aCaps platsec capabilities of client requesting media; plug-in
       
    90     *        should also verify its process capabilities (not yet supported)
       
    91     * @aParam aSpecs specifications for attributes (not yet supported)
       
    92     */
       
    93     void MediaL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
    94         const TArray<TCapability>& aCaps, CMPXAttributeSpecs* aSpecs);
       
    95 
       
    96     /**
       
    97     * From CMPXCollectionPlugin
       
    98     * Cancel outstanding request. Note*** CancelRequest is not currently
       
    99     * implemented because all requests are processed synchronously
       
   100     */
       
   101     void CancelRequest();
       
   102 
       
   103     /**
       
   104     * From CMPXCollectionPlugin
       
   105     * Executes the given TMPXCollectionCommand command on the collection
       
   106     * @param aCmd a command
       
   107     * @param aArg an argument
       
   108     */
       
   109     void CommandL (TMPXCollectionCommand aCmd, TInt aArg = 0);
       
   110 
       
   111     /**
       
   112     * From CMPXCollectionPlugin
       
   113     * Executes the given CMPXCommand command on the collection
       
   114     * @param aCmd a command
       
   115     */
       
   116     void CommandL(CMPXCommand& aCmd);
       
   117 
       
   118     /**
       
   119     * From CMPXCollectionPlugin
       
   120     * Adds an item (song or playlist) to the collection
       
   121     * @param aMedia Properties of the item
       
   122     */
       
   123     void AddL(const CMPXMedia& aMedia);
       
   124 
       
   125     /**
       
   126     * From CMPXCollectionPlugin
       
   127     * Remove an item from the collection database using the given path
       
   128     * Note that the selection indices are hidden within the path
       
   129     * @param aPath path to the item to be removed
       
   130     *
       
   131     */
       
   132     void RemoveL(const CMPXCollectionPath& aPath);
       
   133 
       
   134     /**
       
   135     *  Remove item(s) from the collection database using the given media properties
       
   136     *  @param aMedia Properties of the item(s) to be removed. May cantain a URI
       
   137     *           or metadata. All item(s) matching the specified properties
       
   138     *           will be removed.
       
   139     */
       
   140     void RemoveL(const CMPXMedia& aMedia);
       
   141 
       
   142     /**
       
   143     *  Sets/updates the specified media for an item in the collection.  Media
       
   144     *  is identified by specifying an ID or URI.
       
   145     *  @param aMedia new property values for the item
       
   146     */
       
   147     void SetL(const CMPXMedia& aMedia);
       
   148 
       
   149     /**
       
   150     * From CMPXCollectionPlugin
       
   151     *  Find the items matching the media specifications.  This method is serviced
       
   152     *  asynchronously and HandleFindAllL is called upon completion
       
   153     *  @param aCriteria Properties of the item that is to be found
       
   154     *  @param aAttrs Requested attributes to return
       
   155     */
       
   156     void FindAllL (const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs);
       
   157 
       
   158     /**
       
   159     *  From CMPXCollectionPlugin
       
   160     *  Find the items matching the media specifications
       
   161     *  @param aCriteria Properties of the item that is to be found
       
   162     *  @param aAttrs Requested attributes to return
       
   163     *  @return results of the search. Method abandons ownership of results.
       
   164     */
       
   165     CMPXMedia* FindAllSyncL(const CMPXMedia& aCriteria,
       
   166         const TArray<TMPXAttribute>& aAttrs);
       
   167 
       
   168     /**
       
   169     * From CMPXCollectionPlugin
       
   170     * Get the list of supported capabilities
       
   171     * @return TCollectionCapability, bitmask of supported capabilities
       
   172     */
       
   173     TCollectionCapability GetCapabilities ();
       
   174 
       
   175     /**
       
   176     * From MMPXDbActiveTaskObserver
       
   177     */
       
   178     TBool HandleStepL();
       
   179 
       
   180     /**
       
   181     * From MMPXDbActiveTaskObserver
       
   182     */
       
   183     void HandleOperationCompleted(TInt aErr);
       
   184 
       
   185 private:
       
   186     /**
       
   187     * Constructor
       
   188     */
       
   189     CMPXDbPlugin();
       
   190 
       
   191     /**
       
   192     * Symbian 2nd phase constructor.
       
   193     */
       
   194     void ConstructL();
       
   195 
       
   196     /**
       
   197     * Process the OpenL command
       
   198     * @param aPath a path
       
   199     * @param aAttrs Requested attributes to return
       
   200     * @param aEntries (Output parameter) collection items containing media properties
       
   201     *                  of all items, returned if opening a group of items
       
   202     * @param aFilter CMPXFilter Object
       
   203     * @return ETrue if the open is for a song, EFalse otherwise
       
   204     */
       
   205     TBool DoOpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   206         CMPXMedia& aEntries, CMPXFilter* aFilter );
       
   207 
       
   208     /**
       
   209     * Process the OpenL(EBrowseAll) command
       
   210     * @param aPath Path
       
   211     * @param aAttrs Requested attributes to return
       
   212     * @param aEntries (Output parameter) collection items containing media properties
       
   213     *                  of all items, returned if opening a group of items
       
   214     * @param aArray (Output parameter) collection items
       
   215     * @return ETrue if the open is for a song, EFalse otherwise
       
   216     */
       
   217     TBool DoOpenBrowseAllL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   218         CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   219 
       
   220     /**
       
   221     * Process the OpenL(EBrowseArtist) command
       
   222     * @param aPath Path
       
   223     * @param aAttrs Requested attributes to return
       
   224     * @param aEntries (Output parameter) collection items containing media properties
       
   225     *                  of all items, returned if opening a group of items
       
   226     * @param aArray (Output parameter) collection items
       
   227     * @return ETrue if the open is for a song, EFalse otherwise
       
   228     */
       
   229     TBool DoOpenBrowseArtistL(const CMPXCollectionPath& aPath,
       
   230         const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   231 
       
   232     /**
       
   233     * Process the OpenL(EBrowseAlbum) command
       
   234     * @param aPath Path
       
   235     * @param aAttrs Requested attributes to return
       
   236     * @param aEntries (Output parameter) collection items containing media properties
       
   237     *                  of all items, returned if opening a group of items
       
   238     * @param aArray (Output parameter) collection items
       
   239     * @return ETrue if the open is for a song, EFalse otherwise
       
   240     */
       
   241     TBool DoOpenBrowseAlbumL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   242         CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   243 
       
   244     /**
       
   245     * Process the OpenL(EBrowsePlaylist) command
       
   246     * @param aPath Path
       
   247     * @param aAttrs Requested attributes to return
       
   248     * @param aEntries (Output parameter) collection items containing media properties
       
   249     *                  of all items, returned if opening a group of items
       
   250     * @param aArray (Output parameter) collection items
       
   251     * @return ETrue if the open is for a song, EFalse otherwise
       
   252     */
       
   253     TBool DoOpenBrowsePlaylistL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   254         CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   255 
       
   256     /**
       
   257     * Process the OpenL(EBrowseGenre) command
       
   258     * @param aPath Path
       
   259     * @param aAttrs Requested attributes to return
       
   260     * @param aEntries (Output parameter) collection items containing media properties
       
   261     *                  of all items, returned if opening a group of items
       
   262     * @param aArray (Output parameter) collection items
       
   263     * @return ETrue if the open is for a song, EFalse otherwise
       
   264     */
       
   265     TBool DoOpenBrowseGenreL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   266        CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   267 
       
   268     /**
       
   269     * Process the OpenL(EBrowseComposer) command
       
   270     * @param aPath Path
       
   271     * @param aAttrs Requested attributes to return
       
   272     * @param aEntries (Output parameter) collection items containing media properties
       
   273     *                  of all items, returned if opening a group of items
       
   274     * @param aArray (Output parameter) collection items
       
   275     * @return ETrue if the open is for a song, EFalse otherwise
       
   276     */
       
   277     TBool DoOpenBrowseComposerL(const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
       
   278         CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   279 
       
   280     /**
       
   281     * Process an OpenL command with a EMPXOpenPlaylistOnly open mode
       
   282     * @param aPath path that we want to open
       
   283     * @param aAttrs default attributes to fetch
       
   284     * @return CMPXCollectionPath* which is the new valid browse path
       
   285     */
       
   286     CMPXCollectionPath* DoOpenPlaylistL( const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs );
       
   287 
       
   288     /**
       
   289     * Process the MediaL command
       
   290     * @param aPath a path
       
   291     * @param aAttrs Requested attributes to return
       
   292     * @param aEntries collection items containing media properties of all items, returned if opening a group of items
       
   293     */
       
   294     void DoMediaL (const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aEntries);
       
   295 
       
   296     /**
       
   297     * Get the plugin title, subtitle, icons for this plugin
       
   298     * @param aAttrs attributes to find
       
   299     * @param aMedia media object
       
   300     */
       
   301     void DoRootMediaL(const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
       
   302 
       
   303     /**
       
   304     * Get the media under ALL SONGS category
       
   305     * @param aPath path that leads to a media under ALL SONGS
       
   306     * @param aAttrs attributes of media to find
       
   307     * @param aEntries the media referred by the path
       
   308     * @param aMediaArray media entries contained in the media referred by the path
       
   309     */
       
   310     void DoAllSongsMediaL(const CMPXCollectionPath& aPath,
       
   311                             const TArray<TMPXAttribute>& aAttrs,
       
   312                             CMPXMedia& aEntries,
       
   313                             CMPXMediaArray& aMediaArray);
       
   314 
       
   315     /**
       
   316     * Get the media under ARTISTS category
       
   317     * @param aPath path that leads to a media under ARTISTS
       
   318     * @param aAttrs attributes of media to find
       
   319     * @param aEntries the media referred by the path
       
   320     * @param aMediaArray media entries contained in the media referred by the path
       
   321     */
       
   322     void DoArtistMediaL(const CMPXCollectionPath& aPath,
       
   323                           const TArray<TMPXAttribute>& aAttrs,
       
   324                           CMPXMedia& aEntries,
       
   325                           CMPXMediaArray& aMediaArray);
       
   326 
       
   327     /**
       
   328     * Get the root media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
       
   329     * @param aAttrs attributes of media to find
       
   330     * @param aRootCategoryId Id of the root media in the category, i.e. all albums,
       
   331     *        ...etc.
       
   332     * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
       
   333     *        EMPXGenre, or EMPXComposer
       
   334     * @param aEntries the media referred by the path
       
   335     */
       
   336     void DoRootCategoryMediaL(const TArray<TMPXAttribute>& aAttrs,
       
   337                                TMPXItemId aRootCategoryId,
       
   338                                TMPXGeneralCategory aCategory,
       
   339                                CMPXMedia& aEntries);
       
   340 
       
   341     /**
       
   342     * Get the media under album/playlist/genre/composer category
       
   343     * @param aPath path that leads to a media under ALBUMS/PLAYLISTS/GENRES/COMPOSERS
       
   344     * @param aAttrs attributes of media to find
       
   345     * @param aCategory specifies the category. Will be either EMPXAlbum, EMPXPlaylist,
       
   346     *        EMPXGenre, or EMPXComposer
       
   347     * @param aEntries the media referred by the path
       
   348     * @param aMediaArray medias contained in the media referred by the path
       
   349     */
       
   350     void DoCategoryMediaL(const CMPXCollectionPath& aPath,
       
   351                            const TArray<TMPXAttribute>& aAttrs,
       
   352                            TMPXGeneralCategory aCategory,
       
   353                            CMPXMedia& aEntries,
       
   354                            CMPXMediaArray& aMediaArray);
       
   355 
       
   356     /**
       
   357     * Set all the attributes in CMPXMedia corresponding to KMPXMediaIdDrm
       
   358     * @param aMedia, media to update
       
   359     * @param aDrmAttributes, bitwise or of the flags we want
       
   360     * @param aLocation, full file path including filename
       
   361     */
       
   362     void DoSetMediaDrmL(CMPXMedia& aMedia, TUint aDrmAttributes, const TDesC& aLocation);
       
   363 
       
   364     /**
       
   365     * Add media objects to the array with attributes from song details
       
   366     * @param aPath a path
       
   367     * @param aAttrs requested attributes
       
   368     * @param aEntry media to contain information about the container if it contains
       
   369     *        than one entry
       
   370     * @param aMediaArray array to contain all the media objects added
       
   371     */
       
   372     void GetSongInfoL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs,
       
   373         CMPXMedia& aEntry, CMPXMediaArray& aMediaArray);
       
   374 
       
   375     /**
       
   376     * Add media objects to the array with attributes from song details
       
   377     * @param aAttrs requested attributes
       
   378     * @param aEntryId song ID
       
   379     * @param aPlaylistId corresponding playlist ID, if 0 the attributes will be read from
       
   380     *        the songs table, otherwise they will be read from the playlist table.
       
   381     * @param aEntry media to contain information about the container if it contains
       
   382     *        than one entry
       
   383     */
       
   384     void DoGetSongInfoL(const TArray<TMPXAttribute>& aAttrs, TInt aEntryId, TInt aPlaylistId,
       
   385         CMPXMedia& aEntry);
       
   386 
       
   387     /**
       
   388     * Get the collection details from the db
       
   389     * @param aAttrs, attributes to find
       
   390     * @param aMedia, media object
       
   391     */
       
   392     void DoHandleOtherMediaAttributesL(const TArray<TMPXAttribute>& aAttrs,
       
   393         const CMPXCollectionPath& aPath, CMPXMedia& aMedia);
       
   394 
       
   395     /**
       
   396     * Remove an item from the collection database using the given path
       
   397     * Note that the selection indices are hidden within the path
       
   398     * @param aPath path to the item to be removed
       
   399     * @param aChangeMsgArray array to store change messages
       
   400     * @return an array of files associated with the removed media entries
       
   401     */
       
   402     CDesCArray* DoRemoveL(const CMPXCollectionPath& aPath,
       
   403         CMPXMessageArray& aChangeMsgArray);
       
   404 
       
   405     /**
       
   406     * Remove an item/items from the collection database using the given media properties
       
   407     * @param aMedia: Properties of the item that is to be removed. It may cantain URI only
       
   408     *                or meta data, all of items matched properties will be removed.
       
   409     * @param aDeleteRecord: indicates whether the client has explictly requested
       
   410     *                to delete the records from the database. If ETrue, records
       
   411     *                associated with the media will be deleted from the database;
       
   412     *                if EFalse, whether to mark the records as deleted or to delete
       
   413     *                the records will be based on other deciding factors.
       
   414     */
       
   415     void DoRemoveL(const CMPXMedia& aMedia, TBool aDeleteRecord);
       
   416 
       
   417     /**
       
   418     * Remove an item from the collection database using a command
       
   419     * @param aCmd: remove command which contains collection path to the media(s) to be
       
   420     *        removed. This method should be called until all the selected items are
       
   421     *        removed. When that happens, EMPXCommandCompleted flag is set to ETrue.
       
   422     *        see KMPXCommandIdCollectionRemove in mpxcollectioncommanddefs.h
       
   423     */
       
   424     void DoRemovePathL(CMPXCommand& aCmd);
       
   425 
       
   426     /**
       
   427     * Remove a media/medias from the collection database using a command
       
   428     * @param aCmd: remove command which contains the media(s) to be removed. This
       
   429     *        will delete the records from the database rather than marking them
       
   430     *        as deleted. Designated caller is MTP.
       
   431     */
       
   432     void DoRemoveMediaL(CMPXCommand& aCmd);
       
   433 
       
   434     /**
       
   435     * Remove a media/medias from all songs view
       
   436     * @param aPath, collection path that points to the media items to be removed
       
   437     * @param aSelections, multiple media items selected. This array contains the id
       
   438     *        of the selected media.
       
   439     * @param aUriArray: a descriptor array containing the URI(s) of the deleted file(s)
       
   440     * @param aItemChangedMessages: a list of change events as a result of the
       
   441     *        song removals
       
   442     */
       
   443     void DoRemoveFromAllSongsL(const CMPXCollectionPath& aPath,
       
   444                                const TArray<TMPXItemId>& aSelections,
       
   445                                CDesCArray& aUriArray,
       
   446                                CMPXMessageArray& aItemChangedMessages);
       
   447 
       
   448     /**
       
   449     * Remove a media/medias from artists view
       
   450     * @param aPath, collection path that points to the media(s) to be removed
       
   451     * @param aSelections, multiple media items selected. This array contains the id
       
   452     *        of the selected media.
       
   453     * @param aUriArray: a descriptor array to contain the URI of the deleted file
       
   454     * @param aItemChangedMessages: a list of change events as a result of the
       
   455     *        song removals
       
   456     */
       
   457     void DoRemoveFromArtistsL(const CMPXCollectionPath& aPath,
       
   458                               const TArray<TMPXItemId>& aSelections,
       
   459                               CDesCArray& aUriArray,
       
   460                               CMPXMessageArray& aItemChangedMessages);
       
   461 
       
   462     /**
       
   463     * Remove a media/medias from artists view
       
   464     * @param aPath, collection path that points to the media(s) to be removed
       
   465     * @param aItemId media item to be removed.
       
   466     * @param aUriArray: a descriptor array to contain the URI of the deleted file
       
   467     * @param aItemChangedMessages: a list of change events as a result of the
       
   468     *        song removals
       
   469     */
       
   470     void RemoveFromArtistsL(const CMPXCollectionPath& aPath,
       
   471                                 TUint32 aItemId,
       
   472                                 CDesCArray& aUriArray,
       
   473                                 CMPXMessageArray& aItemChangedMessages);
       
   474 
       
   475     /**
       
   476     * Remove a media entry/entries from albums/genres/composers view
       
   477     * @param aPath, collection path that points to the media entry/entries to be removed
       
   478     * @param aSelections, multiple media entries selected. This array contains the id
       
   479     *        of the selected media.
       
   480     * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
       
   481     *        EMPXComposer
       
   482     * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
       
   483     * @param aItemChangedMessages: a list of change events as a result of the
       
   484     *        song removals
       
   485     */
       
   486     void DoRemoveFromCategoriesL(const CMPXCollectionPath& aPath,
       
   487                                  const TArray<TMPXItemId>& aSelections,
       
   488                                  TMPXGeneralCategory aCategory,
       
   489                                  CDesCArray& aUriArray,
       
   490                                  CMPXMessageArray& aItemChangedMessages);
       
   491 
       
   492     /**
       
   493     * Remove a media entry from albums/genres/composers view
       
   494     * @param aPath, collection path that points to the media entry/entries to be removed
       
   495     * @param aItemId item ID to be removed.
       
   496     * @param aCategory, indicates one of the 3 categories, EMPXAlbum, EMPXGenre, or
       
   497     *        EMPXComposer
       
   498     * @param aUriArray: a descriptor array to contain the URI(s) of the deleted file(s)
       
   499     * @param aItemChangedMessages: a list of change events as a result of the
       
   500     *        song removals
       
   501     */
       
   502     void RemoveFromCategoriesL(const CMPXCollectionPath& aPath,
       
   503                                 TUint32 aItemId,
       
   504                                 TMPXGeneralCategory aCategory,
       
   505                                 CDesCArray& aUriArray,
       
   506                                 CMPXMessageArray& aItemChangedMessages);
       
   507 
       
   508     /**
       
   509     * Remove a media entry/entries from playlists view
       
   510     * @param aPath, collection path that points to the media(s) to be removed
       
   511     * @param aSelections, multiple medias selected. This array contains the id
       
   512     *        of the selected media.
       
   513     * @param aUriArray: a descriptor array to contain the URI of the deleted file
       
   514     * @param aItemChangedMessages: a list of change events as a result of the
       
   515     *        song removals
       
   516     */
       
   517     void DoRemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
       
   518                                 const TArray<TMPXItemId>& aSelections,
       
   519                                 CDesCArray& aUriArray,
       
   520                                 CMPXMessageArray& aItemChangedMessages);
       
   521 
       
   522     /**
       
   523     * Remove a media entry/entries from playlists view
       
   524     * @param aPath, collection path that points to the media(s) to be removed
       
   525     * @param aItemId item to be removed
       
   526     * @param aIndex item index to be removed
       
   527     * @param aUriArray: a descriptor array to contain the URI of the deleted file
       
   528     * @param aItemChangedMessages: a list of change events as a result of the
       
   529     *        song removals
       
   530     */
       
   531     void RemoveFromPlaylistsL(const CMPXCollectionPath& aPath,
       
   532                                 const TMPXItemId& aItemId,
       
   533                                 TInt aIndex,
       
   534                                 CDesCArray& aUriArray,
       
   535                                 CMPXMessageArray& aItemChangedMessages);
       
   536 
       
   537     /**
       
   538     * Retrieves URIs associated with the path for file deletion
       
   539     * @param aCmd, command to retrieve associated URIs for the given path. If
       
   540     *        path ends with a particular artist/album/genre/composer, the path
       
   541     *        will be updated to include all songs in that category. If path
       
   542     *        ends with one or more medias in a particular playlist, an array
       
   543     *        of 0 elements will be returned to avoid client deleting them from
       
   544     *        the file system. see KMPXCommandIdCollectionRetrieveUriForDeletion
       
   545     *        defined in mpxcollectioncommanddefs.h
       
   546     */
       
   547     void DoRetrieveUriForDeletionL(CMPXCommand& aCmd);
       
   548 
       
   549     /**
       
   550     * Deletes records which have been marked as deleted from the collection
       
   551     * @param aCmd command to cleanup deleted medias.
       
   552     *        see KMPXCommandIdCollectionCleanupDeletedRecords defined in
       
   553     *        mpxcollectioncommanddefs.h
       
   554     */
       
   555     void CleanupDeletedRecordsL(CMPXCommand& aCmd);
       
   556 
       
   557     /**
       
   558     * Fetch the duration for a specific category
       
   559     * @param aMedia a media object of which EMPXMediaGeneralDuration is to be
       
   560     *        populated with the duration calculated in this method
       
   561     * @param aFirstCat category of the 1st Id
       
   562     * @param aId id for identifying which category to calculate the duration for
       
   563     * @param aSecondCat category of the 2nd Id
       
   564     * @param aSubId 2nd id for identifying which category to calculate the
       
   565     *        duration for. For example, to calculate the duration of an album of
       
   566     *        a particular artist, 1st Id provided will be the artist Id and the
       
   567     *        2nd Id provided will be the album Id.
       
   568     */
       
   569     TInt DoDurationL(CMPXMedia& aMedia, TMPXGeneralCategory aFirstCat, TMPXItemId aId = 0,
       
   570                       TMPXGeneralCategory aSecondCat = EMPXNoCategory, TMPXItemId aSubId = 0);
       
   571 
       
   572     /**
       
   573     * Append a collection level to the collection path
       
   574     * @param aPath, path to append the level to
       
   575     * @param aMedia, media to extract media ids from
       
   576     * @note: Selection will be put on the first song in the collection path
       
   577     */
       
   578     TInt DoAppendLevelL(CMPXCollectionPath& aPath, CMPXMedia& aMedia);
       
   579 
       
   580     /**
       
   581     * Append a collection level to the collection path with all songs under the
       
   582     * selected category/categories (e.g. artist/artist-album/album/genre/composer).
       
   583     * Once the level is appended, all songs under the selected category/categories
       
   584     * are selected.
       
   585     * @param aPath, path to append the level to. Path remains unchanged if it's not
       
   586     *        one of the following:
       
   587     *        1) path ends at an artist or selected artists
       
   588     *        2) path ends at an album of an artist or selected albums of an artist
       
   589     *        3) path ends at an album or selected albums
       
   590     *        4) path ends at a genre or selected genres
       
   591     *        5) path ends at a composer or selected composers
       
   592     */
       
   593     void DoAppendLevelL(CMPXCollectionPath& aPath);
       
   594 
       
   595     /**
       
   596     * Execute a task step for an asynchronous add
       
   597     */
       
   598     TBool DoAddAsyncL();
       
   599 
       
   600     /**
       
   601     * Add a media object to the collection
       
   602     * @param aMedia media to add
       
   603     * @return TUint32 item id of the item added
       
   604     */
       
   605     TUint32 DoAddL(const CMPXMedia& aMedia);
       
   606 
       
   607     /**
       
   608     * Add an item into the collection
       
   609     * @param aMedia media to add
       
   610     * @param aMessageArray change message array
       
   611     */
       
   612     TUint32 DoAddItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray,
       
   613                         TBool aBatchCommit = EFalse);
       
   614 
       
   615     /**
       
   616     * Set a media object to update the collection
       
   617     * @param aMedia media can be an item or a list. The item is treated as a list
       
   618     *               if it contains a media array
       
   619     */
       
   620     void DoSetL(const CMPXMedia& aMedia);
       
   621 
       
   622     /**
       
   623     * Execute a task step for an asynchronous set
       
   624     */
       
   625     TBool DoSetAsyncL();
       
   626 
       
   627     /**
       
   628     * Set an item media to update the collection
       
   629     * @param aMedia media to update
       
   630     * @param aMessageArray array to append change messages
       
   631     * @return ETrue if the update is UI visible, EFalse otherwise
       
   632     */
       
   633     CMPXDbActiveTask::TChangeVisibility DoSetItemL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray);
       
   634 
       
   635     /**
       
   636     * Set the drm properties for an array of medias
       
   637     * @param mediaArray CMPXMediaArray list of medias
       
   638     * @param aAtts attribute list
       
   639     */
       
   640     void DoSetDrmForArrayL(const CMPXMediaArray& mediaArray,
       
   641                             const TArray<TMPXAttribute>& aAttrs);
       
   642 
       
   643     /**
       
   644     * Send a change message
       
   645     *
       
   646     * @param aMessage: a change message to be sent
       
   647     */
       
   648     void HandleChangeL(const CMPXMessage& aMessage);
       
   649 
       
   650     /**
       
   651     * Construct a CMPXMedia from the array parameter and call HandleChange
       
   652     *
       
   653     * @param aItemChangedMessages: array in the change message to be sent
       
   654     * @param aCommandid command that was executed
       
   655     */
       
   656     void DoHandleChangeL(CMPXMessageArray* aItemChangedMessages,
       
   657                          TMPXCommandId aCommandId = 0 );
       
   658 
       
   659     /**
       
   660     * Returns the category for a given browse type.
       
   661     *
       
   662     * @param aBrowseType browse type
       
   663     * @return Category ID
       
   664     */
       
   665     TMPXGeneralCategory CategoryForBrowseType(TMCBrowseType aBrowseType);
       
   666 
       
   667     /**
       
   668     * Returns the browse type for a given category ID.
       
   669     *
       
   670     * @param aCategory category ID
       
   671     * @return Browse type
       
   672     */
       
   673     TMCBrowseType BrowseTypeForCategory(TMPXGeneralCategory aCategory);
       
   674 
       
   675     /**
       
   676     * Sets the type, category and title attributes in the specified media.
       
   677     *
       
   678     * @param aMedia media instance to be updated
       
   679     * @param aType type attribute value
       
   680     * @param aCategory category attribute value
       
   681     * @param aTitle title attribute value
       
   682     */
       
   683     void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
       
   684         TMPXGeneralCategory aCategory, const TDesC& aTitle);
       
   685 
       
   686     /**
       
   687     * Sets the type, category and title attributes in the specified media.
       
   688     *
       
   689     * @param aMedia media instance to be updated
       
   690     * @param aType type attribute value
       
   691     * @param aCategory category attribute value
       
   692     * @param aId ID of the item to the title from
       
   693     */
       
   694     void SetMediaGeneralAttributesL(CMPXMedia& aMedia, TMPXGeneralType aType,
       
   695         TMPXGeneralCategory aCategory, TInt aId);
       
   696 
       
   697     /**
       
   698     * Leaving function to handle async op completion
       
   699     * @param aErr error code
       
   700     */
       
   701     void DoHandleOperationCompletedL(TInt aErr);
       
   702 
       
   703     /**
       
   704     * Complete a delete operation
       
   705     * Sends out change messages and compacts the database
       
   706     */
       
   707     void DoHandleDeleteCompleteL( CMPXCommand& aCmd );
       
   708 
       
   709     /**
       
   710     * Reorder a song in a playlist
       
   711     * @param aCmd command to reoder a song in a playlist
       
   712     *        see KMPXCommandIdReorderPlaylist defined in
       
   713     *        mpxcollectioncommanddefs.h
       
   714     */
       
   715     void DoReorderPlaylistL( const CMPXCommand& aCmd );
       
   716 
       
   717     /**
       
   718     * Get total song and playlist count
       
   719     * @param aCmd command to return count
       
   720     *        see KMPXCommandCollectionGetCount defined in
       
   721     *        mpxcollectioncommanddefs.h
       
   722     */
       
   723     void DoGetCollectionCountL( const CMPXCommand& aCmd );
       
   724 
       
   725     /**
       
   726     * Get an array of URIs for all songs and playlists in a given db
       
   727     * @param aCmd command to return CDesCArray
       
   728     *        see KMPXCommandCollectionGetURIs defined in
       
   729     *        mpxcollectioncommanddefs.h
       
   730     */
       
   731     void DoGetCollectionUriL( const CMPXCommand& aCmd );
       
   732 
       
   733     /**
       
   734     * Perform 1 step of the incremental read operation
       
   735     * @param aCmd Command to process
       
   736     */
       
   737     void DoIncrementalOpenL( const CMPXCommand& aCmd );
       
   738 
       
   739     /**
       
   740     * Open the all songs view incrementally
       
   741     * @param aPath path that leads to a media under ALL SONGS
       
   742     * @param aAttrs attributes of media to find
       
   743     * @param aEntries the media referred by the path
       
   744     * @param aMediaArray media entries contained in the media referred by the path
       
   745     */
       
   746     TBool DoOpenIncrementalL( const CMPXCollectionPath& aPath,  const TArray<TMPXAttribute>& aAttrs,
       
   747                               CMPXMedia& aEntries, CMPXMediaArray* aArray);
       
   748 
       
   749     /**
       
   750     * Set the attribute list according to current path
       
   751     * @param aPath a path
       
   752     * @param aAttrs attributes array to be filled
       
   753     * @param aSupportedIds array of supported content IDs to be filled
       
   754     */
       
   755     void SetAttributesL( const CMPXCollectionPath& aPath, RArray<TMPXAttribute>& aAttrs,
       
   756                          RArray<TInt>& aSupportedIds );
       
   757 
       
   758 #ifdef _DEBUG
       
   759     /**
       
   760     * Prints messages for debugging
       
   761     * @param aMessage: message(s) to be printed
       
   762     */
       
   763     void PrintMessagesL(const CMPXMessage& aMessage);
       
   764 
       
   765     /**
       
   766     * Prints a single message for debugging
       
   767     * @param aMessage: a message to be printed
       
   768     */
       
   769     void PrintMessage(const CMPXMessage& aMessage);
       
   770 #endif // _DEBUG
       
   771 
       
   772 private:
       
   773     // owned member variables
       
   774     RFs                  iFs;
       
   775     CMPXResource*        iResource;
       
   776     CMPXDbHandler*       iDbHandler;
       
   777     CMPXDrmMediaUtility* iDrmMediaUtility;
       
   778     CDesCArrayFlat*      iMusicLibraryMenuTitles;      // titles for each of the menu items
       
   779     CDesCArrayFlat*      iMusicLibraryTitles;          // titles for each of the category views
       
   780     RArray<TInt>         iMusicLibraryMenuIds;         // music library item menu IDs
       
   781     HBufC*               iAllSongsForArtistTitle;
       
   782     HBufC*               iMusicMenuTitle;
       
   783     TBool                iDisablePodcasting;
       
   784     TBool                iMtpInUse;
       
   785     TBool                iRefreshing;
       
   786     CMPXDbActiveTask*    iActiveTask;
       
   787     RArray<TMPXItemId>   iSelections;   //selected items in the path
       
   788     TBool iFirstDeleteStep;
       
   789     TBool iAllSongsValid;    //to indicate if there's enough space to get all songs information from collection DB.
       
   790     };
       
   791 
       
   792 #endif   // MPXDBPLUGIN_H
       
   793 
       
   794