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