photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerupload.cpp
branchRCL_3
changeset 47 f9e827349359
parent 22 2dac0fdba72b
equal deleted inserted replaced
35:420f6808bf21 47:f9e827349359
    13 *
    13 *
    14 * Description:    Upload commmand handler
    14 * Description:    Upload commmand handler
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include <eikenv.h>
       
    19 #include <SvgCodecImageConstants.hrh>
       
    20 #include <SVGEngineInterfaceImpl.h>
       
    21 
    18 //  CLASS HEADER
    22 //  CLASS HEADER
    19 #include "glxcommandhandlerupload.h"
    23 #include "glxcommandhandlerupload.h"
    20 #include "glxuploadcenrepwatcher.h"
    24 #include "glxuploadcenrepwatcher.h"
    21 #include <mglxmedialist.h>
    25 #include <mglxmedialist.h>
    22 
    26 
    32 #include <glxattributecontext.h>			// for  creating medialist context
    36 #include <glxattributecontext.h>			// for  creating medialist context
    33 #include <glxattributeretriever.h>			// for retrieving the attributes
    37 #include <glxattributeretriever.h>			// for retrieving the attributes
    34 #include <glxcommandhandlers.hrh>			// for EGlxCmdUpload
    38 #include <glxcommandhandlers.hrh>			// for EGlxCmdUpload
    35 #include <glxfetchcontextremover.h>         // for TGlxFetchContextRemover
    39 #include <glxfetchcontextremover.h>         // for TGlxFetchContextRemover
    36 #include <glxtracer.h>                      // for TRACER logs
    40 #include <glxtracer.h>                      // for TRACER logs
       
    41 #include <glxlog.h>                         // for GLX logs
    37 #include <glxuiutilities.rsg>               // for Share AIW interest resource
    42 #include <glxuiutilities.rsg>               // for Share AIW interest resource
    38 #include <mglxmedialist.h>                  // for accessing the media items
    43 #include <mglxmedialist.h>                  // for accessing the media items
    39 
    44 
    40 #include <glxnavigationalstate.h>
    45 #include <glxnavigationalstate.h>
    41 #include <glxcollectionpluginimageviewer.hrh>
    46 #include <glxcollectionpluginimageviewer.hrh>
    42 
       
    43 #include <thumbnaildata.h>
       
    44 #include <gulicon.h>
    47 #include <gulicon.h>
    45 
    48 
    46 // CONSTANTS AND DEFINITIONS
    49 // CONSTANTS AND DEFINITIONS
    47 namespace
    50 namespace
    48     {
    51     {
   114 	        } );
   117 	        } );
   115 	
   118 	
   116 	iSelectedImageCount = 0;
   119 	iSelectedImageCount = 0;
   117 	iSelectedVideoCount = 0;
   120 	iSelectedVideoCount = 0;
   118 	iCurrentCenRepMonitor = EMonitorNone;
   121 	iCurrentCenRepMonitor = EMonitorNone;
   119 	iTnmRequestID = KErrNotFound;
       
   120 	
   122 	
   121 	iIsFullScreenView = IsFullScreenViewL();
   123 	iIsFullScreenView = IsFullScreenViewL();
   122 	
   124 	
   123     //Check for fullscreen here since we dont get the activate call in FS.
   125     //Check for fullscreen here since we dont get the activate call in FS.
   124     if(iIsFullScreenView)
   126     if(iIsFullScreenView)
   138 // Destructor
   140 // Destructor
   139 // ----------------------------------------------------------------------------
   141 // ----------------------------------------------------------------------------
   140 EXPORT_C CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload()
   142 EXPORT_C CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload()
   141 	{
   143 	{
   142 	TRACER("CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload");
   144 	TRACER("CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload");
   143 	delete iTnEngine;
   145 	delete iSvgEngine;
   144 	
   146 	
   145 	if (iUiUtility)
   147 	if (iUiUtility)
   146         {
   148         {
   147         iUiUtility->Close();
   149         iUiUtility->Close();
   148         }
   150         }
   657         iToolbar->DrawNow();
   659         iToolbar->DrawNow();
   658         }
   660         }
   659     }
   661     }
   660 
   662 
   661 // -----------------------------------------------------------------------------
   663 // -----------------------------------------------------------------------------
   662 // CGlxCommandHandlerUpload::ThumbnailPreviewReady()
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 void CGlxCommandHandlerUpload::ThumbnailPreviewReady(MThumbnailData& /*aThumbnail*/,
       
   666         TThumbnailRequestId /*aId*/)
       
   667     {
       
   668     TRACER("CGlxCommandHandlerUpload::ThumbnailPreviewReady");
       
   669     }
       
   670 
       
   671 // -----------------------------------------------------------------------------
       
   672 // CGlxCommandHandlerUpload::ThumbnailReady()
       
   673 // -----------------------------------------------------------------------------
       
   674 //
       
   675 void CGlxCommandHandlerUpload::ThumbnailReady(TInt aError,
       
   676         MThumbnailData& aThumbnail, TThumbnailRequestId /*aId*/)
       
   677     {
       
   678     TRACER("CGlxCommandHandlerUpload::ThumbnailReady");
       
   679     
       
   680     if(aError == KErrNone)
       
   681         {
       
   682         TRAP_IGNORE(SetDecodedUploadIconL(aThumbnail));        
       
   683         }
       
   684     }
       
   685 
       
   686 // -----------------------------------------------------------------------------
       
   687 // CGlxCommandHandlerUpload::SetDecodedUploadIconL()
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 void CGlxCommandHandlerUpload::SetDecodedUploadIconL(MThumbnailData& aThumbnail)
       
   691     {
       
   692     CAknButton* uploadButton =
       
   693             static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
       
   694 
       
   695 	if(uploadButton)
       
   696 		{
       
   697 	    CAknButtonState* currentState = uploadButton->State();    
       
   698 	    CFbsBitmap* normalBmp = aThumbnail.DetachBitmap();    
       
   699 	    CFbsBitmap* pressedBmp = new (ELeave) CFbsBitmap;
       
   700 	    pressedBmp->Duplicate(normalBmp->Handle());
       
   701 	    //Ownership of the icon is transferred here    
       
   702 	    currentState->SetIcon(CGulIcon::NewL(normalBmp));
       
   703 	    currentState->SetPressedIcon(CGulIcon::NewL(pressedBmp));
       
   704 	    iToolbar->DrawNow();
       
   705 	  	}
       
   706     }
       
   707 
       
   708 // -----------------------------------------------------------------------------
       
   709 // CGlxCommandHandlerUpload::UpdateSelectionCount()
   664 // CGlxCommandHandlerUpload::UpdateSelectionCount()
   710 // -----------------------------------------------------------------------------
   665 // -----------------------------------------------------------------------------
   711 //
   666 //
   712 void CGlxCommandHandlerUpload::UpdateSelectionCount(TInt aIndex, TBool aSelected, MGlxMediaList* aList)
   667 void CGlxCommandHandlerUpload::UpdateSelectionCount(TInt aIndex, TBool aSelected, MGlxMediaList* aList)
   713     {
   668     {
   779 
   734 
   780 // -----------------------------------------------------------------------------
   735 // -----------------------------------------------------------------------------
   781 // CGlxCommandHandlerUpload::DecodeIconL()
   736 // CGlxCommandHandlerUpload::DecodeIconL()
   782 // -----------------------------------------------------------------------------
   737 // -----------------------------------------------------------------------------
   783 //
   738 //
   784 void CGlxCommandHandlerUpload::DecodeIconL(const TDes& aUplaodIconNmae)
   739 void CGlxCommandHandlerUpload::DecodeIconL(const TDes& aUplaodIconName)
   785     {
   740     {
   786     TRACER("CGlxCommandHandlerUpload::DecodeIconL");
   741     TRACER("CGlxCommandHandlerUpload::DecodeIconL");
   787     
   742     GLX_LOG_URI("CGlxCommandHandlerUpload:: DecodeIconL(%S)", &aUplaodIconName);
   788     if(!iTnEngine)
   743 
   789         {
   744     if (!iToolbar)
   790         iTnEngine = CThumbnailManager::NewL( *this);
   745         {
   791         iTnEngine->SetDisplayModeL( EColor16M );
   746         return;
   792         }
   747         }
   793     
   748     
   794     if(iTnmRequestID != KErrNotFound)
       
   795         {
       
   796         //Cancel any outstanding request
       
   797         iTnEngine->CancelRequest(iTnmRequestID);
       
   798         }
       
   799                 
       
   800     iTnEngine->SetFlagsL(CThumbnailManager::EDefaultFlags);
       
   801 
       
   802     CAknButton* uploadButton =
   749     CAknButton* uploadButton =
   803                            static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
   750             static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
   804     if(uploadButton)
   751     if (uploadButton)
   805     	{
   752         {
   806 	    CAknButtonState* currentState = uploadButton->State();
   753         CAknButtonState* currentState = uploadButton->State();
   807 	    const CGulIcon *icon = currentState->Icon();    
   754         const CGulIcon *icon = currentState->Icon();
   808 	    iTnEngine->SetThumbnailSizeL(icon->Bitmap()->SizeInPixels());
   755 
   809 	    iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQuality);
   756         TSize size(icon->Bitmap()->SizeInPixels());
   810 	    CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(aUplaodIconNmae, 0);
   757         CFbsBitmap* frameBuffer = new (ELeave) CFbsBitmap;
   811 	    iTnmRequestID = iTnEngine->GetThumbnailL(*source);
   758         CleanupStack::PushL(frameBuffer);
   812 	    CleanupStack::PopAndDestroy(source);
   759         TDisplayMode dispMode =
   813 	    }
   760                 CEikonEnv::Static()->ScreenDevice()->DisplayMode();
       
   761 
       
   762         TFontSpec spec;
       
   763         if (!iSvgEngine)
       
   764             {
       
   765             iSvgEngine = CSvgEngineInterfaceImpl::NewL(frameBuffer, NULL,
       
   766                     spec);
       
   767             }
       
   768 
       
   769         TInt domHandle = KErrNotFound;
       
   770         MSvgError* serr = iSvgEngine->PrepareDom(aUplaodIconName, domHandle);
       
   771         GLX_LOG_INFO3("CGlxCommandHandlerUpload::DecodeIconL prepare svg dom reader, warning:%d, err code:%d, description:[%S]", serr->IsWarning(), serr->ErrorCode(), &(serr->Description()));
       
   772         if (serr->HasError() && !serr->IsWarning())
       
   773             {
       
   774             GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL PrepareDom error:%d",
       
   775                     serr->SystemErrorCode());
       
   776             User::Leave(serr->SystemErrorCode());
       
   777             }
       
   778 
       
   779         // create image bitmap
       
   780         GLX_LOG_INFO("CGlxCommandHandlerUpload::DecodeIconL: Create bitmap for snapshot..");
       
   781 
       
   782         CFbsBitmap* decodedBitmap = new (ELeave) CFbsBitmap;
       
   783         CFbsBitmap* decodedMask = new (ELeave) CFbsBitmap;
       
   784         TRAPD ( createError,
       
   785                     {
       
   786                     decodedBitmap->Create( size, EColor64K );
       
   787                     decodedMask->Create( size, EGray256 );
       
   788                     });
       
   789         if (createError)
       
   790             {
       
   791             GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL Error while creating bitmaps:%d", createError );
       
   792             delete decodedBitmap;
       
   793             decodedBitmap = NULL;
       
   794             delete decodedMask;
       
   795             decodedMask = NULL;
       
   796             User::Leave(createError);
       
   797             }
       
   798 
       
   799         // create soft mask
       
   800         iSvgEngine->SetViewportHeight((CSvgDocumentImpl *) domHandle,
       
   801                 size.iHeight);
       
   802         iSvgEngine->SetViewportWidth((CSvgDocumentImpl *) domHandle,
       
   803                 size.iWidth);
       
   804 
       
   805         // render svg image
       
   806         serr = iSvgEngine->RenderDom(domHandle, decodedBitmap, decodedMask);
       
   807         GLX_LOG_INFO3("CGlxCommandHandlerUpload::DecodeIconL render svg dom reader, warning:%d, err code:%d, description:[%S]",
       
   808                 serr->IsWarning(), serr->ErrorCode(), &(serr->Description()));
       
   809         if (serr->HasError() && !serr->IsWarning())
       
   810             {
       
   811             GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL RenderDom error:%d",
       
   812                     serr->SystemErrorCode());
       
   813             User::Leave(serr->SystemErrorCode());
       
   814             }
       
   815 
       
   816         CleanupStack::PopAndDestroy(frameBuffer);
       
   817         iSvgEngine->DeleteDom(domHandle);
       
   818         iSvgEngine->Destroy();
       
   819 
       
   820         CFbsBitmap* pressedBitmap = new (ELeave) CFbsBitmap;
       
   821         CFbsBitmap* pressedMask = new (ELeave) CFbsBitmap;
       
   822         pressedBitmap->Duplicate(decodedBitmap->Handle());
       
   823         pressedMask->Duplicate(decodedMask->Handle());
       
   824 
       
   825         //Ownership of the icon is transferred here    
       
   826         currentState->SetIcon(CGulIcon::NewL(decodedBitmap, decodedMask));
       
   827         currentState->SetPressedIcon(CGulIcon::NewL(pressedBitmap,
       
   828                 pressedMask));
       
   829         iToolbar->DrawNow();
       
   830         }
   814     }
   831     }
   815 
   832 
   816 
   833 
   817 // -----------------------------------------------------------------------------
   834 // -----------------------------------------------------------------------------
   818 // CGlxCommandHandlerUpload::UpdateFSUploadIconL()
   835 // CGlxCommandHandlerUpload::UpdateFSUploadIconL()