mobilemessaging/audiomsg/src/audiomessageappui.cpp
branchRCL_3
changeset 27 7fdbb852d323
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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:   Provides AudioMessage App UI methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <apgwgnam.h>
       
    21 #include <eikrted.h>
       
    22 #include <data_caging_path_literals.hrh>
       
    23  
       
    24 #include <akntabgrp.h>
       
    25 #include <aknEditStateIndicator.h>
       
    26 #include <akntitle.h>
       
    27 #include <aknnotewrappers.h>
       
    28 #include <AknWaitDialog.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <akncontext.h>
       
    31 #include <AknTaskList.h>
       
    32 #include <AknGlobalNote.h>
       
    33 #include <aknnavi.h>
       
    34 #include <aknnavide.h>
       
    35 #include <AknIndicatorContainer.h>
       
    36 #include <AknIconArray.h>           // CAknIconArray
       
    37 #include <aknlists.h>
       
    38 #include <AknStatuspaneUtils.h>     // AknStatuspaneUtils
       
    39 #include <aknlayoutscalable_apps.cdl.h>
       
    40 #include <aknlayoutscalable_avkon.cdl.h>
       
    41 #include <MuiuMessageIterator.h>
       
    42 #ifdef RD_SCALABLE_UI_V2
       
    43 #include <akntoolbar.h> 
       
    44 #include <eikcolib.h>
       
    45 #endif
       
    46     
       
    47 #include <aknclearer.h>
       
    48 #include <e32property.h>  
       
    49 #include <ctsydomainpskeys.h>
       
    50 
       
    51 // Common components
       
    52 #include <commonphoneparser.h> //Common phone number validity checker
       
    53 #include <PhCltTypes.h>                 // PhCltTypes
       
    54 #include <CommonUiInternalCRKeys.h>
       
    55 #include <DocumentHandler.h>
       
    56 #include <featmgr.h>
       
    57 #include <finditemmenu.h>
       
    58 #include <finditem.hrh> //Place holder
       
    59 #include <ItemFinder.h>
       
    60 #include <StringLoader.h>  
       
    61 #include <messagingvariant.hrh>
       
    62 
       
    63 // Core UI
       
    64 #include <CoreApplicationUIsSDKCRKeys.h>
       
    65 
       
    66 // Help
       
    67 #include <hlplch.h>
       
    68 #include <csxhelp/msg.hlp.hrh>
       
    69 
       
    70 // Profiles
       
    71 #include <Profile.hrh>
       
    72 #include <ProfileEngineSDKCRKeys.h>
       
    73 
       
    74 // Messaging
       
    75 #include <mmsvattachmentmanager.h>
       
    76 #include <mtmuibas.h> 
       
    77 #include <MtmExtendedCapabilities.hrh>
       
    78 
       
    79 // MsgCommonUtils
       
    80 #include <msgvoipextension.h>
       
    81 
       
    82 // MUIU
       
    83 #include <MuiuOperationWait.h>
       
    84 #include <akninputblock.h>
       
    85 #include <MuiuMsvUiServiceUtilities.h>
       
    86 #include <muiumsvuiserviceutilitiesinternal.h>
       
    87 #include <MsgFolderSelectionDialog.h> //Folder Selection dialog, DoMoveMessageL
       
    88 #include <messaginginternalcrkeys.h>  //Inputmode, speaker setting
       
    89 #include <MuiuMsgEditorLauncher.h>
       
    90 
       
    91 // MsgEditor
       
    92 #include <MsgCheckNames.h>
       
    93 #include <MsgAttachmentUtils.h>
       
    94 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension
       
    95 
       
    96 // Send UI
       
    97 #include <sendui.h> 
       
    98 #include <SenduiMtmUids.h> 
       
    99 #include <CMessageData.h> //DoReplyViaL
       
   100 
       
   101 // MMS Engine
       
   102 #include <mmsgenutils.h> //PureAddress
       
   103 #include <mmsclient.h>
       
   104 #include <MsgMimeTypes.h>   
       
   105 #include <MsgMediaResolver.h>
       
   106 #include <MsgMediaInfo.h>
       
   107 #include <msgmediacontrol.h>
       
   108 #include <uniaddresshandler.h>
       
   109 
       
   110 #include "AudioMessageLogging.h"
       
   111 #include "audiomessageappui.h"
       
   112 #include "audiomessageinsertoperation.h"
       
   113 #include "audiomessagelaunchoperation.h"
       
   114 #include "audiomessagesaveoperation.h"
       
   115 #include "audiomessagesendoperation.h"
       
   116 #include "audiomessagesendreadreportoperation.h"
       
   117 #include "audiomessageprogressdialog.h"
       
   118 #include <audiomessage.mbg>   
       
   119 #include <audiomessage.rsg> 
       
   120 
       
   121 #define KFSWApUid TUid::Uid( 0x10207218 )
       
   122 #define KAknNfySrvUid TUid::Uid(0x10281EF2 )
       
   123 
       
   124 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   125 const TUint KNaviGranularity = 2;
       
   126 #endif
       
   127 const TMsvId KNewMessageFolder = KMsvDraftEntryIdValue;
       
   128 const TSize KPriorityIconSize = TSize( 10,16 ); // width, height
       
   129 const TInt  KDelayedExitDelay = 1500000;
       
   130 const TUid KUidAudioMessageApplication = { 0x1020745A };
       
   131 const TInt KAmsNotCaptured = -1;
       
   132 const TInt KDefaultVolume = 5;
       
   133 const TInt KAmsBytesInKilo = 1024;
       
   134 const TInt KMaxAliasLength = 64;
       
   135 
       
   136 _LIT( KAmrFileExt,".amr");
       
   137 //#ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   138 _LIT( KAmsBitmapFileName, "audiomessage.mif" );
       
   139 //#endif
       
   140 
       
   141 // ======== MEMBER FUNCTIONS ========
       
   142  
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CAudioMessageAppUi::Constructor
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 CAudioMessageAppUi::CAudioMessageAppUi()
       
   149     :
       
   150     iWaitResId( -1 ),
       
   151     iEditorFlags( 0 ),
       
   152     iProgressDlg( NULL ),
       
   153     iAlias ( NULL ),
       
   154     iCurrentVolume( KDefaultVolume ),
       
   155     iVoiceKeyHandle( KAmsNotCaptured ),
       
   156    	iSpeakerEarpiece( ETrue ),
       
   157     iInserting( EFalse ),
       
   158     iCurrentSkResId ( 0 )
       
   159     {
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // CAudioMessageAppUi::ConstructL
       
   164 // ---------------------------------------------------------
       
   165 //
       
   166 void CAudioMessageAppUi::ConstructL()
       
   167     {
       
   168 AMSLOGGER_WRITE( "CAudioMessageAppUi::ConstructL" );
       
   169     if ( iEikonEnv->EikAppUi() )
       
   170         {
       
   171         iAbsorber = CAknInputBlock::NewLC();
       
   172         CleanupStack::Pop( iAbsorber );
       
   173         }
       
   174 
       
   175     CMsgEditorAppUi::ConstructL();
       
   176  
       
   177     // Get supported features from feature manager.
       
   178     FeatureManager::InitializeLibL();
       
   179     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   180         {
       
   181         iSupportedFeatures |= EUniFeatureHelp;
       
   182         }
       
   183     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   184         {   
       
   185         iSupportedFeatures |= EUniFeatureOffline;      
       
   186         }        
       
   187     FeatureManager::UnInitializeLib();
       
   188     iMsgVoIPExtension = CMsgVoIPExtension::NewL();
       
   189     
       
   190     iSettingsRepository = CRepository::NewL( KCRUidMuiuSettings );
       
   191  
       
   192     TInt highlight = 0;
       
   193     // Automatic highlight setting storage and change notifications
       
   194     iCUiRepository = CRepository::NewL( KCRUidCommonUi );
       
   195     iCUiRepository->Get( KCuiAutomaticHighlight, highlight  );
       
   196     iNotifyHandler = CCenRepNotifyHandler::NewL( *this,
       
   197                                                  *iCUiRepository,
       
   198                                                  CCenRepNotifyHandler::EIntKey,
       
   199                                                  KCuiAutomaticHighlight );
       
   200     
       
   201     TInt featureBitmask = 0;
       
   202     CRepository* muiuRepository = CRepository::NewL( KCRUidMuiuVariation );
       
   203     muiuRepository->Get( KMuiuMmsFeatures, featureBitmask );
       
   204 
       
   205     if ( featureBitmask & KMmsFeatureIdPrioritySupport )
       
   206        {          
       
   207        iSupportedFeatures |= EUniFeaturePriority;     
       
   208        }
       
   209     if ( featureBitmask & KMmsFeatureIdDeliveryStatusDialog ) 
       
   210         {         
       
   211         iSupportedFeatures |= EUniFeatureDeliveryStatus;
       
   212         }
       
   213 
       
   214 
       
   215     delete muiuRepository;
       
   216     
       
   217     //Read speaker setting ( earpiece / loudspeaker )
       
   218     iAudioMesseageRepository = CRepository::NewL( KCRUidAudioMsg );
       
   219     iAudioMesseageRepository -> Get( KAudioMsgSpeaker, iSpeakerEarpiece );
       
   220 
       
   221     iNotifyHandler->StartListeningL();
       
   222     // Set up highlighting
       
   223     if ( highlight == 0 )
       
   224         {
       
   225         iEditorFlags &= ~EAutohighLightEnabled;
       
   226         }
       
   227     else
       
   228         {
       
   229         iEditorFlags |= EAutohighLightEnabled;
       
   230         }
       
   231         
       
   232         
       
   233     // Disable task swapper from options menu during launch
       
   234     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
       
   235         
       
   236 
       
   237     iTitlePane = static_cast<CAknTitlePane*>
       
   238         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   239 
       
   240     if ( !iEikonEnv->StartedAsServerApp( ) )
       
   241         {
       
   242         Document()->PrepareToLaunchL( this );
       
   243         }
       
   244 
       
   245     Document()->SetEditorModelObserver( this );
       
   246    	iClipFileName = StringLoader::LoadL( R_QTN_VOREC_FIRST_MEMO_NAME );
       
   247    	iTimeDuratBase = StringLoader::LoadL( R_QTN_TIME_DURAT_MIN_SEC );
       
   248 
       
   249 
       
   250     CEikStatusPane* sp = StatusPane();
       
   251     CAknContextPane* contextPane = static_cast< CAknContextPane* >
       
   252        ( sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) );
       
   253 
       
   254       // Audiomsg window group id
       
   255     iMyWgId = iCoeEnv->RootWin().Identifier();
       
   256     
       
   257     CApaWindowGroupName::FindByAppUid(
       
   258         KFSWApUid,
       
   259         iCoeEnv->WsSession(),
       
   260         iFSWindowGroupId );
       
   261         
       
   262     CApaWindowGroupName::FindByAppUid(
       
   263         KAknNfySrvUid,
       
   264         iCoeEnv->WsSession(),
       
   265         iAknNfySrvUi );    
       
   266 
       
   267   	// Set path of bitmap file
       
   268   	TParse fileParse;
       
   269   	fileParse.Set( KAmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   270     
       
   271     iAppIcon = AknsUtils::CreateGulIconL( 
       
   272         AknsUtils::SkinInstance(), 
       
   273         KAknsIIDQgnPropMceAudioTitle,
       
   274         fileParse.FullName(),
       
   275         EMbmAudiomessageQgn_prop_mce_audio_title,
       
   276         EMbmAudiomessageQgn_prop_mce_audio_title_mask );
       
   277 
       
   278     iCoeEnv->RootWin().EnableFocusChangeEvents();   // ignore error
       
   279     
       
   280     iScreenClearer = CAknLocalScreenClearer::NewLC( ETrue );
       
   281     CleanupStack::Pop( iScreenClearer );    
       
   282 AMSLOGGER_WRITE( "CAudioMessageAppUi::ConstructL ends" );    	
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // CAudioMessageAppUi::Destructor
       
   287 // ---------------------------------------------------------
       
   288 //
       
   289 CAudioMessageAppUi::~CAudioMessageAppUi()
       
   290     {
       
   291 AMSLOGGER_WRITE( "CAudioMessageAppUi::~CAudioMessageAppUi" );    
       
   292     
       
   293     
       
   294     iEditorFlags |= EEditorExiting;
       
   295     //Write speaker setting ( earpiece / loudspeaker )
       
   296     if ( iAudioMesseageRepository)
       
   297     	{	
       
   298         iAudioMesseageRepository -> Set( KAudioMsgSpeaker, iSpeakerEarpiece );
       
   299         delete iAudioMesseageRepository;
       
   300     	}
       
   301     // Release voice key
       
   302     if ( iVoiceKeyHandle >= 0 )
       
   303         {
       
   304         iCoeEnv->RootWin().CancelCaptureKey( iVoiceKeyHandle );
       
   305         iVoiceKeyHandle = KAmsNotCaptured;
       
   306         }
       
   307 
       
   308     delete iAddressHandler;
       
   309   
       
   310   
       
   311     delete iAppIcon;
       
   312   
       
   313     // remember input mode:
       
   314     if ( iEditorFlags & ELaunchSuccessful )
       
   315         {
       
   316         TInt id( EMsgComponentIdNull );
       
   317         CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
   318         if ( ctrl )
       
   319             {
       
   320             id = ctrl->ControlId();
       
   321             }
       
   322         if ( id == EMsgComponentIdNull )
       
   323             {
       
   324             id = EMsgComponentIdTo;
       
   325             }
       
   326         if ( id == EMsgComponentIdTo )
       
   327             {
       
   328             CMsgAddressControl* rec = iView ?
       
   329                 static_cast< CMsgAddressControl* >( iView->ControlById( id ) )
       
   330                 : NULL;
       
   331             if ( rec )
       
   332                 {
       
   333                 TInt inputMode = rec->Editor().AknEditorCurrentInputMode();
       
   334                 iSettingsRepository->Set( KMuiuToInputMode, inputMode );
       
   335                 }
       
   336             }
       
   337         }
       
   338 
       
   339     delete iSettingsRepository;
       
   340     delete iLaunchOperation;
       
   341     delete iSaveOperation;
       
   342     delete iSendOperation;
       
   343     delete iInsertOperation;
       
   344     if ( iWaitDialog )
       
   345     	{
       
   346     	TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
       
   347     	}    
       
   348     delete iIdle;
       
   349     delete iAbsorber;
       
   350     delete iFindItemMenu;
       
   351     delete iNotifyHandler;
       
   352     delete iCUiRepository;
       
   353 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT    
       
   354     delete iNavi_next_prev_msg_arrows;
       
   355 #endif    
       
   356 #ifdef RD_SCALABLE_UI_V2
       
   357     if ( iToolbar )
       
   358         {
       
   359         delete iToolbar;    
       
   360         }
       
   361 #endif
       
   362     delete iMsgVoIPExtension;
       
   363     delete iClipFileName;
       
   364     delete iTimeDuratBase;
       
   365     delete iInsertingMedia;
       
   366     delete iAlias;	
       
   367     delete iScreenClearer;	
       
   368     delete iSendReadReportOperation;
       
   369 AMSLOGGER_WRITE( "CAudioMessageAppUi::~CAudioMessageAppUi ends" );       
       
   370   }
       
   371 
       
   372 // ---------------------------------------------------------
       
   373 // CAudioMessageAppUi::LaunchViewL
       
   374 // ---------------------------------------------------------
       
   375 //
       
   376 void CAudioMessageAppUi::LaunchViewL()
       
   377     {
       
   378     AMSLOGGER_WRITE( "CAudioMessageAppUi::LaunchViewL >>" ); 
       
   379     if ( iEditorFlags & EEditorExiting )
       
   380         {
       
   381         // Start the delayed exit here if exit command was given before application was
       
   382         // ready to handle it. Delayed exit is used as LauchViewL cannot 
       
   383         // make proper exit if Exit() is called here.
       
   384         //DoDelayedExitL( 0 );
       
   385         return;
       
   386         }
       
   387     Document()->SetClipStatus( EAmsClipNone );
       
   388     iMtm = &( Document()->Mtm() );
       
   389     const TMsvEntry& entry = Document()->Entry();
       
   390     if ( entry.iType.iUid != KUidMsvMessageEntryValue )
       
   391         {
       
   392         User::Leave( KErrGeneral );
       
   393         }
       
   394 
       
   395     TRAPD( error, iMtm->LoadMessageL() );
       
   396     if ( error )
       
   397         {
       
   398         if ( error != KErrNoMemory )
       
   399             {
       
   400             ShowErrorNoteL( R_AUDIOMESSAGE_ERROR_MSG_CORRUPT, ETrue );
       
   401             }
       
   402         User::Leave( error );
       
   403         }
       
   404 
       
   405     delete iAbsorber;
       
   406     iAbsorber = NULL;
       
   407 
       
   408     Document()->SetMessageType();
       
   409 
       
   410   	if ( !iMtm->Entry().Entry().ReadOnly() ) // editor
       
   411     	{
       
   412     	//SendKey disabled
       
   413     	iAvkonAppUi->SetKeyEventFlags( 
       
   414             CAknAppUiBase::EDisableSendKeyShort | 
       
   415             CAknAppUiBase::EDisableSendKeyLong ); 
       
   416                
       
   417     	SetFixedToolbarL( R_AMSEDITOR_APP_TOOLBAR );
       
   418     	iView = CMsgEditorView::NewL( *this,
       
   419         CMsgEditorView::EMsgDoNotUseDefaultBodyControl );
       
   420 
       
   421       	// Add TO-control to editor
       
   422       	iView->AddControlFromResourceL(
       
   423           	R_AUDIOMESSAGE_TO,
       
   424           	EMsgAddressControl,
       
   425           	EMsgAppendControl,
       
   426           	EMsgHeader );
       
   427 
       
   428 	    // If editor opened from Phonebook or Logs details must be checked
       
   429 	    // so we can add address/alias to Recipient -field
       
   430 	    const TPtrC details = iMtm->Entry().Entry().iDetails;
       
   431 
       
   432 	  	// Message in draft folder OR opening with data in address -field
       
   433 	    if ( entry.iMtmData1 & KMmsMessageEditorOriented
       
   434 	         || details.Length() 
       
   435 	         || iMtm->Entry().Entry().Parent() == KMsvDraftEntryIdValue )
       
   436 	    	{
       
   437 	      	// Set name/number
       
   438 	      	InsertRecipientL();
       
   439 	    	}
       
   440 	    // Restore AddressControl's input mode
       
   441 	    CMsgAddressControl* to = ToCtrl();
       
   442 	    TInt inputMode = EAknEditorNumericInputMode;
       
   443 	  	if ( iSettingsRepository )
       
   444 	        {
       
   445 	        iSettingsRepository->Get( KMuiuToInputMode, inputMode );
       
   446 	    	}
       
   447 	    to->Editor().SetAknEditorInputMode( inputMode );
       
   448 	    Document()->SetAppMode( EAmsEditor );   	
       
   449 	   	InitEditorNaviPaneL();
       
   450 
       
   451 	   	//End key should not close application in editor
       
   452 	   	CMsgEditorAppUi::SetCloseWithEndKey( EFalse);
       
   453 	   	}
       
   454 	else // viewer
       
   455     	{
       
   456     	SetFixedToolbarL( R_AMSVIEWER_APP_TOOLBAR );
       
   457     	iView = CMsgEditorView::NewL( *this,
       
   458         	CMsgEditorView::EMsgReadOnly |
       
   459         	CMsgEditorView::EMsgDoNotUseDefaultBodyControl );
       
   460 
       
   461       	Document()->SetAppMode( EAmsViewer );
       
   462       	// Message in sent folder or moved from sent to documents	
       
   463         if ( entry.iMtmData1 & KMmsMessageEditorOriented  
       
   464              || entry.Parent() == KMsvSentEntryIdValue )
       
   465       		{
       
   466       		// Add TO -control to viewer and set name/number
       
   467       		InsertRecipientL();
       
   468       		}
       
   469     	else // Message in inbox
       
   470 	      	{
       
   471 	      	// Add FROM -control to viewer and set name/number
       
   472 	      	SetSenderL();
       
   473 	      	// Add SUBJECT -control to viewer and set subject
       
   474 	      	SetSubjectL();
       
   475 	      	}
       
   476 	    Document()->SetInsertedStatus( EAmsInsideMessage );  	
       
   477     	InitViewerNaviPaneL();
       
   478     	}
       
   479     
       
   480 
       
   481     iView->SetEdwinObserverL( this );
       
   482     iLaunchOperation = CAudioMessageLaunchOperation::NewL(
       
   483         *this,
       
   484         *Document(),
       
   485         *iView );
       
   486     iLaunchOperation->Launch();
       
   487  
       
   488    AMSLOGGER_WRITE( "CAudioMessageAppUi::LaunchViewL <<" ); 
       
   489     }
       
   490 
       
   491 
       
   492 // ---------------------------------------------------------
       
   493 // CAudioMessageAppUi::FinalizeLaunchL
       
   494 // ---------------------------------------------------------
       
   495 //
       
   496 void CAudioMessageAppUi::FinalizeLaunchL()
       
   497     {
       
   498     AMSLOGGER_WRITE( "CAudioMessageAppUi::FinalizeLaunchL >>" ); 
       
   499     if ( iEditorFlags & EEditorExiting )
       
   500         {
       
   501         // Start the delayed exit here if exit command was given before application was
       
   502         // ready to handle it. Delayed exit is used as LauchViewL cannot 
       
   503         // make proper exit if Exit() is called here.
       
   504         //DoDelayedExitL( 0 );
       
   505         return;
       
   506         }
       
   507     
       
   508     SetAddressSize();
       
   509     
       
   510     if ( Document()->GetClipStatus() == EAmsClipAttachment )
       
   511       	{
       
   512       	FetchAudioFileDataL() ;
       
   513       	}
       
   514 
       
   515     if ( !iMtm->Entry().Entry().ReadOnly() )//editor
       
   516       	{
       
   517       	iView->ExecuteL( ClientRect(), EMsgComponentIdImage );
       
   518       	if ( Document()->GetInsertedStatus() == EAmsSmilAdded ) // from gallery and smil added
       
   519       		{
       
   520       	    iView->SetFocus( EMsgComponentIdTo );
       
   521       	    ShowInformationNoteL( R_AUDIOMESSAGE_INSERTED, EFalse );
       
   522       		}
       
   523       	else
       
   524       	    {
       
   525       	    iView->SetFocus( EMsgComponentIdImage );
       
   526       	    }	
       
   527         }
       
   528     else //viewer
       
   529       	{
       
   530       	iView->ExecuteL( ClientRect(), EMsgComponentIdNull );
       
   531       	iView->SetFocus( EMsgComponentIdImage );
       
   532       	SetFindMode( iEditorFlags & EAutohighLightEnabled ) ;
       
   533         SetViewerToolBarItemVisibilities();
       
   534         }
       
   535     SetTitleIconL();
       
   536     AMSLOGGER_WRITE( "CAudioMessageAppUi::FinalizeLaunchL <<" ); 
       
   537     }
       
   538 
       
   539 // ---------------------------------------------------------
       
   540 // CAudioMessageAppUi::HandleCommandL
       
   541 // Error: EGWG-7HWE2P : Purushotham Reddy K
       
   542 // ---------------------------------------------------------
       
   543 //
       
   544 void CAudioMessageAppUi::HandleCommandL( TInt aCommand )
       
   545     {
       
   546     TRAPD( error, DoHandleCommandL( aCommand ) );
       
   547     if ( error != KErrNone )    
       
   548         {
       
   549         AMSLOGGER_WRITEF( _L("iHandleCommandL: LEAVE (%d) "), error ); 
       
   550         iEditorFlags &= ~EProgressInUse;
       
   551         delete iAbsorber;
       
   552         iAbsorber = NULL;
       
   553         
       
   554         //See the code where the following has been set EFalse
       
   555         iAvkonAppUi->Cba()->MakeVisible( ETrue );
       
   556         iInserting = EFalse;
       
   557         iView->MakeVisible( ETrue );
       
   558         //EGWG-7HWE2P
       
   559         if(error == KErrInUse)
       
   560             {
       
   561             //If this error is due to record is already in use in another message editor,
       
   562             //then de-highlight the record button.
       
   563             iToolbar->SetItemDimmed(EAmsEditorToolbarRecord, EFalse, ETrue);
       
   564             }
       
   565         User::Leave( error );
       
   566         }
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------
       
   570 // CAudioMessageAppUi::SetFixedToolbarL
       
   571 // ---------------------------------------------------------
       
   572 //
       
   573 void CAudioMessageAppUi::SetFixedToolbarL( const TInt aResId )
       
   574     {
       
   575 #ifdef RD_SCALABLE_UI_V2
       
   576     if ( AknLayoutUtils::PenEnabled() && !iToolbar)
       
   577     	{
       
   578     	CEikAppUiFactory* appUiFactory 
       
   579     	    = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() );
       
   580         CAknToolbar* oldFixedToolbar = appUiFactory->CurrentFixedToolbar();
       
   581         iToolbar = CAknToolbar::NewL( aResId );
       
   582         iToolbar->SetToolbarObserver( this );
       
   583         
       
   584         if ( oldFixedToolbar != iToolbar )
       
   585             {
       
   586             oldFixedToolbar->SetToolbarVisibility( EFalse );    
       
   587             }
       
   588         appUiFactory->SetViewFixedToolbar( iToolbar );    	
       
   589         iToolbar->SetToolbarVisibility( ETrue, EFalse ); 
       
   590     	}
       
   591     else if ( AknLayoutUtils::PenEnabled() && iToolbar )
       
   592         {
       
   593         CEikAppUiFactory* appUiFactory = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() );
       
   594         CAknToolbar* oldFixedToolbar = appUiFactory->CurrentFixedToolbar();
       
   595         if ( oldFixedToolbar != iToolbar )
       
   596             {
       
   597             oldFixedToolbar->SetToolbarVisibility( EFalse );
       
   598             appUiFactory->SetViewFixedToolbar( iToolbar );     
       
   599             }
       
   600         }
       
   601 
       
   602     #endif
       
   603     return;
       
   604     }
       
   605 
       
   606 
       
   607 // ---------------------------------------------------------
       
   608 // CAudioMessageAppUi::HandleCommandL
       
   609 // ---------------------------------------------------------
       
   610 //
       
   611 void CAudioMessageAppUi::DoHandleCommandL(TInt aCommand)
       
   612     {
       
   613 AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleCommandL >>" ); 
       
   614     if ( iEditorFlags & EEditorExiting )
       
   615         {
       
   616         // Do not handle any event if we are exiting.
       
   617         return;
       
   618         }
       
   619     
       
   620     if ( !( iEditorFlags & ELaunchSuccessful ) )
       
   621         {
       
   622         if ( aCommand == EEikCmdExit )
       
   623             {
       
   624             if ( !Document()->IsLaunched() )
       
   625                 {
       
   626                 //We come here e.g. when editor is started in very low memory
       
   627                 iEditorFlags |= EEditorExiting;
       
   628                 DoDelayedExitL( 0 );
       
   629                 return;
       
   630                 }   
       
   631             }
       
   632         else
       
   633             {
       
   634             // Do not handle other than exit command if application has not
       
   635             // finished launching.
       
   636             return;
       
   637             }    
       
   638         }
       
   639 
       
   640   	if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) )
       
   641     	{
       
   642     	iFindItemMenu->HandleItemFinderCommandL( aCommand );
       
   643     	return;
       
   644     	}
       
   645     switch ( aCommand )
       
   646         {
       
   647         case EAmsEditorCmdSend:
       
   648             DoUserSendL();
       
   649             break;
       
   650         case EAmsEditorCmdAddRecipient:
       
   651             DoUserAddRecipientL();
       
   652           	break;
       
   653         case EAmsViewerCmdSaveAudio:
       
   654         case EAmsEditorCmdSaveAudio:
       
   655           	SaveAudioClipL();
       
   656           	break;
       
   657         case EAmsEditorCmdPlayAudio:
       
   658             PlayAudioL();
       
   659             break;
       
   660         case EAmsViewerCmdForward:
       
   661           	DoForwardL();
       
   662           	break;
       
   663         case EAmsViewerCmdRemoveAudio:
       
   664           	DeleteMessageL();
       
   665           	break;
       
   666         case EAmsEditorCmdMessageInfo:
       
   667             DoUserMessageInfoL();
       
   668             break;
       
   669         case EAmsViewerCmdDeliveryStatus:
       
   670             OpenDeliveryPopupL();
       
   671             break;
       
   672         case EAmsViewerCmdMoveToFolder:
       
   673             DoMoveMessageL();
       
   674             break;
       
   675         case EAknCmdHelp:
       
   676             LaunchHelpL();
       
   677             break;
       
   678     	case EAknCmdExit:
       
   679         case EEikCmdExit:
       
   680             ExitAndSaveL( );
       
   681             break;
       
   682         // Reply submenu commands
       
   683         case EAmsViewerCmdReplyToSender:
       
   684           	DoReplyViaL( EReplyToSender );
       
   685           	break;
       
   686         case EAmsViewerCmdReplyToAll:
       
   687           	DoReplyViaL( EReplyToAll );
       
   688           	break;       
       
   689         case EAmsViewerCmdReplyViaMessage:
       
   690           	DoReplyViaL( EReplyViaMessage );
       
   691           	break;          	
       
   692         case EAmsEditorCmdRecordAudio:
       
   693            	InsertAudioL( ETrue );
       
   694             break;
       
   695         case EAmsEditorCmdFromGallery:
       
   696             InsertAudioL( EFalse );
       
   697             break;
       
   698         case EAmsEditorCmdReRecordAudio:
       
   699             InsertAudioL( ETrue );
       
   700             break;
       
   701         case EAmsEditorCmdFromGallery2:
       
   702             InsertAudioL( EFalse );
       
   703           	break;
       
   704         // Button commands
       
   705         case EAknSoftkeyClose:
       
   706             DoBackSaveL();
       
   707             break;
       
   708         case EAmsSoftkeyAdd:
       
   709             // Call this function so that check name functionality is called first
       
   710         	DoSelectionKeyL( );
       
   711         	break;
       
   712         case EAmsSoftkeyPlay:
       
   713         	PlayAudioL();
       
   714         	break;
       
   715         case EAmsSoftkeyRecord:
       
   716         	InsertAudioL( ETrue );
       
   717         	break;
       
   718         case EAmsEditorCmdChangePriority:
       
   719             DoEditAmsPriorityL( );
       
   720             break;
       
   721         case EAmsDispSizeAutomatic:
       
   722         case EAmsDispSizeLarge:
       
   723         case EAmsDispSizeNormal:
       
   724         case EAmsDispSizeSmall:
       
   725             DoHandleLocalZoomChangeL( aCommand );
       
   726             break;        	
       
   727         default:
       
   728             CMsgEditorAppUi::HandleCommandL( aCommand );
       
   729             break;
       
   730         }
       
   731     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleCommandL <<" ); 
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------
       
   735 // CAudioMessageAppUi::EditorObserver
       
   736 // ---------------------------------------------------------
       
   737 //
       
   738 void CAudioMessageAppUi::EditorObserver( TMsgEditorObserverFunc aFunc, TAny* aArg1,
       
   739   TAny* aArg2, TAny* aArg3 )
       
   740     {
       
   741     TRAP_IGNORE( DoEditorObserverL( aFunc,aArg1,aArg2,aArg3 ) );
       
   742     }
       
   743 
       
   744 // ---------------------------------------------------------
       
   745 // CAudioMessageAppUi::DoEditorObserverL
       
   746 // ---------------------------------------------------------
       
   747 //
       
   748 void CAudioMessageAppUi::DoEditorObserverL( TMsgEditorObserverFunc aFunc, TAny* aArg1,
       
   749   TAny* aArg2, TAny*/* aArg3*/ )
       
   750     {
       
   751     
       
   752     switch ( aFunc )
       
   753         {
       
   754         case MMsgEditorObserver::EMsgHandleFocusChange:   
       
   755 	        {
       
   756 AMSLOGGER_WRITE( "DoEditorObserverL: EMsgHandleFocusChange" ); 	        
       
   757 	        TMsgFocusEvent event = *( static_cast<TMsgFocusEvent*>( aArg1 ) );  
       
   758 					// Handling of SendKey in Viewer mode
       
   759 					if ( Document()->GetAppMode() == EAmsViewer )
       
   760 						{
       
   761 						if((event == EMsgFocusToHeader) && (iSenderType == ESenderTypePhoneNumber))
       
   762 							{
       
   763 							//disable dialer
       
   764 							iAvkonAppUi->SetKeyEventFlags( 
       
   765 			    				CAknAppUiBase::EDisableSendKeyShort | 
       
   766 			    				CAknAppUiBase::EDisableSendKeyLong ); 	
       
   767 							}
       
   768 							else if(event == EMsgFocusToBody)
       
   769 							{
       
   770 							//enable dialer
       
   771 							iAvkonAppUi->SetKeyEventFlags( 0x00); 
       
   772 							}	
       
   773 						}
       
   774 	        if( event == EMsgFocusMovedTo )
       
   775                 {
       
   776                 SetNaviPaneL( );
       
   777                 UpdateSoftKeysL(); 
       
   778                 }
       
   779 	        }
       
   780 	        break;
       
   781 	    
       
   782 	    
       
   783 #ifdef RD_SCALABLE_UI_V2	    
       
   784 	    case MMsgEditorObserver::EMsgControlPointerEvent:
       
   785             {
       
   786             TPointerEvent* ptrEvent = static_cast<TPointerEvent*>( aArg2 );    
       
   787             if ( Document()->GetAppMode() == EAmsViewer )
       
   788             	{
       
   789             	CMsgBaseControl* control = static_cast<CMsgBaseControl*>( aArg1 );
       
   790             	if(control)
       
   791 	            	{
       
   792 	            	TInt id = control->ControlId();	            
       
   793 								if(id == EMsgComponentIdFrom && iSenderType == ESenderTypePhoneNumber)
       
   794 									{     
       
   795 									//disable dialer
       
   796 									iAvkonAppUi->SetKeyEventFlags( 
       
   797 				    					CAknAppUiBase::EDisableSendKeyShort | 
       
   798 				    					CAknAppUiBase::EDisableSendKeyLong ); 								
       
   799 									}
       
   800 								else            
       
   801 									{
       
   802 	                	//enable dialer
       
   803 									iAvkonAppUi->SetKeyEventFlags( 0x00);
       
   804 									}
       
   805 	            	}
       
   806             	}           
       
   807      	    if ( ptrEvent->iType == TPointerEvent::EButton1Down )
       
   808     	        {
       
   809         	        TPoint point = ptrEvent->iPosition;
       
   810         	        
       
   811         	        TRect bodyRect = iView->FormComponent( EMsgBody ).Rect();
       
   812         	        TRect focusedRect = iView->FocusedControl()->Rect();
       
   813         	        //the bodyrect was already focused i.e not the first press
       
   814         	        if ( bodyRect == focusedRect )
       
   815         	            {
       
   816         	            TSize frameSize = iLaunchOperation->FrameSize();
       
   817                         bodyRect.Shrink((bodyRect.Width()-frameSize.iWidth)/2,
       
   818                             (bodyRect.Height()-frameSize.iHeight)/2);
       
   819                         
       
   820             	        if ( bodyRect.Contains( point ) )
       
   821                             {//the image is clicked - the nth time
       
   822                    	        if ( Document()->GetClipStatus() != EAmsClipNone )
       
   823                 			    {
       
   824                 			    HandleCommandL( EAmsEditorCmdPlayAudio );
       
   825                 			    }
       
   826                     		//there is no any clip, so try to record new.
       
   827                 	    	else
       
   828                 	    		{
       
   829                 	    		HandleCommandL(EAmsEditorCmdRecordAudio);
       
   830                             	}
       
   831                             }
       
   832         	            }
       
   833     	        }
       
   834                 
       
   835             break;
       
   836             }
       
   837  #endif //RD_SCALABLE_UI_V2           
       
   838   
       
   839 	    case MMsgEditorObserver::EMsgButtonEvent:
       
   840             {
       
   841 AMSLOGGER_WRITE( "DoEditorObserverL: EMsgButtonEvent" );            
       
   842             CMsgAddressControl* toControl = ToCtrl();
       
   843 			if( toControl == static_cast<CMsgAddressControl*>( aArg1 ) )
       
   844 				{
       
   845                 TBool modified = EFalse;
       
   846                 if ( toControl->GetRecipientsL()->Count() )
       
   847                     {
       
   848                     // Recipients found. Verify addresses.
       
   849                     if ( !VerifyAddressesL( modified ) )
       
   850                         {
       
   851                         // Illegal address found.
       
   852                         modified = ETrue;
       
   853                         }
       
   854                     }
       
   855                 if ( !modified )//else
       
   856                     {
       
   857                     // Nothing changed on the UI. Open PhoneBook.
       
   858                    HandleCommandL( EAmsEditorCmdAddRecipient ); 
       
   859                     }
       
   860 				}
       
   861             }
       
   862             break;
       
   863         default:
       
   864             break;
       
   865         } 
       
   866     }
       
   867 
       
   868 // ---------------------------------------------------------
       
   869 // CAudioMessageAppUi::FetchFileL
       
   870 // ---------------------------------------------------------
       
   871 //
       
   872 TBool CAudioMessageAppUi::FetchFileL( TFileName &aFileName )
       
   873     {
       
   874     AMSLOGGER_WRITE( "CAudioMessageAppUi::FetchFileL >>" ); 
       
   875     CDesCArrayFlat* dummy = new ( ELeave ) CDesCArrayFlat( 1 );
       
   876     CleanupStack::PushL( dummy );
       
   877     //TFileName fileName;
       
   878 
       
   879     TBool fetchOK = MsgAttachmentUtils::FetchFileL(
       
   880         MsgAttachmentUtils::EAudio,
       
   881         //fileName,
       
   882         aFileName,
       
   883         *dummy,
       
   884         ETrue,
       
   885         EFalse,
       
   886         this );
       
   887     //aFileName = fileName;
       
   888     CleanupStack::PopAndDestroy( dummy );
       
   889     AMSLOGGER_WRITE( "CAudioMessageAppUi::FetchFileL <<" ); 
       
   890     return fetchOK;
       
   891     }
       
   892 
       
   893 // ---------------------------------------------------------
       
   894 // CAudioMessageAppUi::VerifySelectionL
       
   895 // ---------------------------------------------------------
       
   896 //
       
   897 TBool CAudioMessageAppUi::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
   898     {
       
   899    	AMSLOGGER_WRITE( "CAudioMessageAppUi::VerifySelectionL >>" ); 
       
   900 	CAknInputBlock::NewLC();
       
   901 	
       
   902    	TBool ret = EFalse;
       
   903     if ( aSelectedFiles->MdcaCount() == 1 )
       
   904         {
       
   905         TPtrC ptr = aSelectedFiles->MdcaPoint( 0 );
       
   906         if ( CreateMediaInfoForInsertL( ptr ) )
       
   907             {
       
   908             ret = ETrue;
       
   909             }
       
   910         }
       
   911 
       
   912     CleanupStack::PopAndDestroy(); //input blocker
       
   913     AMSLOGGER_WRITE( "CAudioMessageAppUi::VerifySelectionL <<" ); 
       
   914     return ret;
       
   915     }
       
   916 
       
   917 // ---------------------------------------------------------
       
   918 // CAudioMessageAppUi::HandleEdwinEventL
       
   919 //
       
   920 // Performs character counter updating if neccessary. This is needed
       
   921 // for supporting on-screen keyboard. Normally character input
       
   922 // is handled already on OfferKeyEventL function but it does no
       
   923 // harm to do it here again.
       
   924 // ---------------------------------------------------------
       
   925 //
       
   926 void CAudioMessageAppUi::HandleEdwinEventL( CEikEdwin* /*aEdwin*/, TEdwinEvent aEventType )
       
   927     {
       
   928     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleEdwinEventL >>" ); 
       
   929     if ( aEventType == MEikEdwinObserver::EEventTextUpdate )
       
   930         {
       
   931         HandleCharInputL();
       
   932         }
       
   933     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleEdwinEventL <<" ); 
       
   934     }
       
   935 
       
   936 // ---------------------------------------------------------
       
   937 // CAudioMessageAppUi::HandleKeyEventL
       
   938 // ---------------------------------------------------------
       
   939 //
       
   940 TKeyResponse CAudioMessageAppUi::HandleKeyEventL(
       
   941     const TKeyEvent& aKeyEvent,
       
   942     TEventCode aType )
       
   943     {
       
   944     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleKeyEventL >>" ); 
       
   945     if(iEditorFlags & EProgressInUse)
       
   946     	{
       
   947         return EKeyWasNotConsumed;
       
   948     	}
       
   949     
       
   950     if (!(iEditorFlags & ELaunchSuccessful))
       
   951     	{
       
   952         return EKeyWasNotConsumed;
       
   953     	}
       
   954     // still launching
       
   955     if ( !Document()->IsLaunched() )
       
   956         {
       
   957         return EKeyWasNotConsumed;
       
   958         }
       
   959    	if ( iInserting )
       
   960       	{
       
   961         return EKeyWasNotConsumed;
       
   962       	}
       
   963 
       
   964     if ( iView && !IsDisplayingMenuOrDialog() )
       
   965         {
       
   966         switch ( aKeyEvent.iCode )
       
   967         	{
       
   968             case EKeyLeftArrow:
       
   969 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT            
       
   970                	if ( Document()->GetAppMode() == EAmsViewer &&
       
   971                			IsNextMessageAvailableL( EFalse ))
       
   972                 	{
       
   973                    	NextMessageL( EFalse );
       
   974                 	}
       
   975 #else
       
   976                 if ( Document()->GetAppMode() == EAmsViewer &&
       
   977                			iNaviPane->Top() == iNavi_next_prev_msg_arrows &&
       
   978                			IsNextMessageAvailableL( EFalse ))
       
   979                 	{
       
   980                    	NextMessageL( EFalse );
       
   981                 	}
       
   982 #endif            
       
   983     	
       
   984                 break;
       
   985           	case EKeyRightArrow:
       
   986 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT          	
       
   987                 if ( Document()->GetAppMode() == EAmsViewer &&
       
   988               			IsNextMessageAvailableL( ETrue ))
       
   989                 	{
       
   990                    	NextMessageL( ETrue );
       
   991                 	}
       
   992 #else
       
   993                 if ( Document()->GetAppMode() == EAmsViewer &&
       
   994               			iNaviPane->Top() == iNavi_next_prev_msg_arrows &&
       
   995               			IsNextMessageAvailableL( ETrue ))
       
   996                 	{
       
   997                    	NextMessageL( ETrue );
       
   998                 	}
       
   999 #endif                	
       
  1000                 break;
       
  1001            	case EKeyOK: // Selection key: Show context menus OR play/record clip
       
  1002                 {    
       
  1003                 // Check if find item highlight needs to be enabled
       
  1004                 if ( CheckFindItemHighlightL( aKeyEvent, aType ) )
       
  1005                     {
       
  1006                     return EKeyWasConsumed;
       
  1007                     }
       
  1008                 
       
  1009                 if ( Document()->GetAppMode() == EAmsEditor )
       
  1010                   	{
       
  1011                   	HandleCommandL( EAmsSoftkeyAdd );
       
  1012                   	return EKeyWasConsumed;
       
  1013                   	}
       
  1014                 else
       
  1015                   	{
       
  1016                   	CMsgBaseControl* ctrl = iView->FocusedControl();
       
  1017                   	if (  ctrl->ControlId() == EMsgComponentIdImage)
       
  1018                     	{
       
  1019                     	HandleCommandL( EAmsSoftkeyAdd );
       
  1020                     	}
       
  1021                   	else
       
  1022                     	{
       
  1023                     	MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_VIEWER_SELECTMENU );
       
  1024                     	MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1025                     	TRAP_IGNORE(MenuBar()->TryDisplayMenuBarL());
       
  1026                     	MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_MENUBAR );
       
  1027                     	MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1028                     	return EKeyWasConsumed;
       
  1029                     	}
       
  1030 
       
  1031                   	}
       
  1032                 return EKeyWasConsumed;
       
  1033                 }
       
  1034            	case EKeyYes:
       
  1035                 {
       
  1036                 if ( Document()->GetAppMode() == EAmsEditor )
       
  1037                   	{
       
  1038                   	// CallCreationKey: Send message if recipients and audio clip exists.
       
  1039                   	//                  Otherwise fetch recipients
       
  1040                   	if ( !IsHeaderEmpty() &&
       
  1041                      		( !IsBodyEmpty() ||
       
  1042                        		Document()->GetClipStatus() != EAmsClipNone ) )
       
  1043                       	{
       
  1044                       	// has address/es and audio clip inserted/recorded -> Send
       
  1045                       	HandleCommandL( EAmsEditorCmdSend );
       
  1046                       	}
       
  1047                   	else if ( IsHeaderEmpty() )
       
  1048                       	{
       
  1049                       	HandleCommandL( EAmsEditorCmdAddRecipient ); 
       
  1050                       	}
       
  1051                   	else if ( IsBodyEmpty() )
       
  1052                     	{
       
  1053                     	ShowInformationNoteL( R_AUDIOMESSAGE_INFO_CANNOT_SEND, EFalse );
       
  1054                     	}
       
  1055                   	}
       
  1056                 else
       
  1057                   	{
       
  1058                   	// if from field not having a valid phone number, show dialer
       
  1059                   	CMsgBaseControl* ctrl = iView->FocusedControl();
       
  1060                   	if(	iSenderType == ESenderTypePhoneNumber && 
       
  1061                   		ctrl && ctrl->ControlId() == EMsgComponentIdFrom)
       
  1062 	             				{
       
  1063 	             				DoCallToSenderL();									
       
  1064                   		}
       
  1065                 	else
       
  1066 											{
       
  1067                   		iAvkonAppUi->SetKeyEventFlags( 0x00);
       
  1068 											}
       
  1069                   	}
       
  1070                 return EKeyWasConsumed;
       
  1071                 }
       
  1072             case EKeyBackspace:
       
  1073             case EKeyDelete:
       
  1074                 {
       
  1075                 CMsgBaseControl* ctrl = iView->FocusedControl();
       
  1076                 if ( ctrl && ctrl->ControlId() == EMsgComponentIdImage &&
       
  1077                    		Document()->GetAppMode() == EAmsEditor  &&
       
  1078                    		!IsBodyEmpty()  )
       
  1079                 	{
       
  1080                     RemoveAudioL();
       
  1081                     return EKeyWasConsumed;
       
  1082                     }
       
  1083                  if ( Document()->GetAppMode() == EAmsViewer )
       
  1084                  	{
       
  1085                     HandleCommandL( EAmsViewerCmdRemoveAudio );
       
  1086                     return EKeyWasConsumed;
       
  1087                  	}
       
  1088                 }
       
  1089             	break;
       
  1090             case EKeyEnter:
       
  1091             	{
       
  1092             	// Check if find item highlight needs to be enabled
       
  1093                 if ( CheckFindItemHighlightL( aKeyEvent, aType ) )
       
  1094                     {
       
  1095                     return EKeyWasConsumed;
       
  1096                     }
       
  1097               	if (DoEnterKeyL() )
       
  1098                 	{
       
  1099                   	return EKeyWasConsumed;
       
  1100                   	}
       
  1101               	break;
       
  1102               	}
       
  1103         	case EKeyNull:
       
  1104         		if( aKeyEvent.iScanCode == 0xA5 /*EStdKeySpace*/ )
       
  1105         			{
       
  1106        				SetNaviPaneL( );
       
  1107         			}
       
  1108         		break;
       
  1109             default:
       
  1110                 break;
       
  1111             }
       
  1112 
       
  1113         switch ( aKeyEvent.iScanCode )
       
  1114             {
       
  1115             case EStdKeyUpArrow:
       
  1116                 // FALLTHROUGH
       
  1117             case EStdKeyDownArrow:
       
  1118                 // FALLTHROUGH
       
  1119             case EStdKeyLeftArrow:
       
  1120                 // FALLTHROUGH
       
  1121             case EStdKeyRightArrow:
       
  1122                 // FALLTHROUGH
       
  1123             case EStdKeyDevice1: // Close key
       
  1124                 // FALLTHROUGH
       
  1125             case EStdKeyRightShift: // Shift
       
  1126                 // FALLTHROUGH
       
  1127             case EStdKeyApplication0: // Task switching
       
  1128     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleKeyEventL <<" ); 
       
  1129                 return CMsgEditorAppUi::HandleKeyEventL( aKeyEvent, aType );
       
  1130             default:
       
  1131                 break;
       
  1132             }
       
  1133 
       
  1134         TKeyResponse resp = CMsgEditorAppUi::HandleKeyEventL( aKeyEvent, aType );
       
  1135 
       
  1136         if ( aType == EEventKeyUp )
       
  1137             {
       
  1138             // Check if character inserted to controls
       
  1139             HandleCharInputL();
       
  1140             }
       
  1141 AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleKeyEventL <<" ); 
       
  1142 
       
  1143         return resp;
       
  1144         }
       
  1145     else
       
  1146         {
       
  1147     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleKeyEventL <<" ); 
       
  1148         return CMsgEditorAppUi::HandleKeyEventL( aKeyEvent, aType );
       
  1149         }
       
  1150     }
       
  1151 
       
  1152 // ---------------------------------------------------------
       
  1153 // CAudioMessageAppUi::HandleCharInputL
       
  1154 // ---------------------------------------------------------
       
  1155 //
       
  1156 void CAudioMessageAppUi::HandleCharInputL()
       
  1157     {
       
  1158     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleCharInputL >>" ); 
       
  1159     if ( Document()->IsLaunched() )
       
  1160         {
       
  1161         CMsgBaseControl* ctrl = iView->FocusedControl();
       
  1162         TBool changed = EFalse;
       
  1163 
       
  1164         if ( ctrl )
       
  1165             {
       
  1166             switch ( ctrl->ControlId() )
       
  1167                 {
       
  1168                 case EMsgComponentIdTo:
       
  1169                     if ( ctrl->IsModified() )
       
  1170                         {
       
  1171                   		Document()->SetHeaderModified( ETrue );
       
  1172                         changed = ETrue;
       
  1173                         }
       
  1174                     SetAddressSize();
       
  1175                     break;
       
  1176                 case EMsgComponentIdFirstFreeEditorSpecificId:
       
  1177                   	if ( ctrl->IsModified() )
       
  1178                     	{
       
  1179                     	Document()->SetBodyModified( ETrue );
       
  1180                     	changed = ETrue;
       
  1181                     	}
       
  1182                   	break;
       
  1183                 default:
       
  1184                     break;
       
  1185                 }
       
  1186             }
       
  1187         if ( changed )
       
  1188             {
       
  1189       		SetNaviPaneL( );
       
  1190             }
       
  1191         }
       
  1192     AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleCharInputL <<" ); 
       
  1193     }
       
  1194 
       
  1195 // ---------------------------------------------------------
       
  1196 // CAudioMessageAppUi::DynInitMenuPaneL
       
  1197 // ---------------------------------------------------------
       
  1198 //
       
  1199 void CAudioMessageAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
  1200     {
       
  1201     AMSLOGGER_WRITE( "CAudioMessageAppUi::DynInitMenuPaneL >>" ); 
       
  1202     // Confirm app is running properly 
       
  1203     if ( !Document()->IsLaunched() )
       
  1204         {
       
  1205         // If not, hide everything and return
       
  1206         TInt amountOfItems = aMenuPane->NumberOfItemsInPane();
       
  1207         if ( amountOfItems )
       
  1208             {
       
  1209             aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems-1 );
       
  1210             return;
       
  1211             }
       
  1212         }
       
  1213 
       
  1214   	if ( !iFindItemMenu )
       
  1215         {
       
  1216         iFindItemMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
       
  1217         if ( SenderType() == ESenderTypeMailAddress )
       
  1218             {
       
  1219             // Set sender type to find menu
       
  1220             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
  1221             }
       
  1222     else
       
  1223         {
       
  1224             // Set sender type to find menu
       
  1225             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EPhoneNumber );
       
  1226             }
       
  1227         }
       
  1228 
       
  1229     switch ( aResourceId )
       
  1230         {
       
  1231         case R_AUDIOMESSAGE_MAIN_MENU:
       
  1232             {
       
  1233             if ( !iMtm->Entry().Entry().ReadOnly() ) // editor
       
  1234               	{
       
  1235                 /*if ( Document()->GetClipStatus() == EAmsClipNone )
       
  1236               		{
       
  1237               		aMenuPane->SetItemDimmed( EAmsEditorCmdSend, ETrue );
       
  1238               		}*/
       
  1239               	if ( Document()->GetClipStatus() == EAmsClipNone )
       
  1240 	                {
       
  1241 	                aMenuPane->SetItemDimmed( EAmsEditorSubmenuReplaceAudioCommands, ETrue );
       
  1242 	                aMenuPane->SetItemDimmed( EAmsEditorCmdPlayAudio, ETrue );
       
  1243 	                aMenuPane->SetItemDimmed( EAmsEditorCmdSaveAudio, ETrue );
       
  1244 	                }
       
  1245 	            else
       
  1246                 	{
       
  1247                 	aMenuPane->SetItemDimmed( EAmsEditorSubmenuInsertAudioCommands, ETrue );
       
  1248                 	}
       
  1249               	if ( Document()->GetClipStatus() == EAmsClipFromGallery )
       
  1250                 	{
       
  1251                 	aMenuPane->SetItemDimmed( EAmsEditorCmdSaveAudio, ETrue );
       
  1252                 	}
       
  1253               	if ( !( iSupportedFeatures & EUniFeatureHelp ) )
       
  1254                   	{
       
  1255                   	aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1256                   	}
       
  1257               	aMenuPane->SetItemDimmed( EAmsViewerCmdSaveAudio, ETrue );
       
  1258 	            aMenuPane->SetItemDimmed( EAmsViewerCmdSubmenuReply, ETrue );
       
  1259 	            aMenuPane->SetItemDimmed( EAmsViewerCmdForward, ETrue );
       
  1260 	            aMenuPane->SetItemDimmed( EFindItemMenuPlaceHolder, ETrue );
       
  1261 	            aMenuPane->SetItemDimmed( EAmsViewerCmdDeliveryStatus, ETrue );
       
  1262 	            aMenuPane->SetItemDimmed( EAmsViewerCmdMoveToFolder, ETrue );
       
  1263 	            aMenuPane->SetItemDimmed( EAmsViewerCmdRemoveAudio, ETrue );              	
       
  1264               	if ( !(iSupportedFeatures & EUniFeaturePriority) )              	
       
  1265 				    {
       
  1266 				    aMenuPane->SetItemDimmed( EAmsEditorCmdChangePriority, ETrue );
       
  1267 				   	}
       
  1268               	}
       
  1269             else // viewer 
       
  1270               	{
       
  1271             	const TPtrC details = iMtm->Entry().Entry().iDetails;
       
  1272 
       
  1273                 TInt focusedControl = FocusedControlId();                         
       
  1274                 TBool senderHighlighted = EFalse;
       
  1275                 
       
  1276                 if ( focusedControl == EMsgComponentIdFrom )
       
  1277                     {
       
  1278                     CMsgAddressControl* address = static_cast<CMsgAddressControl*>(
       
  1279                         iView->ControlById( EMsgComponentIdFrom ) );
       
  1280                     
       
  1281                     if ( address && address->Editor().SelectionLength() 
       
  1282                             == address->Editor().TextLength() )
       
  1283                         {
       
  1284                         senderHighlighted = ETrue;
       
  1285                         }
       
  1286                     }
       
  1287             	   	
       
  1288                 if( ( focusedControl == EMsgComponentIdFrom ) && ( ( iMtm->Sender( ) ).Length() )
       
  1289                       && senderHighlighted )
       
  1290                     {
       
  1291                     iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
  1292                     iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );
       
  1293                     }
       
  1294 	            else
       
  1295 	     	        {
       
  1296                     iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
  1297 		            }
       
  1298               	iFindItemMenu->AddItemFindMenuL (
       
  1299                   	0,
       
  1300                   	aMenuPane,
       
  1301                   	EFindItemMenuPlaceHolder,
       
  1302                   	senderHighlighted ? 
       
  1303                   	TMmsGenUtils::PureAddress( iMtm->Sender( ) ) : KNullDesC(),
       
  1304           			( details.Length() == 0 ),
       
  1305                   	EFalse );
       
  1306           		//in sent folder reply is dimmed
       
  1307                	if ( iMtm->Entry().Entry().Parent() == KMsvSentEntryIdValue )
       
  1308                 	{
       
  1309                     aMenuPane->SetItemDimmed( EAmsViewerCmdSubmenuReply, ETrue );
       
  1310                 	}
       
  1311         		if ( iMtm->Sender().Length() <= 0 )
       
  1312         			{
       
  1313                   	aMenuPane->SetItemDimmed( EAmsViewerCmdSubmenuReply, ETrue );
       
  1314         			}
       
  1315 	            aMenuPane->SetItemDimmed( EAmsEditorCmdSaveAudio, ETrue );
       
  1316 	            aMenuPane->SetItemDimmed( EAmsEditorCmdSend, ETrue );
       
  1317 	            aMenuPane->SetItemDimmed( EAmsEditorCmdAddRecipient, ETrue );
       
  1318 	            aMenuPane->SetItemDimmed( EAmsEditorSubmenuInsertAudioCommands, ETrue );
       
  1319 	            aMenuPane->SetItemDimmed( EAmsEditorSubmenuReplaceAudioCommands, ETrue );
       
  1320 	            aMenuPane->SetItemDimmed( EAmsEditorCmdChangePriority, ETrue );          
       
  1321                 if (! (     iSupportedFeatures & EUniFeatureDeliveryStatus  
       
  1322                         && ( ( Document( )->Entry( ).iMtmData2 & KMmsDeliveryStatusMask) 
       
  1323                         != KMmsDeliveryStatusNotRequested ) ) )
       
  1324                     {
       
  1325     		        aMenuPane->SetItemDimmed( EAmsViewerCmdDeliveryStatus, ETrue );
       
  1326                     }
       
  1327               	if ( !( iSupportedFeatures & EUniFeatureHelp ) )
       
  1328                   	{
       
  1329                   	aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1330                   	}
       
  1331 
       
  1332               	}
       
  1333             }
       
  1334             break;
       
  1335         case R_AUDIOMESSAGE_VIEWER_CONTEXT_MENU://call, reply fw, delete
       
  1336           	{
       
  1337           	TPhCltTelephoneNumber  number;          // phoneclient
       
  1338           	number.Zero();
       
  1339           	const TPtrC details = iMtm->Entry().Entry().iDetails;
       
  1340           	
       
  1341           	if(CommonPhoneParser::IsValidPhoneNumber( 
       
  1342           	                  details, CommonPhoneParser::ESMSNumber ))
       
  1343                 {
       
  1344              number = details;
       
  1345                 }   
       
  1346             if( (FocusedControlId( ) == EMsgComponentIdFrom) && ( ( iMtm->Sender( ) ).Length() ) )
       
  1347                 {
       
  1348                 iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
  1349                 iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );
       
  1350                 }
       
  1351             else
       
  1352      	        {
       
  1353                 iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
  1354 	            }
       
  1355           	iFindItemMenu->AddItemFindMenuL (
       
  1356             	0,
       
  1357         		aMenuPane,
       
  1358               	EFindItemContextMenuPlaceHolder,
       
  1359               	TMmsGenUtils::PureAddress( iMtm->Sender() ),
       
  1360         		( KErrNotFound == number.Match( details ) ), //"Is sender known"
       
  1361             	ETrue );
       
  1362             // no items dimmed for now
       
  1363           	if ( iMtm->Sender().Length() <= 0 )
       
  1364           		{
       
  1365               	aMenuPane->SetItemDimmed( EAmsViewerCmdSubmenuReply, ETrue );
       
  1366           		}
       
  1367           	break;
       
  1368           	}
       
  1369         case R_AUDIOMESSAGE_ZOOM_SUBMENU:
       
  1370             {
       
  1371             TInt zoomLevel = KErrGeneral;
       
  1372             iMsgEditorAppUiExtension->iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, 
       
  1373                                                                     zoomLevel );
       
  1374             switch ( zoomLevel )
       
  1375                 {
       
  1376                 case EAknUiZoomAutomatic:
       
  1377                     {
       
  1378                     aMenuPane->SetItemButtonState( EAmsDispSizeAutomatic,
       
  1379                                                    EEikMenuItemSymbolOn );
       
  1380                     break;
       
  1381                     }
       
  1382                 case EAknUiZoomNormal:
       
  1383                     {
       
  1384                     aMenuPane->SetItemButtonState( EAmsDispSizeNormal,
       
  1385                                                    EEikMenuItemSymbolOn );
       
  1386                     break;
       
  1387                     }
       
  1388                 case EAknUiZoomSmall:
       
  1389                     {
       
  1390                     aMenuPane->SetItemButtonState( EAmsDispSizeSmall,
       
  1391                                                    EEikMenuItemSymbolOn );
       
  1392                     break;
       
  1393                     }
       
  1394                 case EAknUiZoomLarge:
       
  1395                     {
       
  1396                     aMenuPane->SetItemButtonState( EAmsDispSizeLarge,
       
  1397                                                    EEikMenuItemSymbolOn );
       
  1398                     break;
       
  1399                     }
       
  1400                 default:
       
  1401                     {
       
  1402                     break;
       
  1403                     }
       
  1404                 }
       
  1405             break;
       
  1406             }  	
       
  1407        	case R_AUDIOMESSAGE_REPLY_SUBMENU:
       
  1408         	{
       
  1409             if ( iMtm->AddresseeList().Count() < 2  )
       
  1410             	{
       
  1411                 aMenuPane->SetItemDimmed( EAmsViewerCmdReplyToAll, ETrue );
       
  1412             	}
       
  1413         	break;
       
  1414         	}
       
  1415         default:
       
  1416           	if ( iFindItemMenu )
       
  1417             	{
       
  1418         		iFindItemMenu->UpdateItemFinderMenuL( aResourceId, aMenuPane );
       
  1419             	}
       
  1420           	break;
       
  1421         }
       
  1422     AMSLOGGER_WRITE( "CAudioMessageAppUi::DynInitMenuPaneL <<" ); 
       
  1423     }
       
  1424 
       
  1425 // ---------------------------------------------------------
       
  1426 // CAudioMessageAppUi::IsMessageEmpty
       
  1427 // ---------------------------------------------------------
       
  1428 //
       
  1429 TBool CAudioMessageAppUi::IsMessageEmpty() const
       
  1430     {
       
  1431     AMSLOGGER_WRITE( "CAudioMessageAppUi::IsMessageEmpty >>" ); 
       
  1432     return ( IsHeaderEmpty() && IsBodyEmpty() );
       
  1433     }
       
  1434 
       
  1435 // ---------------------------------------------------------
       
  1436 // CAudioMessageAppUi::DoUserSendL
       
  1437 // ---------------------------------------------------------
       
  1438 // 
       
  1439 void CAudioMessageAppUi::DoUserSendL()
       
  1440     {
       
  1441     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserSendL >>" ); 
       
  1442     //Send command may be issued without recipient
       
  1443     //in this case the phonebook is opened
       
  1444 	if(iInserting)
       
  1445 		{
       
  1446 		return;
       
  1447 		}
       
  1448     if ( IsHeaderEmpty() )
       
  1449         {
       
  1450         HandleCommandL( EAmsEditorCmdAddRecipient ); 
       
  1451         return;
       
  1452         }
       
  1453     else if ( IsBodyEmpty() )
       
  1454         {
       
  1455         ShowInformationNoteL( R_AUDIOMESSAGE_INFO_CANNOT_SEND, EFalse );
       
  1456         return;
       
  1457         }
       
  1458 
       
  1459     iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
  1460     // Check message size
       
  1461     if ( TUint( MessageSizeInBytes() ) > Document()->MaxMessageSize() )
       
  1462         {
       
  1463         TInt maxInKilos = ( Document()->MaxMessageSize() + KAmsBytesInKilo - 1 ) / KAmsBytesInKilo;
       
  1464         HBufC* string = StringLoader::LoadLC(
       
  1465             R_AUDIOMESSAGE_INFO_OBJECT_TOO_BIG,
       
  1466             maxInKilos,
       
  1467             iCoeEnv );
       
  1468         CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
       
  1469         note->ExecuteLD( *string );
       
  1470         CleanupStack::PopAndDestroy( string );  // string
       
  1471         return;
       
  1472         }
       
  1473     TBool dummy;
       
  1474     if ( !CheckNamesL( dummy ) )
       
  1475         {
       
  1476         return;
       
  1477         }
       
  1478 
       
  1479     TInt resourceId = IsPhoneOfflineL()
       
  1480         ? R_QTN_WAIT_MSG_SAVED_OUTBOX
       
  1481         : R_QTN_AUDIOMESSAGE_WAIT_SEND_MESSAGE;
       
  1482 
       
  1483     if ( !iAddressHandler )
       
  1484         {
       
  1485         iAddressHandler = CUniAddressHandler::NewL(
       
  1486             *iMtm,
       
  1487             *ToCtrl(),
       
  1488             *iCoeEnv );
       
  1489         }
       
  1490     iSendOperation = CAudioMessageSendOperation::NewL(
       
  1491         *ToCtrl(),
       
  1492         *iAddressHandler,
       
  1493         *this,
       
  1494         *Document(),
       
  1495         *iView );       
       
  1496         
       
  1497     iEditorFlags |= EEditorClosing;
       
  1498 
       
  1499     iAbsorber = CAknInputBlock::NewLC();
       
  1500     CleanupStack::Pop( iAbsorber ); //iAbsorber
       
  1501 
       
  1502     iSendOperation->Send();
       
  1503     ShowWaitNoteL( resourceId );
       
  1504     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserSendL <<" ); 
       
  1505     }
       
  1506 
       
  1507 // ---------------------------------------------------------
       
  1508 // CAudioMessageAppUi::DoMsgSaveExitL
       
  1509 // ---------------------------------------------------------
       
  1510 //
       
  1511 void CAudioMessageAppUi::DoMsgSaveExitL()
       
  1512     {
       
  1513     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoMsgSaveExitL >>" ); 
       
  1514     if ( CAknEnv::AppWithShutterRunning() )
       
  1515         {
       
  1516         iEditorFlags |= ERunAppShutterAtExit;
       
  1517         }
       
  1518     if ( IsMessageEmpty() )
       
  1519         {
       
  1520         DeleteCurrentEntryL();
       
  1521         }
       
  1522    	else if ( CanSaveMessageL())
       
  1523       	{
       
  1524      	if (  Document()->Modified() )
       
  1525          	{
       
  1526           	// Needs saving
       
  1527           	if ( IsForeground() )
       
  1528               	{
       
  1529               	TInt resId =
       
  1530                   	Document()->Saved() ?
       
  1531                   	R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE :
       
  1532                   	R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE_NEW;
       
  1533 		       	// Cannot trap call below.
       
  1534 		        iEditorFlags |= EEditorClosing;
       
  1535 		        DoSaveL();
       
  1536 		        ShowWaitNoteL( resId );
       
  1537               	}
       
  1538           	else
       
  1539               	{
       
  1540               	TInt err(KErrNone);
       
  1541               	TRAP( err, DoSaveL() );
       
  1542               	}
       
  1543           	BeginActiveWait();
       
  1544           	if ( iEditorFlags & ERunAppShutterAtExit )
       
  1545               	{
       
  1546               	CAknEnv::RunAppShutter();
       
  1547               	}
       
  1548             }
       
  1549       	}
       
  1550     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoMsgSaveExitL <<" ); 
       
  1551     }
       
  1552 
       
  1553 // ---------------------------------------------------------
       
  1554 // CAudioMessageAppUi::DeleteCurrentEntryL
       
  1555 // ---------------------------------------------------------
       
  1556 //
       
  1557 void CAudioMessageAppUi::DeleteCurrentEntryL()
       
  1558     {
       
  1559     AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteCurrentEntryL >>" ); 
       
  1560     CAudioMessageDocument& doc = *Document();
       
  1561 
       
  1562     TInt msgStoreDrive = Document()->Session( ).CurrentDriveL( );
       
  1563     FsSession().GetReserveAccess( msgStoreDrive );
       
  1564 
       
  1565     if ( doc.CurrentEntry().OwningService() == KMsvLocalServiceIndexEntryId )
       
  1566         {
       
  1567         const TMsvId id = doc.Entry().Id();
       
  1568         TRAPD(
       
  1569                 err, 
       
  1570                 {
       
  1571                 doc.CurrentEntry().SetEntryL( doc.Entry().Parent() );
       
  1572                 doc.CurrentEntry().DeleteL( id );
       
  1573                 }
       
  1574             );
       
  1575         if ( err != KErrNone )
       
  1576             {
       
  1577             doc.Session().RemoveEntry( id );
       
  1578             }
       
  1579         }
       
  1580     FsSession().ReleaseReserveAccess( msgStoreDrive );
       
  1581     AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteCurrentEntryL <<" ); 
       
  1582     }
       
  1583 
       
  1584 // ---------------------------------------------------------
       
  1585 // CAudioMessageAppUi::DeleteAndExitL
       
  1586 // ---------------------------------------------------------
       
  1587 //
       
  1588 void CAudioMessageAppUi::DeleteAndExitL()
       
  1589     {
       
  1590     AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteAndExitL >>" ); 
       
  1591     DeleteCurrentEntryL();
       
  1592     AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteAndExitL <<" ); 
       
  1593     Exit( EAknSoftkeyBack );
       
  1594     }
       
  1595 
       
  1596 
       
  1597 // ---------------------------------------------------------
       
  1598 // CAudioMessageAppUi::ExitAndSaveL
       
  1599 // ---------------------------------------------------------
       
  1600 //
       
  1601 void CAudioMessageAppUi::ExitAndSaveL( )
       
  1602     {
       
  1603     AMSLOGGER_WRITE( "CAudioMessageAppUi::ExitAndSaveL >>" ); 
       
  1604     if ( iEditorFlags & EEditorClosing )
       
  1605         {
       
  1606         Exit( EAknSoftkeyClose );
       
  1607         return;
       
  1608         }
       
  1609     if ( CAknEnv::AppWithShutterRunning() )
       
  1610         {
       
  1611         iEditorFlags |= ERunAppShutterAtExit;
       
  1612         }
       
  1613     if (    iEditorFlags & ELaunchSuccessful
       
  1614         &&  Document()->MediaAvailable() )
       
  1615         {
       
  1616         TInt err(KErrNone);
       
  1617         TRAP( err, DoMsgSaveExitL() );
       
  1618         }
       
  1619     AMSLOGGER_WRITE( "CAudioMessageAppUi::ExitAndSaveL <<" ); 
       
  1620     Exit();
       
  1621     }
       
  1622 
       
  1623 // ---------------------------------------------------------
       
  1624 // CAudioMessageAppUi::DeleteMessageL
       
  1625 // ---------------------------------------------------------
       
  1626 //
       
  1627 void CAudioMessageAppUi::DeleteMessageL()
       
  1628   	{
       
  1629   	AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteMessageL >>" ); 
       
  1630   	if ( !ShowConfirmationQueryL( R_AUDIOMESSAGE_QUEST_DELETE_MESSAGE ) )
       
  1631   		{
       
  1632 	    CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
  1633 		SetNaviPaneL();
       
  1634     	return;
       
  1635     	}
       
  1636   	DeleteAndExitL();
       
  1637   	AMSLOGGER_WRITE( "CAudioMessageAppUi::DeleteMessageL <<" ); 
       
  1638   	}
       
  1639 
       
  1640 // ---------------------------------------------------------
       
  1641 // CAudioMessageAppUi::DoBackSaveL
       
  1642 // ---------------------------------------------------------
       
  1643 //
       
  1644 void CAudioMessageAppUi::DoBackSaveL()
       
  1645     {
       
  1646     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoBackSaveL >>" ); 
       
  1647     //Make sure this function is not run in case of very fast press
       
  1648     //of close key after play soft key	
       
  1649 	if ( iEditorFlags & EProgressInUse)
       
  1650 		{
       
  1651 		return;
       
  1652 		}
       
  1653 
       
  1654     if ( Document()->GetAppMode() == EAmsViewer )
       
  1655       	{
       
  1656       	Exit( EAknSoftkeyClose );
       
  1657       	}
       
  1658     if ( IsMessageEmpty() && Document()->GetClipStatus() == EAmsClipNone )
       
  1659         {
       
  1660         if ( iMtm->Entry().Entry().Visible() )
       
  1661             {
       
  1662             ShowInformationNoteL( R_AUDIOMESSAGE_INFO_DELETED, ETrue );
       
  1663             }
       
  1664         DeleteAndExitL();
       
  1665         }
       
  1666     else
       
  1667         {
       
  1668         TInt closeVal = ShowCloseQueryL();
       
  1669         if ( closeVal == EMsgCloseCancel )
       
  1670             {
       
  1671             return;
       
  1672             }
       
  1673         else if ( closeVal == EMsgCloseDelete )
       
  1674             {
       
  1675             DeleteCurrentEntryL();
       
  1676         	Exit( EAknSoftkeyBack );
       
  1677             }
       
  1678         else // closeVal == EMsgCloseSave
       
  1679             {
       
  1680             // Message has data or there is a recipient
       
  1681             if ( Document()->Modified() || ToCtrl() )
       
  1682                 {
       
  1683                 if ( CanSaveMessageL() )
       
  1684                     {
       
  1685                     TInt resId =
       
  1686                         Document()->Saved() ?
       
  1687                         R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE :
       
  1688                         R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE_NEW;
       
  1689                     iEditorFlags |= EEditorClosing;
       
  1690 
       
  1691                     DoSaveL();
       
  1692                     ShowWaitNoteL( resId );
       
  1693                     BeginActiveWait();
       
  1694                     }
       
  1695                 else
       
  1696                     {
       
  1697                     if ( ShowConfirmationQueryL( R_AUDIOMESSAGE_QUEST_CLOSE_OOD ) )
       
  1698                         {
       
  1699                         // Exit without saving.
       
  1700                         Exit( EAknSoftkeyClose );
       
  1701                         }
       
  1702                     }
       
  1703                 }
       
  1704             else
       
  1705                {
       
  1706                 // No changes -> just go away.
       
  1707                Exit( EAknSoftkeyClose );
       
  1708                }
       
  1709             }
       
  1710         }
       
  1711     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoBackSaveL <<" ); 
       
  1712     }
       
  1713 
       
  1714 // ---------------------------------------------------------
       
  1715 // CAudioMessageAppUi::CanSaveMessageL
       
  1716 // ---------------------------------------------------------
       
  1717 //
       
  1718 TBool CAudioMessageAppUi::CanSaveMessageL() const
       
  1719     {
       
  1720     AMSLOGGER_WRITE( "CAudioMessageAppUi::CanSaveMessageL" ); 
       
  1721    	TInt bytes =
       
  1722        	Document()->AddressSize() +
       
  1723         Document()->AudioFileSize();
       
  1724     return !( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(Document()->Session(),
       
  1725         bytes ) );
       
  1726     }
       
  1727 
       
  1728 // ---------------------------------------------------------
       
  1729 // CAudioMessageAppUi::DoSaveL
       
  1730 // ---------------------------------------------------------
       
  1731 //
       
  1732 void CAudioMessageAppUi::DoSaveL()
       
  1733     {
       
  1734     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoSaveL >>" ); 
       
  1735     if ( !CanSaveMessageL() )
       
  1736         {
       
  1737         User::Leave( KErrDiskFull );
       
  1738         }
       
  1739     iAbsorber = CAknInputBlock::NewLC();
       
  1740     CleanupStack::Pop( iAbsorber );
       
  1741  
       
  1742     delete iSaveOperation;
       
  1743     iSaveOperation = NULL;
       
  1744     iSaveOperation = CAudioMessageSaveOperation::NewL( *ToCtrl(),
       
  1745         *this,
       
  1746         *Document(),
       
  1747         *iView );
       
  1748     iSaveOperation->Save();
       
  1749     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoSaveL <<" ); 
       
  1750     }
       
  1751 
       
  1752 
       
  1753 // ---------------------------------------------------------
       
  1754 // CAudioMessageAppUi::CheckNamesL
       
  1755 // ---------------------------------------------------------
       
  1756 //
       
  1757 TBool CAudioMessageAppUi::CheckNamesL( TBool& aModified )
       
  1758     {	
       
  1759     AMSLOGGER_WRITE( "CAudioMessageAppUi::CheckNamesL >>" ); 
       
  1760     iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
  1761     CMsgAddressControl* headerField = ToCtrl();
       
  1762     aModified = EFalse;
       
  1763     TBool retVal = VerifyAddressesL( aModified );
       
  1764 
       
  1765     if ( aModified )
       
  1766         {
       
  1767         Document()->SetHeaderModified( ETrue );
       
  1768         SetAddressSize();
       
  1769     	SetNaviPaneL( );
       
  1770         }
       
  1771 
       
  1772     if ( !retVal )
       
  1773         {
       
  1774         //We'll get here if there's illegal addresses
       
  1775         if ( headerField )
       
  1776             {
       
  1777             // Search first invalid address
       
  1778             CMsgRecipientArray* recipients = headerField->GetRecipientsL();
       
  1779             TInt addrCnt = recipients->Count();
       
  1780 
       
  1781             for ( TInt k = 0; k < addrCnt ; k++ )
       
  1782                 {
       
  1783                 CMsgRecipientItem* addrItem = recipients->At( k );
       
  1784                 if ( addrItem && !addrItem->IsValidated() )
       
  1785                     {
       
  1786                     TInt ret = headerField->HighlightUnvalidatedStringL();
       
  1787                     if ( !ret )
       
  1788                         {
       
  1789                         // highlight succeeded
       
  1790                         break;
       
  1791                         }
       
  1792                     }
       
  1793                 }
       
  1794             }
       
  1795         }
       
  1796 AMSLOGGER_WRITE( "CAudioMessageAppUi::CheckNamesL <<" ); 
       
  1797     return retVal;
       
  1798     }
       
  1799 
       
  1800 // ---------------------------------------------------------
       
  1801 // CAudioMessageAppUi::VerifyAddressesL
       
  1802 // ---------------------------------------------------------
       
  1803 //
       
  1804 TBool CAudioMessageAppUi::VerifyAddressesL( TBool& aModified )
       
  1805     {
       
  1806     AMSLOGGER_WRITE( "CAudioMessageAppUi::VerifyAddressesL >>" ); 
       
  1807     if ( !iAddressHandler )
       
  1808         {
       
  1809         iAddressHandler = CUniAddressHandler::NewL(
       
  1810             *iMtm,
       
  1811             *ToCtrl(),
       
  1812             *iCoeEnv );
       
  1813         }
       
  1814     AMSLOGGER_WRITE( "CAudioMessageAppUi::VerifyAddressesL ... after return <<" ); 
       
  1815 
       
  1816     return iAddressHandler->VerifyAddressesL( aModified );
       
  1817     }
       
  1818 
       
  1819 // ---------------------------------------------------------
       
  1820 // CAudioMessageAppUi::DoUserAddRecipientL
       
  1821 // ---------------------------------------------------------
       
  1822 //JANI-7H3EVA :: fix:: Reddy
       
  1823 //
       
  1824 void CAudioMessageAppUi::DoUserAddRecipientL()
       
  1825     {
       
  1826     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserAddRecipientL >>" ); 
       
  1827     
       
  1828     if(iToolbar)
       
  1829         {
       
  1830         iToolbar->SetToolbarVisibility(EFalse, EFalse);
       
  1831         }
       
  1832  
       
  1833     if ( !iAddressHandler )
       
  1834         {
       
  1835         iAddressHandler = CUniAddressHandler::NewL(
       
  1836             *iMtm,
       
  1837             *ToCtrl(),
       
  1838             *iCoeEnv );
       
  1839         }
       
  1840 
       
  1841     TBool dummy( EFalse );
       
  1842     TBool recipientAdded( EFalse );
       
  1843     recipientAdded =  iAddressHandler->AddRecipientL( dummy ); 
       
  1844     if (recipientAdded)
       
  1845         {
       
  1846         Document()->SetHeaderModified( ETrue );
       
  1847         SetAddressSize();
       
  1848         }
       
  1849     
       
  1850     if(iToolbar)
       
  1851         {
       
  1852         iToolbar->SetToolbarVisibility(ETrue, EFalse);
       
  1853         }
       
  1854         
       
  1855     if( recipientAdded)
       
  1856         {
       
  1857         iView->SetFocus( EMsgComponentIdTo );
       
  1858         }
       
  1859 
       
  1860     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserAddRecipientL <<" ); 
       
  1861     }
       
  1862 
       
  1863 // ---------------------------------------------------------
       
  1864 // CAudioMessageAppUi::SetSubjectL
       
  1865 // ---------------------------------------------------------
       
  1866 //
       
  1867 void CAudioMessageAppUi::SetSubjectL()
       
  1868   	{
       
  1869   	AMSLOGGER_WRITE( "CAudioMessageAppUi::SetSubjectL >>" ); 
       
  1870   	HBufC* subject = iMtm->SubjectL().AllocLC();
       
  1871   	TPtr subjectPtr = subject->Des();
       
  1872   	subjectPtr.Trim();
       
  1873   	if ( subjectPtr.Length() )
       
  1874     	{
       
  1875         iView->AddControlFromResourceL( R_AUDIOMESSAGE_SUBJECT, EMsgExpandableControl,
       
  1876           	EMsgAppendControl, EMsgHeader );
       
  1877       	CMsgExpandableControl* subjectControl =
       
  1878       		static_cast<CMsgExpandableControl*> ( iView->ControlById( EMsgComponentIdSubject ) );
       
  1879         subjectControl->Editor().SetTextL( subject );
       
  1880       	}
       
  1881   	CleanupStack::PopAndDestroy( subject ); //subject
       
  1882   	AMSLOGGER_WRITE( "CAudioMessageAppUi::SetSubjectL <<" ); 
       
  1883   	}
       
  1884 
       
  1885 // ---------------------------------------------------------
       
  1886 // CAudioMessageAppUi::SetSenderL
       
  1887 // ---------------------------------------------------------
       
  1888 //
       
  1889 void CAudioMessageAppUi::SetSenderL()
       
  1890   	{
       
  1891   	AMSLOGGER_WRITE( "CAudioMessageAppUi::SetSenderL >>" ); 
       
  1892   	iView->AddControlFromResourceL( R_AUDIOMESSAGE_VIEWER_FROM,
       
  1893                   EMsgAddressControl,
       
  1894                   EMsgAppendControl,
       
  1895                   EMsgHeader );
       
  1896 
       
  1897   	CMsgAddressControl* fromCtrl = FromCtrl();
       
  1898     const TPtrC sender = iMtm->Sender();
       
  1899     const TPtrC details = iMtm->Entry().Entry().iDetails;
       
  1900 
       
  1901     if ( sender.Length() )
       
  1902         {
       
  1903         if ( CommonPhoneParser::IsValidPhoneNumber(
       
  1904             TMmsGenUtils::PureAddress( sender ),
       
  1905             CommonPhoneParser::ESMSNumber ) )
       
  1906             {
       
  1907             iSenderType = ESenderTypePhoneNumber;
       
  1908             }
       
  1909         else
       
  1910             {
       
  1911             //We trust on that there won't be illegal addresses
       
  1912             //in received messages
       
  1913             iSenderType = ESenderTypeMailAddress;
       
  1914             }
       
  1915 
       
  1916         //Check if MMS engine has put an alias into iDetails field
       
  1917         if ( sender.Compare( details ) != 0 )
       
  1918             {
       
  1919             TPtrC alias = KNullDesC();
       
  1920             
       
  1921             if ( details.Length() && !iAlias )
       
  1922                 {
       
  1923                 iAlias = details.AllocL( );
       
  1924                 alias.Set( *iAlias );
       
  1925                 }
       
  1926             MVPbkContactLink* link = NULL;
       
  1927             fromCtrl->AddRecipientL( alias,
       
  1928                           TMmsGenUtils::PureAddress( sender ),
       
  1929                           ETrue,
       
  1930                           link );
       
  1931 
       
  1932             }
       
  1933         else
       
  1934             {
       
  1935             MVPbkContactLink* link = NULL;
       
  1936             fromCtrl->AddRecipientL( TMmsGenUtils::Alias( sender ),
       
  1937                           TMmsGenUtils::PureAddress( sender ),
       
  1938                           ETrue,
       
  1939                           link );
       
  1940 
       
  1941             }
       
  1942         }
       
  1943         else
       
  1944         	{
       
  1945         	iSenderType = ESenderTypeNone;       	
       
  1946         	}
       
  1947   	AMSLOGGER_WRITE( "CAudioMessageAppUi::SetSenderL <<" ); 
       
  1948   	}
       
  1949 
       
  1950 // ---------------------------------------------------------
       
  1951 // CAudioMessageAppUi::InsertRecipientL
       
  1952 // EKLU-7LGCPT :: Filter Invalid contact details
       
  1953 // ---------------------------------------------------------
       
  1954 void CAudioMessageAppUi::InsertRecipientL()
       
  1955   	{
       
  1956   	AMSLOGGER_WRITE( "CAudioMessageAppUi::InsertRecipientL >>" ); 
       
  1957 
       
  1958   	if ( Document()->GetAppMode() == EAmsViewer )
       
  1959     	{
       
  1960     	iView->AddControlFromResourceL(  R_AUDIOMESSAGE_VIEWER_TO,
       
  1961                EMsgAddressControl,
       
  1962                EMsgAppendControl,
       
  1963                EMsgHeader );
       
  1964     	}
       
  1965     
       
  1966     TBool addInvalidRecipient = EFalse;
       
  1967     if ( !iAddressHandler )
       
  1968         {
       
  1969         iAddressHandler = CUniAddressHandler::NewL( *iMtm, *ToCtrl(), *iCoeEnv );
       
  1970         }
       
  1971     
       
  1972     if( Document()->Entry().iMtmData1 & KMmsMessageEditorOriented )
       
  1973         {
       
  1974         //if opened from draft folders, then simply open the message as saved, without any cntact filtering
       
  1975         addInvalidRecipient = ETrue;
       
  1976         }
       
  1977     iAddressHandler->CopyAddressesFromMtmL( EMsvRecipientTo, addInvalidRecipient );
       
  1978     iAddressHandler->ShowInvalidRecipientInfoNotesL();
       
  1979 
       
  1980   	AMSLOGGER_WRITE( "CAudioMessageAppUi::InsertRecipientL <<" ); 
       
  1981   	}
       
  1982 
       
  1983 // ---------------------------------------------------------
       
  1984 // CAudioMessageAppUi::DoUserMessageInfoL
       
  1985 // ---------------------------------------------------------
       
  1986 //
       
  1987 void CAudioMessageAppUi::DoUserMessageInfoL()
       
  1988     {
       
  1989     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserMessageInfoL >>" ); 
       
  1990     CBaseMtmUi& uiMtm = Document()->MtmUi();
       
  1991     CAknInputBlock::NewLC();
       
  1992   	if ( Document()->HeaderModified() )
       
  1993     	{
       
  1994      	const CMsvRecipientList& addresses = iMtm->AddresseeList();
       
  1995     	// Reset addresses in clientMtm
       
  1996       	for ( TInt i = iMtm->AddresseeList().Count(); --i >=  0; )
       
  1997         	{
       
  1998             iMtm->RemoveAddressee( i );
       
  1999         	}
       
  2000 
       
  2001       	const CMsgRecipientArray* recipients = ToCtrl()->GetRecipientsL();
       
  2002       	// inserts addresses from address control to clientMtm
       
  2003       	TInt addrCnt = recipients->Count();
       
  2004       	for ( TInt ii = 0; ii < addrCnt ; ii++ )
       
  2005       	    {
       
  2006       	    CMsgRecipientItem* addrItem = recipients->At(ii);
       
  2007       	    TPtr realAddress = addrItem->Address()->Des();
       
  2008       	    TPtr alias = addrItem->Name()->Des();
       
  2009       	    iMtm->AddAddresseeL( EMsvRecipientTo, realAddress, alias );
       
  2010       	    }
       
  2011       	iMtm->SaveMessageL();
       
  2012       	Document()->SetHeaderModified( EFalse );
       
  2013     	}
       
  2014 
       
  2015   	TMmsMsvEntry tEntry = static_cast<TMmsMsvEntry>( Document()->Entry() );
       
  2016     tEntry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid;
       
  2017     // Save made because user launched Message Info, Preview or Objects view
       
  2018     // Message should stay invisible and in preparation if it was.
       
  2019     if ( !tEntry.Visible() )
       
  2020      	{
       
  2021         // Guarantee that when Visible is ETrue InPreparation is EFalse
       
  2022         tEntry.SetInPreparation( ETrue );
       
  2023         }
       
  2024     Document()->CurrentEntry().ChangeL(tEntry);
       
  2025     // Pack message size
       
  2026     TInt sizeInKilos = 0;
       
  2027   	if ( EAmsClipAttachment == Document()->GetClipStatus() )
       
  2028   		{
       
  2029         sizeInKilos = ( Document()->AudioFileSize() + KAmsBytesInKilo - 1 ) / KAmsBytesInKilo;
       
  2030   		}
       
  2031     else
       
  2032     	{
       
  2033       	sizeInKilos=( MessageSizeInBytes() + KAmsBytesInKilo - 1 ) / KAmsBytesInKilo;
       
  2034     	}
       
  2035 
       
  2036     TPckgBuf<TInt> param( sizeInKilos );
       
  2037 
       
  2038     //These are not used. They just have to be there
       
  2039     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  2040     CleanupStack::PushL( selection );
       
  2041 
       
  2042     // Change to "sync" operation
       
  2043     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document() );
       
  2044     CMsvOperation* op = uiMtm.InvokeAsyncFunctionL(
       
  2045         KMtmUiFunctionMessageInfo,
       
  2046         *selection,
       
  2047         watch->iStatus,
       
  2048         param );
       
  2049     CleanupStack::Pop( watch ); // watch
       
  2050     Document()->AddSingleOperationL( op, watch );
       
  2051 
       
  2052     CleanupStack::PopAndDestroy( 2 ); // selection, CAknInputBlock
       
  2053 	SetNaviPaneL();
       
  2054     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoUserMessageInfoL <<" ); 
       
  2055     }
       
  2056 
       
  2057 // ---------------------------------------------------------
       
  2058 // CAudioMessageAppUi::SetAudioClipIconL
       
  2059 // ---------------------------------------------------------
       
  2060 //
       
  2061 void CAudioMessageAppUi::SetAudioClipIconL( TAmsRecordIconStatus aStatus )
       
  2062   	{
       
  2063   	AMSLOGGER_WRITE( "CAudioMessageAppUi::SetAudioClipIconL >>" ); 
       
  2064     iLaunchOperation->DoPrepareBodyL( aStatus );
       
  2065     AMSLOGGER_WRITE( "CAudioMessageAppUi::SetAudioClipIconL <<" ); 
       
  2066   	}
       
  2067 
       
  2068 // ---------------------------------------------------------
       
  2069 // CAudioMessageAppUi::PlayAudioL
       
  2070 // ---------------------------------------------------------
       
  2071 //
       
  2072 void CAudioMessageAppUi::PlayAudioL()
       
  2073 	{
       
  2074 	AMSLOGGER_WRITE( "CAudioMessageAppUi::PlayAudioL >>" ); 
       
  2075 	//Make sure this function is not run in case of very fast double press
       
  2076 	//of play softkey
       
  2077 	if ( iEditorFlags & EProgressInUse)
       
  2078 		{
       
  2079 		return;
       
  2080 		}
       
  2081 	
       
  2082 	iEditorFlags |= EProgressInUse;
       
  2083   	if ( IsSilentModeL()
       
  2084         && !ShowConfirmationQueryL( R_QTN_AUDIOMESSAGE_OBEY_SILENT_MODE ) )
       
  2085   		{
       
  2086   		iEditorFlags &= ~EProgressInUse;	
       
  2087     	return;
       
  2088     	}
       
  2089   	CMsvStore* store = Document()->Mtm().Entry().ReadStoreL();
       
  2090   	CleanupStack::PushL( store );
       
  2091   	MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
  2092     RFile rFile = manager.GetAttachmentFileL( Document()->iAudio );
       
  2093     CleanupClosePushL( rFile );
       
  2094 
       
  2095     // Capture voice key while recording
       
  2096     if ( iVoiceKeyHandle <= 0 )
       
  2097         {
       
  2098         iVoiceKeyHandle = iCoeEnv->RootWin().CaptureKey(
       
  2099             EKeyDevice6, 0, 0 );
       
  2100         }
       
  2101 
       
  2102 	iProgressDlg = CAudioMessageProgressDialog::NewL( rFile, 
       
  2103 				iCurrentVolume, iSpeakerEarpiece, EFalse, *Document() );
       
  2104 	iProgressDlg->SetNaviObserver( this );	
       
  2105 
       
  2106     TRAPD( err, iProgressDlg->ExecuteLD( R_AUDIOMESSAGE_VOICE_SPEAK_DIALOG ) );
       
  2107     if (err == KErrNotSupported)
       
  2108     	{
       
  2109     	Document()->SetClipStatus( EAmsClipCorrupted ); 
       
  2110     	SetAudioClipIconL( EAudioCorrupted );
       
  2111     	ShowErrorNoteL( R_AUDIOMESSAGE_ERROR_MSG_CORRUPT, ETrue );
       
  2112     	User::Leave( KErrNotSupported );
       
  2113     	}
       
  2114     else if (err != KErrNone )
       
  2115     	{
       
  2116     	User::Leave( err );
       
  2117     	}
       
  2118     
       
  2119 
       
  2120     SetNaviPaneL();	
       
  2121 
       
  2122 	iProgressDlg = NULL;
       
  2123 	
       
  2124     CleanupStack::PopAndDestroy( &rFile );
       
  2125     CleanupStack::PopAndDestroy( store );
       
  2126 
       
  2127   	// Release voice key
       
  2128   	if ( iVoiceKeyHandle >= 0 )
       
  2129       	{
       
  2130       	iCoeEnv->RootWin().CancelCaptureKey( iVoiceKeyHandle );
       
  2131       	iVoiceKeyHandle = KAmsNotCaptured;
       
  2132       	}
       
  2133    	iEditorFlags &= ~EProgressInUse;
       
  2134 AMSLOGGER_WRITE( "CAudioMessageAppUi::PlayAudioL <<" ); 
       
  2135 	}
       
  2136 
       
  2137 // ---------------------------------------------------------
       
  2138 // CAudioMessageAppUi::InsertAudioL
       
  2139 // ---------------------------------------------------------
       
  2140 //
       
  2141 void CAudioMessageAppUi::InsertAudioL( TBool aNew )
       
  2142     {
       
  2143     AMSLOGGER_WRITE( "CAudioMessageAppUi::InsertAudioL >>" ); 
       
  2144 
       
  2145    	iEditorFlags |= EProgressInUse;
       
  2146 
       
  2147     if ( aNew )
       
  2148      	{
       
  2149      	if ( !iAbsorber )
       
  2150             {
       
  2151             iAbsorber = CAknInputBlock::NewLC();
       
  2152         	CleanupStack::Pop( iAbsorber );
       
  2153             }
       
  2154             
       
  2155         if ( UnsupportedCallTypeOngoingL() )
       
  2156         	{
       
  2157             delete iAbsorber;
       
  2158             iAbsorber = NULL;
       
  2159             iEditorFlags &= ~EProgressInUse;
       
  2160             return;
       
  2161         	}
       
  2162 
       
  2163         SetNaviPaneL( );// Capture voice key while recording
       
  2164       	if ( iVoiceKeyHandle <= 0 )
       
  2165               {
       
  2166               iVoiceKeyHandle = iCoeEnv->RootWin().CaptureKey(
       
  2167                   EKeyDevice6, 0, 0 );
       
  2168               }
       
  2169 
       
  2170       	TFileName* cmdFileName = new( ELeave ) TFileName;
       
  2171     	CleanupStack::PushL( cmdFileName );
       
  2172 
       
  2173         MsgAttachmentUtils::GetMsgEditorTempPath( *cmdFileName );  // It's cleaned by base editor
       
  2174         // Create temp directory if needed
       
  2175         TInt err = iEikonEnv->FsSession( ).MkDirAll( *cmdFileName );
       
  2176       	if ( err != KErrNone && err != KErrAlreadyExists )
       
  2177         	{
       
  2178             User::Leave( err );
       
  2179             }
       
  2180       	// prepare cmdFile name
       
  2181       	cmdFileName->Append( *iClipFileName );
       
  2182       	cmdFileName->Append( KAmrFileExt );
       
  2183       	RFile rFile;
       
  2184         User::LeaveIfError( rFile.Replace( FsSession(), *cmdFileName, EFileWrite ) ); 	
       
  2185     	CleanupClosePushL( rFile );
       
  2186     	
       
  2187     	iProgressDlg 
       
  2188     	    = CAudioMessageProgressDialog::NewL( rFile, iCurrentVolume, iSpeakerEarpiece, ETrue, *Document());
       
  2189     	iProgressDlg->SetMaxMessageSize( Document()->MaxMessageSize() );
       
  2190     	iProgressDlg->SetNaviObserver( this );
       
  2191 	
       
  2192         delete iAbsorber;
       
  2193         iAbsorber = NULL;
       
  2194         
       
  2195         iProgressDlg->ExecuteLD( R_AUDIOMESSAGE_VOICE_SPEAK_DIALOG );
       
  2196 		iAvkonAppUi->Cba()->MakeVisible( EFalse );
       
  2197 	
       
  2198         if ( !iAbsorber )
       
  2199          	{
       
  2200             iAbsorber = CAknInputBlock::NewLC();
       
  2201         	CleanupStack::Pop( iAbsorber );
       
  2202           	}
       
  2203         iProgressDlg=NULL;
       
  2204            	
       
  2205       	CleanupStack::PopAndDestroy( &rFile );
       
  2206       	if(!CheckIncomingCall())
       
  2207       	    {
       
  2208       	    ShowWaitNoteL( R_QTN_AUDIOMESSAGE_WAIT_INSERTING);
       
  2209       	    }
       
  2210       	DoInsertAudioL( *cmdFileName  );
       
  2211         	
       
  2212          // Release voice key
       
  2213         if ( iVoiceKeyHandle >= 0 )
       
  2214           	{
       
  2215           	iCoeEnv->RootWin().CancelCaptureKey( iVoiceKeyHandle );
       
  2216           	iVoiceKeyHandle = KAmsNotCaptured;
       
  2217           	}
       
  2218       	}
       
  2219     else
       
  2220         {
       
  2221         //must update navi here because if you got clip already and play it and after that
       
  2222         //you insert a new clip from gallery the navi field is not correct
       
  2223         SetNaviPaneL( );
       
  2224       	TFileName tmpFileName;
       
  2225       	if ( FetchFileL( tmpFileName ) )
       
  2226           	{
       
  2227           	if(!CheckIncomingCall())
       
  2228       	    	{
       
  2229       	   		 ShowWaitNoteL( R_QTN_AUDIOMESSAGE_WAIT_INSERTING);
       
  2230       	   	 	}
       
  2231         	if ( !iInsertOperation )
       
  2232                 {
       
  2233                 iInsertOperation = CAudioMessageInsertOperation::NewL(
       
  2234                     *this,
       
  2235                     *Document(),
       
  2236                     *iView );
       
  2237                 }
       
  2238 
       
  2239             iInserting = ETrue;
       
  2240             iAbsorber = CAknInputBlock::NewLC();
       
  2241             CleanupStack::Pop( iAbsorber );
       
  2242             iInsertOperation->Insert( iInsertingMedia, EFalse, EFalse  );
       
  2243             Document()->SetClipStatus( EAmsClipFromGallery );	
       
  2244           	}
       
  2245         }
       
  2246     
       
  2247 	iEditorFlags &= ~EProgressInUse;
       
  2248 AMSLOGGER_WRITE( "CAudioMessageAppUi::InsertAudioL <<" ); 
       
  2249     }
       
  2250 
       
  2251 
       
  2252 // ---------------------------------------------------------
       
  2253 // CAudioMessageAppUi::DoInsertAudioL
       
  2254 // ---------------------------------------------------------
       
  2255 //
       
  2256 void CAudioMessageAppUi::DoInsertAudioL( TFileName &aCmdFileName )
       
  2257     {
       
  2258     if ( iInsertingMedia )
       
  2259 	    {
       
  2260 	    delete iInsertingMedia;
       
  2261 	    iInsertingMedia = NULL;
       
  2262 	    }
       
  2263     RFile fileHandle = Document()->MediaResolver()->FileHandleL( aCmdFileName );
       
  2264     CleanupClosePushL( fileHandle );
       
  2265     iInsertingMedia = Document()->MediaResolver()->CreateMediaInfoL( fileHandle );
       
  2266     // No need to parse info details
       
  2267     CleanupStack::PopAndDestroy( &fileHandle );
       
  2268 
       
  2269     if ( !iInsertOperation )
       
  2270      	{
       
  2271         		iInsertOperation = CAudioMessageInsertOperation::NewL(
       
  2272                	 	*this,
       
  2273                 	*Document(),
       
  2274                 	*iView );
       
  2275         }
       
  2276     iInserting = ETrue;
       
  2277     iInsertOperation->Insert( iInsertingMedia, EFalse ,ETrue );
       
  2278     Document()->SetClipStatus( EAmsClipFromRecorder );
       
  2279     CleanupStack::PopAndDestroy( &aCmdFileName );
       
  2280     }
       
  2281 
       
  2282 
       
  2283 // ---------------------------------------------------------
       
  2284 // CAudioMessageAppUi::CreateMediaInfoForInsertL
       
  2285 // ---------------------------------------------------------
       
  2286 //
       
  2287 TBool CAudioMessageAppUi::CreateMediaInfoForInsertL( const TDesC& aFileName )
       
  2288     {
       
  2289     AMSLOGGER_WRITE( "CAudioMessageAppUi::CreateMediaInfoForInsertL >>" ); 
       
  2290     if ( iInsertingMedia )
       
  2291       	{
       
  2292       	delete iInsertingMedia;
       
  2293       	iInsertingMedia = NULL;
       
  2294       	}
       
  2295 
       
  2296     RFile fileHandle = Document()->MediaResolver()->FileHandleL( aFileName );
       
  2297     CleanupClosePushL( fileHandle );
       
  2298     iInsertingMedia = Document()->MediaResolver()->CreateMediaInfoL( fileHandle );
       
  2299     Document()->MediaResolver()->ParseInfoDetailsL( iInsertingMedia, fileHandle );
       
  2300     CleanupStack::PopAndDestroy( &fileHandle );
       
  2301     
       
  2302     TInt errResId = 0;
       
  2303     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( 
       
  2304             Document()->Mtm().Session(),
       
  2305          	iInsertingMedia->FileSize() ) )
       
  2306     	{
       
  2307         User::Leave( KErrDiskFull );
       
  2308         }
       
  2309   	if ( iInsertingMedia->FileSize() > Document()->MaxMessageSize() )
       
  2310     	{
       
  2311     	errResId = R_AUDIOMESSAGE_INFO_SIZE_EXCEEDED;
       
  2312     	}
       
  2313   	else if ( iInsertingMedia->MimeType().CompareF( KMsgMimeAudioAmr ) != 0 )
       
  2314     	{
       
  2315     	errResId = R_AUDIOMESSAGE_INFO_INVALID_OBJECT;
       
  2316     	}
       
  2317     	// Supported type check
       
  2318     else if ( iInsertingMedia->Protection() )
       
  2319         {
       
  2320         errResId = R_AUDIOMESSAGE_INFO_UNABLE_TO_INSERT_DRM;
       
  2321         }
       
  2322     else if ( iInsertingMedia->Corrupt() )
       
  2323         {
       
  2324         // Corrupt is set to only supported media types
       
  2325         errResId = R_AUDIOMESSAGE_INFO_CORRUPTED_OBJECT;
       
  2326         }
       
  2327     if ( errResId != 0 )
       
  2328         {
       
  2329         delete iInsertingMedia;
       
  2330         iInsertingMedia = NULL;
       
  2331         ShowInformationNoteL( errResId, EFalse );
       
  2332 AMSLOGGER_WRITE( "CAudioMessageAppUi::CreateMediaInfoForInsertL <<" ); 
       
  2333         return EFalse;
       
  2334         }
       
  2335 AMSLOGGER_WRITE( "CAudioMessageAppUi::CreateMediaInfoForInsertL <<" ); 
       
  2336     return ETrue;
       
  2337 
       
  2338     }
       
  2339  
       
  2340 
       
  2341 // ---------------------------------------------------------
       
  2342 // CAudioMessageAppUi::InitViewerNaviPaneL
       
  2343 // ---------------------------------------------------------
       
  2344 //
       
  2345 void CAudioMessageAppUi::InitViewerNaviPaneL()
       
  2346     {
       
  2347     AMSLOGGER_WRITE( "CAudioMessageAppUi::InitNaviPaneL >>" ); 
       
  2348 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2349     //main navi control container
       
  2350     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
  2351         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  2352 
       
  2353     
       
  2354     //length
       
  2355     MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  2356     if( editIndi )
       
  2357     	{
       
  2358     	iNavi_length = editIndi->IndicatorContainer();	
       
  2359     	}    
       
  2360 
       
  2361     TMsgEditorMsgPriority priority = EMsgEditorMsgPriorityNormal;
       
  2362     
       
  2363     if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
  2364         {
       
  2365         priority = EMsgEditorMsgPriorityHigh;
       
  2366         }
       
  2367     else if ( iMtm->MessagePriority() == EMmsPriorityLow )
       
  2368         {
       
  2369         priority = EMsgEditorMsgPriorityLow;
       
  2370         }
       
  2371     
       
  2372     TBool utcTime = ETrue;    
       
  2373     CreateViewerNaviPaneL( Document()->Entry().iDate, priority, utcTime  );
       
  2374 
       
  2375     iNaviPane->PushL( *iNaviDecorator );  // <- This has nothing to do with cleanup-stack
       
  2376      
       
  2377 #else    
       
  2378     //main navi control container
       
  2379     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
  2380         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) ); 
       
  2381 
       
  2382 #endif    
       
  2383     AMSLOGGER_WRITE( "CAudioMessageAppUi::InitNaviPaneL <<" ); 
       
  2384     }
       
  2385    
       
  2386 // ---------------------------------------------------------
       
  2387 // CAudioMessageAppUi::InitViewerNaviPaneL
       
  2388 // ---------------------------------------------------------
       
  2389 //
       
  2390 void CAudioMessageAppUi::InitEditorNaviPaneL()
       
  2391     {
       
  2392     AMSLOGGER_WRITE( "CAudioMessageAppUi::InitEditorNaviPaneL >>" ); 
       
  2393 
       
  2394     //main navi control container
       
  2395     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
  2396         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) ); 
       
  2397     
       
  2398     //length
       
  2399     MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  2400     if ( editIndi )
       
  2401       	{
       
  2402       	iNavi_length = editIndi->IndicatorContainer();
       
  2403       	} 
       
  2404     iNaviDecorator = iNaviPane->CreateEditorIndicatorContainerL();    
       
  2405     AMSLOGGER_WRITE( "CAudioMessageAppUi::InitEditorNaviPaneL <<" ); 
       
  2406     }     
       
  2407 
       
  2408 
       
  2409 // ---------------------------------------------------------
       
  2410 // CAudioMessageAppUi::UpdateViewerNaviFieldL 
       
  2411 // ---------------------------------------------------------
       
  2412 //
       
  2413 void CAudioMessageAppUi::UpdateViewerNaviFieldL()
       
  2414   	{	
       
  2415 AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateViewerNaviFieldL >>" );   	
       
  2416 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT	
       
  2417     TInt indexInFolder = 0;
       
  2418     TInt msgsInFolder = 0;
       
  2419     MessageIndexInFolderL( indexInFolder, msgsInFolder );
       
  2420  
       
  2421     CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>(KNaviGranularity);
       
  2422     CleanupStack::PushL( array );
       
  2423     array->AppendL( indexInFolder + 1 );
       
  2424     array->AppendL( msgsInFolder );
       
  2425 
       
  2426     HBufC* buf = StringLoader::LoadLC( R_AUDIOMESSAGE_VIEWER_ORDINAL_NUMBER, *array,
       
  2427       iCoeEnv );
       
  2428     //Pushed into CleanupStack
       
  2429     TBuf<20> finalText;
       
  2430     finalText.Append(*buf);
       
  2431 	AknTextUtils::LanguageSpecificNumberConversion( finalText );
       
  2432     
       
  2433     //Creates iNavi_next_prev_msg_arrows
       
  2434     CreateTabGroupL( finalText );
       
  2435     CleanupStack::PopAndDestroy( 2 ); //buf, array
       
  2436     iNavi_next_prev_msg_arrows->MakeScrollButtonVisible( ETrue );
       
  2437     //NaviButtons are dimmed by default
       
  2438     if ( IsNextMessageAvailableL( ETrue ) )
       
  2439         {
       
  2440         iNavi_next_prev_msg_arrows->SetScrollButtonDimmed( CAknNavigationDecorator::
       
  2441           ERightButton, EFalse );
       
  2442         }
       
  2443     if ( IsNextMessageAvailableL( EFalse ) )
       
  2444         {
       
  2445         iNavi_next_prev_msg_arrows->SetScrollButtonDimmed( CAknNavigationDecorator::
       
  2446           ELeftButton, EFalse );
       
  2447         }
       
  2448   	iNaviPane->PushL( *iNavi_next_prev_msg_arrows );	
       
  2449 #endif
       
  2450 	AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateViewerNaviFieldL <<" ); 	
       
  2451  		}
       
  2452 
       
  2453 
       
  2454 // ---------------------------------------------------------
       
  2455 // CAudioMessageAppUi::UpdateEditorNaviFieldL 
       
  2456 // ---------------------------------------------------------
       
  2457 //
       
  2458 void CAudioMessageAppUi::UpdateEditorNaviFieldL( TAmsNaviType aNaviType)
       
  2459   	{	
       
  2460   	AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateEditorNaviFieldL >>" ); 
       
  2461   	TTimeIntervalMicroSeconds duration = Document()->GetDuration();
       
  2462     TTime lengthAsTime( duration.Int64() );
       
  2463 	TInt strLength = iTimeDuratBase->Length();	
       
  2464 	HBufC* lengthNow2 = HBufC::NewLC( strLength );
       
  2465  	TPtr lengthNow(lengthNow2->Des());
       
  2466 	lengthAsTime.FormatL( lengthNow, *iTimeDuratBase);
       
  2467  
       
  2468     TInt priorityHigh;
       
  2469     TInt priorityLow;
       
  2470 
       
  2471     if ( iMtm->MessagePriority() == EMmsPriorityLow )
       
  2472         {
       
  2473         priorityHigh = EAknIndicatorStateOff;
       
  2474         priorityLow = EAknIndicatorStateOn;
       
  2475         }
       
  2476     else if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
  2477         {
       
  2478         priorityHigh = EAknIndicatorStateOn;
       
  2479         priorityLow = EAknIndicatorStateOff;
       
  2480         }
       
  2481     else
       
  2482         {
       
  2483         priorityHigh = EAknIndicatorStateOff;
       
  2484         priorityLow = EAknIndicatorStateOff;
       
  2485         }
       
  2486    	AknTextUtils::LanguageSpecificNumberConversion( lengthNow );
       
  2487 
       
  2488  	switch ( aNaviType )
       
  2489  		{
       
  2490     	case EAmsOnlyLength:
       
  2491     		{
       
  2492          	CAknIndicatorContainer* indiContainer =
       
  2493           		static_cast<CAknIndicatorContainer*>( iNaviDecorator->DecoratedControl() );
       
  2494         	if ( indiContainer )
       
  2495         		{
       
  2496             	indiContainer->
       
  2497                 	SetIndicatorValueL(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength),
       
  2498                 	lengthNow);
       
  2499             	
       
  2500             	indiContainer->
       
  2501               		SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength),
       
  2502                 	EAknIndicatorStateOn);
       
  2503             	
       
  2504       		    indiContainer->
       
  2505               	    SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityHigh),
       
  2506               	    priorityHigh);
       
  2507                 
       
  2508                 indiContainer->
       
  2509               	    SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityLow),
       
  2510                     priorityLow);
       
  2511       		    
       
  2512       		    iNaviPane->PushL( *iNaviDecorator);
       
  2513         		}
       
  2514     		}
       
  2515       		break;
       
  2516     	case EAmsTextEditorAndLength:
       
  2517     		{
       
  2518           	if ( !iNavi_length )
       
  2519           		{
       
  2520 			  	MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  2521 			   	if ( editIndi )
       
  2522 			      	{
       
  2523 			      	iNavi_length = editIndi->IndicatorContainer();
       
  2524 			      	}
       
  2525 
       
  2526           		}
       
  2527           	if ( iNavi_length )
       
  2528               	{
       
  2529               	iNavi_length->
       
  2530                 	SetIndicatorValueL(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength),
       
  2531                 	lengthNow);
       
  2532               	iNavi_length->
       
  2533                 	SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength),
       
  2534                   	EAknIndicatorStateOn);
       
  2535               	}
       
  2536       		break;
       
  2537     		}
       
  2538     	case EAmsMsgArrows:
       
  2539  		    {	
       
  2540             //Not in editor mode
       
  2541 	      	break;
       
  2542     		}
       
  2543     	default:
       
  2544       		break;
       
  2545   		}
       
  2546   		CleanupStack::PopAndDestroy( lengthNow2 );	
       
  2547 	AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateEditorNaviFieldL <<" ); 	
       
  2548  		}
       
  2549 // ---------------------------------------------------------
       
  2550 // CAudioMessageAppUi::CreateTabGroupL
       
  2551 // ---------------------------------------------------------
       
  2552 //
       
  2553 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT 
       
  2554 void CAudioMessageAppUi::CreateTabGroupL( const TDesC& aText )
       
  2555     {
       
  2556     AMSLOGGER_WRITE( "CAudioMessageAppUi::CreateTabGroupL >>" ); 
       
  2557     CFbsBitmap* bitmapPriority = NULL;
       
  2558    	CFbsBitmap* maskPriority = NULL;
       
  2559     //Delete (possibly) existing navi decorator
       
  2560     delete iNavi_next_prev_msg_arrows;
       
  2561     iNavi_next_prev_msg_arrows = NULL;
       
  2562 
       
  2563     //Create TabGroup
       
  2564     iNavi_next_prev_msg_arrows = iNaviPane->CreateTabGroupL();
       
  2565     CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( iNavi_next_prev_msg_arrows->
       
  2566      	DecoratedControl() );
       
  2567   	// Set path of bitmap file
       
  2568   	TParse fileParse;
       
  2569   	fileParse.Set( KAmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
  2570 
       
  2571   	if ( ( iMtm->MessagePriority() == EMmsPriorityHigh ) || (iMtm->MessagePriority() ==
       
  2572     	EMmsPriorityLow) )
       
  2573     	{
       
  2574     	if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
  2575       		{
       
  2576       		// Create high priority bitmap
       
  2577           	AknsUtils::CreateIconL( AknsUtils::SkinInstance(), KAknsIIDQgnIndiMcePriorityHigh,
       
  2578               	bitmapPriority, maskPriority, fileParse.FullName(),
       
  2579               	EMbmAudiomessageQgn_indi_mce_priority_high,
       
  2580               	EMbmAudiomessageQgn_indi_mce_priority_high_mask );
       
  2581       		}
       
  2582     	else
       
  2583       		{
       
  2584       		// Create low priority bitmap
       
  2585           	AknsUtils::CreateIconL( AknsUtils::SkinInstance(), KAknsIIDQgnIndiMcePriorityLow,
       
  2586               	bitmapPriority, maskPriority, fileParse.FullName(),
       
  2587               	EMbmAudiomessageQgn_indi_mce_priority_low,
       
  2588               	EMbmAudiomessageQgn_indi_mce_priority_low_mask );
       
  2589       		}
       
  2590 
       
  2591     	if ( !bitmapPriority )
       
  2592       		{
       
  2593       		User::Leave( KErrNotFound );
       
  2594       		}
       
  2595    		CleanupStack::PushL( bitmapPriority );
       
  2596         CleanupStack::PushL( maskPriority );
       
  2597         // Priority bitmap has been created, set size
       
  2598         User::LeaveIfError( AknIconUtils::SetSize( bitmapPriority, KPriorityIconSize ) );
       
  2599     	}
       
  2600 
       
  2601   	if (bitmapPriority)
       
  2602     	{
       
  2603     	tabGroup->AddTabL( 0, aText, bitmapPriority, maskPriority );
       
  2604       	CleanupStack::Pop( maskPriority ); // ownership change
       
  2605       	CleanupStack::Pop( bitmapPriority ); // ownership change
       
  2606     	}
       
  2607   	else
       
  2608     	{
       
  2609     	tabGroup->AddTabL( 0, aText );  // No icons required
       
  2610     	}
       
  2611     tabGroup->SetActiveTabById( 0 );
       
  2612     tabGroup->SetTabFixedWidthL( EAknTabWidthWithOneTab );
       
  2613 #ifdef RD_SCALABLE_UI_V2
       
  2614     iNavi_next_prev_msg_arrows->SetNaviDecoratorObserver( this );
       
  2615 #endif    
       
  2616     AMSLOGGER_WRITE( "CAudioMessageAppUi::CreateTabGroupL <<" ); 
       
  2617     }
       
  2618 #endif //!RD_MSG_NAVIPANE_IMPROVEMENT     
       
  2619 
       
  2620 
       
  2621 // ---------------------------------------------------------
       
  2622 // CAudioMessageAppUi::UpdateNaviVol
       
  2623 // ---------------------------------------------------------
       
  2624 //
       
  2625 void CAudioMessageAppUi::UpdateNaviVol( TInt aCurrentVolumeValue )
       
  2626   	{
       
  2627   	AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateNaviVol >>" ); 
       
  2628     iCurrentVolume=aCurrentVolumeValue;
       
  2629     AMSLOGGER_WRITE( "CAudioMessageAppUi::UpdateNaviVol <<" ); 
       
  2630   	}
       
  2631 
       
  2632 // ---------------------------------------------------------
       
  2633 // CAudioMessageAppUi::GetVolume
       
  2634 // ---------------------------------------------------------
       
  2635 //
       
  2636 TInt CAudioMessageAppUi::GetVolume()
       
  2637     {
       
  2638     return iCurrentVolume;
       
  2639     }
       
  2640 // ---------------------------------------------------------
       
  2641 // CAudioMessageAppUi::SetSpeakerOutput
       
  2642 // ---------------------------------------------------------
       
  2643 //
       
  2644 void CAudioMessageAppUi::SetSpeakerOutput(TBool aEarpiece)
       
  2645   	{
       
  2646   	iSpeakerEarpiece = aEarpiece;
       
  2647   	}
       
  2648 
       
  2649 // ---------------------------------------------------------
       
  2650 // CAudioMessageAppUi::ShowInformationNoteL
       
  2651 // ---------------------------------------------------------
       
  2652 //
       
  2653 void CAudioMessageAppUi::ShowInformationNoteL( TInt aResourceID, TBool aWaiting )
       
  2654     {
       
  2655     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowInformationNoteL >>" ); 
       
  2656     HBufC* prompt = NULL;
       
  2657     switch ( aResourceID )
       
  2658         {
       
  2659         case R_AUDIOMESSAGE_INFO_OBJECT_TOO_BIG:
       
  2660         	{
       
  2661             TInt maxInKilos 
       
  2662                 = ( Document()->MaxMessageSize() + KAmsBytesInKilo - 1 ) / KAmsBytesInKilo;
       
  2663             prompt = StringLoader::LoadLC( aResourceID, maxInKilos, iCoeEnv  );
       
  2664             break;
       
  2665         	}
       
  2666         default:
       
  2667             prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  2668             break;
       
  2669         }
       
  2670 
       
  2671     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( aWaiting );
       
  2672     note->ExecuteLD( *prompt );
       
  2673     CleanupStack::PopAndDestroy( prompt );
       
  2674     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowInformationNoteL <<" ); 
       
  2675     }
       
  2676 
       
  2677 // ---------------------------------------------------------
       
  2678 // CAudioMessageAppUi::ShowErrorNoteL
       
  2679 // ---------------------------------------------------------
       
  2680 //
       
  2681 void CAudioMessageAppUi::ShowErrorNoteL( TInt aResourceID, TBool aWaiting )
       
  2682     {
       
  2683     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowErrorNoteL >>" ); 
       
  2684     HBufC* prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  2685     CAknErrorNote* note = new ( ELeave ) CAknErrorNote( aWaiting );
       
  2686     note->ExecuteLD( *prompt );
       
  2687     CleanupStack::PopAndDestroy( prompt );
       
  2688     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowErrorNoteL <<" ); 
       
  2689     }
       
  2690 
       
  2691 // ---------------------------------------------------------
       
  2692 // CAudioMessageAppUi::ShowConfirmationQueryL
       
  2693 // ---------------------------------------------------------
       
  2694 //
       
  2695 TInt CAudioMessageAppUi::ShowConfirmationQueryL( TInt aResourceID )
       
  2696     {
       
  2697     HBufC* prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  2698     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  2699     TInt retVal = dlg->ExecuteLD( R_AUDIOMESSAGE_CONFIRMATION_QUERY, *prompt );
       
  2700     CleanupStack::PopAndDestroy( prompt );
       
  2701     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowConfirmationQueryL <<" ); 
       
  2702     return retVal;
       
  2703     }
       
  2704 
       
  2705 // ---------------------------------------------------------
       
  2706 // CAudioMessageAppUi::ShowWaitNoteL
       
  2707 // ---------------------------------------------------------
       
  2708 //
       
  2709 TBool CAudioMessageAppUi::ShowWaitNoteL( TInt aResourceId )
       
  2710     {
       
  2711     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowWaitNoteL >>" ); 
       
  2712     TInt waitNoteResource = R_AUDIOMESSAGE_WAIT_NOTE;
       
  2713     HBufC* string = NULL;
       
  2714 
       
  2715     switch ( aResourceId )
       
  2716         {
       
  2717         case R_QTN_AUDIOMESSAGE_WAIT_SEND_MESSAGE:
       
  2718             {
       
  2719             waitNoteResource = R_AUDIOMESSAGE_WAIT_NOTE_ICON;//
       
  2720             }
       
  2721             //fallthroug
       
  2722         case R_QTN_WAIT_MSG_SAVED_OUTBOX:
       
  2723         case R_QTN_AUDIOMESSAGE_WAIT_OPENING_EDITOR:
       
  2724         case R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE:
       
  2725         case R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE_NEW:
       
  2726         case R_QTN_AUDIOMESSAGE_WAIT_INSERTING:
       
  2727             {
       
  2728             string = StringLoader::LoadLC(
       
  2729                 aResourceId,
       
  2730                 iCoeEnv );
       
  2731             }
       
  2732             break;
       
  2733         default:
       
  2734             break;
       
  2735         }
       
  2736     
       
  2737     if ( aResourceId == R_QTN_WAIT_MSG_SAVED_OUTBOX
       
  2738         || aResourceId == R_QTN_AUDIOMESSAGE_WAIT_SEND_MESSAGE
       
  2739         //|| aResourceId == R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE
       
  2740         || aResourceId == R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE_NEW )
       
  2741     	{
       
  2742     	if (!iWaitDialog)
       
  2743     	iWaitDialog = new( ELeave )CAknWaitDialog(
       
  2744             reinterpret_cast<CEikDialog**>( &iWaitDialog ), ETrue);
       
  2745     	}
       
  2746     else
       
  2747     	{
       
  2748     	if (!iWaitDialog)
       
  2749     	iWaitDialog = new( ELeave )CAknWaitDialog(
       
  2750             reinterpret_cast<CEikDialog**>( &iWaitDialog ));
       
  2751     	}
       
  2752     	
       
  2753     iWaitDialog->SetCallback( this );	
       
  2754     // Coverty fix, Forward NULL , http://ousrv057/cov.cgi?cid=35709 
       
  2755     if (string)
       
  2756         {
       
  2757         iWaitDialog->SetTextL( *string );
       
  2758         CleanupStack::PopAndDestroy( string );
       
  2759         }
       
  2760     iWaitResId = aResourceId;
       
  2761     iWaitDialog->PrepareLC( waitNoteResource );
       
  2762 
       
  2763     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowWaitNoteL <<" );
       
  2764     return iWaitDialog->RunLD();
       
  2765     }
       
  2766 
       
  2767 // ---------------------------------------------------------
       
  2768 // CAudioMessageAppUi::RemoveWaitNote
       
  2769 // ---------------------------------------------------------
       
  2770 //
       
  2771 void CAudioMessageAppUi::RemoveWaitNote()
       
  2772     {
       
  2773     AMSLOGGER_WRITE( "CAudioMessageAppUi::RemoveWaitNote >>" ); 
       
  2774     //This also deletes the dialog
       
  2775     if ( iWaitDialog)
       
  2776     	{
       
  2777     	TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
       
  2778     	}
       
  2779     AMSLOGGER_WRITE( "CAudioMessageAppUi::RemoveWaitNote <<" ); 
       
  2780     }
       
  2781 
       
  2782 // ---------------------------------------------------------
       
  2783 // CAudioMessageAppUi::SetAddressSize
       
  2784 // ---------------------------------------------------------
       
  2785 //
       
  2786 void CAudioMessageAppUi::SetAddressSize()
       
  2787     {
       
  2788     AMSLOGGER_WRITE( "CAudioMessageAppUi::SetAddressSize >>" ); 
       
  2789     TInt entryCnt( 0 );
       
  2790     TInt sizeInBytes( 0 );
       
  2791     TInt tempBytes( 0 );
       
  2792 
       
  2793     if ( !iMtm->Entry().Entry().ReadOnly() )//not viewer
       
  2794       	{
       
  2795       	CMsgAddressControl* to = ToCtrl();
       
  2796       	to->GetSizeOfAddresses( entryCnt, tempBytes );
       
  2797       	sizeInBytes += tempBytes;
       
  2798       	Document()->SetAddressSize( sizeInBytes );
       
  2799       	}
       
  2800     AMSLOGGER_WRITE( "CAudioMessageAppUi::SetAddressSize <<" ); 
       
  2801     }
       
  2802 
       
  2803 // ---------------------------------------------------------
       
  2804 // CAudioMessageAppUi::SetBodySize
       
  2805 // ---------------------------------------------------------
       
  2806 //
       
  2807 void CAudioMessageAppUi::SetBodySize()
       
  2808     {
       
  2809     AMSLOGGER_WRITE( "CAudioMessageAppUi::SetBodySize >>" ); 
       
  2810     TInt sizeInBytes( 0 );
       
  2811 
       
  2812     if (iInsertingMedia)
       
  2813       	{
       
  2814       	sizeInBytes = iInsertingMedia->FileSize();
       
  2815       	}
       
  2816     Document()->SetAudioFileSize( sizeInBytes );
       
  2817     AMSLOGGER_WRITE( "CAudioMessageAppUi::SetBodySize <<" ); 
       
  2818     }
       
  2819 
       
  2820 // ---------------------------------------------------------
       
  2821 // CAudioMessageAppUi::IsForward
       
  2822 // ---------------------------------------------------------
       
  2823 //
       
  2824 TBool CAudioMessageAppUi::IsForward() const
       
  2825     {
       
  2826     TMmsMsvEntry entry = static_cast<TMmsMsvEntry>( Document()->Entry() );
       
  2827     return entry.IsForwardedMessage();
       
  2828     }
       
  2829 
       
  2830 // ---------------------------------------------------------
       
  2831 // CAudioMessageAppUi::RemoveAudioL
       
  2832 // ---------------------------------------------------------
       
  2833 //
       
  2834 void CAudioMessageAppUi::RemoveAudioL()
       
  2835     {
       
  2836     AMSLOGGER_WRITE( "CAudioMessageAppUi::RemoveAudioL >>" ); 
       
  2837   	if ( ShowConfirmationQueryL( R_AUDIOMESSAGE_QUEST_REMOVE_AUDIO ) )
       
  2838     	{
       
  2839     	if ( !iInsertOperation )
       
  2840       		{
       
  2841       		iInsertOperation = CAudioMessageInsertOperation::NewL(
       
  2842             	*this,
       
  2843             	*Document(),
       
  2844             	*iView );
       
  2845       		}
       
  2846       	//In a case when phone is in silent mode and try to remove audio clip...
       
  2847       	//Press msk twice extremely fast. It will take the second press as play
       
  2848       	//audio and the UI is messed. Following will prevent it.
       
  2849       	//Flag released when remove operation returns.		
       
  2850     	iEditorFlags |= EProgressInUse;
       
  2851     	iInsertOperation->Insert( iInsertingMedia, ETrue );
       
  2852     	}
       
  2853     AMSLOGGER_WRITE( "CAudioMessageAppUi::RemoveAudioL <<" ); 
       
  2854     }
       
  2855 
       
  2856 // ---------------------------------------------------------
       
  2857 // CAudioMessageAppUi::MessageSizeInBytes
       
  2858 // ---------------------------------------------------------
       
  2859 //
       
  2860 TInt CAudioMessageAppUi::MessageSizeInBytes()
       
  2861     {
       
  2862     TInt mSize = 0;
       
  2863     if ( iInsertingMedia )
       
  2864     	{
       
  2865     	mSize = iInsertingMedia->FileSize();
       
  2866     	}
       
  2867     else
       
  2868     	{
       
  2869       	mSize = 0;
       
  2870     	}
       
  2871     return mSize;
       
  2872     }
       
  2873 
       
  2874 // ---------------------------------------------------------
       
  2875 // CAudioMessageAppUi::DoSelectionKeyL
       
  2876 // ---------------------------------------------------------
       
  2877 //
       
  2878 void CAudioMessageAppUi::DoSelectionKeyL()
       
  2879     {
       
  2880     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoSelectionKeyL >>" ); 
       
  2881     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  2882     if ( ctrl )
       
  2883      	{
       
  2884         switch ( ctrl->ControlId() )
       
  2885             {
       
  2886             case EMsgComponentIdTo:
       
  2887                 if ( Document()->GetAppMode() == EAmsEditor )
       
  2888                 	{
       
  2889                   	TBool modified = EFalse;
       
  2890                   	if ( !VerifyAddressesL( modified ) )
       
  2891                       	{
       
  2892                       	// Illegal address found.
       
  2893                       	modified = ETrue;
       
  2894                       	}
       
  2895                   	if ( !modified )//else
       
  2896                       	{
       
  2897             			// Nothing changed on the UI. Open PhoneBook.
       
  2898                     	HandleCommandL( EAmsEditorCmdAddRecipient ); 
       
  2899             			}
       
  2900                 	}
       
  2901             	else
       
  2902               		{
       
  2903                   	MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_VIEWER_SELECTMENU );
       
  2904                   	MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  2905                   	TRAP_IGNORE(MenuBar()->TryDisplayMenuBarL());
       
  2906                   	MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_MENUBAR );
       
  2907                   	MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  2908               		}
       
  2909                 break;
       
  2910       		default:
       
  2911         		//if audio clip is inserted, just play it
       
  2912         		if ( Document()->GetClipStatus() != EAmsClipNone )
       
  2913         			{
       
  2914         			HandleCommandL( EAmsEditorCmdPlayAudio );
       
  2915         			}
       
  2916         		//there is no any clip, so try to record new.
       
  2917         		else
       
  2918         			{
       
  2919                 	HandleCommandL( EAmsEditorCmdRecordAudio );
       
  2920                 	}
       
  2921                 break;
       
  2922         	}
       
  2923     	}
       
  2924     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoSelectionKeyL <<" ); 
       
  2925     }
       
  2926     
       
  2927 // ---------------------------------------------------------
       
  2928 // CAudioMessageAppUi::IsPhoneOfflineL
       
  2929 // ---------------------------------------------------------
       
  2930 //
       
  2931 TBool CAudioMessageAppUi::IsPhoneOfflineL() const
       
  2932     {
       
  2933     AMSLOGGER_WRITE( "CAudioMessageAppUi::IsPhoneOfflineL >>" ); 
       
  2934     if ( iSupportedFeatures & EUniFeatureOffline )
       
  2935         {
       
  2936         TInt connAllowed = 1;
       
  2937         CRepository* repository = CRepository::NewL( KCRUidCoreApplicationUIs );
       
  2938         TInt err = repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
  2939         delete repository;
       
  2940         repository = NULL;
       
  2941         if ( !err && !connAllowed )
       
  2942             {
       
  2943             return ETrue;
       
  2944             }
       
  2945         }
       
  2946     return EFalse;
       
  2947     }
       
  2948 
       
  2949 // ---------------------------------------------------------
       
  2950 // CAudioMessageAppUi::LaunchHelpL
       
  2951 // ---------------------------------------------------------
       
  2952 //
       
  2953 void CAudioMessageAppUi::LaunchHelpL()
       
  2954     { 
       
  2955     AMSLOGGER_WRITE( "CAudioMessageAppUi::LaunchHelpL >>" ); 
       
  2956     // activate Help application
       
  2957     if ( iSupportedFeatures & EUniFeatureHelp )
       
  2958         {
       
  2959         //CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL();
       
  2960         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession()
       
  2961             , iEikonEnv->EikAppUi()->AppHelpContextL()/* helpContext*/ ); 
       
  2962         }
       
  2963     }
       
  2964 
       
  2965 // ---------------------------------------------------------
       
  2966 // CAudioMessageAppUi::HelpContextL
       
  2967 // ---------------------------------------------------------
       
  2968 //
       
  2969 CArrayFix<TCoeHelpContext>* CAudioMessageAppUi::HelpContextL() const
       
  2970     {
       
  2971     CArrayFix<TCoeHelpContext>* r = new ( ELeave ) CArrayFixFlat<TCoeHelpContext>( 1 );
       
  2972     CleanupStack::PushL( r );
       
  2973     if ( Document()->GetAppMode() == EAmsViewer )
       
  2974     	{
       
  2975       	r->AppendL( TCoeHelpContext( KUidAudioMessageApplication, KAUDIO_MSG_HLP_VIEWER() ) );
       
  2976     	}
       
  2977     else // Document()->GetAppMode() == EAmsEditor 
       
  2978     	{
       
  2979       	r->AppendL( TCoeHelpContext( KUidAudioMessageApplication, KAUDIO_MSG_HLP_EDITOR() ) );
       
  2980     	}
       
  2981 	
       
  2982     CleanupStack::Pop( r );
       
  2983     return r;
       
  2984     }
       
  2985 
       
  2986 // ---------------------------------------------------------
       
  2987 // CAudioMessageAppUi::NumberConversionLC
       
  2988 // ---------------------------------------------------------
       
  2989 //
       
  2990 HBufC* CAudioMessageAppUi::NumberConversionLC( const TDesC& aOrigNumber, TBool aDirection )
       
  2991     {
       
  2992     HBufC* addressCopy = aOrigNumber.AllocLC();
       
  2993     TPtr tempTPtr = addressCopy->Des();
       
  2994     if ( aDirection )
       
  2995         {
       
  2996         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tempTPtr );
       
  2997         }
       
  2998     else
       
  2999         {
       
  3000         AknTextUtils::ConvertDigitsTo( tempTPtr, EDigitTypeWestern );
       
  3001         }
       
  3002     return addressCopy;
       
  3003     }
       
  3004 
       
  3005 // ---------------------------------------------------------
       
  3006 // CAudioMessageAppUi::DoInsertCompleteL
       
  3007 // ---------------------------------------------------------
       
  3008 //
       
  3009 void CAudioMessageAppUi::DoInsertCompleteL( TBool aErrorNone )
       
  3010     {
       
  3011     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoInsertCompleteL >>" ); 
       
  3012 	if( !CheckIncomingCall() )
       
  3013 	    {
       
  3014 	    RemoveWaitNote();
       
  3015 	    }
       
  3016 	else
       
  3017 	    {
       
  3018         //There may have been fatal error in inserting
       
  3019         if ( iInsertOperation && iInsertOperation->GetError()<0 )
       
  3020             {
       
  3021            	;//Do nothing, error note is shown elsewhere and application is closed
       
  3022             }
       
  3023         else
       
  3024             {
       
  3025             HBufC* labell = StringLoader::LoadLC( R_AUDIOMESSAGE_INSERTED );
       
  3026   		    CAknGlobalNote *globalNote = CAknGlobalNote::NewLC();
       
  3027 	        globalNote->ShowNoteL( EAknGlobalInformationNote, *labell );
       
  3028 	        CleanupStack::PopAndDestroy( globalNote );
       
  3029             CleanupStack::PopAndDestroy( labell );
       
  3030             }     
       
  3031 	    }
       
  3032 	
       
  3033    	CAknInputBlock::NewLC(); // Absorb keys
       
  3034    	iAvkonAppUi->Cba()->MakeVisible( ETrue );
       
  3035     iInserting = EFalse;
       
  3036   	if ( aErrorNone )
       
  3037     	{
       
  3038 	    SetBodySize();
       
  3039 	    Document()->SetBodyModified( ETrue );
       
  3040 	    Document()->SetInsertedStatus( EAmsRecorded );
       
  3041 	    SetAudioClipIconL( EAudioInserted );
       
  3042        	iView->SetFocus( EMsgComponentIdImage );       
       
  3043     	}
       
  3044   	else
       
  3045     	{
       
  3046       	ShowInsertErrorsL();
       
  3047     	}
       
  3048 
       
  3049     UpdateSoftKeysL();	
       
  3050   	FetchAudioFileDataL( ) ;
       
  3051    	CleanupStack::PopAndDestroy();// Absorb keys
       
  3052     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoInsertCompleteL <<" ); 
       
  3053     }
       
  3054 
       
  3055 // ---------------------------------------------------------
       
  3056 // CAudioMessageAppUi::EditorOperationEvent
       
  3057 // ---------------------------------------------------------
       
  3058 //
       
  3059 void CAudioMessageAppUi::EditorOperationEvent( TAmsOperationType aOperation,
       
  3060   TAmsOperationEvent aEvent )
       
  3061     {
       
  3062     AMSLOGGER_WRITE( "CAudioMessageAppUi::EditorOperationEvent >>" ); 
       
  3063     if ( iEditorFlags & EEditorExiting )
       
  3064         {
       
  3065         // Do not handle any event if we are exiting.
       
  3066         return;
       
  3067         }
       
  3068     
       
  3069     delete iAbsorber;
       
  3070     iAbsorber = NULL;
       
  3071 
       
  3072     TRAPD( error, DoEditorOperationEventL( aOperation, aEvent ) );
       
  3073 	if (error != KErrNone)
       
  3074 		{
       
  3075 		Exit ( error );
       
  3076 		}
       
  3077     AMSLOGGER_WRITE( "CAudioMessageAppUi::EditorOperationEvent <<" ); 
       
  3078     }
       
  3079 
       
  3080 // ---------------------------------------------------------
       
  3081 // CAudioMessageAppUi::DoEditorOperationEventL
       
  3082 // ---------------------------------------------------------
       
  3083 //
       
  3084 void CAudioMessageAppUi::DoEditorOperationEventL( TAmsOperationType aOperation,
       
  3085   TAmsOperationEvent aEvent )
       
  3086     {
       
  3087     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoEditorOperationEventL >>" ); 
       
  3088     switch ( aOperation )
       
  3089         {
       
  3090       	case EAmsOperationInsert:
       
  3091             if ( aEvent == EAmsOperationProcessing )
       
  3092                 {
       
  3093                 ShowWaitNoteL( R_QTN_AUDIOMESSAGE_WAIT_INSERTING );
       
  3094                 }
       
  3095             else if ( aEvent == EAmsOperationError )
       
  3096               	{
       
  3097               	DoInsertCompleteL( EFalse );
       
  3098               	}
       
  3099             else
       
  3100                 {
       
  3101                 DoInsertCompleteL( ETrue );
       
  3102                 }
       
  3103             break;
       
  3104         case EAmsOperationLaunch:
       
  3105             DoLaunchCompleteL( aEvent );
       
  3106             break;
       
  3107         case EAmsOperationSave:
       
  3108             DoSaveCompleteL();
       
  3109             break;
       
  3110         case EAmsOperationSend:
       
  3111             DoSendCompleteL();
       
  3112             break;
       
  3113         case EAmsOperationRemove:
       
  3114             DoRemoveCompleteL();
       
  3115             iEditorFlags &= ~EProgressInUse;
       
  3116             break;
       
  3117         case EAmsOperationSendReadReport:
       
  3118             // free resources
       
  3119             delete iSendReadReportOperation;
       
  3120             iSendReadReportOperation = NULL;
       
  3121             break;
       
  3122         default:
       
  3123             {
       
  3124             // nothing to do
       
  3125             break;
       
  3126             }
       
  3127         }   
       
  3128     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoEditorOperationEventL <<" ); 
       
  3129     }  
       
  3130 
       
  3131 // ---------------------------------------------------------
       
  3132 // CAudioMessageAppUi::DoRemoveCompleteL
       
  3133 // ---------------------------------------------------------
       
  3134 //
       
  3135 void CAudioMessageAppUi::DoRemoveCompleteL()
       
  3136   	{
       
  3137   	AMSLOGGER_WRITE( "CAudioMessageAppUi::DoRemoveCompleteL >>" ); 
       
  3138     CAknInputBlock::NewLC(); // Absorb keys
       
  3139     Document()->SetAudioFileSize( 0 );
       
  3140     Document()->SetDuration( 0 );
       
  3141  	SetNaviPaneL();
       
  3142     Document()->SetBodyModified( ETrue );
       
  3143     Document()->SetClipStatus( EAmsClipNone );
       
  3144     SetAudioClipIconL( EAudioInsert );   
       
  3145   	UpdateSoftKeysL();
       
  3146     ShowInformationNoteL( R_AUDIOMESSAGE_INFO_CLIP_DELETED, EFalse );
       
  3147   	CleanupStack::PopAndDestroy();
       
  3148   	AMSLOGGER_WRITE( "CAudioMessageAppUi::DoRemoveCompleteL <<" ); 
       
  3149   	}
       
  3150 
       
  3151 // ---------------------------------------------------------
       
  3152 // CAudioMessageAppUi::DoLaunchCompleteL
       
  3153 // EKLU-7LGCPT :: Filter Invalid contact details
       
  3154 // ---------------------------------------------------------
       
  3155 //
       
  3156 void CAudioMessageAppUi::DoLaunchCompleteL( TAmsOperationEvent aEvent )
       
  3157     {
       
  3158     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoLaunchCompleteL >>" ); 
       
  3159     TInt error = iLaunchOperation->GetError();
       
  3160     RemoveWaitNote();
       
  3161     
       
  3162     if ( error == EAmsExit )
       
  3163       	{
       
  3164         DoDelayedExitL( 0 );
       
  3165         }
       
  3166     else if ( error != KErrNone )
       
  3167     	{
       
  3168     	if ( !ShowLaunchErrorsL( error  ) )
       
  3169     		{
       
  3170     		//In this case the error not is shown
       
  3171     		DoDelayedExitL( KDelayedExitDelay );
       
  3172     		}
       
  3173     	else
       
  3174     		{
       
  3175     		DoDelayedExitL( 0 );
       
  3176     		}
       
  3177     	}
       
  3178 
       
  3179     else
       
  3180         {
       
  3181        	FinalizeLaunchL();
       
  3182        	
       
  3183        	// Enable task swapper to options menu after launch has been completed.
       
  3184         MenuBar()->SetMenuType( CEikMenuBar::EMenuOptions );
       
  3185        	
       
  3186        	delete iScreenClearer;
       
  3187         iScreenClearer = NULL;
       
  3188         
       
  3189         iEditorFlags |= ELaunchSuccessful;
       
  3190         //Set softkeys
       
  3191 
       
  3192         UpdateSoftKeysL();
       
  3193         //SetNaviPaneL();		
       
  3194         	
       
  3195         TRAP_IGNORE( SendReadReportL( aEvent ) );
       
  3196         }
       
  3197     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoLaunchCompleteL <<" );    
       
  3198     }
       
  3199  
       
  3200 // ---------------------------------------------------------   
       
  3201 // CAudioMessageAppUi::DoDelayedExitL
       
  3202 // ---------------------------------------------------------
       
  3203 //
       
  3204 void CAudioMessageAppUi::DoDelayedExitL( TInt aDelayTime )
       
  3205     {
       
  3206 AMSLOGGER_WRITE( "CAudioMessageAppUi::DoDelayedExitL" );      
       
  3207     delete iIdle;
       
  3208     iIdle = 0;
       
  3209     iIdle = CPeriodic::NewL( EPriorityNormal /*- 1*/);
       
  3210     iIdle->Start(   aDelayTime,
       
  3211                     aDelayTime,
       
  3212                     TCallBack( DelayedExit, this ));
       
  3213     }
       
  3214 
       
  3215 // ---------------------------------------------------------
       
  3216 // CAudioMessageAppUi::DelayedExit
       
  3217 // ---------------------------------------------------------
       
  3218 //
       
  3219 TInt CAudioMessageAppUi::DelayedExit( TAny* aThis )
       
  3220     {
       
  3221     AMSLOGGER_WRITE( "CAudioMessageAppUi::DelayedExit" ); 
       
  3222     CAudioMessageAppUi* editor = static_cast<CAudioMessageAppUi*>( aThis );
       
  3223     editor->DoExternalExit();
       
  3224   	CAknEnv::RunAppShutter( );
       
  3225     return KErrNone;
       
  3226     }
       
  3227 
       
  3228 // ---------------------------------------------------------
       
  3229 // CAudioMessageAppUi::DoExternalExit
       
  3230 // ---------------------------------------------------------
       
  3231 //
       
  3232 void CAudioMessageAppUi::DoExternalExit()
       
  3233     {
       
  3234     delete iAbsorber;
       
  3235     iAbsorber=NULL;
       
  3236     Exit( EAknSoftkeyClose );
       
  3237     }
       
  3238 
       
  3239 // ---------------------------------------------------------
       
  3240 // CAudioMessageAppUi::DoSaveCompleteL
       
  3241 // ---------------------------------------------------------
       
  3242 //
       
  3243 void CAudioMessageAppUi::DoSaveCompleteL()
       
  3244     {
       
  3245     EndActiveWait();
       
  3246     if ( iWaitDialog )
       
  3247         {
       
  3248         // Processing continued at DialogDismissedL when wait note
       
  3249         // has dismissed itself.
       
  3250         iWaitDialog->ProcessFinishedL();
       
  3251         }    
       
  3252     else
       
  3253         {
       
  3254         DoOpComplete2ndPhaseL();
       
  3255         }
       
  3256     
       
  3257     }
       
  3258     
       
  3259 // ---------------------------------------------------------
       
  3260 // CAudioMessageAppUi::DoOpComplete2ndPhaseL
       
  3261 //
       
  3262 // Performs the real send operation completing code.
       
  3263 // ---------------------------------------------------------
       
  3264 //
       
  3265 void CAudioMessageAppUi::DoOpComplete2ndPhaseL()
       
  3266     { 
       
  3267     DoDelayedExitL( 0 );
       
  3268     }    
       
  3269 
       
  3270 // ---------------------------------------------------------
       
  3271 // CAudioMessageAppUi::DoSendCompleteL
       
  3272 // ---------------------------------------------------------
       
  3273 //
       
  3274 void CAudioMessageAppUi::DoSendCompleteL()
       
  3275     {
       
  3276     if ( iWaitDialog )
       
  3277         {
       
  3278         // Processing continued at DialogDismissedL when wait note
       
  3279         // has dismissed itself.
       
  3280         iWaitDialog->ProcessFinishedL();
       
  3281         }    
       
  3282     else
       
  3283         {
       
  3284         DoOpComplete2ndPhaseL();
       
  3285         }    
       
  3286     }
       
  3287 
       
  3288 // ---------------------------------------------------------
       
  3289 // CAudioMessageAppUi::BeginActiveWait
       
  3290 // ---------------------------------------------------------
       
  3291 //
       
  3292 void CAudioMessageAppUi::BeginActiveWait()
       
  3293     {
       
  3294     if ( iWait.IsStarted() )
       
  3295         {
       
  3296         return;
       
  3297         }
       
  3298     iWait.Start();
       
  3299     }
       
  3300 
       
  3301 // ---------------------------------------------------------
       
  3302 // CAudioMessageAppUi::EndActiveWait
       
  3303 // ---------------------------------------------------------
       
  3304 //
       
  3305 void CAudioMessageAppUi::EndActiveWait()
       
  3306     {
       
  3307     if ( iWait.IsStarted() )
       
  3308         {
       
  3309         iWait.AsyncStop();
       
  3310         }
       
  3311     }
       
  3312 
       
  3313 		
       
  3314 // ---------------------------------------------------------
       
  3315 // CAudioMessageAppUi::ShowLaunchErrorsL
       
  3316 // ---------------------------------------------------------
       
  3317 //
       
  3318 TBool CAudioMessageAppUi::ShowLaunchErrorsL( TInt aError )
       
  3319     {
       
  3320     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowLaunchErrorsL >>" ); 
       
  3321     TInt errRes = -1;
       
  3322     switch ( aError )
       
  3323         {
       
  3324         case EAmsSendUiUnsupported:
       
  3325             SetErrorResource( errRes, R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT );
       
  3326           break;
       
  3327         case EAmsSendUiCorrupted:
       
  3328             SetErrorResource( errRes, R_AUDIOMESSAGE_INFO_CORRUPTED_OBJECT );
       
  3329             break;
       
  3330         case EAmsProtectedObject:
       
  3331             SetErrorResource( errRes, R_AUDIOMESSAGE_INFO_SEND_FORBID );
       
  3332             break;
       
  3333         default:
       
  3334             // e.g leave in startup
       
  3335             break;
       
  3336         }
       
  3337 
       
  3338     if ( errRes != -1 )
       
  3339         {
       
  3340         ShowInformationNoteL( errRes, EFalse );
       
  3341     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowLaunchErrorsL, false <<" ); 
       
  3342         return EFalse;
       
  3343         }
       
  3344 
       
  3345     //else nothing
       
  3346    AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowLaunchErrorsL, true <<" ); 
       
  3347     return ETrue;
       
  3348     }
       
  3349 
       
  3350 // ---------------------------------------------------------
       
  3351 // CAudioMessageAppUi::SetErrorResource
       
  3352 // ---------------------------------------------------------
       
  3353 //
       
  3354 void CAudioMessageAppUi::SetErrorResource( TInt& aStoreId, TInt aNewId )
       
  3355     {
       
  3356     if ( ErrorPriority( aNewId ) >= ErrorPriority( aStoreId ) )
       
  3357         {
       
  3358         if ( aStoreId == R_AUDIOMESSAGE_INFO_CORRUPTED_OBJECT &&
       
  3359             ( aNewId == R_AUDIOMESSAGE_INFO_CORRUPTED_OBJECT  ) )
       
  3360             {
       
  3361             //set plural
       
  3362             aStoreId = R_AUDIOMESSAGE_INFO_CORRUPTED_OBJECT;
       
  3363             }
       
  3364         else if ( aStoreId == R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT &&
       
  3365             ( aNewId == R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT ) )
       
  3366             {
       
  3367             //set plural
       
  3368             aStoreId = R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT;
       
  3369             }
       
  3370         else if ( aStoreId != -1 && aStoreId != aNewId )
       
  3371             {
       
  3372             // Set "general error"
       
  3373             aStoreId = aNewId;
       
  3374             }
       
  3375         else
       
  3376             {
       
  3377             aStoreId = aNewId;
       
  3378             }
       
  3379         }
       
  3380     }
       
  3381 
       
  3382 // ---------------------------------------------------------
       
  3383 // CAudioMessageAppUi::ErrorPriority
       
  3384 // ---------------------------------------------------------
       
  3385 //
       
  3386 TInt CAudioMessageAppUi::ErrorPriority( TInt aErrorId )
       
  3387     {
       
  3388     TInt priority = 0;
       
  3389     switch ( aErrorId )
       
  3390         {
       
  3391         case R_AUDIOMESSAGE_INFO_SEND_FORBID:
       
  3392             priority++;
       
  3393         case R_AUDIOMESSAGE_INFO_OBJECT_TOO_BIG:
       
  3394             priority++;
       
  3395         case R_AUDIOMESSAGE_ERROR_CANNOT_OPEN:
       
  3396              priority++;
       
  3397         case R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT:
       
  3398             priority++;
       
  3399         default:
       
  3400             break;
       
  3401         }
       
  3402     return priority;
       
  3403     }
       
  3404 
       
  3405 // ---------------------------------------------------------
       
  3406 // CAudioMessageAppUi::ShowInsertErrorsL
       
  3407 // ---------------------------------------------------------
       
  3408 //
       
  3409 void CAudioMessageAppUi::ShowInsertErrorsL()
       
  3410     {
       
  3411     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowInsertErrorsL >>" ); 
       
  3412     TBool abortedByUser = EFalse;
       
  3413     TInt errRes( -1 );
       
  3414     TInt error = iInsertOperation->GetError();
       
  3415     
       
  3416     //Let's first check if there is degative error value.
       
  3417     //In that case the runL has been leaved e.g. in case low memory
       
  3418     if ( error < 0 )
       
  3419         {
       
  3420         iEikonEnv->HandleError( error );
       
  3421         return;
       
  3422         }
       
  3423     
       
  3424     
       
  3425     switch ( error )
       
  3426         {
       
  3427         case EAmsInsertTooBig:
       
  3428             SetErrorResource( errRes, R_AUDIOMESSAGE_INFO_OBJECT_TOO_BIG );
       
  3429             break;
       
  3430        	case EAmsInsertNotSupported:
       
  3431             SetErrorResource( errRes, R_AUDIOMESSAGE_INFO_UNSUPPORTED_OBJECT );
       
  3432             break;
       
  3433     	default:
       
  3434             break;
       
  3435     	}
       
  3436     if ( !abortedByUser && errRes != -1 )
       
  3437         {
       
  3438         ShowInformationNoteL( errRes, EFalse );
       
  3439         }
       
  3440     }
       
  3441 
       
  3442 
       
  3443 // ---------------------------------------------------------
       
  3444 // CAudioMessageAppUi::OpenDeliveryPopupL
       
  3445 // ---------------------------------------------------------
       
  3446 //
       
  3447 void CAudioMessageAppUi::OpenDeliveryPopupL()
       
  3448     {
       
  3449     AMSLOGGER_WRITE( "CAudioMessageAppUi::OpenDeliveryPopupL >>" ); 
       
  3450     //These are not used. They just have to be there.
       
  3451     TPckgBuf<TInt> param( 0 ); 
       
  3452     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  3453     CleanupStack::PushL( selection );
       
  3454 
       
  3455     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document() );
       
  3456     CMsvOperation* op = Document()->MtmUi().InvokeAsyncFunctionL(
       
  3457         KMtmUiFunctionDeliveryStatus,
       
  3458         *selection,
       
  3459         watch->iStatus,
       
  3460         param ); // launch the dialog through MMSUI
       
  3461     CleanupStack::Pop( watch ); 
       
  3462     Document()->AddSingleOperationL( op, watch );
       
  3463     CleanupStack::PopAndDestroy( selection ); // selection
       
  3464     }
       
  3465 
       
  3466 // ---------------------------------------------------------
       
  3467 // CAudioMessageAppUi::DoMoveMessageL
       
  3468 // ---------------------------------------------------------
       
  3469 //
       
  3470 void CAudioMessageAppUi::DoMoveMessageL()
       
  3471     {
       
  3472     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoMoveMessageL >>" ); 
       
  3473     //ask folder with a dialog (from muiu)
       
  3474     TMsvId target = Document()->Entry().Parent();
       
  3475     HBufC* title = StringLoader::LoadLC( R_AMSVIEWER_MOVE_TEXT, iCoeEnv );
       
  3476     TBool success = CMsgFolderSelectionDialog::SelectFolderL(target, *title);
       
  3477     CleanupStack::PopAndDestroy( title ); // title
       
  3478     if ( success )
       
  3479         {
       
  3480         MoveMessageEntryL( target );
       
  3481     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoMoveMessageL <<" ); 
       
  3482         Exit( EAknSoftkeyClose );
       
  3483         }
       
  3484     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoMoveMessageL <<" ); 
       
  3485     }
       
  3486 
       
  3487 
       
  3488 
       
  3489 // ---------------------------------------------------------
       
  3490 // CAudioMessageAppUi::DoReplyViaL
       
  3491 // ---------------------------------------------------------
       
  3492 //
       
  3493 void CAudioMessageAppUi::DoReplyViaL( TInt aCase  )
       
  3494     {
       
  3495     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoDoReplyViaL >>" ); 
       
  3496      
       
  3497     if ( iToolbar ) 
       
  3498         {
       
  3499         iToolbar->SetToolbarVisibility( EFalse, EFalse );     
       
  3500         }
       
  3501 
       
  3502     //to reduce flickering during closing
       
  3503 	if (!(iEditorBaseFeatures & EStayInViewerAfterReply ))
       
  3504         {
       
  3505         iView->MakeVisible( EFalse );
       
  3506         }
       
  3507 
       
  3508     switch ( aCase )
       
  3509             {
       
  3510             case EReplyToSender:
       
  3511                 ReplyL( KNewMessageFolder );  //Draft
       
  3512                 break;
       
  3513             case EReplyToAll:
       
  3514                 ReplyToAllL( KNewMessageFolder );
       
  3515                 break;                         
       
  3516             case EReplyViaMessage:
       
  3517                 DoDoReplyViaMessageL();
       
  3518                 break;  
       
  3519     
       
  3520             default:
       
  3521                 break;
       
  3522             }      
       
  3523             
       
  3524     if (!(iEditorBaseFeatures & EStayInViewerAfterReply)) 
       
  3525         {
       
  3526         Exit( EAknSoftkeyClose );
       
  3527         }
       
  3528     if ( iToolbar ) 
       
  3529         {
       
  3530         iToolbar->SetToolbarVisibility( ETrue, EFalse );     
       
  3531         }  
       
  3532     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoDoReplyViaL <<" );    
       
  3533     }
       
  3534     
       
  3535 // ---------------------------------------------------------
       
  3536 // CAudioMessageAppUi::DoDoReplyViaMessageL
       
  3537 // ---------------------------------------------------------
       
  3538 //
       
  3539 void CAudioMessageAppUi::DoDoReplyViaMessageL(  )
       
  3540     {
       
  3541     CMessageData* msgData = CMessageData::NewLC();
       
  3542     TPtrC alias = KNullDesC();
       
  3543 
       
  3544     const TPtrC details = iMtm->Entry().Entry().iDetails;
       
  3545 
       
  3546     if ( details.Length() && !iAlias )
       
  3547         {
       
  3548         iAlias = details.AllocL( );
       
  3549         alias.Set( *iAlias );
       
  3550         }
       
  3551         
       
  3552      const TPtrC description = iMtm->Entry().Entry().iDescription;
       
  3553      TPtrC subject = KNullDesC();       
       
  3554 
       
  3555 	// Add address
       
  3556 	const TPtrC sender = iMtm->Sender();
       
  3557    	if ( sender != KNullDesC() )
       
  3558 		{
       
  3559 	    if ( iAlias )
       
  3560 	    	{
       
  3561             msgData->AppendToAddressL( TMmsGenUtils::PureAddress ( sender ), *iAlias );
       
  3562             }
       
  3563         else
       
  3564             {
       
  3565             msgData->AppendToAddressL( TMmsGenUtils::PureAddress ( sender ) );
       
  3566          	}
       
  3567 	 	}
       
  3568 	 	
       
  3569 	//Add Subject Header	
       
  3570  	HBufC* prefixSubject = CreateSubjectPrefixStringL( iMtm->SubjectL(), ETrue );
       
  3571     CleanupStack::PushL( prefixSubject ); 
       
  3572     if ( prefixSubject )
       
  3573         {
       
  3574         msgData->SetSubjectL( prefixSubject );
       
  3575         }
       
  3576     else
       
  3577         {
       
  3578         TPtrC subjectDes = iMtm->SubjectL();
       
  3579         msgData->SetSubjectL( &subjectDes );
       
  3580         }
       
  3581     CleanupStack::PopAndDestroy( prefixSubject ); 
       
  3582 
       
  3583     CSendUi* sendUi = CSendUi::NewLC();
       
  3584     sendUi->CreateAndSendMessageL(
       
  3585             	KSenduiMtmUniMessageUid,
       
  3586                	msgData);
       
  3587     CleanupStack::PopAndDestroy( sendUi );
       
  3588     CleanupStack::PopAndDestroy( msgData );
       
  3589     }    
       
  3590  
       
  3591 // ---------------------------------------------------------
       
  3592 // CAudioMessageAppUi::DoForwardL
       
  3593 // ---------------------------------------------------------
       
  3594 //
       
  3595 void CAudioMessageAppUi::DoForwardL()
       
  3596     {
       
  3597     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoForwardL >>" ); 
       
  3598     if ( iToolbar ) 
       
  3599         {
       
  3600         iToolbar->SetToolbarVisibility( EFalse, EFalse );     
       
  3601         }
       
  3602     
       
  3603     if (!(iEditorBaseFeatures & EStayInViewerAfterReply ))
       
  3604         {
       
  3605         iView->MakeVisible( EFalse );
       
  3606         }
       
  3607     
       
  3608     ForwardL( KNewMessageFolder );
       
  3609     if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  3610 	    {
       
  3611 	    Exit( EAknSoftkeyClose );
       
  3612 	    }
       
  3613     if ( iToolbar ) 
       
  3614         {
       
  3615         iToolbar->SetToolbarVisibility( ETrue, EFalse );     
       
  3616         } 
       
  3617     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoForwardL <<" ); 
       
  3618     }
       
  3619 
       
  3620 
       
  3621 // ---------------------------------------------------------
       
  3622 // CAudioMessageAppUi::FetchAudioFileDataL
       
  3623 // ---------------------------------------------------------
       
  3624 //
       
  3625 void CAudioMessageAppUi::FetchAudioFileDataL( )
       
  3626     {
       
  3627     AMSLOGGER_WRITE( "CAudioMessageAppUi::FetchAudioFileDataL >>" ); 
       
  3628     CMsvStore* store = Document()->Mtm().Entry().ReadStoreL();
       
  3629     CleanupStack::PushL( store );
       
  3630     MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
  3631 	RFile rFile = manager.GetAttachmentFileL( Document()->iAudio );
       
  3632 
       
  3633     CleanupClosePushL( rFile );
       
  3634 
       
  3635     TInt currentSize = 0;
       
  3636     rFile.Size( currentSize );
       
  3637     Document()->SetAudioFileSize( currentSize );
       
  3638 
       
  3639     TDataType testType( KMsgMimeAudioAmr );
       
  3640     if ( Document()->GetAppMode() == EAmsViewer && !( Document()->IsAmrL( rFile, testType ) ))
       
  3641         {
       
  3642         Document()->SetClipStatus( EAmsClipCorrupted ); 
       
  3643     	SetAudioClipIconL( EAudioCorrupted );
       
  3644         UpdateSoftKeysL(); 
       
  3645         ShowInformationNoteL( R_AUDIOMESSAGE_ERROR_MSG_CORRUPT, EFalse );
       
  3646         }
       
  3647     
       
  3648     CleanupStack::PopAndDestroy( &rFile );
       
  3649     CleanupStack::PopAndDestroy( store );
       
  3650     AMSLOGGER_WRITE( "CAudioMessageAppUi::FetchAudioFileDataL <<" ); 
       
  3651     }
       
  3652 
       
  3653 // ---------------------------------------------------------
       
  3654 // CAudioMessageAppUi::FocusedControlId
       
  3655 // ---------------------------------------------------------
       
  3656 //
       
  3657 TInt CAudioMessageAppUi::FocusedControlId()
       
  3658     {
       
  3659     TInt controlType = EMsgComponentIdNull;
       
  3660     if ( iView && iView->FocusedControl() )
       
  3661         {
       
  3662         controlType = iView->FocusedControl()->ControlId();
       
  3663         }
       
  3664     return controlType;
       
  3665     }
       
  3666 
       
  3667 // ---------------------------------------------------------
       
  3668 // CAudioMessageAppUi::IsSilentModeL
       
  3669 // ---------------------------------------------------------
       
  3670 //
       
  3671 TBool CAudioMessageAppUi::IsSilentModeL()
       
  3672     {
       
  3673     TBool result( EFalse );
       
  3674 
       
  3675     CRepository* repository = CRepository::NewLC( KCRUidProfileEngine );
       
  3676     TInt defaultType( EProfileGeneralId );
       
  3677     User::LeaveIfError( repository->Get( KProEngActiveProfile, defaultType ) );
       
  3678     CleanupStack::PopAndDestroy( repository );
       
  3679 
       
  3680     if ( defaultType == EProfileSilentId )
       
  3681         {
       
  3682         result = ETrue;
       
  3683         }
       
  3684     return result;
       
  3685     }
       
  3686 
       
  3687 
       
  3688 // ---------------------------------------------------------
       
  3689 // CAudioMessageAppUi::HandleWsEventL
       
  3690 // ---------------------------------------------------------
       
  3691 //
       
  3692 void CAudioMessageAppUi::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
  3693   	{
       
  3694   	const TInt systemAppWgId( 4 );
       
  3695   	switch ( aEvent.Type() )
       
  3696     	{
       
  3697         case EEventFocusGroupChanged:
       
  3698         	{
       
  3699 AMSLOGGER_WRITE( "CAudioMessageAppUi::HandleWsEventL: EEventFocusGroupChanged " );           	
       
  3700           	TInt windowGroupId = iEikonEnv->WsSession().GetFocusWindowGroup();
       
  3701 
       
  3702           	if ( ( windowGroupId != iMyWgId  ) && ( windowGroupId != iFSWindowGroupId ) &&
       
  3703               	( windowGroupId != systemAppWgId ) && (windowGroupId != iAknNfySrvUi ) )
       
  3704             	if ( iProgressDlg )
       
  3705             		{                                       		
       
  3706 AMSLOGGER_WRITE( "HandleWsEventL(): Event caused  iProgressDlg->Stop() " );            		                                      		
       
  3707 AMSLOGGER_WRITEF( _L("iEikonEnv->WsSession().GetFocusWindowGroup() = : %d"), windowGroupId );
       
  3708               		iProgressDlg->Stop();
       
  3709               		
       
  3710              		// Release voice key
       
  3711           			if ( iVoiceKeyHandle >= 0 )
       
  3712               			{
       
  3713               		    iCoeEnv->RootWin().CancelCaptureKey( iVoiceKeyHandle );
       
  3714               			iVoiceKeyHandle = KAmsNotCaptured;
       
  3715               			}
       
  3716             		}	
       
  3717           	break;
       
  3718         	}
       
  3719 
       
  3720         default:
       
  3721             {
       
  3722             break;
       
  3723             }
       
  3724     	}
       
  3725     CMsgEditorAppUi::HandleWsEventL( aEvent, aDestination );      	
       
  3726   	}
       
  3727 
       
  3728 
       
  3729 // ---------------------------------------------------------
       
  3730 // CAudioMessageAppUi::SaveAudioClipL
       
  3731 // ---------------------------------------------------------
       
  3732 //
       
  3733 void CAudioMessageAppUi::SaveAudioClipL()
       
  3734     {
       
  3735     AMSLOGGER_WRITE( "CAudioMessageAppUi::SaveAudioClipL >>" ); 
       
  3736     TFileName fileName;
       
  3737     TDataType dataType( KMsgMimeAudioAmr );
       
  3738 
       
  3739     CMsvStore* store = Document()->Mtm().Entry().ReadStoreL();
       
  3740     CleanupStack::PushL( store );
       
  3741     MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
  3742  
       
  3743 	RFile rFile = manager.GetAttachmentFileL( Document()->iAudio );
       
  3744 
       
  3745     rFile.Name(fileName);
       
  3746     const TPtrC newName = fileName;
       
  3747     
       
  3748     
       
  3749     CDocumentHandler* docHandler = CDocumentHandler::NewL( );
       
  3750     CleanupStack::PushL(docHandler);
       
  3751     CleanupClosePushL( rFile );
       
  3752 
       
  3753     TInt ret = docHandler->CopyL( rFile,
       
  3754                             	newName,
       
  3755                                 dataType,
       
  3756                                 KEntryAttNormal );
       
  3757     if ( ret != KErrNone && ret != KUserCancel )
       
  3758         {
       
  3759         User::LeaveIfError( ret );
       
  3760         }
       
  3761     CleanupStack::PopAndDestroy(3, store);
       
  3762     AMSLOGGER_WRITE( "CAudioMessageAppUi::SaveAudioClipL <<" ); 
       
  3763     }
       
  3764 
       
  3765 // ---------------------------------------------------------
       
  3766 // CAudioMessageAppUi::ShowAddressInfoNoteL
       
  3767 // ---------------------------------------------------------
       
  3768 //
       
  3769 void CAudioMessageAppUi::ShowAddressInfoNoteL( const TDesC& aAddress, const TDesC& aAlias )
       
  3770     {
       
  3771     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowAddressInfoNoteL >>" ); 
       
  3772     TInt cleanupCount = 0;
       
  3773     HBufC* string = NULL;
       
  3774     HBufC* convertedAddress = NumberConversionLC( aAddress, ETrue );
       
  3775     cleanupCount++;
       
  3776 
       
  3777     if ( aAlias.Length() == 0 )
       
  3778         {
       
  3779         string = StringLoader::LoadLC(
       
  3780             R_AUDIOMESSAGE_INFO_FAIL_RECIPIENT_NO_ALIAS,
       
  3781             *convertedAddress,
       
  3782             iCoeEnv );
       
  3783         cleanupCount++;
       
  3784         }
       
  3785     else
       
  3786         {
       
  3787         CDesCArrayFlat* stringArr = new ( ELeave ) CDesCArrayFlat( 2 );
       
  3788         CleanupStack::PushL( stringArr );
       
  3789         cleanupCount++;
       
  3790         stringArr->AppendL( aAlias );    //First string
       
  3791         stringArr->AppendL( *convertedAddress );  //Second string
       
  3792         string = StringLoader::LoadLC(
       
  3793             R_AUDIOMESSAGE_INFO_FAIL_RECIPIENT,
       
  3794             *stringArr,
       
  3795             iCoeEnv );
       
  3796         cleanupCount++;
       
  3797         }
       
  3798 
       
  3799     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
  3800     note->ExecuteLD( *string );
       
  3801     CleanupStack::PopAndDestroy( cleanupCount );  // string, (stringArr)
       
  3802     AMSLOGGER_WRITE( "CAudioMessageAppUi::ShowAddressInfoNoteL <<" ); 
       
  3803     }
       
  3804 
       
  3805 // ---------------------------------------------------------
       
  3806 // CAudioMessageAppUi::DoCallToSenderL
       
  3807 // ---------------------------------------------------------
       
  3808 //
       
  3809 void CAudioMessageAppUi::DoCallToSenderL()
       
  3810   	{
       
  3811   	AMSLOGGER_WRITE( "CAudioMessageAppUi::DoCallToSenderL >>" ); 
       
  3812     if ( !iMsgVoIPExtension )
       
  3813         {
       
  3814         return;
       
  3815         }
       
  3816   	
       
  3817     TPtrC senderAddr = KNullDesC( );
       
  3818     TPtrC alias = KNullDesC();
       
  3819     TPtrC focusedAddr = KNullDesC( );
       
  3820 
       
  3821     senderAddr.Set( TMmsGenUtils::PureAddress( iMtm->Sender() ) );
       
  3822       
       
  3823     HBufC* ali = HBufC::NewL( KMaxAliasLength );
       
  3824     CleanupStack::PushL( ali ); 
       
  3825     TPtr aliPtr ( ali->Des() );
       
  3826     
       
  3827     TMmsGenUtils::GetAlias( 
       
  3828         iMtm->Sender() ,
       
  3829         aliPtr,
       
  3830         KMaxAliasLength,
       
  3831         FsSession()   ); 
       
  3832     alias.Set( aliPtr );
       
  3833 
       
  3834     // find item not possible as there is no message body
       
  3835 
       
  3836     MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( 
       
  3837             *iMsgVoIPExtension,
       
  3838             senderAddr,
       
  3839             alias,
       
  3840             focusedAddr,
       
  3841             ETrue,
       
  3842             iEikonEnv );
       
  3843    CleanupStack::PopAndDestroy( ali ); 
       
  3844 AMSLOGGER_WRITE( "CAudioMessageAppUi::DoCallToSenderL <<" ); 
       
  3845   	}
       
  3846 
       
  3847 // ---------------------------------------------------------
       
  3848 // CAudioMessageAppUi::SetFindMode
       
  3849 // ---------------------------------------------------------
       
  3850 //
       
  3851 void CAudioMessageAppUi::SetFindMode( TBool aEnable )
       
  3852     {
       
  3853     if ( iView )
       
  3854         {
       
  3855         CMsgBaseControl* fromControl = iView->ControlById( EMsgComponentIdFrom );
       
  3856         if ( fromControl && iMtm->Sender().Length() )
       
  3857             {
       
  3858             static_cast<CMsgAddressControl*>( fromControl )
       
  3859                 ->SetAddressFieldAutoHighlight( aEnable );
       
  3860             }
       
  3861         }
       
  3862     }
       
  3863 
       
  3864 // ---------------------------------------------------------
       
  3865 // CAudioMessageAppUi::HandleNotifyInt
       
  3866 // ---------------------------------------------------------
       
  3867 //
       
  3868 void CAudioMessageAppUi::HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue )
       
  3869     {
       
  3870     if ( aNewValue == 0 )
       
  3871         {
       
  3872         iEditorFlags &= ~EAutohighLightEnabled;
       
  3873         }
       
  3874     else
       
  3875         {
       
  3876         iEditorFlags |= EAutohighLightEnabled;
       
  3877         }
       
  3878     SetFindMode( iEditorFlags & EAutohighLightEnabled );
       
  3879     }
       
  3880 
       
  3881 // ---------------------------------------------------------
       
  3882 // CAudioMessageAppUi::SetNaviPaneL
       
  3883 // ---------------------------------------------------------
       
  3884 //
       
  3885 void CAudioMessageAppUi::SetNaviPaneL()
       
  3886 	{
       
  3887    	CMsgBaseControl* ctrl = iView->FocusedControl();
       
  3888     if ( Document()->GetAppMode() == EAmsEditor )
       
  3889     	{
       
  3890 	   	if (  ctrl->ControlId() == EMsgComponentIdImage )
       
  3891 	       	{
       
  3892 	  		UpdateEditorNaviFieldL( EAmsOnlyLength );
       
  3893 	       	}
       
  3894 	   	else
       
  3895 	       	{
       
  3896 	  		UpdateEditorNaviFieldL( EAmsTextEditorAndLength );
       
  3897 	       	}
       
  3898     	}
       
  3899     else
       
  3900     	{
       
  3901 	  	UpdateViewerNaviFieldL(  );
       
  3902     	}
       
  3903 	}
       
  3904 
       
  3905 #ifdef RD_SCALABLE_UI_V2
       
  3906 
       
  3907 // -----------------------------------------------------------------------------
       
  3908 // handles the touch-ui related control events for next/previous message
       
  3909 // -----------------------------------------------------------------------------
       
  3910 //
       
  3911 void CAudioMessageAppUi::HandleNaviDecoratorEventL( TInt aEventID )     
       
  3912     {
       
  3913     if( IsNextMessageAvailableL( aEventID == EAknNaviDecoratorEventRightTabArrow ) )
       
  3914         {
       
  3915         /* no need for separate checks for right and left arrows
       
  3916             because IsNextMessageAvailableL() and NextMessageL
       
  3917             are called with the truth-value of the same comparison */
       
  3918         NextMessageL( aEventID == EAknNaviDecoratorEventRightTabArrow );
       
  3919         }
       
  3920     }
       
  3921 
       
  3922 #else
       
  3923 void CAudioMessageAppUi::HandleNaviDecoratorEventL( TInt /* aEventID */)
       
  3924     {}
       
  3925 #endif
       
  3926 
       
  3927 
       
  3928 // ---------------------------------------------------------
       
  3929 // CAudioMessageAppUi::DialogDismissedL
       
  3930 //
       
  3931 // This is a bit tricky. DialogDismissedL is called when wait dialog
       
  3932 // is really dismissed from the screen. Wait dialog is not neccessary
       
  3933 // dismmissed at once the ProcessFinishedL function is called. This 
       
  3934 // is because of some minimum delayes etc. tied to the visibility of
       
  3935 // wait dialog. But this more complex than that as wait dialog can be dismissed
       
  3936 // by end key or escape key from the screen before the operation has really been
       
  3937 // completed or cancelled. This needs to be taken into account here.
       
  3938 // ---------------------------------------------------------
       
  3939 //
       
  3940 void CAudioMessageAppUi::DialogDismissedL( TInt dismissed )
       
  3941     {
       
  3942     if ( dismissed == EAknSoftkeyDone )
       
  3943         {
       
  3944         switch ( iWaitResId )
       
  3945             {
       
  3946             case R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE :
       
  3947             case R_QTN_AUDIOMESSAGE_WAIT_SAVING_MESSAGE_NEW:
       
  3948                 {
       
  3949                 //We are still in saving phase. Prevents opening the options menu
       
  3950                 if ( !iAbsorber )
       
  3951                     {
       
  3952                     iAbsorber = CAknInputBlock::NewLC();
       
  3953         	        CleanupStack::Pop( iAbsorber );
       
  3954                     }
       
  3955                 DoOpComplete2ndPhaseL();
       
  3956                 break;
       
  3957                 }
       
  3958             case R_QTN_AUDIOMESSAGE_WAIT_INSERTING:
       
  3959                 {
       
  3960                 //There may have been fatal error in inserting
       
  3961                 if ( iInsertOperation && iInsertOperation->GetError()<0 )
       
  3962                     {
       
  3963                     ;//Do nothing, error note is shown elsewhere and application is closed
       
  3964                     }
       
  3965                 else
       
  3966                     {
       
  3967                     HBufC* labell = StringLoader::LoadLC( R_AUDIOMESSAGE_INSERTED );
       
  3968   		            CAknGlobalNote *globalNote = CAknGlobalNote::NewLC();
       
  3969 	                globalNote->ShowNoteL( EAknGlobalInformationNote, *labell );
       
  3970 	                CleanupStack::PopAndDestroy( globalNote );
       
  3971                     CleanupStack::PopAndDestroy( labell );
       
  3972                     }
       
  3973                   	 break;                 
       
  3974                 }
       
  3975             case R_QTN_AUDIOMESSAGE_WAIT_SEND_MESSAGE:
       
  3976             case R_QTN_WAIT_MSG_SAVED_OUTBOX:
       
  3977                 {
       
  3978                 //We are still in sending/saving phase. Prevents opening the options menu
       
  3979                 if ( !iAbsorber )
       
  3980                     {
       
  3981                     iAbsorber = CAknInputBlock::NewLC();
       
  3982         	        CleanupStack::Pop( iAbsorber );
       
  3983                     }
       
  3984                 DoOpComplete2ndPhaseL();
       
  3985                 break;
       
  3986                 }   
       
  3987             case R_QTN_AUDIOMESSAGE_WAIT_OPENING_EDITOR:
       
  3988                 {
       
  3989                 break;
       
  3990                 }    
       
  3991             default:
       
  3992                 {
       
  3993                 break;
       
  3994                 }
       
  3995             }
       
  3996         }
       
  3997     else if ( dismissed == EEikBidCancel )
       
  3998         {
       
  3999         iWaitDialog = NULL;
       
  4000         }
       
  4001     
       
  4002     iWaitDialog = NULL;
       
  4003     iWaitResId = -1;
       
  4004     }
       
  4005 
       
  4006 // -----------------------------------------------------------------------------
       
  4007 // Update softkeys
       
  4008 // Err ID: EJJN-7J3BBY :: 05/09/2008 :: Purushotham Reddy K
       
  4009 // -----------------------------------------------------------------------------
       
  4010 //
       
  4011 void CAudioMessageAppUi::DoUpdateSoftKeysL( TInt aSk )
       
  4012 	{   
       
  4013     if ( iCurrentSkResId != aSk )
       
  4014     	{
       
  4015         CEikButtonGroupContainer* cba  = CEikButtonGroupContainer::Current();     
       
  4016         if(cba)
       
  4017             {
       
  4018             cba->SetCommandSetL( aSk  );
       
  4019             iCurrentSkResId = aSk;	
       
  4020     	    cba->DrawNow();
       
  4021             }
       
  4022     	}
       
  4023 	}
       
  4024 
       
  4025 // -----------------------------------------------------------------------------
       
  4026 // Update softkeys second version
       
  4027 // This can be called without knowing the application state or focused item
       
  4028 // -----------------------------------------------------------------------------
       
  4029 //
       
  4030 void CAudioMessageAppUi::UpdateSoftKeysL( )
       
  4031 	{
       
  4032 	CMsgBaseControl* ctrl = iView->FocusedControl();
       
  4033        	        
       
  4034     if ( Document()->GetAppMode() == EAmsViewer )
       
  4035 		{
       
  4036         if ( ctrl->ControlId() == EMsgComponentIdImage)
       
  4037 	        {
       
  4038             DoUpdateSoftKeysL( R_AUDIOMESSAGE_OPTIONS_PLAY_BACK);
       
  4039 	        }
       
  4040 	    else
       
  4041 	        {   
       
  4042 		    MenuBar()->SetContextMenuTitleResourceId(
       
  4043 		        R_AUDIOMESSAGE_VIEWER_SELECTMENU );
       
  4044 
       
  4045             DoUpdateSoftKeysL( R_AUDIOMESSAGE_OPTIONS_CONTEXTOPTIONS_BACK ); 	
       
  4046 	        }
       
  4047 		}
       
  4048 	 else  //AppMode == EAmsEditor
       
  4049 	    {
       
  4050 	    if ( ctrl->ControlId() == EMsgComponentIdImage )
       
  4051 	        {
       
  4052             //Now we are in the body we must check if the clip has already been recorded
       
  4053             if( Document()->GetClipStatus() != EAmsClipNone )
       
  4054             	{
       
  4055                 DoUpdateSoftKeysL( R_AUDIOMESSAGE_OPTIONS_PLAY_CLOSE );
       
  4056                 }
       
  4057             else 
       
  4058              	{
       
  4059                 DoUpdateSoftKeysL( R_AUDIOMESSAGE_OPTIONS_RECORD_CLOSE );
       
  4060                 }
       
  4061 	        }
       
  4062 	    else
       
  4063 	        {
       
  4064 	        DoUpdateSoftKeysL( R_AUDIOMESSAGE_OPTIONS_ADD_CLOSE );
       
  4065 	        }
       
  4066 	    }
       
  4067 	}
       
  4068 // ---------------------------------------------------------
       
  4069 // CAudioMessageAppUi::DoEditMmsPriorityL
       
  4070 // ---------------------------------------------------------
       
  4071 void CAudioMessageAppUi::DoEditAmsPriorityL( )
       
  4072     {
       
  4073     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoEditAmsPriorityL >>" ); 
       
  4074     TInt currentlySelected = 0;
       
  4075     switch( Document()->Mtm().MessagePriority(  ) )
       
  4076         {
       
  4077         case EMmsPriorityNormal:
       
  4078             currentlySelected = 1;
       
  4079             break;
       
  4080         case EMmsPriorityLow:
       
  4081             currentlySelected = 2;
       
  4082             break;
       
  4083         default:
       
  4084             break;
       
  4085         }
       
  4086      
       
  4087 	// Create listbox    
       
  4088     CAknSingleGraphicPopupMenuStyleListBox* listBox 
       
  4089         = new (ELeave) CAknSingleGraphicPopupMenuStyleListBox;
       
  4090     CleanupStack::PushL( listBox );
       
  4091     
       
  4092     // Create popup
       
  4093     CAknPopupList* popup = CAknPopupList::NewL( 
       
  4094                 listBox, 
       
  4095                 R_AVKON_SOFTKEYS_SELECT_CANCEL, 
       
  4096                 AknPopupLayouts::EMenuGraphicWindow );
       
  4097     CleanupStack::PushL( popup );
       
  4098 
       
  4099 	// Construct listbox
       
  4100     listBox->ConstructL( popup, CEikListBox::ELeftDownInViewRect );
       
  4101     listBox->CreateScrollBarFrameL( ETrue );
       
  4102     listBox->ScrollBarFrame( )->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
  4103                                                       CEikScrollBarFrame::EAuto );
       
  4104   
       
  4105 	// Set title    
       
  4106     HBufC* title = StringLoader::LoadLC( R_AUDIOMESSAGE_PRIORITY_TITLE, iCoeEnv );
       
  4107     popup->SetTitleL( title->Des( ) );
       
  4108     CleanupStack::PopAndDestroy( title );
       
  4109 
       
  4110 	CAknIconArray* iconArray = RadioButtonArrayL( );
       
  4111     listBox->ItemDrawer( )->FormattedCellData( )->SetIconArray( iconArray ); // FormattedCellData owns
       
  4112 
       
  4113     listBox->HandleItemAdditionL( );
       
  4114 
       
  4115     TResourceReader reader;
       
  4116     iEikonEnv->CreateResourceReaderLC( reader, R_AUDIOMESSAGE_PRIORITY_LIST );
       
  4117     
       
  4118     const TInt KSettingsGranularity = 4;
       
  4119     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KSettingsGranularity );
       
  4120     CleanupStack::PushL( items );
       
  4121 
       
  4122     // Get the labels from resources
       
  4123     const TInt count = reader.ReadInt16();
       
  4124 
       
  4125     for ( TInt loop = 0; loop < count; loop++ )
       
  4126         {
       
  4127         HBufC* label = reader.ReadHBufCL();        
       
  4128         CleanupStack::PushL( label );
       
  4129         TPtr pLabel = label->Des();
       
  4130         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( pLabel );
       
  4131         
       
  4132         TBuf<20> itemString;
       
  4133         if( currentlySelected == loop )
       
  4134             { // This one is selected
       
  4135             itemString.AppendNum( 1 );
       
  4136             }
       
  4137         else
       
  4138             {
       
  4139             itemString.AppendNum( 0 );
       
  4140             }
       
  4141 
       
  4142         _LIT( KT,"\t");
       
  4143         itemString.Append( KT );
       
  4144         itemString.Append( pLabel );
       
  4145         items->AppendL( itemString );
       
  4146         
       
  4147         CleanupStack::PopAndDestroy( label );
       
  4148         label = NULL;
       
  4149         }
       
  4150 
       
  4151     CTextListBoxModel* model = listBox->Model( );
       
  4152     model->SetItemTextArray( items );
       
  4153     model->SetOwnershipType( ELbmOwnsItemArray );
       
  4154 	CleanupStack::Pop( items ); // model owns it now  
       
  4155 	CleanupStack::PopAndDestroy( ); // reader 
       
  4156     listBox->SetCurrentItemIndexAndDraw( currentlySelected );
       
  4157 
       
  4158     TInt result = popup->ExecuteLD();
       
  4159  
       
  4160     if( result )
       
  4161         {
       
  4162         // OK, user chose the priority bit
       
  4163         switch( listBox->CurrentItemIndex( ) )
       
  4164             {
       
  4165             case 0:
       
  4166                 Document()->Mtm().SetMessagePriority( EMmsPriorityHigh );
       
  4167                 break;
       
  4168             case 1:
       
  4169                 Document()->Mtm().SetMessagePriority( EMmsPriorityNormal );
       
  4170                 break;
       
  4171             default:
       
  4172                 Document()->Mtm().SetMessagePriority( EMmsPriorityLow );
       
  4173                 break;
       
  4174             }   
       
  4175         }
       
  4176     UpdateIndicatorIcons( (TMmsMessagePriority)Document()->Mtm().MessagePriority() );    
       
  4177     Document()->SetHeaderModified( ETrue ); //This makes us save headers in case of 
       
  4178                                             //Message details menu shown
       
  4179     CleanupStack::Pop( popup ); 
       
  4180     CleanupStack::PopAndDestroy( listBox );
       
  4181     AMSLOGGER_WRITE( "CAudioMessageAppUi::DoEditAmsPriorityL <<" ); 
       
  4182     }
       
  4183 
       
  4184 // ---------------------------------------------------------
       
  4185 // CAudioMessageAppUi::RadioButtonArrayL
       
  4186 // ---------------------------------------------------------
       
  4187 CAknIconArray* CAudioMessageAppUi::RadioButtonArrayL( )
       
  4188 	{
       
  4189     TFileName fileName;
       
  4190     fileName.Copy( KAvkonBitmapFile );
       
  4191 
       
  4192     CAknIconArray* iconArray = new (ELeave) CAknIconArray( 2 );
       
  4193     CleanupStack::PushL( iconArray ); 
       
  4194 
       
  4195     CFbsBitmap* bitmap = NULL;
       
  4196     CFbsBitmap* mask = NULL;
       
  4197     CGulIcon* icon = NULL;
       
  4198 
       
  4199     TAknsItemID skinId = KAknsIIDQgnPropRadiobuttOff;
       
  4200     TInt bitmapId = EMbmAvkonQgn_prop_radiobutt_off;
       
  4201 
       
  4202     AknsUtils::CreateIconL(
       
  4203         AknsUtils::SkinInstance(),
       
  4204         skinId,
       
  4205         bitmap,
       
  4206         mask,
       
  4207         fileName,
       
  4208         bitmapId,
       
  4209         bitmapId+1
       
  4210         );
       
  4211     CleanupStack::PushL( bitmap );
       
  4212     CleanupStack::PushL( mask );
       
  4213     icon = CGulIcon::NewL( bitmap, mask );
       
  4214     CleanupStack::Pop( mask );
       
  4215     CleanupStack::Pop( bitmap );
       
  4216     CleanupStack::PushL( icon ); 
       
  4217     iconArray->AppendL( icon );
       
  4218     CleanupStack::Pop( icon );   
       
  4219 
       
  4220     skinId = KAknsIIDQgnPropRadiobuttOn;
       
  4221     bitmapId = EMbmAvkonQgn_prop_radiobutt_on;
       
  4222 
       
  4223     AknsUtils::CreateIconL(
       
  4224         AknsUtils::SkinInstance(),
       
  4225         skinId,
       
  4226         bitmap,
       
  4227         mask,
       
  4228         fileName,
       
  4229         bitmapId,
       
  4230         bitmapId+1
       
  4231         );
       
  4232     CleanupStack::PushL( bitmap );
       
  4233     CleanupStack::PushL( mask );
       
  4234     icon = CGulIcon::NewL( bitmap, mask );
       
  4235     CleanupStack::Pop( mask );//popup mask first
       
  4236     CleanupStack::Pop( bitmap );//then bitmap
       
  4237     CleanupStack::PushL( icon ); 
       
  4238     iconArray->AppendL( icon );
       
  4239     CleanupStack::Pop( icon );   
       
  4240 
       
  4241     CleanupStack::Pop( iconArray );
       
  4242     
       
  4243     return iconArray;
       
  4244 	}
       
  4245 
       
  4246 // ---------------------------------------------------------
       
  4247 // CAudioMessageAppUi::UpdateIndicatorIcons
       
  4248 //
       
  4249 // ---------------------------------------------------------
       
  4250 //
       
  4251 void CAudioMessageAppUi::UpdateIndicatorIcons( TMmsMessagePriority aPriority )
       
  4252     {
       
  4253     TInt priorityHigh;
       
  4254     TInt priorityLow;
       
  4255 
       
  4256 	if( aPriority == EMmsPriorityLow )
       
  4257 	    {
       
  4258 	    priorityHigh = EAknIndicatorStateOff;
       
  4259 	    priorityLow = EAknIndicatorStateOn;
       
  4260 	    }
       
  4261 	else if( aPriority == EMmsPriorityHigh )
       
  4262 	    {
       
  4263 	    priorityHigh = EAknIndicatorStateOn;
       
  4264 	    priorityLow = EAknIndicatorStateOff;
       
  4265 	    }
       
  4266 	else
       
  4267 	    {
       
  4268 	    priorityHigh = EAknIndicatorStateOff;
       
  4269 	    priorityLow = EAknIndicatorStateOff;
       
  4270 	    }
       
  4271 
       
  4272     MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  4273         
       
  4274     CAknIndicatorContainer* naviIndi = 
       
  4275         static_cast<CAknIndicatorContainer*>( iNaviDecorator->DecoratedControl() );
       
  4276     
       
  4277     // Update the Edwin indicator pane
       
  4278     if( editIndi )
       
  4279         {
       
  4280         CAknIndicatorContainer* indiContainer = editIndi->IndicatorContainer();
       
  4281         if ( indiContainer )
       
  4282             {
       
  4283             indiContainer->SetIndicatorState(
       
  4284                         TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityHigh), 
       
  4285                         priorityHigh);
       
  4286             indiContainer->SetIndicatorState(
       
  4287                         TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityLow), 
       
  4288                         priorityLow);
       
  4289             }
       
  4290         }
       
  4291     // Update the navi indicator pane
       
  4292     if( naviIndi )
       
  4293         {
       
  4294         naviIndi->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityHigh), 
       
  4295                     priorityHigh);
       
  4296         naviIndi->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityLow), 
       
  4297                     priorityLow);
       
  4298         }
       
  4299     }
       
  4300 
       
  4301 // -----------------------------------------------------------------------------
       
  4302 // SendReadReportL
       
  4303 // -----------------------------------------------------------------------------
       
  4304 //
       
  4305 void CAudioMessageAppUi::SendReadReportL( TAmsOperationEvent aEvent )
       
  4306     {
       
  4307     // send read report
       
  4308     if (    aEvent == 	EAmsOperationComplete
       
  4309         &&  Document( )->LaunchFlags() & EMsgUnreadMessage )
       
  4310         {
       
  4311         // Do not leave because of read report
       
  4312         iSendReadReportOperation = new (ELeave ) CAudioMessageSendReadReportOperation(
       
  4313                                                     *this,
       
  4314                                                     *Document( ) );
       
  4315         iSendReadReportOperation->SendReadReportL( );
       
  4316         }
       
  4317     }
       
  4318 
       
  4319 // -----------------------------------------------------------------------------
       
  4320 // DoHandleLocalZoomChangeL
       
  4321 // -----------------------------------------------------------------------------
       
  4322 //
       
  4323 void CAudioMessageAppUi::DoHandleLocalZoomChangeL( TInt aCommand )
       
  4324 	{
       
  4325 	switch ( aCommand )
       
  4326 		{	
       
  4327 	    case EAmsDispSizeAutomatic:
       
  4328 		    {
       
  4329 		    HandleLocalZoomChangeL( EMsgDispSizeAutomatic );
       
  4330 		    break;
       
  4331 		    }
       
  4332         case EAmsDispSizeLarge:
       
  4333             {
       
  4334             HandleLocalZoomChangeL( EMsgDispSizeLarge );
       
  4335 		    break;
       
  4336 		    }
       
  4337         case EAmsDispSizeSmall:
       
  4338             {
       
  4339             HandleLocalZoomChangeL( EMsgDispSizeSmall );
       
  4340 		    break;
       
  4341 		    }
       
  4342 	    default: //EAmsDispSizeNormal
       
  4343             {
       
  4344             HandleLocalZoomChangeL(  EMsgDispSizeNormal );
       
  4345 		    break;
       
  4346 		    }	    
       
  4347 		}
       
  4348 	}
       
  4349 
       
  4350 // -----------------------------------------------------------------------------
       
  4351 // UnsupportedCallTypeOngoing
       
  4352 // -----------------------------------------------------------------------------
       
  4353 //
       
  4354 TBool CAudioMessageAppUi::UnsupportedCallTypeOngoingL(  )
       
  4355 	{
       
  4356 	TBool unsupported( EFalse );
       
  4357 	TInt value( 0 );
       
  4358 
       
  4359 	TInt err( 0 );
       
  4360     RProperty property;
       
  4361     err = property.Attach( KPSUidCtsyCallInformation, KCTsyCallState );
       
  4362 	if ( err )
       
  4363 		{
       
  4364 		return EFalse;
       
  4365 		}
       
  4366 
       
  4367     property.Get( value );
       
  4368 
       
  4369     switch ( value )
       
  4370 	    {
       
  4371     	case EPSCTsyCallStateUninitialized:
       
  4372     	case EPSCTsyCallStateNone:
       
  4373     		{ // No any kind of call in progress
       
  4374     		return EFalse;
       
  4375     		}
       
  4376 		default: // Call in progress, check if it is videocall
       
  4377 		    {
       
  4378 		    err = property.Attach( KPSUidCtsyCallInformation,
       
  4379         		KCTsyCallType );
       
  4380         	if ( err )
       
  4381         		{
       
  4382         		return EFalse;
       
  4383         		}
       
  4384         	value = 0;
       
  4385     		property.Get( value );
       
  4386 			break;
       
  4387 		    }
       
  4388     	}
       
  4389 
       
  4390 	switch( value )
       
  4391 		{
       
  4392 		// Video call ongoing
       
  4393 		case EPSCTsyCallTypeH324Multimedia:
       
  4394 			{
       
  4395 			unsupported = ETrue;
       
  4396 			ShowUnsupportedCallTypeNoteL( R_VR_VIDEO_CALL_INFONOTE_LABEL );
       
  4397 			break;			
       
  4398 			}
       
  4399 		// Voip call ongoing
       
  4400 		case EPSCTsyCallTypeVoIP:
       
  4401 			{
       
  4402 			unsupported = ETrue;
       
  4403 			ShowUnsupportedCallTypeNoteL( R_VR_INTERNET_CALL_INFONOTE_LABEL );
       
  4404 			break;			
       
  4405 			}			
       
  4406 		}
       
  4407 	
       
  4408 	return unsupported;
       
  4409 	}
       
  4410 	
       
  4411 // ---------------------------------------------------------------------------
       
  4412 // CAudioMessageAppUi::ShowUnsupportedCallTypeNoteL
       
  4413 // 
       
  4414 // ---------------------------------------------------------------------------
       
  4415 //
       
  4416 void CAudioMessageAppUi::ShowUnsupportedCallTypeNoteL( TInt aResourceId )
       
  4417     {
       
  4418     CAknInformationNote* infoNote;
       
  4419     HBufC* noteText;
       
  4420     
       
  4421     noteText = CEikonEnv::Static()->
       
  4422         AllocReadResourceLC( aResourceId );
       
  4423     
       
  4424     infoNote = new( ELeave ) CAknInformationNote( ETrue );
       
  4425     infoNote->ExecuteLD( *noteText );
       
  4426 
       
  4427     CleanupStack::PopAndDestroy( noteText );
       
  4428     }
       
  4429 
       
  4430 // ---------------------------------------------------------------------------
       
  4431 // CAudioMessageAppUi::CheckIncomingCall
       
  4432 // 
       
  4433 // ---------------------------------------------------------------------------
       
  4434 //
       
  4435 TBool CAudioMessageAppUi::CheckIncomingCall(  )
       
  4436     {
       
  4437 	TInt value( 0 );
       
  4438 	TInt err( 0 );
       
  4439 	RProperty property;
       
  4440 	err  = property.Attach( KPSUidCtsyCallInformation, KCTsyCallState );
       
  4441 	if ( err )
       
  4442 		{
       
  4443 		return EFalse;
       
  4444 		}
       
  4445 	property.Get( value );
       
  4446 
       
  4447     switch ( value )
       
  4448         {
       
  4449 		case EPSCTsyCallStateUninitialized:
       
  4450 		case EPSCTsyCallStateNone:
       
  4451 			{ // No any kind of call in progress
       
  4452 			return EFalse;
       
  4453 			}
       
  4454 		default: // Call in progress, 
       
  4455 	    	{
       
  4456 			//we can return from here, as we found call in progress
       
  4457 			return ETrue;
       
  4458 	    	}
       
  4459         }
       
  4460     }
       
  4461 // ---------------------------------------------------------
       
  4462 // CAudioMessageAppUi::HandleIteratorEventL
       
  4463 // ---------------------------------------------------------
       
  4464 //
       
  4465 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  4466 void CAudioMessageAppUi::HandleIteratorEventL( TMessageIteratorEvent aEvent )
       
  4467     {
       
  4468     if ( aEvent == EFolderCountChanged  )
       
  4469         {
       
  4470         SetNaviPaneL();
       
  4471         }
       
  4472     }
       
  4473 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
       
  4474 
       
  4475 
       
  4476 // ---------------------------------------------------------
       
  4477 // DynInitToolbarL
       
  4478 // ---------------------------------------------------------
       
  4479 //
       
  4480 #ifdef RD_SCALABLE_UI_V2
       
  4481 void CAudioMessageAppUi::DynInitToolbarL(  TInt            /*aResourceId*/, 
       
  4482                                         CAknToolbar*    /*aToolbar*/ )
       
  4483     {
       
  4484     }
       
  4485 #endif        
       
  4486 // ---------------------------------------------------------
       
  4487 // OfferToolbarEventL
       
  4488 // ---------------------------------------------------------
       
  4489 //
       
  4490 #ifdef RD_SCALABLE_UI_V2
       
  4491 void CAudioMessageAppUi::OfferToolbarEventL( TInt aCommand )
       
  4492     {
       
  4493     switch ( aCommand )
       
  4494         {
       
  4495         case EAmsViewerToolbarReply:
       
  4496             if ( IsOwnMessage( ) )
       
  4497                 {
       
  4498                 HandleCommandL( EAmsViewerCmdReplyToAll );
       
  4499                 }
       
  4500             else
       
  4501                 {
       
  4502                 HandleCommandL( EAmsViewerCmdReplyToSender );
       
  4503                 }
       
  4504             
       
  4505             break;
       
  4506 
       
  4507         case EAmsViewerToolbarForward:
       
  4508             HandleCommandL( EAmsViewerCmdForward );
       
  4509             break;
       
  4510 
       
  4511         case EAmsViewerToolbarDelete:
       
  4512             HandleCommandL( EAmsViewerCmdRemoveAudio );
       
  4513             break;
       
  4514             
       
  4515         case EAmsEditorToolbarSend:
       
  4516             HandleCommandL( EAmsEditorCmdSend );
       
  4517             break;
       
  4518             
       
  4519         case EAmsEditorToolbarRecord:
       
  4520             HandleCommandL( EAmsEditorCmdRecordAudio );
       
  4521             break;
       
  4522             
       
  4523         case EAmsEditorToolbarAddRecipient:
       
  4524             HandleCommandL( EAmsEditorCmdAddRecipient );
       
  4525             break; 
       
  4526                    
       
  4527         default:
       
  4528             break;
       
  4529 
       
  4530        
       
  4531         }
       
  4532     } 
       
  4533 
       
  4534 // ---------------------------------------------------------
       
  4535 // SetEditorToolBarItemVisibilities
       
  4536 // ---------------------------------------------------------
       
  4537 //
       
  4538 void CAudioMessageAppUi::SetEditorToolBarItemVisibilities()
       
  4539     {
       
  4540     /*TBool sendDimming( EFalse );
       
  4541     TBool recordDimming( EFalse );
       
  4542     TBool AddRecipientDimming( EFalse );*/
       
  4543     }
       
  4544 
       
  4545 // ---------------------------------------------------------
       
  4546 // SetViewerToolBarItemVisibilities
       
  4547 // ---------------------------------------------------------
       
  4548 //
       
  4549 void CAudioMessageAppUi::SetViewerToolBarItemVisibilities()
       
  4550     {
       
  4551     TBool replyDimming( EFalse );
       
  4552     
       
  4553     if ( iToolbar )
       
  4554         {                
       
  4555         if ( IsOwnMessage( ) || !HasSender( ) )
       
  4556             {
       
  4557             replyDimming = ETrue;
       
  4558             }
       
  4559 
       
  4560         iToolbar->SetItemDimmed(    EAmsViewerToolbarReply,
       
  4561                                     replyDimming,
       
  4562                                     ETrue );
       
  4563         }
       
  4564     }
       
  4565     
       
  4566 // ---------------------------------------------------------
       
  4567 // CAudioMessageAppUi::IsOwnMessage
       
  4568 // ---------------------------------------------------------
       
  4569 //
       
  4570 TBool CAudioMessageAppUi::IsOwnMessage( ) const
       
  4571     {
       
  4572     const TMmsMsvEntry* mmsEntry =
       
  4573         static_cast<const TMmsMsvEntry*>( &Document( )->Entry( ) );
       
  4574     return ( !(mmsEntry->IsMobileTerminated( ) ) );
       
  4575     }    
       
  4576     
       
  4577 // ---------------------------------------------------------
       
  4578 // CAudioMessageAppUi::HasSender
       
  4579 // ---------------------------------------------------------
       
  4580 //
       
  4581 TBool CAudioMessageAppUi::HasSender( ) const
       
  4582     {
       
  4583     return ( iMtm->Sender( ).Length( ) > 0 );
       
  4584     }    
       
  4585 #endif
       
  4586 
       
  4587 // ---------------------------------------------------------
       
  4588 // CAudioMessageAppUi::HandleResourceChangeL
       
  4589 // ---------------------------------------------------------
       
  4590 //
       
  4591 void CAudioMessageAppUi::HandleResourceChangeL( TInt aType )
       
  4592     {
       
  4593      // Base class call must be first
       
  4594     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  4595     
       
  4596     if ( aType == KAknsMessageSkinChange )
       
  4597         {
       
  4598         if ( iAppIcon )
       
  4599             {
       
  4600             delete iAppIcon;
       
  4601             iAppIcon = NULL;
       
  4602             }
       
  4603     
       
  4604         // Set path of bitmap file
       
  4605   	    TParse fileParse;
       
  4606   	    fileParse.Set( KAmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
  4607     
       
  4608         iAppIcon = AknsUtils::CreateGulIconL( 
       
  4609             AknsUtils::SkinInstance(), 
       
  4610             KAknsIIDQgnPropMceAudioTitle,
       
  4611             fileParse.FullName(),
       
  4612             EMbmAudiomessageQgn_prop_mce_audio_title,
       
  4613             EMbmAudiomessageQgn_prop_mce_audio_title_mask );
       
  4614         SetTitleIconL();   
       
  4615         }
       
  4616     else if ( aType == KEikDynamicLayoutVariantSwitch && Document()->IsLaunched() )
       
  4617         {
       
  4618         //The following does not change the icon but scales it
       
  4619         SetAudioClipIconL( Document()->GetRecordIconStatus() );  
       
  4620         
       
  4621         if ( !iMtm->Entry().Entry().ReadOnly() ) // editor
       
  4622     	    {
       
  4623     	    SetFixedToolbarL( R_AMSEDITOR_APP_TOOLBAR );      	        
       
  4624     	    }
       
  4625     	else
       
  4626     	    {
       
  4627     	    SetFixedToolbarL( R_AMSVIEWER_APP_TOOLBAR );
       
  4628     	    SetViewerToolBarItemVisibilities();
       
  4629     	    }    
       
  4630         SetTitleIconL();   
       
  4631         }
       
  4632      
       
  4633     }
       
  4634 
       
  4635 
       
  4636 // ---------------------------------------------------------
       
  4637 // CAudioMessageAppUi::SetTitleIconL
       
  4638 // ---------------------------------------------------------
       
  4639 //
       
  4640 void CAudioMessageAppUi::SetTitleIconL()
       
  4641     {
       
  4642     SetTitleIconSize();
       
  4643     // Create duplicates of the icon to be used
       
  4644     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  4645     CleanupStack::PushL( bitmap );
       
  4646     
       
  4647     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  4648     CleanupStack::PushL( bitmapMask );
       
  4649     
       
  4650     User::LeaveIfError( bitmap->Duplicate( iAppIcon->Bitmap()->Handle() ) );
       
  4651     User::LeaveIfError( bitmapMask->Duplicate( iAppIcon->Mask()->Handle() ) );
       
  4652 
       
  4653     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  4654     iTitlePane->DrawNow();
       
  4655     
       
  4656     CleanupStack::Pop( bitmapMask );
       
  4657     CleanupStack::Pop( bitmap );
       
  4658     }
       
  4659     
       
  4660 // ---------------------------------------------------------
       
  4661 // CAudioMessageAppUi::SetTitleIconSize
       
  4662 //
       
  4663 // Sets the correct size from LAF for title icon
       
  4664 // ---------------------------------------------------------
       
  4665 //
       
  4666 void CAudioMessageAppUi::SetTitleIconSize()
       
  4667     {
       
  4668     TRect mainPane;
       
  4669     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, mainPane );
       
  4670     TAknLayoutRect titleIconPaneLayoutRect;
       
  4671     
       
  4672     if ( AknStatuspaneUtils::StaconPaneActive() )
       
  4673         {
       
  4674         titleIconPaneLayoutRect.LayoutRect( 
       
  4675             mainPane,
       
  4676             AknLayoutScalable_Avkon::title_pane_stacon_g1( 0 ).LayoutLine() );
       
  4677         }
       
  4678     else
       
  4679         {
       
  4680         titleIconPaneLayoutRect.LayoutRect( 
       
  4681             mainPane,
       
  4682             AknLayoutScalable_Avkon::title_pane_g2( 0 ).LayoutLine() );
       
  4683         }
       
  4684     
       
  4685     TSize iconSize = titleIconPaneLayoutRect.Rect().Size();
       
  4686     AknIconUtils::SetSize( iAppIcon->Bitmap(), iconSize, EAspectRatioPreserved );
       
  4687     }    
       
  4688     
       
  4689 // ---------------------------------------------------------
       
  4690 // CAudioMessageAppUi::DoEnterKeyL
       
  4691 // ---------------------------------------------------------
       
  4692 //
       
  4693 TBool CAudioMessageAppUi::DoEnterKeyL()
       
  4694     {
       
  4695     TBool result( EFalse );
       
  4696     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  4697 
       
  4698     if ( ctrl )
       
  4699         {
       
  4700         switch ( ctrl->ControlId() )
       
  4701             {
       
  4702             case EMsgComponentIdAudio:
       
  4703             case EMsgComponentIdImage:
       
  4704                 {
       
  4705                 DoSelectionKeyL();
       
  4706                 result = ETrue;
       
  4707                 break;
       
  4708                 }
       
  4709                 
       
  4710             case EMsgComponentIdFrom:
       
  4711                 {
       
  4712                 MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_VIEWER_SELECTMENU );
       
  4713                 MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  4714                 TRAP_IGNORE(MenuBar()->TryDisplayMenuBarL());
       
  4715                 MenuBar()->SetMenuTitleResourceId( R_AUDIOMESSAGE_MENUBAR );
       
  4716                 MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  4717                 result = ETrue;
       
  4718                 break;
       
  4719                 }
       
  4720                 
       
  4721             default:
       
  4722                 {
       
  4723                 break;
       
  4724                 }
       
  4725             }
       
  4726         }
       
  4727     
       
  4728     return result;
       
  4729     }
       
  4730 
       
  4731 // ---------------------------------------------------------
       
  4732 // CAudioMessageAppUi::CheckFindItemHighlightL
       
  4733 // ---------------------------------------------------------
       
  4734 //
       
  4735 TBool CAudioMessageAppUi::CheckFindItemHighlightL( 
       
  4736     const TKeyEvent& aKeyEvent, TEventCode aType )
       
  4737     {   
       
  4738     TKeyResponse keyResp = EKeyWasNotConsumed;
       
  4739     CMsgExpandableControl* ctrl = NULL;
       
  4740     TBool checkHighlight = EFalse;
       
  4741     
       
  4742     if( iView->FocusedControl() )
       
  4743         {
       
  4744         ctrl = static_cast<CMsgExpandableControl*>( iView->FocusedControl() );
       
  4745         if ( ctrl )
       
  4746         	{	
       
  4747         	if ( ctrl->ControlType() == EMsgAddressControl
       
  4748                 && !ctrl->Editor().SelectionLength()  ) 
       
  4749             {
       
  4750             checkHighlight = ETrue;
       
  4751             }
       
  4752         	else if ( ctrl->ControlType() == EMsgBodyControl )
       
  4753             {       
       
  4754             CItemFinder* itemFinder = iView->ItemFinder();
       
  4755             if ( FocusedControlId() == EMsgComponentIdBody && itemFinder
       
  4756                     && !itemFinder->CurrentSelection().Length() )
       
  4757                 {                                                              
       
  4758                 checkHighlight = ETrue;
       
  4759                 }
       
  4760             }
       
  4761           }
       
  4762         }
       
  4763     
       
  4764     if ( ctrl && checkHighlight )
       
  4765         {
       
  4766         // Check if highlight needs to be restored to editor,
       
  4767         // address/body editor offerkeyevent will handle it
       
  4768         keyResp = ctrl->Editor().OfferKeyEventL( aKeyEvent, aType );
       
  4769         }    
       
  4770 
       
  4771     return ( keyResp == EKeyWasConsumed ? ETrue : EFalse );  
       
  4772     }