photosgallery/controllers/fetcher/src/glxfetcherdialog.cpp
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Creates a Fetcher Dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  EXTERNAL INCLUDES
       
    21 #include <aknappui.h>
       
    22 #include <akntoolbar.h>
       
    23 #include <eikdialg.h>					  // for CEikDialog
       
    24 #include <AknUtils.h>
       
    25 #include <StringLoader.h>
       
    26 #include <eikdialogext.h>
       
    27 #include <AknsBasicBackgroundControlContext.h>
       
    28 #include <MMGFetchVerifier.h>             // For VerifySelectionL()
       
    29 
       
    30 #include <glxuiutility.h>
       
    31 #include <glxscreenfurniture.h>
       
    32 #include <glxtracer.h> 					  // Logging macros
       
    33 #include <glxlog.h>
       
    34 #include <glxcommandhandlers.hrh>         //command ids
       
    35 
       
    36 #include <mglxmedialist.h>				  // MGlxMediaList, CMPXCollectionPath
       
    37 
       
    38 #include <alf/alfevent.h>
       
    39 #include <alf/alfdisplay.h>
       
    40 
       
    41 //  CLASS HEADER
       
    42 #include <glxfetcherdialog.rsg>           // FOR GETTING VIEW ID AND RESOURCE ID
       
    43 #include "glxfetcherdialog.h"
       
    44 #include "glxfetchercontainer.h"
       
    45 #include "glxfetcher.hrh"
       
    46 
       
    47 #define GetAppUi() (dynamic_cast<CAknAppUi*>(iEikonEnv->EikAppUi()))
       
    48 const TInt KControlId = 1;
       
    49      
       
    50 //-----------------------------------------------------------------------------
       
    51 // C++ default constructor.
       
    52 //-----------------------------------------------------------------------------
       
    53 inline CGlxFetcherDialog::CGlxFetcherDialog(
       
    54             CDesCArray& aSelectedFiles, 
       
    55             MMGFetchVerifier* aVerifier, 
       
    56             TGlxFilterItemType aFilterType,
       
    57             const TDesC& aTitle,
       
    58             TBool aMultiSelectionEnabled)
       
    59         : iSelectedFiles( aSelectedFiles ),
       
    60           iVerifier( aVerifier ),
       
    61           iFilterType( aFilterType ),
       
    62           iTitle( aTitle ),
       
    63           iMultiSelectionEnabled(aMultiSelectionEnabled)
       
    64 	{
       
    65 	TRACER("CGlxFetcherDialog::CGlxFetcherDialog");
       
    66 	// No implementation required
       
    67 	}
       
    68 
       
    69 //-----------------------------------------------------------------------------
       
    70 // Two-phased constructor.
       
    71 //-----------------------------------------------------------------------------
       
    72 CGlxFetcherDialog* CGlxFetcherDialog::NewL(CDesCArray& aSelectedFiles, 
       
    73                MMGFetchVerifier* aVerifier, TGlxFilterItemType aFilterType ,
       
    74                 const TDesC& aTitle, TBool aMultiSelectionEnabled )
       
    75 	{
       
    76 	TRACER("CGlxFetcherDialog::NewL");
       
    77 	CGlxFetcherDialog* self=
       
    78 	    new( ELeave ) CGlxFetcherDialog(
       
    79 	        aSelectedFiles, aVerifier, aFilterType, aTitle, aMultiSelectionEnabled );
       
    80     CleanupStack::PushL( self );
       
    81     self->ConstructL();
       
    82     CleanupStack::Pop( self );
       
    83     return self;
       
    84    	}
       
    85 
       
    86 //-----------------------------------------------------------------------------
       
    87 // Destructor
       
    88 //-----------------------------------------------------------------------------
       
    89 CGlxFetcherDialog::~CGlxFetcherDialog()
       
    90 	{
       
    91 	TRACER("CGlxFetcherDialog::~CGlxFetcherDialog");
       
    92 	if(iFetcherContainer)
       
    93 	    {
       
    94 	    // Restore the Toolbar as it was in the Calling application
       
    95 	    if(GetAppUi()->CurrentFixedToolbar())  // there is Hardware Specific Output for Fixed ToolBar
       
    96 	        {
       
    97 	        GetAppUi()->CurrentFixedToolbar()->SetToolbarVisibility(ETrue);
       
    98 	        }
       
    99 
       
   100 	    TRAP_IGNORE(iFetcherContainer->SetPreviousTitleL());
       
   101 		}
       
   102 	if (iUiUtility)
       
   103 		{
       
   104 	    iUiUtility->Close();
       
   105 		}
       
   106 	}
       
   107 
       
   108 //-----------------------------------------------------------------------------
       
   109 // Symbian 2nd phase constructor can leave.
       
   110 // Create the alfscreenbuffer with a generic buffer screen id
       
   111 //-----------------------------------------------------------------------------
       
   112 void CGlxFetcherDialog::ConstructL()
       
   113 	{
       
   114 	TRACER("CGlxFetcherDialog::ConstructL");
       
   115 	// always first call the base class
       
   116     CAknDialog::ConstructL( R_MULTISELECT_FETCHER_MENUBAR );
       
   117 
       
   118     // Get the Instance of the toolbar and disable it as it is note required in the Fetcher Application
       
   119     if(GetAppUi()->CurrentFixedToolbar())  // there is Hardware Specific Output for Fixed ToolBar
       
   120         {
       
   121         GetAppUi()->CurrentFixedToolbar()->SetToolbarVisibility(EFalse);
       
   122         }
       
   123 	// Get the Hitchcock environment.
       
   124     iUiUtility = CGlxUiUtility::UtilityL();
       
   125     iEnv = iUiUtility->Env();
       
   126     iFetchUri = EFalse;
       
   127     }
       
   128     
       
   129 //-----------------------------------------------------------------------------
       
   130 // CGlxFetcherDialog::CreateCustomControlL
       
   131 //-----------------------------------------------------------------------------
       
   132 SEikControlInfo CGlxFetcherDialog::CreateCustomControlL(TInt aControlType)
       
   133     {
       
   134     TRACER("CGlxFetcherDialog::CreateCustomControlL");
       
   135     // Create Carousal control and add it to HUI CCoecontrol
       
   136     SEikControlInfo controlInfo;
       
   137     controlInfo.iControl = NULL;
       
   138     controlInfo.iTrailerTextId = 0;
       
   139     controlInfo.iFlags = 0;
       
   140 
       
   141     switch( aControlType )
       
   142         {
       
   143         case EFetcherControl :
       
   144             {
       
   145             iFetcherContainer = CGlxFetcherContainer::NewL( 
       
   146                     iFilterType, iTitle, *this, iMultiSelectionEnabled );
       
   147             controlInfo.iControl = iFetcherContainer;  // transfers ownership      
       
   148             break;
       
   149             }
       
   150         default :
       
   151             break;
       
   152         }
       
   153     return controlInfo;
       
   154     }
       
   155 
       
   156 //-----------------------------------------------------------------------------
       
   157 // CGlxFetcherDialog::ProcessCommandL
       
   158 // This processes the events to the OkToExitL
       
   159 //-----------------------------------------------------------------------------
       
   160 void CGlxFetcherDialog::ProcessCommandL(TInt aCommandId)
       
   161 	{
       
   162 	TRACER("CGlxFetcherDialog::ProcessCommandL");
       
   163 
       
   164 	if( iMenuBar )
       
   165 	    {
       
   166 	    iMenuBar->StopDisplayingMenuBar();
       
   167 	    }
       
   168 	switch( aCommandId )
       
   169 		{
       
   170 		case EAknSoftkeyCancel :
       
   171 			{
       
   172 			TryExitL( aCommandId );
       
   173 			break;
       
   174 			}
       
   175 		case EAknSoftkeySelect :
       
   176 		case EGlxCmdSelectMarked :
       
   177         case EAknSoftkeyOk :
       
   178             {
       
   179             GLX_LOG_INFO("CGlxFetcherDialog::ProcessCommandL() : EAknSoftkeyOk");
       
   180 			TryExitL( aCommandId );
       
   181 			break;
       
   182             }
       
   183 		default :
       
   184 		    {
       
   185             iFetcherContainer->DoExecuteL( aCommandId );
       
   186             break;
       
   187 		    }
       
   188 		}
       
   189 	}
       
   190 //-----------------------------------------------------------------------------
       
   191 // CGlxFetcherDialog::OkToExitL
       
   192 //-----------------------------------------------------------------------------
       
   193 TBool CGlxFetcherDialog::OkToExitL(TInt aKeycode)
       
   194 	{
       
   195 	TRACER("CGlxFetcherDialog::OkToExitL");
       
   196 	GLX_LOG_INFO1("CGlxFetcherDialog::OkToExitL : %d",aKeycode );
       
   197     TBool retVal = ETrue;
       
   198     TBool retrieveUriValue = EFalse;
       
   199     switch( aKeycode )
       
   200         {
       
   201         case EAknSoftkeySelect :
       
   202         case EGlxCmdSelectMarked :
       
   203         case EAknSoftkeyOk :
       
   204         case EAknCmdOpen :
       
   205             {
       
   206             // Retreives the uri's of the selected files and verifies if it is a 
       
   207             // supported format
       
   208             if (!iFetchUri)
       
   209                 {
       
   210                 iFetchUri = ETrue;
       
   211                 retrieveUriValue = iFetcherContainer->RetrieveUrisL(iSelectedFiles, iFetchUri);
       
   212                 if ( iVerifier && !iVerifier->VerifySelectionL( &iSelectedFiles ) )
       
   213                     {
       
   214                     iSelectedFiles.Reset();
       
   215                     retVal = EFalse;
       
   216                     } 
       
   217                 if (!retrieveUriValue)
       
   218                     {
       
   219                     retVal = EFalse;
       
   220                     }
       
   221                 if (iMultiSelectionEnabled)
       
   222                     {
       
   223                     iFetcherContainer->DoExecuteL(EGlxCmdEndMultipleMarking);    
       
   224                     }
       
   225                 }
       
   226             else
       
   227                 {
       
   228                 // if uri is being fetched then do not set the return value true, else it would cause
       
   229                 // Destructor of Dialog to be called and result in a crash when OKtoExitL is called multiple times.
       
   230                 retVal = EFalse;
       
   231                 }
       
   232             break;
       
   233             }
       
   234         case EAknSoftkeyCancel : // exit dialog
       
   235         case EAknCmdExit :
       
   236             {
       
   237             break;
       
   238             }
       
   239         case EAknCmdMark:
       
   240         case EAknSoftkeyMark:
       
   241             {
       
   242             if (iMultiSelectionEnabled)
       
   243                 {                
       
   244                 if(iUiUtility->IsPenSupported())
       
   245                     {
       
   246                     //Since the MSK is disabled we always get EAknCmdMark
       
   247                     //when we select msk hardkey in touch phone, so we need 
       
   248                     //to toggle between mark/unmark on the same hardkey event
       
   249                     if (!iMarkStarted)
       
   250                         {
       
   251                         iFetcherContainer->DoExecuteL(EGlxCmdStartMultipleMarking);
       
   252                         iMarkStarted = ETrue;
       
   253                         }
       
   254                     else
       
   255                         {
       
   256                         MGlxMediaList& mediaList = iFetcherContainer->MediaList();
       
   257                         TInt focusIdx = mediaList.FocusIndex();                        
       
   258                         if ( mediaList.IsSelected(focusIdx) )
       
   259                             iFetcherContainer->DoExecuteL(EAknCmdUnmark);
       
   260                         else
       
   261                             iFetcherContainer->DoExecuteL(EAknCmdMark);
       
   262                         }
       
   263                     }
       
   264                 else
       
   265                     {
       
   266                     if (!iMarkStarted)
       
   267                         {
       
   268                         iFetcherContainer->DoExecuteL(EGlxCmdStartMultipleMarking);
       
   269                         iMarkStarted = ETrue;
       
   270                         }
       
   271                     else
       
   272                         {
       
   273                         iFetcherContainer->DoExecuteL(EAknCmdMark);
       
   274                         }
       
   275                     }
       
   276                 }
       
   277             retVal = EFalse;
       
   278             break;
       
   279             }
       
   280         case EAknCmdUnmark:
       
   281         case EAknSoftkeyUnmark:
       
   282             {
       
   283             if (iMultiSelectionEnabled)
       
   284                 {
       
   285                 iFetcherContainer->DoExecuteL(EAknCmdUnmark);
       
   286 				                
       
   287                 //@ fix for ELWU-7RA7NX 
       
   288                 //@ Reset the flag on no selection, else it'll not pass the events to container for
       
   289                 //@ EGlxCmdStartMultipleMarking  case.
       
   290                 MGlxMediaList& mediaList = iFetcherContainer->MediaList() ;
       
   291                 if ( mediaList.SelectionCount() <= 0 )
       
   292 	                {
       
   293 	                iMarkStarted = EFalse;	
       
   294 	                } 
       
   295 					
       
   296                 HBufC* mskTextMark = StringLoader::LoadLC( R_GLX_MARKING_MARK );
       
   297                 HBufC* rskTextCancel = StringLoader::LoadLC( R_GLX_SOFTKEY_CANCEL );
       
   298                 iUiUtility->ScreenFurniture()->ModifySoftkeyIdL(
       
   299                         CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   300                         EAknCmdMark, 0, *mskTextMark);
       
   301                 iUiUtility->ScreenFurniture()->ModifySoftkeyIdL(
       
   302                         CEikButtonGroupContainer::ERightSoftkeyPosition,
       
   303                         EAknSoftkeyCancel, 0, *rskTextCancel);
       
   304                 CleanupStack::PopAndDestroy(rskTextCancel);
       
   305                 CleanupStack::PopAndDestroy(mskTextMark);
       
   306                 }
       
   307             retVal = EFalse;
       
   308             break;
       
   309             }
       
   310         default :
       
   311             break;
       
   312         }
       
   313     return retVal;
       
   314 	}
       
   315 
       
   316 //-----------------------------------------------------------------------------
       
   317 // CGlxFetcherDialog::SizeChanged
       
   318 //-----------------------------------------------------------------------------
       
   319 void CGlxFetcherDialog::SizeChanged()
       
   320 	{
       
   321 	TRACER("CGlxFetcherDialog::SizeChanged");
       
   322 	if (iFetcherContainer)
       
   323 	    {
       
   324 	    TRAP_IGNORE (iFetcherContainer->HandleSizeChangeL());    
       
   325 	    }
       
   326 	}
       
   327 
       
   328 //-----------------------------------------------------------------------------
       
   329 // CGlxFetcherDialog::PreLayoutDynInitL
       
   330 //-----------------------------------------------------------------------------
       
   331 void CGlxFetcherDialog::PreLayoutDynInitL()
       
   332     {
       
   333     TRACER("CGlxFetcherDialog::PreLayoutDynInitL");
       
   334     CreateLineByTypeL( KNullDesC, KControlId, EFetcherControl, NULL );
       
   335     }
       
   336 //-----------------------------------------------------------------------------
       
   337 // CGlxFetcherDialog::PostLayoutDynInitL
       
   338 //-----------------------------------------------------------------------------
       
   339 void CGlxFetcherDialog::PostLayoutDynInitL()
       
   340     {
       
   341     TRACER("CGlxFetcherDialog::PostLayoutDynInitL");
       
   342     
       
   343     // Create and Display Grid widget 
       
   344     iFetcherContainer->CreateAndDisplayGridL();
       
   345     }
       
   346 
       
   347 //-----------------------------------------------------------------------------
       
   348 // CGlxFetcherDialog::DynInitMenuPaneL
       
   349 //-----------------------------------------------------------------------------
       
   350 void CGlxFetcherDialog::DynInitMenuPaneL(
       
   351         TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
   352     {
       
   353     TRACER("CGlxFetcherDialog::DynInitMenuPaneL");
       
   354     // No Implementation
       
   355     }
       
   356 
       
   357 //-----------------------------------------------------------------------------
       
   358 // CGlxFetcherDialog::OfferKeyEventL
       
   359 //-----------------------------------------------------------------------------
       
   360 TKeyResponse CGlxFetcherDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   361         TEventCode aType)
       
   362     {
       
   363     TRACER("CGlxFetcherDialog::OfferKeyEventL");
       
   364     TKeyResponse response = EKeyWasNotConsumed;
       
   365     response = iFetcherContainer->OfferKeyEventL(aKeyEvent,aType);
       
   366  
       
   367     if(response == EKeyWasNotConsumed)
       
   368         response = CAknDialog::OfferKeyEventL(aKeyEvent,aType);
       
   369 
       
   370     return response;    
       
   371     }
       
   372 
       
   373 //-----------------------------------------------------------------------------
       
   374 // CGlxFetcherDialog::HandlePointerEventL
       
   375 // Handles all pointer events to the screen.
       
   376 // Offers the events to the primary display control (container - widgets)
       
   377 // and also finally calls handlescreenbufferevent and draws the bitmap onto
       
   378 // the screen
       
   379 //-----------------------------------------------------------------------------
       
   380 void CGlxFetcherDialog::HandlePointerEventL(
       
   381     const TPointerEvent& aPointerEvent)
       
   382     {
       
   383     TRACER("CGlxFetcherDialog::HandlePointerEventL");
       
   384     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   385     iEnv->PrimaryDisplay().HandlePointerEventL( aPointerEvent );
       
   386     }
       
   387 
       
   388 //-----------------------------------------------------------------------------
       
   389 // CGlxFetcherDialog::HandleDoubleTapEvent
       
   390 // Callback from the container for double tap events
       
   391 // Offers the event from container to Dialog
       
   392 //-----------------------------------------------------------------------------
       
   393 void CGlxFetcherDialog::HandleDoubleTapEventL(TInt aCommandId)
       
   394     {
       
   395     TRACER("CGlxFetcherDialog::HandleTapEvent");
       
   396     Extension()->iPublicFlags.Set(CEikDialogExtension::EDelayedExit);
       
   397     ProcessCommandL(aCommandId);
       
   398     Extension()->iPublicFlags.Clear(CEikDialogExtension::EDelayedExit);
       
   399     }
       
   400     
       
   401 //-----------------------------------------------------------------------------
       
   402 // CGlxFetcherDialog::CallCancelFetcherL
       
   403 // This function will be called from CGlxFetcher::CancelFetcherL
       
   404 // This will ensure exit of fetcher dialog & fetcher app
       
   405 //-----------------------------------------------------------------------------
       
   406 
       
   407 void CGlxFetcherDialog::CallCancelFetcherL(TInt aCommandId)
       
   408 	{
       
   409 	TRACER("CGlxFetcherDialog::CallCancelFetcherL");
       
   410 	TryExitL(aCommandId);
       
   411 	}
       
   412 //  End of File