phonebookui/Phonebook2/Application/src/CPbk2AppUi.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 68 9da50d567e3c
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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:  Phonebook 2 application UI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPbk2AppUi.h"
       
    21 
       
    22 // Phonebook 2
       
    23 #include "CPbk2StartupMonitor.h"
       
    24 #include "CPbk2Application.h"
       
    25 #include "CPbk2Document.h"
       
    26 #include "CPbk2ViewExplorer.h"
       
    27 #include "CPbk2TabGroupContainerExtensionModifier.h"
       
    28 #include "MPbk2ApplicationServices.h"
       
    29 #include "MPbk2ApplicationServices2.h"
       
    30 #include <CPbk2AppViewBase.h>
       
    31 #include <Pbk2DataCaging.hrh>
       
    32 #include <CPbk2StoreManager.h>
       
    33 #include <Pbk2MenuFilteringFlags.hrh>
       
    34 #include <Pbk2Commands.hrh>
       
    35 #include <CPbk2UIExtensionManager.h>
       
    36 #include <MPbk2UIExtensionFactory.h>
       
    37 #include <CPbk2ViewState.h>
       
    38 #include <Phonebook2PrivateCRKeys.h>
       
    39 #include <CPbk2SortOrderManager.h>
       
    40 #include <MPbk2ContactNameFormatter.h>
       
    41 #include <Pbk2ContactNameFormatterFactory.h>
       
    42 #include <CPbk2StorePropertyArray.h>
       
    43 #include <CPbk2FieldPropertyArray.h>
       
    44 #include <CPbk2TabGroupContainer.h>
       
    45 #include <MPbk2ContactViewSupplier.h>
       
    46 #include <Pbk2CommonUi.rsg>
       
    47 #include <Pbk2UID.h>
       
    48 #include <Phonebook2PublicPSKeys.h> 
       
    49 
       
    50 // Virtual Phonebook
       
    51 #include <VPbkVariant.hrh>
       
    52 
       
    53 // System includes
       
    54 #include <aknview.h>
       
    55 #include <eikmenup.h>
       
    56 #include <centralrepository.h>
       
    57 #include <gfxtranseffect/gfxtranseffect.h>
       
    58 #include <akntranseffect.h>
       
    59 #include <e32property.h>
       
    60 
       
    61 // Debugging headers
       
    62 #include <Pbk2Config.hrh>
       
    63 #include <Pbk2Debug.h>
       
    64 #include <Pbk2Profile.h>
       
    65 
       
    66 /// Unnamed namespace for local definitions
       
    67 namespace {
       
    68 
       
    69 _LIT( KPbk2CommandsDllResFileName, "Pbk2Commands.rsc" );
       
    70 _LIT( KPbk2UiControlsDllResFileName, "Pbk2UiControls.rsc" );
       
    71 _LIT( KPbk2CommonUiDllResFileName, "Pbk2CommonUi.rsc" );
       
    72 
       
    73 }  /// namespace
       
    74 
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CPbk2AppUi::CPbk2AppUi
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 CPbk2AppUi::CPbk2AppUi() :
       
    81         iUiControlsResourceFile( *iCoeEnv ),
       
    82         iCommandsResourceFile( *iCoeEnv ),
       
    83         iCommonUiResourceFile( *iCoeEnv )
       
    84     {
       
    85     }
       
    86 
       
    87 // --------------------------------------------------------------------------
       
    88 // CPbk2AppUi::~CPbk2AppUi
       
    89 // Application views will be deleted by the base class destructor
       
    90 // --------------------------------------------------------------------------
       
    91 //
       
    92 CPbk2AppUi::~CPbk2AppUi()
       
    93     {
       
    94     CCoeEnv::Static()->RemoveForegroundObserver( *this );
       
    95 
       
    96     delete iStartupMonitor;
       
    97     delete iTabGroups;
       
    98     delete iViewExplorer;
       
    99     iUiControlsResourceFile.Close();
       
   100     iCommandsResourceFile.Close();
       
   101     iCommonUiResourceFile.Close();
       
   102     Release( iAppUiExtension );
       
   103     }
       
   104 
       
   105 // --------------------------------------------------------------------------
       
   106 // CPbk2AppUi::ConstructL
       
   107 // --------------------------------------------------------------------------
       
   108 //
       
   109 void CPbk2AppUi::ConstructL()
       
   110     {
       
   111     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   112         ("CPbk2AppUi::ConstructL(0x%x)"), this);
       
   113 
       
   114     PBK2_PROFILE_START(Pbk2Profile::EAppUiConstruction);
       
   115 
       
   116     // Init base class
       
   117     // Use local impl of the LocalVariationFeatureEnabled because app globals
       
   118     // haven't been initialized yet at this point.
       
   119     PBK2_PROFILE_START(Pbk2Profile::EAppUiBaseConstruct);
       
   120     
       
   121     //Set the single click compatibility on
       
   122     if ( LocalVariationFeatureEnabled( EVPbkLVEnableMiddleSoftKey ) )
       
   123         {
       
   124         BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
   125         }
       
   126     else
       
   127         {
       
   128         BaseConstructL( EAknEnableSkin | EAknSingleClickCompatible );
       
   129         }
       
   130     
       
   131     PBK2_PROFILE_END(Pbk2Profile::EAppUiBaseConstruct);
       
   132 
       
   133     // Load resource files
       
   134     PBK2_PROFILE_START(Pbk2Profile::EAppUiResouceFileLoading);
       
   135     iUiControlsResourceFile.OpenL(KPbk2RomFileDrive,
       
   136         KDC_RESOURCE_FILES_DIR, KPbk2UiControlsDllResFileName);
       
   137     iCommandsResourceFile.OpenL(KPbk2RomFileDrive,
       
   138         KDC_RESOURCE_FILES_DIR, KPbk2CommandsDllResFileName);
       
   139     iCommonUiResourceFile.OpenL(KPbk2RomFileDrive,
       
   140         KDC_RESOURCE_FILES_DIR, KPbk2CommonUiDllResFileName);
       
   141     PBK2_PROFILE_END(Pbk2Profile::EAppUiResouceFileLoading);
       
   142 
       
   143     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   144         ("CPbk2AppUi::ConstructL(0x%x) Creating globals"), this);
       
   145     // Initialize global objects after loading the resource files
       
   146     PBK2_PROFILE_START(Pbk2Profile::EAppUiCreateGlobals);
       
   147     iAppServices = PhonebookDocument()->ApplicationServicesL();
       
   148     iAppServicesExtension = reinterpret_cast<MPbk2ApplicationServices2*>
       
   149         ( PhonebookDocument()->ApplicationServicesL()->
       
   150             MPbk2ApplicationServicesExtension(
       
   151                 KMPbk2ApplicationServicesExtension2Uid ) );
       
   152     PhonebookDocument()->CreateGlobalsL();
       
   153     PBK2_PROFILE_END(Pbk2Profile::EAppUiCreateGlobals);
       
   154 
       
   155     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   156         ("CPbk2AppUi::ConstructL(0x%x) Globals created"), this);
       
   157 
       
   158     // Create view explorer
       
   159     PBK2_PROFILE_START(Pbk2Profile::EAppUiCreateViewExplorer);
       
   160     iViewExplorer = CPbk2ViewExplorer::NewL( *this );
       
   161     PBK2_PROFILE_END(Pbk2Profile::EAppUiCreateViewExplorer);
       
   162 
       
   163     // Create AppUi extension
       
   164     PBK2_PROFILE_START(Pbk2Profile::EAppUiCreateAppUiExtension);
       
   165     MPbk2UIExtensionFactory* extFactory =
       
   166         PhonebookDocument()->ExtensionManager().FactoryL();
       
   167     iAppUiExtension = extFactory->CreatePbk2AppUiExtensionL
       
   168         ( iAppServices->ContactManager() );
       
   169     PBK2_PROFILE_END(Pbk2Profile::EAppUiCreateAppUiExtension);
       
   170 
       
   171     // Create tab group
       
   172     PBK2_PROFILE_START(Pbk2Profile::EViewExplorerConstructionCreateTabGroup);
       
   173     // Allow extensions to extend the tab group
       
   174     CPbk2TabGroupContainerExtensionModifier* tabGroupModifier =
       
   175             CPbk2TabGroupContainerExtensionModifier::NewLC(
       
   176                     *iAppUiExtension);
       
   177     // Read and create the tab groups
       
   178     iTabGroups = CPbk2TabGroupContainer::NewL( *iViewExplorer,
       
   179             *tabGroupModifier );
       
   180     CleanupStack::PopAndDestroy(tabGroupModifier);
       
   181     PBK2_PROFILE_END(Pbk2Profile::EViewExplorerConstructionCreateTabGroup);
       
   182 
       
   183     // Create start-up monitor
       
   184     PBK2_PROFILE_START(Pbk2Profile::EAppUiCreateStartupMonitor);
       
   185     iStartupMonitor = CPbk2StartupMonitor::NewL
       
   186         ( *iAppUiExtension, iAppServices->StoreProperties(),
       
   187           iAppServices->StoreConfiguration(),
       
   188           iAppServices->ContactManager() );
       
   189     iStartupMonitor->StartupBeginsL();
       
   190     PBK2_PROFILE_END(Pbk2Profile::EAppUiCreateStartupMonitor);
       
   191 
       
   192     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   193         ("CPbk2AppUi::ConstructL(0x%x) Opening AllContactsView"), this);
       
   194 
       
   195     // Open the all contacts view...
       
   196     Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   197         ViewSupplier().AllContactsViewL();
       
   198 
       
   199     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   200         ("CPbk2AppUi::ConstructL(0x%x) Opening stores"), this);
       
   201 
       
   202     // ...and only after that, order the stores to be opened
       
   203     PBK2_PROFILE_START(Pbk2Profile::EAppUiOpenStores);
       
   204     iAppServicesExtension->StoreManager().OpenStoresL();
       
   205     PBK2_PROFILE_END(Pbk2Profile::EAppUiOpenStores);
       
   206 
       
   207     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   208         ("CPbk2AppUi::ConstructL(0x%x) Launching names list"), this);
       
   209 
       
   210     // Create views
       
   211     PBK2_PROFILE_START(Pbk2Profile::EAppUiCreateViews);
       
   212     iViewExplorer->CreateViewsL();
       
   213     PBK2_PROFILE_END(Pbk2Profile::EAppUiCreateViews);
       
   214 
       
   215     CCoeEnv::Static()->AddForegroundObserverL(*this);
       
   216 
       
   217     if ( !IsForeground() )
       
   218         {
       
   219         if ( ExitHidesInBackground() )
       
   220             {
       
   221             LeavePbkInMemExitL();
       
   222             }
       
   223         }
       
   224     
       
   225     PBK2_PROFILE_END(Pbk2Profile::EAppUiConstruction);
       
   226 
       
   227     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   228         ("CPbk2AppUi::ConstructL end"));
       
   229     }
       
   230 
       
   231 // --------------------------------------------------------------------------
       
   232 // CPbk2AppUi::Document
       
   233 // --------------------------------------------------------------------------
       
   234 //
       
   235 CPbk2Document* CPbk2AppUi::PhonebookDocument() const
       
   236     {
       
   237     // Explicit cast: the document must always be of type CPbk2Document
       
   238     return static_cast<CPbk2Document*>( Document() );
       
   239     }
       
   240 
       
   241 // --------------------------------------------------------------------------
       
   242 // CPbk2AppUi::StoreManager
       
   243 // --------------------------------------------------------------------------
       
   244 //
       
   245 CPbk2StoreManager& CPbk2AppUi::StoreManager() const
       
   246     {
       
   247     return iAppServicesExtension->StoreManager();
       
   248     }
       
   249 
       
   250 // --------------------------------------------------------------------------
       
   251 // CPbk2AppUi::Pbk2Application
       
   252 // --------------------------------------------------------------------------
       
   253 //
       
   254 CPbk2Application* CPbk2AppUi::Pbk2Application() const
       
   255     {
       
   256     // Explicit cast: the application must always be of type CPbk2Application
       
   257     return static_cast<CPbk2Application*>( Application() );
       
   258     }
       
   259 
       
   260 // --------------------------------------------------------------------------
       
   261 // CPbk2AppUi::ExitL
       
   262 // --------------------------------------------------------------------------
       
   263 //
       
   264 void CPbk2AppUi::ExitL()
       
   265     {
       
   266     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ExitL"));
       
   267 
       
   268     TInt err = RProperty::Set( TUid::Uid( KPbk2PSUidPublic ),
       
   269                                KPhonebookOpenCompleted, EPhonebookClosed );
       
   270     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   271         ("CPbk2AppUi::ExitL set pubsub key to EPhonebookClosed (%d)"), err);
       
   272 
       
   273 #ifdef _DEBUG
       
   274     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ExitL real exit debug"));
       
   275     CAknViewAppUi::ProcessCommandL( EAknCmdExit );
       
   276 #else
       
   277     if ( ExitHidesInBackground() )
       
   278     	{
       
   279     	LeavePbkInMemExitL();
       
   280     	}
       
   281     else
       
   282     	{
       
   283     	PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ExitL real exit"));
       
   284 		CAknViewAppUi::ProcessCommandL( EAknCmdExit );
       
   285     	}   
       
   286 #endif
       
   287     
       
   288     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ExitL end"));
       
   289     }
       
   290 
       
   291 // --------------------------------------------------------------------------
       
   292 // CPbk2AppUi::ActivatePhonebookViewL
       
   293 // --------------------------------------------------------------------------
       
   294 //
       
   295 void CPbk2AppUi::ActivatePhonebookViewL
       
   296         ( TUid aViewId, const CPbk2ViewState* aViewState /*=NULL*/ )
       
   297     {
       
   298     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ActivatePhonebookViewL"));
       
   299     
       
   300     if ( aViewState )
       
   301         {
       
   302         HBufC8* stateBuf = aViewState->PackLC();
       
   303         ActivateLocalViewL(aViewId, CPbk2ViewState::Uid(), *stateBuf);
       
   304         CleanupStack::PopAndDestroy();  // stateBuf
       
   305         }
       
   306     else
       
   307         {
       
   308         ActivateLocalViewL(aViewId);
       
   309         }
       
   310     
       
   311     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::ActivatePhonebookViewL end"));
       
   312     }
       
   313 
       
   314 // --------------------------------------------------------------------------
       
   315 // CPbk2AppUi::ActiveView
       
   316 // --------------------------------------------------------------------------
       
   317 //
       
   318 CPbk2AppViewBase* CPbk2AppUi::ActiveView() const
       
   319     {
       
   320     // Explicit cast: iView must always be of type CPbk2AppViewBase
       
   321     return static_cast<CPbk2AppViewBase*>( iView );
       
   322     }
       
   323 
       
   324 // --------------------------------------------------------------------------
       
   325 // CPbk2AppUi::Pbk2ViewExplorer
       
   326 // --------------------------------------------------------------------------
       
   327 //
       
   328 MPbk2ViewExplorer* CPbk2AppUi::Pbk2ViewExplorer() const
       
   329     {
       
   330     return iViewExplorer;
       
   331     }
       
   332 
       
   333 // --------------------------------------------------------------------------
       
   334 // CPbk2AppUi::Pbk2StartupMonitor
       
   335 // --------------------------------------------------------------------------
       
   336 //
       
   337 MPbk2StartupMonitor* CPbk2AppUi::Pbk2StartupMonitor() const
       
   338     {
       
   339     return iStartupMonitor;
       
   340     }
       
   341 
       
   342 // --------------------------------------------------------------------------
       
   343 // CPbk2AppUi::TabGroup
       
   344 // --------------------------------------------------------------------------
       
   345 //
       
   346 CPbk2TabGroupContainer* CPbk2AppUi::TabGroups() const
       
   347     {
       
   348     return iTabGroups;
       
   349     }
       
   350 
       
   351 // --------------------------------------------------------------------------
       
   352 // CPbk2AppUi::KeyEventHandler
       
   353 // --------------------------------------------------------------------------
       
   354 //
       
   355 MPbk2KeyEventHandler& CPbk2AppUi::KeyEventHandler()
       
   356     {
       
   357     return *this;
       
   358     }
       
   359 
       
   360 // --------------------------------------------------------------------------
       
   361 // CPbk2AppUi::ApplicationServices
       
   362 // --------------------------------------------------------------------------
       
   363 //
       
   364 MPbk2ApplicationServices& CPbk2AppUi::ApplicationServices() const
       
   365     {
       
   366     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   367         ("CPbk2AppUi::ApplicationServices() returning 0x%x"), iAppServices );
       
   368 
       
   369     return *iAppServices;
       
   370     }
       
   371 
       
   372 // --------------------------------------------------------------------------
       
   373 // CPbk2AppUi::HandleCommandL
       
   374 // --------------------------------------------------------------------------
       
   375 //
       
   376 void CPbk2AppUi::HandleCommandL( TInt aCommand )
       
   377     {
       
   378     switch ( aCommand )
       
   379         {
       
   380         case EEikCmdExit:
       
   381             {
       
   382             // Standard exit command
       
   383             CmdExit();
       
   384             break;
       
   385             }
       
   386             
       
   387         case EAknCmdHideInBackground:
       
   388         	{
       
   389             // Leave app in ram
       
   390         	LeavePbkInMemExitL();
       
   391         	break;
       
   392         	}
       
   393 
       
   394         case EAknCmdExit:
       
   395         case EAknSoftkeyExit:
       
   396         case EPbk2CmdExit:
       
   397             {
       
   398             // Perhaps leave app in ram
       
   399             ExitL();
       
   400             break;
       
   401             }      
       
   402             
       
   403         case EAknSoftkeyBack:
       
   404             {
       
   405             iViewExplorer->ActivatePreviousViewL( NULL );
       
   406             break;
       
   407             }
       
   408 
       
   409         default:
       
   410             {
       
   411             CAknViewAppUi::HandleCommandL( aCommand );
       
   412             break;
       
   413             }
       
   414         }
       
   415     }
       
   416 
       
   417 // --------------------------------------------------------------------------
       
   418 // CPbk2AppUi::ExitApplication
       
   419 // --------------------------------------------------------------------------
       
   420 //
       
   421 void CPbk2AppUi::ExitApplication()
       
   422     {
       
   423     Exit();
       
   424     }
       
   425 
       
   426 // --------------------------------------------------------------------------
       
   427 // CPbk2AppUi::HandleGainingForeground
       
   428 // --------------------------------------------------------------------------
       
   429 //
       
   430 void CPbk2AppUi::HandleGainingForeground()
       
   431     {    
       
   432     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::HandleGainingForeground"));
       
   433 
       
   434     if ( ExitHidesInBackground() )
       
   435         {
       
   436         TRAP_IGNORE( iStartupMonitor->RestartStartupL() );
       
   437         }
       
   438     
       
   439     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::HandleGainingForeground end"));
       
   440     }
       
   441 
       
   442 // --------------------------------------------------------------------------
       
   443 // CPbk2AppUi::HandleLosingForeground
       
   444 // --------------------------------------------------------------------------
       
   445 //
       
   446 void CPbk2AppUi::HandleLosingForeground()
       
   447     {
       
   448     PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING(
       
   449             "void CPbk2AppUi::HandleLosingForeground" ) );    
       
   450 
       
   451     // we need to close possible popup menu when application is sent to
       
   452     // background. Otherwise AvKon will likely crash since its
       
   453     // intermediate state array is corrupted.
       
   454     
       
   455     // make sure we have a view
       
   456     if (ActiveView())
       
   457         {
       
   458         ActiveView()->ClosePopup();
       
   459         }
       
   460     
       
   461     PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING(
       
   462                 "void CPbk2AppUi::HandleLosingForeground end" ) );
       
   463     }
       
   464 
       
   465 // --------------------------------------------------------------------------
       
   466 // CPbk2AppUi::DynInitMenuPaneL
       
   467 // --------------------------------------------------------------------------
       
   468 //
       
   469 void CPbk2AppUi::DynInitMenuPaneL
       
   470         ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
   471     {
       
   472     // All menu filtering happens elsewhere
       
   473     }
       
   474 
       
   475 // --------------------------------------------------------------------------
       
   476 // CPbk2AppUi::HandleKeyEventL
       
   477 // --------------------------------------------------------------------------
       
   478 //
       
   479 TKeyResponse CPbk2AppUi::HandleKeyEventL
       
   480         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   481     {
       
   482     if (Pbk2ProcessKeyEventL(aKeyEvent, aType))
       
   483         {
       
   484         return EKeyWasConsumed;
       
   485         }
       
   486     return EKeyWasNotConsumed;
       
   487     }
       
   488 
       
   489 // --------------------------------------------------------------------------
       
   490 // CPbk2AppUi::HandleResourceChangeL
       
   491 // --------------------------------------------------------------------------
       
   492 //
       
   493 void CPbk2AppUi::HandleResourceChangeL(TInt aType)
       
   494     {
       
   495     CAknAppUiBase::HandleResourceChangeL( aType );
       
   496 
       
   497     // This is needed to change the application icon when the skin changes
       
   498     // (especially if a contact with a thumbnail is currently selected
       
   499     // and the app icon is not visible)
       
   500     CEikStatusPane* pane = StatusPane();
       
   501     if ( pane )
       
   502         {
       
   503         pane->HandleResourceChange( aType );
       
   504         }
       
   505     }
       
   506 
       
   507 // --------------------------------------------------------------------------
       
   508 // CPbk2AppUi::HandleForegroundEventL
       
   509 // --------------------------------------------------------------------------
       
   510 //
       
   511 void CPbk2AppUi::HandleForegroundEventL( TBool aForeground )
       
   512     {
       
   513     iAppServicesExtension->StoreManager().EnableCompression( aForeground );
       
   514 
       
   515     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
   516     }
       
   517 
       
   518 // --------------------------------------------------------------------------
       
   519 // CPbk2AppUi::Pbk2ProcessKeyEventL
       
   520 // --------------------------------------------------------------------------
       
   521 //
       
   522 TBool CPbk2AppUi::Pbk2ProcessKeyEventL
       
   523         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   524     {
       
   525     return iTabGroups->HandleNavigationKeyEventL( aKeyEvent, aType );
       
   526     }
       
   527 
       
   528 // --------------------------------------------------------------------------
       
   529 // CPbk2AppUi::CmdExit
       
   530 // --------------------------------------------------------------------------
       
   531 //
       
   532 inline void CPbk2AppUi::CmdExit()
       
   533     {
       
   534     CAknViewAppUi::Exit();
       
   535     }
       
   536 
       
   537 // --------------------------------------------------------------------------
       
   538 // CPbk2AppUi::LocalVariationFeatureEnabled
       
   539 // --------------------------------------------------------------------------
       
   540 //
       
   541 TBool CPbk2AppUi::LocalVariationFeatureEnabled( TInt aFeatureFlag )
       
   542     {
       
   543     TBool ret( EFalse );
       
   544     TInt lvFlags( KErrNotFound );
       
   545     CRepository* key = NULL;
       
   546     // Read local variation flags
       
   547     TRAPD( err, key =
       
   548             CRepository::NewL( TUid::Uid( KCRUidPhonebook ) ) );
       
   549     // if NewL fails do not set iLVFlags, new query is made next time
       
   550     if ( err == KErrNone )
       
   551         {
       
   552         err = key->Get( KPhonebookLocalVariationFlags, lvFlags );
       
   553         if ( err != KErrNone )
       
   554             {
       
   555             // If there were problems reading the flags,
       
   556             // assume everything is off
       
   557             lvFlags = 0;
       
   558             }
       
   559         delete key;
       
   560         }
       
   561 
       
   562     if ( lvFlags != KErrNotFound )
       
   563         {
       
   564         ret = lvFlags & aFeatureFlag;
       
   565         }
       
   566 
       
   567     return ret;
       
   568     }
       
   569 
       
   570 // --------------------------------------------------------------------------
       
   571 // CPbk2AppUi::LeavePbkInMemExitL
       
   572 // --------------------------------------------------------------------------
       
   573 //
       
   574 void CPbk2AppUi::LeavePbkInMemExitL()
       
   575 	{
       
   576 	PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::LeavePbkInMemExitL"));
       
   577 	
       
   578 	// Diasable bring to foreground on view activation event
       
   579 	SetCustomControl(1);
       
   580 	
       
   581 	// Hide application in background
       
   582 	HideInBackground();
       
   583 	 
       
   584 	// Activation of Names list view will send application to
       
   585 	// background. Application can not be sent here to background
       
   586 	// because  activation is asynchronous operation and application
       
   587 	// could be set to background before the view activation.
       
   588 	CPbk2ViewState* state = CPbk2ViewState::NewLC();
       
   589 	            state->SetFlags( CPbk2ViewState::EInitialized |
       
   590 	                CPbk2ViewState::ESendToBackground );
       
   591 	
       
   592 	ActivatePhonebookViewL( Phonebook2::KPbk2NamesListViewUid, state );
       
   593 	
       
   594 	CleanupStack::PopAndDestroy( state );
       
   595 	
       
   596 	PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2AppUi::LeavePbkInMemExitL end"));
       
   597 	}
       
   598 //  End of File