messagingappbase/smartmessaging/bva/src/BvaAppUi.cpp
branchRCL_3
changeset 27 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   Declares UI class for BVA application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <akntitle.h>
       
    21 #include <msgbiocontrol.h>
       
    22 #include <aknnotewrappers.h>      // CAknInformationNote
       
    23 #include <bva.rsg>
       
    24 #include "BvaContainer.h"
       
    25 #include "BvaDocument.h"
       
    26 #include "BvaAppUi.h"
       
    27 #include "bvalog.h"
       
    28 
       
    29 #include <featmgr.h>
       
    30 #include <hlplch.h>                 // for HlpLauncher
       
    31 #include <AiwCommon.hrh>
       
    32 // CONSTANTS
       
    33 const TInt KBvaFirstFreeCommandId = 10000;
       
    34 _LIT(KBVAAppUI,"BVA AppUI");
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 void CBvaAppUi::ConstructL()
       
    38     {
       
    39     LOG("CBvaAppUi::ConstructL begin");
       
    40     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
    41     iContainer = new (ELeave) CBvaContainer;
       
    42     iContainer->ConstructL(ClientRect());
       
    43     AddToStackL( iContainer );
       
    44     iEikonEnv->AppUiFactory()->MenuBar()->SetContextMenuTitleResourceId( R_BVA_CONTEXT_MENUBAR );
       
    45     iFileHandleSize = -1;
       
    46 	FeatureManager::InitializeLibL();
       
    47     
       
    48 	//assume that the loading of BC can fail with any arbitrary
       
    49     //leave code or not to happen at all...
       
    50     iBioControlLoadFailed = ETrue;
       
    51 	LOG("CBvaAppUi::ConstructL end");
       
    52     }
       
    53 
       
    54 void CBvaAppUi::LoadBioControlL( const RFile& aFile )
       
    55 	{
       
    56 	LOG("CBvaAppUi::LoadBioControlL begin");
       
    57     TInt err0 = aFile.Size( iFileHandleSize );
       
    58 	if ( err0 )
       
    59 		{
       
    60 		iFileHandleSize = 0;
       
    61 		}
       
    62 
       
    63 	TRAPD(err, iContainer->LoadBioControlL( aFile ));
       
    64 
       
    65     if( err == KErrMsgBioMessageNotValid )
       
    66         {
       
    67         // no note is displayed as that is handled by the launching application
       
    68         // Exit application.
       
    69         HandleCommandL(EAknCmdExit);
       
    70         }
       
    71 
       
    72     else if ( err == KErrNone )
       
    73         {
       
    74         //set the flag to EFalse as the BIO control has been instantiated
       
    75         //succesfully
       
    76         iBioControlLoadFailed = EFalse;
       
    77 
       
    78         //
       
    79         // Update the heading
       
    80         //
       
    81         HBufC* text = iContainer->BioControl().HeaderTextL();
       
    82         CleanupStack::PushL(text);
       
    83         CAknTitlePane* titlePane = STATIC_CAST(
       
    84             CAknTitlePane*,
       
    85             StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
    86         titlePane->SetTextL( *text );
       
    87         CleanupStack::PopAndDestroy(text); // text
       
    88         }
       
    89 
       
    90     else
       
    91         {
       
    92         User::LeaveIfError(err);
       
    93         }
       
    94     LOG("CBvaAppUi::LoadBioControlL end");
       
    95 	}
       
    96 
       
    97 CBvaAppUi::~CBvaAppUi()
       
    98     {
       
    99 	if (iContainer)
       
   100 		{
       
   101 		RemoveFromStack(iContainer);
       
   102 		delete iContainer;
       
   103 		}
       
   104     FeatureManager::UnInitializeLib();
       
   105     }
       
   106 
       
   107 void CBvaAppUi::DynInitMenuPaneL(
       
   108     TInt aResourceId, CEikMenuPane* aMenuPane)
       
   109     {
       
   110 	__ASSERT_ALWAYS(aMenuPane,Panic(EMenuPaneNull));
       
   111     if (aResourceId == R_BVA_MENU)
       
   112         {
       
   113         // disable aiw menu item for calender, enabled in vcalbc
       
   114         aMenuPane->SetItemDimmed( KAiwCmdSaveToCalendar, ETrue );
       
   115 
       
   116         // Check that datafile exist
       
   117         if (!NoDataFile())
       
   118             {
       
   119             TUint32 permBio = 0;
       
   120             if(iContainer->IsBioControl())
       
   121                 {
       
   122                 permBio = iContainer->BioControl().OptionMenuPermissionsL();
       
   123                 }
       
   124 
       
   125             if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) || !( permBio & EMsgBioHelp ))
       
   126                 {
       
   127                 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   128                 }
       
   129             if(iContainer->IsBioControl())
       
   130                 {
       
   131                 iContainer->BioControl().SetMenuCommandSetL(*aMenuPane);
       
   132                 }
       
   133             }
       
   134         }
       
   135     else if ( aResourceId == R_BVA_CONTEXT_MENU )
       
   136         {
       
   137         // Check that datafile exist
       
   138         if ( !NoDataFile() )
       
   139             {
       
   140             if(iContainer->IsBioControl())
       
   141                 {
       
   142                 iContainer->BioControl().SetMenuCommandSetL( *aMenuPane );
       
   143                 }
       
   144             }
       
   145         }
       
   146 
       
   147     }
       
   148 
       
   149 TKeyResponse CBvaAppUi::HandleKeyEventL(
       
   150     const TKeyEvent& aKeyEvent,TEventCode aType)
       
   151     {
       
   152     if (NoDataFile())
       
   153         {
       
   154         // someone launched this app the wrong way.
       
   155         return EKeyWasNotConsumed;
       
   156         }
       
   157 
       
   158     return iContainer->OfferKeyEventL(aKeyEvent, aType);
       
   159     }
       
   160 
       
   161 void CBvaAppUi::HandleCommandL(TInt aCommand)
       
   162     {
       
   163     LOG("CBvaAppUi::HandleCommandL begin");
       
   164     switch ( aCommand )
       
   165         {
       
   166         case EAknSoftkeyBack:
       
   167         case EAknCmdExit:
       
   168         case EEikCmdExit: // seems that currently it is this one
       
   169             {
       
   170             //closing the BVA application is not possible
       
   171             //until the BIO control has been created, unless the
       
   172             //instantiation of the control has failed altogether!
       
   173             if( iBioControlLoadFailed || iContainer->IsBioControl() )
       
   174                 {
       
   175                 if (iDoorObserver   )
       
   176                     {
       
   177                     iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::ENoChanges);
       
   178                     }
       
   179                 Exit();
       
   180                 }
       
   181             break;
       
   182             }
       
   183         case EAknCmdHelp:
       
   184             {
       
   185             LaunchHelpL();
       
   186             break;
       
   187             }
       
   188         case EAknSoftkeyContextOptions:
       
   189             ProcessCommandL(EAknSoftkeyContextOptions);
       
   190         break;	
       
   191         default:
       
   192             break;
       
   193         }
       
   194     if ( aCommand >=  FirstFreeCommand() && !NoDataFile() )
       
   195         {
       
   196         iContainer->BioControl().HandleBioCommandL(aCommand);
       
   197         }
       
   198     LOG("CBvaAppUi::HandleCommandL end");
       
   199     }
       
   200 
       
   201 TInt CBvaAppUi::FirstFreeCommand() const
       
   202     {
       
   203     return KBvaFirstFreeCommandId;
       
   204     }
       
   205 
       
   206 TInt CBvaAppUi::RequestHandleCommandL(TMsgCommands aCommand)
       
   207     {
       
   208 
       
   209     switch(aCommand)
       
   210     	{
       
   211     	case EMsgClose:
       
   212     		{
       
   213     		HandleCommandL(EAknCmdExit);
       
   214     		break;
       
   215     		}
       
   216     	//intentional fallthrough
       
   217     	case EMsgNone:
       
   218     	case EMsgSave:
       
   219     	case EMsgReply:
       
   220     	case EMsgForwad:
       
   221     	case EMsgSend:
       
   222     	case EMsgAddressBook:
       
   223     		{
       
   224 			break;
       
   225 			}
       
   226 		}
       
   227 
       
   228     return KErrNone;
       
   229     }
       
   230 
       
   231 TBool CBvaAppUi::IsCommandSupported(TMsgCommands /*aCommand*/) const
       
   232     {
       
   233     //Nothing supported
       
   234     return EFalse;
       
   235     }
       
   236 
       
   237 TBool CBvaAppUi::NoDataFile()
       
   238     {
       
   239 	return (iFileHandleSize == 0);
       
   240     }
       
   241 
       
   242 // ----------------------------------------------------------------------------
       
   243 // CBvaAppUi::LaunchHelpL
       
   244 // launch help using context
       
   245 //
       
   246 // ----------------------------------------------------------------------------
       
   247 void CBvaAppUi::LaunchHelpL()
       
   248     {
       
   249     // activate Help application
       
   250     CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL();
       
   251     HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
   252     }
       
   253 
       
   254 
       
   255 // ----------------------------------------------------------------------------
       
   256 // CBvaAppUi::HelpContextL
       
   257 // returns help context
       
   258 //
       
   259 // ----------------------------------------------------------------------------
       
   260 CArrayFix<TCoeHelpContext>* CBvaAppUi::HelpContextL() const
       
   261 	{
       
   262 
       
   263     TCoeHelpContext bioControlHelpContext;
       
   264 	if(iContainer->IsBioControl())
       
   265 	    {
       
   266     	iContainer->BioControl().GetHelpContext( bioControlHelpContext );
       
   267 
       
   268     	if(!bioControlHelpContext.IsNull())
       
   269 			{
       
   270 			return CreateHelpContextArrayL(bioControlHelpContext);
       
   271 			}
       
   272 		// if help context not available for bio control
       
   273 		else
       
   274 			{
       
   275 			return NULL;
       
   276 			}
       
   277 	    }
       
   278 	return NULL;
       
   279 	}
       
   280 
       
   281 CArrayFix<TCoeHelpContext>* CBvaAppUi::CreateHelpContextArrayL(
       
   282 	const TCoeHelpContext& aHelpContext ) const
       
   283 	{
       
   284 	CArrayFix<TCoeHelpContext>* help =
       
   285 		new(ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
   286 	CleanupStack::PushL(help);
       
   287 	help->AppendL(aHelpContext);
       
   288 	CleanupStack::Pop(help);
       
   289 	return help;
       
   290 	}
       
   291 
       
   292 void CBvaAppUi::Panic(TBVAPanic aCode)
       
   293     {
       
   294     User::Panic(KBVAAppUI, aCode);
       
   295     }
       
   296 
       
   297 
       
   298 // End of File