mobilemessaging/mmsui/notviewersrc/NotViewerAppUi.cpp
branchRCL_3
changeset 60 7fdbb852d323
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2004 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:  
       
    15 *       Provides CNotViewerAppUi class methods. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include <featmgr.h>                        // FeatureManager
       
    22 #include <bldvariant.hrh>
       
    23 #include <messagingvariant.hrh>
       
    24 #include <txtrich.h>                        // CRichText
       
    25 #include <eikrted.h>                        // CEikRichTextEditor
       
    26 #include <StringLoader.h>                   // StringLoader (load and format strings from resources)
       
    27 
       
    28 #include <centralrepository.h>    // link against centralrepository.lib
       
    29 #include <CommonUiInternalCRKeys.h>
       
    30 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
    31 #include <CoreApplicationUIsSDKCRKeys.h>
       
    32 
       
    33 #include <AknFepGlobalEnums.h>              // Global Fep enums (ELatin, ENumber)
       
    34 
       
    35 // Base editor stuff
       
    36 #include <MsgBodyControl.h>                 // CMsgBodyControl
       
    37 #include <MsgEditorView.h>                  // CMsgEditorView
       
    38 #include <MsgAddressControl.h>              // CMsgAddressControl
       
    39 #include <MsgAttachmentUtils.h>             // CMsgAttachmentUtils
       
    40 #include <MsgEditorAppUiExtension.h>        // CMsgEditorAppUiExtension
       
    41 
       
    42 // Help
       
    43 #include <csxhelp/mms.hlp.hrh>
       
    44 #include <hlplch.h>                         // For HlpLauncher 
       
    45 
       
    46 // Phone
       
    47 #include <commonphoneparser.h>              // Common phone number validity checker
       
    48 
       
    49 // Contacts
       
    50 #include <cntdef.h>                         // KNullContactId
       
    51 
       
    52 // MUIU stuff
       
    53 #include <MuiuMsvUiServiceUtilities.h>      // Call back to sender
       
    54 #include <muiumsvuiserviceutilitiesinternal.h>
       
    55 
       
    56 #include <MuiuOperationWait.h>              // CMuiuOperationWait
       
    57 #include <akninputblock.h>                  // CAknInputBlock
       
    58 #include <MuiuMsvProgressReporterOperation.h> // CMsvProgressReporterOperation
       
    59 #include <MuiuMsgEmbeddedEditorWatchingOperation.h>
       
    60 
       
    61 // AKN Stuff
       
    62 #include <AknUtils.h>                       // Apac, layout, etc
       
    63 #include <AknsUtils.h>						// AknsUtils
       
    64 #include <aknnotewrappers.h>                // CAknInformationNote
       
    65 #include <applayout.cdl.h> // LAF
       
    66 #include <aknlayoutscalable_avkon.cdl.h>
       
    67 
       
    68 // Client MTM Stuff
       
    69 #include <mmsnotificationclient.h>          // CMmsClientMtm
       
    70 #include <mtmuidef.hrh>                     // EMtmUiFlagEditorPreferEmbedded
       
    71 #include <mmsgenutils.h>                    // TMmsGenUtils
       
    72 #include <mmsmsventry.h>                    // TMmsMsvEntry
       
    73 #include <MtmExtendedCapabilities.hrh>      // function id of MessageInfo
       
    74 
       
    75 // Send As Stuff
       
    76 #include <sendui.h>                         // SendUI (for Reply via SMS)
       
    77 #include <SenduiMtmUids.h>                  // MTM Uids
       
    78 #include <CMessageData.h>
       
    79 
       
    80 // Find item
       
    81 #include <FindItemmenu.rsg>                 // Find item stuff
       
    82 #include <finditemmenu.h>                   //
       
    83 #include <finditemdialog.h>                 //
       
    84 #include <finditem.hrh>
       
    85 #include <ItemFinder.h>
       
    86 
       
    87 #ifdef RD_SCALABLE_UI_V2
       
    88 #include <akntoolbar.h>
       
    89 #endif
       
    90 
       
    91 #include <aknnavi.h>                        // CAknNavigationControlContainer
       
    92 #include <aknnavide.h>                      // CAknNavigationDecorator
       
    93 #include <akntabgrp.h>                      // CAknTabGroup
       
    94 #include <akntitle.h>
       
    95 #include <mmserrors.h>
       
    96 #include <mmsregisteredapplications.h>
       
    97 #include <mmssettings.h>
       
    98 
       
    99 #include <mmsui.mbg>                        // Bitmap identifiers
       
   100 #include <data_caging_path_literals.hrh>    // KDC_APP_BITMAP_DIR
       
   101 #include "MmsMtmConst.h"
       
   102 #include "NotMtmUi.h"                       // Notification MTM UI
       
   103 #include "NotMtmUiData.h"                   // Notification MTM UI Data
       
   104 #include "NotViewerAppUi.h"
       
   105 #include "NotViewerDocument.h"
       
   106 #include "NotViewer.hrh"
       
   107 #include <NotViewer.rsg>
       
   108 #include <uniaddresshandler.h>
       
   109 #include "MmsSettingsHandler.h"
       
   110 #include <msgvoipextension.h>
       
   111 #include <textresolver.h>
       
   112 
       
   113 // CONSTANTS
       
   114 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   115 const TUint KNaviGranularity = 2;
       
   116 const TInt KIconDefaultColor = 0;
       
   117 #endif
       
   118 _LIT( KMmsUiMbmFile, "mmsui.mbm" );
       
   119 
       
   120 const TInt KDateSize            = 30;
       
   121 const TInt KMaxDetailsLength    = 64;   // Copy max this many chars to TMsvEntry iDetails
       
   122 const TInt KReplyToSenderSize = 2048;
       
   123 // Exit time when using CIdle to close the application
       
   124 const TInt KDelayedExitDelay = 2500000;
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CNotViewerAppUi
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 CNotViewerAppUi::CNotViewerAppUi() :
       
   131     iIdle( NULL ),
       
   132     iAbsorber( NULL ),
       
   133     iOperation( NULL ),
       
   134     iSenderType( EMuiuAddressTypeNone ), 
       
   135     iFlags(0),
       
   136     iMsgId( 0 )
       
   137     {
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // ~CNotViewerAppUi
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 CNotViewerAppUi::~CNotViewerAppUi()
       
   145     {
       
   146     FeatureManager::UnInitializeLib();
       
   147     delete iOperation;
       
   148     if (    iView
       
   149         &&  !( iFlags & ENotViewerIsNotification ) )
       
   150         {   // FR mode
       
   151         if ( !( iMtm->Entry( ).Entry( ).ReadOnly( ) ) )
       
   152             { // FR in edit mode
       
   153             CMsgAddressControl* to = 
       
   154                 static_cast<CMsgAddressControl*>( iView->ControlById( EMsgComponentIdTo ) );
       
   155             if ( to )
       
   156                 { // Lets save the current input mode to shared data
       
   157                 TInt inputMode = to->Editor().AknEditorCurrentInputMode();
       
   158                 iMuiuSettRepository->Set( KMuiuToInputMode, inputMode );
       
   159                 }        
       
   160             }
       
   161         }
       
   162     if ( iNotifyHandler )
       
   163         {        
       
   164         iNotifyHandler->StopListening();
       
   165         }
       
   166     delete iNotifyHandler;
       
   167     delete iCUiRepository;
       
   168     delete iMuiuSettRepository;
       
   169 
       
   170     delete iIdle;
       
   171     delete iAbsorber;
       
   172     delete iSendUi;
       
   173     delete iFindItemMenu;
       
   174 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   175     delete iNaviDecorator;
       
   176 #endif
       
   177     delete iMsgVoIPExtension;
       
   178 	delete iAlias;
       
   179     delete iAddressHandler;
       
   180     delete iSettingsHandler;
       
   181     delete iAppIcon;
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // ConstructL
       
   186 // ---------------------------------------------------------
       
   187 //
       
   188 void CNotViewerAppUi::ConstructL()
       
   189     {
       
   190     LOGTEXT(_L8("NotViewerAppUi: Construct start"));
       
   191     CMsgEditorAppUi::ConstructL(); // Constructor of the base class
       
   192 
       
   193     // Disable task swapper from options menu during launch
       
   194     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
       
   195 
       
   196 	FeatureManager::InitializeLibL();
       
   197 
       
   198 	if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   199 		{
       
   200 		iFlags |= ENotViewerFlagsHelp;
       
   201 		}
       
   202 		
       
   203     // KFeatureIdMmsNonDestructiveForward has been deprecated
       
   204     // Check of TMsvEntry::iMtmData2 & KMmsStoredInMMBox replaces it. 
       
   205     // MMSEngine sets KMmsStoredInMMBox for received notifications
       
   206     
       
   207     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   208         {
       
   209         iFlags |= ENotViewerOffline;
       
   210         }    
       
   211     if ( FeatureManager::FeatureSupported( KFeatureIdAudioMessaging ) )
       
   212         {
       
   213         iFlags |= ENotViewerAudioMessaging;
       
   214         }
       
   215 
       
   216     iMtm = &(Document()->Mtm());
       
   217     if ( !iMtm )
       
   218         {
       
   219         User::Leave( KErrBadHandle );
       
   220         }
       
   221     
       
   222     iSettingsHandler = CMmsSettingsHandler::NewL( *iMtm );
       
   223 
       
   224 #ifndef RD_SCALABLE_UI_V2
       
   225     iView = CMsgEditorView::NewL( *this, CMsgEditorView::EMsgReadOnly );
       
   226 #endif
       
   227 
       
   228     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   229         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   230     iTitlePane = static_cast<CAknTitlePane*>
       
   231         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   232     iSendUi = CSendUi::NewL();
       
   233 
       
   234     TInt highlight = 0;
       
   235     iMuiuSettRepository = CRepository::NewL( KCRUidMuiuSettings );
       
   236 
       
   237     iCUiRepository = CRepository::NewL( KCRUidCommonUi );
       
   238     iCUiRepository->Get( KCuiAutomaticHighlight, highlight  );
       
   239     iNotifyHandler = CCenRepNotifyHandler::NewL( *this, 
       
   240                                                  *iCUiRepository, 
       
   241                                                  CCenRepNotifyHandler::EIntKey, 
       
   242                                                  KCuiAutomaticHighlight );
       
   243     iNotifyHandler->StartListeningL();
       
   244     
       
   245     if ( highlight == 0 )
       
   246         { // Disable autofind if it's disable in Shared Data 
       
   247         iFlags &= ~ENotViewerAutoFind;
       
   248         }
       
   249     else
       
   250         {
       
   251         iFlags |= ENotViewerAutoFind;
       
   252         }
       
   253 
       
   254     // No other reply types as mms is not possible
       
   255     TInt features( 0 );
       
   256     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
       
   257     repository->Get( KMuiuUniEditorFeatures, features );
       
   258     if ( features & KUniEditorFeatureIdRestrictedReplyMms )
       
   259         {
       
   260         iFlags |= ENotViewerRestrictedReply;
       
   261         }
       
   262     delete repository;
       
   263 
       
   264     LOGTEXT2(_L("CNotViewerAppUi::ConstructL: iFlags 0x%x"), iFlags );
       
   265 
       
   266     iFindItemMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
       
   267     iFindItemMenu->AttachItemFinderMenuL(0);
       
   268 
       
   269 	if( !iEikonEnv->StartedAsServerApp( ) )
       
   270 		{
       
   271 	    Document()->PrepareToLaunchL( this );
       
   272 		}
       
   273 		
       
   274     MenuBar()->SetContextMenuTitleResourceId( R_NOTVIEWER_SELECTIONMENUBAR );
       
   275 
       
   276   	// Set path of bitmap file
       
   277   	TParse fileParse;
       
   278   	fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
   279     
       
   280     iAppIcon = AknsUtils::CreateGulIconL( 
       
   281         AknsUtils::SkinInstance(), 
       
   282         KAknsIIDQgnPropMceMmsTitle,
       
   283         fileParse.FullName(),
       
   284         EMbmMmsuiQgn_prop_mce_mms_title,
       
   285         EMbmMmsuiQgn_prop_mce_mms_title_mask );
       
   286     
       
   287     ApplyFormat(iLabelFormat, iLabelMask, ETrue);
       
   288     ApplyFormat(iValueFormat, iValueMask, EFalse);    
       
   289     LOGTEXT(_L8("NotViewerAppUi: Construct end"));
       
   290     }
       
   291 
       
   292 // ---------------------------------------------------------
       
   293 // LaunchViewL
       
   294 // ---------------------------------------------------------
       
   295 //
       
   296 void CNotViewerAppUi::LaunchViewL()
       
   297     {
       
   298     LOGTEXT(_L8("NotViewerAppUi: LaunchViewL start"));
       
   299     
       
   300     TRAPD( err, iMtm->LoadMessageL() );
       
   301 
       
   302    	if ( err )
       
   303        	{
       
   304        	if ( err != KErrNoMemory )
       
   305            	{
       
   306            	User::Leave( KErrCorrupt );
       
   307            	}
       
   308        	User::Leave( err );
       
   309        	}
       
   310 
       
   311    	GetTypeL( ); // Updates the iFlag
       
   312     
       
   313     SetTitleIconL();   
       
   314 
       
   315 #ifdef RD_SCALABLE_UI_V2
       
   316     if ( AknLayoutUtils::PenEnabled() )
       
   317         {
       
   318         // iToolbar should have been assigned already in HandleForegroundEventL()
       
   319         // If it failed,
       
   320         // - catch it here
       
   321         // - but it means also that some of functionality cannot be fulfilled
       
   322         if ( !iToolbar )
       
   323             {
       
   324             iToolbar = CurrentFixedToolbar();  
       
   325             if ( iToolbar )
       
   326                 {
       
   327                 iToolbar->SetToolbarObserver( this );
       
   328                 }
       
   329             }
       
   330         }
       
   331 
       
   332     if (    iToolbar
       
   333         &&  iToolbar->IsToolbarDisabled() )
       
   334         {
       
   335         iToolbar->DisableToolbarL( EFalse ); 
       
   336         iToolbar->SetToolbarVisibility( ETrue, EFalse );
       
   337         }
       
   338     // Creation of CMsgEditorView must be after toolbar is set visible otherwise layout things can go wrong. 
       
   339     // This has been moved here from ConstructL(). For that reason couple of 'if ( iView &&' checks has been added 
       
   340     // at locations which could use CMsgEditorView very early at startup
       
   341     iView = CMsgEditorView::NewL( *this, CMsgEditorView::EMsgReadOnly );
       
   342 
       
   343 #endif
       
   344 
       
   345     // Editors must not exit due to End key. Flag is set by GetTypeL();
       
   346     if ( ! ( iFlags & ENotViewerIsNotification ) )
       
   347         {
       
   348         SetCloseWithEndKey( EFalse );
       
   349         }
       
   350         
       
   351    	iMsgId = iMtm->Entry( ).Entry( ).Id( );
       
   352 
       
   353     TInt focusedControl = 0;
       
   354 
       
   355 	if( iFlags & ENotViewerIsNotification )
       
   356     	{   // We are in the notification mode
       
   357         focusedControl = EMsgComponentIdFrom;
       
   358         iView->AddControlFromResourceL( 
       
   359         	R_NOTVIEWER_FROM, 
       
   360             EMsgAddressControl, 
       
   361             EMsgAppendControl, 
       
   362             EMsgHeader );
       
   363     	}
       
   364     else
       
   365         {   // we are in the forward request mode
       
   366         focusedControl = EMsgComponentIdTo;
       
   367         iView->AddControlFromResourceL( 
       
   368             R_NOTVIEWER_TO, 
       
   369             EMsgAddressControl, 
       
   370             EMsgAppendControl, 
       
   371             EMsgHeader );
       
   372         CMsgAddressControl* to = AddressControl( );
       
   373 
       
   374         // Remove the auto highlight in FR mode
       
   375         iFlags &= ~ENotViewerAutoFind;
       
   376 
       
   377         TMsvEntry msvEntry = iMtm->Entry( ).Entry( );
       
   378 
       
   379         if( msvEntry.ReadOnly( ) ) // Sent 
       
   380             {
       
   381             to->SetReadOnly( ETrue );
       
   382             }
       
   383         else    // Unsent: To-control must not be read only
       
   384             {
       
   385             to->SetReadOnly( EFalse );
       
   386             TInt inputMode = ENumber;
       
   387 
       
   388             if ( iMuiuSettRepository->Get( KMuiuToInputMode, inputMode ) )
       
   389                 {
       
   390                 inputMode = ENumber;
       
   391                 }
       
   392             to->Editor( ).SetAknEditorCurrentInputMode( inputMode );
       
   393             }
       
   394         UpdateTitlePaneL( ); // Updates the "Forward Request" to Title pane
       
   395         }
       
   396         
       
   397     // Adds the text in message body here
       
   398     if( iFlags & ENotViewerIsNotification )
       
   399         { // We are in the Viewer so lets add from field
       
   400         const TPtrC sender = iMtm->Sender();
       
   401         const TPtrC details = iMtm->Entry().Entry().iDetails;
       
   402         if ( sender.Length() )
       
   403             {
       
   404             iSenderType = MsvUiServiceUtilitiesInternal::ResolveAddressTypeL(    
       
   405                 TMmsGenUtils::PureAddress( sender ),
       
   406                             CommonPhoneParser::ESMSNumber );
       
   407             
       
   408             if ( iSenderType != EMuiuAddressTypePhoneNumber )
       
   409                 {
       
   410                 //We trust on that there won't be illegal addresses
       
   411                 //in received messages
       
   412                 iSenderType = EMuiuAddressTypeEmail;
       
   413                 if ( iFindItemMenu )
       
   414                     {
       
   415                     iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
   416                     }
       
   417                 }
       
   418             CMsgAddressControl* fromControl = AddressControl( );
       
   419 
       
   420             //Check if MMS engine has put an alias into iDetails field
       
   421             if ( sender.Compare( details ) != 0 )
       
   422                 {
       
   423                 TPtrC alias = KNullDesC();
       
   424                 if ( details.Length() && !iAlias )
       
   425                     {
       
   426                     iAlias = details.AllocL( );
       
   427                     alias.Set( *iAlias );
       
   428                     }
       
   429 
       
   430                 // Resolve whether this is remote alias. Local alias takes precedence
       
   431                 TPtrC tempAlias( TMmsGenUtils::Alias( sender ) );
       
   432                 if (    iAlias
       
   433                     &&  tempAlias.Length()
       
   434                     &&  !tempAlias.CompareF( *iAlias ) )
       
   435                     
       
   436                     {
       
   437                     iRemoteAlias = ETrue;
       
   438                     }                    
       
   439 
       
   440                 MVPbkContactLink* link = NULL;
       
   441                 fromControl->AddRecipientL( alias,
       
   442                     TMmsGenUtils::PureAddress( sender ),
       
   443                     ETrue,
       
   444                     link );
       
   445                 }
       
   446             else
       
   447                 {
       
   448                 MVPbkContactLink* link = NULL;
       
   449                 fromControl->AddRecipientL( TMmsGenUtils::Alias( sender ),
       
   450                     TMmsGenUtils::PureAddress( sender ),
       
   451                     ETrue,
       
   452                     link );
       
   453                 }
       
   454             }
       
   455         else
       
   456             {
       
   457             // Leave the address control empty
       
   458             // This should not happen, though
       
   459             }
       
   460         }
       
   461     else
       
   462         {
       
   463         const CMsvRecipientList& addresses = iMtm->AddresseeList();
       
   464 
       
   465         TInt count = addresses.Count();
       
   466         CMsgAddressControl* toControl = AddressControl( );
       
   467 
       
   468         if ( count > 0 )
       
   469             {
       
   470             CMsgRecipientList* recipientList = CMsgRecipientList::NewL();
       
   471             CleanupStack::PushL( recipientList );
       
   472 
       
   473             for ( TInt i = 0; i < count; i++)
       
   474                 {
       
   475                 CMsgRecipientItem* recipient = CMsgRecipientItem::NewLC(
       
   476                     TMmsGenUtils::Alias( addresses[i] ),
       
   477                     TMmsGenUtils::PureAddress( addresses[i] ) );
       
   478                 recipient->SetVerified( ETrue );
       
   479                 recipientList->AppendL( recipient );
       
   480                 CleanupStack::Pop();
       
   481                 recipient = NULL;
       
   482                 }
       
   483             toControl->AddRecipientsL( *recipientList );
       
   484             CleanupStack::PopAndDestroy();
       
   485             }
       
   486         if ( !iMtm->Entry().Entry().ReadOnly( ) )
       
   487             { // Address handler is created only when we have unsent Forward Request
       
   488             iAddressHandler = CUniAddressHandler::NewL( Document()->Mtm(), *toControl, *iCoeEnv );
       
   489             }
       
   490         }
       
   491 
       
   492     // Add the body field stuff
       
   493     if( iFlags & ENotViewerIsNotification )
       
   494         { // We are in the Viewer so lets add message field, too
       
   495         AddMessageFieldL( );
       
   496         }
       
   497     AddSubjectFieldL( );
       
   498     AddTextFieldL( );
       
   499     AddSizeFieldL( );
       
   500     if( iFlags & ENotViewerIsNotification )
       
   501         { // We are in the Viewer so lets add expiry field, too
       
   502         AddExpiryFieldL( );
       
   503         }
       
   504     AddClassFieldL( );
       
   505     AddPriorityFieldL( );
       
   506 
       
   507     if( iFlags & ENotViewerIsNotification )
       
   508         { // We are in the Viewer so Find stuff too
       
   509         SetFindModeL( iFlags & ENotViewerAutoFind );
       
   510 
       
   511         }
       
   512     else
       
   513         {
       
   514         if ( iView->ItemFinder() )
       
   515             {
       
   516 	        iView->ItemFinder()->SetFindModeL(
       
   517                 CItemFinder::ENoneSelected );
       
   518             }
       
   519         }
       
   520 
       
   521     iView->ExecuteL( ClientRect(), focusedControl );
       
   522     InitNavipaneL( );
       
   523 
       
   524     // Enable task swapper to options menu after launch has been completed.
       
   525     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptions );
       
   526 
       
   527 
       
   528     LOGTEXT(_L8("NotViewerAppUi: LaunchViewL end"));
       
   529     }
       
   530 
       
   531 // ---------------------------------------------------------
       
   532 // DynInitMenuPaneL
       
   533 // ---------------------------------------------------------
       
   534 //
       
   535 void CNotViewerAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane )
       
   536     {
       
   537     if ( aMenuPane )
       
   538         {       
       
   539         TInt amountOfItems( aMenuPane->NumberOfItemsInPane() );
       
   540         if ( !Document( )->IsLaunched( )  )
       
   541             {
       
   542             if ( amountOfItems )
       
   543                 {
       
   544                 aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems - 1 );
       
   545                 }
       
   546             return;
       
   547             }
       
   548         switch ( aMenuId )
       
   549             {
       
   550             case R_NOTVIEWER_OPTIONSMENU:
       
   551                 {
       
   552                 DynInitOptionsMenuL( aMenuPane );
       
   553                 break;
       
   554                 }
       
   555             case R_NOTVIEWER_REPLY_SUBMENU:
       
   556                 {
       
   557                 DynInitReplyMenuL( aMenuPane );
       
   558                 break;
       
   559                 }
       
   560             case R_NOTVIEWER_SELECTIONMENU:
       
   561                 {
       
   562                 DynInitContextMenuL( aMenuPane );
       
   563                 break;
       
   564                 }
       
   565             case R_NOTVIEWER_ZOOM_SUBMENU:
       
   566                 {
       
   567                 TInt zoomLevel = KErrGeneral;
       
   568                 iMsgEditorAppUiExtension->
       
   569                     iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, zoomLevel );
       
   570                 switch ( zoomLevel )
       
   571                     {
       
   572                     case EAknUiZoomAutomatic:
       
   573                         aMenuPane->SetItemButtonState(  EMsgDispSizeAutomatic,
       
   574                                                         EEikMenuItemSymbolOn );
       
   575                         break;
       
   576                     case EAknUiZoomNormal:
       
   577                         aMenuPane->SetItemButtonState(  EMsgDispSizeNormal,
       
   578                                                         EEikMenuItemSymbolOn );
       
   579                         break;
       
   580                     case EAknUiZoomSmall:
       
   581                         aMenuPane->SetItemButtonState(  EMsgDispSizeSmall,
       
   582                                                         EEikMenuItemSymbolOn );
       
   583                         break;
       
   584                     case EAknUiZoomLarge:
       
   585                         aMenuPane->SetItemButtonState(  EMsgDispSizeLarge,
       
   586                                                         EEikMenuItemSymbolOn );
       
   587                         break;
       
   588                     default:
       
   589                         break;
       
   590                     }
       
   591                 }
       
   592                 break;
       
   593             default:
       
   594                 {
       
   595                 // this does nothing if we're not, so this is safe
       
   596                 iFindItemMenu->UpdateItemFinderMenuL( aMenuId, aMenuPane );
       
   597                 break;
       
   598                 }
       
   599             }
       
   600         }
       
   601     }
       
   602 
       
   603 // ---------------------------------------------------------
       
   604 // DynInitOptionsMenuL
       
   605 // ---------------------------------------------------------
       
   606 //
       
   607 void CNotViewerAppUi::DynInitOptionsMenuL( CEikMenuPane* aMenuPane )
       
   608     {
       
   609     LOGTEXT(_L8("NotViewerAppUi: DynInitOptionsMenuL start"));
       
   610     if( !(iFlags & ENotViewerFlagsHelp ) )
       
   611         {
       
   612         aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   613         }
       
   614     if (    iFlags & ENotViewerIsNotification )
       
   615         {   // Notification mode        
       
   616         if ( iView  )
       
   617             {      
       
   618             TInt focusedControl = FocusedControlId();                     
       
   619             TBool senderHighlighted = EFalse;
       
   620             
       
   621             if ( focusedControl == EMsgComponentIdFrom )
       
   622                 {
       
   623                 CMsgAddressControl* address = static_cast<CMsgAddressControl*>(
       
   624                     iView->ControlById( EMsgComponentIdFrom ) );
       
   625                 
       
   626                 if ( address && address->Editor().SelectionLength() 
       
   627                         == address->Editor().TextLength() )
       
   628                     {
       
   629                     senderHighlighted = ETrue;
       
   630                     }
       
   631                 }
       
   632         
       
   633             if( ( focusedControl == EMsgComponentIdFrom ) && ( ( iMtm->Sender( ) ).Length() )
       
   634                   && senderHighlighted )
       
   635                 {
       
   636                 iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
   637                 iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );
       
   638                 }
       
   639 	        else
       
   640 	     	    {
       
   641                 iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
   642 		        }
       
   643 		    iFindItemMenu->AddItemFindMenuL( 
       
   644 		        ( iView->ItemFinder() && 
       
   645 		          iView->ItemFinder()->CurrentSelection().Length() ) 
       
   646 		        ? iView->ItemFinder() : 0,
       
   647     			aMenuPane, 
       
   648                 EFindItemMenuPlaceHolder,
       
   649                 senderHighlighted ? 
       
   650                 iMtm->Sender( ) : KNullDesC(),
       
   651                 iAlias && !iRemoteAlias ? ETrue : EFalse, //"Is sender known"
       
   652     			EFalse );
       
   653             }
       
   654 
       
   655         aMenuPane->SetItemDimmed( ENotViewerSend, ETrue );
       
   656         aMenuPane->SetItemDimmed( ENotViewerAddRecipient, ETrue );
       
   657         aMenuPane->SetItemDimmed( ENotViewerCheckNames, ETrue );
       
   658 
       
   659         CNotViewerDocument* doc = Document( );
       
   660 
       
   661         CNotMtmUiData* uiData = &doc->MtmUiDataL( );
       
   662         
       
   663         TMsvEntry entry = iMtm->Entry( ).Entry( );
       
   664 
       
   665         // Note: OperationSupportedL returns 0 if operation is supported,
       
   666         // otherwise it returns some kind of error code
       
   667 
       
   668         if( uiData->OperationSupportedL( KMtmUiFunctionFetchMMS, entry ) )
       
   669             {
       
   670             aMenuPane->SetItemDimmed( ENotViewerRetrieve, ETrue );
       
   671             }
       
   672 
       
   673         if( uiData->OperationSupportedL( KMtmUiFunctionDeleteMessage, entry ) )
       
   674             {
       
   675             aMenuPane->SetItemDimmed( ENotViewerDelete, ETrue );
       
   676             }
       
   677 
       
   678         if( uiData->OperationSupportedL( KMtmUiFunctionForward, entry ) )
       
   679             {
       
   680             aMenuPane->SetItemDimmed( ENotViewerForward, ETrue ); 
       
   681             }
       
   682 
       
   683         if( iMtm->Sender().Length()==0 )
       
   684             {
       
   685             aMenuPane->SetItemDimmed( ENotViewerReplyMenu, ETrue );
       
   686             }
       
   687 
       
   688         }
       
   689     else
       
   690         {   // ForwReq mode
       
   691         aMenuPane->SetItemDimmed( EFindItemMenuPlaceHolder, ETrue );
       
   692         aMenuPane->SetItemDimmed( ENotViewerRetrieve, ETrue );
       
   693         aMenuPane->SetItemDimmed( ENotViewerForward, ETrue );
       
   694         aMenuPane->SetItemDimmed( ENotViewerReplyMenu, ETrue );
       
   695         if ( iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
   696             { // Sent ForwReq
       
   697             aMenuPane->SetItemDimmed( ENotViewerMessageDetails, ETrue );
       
   698             aMenuPane->SetItemDimmed( ENotViewerSend, ETrue );
       
   699             aMenuPane->SetItemDimmed( ENotViewerAddRecipient, ETrue );
       
   700             aMenuPane->SetItemDimmed( ENotViewerCheckNames, ETrue );
       
   701             }
       
   702         else
       
   703             { 
       
   704             // This is not needed when we are in edit mode  
       
   705             // Send is always visible
       
   706             aMenuPane->SetItemDimmed( ENotViewerDelete, ETrue );
       
   707             // Lets check if we need Send or not
       
   708             if ( iView  )
       
   709                 {
       
   710                 CMsgAddressControl* toCtrl = 
       
   711                     static_cast<CMsgAddressControl*>( iView->ControlById( EMsgComponentIdTo ) );
       
   712                 if ( toCtrl && toCtrl->GetRecipientsL()->Count() < 1 )
       
   713                     {
       
   714                     // To field empty -> cannot send.
       
   715                     aMenuPane->SetItemDimmed( ENotViewerCheckNames, ETrue );
       
   716                     }            
       
   717                 }
       
   718             }
       
   719         }
       
   720     LOGTEXT(_L8("NotViewerAppUi: DynInitOptionsMenuL end"));
       
   721     }
       
   722 
       
   723 // ---------------------------------------------------------
       
   724 // DynInitReplyMenuL
       
   725 // ---------------------------------------------------------
       
   726 //
       
   727 void CNotViewerAppUi::DynInitReplyMenuL( CEikMenuPane* aMenuPane )
       
   728     {
       
   729     if( iSenderType == EMuiuAddressTypeNone )
       
   730         {   // If sender type is email, disable SMS
       
   731         aMenuPane->SetItemDimmed( ENotViewerReplyViaMessage, ETrue );
       
   732         }
       
   733 
       
   734     if (    ! ( iFlags & ENotViewerAudioMessaging ) 
       
   735         ||  iFlags & ENotViewerRestrictedReply
       
   736         ||  iSenderType == EMuiuAddressTypeNone )
       
   737         {   
       
   738         aMenuPane->SetItemDimmed( ENotViewerReplyViaAudio, ETrue );
       
   739         }        
       
   740 
       
   741     if ( iSenderType != EMuiuAddressTypeEmail   ||
       
   742          iFlags & ENotViewerRestrictedReply     ||
       
   743          MsvUiServiceUtilitiesInternal::DefaultServiceForMTML(
       
   744             Document()->Session(),
       
   745             KSenduiMtmSmtpUid,
       
   746             ETrue )
       
   747             == KMsvUnknownServiceIndexEntryId )
       
   748         {
       
   749         // "Reply via e-mail" feature
       
   750         aMenuPane->SetItemDimmed( ENotViewerReplyViaMail, ETrue );
       
   751         }
       
   752     }
       
   753 
       
   754 // ---------------------------------------------------------
       
   755 // DynInitContextMenuL
       
   756 // ---------------------------------------------------------
       
   757 //
       
   758 void CNotViewerAppUi::DynInitContextMenuL( CEikMenuPane* aMenuPane )
       
   759     {
       
   760     LOGTEXT(_L8("NotViewerAppUi: DynInitContextMenuL start"));
       
   761     if (  iFlags & ENotViewerIsNotification )
       
   762         {   // Notification
       
   763         if ( iView  )
       
   764             {
       
   765             if( (FocusedControlId( ) == EMsgComponentIdFrom) && ( ( iMtm->Sender( ) ).Length() ) )
       
   766                 {
       
   767                 iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
   768            	    iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );
       
   769            	    }
       
   770 	        else
       
   771 	     	    {
       
   772                 iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
   773 		        }
       
   774 		    iFindItemMenu->AddItemFindMenuL( 
       
   775                 ( FocusedControlId() == EMsgComponentIdBody ) ? iView->ItemFinder() : 0,
       
   776     			aMenuPane, 
       
   777                 EFindItemContextMenuPlaceHolder,
       
   778                 iMtm->Sender(),
       
   779                 iAlias && !iRemoteAlias ? ETrue : EFalse, //"Is sender known"
       
   780     			ETrue );
       
   781             }
       
   782 
       
   783         if( iSenderType == EMuiuAddressTypeNone )
       
   784             {   // If sender type is none, disable Reply menu
       
   785             aMenuPane->SetItemDimmed( ENotViewerReplyMenu, ETrue );
       
   786             }
       
   787         aMenuPane->SetItemDimmed( ENotViewerSend, ETrue );
       
   788         aMenuPane->SetItemDimmed( ENotViewerAddRecipient, ETrue );
       
   789 
       
   790         CNotViewerDocument* doc = Document( );
       
   791 
       
   792         CNotMtmUiData* uiData = &doc->MtmUiDataL( );
       
   793 
       
   794         TMsvEntry entry = iMtm->Entry( ).Entry( );
       
   795 
       
   796         // Note: OperationSupportedL returns 0 if operation is supported,
       
   797         // otherwise it returns some kind of error code
       
   798 
       
   799         if( uiData->OperationSupportedL( KMtmUiFunctionFetchMMS, entry ) )
       
   800             {
       
   801             aMenuPane->SetItemDimmed( ENotViewerRetrieve, ETrue );
       
   802             }
       
   803         }
       
   804     else
       
   805         {   // ForwReq
       
   806         aMenuPane->SetItemDimmed( ENotViewerRetrieve, ETrue );
       
   807         aMenuPane->SetItemDimmed( ENotViewerReplyMenu, ETrue );
       
   808         aMenuPane->SetItemDimmed( EFindItemContextMenuPlaceHolder, ETrue );
       
   809         if ( iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
   810             {
       
   811             aMenuPane->SetItemDimmed( ENotViewerSend, ETrue );
       
   812             aMenuPane->SetItemDimmed( ENotViewerAddRecipient, ETrue );
       
   813             }
       
   814         // else - send key is always available
       
   815         }
       
   816     LOGTEXT(_L8("NotViewerAppUi: DynInitContextMenuL end"));
       
   817     }
       
   818 
       
   819 // ---------------------------------------------------------
       
   820 // HandleKeyEventL
       
   821 // ---------------------------------------------------------
       
   822 //
       
   823 TKeyResponse CNotViewerAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   824     {
       
   825     LOGTEXT(_L8("NotViewerAppUi: HandleKeyEventL start"));
       
   826     if ( !Document()->IsLaunched() || !iView )
       
   827         {
       
   828         return EKeyWasNotConsumed;
       
   829         }
       
   830     if ( aType != EEventKey )
       
   831         {
       
   832         return EKeyWasNotConsumed;
       
   833         }
       
   834     TMsvEntry msvEntry = iMtm->Entry( ).Entry( );
       
   835 
       
   836     switch ( aKeyEvent.iCode )
       
   837         {
       
   838         case EKeyBackspace:
       
   839             {
       
   840             if ( msvEntry.ReadOnly( ) || iFlags & ENotViewerIsNotification )
       
   841                 { // We have either a notification or sent FR open
       
   842                 CNotViewerDocument* doc = Document( );
       
   843                 CNotMtmUiData* uiData = &doc->MtmUiDataL( );
       
   844                 TMsvEntry entry = iMtm->Entry( ).Entry( );
       
   845                 if( !uiData->OperationSupportedL( KMtmUiFunctionDeleteMessage, entry ) )
       
   846                     {
       
   847                     DeleteNotificationL( );
       
   848                     }
       
   849                 // We can consume this because Delete is the only possible function here
       
   850                 return EKeyWasConsumed;
       
   851                 }
       
   852             // else we need to be able to delete characters in To field
       
   853             break;
       
   854             }
       
   855         case EKeyRightArrow:
       
   856             {
       
   857             if ( msvEntry.ReadOnly( ) || iFlags & ENotViewerIsNotification )
       
   858                 { // We have either a notification or sent FR open
       
   859                 if(     iNaviDecorator
       
   860                     &&  IsNextMessageAvailableL( ETrue ) )
       
   861                     {
       
   862                     NextMessageL( ETrue );
       
   863                     }
       
   864                 // We can consume this because Next msg is the only possible function here
       
   865                 return EKeyWasConsumed;
       
   866                 }
       
   867             // else we need to be able to move inside To field
       
   868             break;
       
   869             }
       
   870         case EKeyLeftArrow:
       
   871             {
       
   872             if ( msvEntry.ReadOnly( ) || iFlags & ENotViewerIsNotification )
       
   873                 { // We have either a notification or sent FR open
       
   874                 if(     iNaviDecorator
       
   875                     &&  IsNextMessageAvailableL( EFalse ) )
       
   876                     {
       
   877                     NextMessageL( EFalse );
       
   878                     }
       
   879                 // We can consume this because Next msg is the only possible function here
       
   880                 return EKeyWasConsumed;
       
   881                 }
       
   882             // else we need to be able to move inside To field
       
   883             break;
       
   884             }
       
   885     
       
   886         case EKeyDevice3:       //Selection key
       
   887         case EKeyEnter:         //Enter Key
       
   888             {
       
   889             CMsgExpandableControl* ctrl = NULL;
       
   890             TBool checkHighlight = EFalse;
       
   891             
       
   892             if( iView->FocusedControl() )
       
   893                 {
       
   894                 ctrl = static_cast<CMsgExpandableControl*>( iView->FocusedControl() );
       
   895                 if ( ctrl )
       
   896                 	{
       
   897                 	if ( ctrl->ControlType() == EMsgAddressControl
       
   898                         && !ctrl->Editor().SelectionLength()  ) 
       
   899                     {
       
   900                     checkHighlight = ETrue;
       
   901                     }
       
   902                 	else if ( ctrl->ControlType() == EMsgBodyControl )
       
   903                     {       
       
   904                     CItemFinder* itemFinder = iView->ItemFinder();
       
   905                     if ( FocusedControlId() == EMsgComponentIdBody && itemFinder
       
   906                             && !itemFinder->CurrentSelection().Length() )
       
   907                         {                                                              
       
   908                         checkHighlight = ETrue;
       
   909                         }
       
   910                     }
       
   911                   }
       
   912                 }
       
   913             if ( ctrl && checkHighlight )
       
   914                 {
       
   915                 // Check if highlight needs to be restored to editor,
       
   916                 // address/body editor offerkeyevent will handle it
       
   917                 if ( ctrl->Editor().OfferKeyEventL( aKeyEvent, aType ) 
       
   918                         == EKeyWasConsumed )
       
   919                     {
       
   920                     // Highlight was restored, just return, no cs menu needed
       
   921                     return EKeyWasConsumed;
       
   922                     }
       
   923                 } 
       
   924   
       
   925             if ( DoSelectionKeyL( ) )
       
   926                 {
       
   927                 return EKeyWasConsumed;
       
   928                 }
       
   929             break;  //Lint e527
       
   930             }
       
   931         case EKeyYes:           //Send key
       
   932             {
       
   933             DoHandleSendKeyL( );
       
   934             return EKeyWasConsumed;           
       
   935             }
       
   936         default:
       
   937             break;
       
   938         }
       
   939     return iView->OfferKeyEventL( aKeyEvent, aType );
       
   940     }
       
   941 
       
   942 // ---------------------------------------------------------
       
   943 // HandleCommandL
       
   944 // ---------------------------------------------------------
       
   945 //
       
   946 void CNotViewerAppUi::HandleCommandL( TInt aCommand )
       
   947     {
       
   948     LOGTEXT(_L8("NotViewerAppUi: HandleCommandL start"));
       
   949     if ( aCommand != EEikCmdExit &&
       
   950         ! Document()->IsLaunched() )
       
   951         {
       
   952         return;
       
   953         }
       
   954     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) )
       
   955         {
       
   956         iFindItemMenu->HandleItemFinderCommandL( aCommand );
       
   957         return;
       
   958         }
       
   959     switch ( aCommand )
       
   960         {
       
   961         case ENotViewerRetrieve:
       
   962             {
       
   963             FetchL( );
       
   964             break;
       
   965             }
       
   966         case ENotViewerForward:
       
   967             {
       
   968             DoForwardL( );
       
   969             break;
       
   970             }
       
   971         case ENotViewerSend:
       
   972             {
       
   973             DoHandleSendKeyL( );
       
   974             break;
       
   975             }
       
   976         case ENotViewerReplyViaMessage:
       
   977         case ENotViewerReplyViaAudio:
       
   978         case ENotViewerReplyViaMail:
       
   979             {
       
   980             UniReplyL( aCommand );
       
   981             break;
       
   982             }
       
   983         case ENotViewerAddRecipient:
       
   984             {
       
   985             AddRecipientL( );
       
   986             break;
       
   987             }
       
   988         case ENotViewerCheckNames:
       
   989             {
       
   990             CheckNamesL( );
       
   991             break;
       
   992             }
       
   993         case ENotViewerDelete:
       
   994             {
       
   995             DeleteNotificationL( );
       
   996             break;
       
   997             }
       
   998         case ENotViewerMessageDetails:
       
   999             {
       
  1000             MessageDetailsL( );
       
  1001             break;
       
  1002             }
       
  1003         case EMsgDispSizeAutomatic:
       
  1004         case EMsgDispSizeLarge:
       
  1005         case EMsgDispSizeNormal:
       
  1006         case EMsgDispSizeSmall:
       
  1007             HandleLocalZoomChangeL( (TMsgCommonCommands)aCommand );
       
  1008             break;
       
  1009         case EAknCmdHelp:
       
  1010             {
       
  1011             LaunchHelpL( );
       
  1012             break;
       
  1013             }
       
  1014         case EEikCmdExit:
       
  1015             iExitMode = MApaEmbeddedDocObserver::TExitMode(CMsgEmbeddedEditorWatchingOperation::EMsgExternalExit);        
       
  1016             // Let it flow thru..
       
  1017         case EAknSoftkeyBack:
       
  1018         case EAknSoftkeyClose:
       
  1019         case EAknSoftkeyCancel:
       
  1020             // system exit
       
  1021             Exit( aCommand );
       
  1022             break;
       
  1023         default:
       
  1024             break;
       
  1025         }
       
  1026     LOGTEXT(_L8("NotViewerAppUi: HandleCommandL end"));
       
  1027     }
       
  1028 
       
  1029 // ---------------------------------------------------------
       
  1030 // DoSelectionKeyL
       
  1031 // ---------------------------------------------------------
       
  1032 TBool CNotViewerAppUi::DoSelectionKeyL()
       
  1033     {
       
  1034     if ( iView )
       
  1035         {
       
  1036         CMsgBaseControl* ctrl = iView->FocusedControl();
       
  1037 
       
  1038         if ( ctrl )
       
  1039             {
       
  1040             switch ( FocusedControlId() )
       
  1041                 {
       
  1042                 case EMsgComponentIdTo:
       
  1043                     {
       
  1044                     if( iFlags & ENotViewerIsNotification ) 
       
  1045                         {   // We have a notification, we should handle recipients
       
  1046                         CMsgAddressControl* to = AddressControl( );
       
  1047                         // Check is there any recipients in address ctrl
       
  1048                         TBool modified = EFalse;
       
  1049                         if ( to->GetRecipientsL()->Count() )
       
  1050                             {
       
  1051                             // Recipients found. Verify addresses.
       
  1052                             if ( !VerifyAddressesL( modified ) )
       
  1053                                 {
       
  1054                                 // Illegal address found.
       
  1055                                 modified = ETrue;
       
  1056                                 }
       
  1057                             }
       
  1058                         if ( !modified )//else
       
  1059                             {
       
  1060                             // Nothing changed on the UI. Open PhoneBook.
       
  1061                             AddRecipientL();
       
  1062                             }
       
  1063                         break; // break only if notification
       
  1064                         }
       
  1065                     else // If we are in Forward Request, it's ok to go down to menubar
       
  1066                         {
       
  1067                         return EFalse;
       
  1068                         }
       
  1069                     }
       
  1070                 case EMsgComponentIdFrom:
       
  1071                 case EMsgComponentIdBody:
       
  1072                     {
       
  1073                     MenuBar()->SetMenuTitleResourceId( R_NOTVIEWER_SELECTIONMENUBAR );
       
  1074                     MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1075                     TRAPD( err, MenuBar()->TryDisplayMenuBarL() );
       
  1076                     MenuBar()->SetMenuTitleResourceId( R_NOTVIEWER_MENU );
       
  1077                     MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1078                     User::LeaveIfError( err );
       
  1079                     }
       
  1080                     break;
       
  1081                             
       
  1082                 default:
       
  1083                     break;
       
  1084                 }
       
  1085             }
       
  1086         }
       
  1087     return ETrue;
       
  1088     }
       
  1089 
       
  1090 // ---------------------------------------------------------
       
  1091 // DoHandleSendKeyL
       
  1092 // ---------------------------------------------------------
       
  1093 //
       
  1094 void CNotViewerAppUi::DoHandleSendKeyL()
       
  1095     {
       
  1096     if( iFlags & ENotViewerIsNotification ) 
       
  1097         {   // We have a notification, we should call to sender
       
  1098         CallToNumberL( );
       
  1099         }
       
  1100     else if ( !iMtm->Entry( ).Entry( ).ReadOnly( ) )                                 
       
  1101         {   // We are not-readonly Forward Request -> Send is possible
       
  1102 
       
  1103         // Disable dialer
       
  1104         iAvkonAppUi->SetKeyEventFlags( 
       
  1105               CAknAppUiBase::EDisableSendKeyShort | 
       
  1106               CAknAppUiBase::EDisableSendKeyLong );
       
  1107               
       
  1108         // CallCreationKey: Send message if recipients.
       
  1109         //                  Otherwise fetch recipients
       
  1110         CMsgAddressControl* to = AddressControl();
       
  1111 
       
  1112         if ( to->GetRecipientsL()->Count() > 0 )
       
  1113             {
       
  1114             // has addresses -> Send
       
  1115             SendL();
       
  1116             }
       
  1117         else
       
  1118             {
       
  1119             AddRecipientL();
       
  1120             }
       
  1121         }
       
  1122     }
       
  1123 
       
  1124 // ---------------------------------------------------------
       
  1125 // FetchL
       
  1126 // ---------------------------------------------------------
       
  1127 //
       
  1128 void CNotViewerAppUi::FetchL( )
       
  1129     {
       
  1130     LOGTEXT(_L8("NotViewerAppUi: Fetch start"));
       
  1131     if( !(iFlags & ENotViewerIsNotification) )
       
  1132         {   // We are in forward request
       
  1133         return;
       
  1134         }
       
  1135 
       
  1136     if(     iFlags & ENotViewerOffline 
       
  1137         &&  MsvUiServiceUtilitiesInternal::IsPhoneOfflineL() )
       
  1138         {   // We are in offline at the moment -> Infonote & exit
       
  1139         ShowInformationNoteL( R_NOTVIEWER_OFFLINE_NOT_POSSIBLE, EFalse );
       
  1140 		DoDelayedExitL( KDelayedExitDelay );
       
  1141 		return;
       
  1142         }
       
  1143 
       
  1144     if( !CheckAPSettingsL( ) )
       
  1145         {
       
  1146         return;
       
  1147         }
       
  1148     TTime currentTime;
       
  1149     currentTime.HomeTime( );
       
  1150     TTime expiryTime = iMtm->ExpiryDate( );
       
  1151 	TLocale locale;
       
  1152     expiryTime += locale.UniversalTimeOffset();
       
  1153 	if (locale.QueryHomeHasDaylightSavingOn())          
       
  1154 		{
       
  1155 		TTimeIntervalHours daylightSaving(1);          
       
  1156 		expiryTime += daylightSaving;
       
  1157 		}
       
  1158 
       
  1159     if( currentTime > expiryTime )
       
  1160         {   // Message is expired
       
  1161         if ( !ShowConfirmationQueryL( R_NOTVIEWER_QUEST_MSG_EXPIRED ) )
       
  1162             {   // User did not want to fetch expired message
       
  1163             return;
       
  1164             }
       
  1165         }
       
  1166 
       
  1167     CAknInputBlock* abs = CAknInputBlock::NewLC( );  
       
  1168 
       
  1169     ShowInformationNoteL( R_NOTVIEWER_RETRIEVING_MESSAGE, EFalse );
       
  1170 
       
  1171     TMsvId entryId = iMtm->Entry( ).Entry( ).Id( );
       
  1172     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
  1173 
       
  1174     CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection;
       
  1175     CleanupStack::PushL( sel );
       
  1176 	sel->AppendL( entryId );    
       
  1177     
       
  1178     CMsvOperation* op = iMtm->FetchMessagesL( *sel, wait->iStatus );
       
  1179 
       
  1180     if( !op )
       
  1181         {  
       
  1182         CleanupStack::PopAndDestroy( sel ); // selection
       
  1183         CleanupStack::PopAndDestroy( wait ); // wait
       
  1184         CleanupStack::PopAndDestroy( abs ); // abs
       
  1185         return; 
       
  1186         }
       
  1187 
       
  1188     CleanupStack::PushL( op );
       
  1189     wait->Start();
       
  1190 
       
  1191     // Lets ignore the return value of wait
       
  1192 
       
  1193     CleanupStack::PopAndDestroy( op ); // op 
       
  1194     CleanupStack::PopAndDestroy( sel ); // selection
       
  1195     CleanupStack::PopAndDestroy( wait ); // wait
       
  1196     CleanupStack::PopAndDestroy( abs ); // abs
       
  1197     LOGTEXT(_L8("NotViewerAppUi: Fetch end"));
       
  1198     // Let information note time to exit
       
  1199     DoDelayedExitL( KDelayedExitDelay );
       
  1200     }
       
  1201 
       
  1202 // ---------------------------------------------------------
       
  1203 // DoForwardL
       
  1204 // ---------------------------------------------------------
       
  1205 //
       
  1206 void CNotViewerAppUi::DoForwardL( )
       
  1207     {
       
  1208     LOGTEXT(_L8("NotViewerAppUi: ForwardL start"));
       
  1209     if( !(iFlags & ENotViewerIsNotification) )
       
  1210         {   // We are in forward request
       
  1211         return;
       
  1212         }
       
  1213 
       
  1214     // Lets check the disk space
       
  1215     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(
       
  1216         Document()->Session( ),
       
  1217         KReplyToSenderSize ) )
       
  1218         {
       
  1219         User::Leave( KErrDiskFull );
       
  1220         }
       
  1221 
       
  1222     if( !CheckAPSettingsL( ) )
       
  1223         {
       
  1224         return;
       
  1225         }
       
  1226 
       
  1227     TTime currentTime;
       
  1228     currentTime.HomeTime( );
       
  1229     TTime expiryTime = iMtm->ExpiryDate( );
       
  1230 	TLocale locale;
       
  1231     expiryTime += locale.UniversalTimeOffset();
       
  1232 	if (locale.QueryHomeHasDaylightSavingOn())          
       
  1233 		{
       
  1234 		TTimeIntervalHours daylightSaving(1);          
       
  1235 		expiryTime += daylightSaving;
       
  1236 		}
       
  1237 
       
  1238     if( currentTime > expiryTime )
       
  1239         {   // Message is expired
       
  1240         if ( !ShowConfirmationQueryL( R_NOTVIEWER_QUEST_MSG_EXPIRED ) )
       
  1241             {   
       
  1242             // User did not want to forward expired message
       
  1243             return;
       
  1244             }
       
  1245         }
       
  1246     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  1247     if( ! ( entry.iMtmData2 & KMmsStoredInMMBox ) )
       
  1248         {   // Query, if multiple forward is not possible
       
  1249         if ( !ShowConfirmationQueryL( R_NOTVIEWER_QUEST_FORWARD_NOTIF ) )
       
  1250             {   
       
  1251             // User did not want forward message, as it cannot not be fetched to the phone after that
       
  1252             return;
       
  1253             }
       
  1254         }
       
  1255 
       
  1256     TRAPD ( error,
       
  1257         {
       
  1258         ForwardL( Document()->DefaultMsgFolder() );  //Draft
       
  1259         } ); //end TRAP
       
  1260     if ( error )
       
  1261         {
       
  1262         User::Leave( error );
       
  1263         }
       
  1264     iMtm->Entry( ).SetEntryL( iMsgId );
       
  1265     TRAP_IGNORE( iMtm->LoadMessageL( ) );
       
  1266     EntryChangedL( );
       
  1267     LOGTEXT(_L8("NotViewerAppUi: ForwardL end"));
       
  1268     }
       
  1269 
       
  1270 // ---------------------------------------------------------
       
  1271 // SendL
       
  1272 // ---------------------------------------------------------
       
  1273 //
       
  1274 void CNotViewerAppUi::SendL( )
       
  1275     {
       
  1276     LOGTEXT(_L8("NotViewerAppUi: SendL start"));
       
  1277     if( iFlags & ENotViewerIsNotification )
       
  1278         {   // We are in notification
       
  1279         return;
       
  1280         }
       
  1281     TBool dummy;
       
  1282     if ( !VerifyAddressesL( dummy ) )
       
  1283         {
       
  1284         return;
       
  1285         }
       
  1286 
       
  1287     // For eating key presses
       
  1288     CAknInputBlock* abs = CAknInputBlock::NewLC( );
       
  1289 
       
  1290     DoSaveL( );
       
  1291 
       
  1292     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
  1293     CMsvOperation* op = iMtm->SendL( wait->iStatus );
       
  1294 
       
  1295     if( !op )
       
  1296         {
       
  1297         CleanupStack::PopAndDestroy( wait );
       
  1298         CleanupStack::PopAndDestroy( abs ); 
       
  1299         return;
       
  1300         }
       
  1301 
       
  1302     CleanupStack::PushL( op );
       
  1303     wait->Start();
       
  1304    
       
  1305     // Let's ignore the return value of wait
       
  1306 
       
  1307     CleanupStack::PopAndDestroy( 2 ); // op, wait
       
  1308 
       
  1309     CleanupStack::PopAndDestroy( abs ); 
       
  1310     if(     iFlags & ENotViewerOffline 
       
  1311         &&  MsvUiServiceUtilitiesInternal::IsPhoneOfflineL() )
       
  1312         {   // We are in offline at the moment -> Infonote
       
  1313         ShowInformationNoteL( R_NOTVIEWER_SAVED_OUTBOX, EFalse );
       
  1314         DoDelayedExitL( KDelayedExitDelay  );
       
  1315         LOGTEXT(_L8("NotViewerAppUi: Offline SendL end"));
       
  1316         return;
       
  1317         }
       
  1318 
       
  1319     LOGTEXT(_L8("NotViewerAppUi: SendL end"));
       
  1320     Exit( EAknSoftkeyBack );
       
  1321     }
       
  1322 
       
  1323 // ---------------------------------------------------------
       
  1324 // UniReplyL
       
  1325 // ---------------------------------------------------------
       
  1326 //
       
  1327 void CNotViewerAppUi::UniReplyL( TInt aCommand )
       
  1328     {
       
  1329     LOGTEXT(_L8("NotViewerAppUi: ReplyL start"));
       
  1330     if( !(iFlags & ENotViewerIsNotification) )
       
  1331         {   // We are in forward request
       
  1332         return;
       
  1333         }
       
  1334 
       
  1335     // Lets check the disk space
       
  1336     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(
       
  1337         Document()->Session( ),
       
  1338         KReplyToSenderSize ) )
       
  1339         {
       
  1340         User::Leave( KErrDiskFull );
       
  1341         }
       
  1342 
       
  1343     CMessageData* msgData = CMessageData::NewLC();
       
  1344 
       
  1345     const TPtrC sender = iMtm->Sender();
       
  1346     
       
  1347     if ( sender != KNullDesC() )
       
  1348         {
       
  1349 		TMsvEntry entry = iMtm->Entry().Entry();
       
  1350 
       
  1351 	    if ( sender.Compare( entry.iDetails ) )
       
  1352 	        {
       
  1353 	        msgData->AppendToAddressL( TMmsGenUtils::PureAddress( sender ), *iAlias );
       
  1354 	        }
       
  1355 	    else
       
  1356 	        {
       
  1357 		    msgData->AppendToAddressL( 	TMmsGenUtils::PureAddress( sender ), 
       
  1358 		        						TMmsGenUtils::Alias( sender ) );
       
  1359 	        }
       
  1360         }
       
  1361         
       
  1362     // audio message has not subject field
       
  1363     if( aCommand != ENotViewerReplyViaAudio ) 
       
  1364         {
       
  1365         HBufC* prefixSubject = CreateSubjectPrefixStringL( iMtm->SubjectL(), ETrue );
       
  1366         CleanupStack::PushL( prefixSubject ); 
       
  1367         if ( prefixSubject )
       
  1368             {
       
  1369             msgData->SetSubjectL( prefixSubject );
       
  1370             }
       
  1371         else
       
  1372             {
       
  1373             TPtrC subjectDes = iMtm->SubjectL();
       
  1374             msgData->SetSubjectL( &subjectDes );
       
  1375             }
       
  1376         CleanupStack::PopAndDestroy( prefixSubject ); 
       
  1377         }
       
  1378 
       
  1379 
       
  1380     TUid mtmUid = KSenduiMtmUniMessageUid;
       
  1381     switch ( aCommand )
       
  1382         {
       
  1383         case ENotViewerReplyViaAudio:
       
  1384             mtmUid = KSenduiMtmAudioMessageUid;
       
  1385             break;
       
  1386         case ENotViewerReplyViaMail:
       
  1387             mtmUid = KSenduiMtmSmtpUid;
       
  1388             break;
       
  1389         case ENotViewerReplyViaMessage:
       
  1390         default:
       
  1391 	     if( iFlags & ENotViewerRestrictedReply  )
       
  1392 	     {
       
  1393             mtmUid = KSenduiMtmMmsUid;
       
  1394 	     }
       
  1395             break;
       
  1396         }
       
  1397         
       
  1398     // And do the sending
       
  1399     TInt error;
       
  1400     TRAP ( error,
       
  1401             {
       
  1402             iSendUi->CreateAndSendMessageL(
       
  1403             mtmUid,
       
  1404             msgData);
       
  1405             } ); //TRAP
       
  1406 
       
  1407     CleanupStack::PopAndDestroy( msgData ); // msgData
       
  1408 
       
  1409     if ( error )
       
  1410         {
       
  1411         iMtm->Entry( ).SetEntryL( iMsgId );
       
  1412         TRAP_IGNORE( iMtm->LoadMessageL() );
       
  1413         EntryChangedL( );
       
  1414         LOGTEXT(_L8("NotViewerAppUi: Reply end error"));
       
  1415         User::Leave( error );
       
  1416         }
       
  1417 	else
       
  1418 		{
       
  1419         LOGTEXT(_L8("NotViewerAppUi: Reply end success"));
       
  1420 		if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1421             {
       
  1422             Exit( EAknSoftkeyBack );
       
  1423             }
       
  1424 		}
       
  1425     }
       
  1426 
       
  1427 // ---------------------------------------------------------
       
  1428 // DeleteNotificationL
       
  1429 // ---------------------------------------------------------
       
  1430 //
       
  1431 void CNotViewerAppUi::DeleteNotificationL()
       
  1432     {
       
  1433     LOGTEXT(_L8("NotViewerAppUi: Delete start"));
       
  1434     __ASSERT_DEBUG( iOperation == NULL, Panic( ENotViewerOperationNotFinished ) );
       
  1435     CMsgEditorDocument* doc = Document( );
       
  1436     CNotMtmUi* uiMtm = static_cast<CNotMtmUi*>( &doc->MtmUi( ) );
       
  1437 
       
  1438 
       
  1439     if( iFlags & ENotViewerIsNotification )
       
  1440         { // This is a notification -> lets see if we have options
       
  1441         LOGTEXT(_L8("NotViewerAppUi: Delete: We r dealing with a notification"));
       
  1442 
       
  1443         TBool inboxNotification = EFalse;   
       
  1444 
       
  1445         if( iMtm->Entry().Entry().Parent() == KMsvGlobalInBoxIndexEntryId )
       
  1446             {// Are we in Inbox now
       
  1447             inboxNotification = ETrue;
       
  1448             LOGTEXT(_L8("NotViewerAppUi: Delete: in Inbox"));
       
  1449             }
       
  1450           
       
  1451         if( inboxNotification && uiMtm->DeleteQueryRequiredByMtm( ) && !AlreadyDeletedFromServer( ) )
       
  1452             { // We are in Inbox, delete options supported and not deleted from server
       
  1453             LOGTEXT(_L8("NotViewerAppUi: Delete: Lets show the delete options"));
       
  1454             TInt index = 0;
       
  1455 
       
  1456             CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &index );
       
  1457             dlg->PrepareLC( R_NOTVIEWER_DELETE_FROM_QUERY );
       
  1458 
       
  1459             // Populate list query array
       
  1460             CDesCArrayFlat *array = new(ELeave) CDesCArrayFlat(2);
       
  1461             CleanupStack::PushL(array);
       
  1462             HBufC* buf = StringLoader::LoadLC( R_NOTVIEWER_DELETE_QUERY_REMOTEONLY );
       
  1463             array->AppendL( *buf );
       
  1464             CleanupStack::PopAndDestroy(); //buf
       
  1465             buf = StringLoader::LoadLC( R_NOTVIEWER_DELETE_QUERY_BOTHLOCALANDREMOTE );
       
  1466             array->AppendL( *buf );
       
  1467             CleanupStack::PopAndDestroy(); //buf
       
  1468             dlg->SetItemTextArray( array );
       
  1469             CleanupStack::Pop(); //array
       
  1470 
       
  1471             LOGTEXT(_L8("NotViewerAppUi: Delete: Next asks the delete options"));
       
  1472             TInt queryOk = dlg->RunLD();
       
  1473             if( queryOk )
       
  1474                 {
       
  1475                 /* list query approved, index is usable to see what list item was selected */
       
  1476                 if( index == 0 )
       
  1477                     {
       
  1478                     iFlags &= ~ENotViewerDeleteBoth;
       
  1479                     LOGTEXT(_L8("NotViewerAppUi: Delete: Just the server"));
       
  1480                     }
       
  1481                 else
       
  1482                     { // If action withe server was selected, keep it in mind
       
  1483                     iFlags |= ENotViewerDeleteBoth;
       
  1484                     LOGTEXT(_L8("NotViewerAppUi: Delete: Both ones"));
       
  1485                     }
       
  1486                 // The deletion process starts a bit later
       
  1487                 }
       
  1488             else
       
  1489                 {
       
  1490                 // list query was cancelled -> just return
       
  1491             LOGTEXT(_L8("NotViewerAppUi: Delete: Query cancelled"));
       
  1492                 return;
       
  1493                 }
       
  1494             }
       
  1495         else
       
  1496             { // In this case we need just a query "Delete message?"
       
  1497             LOGTEXT(_L8("NotViewerAppUi: Delete: Show just Delete message?"));
       
  1498             if( ShowConfirmationQueryL( R_NOTVIEWER_QUEST_DELETE_MESSAGE ) )
       
  1499                 { // Delete message confirmed
       
  1500                 LOGTEXT(_L8("NotViewerAppUi: Delete: Answered Yes"));
       
  1501                 if( inboxNotification )
       
  1502                     {
       
  1503                     // We are in Inbox, so it means we delete just the local one
       
  1504                     LOGTEXT(_L8("NotViewerAppUi: Delete: Inbox notification again"));
       
  1505                     CAknInputBlock* abs = CAknInputBlock::NewLC( );  
       
  1506     
       
  1507                     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1508                     CleanupStack::PushL( selection );
       
  1509                     selection->AppendL( iMtm->Entry().EntryId() );
       
  1510                 
       
  1511                     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
  1512 
       
  1513                     LOGTEXT(_L8("NotViewerAppUi: Delete: Inbox locl deletion starts"));
       
  1514                     CMsvOperation* deleteop = iMtm->DeleteNotificationL(
       
  1515                                         *selection,
       
  1516                                         EMmsDeleteNotificationOnly,
       
  1517                                         wait->iStatus );
       
  1518 
       
  1519                    LOGTEXT(_L8("NotViewerAppUi: Delete: and goes on.."));
       
  1520                    if( !deleteop )   // Check this just in case
       
  1521                         {  
       
  1522                         CleanupStack::PopAndDestroy( wait ); 
       
  1523                         CleanupStack::PopAndDestroy( selection  ); 
       
  1524                         CleanupStack::PopAndDestroy( abs );
       
  1525                         LOGTEXT(_L8("NotViewerAppUi: Delete: NULL returned"));
       
  1526                         return; 
       
  1527                         }
       
  1528 
       
  1529                     CleanupStack::PushL( deleteop );
       
  1530                     wait->Start();
       
  1531     
       
  1532                     if( wait->iStatus != KErrNone )
       
  1533                         {
       
  1534                         LOGTEXT(_L8("NotViewerAppUi: Delete: Wait->iStatus != KErrNone "));
       
  1535                         CleanupStack::PopAndDestroy( 3 ); // op, wait, sel
       
  1536                         CleanupStack::PopAndDestroy( abs );
       
  1537                         return;
       
  1538                         }
       
  1539 
       
  1540                     // -> no error, we can exit the viewer
       
  1541                     CleanupStack::PopAndDestroy( 3 ); // op, wait, sel
       
  1542                     CleanupStack::PopAndDestroy( abs );
       
  1543                     // This was the local deletion so lets just exit from here
       
  1544                     LOGTEXT(_L8("NotViewerAppUi: Delete: Local delete succesfull - exit"));
       
  1545                 	Exit( EAknSoftkeyBack );
       
  1546                     }
       
  1547                 else
       
  1548                     {
       
  1549                     // else we are in MMBoxFolder and we can continue
       
  1550                     // there we always need action with server and local
       
  1551                     LOGTEXT(_L8("NotViewerAppUi: Delete: We have mmbox notification"));
       
  1552                     iFlags |= ENotViewerDeleteBoth;
       
  1553                     }
       
  1554                 }
       
  1555             else
       
  1556                 { // Answer was NO.
       
  1557                 return;
       
  1558                 }
       
  1559             }
       
  1560         // OK, now we are either in Inbox and chose some action related to server
       
  1561         // or we are in MMBoxView and wanted to delete a message in there..
       
  1562             
       
  1563         if( !CheckAPSettingsL( ) )
       
  1564             { // Are the settings OK
       
  1565             return;
       
  1566             }
       
  1567         LOGTEXT(_L8("NotViewerAppUi: Delete: AP Checked"));
       
  1568         // Just in case to make sure after checking settings
       
  1569         iMtm->Entry( ).SetEntryL( iMsgId );
       
  1570         iMtm->LoadMessageL( );
       
  1571 
       
  1572         if(     iFlags & ENotViewerOffline 
       
  1573             &&  MsvUiServiceUtilitiesInternal::IsPhoneOfflineL() )
       
  1574             {   // We are in offline at the moment -> Infonote and return
       
  1575             ShowInformationNoteL( R_NOTVIEWER_OFFLINE_NOT_POSSIBLE, EFalse );
       
  1576             return;
       
  1577             }
       
  1578         LOGTEXT(_L8("NotViewerAppUi: Delete: Not Offline"));
       
  1579 
       
  1580         // OK, lets go on with the deletion process
       
  1581         CAknInputBlock* abs = CAknInputBlock::NewLC( );  
       
  1582 
       
  1583         CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL(*this);
       
  1584         CleanupStack::PushL(singleOpWatcher);
       
  1585 
       
  1586         CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1587         CleanupStack::PushL( selection );
       
  1588         selection->AppendL( iMtm->Entry().EntryId() );
       
  1589 
       
  1590         CMsvProgressReporterOperation* reporter = 
       
  1591             CMsvProgressReporterOperation::NewL(
       
  1592                 doc->Session(),
       
  1593                 singleOpWatcher->iStatus,
       
  1594                 EMbmAvkonQgn_note_erased );
       
  1595         CleanupStack::PushL(reporter);
       
  1596 
       
  1597         LOGTEXT(_L8("NotViewerAppUi: Delete: Call unscheduled delete"));
       
  1598         CMsvOperation* deleteop = iMtm->UnscheduledDeleteNotificationL(
       
  1599                 *selection,
       
  1600                 EMmsDeleteMMBoxOnly,
       
  1601                 reporter->RequestStatus() );
       
  1602         LOGTEXT(_L8("NotViewerAppUi: Delete: End of call"));
       
  1603         reporter->SetProgressDecoder( *this );
       
  1604         reporter->SetOperationL( deleteop ); // Takes immediate ownership
       
  1605         CleanupStack::Pop( reporter ); //reporter
       
  1606         CleanupStack::PopAndDestroy( selection); // selection ownership moved to reporter?
       
  1607         CleanupStack::Pop( singleOpWatcher );
       
  1608 
       
  1609         iOperation = singleOpWatcher;
       
  1610         LOGTEXT(_L8("NotViewerAppUi: Delete: Set operation"));
       
  1611         iOperation->SetOperation( reporter );
       
  1612 
       
  1613         CleanupStack::PopAndDestroy( abs ); 
       
  1614         }       
       
  1615     else if( !iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  1616         {   // New Forward Request: It's not been saved -> just Exit
       
  1617         if( ShowConfirmationQueryL( R_NOTVIEWER_QUEST_DELETE_MESSAGE ) )
       
  1618             {
       
  1619         	Exit( EAknSoftkeyBack );
       
  1620             }
       
  1621         }
       
  1622     else
       
  1623         {   // We have an open Sent Forward Request open
       
  1624         if( ShowConfirmationQueryL( R_NOTVIEWER_QUEST_DELETE_MESSAGE ) )
       
  1625             {
       
  1626             DeleteAndExitL( );
       
  1627             }
       
  1628         }
       
  1629     LOGTEXT(_L8("NotViewerAppUi: Delete: End"));
       
  1630     }
       
  1631 
       
  1632 // ---------------------------------------------------------
       
  1633 // CallToNumberL
       
  1634 // ---------------------------------------------------------
       
  1635 //
       
  1636 void CNotViewerAppUi::CallToNumberL()
       
  1637     {
       
  1638     if( !(iFlags & ENotViewerIsNotification) )
       
  1639         {   // We are in forward request
       
  1640         return;
       
  1641         }
       
  1642     if ( !iMsgVoIPExtension )
       
  1643         {
       
  1644         iMsgVoIPExtension = CMsgVoIPExtension::NewL();
       
  1645         }
       
  1646   	
       
  1647     TPtrC senderAddr = KNullDesC( );
       
  1648     TPtrC senderAlias = KNullDesC( );
       
  1649     TPtrC focusedAddr = KNullDesC( );
       
  1650     TBool dialerDisabled = EFalse;
       
  1651 
       
  1652     senderAddr.Set( TMmsGenUtils::PureAddress( iMtm->Sender() ) );
       
  1653     if ( iAlias )
       
  1654         {
       
  1655         senderAlias.Set( *iAlias );
       
  1656         }
       
  1657 
       
  1658     if (    FocusedControlId( ) == EMsgComponentIdBody
       
  1659         &&  iView
       
  1660         &&  iView->ItemFinder( ) )
       
  1661         {
       
  1662         const CItemFinder::CFindItemExt& item =
       
  1663             iView->ItemFinder( )->CurrentItemExt( );
       
  1664         if (    item.iItemDescriptor
       
  1665             &&  (   item.iItemType == CItemFinder::EPhoneNumber
       
  1666                 ||  item.iItemType == CItemFinder::EEmailAddress ) )
       
  1667             {
       
  1668             if ( item.iItemType == CItemFinder::EPhoneNumber )
       
  1669                 {
       
  1670                 // Disable dialer
       
  1671                 iAvkonAppUi->SetKeyEventFlags( 
       
  1672                     CAknAppUiBase::EDisableSendKeyShort | 
       
  1673                     CAknAppUiBase::EDisableSendKeyLong );		
       
  1674                 dialerDisabled = ETrue;    
       
  1675                 }
       
  1676             focusedAddr.Set( *(item.iItemDescriptor) );
       
  1677             }
       
  1678         }
       
  1679 
       
  1680     if ( FocusedControlId( ) == EMsgComponentIdFrom && 
       
  1681          senderAddr.Length() &&
       
  1682          iSenderType == EMuiuAddressTypePhoneNumber )    
       
  1683         {
       
  1684         // Disable dialer
       
  1685         iAvkonAppUi->SetKeyEventFlags( 
       
  1686             CAknAppUiBase::EDisableSendKeyShort | 
       
  1687             CAknAppUiBase::EDisableSendKeyLong );	
       
  1688         dialerDisabled = ETrue;
       
  1689         }
       
  1690     // Only when dialer is disabled try placing the call    
       
  1691     if ( dialerDisabled )
       
  1692         {
       
  1693     	MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( 
       
  1694             *iMsgVoIPExtension,
       
  1695             senderAddr,
       
  1696             senderAlias,
       
  1697             focusedAddr,
       
  1698             ETrue,
       
  1699             iEikonEnv );
       
  1700         }
       
  1701     }
       
  1702 
       
  1703 
       
  1704 // ---------------------------------------------------------
       
  1705 // MessageDetailsL
       
  1706 // ---------------------------------------------------------
       
  1707 //
       
  1708 void CNotViewerAppUi::MessageDetailsL( )
       
  1709     {
       
  1710     LOGTEXT(_L8("NotViewerAppUi: Details start"));
       
  1711     //These are not used! They just have to be there.
       
  1712     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1713     CleanupStack::PushL( selection );
       
  1714     TBuf8<1> param;
       
  1715     param.Zero();
       
  1716 
       
  1717     CAknInputBlock::NewLC( );  
       
  1718 
       
  1719     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document() );
       
  1720     
       
  1721     CMsgEditorDocument* doc = Document( );
       
  1722 
       
  1723     CMsgAddressControl* cntrl = AddressControl( );
       
  1724 
       
  1725     if ( !cntrl )
       
  1726         {
       
  1727         return;
       
  1728         }
       
  1729 
       
  1730     CNotMtmUi* uiMtm = static_cast<CNotMtmUi*>( &doc->MtmUi( ) );
       
  1731 
       
  1732     if ( !(iFlags & ENotViewerIsNotification) )
       
  1733         {
       
  1734         // Need to save only if addresses are changed.
       
  1735         if ( cntrl && cntrl->IsModified() )
       
  1736             {
       
  1737             iAddressHandler->CopyAddressesToMtmL( EMsvRecipientTo );
       
  1738             iMtm->SaveMessageL();
       
  1739             }
       
  1740         }
       
  1741     
       
  1742     CMsvOperation* op = uiMtm->InvokeAsyncFunctionL(
       
  1743         KMtmUiFunctionMessageInfo,
       
  1744         *selection,
       
  1745         watch->iStatus,
       
  1746         param );
       
  1747     CleanupStack::Pop(); // watch
       
  1748     Document()->AddSingleOperationL( op, watch );
       
  1749 
       
  1750     CleanupStack::PopAndDestroy( 2 ); // selection, CAknInputBlock
       
  1751     LOGTEXT(_L8("NotViewerAppUi: Details end"));
       
  1752     }
       
  1753 
       
  1754 // ---------------------------------------------------------
       
  1755 // AddRecipientL
       
  1756 // ---------------------------------------------------------
       
  1757 //
       
  1758 void CNotViewerAppUi::AddRecipientL(  )
       
  1759     {
       
  1760     LOGTEXT(_L8("NotViewerAppUi: AddRecipient start"));
       
  1761     if( iFlags & ENotViewerIsNotification )
       
  1762         {   // We are in notification
       
  1763         return;
       
  1764         }
       
  1765 
       
  1766     TBool invalid = EFalse;
       
  1767 
       
  1768     TBool addressesAdded = iAddressHandler->AddRecipientL( invalid );
       
  1769 
       
  1770     if ( addressesAdded )
       
  1771         {
       
  1772 
       
  1773         Document()->SetHeaderModified( ETrue );
       
  1774 
       
  1775         CMsgAddressControl* to = NULL; 
       
  1776         to = AddressControl( ); 
       
  1777 
       
  1778         if ( iView->FocusedControl() != to )
       
  1779             {
       
  1780             // Focus was not in address control -> Move it
       
  1781             iView->SetFocus( EMsgComponentIdTo );
       
  1782             }
       
  1783         }
       
  1784     LOGTEXT(_L8("NotViewerAppUi: AddRecipient end"));
       
  1785     }
       
  1786 
       
  1787 
       
  1788 // ---------------------------------------------------------
       
  1789 // CheckNamesL
       
  1790 // ---------------------------------------------------------
       
  1791 //
       
  1792 void CNotViewerAppUi::CheckNamesL(  )
       
  1793     {
       
  1794     LOGTEXT(_L8("NotViewerAppUi: CheckNamesL start"));
       
  1795     if( iFlags & ENotViewerIsNotification )
       
  1796         {   // We are in notification
       
  1797         return;
       
  1798         }
       
  1799     TBool dummy;
       
  1800     VerifyAddressesL( dummy );
       
  1801     }
       
  1802 
       
  1803 // ---------------------------------------------------------
       
  1804 // VerifyAddressesL
       
  1805 // ---------------------------------------------------------
       
  1806 //
       
  1807 TBool CNotViewerAppUi::VerifyAddressesL( TBool& aModified )
       
  1808     {
       
  1809     LOGTEXT(_L8("NotViewerAppUi: VerifyAddresses start"));
       
  1810     if( iFlags & ENotViewerIsNotification )
       
  1811         {   // We are in notification
       
  1812         return EFalse;
       
  1813         }
       
  1814     aModified = EFalse;
       
  1815     TBool retVal = iAddressHandler->VerifyAddressesL( aModified );
       
  1816     if ( aModified )
       
  1817         {
       
  1818         Document()->SetHeaderModified( ETrue );
       
  1819         }
       
  1820     LOGTEXT(_L8("NotViewerAppUi: VerifyAddressesL end"));
       
  1821     return retVal;
       
  1822     }
       
  1823 
       
  1824 
       
  1825 // ---------------------------------------------------------
       
  1826 // RichText
       
  1827 // ---------------------------------------------------------
       
  1828 //
       
  1829 CRichText& CNotViewerAppUi::RichText() const
       
  1830     {
       
  1831     CMsgBaseControl* baseControl = iView->ControlById( 
       
  1832         EMsgComponentIdBody );
       
  1833     CMsgBodyControl* bodyControl = STATIC_CAST( 
       
  1834         CMsgBodyControl*, 
       
  1835         baseControl );
       
  1836     return bodyControl->TextContent( );
       
  1837     }
       
  1838 
       
  1839 // ---------------------------------------------------------
       
  1840 // DoSaveL
       
  1841 // ---------------------------------------------------------
       
  1842 //
       
  1843 void CNotViewerAppUi::DoSaveL( )
       
  1844     {
       
  1845     LOGTEXT(_L8("NotViewerAppUi: DoSaveL start"));
       
  1846     iMtm = &(Document()->Mtm());
       
  1847     if( !(iFlags & ENotViewerIsNotification) && !iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  1848         {
       
  1849         iAddressHandler->CopyAddressesToMtmL( EMsvRecipientTo );
       
  1850 
       
  1851         iMtm->SaveMessageL();
       
  1852 
       
  1853         TMmsMsvEntry tEntry = static_cast<TMmsMsvEntry>( Document()->Entry() );
       
  1854 
       
  1855         TBuf<KMaxDetailsLength> detailsBuf; 
       
  1856         iAddressHandler->MakeDetailsL( detailsBuf );
       
  1857         tEntry.iDetails.Set( detailsBuf );
       
  1858         if ( !tEntry.EditorOriented() )
       
  1859             {
       
  1860             tEntry.SetEditorOriented( ETrue );
       
  1861             }
       
  1862         tEntry.iDate.UniversalTime();
       
  1863 
       
  1864         if ( !tEntry.Visible() )
       
  1865             {
       
  1866             // Save from close or exit save.
       
  1867             // Message should be visible after save
       
  1868             tEntry.SetVisible( ETrue );
       
  1869             tEntry.SetInPreparation( EFalse );
       
  1870             }
       
  1871         Document()->CurrentEntry().ChangeL( tEntry );
       
  1872 
       
  1873         Document()->SetHeaderModified( EFalse );
       
  1874         }
       
  1875     LOGTEXT(_L8("NotViewerAppUi: DoSaveL end"));
       
  1876     }
       
  1877 
       
  1878 // ---------------------------------------------------------
       
  1879 // DoMsgSaveExitL
       
  1880 // ---------------------------------------------------------
       
  1881 //
       
  1882 void CNotViewerAppUi::DoMsgSaveExitL( )
       
  1883     {
       
  1884     LOGTEXT(_L8("NotViewerAppUi: DoMsgSaveExitL"));
       
  1885 	Exit( EAknSoftkeyBack );
       
  1886 	}
       
  1887     
       
  1888 // ---------------------------------------------------------
       
  1889 // HandleEntryDeletedL
       
  1890 // ---------------------------------------------------------
       
  1891 //
       
  1892 void CNotViewerAppUi::HandleEntryDeletedL()
       
  1893     {
       
  1894     LOGTEXT(_L8("NotViewerAppUi: HandleEntryDeletedL"));
       
  1895 	Exit( EAknSoftkeyBack );
       
  1896     }
       
  1897 
       
  1898 // ---------------------------------------------------------
       
  1899 // HandleEntryChangeL
       
  1900 // ---------------------------------------------------------
       
  1901 //
       
  1902 void CNotViewerAppUi::HandleEntryChangeL()
       
  1903     { // Call EntryChangedL to update the status
       
  1904     LOGTEXT(_L8("NotViewerAppUi: HandleEntryChangeL start"));
       
  1905     if( !( iFlags & ENotViewerIsNotification ) )
       
  1906         {   // We are not in notification mode -> entry change can be ignored
       
  1907         return;
       
  1908         }
       
  1909     iMtm->Entry( ).SetEntryL( iMsgId );
       
  1910     TRAP_IGNORE( iMtm->LoadMessageL() );
       
  1911     EntryChangedL( );
       
  1912     LOGTEXT(_L8("NotViewerAppUi: HandleEntryChangeL end"));
       
  1913     }
       
  1914 
       
  1915 // ---------------------------------------------------------
       
  1916 // AddItemL
       
  1917 // ---------------------------------------------------------
       
  1918 //
       
  1919 void CNotViewerAppUi::AddItemL(const TDesC& aLabel, const TDesC& aValue )
       
  1920     {
       
  1921     if ( aLabel.Length() > 0 )
       
  1922         {
       
  1923         AppendTextL( aLabel , iLabelFormat, iLabelMask );
       
  1924         }
       
  1925 
       
  1926     if ( aValue.Length() > 0 )
       
  1927         {
       
  1928         AppendTextL( aValue , iValueFormat, iValueMask );
       
  1929         }
       
  1930     }
       
  1931 
       
  1932 // ---------------------------------------------------------
       
  1933 // ApplyFormat
       
  1934 // ---------------------------------------------------------
       
  1935 //
       
  1936 void CNotViewerAppUi::ApplyFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TBool aIsLabel)
       
  1937     {
       
  1938     TRect mainPane;
       
  1939     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
       
  1940     TAknLayoutText textLayout;
       
  1941 
       
  1942     if( aIsLabel )
       
  1943         { // Font for headings
       
  1944         textLayout.LayoutText(
       
  1945             mainPane,
       
  1946             AppLayout::Smart_Messages_Line_1( 0 ) );
       
  1947         }
       
  1948     else
       
  1949         { // Font for data
       
  1950         textLayout.LayoutText(
       
  1951             mainPane,
       
  1952             AppLayout::Smart_Messages_Line_2( 0 ) );
       
  1953         }
       
  1954 
       
  1955     aFormat.iFontSpec = textLayout.Font( )->FontSpecInTwips();    
       
  1956     aMask.ClearAll();
       
  1957     aMask.SetAttrib(EAttFontStrokeWeight);
       
  1958     // If following line in use, it disables text zooming
       
  1959     //aMask.SetAttrib(EAttFontHeight);
       
  1960     aMask.SetAttrib(EAttFontTypeface);
       
  1961     }
       
  1962 
       
  1963 // ---------------------------------------------------------
       
  1964 // AppendTextL
       
  1965 // ---------------------------------------------------------
       
  1966 //
       
  1967 void CNotViewerAppUi::AppendTextL( const TDesC& aText,
       
  1968     const TCharFormat& aFormat, 
       
  1969     const TCharFormatMask& aMask )
       
  1970     {
       
  1971     // Create the modifiable descriptor
       
  1972     HBufC* buf = HBufC::NewLC( aText.Length() );
       
  1973     TPtr modifiedText = buf->Des();
       
  1974     modifiedText = aText;
       
  1975     TInt pos(0);
       
  1976 
       
  1977 	AknTextUtils::DisplayTextLanguageSpecificNumberConversion( modifiedText );
       
  1978 
       
  1979     /*
       
  1980     We have three cases, where specific character(s) must be
       
  1981     converted to the CRichText understandable linebreak character
       
  1982     (CEditableText::ELineBreak).
       
  1983     1)  Text contains ascii code linefeed (LF) character 0x0A, which
       
  1984         is converted to linebreak.
       
  1985     2)  Text contains ascii code carrier return (CR) character 0x0D
       
  1986     3)  Text contains both CR and LF characters particularly in this order.
       
  1987         These two characters must be converted to one linebreak.
       
  1988     */
       
  1989     
       
  1990     TUint LF(0x0A); // Linefeed character in ascii set
       
  1991     TUint CR(0x0D); // Carriage return character in ascii set
       
  1992 
       
  1993     // Case 2 and 3
       
  1994     while ( ( pos = modifiedText.Locate( CR ) ) != KErrNotFound ) // Locate CR
       
  1995         {
       
  1996         if ( pos + 1 < modifiedText.Length() && LF == modifiedText[pos + 1] ) // Is the next LF?
       
  1997             {
       
  1998             modifiedText.Delete( pos + 1, 1 ); // Delete if LF
       
  1999             }
       
  2000         modifiedText[pos] = CEditableText::ELineBreak; // Replace CR with linebreak
       
  2001         }
       
  2002 
       
  2003     // Case 1
       
  2004     while ( ( pos = modifiedText.Locate( LF ) ) != KErrNotFound ) // Locate LF
       
  2005         {        
       
  2006         modifiedText[pos] = CEditableText::ELineBreak; // Replace LF with linebreak
       
  2007         }
       
  2008 
       
  2009     // Append the modified text to the richtext.
       
  2010     CRichText& rich = RichText();
       
  2011     
       
  2012     TInt documentPos = rich.DocumentLength();
       
  2013 
       
  2014     // Every time when text is added, the cursor is left at the end of the line.
       
  2015     // When the new text is added we must first add linebreak and then the text
       
  2016     // linebreak is not added if the text is first item.
       
  2017     if ( iFlags & ENotViewerIsNotFirstItem )
       
  2018         {
       
  2019         //Append the linebreak to the end of the richtext.
       
  2020         rich.InsertL(documentPos, CEditableText::ELineBreak);
       
  2021 
       
  2022         }
       
  2023     else
       
  2024         {
       
  2025         iFlags |= ENotViewerIsNotFirstItem;
       
  2026         }
       
  2027 
       
  2028     documentPos = rich.DocumentLength();
       
  2029     rich.SetInsertCharFormatL(aFormat, aMask, documentPos);
       
  2030     rich.InsertL( documentPos, *buf );
       
  2031     rich.CancelInsertCharFormat();
       
  2032     
       
  2033     CleanupStack::PopAndDestroy( buf );
       
  2034     }
       
  2035 
       
  2036 // ---------------------------------------------------------
       
  2037 // CNotViewerAppUi::FocusedControlId
       
  2038 // ---------------------------------------------------------
       
  2039 //
       
  2040 TInt CNotViewerAppUi::FocusedControlId()
       
  2041     {
       
  2042     TInt ret = EMsgComponentIdNull;
       
  2043     if ( iView && iView->FocusedControl() )
       
  2044         {
       
  2045         ret = iView->FocusedControl()->ControlId();
       
  2046         }
       
  2047     return ret;
       
  2048     }
       
  2049 
       
  2050 // ---------------------------------------------------------
       
  2051 // Document
       
  2052 // ---------------------------------------------------------
       
  2053 //
       
  2054 CNotViewerDocument* CNotViewerAppUi::Document() const
       
  2055     {
       
  2056     return static_cast<CNotViewerDocument*>( CMsgEditorAppUi::Document() );
       
  2057     }
       
  2058 
       
  2059 // ---------------------------------------------------------
       
  2060 // LaunchHelpL
       
  2061 // ---------------------------------------------------------
       
  2062 //
       
  2063 void CNotViewerAppUi::LaunchHelpL()
       
  2064     {
       
  2065     LOGTEXT(_L8("NotViewerAppUi: LaunchHelp"));
       
  2066 	if ( iFlags & ENotViewerFlagsHelp )
       
  2067 		{
       
  2068 	    CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL();
       
  2069 		HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
  2070 		}
       
  2071     }
       
  2072 
       
  2073 // ---------------------------------------------------------
       
  2074 // HelpContextL
       
  2075 // ---------------------------------------------------------
       
  2076 //
       
  2077 CArrayFix<TCoeHelpContext>* CNotViewerAppUi::HelpContextL() const
       
  2078     {
       
  2079 	if ( iFlags & ENotViewerFlagsHelp )
       
  2080 		{
       
  2081 	    CArrayFix<TCoeHelpContext>* r = new ( ELeave ) CArrayFixFlat<TCoeHelpContext>(1);
       
  2082 		CleanupStack::PushL( r );     
       
  2083 
       
  2084         if ( iFlags & ENotViewerIsNotification )
       
  2085             {   // Notification mode
       
  2086     	    r->AppendL( TCoeHelpContext( KUidMmsViewer, KMMS_HLP_NOTIFICATION_VIEWER() ) );
       
  2087             }
       
  2088         else
       
  2089             {
       
  2090             if ( iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  2091                 {
       
  2092         	    r->AppendL( TCoeHelpContext( KUidMmsViewer, KMMS_HLP_NOTIFICATION_VIEWER() ) );
       
  2093                 }
       
  2094             else
       
  2095                 {
       
  2096         	    r->AppendL( TCoeHelpContext( KUidMmsViewer, KMMS_HLP_MMS_FWD_REQUEST() ) );
       
  2097                 }
       
  2098             }
       
  2099 		CleanupStack::Pop( r );
       
  2100 		return r;
       
  2101 		}
       
  2102 	return NULL;
       
  2103     }
       
  2104 
       
  2105 // -------------------------------------------------------------
       
  2106 // AddMessageFieldL
       
  2107 // -------------------------------------------------------------
       
  2108 void CNotViewerAppUi::AddMessageFieldL( )
       
  2109     {
       
  2110     LOGTEXT(_L8("NotViewerAppUi: AddMessageField start"));
       
  2111     TInt resourceId = 0;
       
  2112     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2113 
       
  2114     CTextResolver* resolver = CTextResolver::NewLC();
       
  2115     const TDesC& error = resolver->ResolveErrorString( entry.iError, CTextResolver::ECtxNoCtxNoSeparator );
       
  2116     
       
  2117     switch( iMsgStatus )
       
  2118         {
       
  2119         case ENotViewerStatusFailed:
       
  2120             resourceId = R_NOTVIEWER_INFO_FAILED;
       
  2121             break;
       
  2122         case ENotViewerStatusExpired:
       
  2123             resourceId = R_NOTVIEWER_INFO_EXPIRED;
       
  2124             break;
       
  2125         case ENotViewerStatusForwarding:
       
  2126             resourceId = R_NOTVIEWER_INFO_FORWARDING;
       
  2127             break;
       
  2128         case ENotViewerStatusForwarded:
       
  2129             resourceId = R_NOTVIEWER_INFO_FORWARDED;
       
  2130             break;
       
  2131         case ENotViewerStatusNull:
       
  2132         case ENotViewerStatusWaiting:
       
  2133         default:
       
  2134             resourceId = R_NOTVIEWER_INFO_WAITING;
       
  2135             break;
       
  2136         }
       
  2137     HBufC* message = StringLoader::LoadLC( resourceId );
       
  2138     AddItemL( message->Des( ), error );
       
  2139     CleanupStack::PopAndDestroy( 2 ); //message, resolver
       
  2140     LOGTEXT(_L8("NotViewerAppUi: AddMessageField end"));
       
  2141     }
       
  2142 // -------------------------------------------------------------
       
  2143 // AddSubjectFieldL
       
  2144 // -------------------------------------------------------------
       
  2145 void CNotViewerAppUi::AddSubjectFieldL( )
       
  2146     {
       
  2147     LOGTEXT(_L8("NotViewerAppUi: AddSubject start"));
       
  2148     TPtrC subject = iMtm->SubjectL( );
       
  2149     if( subject.Length( ) > 0 )
       
  2150         {
       
  2151         HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_SUBJECT );
       
  2152         AddItemL( label->Des( ), subject );
       
  2153         CleanupStack::PopAndDestroy( label );
       
  2154         }
       
  2155     LOGTEXT(_L8("NotViewerAppUi: AddSubject end"));
       
  2156     }
       
  2157 
       
  2158 // -------------------------------------------------------------
       
  2159 // AddTextFieldL
       
  2160 // -------------------------------------------------------------
       
  2161 //
       
  2162 void CNotViewerAppUi::AddTextFieldL( )
       
  2163     {
       
  2164     LOGTEXT(_L8("NotViewerAppUi: AddText start"));
       
  2165     TPtrC text = iMtm->GetExtendedText( );
       
  2166     if( text.Length( ) > 0 )
       
  2167         {
       
  2168         HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_TEXT );
       
  2169         AddItemL( label->Des( ), text );
       
  2170         CleanupStack::PopAndDestroy( label );
       
  2171         }
       
  2172     LOGTEXT(_L8("NotViewerAppUi: AddText end"));
       
  2173     }
       
  2174 
       
  2175 // -------------------------------------------------------------
       
  2176 // AddExpiryFieldL
       
  2177 // -------------------------------------------------------------
       
  2178 void CNotViewerAppUi::AddExpiryFieldL( )
       
  2179     {
       
  2180     LOGTEXT(_L8("NotViewerAppUi: AddExpiry start"));
       
  2181     HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_EXPIRES );
       
  2182     TTime messageDate = iMtm->ExpiryDate( );
       
  2183 
       
  2184 	TLocale locale;
       
  2185     messageDate += locale.UniversalTimeOffset();
       
  2186 	if (locale.QueryHomeHasDaylightSavingOn())          
       
  2187 		{
       
  2188 		TTimeIntervalHours daylightSaving(1);          
       
  2189 		messageDate += daylightSaving;
       
  2190 		}
       
  2191 
       
  2192     HBufC* dateFormat = StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv );
       
  2193     TBuf<KDateSize> dateString;
       
  2194     messageDate.FormatL( dateString, *dateFormat );
       
  2195     CleanupStack::PopAndDestroy(); //dateFormat
       
  2196 
       
  2197     dateFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv );
       
  2198     TBuf<KDateSize> timeString;
       
  2199     messageDate.FormatL( timeString, *dateFormat );
       
  2200     CleanupStack::PopAndDestroy(); //dateFormat
       
  2201 
       
  2202     CDesC16ArrayFlat* array = new(ELeave) CDesC16ArrayFlat( 2 );
       
  2203     CleanupStack::PushL( array );
       
  2204     array->AppendL( timeString );
       
  2205     array->AppendL( dateString );
       
  2206     HBufC* expiryString = 
       
  2207         StringLoader::LoadLC( R_NOTVIEWER_VALUE_EXPIRES, *array, iCoeEnv );
       
  2208     AddItemL( label->Des( ), expiryString->Des( ) );
       
  2209     CleanupStack::PopAndDestroy( expiryString );
       
  2210     CleanupStack::PopAndDestroy( array );
       
  2211     CleanupStack::PopAndDestroy( label );        
       
  2212     LOGTEXT(_L8("NotViewerAppUi: AddExpiry end"));
       
  2213     }
       
  2214 
       
  2215 // -------------------------------------------------------------
       
  2216 // AddSizeFieldL
       
  2217 // -------------------------------------------------------------
       
  2218 void CNotViewerAppUi::AddSizeFieldL( )
       
  2219     {
       
  2220     LOGTEXT(_L8("NotViewerAppUi: AddSize start"));
       
  2221     TInt size = iMtm->MessageTransferSize( );
       
  2222 
       
  2223     TInt maxSize = static_cast<TInt>( iMtm->MmsSettings().MaximumReceiveSize( ) );
       
  2224     if( maxSize > 0 )
       
  2225         {
       
  2226         if( size > maxSize )
       
  2227             {
       
  2228             size = maxSize;
       
  2229             }
       
  2230         }
       
  2231 
       
  2232     HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_SIZE );
       
  2233 
       
  2234     TBuf<20> sizeString;
       
  2235 
       
  2236     MsgAttachmentUtils::FileSizeToStringL( sizeString, size, ETrue );
       
  2237 
       
  2238     sizeString.Trim();
       
  2239 
       
  2240     AddItemL( label->Des( ), sizeString );
       
  2241     CleanupStack::PopAndDestroy( label );
       
  2242     LOGTEXT(_L8("NotViewerAppUi: AddSize end"));
       
  2243     }
       
  2244 
       
  2245 // -------------------------------------------------------------
       
  2246 // AddClassFieldL
       
  2247 // -------------------------------------------------------------
       
  2248 void CNotViewerAppUi::AddClassFieldL( )
       
  2249     {
       
  2250     LOGTEXT(_L8("NotViewerAppUi: AddClass start"));
       
  2251     TInt msgClass = iMtm->MessageClass( );
       
  2252     TInt resourceId;
       
  2253     switch( msgClass )
       
  2254         {
       
  2255         case EMmsClassPersonal:
       
  2256             {
       
  2257             resourceId = R_NOTVIEWER_VALUE_CLASS_PERSONAL;
       
  2258             break;
       
  2259             }
       
  2260         case EMmsClassAdvertisement:
       
  2261             {
       
  2262             resourceId = R_NOTVIEWER_VALUE_CLASS_ADVERTISEMENT;
       
  2263             break;
       
  2264             }
       
  2265         case EMmsClassInformational:
       
  2266             {
       
  2267             resourceId = R_NOTVIEWER_VALUE_CLASS_INFORMATIVE;
       
  2268             break;
       
  2269             }
       
  2270         default:
       
  2271             {   // In case no class is returned (0), don't add the field
       
  2272             return;
       
  2273             }
       
  2274         }
       
  2275     HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_CLASS );
       
  2276     HBufC* value = StringLoader::LoadLC( resourceId );
       
  2277     AddItemL( label->Des( ), value->Des( ) );
       
  2278     CleanupStack::PopAndDestroy( value );
       
  2279     CleanupStack::PopAndDestroy( label );
       
  2280     LOGTEXT(_L8("NotViewerAppUi: AddClass end"));
       
  2281     }
       
  2282 
       
  2283 // -------------------------------------------------------------
       
  2284 // AddPriorityFieldL
       
  2285 // -------------------------------------------------------------
       
  2286 void CNotViewerAppUi::AddPriorityFieldL( )
       
  2287     {
       
  2288     LOGTEXT(_L8("NotViewerAppUi: AddPriority start"));
       
  2289     TInt msgPri = iMtm->MessagePriority( );
       
  2290     TInt resourceId;
       
  2291     switch( msgPri )
       
  2292         {
       
  2293         case EMmsPriorityLow:
       
  2294             {
       
  2295             resourceId = R_NOTVIEWER_VALUE_PRIORITY_LOW;
       
  2296             break;
       
  2297             }
       
  2298         case EMmsPriorityHigh:
       
  2299             {
       
  2300             resourceId = R_NOTVIEWER_VALUE_PRIORITY_HIGH;
       
  2301             break;
       
  2302             }
       
  2303         case EMmsPriorityNormal:
       
  2304             {
       
  2305             resourceId = R_NOTVIEWER_VALUE_PRIORITY_NORMAL;
       
  2306             break;
       
  2307             }
       
  2308         default:
       
  2309             {   // In case no priority is returned (0), don't add the field
       
  2310             return;
       
  2311             }
       
  2312         }
       
  2313     HBufC* label = StringLoader::LoadLC( R_NOTVIEWER_LABEL_PRIORITY );
       
  2314     HBufC* value = StringLoader::LoadLC( resourceId );
       
  2315     AddItemL( label->Des( ), value->Des( ) );
       
  2316     CleanupStack::PopAndDestroy( value );
       
  2317     CleanupStack::PopAndDestroy( label );
       
  2318     LOGTEXT(_L8("NotViewerAppUi: AddPriority end"));
       
  2319     }
       
  2320 
       
  2321 // ---------------------------------------------------------
       
  2322 // CNotViewerAppUi::ShowConfirmationQueryL
       
  2323 // ---------------------------------------------------------
       
  2324 //
       
  2325 TInt CNotViewerAppUi::ShowConfirmationQueryL( TInt aResourceId ) const
       
  2326     {
       
  2327     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  2328     HBufC* prompt = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  2329     TInt retVal = dlg->ExecuteLD( R_NOTVIEWER_CONFIRMATION_QUERY, *prompt );
       
  2330     CleanupStack::PopAndDestroy( prompt );
       
  2331     return retVal;
       
  2332     }
       
  2333 
       
  2334 // ---------------------------------------------------------
       
  2335 // CNotViewerAppUi::ShowInformationNoteL
       
  2336 // ---------------------------------------------------------
       
  2337 //
       
  2338 void CNotViewerAppUi::ShowInformationNoteL( TInt aResourceID, TBool aWaiting )
       
  2339     {
       
  2340     HBufC* string = NULL;
       
  2341     string = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  2342 
       
  2343     CAknInformationNote* note = new ( ELeave )
       
  2344         CAknInformationNote( aWaiting );
       
  2345     note->ExecuteLD( *string );
       
  2346 
       
  2347     CleanupStack::PopAndDestroy(); //string
       
  2348     }
       
  2349 
       
  2350 // ---------------------------------------------------------
       
  2351 // CNotViewerAppUi::AddressControl
       
  2352 // ---------------------------------------------------------
       
  2353 //
       
  2354 CMsgAddressControl* CNotViewerAppUi::AddressControl( )
       
  2355     {
       
  2356     TInt controlType = 0;
       
  2357     if( iFlags & ENotViewerIsNotification )
       
  2358         {   // We are in notification mode
       
  2359         controlType = EMsgComponentIdFrom;
       
  2360         }
       
  2361     else
       
  2362         {   // we are in the ForwReq mode
       
  2363         controlType = EMsgComponentIdTo;
       
  2364         }
       
  2365     return static_cast<CMsgAddressControl*>( iView->ControlById( controlType ) );
       
  2366     }
       
  2367 
       
  2368 // ---------------------------------------------------------
       
  2369 // CNotViewerAppUi::EntryChangedL
       
  2370 // ---------------------------------------------------------
       
  2371 //
       
  2372 void CNotViewerAppUi::EntryChangedL( )
       
  2373     {
       
  2374     LOGTEXT(_L8("NotViewerAppUi: EntryChangedL start"));
       
  2375     if ( !Document()->IsLaunched() )
       
  2376         {
       
  2377         return;
       
  2378         }
       
  2379 
       
  2380     TNotViewerStatus status = MessageStatus( );
       
  2381     if( iMsgStatus != status )
       
  2382         {
       
  2383         iMsgStatus = status;
       
  2384 
       
  2385         iFlags &= ~ENotViewerIsNotFirstItem;
       
  2386     
       
  2387         CMsgBaseControl* control = iView->RemoveControlL( EMsgComponentIdBody );
       
  2388         delete control;
       
  2389 
       
  2390         CMsgBodyControl* bodyC = CMsgBodyControl::NewL(iView);
       
  2391         iView->AddControlL(bodyC, EMsgComponentIdBody, EMsgAppendControl, EMsgBody);
       
  2392 
       
  2393         AddMessageFieldL( );
       
  2394         AddSubjectFieldL( );
       
  2395         AddTextFieldL( );
       
  2396         AddSizeFieldL( );
       
  2397         if( iFlags & ENotViewerIsNotification )
       
  2398             { // We are in the Viewer so lets add expiry, too
       
  2399             AddExpiryFieldL( );
       
  2400             }
       
  2401         AddClassFieldL( );
       
  2402         AddPriorityFieldL( );
       
  2403 
       
  2404         // without this editor control does not become properly visible
       
  2405         bodyC->Editor( ).NotifyNewDocumentL( );
       
  2406         }
       
  2407 
       
  2408     // update toolbar
       
  2409     if(  iToolbar )   //check to be provided for non-touch devices.
       
  2410         {
       
  2411         CNotViewerDocument* doc = Document( );
       
  2412         CNotMtmUiData* uiData = &doc->MtmUiDataL( );
       
  2413         TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2414 
       
  2415 	    if( iFlags & ENotViewerIsNotification )
       
  2416 	        {
       
  2417 	        // return value 0=> OK, !=0 => NOK
       
  2418             if( uiData->OperationSupportedL( KMtmUiFunctionFetchMMS, entry ) )
       
  2419                 {
       
  2420                 iToolbar->SetItemDimmed(    ENotViewerToolbarRetrieve,
       
  2421                                             ETrue,
       
  2422                                             ETrue );
       
  2423                 }
       
  2424             else
       
  2425                 {                        
       
  2426                 iToolbar->SetItemDimmed(    ENotViewerToolbarRetrieve,
       
  2427                                             EFalse,
       
  2428                                             ETrue );
       
  2429                 }
       
  2430 	        }
       
  2431         }
       
  2432 
       
  2433     LOGTEXT(_L8("NotViewerAppUi: EntryChangedL end"));
       
  2434     }
       
  2435 
       
  2436 // ---------------------------------------------------------
       
  2437 // CNotViewerAppUi::UpdateTitlePaneL
       
  2438 // ---------------------------------------------------------
       
  2439 //
       
  2440 void CNotViewerAppUi::UpdateTitlePaneL( )
       
  2441     {
       
  2442     LOGTEXT(_L8("NotViewerAppUi: UpdateTitle"));
       
  2443     HBufC*  str = StringLoader::LoadLC( R_NOTVIEWER_TITLE_FWD_RQST, iCoeEnv );
       
  2444     CAknTitlePane* title = static_cast<CAknTitlePane*>
       
  2445         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  2446     title->SetTextL( str->Des( ) );
       
  2447     CleanupStack::PopAndDestroy(); //str
       
  2448     if( !iMtm->Entry( ).Entry( ).ReadOnly() )
       
  2449         { // We have a new unsent FR, change CBA too
       
  2450         Cba()->SetCommandSetL( R_NOTVIEWER_SOFTKEYS_FORWARD_OPTIONS_CANCEL__CONTEXTOPTIONS );
       
  2451         Cba()->DrawNow();
       
  2452         }
       
  2453     }
       
  2454 
       
  2455 // ---------------------------------------------------------
       
  2456 // CNotViewerAppUi::MessageStatus
       
  2457 // ---------------------------------------------------------
       
  2458 //
       
  2459 TNotViewerStatus CNotViewerAppUi::MessageStatus( ) const
       
  2460     {
       
  2461     TNotViewerStatus status = ENotViewerStatusNull; 
       
  2462     TTime currentTime;
       
  2463     currentTime.HomeTime( );
       
  2464     TTime expiryTime = iMtm->ExpiryDate( );
       
  2465 	TLocale locale;
       
  2466     expiryTime += locale.UniversalTimeOffset();
       
  2467 	if (locale.QueryHomeHasDaylightSavingOn())          
       
  2468 		{
       
  2469 		TTimeIntervalHours daylightSaving(1);          
       
  2470 		expiryTime += daylightSaving;
       
  2471 		}
       
  2472 
       
  2473     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2474 
       
  2475     if( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) // Notification
       
  2476         {
       
  2477         if(     !( entry.iMtmData2 & KMmsOperationForward ) 
       
  2478             &&   ( entry.iMtmData2 & KMmsOperationFetch )
       
  2479             &&  !( entry.iMtmData2 & KMmsOperationOngoing )  // It's !ongoing
       
  2480             &&   ( entry.iMtmData2 & KMmsOperationFinished ) // It's finished
       
  2481             &&   ( entry.iMtmData2 & KMmsOperationResult || 
       
  2482                    entry.iError ) ) // There's error code
       
  2483             { // Fetch has been failed
       
  2484             status = ENotViewerStatusFailed;
       
  2485             }
       
  2486         else if( currentTime > expiryTime )
       
  2487             {
       
  2488             status = ENotViewerStatusExpired;
       
  2489             }
       
  2490         else if( ( entry.iMtmData2 & KMmsOperationForward )     // It's forward
       
  2491             &&  !( entry.iMtmData2 & KMmsOperationFetch )   // It's not delete
       
  2492             &&   ( entry.iMtmData2 & KMmsOperationOngoing )     // It's ongoing
       
  2493             &&  !( entry.iMtmData2 & KMmsOperationFinished ) )    // It's not finished
       
  2494             { // Message is being forwarded
       
  2495             status = ENotViewerStatusForwarding;
       
  2496             }
       
  2497         else if( ( entry.iMtmData2 & KMmsOperationForward )     // It's forward
       
  2498             &&  !( entry.iMtmData2 & KMmsOperationFetch )   // It's not delete
       
  2499             &&  !( entry.iMtmData2 & KMmsOperationOngoing )     // It's !ongoing
       
  2500             &&   ( entry.iMtmData2 & KMmsOperationFinished )    // It's finished
       
  2501             &&  !( entry.iMtmData2 & KMmsOperationResult ) )    // There was no error
       
  2502             { // Message has been forwarded
       
  2503             status = ENotViewerStatusForwarded;
       
  2504             }
       
  2505         else 
       
  2506             {   // Normal waiting state
       
  2507             status = ENotViewerStatusWaiting;
       
  2508             }
       
  2509         }
       
  2510     
       
  2511     return status;
       
  2512     }
       
  2513 
       
  2514 // ---------------------------------------------------------
       
  2515 // CNotViewerAppUi::GetTypeL
       
  2516 // ---------------------------------------------------------
       
  2517 //
       
  2518 void CNotViewerAppUi::GetTypeL( )
       
  2519     {
       
  2520     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2521 
       
  2522     if( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) // Notification
       
  2523         {
       
  2524         iFlags |= ENotViewerIsNotification;
       
  2525         }
       
  2526     else if( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageForwardReq ) // Forward Request
       
  2527         {
       
  2528         iFlags &= ~ENotViewerIsNotification;
       
  2529         }
       
  2530     else
       
  2531         {
       
  2532         User::Leave( KErrNotSupported); // Unsupported msg type
       
  2533         }
       
  2534     iMsgStatus = MessageStatus( );
       
  2535     }
       
  2536 
       
  2537 // ---------------------------------------------------------
       
  2538 // CNotViewerAppUi::HandleNotifyInt
       
  2539 //
       
  2540 // Notification from central repository
       
  2541 //
       
  2542 // There is no need to check aId as we are listening events 
       
  2543 // only from one key
       
  2544 // ---------------------------------------------------------
       
  2545 //
       
  2546 void CNotViewerAppUi::HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue )
       
  2547     {    
       
  2548     LOGTEXT(_L8("NotViewerAppUi: HandleNotifyInt"));
       
  2549     if( iFlags & ENotViewerIsNotification )
       
  2550         {
       
  2551         if ( aNewValue == 0 )
       
  2552             {
       
  2553             iFlags &= ~ENotViewerAutoFind;
       
  2554             }
       
  2555         else
       
  2556             {
       
  2557             iFlags |= ENotViewerAutoFind;
       
  2558             }
       
  2559         TRAP_IGNORE( SetFindModeL( iFlags & ENotViewerAutoFind ) );
       
  2560         }
       
  2561     }
       
  2562 
       
  2563 // ---------------------------------------------------------
       
  2564 // CNotViewerAppUi::HandleNotifyGeneric
       
  2565 // ---------------------------------------------------------
       
  2566 //
       
  2567 void CNotViewerAppUi::HandleNotifyGeneric( TUint32 /*aId*/ )
       
  2568     {
       
  2569     //Nothing.
       
  2570     }
       
  2571     
       
  2572 // ---------------------------------------------------------
       
  2573 // CNotViewerAppUi::HandleNotifyError
       
  2574 // ---------------------------------------------------------
       
  2575 //
       
  2576 void CNotViewerAppUi::HandleNotifyError( TUint32 /*aId*/, TInt /*error*/, CCenRepNotifyHandler* /*aHandler*/ )
       
  2577     {
       
  2578     //Nothing.
       
  2579     }
       
  2580   
       
  2581 //  
       
  2582 // NOTICE:
       
  2583 //
       
  2584 // Startup observer moved to own class because Publish & Subscribe
       
  2585 // requires an active object for event handling.
       
  2586 //
       
  2587 
       
  2588 // ---------------------------------------------------------
       
  2589 // CNotViewerAppUi::SetFindModeL
       
  2590 // ---------------------------------------------------------
       
  2591 //
       
  2592 void CNotViewerAppUi::SetFindModeL( TBool aEnable )
       
  2593     {
       
  2594     if ( iView )
       
  2595         {
       
  2596         if ( iView->ItemFinder() )
       
  2597             {
       
  2598             TInt findMode = aEnable ?
       
  2599                 CItemFinder::EPhoneNumber |
       
  2600                 CItemFinder::EUrlAddress |
       
  2601                 CItemFinder::EEmailAddress :
       
  2602                 CItemFinder::ENoneSelected;
       
  2603             iView->ItemFinder()->SetFindModeL( findMode );
       
  2604             }
       
  2605         CMsgBaseControl* fromControl = iView->ControlById( EMsgComponentIdFrom );
       
  2606         if ( fromControl && iMtm->Sender().Length() )
       
  2607             {
       
  2608             static_cast<CMsgAddressControl*>( fromControl )
       
  2609                 ->SetAddressFieldAutoHighlight( aEnable );
       
  2610             }
       
  2611         }
       
  2612     }
       
  2613 
       
  2614 // ----------------------------------------------------
       
  2615 // CNotViewerAppUi::OpCompleted
       
  2616 // ----------------------------------------------------
       
  2617 //
       
  2618 void CNotViewerAppUi::OpCompleted(
       
  2619     CMsvSingleOpWatcher& aOpWatcher,
       
  2620     TInt aCompletionCode )
       
  2621     {
       
  2622     LOGTEXT(_L8("NotViewerAppUi: OpCompleted start"));
       
  2623     CMsvOperation* op=&aOpWatcher.Operation();
       
  2624 
       
  2625     if( iOperation )
       
  2626         {
       
  2627         if( iOperation->Operation( ).Id( ) == op->Id( ) )
       
  2628             {
       
  2629             delete iOperation;
       
  2630             iOperation = NULL;
       
  2631             }
       
  2632         else
       
  2633             {
       
  2634             // This should never happen ie. unrecognised operation completed
       
  2635             return;
       
  2636             }
       
  2637         }
       
  2638     else
       
  2639         {
       
  2640         // This should never happen ie. unrecognised operation completed
       
  2641         return;
       
  2642         }
       
  2643 
       
  2644     if ( aCompletionCode == KErrCancel )
       
  2645         {
       
  2646         LOGTEXT(_L8("NotViewerAppUi: OpCompleted end3"));
       
  2647         return;
       
  2648         }
       
  2649 
       
  2650     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2651 
       
  2652     if(      ( entry.iMtmData2 & KMmsOperationFetch )   // Fetch + forward
       
  2653         &&   ( entry.iMtmData2 & KMmsOperationForward ) // == DELETE!
       
  2654         &&   ( entry.iMtmData2 & KMmsOperationFinished ) // It's finished
       
  2655         &&   ( entry.iMtmData2 & KMmsOperationResult ) ) // Error code
       
  2656         {
       
  2657         // Error note here!
       
  2658         TRAP_IGNORE( ShowInformationNoteL( R_NOTVIEWER_REMOTE_DELETE_FAILED, EFalse ) );
       
  2659         // Ignore err
       
  2660         }
       
  2661     else
       
  2662         {
       
  2663         LOGTEXT(_L8("NotViewerAppUi: OpCompleted: First delete successful"));
       
  2664         // If also local chosen, call that and exit
       
  2665         // else show completed note
       
  2666         if( iFlags & ENotViewerDeleteBoth )
       
  2667             { // Deletion was succesfull, but also local delete still needed
       
  2668             TRAPD( err, DoDeleteOpCompletedL( ) );
       
  2669             if( err )
       
  2670                 { // We may not leave as we are in non-leaving function
       
  2671                 delete iAbsorber;
       
  2672                 iAbsorber = NULL;
       
  2673                 }
       
  2674             LOGTEXT(_L8("NotViewerAppUi: OpCompleted end2"));
       
  2675             return;
       
  2676             }
       
  2677         else
       
  2678             {
       
  2679             // MMBox Deletion was succesfull
       
  2680             TRAP_IGNORE( ShowInformationNoteL( R_NOTVIEWER_REMOTE_DELETED, EFalse ) );
       
  2681             // Ignore err 
       
  2682             }
       
  2683         }
       
  2684     LOGTEXT(_L8("NotViewerAppUi: OpCompleted end"));
       
  2685     }
       
  2686 
       
  2687 // ----------------------------------------------------
       
  2688 // CNotViewerAppUi::DoDeleteOpCompletedL
       
  2689 // ----------------------------------------------------
       
  2690 //
       
  2691 void CNotViewerAppUi::DoDeleteOpCompletedL( )
       
  2692     {
       
  2693     LOGTEXT(_L8("NotViewerAppUi: DoDeleteOpCompletedL start"));
       
  2694     iAbsorber = CAknInputBlock::NewLC( );
       
  2695     CleanupStack::Pop(); // Pop the absorber
       
  2696 
       
  2697     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  2698     CleanupStack::PushL( selection );
       
  2699     selection->AppendL( iMtm->Entry().EntryId() );
       
  2700 
       
  2701     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
  2702 
       
  2703     CMsvOperation* deleteop = iMtm->DeleteNotificationL(
       
  2704                         *selection,
       
  2705                         EMmsDeleteNotificationOnly,
       
  2706                         wait->iStatus );
       
  2707 
       
  2708     if( !deleteop )   // Check this just in case
       
  2709         {  
       
  2710         CleanupStack::PopAndDestroy( 2 ); // wait, sel
       
  2711         return; 
       
  2712         }
       
  2713 
       
  2714     CleanupStack::PushL( deleteop );
       
  2715     wait->Start();
       
  2716 
       
  2717     if( wait->iStatus != KErrNone )
       
  2718         {
       
  2719         CleanupStack::PopAndDestroy( 3 ); // op, wait, sel
       
  2720         return;
       
  2721         }
       
  2722 
       
  2723     // -> no error, we can exit the viewer
       
  2724     CleanupStack::PopAndDestroy( 3 ); // op, wait, sel
       
  2725 
       
  2726 	DoDelayedExitL( 0 );
       
  2727     LOGTEXT(_L8("NotViewerAppUi: DoDeleteOpCompleted end"));
       
  2728     return;
       
  2729     }
       
  2730 
       
  2731 //--------------------------------
       
  2732 // DecodeProgress
       
  2733 //--------------------------------
       
  2734 TInt CNotViewerAppUi::DecodeProgress(
       
  2735     const TDesC8& /*aProgress*/, 
       
  2736     TBuf<CBaseMtmUi::EProgressStringMaxLen>& aReturnString, 
       
  2737     TInt& aTotalEntryCount, 
       
  2738     TInt& aEntriesDone,
       
  2739     TInt& aCurrentEntrySize, 
       
  2740     TInt& aCurrentBytesTrans, 
       
  2741     TBool /*aInternal*/ )
       
  2742     {
       
  2743     aCurrentEntrySize = 0;
       
  2744     aCurrentBytesTrans = 0;   
       
  2745     aEntriesDone = 0;
       
  2746     aTotalEntryCount = 0;
       
  2747     StringLoader::Load( aReturnString,
       
  2748                         R_NOTVIEWER_WAIT_DELETING_REMOTE,
       
  2749                         iCoeEnv );
       
  2750     return KErrNone;
       
  2751     }
       
  2752 
       
  2753 // ---------------------------------------------------------
       
  2754 // CNotViewerAppUi::HandleIteratorEventL
       
  2755 // ---------------------------------------------------------
       
  2756 //
       
  2757 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2758 void CNotViewerAppUi::HandleIteratorEventL( TMessageIteratorEvent aEvent )
       
  2759     {
       
  2760     LOGTEXT(_L8("NotViewerAppUi: HandleIteratorEventL"));
       
  2761     if (aEvent == EFolderCountChanged)
       
  2762         {
       
  2763         InitNavipaneL();
       
  2764         }
       
  2765     }
       
  2766 #endif
       
  2767 
       
  2768 // ---------------------------------------------------------
       
  2769 // CNotViewerAppUi::InitNavipaneL
       
  2770 // ---------------------------------------------------------
       
  2771 //
       
  2772 void CNotViewerAppUi::InitNavipaneL()
       
  2773     {
       
  2774     LOGTEXT(_L8("NotViewerAppUi: InitNavipaneL start"));
       
  2775 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2776     if ( !iNaviDecorator )
       
  2777         {
       
  2778         TMsgEditorMsgPriority priority = EMsgEditorMsgPriorityNormal;
       
  2779     
       
  2780         if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
  2781             {
       
  2782             priority = EMsgEditorMsgPriorityHigh;
       
  2783             }
       
  2784         else if ( iMtm->MessagePriority() == EMmsPriorityLow )
       
  2785             {
       
  2786             priority = EMsgEditorMsgPriorityLow;
       
  2787             }        
       
  2788         CreateViewerNaviPaneL( Document()->Entry().iDate, priority, ETrue );
       
  2789         }
       
  2790         
       
  2791     iNaviPane->PushL( *iNaviDecorator );
       
  2792 #else
       
  2793     TMsvEntry msvEntry = iMtm->Entry( ).Entry( );
       
  2794 
       
  2795     if( msvEntry.ReadOnly( ) || iFlags & ENotViewerIsNotification )
       
  2796         // If message is readonly or it is a notification ->
       
  2797         // we need msg ordinal number and scroll arrows visible
       
  2798         {
       
  2799         TInt indexInFolder = 0;
       
  2800         TInt msgsInFolder = 0;
       
  2801         MessageIndexInFolderL( indexInFolder, msgsInFolder );
       
  2802 
       
  2803         if (    indexInFolder < 0
       
  2804             ||  msgsInFolder == 0 )
       
  2805             {
       
  2806             // this may occur when viewer is used in cover ui. Viewer is started as 
       
  2807             // stand alone without current folder and '1/0' would be visible. 
       
  2808             iNaviPane->PushDefaultL( );
       
  2809             return;
       
  2810             }
       
  2811 
       
  2812         CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>(KNaviGranularity);
       
  2813         CleanupStack::PushL( array );
       
  2814         array->AppendL( indexInFolder + 1 );
       
  2815         array->AppendL( msgsInFolder );
       
  2816 
       
  2817         HBufC* buf = StringLoader::LoadLC( R_NOTVIEWER_ORDINAL_NUMBER, *array, iCoeEnv );
       
  2818         CreateTabGroupL( *buf );
       
  2819         CleanupStack::PopAndDestroy( 2 ); //buf, array
       
  2820 
       
  2821         iNaviDecorator->MakeScrollButtonVisible( ETrue );
       
  2822 
       
  2823         //NaviButtons are dimmed by default
       
  2824         if ( IsNextMessageAvailableL( ETrue ) )
       
  2825             {
       
  2826             iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, EFalse );
       
  2827             }
       
  2828         if ( IsNextMessageAvailableL( EFalse ) )
       
  2829             {
       
  2830             iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, EFalse );
       
  2831             }        
       
  2832         }
       
  2833     else    // Unsent FR: Make navipane null
       
  2834         {
       
  2835         CreateTabGroupL( KNullDesC );
       
  2836         }
       
  2837     iNaviPane->PushL( *iNaviDecorator );  // Make it visible
       
  2838 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
       
  2839     LOGTEXT(_L8("NotViewerAppUi: InitNavipaneL end"));
       
  2840     }
       
  2841 
       
  2842 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2843 // ---------------------------------------------------------
       
  2844 // CNotViewerAppUi::CreateTabGroupL
       
  2845 // ---------------------------------------------------------
       
  2846 //
       
  2847 void CNotViewerAppUi::CreateTabGroupL( const TDesC& aText )
       
  2848     {
       
  2849     //Delete (possibly) existing navi decorator
       
  2850     delete iNaviDecorator;
       
  2851     iNaviDecorator = NULL;
       
  2852 
       
  2853     //Create TabGroup
       
  2854     iNaviDecorator = iNaviPane->CreateTabGroupL();
       
  2855     CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>
       
  2856         ( iNaviDecorator->DecoratedControl() );
       
  2857 
       
  2858     
       
  2859     TRect naviPane;
       
  2860     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ENaviPane, naviPane );
       
  2861     
       
  2862     TAknLayoutRect naviTabsPane;
       
  2863     naviTabsPane.LayoutRect( naviPane,
       
  2864                              AknLayoutScalable_Avkon::navi_navi_tabs_pane().LayoutLine() );
       
  2865     
       
  2866     TAknLayoutRect navi2TabsPane;
       
  2867     navi2TabsPane.LayoutRect( naviTabsPane.Rect(),
       
  2868                               AknLayoutScalable_Avkon::navi_tabs_2_pane().LayoutLine() );
       
  2869 
       
  2870     TAknLayoutRect tabs2ActivePane;
       
  2871     tabs2ActivePane.LayoutRect( navi2TabsPane.Rect(),
       
  2872                                 AknLayoutScalable_Avkon::tabs_2_active_pane( 0 ).LayoutLine() );
       
  2873 
       
  2874     TAknLayoutRect tabs2ActivePaneIcon;
       
  2875     tabs2ActivePaneIcon.LayoutRect( tabs2ActivePane.Rect(),
       
  2876                                     AknLayoutScalable_Avkon::tabs_2_active_pane_g1().LayoutLine() );
       
  2877 
       
  2878     TSize indicatorIconSize( tabs2ActivePaneIcon.Rect().Size() );
       
  2879     
       
  2880     CFbsBitmap* bitmapPriority = NULL;
       
  2881 	CFbsBitmap* maskPriority = NULL;
       
  2882     
       
  2883     // Create message priority bitmap
       
  2884     if ( iMtm->MessagePriority() == EMmsPriorityHigh || 
       
  2885          iMtm->MessagePriority() == EMmsPriorityLow )
       
  2886         {
       
  2887         // Set path of bitmap file
       
  2888         TParse fileParse;
       
  2889         fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
  2890         
       
  2891         if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
  2892             {
       
  2893             // Create high priority bitmap
       
  2894             AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
       
  2895                                          KAknsIIDQgnIndiMcePriorityHigh,
       
  2896                                          KAknsIIDQsnIconColors,
       
  2897                                          EAknsCIQsnIconColorsCG7,
       
  2898                                          bitmapPriority,
       
  2899                                          maskPriority,
       
  2900                                          fileParse.FullName(),
       
  2901                                          EMbmMmsuiQgn_indi_mce_priority_high,
       
  2902                                          EMbmMmsuiQgn_indi_mce_priority_high_mask,
       
  2903                                          AKN_LAF_COLOR( KIconDefaultColor ),
       
  2904                                          indicatorIconSize,
       
  2905                                          EAspectRatioPreserved );    
       
  2906             }
       
  2907         else
       
  2908             {
       
  2909             // Create low priority bitmap
       
  2910             AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
       
  2911                                          KAknsIIDQgnIndiMcePriorityLow,
       
  2912                                          KAknsIIDQsnIconColors,
       
  2913                                          EAknsCIQsnIconColorsCG7,
       
  2914                                          bitmapPriority,
       
  2915                                          maskPriority,
       
  2916                                          fileParse.FullName(),
       
  2917                                          EMbmMmsuiQgn_indi_mce_priority_low,
       
  2918                                          EMbmMmsuiQgn_indi_mce_priority_low_mask,
       
  2919                                          AKN_LAF_COLOR( KIconDefaultColor ),
       
  2920                                          indicatorIconSize,                                         
       
  2921                                          EAspectRatioPreserved ); 
       
  2922             }
       
  2923             
       
  2924         if ( !bitmapPriority )            
       
  2925             {
       
  2926             User::Leave( KErrNotFound );
       
  2927             }
       
  2928             
       
  2929         CleanupStack::PushL( bitmapPriority );
       
  2930         CleanupStack::PushL( maskPriority );
       
  2931 
       
  2932         if ( tabGroup->TabCount() == 0 )
       
  2933             {
       
  2934             tabGroup->AddTabL( 0, aText, bitmapPriority, maskPriority );
       
  2935             }
       
  2936         else
       
  2937             {
       
  2938             tabGroup->ReplaceTabL( 0, aText, bitmapPriority, maskPriority );
       
  2939             }
       
  2940 	      
       
  2941     	CleanupStack::Pop( maskPriority );
       
  2942         CleanupStack::Pop( bitmapPriority );
       
  2943         }
       
  2944     else
       
  2945 	    {
       
  2946         if ( tabGroup->TabCount() == 0 )
       
  2947             {
       
  2948 	        tabGroup->AddTabL( 0, aText );	
       
  2949             }
       
  2950         else
       
  2951             {
       
  2952 	        tabGroup->ReplaceTabL( 0, aText );	
       
  2953             }
       
  2954 	    }
       
  2955 	    
       
  2956 	tabGroup->SetActiveTabById( 0 );
       
  2957     tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab );
       
  2958     }
       
  2959 #endif // !RD_MSG_NAVIPANE_IMPROVEMENT
       
  2960 
       
  2961 // ---------------------------------------------------------
       
  2962 // CNotViewerAppUi::AlreadyDeletedFromServer
       
  2963 // ---------------------------------------------------------
       
  2964 //
       
  2965 TBool CNotViewerAppUi::AlreadyDeletedFromServer( )
       
  2966     {
       
  2967     TBool resp = EFalse;
       
  2968     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  2969     if(      ( entry.iMtmData2 & KMmsOperationFetch )   // Fetch + forward
       
  2970         &&   ( entry.iMtmData2 & KMmsOperationForward ) // == DELETE!
       
  2971         &&   ( entry.iMtmData2 & KMmsOperationFinished ) // It's finished
       
  2972         &&  !( entry.iMtmData2 & KMmsOperationResult ) ) // No error code
       
  2973         { // Message fetch has been failed
       
  2974         resp = ETrue;
       
  2975         }
       
  2976     return resp;
       
  2977     }
       
  2978 
       
  2979 // ---------------------------------------------------------
       
  2980 // CNotViewerAppUi::CheckAPSettingsL
       
  2981 // ---------------------------------------------------------
       
  2982 //
       
  2983 TBool CNotViewerAppUi::CheckAPSettingsL( )
       
  2984     {
       
  2985     LOGTEXT(_L8("NotViewerAppUi: CheckAPSettingsL start"));
       
  2986     CMsgEditorDocument* doc = Document( );
       
  2987 
       
  2988     CNotMtmUi* uiMtm = static_cast<CNotMtmUi*>( &doc->MtmUi( ) );
       
  2989 
       
  2990     CMmsSettingsDialog::TMmsExitCode exitCode = CMmsSettingsDialog::EMmsExternalInterrupt;
       
  2991 
       
  2992     if ( iToolbar ) //check to be provided for non-touch devices.
       
  2993         {    
       
  2994     iToolbar->HideItemsAndDrawOnlyBackground( ETrue ); // Hide the toolbar before settings dialog is launched
       
  2995         }
       
  2996     // Enable Dialer as MMS Settings dialog may be launched
       
  2997     iAvkonAppUi->SetKeyEventFlags( 0x00 );	
       
  2998     if( !uiMtm->CheckSettingsL( exitCode ) )
       
  2999         {
       
  3000 
       
  3001         // Refresh the settings because they were changed
       
  3002         iSettingsHandler->RefreshSettingsL( );
       
  3003         TInt32 ap = iSettingsHandler->MmsSettings( )->AccessPoint( 0 );
       
  3004 
       
  3005         //settings saved
       
  3006         if( !( exitCode==CMmsSettingsDialog::EMmsBack && uiMtm->ApExistsL( ap ) ) )
       
  3007             { // Settings NOK
       
  3008              if ( iToolbar ) //check to be provided for non-touch devices.
       
  3009                 {            
       
  3010             iToolbar->HideItemsAndDrawOnlyBackground( EFalse ); // Show the toolbar 
       
  3011                 }  
       
  3012             return EFalse;
       
  3013             }
       
  3014         //Settings now OK
       
  3015         }
       
  3016     if ( iToolbar ) //check to be provided for non-touch devices.
       
  3017         {
       
  3018     iToolbar->HideItemsAndDrawOnlyBackground( EFalse ); // Show the toolbar 
       
  3019         }
       
  3020     if( exitCode==CMmsSettingsDialog::EMmsExit )
       
  3021         {
       
  3022         // Exit was called
       
  3023         Exit( );
       
  3024         }
       
  3025 
       
  3026     LOGTEXT(_L8("NotViewerAppUi: CheckAPSettingsL end"));
       
  3027     return ETrue;
       
  3028     }
       
  3029 
       
  3030 // ---------------------------------------------------------
       
  3031 // DoDelayedExitL
       
  3032 // ---------------------------------------------------------
       
  3033 void CNotViewerAppUi::DoDelayedExitL( const TInt aDelay )
       
  3034     {
       
  3035     delete iIdle;
       
  3036     iIdle = 0;
       
  3037     iIdle = CPeriodic::NewL( EPriorityNormal - 1 );
       
  3038     iIdle->Start(   aDelay,
       
  3039                     aDelay,
       
  3040                     TCallBack( DelayedExit, this ) );
       
  3041     }
       
  3042 
       
  3043 // ---------------------------------------------------------
       
  3044 // DelayedExit
       
  3045 // ---------------------------------------------------------
       
  3046 TInt CNotViewerAppUi::DelayedExit( TAny* aThis )
       
  3047     {
       
  3048     CNotViewerAppUi* editor = static_cast<CNotViewerAppUi*>( aThis );
       
  3049     TRAP_IGNORE( editor->DoInternalExitL() );
       
  3050 	CAknEnv::RunAppShutter( );
       
  3051     return KErrNone;
       
  3052     }
       
  3053 
       
  3054 // ---------------------------------------------------------
       
  3055 // DoExternalExitL
       
  3056 // ---------------------------------------------------------
       
  3057 void CNotViewerAppUi::DoInternalExitL()
       
  3058     {
       
  3059     delete iAbsorber; // Remove absorber now just in case
       
  3060     iAbsorber = NULL;
       
  3061     Exit( EAknSoftkeyBack );
       
  3062     }
       
  3063 
       
  3064 // ---------------------------------------------------------
       
  3065 // EditorObserver
       
  3066 // ---------------------------------------------------------
       
  3067 void CNotViewerAppUi::EditorObserver(TMsgEditorObserverFunc aFunc, TAny* aArg1, TAny* aArg2, TAny* aArg3)
       
  3068     {
       
  3069     TRAP_IGNORE(DoEditorObserverL(aFunc,aArg1,aArg2,aArg3 ) );
       
  3070     }
       
  3071 
       
  3072 // ---------------------------------------------------------
       
  3073 // EditorObserver
       
  3074 // ---------------------------------------------------------
       
  3075 void CNotViewerAppUi::DoEditorObserverL(TMsgEditorObserverFunc aFunc, TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/)
       
  3076     {
       
  3077     switch ( aFunc )
       
  3078         {
       
  3079         case EMsgButtonEvent:
       
  3080             {
       
  3081             if( !( iFlags & ENotViewerIsNotification ) &&  !iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  3082             	{
       
  3083             	CMsgAddressControl* addrControl = AddressControl( );
       
  3084 				if( addrControl == static_cast<CMsgAddressControl*>( aArg1 ) )
       
  3085 					{
       
  3086                     TBool modified = EFalse;
       
  3087                     if ( addrControl->GetRecipientsL()->Count() )
       
  3088                         {
       
  3089                         // Recipients found. Verify addresses.
       
  3090                         if ( !VerifyAddressesL( modified ) )
       
  3091                             {
       
  3092                             // Illegal address found.
       
  3093                             modified = ETrue;
       
  3094                             }
       
  3095                         }
       
  3096                     if ( !modified )//else
       
  3097                         {
       
  3098                         // Nothing changed on the UI. Open PhoneBook.
       
  3099                         AddRecipientL();
       
  3100                         }
       
  3101 					}
       
  3102             	}
       
  3103             }
       
  3104             break;
       
  3105          case EMsgHandleFocusChange:
       
  3106          case EMsgControlPointerEvent:
       
  3107             {
       
  3108             // Enable Dialer 
       
  3109             iAvkonAppUi->SetKeyEventFlags( 0x00 );
       
  3110             break; 
       
  3111             }
       
  3112 		default:
       
  3113 			break;
       
  3114         }
       
  3115     }
       
  3116 
       
  3117 // -----------------------------------------------------------------------------
       
  3118 // handles the touch-ui related control events for next/previous message
       
  3119 // -----------------------------------------------------------------------------
       
  3120 //
       
  3121 #ifdef RD_SCALABLE_UI_V2
       
  3122 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  3123 void CNotViewerAppUi::HandleNaviDecoratorEventL( TInt aEventID )     
       
  3124     {
       
  3125     if ( AknLayoutUtils::PenEnabled() )
       
  3126         {
       
  3127         if (    iNaviDecorator
       
  3128             &&  iNaviPane->Top( ) == iNaviDecorator )
       
  3129             {
       
  3130             if( IsNextMessageAvailableL( aEventID == EAknNaviDecoratorEventRightTabArrow ) )
       
  3131                 {
       
  3132                 /* no need for separate checks for right and left arrows
       
  3133                     because IsNextMessageAvailableL() and NextMessageL
       
  3134                     are called with the truth-value of the same comparison */
       
  3135                 NextMessageL( aEventID == EAknNaviDecoratorEventRightTabArrow );
       
  3136                 }
       
  3137             }
       
  3138         }
       
  3139     }
       
  3140 #endif
       
  3141 #endif
       
  3142 
       
  3143 // ---------------------------------------------------------
       
  3144 // DynInitToolbarL
       
  3145 // ---------------------------------------------------------
       
  3146 //
       
  3147 #ifdef RD_SCALABLE_UI_V2
       
  3148 void CNotViewerAppUi::DynInitToolbarL(  TInt            /*aResourceId*/, 
       
  3149                                         CAknToolbar*    aToolbar )
       
  3150     {
       
  3151     if (    iToolbar
       
  3152         &&  iToolbar  == aToolbar )
       
  3153         {
       
  3154         // Dimming buttons follow     
       
  3155         CNotViewerDocument* doc = Document( );
       
  3156         CNotMtmUiData* uiData = &doc->MtmUiDataL( );
       
  3157         TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  3158 
       
  3159 	    if( iFlags & ENotViewerIsNotification )
       
  3160 	        {
       
  3161             // Hide always Send and Add
       
  3162             iToolbar->HideItem( ENotViewerToolbarSend,
       
  3163                                 ETrue,
       
  3164                                 EFalse );
       
  3165             iToolbar->HideItem( ENotViewerToolbarAdd,
       
  3166                                 ETrue,
       
  3167                                 EFalse );
       
  3168             
       
  3169             if( uiData->OperationSupportedL( KMtmUiFunctionFetchMMS, entry ) )
       
  3170                 {
       
  3171                 iToolbar->SetItemDimmed(    ENotViewerToolbarRetrieve,
       
  3172                                             ETrue,
       
  3173                                             EFalse );
       
  3174                 }
       
  3175             if( iMtm->Sender().Length()==0 )
       
  3176                 {
       
  3177                 iToolbar->SetItemDimmed(    ENotViewerToolbarReply,
       
  3178                                             ETrue,
       
  3179                                             EFalse );
       
  3180                 }
       
  3181             if( uiData->OperationSupportedL( KMtmUiFunctionDeleteMessage, entry ) )
       
  3182                 {
       
  3183                 iToolbar->SetItemDimmed(    ENotViewerToolbarDelete,
       
  3184                                             ETrue,
       
  3185                                             EFalse );
       
  3186                 }
       
  3187 	        }
       
  3188 	    else 
       
  3189             {            
       
  3190             // Hide always Retrieve and Reply
       
  3191             iToolbar->HideItem( ENotViewerToolbarRetrieve,
       
  3192                                 ETrue,
       
  3193                                 EFalse );
       
  3194             iToolbar->HideItem( ENotViewerToolbarReply,
       
  3195                                 ETrue,
       
  3196                                 EFalse );
       
  3197             
       
  3198 	        if( !iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  3199 	            {
       
  3200                 iToolbar->SetItemDimmed(    ENotViewerToolbarDelete,
       
  3201                                             ETrue,
       
  3202                                             EFalse );
       
  3203 	            }
       
  3204 	        if( iMtm->Entry( ).Entry( ).ReadOnly( ) )
       
  3205 	            {
       
  3206                 iToolbar->SetItemDimmed(    ENotViewerToolbarSend,
       
  3207                                             ETrue,
       
  3208                                             EFalse );	            
       
  3209                 iToolbar->SetItemDimmed(    ENotViewerToolbarAdd,
       
  3210                                             ETrue,
       
  3211                                             EFalse );	            
       
  3212 	            }
       
  3213             }
       
  3214 	                
       
  3215         }
       
  3216     }
       
  3217 #endif        
       
  3218 
       
  3219 
       
  3220 // ---------------------------------------------------------
       
  3221 // OfferToolbarEventL
       
  3222 // ---------------------------------------------------------
       
  3223 //
       
  3224 #ifdef RD_SCALABLE_UI_V2
       
  3225 void CNotViewerAppUi::OfferToolbarEventL( TInt aCommand )
       
  3226     {
       
  3227     switch ( aCommand )
       
  3228         {
       
  3229         case ENotViewerToolbarRetrieve:
       
  3230             HandleCommandL( ENotViewerRetrieve );
       
  3231             break;
       
  3232             
       
  3233         case ENotViewerToolbarReply:
       
  3234             HandleCommandL( ENotViewerReplyViaMessage );            
       
  3235             break;
       
  3236             
       
  3237         case ENotViewerToolbarSend:
       
  3238             HandleCommandL( ENotViewerSend );
       
  3239             break;
       
  3240             
       
  3241         case ENotViewerToolbarAdd:
       
  3242             HandleCommandL( ENotViewerAddRecipient );            
       
  3243             break;
       
  3244 
       
  3245         case ENotViewerToolbarDelete:
       
  3246             HandleCommandL( ENotViewerDelete );
       
  3247             break;
       
  3248 
       
  3249         default:
       
  3250             break;
       
  3251         }
       
  3252     }
       
  3253 
       
  3254 // ---------------------------------------------------------
       
  3255 // OperationOngoing
       
  3256 // ---------------------------------------------------------
       
  3257 //
       
  3258 TBool CNotViewerAppUi::OperationOngoing( const TMsvEntry& aEntry ) const
       
  3259     {
       
  3260     return (    aEntry.iMtmData2 & KMmsOperationOngoing 
       
  3261             &&  !( aEntry.iMtmData2 & KMmsOperationFinished ) );
       
  3262     }
       
  3263 
       
  3264 // ---------------------------------------------------------
       
  3265 // OperationFinished
       
  3266 // ---------------------------------------------------------
       
  3267 //
       
  3268 TBool CNotViewerAppUi::OperationFinished( const TMsvEntry& aEntry ) const
       
  3269     {
       
  3270     return (    aEntry.iMtmData2 & KMmsOperationFinished
       
  3271             &&  !( aEntry.iMtmData2 & KMmsOperationOngoing ) );
       
  3272     }
       
  3273     
       
  3274 // ---------------------------------------------------------
       
  3275 // HandleForegroundEventL
       
  3276 // ---------------------------------------------------------
       
  3277 //
       
  3278 void CNotViewerAppUi::HandleForegroundEventL(TBool aForeground)
       
  3279     {
       
  3280     if ( AknLayoutUtils::PenEnabled() )
       
  3281         {                
       
  3282         if ( !iToolbar )
       
  3283             {
       
  3284             iToolbar = CurrentFixedToolbar();  
       
  3285             if ( iToolbar )
       
  3286                 {
       
  3287                 iToolbar->SetToolbarObserver( this );
       
  3288                 iToolbar->DisableToolbarL( ETrue ); 
       
  3289                 }
       
  3290             }
       
  3291         }
       
  3292     CMsgEditorAppUi::HandleForegroundEventL( aForeground );
       
  3293     }
       
  3294 #endif
       
  3295 
       
  3296 // ---------------------------------------------------------
       
  3297 // HandleResourceChangeL
       
  3298 // ---------------------------------------------------------
       
  3299 //
       
  3300 void CNotViewerAppUi::HandleResourceChangeL(TInt aType)
       
  3301     {
       
  3302     // Base class call must be first
       
  3303     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  3304 
       
  3305     if ( aType == KAknsMessageSkinChange )
       
  3306         {
       
  3307         if ( iAppIcon )
       
  3308             {
       
  3309             delete iAppIcon;
       
  3310             iAppIcon = NULL;
       
  3311             }
       
  3312     
       
  3313       	// Set path of bitmap file
       
  3314       	TParse fileParse;
       
  3315       	fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
  3316         
       
  3317         iAppIcon = AknsUtils::CreateGulIconL( 
       
  3318             AknsUtils::SkinInstance(), 
       
  3319             KAknsIIDQgnPropMceMmsTitle,
       
  3320             fileParse.FullName(),
       
  3321             EMbmMmsuiQgn_prop_mce_mms_title,
       
  3322             EMbmMmsuiQgn_prop_mce_mms_title_mask );
       
  3323         SetTitleIconL();   
       
  3324         }
       
  3325     else if ( aType == KEikDynamicLayoutVariantSwitch )
       
  3326         {
       
  3327         SetTitleIconL();   
       
  3328         }
       
  3329     }
       
  3330 
       
  3331 // ---------------------------------------------------------
       
  3332 // SetTitleIconL
       
  3333 // ---------------------------------------------------------
       
  3334 //
       
  3335 void CNotViewerAppUi::SetTitleIconL()
       
  3336     {
       
  3337     SetTitleIconSizeL( iAppIcon->Bitmap() );
       
  3338     // Create duplicates of the icon to be used
       
  3339     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  3340     CleanupStack::PushL( bitmap );
       
  3341     
       
  3342     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  3343     CleanupStack::PushL( bitmapMask );
       
  3344     
       
  3345     User::LeaveIfError( bitmap->Duplicate( iAppIcon->Bitmap()->Handle() ) );
       
  3346     User::LeaveIfError( bitmapMask->Duplicate( iAppIcon->Mask()->Handle() ) );
       
  3347 
       
  3348     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  3349     iTitlePane->DrawNow();
       
  3350     
       
  3351     CleanupStack::Pop( bitmapMask );
       
  3352     CleanupStack::Pop( bitmap );
       
  3353     }