34 #include <glxfetchcontextremover.h> // for TGlxFetchContextRemover |
35 #include <glxfetchcontextremover.h> // for TGlxFetchContextRemover |
35 #include <glxtracer.h> // for TRACER logs |
36 #include <glxtracer.h> // for TRACER logs |
36 #include <glxuiutilities.rsg> // for Share AIW interest resource |
37 #include <glxuiutilities.rsg> // for Share AIW interest resource |
37 #include <mglxmedialist.h> // for accessing the media items |
38 #include <mglxmedialist.h> // for accessing the media items |
38 |
39 |
|
40 #include <glxnavigationalstate.h> |
|
41 #include <glxcollectionpluginimageviewer.hrh> |
|
42 |
|
43 #include <thumbnaildata.h> |
|
44 #include <gulicon.h> |
|
45 |
39 // CONSTANTS AND DEFINITIONS |
46 // CONSTANTS AND DEFINITIONS |
40 namespace |
47 namespace |
41 { |
48 { |
42 // ShareOnline application UID |
49 // ShareOnline application UID |
43 const TUid KShareOnlineUid = { 0x2000BB53 }; |
50 const TUid KShareOnlineUid = { 0x2002CC1F }; |
44 // Shareonline Application version |
51 // Shareonline Application version |
45 const TUint32 KShareApplicationVersion = 0x01010020; |
52 const TUint32 KShareApplicationVersion = 0x1010020; |
46 // Buffer to maintain the ShareOnline version number in use |
53 // Buffer to maintain the ShareOnline version number in use |
47 const TInt KPhotosShareOnlineVersionBufLen = 12; |
54 const TInt KPhotosShareOnlineVersionBufLen = 12; |
48 // Minimum version required for OneClickUpload to work |
55 // Minimum version required for OneClickUpload to work |
49 const TVersion KShareOnlineMinimumVersion( 4, 3, 0 ); |
56 const TVersion KShareOnlineMinimumVersion( 5, 0, 0 ); |
50 // OneClickUpload command |
57 // OneClickUpload command |
51 const TUid KOpenModeOneClick = { 2 }; |
58 const TUid KOpenModeOneClick = { 2 }; |
52 // Command to request for the tooltip |
59 // Command to request for the tooltip |
53 const TUid KCmdGetOneClickToolTip = { 15 }; |
60 const TUid KCmdGetOneClickToolTip = { 15 }; |
|
61 // OneClickUpload default image icon |
|
62 const TUint32 KUploadImageServiceIconFileName = 0x00000002; |
|
63 // OneClickUpload default video icon |
|
64 const TUint32 KUploadVideoServiceIconFileName = 0x00000003; |
|
65 // OneClickUpload default video and image icon |
|
66 const TUint32 KUploadImageAndVideoServiceIconFileName = 0x00000004; |
54 } |
67 } |
55 |
68 |
56 // ---------------------------------------------------------------------------- |
69 // ---------------------------------------------------------------------------- |
57 // Two-phased constructor. |
70 // Two-phased constructor. |
58 // ---------------------------------------------------------------------------- |
71 // ---------------------------------------------------------------------------- |
407 User::Leave(KErrArgument); |
463 User::Leave(KErrArgument); |
408 } |
464 } |
409 } // if(uploadButton && iUploadSupported) |
465 } // if(uploadButton && iUploadSupported) |
410 } |
466 } |
411 |
467 |
|
468 |
|
469 // ---------------------------------------------------------------------------- |
|
470 // HandleItemAddedL |
|
471 // ---------------------------------------------------------------------------- |
|
472 // |
|
473 void CGlxCommandHandlerUpload::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
474 MGlxMediaList* /*aList*/) |
|
475 { |
|
476 |
|
477 } |
|
478 |
|
479 |
|
480 // ---------------------------------------------------------------------------- |
|
481 // HandleMediaL |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 void CGlxCommandHandlerUpload::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
485 { |
|
486 |
|
487 } |
|
488 |
|
489 |
|
490 // ---------------------------------------------------------------------------- |
|
491 // HandleItemRemovedL |
|
492 // ---------------------------------------------------------------------------- |
|
493 // |
|
494 void CGlxCommandHandlerUpload::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
495 MGlxMediaList* /*aList*/) |
|
496 { |
|
497 |
|
498 } |
|
499 |
|
500 |
|
501 // ---------------------------------------------------------------------------- |
|
502 // HandleItemModifiedL |
|
503 // ---------------------------------------------------------------------------- |
|
504 // |
|
505 void CGlxCommandHandlerUpload::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
506 MGlxMediaList* /*aList*/) |
|
507 { |
|
508 |
|
509 } |
|
510 |
|
511 |
|
512 // ---------------------------------------------------------------------------- |
|
513 // HandleAttributesAvailableL |
|
514 // ---------------------------------------------------------------------------- |
|
515 // |
|
516 void CGlxCommandHandlerUpload::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
|
517 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
|
518 { |
|
519 TRACER("CGlxCommandHandlerUpload::HandleAttributesAvailableL"); |
|
520 } |
|
521 |
|
522 |
|
523 // ---------------------------------------------------------------------------- |
|
524 // HandleFocusChangedL |
|
525 // ---------------------------------------------------------------------------- |
|
526 // |
|
527 void CGlxCommandHandlerUpload::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
|
528 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
|
529 { |
|
530 TRACER("CGlxCommandHandlerUpload::HandleFocusChangedL"); |
|
531 //In Fullscreen change the icons based on current focused icon |
|
532 if(iUploadSupported && IsFullScreenViewL()) |
|
533 { |
|
534 UpdateFSUploadIconL(); |
|
535 } |
|
536 } |
|
537 |
|
538 |
|
539 // ---------------------------------------------------------------------------- |
|
540 // HandleItemSelectedL |
|
541 // ---------------------------------------------------------------------------- |
|
542 // |
|
543 void CGlxCommandHandlerUpload::HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList) |
|
544 { |
|
545 TRACER("CGlxCommandHandlerUpload::HandleItemSelectedL"); |
|
546 //In grid if an item is selected update the toolbar icon based on |
|
547 //the mime types of items |
|
548 if(iUploadSupported && !IsFullScreenViewL()) |
|
549 { |
|
550 if(aList->SelectionCount() >= 1 ) |
|
551 { |
|
552 TFileName uploadIconFileName; |
|
553 UpdateSelectionCount(aIndex, aSelected, aList); |
|
554 GetIconNameL(uploadIconFileName); |
|
555 if(uploadIconFileName.Length()) |
|
556 { |
|
557 DecodeIconL(uploadIconFileName); |
|
558 } |
|
559 DisableUploadToolbarItem(EFalse); |
|
560 } |
|
561 else |
|
562 { |
|
563 iSelectedImageCount = 0; |
|
564 iSelectedVideoCount = 0; |
|
565 iCurrentCenRepMonitor = EMonitorNone; |
|
566 delete iUploadCenRepWatcher; |
|
567 iUploadCenRepWatcher = NULL; |
|
568 DisableUploadToolbarItem(ETrue); |
|
569 } |
|
570 } |
|
571 } |
|
572 |
|
573 |
|
574 // ---------------------------------------------------------------------------- |
|
575 // HandleMessageL |
|
576 // ---------------------------------------------------------------------------- |
|
577 // |
|
578 void CGlxCommandHandlerUpload::HandleMessageL(const CMPXMessage& /*aMessage*/, MGlxMediaList* /*aList*/) |
|
579 { |
|
580 |
|
581 } |
|
582 |
|
583 |
|
584 // ---------------------------------------------------------------------------- |
|
585 // HandlePopulatedL |
|
586 // ---------------------------------------------------------------------------- |
|
587 // |
|
588 void CGlxCommandHandlerUpload::HandlePopulatedL(MGlxMediaList* aList) |
|
589 { |
|
590 if(aList && aList->Count() > 0) |
|
591 { |
|
592 if(!iUploadSupported || !IsFullScreenViewL()) |
|
593 { |
|
594 DisableUploadToolbarItem(ETrue); |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 //---------------------------------------------------------------------------- |
|
600 // Check for current view mode .Grid/fullscreen/imgviewer |
|
601 //---------------------------------------------------------------------------- |
|
602 // |
|
603 TBool CGlxCommandHandlerUpload::IsFullScreenViewL() |
|
604 { |
|
605 TRACER("CGlxCommandHandlerUpload::IsFullScreenViewL"); |
|
606 TBool fullscreenViewingMode = EFalse; |
|
607 |
|
608 CGlxNavigationalState* navigationalState = CGlxNavigationalState::InstanceL(); |
|
609 CleanupClosePushL( *navigationalState ); |
|
610 CMPXCollectionPath* naviState = navigationalState->StateLC(); |
|
611 |
|
612 if ( naviState->Levels() >= 1) |
|
613 { |
|
614 if (navigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
|
615 { |
|
616 // For image viewer collection, goto view mode |
|
617 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
|
618 { |
|
619 // current view mode is img vwr |
|
620 fullscreenViewingMode = ETrue; |
|
621 } |
|
622 else |
|
623 { |
|
624 //current view mode is Grid |
|
625 fullscreenViewingMode = EFalse; |
|
626 } |
|
627 } |
|
628 else |
|
629 { |
|
630 //current view mode is Fullscreen |
|
631 fullscreenViewingMode = ETrue; |
|
632 } |
|
633 } |
|
634 CleanupStack::PopAndDestroy( naviState ); |
|
635 CleanupStack::PopAndDestroy( navigationalState ); |
|
636 return fullscreenViewingMode; |
|
637 } |
|
638 |
|
639 // ---------------------------------------------------------------------------- |
|
640 // DisableUploadToolbarItem |
|
641 // ---------------------------------------------------------------------------- |
|
642 // |
|
643 void CGlxCommandHandlerUpload::DisableUploadToolbarItem(TBool aDimmed) |
|
644 { |
|
645 TRACER("CGlxCommandHandlerUpload::DisableUploadToolbarItem"); |
|
646 |
|
647 if(iToolbar) |
|
648 { |
|
649 iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue); |
|
650 //DrawNow must be called since SetDimmed does not redraw the toolbar |
|
651 iToolbar->DrawNow(); |
|
652 } |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // CGlxCommandHandlerUpload::ThumbnailPreviewReady() |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 void CGlxCommandHandlerUpload::ThumbnailPreviewReady(MThumbnailData& /*aThumbnail*/, |
|
660 TThumbnailRequestId /*aId*/) |
|
661 { |
|
662 TRACER("CGlxCommandHandlerUpload::ThumbnailPreviewReady"); |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CGlxCommandHandlerUpload::ThumbnailReady() |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 void CGlxCommandHandlerUpload::ThumbnailReady(TInt aError, |
|
670 MThumbnailData& aThumbnail, TThumbnailRequestId /*aId*/) |
|
671 { |
|
672 TRACER("CGlxCommandHandlerUpload::ThumbnailReady"); |
|
673 |
|
674 if(aError == KErrNone) |
|
675 { |
|
676 TRAP_IGNORE(SetDecodedUploadIconL(aThumbnail)); |
|
677 } |
|
678 } |
|
679 |
|
680 // ----------------------------------------------------------------------------- |
|
681 // CGlxCommandHandlerUpload::SetDecodedUploadIconL() |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 void CGlxCommandHandlerUpload::SetDecodedUploadIconL(MThumbnailData& aThumbnail) |
|
685 { |
|
686 CAknButton* uploadButton = |
|
687 static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload)); |
|
688 |
|
689 if(uploadButton) |
|
690 { |
|
691 CAknButtonState* currentState = uploadButton->State(); |
|
692 CFbsBitmap* normalBmp = aThumbnail.DetachBitmap(); |
|
693 CFbsBitmap* pressedBmp = new (ELeave) CFbsBitmap; |
|
694 pressedBmp->Duplicate(normalBmp->Handle()); |
|
695 //Ownership of the icon is transferred here |
|
696 currentState->SetIcon(CGulIcon::NewL(normalBmp)); |
|
697 currentState->SetPressedIcon(CGulIcon::NewL(pressedBmp)); |
|
698 iToolbar->DrawNow(); |
|
699 } |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // CGlxCommandHandlerUpload::UpdateSelectionCount() |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 void CGlxCommandHandlerUpload::UpdateSelectionCount(TInt aIndex, TBool aSelected, MGlxMediaList* aList) |
|
707 { |
|
708 TRACER("CGlxCommandHandlerUpload::UpdateSelectionCount"); |
|
709 if(!aList) |
|
710 { |
|
711 return; |
|
712 } |
|
713 |
|
714 TGlxMedia media = aList->Item(aIndex); |
|
715 |
|
716 switch(media.Category()) |
|
717 { |
|
718 case EMPXImage: |
|
719 aSelected?iSelectedImageCount++:iSelectedImageCount--; |
|
720 break; |
|
721 case EMPXVideo: |
|
722 aSelected?iSelectedVideoCount++:iSelectedVideoCount--; |
|
723 break; |
|
724 default: |
|
725 break; |
|
726 } |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CGlxCommandHandlerUpload::GetIconNameL() |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 void CGlxCommandHandlerUpload::GetIconNameL(TDes& aUplaodIconNmae) |
|
734 { |
|
735 TRACER("CGlxCommandHandlerUpload::GetIconNameL"); |
|
736 TUint32 serviceIconId = KErrNone; |
|
737 |
|
738 if(iSelectedImageCount && iSelectedVideoCount) |
|
739 { |
|
740 if(iCurrentCenRepMonitor != EImageVideoMonitor) |
|
741 { |
|
742 serviceIconId = KUploadImageAndVideoServiceIconFileName; |
|
743 iCurrentCenRepMonitor = EImageVideoMonitor; |
|
744 } |
|
745 } |
|
746 else if(iSelectedImageCount) |
|
747 { |
|
748 if(iCurrentCenRepMonitor != EImageMonitor) |
|
749 { |
|
750 serviceIconId = KUploadImageServiceIconFileName; |
|
751 iCurrentCenRepMonitor = EImageMonitor; |
|
752 } |
|
753 } |
|
754 else if(iSelectedVideoCount) |
|
755 { |
|
756 if(iCurrentCenRepMonitor != EVideoMonitor) |
|
757 { |
|
758 serviceIconId = KUploadVideoServiceIconFileName; |
|
759 iCurrentCenRepMonitor = EVideoMonitor; |
|
760 } |
|
761 } |
|
762 |
|
763 if(serviceIconId != KErrNone) |
|
764 { |
|
765 delete iUploadCenRepWatcher; |
|
766 iUploadCenRepWatcher = NULL; |
|
767 |
|
768 iUploadCenRepWatcher = CGlxUploadCenRepWatcher::NewL(*this, KShareOnlineUid, |
|
769 serviceIconId ); |
|
770 iUploadCenRepWatcher->KeyValueL(aUplaodIconNmae); |
|
771 } |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CGlxCommandHandlerUpload::DecodeIconL() |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 void CGlxCommandHandlerUpload::DecodeIconL(const TDes& aUplaodIconNmae) |
|
779 { |
|
780 TRACER("CGlxCommandHandlerUpload::DecodeIconL"); |
|
781 |
|
782 if(!iTnEngine) |
|
783 { |
|
784 iTnEngine = CThumbnailManager::NewL( *this); |
|
785 iTnEngine->SetDisplayModeL( EColor16M ); |
|
786 } |
|
787 |
|
788 if(iTnmRequestID != KErrNotFound) |
|
789 { |
|
790 //Cancel any outstanding request |
|
791 iTnEngine->CancelRequest(iTnmRequestID); |
|
792 } |
|
793 |
|
794 iTnEngine->SetFlagsL(CThumbnailManager::EDefaultFlags); |
|
795 |
|
796 CAknButton* uploadButton = |
|
797 static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload)); |
|
798 if(uploadButton) |
|
799 { |
|
800 CAknButtonState* currentState = uploadButton->State(); |
|
801 const CGulIcon *icon = currentState->Icon(); |
|
802 iTnEngine->SetThumbnailSizeL(icon->Bitmap()->SizeInPixels()); |
|
803 iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQuality); |
|
804 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(aUplaodIconNmae, 0); |
|
805 iTnmRequestID = iTnEngine->GetThumbnailL(*source); |
|
806 CleanupStack::PopAndDestroy(source); |
|
807 } |
|
808 } |
|
809 |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CGlxCommandHandlerUpload::UpdateFSUploadIconL() |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 void CGlxCommandHandlerUpload::UpdateFSUploadIconL() |
|
816 { |
|
817 if(!iUploadSupported) |
|
818 { |
|
819 return; |
|
820 } |
|
821 |
|
822 // get the media list reference |
|
823 MGlxMediaList& mediaList = MediaList(); |
|
824 if(mediaList.Count() ) |
|
825 { |
|
826 TGlxMedia media = mediaList.Item(mediaList.FocusIndex()); |
|
827 iSelectedImageCount = 0; |
|
828 iSelectedVideoCount = 0; |
|
829 if(media.Category() == EMPXImage) |
|
830 { |
|
831 iSelectedImageCount++; |
|
832 } |
|
833 else if(media.Category() == EMPXVideo) |
|
834 { |
|
835 iSelectedVideoCount++; |
|
836 } |
|
837 |
|
838 if(iSelectedImageCount || iSelectedVideoCount) |
|
839 { |
|
840 TFileName uploadIconFileName; |
|
841 GetIconNameL(uploadIconFileName); |
|
842 |
|
843 if(uploadIconFileName.Length()) |
|
844 { |
|
845 DecodeIconL(uploadIconFileName); |
|
846 } |
|
847 } |
|
848 } |
|
849 } |
|
850 |
|
851 //----------------------------------------------------------------------------- |
|
852 // From class MGlxUploadIconObserver. |
|
853 // Called when upload icon changes |
|
854 //----------------------------------------------------------------------------- |
|
855 // |
|
856 void CGlxCommandHandlerUpload::HandleUploadIconChangedL( ) |
|
857 { |
|
858 TRACER("CGlxCommandHandlerUpload::HandleUploadIconChangedL"); |
|
859 if(iUploadSupported && iUploadCenRepWatcher) |
|
860 { |
|
861 TFileName uploadIconFileName; |
|
862 iUploadCenRepWatcher->KeyValueL(uploadIconFileName); |
|
863 if(uploadIconFileName.Length()) |
|
864 { |
|
865 DecodeIconL(uploadIconFileName); |
|
866 } |
|
867 } |
|
868 } |
412 // End of file |
869 // End of file |
413 |
870 |