- /*
- * ============================================================================
- * Name : CEmailExampleAppUi from EmailExampleAppUi.cpp
- * Part of : EmailExample
- * Created : 09/11/2003 by Forum Nokia
- * Implementation notes:
- * Basic framework class constructed initially with appwizard
- *
- * Version : 1.0
- * Copyright: Nokia Corporation
- * ============================================================================
- */
- //application
- #include "EmailExampleAui.h"
- #include "EmailExampleWin.h"
- #include "EmailExampleVer.h"
- #include "EmailExample.hrh"
- //symbian
- #include <EikEnv.h>
- #include <EikApp.h>
- #include <EikDoc.h>
- #include <EikTBar.h> //for CEikButtonGroup
- #include <EikMenuP.h> //for menupane
- #include <eikspane.h> //for statuspane
- //resource specific
- #include <EmailExample.rsg>
- #include <Eikon.rsg>
- CEmailExampleAppUi::CEmailExampleAppUi()
- {}
- CEmailExampleAppUi::~CEmailExampleAppUi()
- {
- RemoveFromStack(iMainWindow);
- delete iMainWindow;
- }
- void CEmailExampleAppUi::ConstructL()
- {
- BaseConstructL();
- iMainWindow=new(ELeave) CEmailMainWindow(*this);
- iMainWindow->ConstructL();
- LoadIniFileL();
- iMainWindow->ActivateL();
- ShowToolBar();
- AddToStackL(iMainWindow);
- }
- // save current applciation settings to INI file
- void CEmailExampleAppUi::SaveIniFileL()
- {
- CEikApplication* app=(CEikApplication*)Document()->Application();
- CDictionaryStore* iniFile=app->OpenIniFileLC(iEikonEnv->FsSession());
- if(!iniFile)
- {
- return;
- }
- RDictionaryWriteStream writeStream;
- writeStream.AssignLC(*iniFile,KUidEmailExample);
- writeStream.WriteInt32L(iFullScreen);
- writeStream.CommitL();
- CleanupStack::PopAndDestroy(); // writeStream
- iniFile->CommitL();
- CleanupStack::PopAndDestroy(); // iniFile
- }
- // load application settings from INI file
- void CEmailExampleAppUi::LoadIniFileL()
- {
- CEikApplication* app=(CEikApplication*)Document()->Application();
- CDictionaryStore* iniFile=app->OpenIniFileLC(iEikonEnv->FsSession());
- TBool missingOrCorrupt=ETrue;
- if(iniFile)
- {
- TBool present=EFalse;
- TRAPD(err,present=iniFile->IsPresentL(KUidEmailExample));
- if(present)
- {
- RDictionaryReadStream readStream;
- readStream.OpenLC(*iniFile,KUidEmailExample);
- TRAP(err,iFullScreen=readStream.ReadInt32L());
- if(err==KErrNone)
- {
- if(err==KErrNone)
- {
- missingOrCorrupt=EFalse;
- }
- }
- CleanupStack::PopAndDestroy(); // readStream
- }
- CleanupStack::PopAndDestroy(); // iniFile
- }
- if(missingOrCorrupt)
- { // INI file missing or corrupt - use default settings
- iFullScreen=EFalse;
- }
- }
- void CEmailExampleAppUi::ShowToolBar()
- {
- iEikonEnv->AppUiFactory()->ToolBar()->MakeVisible(!iFullScreen);
- CEikStatusPane* statusPane=iEikonEnv->AppUiFactory()->StatusPane();
- if (statusPane)
- {
- statusPane->MakeVisible(!iFullScreen);
- }
- iMainWindow->SetRect(ClientRect());
- }
- TBool CEmailExampleAppUi::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aDocumentName,const TDesC& /*aTail*/)
- {
- return CEikAppUi::ProcessCommandParametersL(aCommand,aDocumentName);
- }
- void CEmailExampleAppUi::DynInitMenuPaneL(TInt aResource,CEikMenuPane* aMenuPane)
- {
- switch(aResource)
- {
- case R_EMAILEXAMPLEAPP_VIEW_MENU:
- if(iFullScreen)
- {
- aMenuPane->SetItemButtonState(EEmailExampleCmdFullScreen,EEikMenuItemSymbolOn);
- }
- break;
- default:
- break;
- }
- }
- void CEmailExampleAppUi::HandleCommandL(TInt aCommand)
- {
- switch(aCommand)
- {
- case EEmailExampleCmdFullScreen:
- {
- iFullScreen=!iFullScreen;
- ShowToolBar();
- iMainWindow->DrawDeferred();
- }
- break;
- case EEikCmdExit:
- {
- SaveIniFileL();
- SaveL();
- Exit();
- }
- break;
- default:
- {
- iMainWindow->HandleCommandL(aCommand);
- }
- break;
- }
- }
- void CEmailExampleAppUi::HandleForegroundEventL(TBool /*aForeground*/)
- {}