photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerback.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:    Back commmand handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcommandhandlerback.h"
       
    22 
       
    23 #include <avkon.hrh>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 
       
    26    
       
    27 #include <apgtask.h>
       
    28 
       
    29 
       
    30 #include <apgcli.h>
       
    31 #include <mpxcollectionutility.h>
       
    32 #include <mpxviewutility.h>			// For MMPXViewUtility
       
    33 
       
    34 #include <glxcommandhandlers.hrh>
       
    35 #include <glxpanic.h>
       
    36 #include <glxtracer.h>
       
    37 #include <glxlog.h>
       
    38 #include <glxnavigationalstate.h>
       
    39 #include <glxcollectionplugincamera.hrh>
       
    40 #include <glxcollectionplugindownloads.hrh>
       
    41 #include <glxcollectionpluginalbums.hrh>
       
    42 #include <glxcollectionpluginmonths.hrh>
       
    43 #include <glxcollectionplugintags.hrh>
       
    44 #include <glxbackservicewrapper.h>
       
    45 #include <glxgallery.hrh>
       
    46 
       
    47 #include "glxmediaselectionpopup.h"
       
    48 //constants
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Two-phased constructor.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CGlxCommandHandlerBack* 
       
    56 			CGlxCommandHandlerBack::NewBackCommandHandlerL()
       
    57 	{
       
    58 	return CGlxCommandHandlerBack::NewL(EGlxCmdBack,NULL,0);
       
    59 	}																	
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Two-phased constructor.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C CGlxCommandHandlerBack* 
       
    66 			CGlxCommandHandlerBack::NewPreviousViewCommandHandlerL( 	
       
    67 			MGlxMediaListProvider* aMediaListProvider )
       
    68 	{
       
    69 	return CGlxCommandHandlerBack::NewL(EGlxCmdPreviousView,aMediaListProvider,0);
       
    70 	}
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Two-phased constructor.
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C CGlxCommandHandlerBack* 
       
    77 			CGlxCommandHandlerBack::NewContainerPreviousViewCommandHandlerL( 	
       
    78 			MGlxMediaListProvider* aMediaListProvider, TInt aPrevViewId )
       
    79 	{
       
    80 	return CGlxCommandHandlerBack::NewL(EGlxCmdContainerPreviousView,
       
    81 			aMediaListProvider,aPrevViewId);
       
    82 	}																	
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // Two-phased constructor.
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CGlxCommandHandlerBack* 
       
    89 			CGlxCommandHandlerBack::NewL( 
       
    90 			TInt aCommandId, MGlxMediaListProvider* aMediaListProvider,
       
    91 			TInt aPrevViewId )
       
    92 	{
       
    93 	CGlxCommandHandlerBack* self = new (ELeave)
       
    94 	    CGlxCommandHandlerBack(aMediaListProvider,aPrevViewId);
       
    95 	CleanupStack::PushL(self);
       
    96 	self->ConstructL(aCommandId);
       
    97 	CleanupStack::Pop(self);
       
    98 	return self;
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // C++ default constructor can NOT contain any code, that
       
   103 // might leave.
       
   104 // ---------------------------------------------------------------------------
       
   105 //	
       
   106 CGlxCommandHandlerBack::CGlxCommandHandlerBack( MGlxMediaListProvider*
       
   107     aMediaListProvider, TInt aPrevViewId )
       
   108 	{
       
   109 	iMediaListProvider = aMediaListProvider;
       
   110 	iPrevViewId = aPrevViewId;
       
   111 	}			
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Symbian 2nd phase constructor can leave.
       
   115 // ---------------------------------------------------------------------------
       
   116 //	
       
   117 void CGlxCommandHandlerBack::ConstructL( TInt aCommandId )
       
   118 	{
       
   119     TRACER( "CGlxCommandHandlerBack::ConstructL" );
       
   120     
       
   121     GLX_LOG_INFO1( "CGlxCommandHandlerBack::ConstructL::Command Id (%d)",
       
   122         aCommandId );
       
   123     iCurrentCommandId = aCommandId;
       
   124     iNavigationalState =  CGlxNavigationalState::InstanceL();
       
   125     iIsViewActivated = EFalse;
       
   126   
       
   127     iBSWrapper = CGlxBackServiceWrapper::NewL( TUid::Uid( KGlxGalleryApplicationUid ) );
       
   128     iAppUi = static_cast< CAknAppUi* >( CCoeEnv::Static()->AppUi() );
       
   129 
       
   130 	}	
       
   131 	
       
   132 // ---------------------------------------------------------------------------
       
   133 // Destructor
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C CGlxCommandHandlerBack::~CGlxCommandHandlerBack()
       
   137 	{
       
   138 	TRACER( "CGlxCommandHandlerBack::~CGlxCommandHandlerBack" );
       
   139 	
       
   140 	iNavigationalState->Close();
       
   141    
       
   142     if( iBSWrapper )
       
   143         {	
       
   144         delete iBSWrapper;    
       
   145         }
       
   146 
       
   147 	}
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // ExecuteL
       
   151 // -----------------------------------------------------------------------------
       
   152 //	
       
   153 TBool CGlxCommandHandlerBack::ExecuteL( TInt aCommandId )
       
   154 	{
       
   155     TRACER("CGlxCommandHandlerBack::ExecuteL");
       
   156 	_LIT8( KPhotosSuiteNavigation, "SuiteNavigation" );
       
   157 	TBool consume(EFalse);
       
   158 
       
   159 	GLX_LOG_INFO1( "CGlxCommandHandlerBack::ExecuteL::Command Id (%d)",
       
   160 	    aCommandId );
       
   161 	    
       
   162 	if ( aCommandId == EAknSoftkeyBack )
       
   163     	{
       
   164     	switch( iCurrentCommandId )
       
   165     		{
       
   166     		case EGlxCmdBack:
       
   167     			{
       
   168     			GLX_LOG_INFO("CGlxCommandHandlerBack::ExecuteL::One step \
       
   169     			    back in UI hierarchy");
       
   170                 MMPXCollectionUtility* collectionUtility = MMPXCollectionUtility::NewL(NULL, KMcModeDefault);
       
   171                 CleanupClosePushL(*collectionUtility);
       
   172                 CMPXCollectionPath* navigationalState = collectionUtility->Collection().PathL();
       
   173                 CleanupStack::PopAndDestroy(collectionUtility);
       
   174                 CleanupStack::PushL(navigationalState);
       
   175 
       
   176                 // let Back Stepping Service handle the event
       
   177                 if(2 == navigationalState->Levels()&&  iNavigationalState->BackExitStatus())
       
   178                     {
       
   179                     iBSWrapper->HandleBackCommandL( KPhotosSuiteNavigation );
       
   180                     if(iAppUi)
       
   181                         {
       
   182                         iAppUi->ProcessCommandL(EAknSoftkeyExit);    
       
   183                         }
       
   184                     }
       
   185                 else if (!(iNavigationalState->BackExitStatus()))
       
   186                     {
       
   187                     if(iAppUi)
       
   188                         {
       
   189                         iAppUi->ProcessCommandL(EAknSoftkeyExit);    
       
   190                         }
       
   191                     }
       
   192                 else if( iIsViewActivated )
       
   193                     {
       
   194                     iIsViewActivated = EFalse;
       
   195                     iNavigationalState->NavigateToParentL();  
       
   196                     }
       
   197                 CleanupStack::PopAndDestroy(navigationalState); 
       
   198     			consume = ETrue;
       
   199     			break;
       
   200     			}
       
   201     		case EGlxCmdPreviousView:
       
   202     			{
       
   203     			GLX_LOG_INFO("CGlxCommandHandlerBack::ExecuteL::Go back \
       
   204                 to the previous view");
       
   205                 if (!(iNavigationalState->BackExitStatus()))
       
   206                     {
       
   207                     if(iAppUi)
       
   208                         {
       
   209                         iAppUi->ProcessCommandL(EAknSoftkeyExit);    
       
   210                         }
       
   211                     }
       
   212     			if( iIsViewActivated )
       
   213     			    {
       
   214                     iIsViewActivated = EFalse;
       
   215                     iNavigationalState->ActivatePreviousViewL();
       
   216     			    
       
   217     			    }
       
   218     			consume = ETrue;
       
   219     			break;
       
   220     			}
       
   221     			
       
   222     		case EGlxCmdContainerPreviousView:
       
   223     			{
       
   224     			GLX_LOG_INFO("CGlxCommandHandlerBack::ExecuteL::Go back \
       
   225     			    to the previous view when continer is still there else go two views back");
       
   226                 // The code commented is to be removed after testing with migrated code is over
       
   227                 // below code is no longer  expected to be required  as the 
       
   228                 // "deletion of tags" from tag manager test case dont exist in rel 8.0
       
   229                 // the private API CheckContainerDeletion()can also to be removed 
       
   230                 
       
   231     		/*	// check if special case of container deletion need to be checked
       
   232     			// this must be done before the previous view is activated as the check
       
   233     			// is based on the view id
       
   234     			TBool containerDeleted = CheckContainerDeletion();
       
   235  
       
   236     			//go back one view
       
   237 
       
   238                  if ( iViewUtility->ViewHistoryDepth() > 1 )
       
   239                      {
       
   240                      iViewUtility->ActivatePreviousViewL();
       
   241                      }
       
   242 
       
   243     			if( containerDeleted )
       
   244     				{
       
   245     				//path to get list of containers
       
   246     				CMPXCollectionPath* containerPath = iMediaListProvider->MediaList().PathLC();
       
   247                     //current navigational state
       
   248                     CMPXCollectionPath* navigationalState = iCollectionUtility->Collection().PathL();
       
   249                     CleanupStack::PushL(navigationalState);
       
   250    				
       
   251     				//current node id in UI Hierarchy
       
   252     				TMPXItemId currentNodeId = navigationalState->Id(navigationalState->Levels() - 2);
       
   253 
       
   254     				//check if current node is present in containers list
       
   255     				if(KErrNotFound == containerPath->IndexOfId(currentNodeId))
       
   256     					{
       
   257     					iCollectionUtility->Collection().BackL();
       
   258     					}
       
   259                     CleanupStack::PopAndDestroy(navigationalState);
       
   260     				CleanupStack::PopAndDestroy(containerPath);
       
   261     				}*/
       
   262     			consume = ETrue;
       
   263     			break;
       
   264     			}
       
   265     		default:
       
   266     		    User::Leave( KErrNotFound );
       
   267     		    break;
       
   268     		}
       
   269     	}
       
   270 		
       
   271 	return consume;
       
   272 	}
       
   273 
       
   274 //The below commented code to be removed 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CheckContainerDeletion
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 /*TBool CGlxCommandHandlerBack::CheckContainerDeletion() const
       
   280 	{
       
   281 	return((iViewUtility->PreviousViewType().operator != (TUid::Uid(0))) && 
       
   282 		(iViewUtility->PreviousViewType().operator ==(TUid::Uid(iPrevViewId))));
       
   283 	}*/
       
   284 // -----------------------------------------------------------------------------
       
   285 // DynInitMenuPaneL
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 void CGlxCommandHandlerBack::DynInitMenuPaneL(TInt /*aResourceId*/, 
       
   289 												CEikMenuPane* /*aMenuPane*/)
       
   290 	{
       
   291 	// Do Nothing		
       
   292 	}
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // DoActivateL
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 void CGlxCommandHandlerBack::DoActivateL(TInt /*aViewId*/)
       
   299 	{
       
   300 	iIsViewActivated = ETrue;
       
   301 	}
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // Deactivate
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 void CGlxCommandHandlerBack::Deactivate()
       
   308 	{
       
   309 	iIsViewActivated = EFalse;
       
   310 	}
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // OfferKeyEventL
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 TKeyResponse CGlxCommandHandlerBack::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, 
       
   317 														TEventCode /*aType*/)
       
   318 	{
       
   319 	return EKeyWasNotConsumed;		
       
   320 	}
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // PreDynInitMenuPaneL
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CGlxCommandHandlerBack::PreDynInitMenuPaneL( TInt /*aResourceId*/ )
       
   327 	{
       
   328 	// Do Nothing		
       
   329 	}
       
   330 	
       
   331 	
       
   332 //End of file