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