52 // ---------------------------------------------------------------------------------------- |
52 // ---------------------------------------------------------------------------------------- |
53 |
53 |
54 // ---------------------------------------------------------------------------------------- |
54 // ---------------------------------------------------------------------------------------- |
55 // Total number of ranges |
55 // Total number of ranges |
56 // ---------------------------------------------------------------------------------------- |
56 // ---------------------------------------------------------------------------------------- |
57 const TUint KThumbnailServerRangeCount = 17; |
57 const TUint KThumbnailServerRangeCount = 16; |
58 |
58 |
59 // ---------------------------------------------------------------------------------------- |
59 // ---------------------------------------------------------------------------------------- |
60 // Definition of the ranges |
60 // Definition of the ranges |
61 // ---------------------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------------------- |
62 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = |
62 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = |
88 CPolicyServer::ECustomCheck, // ERequestThumbByPathAsync |
87 CPolicyServer::ECustomCheck, // ERequestThumbByPathAsync |
89 CPolicyServer::ECustomCheck, // ERequestThumbByFileHandleAsync |
88 CPolicyServer::ECustomCheck, // ERequestThumbByFileHandleAsync |
90 CPolicyServer::ECustomCheck, // EReleaseBitmap |
89 CPolicyServer::ECustomCheck, // EReleaseBitmap |
91 CPolicyServer::ECustomCheck, // ECancelRequest |
90 CPolicyServer::ECustomCheck, // ECancelRequest |
92 CPolicyServer::ECustomCheck, // EChangePriority |
91 CPolicyServer::ECustomCheck, // EChangePriority |
93 CPolicyServer::ECustomCheck, // ECreateThumbnails |
|
94 CPolicyServer::ECustomCheck, // EDeleteThumbnails |
92 CPolicyServer::ECustomCheck, // EDeleteThumbnails |
95 CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize |
93 CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize |
96 CPolicyServer::ECustomCheck, // EGetMimeTypeList |
94 CPolicyServer::ECustomCheck, // EGetMimeTypeList |
97 CPolicyServer::ECustomCheck, // ERequestThumbByIdAsync |
95 CPolicyServer::ECustomCheck, // ERequestThumbByIdAsync |
98 CPolicyServer::ECustomCheck, // ERequestThumbByBufferAsync |
96 CPolicyServer::ECustomCheck, // ERequestThumbByBufferAsync |
316 // CThumbnailServer::HandleSessionError |
323 // CThumbnailServer::HandleSessionError |
317 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
318 // |
325 // |
319 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
326 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
320 { |
327 { |
321 if (aError != KErrNone) |
328 TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError ); |
322 { |
329 if (aError != KErrNone && !iShutdown) |
323 TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError ); |
330 { |
324 } |
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 } |
325 } |
339 } |
326 |
340 |
327 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
328 // CThumbnailServer::NewSessionL() |
342 // CThumbnailServer::NewSessionL() |
329 // Creates new server session. |
343 // Creates new server session. |
497 // CThumbnailServer::StoreThumbnailL() |
511 // CThumbnailServer::StoreThumbnailL() |
498 // ----------------------------------------------------------------------------- |
512 // ----------------------------------------------------------------------------- |
499 // |
513 // |
500 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, |
514 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, |
501 const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, |
515 const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, |
502 const TThumbnailId aThumbnailId, const TBool aThumbFromPath, const TBool aCheckExist ) |
516 const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist ) |
503 { |
517 { |
504 TN_DEBUG6( |
518 TN_DEBUG6( |
505 "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 ); |
506 #ifdef _DEBUG |
520 #ifdef _DEBUG |
507 TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode()); |
521 TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode()); |
508 #endif |
522 #endif |
509 |
523 |
510 if (!aCheckExist) |
524 if (!aCheckExist) |
511 { |
525 { |
512 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
526 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
513 aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); |
527 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
514 } |
528 } |
515 else if(BaflUtils::FileExists( iFs, aPath)) |
529 else if(BaflUtils::FileExists( iFs, aPath)) |
516 { |
530 { |
517 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
531 StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, |
518 aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); |
532 aCropped, aThumbnailSize, aModified, aThumbFromPath ); |
519 } |
533 } |
520 else |
534 else |
521 { |
535 { |
522 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
536 TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); |
523 } |
537 } |
584 { |
598 { |
585 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); |
599 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); |
586 |
600 |
587 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
601 StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); |
588 } |
602 } |
589 |
|
590 |
|
591 // ----------------------------------------------------------------------------- |
|
592 // Delete thumbnails by Id |
|
593 // ----------------------------------------------------------------------------- |
|
594 // |
|
595 void CThumbnailServer::DeleteThumbnailsByIdL( const TThumbnailId aItemId ) |
|
596 { |
|
597 TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsByIdL(%d)", aItemId); |
|
598 |
|
599 #ifdef _DEBUG |
|
600 TTime aStart, aStop; |
|
601 aStart.UniversalTime(); |
|
602 #endif |
|
603 |
|
604 // no path available, can be any store |
|
605 THashMapIter<TInt, CThumbnailStore*> iter( iStores ); |
|
606 CThumbnailStore* const *store = iter.NextValue(); |
|
607 |
|
608 while ( store ) |
|
609 { |
|
610 TInt err = KErrNone; |
|
611 TRAP(err, ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId) ); |
|
612 if (err == KErrNone) |
|
613 { |
|
614 #ifdef _DEBUG |
|
615 aStop.UniversalTime(); |
|
616 TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
617 #endif |
|
618 return; |
|
619 } |
|
620 store = iter.NextValue(); |
|
621 } |
|
622 } |
|
623 |
|
624 |
603 |
625 // ----------------------------------------------------------------------------- |
604 // ----------------------------------------------------------------------------- |
626 // CThumbnailServer::ResolveMimeTypeL() |
605 // CThumbnailServer::ResolveMimeTypeL() |
627 // ----------------------------------------------------------------------------- |
606 // ----------------------------------------------------------------------------- |
628 // |
607 // |
907 } |
886 } |
908 |
887 |
909 return res; |
888 return res; |
910 } |
889 } |
911 |
890 |
912 |
|
913 // ----------------------------------------------------------------------------- |
|
914 // CThumbnailServer::FetchThumbnailL() |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 void CThumbnailServer::FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* & |
|
918 aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) |
|
919 { |
|
920 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aThumbnailId=%d aThumbnailSize=%d)", aThumbnailId, aThumbnailSize ); |
|
921 |
|
922 #ifdef _DEBUG |
|
923 TTime aStart, aStop; |
|
924 aStart.UniversalTime(); |
|
925 TInt roundCount = 1; |
|
926 #endif |
|
927 |
|
928 THashMapIter<TInt, CThumbnailStore*> storeIter(iStores); |
|
929 |
|
930 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() store iteration - begin"); |
|
931 for (CThumbnailStore* const* pStore = storeIter.NextValue(); |
|
932 pStore && aThumbnail == NULL ; |
|
933 pStore = storeIter.NextValue()) |
|
934 { |
|
935 TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() store iteration - round == %d ", roundCount++); |
|
936 CThumbnailStore* const store = (CThumbnailStore*)(*pStore); |
|
937 |
|
938 TRAPD(err, store->FetchThumbnailL( aThumbnailId, aThumbnail, aData, aThumbnailSize, aOriginalSize )); |
|
939 |
|
940 if( err == KErrCompletion ) |
|
941 { |
|
942 // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion |
|
943 TN_DEBUG1( |
|
944 "CThumbnailServer::FetchThumbnailL() - thumbnail blacklisted" ); |
|
945 User::Leave( err ); |
|
946 } |
|
947 else if ( aThumbnail || aData) |
|
948 { // thumbnail found from DB |
|
949 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() found" ); |
|
950 break; |
|
951 } |
|
952 /* |
|
953 #ifdef _DEBUG |
|
954 aStop.UniversalTime(); |
|
955 TN_DEBUG3( "CThumbnailServer::FetchThumbnailL() iteration round %d took %d ms", roundCount, (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
956 #endif |
|
957 */ |
|
958 } |
|
959 |
|
960 #ifdef _DEBUG |
|
961 aStop.UniversalTime(); |
|
962 TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
963 #endif |
|
964 |
|
965 if ( !aThumbnail && !aData) |
|
966 { // thumbnail not found from DB |
|
967 TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() not found" ); |
|
968 User::Leave( KErrNotFound ); |
|
969 } |
|
970 } |
|
971 |
|
972 |
|
973 // ----------------------------------------------------------------------------- |
891 // ----------------------------------------------------------------------------- |
974 // Get the thumbnail store instance, which is responsible for the drive |
892 // Get the thumbnail store instance, which is responsible for the drive |
975 // identified by given path |
893 // identified by given path |
976 // ----------------------------------------------------------------------------- |
894 // ----------------------------------------------------------------------------- |
977 // |
895 // |
1064 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL() |
979 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL() |
1065 { |
980 { |
1066 return iPersistentSizes; |
981 return iPersistentSizes; |
1067 } |
982 } |
1068 |
983 |
1069 void CThumbnailServer::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < |
984 void CThumbnailServer::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray < |
1070 TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs ) |
985 TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly ) |
1071 { |
986 { |
1072 StoreForPathL( aPath )->GetMissingSizesAndIDsL( aPath, aSourceType, aMissingSizes, aMissingIDs ); |
987 StoreForPathL( aPath )->GetMissingSizesL( aPath, aSourceType, aMissingSizes, aCheckGridSizeOnly ); |
1073 } |
988 } |
1074 |
989 |
1075 // --------------------------------------------------------------------------- |
990 // --------------------------------------------------------------------------- |
1076 // CThumbnailServer::Fs() |
991 // CThumbnailServer::Fs() |
1077 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
1212 |
1126 |
1213 // ----------------------------------------------------------------------------- |
1127 // ----------------------------------------------------------------------------- |
1214 // Updates thumbnails by given Id. |
1128 // Updates thumbnails by given Id. |
1215 // ----------------------------------------------------------------------------- |
1129 // ----------------------------------------------------------------------------- |
1216 // |
1130 // |
1217 TBool CThumbnailServer::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, |
1131 TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath, |
1218 const TInt /*aOrientation*/, const TInt64 aModified ) |
1132 const TInt /*aOrientation*/, const TInt64 aModified ) |
1219 { |
1133 { |
1220 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1134 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); |
1221 |
1135 |
1222 // 1. check path change |
1136 // 1. check path change |
1223 // 2. check orientation change |
1137 // 2. check orientation change |
1224 // 3. check timestamp change |
1138 // 3. check timestamp change |
1225 TBool pathChanged = EFalse; |
1139 |
1226 TBool orientationChanged = EFalse; |
1140 TBool orientationChanged = EFalse; |
1227 TBool modifiedChanged = EFalse; |
1141 TBool modifiedChanged = EFalse; |
1228 |
1142 |
1229 CThumbnailStore* newstore = StoreForPathL( aPath ); |
1143 CThumbnailStore* store = StoreForPathL( aPath ); |
1230 TInt err(KErrNone); |
1144 |
1231 |
1145 // placeholder for orientation check |
1232 // no path available, can be any store |
1146 orientationChanged = EFalse; |
1233 THashMapIter<TInt, CThumbnailStore*> iter( iStores ); |
1147 |
1234 CThumbnailStore* const *store = iter.NextValue(); |
1148 if (orientationChanged) |
1235 |
1149 { |
1236 while ( store ) |
1150 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); |
1237 { |
1151 |
1238 err = KErrNone; |
1152 // orientation updated, no need to check further |
1239 |
1153 return ETrue; |
1240 TRAP(err, ((CThumbnailStore*)(*store))->FindStoreL( aItemId ) ); |
1154 } |
1241 |
1155 else |
1242 // no need to move thumbs to different store |
1156 { |
1243 if (err == KErrNone && *store == newstore) |
1157 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist"); |
1244 { |
1158 |
1245 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"); |
1246 |
1173 |
1247 if (pathChanged) |
1174 // delete old thumbs |
1248 { |
1175 store->DeleteThumbnailsL(aPath, ETrue); |
1249 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - path updated"); |
|
1250 |
|
1251 // path updated, no need to check further |
|
1252 return ETrue; |
|
1253 } |
|
1254 else |
|
1255 { |
|
1256 // placeholder for orientation check |
|
1257 orientationChanged = EFalse; |
|
1258 |
|
1259 if (orientationChanged) |
|
1260 { |
|
1261 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); |
|
1262 |
|
1263 // orientation updated, no need to check further |
|
1264 return ETrue; |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); |
|
1269 modifiedChanged = ((CThumbnailStore*)(*store))->CheckModifiedL(aItemId, aModified); |
|
1270 |
|
1271 if (modifiedChanged) |
|
1272 { |
|
1273 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); |
|
1274 |
|
1275 // delete old thumbs |
|
1276 ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); |
|
1277 |
|
1278 // need to create new thumbs |
|
1279 return EFalse; |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
|
1284 |
|
1285 // not modified |
|
1286 return ETrue; |
|
1287 } |
|
1288 } |
|
1289 } |
|
1290 |
1176 |
1291 } |
1177 // need to create new thumbs |
1292 // move to new store |
1178 } |
1293 else if (err == KErrNone && *store != newstore) |
1179 else |
1294 { |
1180 { |
1295 RArray < TThumbnailDatabaseData* >* thumbnails = NULL; |
1181 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); |
1296 thumbnails = new (ELeave) RArray < TThumbnailDatabaseData* >; |
|
1297 CleanupClosePushL( *thumbnails ); |
|
1298 ((CThumbnailStore*)(*store))->FetchThumbnailsL(aItemId, *thumbnails); |
|
1299 newstore->StoreThumbnailsL(aPath, *thumbnails); |
|
1300 ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); |
|
1301 CleanupStack::PopAndDestroy( thumbnails); |
|
1302 delete thumbnails; |
|
1303 thumbnails = NULL; |
|
1304 |
1182 |
1305 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - moved to different store"); |
1183 // not modified |
1306 |
|
1307 // no need to check further |
|
1308 return ETrue; |
1184 return ETrue; |
1309 } |
1185 } |
1310 |
1186 } |
1311 store = iter.NextValue(); |
1187 |
1312 } |
|
1313 |
1188 |
1314 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1189 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); |
1315 |
1190 |
1316 return EFalse; |
1191 return EFalse; |
1317 } |
1192 } |
1578 __UHEAP_MARKEND; |
1453 __UHEAP_MARKEND; |
1579 return result; |
1454 return result; |
1580 } |
1455 } |
1581 |
1456 |
1582 // ----------------------------------------------------------------------------- |
1457 // ----------------------------------------------------------------------------- |
1583 // Updates ID for thumbnails with given Path |
|
1584 // ----------------------------------------------------------------------------- |
|
1585 // |
|
1586 void CThumbnailServer::UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId ) |
|
1587 { |
|
1588 TN_DEBUG3( "CThumbnailServer::UpdateIDL() aPath = %S aId = %d", &aPath, aNewId); |
|
1589 |
|
1590 CThumbnailStore* store = StoreForPathL( aPath ); |
|
1591 User::LeaveIfNull( store ); |
|
1592 store->UpdateStoreL( aPath, aNewId ); |
|
1593 } |
|
1594 |
|
1595 // ----------------------------------------------------------------------------- |
|
1596 // Closes stores for removable drives |
1458 // Closes stores for removable drives |
1597 // ----------------------------------------------------------------------------- |
1459 // ----------------------------------------------------------------------------- |
1598 // |
1460 // |
1599 void CThumbnailServer::CloseRemovableDrivesL() |
1461 void CThumbnailServer::CloseRemovableDrivesL() |
1600 { |
1462 { |