161 User::LeaveIfError( iFile.Open( iFs, iPath, EFileShareReadersOrWriters ) ); |
161 User::LeaveIfError( iFile.Open( iFs, iPath, EFileShareReadersOrWriters ) ); |
162 |
162 |
163 TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iPath ); |
163 TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iPath ); |
164 |
164 |
165 CleanupClosePushL( iFile ); |
165 CleanupClosePushL( iFile ); |
|
166 |
|
167 if ( iParams.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview ) |
|
168 { |
|
169 // We may need the file handle later for the 2nd phase thumbnail |
|
170 iMyFileHandle.Close(); |
|
171 User::LeaveIfError( iMyFileHandle.Duplicate( iFile )); |
|
172 } |
|
173 |
166 iSession.RequestThumbnailL( iFile, iPath, iParamsPckg, iStatus ); |
174 iSession.RequestThumbnailL( iFile, iPath, iParamsPckg, iStatus ); |
167 CleanupStack::PopAndDestroy( &iFile ); |
175 CleanupStack::PopAndDestroy( &iFile ); |
168 } |
176 } |
169 else |
177 else |
170 { |
178 { |
195 User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) ); |
203 User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) ); |
196 |
204 |
197 TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri ); |
205 TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri ); |
198 |
206 |
199 CleanupClosePushL( iFile ); |
207 CleanupClosePushL( iFile ); |
|
208 |
|
209 if ( iParams.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview ) |
|
210 { |
|
211 // We may need the file handle later for the 2nd phase thumbnail |
|
212 iMyFileHandle.Close(); |
|
213 User::LeaveIfError( iMyFileHandle.Duplicate( iFile )); |
|
214 } |
|
215 |
200 iSession.RequestThumbnailL( iFile, iTargetUri, iParamsPckg, iStatus ); |
216 iSession.RequestThumbnailL( iFile, iTargetUri, iParamsPckg, iStatus ); |
201 CleanupStack::PopAndDestroy( &iFile ); |
217 CleanupStack::PopAndDestroy( &iFile ); |
202 break; |
218 break; |
203 } |
219 } |
204 case EReqDeleteThumbnails: |
220 case EReqDeleteThumbnails: |
218 case EReqRenameThumbnails: |
234 case EReqRenameThumbnails: |
219 { |
235 { |
220 iSession.RenameThumbnails( iParamsPckg, iStatus ); |
236 iSession.RenameThumbnails( iParamsPckg, iStatus ); |
221 break; |
237 break; |
222 } |
238 } |
|
239 case EReqSetThumbnailPath: |
|
240 { |
|
241 // open file handle |
|
242 iFile.Close(); |
|
243 User::LeaveIfError( iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters ) ); |
|
244 |
|
245 TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iParams.iFileName ); |
|
246 |
|
247 CleanupClosePushL( iFile ); |
|
248 |
|
249 if ( iParams.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview ) |
|
250 { |
|
251 // We may need the file handle later for the 2nd phase thumbnail |
|
252 iMyFileHandle.Close(); |
|
253 User::LeaveIfError( iMyFileHandle.Duplicate( iFile )); |
|
254 } |
|
255 |
|
256 iSession.RequestThumbnailL( iFile, iTargetUri, iParamsPckg, iStatus ); |
|
257 CleanupStack::PopAndDestroy( &iFile ); |
|
258 |
|
259 break; |
|
260 } |
|
261 |
223 default: |
262 default: |
224 { |
263 { |
225 break; |
264 break; |
226 } |
265 } |
227 } |
266 } |
649 iParams.iFlags = aFlags; |
688 iParams.iFlags = aFlags; |
650 iParams.iQualityPreference = aQualityPreference; |
689 iParams.iQualityPreference = aQualityPreference; |
651 iParams.iThumbnailSize = aThumbnailSize; |
690 iParams.iThumbnailSize = aThumbnailSize; |
652 iParams.iThumbnailId = aThumbnailId; |
691 iParams.iThumbnailId = aThumbnailId; |
653 iParams.iOverwrite = EFalse; |
692 iParams.iOverwrite = EFalse; |
|
693 iParams.iImport = EFalse; |
654 |
694 |
655 User::LeaveIfError( iFile.Duplicate( aFile )); |
695 User::LeaveIfError( iFile.Duplicate( aFile )); |
656 |
696 |
657 iTargetUri = aTargetUri; |
697 iTargetUri = aTargetUri; |
|
698 |
|
699 if (iParams.iFileName.Length() && IsVirtualUri(iParams.iFileName)) |
|
700 { |
|
701 iParams.iVirtualUri = ETrue; |
|
702 } |
|
703 else |
|
704 { |
|
705 iParams.iVirtualUri = EFalse; |
|
706 } |
658 } |
707 } |
659 |
708 |
660 |
709 |
661 // --------------------------------------------------------------------------- |
710 // --------------------------------------------------------------------------- |
662 // CThumbnailRequestActive::GetThumbnailL() |
711 // CThumbnailRequestActive::GetThumbnailL() |
685 iParams.iFlags = aFlags; |
734 iParams.iFlags = aFlags; |
686 iParams.iQualityPreference = aQualityPreference; |
735 iParams.iQualityPreference = aQualityPreference; |
687 iParams.iThumbnailSize = aThumbnailSize; |
736 iParams.iThumbnailSize = aThumbnailSize; |
688 iParams.iThumbnailId = aThumbnailId; |
737 iParams.iThumbnailId = aThumbnailId; |
689 iParams.iOverwrite = EFalse; |
738 iParams.iOverwrite = EFalse; |
|
739 iParams.iImport = EFalse; |
690 |
740 |
691 iTargetUri = aTargetUri; |
741 iTargetUri = aTargetUri; |
|
742 |
|
743 if (iPath.Length() && IsVirtualUri(iPath)) |
|
744 { |
|
745 iParams.iVirtualUri = ETrue; |
|
746 } |
|
747 else |
|
748 { |
|
749 iParams.iVirtualUri = EFalse; |
|
750 } |
692 } |
751 } |
693 |
752 |
694 |
753 |
695 // --------------------------------------------------------------------------- |
754 // --------------------------------------------------------------------------- |
696 // CThumbnailRequestActive::GetThumbnailL() |
755 // CThumbnailRequestActive::GetThumbnailL() |
719 iParams.iQualityPreference = aQualityPreference; |
778 iParams.iQualityPreference = aQualityPreference; |
720 iParams.iThumbnailSize = aThumbnailSize; |
779 iParams.iThumbnailSize = aThumbnailSize; |
721 iParams.iThumbnailId = aThumbnailId; |
780 iParams.iThumbnailId = aThumbnailId; |
722 iParams.iFileName = aPath; |
781 iParams.iFileName = aPath; |
723 iParams.iOverwrite = EFalse; |
782 iParams.iOverwrite = EFalse; |
|
783 iParams.iImport = EFalse; |
724 |
784 |
725 iPath = aPath; |
785 iPath = aPath; |
726 iTargetUri = aTargetUri; |
786 iTargetUri = aTargetUri; |
|
787 |
|
788 if (iPath.Length() && IsVirtualUri(iPath)) |
|
789 { |
|
790 iParams.iVirtualUri = ETrue; |
|
791 } |
|
792 else |
|
793 { |
|
794 iParams.iVirtualUri = EFalse; |
|
795 } |
727 } |
796 } |
728 |
797 |
729 // --------------------------------------------------------------------------- |
798 // --------------------------------------------------------------------------- |
730 // CThumbnailRequestActive::SetThumbnailL() |
799 // CThumbnailRequestActive::SetThumbnailL() |
731 // Get a thumbnail for an object file. |
800 // Get a thumbnail for an object file. |
755 iParams.iPriority = aPriority; |
824 iParams.iPriority = aPriority; |
756 iParams.iFlags = aFlags; |
825 iParams.iFlags = aFlags; |
757 iParams.iQualityPreference = aQualityPreference; |
826 iParams.iQualityPreference = aQualityPreference; |
758 iParams.iThumbnailId = aThumbnailId; |
827 iParams.iThumbnailId = aThumbnailId; |
759 iParams.iOverwrite = aOverwrite; |
828 iParams.iOverwrite = aOverwrite; |
|
829 iParams.iImport = EFalse; |
760 |
830 |
761 iTargetUri = aTargetUri; |
831 iTargetUri = aTargetUri; |
|
832 |
|
833 if (iTargetUri.Length() && IsVirtualUri(iTargetUri)) |
|
834 { |
|
835 iParams.iVirtualUri = ETrue; |
|
836 } |
|
837 else |
|
838 { |
|
839 iParams.iVirtualUri = EFalse; |
|
840 } |
762 } |
841 } |
763 |
842 |
764 // --------------------------------------------------------------------------- |
843 // --------------------------------------------------------------------------- |
765 // CThumbnailRequestActive::SetThumbnailL() |
844 // CThumbnailRequestActive::SetThumbnailL() |
766 // Get a thumbnail for an object file. |
845 // Get a thumbnail for an object file. |
787 iParams.iFlags = aFlags; |
866 iParams.iFlags = aFlags; |
788 iParams.iQualityPreference = aQualityPreference; |
867 iParams.iQualityPreference = aQualityPreference; |
789 iParams.iThumbnailId = aThumbnailId; |
868 iParams.iThumbnailId = aThumbnailId; |
790 iParams.iFileName = aTargetUri; |
869 iParams.iFileName = aTargetUri; |
791 iParams.iOverwrite = aOverwrite; |
870 iParams.iOverwrite = aOverwrite; |
|
871 iParams.iImport = EFalse; |
792 |
872 |
793 iTargetUri = aTargetUri; |
873 iTargetUri = aTargetUri; |
|
874 |
|
875 if (iTargetUri.Length() && IsVirtualUri(iTargetUri)) |
|
876 { |
|
877 iParams.iVirtualUri = ETrue; |
|
878 } |
|
879 else |
|
880 { |
|
881 iParams.iVirtualUri = EFalse; |
|
882 } |
794 |
883 |
795 TInt memoryFree( 0 ); |
884 TInt memoryFree( 0 ); |
796 HAL::Get( HALData::EMemoryRAMFree, memoryFree ); |
885 HAL::Get( HALData::EMemoryRAMFree, memoryFree ); |
797 |
886 |
798 TN_DEBUG2( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memoryFree %d", memoryFree ); |
887 TN_DEBUG2( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memoryFree %d", memoryFree ); |
802 // save parameter bitmap, it will be deleted when request is complete |
891 // save parameter bitmap, it will be deleted when request is complete |
803 iBitmap = aBitmap; |
892 iBitmap = aBitmap; |
804 iParams.iMimeType = TDataType( aMimeType ); |
893 iParams.iMimeType = TDataType( aMimeType ); |
805 iRequestType = EReqSetThumbnailBitmap; |
894 iRequestType = EReqSetThumbnailBitmap; |
806 } |
895 } |
807 else |
896 else if (!iParams.iVirtualUri) |
808 { |
897 { |
809 // memory low, create thumbs using filehandle |
898 // memory low, create thumbs using filehandle |
810 TN_DEBUG1( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memory low, create thumbs using filehandle!" ); |
899 TN_DEBUG1( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memory low, create thumbs using filehandle!" ); |
811 delete aBitmap; |
900 delete aBitmap; |
812 aBitmap = NULL; |
901 aBitmap = NULL; |
813 iParams.iPriority = aPriority - 1; |
902 iParams.iPriority = aPriority - 1; |
814 iRequestType = EReqGetThumbnailHandleLater; |
903 iRequestType = EReqGetThumbnailHandleLater; |
|
904 } |
|
905 else |
|
906 { |
|
907 User::Leave(KErrNoMemory); |
815 } |
908 } |
816 } |
909 } |
817 |
910 |
818 // --------------------------------------------------------------------------- |
911 // --------------------------------------------------------------------------- |
819 // CThumbnailRequestActive::UpdateThumbnailsL() |
912 // CThumbnailRequestActive::UpdateThumbnailsL() |
836 iParams.iPriority = aPriority; |
929 iParams.iPriority = aPriority; |
837 iParams.iFlags = aFlags; |
930 iParams.iFlags = aFlags; |
838 iParams.iQualityPreference = aQualityPreference; |
931 iParams.iQualityPreference = aQualityPreference; |
839 iParams.iThumbnailId = aThumbnailId; |
932 iParams.iThumbnailId = aThumbnailId; |
840 iParams.iOverwrite = EFalse; |
933 iParams.iOverwrite = EFalse; |
|
934 iParams.iVirtualUri = EFalse; |
|
935 iParams.iImport = EFalse; |
841 |
936 |
842 iPath = aPath; |
937 iPath = aPath; |
843 iOrientation = aOrientation; |
938 iOrientation = aOrientation; |
844 iModified = aModified; |
939 iModified = aModified; |
845 } |
940 } |
876 iParams.iFileName = aCurrentPath; |
971 iParams.iFileName = aCurrentPath; |
877 iParams.iTargetUri = aNewPath; |
972 iParams.iTargetUri = aNewPath; |
878 } |
973 } |
879 |
974 |
880 // --------------------------------------------------------------------------- |
975 // --------------------------------------------------------------------------- |
|
976 // CThumbnailRequestActive::SetThumbnailL() |
|
977 // Set thumbnail from file path. |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 void CThumbnailRequestActive::SetThumbnailL( const TDesC& aPath, const TDesC8& aMimeType, |
|
981 CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager |
|
982 ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const |
|
983 TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, |
|
984 TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri, |
|
985 TThumbnailSize aThumbnailSize, TBool aOverwrite) |
|
986 { |
|
987 iRequestType = EReqSetThumbnailPath; |
|
988 |
|
989 iClientData = aClientData; |
|
990 iParams.iControlFlags = (aGeneratePersistentSizesOnly ? |
|
991 EThumbnailGeneratePersistentSizesOnly : |
|
992 EThumbnailNoControlFlags); |
|
993 iParams.iOriginalControlFlags = iParams.iControlFlags; |
|
994 iParams.iMimeType = TDataType( aMimeType ); |
|
995 iParams.iBitmapHandle = 0; |
|
996 iParams.iSize = aSize; |
|
997 iParams.iDisplayMode = aDisplayMode; |
|
998 iParams.iFileName = aPath; |
|
999 iParams.iRequestId = iRequestId; |
|
1000 iParams.iPriority = aPriority; |
|
1001 iParams.iFlags = aFlags; |
|
1002 iParams.iQualityPreference = aQualityPreference; |
|
1003 iParams.iThumbnailSize = aThumbnailSize; |
|
1004 iParams.iOverwrite = aOverwrite; |
|
1005 |
|
1006 iTargetUri = aTargetUri; |
|
1007 |
|
1008 if (iTargetUri.Length() && IsVirtualUri(iTargetUri)) |
|
1009 { |
|
1010 iParams.iVirtualUri = ETrue; |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 iParams.iVirtualUri = EFalse; |
|
1015 } |
|
1016 |
|
1017 iParams.iImport = ETrue; |
|
1018 } |
|
1019 |
|
1020 // --------------------------------------------------------------------------- |
881 // Request 2nd phase thumbnail |
1021 // Request 2nd phase thumbnail |
882 // --------------------------------------------------------------------------- |
1022 // --------------------------------------------------------------------------- |
883 // |
1023 // |
884 void CThumbnailRequestActive::Get2ndPhaseThumbnailL() |
1024 void CThumbnailRequestActive::Get2ndPhaseThumbnailL() |
885 { |
1025 { |