|
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 all category tables (Artist, |
|
15 * Album, Genre, Composer). |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef MPXDBALBUM_H |
|
22 #define MPXDBALBUM_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "mpxdbcategory.h" |
|
26 |
|
27 // CLASS DECLARATION |
|
28 |
|
29 class MMPXDbAlbumObserver |
|
30 { |
|
31 public: |
|
32 virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0; |
|
33 virtual TUint32 HandleArtistForAlbumL( const TUint32 aId ) = 0; |
|
34 }; |
|
35 /** |
|
36 * Responsible for managing all music databases |
|
37 * |
|
38 * @lib MPXDbPlugin.lib |
|
39 */ |
|
40 |
|
41 class CMPXDbAlbum : |
|
42 public CMPXDbCategory |
|
43 { |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 * @param aDbManager database manager to use for database interactions |
|
49 * @param aCategory identifies the category |
|
50 * @return New CMPXDbCategory instance. |
|
51 */ |
|
52 static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager, |
|
53 TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver); |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * @param aDbManager database manager to use for database interactions |
|
58 * @param aCategory identifies the category |
|
59 * @return New CMPXDbCategory instance on the cleanup stack. |
|
60 */ |
|
61 static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager, |
|
62 TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver); |
|
63 |
|
64 /** |
|
65 * Destructor |
|
66 */ |
|
67 virtual ~CMPXDbAlbum(); |
|
68 |
|
69 public: |
|
70 |
|
71 /** |
|
72 * Add a category item. If the record already exists, its counter will |
|
73 * be incremented. |
|
74 * @param aName: This is the name to be entered into the row |
|
75 * @param aDriveId: The Drive Id the name (category) belongs |
|
76 * @param aNewRecord: indicates to the caller if a new record is created. |
|
77 * ETrue if a new row is created in the table; otherwise EFalse. |
|
78 * @param aCaseSensitive indicates whether case sensitivity should be taken |
|
79 * into consideration when generating the unique row id |
|
80 * @return The unique id of the row added. |
|
81 */ |
|
82 TUint32 AddItemL(const TDesC& aName, TUint32 aArtist, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord, |
|
83 TBool aCaseSensitive = ETrue); |
|
84 |
|
85 /** |
|
86 * Decrement the number of songs for the item. If the count gets to 0, remove |
|
87 * the item. |
|
88 * @param aId: The ID of the category to delete. |
|
89 * @param aDriveId: The drive Id the name (category) belongs to. Songs on different |
|
90 * drives may belong to the same album or artist; consequently, one |
|
91 * row for each artist/album id and drive ID pair will exist in the |
|
92 * lookup table with a count existing for each row that tracks the |
|
93 * number number of songs on that drive with that album/artist. |
|
94 * @param aItemChangedMessages if valid on return contains a deleted message if the |
|
95 * category was deleted |
|
96 * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete, |
|
97 * EFalse otherwise |
|
98 * @param aArtist: The ID of the artist |
|
99 */ |
|
100 void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId, |
|
101 CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TUint32 aArtist); |
|
102 |
|
103 /** |
|
104 * Gets the details for all category items. |
|
105 * @param aAttrs attributes to be returned |
|
106 * @param aMediaArray returns the requested attributes for all items |
|
107 */ |
|
108 void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs, |
|
109 CMPXMediaArray& aMediaArray); |
|
110 |
|
111 /** |
|
112 * Update a category item. |
|
113 * @param aId: The ID of the category to update |
|
114 * @param aMedia: The media data |
|
115 * @param aDriveId: The Drive Id the name (category) belongs |
|
116 * @param aItemChangedMessages: if valid on return contains a updated message if the |
|
117 * category was updated |
|
118 */ |
|
119 void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages); |
|
120 |
|
121 public: |
|
122 /** |
|
123 * Get albums count for a specified artist |
|
124 * @param aId: The ID of the artist |
|
125 */ |
|
126 TInt GetAlbumsCountForArtistL(TUint32 aArtistId); |
|
127 |
|
128 /** |
|
129 * Get songs count for a specified album and a specified artist |
|
130 * @param aArtistId: The ID of the artist |
|
131 * @param aAlbumId: The ID of the album |
|
132 */ |
|
133 TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId); |
|
134 |
|
135 private: |
|
136 /** |
|
137 * Updates the media with information from the table |
|
138 * @param aRecord record containing the source fields |
|
139 * @param aAttrs attributes to be returned |
|
140 * @param aMedia returns the requested attributes |
|
141 */ |
|
142 void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs, |
|
143 CMPXMedia& aMedia); |
|
144 |
|
145 /** |
|
146 * Generate searching criteria for album table from the given criteria |
|
147 * @param aMedia media data |
|
148 * @param aFields fields of Album table |
|
149 * @param aValues values of each field of Album table |
|
150 * @return a string containing the selection criteria. The ownership is passed to the caller. |
|
151 */ |
|
152 void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, |
|
153 CDesCArray& aFields, CDesCArray& aValues); |
|
154 |
|
155 |
|
156 TBool IsUnknownArtistL(TUint32 aId); |
|
157 |
|
158 TUint32 ArtistForAlbumL(const TUint32 aId); |
|
159 |
|
160 private: // from MMPXTable |
|
161 |
|
162 /** |
|
163 * @see MMPXTable |
|
164 */ |
|
165 virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable); |
|
166 |
|
167 /** |
|
168 * @see MMPXTable |
|
169 */ |
|
170 virtual TBool CheckTableL(RSqlDatabase& aDatabase); |
|
171 |
|
172 private: |
|
173 |
|
174 /** |
|
175 * C++ constructor. |
|
176 * @param aDbManager database manager to use for database interactions |
|
177 * @param aCategory identifies the category |
|
178 */ |
|
179 CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver); |
|
180 |
|
181 /** |
|
182 * Second phase constructor. |
|
183 */ |
|
184 void ConstructL(); |
|
185 |
|
186 public: |
|
187 |
|
188 /** |
|
189 * Column indexes in the category tables |
|
190 */ |
|
191 enum TAlbumColumns |
|
192 { |
|
193 EAlbumUniqueId = KMPXTableDefaultIndex, |
|
194 EAlbumName, |
|
195 EAlbumSongCount, |
|
196 EAlbumArtist, |
|
197 EAlbumArt, |
|
198 EAlbumArtistName, |
|
199 EAlbumFieldCount |
|
200 }; |
|
201 |
|
202 private: // Data |
|
203 MMPXDbAlbumObserver& iObserver; |
|
204 }; |
|
205 #endif // MPXDBALBUM_H |
|
206 |
|
207 // End of File |