33 #include "thumbnailstore.h" |
33 #include "thumbnailstore.h" |
34 #include "thumbnaildiskunmountobserver.h" |
34 #include "thumbnaildiskunmountobserver.h" |
35 #include "thumbnailpanic.h" |
35 #include "thumbnailpanic.h" |
36 #include "thumbnailcenrep.h" |
36 #include "thumbnailcenrep.h" |
37 #include "thumbnailmemorycardobserver.h" |
37 #include "thumbnailmemorycardobserver.h" |
38 #include "tnmgetimei.h" |
38 #include "tmgetimei.h" |
39 #include "thumbnailformatobserver.h" |
|
40 |
39 |
41 |
40 |
42 _LIT8( KThumbnailMimeWildCard, "*" ); |
41 _LIT8( KThumbnailMimeWildCard, "*" ); |
43 _LIT8( KThumbnailMimeImage, "image" ); |
42 _LIT8( KThumbnailMimeImage, "image" ); |
44 _LIT8( KThumbnailMimeVideo, "video" ); |
43 _LIT8( KThumbnailMimeVideo, "video" ); |
53 // ---------------------------------------------------------------------------------------- |
52 // ---------------------------------------------------------------------------------------- |
54 |
53 |
55 // ---------------------------------------------------------------------------------------- |
54 // ---------------------------------------------------------------------------------------- |
56 // Total number of ranges |
55 // Total number of ranges |
57 // ---------------------------------------------------------------------------------------- |
56 // ---------------------------------------------------------------------------------------- |
58 const TUint KThumbnailServerRangeCount = 17; |
57 const TUint KThumbnailServerRangeCount = 16; |
59 |
58 |
60 // ---------------------------------------------------------------------------------------- |
59 // ---------------------------------------------------------------------------------------- |
61 // Definition of the ranges |
60 // Definition of the ranges |
62 // ---------------------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------------------- |
63 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = |
62 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = |
89 CPolicyServer::ECustomCheck, // ERequestThumbByPathAsync |
87 CPolicyServer::ECustomCheck, // ERequestThumbByPathAsync |
90 CPolicyServer::ECustomCheck, // ERequestThumbByFileHandleAsync |
88 CPolicyServer::ECustomCheck, // ERequestThumbByFileHandleAsync |
91 CPolicyServer::ECustomCheck, // EReleaseBitmap |
89 CPolicyServer::ECustomCheck, // EReleaseBitmap |
92 CPolicyServer::ECustomCheck, // ECancelRequest |
90 CPolicyServer::ECustomCheck, // ECancelRequest |
93 CPolicyServer::ECustomCheck, // EChangePriority |
91 CPolicyServer::ECustomCheck, // EChangePriority |
94 CPolicyServer::ECustomCheck, // ECreateThumbnails |
|
95 CPolicyServer::ECustomCheck, // EDeleteThumbnails |
92 CPolicyServer::ECustomCheck, // EDeleteThumbnails |
96 CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize |
93 CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize |
97 CPolicyServer::ECustomCheck, // EGetMimeTypeList |
94 CPolicyServer::ECustomCheck, // EGetMimeTypeList |
98 CPolicyServer::ECustomCheck, // ERequestThumbByIdAsync |
95 CPolicyServer::ECustomCheck, // ERequestThumbByIdAsync |
99 CPolicyServer::ECustomCheck, // ERequestThumbByBufferAsync |
96 CPolicyServer::ECustomCheck, // ERequestThumbByBufferAsync |
232 iProcessor = CThumbnailTaskProcessor::NewL(); |
228 iProcessor = CThumbnailTaskProcessor::NewL(); |
233 REComSession::FinalClose(); |
229 REComSession::FinalClose(); |
234 REComSession::ListImplementationsL( TUid::Uid( THUMBNAIL_PROVIDER_IF_UID ), |
230 REComSession::ListImplementationsL( TUid::Uid( THUMBNAIL_PROVIDER_IF_UID ), |
235 iPluginInfoArray ); |
231 iPluginInfoArray ); |
236 |
232 |
237 CTnmgetimei * imeigetter = CTnmgetimei::NewLC(); |
233 CTMGetImei * imeiGetter = CTMGetImei::NewLC(); |
238 |
234 |
239 iImei = imeigetter->GetIMEI(); |
235 iImei = imeiGetter->GetIMEI(); |
240 CleanupStack::PopAndDestroy(imeigetter); |
236 CleanupStack::PopAndDestroy(imeiGetter); |
241 |
237 |
242 iFs.CreatePrivatePath(EDriveC); |
238 iFs.CreatePrivatePath(EDriveC); |
243 iFs.SetSessionToPrivate(EDriveC); |
239 iFs.SetSessionToPrivate(EDriveC); |
244 |
240 |
245 iCenrep = CThumbnailCenRep::NewL(); |
241 iCenrep = CThumbnailCenRep::NewL(); |
246 |
242 |
247 iPersistentSizes = iCenrep->GetPersistentSizes(); |
243 iPersistentSizes = iCenrep->GetPersistentSizes(); |
248 |
244 |
249 iMMCObserver = CThumbnailMemoryCardObserver::NewL( this, iFs ); |
245 iMMCObserver = CThumbnailMemoryCardObserver::NewL( this, iFs ); |
250 |
246 |
251 iFormatObserver = CThumbnailFormatObserver::NewL( this ); |
247 iFormatObserver = CTMFormatObserver::NewL( *this ); |
252 |
248 |
253 iFormatting = EFalse; |
249 iFormatting = EFalse; |
254 |
250 |
255 OpenStoresL(); |
251 //OpenStoresL(); |
256 |
252 |
257 AddUnmountObserversL(); |
253 AddUnmountObserversL(); |
|
254 |
|
255 iReconnect = CPeriodic::NewL(CActive::EPriorityIdle); |
258 } |
256 } |
259 |
257 |
260 |
258 |
261 // --------------------------------------------------------------------------- |
259 // --------------------------------------------------------------------------- |
262 // Destructor. |
260 // Destructor. |
317 // CThumbnailServer::HandleSessionError |
323 // CThumbnailServer::HandleSessionError |
318 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
319 // |
325 // |
320 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
326 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
321 { |
327 { |
322 if (aError != KErrNone) |
328 TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError ); |
323 { |
329 if (aError != KErrNone && !iShutdown) |
324 TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError ); |
330 { |
325 } |
331 if (!iReconnect->IsActive()) |
|
332 { |
|
333 iReconnect->Start( KMdEReconnect, KMdEReconnect, |
|
334 TCallBack(ReconnectCallBack, this)); |
|
335 |
|
336 TN_DEBUG1( "CThumbnailServer::HandleSessionError() - reconnect timer started" ); |
|
337 } |
|
338 } |
326 } |
339 } |
327 |
340 |
328 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
329 // CThumbnailServer::NewSessionL() |
342 // CThumbnailServer::NewSessionL() |
330 // Creates new server session. |
343 // Creates new server session. |
396 TN_DEBUG2( "CThumbnailServer::DropSession() iSessionCount was %d", |
409 TN_DEBUG2( "CThumbnailServer::DropSession() iSessionCount was %d", |
397 iSessionCount ); |
410 iSessionCount ); |
398 iSessionCount--; |
411 iSessionCount--; |
399 |
412 |
400 iProcessor->RemoveTasks(aSession); |
413 iProcessor->RemoveTasks(aSession); |
|
414 |
|
415 TN_DEBUG2( "CThumbnailServer::DropSession() aSession = 0x%08x", aSession ); |
|
416 |
|
417 // clean-up bitmap pool |
|
418 |
|
419 THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool ); |
|
420 |
|
421 // const pointer to a non-const object |
|
422 const TThumbnailBitmapRef* ref = bpiter.NextValue(); |
|
423 |
|
424 while ( ref ) |
|
425 { |
|
426 |
|
427 TN_DEBUG2( "CThumbnailServer::DropSession() - ref->iSession = 0x%08x", ref->iSession ); |
|
428 |
|
429 if ( ref->iSession == aSession ) |
|
430 { |
|
431 delete ref->iBitmap; |
|
432 bpiter.RemoveCurrent(); |
|
433 |
|
434 TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", |
|
435 iBitmapPool.Count()); |
|
436 } |
|
437 ref = bpiter.NextValue(); |
|
438 |
|
439 } |
|
440 |
401 if ( iSessionCount <= 0 ) |
441 if ( iSessionCount <= 0 ) |
402 { |
442 { |
403 // rename thread |
443 // rename thread |
404 User::RenameThread( KThumbnailServerShutdown ); |
444 User::RenameThread( KThumbnailServerShutdown ); |
405 |
445 |
442 TN_DEBUG4( |
482 TN_DEBUG4( |
443 "CThumbnailServer::AddBitmapToPoolL(aSession=0x%08x, aBitmap=0x%08x), handle=%d", aSession, aBitmap, aBitmap->Handle()); |
483 "CThumbnailServer::AddBitmapToPoolL(aSession=0x%08x, aBitmap=0x%08x), handle=%d", aSession, aBitmap, aBitmap->Handle()); |
444 |
484 |
445 TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle()); |
485 TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle()); |
446 |
486 |
|
487 TN_DEBUG2( "CThumbnailServer::AddBitmapToPoolL() - id = %d", aRequestId.iRequestId ); |
|
488 |
447 if ( ptr ) |
489 if ( ptr ) |
448 { |
490 { |
449 ptr->iRefCount++; |
491 ptr->iRefCount++; |
450 } |
492 } |
451 else |
493 else |
452 { |
494 { |
453 TThumbnailBitmapRef ref; |
495 TThumbnailBitmapRef ref; |
454 ref.iBitmap = aBitmap; |
496 ref.iBitmap = aBitmap; |
455 ref.iSession = aSession; |
497 ref.iSession = aSession; |
456 ref.iRefCount = 1; // magic: first reference |
498 ref.iRefCount = 1; // magic: first reference |
|
499 ref.iRequestId = aRequestId.iRequestId; |
|
500 |
457 iBitmapPool.InsertL( aBitmap->Handle(), ref ); |
501 iBitmapPool.InsertL( aBitmap->Handle(), ref ); |
458 } |
502 } |
459 |
503 |
460 #ifdef _DEBUG |
504 #ifdef _DEBUG |
461 TN_DEBUG2( "CThumbnailServer::BITMAP-POOL-COUNTER----------, Bitmaps = %d", iBitmapPool.Count() ); |
505 TN_DEBUG2( "CThumbnailServer::BITMAP-POOL-COUNTER----------, Bitmaps = %d", iBitmapPool.Count() ); |
467 // CThumbnailServer::StoreThumbnailL() |
511 // CThumbnailServer::StoreThumbnailL() |
468 // ----------------------------------------------------------------------------- |
512 // ----------------------------------------------------------------------------- |
469 // |
513 // |
470 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, |
514 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, |
471 const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, |
515 const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, |
472 const TThumbnailId aThumbnailId, const TBool aThumbFromPath, const TBool aCheckExist ) |
516 const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist ) |
473 { |
517 { |
474 TN_DEBUG6( |
518 TN_DEBUG6( |
475 "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped ); |
519 "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped ); |
476 #ifdef _DEBUG |
520 #ifdef _DEBUG |
477 TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode()); |
521 TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode()); |
478 #endif |
522 #endif |
479 |
523 |
480 if (!aCheckExist) |
524 if (!aCheckExist) |
481 { |
525 { |
482 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
526 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
483 aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); |
527 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
484 } |
528 } |
485 else if(BaflUtils::FileExists( iFs, aPath)) |
529 else if(BaflUtils::FileExists( iFs, aPath)) |
486 { |
530 { |
487 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
531 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
488 aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); |
532 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
489 } |
533 } |
490 else |
534 else |
491 { |
535 { |
492 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
536 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
493 } |
537 } |
526 TN_DEBUG3( |
570 TN_DEBUG3( |
527 "CThumbnailServer::DeleteBitmapFromPool(%d) -- deleting 0x%08x)", aHandle, ptr ); |
571 "CThumbnailServer::DeleteBitmapFromPool(%d) -- deleting 0x%08x)", aHandle, ptr ); |
528 delete ptr->iBitmap; |
572 delete ptr->iBitmap; |
529 ptr->iBitmap = NULL; |
573 ptr->iBitmap = NULL; |
530 iBitmapPool.Remove( aHandle ); |
574 iBitmapPool.Remove( aHandle ); |
|
575 TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool -- items left %d", iBitmapPool.Count() ); |
531 } |
576 } |
532 else |
577 else |
533 { |
578 { |
534 TN_DEBUG3( |
579 TN_DEBUG3( |
535 "CThumbnailServer::DeleteBitmapFromPool(%d) -- refcount now %d", |
580 "CThumbnailServer::DeleteBitmapFromPool(%d) -- refcount now %d", |
536 aHandle, ptr->iRefCount ); |
581 aHandle, ptr->iRefCount ); |
537 } |
582 } |
538 } |
583 } |
539 else |
584 else |
540 { |
585 { |
|
586 //__ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased )); |
541 TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!", |
587 TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!", |
542 aHandle ); |
588 aHandle ); |
543 } |
589 } |
544 } |
590 } |
545 |
591 |
552 { |
598 { |
553 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); |
599 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); |
554 |
600 |
555 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
601 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
556 } |
602 } |
557 |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // Delete thumbnails by Id |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 void CThumbnailServer::DeleteThumbnailsByIdL( const TThumbnailId aItemId ) |
|
564 { |
|
565 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsByIdL(%d)", aItemId); |
|
566 |
|
567 #ifdef _DEBUG |
|
568 TTime aStart, aStop; |
|
569 aStart.UniversalTime(); |
|
570 #endif |
|
571 |
|
572 // no path available, can be any store |
|
573 THashMapIter<TInt, CThumbnailStore*> iter( iStores ); |
|
574 CThumbnailStore* const *store = iter.NextValue(); |
|
575 |
|
576 while ( store ) |
|
577 { |
|
578 TInt err = KErrNone; |
|
579 TRAP(err, ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId) ); |
|
580 if (err == KErrNone) |
|
581 { |
|
582 #ifdef _DEBUG |
|
583 aStop.UniversalTime(); |
|
584 TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
585 #endif |
|
586 return; |
|
587 } |
|
588 store = iter.NextValue(); |
|
589 } |
|
590 } |
|
591 |
|
592 |
603 |
593 // ----------------------------------------------------------------------------- |
604 // ----------------------------------------------------------------------------- |
594 // CThumbnailServer::ResolveMimeTypeL() |
605 // CThumbnailServer::ResolveMimeTypeL() |
595 // ----------------------------------------------------------------------------- |
606 // ----------------------------------------------------------------------------- |
596 // |
607 // |
739 // Removes thumbnailtask from processor queue. |
750 // Removes thumbnailtask from processor queue. |
740 // ----------------------------------------------------------------------------- |
751 // ----------------------------------------------------------------------------- |
741 // |
752 // |
742 TInt CThumbnailServer::DequeTask( const TThumbnailServerRequestId& aRequestId ) |
753 TInt CThumbnailServer::DequeTask( const TThumbnailServerRequestId& aRequestId ) |
743 { |
754 { |
744 return iProcessor->RemoveTask( aRequestId ); |
755 |
|
756 TInt error = iProcessor->RemoveTask( aRequestId ); |
|
757 |
|
758 // clean-up bitmap pool |
|
759 |
|
760 THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool ); |
|
761 |
|
762 // const pointer to a non-const object |
|
763 const TThumbnailBitmapRef* ref = bpiter.NextValue(); |
|
764 |
|
765 while ( ref ) |
|
766 { |
|
767 |
|
768 TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId ); |
|
769 |
|
770 if ( ref->iSession == aRequestId.iSession && |
|
771 ref->iRequestId == aRequestId.iRequestId ) |
|
772 { |
|
773 delete ref->iBitmap; |
|
774 bpiter.RemoveCurrent(); |
|
775 |
|
776 TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", |
|
777 iBitmapPool.Count()); |
|
778 } |
|
779 ref = bpiter.NextValue(); |
|
780 |
|
781 } |
|
782 |
|
783 return error; |
745 } |
784 } |
746 |
785 |
747 |
786 |
748 // ----------------------------------------------------------------------------- |
787 // ----------------------------------------------------------------------------- |
749 // CThumbnailServer::ChangeTaskPriority() |
788 // CThumbnailServer::ChangeTaskPriority() |
847 } |
886 } |
848 |
887 |
849 return res; |
888 return res; |
850 } |
889 } |
851 |
890 |
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CThumbnailServer::FetchThumbnailL() |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 void CThumbnailServer::FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* & |
|
858 aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) |
|
859 { |
|
860 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aThumbnailId=%d aThumbnailSize=%d)", aThumbnailId, aThumbnailSize ); |
|
861 |
|
862 #ifdef _DEBUG |
|
863 TTime aStart, aStop; |
|
864 aStart.UniversalTime(); |
|
865 TInt roundCount = 1; |
|
866 #endif |
|
867 |
|
868 THashMapIter<TInt, CThumbnailStore*> storeIter(iStores); |
|
869 |
|
870 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() store iteration - begin"); |
|
871 for (CThumbnailStore* const* pStore = storeIter.NextValue(); |
|
872 pStore && aThumbnail == NULL ; |
|
873 pStore = storeIter.NextValue()) |
|
874 { |
|
875 TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() store iteration - round == %d ", roundCount++); |
|
876 CThumbnailStore* const store = (CThumbnailStore*)(*pStore); |
|
877 |
|
878 TRAP_IGNORE( store->FetchThumbnailL( aThumbnailId, aThumbnail, aData, aThumbnailSize, aOriginalSize )); |
|
879 |
|
880 if ( aThumbnail || aData) |
|
881 { // thumbnail found from DB |
|
882 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() found" ); |
|
883 break; |
|
884 } |
|
885 /* |
|
886 #ifdef _DEBUG |
|
887 aStop.UniversalTime(); |
|
888 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL() iteration round %d took %d ms", roundCount, (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
889 #endif |
|
890 */ |
|
891 } |
|
892 |
|
893 #ifdef _DEBUG |
|
894 aStop.UniversalTime(); |
|
895 TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
896 #endif |
|
897 |
|
898 if ( !aThumbnail && !aData) |
|
899 { // thumbnail not found from DB |
|
900 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() not found" ); |
|
901 User::Leave( KErrNotFound ); |
|
902 } |
|
903 } |
|
904 |
|
905 |
|
906 // ----------------------------------------------------------------------------- |
891 // ----------------------------------------------------------------------------- |
907 // Get the thumbnail store instance, which is responsible for the drive |
892 // Get the thumbnail store instance, which is responsible for the drive |
908 // identified by given path |
893 // identified by given path |
909 // ----------------------------------------------------------------------------- |
894 // ----------------------------------------------------------------------------- |
910 // |
895 // |
997 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL() |
979 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL() |
998 { |
980 { |
999 return iPersistentSizes; |
981 return iPersistentSizes; |
1000 } |
982 } |
1001 |
983 |
1002 void CThumbnailServer::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < |
984 void CThumbnailServer::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray < |
1003 TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs ) |
985 TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly ) |
1004 { |
986 { |
1005 StoreForPathL( aPath )->GetMissingSizesAndIDsL( aPath, aSourceType, aMissingSizes, aMissingIDs ); |
987 StoreForPathL( aPath )->GetMissingSizesL( aPath, aSourceType, aMissingSizes, aCheckGridSizeOnly ); |
1006 } |
988 } |
1007 |
989 |
1008 // --------------------------------------------------------------------------- |
990 // --------------------------------------------------------------------------- |
1009 // CThumbnailServer::Fs() |
991 // CThumbnailServer::Fs() |
1010 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
1145 |
1126 |
1146 // ----------------------------------------------------------------------------- |
1127 // ----------------------------------------------------------------------------- |
1147 // Updates thumbnails by given Id. |
1128 // Updates thumbnails by given Id. |
1148 // ----------------------------------------------------------------------------- |
1129 // ----------------------------------------------------------------------------- |
1149 // |
1130 // |
1150 TBool CThumbnailServer::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, |
1131 TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath, |
1151 const TInt /*aOrientation*/, const TInt64 aModified ) |
1132 const TInt /*aOrientation*/, const TInt64 aModified ) |
1152 { |
1133 { |
1153 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1134 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1154 |
1135 |
1155 // 1. check path change |
1136 // 1. check path change |
1156 // 2. check orientation change |
1137 // 2. check orientation change |
1157 // 3. check timestamp change |
1138 // 3. check timestamp change |
1158 TBool pathChanged = EFalse; |
1139 |
1159 TBool orientationChanged = EFalse; |
1140 TBool orientationChanged = EFalse; |
1160 TBool modifiedChanged = EFalse; |
1141 TBool modifiedChanged = EFalse; |
1161 |
1142 |
1162 CThumbnailStore* newstore = StoreForPathL( aPath ); |
1143 CThumbnailStore* store = StoreForPathL( aPath ); |
1163 TInt err(KErrNone); |
1144 |
1164 |
1145 // placeholder for orientation check |
1165 // no path available, can be any store |
1146 orientationChanged = EFalse; |
1166 THashMapIter<TInt, CThumbnailStore*> iter( iStores ); |
1147 |
1167 CThumbnailStore* const *store = iter.NextValue(); |
1148 if (orientationChanged) |
1168 |
1149 { |
1169 while ( store ) |
1150 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); |
1170 { |
1151 |
1171 err = KErrNone; |
1152 // orientation updated, no need to check further |
1172 |
1153 return ETrue; |
1173 TRAP(err, ((CThumbnailStore*)(*store))->FindStoreL( aItemId ) ); |
1154 } |
1174 |
1155 else |
1175 // no need to move thumbs to different store |
1156 { |
1176 if (err == KErrNone && *store == newstore) |
1157 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist"); |
1177 { |
1158 |
1178 pathChanged = ((CThumbnailStore*)(*store))->UpdateStoreL(aItemId, aPath); |
1159 TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged); |
|
1160 |
|
1161 if(!exists) |
|
1162 { |
|
1163 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO"); |
|
1164 //not found, needs to be generated |
|
1165 return EFalse; |
|
1166 } |
|
1167 |
|
1168 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); |
|
1169 |
|
1170 if (modifiedChanged) |
|
1171 { |
|
1172 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); |
1179 |
1173 |
1180 if (pathChanged) |
1174 // delete old thumbs |
1181 { |
1175 store->DeleteThumbnailsL(aPath, ETrue); |
1182 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - path updated"); |
|
1183 |
|
1184 // path updated, no need to check further |
|
1185 return ETrue; |
|
1186 } |
|
1187 else |
|
1188 { |
|
1189 // placeholder for orientation check |
|
1190 orientationChanged = EFalse; |
|
1191 |
|
1192 if (orientationChanged) |
|
1193 { |
|
1194 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); |
|
1195 |
|
1196 // orientation updated, no need to check further |
|
1197 return ETrue; |
|
1198 } |
|
1199 else |
|
1200 { |
|
1201 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); |
|
1202 modifiedChanged = ((CThumbnailStore*)(*store))->CheckModifiedL(aItemId, aModified); |
|
1203 |
|
1204 if (modifiedChanged) |
|
1205 { |
|
1206 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); |
|
1207 |
|
1208 // delete old thumbs |
|
1209 ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); |
|
1210 |
|
1211 // need to create new thumbs |
|
1212 return EFalse; |
|
1213 } |
|
1214 else |
|
1215 { |
|
1216 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
|
1217 |
|
1218 // not modified |
|
1219 return ETrue; |
|
1220 } |
|
1221 } |
|
1222 } |
|
1223 |
1176 |
1224 } |
1177 // need to create new thumbs |
1225 // move to new store |
1178 } |
1226 else if (err == KErrNone && *store != newstore) |
1179 else |
1227 { |
1180 { |
1228 RArray < TThumbnailDatabaseData* >* thumbnails = NULL; |
1181 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
1229 thumbnails = new (ELeave) RArray < TThumbnailDatabaseData* >; |
|
1230 CleanupClosePushL( *thumbnails ); |
|
1231 ((CThumbnailStore*)(*store))->FetchThumbnailsL(aItemId, *thumbnails); |
|
1232 newstore->StoreThumbnailsL(aPath, *thumbnails); |
|
1233 ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); |
|
1234 CleanupStack::PopAndDestroy( thumbnails); |
|
1235 delete thumbnails; |
|
1236 thumbnails = NULL; |
|
1237 |
1182 |
1238 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - moved to different store"); |
1183 // not modified |
1239 |
|
1240 // no need to check further |
|
1241 return ETrue; |
1184 return ETrue; |
1242 } |
1185 } |
1243 |
1186 } |
1244 store = iter.NextValue(); |
1187 |
1245 } |
|
1246 |
1188 |
1247 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1189 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1248 |
1190 |
1249 return EFalse; |
1191 return EFalse; |
1250 } |
1192 } |
1511 __UHEAP_MARKEND; |
1453 __UHEAP_MARKEND; |
1512 return result; |
1454 return result; |
1513 } |
1455 } |
1514 |
1456 |
1515 // ----------------------------------------------------------------------------- |
1457 // ----------------------------------------------------------------------------- |
1516 // Updates ID for thumbnails with given Path |
|
1517 // ----------------------------------------------------------------------------- |
|
1518 // |
|
1519 void CThumbnailServer::UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId ) |
|
1520 { |
|
1521 TN_DEBUG3( "CThumbnailServer::UpdateIDL() aPath = %S aId = %d", &aPath, aNewId); |
|
1522 |
|
1523 CThumbnailStore* store = StoreForPathL( aPath ); |
|
1524 User::LeaveIfNull( store ); |
|
1525 store->UpdateStoreL( aPath, aNewId ); |
|
1526 } |
|
1527 |
|
1528 // ----------------------------------------------------------------------------- |
|
1529 // Closes stores for removable drives |
1458 // Closes stores for removable drives |
1530 // ----------------------------------------------------------------------------- |
1459 // ----------------------------------------------------------------------------- |
1531 // |
1460 // |
1532 |
|
1533 void CThumbnailServer::CloseRemovableDrivesL() |
1461 void CThumbnailServer::CloseRemovableDrivesL() |
1534 { |
1462 { |
1535 TDriveList driveList; |
1463 TDriveList driveList; |
1536 TInt drive; |
1464 TInt drive; |
1537 TDriveInfo driveInfo; |
1465 TDriveInfo driveInfo; |
1596 |
1523 |
1597 // ----------------------------------------------------------------------------- |
1524 // ----------------------------------------------------------------------------- |
1598 // Is formatting ongoing |
1525 // Is formatting ongoing |
1599 // ----------------------------------------------------------------------------- |
1526 // ----------------------------------------------------------------------------- |
1600 // |
1527 // |
1601 |
|
1602 TBool CThumbnailServer::IsFormatting() |
1528 TBool CThumbnailServer::IsFormatting() |
1603 { |
1529 { |
1604 return iFormatting; |
1530 return iFormatting; |
1605 } |
1531 } |
1606 |
1532 |
|
1533 // --------------------------------------------------------------------------- |
|
1534 // CThumbnailServer::FormatNotification |
|
1535 // Handles a format operation |
|
1536 // --------------------------------------------------------------------------- |
|
1537 // |
|
1538 void CThumbnailServer::FormatNotification( TBool aFormat ) |
|
1539 { |
|
1540 TN_DEBUG2( "CThumbnailServer::FormatNotification(%d)", aFormat ); |
|
1541 |
|
1542 if(aFormat) |
|
1543 { |
|
1544 TRAP_IGNORE( CloseRemovableDrivesL() ); |
|
1545 } |
|
1546 else |
|
1547 { |
|
1548 TRAP_IGNORE( OpenRemovableDrivesL() ); |
|
1549 } |
|
1550 } |
|
1551 |
|
1552 // --------------------------------------------------------------------------- |
|
1553 // CThumbnailServer::ReconnectCallBack() |
|
1554 // --------------------------------------------------------------------------- |
|
1555 // |
|
1556 TInt CThumbnailServer::ReconnectCallBack(TAny* aAny) |
|
1557 { |
|
1558 TN_DEBUG1( "CThumbnailServer::ReconnectCallBack() - reconnect"); |
|
1559 |
|
1560 CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny ); |
|
1561 |
|
1562 self->iReconnect->Cancel(); |
|
1563 |
|
1564 if (self->iMdESession) |
|
1565 { |
|
1566 delete self->iMdESession; |
|
1567 self->iMdESession = NULL; |
|
1568 } |
|
1569 |
|
1570 // reconnect to MDS |
|
1571 TRAP_IGNORE( self->iMdESession = CMdESession::NewL( *self ) ); |
|
1572 |
|
1573 TN_DEBUG1( "CThumbAGDaemon::ReconnectCallBack() - done"); |
|
1574 |
|
1575 return KErrNone; |
|
1576 } |
|
1577 |