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