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