|
1 /* |
|
2 * Copyright (c) 2007 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: This class is responsible for Artist table. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef MPXDBARTIST_H |
|
21 #define MPXDBARTIST_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "mpxdbcategory.h" |
|
25 |
|
26 // CLASS DECLARATION |
|
27 |
|
28 /** |
|
29 * Responsible for managing all music databases |
|
30 * |
|
31 * @lib MPXDbPlugin.lib |
|
32 */ |
|
33 |
|
34 class CMPXDbArtist : |
|
35 public CMPXDbCategory |
|
36 { |
|
37 public: |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 * @param aDbManager database manager to use for database interactions |
|
41 * @param aCategory identifies the category |
|
42 * @return New CMPXDbArtist instance. |
|
43 */ |
|
44 static CMPXDbArtist* NewL(CMPXDbManager& aDbManager, |
|
45 TMPXGeneralCategory aCategory); |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 * @param aDbManager database manager to use for database interactions |
|
50 * @param aCategory identifies the category |
|
51 * @return New CMPXDbArtist instance on the cleanup stack. |
|
52 */ |
|
53 static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager, |
|
54 TMPXGeneralCategory aCategory); |
|
55 |
|
56 /** |
|
57 * Destructor |
|
58 */ |
|
59 virtual ~CMPXDbArtist(); |
|
60 |
|
61 public: |
|
62 /** |
|
63 * Add a artist item. If the record already exists, its counter will |
|
64 * be incremented. |
|
65 * @param aCategory category type |
|
66 * @param aMedia: This is the media object |
|
67 * @param aDriveId: The Drive Id the name (category) belongs |
|
68 * @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. |
|
70 * @return The unique id of the row added. |
|
71 */ |
|
72 virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord, |
|
73 TBool aCaseSensitive = ETrue); |
|
74 |
|
75 /** |
|
76 * Gets the details for all category items. |
|
77 * @param aAttrs attributes to be returned |
|
78 * @param aMediaArray returns the requested attributes for all items |
|
79 */ |
|
80 void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs, |
|
81 CMPXMediaArray& aMediaArray); |
|
82 |
|
83 /** |
|
84 * Update a category item. |
|
85 * @param aId: The ID of the category to update |
|
86 * @param aMedia: The media data |
|
87 * @param aDriveId: The Drive Id the name (category) belongs |
|
88 * @param aItemChangedMessages: if valid on return contains a updated message if the |
|
89 * category was updated |
|
90 */ |
|
91 virtual void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages); |
|
92 |
|
93 /** |
|
94 * Decrement the number of songs for the item. If the song and album count gets to 0, |
|
95 * remove the item. |
|
96 * @param aId: The ID of the category to delete. |
|
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 */ |
|
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); |
|
139 |
|
140 private: |
|
141 |
|
142 /** |
|
143 * Updates the media with information from the table |
|
144 * @param aRecord record containing the source fields |
|
145 * @param aAttrs attributes to be returned |
|
146 * @param aMedia returns the requested attributes |
|
147 */ |
|
148 void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs, |
|
149 CMPXMedia& aMedia); |
|
150 |
|
151 /** |
|
152 * Generate searching criteria for artist table from the given criteria |
|
153 * @param aMedia media data |
|
154 * @param aFields fields of Artist table |
|
155 * @param aValues values of each field of Artist table |
|
156 * @return a string containing the selection criteria. The ownership is passed to the caller. |
|
157 */ |
|
158 void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, |
|
159 CDesCArray& aFields, CDesCArray& aValues); |
|
160 |
|
161 /** |
|
162 * Gets the Songs count and Albums count for a Artist item |
|
163 * @param aDrivceId The Drive Id the name (category) belongs |
|
164 * @param aId identifies the Artist item |
|
165 * @param aSongsCount songs count |
|
166 * @param aAlbumsCount albums count |
|
167 */ |
|
168 void GetSongsAndAlbumsCountL(TInt aDriveId, TUint32 aId, TInt& aSongsCount, TInt& aAlbumsCount); |
|
169 |
|
170 private: // from MMPXTable |
|
171 |
|
172 /** |
|
173 * @see MMPXTable |
|
174 */ |
|
175 virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable); |
|
176 |
|
177 /** |
|
178 * @see MMPXTable |
|
179 */ |
|
180 virtual TBool CheckTableL(RSqlDatabase& aDatabase); |
|
181 |
|
182 private: |
|
183 |
|
184 /** |
|
185 * C++ constructor. |
|
186 * @param aDbManager database manager to use for database interactions |
|
187 * @param aCategory identifies the category |
|
188 */ |
|
189 CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory); |
|
190 |
|
191 /** |
|
192 * Second phase constructor. |
|
193 */ |
|
194 void ConstructL(); |
|
195 |
|
196 private: |
|
197 |
|
198 /** |
|
199 * Column indexes in the category tables |
|
200 */ |
|
201 enum TArtistColumns |
|
202 { |
|
203 EArtistUniqueId = KMPXTableDefaultIndex, |
|
204 EArtistName, |
|
205 EArtistSongCount, |
|
206 EArtistAlbumCount, |
|
207 EArtistArt, |
|
208 EArtistFieldCount |
|
209 }; |
|
210 }; |
|
211 |
|
212 #endif // MPXDBARTIST_H |
|
213 |
|
214 // End of File |