author | hgs |
Tue, 24 Aug 2010 03:36:14 -0500 | |
changeset 51 | 560ce2306a17 |
parent 38 | b93f525c9244 |
child 55 | f3930dda3342 |
permissions | -rw-r--r-- |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Responsible for interation with the category tables: |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* Artist, Album, Genre and Composer |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
* |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
*/ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
// INCLUDE FILES |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <sqldb.h> |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <mpxlog.h> |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include "mpxdbcommonutil.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include "mpxdbcommondef.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include "mpxdbmanager.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include "mpxcollectiondbdef.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "mpxmediamusicdefs.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "mpxdbpluginqueries.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "mpxdbutil.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
#include "mpxdbalbum.h" |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
// CONSTANTS |
35 | 36 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
37 |
_LIT( KAbstractAlbumExt, ".alb" ); |
|
38 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
|
51 | 40 |
_LIT( KAlbumAlbumArtistSeperator, "\t1"); |
41 |
_LIT( KAlbumArtistSeperator, "\t2"); |
|
42 |
||
43 |
const TInt KUnknownAlbumsGranularity = 250; |
|
44 |
||
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
// ============================ MEMBER FUNCTIONS ============================== |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
// Two-phased constructor. |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
CMPXDbAlbum* CMPXDbAlbum::NewL( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
CMPXDbManager& aDbManager, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
TMPXGeneralCategory aCategory, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
MMPXDbAlbumObserver& aObserver) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
MPX_FUNC("CMPXDbAlbum::NewL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
CMPXDbAlbum* self = CMPXDbAlbum::NewLC(aDbManager, aCategory, aObserver); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
CleanupStack::Pop(self); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
return self; |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
// Two-phased constructor. |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
CMPXDbAlbum* CMPXDbAlbum::NewLC( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
CMPXDbManager& aDbManager, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
TMPXGeneralCategory aCategory, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
MMPXDbAlbumObserver& aObserver) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
MPX_FUNC("CMPXDbAlbum::NewLC"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
CMPXDbAlbum* self = new (ELeave) CMPXDbAlbum(aDbManager, aCategory, aObserver); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
CleanupStack::PushL(self); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
self->ConstructL(); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
return self; |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
// Destructor |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
CMPXDbAlbum::~CMPXDbAlbum() |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
MPX_FUNC("CMPXDbAlbum::~CMPXDbAlbum"); |
51 | 87 |
|
88 |
iUnknownArtists.ResetAndDestroy(); |
|
89 |
iUnknownAlbums.ResetAndDestroy(); |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
// Constructor |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
CMPXDbAlbum::CMPXDbAlbum( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
CMPXDbManager& aDbManager, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
TMPXGeneralCategory aCategory, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
MMPXDbAlbumObserver& aObserver) : |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
CMPXDbCategory(aDbManager, aCategory), |
51 | 101 |
iObserver(aObserver), |
102 |
iUnknownArtists(KUnknownAlbumsGranularity), |
|
103 |
iUnknownAlbums(KUnknownAlbumsGranularity) |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
MPX_FUNC("CMPXDbAlbum::CMPXDbAlbum"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
// Second phase constructor. |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
void CMPXDbAlbum::ConstructL() |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
MPX_FUNC("CMPXDbAlbum::ConstructL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
BaseConstructL(); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
// CMPXDbAlbum::AddItemL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
TUint32 CMPXDbAlbum::AddItemL( |
51 | 124 |
TMPXGeneralCategory /*aCategory*/, |
125 |
const CMPXMedia& aMedia, |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
TInt aDriveId, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
TBool& aNewRecord, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
TBool aCaseSensitive) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
MPX_FUNC("CMPXDbAlbum::AddItemL"); |
34 | 131 |
|
51 | 132 |
TPtrC album(KNullDesC); |
133 |
TPtrC albumArtist(KNullDesC); |
|
134 |
TPtrC artist(KNullDesC); |
|
135 |
TPtrC albumArt(KNullDesC); |
|
136 |
||
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
// try to find the item first |
51 | 138 |
TUint32 rowId(GenerateUniqueIdL(aMedia)); |
139 |
||
140 |
// retrieve the existing record |
|
141 |
HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
142 |
RSqlStatement recordset( |
|
143 |
iDbManager.ExecuteSelectQueryL(aDriveId, *query, rowId)); |
|
144 |
CleanupStack::PopAndDestroy(query); |
|
145 |
CleanupClosePushL(recordset); |
|
146 |
||
147 |
TInt result = recordset.Next(); |
|
148 |
if (result == KSqlAtEnd) |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
{ |
51 | 150 |
aNewRecord = result; |
151 |
||
152 |
// check Album attribute |
|
153 |
if (aMedia.IsSupported(KMPXMediaMusicAlbum)) |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
{ |
51 | 155 |
album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen)); |
156 |
} |
|
157 |
||
158 |
// check AlbumArt attirbute |
|
159 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
{ |
51 | 161 |
albumArt.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
} |
34 | 163 |
|
51 | 164 |
// insert new |
165 |
HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(album); |
|
166 |
TUint32 artistId(0); |
|
167 |
HBufC* artistName = NULL; |
|
168 |
if (RetrieveAlbumArtistL(aMedia, albumArtist)) |
|
169 |
{ |
|
170 |
artistId = iObserver.AddAlbumArtistL(albumArtist, albumArt, aDriveId); |
|
171 |
artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArtist); |
|
172 |
} |
|
173 |
else |
|
174 |
{ |
|
175 |
RetrieveArtist(aMedia, artist); |
|
176 |
artistId = iObserver.AddAlbumArtistL(artist, albumArt, aDriveId); |
|
177 |
artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(artist); |
|
178 |
} |
|
179 |
||
180 |
HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArt); |
|
181 |
||
182 |
iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumInsert, rowId, name, 1, artistId, artistName,art); |
|
183 |
||
184 |
CleanupStack::PopAndDestroy(art); |
|
185 |
CleanupStack::PopAndDestroy(artistName); |
|
186 |
CleanupStack::PopAndDestroy(name); |
|
187 |
} |
|
188 |
else if (result == KSqlAtRow) |
|
189 |
{ |
|
190 |
// retrieve Art from Album table |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
TPtrC art(KNullDesC); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt)); |
34 | 193 |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
// the current one is Unknown and the new one is Not Unknown |
51 | 195 |
if ( art == KNullDesC && albumArt != KNullDesC ) |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
HBufC* artReplaceSingleQuote = |
51 | 198 |
MPXDbCommonUtil::ProcessSingleQuotesLC( albumArt ); |
38 | 199 |
|
200 |
TPtrC criteria(KCriterionArt); |
|
201 |
HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); |
|
202 |
setStr->Des().Format( KCriterionArt, artReplaceSingleQuote ); |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
CleanupStack::PopAndDestroy(setStr); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
} |
34 | 208 |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
209 |
// increment the number of songs for the category |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
210 |
query = PreProcessStringLC(KQueryCategoryIncrementSongCount); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
iDbManager.ExecuteQueryL(aDriveId, *query, rowId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
212 |
CleanupStack::PopAndDestroy(query); |
51 | 213 |
} // existing record |
214 |
else |
|
215 |
{ |
|
216 |
MPX_DEBUG2("SQL error %d", result); |
|
217 |
User::Leave(result); |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
218 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
219 |
|
51 | 220 |
CleanupStack::PopAndDestroy(&recordset); |
221 |
||
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
return rowId; |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
223 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
224 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
225 |
// ---------------------------------------------------------------------------- |
51 | 226 |
// CMPXDbAlbum::DecrementSongsForAlbumL |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
228 |
// |
51 | 229 |
void CMPXDbAlbum::DecrementSongsForAlbumL( |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
230 |
const TUint32 aId, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
TInt aDriveId, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
232 |
CMPXMessageArray* aItemChangedMessages, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
TBool& aItemExist, |
51 | 234 |
const TDesC& aArt) |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
{ |
51 | 236 |
MPX_FUNC("CMPXDbAlbum::DecrementSongsForAlbumL"); |
237 |
||
238 |
// retrieve the existing record |
|
239 |
HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
240 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId)); |
|
241 |
CleanupStack::PopAndDestroy(query); |
|
242 |
||
243 |
CleanupClosePushL(recordset); |
|
244 |
||
245 |
if (recordset.Next() != KSqlAtRow) |
|
246 |
{ |
|
247 |
User::Leave(KErrNotFound); |
|
248 |
} |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
// if just one song uses this category. Use <= just in case |
51 | 251 |
if (recordset.ColumnInt64(EAlbumSongCount) <= 1) |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
aItemExist = EFalse; |
51 | 254 |
|
255 |
// Decrement albums count on artist |
|
256 |
TUint32 albumArtistId = recordset.ColumnInt64(EAlbumArtist); |
|
257 |
iObserver.DeleteAlbumForArtistL(albumArtistId, aDriveId, aItemChangedMessages); |
|
258 |
CleanupStack::PopAndDestroy(&recordset); |
|
259 |
||
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
260 |
// delete the category |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
DeleteCategoryL(aId, aDriveId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
262 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
263 |
if (aItemChangedMessages) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
// add the item changed message |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
267 |
iCategory, KDBPluginUid); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
268 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
270 |
else |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
271 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
272 |
aItemExist = ETrue; |
34 | 273 |
|
35 | 274 |
TBool itemModified = EFalse; |
51 | 275 |
|
276 |
TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt)); |
|
277 |
if (NeedToUpdateArt(aArt, art)) |
|
35 | 278 |
{ |
279 |
MPX_DEBUG2("AlbumArt of the Song to be deleted is [%S]", &aArt); |
|
280 |
||
281 |
//need to get alternative art in the same album to display |
|
282 |
HBufC* newArt = AlbumartForAlbumL(aId, aArt); |
|
283 |
CleanupStack::PushL(newArt); |
|
284 |
||
285 |
//update Album table only if alternative albumart found |
|
286 |
if (newArt) |
|
287 |
{ |
|
51 | 288 |
MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForAlbumL, get newArt"); |
35 | 289 |
HBufC* artReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArt ); |
38 | 290 |
TPtrC criteria(KCriterionArt); |
291 |
HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); |
|
292 |
setStr->Des().Format( KCriterionArt, artReplaceSingleQuote ); |
|
35 | 293 |
|
294 |
iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
|
295 |
CleanupStack::PopAndDestroy(setStr); |
|
296 |
CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
|
297 |
itemModified = ETrue; |
|
298 |
} |
|
51 | 299 |
CleanupStack::PopAndDestroy(newArt); |
300 |
} |
|
301 |
||
35 | 302 |
if (aItemChangedMessages && itemModified) |
51 | 303 |
{ |
304 |
// add the item changed message |
|
305 |
MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
306 |
EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
|
307 |
} |
|
35 | 308 |
CleanupStack::PopAndDestroy(&recordset); |
309 |
||
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
// decrement the number of songs for the category |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
query = PreProcessStringLC(KQueryCategoryDecrementSongCount); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
iDbManager.ExecuteQueryL(aDriveId, *query, aId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
313 |
CleanupStack::PopAndDestroy(query); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
316 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
// CMPXDbAlbum::GetAllCategoryItemsL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
320 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
321 |
void CMPXDbAlbum::GetAllCategoryItemsL( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
322 |
const TArray<TMPXAttribute>& aAttrs, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
323 |
CMPXMediaArray& aMediaArray) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
324 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
|
51 | 327 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAlbumAll)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
329 |
CleanupClosePushL(recordset); |
51 | 330 |
TRAPD(err, ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray)); |
331 |
if (err != KErrNone) |
|
332 |
{ |
|
333 |
iUnknownArtists.ResetAndDestroy(); |
|
334 |
iUnknownAlbums.ResetAndDestroy(); |
|
335 |
||
336 |
User::LeaveIfError(err); |
|
337 |
} |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
CleanupStack::PopAndDestroy(&recordset); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
340 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
// ---------------------------------------------------------------------------- |
35 | 342 |
// CMPXDbAlbum::GetAllCategoryItemsMediaWallL |
343 |
// ---------------------------------------------------------------------------- |
|
344 |
// |
|
345 |
void CMPXDbAlbum::GetAllCategoryItemsMediaWallL( |
|
346 |
const TArray<TMPXAttribute>& aAttrs, |
|
347 |
CMPXMediaArray& aMediaArray) |
|
348 |
{ |
|
349 |
MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL"); |
|
350 |
||
51 | 351 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAlbumAllMediaWall)); |
35 | 352 |
|
353 |
CleanupClosePushL(recordset); |
|
51 | 354 |
TRAPD(err, ProcessMediaWallAlbumRecordSetL(aAttrs, recordset, aMediaArray)); |
355 |
if (err != KErrNone) |
|
356 |
{ |
|
357 |
iUnknownArtists.ResetAndDestroy(); |
|
358 |
iUnknownAlbums.ResetAndDestroy(); |
|
359 |
||
360 |
User::LeaveIfError(err); |
|
361 |
} |
|
35 | 362 |
CleanupStack::PopAndDestroy(&recordset); |
363 |
} |
|
51 | 364 |
|
365 |
// ---------------------------------------------------------------------------- |
|
366 |
// CMPXDbCategory::GetSubCategoryItemsL |
|
367 |
// ---------------------------------------------------------------------------- |
|
368 |
// |
|
369 |
void CMPXDbAlbum::GetSubCategoryItemsL( |
|
370 |
TMPXGeneralCategory aParentCategory, |
|
371 |
TUint32 aParentId, |
|
372 |
const TArray<TMPXAttribute>& aAttrs, |
|
373 |
CMPXMediaArray& aMediaArray) |
|
374 |
{ |
|
375 |
MPX_FUNC("CMPXDbCategory::GetSubCategoryItemsL"); |
|
376 |
||
377 |
// this is only valid for albums belonging to an artist |
|
378 |
ASSERT((iCategory == EMPXAlbum) && (aParentCategory == EMPXArtist)); |
|
379 |
||
380 |
// to handle the UREL warning |
|
381 |
(void)aParentCategory; |
|
382 |
||
383 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAlbumsforArtist, aParentId)); |
|
384 |
CleanupClosePushL(recordset); |
|
385 |
ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray); |
|
386 |
CleanupStack::PopAndDestroy(&recordset); |
|
387 |
} |
|
388 |
||
35 | 389 |
// ---------------------------------------------------------------------------- |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
// CMPXDbAlbum::UpdateItemL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
392 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
void CMPXDbAlbum::UpdateItemL( |
34 | 394 |
TUint32 aId, |
395 |
const CMPXMedia& aMedia, |
|
396 |
TInt aDriveId, |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
CMPXMessageArray* aItemChangedMessages) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
398 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
MPX_FUNC("CMPXDbAlbum::UpdateItemL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
400 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
401 |
CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EAlbumFieldCount); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
402 |
CleanupStack::PushL(fields); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EAlbumFieldCount); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
CleanupStack::PushL(values); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
406 |
// process the media parameter and construct the fields and values array |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
407 |
GenerateAlbumFieldsValuesL(aMedia, *fields, *values); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
408 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
409 |
// construct the SET string |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
411 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
if (setStr->Length()) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
// execute the query |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
416 |
MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
417 |
EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
418 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
419 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
420 |
CleanupStack::PopAndDestroy(setStr); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
421 |
CleanupStack::PopAndDestroy(values); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
422 |
CleanupStack::PopAndDestroy(fields); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
423 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
424 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
425 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
426 |
// CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
428 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
429 |
TInt CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
MPX_FUNC("CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL"); |
34 | 432 |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
433 |
return ExecuteSumQueryL(KQuerySongsInArtistAlbum, aArtistId, aAlbumId); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
434 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
437 |
// CMPXDbAlbum::UpdateMediaL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
440 |
void CMPXDbAlbum::UpdateMediaL( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
RSqlStatement& aRecord, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
const TArray<TMPXAttribute>& aAttrs, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
CMPXMedia& aMedia) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
444 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
445 |
MPX_FUNC("CMPXDbAlbum::UpdateMediaL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
446 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
447 |
TInt count(aAttrs.Count()); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
448 |
for (TInt i = 0; i < count; ++i) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
449 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
450 |
TInt contentId(aAttrs[i].ContentId()); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
451 |
TUint attributeId(aAttrs[i].AttributeId()); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
453 |
if (contentId == KMPXMediaIdGeneral) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
454 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
455 |
if (attributeId & EMPXMediaGeneralId) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
457 |
MPX_DEBUG1(" EMPXMediaGeneralId"); |
34 | 458 |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
459 |
aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
460 |
aRecord.ColumnInt64(EAlbumUniqueId)); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
if (attributeId & EMPXMediaGeneralTitle) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
463 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
MPX_DEBUG1(" EMPXMediaGeneralTitle"); |
34 | 465 |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
aMedia.SetTextValueL(KMPXMediaGeneralTitle, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
468 |
MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName)); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
MPX_DEBUG2(" Album[%S]", &album ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
471 |
if (attributeId & EMPXMediaGeneralCount) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
472 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
473 |
MPX_DEBUG1(" EMPXMediaGeneralCount"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
474 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
475 |
TInt songCount = GetSongsCountL(KDbManagerAllDrives, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
aRecord.ColumnInt64(EAlbumUniqueId)); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
MPX_DEBUG2(" SongCount[%d]", songCount ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
480 |
} // end if contentId == KMPXMediaIdGeneral |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
481 |
else if ( contentId == KMPXMediaIdMusic ) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
482 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
483 |
if (attributeId & EMPXMediaMusicArtist) |
34 | 484 |
{ |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
MPX_DEBUG1(" EMPXMediaMusicArtist"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
|
51 | 487 |
TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
488 |
aMedia.SetTextValueL(KMPXMediaMusicArtist, artistName); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
489 |
MPX_DEBUG2(" Artist[%S]", &artistName); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
490 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
492 |
if (attributeId & EMPXMediaMusicAlbum) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
493 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
494 |
MPX_DEBUG1(" EMPXMediaMusicAlbum"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
495 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
496 |
TPtrC albumName(KNullDesC); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
497 |
TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) ); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
498 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
499 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
500 |
// if album is unknown |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
501 |
if ( album != KNullDesC) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
502 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
503 |
albumName.Set(album); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
504 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
505 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
506 |
aMedia.SetTextValueL(KMPXMediaMusicAlbum, albumName); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
507 |
MPX_DEBUG2(" Album[%S]", &albumName); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
508 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
509 |
if (attributeId & EMPXMediaMusicAlbumArtFileName) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
510 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
511 |
MPX_DEBUG1(" EMPXMediaMusicAlbumArtFileName"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
512 |
|
51 | 513 |
TPtrC art(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
514 |
aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
515 |
MPX_DEBUG2(" Art[%S]", &art); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
516 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
518 |
} // end for |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
519 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
520 |
aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
521 |
aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
522 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
523 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
524 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
525 |
// CMPXDbAlbum::GenerateAlbumFieldsValuesL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
526 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
527 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
528 |
void CMPXDbAlbum::GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
529 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
530 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
531 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
533 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename); |
51 | 534 |
} |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
536 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
537 |
// ---------------------------------------------------------------------------- |
35 | 538 |
// CMPXDbAlbum::AlbumartForAlbumL |
539 |
// ---------------------------------------------------------------------------- |
|
540 |
// |
|
541 |
HBufC* CMPXDbAlbum::AlbumartForAlbumL(const TUint32 aId, TPtrC aArt) |
|
542 |
{ |
|
543 |
return iObserver.HandleAlbumartForAlbumL(aId, aArt); |
|
544 |
} |
|
545 |
||
546 |
// ---------------------------------------------------------------------------- |
|
51 | 547 |
// CMPXDbAlbum::ProcessAlbumRecordSetL |
548 |
// Unknown album or Unknown artist are stored in the database as NULL (Name field and ArtistName field). |
|
549 |
// The available unknown artist is saved for later and will be appended to the array |
|
550 |
// as the last item among items which have the same artist. |
|
551 |
// The available unknown albums are saved for later and will be appended to the array |
|
552 |
// as the last items after all known albums are appended. |
|
553 |
// The unknown album and unknown artist is saved for later and will be appended to the array |
|
554 |
// as the last item. |
|
555 |
// |
|
556 |
// NOTE: putting unknown album to the end of the array only takes place when title |
|
557 |
// field is requested. normal sorting algorithm occurs if title isn't |
|
558 |
// requested. |
|
559 |
// |
|
560 |
// Example: |
|
561 |
// Album X of artist A |
|
562 |
// Album X of artist B |
|
563 |
// Album X of unknown artist |
|
564 |
// Album Y of artist A |
|
565 |
// Album Y of unknown artist |
|
566 |
// Unknown album of artist A |
|
567 |
// Unknown album of artist B |
|
568 |
// Unknown album of unknown artist |
|
569 |
// ---------------------------------------------------------------------------- |
|
570 |
// |
|
571 |
void CMPXDbAlbum::ProcessAlbumRecordSetL( |
|
572 |
const TArray<TMPXAttribute>& aAttrs, |
|
573 |
RSqlStatement& aRecordset, |
|
574 |
CMPXMediaArray& aMediaArray) |
|
575 |
{ |
|
576 |
// populate the array |
|
577 |
TBool firstRecord(ETrue); |
|
578 |
CMPXMedia* unknownAlbumUnknownArtistMedia(NULL); |
|
579 |
CMPXMedia* unknownMedia(NULL); |
|
580 |
TUint32 prevId(0); |
|
581 |
TUint32 albumId(0); |
|
582 |
TUint32 prevAlbumId(0); |
|
583 |
TInt count(0); |
|
584 |
TInt err(KErrNone); |
|
585 |
||
586 |
// Reset array for unknown artists |
|
587 |
if (iUnknownArtists.Count() > 0) |
|
588 |
{ |
|
589 |
iUnknownArtists.ResetAndDestroy(); |
|
590 |
} |
|
591 |
||
592 |
// Reset array for unknown albums |
|
593 |
if (iUnknownAlbums.Count() > 0) |
|
594 |
{ |
|
595 |
iUnknownAlbums.ResetAndDestroy(); |
|
596 |
} |
|
597 |
||
598 |
TInt pPath(0); |
|
599 |
if (aMediaArray.Count()) |
|
600 |
{ |
|
601 |
CMPXMedia* pMedia = aMediaArray[0]; |
|
602 |
if (pMedia->IsSupported(KMPXMediaGeneralValue)) |
|
603 |
{ // Query excuted by OpenL |
|
604 |
pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue); |
|
605 |
MPX_ASSERT(pPath); |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
RArray<TMPXItemId> ids; |
|
610 |
CleanupClosePushL(ids); |
|
611 |
||
612 |
while ((err = aRecordset.Next()) == KSqlAtRow) |
|
613 |
{ |
|
614 |
TUint32 rowId(aRecordset.ColumnInt64(EAlbumUniqueId)); |
|
615 |
if (prevId == rowId) |
|
616 |
{ |
|
617 |
continue; |
|
618 |
} |
|
619 |
||
620 |
prevId = rowId; |
|
621 |
CMPXMedia* media = CMPXMedia::NewL(); |
|
622 |
CleanupStack::PushL(media); |
|
623 |
||
624 |
UpdateMediaL(aRecordset, aAttrs, *media); |
|
625 |
||
626 |
albumId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, |
|
627 |
MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName), ETrue); |
|
628 |
||
629 |
// Append Known album and Unknown artists |
|
630 |
count = iUnknownArtists.Count(); |
|
631 |
if ( prevAlbumId != albumId && count > 0) |
|
632 |
{ |
|
633 |
unknownMedia = NULL; |
|
634 |
||
635 |
for (TInt i = 0; i < count; i++) |
|
636 |
{ |
|
637 |
unknownMedia = iUnknownArtists[i]; |
|
638 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
639 |
{ |
|
640 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
641 |
} |
|
642 |
aMediaArray.AppendL(*unknownMedia); |
|
643 |
} |
|
644 |
||
645 |
iUnknownArtists.ResetAndDestroy(); |
|
646 |
} |
|
647 |
||
648 |
// for Unknown album and Unknown artist |
|
649 |
if (firstRecord && (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) && |
|
650 |
(MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0)) |
|
651 |
{ |
|
652 |
unknownAlbumUnknownArtistMedia = media; |
|
653 |
} |
|
654 |
// for Unknown albums and Known artists |
|
655 |
else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) |
|
656 |
{ |
|
657 |
iUnknownAlbums.Append(media); |
|
658 |
CleanupStack::Pop(media); |
|
659 |
} |
|
660 |
// for Known album and Unknown artist |
|
661 |
else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) |
|
662 |
{ |
|
663 |
iUnknownArtists.Append(media); |
|
664 |
CleanupStack::Pop(media); |
|
665 |
||
666 |
prevAlbumId = albumId; |
|
667 |
} |
|
668 |
else |
|
669 |
{ |
|
670 |
if (media->IsSupported(KMPXMediaGeneralId) && pPath) |
|
671 |
{ |
|
672 |
ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
673 |
} |
|
674 |
aMediaArray.AppendL(*media); |
|
675 |
CleanupStack::PopAndDestroy(media); |
|
676 |
} |
|
677 |
||
678 |
firstRecord = EFalse; |
|
679 |
} // end while |
|
680 |
||
681 |
if (err != KSqlAtEnd) |
|
682 |
{ |
|
683 |
User::LeaveIfError(err); |
|
684 |
} |
|
685 |
||
686 |
// Append Known artist and Unknown albums |
|
687 |
count = iUnknownArtists.Count(); |
|
688 |
if ( count > 0) |
|
689 |
{ |
|
690 |
unknownMedia = NULL; |
|
691 |
||
692 |
for (TInt i = 0; i < count; i++) |
|
693 |
{ |
|
694 |
unknownMedia = iUnknownArtists[i]; |
|
695 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
696 |
{ |
|
697 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
698 |
} |
|
699 |
aMediaArray.AppendL(*unknownMedia); |
|
700 |
} |
|
701 |
||
702 |
iUnknownArtists.ResetAndDestroy(); |
|
703 |
} |
|
704 |
||
705 |
// Append Unknown artists to MediaArray |
|
706 |
count = iUnknownAlbums.Count(); |
|
707 |
if ( count > 0) |
|
708 |
{ |
|
709 |
CMPXMedia* unknownMedia = NULL; |
|
710 |
||
711 |
for (TInt i = 0; i < count; i++) |
|
712 |
{ |
|
713 |
unknownMedia = iUnknownAlbums[i]; |
|
714 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
715 |
{ |
|
716 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
717 |
} |
|
718 |
aMediaArray.AppendL(*unknownMedia); |
|
719 |
} |
|
720 |
||
721 |
iUnknownAlbums.ResetAndDestroy(); |
|
722 |
} |
|
723 |
||
724 |
// the last item in the list |
|
725 |
if (unknownAlbumUnknownArtistMedia) |
|
726 |
{ |
|
727 |
if (unknownAlbumUnknownArtistMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
728 |
{ |
|
729 |
ids.AppendL(unknownAlbumUnknownArtistMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
730 |
} |
|
731 |
aMediaArray.AppendL(*unknownAlbumUnknownArtistMedia); |
|
732 |
CleanupStack::PopAndDestroy(unknownAlbumUnknownArtistMedia); |
|
733 |
} |
|
734 |
||
735 |
// Append ids to the returned path |
|
736 |
if (pPath) |
|
737 |
{ |
|
738 |
((CMPXCollectionPath*)pPath)->AppendL(ids.Array()); |
|
739 |
} |
|
740 |
CleanupStack::PopAndDestroy(&ids); |
|
741 |
} |
|
742 |
||
743 |
// ---------------------------------------------------------------------------- |
|
744 |
// CMPXDbAlbum::ProcessMediaWallAlbumRecordSetL |
|
745 |
// Unknown album or Unknown artist are stored in the database as NULL (Name field and ArtistName field). |
|
746 |
// The available unknown album is saved for later and will be appended to the array |
|
747 |
// as the last item among items which have the same artist. |
|
748 |
// The available unknown artists are saved for later and will be appended to the array |
|
749 |
// as the last items after all known artists are appended. |
|
750 |
// The unknown album and unknown artist is saved for later and will be appended to the array |
|
751 |
// as the last item. |
|
752 |
// |
|
753 |
// NOTE: putting unknown album to the end of the array only takes place when title |
|
754 |
// field is requested. normal sorting algorithm occurs if title isn't |
|
755 |
// requested. |
|
756 |
// |
|
757 |
// Example: |
|
758 |
// Album X of artist A |
|
759 |
// Album Y of artist A |
|
760 |
// Unknown album of artist A |
|
761 |
// Album X of artist B |
|
762 |
// Album Z of artist B |
|
763 |
// Unknown album of artist B |
|
764 |
// Album X of unknown artist |
|
765 |
// Album Y of unknown artist |
|
766 |
// Unknown album of unknown artist |
|
767 |
// ---------------------------------------------------------------------------- |
|
768 |
// |
|
769 |
// |
|
770 |
void CMPXDbAlbum::ProcessMediaWallAlbumRecordSetL( |
|
771 |
const TArray<TMPXAttribute>& aAttrs, |
|
772 |
RSqlStatement& aRecordset, |
|
773 |
CMPXMediaArray& aMediaArray) |
|
774 |
{ |
|
775 |
// populate the array |
|
776 |
TBool firstRecord(ETrue); |
|
777 |
CMPXMedia* unknownAlbumUnknownArtistMedia(NULL); |
|
778 |
CMPXMedia* unknownMedia(NULL); |
|
779 |
TUint32 prevId(0); |
|
780 |
TUint32 artistId(0); |
|
781 |
TUint32 prevArtistId(0); |
|
782 |
TInt count(0); |
|
783 |
TInt err(KErrNone); |
|
784 |
||
785 |
// Reset array for unknown artists |
|
786 |
if (iUnknownArtists.Count() > 0) |
|
787 |
{ |
|
788 |
iUnknownArtists.ResetAndDestroy(); |
|
789 |
} |
|
790 |
||
791 |
// Reset array for unknown albums |
|
792 |
if (iUnknownAlbums.Count() > 0) |
|
793 |
{ |
|
794 |
iUnknownAlbums.ResetAndDestroy(); |
|
795 |
} |
|
796 |
||
797 |
TInt pPath(0); |
|
798 |
if (aMediaArray.Count()) |
|
799 |
{ |
|
800 |
CMPXMedia* pMedia = aMediaArray[0]; |
|
801 |
if (pMedia->IsSupported(KMPXMediaGeneralValue)) |
|
802 |
{ // Query excuted by OpenL |
|
803 |
pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue); |
|
804 |
MPX_ASSERT(pPath); |
|
805 |
} |
|
806 |
} |
|
807 |
||
808 |
RArray<TMPXItemId> ids; |
|
809 |
CleanupClosePushL(ids); |
|
810 |
||
811 |
while ((err = aRecordset.Next()) == KSqlAtRow) |
|
812 |
{ |
|
813 |
TUint32 rowId(aRecordset.ColumnInt64(EAlbumUniqueId)); |
|
814 |
if (prevId == rowId) |
|
815 |
{ |
|
816 |
continue; |
|
817 |
} |
|
818 |
||
819 |
prevId = rowId; |
|
820 |
CMPXMedia* media = CMPXMedia::NewL(); |
|
821 |
CleanupStack::PushL(media); |
|
822 |
||
823 |
UpdateMediaL(aRecordset, aAttrs, *media); |
|
824 |
||
825 |
artistId = aRecordset.ColumnInt64(EAlbumArtist); |
|
826 |
||
827 |
// Append Known artist and Unknown albums |
|
828 |
count = iUnknownAlbums.Count(); |
|
829 |
if (prevArtistId != artistId && count > 0) |
|
830 |
{ |
|
831 |
unknownMedia = NULL; |
|
832 |
||
833 |
for (TInt i = 0; i < count; i++) |
|
834 |
{ |
|
835 |
unknownMedia = iUnknownAlbums[i]; |
|
836 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
837 |
{ |
|
838 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
839 |
} |
|
840 |
aMediaArray.AppendL(*unknownMedia); |
|
841 |
} |
|
842 |
||
843 |
iUnknownAlbums.ResetAndDestroy(); |
|
844 |
} |
|
845 |
||
846 |
// for Unknown artist and Unknown album |
|
847 |
if (firstRecord && (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) && |
|
848 |
(MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0)) |
|
849 |
{ |
|
850 |
unknownAlbumUnknownArtistMedia = media; |
|
851 |
} |
|
852 |
// for Unknown artists and Known albums |
|
853 |
else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) |
|
854 |
{ |
|
855 |
iUnknownArtists.Append(media); |
|
856 |
CleanupStack::Pop(media); |
|
857 |
} |
|
858 |
// for Known artist and Unknown album |
|
859 |
else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) |
|
860 |
{ |
|
861 |
iUnknownAlbums.Append(media); |
|
862 |
CleanupStack::Pop(media); |
|
863 |
prevArtistId = artistId; |
|
864 |
} |
|
865 |
else |
|
866 |
{ |
|
867 |
if (media->IsSupported(KMPXMediaGeneralId) && pPath) |
|
868 |
{ |
|
869 |
ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
870 |
} |
|
871 |
aMediaArray.AppendL(*media); |
|
872 |
CleanupStack::PopAndDestroy(media); |
|
873 |
} |
|
874 |
||
875 |
firstRecord = EFalse; |
|
876 |
} // end while |
|
877 |
||
878 |
if (err != KSqlAtEnd) |
|
879 |
{ |
|
880 |
User::LeaveIfError(err); |
|
881 |
} |
|
882 |
||
883 |
// Append Known artist and Unknown albums |
|
884 |
count = iUnknownAlbums.Count(); |
|
885 |
if ( count > 0) |
|
886 |
{ |
|
887 |
unknownMedia = NULL; |
|
888 |
||
889 |
for (TInt i = 0; i < count; i++) |
|
890 |
{ |
|
891 |
unknownMedia = iUnknownAlbums[i]; |
|
892 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
893 |
{ |
|
894 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
895 |
} |
|
896 |
aMediaArray.AppendL(*unknownMedia); |
|
897 |
} |
|
898 |
||
899 |
iUnknownAlbums.ResetAndDestroy(); |
|
900 |
} |
|
901 |
||
902 |
// Append Unknown artists to MediaArray |
|
903 |
count = iUnknownArtists.Count(); |
|
904 |
if ( count > 0) |
|
905 |
{ |
|
906 |
CMPXMedia* unknownMedia = NULL; |
|
907 |
||
908 |
for (TInt i = 0; i < count; i++) |
|
909 |
{ |
|
910 |
unknownMedia = iUnknownArtists[i]; |
|
911 |
if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
912 |
{ |
|
913 |
ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
914 |
} |
|
915 |
aMediaArray.AppendL(*unknownMedia); |
|
916 |
} |
|
917 |
||
918 |
iUnknownArtists.ResetAndDestroy(); |
|
919 |
} |
|
920 |
||
921 |
// the last item in the list |
|
922 |
if (unknownAlbumUnknownArtistMedia) |
|
923 |
{ |
|
924 |
if (unknownAlbumUnknownArtistMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
925 |
{ |
|
926 |
ids.AppendL(unknownAlbumUnknownArtistMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
927 |
} |
|
928 |
aMediaArray.AppendL(*unknownAlbumUnknownArtistMedia); |
|
929 |
CleanupStack::PopAndDestroy(unknownAlbumUnknownArtistMedia); |
|
930 |
} |
|
931 |
||
932 |
// Append ids to the returned path |
|
933 |
if (pPath) |
|
934 |
{ |
|
935 |
((CMPXCollectionPath*)pPath)->AppendL(ids.Array()); |
|
936 |
} |
|
937 |
CleanupStack::PopAndDestroy(&ids); |
|
938 |
} |
|
939 |
||
940 |
// ---------------------------------------------------------------------------- |
|
941 |
// CMPXDbAlbum::GenerateUniqueIdL |
|
942 |
// ---------------------------------------------------------------------------- |
|
943 |
// |
|
944 |
TUint32 CMPXDbAlbum::GenerateUniqueIdL(const CMPXMedia& aMedia) |
|
945 |
{ |
|
946 |
TPtrC album(KNullDesC); |
|
947 |
TPtrC albumArtist(KNullDesC); |
|
948 |
TPtrC artist(KNullDesC); |
|
949 |
||
950 |
// check Album attirbute |
|
951 |
if (aMedia.IsSupported(KMPXMediaMusicAlbum)) |
|
952 |
{ |
|
953 |
album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen)); |
|
954 |
} |
|
955 |
||
956 |
HBufC* buf(NULL); |
|
957 |
if (RetrieveAlbumArtistL(aMedia, albumArtist)) |
|
958 |
{ |
|
959 |
buf = HBufC::NewLC(album.Length() + albumArtist.Length() + KAlbumAlbumArtistSeperator().Length()); |
|
960 |
||
961 |
buf->Des().Append(album); |
|
962 |
buf->Des().Append(KAlbumAlbumArtistSeperator); |
|
963 |
buf->Des().Append(albumArtist); |
|
964 |
} |
|
965 |
else |
|
966 |
{ |
|
967 |
RetrieveArtist(aMedia, artist); |
|
968 |
||
969 |
buf = HBufC::NewLC(album.Length() + artist.Length() + KAlbumArtistSeperator().Length()); |
|
970 |
||
971 |
buf->Des().Append(album); |
|
972 |
buf->Des().Append(KAlbumArtistSeperator); |
|
973 |
buf->Des().Append(artist); |
|
974 |
} |
|
975 |
||
976 |
// try to find the item first |
|
977 |
TUint32 id(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, |
|
978 |
*buf, ETrue)); |
|
979 |
CleanupStack::PopAndDestroy(buf); |
|
980 |
||
981 |
return id; |
|
982 |
} |
|
983 |
||
984 |
// ---------------------------------------------------------------------------- |
|
985 |
// CMPXDbAlbum::IsUnknownAlbumL |
|
986 |
// ---------------------------------------------------------------------------- |
|
987 |
// |
|
988 |
TBool CMPXDbAlbum::IsUnknownAlbumL(const TUint32 aId) |
|
989 |
{ |
|
990 |
HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
991 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId)); |
|
992 |
CleanupStack::PopAndDestroy(query); |
|
993 |
CleanupClosePushL(recordset); |
|
994 |
||
995 |
if (recordset.Next() != KSqlAtRow) |
|
996 |
{ |
|
997 |
User::Leave(KErrNotFound); |
|
998 |
} |
|
999 |
||
1000 |
TPtrC album(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumName)); |
|
1001 |
TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName)); |
|
1002 |
||
1003 |
TBool ret = EFalse; |
|
1004 |
if (album.Length() == 0 || artistName.Length() == 0) |
|
1005 |
{ |
|
1006 |
ret = ETrue; |
|
1007 |
} |
|
1008 |
else |
|
1009 |
{ |
|
1010 |
ret = EFalse; |
|
1011 |
} |
|
1012 |
||
1013 |
CleanupStack::PopAndDestroy(&recordset); |
|
1014 |
||
1015 |
return ret; |
|
1016 |
} |
|
1017 |
||
1018 |
// ---------------------------------------------------------------------------- |
|
1019 |
// CMPXDbAlbum::RetrieveAlbumArtistL |
|
1020 |
// ---------------------------------------------------------------------------- |
|
1021 |
// |
|
1022 |
TBool CMPXDbAlbum::RetrieveAlbumArtistL(const CMPXMedia& aMedia, TPtrC& aName) |
|
1023 |
{ |
|
1024 |
// check AlbumArtist attribute |
|
1025 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist)) |
|
1026 |
{ |
|
1027 |
aName.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
|
1028 |
} |
|
1029 |
else |
|
1030 |
{ |
|
1031 |
aName.Set(KNullDesC); |
|
1032 |
} |
|
1033 |
||
1034 |
if (aName.Length() > 0 ) |
|
1035 |
{ |
|
1036 |
return ETrue; |
|
1037 |
} |
|
1038 |
else |
|
1039 |
{ |
|
1040 |
return EFalse; |
|
1041 |
} |
|
1042 |
} |
|
1043 |
||
1044 |
// ---------------------------------------------------------------------------- |
|
1045 |
// CMPXDbAlbum::RetrieveArtist |
|
1046 |
// ---------------------------------------------------------------------------- |
|
1047 |
// |
|
1048 |
void CMPXDbAlbum::RetrieveArtist(const CMPXMedia& aMedia, TPtrC& aName) |
|
1049 |
{ |
|
1050 |
// check Artist attribute |
|
1051 |
if (aMedia.IsSupported(KMPXMediaMusicArtist)) |
|
1052 |
{ |
|
1053 |
aName.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen)); |
|
1054 |
} |
|
1055 |
else |
|
1056 |
{ |
|
1057 |
aName.Set(KNullDesC); |
|
1058 |
} |
|
1059 |
} |
|
1060 |
||
1061 |
// ---------------------------------------------------------------------------- |
|
1062 |
// CMPXDbAlbum::NeedToUpdateArt |
|
1063 |
// ---------------------------------------------------------------------------- |
|
1064 |
// |
|
1065 |
TBool CMPXDbAlbum::NeedToUpdateArt(const TDesC& aDeletedSongArt, const TDesC& aCurrentAlbumArt) |
|
1066 |
{ |
|
1067 |
if (aDeletedSongArt.Length() == 0) |
|
1068 |
{ |
|
1069 |
// Deleted song's art has default album art |
|
1070 |
return EFalse; |
|
1071 |
} |
|
1072 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1073 |
else |
|
1074 |
if (aDeletedSongArt.Length() > 0) |
|
1075 |
{ |
|
1076 |
TParsePtrC parse(aDeletedSongArt); |
|
1077 |
TPtrC ext(parse.Ext()); |
|
1078 |
//set flag to false, so .alb will not overwrite art field in album, artist table |
|
1079 |
// when song with embedded art |
|
1080 |
if (ext.CompareF(KAbstractAlbumExt) == 0) |
|
1081 |
{ |
|
1082 |
// Deleted song's art is Non-embedded album art |
|
1083 |
return EFalse; |
|
1084 |
} |
|
1085 |
} |
|
1086 |
else |
|
1087 |
#endif |
|
1088 |
if (aDeletedSongArt.Length() > 0 && aCurrentAlbumArt.Length() > 0 && aDeletedSongArt.CompareF(aCurrentAlbumArt) == 0) |
|
1089 |
{ |
|
1090 |
// Deleted song's art is Embedded album art and it is the same as Album's current art |
|
1091 |
return ETrue; |
|
1092 |
} |
|
1093 |
else |
|
1094 |
{ |
|
1095 |
return EFalse; |
|
1096 |
} |
|
1097 |
} |
|
1098 |
||
1099 |
// ---------------------------------------------------------------------------- |
|
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1100 |
// CMPXDbAlbum::CreateTableL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1101 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1102 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1103 |
void CMPXDbAlbum::CreateTableL( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1104 |
RSqlDatabase& aDatabase, |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1105 |
TBool /* aCorruptTable */) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1106 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1107 |
MPX_FUNC("CMPXDbCategory::CreateTableL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1108 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1109 |
// create the table |
51 | 1110 |
User::LeaveIfError(aDatabase.Exec(KAlbumCreateTable)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1111 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1112 |
// do not create an index on the Name field |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1113 |
// as it only slows down the insert/update queries overall |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1114 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1115 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1116 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1117 |
// CMPXDbAlbum::CheckTableL |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1118 |
// ---------------------------------------------------------------------------- |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1119 |
// |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1120 |
TBool CMPXDbAlbum::CheckTableL( |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1121 |
RSqlDatabase& aDatabase) |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1122 |
{ |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1123 |
MPX_FUNC("CMPXDbCategory::CheckTableL"); |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1124 |
|
51 | 1125 |
TBool check(DoCheckTable(aDatabase, KAlbumCheckTable)); |
22
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1126 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1127 |
return check; |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1128 |
} |
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1129 |
|
ecf06a08d4d9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1130 |
// End of File |