phonebookui/Phonebook/App/src/CPbkAppUi.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPbkAppUi.h"       // This class' declaration
       
    21 
       
    22 #include <pbkconfig.hrh>
       
    23 #include <barsread.h>        // TResourceReader
       
    24 #include <eikmenup.h>
       
    25 #include <aknnavide.h>       // CAknNavigationDecorator
       
    26 #include <aknnotewrappers.h>
       
    27 #include <FeatMgr.h>
       
    28 #include <hlplch.h>          // HlpLauncher
       
    29 
       
    30 #include <Phonebook.rsg>     // Phonebook resources
       
    31 #include "CPbkApplication.h" // Phonebook application class
       
    32 #include "CPbkDocument.h"    // Phonebook document class
       
    33 #include "PbkAppViewFactory.h"   // Application view factory
       
    34 #include "CViewActivationTransactionImpl.h"
       
    35 #include "CPbkAppGlobals.h"
       
    36 #include "CPbkViewNavigator.h"
       
    37 #include "CPbkStartupView.h"
       
    38 
       
    39 //SendUi
       
    40 #include <sendui.h>                 // Send UI API
       
    41 #include <SenduiMtmUids.h>          // Send UI MTM uids
       
    42 
       
    43 
       
    44 // PbkEng.dll header files
       
    45 #include <DigViewGraph.h>
       
    46 
       
    47 // PbkView.dll header files
       
    48 #include <CPbkViewState.h>
       
    49 #include <CPbkCompressUiImpl.h>  // Phonebook compression UI
       
    50 #include <CPbkFFSCheck.h>
       
    51 
       
    52 // PbkUI.dll header files
       
    53 #include <CPbkAppViewBase.h>
       
    54 #include <MPbkCommandFactory.h>
       
    55 
       
    56 // From PbkExt
       
    57 #include <MPbkExtensionFactory.h>
       
    58 #include <CPbkExtGlobals.h>
       
    59 
       
    60 // Engine classes
       
    61 #include    <CPbkContactEngine.h> // Phonebook engine class
       
    62 #include    <CPbkConstants.h>
       
    63 
       
    64 // Debugging headers
       
    65 #include <pbkdebug.h>
       
    66 #include "PbkProfiling.h"
       
    67 
       
    68 
       
    69 // CONSTANTS
       
    70 // View UID constants
       
    71 const TUid CPbkAppUi::KPbkNamesListViewUid          = { EPbkNamesListViewId         };
       
    72 const TUid CPbkAppUi::KPbkGroupsListViewUid         = { EPbkGroupsListViewId        };
       
    73 const TUid CPbkAppUi::KPbkGroupMembersListViewUid   = { EPbkGroupMembersListViewId  };
       
    74 const TUid CPbkAppUi::KPbkContactInfoViewUid        = { EPbkContactInfoViewId       };
       
    75 const TUid CPbkAppUi::KPbkPhotoViewUid              = { EPbkPhotoViewViewId         };
       
    76 const TUid CPbkAppUi::KPbkPersonalInfoViewUid       = { EPbkPersonalInfoViewId      };
       
    77 
       
    78 /// Unnamed namespace for local definitions
       
    79 namespace {
       
    80 
       
    81 // LOCAL CONSTANTS AND MACROS
       
    82 #ifdef _DEBUG
       
    83 enum TPanicCode
       
    84     {
       
    85     EPanicPreCond_ConstructL = 1,
       
    86     EPanicPostCond_ConstructL,
       
    87     };
       
    88     
       
    89 #else
       
    90 // Amount of free heap memory required for always-on functionality
       
    91 const TInt KAlwaysOnMinimumTreshold = 200*1024; // 200 kB
       
    92 
       
    93 #endif
       
    94 
       
    95 
       
    96 // ==================== LOCAL FUNCTIONS ====================
       
    97 
       
    98 #ifdef _DEBUG
       
    99 void Panic(TPanicCode aReason)
       
   100     {
       
   101     _LIT(KPanicText, "CPbkAppUi");
       
   102     User::Panic(KPanicText, aReason);
       
   103     }
       
   104 #endif
       
   105 
       
   106 }  // namespace
       
   107 
       
   108 
       
   109 // ================= MEMBER FUNCTIONS =======================
       
   110 
       
   111 CPbkAppUi::CPbkAppUi() :
       
   112     iViewResourceFile(*iCoeEnv)
       
   113     {
       
   114     }
       
   115 
       
   116 inline void CPbkAppUi::CreateEngineL()
       
   117     {
       
   118     TRAPD(err, PbkDocument()->CreateEngineL(EFalse));
       
   119     if (err == KErrCorrupt)
       
   120         {
       
   121         // Database cannot be opened or recoverd -> replace it with an
       
   122         // empty one. Always notify caller about DB corruption, even if
       
   123         // replacing fails.
       
   124         CAknNoteWrapper* note = new(ELeave) CAknNoteWrapper;
       
   125         note->ExecuteLD(R_PBK_NOTE_DATABASE_CORRUPTED);
       
   126         PbkDocument()->CreateEngineL(ETrue);
       
   127         }
       
   128     else if (err != KErrNone)
       
   129         {
       
   130         User::Leave(err);
       
   131         }
       
   132     }
       
   133 
       
   134 /**
       
   135  * Loads view navigation graph from resources.
       
   136  */
       
   137 inline void CPbkAppUi::ReadViewGraphL()
       
   138     {
       
   139     TResourceReader reader;
       
   140     iCoeEnv->CreateResourceReaderLC(reader, R_PBK_VIEWNODES);
       
   141     iViewGraph = CDigViewGraph::NewL(reader);
       
   142     CleanupStack::PopAndDestroy(); // reader
       
   143 
       
   144     iAppUiExtension->ApplyExtensionViewGraphChangesL(*iViewGraph);
       
   145     }
       
   146 
       
   147 void CPbkAppUi::ConstructL()
       
   148     {
       
   149     __ASSERT_DEBUG(
       
   150         !iViewGraph && !iNaviPane && !iCompressUi,
       
   151         Panic(EPanicPreCond_ConstructL));
       
   152 
       
   153     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("PHONEBOOK: started"));
       
   154 
       
   155     // Init base class
       
   156     __PBK_PROFILE_START(PbkProfiling::EAppUiBaseConstruct);
       
   157     BaseConstructL(EAknEnableSkin);
       
   158     __PBK_PROFILE_END(PbkProfiling::EAppUiBaseConstruct);
       
   159 
       
   160     // Initialize feature manager
       
   161     FeatureManager::InitializeLibL();
       
   162 
       
   163     // Create Phonebook engine
       
   164     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Engine construct begin"));
       
   165     CreateEngineL();
       
   166     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Engine construct end"));
       
   167     PbkDocument()->CreateGlobalsL();
       
   168 
       
   169     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Extension construct start"));
       
   170     CPbkExtGlobals* extGlobal = CPbkExtGlobals::InstanceL();
       
   171     extGlobal->PushL();
       
   172     iAppUiExtension = extGlobal->FactoryL().
       
   173         CreatePbkAppUiExtensionL(*PbkDocument()->Engine());
       
   174     CleanupStack::PopAndDestroy(extGlobal);
       
   175     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Extension construct end"));
       
   176 
       
   177     // Create UI elements
       
   178     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Viewnavi construct start"));
       
   179     __PBK_PROFILE_START(PbkProfiling::EViewNaviConstruct);
       
   180     ReadViewGraphL();
       
   181     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   182         (StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
       
   183     iViewNavigator = CPbkViewNavigator::NewL(*iViewGraph, *this);
       
   184     __PBK_PROFILE_END(PbkProfiling::EViewNaviConstruct);
       
   185     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Viewnavi construct end"));
       
   186 
       
   187     // Load view dll resource file
       
   188     iViewResourceFile.OpenL();
       
   189     // Create FFS space checker
       
   190     iFFSCheck = CPbkFFSCheck::NewL(iCoeEnv);
       
   191     // Create the compression UI
       
   192     iCompressUi = CPbkCompressUiImpl::NewL(*PbkDocument()->Engine());
       
   193     // Enable compression always
       
   194     iCompressUi->EnableCompression(ETrue);
       
   195 
       
   196     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Views construct start"));
       
   197     CPbkStartupView* startupView = CPbkStartupView::NewLC(*iAppUiExtension);
       
   198     AddViewL(startupView);
       
   199     CleanupStack::Pop(startupView);
       
   200     SetDefaultViewL(*startupView);
       
   201     CreateViewsL();
       
   202     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Views construct end"));
       
   203 
       
   204     CCoeEnv::Static()->AddForegroundObserverL(*this);
       
   205 
       
   206     __PBK_PROFILE_START(PbkProfiling::EStartupViewActivation);
       
   207 
       
   208     __ASSERT_DEBUG(
       
   209         iViewGraph && iNaviPane && iCompressUi,
       
   210         Panic(EPanicPostCond_ConstructL));
       
   211     }
       
   212 
       
   213 CPbkAppUi::~CPbkAppUi()
       
   214     {
       
   215     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("CPbkAppUi::~CPbkAppUi()"));
       
   216 
       
   217     CCoeEnv::Static()->RemoveForegroundObserver(*this);
       
   218 
       
   219     // delete data members
       
   220     delete iCompressUi;
       
   221     delete iFFSCheck;
       
   222     iViewResourceFile.Close();
       
   223     // Application views will be deleted by the base class destructor.
       
   224     delete iViewNavigator;
       
   225     delete iViewGraph;
       
   226     delete iAppGlobals;
       
   227     Release(iAppUiExtension);
       
   228 
       
   229     FeatureManager::UnInitializeLib();
       
   230     }
       
   231 
       
   232 CPbkDocument* CPbkAppUi::PbkDocument() const
       
   233     {
       
   234     // Explicit cast: the document must always be of type CPbkDocument
       
   235     return static_cast<CPbkDocument*>(Document());
       
   236     }
       
   237 
       
   238 CPbkApplication* CPbkAppUi::PbkApplication() const
       
   239     {
       
   240     // Explicit cast: the application must always be of type CPbkApplication
       
   241     return static_cast<CPbkApplication*>(Application());
       
   242     }
       
   243 
       
   244 void CPbkAppUi::ActivatePhonebookViewL
       
   245         (TUid aViewId,
       
   246         const CPbkViewState* aViewState/*=NULL*/)
       
   247     {
       
   248     if (aViewState)
       
   249         {
       
   250         HBufC8* stateBuf = aViewState->PackLC();
       
   251         ActivateLocalViewL(aViewId, CPbkViewState::Uid(), *stateBuf);
       
   252         CleanupStack::PopAndDestroy();  // stateBuf
       
   253         }
       
   254     else
       
   255         {
       
   256         ActivateLocalViewL(aViewId);
       
   257         }
       
   258     }
       
   259 
       
   260 void CPbkAppUi::ActivatePreviousViewL
       
   261         (const CPbkViewState* aViewState /*=NULL*/)
       
   262     {
       
   263     // Find current view in the graph
       
   264     CDigViewNode* viewNode = iViewGraph->FindNodeWithViewId(iView->Id());
       
   265     if (viewNode)
       
   266         {
       
   267         // get previous node
       
   268         CDigViewNode* prevNode = viewNode->PreviousNode();
       
   269         if (!prevNode)
       
   270             {
       
   271             prevNode = viewNode->DefaultPreviousNode();
       
   272             }
       
   273         if (prevNode)
       
   274             {
       
   275             if (prevNode->ExitNode())
       
   276                 {
       
   277                 ExitL();
       
   278                 }
       
   279             else
       
   280                 {
       
   281                 ActivatePhonebookViewL(prevNode->ViewId(), aViewState);
       
   282                 }
       
   283             }
       
   284         }
       
   285     }
       
   286 
       
   287 CAknNavigationControlContainer* CPbkAppUi::NaviPane()
       
   288     {
       
   289     return iNaviPane;
       
   290     }
       
   291 
       
   292 void CPbkAppUi::FFSClCheckL(const MPbkCommandHandler& aCommandHandler,
       
   293                             TInt aBytesToWrite /*=0*/)
       
   294     {
       
   295     iFFSCheck->FFSClCheckL(aCommandHandler, aBytesToWrite);
       
   296     }
       
   297 
       
   298 CPbkAppUi::CViewActivationTransaction* CPbkAppUi::HandleViewActivationLC
       
   299         (const TUid& aViewId, const TVwsViewId& aPrevViewId,
       
   300         const TDesC* aTitlePaneText,
       
   301         const CEikImage* aContextPanePicture,
       
   302         TUint aFlags)
       
   303     {
       
   304     // Create and return an instance of view activation transaction
       
   305     return CViewActivationTransactionImpl::NewLC
       
   306         (*this, aViewId, aPrevViewId, aTitlePaneText,
       
   307         aContextPanePicture, aFlags);
       
   308     }
       
   309 
       
   310 CPbkAppGlobalsBase* CPbkAppUi::AppGlobalsL()
       
   311     {
       
   312     if (!iAppGlobals)
       
   313         {
       
   314         iAppGlobals = CPbkAppGlobals::NewL();
       
   315         }
       
   316     return iAppGlobals;
       
   317     }
       
   318 
       
   319 void CPbkAppUi::ExitL()
       
   320     {
       
   321     // Set this flag to EFalse to signal that we're either dying or going
       
   322     // to background.
       
   323     iIsRunningForeground = EFalse;
       
   324 
       
   325 #ifndef _DEBUG
       
   326 
       
   327     // Check that we have enough free heap memory to go to background.
       
   328     // User::Available() does not check for the possibility to grow the heap,
       
   329     // so we'll need to allocate a dummy block and release it immediately.
       
   330     TAny* tmp = User::Alloc(KAlwaysOnMinimumTreshold);
       
   331     delete tmp;
       
   332     if (!iEndKeyExit && tmp &&
       
   333         PbkDocument()->Engine()->Constants()->LocallyVariatedFeatureEnabled(
       
   334             EPbkLVAlwaysOnPhonebook))
       
   335         {
       
   336         CPbkViewState* state = CPbkViewState::NewLC();
       
   337         state->SetFlags(CPbkViewState::EInitialized | CPbkViewState::ESendToBackground);
       
   338         // Activation of Names list view will send application to background.
       
   339         // Application can not be sent here to background because
       
   340         // activation is asynchronous operation and application could be set
       
   341         // to background before the view activation.
       
   342         ActivatePhonebookViewL(KPbkNamesListViewUid, state);
       
   343         CleanupStack::PopAndDestroy();  // state
       
   344         }
       
   345     else
       
   346         {
       
   347         CAknViewAppUi::ProcessCommandL(EAknCmdExit);
       
   348         }
       
   349 #else // _DEBUG
       
   350     CAknViewAppUi::ProcessCommandL(EAknCmdExit);
       
   351 #endif // _DEBUG
       
   352     }
       
   353 
       
   354 void CPbkAppUi::Exit()
       
   355     {
       
   356     CPbkAppUiBase::Exit();
       
   357     }
       
   358 
       
   359 TBool CPbkAppUi::IsRunningForeground() const
       
   360     {
       
   361     return iIsRunningForeground;
       
   362     }
       
   363 
       
   364 /**
       
   365  * Returns true if aViewId is a phonebook view.
       
   366  */
       
   367 TBool CPbkAppUi::IsPhonebookView(const TVwsViewId& aViewId) const
       
   368     {
       
   369     if (aViewId.iAppUid == Application()->AppDllUid())
       
   370         {
       
   371         const CDigViewNode* viewNode =
       
   372             iViewGraph->FindNodeWithViewId(aViewId.iViewUid);
       
   373         return viewNode && !viewNode->ExitNode();
       
   374         }
       
   375     else
       
   376         {
       
   377         return EFalse;
       
   378         }
       
   379     }
       
   380 
       
   381 inline void CPbkAppUi::CmdExitL()
       
   382     {
       
   383     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("CPbkAppUi::CmdExitL()"));
       
   384     // notify views before the exit is executed
       
   385     CAknViewAppUi::ProcessCommandL(EPbkCmdExit);
       
   386     CAknViewAppUi::Exit();
       
   387     }
       
   388 
       
   389 void CPbkAppUi::SendAppToBackgroundL()
       
   390     {
       
   391     // Get the current task
       
   392     RWsSession ws;
       
   393     User::LeaveIfError(ws.Connect());
       
   394     TApaTaskList tasklist(ws);
       
   395 
       
   396     TApaTask task = tasklist.FindApp(Application()->AppDllUid());
       
   397     CleanupClosePushL(ws);
       
   398     if (task.Exists())
       
   399         {
       
   400         task.SendToBackground();
       
   401         }
       
   402     CleanupStack::PopAndDestroy(); // ws
       
   403     }
       
   404 
       
   405 void CPbkAppUi::HandleCommandL(TInt aCommand)
       
   406     {
       
   407     switch (aCommand)
       
   408         {
       
   409         case EAknCmdHelp:
       
   410             {
       
   411             HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(),
       
   412                 AppHelpContextL());
       
   413             break;
       
   414             }
       
   415 
       
   416         case EEikCmdExit:
       
   417             {
       
   418             // standard exit command
       
   419             CmdExitL();
       
   420             break;
       
   421             }
       
   422 
       
   423         case EAknSoftkeyExit:
       
   424         case EAknCmdExit:
       
   425         case EPbkCmdExit:
       
   426             {
       
   427             ExitL();
       
   428             break;
       
   429             }
       
   430 
       
   431         default:
       
   432             {
       
   433             break;
       
   434             }
       
   435         }
       
   436     }
       
   437 
       
   438 void CPbkAppUi::DynInitMenuPaneL
       
   439         (TInt aResourceId,
       
   440         CEikMenuPane* aMenuPane)
       
   441     {
       
   442     switch (aResourceId)
       
   443         {
       
   444         case R_PHONEBOOK_SYSTEM_MENU:
       
   445             {
       
   446             if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   447                 {
       
   448                 // remove non-supported help from menu
       
   449                 aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
       
   450                 }
       
   451             break;
       
   452             }
       
   453 
       
   454         default:
       
   455             {
       
   456             break;
       
   457             }
       
   458         }
       
   459     }
       
   460 
       
   461 TKeyResponse CPbkAppUi::HandleKeyEventL
       
   462         (const TKeyEvent& aKeyEvent,
       
   463         TEventCode aType)
       
   464     {
       
   465     if (PbkProcessKeyEventL(aKeyEvent, aType))
       
   466         {
       
   467         PBK_DEBUG_PRINT(PBK_DEBUG_STRING("CPbkAppUi::HandleKeyEventL() processed key event"));
       
   468         return EKeyWasConsumed;
       
   469         }
       
   470     return EKeyWasNotConsumed;
       
   471     }
       
   472 
       
   473 void CPbkAppUi::HandleForegroundEventL(TBool aForeground)
       
   474     {
       
   475     // Call base class
       
   476     CAknViewAppUi::HandleForegroundEventL(aForeground);
       
   477     }
       
   478 
       
   479 void CPbkAppUi::HandleResourceChangeL(TInt aType)
       
   480     {
       
   481     CPbkAppUiBase::HandleResourceChangeL(aType);
       
   482     // This is needed to change the application
       
   483     // icon when the skin changes (especially if
       
   484     // a contact with a thumbnail is currently
       
   485     // selected and the app icon is not visible)
       
   486     CEikStatusPane* pane = StatusPane();
       
   487     if (pane)
       
   488         {
       
   489         pane->HandleResourceChange(aType);
       
   490         }
       
   491 
       
   492     // The resource change event has to be forwarded to
       
   493     // view navigator
       
   494     if(iViewNavigator)
       
   495         {
       
   496         iViewNavigator->HandleResourceChange(aType);
       
   497         }
       
   498     }
       
   499 
       
   500 void CPbkAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
       
   501     {
       
   502     switch (aEvent.Type())
       
   503         {
       
   504         case KAknUidValueEndKeyCloseEvent:
       
   505             {
       
   506             // Make a real exit on end-key event
       
   507             iEndKeyExit = ETrue;
       
   508             } // fallthrough
       
   509         default:
       
   510             {
       
   511             CPbkAppUiBase::HandleWsEventL(aEvent, aDestination);
       
   512             break;
       
   513             }
       
   514         }
       
   515     }
       
   516 
       
   517 TBool CPbkAppUi::PbkProcessKeyEventL
       
   518         (const TKeyEvent& aKeyEvent, TEventCode aType)
       
   519     {
       
   520     // Ensure that navigator has already been constructed
       
   521     if (iViewNavigator)
       
   522         {
       
   523         return iViewNavigator->HandleNavigationKeyEventL(aKeyEvent,aType);
       
   524         }
       
   525     return EFalse;
       
   526     }
       
   527 
       
   528 void CPbkAppUi::CreateViewsL()
       
   529     {
       
   530     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("CPbkAppUi::CreateViewsL start"));
       
   531 
       
   532     CPbkAppViewFactory* factory = CPbkAppViewFactory::NewLC();
       
   533 
       
   534     // Create and add application views
       
   535     for (TInt i = 0; i < iViewGraph->Count(); ++i)
       
   536         {
       
   537         const CDigViewNode& viewNode = (*iViewGraph)[i];
       
   538         if (!viewNode.ExitNode())
       
   539             {
       
   540             CAknView* view = factory->CreateAppViewLC(viewNode.ViewId());
       
   541             PBK_DEBUG_PRINT(PBK_DEBUG_STRING(
       
   542                 "CPbkAppUi::CreateViewsL created view %d"), viewNode.ViewId());
       
   543 
       
   544             AddViewL(view);
       
   545             CleanupStack::Pop();  // view
       
   546             }
       
   547         }
       
   548     CleanupStack::PopAndDestroy(); // factory
       
   549     }
       
   550 
       
   551 void CPbkAppUi::HandleGainingForeground()
       
   552     {
       
   553     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("void CPbkAppUi::HandleGainingForeground()"));
       
   554 
       
   555     if (PbkDocument()->Engine()->Constants()->
       
   556             LocallyVariatedFeatureEnabled(EPbkLVAlwaysOnPhonebook))
       
   557         {
       
   558         // If phonebook is running in background (i.e. user has exited it) the
       
   559         // Names list view is active and it is incorrectly marked as being in
       
   560         // foreground (this happens during the view's activation
       
   561         // when exiting Phonebook). Therefore its HandleForegroundEventL() will
       
   562         // not be called unless we first mark the view explicitly as being in
       
   563         // background. Now when CPbkAppUi::HandleForegroundEventL(ETrue) is
       
   564         // called, the NamesListView's HandleForegroundEventL() is called
       
   565         // correctly
       
   566         if (!iIsRunningForeground && iView &&
       
   567             iView->Id() == KPbkNamesListViewUid)
       
   568             {
       
   569             TRAPD(err, HandleForegroundEventL(EFalse));
       
   570             if (KErrNone != err)
       
   571                 {
       
   572                 CCoeEnv::Static()->HandleError(err);
       
   573                 }
       
   574             }        
       
   575         // this if-case is here, because if the end-key is pressed to execute 
       
   576         // the exit, the activation of names list view causes additional call of
       
   577         // HandleGainingForeground and HandleLosingForeground methods. 
       
   578         // In end-key-exit-case the phonebook should not be shown in fast
       
   579         // swap menu, and the additional gaining foreground call causes
       
   580         // the visibility of phonebook in fast swap if it is not 
       
   581         // blocked.        
       
   582         if ( !iEndKeyExit )
       
   583             {
       
   584             iIsRunningForeground = ETrue;
       
   585             }
       
   586         else
       
   587             {            
       
   588             iEndKeyExit = EFalse;
       
   589             }
       
   590         HideApplicationFromFSW(!iIsRunningForeground);
       
   591         }
       
   592     }
       
   593 
       
   594 void CPbkAppUi::HandleLosingForeground()
       
   595     {
       
   596     PBK_DEBUG_PRINT(PBK_DEBUG_STRING("void CPbkAppUi::HandleLosingForeground()"));
       
   597 
       
   598     if (PbkDocument()->Engine()->Constants()->
       
   599             LocallyVariatedFeatureEnabled(EPbkLVAlwaysOnPhonebook))
       
   600         {
       
   601         HideApplicationFromFSW(!iIsRunningForeground);
       
   602         }
       
   603     }
       
   604 
       
   605 //  End of File