|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CUpnpContentMetadataUtility class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 // System |
|
25 #include <e32base.h> |
|
26 #include <MCLFContentListingEngine.h> |
|
27 #include <ContentListingFactory.h> |
|
28 #include <MCLFItemListModel.h> |
|
29 #include <CLFContentListing.hrh> |
|
30 #include <MCLFItem.h> |
|
31 #include <f32file.h> |
|
32 |
|
33 // upnp stack api |
|
34 #include <upnpitem.h> |
|
35 #include <upnpcontainer.h> |
|
36 #include <upnpstring.h> |
|
37 |
|
38 // upnpframework / avcontroller helper api |
|
39 #include "upnpfileutility.h" |
|
40 |
|
41 // upnpframework / internal api's |
|
42 #include "upnpcommonutils.h" |
|
43 #include "upnpmetadatautility.h" |
|
44 |
|
45 #include "upnpdlnaprofiler.h" |
|
46 #include "upnpcdsreselementutility.h" |
|
47 |
|
48 // homeconnect internal |
|
49 #include "upnpcontentmetadatautility.h" |
|
50 #include "upnpcustomgrouper.h" |
|
51 #include "upnppostfilter.h" |
|
52 |
|
53 #include "upnpcontentserverdefs.h" |
|
54 |
|
55 _LIT( KComponentLogfile, "contentserver.txt"); |
|
56 #include "upnplog.h" |
|
57 |
|
58 // CONSTANTS |
|
59 _LIT( KUPnPFileListSeparator, "\t" ); |
|
60 const TInt KMediaTypeArrGranularity(1); |
|
61 |
|
62 using namespace UpnpContentServer; |
|
63 |
|
64 // ============================ MEMBER FUNCTIONS ============================ |
|
65 // -------------------------------------------------------------------------- |
|
66 // CUpnpContentMetadataUtility::CUpnpContentMetadataUtility() |
|
67 // Default constructor |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 CUpnpContentMetadataUtility::CUpnpContentMetadataUtility() |
|
71 : iRefreshOngoing( ETrue ) |
|
72 { |
|
73 } |
|
74 |
|
75 void CUpnpContentMetadataUtility::ConstructL() |
|
76 { |
|
77 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
78 // Create Content Listing Engine and a list model |
|
79 iEngine = ContentListingFactory::NewContentListingEngineLC(); |
|
80 CleanupStack::Pop(); // iEngine |
|
81 iMusicModel = iEngine->CreateListModelLC( *this ); |
|
82 CleanupStack::Pop(); // iMusicModel |
|
83 |
|
84 iImageModel = iEngine->CreateListModelLC( *this ); |
|
85 CleanupStack::Pop(); // iImageModel |
|
86 |
|
87 iVideoModel = iEngine->CreateListModelLC( *this ); |
|
88 CleanupStack::Pop(); // iVideoModel |
|
89 |
|
90 iCollectionModel = iEngine->CreateListModelLC( *this ); |
|
91 CleanupStack::Pop(); // iCollectionModel |
|
92 // Set music media type filter to CLF |
|
93 RArray<TInt> musicArray( KMediaTypeArrGranularity ); |
|
94 |
|
95 CleanupClosePushL( musicArray ); |
|
96 musicArray.AppendL( ECLFMediaTypeMusic ); |
|
97 iMusicModel->SetWantedMediaTypesL( musicArray.Array() ); |
|
98 CleanupStack::PopAndDestroy( &musicArray ); |
|
99 |
|
100 // Set image media type filter to CLF |
|
101 RArray<TInt> imageArray( KMediaTypeArrGranularity ); |
|
102 |
|
103 CleanupClosePushL( imageArray ); |
|
104 imageArray.AppendL( ECLFMediaTypeImage ); |
|
105 iImageModel->SetWantedMediaTypesL( imageArray.Array() ); |
|
106 CleanupStack::PopAndDestroy( &imageArray ); |
|
107 |
|
108 // Set video media type filter to CLF |
|
109 RArray<TInt> videoArray( KMediaTypeArrGranularity ); |
|
110 CleanupClosePushL( videoArray ); |
|
111 videoArray.AppendL( ECLFMediaTypeVideo ); |
|
112 iVideoModel->SetWantedMediaTypesL( videoArray.Array() ); |
|
113 CleanupStack::PopAndDestroy( &videoArray ); |
|
114 |
|
115 // Set Collection media type filter to CLF |
|
116 RArray<TInt> collectionArray( KMediaTypeArrGranularity ); |
|
117 |
|
118 CleanupClosePushL( collectionArray ); |
|
119 collectionArray.AppendL( ECLFMediaTypeCollection ); |
|
120 iCollectionModel->SetWantedMediaTypesL( collectionArray.Array() ); |
|
121 CleanupStack::PopAndDestroy( &collectionArray ); |
|
122 |
|
123 // Group items by collection name |
|
124 iCustomGrouper = CUpnpCustomGrouper::NewL( ECLFFieldIdCollectionName ); |
|
125 iCollectionModel->SetCustomGrouper( iCustomGrouper ); |
|
126 |
|
127 // Start to refresh the music files (HandleOperationEventL |
|
128 // callback comes when finished) |
|
129 iMusicModel->RefreshL(); |
|
130 |
|
131 // Create metadata utility |
|
132 iMetaDataUtility = CUPnPMetaDataUtility::NewL(); |
|
133 |
|
134 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CUpnpContentMetadataUtility::NewL() |
|
139 // 2 phased constructor |
|
140 // -------------------------------------------------------------------------- |
|
141 // |
|
142 CUpnpContentMetadataUtility* CUpnpContentMetadataUtility::NewL() |
|
143 { |
|
144 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
145 CUpnpContentMetadataUtility* self |
|
146 = new( ELeave ) CUpnpContentMetadataUtility; |
|
147 |
|
148 CleanupStack::PushL( self ); |
|
149 self->ConstructL(); |
|
150 CleanupStack::Pop(); |
|
151 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
152 return self; |
|
153 } |
|
154 |
|
155 // -------------------------------------------------------------------------- |
|
156 // CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility() |
|
157 // Default destructor |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility() |
|
161 { |
|
162 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
163 delete iMusicModel; |
|
164 delete iImageModel; |
|
165 delete iVideoModel; |
|
166 delete iCollectionModel; |
|
167 delete iPostFilter; |
|
168 delete iCustomGrouper; |
|
169 delete iEngine; |
|
170 delete iMetaDataUtility; |
|
171 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CUpnpContentMetadataUtility::HandleOperationEventL |
|
176 // Callback implementation for MCLFOperationObserver |
|
177 // -------------------------------------------------------------------------- |
|
178 // |
|
179 void CUpnpContentMetadataUtility::HandleOperationEventL( |
|
180 TCLFOperationEvent aOperationEvent, |
|
181 TInt /*aError*/ ) |
|
182 { |
|
183 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
184 // Waiting is stopped when an event for refresh completion is received |
|
185 if( aOperationEvent == ECLFRefreshComplete ) |
|
186 |
|
187 { |
|
188 switch ( iRefreshCounter ) |
|
189 { |
|
190 case 0 : |
|
191 { |
|
192 iVideoModel->RefreshL(); |
|
193 break; |
|
194 } |
|
195 case 1 : |
|
196 { |
|
197 iImageModel->RefreshL(); |
|
198 break; |
|
199 } |
|
200 case 2 : |
|
201 { |
|
202 iCollectionModel->RefreshL(); |
|
203 break; |
|
204 } |
|
205 case 3 : |
|
206 { |
|
207 |
|
208 iRefreshOngoing = EFalse; |
|
209 iRefreshCounter = 0; |
|
210 if ( iHandler ) |
|
211 { |
|
212 iHandler->RefreshDoneL(); |
|
213 } |
|
214 __LOG("CUpnpContentMetadataUtility::HandleOperationEventL: \ |
|
215 Refresh done"); |
|
216 break; |
|
217 |
|
218 } |
|
219 default : |
|
220 { |
|
221 __LOG("CUpnpContentMetadataUtility::HandleOperationEventL: \ |
|
222 default: error"); |
|
223 break; |
|
224 } |
|
225 |
|
226 } |
|
227 if ( iRefreshOngoing ) |
|
228 { |
|
229 iRefreshCounter++; |
|
230 } |
|
231 } |
|
232 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
233 } |
|
234 |
|
235 // -------------------------------------------------------------------------- |
|
236 // CUpnpContentMetadataUtility::HandleItemChangeL |
|
237 // CLF content is changed --> model needs to be refreshed |
|
238 // -------------------------------------------------------------------------- |
|
239 // |
|
240 void CUpnpContentMetadataUtility::HandleItemChangeL( |
|
241 const TArray<TCLFItemId>& /*aItemIDArray*/ ) |
|
242 { |
|
243 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
244 // Start to refresh the music files (HandleOperationEventL |
|
245 // callback comes when finished) |
|
246 iRefreshOngoing = ETrue; |
|
247 iMusicModel->RefreshL(); |
|
248 iImageModel->RefreshL(); |
|
249 iVideoModel->RefreshL(); |
|
250 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
251 } |
|
252 |
|
253 // -------------------------------------------------------------------------- |
|
254 // CUpnpContentMetadataUtility::HandleError |
|
255 // Method is used to handle errors in changed item event. |
|
256 // -------------------------------------------------------------------------- |
|
257 // |
|
258 void CUpnpContentMetadataUtility::HandleError( TInt /*aError*/ ) |
|
259 { |
|
260 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
261 } |
|
262 |
|
263 |
|
264 // -------------------------------------------------------------------------- |
|
265 // CUpnpContentMetadataUtility::MusicFiles |
|
266 // ( other items are commented in header ) |
|
267 // -------------------------------------------------------------------------- |
|
268 // |
|
269 const MCLFItemListModel& CUpnpContentMetadataUtility::MusicFiles() const |
|
270 { |
|
271 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
272 return *iMusicModel; |
|
273 } |
|
274 |
|
275 // -------------------------------------------------------------------------- |
|
276 // CUpnpContentMetadataUtility::ImageFiles |
|
277 // ( other items are commented in header ) |
|
278 // -------------------------------------------------------------------------- |
|
279 // |
|
280 const MCLFItemListModel& CUpnpContentMetadataUtility::ImageFiles() const |
|
281 { |
|
282 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
283 return *iImageModel; |
|
284 } |
|
285 |
|
286 |
|
287 // -------------------------------------------------------------------------- |
|
288 // CUpnpContentMetadataUtility::VideoFiles |
|
289 // ( other items are commented in header ) |
|
290 // -------------------------------------------------------------------------- |
|
291 // |
|
292 const MCLFItemListModel& CUpnpContentMetadataUtility::VideoFiles() const |
|
293 { |
|
294 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
295 return *iVideoModel; |
|
296 } |
|
297 |
|
298 // -------------------------------------------------------------------------- |
|
299 // CUpnpContentMetadataUtility::Collections |
|
300 // ( other items are commented in header ) |
|
301 // -------------------------------------------------------------------------- |
|
302 // |
|
303 const MCLFItemListModel& CUpnpContentMetadataUtility::Collections() const |
|
304 { |
|
305 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
306 return *iCollectionModel; |
|
307 } |
|
308 |
|
309 |
|
310 |
|
311 // -------------------------------------------------------------------------- |
|
312 // CUpnpContentMetadataUtility::GetCollectionFileNamesL |
|
313 // ( other items are commented in header ) |
|
314 // -------------------------------------------------------------------------- |
|
315 // |
|
316 void CUpnpContentMetadataUtility::GetCollectionFileNamesL( |
|
317 CDesCArray& aFileArray, |
|
318 const TDesC& aFiles ) const |
|
319 { |
|
320 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
321 |
|
322 TInt collectionLength( aFiles.Length() ); |
|
323 TInt position( 0 ); |
|
324 TInt dataPos( 0 ); |
|
325 do |
|
326 { |
|
327 // Put filenames from ":" separeted row to aFileArray |
|
328 TPtrC data( aFiles.Right( collectionLength - position ) ); |
|
329 dataPos = data.Find( KUPnPFileListSeparator ); |
|
330 if( dataPos > 0 ) |
|
331 { |
|
332 ++position; // skip KUPnPFileListSeparator |
|
333 position += dataPos; |
|
334 aFileArray.AppendL( data.Left( dataPos ) ); |
|
335 } |
|
336 } while ( dataPos > 0 ); |
|
337 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
338 } |
|
339 |
|
340 // -------------------------------------------------------------------------- |
|
341 // CUpnpContentMetadataUtility::CollectionItemsL() |
|
342 // ( other items are commented in header ) |
|
343 // -------------------------------------------------------------------------- |
|
344 // |
|
345 void CUpnpContentMetadataUtility::CollectionItemsL( |
|
346 const TDesC& aNameOfCollection ) |
|
347 { |
|
348 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
349 __LOG1( "CUpnpContentMetadataUtility: collection: %S", |
|
350 &aNameOfCollection ); |
|
351 |
|
352 //clear previous filtering |
|
353 iCollectionModel->SetPostFilter( NULL ); |
|
354 |
|
355 // Delete old post filter if any |
|
356 |
|
357 delete iPostFilter; |
|
358 iPostFilter = NULL; |
|
359 |
|
360 // Create and activate a post filter for collection filtering |
|
361 // so that the model will contain only files |
|
362 // from selected collection |
|
363 iPostFilter = CUpnpPostFilter::NewL( ECLFFieldIdCollectionName, |
|
364 aNameOfCollection, EFalse ); |
|
365 iCollectionModel->SetPostFilter( iPostFilter ); |
|
366 |
|
367 iCollectionModel->RefreshL( ECLFRefreshPostFilter ); |
|
368 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
369 } |
|
370 |
|
371 |
|
372 // -------------------------------------------------------------------------- |
|
373 // CUpnpContentMetadataUtility::CreateItemL |
|
374 // Create the item with mandatory fields |
|
375 // -------------------------------------------------------------------------- |
|
376 // |
|
377 CUpnpItem* CUpnpContentMetadataUtility::CreateItemL( |
|
378 const MCLFItem& aCLFItem, |
|
379 const TDesC8& aParentId ) const |
|
380 { |
|
381 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
382 |
|
383 TPtrC fullFileName; |
|
384 TInt err( aCLFItem.GetField( ECLFFieldIdFileNameAndPath, |
|
385 fullFileName )); |
|
386 |
|
387 TInt32 filesize( 0 ); |
|
388 TInt err1( aCLFItem.GetField( ECLFFieldIdFileSize, filesize ) ); |
|
389 |
|
390 CUpnpItem* newItem( NULL ); |
|
391 |
|
392 if ( !err && !err1 && filesize ) |
|
393 { |
|
394 newItem = CreateItemL( fullFileName, aParentId ); |
|
395 } |
|
396 else |
|
397 { |
|
398 __LOG8_1( "MCLFItem ECLFFieldIdFileNameAndPath err= %d", err ); |
|
399 __LOG8_1( "MCLFItem ECLFFieldIdFileSize err= %d", err1 ); |
|
400 } |
|
401 |
|
402 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
403 return newItem; |
|
404 } |
|
405 |
|
406 // -------------------------------------------------------------------------- |
|
407 // CUpnpContentMetadataUtility::CreateItemL |
|
408 // Update the basic fields, based on list of filenames |
|
409 // -------------------------------------------------------------------------- |
|
410 // |
|
411 CUpnpItem* CUpnpContentMetadataUtility::CreateItemL( |
|
412 const TDesC& aFullFilename, |
|
413 const TDesC8& aParentId |
|
414 ) const |
|
415 { |
|
416 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
417 |
|
418 CUpnpItem* newItem( NULL ); |
|
419 |
|
420 TFileName path( aFullFilename ); |
|
421 TBool isProtected( EFalse ); |
|
422 TRAPD( err, |
|
423 isProtected = UPnPFileUtility::IsFileProtectedL( path ) ); |
|
424 |
|
425 if ( !isProtected && !err ) |
|
426 { |
|
427 // title |
|
428 HBufC8* itemName( NULL ); |
|
429 iMetaDataUtility->LoadTitleL( path ); |
|
430 if( iMetaDataUtility->Title().Length() > 0 ) |
|
431 { |
|
432 itemName = UpnpString::FromUnicodeL( |
|
433 iMetaDataUtility->Title() ); |
|
434 } |
|
435 else |
|
436 { |
|
437 // If does not find the title, using filename instead |
|
438 TParse fileParser; |
|
439 fileParser.Set( path, NULL, NULL ); |
|
440 itemName = UpnpString::FromUnicodeL( fileParser.Name() ); |
|
441 } |
|
442 |
|
443 if ( itemName ) |
|
444 { |
|
445 CleanupStack::PushL( itemName ); |
|
446 |
|
447 newItem = CUpnpItem::NewL(); |
|
448 CleanupStack::PushL( newItem ); |
|
449 newItem->SetTitleL( *itemName ); |
|
450 newItem->SetObjectClassL( KClassItem ); |
|
451 newItem->SetParentIdL( aParentId ); |
|
452 CleanupStack::Pop( newItem ); |
|
453 |
|
454 CleanupStack::PopAndDestroy( itemName ); |
|
455 } |
|
456 } |
|
457 else |
|
458 { |
|
459 __LOG8_1( "UPnPFileUtility::IsFileProtectedL err= %d", err ); |
|
460 } |
|
461 |
|
462 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
463 return newItem; |
|
464 } |
|
465 |
|
466 // -------------------------------------------------------------------------- |
|
467 // CUpnpContentMetadataUtility::RefreshOngoing() const |
|
468 // Used to check if refresh is ongoing. |
|
469 // -------------------------------------------------------------------------- |
|
470 // |
|
471 |
|
472 TBool CUpnpContentMetadataUtility::RefreshOngoing() const |
|
473 { |
|
474 return iRefreshOngoing; |
|
475 } |
|
476 |
|
477 // -------------------------------------------------------------------------- |
|
478 // CUpnpContentMetadataUtility::UpdateMetaDataL |
|
479 // Updates meta data for the item |
|
480 // -------------------------------------------------------------------------- |
|
481 // |
|
482 TBool CUpnpContentMetadataUtility::UpdateMetadataL( |
|
483 const TUpnpMediaType& aMediaType, |
|
484 CUpnpItem* aItem, |
|
485 const TDesC& aFileName ) |
|
486 { |
|
487 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
488 |
|
489 // 1st use correct model according to item type |
|
490 MCLFItemListModel* model = NULL; |
|
491 switch( aMediaType ) |
|
492 { |
|
493 case EMusicFile : |
|
494 { |
|
495 model = iMusicModel; |
|
496 break; |
|
497 } |
|
498 case EVideoFile : |
|
499 { |
|
500 model = iVideoModel; |
|
501 break; |
|
502 } |
|
503 case EPhotoFile : |
|
504 { |
|
505 model = iImageModel; |
|
506 break; |
|
507 } |
|
508 default: |
|
509 { |
|
510 break; |
|
511 } |
|
512 } |
|
513 // Then find the CLF item and update data from it |
|
514 TBool found = EFalse; |
|
515 TBool end = EFalse; |
|
516 TInt beginLoop = iClfIndex; |
|
517 |
|
518 // increment. If passed item count, start from beginning. |
|
519 iClfIndex = 0; |
|
520 beginLoop = -1; |
|
521 |
|
522 while ( model->ItemCount() && |
|
523 !found && |
|
524 !end ) |
|
525 { |
|
526 // Get the item |
|
527 const MCLFItem& myItem = model->Item( iClfIndex ); |
|
528 TPtrC fileName; |
|
529 TInt error = myItem.GetField( ECLFFieldIdFileNameAndPath, |
|
530 fileName ); |
|
531 |
|
532 // if there was no error and file name matched |
|
533 if ( !error && aFileName.CompareF( fileName ) == 0 ) |
|
534 { |
|
535 found = ETrue; |
|
536 |
|
537 // Get the mediatype |
|
538 TInt32 mediaType; |
|
539 TInt errorType = myItem.GetField( ECLFFieldIdMediaType, |
|
540 mediaType ); |
|
541 // If it is music file, fill the meta data for it |
|
542 if ( !errorType && mediaType == ECLFMediaTypeMusic ) |
|
543 { |
|
544 // Get title, artist, album & genre tag info of the item |
|
545 // Test update the class as it is in 1.x |
|
546 aItem->SetObjectClassL( |
|
547 KClassAudioMusicTrack ); |
|
548 |
|
549 TPtrC songArtist; |
|
550 TInt errorArtist( myItem.GetField( ECLFFieldIdArtist, |
|
551 songArtist ) ); |
|
552 if ( !errorArtist ) |
|
553 { |
|
554 CUpnpElement* elArtist = CUpnpElement::NewL( |
|
555 KElementArtist ); |
|
556 CleanupStack::PushL( elArtist ); |
|
557 HBufC8* artist = UpnpString::FromUnicodeL( |
|
558 songArtist ); |
|
559 CleanupStack::PushL( artist ); |
|
560 elArtist->SetValueL( *artist ); |
|
561 // UPnP stack needs filepath |
|
562 elArtist->SetFilePathL( aFileName ); |
|
563 CleanupStack::PopAndDestroy( artist ); |
|
564 aItem->AddElementL( elArtist ); // transfer own.. |
|
565 CleanupStack::Pop( elArtist ); |
|
566 } |
|
567 TPtrC songAlbum; |
|
568 TInt errorAlbum( myItem.GetField( ECLFFieldIdAlbum, |
|
569 songAlbum ) ); |
|
570 if ( !errorAlbum ) |
|
571 { |
|
572 CUpnpElement* elAlbum = CUpnpElement::NewL( |
|
573 KElementAlbum ); |
|
574 CleanupStack::PushL( elAlbum ); |
|
575 HBufC8* album = UpnpString::FromUnicodeL( songAlbum ); |
|
576 |
|
577 CleanupStack::PushL( album ); |
|
578 elAlbum->SetValueL( *album ); |
|
579 // UPnP stack needs filepath |
|
580 elAlbum->SetFilePathL( aFileName ); |
|
581 CleanupStack::PopAndDestroy( album ); |
|
582 aItem->AddElementL( elAlbum ); // transfer own.. |
|
583 CleanupStack::Pop( elAlbum ); |
|
584 } |
|
585 TPtrC songGenre; |
|
586 TInt errorGenre( myItem.GetField( ECLFFieldIdGenre, |
|
587 songGenre ) ); |
|
588 if ( !errorGenre ) |
|
589 { |
|
590 CUpnpElement* elGenre = CUpnpElement::NewL( |
|
591 KElementGenre ); |
|
592 CleanupStack::PushL( elGenre ); |
|
593 HBufC8* genre = UpnpString::FromUnicodeL( songGenre ); |
|
594 |
|
595 CleanupStack::PushL( genre ); |
|
596 elGenre->SetValueL( *genre ); |
|
597 // UPnP stack needs filepath |
|
598 elGenre->SetFilePathL( aFileName ); |
|
599 CleanupStack::PopAndDestroy( genre ); |
|
600 aItem->AddElementL( elGenre ); // transfer own.. |
|
601 CleanupStack::Pop( elGenre ); |
|
602 |
|
603 } |
|
604 } |
|
605 else if ( !errorType && mediaType == ECLFMediaTypeImage ) |
|
606 { |
|
607 // Just set correct object class |
|
608 aItem->SetObjectClassL( KImageItemObjectClass ); |
|
609 } |
|
610 else if ( !errorType && mediaType == ECLFMediaTypeVideo ) |
|
611 { |
|
612 // Just set correct object class |
|
613 aItem->SetObjectClassL( KVideoItemObjectClass ); |
|
614 } |
|
615 |
|
616 // Below this happens to ALL media types |
|
617 TTime dateTime; |
|
618 TInt errorDate( myItem.GetField( ECLFFieldIdFileDate, |
|
619 dateTime ) ); |
|
620 |
|
621 if ( !errorDate ) |
|
622 { |
|
623 HBufC* date = NULL; |
|
624 TRAP( errorDate, date = |
|
625 UPnPCommonUtils::TTimeToUPnPDateL(dateTime)); |
|
626 |
|
627 |
|
628 if(date && errorDate == KErrNone) |
|
629 { |
|
630 CleanupStack::PushL( date ); |
|
631 |
|
632 CUpnpElement* elDate = CUpnpElement::NewL( |
|
633 KElementDate ); |
|
634 CleanupStack::PushL( elDate ); |
|
635 |
|
636 |
|
637 HBufC8* date8 = UpnpString::FromUnicodeL( *date ); |
|
638 CleanupStack::PushL( date8 ); |
|
639 elDate->SetValueL( *date8 ); |
|
640 |
|
641 CleanupStack::PopAndDestroy( date8 ); |
|
642 |
|
643 elDate->SetFilePathL( aFileName ); |
|
644 aItem->AddElementL( elDate ); // transfer own.. |
|
645 |
|
646 CleanupStack::Pop( elDate ); |
|
647 CleanupStack::Pop( date ); |
|
648 } |
|
649 |
|
650 |
|
651 if(date) |
|
652 { |
|
653 delete date; |
|
654 date = NULL; |
|
655 } |
|
656 } |
|
657 |
|
658 } |
|
659 else |
|
660 { |
|
661 // The item was not found |
|
662 if ( iClfIndex != beginLoop ) |
|
663 { |
|
664 if ( ++iClfIndex >= model->ItemCount() ) |
|
665 { |
|
666 iClfIndex = 0; |
|
667 end = ETrue; |
|
668 } |
|
669 } |
|
670 else |
|
671 { |
|
672 end = ETrue; |
|
673 __LOG("end=ETRue"); |
|
674 } |
|
675 } |
|
676 } // while |
|
677 if( found ) |
|
678 { |
|
679 __LOG("CUpnpContentMetadataUtility:: item found"); |
|
680 } |
|
681 else |
|
682 { |
|
683 __LOG("CUpnpContentMetadataUtility:: item not found"); |
|
684 } |
|
685 |
|
686 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
687 return found; |
|
688 } |
|
689 |
|
690 // -------------------------------------------------------------------------- |
|
691 // CUpnpContentMetadataUtility::ClearPostFiltersL |
|
692 // ( other items are commented in header ) |
|
693 // -------------------------------------------------------------------------- |
|
694 void CUpnpContentMetadataUtility::ClearPostFiltersL() |
|
695 { |
|
696 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
697 //clear previous filtering |
|
698 iCollectionModel->SetPostFilter( NULL ); |
|
699 |
|
700 // Delete old post filter if any |
|
701 |
|
702 delete iPostFilter; |
|
703 iPostFilter = NULL; |
|
704 |
|
705 iCollectionModel->RefreshL( ECLFRefreshPostFilter ); |
|
706 |
|
707 // Set the default postfilter |
|
708 iPostFilter = CUpnpPostFilter::NewL( ECLFFieldIdCollectionName, |
|
709 KNullDesC, ETrue ); |
|
710 iCollectionModel->SetPostFilter( iPostFilter ); |
|
711 |
|
712 iCollectionModel->RefreshL( ECLFRefreshPostFilter ); |
|
713 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
714 } |
|
715 |
|
716 // -------------------------------------------------------------------------- |
|
717 // CUpnpContentMetadataUtility::SetCallback |
|
718 // ( other items are commented in header ) |
|
719 // -------------------------------------------------------------------------- |
|
720 void CUpnpContentMetadataUtility::SetCallback( |
|
721 MUpnpMetadataObserver* aObserver ) |
|
722 { |
|
723 iHandler = aObserver; |
|
724 |
|
725 } |
|
726 |
|
727 // End of File |