photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerupload.cpp
branchRCL_3
changeset 18 bcb43dc84c44
parent 2 7d9067c6fcb1
child 22 2dac0fdba72b
equal deleted inserted replaced
14:ce1c7ad1f18b 18:bcb43dc84c44
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 //  CLASS HEADER
    18 //  CLASS HEADER
    19 #include "glxcommandhandlerupload.h"
    19 #include "glxcommandhandlerupload.h"
       
    20 #include "glxuploadcenrepwatcher.h"
       
    21 #include <mglxmedialist.h>
    20 
    22 
    21 //  EXTERNAL INCLUDES
    23 //  EXTERNAL INCLUDES
    22 #include <AiwGenericParam.h>                // for passing data between applications
    24 #include <AiwGenericParam.h>                // for passing data between applications
    23 #include <aknbutton.h>                      // for getting the button state
    25 #include <aknbutton.h>                      // for getting the button state
    24 #include <akntoolbar.h>                     // for accessing currently active toolbar
    26 #include <akntoolbar.h>                     // for accessing currently active toolbar
    25 #include <centralrepository.h>              // for checking the ShareOnline version
       
    26 #include <data_caging_path_literals.hrh> 	// for directory and file names
    27 #include <data_caging_path_literals.hrh> 	// for directory and file names
    27 #include <utf.h>							// for CnvUtfConverter
    28 #include <utf.h>							// for CnvUtfConverter
    28 
    29 
    29 
    30 
    30 //  INTERNAL INCLUDES
    31 //  INTERNAL INCLUDES
    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 // ----------------------------------------------------------------------------
    98 	        CheckVersionL();
   111 	        CheckVersionL();
    99 	        InitializeOneClickUploadL();
   112 	        InitializeOneClickUploadL();
   100 	        iUploadSupported = ETrue;
   113 	        iUploadSupported = ETrue;
   101 	        } );
   114 	        } );
   102 	
   115 	
   103 	
   116 	iSelectedImageCount = 0;
       
   117 	iSelectedVideoCount = 0;
       
   118 	iCurrentCenRepMonitor = EMonitorNone;
       
   119 	iTnmRequestID = KErrNotFound;
       
   120 	
       
   121     //Check for fullscreen here since we dont get the activate call in FS.
       
   122     if(IsFullScreenViewL())
       
   123         {
       
   124         //Giving the viewid as zero, since its not used anywhere.
       
   125         iToolbar = iAvkonAppUi->CurrentFixedToolbar();        
       
   126         ActivateL(0);
       
   127         UpdateFSUploadIconL();
       
   128         }
       
   129     
   104 	// Add the upload command
   130 	// Add the upload command
   105    	TCommandInfo info(EGlxCmdUpload);
   131    	TCommandInfo info(EGlxCmdUpload);
   106    	AddCommandL(info);	
   132    	AddCommandL(info);	
   107 	}	
   133 	}	
   108 	
   134 	
   110 // Destructor
   136 // Destructor
   111 // ----------------------------------------------------------------------------
   137 // ----------------------------------------------------------------------------
   112 EXPORT_C CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload()
   138 EXPORT_C CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload()
   113 	{
   139 	{
   114 	TRACER("CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload");
   140 	TRACER("CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload");
       
   141 	delete iTnEngine;
   115 	
   142 	
   116 	if (iUiUtility)
   143 	if (iUiUtility)
   117         {
   144         {
   118         iUiUtility->Close();
   145         iUiUtility->Close();
   119         }
   146         }
   120 	delete iServiceHandler;
   147 	delete iServiceHandler;
       
   148 	delete iUploadCenRepWatcher;	
   121 	}
   149 	}
   122 	
   150 	
   123 // InitializeAIWForShareOnlineL
   151 // InitializeAIWForShareOnlineL
   124 // ----------------------------------------------------------------------------
   152 // ----------------------------------------------------------------------------
   125 //
   153 //
   128     TRACER("CGlxCommandHandlerUpload::InitializeOneClickUploadL");
   156     TRACER("CGlxCommandHandlerUpload::InitializeOneClickUploadL");
   129     
   157     
   130     iServiceHandler = CAiwServiceHandler::NewL();
   158     iServiceHandler = CAiwServiceHandler::NewL();
   131 
   159 
   132     // Attach the AIW Resource defined in uiutilities.rss
   160     // Attach the AIW Resource defined in uiutilities.rss
   133     iServiceHandler->AttachL( R_AIW_SHARE_BASE_INTEREST );
   161     iServiceHandler->AttachL( R_GLX_AIW_SHARE_BASE_INTEREST );
   134     }
   162     }
   135 
   163 
   136 // Check Share Online version
   164 // Check Share Online version
   137 // ---------------------------------------------------------------------------
   165 // ---------------------------------------------------------------------------
   138 //
   166 //
   209 	// handle the upload command
   237 	// handle the upload command
   210 	if (iUploadSupported && ( EGlxCmdUpload == aCommandId ))
   238 	if (iUploadSupported && ( EGlxCmdUpload == aCommandId ))
   211 	    { 
   239 	    { 
   212 
   240 
   213 	    CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
   241 	    CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
       
   242 	    inputParams.Reset();
   214 	    
   243 	    
   215 	    TAiwVariant variant( KOpenModeOneClick ); //For one click photo upload
   244 	    TAiwVariant variant( KOpenModeOneClick ); //For one click photo upload
   216 	    TAiwGenericParam param( EGenericParamModeActivation, variant );
   245 	    TAiwGenericParam param( EGenericParamModeActivation, variant );
   217 	    inputParams.AppendL( param );
   246 	    inputParams.AppendL( param );
   218 
   247 
   232 // DoActivateL
   261 // DoActivateL
   233 // ----------------------------------------------------------------------------
   262 // ----------------------------------------------------------------------------
   234 void CGlxCommandHandlerUpload::DoActivateL(TInt aViewId)
   263 void CGlxCommandHandlerUpload::DoActivateL(TInt aViewId)
   235 	{
   264 	{
   236 	TRACER("CGlxCommandHandlerUpload::DoActivateL");
   265 	TRACER("CGlxCommandHandlerUpload::DoActivateL");
   237     iViewId = aViewId;   
   266     iViewId = aViewId;  
   238     
   267 
       
   268     // get media list from provider and add observer
       
   269 
       
   270     MediaList().AddMediaListObserverL( this );
       
   271     
       
   272     //Get the grid toolbar here as it wont be created yet in
       
   273     //constructor
       
   274     if(!IsFullScreenViewL())
       
   275         {    
       
   276         iToolbar = iUiUtility->GetGridToolBar();        
       
   277         }
   239 	}
   278 	}
   240 	
   279 	
   241 // ----------------------------------------------------------------------------
   280 // ----------------------------------------------------------------------------
   242 // Deactivate
   281 // Deactivate
   243 // ----------------------------------------------------------------------------
   282 // ----------------------------------------------------------------------------
   244 void CGlxCommandHandlerUpload::Deactivate()
   283 void CGlxCommandHandlerUpload::Deactivate()
   245     {
   284     {
   246     TRACER("CGlxCommandHandlerUpload::Deactivate");
   285     TRACER("CGlxCommandHandlerUpload::Deactivate");
   247     
   286 	
       
   287 	//Remove the Medialist observer
       
   288     MediaList().RemoveMediaListObserver( this );
       
   289 
       
   290 	//Reset the tracking variables here    
       
   291     iSelectedImageCount = 0;
       
   292     iSelectedVideoCount = 0;
       
   293     iCurrentCenRepMonitor = EMonitorNone;
   248     }	
   294     }	
   249 
   295 
   250 // ----------------------------------------------------------------------------
   296 // ----------------------------------------------------------------------------
   251 // AppendSelectedFilesL()
   297 // AppendSelectedFilesL()
   252 // ----------------------------------------------------------------------------
   298 // ----------------------------------------------------------------------------
   317 // ----------------------------------------------------------------------------
   363 // ----------------------------------------------------------------------------
   318 //
   364 //
   319 void CGlxCommandHandlerUpload::PopulateToolbarL()
   365 void CGlxCommandHandlerUpload::PopulateToolbarL()
   320 	{
   366 	{
   321 	TRACER( "CGlxCommandHandlerUpload::PopulateToolbarL" );
   367 	TRACER( "CGlxCommandHandlerUpload::PopulateToolbarL" );
   322 		   
   368     
       
   369 	//When the Upload is not supported or if we are in grid view
       
   370 	//and none of the item is selected Dim the Upload icon
       
   371 	if(!iUploadSupported || (!IsFullScreenViewL() && 
       
   372                                    (MediaList().SelectionCount()== 0)))
       
   373         {        
       
   374         DisableUploadToolbarItem(ETrue);
       
   375         }
       
   376     
   323 	if( iUploadSupported )
   377 	if( iUploadSupported )
   324 	    {
   378 	    {
   325 	    SetToolTipL();
   379 	    SetToolTipL();
   326 	    } 
   380 	    } 
   327 	}
   381 	}
   333 void CGlxCommandHandlerUpload::GetToolTipL( HBufC*& aToolTipText )
   387 void CGlxCommandHandlerUpload::GetToolTipL( HBufC*& aToolTipText )
   334     {
   388     {
   335     TRACER("CGlxCommandHandlerUpload::GetToolTipL");
   389     TRACER("CGlxCommandHandlerUpload::GetToolTipL");
   336     
   390     
   337     CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
   391     CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
       
   392     inputParams.Reset();
   338     
   393     
   339     // Insert Command parameter that tells provider that tooltip is required        
   394     // Insert Command parameter that tells provider that tooltip is required        
   340     TAiwVariant variant(KCmdGetOneClickToolTip);
   395     TAiwVariant variant(KCmdGetOneClickToolTip);
   341     TAiwGenericParam param(EGenericParamModeActivation, variant);
   396     TAiwGenericParam param(EGenericParamModeActivation, variant);
   342     inputParams.AppendL(param);
   397     inputParams.AppendL(param);
   343     
   398     
   344     //Get a reference to output parameter list
   399     //Get a reference to output parameter list
   345     CAiwGenericParamList& outputParams = iServiceHandler->OutParamListL();
   400     CAiwGenericParamList& outputParams = iServiceHandler->OutParamListL();
       
   401     outputParams.Reset();
       
   402     
   346     iServiceHandler->ExecuteServiceCmdL(KAiwCmdUpload, inputParams, outputParams);
   403     iServiceHandler->ExecuteServiceCmdL(KAiwCmdUpload, inputParams, outputParams);
   347     
   404     
   348     //Tooltip is returned as a parameter in output list
   405     //Tooltip is returned as a parameter in output list
   349     for( TInt i = 0 ; i < outputParams.Count(); i++ )
   406     for( TInt i = 0 ; i < outputParams.Count(); i++ )
   350         {
   407         {
   364 //
   421 //
   365 void CGlxCommandHandlerUpload::SetToolTipL()
   422 void CGlxCommandHandlerUpload::SetToolTipL()
   366     {
   423     {
   367     TRACER("CGlxCommandHandlerUpload::SetToolTipL");
   424     TRACER("CGlxCommandHandlerUpload::SetToolTipL");
   368 
   425 
   369     CAknToolbar* toolbar = iAvkonAppUi->CurrentFixedToolbar();
   426     if (!iToolbar)
   370     if (!toolbar)
       
   371         {
   427         {
   372         return;
   428         return;
   373         }
   429         }
   374 
   430 
   375     CAknButton* uploadButton =
   431     CAknButton* uploadButton =
   376             static_cast<CAknButton*> (toolbar->ControlOrNull(EGlxCmdUpload));
   432             static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
   377 
   433 
   378     if (uploadButton && iUploadSupported)
   434     if (uploadButton && iUploadSupported)
   379         {
   435         {
   380         // Get the tooltip text from AIW ShareOnline application
   436         // Get the tooltip text from AIW ShareOnline application
   381         HBufC* toolTipText = NULL;
   437         HBufC* toolTipText = NULL;
   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