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: Responsible for interation with the Artist table |
|
15 |
* |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <sqldb.h> |
|
22 |
||
23 |
#include <mpxlog.h> |
|
24 |
||
25 |
#include "mpxdbcommonutil.h" |
|
26 |
#include "mpxdbcommondef.h" |
|
27 |
#include "mpxmediamusicdefs.h" |
|
28 |
#include "mpxdbmanager.h" |
|
29 |
||
30 |
#include "mpxcollectiondbdef.h" |
|
31 |
#include "mpxdbpluginqueries.h" |
|
32 |
#include "mpxdbutil.h" |
|
33 |
#include "mpxdbartist.h" |
|
34 |
||
35 |
// CONSTANTS |
|
36 |
||
37 |
// ============================ MEMBER FUNCTIONS ============================== |
|
38 |
||
39 |
// ---------------------------------------------------------------------------- |
|
40 |
// Two-phased constructor. |
|
41 |
// ---------------------------------------------------------------------------- |
|
42 |
// |
|
43 |
CMPXDbArtist* CMPXDbArtist::NewL( |
|
44 |
CMPXDbManager& aDbManager, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
45 |
TMPXGeneralCategory aCategory, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
46 |
MMPXDbArtistObserver& aObserver) |
53 | 47 |
{ |
48 |
MPX_FUNC("CMPXDbArtist::NewL"); |
|
49 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
50 |
CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory, aObserver); |
53 | 51 |
CleanupStack::Pop(self); |
52 |
return self; |
|
53 |
} |
|
54 |
||
55 |
// ---------------------------------------------------------------------------- |
|
56 |
// Two-phased constructor. |
|
57 |
// ---------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
CMPXDbArtist* CMPXDbArtist::NewLC( |
|
60 |
CMPXDbManager& aDbManager, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
61 |
TMPXGeneralCategory aCategory, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
62 |
MMPXDbArtistObserver& aObserver) |
53 | 63 |
{ |
64 |
MPX_FUNC("CMPXDbArtist::NewLC"); |
|
65 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
66 |
CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory, aObserver); |
53 | 67 |
CleanupStack::PushL(self); |
68 |
self->ConstructL(); |
|
69 |
return self; |
|
70 |
} |
|
71 |
||
72 |
// ---------------------------------------------------------------------------- |
|
73 |
// Destructor |
|
74 |
// ---------------------------------------------------------------------------- |
|
75 |
// |
|
76 |
CMPXDbArtist::~CMPXDbArtist() |
|
77 |
{ |
|
78 |
MPX_FUNC("CMPXDbArtist::~CMPXDbArtist"); |
|
79 |
} |
|
80 |
||
81 |
// ---------------------------------------------------------------------------- |
|
82 |
// Constructor |
|
83 |
// ---------------------------------------------------------------------------- |
|
84 |
// |
|
85 |
CMPXDbArtist::CMPXDbArtist( |
|
86 |
CMPXDbManager& aDbManager, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
87 |
TMPXGeneralCategory aCategory, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
88 |
MMPXDbArtistObserver& aObserver) : |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
89 |
CMPXDbCategory(aDbManager, aCategory), |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
90 |
iObserver(aObserver) |
53 | 91 |
{ |
92 |
MPX_FUNC("CMPXDbArtist::CMPXDbArtist"); |
|
93 |
} |
|
94 |
||
95 |
// ---------------------------------------------------------------------------- |
|
96 |
// Second phase constructor. |
|
97 |
// ---------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
void CMPXDbArtist::ConstructL() |
|
100 |
{ |
|
101 |
MPX_FUNC("CMPXDbArtist::ConstructL"); |
|
102 |
||
103 |
BaseConstructL(); |
|
104 |
} |
|
105 |
||
106 |
// ---------------------------------------------------------------------------- |
|
107 |
// CMPXDbArtist::AddItemL |
|
108 |
// ---------------------------------------------------------------------------- |
|
109 |
// |
|
110 |
TUint32 CMPXDbArtist::AddItemL( |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
111 |
const TDesC& aName, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
112 |
const TDesC& aArt, |
53 | 113 |
TInt aDriveId, |
114 |
TBool& aNewRecord, |
|
115 |
TBool aCaseSensitive) |
|
116 |
{ |
|
117 |
MPX_FUNC("CMPXDbArtist::AddItemL"); |
|
118 |
||
119 |
// try to find the item first |
|
120 |
TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
121 |
aName, aCaseSensitive)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
122 |
aNewRecord = !CategoryItemExistsL(aDriveId, rowId); |
53 | 123 |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
124 |
if (aNewRecord) |
53 | 125 |
{ |
126 |
// insert new |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
127 |
HBufC* query = PreProcessStringLC(KQueryArtistInsert); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
128 |
HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
129 |
HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt); |
53 | 130 |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
131 |
iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, art); |
53 | 132 |
|
133 |
CleanupStack::PopAndDestroy(art); |
|
134 |
CleanupStack::PopAndDestroy(name); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
135 |
CleanupStack::PopAndDestroy(query); |
53 | 136 |
} |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
137 |
else |
53 | 138 |
{ |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
139 |
// retrieve the existing record |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
140 |
HBufC* query = NULL; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
141 |
query = PreProcessStringLC(KQueryCategoryItem); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
142 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
143 |
CleanupStack::PopAndDestroy(query); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
144 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
145 |
CleanupClosePushL(recordset); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
146 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
147 |
if (recordset.Next() != KSqlAtRow) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
148 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
149 |
User::Leave(KErrNotFound); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
150 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
151 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
152 |
// Album Art |
53 | 153 |
TPtrC art(KNullDesC); |
154 |
art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt)); |
|
155 |
||
156 |
// the current one is Unknown and the new one is Not Unknown |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
157 |
if ( art == KNullDesC && aArt != KNullDesC ) |
53 | 158 |
{ |
159 |
HBufC* artReplaceSingleQuote = |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
160 |
MPXDbCommonUtil::ProcessSingleQuotesLC( aArt ); |
53 | 161 |
_LIT( KFormatArt, "Art=\'%S\'" ); |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
162 |
HBufC* setStr = HBufC::NewLC(256); |
53 | 163 |
setStr->Des().Format( KFormatArt, artReplaceSingleQuote ); |
164 |
||
165 |
iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId); |
|
166 |
CleanupStack::PopAndDestroy(setStr); |
|
167 |
CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
|
168 |
} |
|
169 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
170 |
CleanupStack::PopAndDestroy(&recordset); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
171 |
|
53 | 172 |
// increment the number of songs for the category |
173 |
query = PreProcessStringLC(KQueryCategoryIncrementSongCount); |
|
174 |
iDbManager.ExecuteQueryL(aDriveId, *query, rowId); |
|
175 |
CleanupStack::PopAndDestroy(query); |
|
176 |
} |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
177 |
|
53 | 178 |
return rowId; |
179 |
} |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
180 |
|
53 | 181 |
// ---------------------------------------------------------------------------- |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
182 |
// CMPXDbArtist::IsUnknownArtistL |
53 | 183 |
// ---------------------------------------------------------------------------- |
184 |
// |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
185 |
TBool CMPXDbArtist::IsUnknownArtistL(TUint32 aId) |
53 | 186 |
{ |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
187 |
MPX_FUNC("CMPXDbArtist::IsUnknownArtistL"); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
188 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
189 |
HBufC* name = GetNameL(aId); |
53 | 190 |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
191 |
TInt ret = EFalse; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
192 |
if (*name == KNullDesC) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
193 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
194 |
ret = ETrue; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
195 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
196 |
delete name; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
197 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
198 |
return ret; |
53 | 199 |
} |
200 |
||
201 |
// ---------------------------------------------------------------------------- |
|
202 |
// CMPXDbArtist::UpdateMediaL |
|
203 |
// ---------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
void CMPXDbArtist::UpdateMediaL( |
|
206 |
RSqlStatement& aRecord, |
|
207 |
const TArray<TMPXAttribute>& aAttrs, |
|
208 |
CMPXMedia& aMedia) |
|
209 |
{ |
|
210 |
MPX_FUNC("CMPXDbArtist::UpdateMediaL"); |
|
211 |
||
212 |
TInt count(aAttrs.Count()); |
|
213 |
for (TInt i = 0; i < count; ++i) |
|
214 |
{ |
|
215 |
TInt contentId(aAttrs[i].ContentId()); |
|
216 |
TUint attributeId(aAttrs[i].AttributeId()); |
|
217 |
||
218 |
if (contentId == KMPXMediaIdGeneral) |
|
219 |
{ |
|
220 |
if (attributeId & EMPXMediaGeneralId) |
|
221 |
{ |
|
222 |
MPX_DEBUG1(" EMPXMediaGeneralId"); |
|
223 |
||
224 |
aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
|
225 |
aRecord.ColumnInt64(EArtistUniqueId)); |
|
226 |
MPX_DEBUG2(" Id[%d]", aRecord.ColumnInt64(EArtistUniqueId)); |
|
227 |
} |
|
228 |
if (attributeId & EMPXMediaGeneralTitle) |
|
229 |
{ |
|
230 |
MPX_DEBUG1(" EMPXMediaGeneralTitle"); |
|
231 |
||
232 |
TPtrC artist( MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName) ); |
|
233 |
aMedia.SetTextValueL(KMPXMediaGeneralTitle, |
|
234 |
MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName)); |
|
235 |
||
236 |
MPX_DEBUG2(" Artist[%S]", &artist); |
|
237 |
} |
|
238 |
if (attributeId & EMPXMediaGeneralCount) |
|
239 |
{ |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
240 |
// TInt albumCount = GetAlbumsCountL(aRecord.ColumnInt64(EArtistUniqueId)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
241 |
// aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,albumCount); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
242 |
// MPX_DEBUG1(" EMPXMediaGeneralCount"); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
243 |
// MPX_DEBUG2(" AlbumCount[%d]", albumCount); |
53 | 244 |
// get songs count from all drives |
245 |
TInt songCount = GetSongsCountL( KDbManagerAllDrives, |
|
246 |
aRecord.ColumnInt64( EArtistUniqueId ) ); |
|
247 |
aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount); // mod by anjokela |
|
248 |
||
249 |
MPX_DEBUG1(" EMPXMediaGeneralCount"); |
|
250 |
MPX_DEBUG2(" SongCount[%d]", songCount); |
|
251 |
} |
|
252 |
} // end if contentId == KMPXMediaIdGeneral |
|
253 |
else if ( contentId == KMPXMediaIdMusic ) |
|
254 |
{ |
|
255 |
if (attributeId & EMPXMediaMusicAlbumArtFileName) |
|
256 |
{ |
|
257 |
MPX_DEBUG1(" EMPXMediaMusicAlbumArtFileName"); |
|
258 |
TPtrC art(KNullDesC); |
|
259 |
art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistArt)); |
|
260 |
aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art); |
|
261 |
MPX_DEBUG2(" Art[%S]", &art); |
|
262 |
} |
|
263 |
} |
|
264 |
} // end for |
|
265 |
||
266 |
aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem); |
|
267 |
aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory); |
|
268 |
} |
|
269 |
||
270 |
// ---------------------------------------------------------------------------- |
|
271 |
// CMPXDbArtist::GenerateArtistFieldsValuesL |
|
272 |
// ---------------------------------------------------------------------------- |
|
273 |
// |
|
274 |
void CMPXDbArtist::GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues) |
|
275 |
{ |
|
276 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
277 |
{ |
|
278 |
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
|
279 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename); |
|
280 |
} |
|
281 |
} |
|
282 |
||
283 |
// ---------------------------------------------------------------------------- |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
284 |
// CMPXDbArtist::GetAlbumsCountL |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
285 |
// ---------------------------------------------------------------------------- |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
286 |
// |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
287 |
TInt CMPXDbArtist::GetAlbumsCountL(TUint32 aId) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
288 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
289 |
MPX_FUNC("CMPXDbArtist::GetAlbumsCountL"); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
290 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
291 |
return iObserver.HandleGetAlbumsCountForArtistL(aId); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
292 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
293 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
294 |
// ---------------------------------------------------------------------------- |
53 | 295 |
// CMPXDbArtist::GetAllCategoryItemsL |
296 |
// ---------------------------------------------------------------------------- |
|
297 |
// |
|
298 |
void CMPXDbArtist::GetAllCategoryItemsL( |
|
299 |
const TArray<TMPXAttribute>& aAttrs, |
|
300 |
CMPXMediaArray& aMediaArray) |
|
301 |
{ |
|
302 |
MPX_FUNC("CMPXDbArtist::GetAllCategoryItemsL"); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
303 |
HBufC* query = PreProcessStringLC(KQueryArtistAll); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
304 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
305 |
CleanupStack::PopAndDestroy(query); |
53 | 306 |
CleanupClosePushL(recordset); |
307 |
ProcessRecordsetL(aAttrs, recordset, aMediaArray); |
|
308 |
CleanupStack::PopAndDestroy(&recordset); |
|
309 |
} |
|
310 |
||
311 |
// ---------------------------------------------------------------------------- |
|
312 |
// CMPXDbArtist::UpdateItemL |
|
313 |
// ---------------------------------------------------------------------------- |
|
314 |
// |
|
315 |
void CMPXDbArtist::UpdateItemL( |
|
316 |
TUint32 aId, |
|
317 |
const CMPXMedia& aMedia, |
|
318 |
TInt aDriveId, |
|
319 |
CMPXMessageArray* aItemChangedMessages) |
|
320 |
{ |
|
321 |
MPX_FUNC("CMPXDbAlbum::UpdateItemL"); |
|
322 |
||
323 |
CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EArtistFieldCount); |
|
324 |
CleanupStack::PushL(fields); |
|
325 |
CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EArtistFieldCount); |
|
326 |
CleanupStack::PushL(values); |
|
327 |
||
328 |
// process the media parameter and construct the fields and values array |
|
329 |
GenerateArtistFieldsValuesL(aMedia, *fields, *values); |
|
330 |
||
331 |
// construct the SET string |
|
332 |
HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign); |
|
333 |
||
334 |
if (setStr->Length()) |
|
335 |
{ |
|
336 |
// execute the query |
|
337 |
iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, aId); |
|
338 |
MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
339 |
EMPXArtist, KDBPluginUid, ETrue, 0 ); |
|
340 |
} |
|
341 |
||
342 |
CleanupStack::PopAndDestroy(setStr); |
|
343 |
CleanupStack::PopAndDestroy(values); |
|
344 |
CleanupStack::PopAndDestroy(fields); |
|
345 |
} |
|
346 |
// ---------------------------------------------------------------------------- |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
347 |
// CMPXDbAlbum::CreateTableL |
53 | 348 |
// ---------------------------------------------------------------------------- |
349 |
// |
|
350 |
void CMPXDbArtist::CreateTableL( |
|
351 |
RSqlDatabase& aDatabase, |
|
352 |
TBool /* aCorruptTable */) |
|
353 |
{ |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
354 |
MPX_FUNC("CMPXDbCategory::CreateTableL"); |
53 | 355 |
|
356 |
// create the table |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
357 |
HBufC* query = PreProcessStringLC(KArtistCreateTable); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
358 |
User::LeaveIfError(aDatabase.Exec(*query)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
359 |
CleanupStack::PopAndDestroy(query); |
53 | 360 |
|
361 |
// do not create an index on the Name field |
|
362 |
// as it only slows down the insert/update queries overall |
|
363 |
} |
|
364 |
||
365 |
// ---------------------------------------------------------------------------- |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
366 |
// CMPXDbAlbum::CheckTableL |
53 | 367 |
// ---------------------------------------------------------------------------- |
368 |
// |
|
369 |
TBool CMPXDbArtist::CheckTableL( |
|
370 |
RSqlDatabase& aDatabase) |
|
371 |
{ |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
372 |
MPX_FUNC("CMPXDbCategory::CheckTableL"); |
53 | 373 |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
374 |
HBufC* query = PreProcessStringLC(KArtistCheckTable); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
375 |
TBool check(DoCheckTable(aDatabase, *query)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
376 |
CleanupStack::PopAndDestroy(query); |
53 | 377 |
|
378 |
return check; |
|
379 |
} |
|
380 |
||
381 |
// End of File |