26
|
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 MPXDBCATEGORY_H
|
|
22 |
#define MPXDBCATEGORY_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include "mpxdbtable.h"
|
|
26 |
#include "mpxmediageneraldefs.h"
|
|
27 |
#include "mpxmessage2.h"
|
|
28 |
|
|
29 |
// CLASS FORWARDS
|
|
30 |
class CMPXMedia;
|
|
31 |
class CMPXMediaArray;
|
|
32 |
class RSqlStatement;
|
|
33 |
|
|
34 |
// CLASS DECLARATION
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Responsible for managing all music databases
|
|
38 |
*
|
|
39 |
* @lib MPXDbPlugin.lib
|
|
40 |
*/
|
|
41 |
class CMPXDbCategory :
|
|
42 |
public CMPXDbTable
|
|
43 |
{
|
|
44 |
protected:
|
|
45 |
/**
|
|
46 |
* Destructor
|
|
47 |
*/
|
|
48 |
virtual ~CMPXDbCategory();
|
|
49 |
|
|
50 |
|
|
51 |
public:
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Add a category item. If the record already exists, its counter will
|
|
55 |
* be incremented.
|
|
56 |
* @param aName: This is the name to be entered into the row
|
|
57 |
* @param aDriveId: The Drive Id the name (category) belongs
|
|
58 |
* @param aNewRecord: indicates to the caller if a new record is created.
|
|
59 |
* ETrue if a new row is created in the table; otherwise EFalse.
|
|
60 |
* @param aCaseSensitive indicates whether case sensitivity should be taken
|
|
61 |
* into consideration when generating the unique row id
|
|
62 |
* @return The unique id of the row added.
|
|
63 |
*/
|
|
64 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
|
|
65 |
virtual TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
|
|
66 |
TBool aCaseSensitive = ETrue);
|
|
67 |
#else
|
|
68 |
TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
|
|
69 |
TBool aCaseSensitive = ETrue);
|
|
70 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Get the name field for a given ID.
|
|
74 |
* @param aId identifies the category item
|
|
75 |
* @return name that matches aId. Ownership is abandoned.
|
|
76 |
*/
|
|
77 |
HBufC* GetNameL(TUint32 aId);
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Gets the total number of items in the category table.
|
|
81 |
* @return number of items
|
|
82 |
*/
|
|
83 |
TInt CountL();
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Find record(s) matching the criteria
|
|
87 |
* @param aCriteria, selection criteria
|
|
88 |
* @param aAttrs, attributes for the matching record(s)
|
|
89 |
* @param aMediaArray returns the matching record(s)
|
|
90 |
*/
|
|
91 |
void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
|
|
92 |
CMPXMediaArray& aMediaArray);
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Decrement the number of songs for the item. If the count gets to 0, remove
|
|
96 |
* the item.
|
|
97 |
* @param aId: The ID of the category to delete.
|
|
98 |
* @param aDriveId: The drive Id the name (category) belongs to. Songs on different
|
|
99 |
* drives may belong to the same album or artist; consequently, one
|
|
100 |
* row for each artist/album id and drive ID pair will exist in the
|
|
101 |
* lookup table with a count existing for each row that tracks the
|
|
102 |
* number number of songs on that drive with that album/artist.
|
|
103 |
* @param aItemChangedMessages if valid on return contains a deleted message if the
|
|
104 |
* category was deleted
|
|
105 |
* @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
|
|
106 |
* EFalse otherwise
|
|
107 |
*/
|
|
108 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
|
|
109 |
virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
|
|
110 |
CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse = EFalse);
|
|
111 |
#else
|
|
112 |
void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
|
|
113 |
CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
|
|
114 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED
|
|
115 |
/**
|
|
116 |
* Deletes a category.
|
|
117 |
* @param aId identifies the category
|
|
118 |
* @param aDriveId category drive
|
|
119 |
*/
|
|
120 |
void DeleteCategoryL(TUint32 aId, TInt aDriveId);
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Gets the details for multiple category items.
|
|
124 |
* @param aAttrs attributes to be returned
|
|
125 |
* @param aMediaArray inout parameter, on input contains the IDs of the
|
|
126 |
* category items to be returned, on exit contains the requested
|
|
127 |
* attributes for these items
|
|
128 |
*/
|
|
129 |
void GetCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
|
|
130 |
CMPXMediaArray& aMediaArray);
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Gets the details for all category items.
|
|
134 |
* @param aAttrs attributes to be returned
|
|
135 |
* @param aMediaArray returns the requested attributes for all items
|
|
136 |
*/
|
|
137 |
void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
|
|
138 |
CMPXMediaArray& aMediaArray);
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Gets details for one category item.
|
|
142 |
* @param aId identifies the category item
|
|
143 |
* @param aAttrs attributes to be returned
|
|
144 |
* @param aMedia returns the requested attributes for te item
|
|
145 |
* @leave KErrCorrupt if there are multiple items with the same ID
|
|
146 |
* KErrNotFound if there is no item with the specified ID
|
|
147 |
*/
|
|
148 |
void GetCategoryItemL(TUint32 aId, const TArray<TMPXAttribute>& aAttrs,
|
|
149 |
CMPXMedia& aMedia);
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Gets details for the category items under a parent category item.
|
|
153 |
* This applies to albums for a given artist. The method panics if the
|
|
154 |
* category or parent category are invalid.
|
|
155 |
* @param aParentCategory identifies the parent category
|
|
156 |
* @param aParentId identifies the parent item
|
|
157 |
* @param aAttrs attributes to be returned
|
|
158 |
* @param aMediaArray returns the requested attributes for all items
|
|
159 |
*/
|
|
160 |
void GetSubCategoryItemsL(TMPXGeneralCategory aParentCategory, TUint32 aParentId,
|
|
161 |
const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Checks if the specified category item exists.
|
|
165 |
* @param aDriveId drive to check or KDbManagerAllDrives
|
|
166 |
* @param aId identifies the category item
|
|
167 |
* @return ETrue if it exists, EFalse otherwise
|
|
168 |
*/
|
|
169 |
TBool CategoryItemExistsL(TInt aDriveId, TUint32 aId);
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Gets the CountSongs field for a category item
|
|
173 |
* @param aDriveId drive to check or KDbManagerAllDrives
|
|
174 |
* @param aId identifies the category item
|
|
175 |
* @return value of the CountSongs field.
|
|
176 |
*/
|
|
177 |
TInt GetSongsCountL(TInt aDriveId, TUint32 aId);
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Update a category item.
|
|
181 |
* @param aId: The ID of the category to update
|
|
182 |
* @param aMedia: The media data
|
|
183 |
* @param aDriveId: The Drive Id the name (category) belongs
|
|
184 |
* @param aItemChangedMessages: if valid on return contains a updated message if the
|
|
185 |
* category was updated
|
|
186 |
*/
|
|
187 |
void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
|
|
188 |
|
|
189 |
protected:
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Updates the media with information from the table
|
|
193 |
* @param aRecord record containing the source fields
|
|
194 |
* @param aAttrs attributes to be returned
|
|
195 |
* @param aMedia returns the requested attributes
|
|
196 |
*/
|
|
197 |
void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
|
|
198 |
CMPXMedia& aMedia);
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Returns the category record for a given ID
|
|
202 |
* @param aId identifies the category item
|
|
203 |
* @return rowset
|
|
204 |
*/
|
|
205 |
RSqlStatement GetCategoryRecordL(TUint32 aId);
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Replaces the table placeholder in the string parameter with the
|
|
209 |
* category table name.
|
|
210 |
* @param aQuery raw query string
|
|
211 |
* @return processed query string, ownership is transferred.
|
|
212 |
*/
|
|
213 |
HBufC* PreProcessStringLC(const TDesC& aQuery);
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Processes a recordset by constructing media instances and adding them
|
|
217 |
* to the specified array.
|
|
218 |
* @param aAttrs attributes to be returned
|
|
219 |
* @param aRecordset recordset to be processed
|
|
220 |
* @param aMediaArray returns the media instances
|
|
221 |
*/
|
|
222 |
void ProcessRecordsetL(const TArray<TMPXAttribute>& aAttrs,
|
|
223 |
RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
|
|
224 |
|
|
225 |
private: // from MMPXTable
|
|
226 |
|
|
227 |
/**
|
|
228 |
* @see MMPXTable
|
|
229 |
*/
|
|
230 |
virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
|
|
231 |
|
|
232 |
/**
|
|
233 |
* @see MMPXTable
|
|
234 |
*/
|
|
235 |
virtual void DropTableL(RSqlDatabase& aDatabase);
|
|
236 |
|
|
237 |
/**
|
|
238 |
* @see MMPXTable
|
|
239 |
*/
|
|
240 |
virtual TBool CheckTableL(RSqlDatabase& aDatabase);
|
|
241 |
|
|
242 |
protected:
|
|
243 |
|
|
244 |
/**
|
|
245 |
* C++ constructor.
|
|
246 |
* @param aDbManager database manager to use for database interactions
|
|
247 |
* @param aCategory identifies the category
|
|
248 |
*/
|
|
249 |
CMPXDbCategory(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Second phase constructor.
|
|
253 |
*/
|
|
254 |
void BaseConstructL();
|
|
255 |
|
|
256 |
private:
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Column indexes in the category tables
|
|
260 |
*/
|
|
261 |
enum TCategoryColumns
|
|
262 |
{
|
|
263 |
ECategoryUniqueId = KMPXTableDefaultIndex,
|
|
264 |
ECategoryName,
|
|
265 |
ECategorySongCount
|
|
266 |
};
|
|
267 |
|
|
268 |
protected:
|
|
269 |
|
|
270 |
HBufC* iTableName; // owned
|
|
271 |
TMPXGeneralCategory iCategory;
|
|
272 |
|
|
273 |
};
|
|
274 |
|
|
275 |
#endif // MPXDBCATEGORY_H
|
|
276 |
|
|
277 |
// End of File
|