41 |
41 |
42 _LIT8( KThumbnailMimeWildCard, "*" ); |
42 _LIT8( KThumbnailMimeWildCard, "*" ); |
43 _LIT8( KThumbnailMimeImage, "image" ); |
43 _LIT8( KThumbnailMimeImage, "image" ); |
44 _LIT8( KThumbnailMimeVideo, "video" ); |
44 _LIT8( KThumbnailMimeVideo, "video" ); |
45 _LIT8( KThumbnailMimeAudio, "audio" ); |
45 _LIT8( KThumbnailMimeAudio, "audio" ); |
46 _LIT8( KThumbnailMimeContact, "contact" ); |
|
47 |
46 |
48 const TChar KThumbnailMimeSeparatorChar = '/'; |
47 const TChar KThumbnailMimeSeparatorChar = '/'; |
49 const TChar KThumbnailMimeWildCardChar = '*'; |
48 const TChar KThumbnailMimeWildCardChar = '*'; |
50 const TChar KThumbnailMimeTypeSeparatorChar = ' '; |
49 const TChar KThumbnailMimeTypeSeparatorChar = ' '; |
51 |
50 |
461 { |
459 { |
462 if ( ref->iSession == aSession ) |
460 if ( ref->iSession == aSession ) |
463 { |
461 { |
464 TN_DEBUG2( "CThumbnailServer::DropSession() - ref->iSession = 0x%08x", ref->iSession ); |
462 TN_DEBUG2( "CThumbnailServer::DropSession() - ref->iSession = 0x%08x", ref->iSession ); |
465 |
463 |
466 delete ref->iBitmap; |
464 delete ref->iBitmap; |
467 bpiter.RemoveCurrent(); |
465 bpiter.RemoveCurrent(); |
468 |
466 |
469 TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count()); |
467 TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count()); |
470 } |
468 } |
471 |
469 |
558 #endif |
556 #endif |
559 |
557 |
560 if (!aCheckExist) |
558 if (!aCheckExist) |
561 { |
559 { |
562 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
560 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
563 aCropped, aThumbnailSize, aModified, aThumbFromPath, EFalse ); |
561 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
564 } |
562 } |
565 else if(BaflUtils::FileExists( iFs, aPath)) |
563 else if(BaflUtils::FileExists( iFs, aPath)) |
566 { |
564 { |
567 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
565 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
568 aCropped, aThumbnailSize, aModified, aThumbFromPath, EFalse ); |
566 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
569 } |
567 } |
570 else |
568 else |
571 { |
569 { |
572 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
570 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
573 } |
571 } |
574 |
572 |
575 if( iFetchedChecker ) |
573 if( iFetchedChecker ) |
576 { |
574 { |
577 iFetchedChecker->SetFetchResult( aPath, aThumbnailSize, KErrNone ); |
575 iFetchedChecker->SetFetchResult( aPath, KErrNone ); |
578 } |
576 } |
579 } |
577 } |
580 |
578 |
581 |
579 |
582 // ----------------------------------------------------------------------------- |
580 // ----------------------------------------------------------------------------- |
587 aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) |
585 aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) |
588 { |
586 { |
589 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize ); |
587 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize ); |
590 if( iFetchedChecker ) |
588 if( iFetchedChecker ) |
591 { |
589 { |
592 TInt err( iFetchedChecker->LastFetchResult( aPath, aThumbnailSize ) ); |
590 TInt err( iFetchedChecker->LastFetchResult( aPath ) ); |
593 if ( err == KErrNone ) // To avoid useless sql gets that fails for sure |
591 if ( err == KErrNone ) // To avoid useless sql gets that fails for sure |
594 { |
592 { |
595 // custom sizes are not stored to db, skip fetching |
593 // custom sizes are not stored to db, skip fetching |
596 if ( aThumbnailSize == ECustomThumbnailSize ) |
594 if ( aThumbnailSize == ECustomThumbnailSize ) |
597 { |
595 { |
599 } |
597 } |
600 |
598 |
601 TRAP( err, StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize) ); |
599 TRAP( err, StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize) ); |
602 if ( err != KErrNone ) |
600 if ( err != KErrNone ) |
603 { |
601 { |
604 iFetchedChecker->SetFetchResult( aPath, aThumbnailSize, err ); |
602 iFetchedChecker->SetFetchResult( aPath, err ); |
605 } |
603 } |
606 } |
604 } |
607 User::LeaveIfError( err ); |
605 User::LeaveIfError( err ); |
608 } |
606 } |
609 else |
607 else |
668 |
666 |
669 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
667 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
670 |
668 |
671 if( iFetchedChecker ) |
669 if( iFetchedChecker ) |
672 { |
670 { |
673 iFetchedChecker->DeleteFetchResult( aPath ); |
671 iFetchedChecker->SetFetchResult( aPath, KErrNone ); |
674 } |
672 } |
675 } |
673 } |
676 |
674 |
677 // ----------------------------------------------------------------------------- |
675 // ----------------------------------------------------------------------------- |
678 // CThumbnailServer::ResolveMimeTypeL() |
676 // CThumbnailServer::ResolveMimeTypeL() |
854 TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId ); |
852 TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId ); |
855 |
853 |
856 if ( ref->iSession == aRequestId.iSession && |
854 if ( ref->iSession == aRequestId.iSession && |
857 ref->iRequestId == aRequestId.iRequestId ) |
855 ref->iRequestId == aRequestId.iRequestId ) |
858 { |
856 { |
859 delete ref->iBitmap; |
857 delete ref->iBitmap; |
860 bpiter.RemoveCurrent(); |
858 bpiter.RemoveCurrent(); |
861 |
859 |
862 TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", |
860 TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", |
863 iBitmapPool.Count()); |
861 iBitmapPool.Count()); |
864 } |
862 } |
946 { |
944 { |
947 res = * resPtr; |
945 res = * resPtr; |
948 } |
946 } |
949 else |
947 else |
950 { |
948 { |
951 if( iFormatting ) |
949 if(iFormatting) |
952 { |
950 { |
953 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT"); |
951 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT"); |
954 User::Leave( KErrNotSupported ); |
952 User::Leave( KErrNotSupported ); |
955 } |
953 } |
956 |
954 |
957 TVolumeInfo volumeInfo; |
955 TVolumeInfo volumeInfo; |
958 TInt err = iFs.Volume( volumeInfo, aDrive ); |
956 TInt err = iFs.Volume( volumeInfo, aDrive ); |
959 |
957 |
960 if ( err ) |
958 if ( err || volumeInfo.iDrive.iDriveAtt& KDriveAttRom || |
961 { |
|
962 // Locked |
|
963 TN_DEBUG2( "CThumbnailServer::StoreForDriveL() - err %d", err); |
|
964 User::Leave( err); |
|
965 } |
|
966 else if( volumeInfo.iDrive.iMediaAtt& KMediaAttLocked ) |
|
967 { |
|
968 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - locked"); |
|
969 User::Leave( KErrAccessDenied ); |
|
970 } |
|
971 else if ( volumeInfo.iDrive.iDriveAtt& KDriveAttRom || |
|
972 volumeInfo.iDrive.iDriveAtt& KDriveAttRemote || |
959 volumeInfo.iDrive.iDriveAtt& KDriveAttRemote || |
973 volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected ) |
960 volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected || |
974 { |
961 volumeInfo.iDrive.iMediaAtt& KMediaAttLocked ) |
975 // We support ROM disks and remote disks in read only mode. |
962 { |
976 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - rom/remote/write protected"); |
963 // We don't support ROM disks or remote mounts. Media |
977 res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, ETrue ); |
964 // must be read-write and not locked. |
978 } |
965 User::Leave( KErrAccessDenied); |
979 else |
966 } |
980 { |
967 |
981 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - normal"); |
968 res = CThumbnailStore::NewL( iFs, aDrive, iImei, this ); |
982 res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, EFalse ); |
|
983 } |
|
984 |
|
985 CleanupStack::PushL( res ); |
969 CleanupStack::PushL( res ); |
986 iStores.InsertL( aDrive, res ); |
970 iStores.InsertL( aDrive, res ); |
987 res->SetPersistentSizes(iPersistentSizes); |
971 res->SetPersistentSizes(iPersistentSizes); |
988 CleanupStack::Pop( res ); |
972 CleanupStack::Pop( res ); |
989 |
973 |
1162 if( !driveList[drive] ) |
1145 if( !driveList[drive] ) |
1163 { |
1146 { |
1164 // If drive-list entry is zero, drive is not available |
1147 // If drive-list entry is zero, drive is not available |
1165 continue; |
1148 continue; |
1166 } |
1149 } |
1167 |
1150 |
1168 TInt err = iFs.Volume(volumeInfo, drive); |
1151 TInt err = iFs.Volume(volumeInfo, drive); |
1169 TInt err_drive = iFs.Drive(driveInfo, drive); |
1152 TInt err_drive = iFs.Drive(driveInfo, drive); |
1170 |
1153 |
1171 // mount -- if removable drive, add new store |
1154 // mount -- if removable drive, add new store |
1172 if (!err && !err_drive |
1155 if (!err && !err_drive |
1277 const TInt /*aOrientation*/, const TInt64 aModified ) |
1260 const TInt /*aOrientation*/, const TInt64 aModified ) |
1278 { |
1261 { |
1279 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1262 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1280 |
1263 |
1281 // 1. check path change |
1264 // 1. check path change |
1282 // 2. check timestamp change |
1265 // 2. check orientation change |
|
1266 // 3. check timestamp change |
|
1267 |
|
1268 TBool orientationChanged = EFalse; |
1283 TBool modifiedChanged = EFalse; |
1269 TBool modifiedChanged = EFalse; |
1284 |
1270 |
1285 CThumbnailStore* store = StoreForPathL( aPath ); |
1271 CThumbnailStore* store = StoreForPathL( aPath ); |
1286 |
1272 |
1287 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist"); |
1273 // placeholder for orientation check |
1288 |
1274 orientationChanged = EFalse; |
1289 TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged); |
1275 |
|
1276 if (orientationChanged) |
|
1277 { |
|
1278 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); |
|
1279 |
|
1280 // orientation updated, no need to check further |
|
1281 return ETrue; |
|
1282 } |
|
1283 else |
|
1284 { |
|
1285 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist"); |
|
1286 |
|
1287 TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged); |
1290 |
1288 |
1291 if(!exists) |
1289 if(!exists) |
1292 { |
1290 { |
1293 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO"); |
1291 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO"); |
1294 //not found, needs to be generated |
1292 //not found, needs to be generated |
1295 return EFalse; |
1293 return EFalse; |
1296 } |
1294 } |
1297 |
1295 |
1298 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); |
1296 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); |
1299 |
1297 |
1300 if (modifiedChanged) |
1298 if (modifiedChanged) |
1301 { |
1299 { |
1302 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); |
1300 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); |
1303 |
1301 |
1304 // delete old thumbs |
1302 // delete old thumbs |
1305 store->DeleteThumbnailsL(aPath, ETrue); |
1303 store->DeleteThumbnailsL(aPath, ETrue); |
1306 |
1304 |
1307 if( iFetchedChecker ) |
1305 if( iFetchedChecker ) |
1308 { |
1306 { |
1309 iFetchedChecker->DeleteFetchResult( aPath ); |
1307 iFetchedChecker->SetFetchResult( aPath, KErrNone ); |
1310 } |
1308 } |
1311 |
1309 |
1312 // need to create new thumbs |
1310 // need to create new thumbs |
1313 } |
1311 } |
1314 else |
1312 else |
1315 { |
1313 { |
1316 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
1314 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
1317 |
1315 |
1318 // not modified |
1316 // not modified |
1319 return ETrue; |
1317 return ETrue; |
1320 } |
1318 } |
|
1319 } |
|
1320 |
1321 |
1321 |
1322 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1322 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1323 |
1323 |
1324 return EFalse; |
1324 return EFalse; |
1325 } |
1325 } |
1334 |
1334 |
1335 StoreForPathL( aCurrentPath )->RenameThumbnailsL( aCurrentPath, aNewPath ); |
1335 StoreForPathL( aCurrentPath )->RenameThumbnailsL( aCurrentPath, aNewPath ); |
1336 |
1336 |
1337 if( iFetchedChecker ) |
1337 if( iFetchedChecker ) |
1338 { |
1338 { |
1339 iFetchedChecker->RenameFetchResultL( aNewPath, aCurrentPath ); |
1339 iFetchedChecker->SetFetchResult( aNewPath, iFetchedChecker->LastFetchResult(aCurrentPath) ); |
|
1340 iFetchedChecker->SetFetchResult( aCurrentPath, KErrNone ); |
1340 } |
1341 } |
1341 } |
1342 } |
1342 |
1343 |
1343 // ----------------------------------------------------------------------------- |
1344 // ----------------------------------------------------------------------------- |
1344 // CThumbnailServer::MimeTypeFromFileExt() |
1345 // CThumbnailServer::MimeTypeFromFileExt() |
1345 // ----------------------------------------------------------------------------- |
1346 // ----------------------------------------------------------------------------- |
1346 // |
1347 // |
1347 TInt CThumbnailServer::MimeTypeFromFileExt( const TDesC& aFileName, TDataType& aMimeType ) |
1348 TInt CThumbnailServer::MimeTypeFromFileExt( const TDesC& aFileName, TDataType& aMimeType ) |
1348 { |
1349 { |
1349 TBool found = ETrue; |
1350 TBool found = ETrue; |
1350 TPtrC ext( aFileName.Right(KExtLength) ); // tparse panics with virtual URI |
1351 TParsePtrC parse( aFileName ); |
|
1352 TPtrC ext( parse.Ext() ); |
1351 |
1353 |
1352 if ( ext.CompareF( KJpegExt ) == 0 || ext.CompareF( KJpgExt ) == 0) |
1354 if ( ext.CompareF( KJpegExt ) == 0 || ext.CompareF( KJpgExt ) == 0) |
1353 { |
1355 { |
1354 aMimeType = TDataType( KJpegMime ); |
1356 aMimeType = TDataType( KJpegMime ); |
1355 } |
1357 } |
1537 case EAudioGridThumbnailSize: |
1527 case EAudioGridThumbnailSize: |
1538 case EAudioListThumbnailSize: |
1528 case EAudioListThumbnailSize: |
1539 case EAudioFullScreenThumbnailSize: |
1529 case EAudioFullScreenThumbnailSize: |
1540 sourceType = TThumbnailPersistentSize::EAudio; |
1530 sourceType = TThumbnailPersistentSize::EAudio; |
1541 break; |
1531 break; |
1542 case EContactListThumbnailSize: |
|
1543 case EContactGridThumbnailSize: |
|
1544 case EContactFullScreenThumbnailSize: |
|
1545 sourceType = TThumbnailPersistentSize::EContact; |
|
1546 break; |
|
1547 default: |
1532 default: |
1548 sourceType = TThumbnailPersistentSize::EUnknownSourceType; |
1533 sourceType = TThumbnailPersistentSize::EUnknownSourceType; |
1549 } |
1534 } |
1550 |
1535 |
1551 return sourceType; |
1536 return sourceType; |
1561 |
1546 |
1562 if ( mimeType.CompareF( KJpegMime ) == 0 || |
1547 if ( mimeType.CompareF( KJpegMime ) == 0 || |
1563 mimeType.CompareF( KJpeg2000Mime ) == 0 || |
1548 mimeType.CompareF( KJpeg2000Mime ) == 0 || |
1564 mimeType.CompareF( KGifMime ) == 0 || |
1549 mimeType.CompareF( KGifMime ) == 0 || |
1565 mimeType.CompareF( KPngMime ) == 0 || |
1550 mimeType.CompareF( KPngMime ) == 0 || |
1566 mimeType.CompareF( KSvgMime ) == 0 || |
1551 mimeType.CompareF( KBmpMime ) == 0 || |
1567 mimeType.CompareF( KMpgMime1 ) == 0 || |
1552 mimeType.CompareF( KMpgMime1 ) == 0 || |
1568 mimeType.CompareF( KMpeg4Mime ) == 0 || |
1553 mimeType.CompareF( KMpeg4Mime ) == 0 || |
1569 mimeType.CompareF( KMp4Mime ) == 0 || |
1554 mimeType.CompareF( KMp4Mime ) == 0 || |
1570 mimeType.CompareF( KAviMime ) == 0 || |
1555 mimeType.CompareF( KAviMime ) == 0 || |
|
1556 mimeType.CompareF( KVideo3gppMime ) == 0 || |
|
1557 mimeType.CompareF( KVideoWmvMime ) == 0 || |
|
1558 mimeType.CompareF( KRealVideoMime ) == 0 || |
1571 mimeType.CompareF( KMp3Mime ) == 0 || |
1559 mimeType.CompareF( KMp3Mime ) == 0 || |
1572 mimeType.CompareF( KNonEmbeddArtMime ) == 0 || |
|
1573 mimeType.CompareF( KM4aMime ) == 0 || |
|
1574 mimeType.CompareF( KAacMime ) == 0 || |
1560 mimeType.CompareF( KAacMime ) == 0 || |
1575 mimeType.CompareF( KWmaMime ) == 0 || |
1561 mimeType.CompareF( KWmaMime ) == 0 || |
1576 mimeType.CompareF( KBmpMime ) == 0 || |
|
1577 mimeType.CompareF( KAudio3gppMime ) == 0 || |
|
1578 mimeType.CompareF( KVideo3gppMime ) == 0 || |
|
1579 mimeType.CompareF( KAudioAmrMime ) == 0 || |
1562 mimeType.CompareF( KAudioAmrMime ) == 0 || |
1580 mimeType.CompareF( KVideoWmvMime ) == 0 || |
|
1581 mimeType.CompareF( KRealAudioMime ) == 0 || |
1563 mimeType.CompareF( KRealAudioMime ) == 0 || |
1582 mimeType.CompareF( KPmRealAudioPluginMime ) == 0 || |
1564 mimeType.CompareF( KM4aMime ) == 0 || |
|
1565 mimeType.CompareF( KFlashVideoMime ) == 0 || |
1583 mimeType.CompareF( KPmRealVideoPluginMime ) == 0 || |
1566 mimeType.CompareF( KPmRealVideoPluginMime ) == 0 || |
1584 mimeType.CompareF( KPmRealVbVideoPluginMime ) == 0 || |
1567 mimeType.CompareF( KPmRealVbVideoPluginMime ) == 0 || |
1585 mimeType.CompareF( KRealVideoMime ) == 0 || |
1568 mimeType.CompareF( KPmRealAudioPluginMime ) == 0 ) |
1586 mimeType.CompareF( KFlashVideoMime ) == 0 || |
|
1587 mimeType.CompareF( KMatroskaVideoMime ) == 0 || |
|
1588 mimeType.CompareF( KContactMime ) == 0 || |
|
1589 mimeType.CompareF( KAlbumArtMime ) == 0 ) |
|
1590 { |
1569 { |
1591 return ETrue; |
1570 return ETrue; |
1592 } |
1571 } |
1593 |
1572 |
1594 return EFalse; |
1573 return EFalse; |
1618 TRAP( result, CThumbnailServer::ThreadFunctionL()); |
1597 TRAP( result, CThumbnailServer::ThreadFunctionL()); |
1619 TN_DEBUG2( |
1598 TN_DEBUG2( |
1620 "CThumbnailServer::E32Main() -- thread function out, result=%d", |
1599 "CThumbnailServer::E32Main() -- thread function out, result=%d", |
1621 result ); |
1600 result ); |
1622 delete cleanup; |
1601 delete cleanup; |
1623 cleanup = NULL; |
|
1624 } |
1602 } |
1625 if ( result != KErrNone ) |
1603 if ( result != KErrNone ) |
1626 { |
1604 { |
1627 // Signal the client that server creation failed |
1605 // Signal the client that server creation failed |
1628 TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() in" ); |
1606 TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() in" ); |