232 iProcessor = CThumbnailTaskProcessor::NewL(); |
232 iProcessor = CThumbnailTaskProcessor::NewL(); |
233 REComSession::FinalClose(); |
233 REComSession::FinalClose(); |
234 REComSession::ListImplementationsL( TUid::Uid( THUMBNAIL_PROVIDER_IF_UID ), |
234 REComSession::ListImplementationsL( TUid::Uid( THUMBNAIL_PROVIDER_IF_UID ), |
235 iPluginInfoArray ); |
235 iPluginInfoArray ); |
236 |
236 |
|
237 //preload provide plugins |
|
238 PreLoadProviders(); |
|
239 |
237 CTMGetImei * imeiGetter = CTMGetImei::NewLC(); |
240 CTMGetImei * imeiGetter = CTMGetImei::NewLC(); |
238 |
241 |
239 iImei = imeiGetter->GetIMEI(); |
242 iImei = imeiGetter->GetIMEI(); |
240 CleanupStack::PopAndDestroy(imeiGetter); |
243 CleanupStack::PopAndDestroy(imeiGetter); |
241 |
244 |
250 |
253 |
251 iFormatObserver = CTMFormatObserver::NewL( *this ); |
254 iFormatObserver = CTMFormatObserver::NewL( *this ); |
252 |
255 |
253 iFormatting = EFalse; |
256 iFormatting = EFalse; |
254 |
257 |
255 //OpenStoresL(); |
258 OpenStoresL(); |
256 |
259 |
257 AddUnmountObserversL(); |
260 AddUnmountObserversL(); |
258 iFetchedChecker = CThumbnailFetchedChecker::NewL(); |
261 iFetchedChecker = CThumbnailFetchedChecker::NewL(); |
|
262 |
|
263 // Unmount timeout timer |
|
264 iUnmount = CPeriodic::NewL(CActive::EPriorityIdle); |
259 } |
265 } |
260 |
266 |
261 |
267 |
262 // --------------------------------------------------------------------------- |
268 // --------------------------------------------------------------------------- |
263 // Destructor. |
269 // Destructor. |
316 |
331 |
317 // ----------------------------------------------------------------------------- |
332 // ----------------------------------------------------------------------------- |
318 // CThumbnailServer::HandleSessionOpened |
333 // CThumbnailServer::HandleSessionOpened |
319 // ----------------------------------------------------------------------------- |
334 // ----------------------------------------------------------------------------- |
320 // |
335 // |
|
336 #ifdef _DEBUG |
|
337 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt aError ) |
|
338 #else |
321 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt /*aError*/ ) |
339 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt /*aError*/ ) |
322 { |
340 #endif |
323 TN_DEBUG1( "CThumbnailServer::HandleSessionOpened"); |
341 { |
|
342 TN_DEBUG2( "CThumbnailServer::HandleSessionOpened error == %d", aError ); |
324 } |
343 } |
325 |
344 |
326 // ----------------------------------------------------------------------------- |
345 // ----------------------------------------------------------------------------- |
327 // CThumbnailServer::HandleSessionError |
346 // CThumbnailServer::HandleSessionError |
328 // ----------------------------------------------------------------------------- |
347 // ----------------------------------------------------------------------------- |
460 // CThumbnailServer::ShutdownNotification |
479 // CThumbnailServer::ShutdownNotification |
461 // ----------------------------------------------------------------------------- |
480 // ----------------------------------------------------------------------------- |
462 // |
481 // |
463 void CThumbnailServer::ShutdownNotification() |
482 void CThumbnailServer::ShutdownNotification() |
464 { |
483 { |
|
484 TN_DEBUG1( "CThumbnailServer::ShutdownNotification()"); |
465 if (!iShutdown) |
485 if (!iShutdown) |
466 { |
486 { |
|
487 TN_DEBUG1( "CThumbnailServer::ShutdownNotification() shutdown"); |
467 CActiveScheduler::Stop(); |
488 CActiveScheduler::Stop(); |
468 iShutdown = ETrue; |
489 iShutdown = ETrue; |
469 } |
490 } |
470 } |
491 } |
471 |
492 |
773 return res; |
794 return res; |
774 } |
795 } |
775 |
796 |
776 |
797 |
777 // ----------------------------------------------------------------------------- |
798 // ----------------------------------------------------------------------------- |
|
799 // CThumbnailServer::GetProviderL() |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 void CThumbnailServer::PreLoadProviders( ) |
|
803 { |
|
804 TN_DEBUG1( "CThumbnailServer::PreLoadProvidersL()" ); |
|
805 TInt err(KErrNone); |
|
806 |
|
807 for(TInt i=0; i< iPluginInfoArray.Count(); i++) |
|
808 { |
|
809 TRAP(err, GetProviderL( iPluginInfoArray[i]->ImplementationUid())); |
|
810 } |
|
811 } |
|
812 |
|
813 |
|
814 // ----------------------------------------------------------------------------- |
778 // CThumbnailServer::QueueTaskL() |
815 // CThumbnailServer::QueueTaskL() |
779 // Adds thumbnailtask to processor queue. |
816 // Adds thumbnailtask to processor queue. |
780 // ----------------------------------------------------------------------------- |
817 // ----------------------------------------------------------------------------- |
781 // |
818 // |
782 void CThumbnailServer::QueueTaskL( CThumbnailTask* aTask ) |
819 void CThumbnailServer::QueueTaskL( CThumbnailTask* aTask ) |
885 // ----------------------------------------------------------------------------- |
922 // ----------------------------------------------------------------------------- |
886 // |
923 // |
887 CThumbnailStore* CThumbnailServer::StoreForDriveL( const TInt aDrive ) |
924 CThumbnailStore* CThumbnailServer::StoreForDriveL( const TInt aDrive ) |
888 { |
925 { |
889 TN_DEBUG2( "CThumbnailServer::StoreForDriveL() drive=%d", aDrive ); |
926 TN_DEBUG2( "CThumbnailServer::StoreForDriveL() drive=%d", aDrive ); |
|
927 |
|
928 if(iUnmountedDrives.Find( aDrive ) >= KErrNone) |
|
929 { |
|
930 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() unmount in progress, skip!"); |
|
931 User::Leave( KErrDisMounted ); |
|
932 } |
|
933 |
890 CThumbnailStore** resPtr = iStores.Find( aDrive ); |
934 CThumbnailStore** resPtr = iStores.Find( aDrive ); |
891 CThumbnailStore* res = NULL; |
935 CThumbnailStore* res = NULL; |
892 |
936 |
893 if ( resPtr ) |
937 if ( resPtr ) |
894 { |
938 { |
899 if(iFormatting) |
943 if(iFormatting) |
900 { |
944 { |
901 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT"); |
945 TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT"); |
902 User::Leave( KErrNotSupported ); |
946 User::Leave( KErrNotSupported ); |
903 } |
947 } |
|
948 |
904 TVolumeInfo volumeInfo; |
949 TVolumeInfo volumeInfo; |
905 TInt err = iFs.Volume( volumeInfo, aDrive ); |
950 TInt err = iFs.Volume( volumeInfo, aDrive ); |
|
951 |
906 if ( err || volumeInfo.iDrive.iDriveAtt& KDriveAttRom || |
952 if ( err || volumeInfo.iDrive.iDriveAtt& KDriveAttRom || |
907 volumeInfo.iDrive.iDriveAtt& KDriveAttRemote || |
953 volumeInfo.iDrive.iDriveAtt& KDriveAttRemote || |
908 volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected || |
954 volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected || |
909 volumeInfo.iDrive.iMediaAtt& KMediaAttLocked ) |
955 volumeInfo.iDrive.iMediaAtt& KMediaAttLocked ) |
910 { |
956 { |
911 // We don't support ROM disks or remote mounts. Media |
957 // We don't support ROM disks or remote mounts. Media |
912 // must be read-write and not locked. |
958 // must be read-write and not locked. |
913 User::Leave( KErrAccessDenied); |
959 User::Leave( KErrAccessDenied); |
914 } |
960 } |
915 |
961 |
916 res = CThumbnailStore::NewL( iFs, aDrive, iImei, this ); |
962 res = CThumbnailStore::NewL( iFs, aDrive, iImei, this ); |
917 CleanupStack::PushL( res ); |
963 CleanupStack::PushL( res ); |
918 iStores.InsertL( aDrive, res ); |
964 iStores.InsertL( aDrive, res ); |
919 res->SetPersistentSizes(iPersistentSizes); |
965 res->SetPersistentSizes(iPersistentSizes); |
920 CleanupStack::Pop( res ); |
966 CleanupStack::Pop( res ); |
921 |
967 |
922 for(TInt i = 0; i<iUnmountObservers.Count(); i++) |
968 for(TInt i = 0; i < iUnmountObservers.Count(); i++) |
923 { |
969 { |
924 iUnmountObservers[i]->StartNotify(); |
970 iUnmountObservers[i]->StartNotify(); |
925 } |
971 } |
926 } |
972 } |
927 |
973 |
1000 void CThumbnailServer::CloseStoreForDriveL( const TInt aDrive ) |
1046 void CThumbnailServer::CloseStoreForDriveL( const TInt aDrive ) |
1001 { |
1047 { |
1002 TN_DEBUG2( "CThumbnailServer::CloseStoreForDriveL drive=%d", aDrive); |
1048 TN_DEBUG2( "CThumbnailServer::CloseStoreForDriveL drive=%d", aDrive); |
1003 CThumbnailStore** store = iStores.Find( aDrive ); |
1049 CThumbnailStore** store = iStores.Find( aDrive ); |
1004 |
1050 |
|
1051 StartUnmountTimeout( aDrive); |
|
1052 |
1005 if (store) |
1053 if (store) |
1006 { |
1054 { |
1007 delete *store; |
1055 delete *store; |
1008 iStores.Remove( aDrive ); |
1056 iStores.Remove( aDrive ); |
1009 } |
1057 } |
1096 |
1144 |
1097 TInt err = iFs.Volume(volumeInfo, drive); |
1145 TInt err = iFs.Volume(volumeInfo, drive); |
1098 TInt err_drive = iFs.Drive(driveInfo, drive); |
1146 TInt err_drive = iFs.Drive(driveInfo, drive); |
1099 |
1147 |
1100 // mount -- if removable drive, add new store |
1148 // mount -- if removable drive, add new store |
1101 if (!err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable) |
1149 if (!err && !err_drive |
1102 { |
1150 && driveInfo.iType != EMediaNotPresent |
|
1151 && driveInfo.iDriveAtt& KDriveAttRemovable ) |
|
1152 { |
|
1153 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL mount drive==%d", drive); |
|
1154 |
|
1155 CThumbnailStore** resPtr = iStores.Find( drive ); |
|
1156 |
|
1157 if ( resPtr ) |
|
1158 { |
|
1159 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() already mounted, skip %d", drive); |
|
1160 continue; |
|
1161 } |
|
1162 |
1103 // ignore errors |
1163 // ignore errors |
1104 //TRAP_IGNORE( StoreForDriveL( drive )); |
1164 TRAP_IGNORE( StoreForDriveL( drive )); |
|
1165 TInt index = iUnmountedDrives.Find( drive ); |
|
1166 |
|
1167 if(index >= KErrNone) |
|
1168 { |
|
1169 iUnmountedDrives.Remove( index ); |
|
1170 } |
|
1171 |
|
1172 if(!iUnmountedDrives.Count()&& iUnmount && iUnmount->IsActive()) |
|
1173 { |
|
1174 TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL() cancel unmount timer"); |
|
1175 iUnmount->Cancel(); |
|
1176 } |
1105 } |
1177 } |
1106 |
1178 |
1107 //dismount -- if removable drive, close store |
1179 //dismount -- if removable drive, close store |
1108 else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable) |
1180 else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable ) |
1109 { |
1181 { |
|
1182 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() unmount drive==%d", drive); |
1110 CloseStoreForDriveL( drive); |
1183 CloseStoreForDriveL( drive); |
1111 } |
1184 } |
1112 } |
1185 } |
1113 |
1186 |
1114 TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL out()" ); |
1187 TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL out()" ); |
1663 } |
1736 } |
1664 |
1737 |
1665 return ETrue; |
1738 return ETrue; |
1666 } |
1739 } |
1667 |
1740 |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // CThumbnailServer::StartUnmount() |
|
1743 // --------------------------------------------------------------------------- |
|
1744 // |
|
1745 void CThumbnailServer::StartUnmountTimeout( const TInt aDrive) |
|
1746 { |
|
1747 TN_DEBUG2( "CThumbnailServer::StartUnmountTimeout(%d)", aDrive); |
|
1748 |
|
1749 if(iUnmount ) |
|
1750 { |
|
1751 if(iUnmountedDrives.Find( aDrive ) == KErrNotFound) |
|
1752 { |
|
1753 iUnmountedDrives.Append( aDrive ); |
|
1754 } |
|
1755 |
|
1756 if(iUnmount->IsActive()) |
|
1757 { |
|
1758 iUnmount->Cancel(); |
|
1759 } |
|
1760 |
|
1761 TN_DEBUG1( "CThumbnailServer::StartUnmountTimeout() start unmount timer"); |
|
1762 iUnmount->Start( KUnmountTimerTimeout, KUnmountTimerTimeout, TCallBack(UnmountCallBack, this)); |
|
1763 } |
|
1764 __ASSERT_DEBUG(( iUnmount ), ThumbnailPanic( EThumbnailNullPointer )); |
|
1765 } |
|
1766 |
|
1767 |
|
1768 // --------------------------------------------------------------------------- |
|
1769 // CThumbnailServer::ReconnectCallBack() |
|
1770 // --------------------------------------------------------------------------- |
|
1771 // |
|
1772 TInt CThumbnailServer::UnmountCallBack(TAny* aAny) |
|
1773 { |
|
1774 TN_DEBUG1( "CThumbnailServer::UnmountCallBack() - unmount finished"); |
|
1775 |
|
1776 CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny ); |
|
1777 |
|
1778 self->iUnmount->Cancel(); |
|
1779 |
|
1780 self->iUnmountedDrives.Reset(); |
|
1781 |
|
1782 TN_DEBUG1( "CThumbAGDaemon::UnmountCallBack() - done"); |
|
1783 |
|
1784 return KErrNone; |
|
1785 } |