|
1 /* |
|
2 * Copyright (c) 2008 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: Collects metadata based on user selections |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <e32std.h> |
|
21 #include "cmsqlpropertycontainer.h" |
|
22 #include "cmsqlpropertyitem.h" |
|
23 #include "cmsqlpropertycollector.h" |
|
24 #include "msmetadatacollector.h" |
|
25 #include "msappui.h" |
|
26 #include "msengine.h" |
|
27 #include "msdebug.h" |
|
28 |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CMSMetadataCollector* CMSMetadataCollector::NewL( |
|
35 CMSAppUi& aMSAppUi, |
|
36 TCmMediaType aMediaType, |
|
37 RArray<TInt>& aGenreArray, |
|
38 RArray<TInt>& aArtistArray, |
|
39 RArray<TInt>& aAlbumArray, |
|
40 RArray<TInt>& aTrackArray ) |
|
41 { |
|
42 LOG(_L("[MediaServant]\t CMSMetadataCollector::NewL")); |
|
43 |
|
44 CMSMetadataCollector* self = CMSMetadataCollector::NewLC( |
|
45 aMSAppUi, |
|
46 aMediaType, |
|
47 aGenreArray, |
|
48 aArtistArray, |
|
49 aAlbumArray, |
|
50 aTrackArray ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // NewLC |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CMSMetadataCollector* CMSMetadataCollector::NewLC( |
|
60 CMSAppUi& aAppUi, |
|
61 TCmMediaType aMediaType, |
|
62 RArray<TInt>& aGenreArray, |
|
63 RArray<TInt>& aArtistArray, |
|
64 RArray<TInt>& aAlbumArray, |
|
65 RArray<TInt>& aTrackArray ) |
|
66 { |
|
67 LOG(_L("[MediaServant]\t CMSMetadataCollector::NewLC")); |
|
68 |
|
69 CMSMetadataCollector* self = new ( ELeave ) CMSMetadataCollector( |
|
70 aAppUi, |
|
71 aMediaType, |
|
72 aGenreArray, |
|
73 aArtistArray, |
|
74 aAlbumArray, |
|
75 aTrackArray ); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Destructor |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CMSMetadataCollector::~CMSMetadataCollector() |
|
86 { |
|
87 LOG(_L("[MediaServant]\t CMSMetadataCollector::~CMSMetadataCollector")); |
|
88 |
|
89 delete iMetadataCollector; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Default constructor |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CMSMetadataCollector::CMSMetadataCollector( CMSAppUi& aMSAppUi, |
|
97 TCmMediaType aMediaType, |
|
98 RArray<TInt>& aGenreArray, |
|
99 RArray<TInt>& aArtistArray, |
|
100 RArray<TInt>& aAlbumArray, |
|
101 RArray<TInt>& aTrackArray ) : |
|
102 iMSAppUi( &aMSAppUi ), |
|
103 iMediaType( aMediaType ), |
|
104 iGenreArray( &aGenreArray ), |
|
105 iArtistArray( &aArtistArray ), |
|
106 iAlbumArray( &aAlbumArray ), |
|
107 iTrackArray( &aTrackArray ) |
|
108 { |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CMSMetadataCollector::ConstructL |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CMSMetadataCollector::ConstructL() |
|
116 { |
|
117 LOG(_L("[MediaServant]\t CMSMetadataCollector::ConstructL")); |
|
118 |
|
119 iMetadataCollector = CCmSqlPropertyCollector::NewL(); |
|
120 AddContainersL(); |
|
121 |
|
122 GetFilteredMetadataL(); |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 //CMSMetadataCollector::GetFilteredMetadataL |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CMSMetadataCollector::GetFilteredMetadataL() |
|
131 { |
|
132 LOG(_L("[MediaServant]\t CMSMetadataCollector::GetFilteredMetadataL")); |
|
133 |
|
134 DeleteAllItems(); |
|
135 |
|
136 // TRACKS - this is both video titles and music tracks |
|
137 for ( TInt index = 0; index < iTrackArray->Count(); index++ ) |
|
138 { |
|
139 CCmSqlPropertyItem* item = CCmSqlPropertyItem::NewLC(); |
|
140 |
|
141 item->SetId( (*iTrackArray)[index] ); |
|
142 |
|
143 |
|
144 CCmSqlPropertyContainer* container = |
|
145 iMetadataCollector->PropertyContainer( ETracks ); |
|
146 container->AddPropertyItemL( item ); |
|
147 CleanupStack::Pop( item ); |
|
148 } |
|
149 |
|
150 if ( iMediaType == ECmAudio ) |
|
151 { |
|
152 // ARTISTS |
|
153 for ( TInt index = 0; index < iArtistArray->Count(); index++ ) |
|
154 { |
|
155 CCmSqlPropertyItem* item = CCmSqlPropertyItem::NewLC(); |
|
156 item->SetId( (*iArtistArray)[index] ); |
|
157 |
|
158 CCmSqlPropertyContainer* container = |
|
159 iMetadataCollector->PropertyContainer( EArtists ); |
|
160 container->AddPropertyItemL( item ); |
|
161 CleanupStack::Pop( item ); |
|
162 } |
|
163 |
|
164 // GENRES |
|
165 for ( TInt index = 0; index < iGenreArray->Count(); index++ ) |
|
166 { |
|
167 CCmSqlPropertyItem* item = CCmSqlPropertyItem::NewLC(); |
|
168 item->SetId( (*iGenreArray)[index] ); |
|
169 |
|
170 CCmSqlPropertyContainer* container = |
|
171 iMetadataCollector->PropertyContainer( EGenres ); |
|
172 container->AddPropertyItemL( item ); |
|
173 |
|
174 CleanupStack::Pop( item ); |
|
175 } |
|
176 |
|
177 // ALBUMS |
|
178 for ( TInt index = 0; index < iAlbumArray->Count(); index++ ) |
|
179 { |
|
180 CCmSqlPropertyItem* item = CCmSqlPropertyItem::NewLC(); |
|
181 item->SetId( (*iAlbumArray)[index] ); |
|
182 |
|
183 CCmSqlPropertyContainer* container = |
|
184 iMetadataCollector->PropertyContainer( EAlbums ); |
|
185 container->AddPropertyItemL( item ); |
|
186 |
|
187 CleanupStack::Pop( item ); |
|
188 } |
|
189 } |
|
190 |
|
191 // Start asynchronous metadata query. |
|
192 // Engine observer's ReadyL will be called when ready |
|
193 iMSAppUi->MSEngine()->GetFilteredMetadataL( iMetadataCollector ); |
|
194 } |
|
195 |
|
196 // -------------------------------------------------------------------------- |
|
197 //CMSMetadataCollector::DeleteAllItems |
|
198 // -------------------------------------------------------------------------- |
|
199 // |
|
200 void CMSMetadataCollector::DeleteAllItems() |
|
201 { |
|
202 LOG(_L("[MediaServant]\t CMSMetadataCollector::DeleteAllItems")); |
|
203 |
|
204 for ( TInt index = 0; |
|
205 index < iMetadataCollector->PropertyContainerCount(); |
|
206 index++ ) |
|
207 { |
|
208 CCmSqlPropertyContainer* container = |
|
209 iMetadataCollector->PropertyContainer( index ); |
|
210 for ( TInt idx = 0; idx < container->PropertyItemCount(); idx++ ) |
|
211 { |
|
212 container->DeletePropertyItem( idx-- ); |
|
213 } |
|
214 } |
|
215 } |
|
216 |
|
217 // -------------------------------------------------------------------------- |
|
218 //CMSMetadataCollector::AddContainersL |
|
219 // -------------------------------------------------------------------------- |
|
220 // |
|
221 void CMSMetadataCollector::AddContainersL() |
|
222 { |
|
223 LOG(_L("[MediaServant]\t CMSMetadataCollector::AddContainersL")); |
|
224 |
|
225 // tracks |
|
226 // this container is used both videos and music |
|
227 CCmSqlPropertyContainer* trackContainer = |
|
228 CCmSqlPropertyContainer::NewLC(); |
|
229 trackContainer->SetType( ECmTitle ); |
|
230 iMetadataCollector->AddPropertyContainerL( trackContainer ); |
|
231 CleanupStack::Pop( trackContainer ); |
|
232 |
|
233 if ( iMediaType == ECmAudio ) |
|
234 { |
|
235 // artists |
|
236 CCmSqlPropertyContainer* artistContainer = |
|
237 CCmSqlPropertyContainer::NewLC(); |
|
238 artistContainer->SetType( ECmArtist ); |
|
239 iMetadataCollector->AddPropertyContainerL( artistContainer ); |
|
240 CleanupStack::Pop( artistContainer ); |
|
241 |
|
242 // genres |
|
243 CCmSqlPropertyContainer* genreContainer = |
|
244 CCmSqlPropertyContainer::NewLC(); |
|
245 genreContainer->SetType( ECmGenre ); |
|
246 iMetadataCollector->AddPropertyContainerL( genreContainer ); |
|
247 CleanupStack::Pop( genreContainer ); |
|
248 |
|
249 // albums |
|
250 CCmSqlPropertyContainer* albumContainer = |
|
251 CCmSqlPropertyContainer::NewLC(); |
|
252 albumContainer->SetType( ECmAlbum ); |
|
253 iMetadataCollector->AddPropertyContainerL( albumContainer ); |
|
254 CleanupStack::Pop( albumContainer ); |
|
255 } |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 //CMSMetadataCollector::Genres |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 CCmSqlPropertyContainer* CMSMetadataCollector::Genres() |
|
263 { |
|
264 return iMetadataCollector->PropertyContainer( EGenres ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 //CMSMetadataCollector::Artists |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 CCmSqlPropertyContainer* CMSMetadataCollector::Artists() |
|
272 { |
|
273 return iMetadataCollector->PropertyContainer( EArtists ); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 //CMSMetadataCollector::Albums |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 CCmSqlPropertyContainer* CMSMetadataCollector::Albums() |
|
281 { |
|
282 return iMetadataCollector->PropertyContainer( EAlbums ); |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 //CMSMetadataCollector::Tracks |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 CCmSqlPropertyContainer* CMSMetadataCollector::Tracks() |
|
290 { |
|
291 return iMetadataCollector->PropertyContainer( ETracks ); |
|
292 } |
|
293 |
|
294 // End of file |
|
295 |