mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbartist.h
branchRCL_3
changeset 66 1f1dad4af8f8
parent 56 2cbbefa9af78
equal deleted inserted replaced
60:bdd9da0d70fe 66:1f1dad4af8f8
    22 
    22 
    23 // INCLUDES
    23 // INCLUDES
    24 #include "mpxdbcategory.h"
    24 #include "mpxdbcategory.h"
    25 
    25 
    26 // CLASS DECLARATION
    26 // CLASS DECLARATION
       
    27 class MMPXDbArtistObserver
       
    28     {
       
    29     public:
       
    30 		virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aId) = 0;
       
    31 	};
    27 
    32 
    28 /**
    33 /**
    29 * Responsible for managing all music databases
    34 * Responsible for managing all music databases
    30 *
    35 *
    31 * @lib MPXDbPlugin.lib
    36 * @lib MPXDbPlugin.lib
    40         * @param aDbManager database manager to use for database interactions
    45         * @param aDbManager database manager to use for database interactions
    41         * @param aCategory identifies the category
    46         * @param aCategory identifies the category
    42         * @return New CMPXDbArtist instance.
    47         * @return New CMPXDbArtist instance.
    43         */
    48         */
    44         static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
    49         static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
    45             TMPXGeneralCategory aCategory);
    50             TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
    46 
    51 
    47         /**
    52         /**
    48         * Two-phased constructor.
    53         * Two-phased constructor.
    49         * @param aDbManager database manager to use for database interactions
    54         * @param aDbManager database manager to use for database interactions
    50         * @param aCategory identifies the category
    55         * @param aCategory identifies the category
    51         * @return New CMPXDbArtist instance on the cleanup stack.
    56         * @return New CMPXDbArtist instance on the cleanup stack.
    52         */
    57         */
    53         static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
    58         static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
    54             TMPXGeneralCategory aCategory);
    59             TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
    55         
    60 
    56         /**
    61         /**
    57         * Destructor
    62         * Destructor
    58         */
    63         */
    59         virtual ~CMPXDbArtist();
    64         virtual ~CMPXDbArtist();
    60 
    65 
    61     public:
    66     public:
    62         /**
    67         /**
    63         * Add a artist item. If the record already exists, its counter will
    68         * Add a category item. If the record already exists, its counter will
    64         * be incremented.
    69         * be incremented.
    65         * @param aCategory category type
    70         * @param aName: This is the name to be entered into the row
    66         * @param aMedia: This is the media object
       
    67         * @param aDriveId: The Drive Id the name (category) belongs
    71         * @param aDriveId: The Drive Id the name (category) belongs
    68         * @param aNewRecord: indicates to the caller if a new record is created.
    72         * @param aNewRecord: indicates to the caller if a new record is created.
    69         *        ETrue if a new row is created in the table; otherwise EFalse.
    73         *        ETrue if a new row is created in the table; otherwise EFalse.
       
    74         * @param aCaseSensitive indicates whether case sensitivity should be taken
       
    75         *        into consideration when generating the unique row id
    70         * @return The unique id of the row added.
    76         * @return The unique id of the row added.
    71         */
    77         */
    72         virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord,
    78         TUint32 AddItemL(const TDesC& aName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
    73             TBool aCaseSensitive = ETrue);
    79             TBool aCaseSensitive = ETrue);
    74 
    80 
    75         /**
    81         /**
    76         * Gets the details for all category items.
    82         * Gets the details for all category items.
    77         * @param aAttrs attributes to be returned
    83         * @param aAttrs attributes to be returned
    86         * @param aMedia: The media data
    92         * @param aMedia: The media data
    87         * @param aDriveId: The Drive Id the name (category) belongs
    93         * @param aDriveId: The Drive Id the name (category) belongs
    88         * @param aItemChangedMessages: if valid on return contains a updated message if the
    94         * @param aItemChangedMessages: if valid on return contains a updated message if the
    89         *        category was updated
    95         *        category was updated
    90         */
    96         */
    91         virtual void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
    97         void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
    92         
    98 
    93         /**
    99         /*
    94         * Decrement the number of songs for the item. If the song and album count gets to 0, 
   100         * Checks if the specified artist item is unknown
    95         * remove the item.
   101         * @param aId identifies the artist item
    96         * @param aId: The ID of the category to delete.
   102         * @return ETrue if it is unknown, EFalse otherwise
    97         * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
       
    98         *                  drives may belong to the same album or artist; consequently, one
       
    99         *                  row for each artist/album id and drive ID pair will exist in the
       
   100         *                  lookup table with a count existing for each row that tracks the
       
   101         *                  number number of songs on that drive with that album/artist.
       
   102         * @param aItemChangedMessages if valid on return contains a deleted message if the
       
   103         *                  category was deleted
       
   104         * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
       
   105         *        EFalse otherwise
       
   106         */
   103         */
   107 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   104         TBool IsUnknownArtistL(TUint32 aId);
   108         virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
       
   109             CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse = EFalse); 
       
   110 #else
       
   111         virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
       
   112             CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
       
   113 #endif //ABSTRACTAUDIOALBUM_INCLUDED            
       
   114 
       
   115         /**
       
   116         * Add a AlbumArtist. If the record already exists, its counter will
       
   117         * be incremented.
       
   118         * @param aName: This is the name to be entered into the row
       
   119         * @param aArt: Album art
       
   120         * @param aDriveId: The Drive Id the name (category) belongs
       
   121         * @return The unique id of the row added.
       
   122         */
       
   123         TUint32 AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId);
       
   124         
       
   125         /**
       
   126         * Decrement the number of albums for the item. If the song and album count gets to 0, 
       
   127         * remove the item.
       
   128         * @param aId: The ID of the category to delete.
       
   129         * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
       
   130         *                  drives may belong to the same album or artist; consequently, one
       
   131         *                  row for each artist/album id and drive ID pair will exist in the
       
   132         *                  lookup table with a count existing for each row that tracks the
       
   133         *                  number number of songs on that drive with that album/artist.
       
   134         * @param aItemChangedMessages if valid on return contains a deleted message if the
       
   135         *                  category was deleted
       
   136         */
       
   137         void DecrementAlbumsForArtistL(TUint32 aId, TInt aDriveId,
       
   138             CMPXMessageArray* aItemChangedMessages);       
       
   139 
   105 
   140     private:
   106     private:
   141 
   107 
   142         /**
   108         /**
   143         * Updates the media with information from the table
   109         * Updates the media with information from the table
   155         * @param aValues values of each field of Artist table
   121         * @param aValues values of each field of Artist table
   156         * @return a string containing the selection criteria. The ownership is passed to the caller.
   122         * @return a string containing the selection criteria. The ownership is passed to the caller.
   157         */
   123         */
   158         void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia,
   124         void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia,
   159             CDesCArray& aFields, CDesCArray& aValues);
   125             CDesCArray& aFields, CDesCArray& aValues);
   160        
   126 
   161         /**
   127         /**
   162         * Gets the Songs count and Albums count for a Artist item
   128         * Gets the Album counts for a Artist item
   163         * @param aDrivceId The Drive Id the name (category) belongs
       
   164         * @param aId identifies the Artist item
   129         * @param aId identifies the Artist item
   165         * @param aSongsCount songs count
   130         * @return value of the Album counts
   166         * @param aAlbumsCount albums count
       
   167         */
   131         */
   168         void GetSongsAndAlbumsCountL(TInt aDriveId, TUint32 aId, TInt& aSongsCount, TInt& aAlbumsCount);
   132         TInt GetAlbumsCountL(TUint32 aId);
   169         
   133 
   170     private:    // from MMPXTable
   134     private:    // from MMPXTable
   171 
   135 
   172         /**
   136         /**
   173         * @see MMPXTable
   137         * @see MMPXTable
   174         */
   138         */
   184         /**
   148         /**
   185         * C++ constructor.
   149         * C++ constructor.
   186         * @param aDbManager database manager to use for database interactions
   150         * @param aDbManager database manager to use for database interactions
   187         * @param aCategory identifies the category
   151         * @param aCategory identifies the category
   188         */
   152         */
   189         CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
   153         CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
   190 
   154 
   191         /**
   155         /**
   192         * Second phase constructor.
   156         * Second phase constructor.
   193         */
   157         */
   194         void ConstructL();
   158         void ConstructL();
   201         enum TArtistColumns
   165         enum TArtistColumns
   202             {
   166             {
   203             EArtistUniqueId = KMPXTableDefaultIndex,
   167             EArtistUniqueId = KMPXTableDefaultIndex,
   204             EArtistName,
   168             EArtistName,
   205             EArtistSongCount,
   169             EArtistSongCount,
   206             EArtistAlbumCount,
       
   207             EArtistArt,
   170             EArtistArt,
   208             EArtistFieldCount
   171             EArtistFieldCount
   209             };
   172             };
       
   173 
       
   174     private:    // Data
       
   175         MMPXDbArtistObserver& iObserver;
   210     };
   176     };
   211     
       
   212 #endif // MPXDBARTIST_H
   177 #endif // MPXDBARTIST_H
   213 
   178 
   214 // End of File
   179 // End of File