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