emailuis/emailui/src/FreestyleEmailUiGlobalSettingsListView.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Freestyle Email implementation file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include "emailtrace.h"
       
    21 #include <aknViewAppUi.h>
       
    22 #include <eikmenub.h>
       
    23 #include <avkon.hrh>
       
    24 #include <akncontext.h>
       
    25 #include <akntitle.h>
       
    26 #include <StringLoader.h>
       
    27 #include <barsread.h>
       
    28 #include <FreestyleEmailUi.rsg>
       
    29 // <cmail> 
       
    30 #include <csxhelp/cmail.hlp.hrh>
       
    31 // </cmail>
       
    32 #include <featmgr.h>
       
    33 //</cmail>
       
    34 
       
    35 // LOCAL INCLUDES
       
    36 #include "FreestyleEmailUiUtilities.h"
       
    37 #include "FreestyleEmailUiGlobalSettings.hrh"
       
    38 #include "FreestyleEmailUiGlobalSettingsListView.h"
       
    39 #include "FreestyleEmailUiGlobalSettingsList.h"
       
    40 #include "FreestyleEmailUiGlobalSettingsData.h"
       
    41 #include "FreestyleEmailUiAppui.h"
       
    42 #include "FreestyleEmailUiConstants.h" 
       
    43 #include "FreestyleEmailUiShortcutBinding.h"
       
    44 #include "FSEmail.pan"
       
    45 
       
    46 /**
       
    47  * First phase of Symbian two-phase construction. Should not contain any
       
    48  * code that could leave.
       
    49  */
       
    50 CFsEmailUiGlobalSettingsListView::CFsEmailUiGlobalSettingsListView( CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup )
       
    51 	: CFsEmailUiViewBase( aControlGroup, *aAppUi )
       
    52 	{
       
    53     FUNC_LOG;
       
    54 	}
       
    55 
       
    56 /** 
       
    57  * Destructor
       
    58  */
       
    59 CFsEmailUiGlobalSettingsListView::~CFsEmailUiGlobalSettingsListView()
       
    60 	{
       
    61     FUNC_LOG;
       
    62 	}
       
    63 
       
    64 /**
       
    65  * Symbian two-phase constructor.
       
    66  * This creates an instance then calls the second-phase constructor
       
    67  * without leaving the instance on the cleanup stack.
       
    68  * @return new instance of CFsEmailUiGlobalSettingsListView
       
    69  */
       
    70 CFsEmailUiGlobalSettingsListView* CFsEmailUiGlobalSettingsListView::NewL(
       
    71 		CFreestyleEmailUiAppUi* aAppUi,
       
    72 		CAlfControlGroup& aControlGroup )
       
    73 	{
       
    74     FUNC_LOG;
       
    75 
       
    76 	CFsEmailUiGlobalSettingsListView* self = CFsEmailUiGlobalSettingsListView::NewLC( aAppUi, aControlGroup );
       
    77 	CleanupStack::Pop( self );
       
    78 
       
    79 	return self;
       
    80 	}
       
    81 
       
    82 /**
       
    83  * Symbian two-phase constructor.
       
    84  * This creates an instance, pushes it on the cleanup stack,
       
    85  * then calls the second-phase constructor.
       
    86  * @return new instance of CFsEmailUiGlobalSettingsListView
       
    87  */
       
    88 CFsEmailUiGlobalSettingsListView* CFsEmailUiGlobalSettingsListView::NewLC(
       
    89 		CFreestyleEmailUiAppUi* aAppUi, 
       
    90 		CAlfControlGroup& aControlGroup )
       
    91 	{
       
    92     FUNC_LOG;
       
    93 
       
    94 	CFsEmailUiGlobalSettingsListView* self = new ( ELeave ) CFsEmailUiGlobalSettingsListView( aAppUi, aControlGroup );
       
    95 	CleanupStack::PushL( self );
       
    96 	self->ConstructL();
       
    97 
       
    98 	return self;
       
    99 	}
       
   100 
       
   101 
       
   102 /**
       
   103  * Second-phase constructor for view.  
       
   104  * Initialize contents from resource.
       
   105  */ 
       
   106 void CFsEmailUiGlobalSettingsListView::ConstructL()
       
   107 	{
       
   108     FUNC_LOG;
       
   109 
       
   110 	BaseConstructL( R_GLOBAL_SETTINGS_LIST_VIEW );
       
   111 
       
   112 	}
       
   113 	
       
   114 /**
       
   115  * @return The UID for this view
       
   116  */
       
   117 TUid CFsEmailUiGlobalSettingsListView::Id() const
       
   118 	{
       
   119     FUNC_LOG;
       
   120 	return GlobalSettingsViewId;
       
   121 	}
       
   122 
       
   123 void CFsEmailUiGlobalSettingsListView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   124 	{
       
   125     FUNC_LOG;
       
   126     if ( aResourceId == R_GLOBAL_SETTINGS_MENU_PANE )
       
   127         {
       
   128 		
       
   129 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
   130 		   {
       
   131 		   // remove help support in pf5250
       
   132 		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
       
   133 		   }
       
   134   // Dim "Open" and "Change" 
       
   135 	    aMenuPane->SetItemDimmed( EFsEmailUiCmdChange, ETrue );
       
   136 	    aMenuPane->SetItemDimmed( EFsEmailUiCmdOpen, ETrue );
       
   137                  
       
   138         // Add shortcut hints
       
   139         iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, 
       
   140                                      CFSEmailUiShortcutBinding::EContextSettings );         
       
   141         }
       
   142 	}
       
   143 
       
   144 /**
       
   145  * Handle a command for this view (override)
       
   146  * @param aCommand command id to be handled
       
   147  */
       
   148 void CFsEmailUiGlobalSettingsListView::HandleCommandL( TInt aCommand )
       
   149 	{
       
   150     FUNC_LOG;
       
   151 
       
   152 	switch ( aCommand )
       
   153 		{
       
   154 		case EAknSoftkeyBack:
       
   155 			iAppUi.ReturnToPreviousViewL();
       
   156 			break;
       
   157 		case EFsEmailUiCmdChange:
       
   158 		case EAknSoftkeyChange:
       
   159 		case EFsEmailUiCmdOpen:
       
   160 		case EAknSoftkeyOpen:
       
   161 			HandleChangeSelectedSettingItemL( aCommand );
       
   162 			break;
       
   163 		case EFsEmailUiCmdHelp:
       
   164 			TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
       
   165 			break;
       
   166 		case EFsEmailUiCmdExit:
       
   167 		case EEikCmdExit:
       
   168 		case EAknCmdExit:
       
   169 			AppUi()->HandleCommandL( EEikCmdExit );
       
   170 			break;
       
   171 		case EFsEmailUiCmdGoToTop:
       
   172 		    iGlobalSettingsSettingItemList->GoToTop();
       
   173 		    break;
       
   174 		case EFsEmailUiCmdGoToBottom:
       
   175 		    iGlobalSettingsSettingItemList->GoToBottom();
       
   176 		    break;
       
   177         case EFsEmailUiCmdPageUp:
       
   178             iGlobalSettingsSettingItemList->PageUp();
       
   179             break;
       
   180         case EFsEmailUiCmdPageDown:
       
   181             iGlobalSettingsSettingItemList->PageDown();
       
   182             break;
       
   183 		default:
       
   184 		    __ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) );
       
   185 			break;
       
   186 		}	
       
   187 	}
       
   188 
       
   189 /**
       
   190  * Set MSK label depending on the currently focused item
       
   191  */
       
   192 void CFsEmailUiGlobalSettingsListView::SetMskL()
       
   193     {
       
   194     FUNC_LOG;
       
   195     if ( iGlobalSettingsSettingItemList )
       
   196         {
       
   197         TInt focusedId = iGlobalSettingsSettingItemList->FocusedItemId();
       
   198         if ( focusedId == EGlobalSettingsActiveIdle )
       
   199             {
       
   200             ChangeMskCommandL( R_FSE_QTN_MSK_OPEN );
       
   201             }
       
   202         else
       
   203             {
       
   204             ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE );
       
   205             }
       
   206         }
       
   207     }
       
   208 
       
   209 /**
       
   210  *	Handles actions during activation of the view, 
       
   211  *	such as initializing the content.
       
   212  */
       
   213 // <cmail> Toolbar
       
   214 /*void CFsEmailUiGlobalSettingsListView::DoActivateL(
       
   215         const TVwsViewId& aPrevViewId,
       
   216         TUid aCustomMessageId,
       
   217         const TDesC8& aCustomMessage )*/
       
   218 void CFsEmailUiGlobalSettingsListView::ChildDoActivateL(
       
   219         const TVwsViewId& /*aPrevViewId*/,
       
   220         TUid /*aCustomMessageId*/,
       
   221         const TDesC8& /*aCustomMessage*/ )
       
   222 // </cmail> Toolbar
       
   223 	{
       
   224     FUNC_LOG;
       
   225 	
       
   226 	SetupStatusPaneL();
       
   227 	
       
   228 	if ( !iGlobalSettingsSettingItemList )
       
   229 		{
       
   230 		iSettings = CFsEmailUiGlobalSettingsData::NewL();
       
   231 		iGlobalSettingsSettingItemList = new ( ELeave ) CFsEmailUiGlobalSettingsList( *iSettings, this );
       
   232 		iGlobalSettingsSettingItemList->SetMopParent( this );
       
   233 		iGlobalSettingsSettingItemList->ConstructFromResourceL( R_GLOBAL_SETTINGS_ITEM_LIST );
       
   234 		iGlobalSettingsSettingItemList->ActivateL();
       
   235 		iGlobalSettingsSettingItemList->LoadSettingValuesL();
       
   236 		iGlobalSettingsSettingItemList->LoadSettingsL();
       
   237 		AppUi()->AddToStackL( *this, iGlobalSettingsSettingItemList );
       
   238 		} 
       
   239 	iAppUi.HideTitlePaneConnectionStatus();
       
   240 
       
   241 	}
       
   242 
       
   243 /**
       
   244  * ChildDoDeactivate
       
   245  * From CFsEmailUiViewBase (override)
       
   246  */
       
   247 void CFsEmailUiGlobalSettingsListView::ChildDoDeactivate()
       
   248 	{
       
   249     FUNC_LOG;
       
   250 
       
   251 	if ( iGlobalSettingsSettingItemList )
       
   252 		{
       
   253 		AppUi()->RemoveFromStack( iGlobalSettingsSettingItemList );
       
   254 		delete iGlobalSettingsSettingItemList;
       
   255 		iGlobalSettingsSettingItemList = NULL;
       
   256 		delete iSettings;
       
   257 		iSettings = NULL;
       
   258 		}
       
   259 
       
   260 	}
       
   261 
       
   262 /**
       
   263  * SetupStatusPaneL
       
   264  * From CAknView
       
   265  */
       
   266 void CFsEmailUiGlobalSettingsListView::SetupStatusPaneL()
       
   267 	{
       
   268     FUNC_LOG;
       
   269 
       
   270 	// reset the context pane
       
   271 	TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
       
   272 	CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
       
   273 		StatusPane()->PaneCapabilities( contextPaneUid );
       
   274 	if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
       
   275 		{
       
   276 		CAknContextPane* context = static_cast< CAknContextPane* > ( 
       
   277 			StatusPane()->ControlL( contextPaneUid ) );
       
   278 		context->SetPictureToDefaultL();
       
   279 		}
       
   280 	
       
   281 	// setup the title pane
       
   282 	TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
       
   283 	CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
       
   284 		StatusPane()->PaneCapabilities( titlePaneUid );
       
   285 	if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
       
   286 		{
       
   287 		CAknTitlePane* title = static_cast< CAknTitlePane* >( 
       
   288 			StatusPane()->ControlL( titlePaneUid ) );
       
   289 		TResourceReader reader;
       
   290 		iEikonEnv->CreateResourceReaderLC( reader, R_GLOBAL_SETTINGS_TITLE_RESOURCE );
       
   291 		title->SetFromResourceL( reader );
       
   292 		CleanupStack::PopAndDestroy(); // reader internal state
       
   293 		}
       
   294 				
       
   295 	}
       
   296 
       
   297 /**
       
   298  * CleanupStatusPaneL
       
   299  * Change status pane title back to default
       
   300  */
       
   301 void CFsEmailUiGlobalSettingsListView::CleanupStatusPaneL()
       
   302 	{
       
   303     FUNC_LOG;
       
   304     iAppUi.ResetTitlePaneTextL();
       
   305 	}
       
   306 
       
   307 
       
   308 /** 
       
   309  * Handle status pane size change for this view (override)
       
   310  * 
       
   311  */
       
   312 void CFsEmailUiGlobalSettingsListView::HandleStatusPaneSizeChange()
       
   313 	{
       
   314     FUNC_LOG;
       
   315 	if ( IsForeground() )
       
   316 		{
       
   317 		CAknView::HandleStatusPaneSizeChange();
       
   318 		
       
   319 		// this may fail, but we're not able to propagate exceptions here
       
   320 		TRAPD( err, SetupStatusPaneL() );
       
   321 		if (err)
       
   322 		    {
       
   323 		    }
       
   324 		}
       
   325 	}
       
   326 
       
   327 
       
   328 /** 
       
   329  * Handle the selected event.
       
   330  * @param aCommand the command id invoked
       
   331  * @return ETrue if the command was handled, EFalse if not
       
   332  */
       
   333 TBool CFsEmailUiGlobalSettingsListView::HandleChangeSelectedSettingItemL( TInt aCommand )
       
   334 	{
       
   335     FUNC_LOG;
       
   336 
       
   337   	TBool calledFromMenu = 
       
   338         ( aCommand != EAknSoftkeyChange && aCommand != EAknSoftkeyOpen );
       
   339 	iGlobalSettingsSettingItemList->ChangeSelectedItemL( calledFromMenu );
       
   340 
       
   341 	return ETrue;
       
   342 	}
       
   343