636 TParsePtrC parse( item.Uri() ); |
631 TParsePtrC parse( item.Uri() ); |
637 if( parse.PathPresent() && |
632 if( parse.PathPresent() && |
638 parse.Path().Length() > KPrivateFolder().Length() && |
633 parse.Path().Length() > KPrivateFolder().Length() && |
639 parse.Path().Left( KPrivateFolder().Length() ).CompareF( KPrivateFolder ) == 0 ) |
634 parse.Path().Left( KPrivateFolder().Length() ).CompareF( KPrivateFolder ) == 0 ) |
640 { |
635 { |
|
636 CreateImageViewerInstanceL(); |
641 GLX_DEBUG1("KGlxCollectionPluginImageViewerImplementationUid - Fetch (Private) TN!"); |
637 GLX_DEBUG1("KGlxCollectionPluginImageViewerImplementationUid - Fetch (Private) TN!"); |
642 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(iImageViewerInstance->ImageFileHandle()); |
638 if ( &(iImageViewerInstance->ImageFileHandle()) != NULL ) |
643 iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(*source), spaceId, tnSize, itemId)); |
639 { |
644 CleanupStack::PopAndDestroy(source); |
640 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(iImageViewerInstance->ImageFileHandle()); |
|
641 iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(*source), spaceId, tnSize, itemId)); |
|
642 CleanupStack::PopAndDestroy(source); |
|
643 } |
|
644 DeleteImageViewerInstance(); |
645 } |
645 } |
646 else |
646 else |
647 { |
647 { |
648 GLX_DEBUG1("KGlxCollectionPluginImageViewerImplementationUid - Fetch TN!"); |
648 GLX_DEBUG1("KGlxCollectionPluginImageViewerImplementationUid - Fetch TN!"); |
649 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(item.Uri(), 0); |
649 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(item.Uri(), 0); |
693 collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs); |
693 collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs); |
694 } |
694 } |
695 } |
695 } |
696 } |
696 } |
697 else |
697 else |
698 { |
698 { |
699 GLX_DEBUG3("MGallery - CGlxCacheManager::MaintainCacheL() requesting attribute for list %x and item %d", list, itemId.Value()); |
699 GLX_DEBUG3("MGallery - CGlxCacheManager::MaintainCacheL() requesting attribute for list %x and item %d", list, itemId.Value()); |
700 |
700 |
701 // Use list's isolated collection |
701 // Use list's isolated collection |
702 MMPXCollection& collection = list->Collection(); |
702 MMPXCollection& collection = list->Collection(); |
703 if (collection.UidL().iUid == KGlxCollectionPluginImageViewerImplementationUid) |
703 if (collection.UidL().iUid == KGlxCollectionPluginImageViewerImplementationUid) |
704 { |
704 { |
|
705 CreateImageViewerInstanceL(); |
705 TInt mediaCnt = list->Count(); |
706 TInt mediaCnt = list->Count(); |
706 TInt errInImage = KErrNone; |
707 TInt errInImage = KErrNone; |
707 |
708 |
708 |
|
709 GLX_DEBUG3("Image Viewer Collection - Attrib population! mediaCnt=%d, Media Id=%d", |
709 GLX_DEBUG3("Image Viewer Collection - Attrib population! mediaCnt=%d, Media Id=%d", |
710 mediaCnt, itemId.Value()); |
710 mediaCnt, itemId.Value()); |
711 |
711 |
712 delete iMPXMedia; |
712 delete iMPXMedia; |
713 iMPXMedia = NULL; |
713 iMPXMedia = NULL; |
714 |
714 |
715 TFileName fileName; |
715 TFileName fileName(KNullDesC); |
716 //retrieve the filename as per the caller app. |
716 //retrieve the filename as per the caller app. |
717 if(!iImageViewerInstance->IsPrivate()) |
717 if(iImageViewerInstance->IsPrivate()) |
718 { |
718 { |
719 //filemngr |
719 const TGlxMedia& item = list->Item( iRequestedItemIndexes[0] ); |
720 fileName.Append(iImageViewerInstance->ImageUri()->Des()); |
720 // If there is an URI available, then the request is due to EPathChanged message |
|
721 // due to a file save from Image Viewer, and attribs needs to be re-populated. |
|
722 // So, use the same URI; Oherwise getting fullname from handle might result in a crash. |
|
723 if (item.Uri().Length()) |
|
724 { |
|
725 fileName.Append(item.Uri()); |
|
726 } |
|
727 else |
|
728 { |
|
729 // private path |
|
730 RFile64& imageHandle = iImageViewerInstance->ImageFileHandle(); |
|
731 if ( &imageHandle != NULL ) |
|
732 { |
|
733 fileName.Append(imageHandle.FullName(fileName)); |
|
734 } |
|
735 else |
|
736 { |
|
737 errInImage = KErrArgument; |
|
738 } |
|
739 } |
721 } |
740 } |
722 else |
741 else |
723 { |
742 { |
724 //msging |
743 // user data path |
725 fileName.Append(iImageViewerInstance->ImageFileHandle().FullName(fileName)); |
744 if( iImageViewerInstance->ImageUri() != NULL ) |
|
745 { |
|
746 fileName.Append(iImageViewerInstance->ImageUri()->Des()); |
|
747 RFs fs; |
|
748 CleanupClosePushL(fs); |
|
749 TInt err = fs.Connect(); |
|
750 errInImage = KErrArgument; |
|
751 if(err == KErrNone) |
|
752 { |
|
753 if (fs.IsValidName(fileName)) |
|
754 { |
|
755 errInImage = KErrNone; |
|
756 } |
|
757 } |
|
758 CleanupStack::PopAndDestroy(&fs); |
|
759 } |
|
760 else |
|
761 { |
|
762 errInImage = KErrArgument; |
|
763 } |
726 } |
764 } |
|
765 |
727 iMPXMedia = CMPXMedia::NewL(); |
766 iMPXMedia = CMPXMedia::NewL(); |
|
767 |
|
768 if (errInImage != KErrNone) |
|
769 { |
|
770 HandleGarbageCollectionL(EFalse); |
|
771 CleanupStack::PopAndDestroy(path); |
|
772 iRequestOwner = list; |
|
773 CleanupStack::PopAndDestroy(attrSpecs); |
|
774 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]); |
|
775 HandleCollectionMediaL(spaceId, *iMPXMedia, KErrArgument); |
|
776 DeleteImageViewerInstance(); |
|
777 return; |
|
778 } |
|
779 |
728 if(!iReader) |
780 if(!iReader) |
729 { |
781 { |
730 TRAP(errInImage,iReader = CGlxImageReader::NewL(*this)); |
782 TRAP(errInImage,iReader = CGlxImageReader::NewL(*this)); |
731 if(errInImage == KErrNone) |
783 if(errInImage == KErrNone) |
732 { |
784 { |
733 iSchedulerWait->Start(); |
785 iSchedulerWait->Start(); |
734 } |
786 } |
735 } |
787 } |
736 |
788 |
737 for ( TInt i = 0; i < iRequestedAttrs.Count(); i++ ) |
789 for ( TInt i = 0; i < iRequestedAttrs.Count(); i++ ) |
738 { |
790 { |
739 if ( iRequestedAttrs[i] == KMPXMediaGeneralId ) |
791 if ( iRequestedAttrs[i] == KMPXMediaGeneralId ) |
740 { |
792 { |
741 iMPXMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
793 iMPXMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
766 } |
818 } |
767 else if ( iRequestedAttrs[i] == KGlxMediaGeneralLastModifiedDate ) |
819 else if ( iRequestedAttrs[i] == KGlxMediaGeneralLastModifiedDate ) |
768 { |
820 { |
769 if(errInImage == KErrNone) |
821 if(errInImage == KErrNone) |
770 { |
822 { |
771 RFs fs; |
823 RFs fs; |
772 fs.Connect(); |
824 CleanupClosePushL(fs); |
773 TEntry entry; |
825 TInt err = fs.Connect(); |
774 fs.Entry(fileName,entry); |
826 if(err == KErrNone) |
775 TTime time = entry.iModified; |
827 { |
776 fs.Close(); |
828 TEntry entry; |
777 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLastModifiedDate, time.Int64()); |
829 fs.Entry(fileName,entry); |
|
830 TTime time = entry.iModified; |
|
831 iMPXMedia->SetTObjectValueL( |
|
832 KGlxMediaGeneralLastModifiedDate, |
|
833 time.Int64()); |
|
834 } |
|
835 else |
|
836 { |
|
837 TTime time; |
|
838 time.HomeTime(); |
|
839 iMPXMedia->SetTObjectValueL( |
|
840 KGlxMediaGeneralLastModifiedDate, |
|
841 time.Int64()); |
|
842 } |
|
843 CleanupStack::PopAndDestroy(&fs); |
778 } |
844 } |
779 else |
845 else |
780 { |
846 { |
781 TTime time; |
847 TTime time; |
782 time.HomeTime(); |
848 time.HomeTime(); |
783 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLastModifiedDate, time.Int64()); |
849 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLastModifiedDate, time.Int64()); |
784 } |
850 } |
785 } |
851 } |
786 else if ( iRequestedAttrs[i] == KMPXMediaGeneralSize ) |
852 else if ( iRequestedAttrs[i] == KMPXMediaGeneralSize ) |
787 { |
853 { |
788 if(errInImage == KErrNone) |
854 if(errInImage == KErrNone) |
789 { |
855 { |
790 RFs fs; |
856 if(iImageViewerInstance->IsPrivate()) |
791 TInt err = fs.Connect(); |
857 { |
792 if(err == KErrNone) |
858 TInt64 sz = 0; |
793 { |
859 TInt err = KErrNotFound; |
794 TEntry entry; |
860 RFile64& imageHandle = iImageViewerInstance->ImageFileHandle(); |
795 fs.Entry(fileName,entry); |
861 if ( imageHandle.SubSessionHandle() != KNullHandle ) |
796 TInt sz; |
862 { |
797 sz = entry.iSize; |
863 err = imageHandle.Size(sz); |
798 fs.Close(); |
864 } |
799 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, sz); |
865 if(err == KErrNone) |
800 } |
866 { |
801 else |
867 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, sz); |
802 { |
868 } |
803 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0); |
869 else |
804 } |
870 { |
805 } |
871 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0); |
|
872 } |
|
873 } |
|
874 else |
|
875 { |
|
876 RFs fs; |
|
877 CleanupClosePushL(fs); |
|
878 TInt err = fs.Connect(); |
|
879 if(err == KErrNone) |
|
880 { |
|
881 TEntry entry; |
|
882 fs.Entry(fileName,entry); |
|
883 TInt sz = (TUint)entry.iSize; |
|
884 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, sz); |
|
885 } |
|
886 else |
|
887 { |
|
888 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0); |
|
889 } |
|
890 CleanupStack::PopAndDestroy(&fs); |
|
891 } |
|
892 } |
806 // If any error while image is being decoded by image decorder, Need to set |
893 // If any error while image is being decoded by image decorder, Need to set |
807 // default vaule for that image. Typical case is corrupted image. |
894 // default vaule for that image. Typical case is corrupted image. |
808 else |
895 else |
809 { |
896 { |
810 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0); |
897 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0); |
859 { |
946 { |
860 iMPXMedia->SetTextValueL(KMPXMediaGeneralComment, KNullDesC); |
947 iMPXMedia->SetTextValueL(KMPXMediaGeneralComment, KNullDesC); |
861 } |
948 } |
862 else if (iRequestedAttrs[i] == KMPXMediaDrmProtected ) |
949 else if (iRequestedAttrs[i] == KMPXMediaDrmProtected ) |
863 { |
950 { |
864 TBool protection = iReader->GetDRMRightsL |
951 TBool protection = EFalse; |
865 (ContentAccess::EIsProtected); |
952 if(errInImage == KErrNone) |
866 iMPXMedia->SetTObjectValueL(KMPXMediaDrmProtected, protection); |
953 { |
|
954 protection = iReader->GetDRMRightsL |
|
955 (ContentAccess::EIsProtected); |
|
956 } |
|
957 iMPXMedia->SetTObjectValueL(KMPXMediaDrmProtected, protection); |
867 } |
958 } |
868 else if ( iRequestedAttrs[i] == KGlxMediaGeneralDRMRightsValid ) |
959 else if ( iRequestedAttrs[i] == KGlxMediaGeneralDRMRightsValid ) |
869 { |
960 { |
870 TBool canView = iReader->GetDRMRightsL(ContentAccess::ECanView); |
961 TInt rightsValid = EGlxDrmRightsValidityUnknown; |
871 TInt rightsValid = canView ? |
962 if(errInImage == KErrNone) |
872 EGlxDrmRightsValid : EGlxDrmRightsInvalid; |
963 { |
|
964 TBool canView = iReader->GetDRMRightsL(ContentAccess::ECanView); |
|
965 rightsValid = canView ? |
|
966 EGlxDrmRightsValid : EGlxDrmRightsInvalid; |
|
967 } |
873 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, |
968 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, |
874 rightsValid); |
969 rightsValid); |
875 } |
970 } |
876 else if ( iRequestedAttrs[i] == KMPXMediaGeneralCount ) |
971 else if ( iRequestedAttrs[i] == KMPXMediaGeneralCount ) |
877 { |
972 { |
878 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralCount, 1); |
973 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralCount, 1); |
879 } |
974 } |
880 else if ( iRequestedAttrs[i] == KMPXMediaColDetailSpaceId ) |
975 else if ( iRequestedAttrs[i] == KMPXMediaColDetailSpaceId ) |
881 { |
976 { |
882 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]); |
977 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]); |
883 iMPXMedia->SetTObjectValueL(KMPXMediaColDetailSpaceId, |
978 iMPXMedia->SetTObjectValueL(KMPXMediaColDetailSpaceId, |
884 spaceId.Value()); |
979 spaceId.Value()); |
885 } |
980 } |
886 else if ( iRequestedAttrs[i] == KGlxMediaGeneralSlideshowableContent ) |
981 else if ( iRequestedAttrs[i] == KGlxMediaGeneralSlideshowableContent ) |
887 { |
982 { |
888 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralSlideshowableContent, -1); |
983 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralSlideshowableContent, -1); |
889 } |
984 } |
892 // Set the attribute to a TCoordinate initialised to NaN. |
987 // Set the attribute to a TCoordinate initialised to NaN. |
893 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLocation, TCoordinate()); |
988 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLocation, TCoordinate()); |
894 } |
989 } |
895 else |
990 else |
896 { |
991 { |
|
992 DeleteImageViewerInstance(); |
897 User::Leave(KErrNotSupported); |
993 User::Leave(KErrNotSupported); |
898 } |
994 } |
899 } |
995 } |
900 |
996 |
901 HandleGarbageCollectionL(EFalse); |
997 HandleGarbageCollectionL(EFalse); |
902 CleanupStack::PopAndDestroy(path); |
998 CleanupStack::PopAndDestroy(path); |
903 iRequestOwner = list; |
999 iRequestOwner = list; |
904 CleanupStack::PopAndDestroy(attrSpecs); |
1000 CleanupStack::PopAndDestroy(attrSpecs); |
905 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]); |
1001 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]); |
906 HandleCollectionMediaL(spaceId, *iMPXMedia, KErrNone); |
1002 HandleCollectionMediaL(spaceId, *iMPXMedia, KErrNone); |
|
1003 DeleteImageViewerInstance(); |
907 return; |
1004 return; |
908 } |
1005 } |
909 else |
1006 else |
910 { |
1007 { |
911 // Issue the request |
1008 // Issue the request |
912 collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs); |
1009 collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs); |
913 } |
1010 } |
914 } |
1011 } |
915 #else // USE_S60_TNM |
1012 #else // USE_S60_TNM |
916 delete iTempThumbnail; |
1013 delete iTempThumbnail; |
917 iTempThumbnail = NULL; |
1014 iTempThumbnail = NULL; |
1425 FindLoadingById(aId, ETrue); |
1522 FindLoadingById(aId, ETrue); |
1426 } |
1523 } |
1427 } |
1524 } |
1428 #endif |
1525 #endif |
1429 |
1526 |
|
1527 // ----------------------------------------------------------------------------- |
|
1528 // GetMimeTypeL() |
|
1529 // ----------------------------------------------------------------------------- |
|
1530 // |
1430 void CGlxCacheManager::GetMimeTypeL(TFileName& aFileName, TDataType& aMimeType) |
1531 void CGlxCacheManager::GetMimeTypeL(TFileName& aFileName, TDataType& aMimeType) |
1431 { |
1532 { |
1432 TRACER("CGlxCacheManager::GetMimeTypeL"); |
1533 TRACER("CGlxCacheManager::GetMimeTypeL"); |
1433 |
|
1434 RApaLsSession session; |
1534 RApaLsSession session; |
1435 User::LeaveIfError( session.Connect() ); |
1535 User::LeaveIfError( session.Connect() ); |
1436 CleanupClosePushL( session ); |
1536 CleanupClosePushL( session ); |
1437 |
1537 |
1438 TUid uid; |
1538 TUid uid; |
1439 User::LeaveIfError( session.AppForDocument( aFileName, uid, aMimeType ) ); |
1539 User::LeaveIfError( session.AppForDocument( aFileName, uid, aMimeType ) ); |
1440 CleanupStack::PopAndDestroy(&session); |
1540 CleanupStack::PopAndDestroy(&session); |
1441 |
1541 } |
1442 } |
1542 |
1443 void CGlxCacheManager::ImageReadyL(const TInt& aError, const TSize aSz) |
1543 // ----------------------------------------------------------------------------- |
1444 { |
1544 // ImageSizeReady() |
1445 TRACER("CGlxCacheManager::ImageReadyL"); |
1545 // ----------------------------------------------------------------------------- |
1446 GLX_DEBUG2("CGlxCacheManager::ImageReadyL aError=%d", aError); |
1546 // |
|
1547 void CGlxCacheManager::ImageSizeReady(TInt aError, const TSize aSz) |
|
1548 { |
|
1549 TRACER("CGlxCacheManager::ImageSizeReady"); |
|
1550 GLX_DEBUG2("CGlxCacheManager::ImageSizeReady aError=%d", aError); |
1447 iImgSz = TSize(); |
1551 iImgSz = TSize(); |
1448 if(iSchedulerWait) |
1552 if(iSchedulerWait) |
1449 { |
1553 { |
1450 iSchedulerWait->AsyncStop(); |
1554 iSchedulerWait->AsyncStop(); |
1451 } |
1555 } |
1452 User::LeaveIfError( aError ); |
1556 |
1453 iImgSz = aSz; |
1557 iImgSz = aSz; |
1454 } |
1558 GLX_DEBUG3("CGlxCacheManager::ImageSizeReady() iImgSz w(%d) h(%d)", |
|
1559 iImgSz.iWidth, iImgSz.iHeight); |
|
1560 } |
|
1561 |
|
1562 // ----------------------------------------------------------------------------- |
|
1563 // CreateImageViewerInstanceL |
|
1564 // ----------------------------------------------------------------------------- |
|
1565 // |
|
1566 void CGlxCacheManager::CreateImageViewerInstanceL() |
|
1567 { |
|
1568 TRACER("CGlxCacheManager::CreateImageViewerInstanceL"); |
|
1569 if ( iImageViewerInstance == NULL ) |
|
1570 { |
|
1571 iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
|
1572 } |
|
1573 __ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer)); |
|
1574 } |
|
1575 |
|
1576 // ----------------------------------------------------------------------------- |
|
1577 // DeleteImageViewerInstance |
|
1578 // ----------------------------------------------------------------------------- |
|
1579 // |
|
1580 void CGlxCacheManager::DeleteImageViewerInstance() |
|
1581 { |
|
1582 TRACER("CGlxCacheManager::DeleteImageViewerInstance"); |
|
1583 if ( iImageViewerInstance != NULL ) |
|
1584 { |
|
1585 iImageViewerInstance->DeleteInstance(); |
|
1586 } |
|
1587 } |
|
1588 |
|
1589 //End of file |