mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h
branchRCL_3
changeset 66 1f1dad4af8f8
parent 56 2cbbefa9af78
equal deleted inserted replaced
60:bdd9da0d70fe 66:1f1dad4af8f8
    27 // CLASS DECLARATION
    27 // CLASS DECLARATION
    28 
    28 
    29 class MMPXDbAlbumObserver
    29 class MMPXDbAlbumObserver
    30     {
    30     {
    31     public:
    31     public:
       
    32         virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0;
       
    33         virtual HBufC* HandleArtistForAlbumL( const TUint32 aId ) = 0;
    32         /**
    34         /**
    33         * HandleAlbumartForAlbumL.
    35         * HandleAlbumartForAlbumL.
    34         * @param aId, The album ID.
    36         * @param aId, The album ID.
    35         * @param aArt, The albumart uri.
    37         * @param aArt, The albumart uri.
    36         * @returns alternative albumart retrieved in the specified Album.
    38         * @returns alternative albumart retrieved in the specified Album.
    37         */
    39         */
    38         virtual HBufC* HandleAlbumartForAlbumL( const TUint32 aId, TPtrC aArt ) = 0;
    40         virtual HBufC* HandleAlbumartForAlbumL( const TUint32 aId, TPtrC aArt ) = 0;
    39                
       
    40         /**
       
    41         * Called when album artist is removed from an album
       
    42         * @param aCategoryId category item ID
       
    43         * @param aDrive drive the category item is on
       
    44         * @param aItemChangedMessages changed mesages array to be updated or NULL
       
    45         */
       
    46         virtual void DeleteAlbumForArtistL(TUint32 aCategoryId,
       
    47             TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0;
       
    48 
       
    49         /**
       
    50         * Called when album artist is added to an album
       
    51         * @param aName name string
       
    52         * @param aArt Album art path
       
    53         * @param aDriveId drive to add the category to
       
    54         * @return the ID of the category item (new or existing)
       
    55         */
       
    56         virtual TUint32 AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId) = 0;
       
    57     };
    41     };
    58 /**
    42 /**
    59 * Responsible for managing all music databases
    43 * Responsible for managing all music databases
    60 *
    44 *
    61 * @lib MPXDbPlugin.lib
    45 * @lib MPXDbPlugin.lib
    72         * @param aCategory identifies the category
    56         * @param aCategory identifies the category
    73         * @return New CMPXDbCategory instance.
    57         * @return New CMPXDbCategory instance.
    74         */
    58         */
    75         static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager,
    59         static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager,
    76             TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
    60             TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
    77         
    61 
    78         /**
    62         /**
    79         * Two-phased constructor.
    63         * Two-phased constructor.
    80         * @param aDbManager database manager to use for database interactions
    64         * @param aDbManager database manager to use for database interactions
    81         * @param aCategory identifies the category
    65         * @param aCategory identifies the category
    82         * @return New CMPXDbCategory instance on the cleanup stack.
    66         * @return New CMPXDbCategory instance on the cleanup stack.
    83         */
    67         */
    84         static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager,
    68         static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager,
    85             TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
    69             TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
    86         
    70 
    87         /**
    71         /**
    88         * Destructor
    72         * Destructor
    89         */
    73         */
    90         virtual ~CMPXDbAlbum();
    74         virtual ~CMPXDbAlbum();
    91 
    75 
    92     public:
    76     public:
    93         /**
    77 
    94         * Add an album item. If the record already exists, its counter will
    78         /**
       
    79         * Add a category item. If the record already exists, its counter will
    95         * be incremented.
    80         * be incremented.
    96         * @param aCategory category type
    81         * @param aName: This is the name to be entered into the row
    97         * @param aMedia: The media object
       
    98         * @param aDriveId: The Drive Id the name (category) belongs
    82         * @param aDriveId: The Drive Id the name (category) belongs
    99         * @param aNewRecord: indicates to the caller if a new record is created.
    83         * @param aNewRecord: indicates to the caller if a new record is created.
   100         *        ETrue if a new row is created in the table; otherwise EFalse.
    84         *        ETrue if a new row is created in the table; otherwise EFalse.
   101         * @param aCaseSensitive indicates whether case sensitivity should be taken
    85         * @param aCaseSensitive indicates whether case sensitivity should be taken
   102         *        into consideration when generating the unique row id
    86         *        into consideration when generating the unique row id
   103         * @return The unique id of the row added.
    87         * @return The unique id of the row added.
   104         */
    88         */
   105         virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord,
    89         TUint32 AddItemL(const TDesC& aName, const TDesC& aArtistName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
   106             TBool aCaseSensitive = ETrue);
    90             TBool aCaseSensitive = ETrue);
   107         
    91 
   108         /**
    92         /**
   109         * Decrement the number of songs for the item. If the count gets to 0, remove
    93         * Decrement the number of songs for the item. If the count gets to 0, remove
   110         * the item.
    94         * the item.
   111         * @param aId: The ID of the category to delete.
    95         * @param aId: The ID of the category to delete.
   112         * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
    96         * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
   116         *                  number number of songs on that drive with that album/artist.
   100         *                  number number of songs on that drive with that album/artist.
   117         * @param aItemChangedMessages if valid on return contains a deleted message if the
   101         * @param aItemChangedMessages if valid on return contains a deleted message if the
   118         *                  category was deleted
   102         *                  category was deleted
   119         * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
   103         * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
   120         *        EFalse otherwise
   104         *        EFalse otherwise
       
   105         * @param aArtist: The ID of the artist
   121         * @param aArt: The albumart uri
   106         * @param aArt: The albumart uri
   122         */
   107         */
   123         void DecrementSongsForAlbumL(TUint32 aId, TInt aDriveId,
   108         void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
   124             CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aArt );
   109             CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TUint32 aArtist, const TDesC& aArt );
   125 
   110 
   126         /**
   111         /**
   127         * Gets the details for all category items.
   112     * Gets the details for all category items.
   128         * @param aAttrs attributes to be returned
   113     * @param aAttrs attributes to be returned
   129         * @param aMediaArray returns the requested attributes for all items
   114     * @param aMediaArray returns the requested attributes for all items
   130         */
   115     */
   131         void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
   116         void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
   132             CMPXMediaArray& aMediaArray);
   117             CMPXMediaArray& aMediaArray);
   133 
   118 
   134         /**
   119     /**
   135         * Update a category item.
   120     * Update a category item.
   136         * @param aId: The ID of the category to update
   121     * @param aId: The ID of the category to update
   137         * @param aMedia: The media data
   122     * @param aMedia: The media data
   138         * @param aDriveId: The Drive Id the name (category) belongs
   123     * @param aDriveId: The Drive Id the name (category) belongs
   139         * @param aItemChangedMessages: if valid on return contains a updated message if the
   124     * @param aItemChangedMessages: if valid on return contains a updated message if the
   140         *        category was updated
   125     *        category was updated
   141         */
   126     */
   142         void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
   127         void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
   143 
   128 
   144     public:        
   129     public:
   145         /**
   130         /**
   146         * Get songs count for a specified album and a specified artist
   131     * Get albums count for a specified artist
   147         * @param aArtistId: The ID of the artist
   132     * @param aId: The ID of the artist
   148         * @param aAlbumId: The ID of the album
   133     */
   149         */
   134         TInt GetAlbumsCountForArtistL(TUint32 aArtistId);
       
   135 
       
   136         /**
       
   137     * Get songs count for a specified album and a specified artist
       
   138     * @param aArtistId: The ID of the artist
       
   139     * @param aAlbumId: The ID of the album
       
   140     */
   150         TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
   141         TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
   151        /**
       
   152         * Check if the specified album ID is an unknown album.
       
   153         * An “Unknown album” is one where the album name and album artist are unknown.
       
   154         * @param aId: The ID of the album
       
   155         * @return ETrue if it's an unknown album
       
   156         */
       
   157         TBool IsUnknownAlbumL(const TUint32 aId);
       
   158         
       
   159         /**
       
   160         * Generate Unique ID for Album
       
   161         * @param aMedia media object
       
   162         * @param aCaseSensitive indicates whether case sensitivity should be taken
       
   163         *        into consideration when generating the unique row id
       
   164         * @return the ID of album
       
   165         */
       
   166         TUint32 GenerateUniqueIdL(const CMPXMedia& aMedia);
       
   167 
   142 
   168     private:
   143     private:
   169         /**
   144         /**
   170         * Updates the media with information from the table
   145         * Updates the media with information from the table
   171         * @param aRecord record containing the source fields
   146         * @param aRecord record containing the source fields
   182         * @param aValues values of each field of Album table
   157         * @param aValues values of each field of Album table
   183         * @return a string containing the selection criteria. The ownership is passed to the caller.
   158         * @return a string containing the selection criteria. The ownership is passed to the caller.
   184         */
   159         */
   185         void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia,
   160         void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia,
   186             CDesCArray& aFields, CDesCArray& aValues);
   161             CDesCArray& aFields, CDesCArray& aValues);
   187         
   162 
       
   163 
       
   164         TBool IsUnknownArtistL(TUint32 aId);
       
   165 
       
   166         /**
       
   167         * Get the ArtistName of song which belongs to the specified Album.
       
   168         * @param aId The ID of the album
       
   169         * @returns alternative artistname retrieved in the specified Album.
       
   170         */
       
   171         HBufC* ArtistForAlbumL(const TUint32 aId);
   188         /**
   172         /**
   189         * Get the Albumart of song which belongs to the specified Album.
   173         * Get the Albumart of song which belongs to the specified Album.
   190         * @param aId The ID of the album
   174         * @param aId The ID of the album
   191         * @param aArt albumart with the song is deleted.
   175         * @param aArt albumart with the song is deleted.
   192         * @returns alternative albumart retrieved in the specified Album.
   176         * @returns alternative albumart retrieved in the specified Album.
   193         */
   177         */
   194         HBufC* AlbumartForAlbumL(const TUint32 aId, TPtrC aArt);
   178         HBufC* AlbumartForAlbumL(const TUint32 aId, TPtrC aArt);
   195         
   179 
   196         /**
       
   197         * Processes a recordset by constructing media instances and adding them
       
   198         * to the specified array.
       
   199         * @param aAttrs attributes to be returned
       
   200         * @param aRecordset recordset to be processed
       
   201         * @param aMediaArray returns the media instances
       
   202         */
       
   203         void ProcessAlbumRecordSetL(const TArray<TMPXAttribute>& aAttrs,
       
   204             RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
       
   205         
       
   206         /**
       
   207         * Retrieve AlbumArtist name from media object
       
   208         * @param aMedia media object
       
   209         * @param aName returned name
       
   210         * @return ETrue if name is available
       
   211         */   
       
   212         TBool RetrieveAlbumArtistL(const CMPXMedia& aMedia, TPtrC& aName);
       
   213 
       
   214         /**
       
   215         * Retrieve Artist name from media object
       
   216         * @param aMedia media object
       
   217         * @param aName returned name
       
   218         */   
       
   219         void RetrieveArtist(const CMPXMedia& aMedia, TPtrC& aName);
       
   220 
       
   221         /**
       
   222         * Check if Art needs to be updated
       
   223         * @param aDeletedSongArt deleted song's art
       
   224         * @param aCurrentAlbumArt Album's current art
       
   225         * @return ETrue if aDeletedSongArt is not non-embedded album art and 
       
   226         *         aDeleteSongArt and aCurrentAlbumArt are the same and known
       
   227         */   
       
   228         TBool NeedToUpdateArt(const TDesC& aDeletedSongArt, const TDesC& aCurrentAlbumArt);
       
   229         
       
   230     private:    // from MMPXTable
   180     private:    // from MMPXTable
   231 
   181 
   232         /**
   182         /**
   233         * @see MMPXTable
   183         * @see MMPXTable
   234         */
   184         */
   245         * C++ constructor.
   195         * C++ constructor.
   246         * @param aDbManager database manager to use for database interactions
   196         * @param aDbManager database manager to use for database interactions
   247         * @param aCategory identifies the category
   197         * @param aCategory identifies the category
   248         */
   198         */
   249         CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
   199         CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
   250         
   200 
   251         /**
   201         /**
   252         * Second phase constructor.
   202         * Second phase constructor.
   253         */
   203         */
   254         void ConstructL();
   204         void ConstructL();
   255 
   205 
   259         * Column indexes in the category tables
   209         * Column indexes in the category tables
   260         */
   210         */
   261         enum TAlbumColumns
   211         enum TAlbumColumns
   262             {
   212             {
   263             EAlbumUniqueId = KMPXTableDefaultIndex,
   213             EAlbumUniqueId = KMPXTableDefaultIndex,
       
   214             EAlbumArtistName,
   264             EAlbumName,
   215             EAlbumName,
   265             EAlbumSongCount,      
   216             EAlbumSongCount,      
   266             EAlbumArtist,
       
   267             EAlbumArtistName,
       
   268             EAlbumArt,
   217             EAlbumArt,
   269             EAlbumFieldCount
   218             EAlbumFieldCount
   270             };
   219             };
   271 
   220 
   272     private:    // Data
   221     private:    // Data
   273         MMPXDbAlbumObserver& iObserver;
   222         MMPXDbAlbumObserver& iObserver;
   274         RPointerArray<CMPXMedia> iUnknownArtists;
       
   275         RPointerArray<CMPXMedia> iUnknownAlbums;
       
   276     };
   223     };
   277     
       
   278 #endif // MPXDBALBUM_H
   224 #endif // MPXDBALBUM_H
   279 
   225 
   280 // End of File
   226 // End of File