messagingappbase/msgeditor/appuisrc/MsgEditorAppUi.cpp
branchRCL_3
changeset 60 7fdbb852d323
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  MsgEditorAppUi implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 #include <featmgr.h>                // for feature manager
       
    23 
       
    24 #include <eikenv.h>                 // Eikon Enviroment
       
    25 #include <txtrich.h>                // Rich Text
       
    26 #include <eikrted.h>                // CEikRichTextEditor
       
    27 #include <eikmenub.h>               // CEikMenuBar
       
    28 #include <eikspane.h>               // status panel
       
    29 
       
    30 #include <eikapp.h>                 // CEikApplication
       
    31 #include <eikserverapp.h>
       
    32 #include <bautils.h>                // NearestLanguageFile
       
    33 #include <eikdialg.h>               // CEikDialog
       
    34 #include <data_caging_path_literals.hrh>
       
    35 
       
    36 #include <msvapi.h>                 //
       
    37 #include <mtmuibas.h>               // MTM UI
       
    38 #include <mtmuidef.hrh>             // Preferences
       
    39 #include <mtmdef.h>                 // TMsvPartList
       
    40 
       
    41 #include <MuiuMsgEmbeddedEditorWatchingOperation.h>
       
    42 #include <MuiuMsgEditorLauncher.h>  // for TEditorParameters
       
    43 #include <MuiuMessageIterator.h>    // for CMessageIterator
       
    44 #include <MuiuOperationWait.h>      // for CMuiuOperationWait
       
    45 #include <muiu.mbg>
       
    46 
       
    47 #include <aknenv.h>
       
    48 #include <aknnavi.h>                // CAknNavigationControlContainer
       
    49 #include <aknnavide.h>              // CAknNavigationDecorator
       
    50 #include <akntabgrp.h>              // CAknTabGroup
       
    51 #include <akninputblock.h>          // CAknInputBlock
       
    52 #include <aknnotewrappers.h>
       
    53 #include <AknIndicatorContainer.h>
       
    54 #include <akncontext.h>             // For message store in MMC -indication
       
    55 #include <AknsUtils.h>
       
    56 #include <AknsConstants.h>
       
    57 #include <commonphoneparser.h>      // Common phone number validity checker
       
    58 #include <apgicnfl.h>               // apamasked bitmaps
       
    59 #include <ErrorUI.h>				// CErrorUI - to show global error notes
       
    60 #include <StringLoader.h>           // StringLoader
       
    61 #include <NpdApi.h>                 // Notepad API
       
    62 #include <avkon.hrh>
       
    63 #include <AknStatuspaneUtils.h>
       
    64 #include <AknSettingCache.h>
       
    65 #include <messaginginternalcrkeys.h>
       
    66 #include <MessagingSDKCRKeys.h>
       
    67 #include "MsgEditorAppUiExtension.h"
       
    68 
       
    69 #include <aknlayoutscalable_avkon.cdl.h>
       
    70 
       
    71 #include "MsgEditorShutter.h"
       
    72 
       
    73 #include "MsgEditorCommon.h"
       
    74 #include "MsgEditorAppUi.h"         // class header
       
    75 #include "MsgEditorView.h"          // View
       
    76 #include "MsgBodyControl.h"         // Body Control
       
    77 #include "MsgSendKeyAcceptingQuery.h"
       
    78 #include "MsgEditorAppUiPanic.h"    // Panics
       
    79 #include "MsgEditorFlags.h"         // EditorFlags
       
    80 #include "MsgAttachmentUtils.h"
       
    81 #include <MsgEditorAppUi.rsg>       // resource identifiers
       
    82 #include "MsgNaviPaneControl.h"
       
    83 
       
    84 #ifdef RD_MSG_FAST_PREV_NEXT
       
    85 #include <messaginginternalpskeys.h>
       
    86 #endif
       
    87 
       
    88 #include "MsgEditorLogging.h"
       
    89 
       
    90 // ========== EXTERNAL DATA STRUCTURES =====================
       
    91 
       
    92 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    93 
       
    94 // ========== CONSTANTS ====================================
       
    95 
       
    96 const TInt KMsgDiskSpaceForDelete = ( 5 * 1024 ); // minimum disk space needed when deleting messages
       
    97 
       
    98 // ========== MACROS =======================================
       
    99 
       
   100 _LIT( KMsgEditorAppUiResourceFileName, "msgeditorappui.rsc" );
       
   101 _LIT( KMuiuBitmapFileName, "muiu.mbm" );
       
   102 _LIT( KMsgEditorAppUiFilterRe, "RE:" );
       
   103 _LIT( KMsgEditorAppUiFilterFw, "FW:" );
       
   104 _LIT( KMsgEditorAppUiFilterFwd, "FWD:" );
       
   105 
       
   106 // ========== LOCAL CONSTANTS AND MACROS ===================
       
   107 
       
   108 // ========== MODULE DATA STRUCTURES =======================
       
   109 
       
   110 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
   111 
       
   112 // ========== LOCAL FUNCTIONS ==============================
       
   113 
       
   114 // ========== MEMBER FUNCTIONS =============================
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CMsgEditorAppUi::CMsgEditorAppUi
       
   118 //
       
   119 // Constructor.
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 EXPORT_C CMsgEditorAppUi::CMsgEditorAppUi() : 
       
   123     iExitMode( MApaEmbeddedDocObserver::EKeepChanges ),
       
   124     iCloseWithEndKey( ETrue )
       
   125     {
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CMsgEditorAppUi::ConstructL
       
   130 //
       
   131 // 2nd phase constructor.
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 EXPORT_C void CMsgEditorAppUi::ConstructL()
       
   135     {
       
   136     CMsgEditorBaseUi::ConstructL();
       
   137     
       
   138     iMsgNaviDirection = KErrNotFound; 
       
   139 
       
   140     // initialize feature manager to check supported features
       
   141     FeatureManager::InitializeLibL();
       
   142     iMmcFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdMmc );
       
   143 
       
   144     TParse parse;
       
   145     parse.Set( KMsgEditorAppUiResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
   146     TFileName fileName( parse.FullName() );
       
   147 
       
   148     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   149     iResourceFileOffset = iEikonEnv->AddResourceFileL( fileName );
       
   150 
       
   151     Document()->SetEditorModelObserver( this );
       
   152 
       
   153     iFileMan = CFileMan::NewL( iEikonEnv->FsSession() );
       
   154 
       
   155     // create msgeditor temp directory.
       
   156     TFileName temppath;
       
   157     MsgAttachmentUtils::GetMsgEditorTempPath( temppath );
       
   158 
       
   159     RFs& fs = iEikonEnv->FsSession();
       
   160     fs.MkDir( temppath );
       
   161 
       
   162     CEikStatusPane* sp = StatusPane();
       
   163     if ( iMmcFeatureSupported && 
       
   164         TInt( Document()->Session().CurrentDriveL() ) == EDriveE )
       
   165         {
       
   166         CAknContextPane* contextPane = static_cast<CAknContextPane*>
       
   167             ( sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) );
       
   168         TParse fileParse;
       
   169         fileParse.Set( KMuiuBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   170         CFbsBitmap* bmp = NULL;
       
   171         CFbsBitmap* mask = NULL;
       
   172 #ifdef __SCALABLE_ICONS
       
   173         AknsUtils::CreateIconL(
       
   174             AknsUtils::SkinInstance(),
       
   175             KAknsIIDQgnMenuMceMmcCxt,
       
   176             bmp,
       
   177             mask,
       
   178             fileParse.FullName(),
       
   179             EMbmMuiuQgn_menu_mce_mmc,
       
   180             EMbmMuiuQgn_menu_mce_mmc_mask );
       
   181 #else
       
   182         AknsUtils::CreateIconL(
       
   183             AknsUtils::SkinInstance(),
       
   184             KAknsIIDQgnMenuMceMmcCxt,
       
   185             bmp,
       
   186             mask,
       
   187             fileParse.FullName(),
       
   188             EMbmMuiuQgn_menu_mce_mmc_cxt,
       
   189             EMbmMuiuQgn_menu_mce_mmc_cxt_mask );
       
   190 #endif  //__SCALABLE_ICONS
       
   191         contextPane->SetPicture( bmp, mask );
       
   192         }
       
   193     iOwnNaviPane = static_cast<CAknNavigationControlContainer*>
       
   194         ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   195     iCoeEnv->FsSession().ReserveDriveSpace(
       
   196         TInt( Document()->Session().CurrentDriveL() ),
       
   197         KMsgDiskSpaceForDelete );
       
   198   
       
   199     CMsgEditorDocument* doc = Document();
       
   200     iEditorShutter = CMsgEditorShutter::NewL(*doc);
       
   201   
       
   202     iMsgEditorAppUiExtension = new(ELeave) CMsgEditorAppUiExtension( this );
       
   203     CAknEnv* env = iAvkonEnv;
       
   204     CAknSettingCache& cache = env->SettingCache();
       
   205     cache.RegisterPluginL( &( iMsgEditorAppUiExtension->iSettingCachePlugin ) );    
       
   206     
       
   207     iStatusPaneRes = StatusPane()->CurrentLayoutResId();
       
   208     
       
   209     iIterator = NULL;
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // CMsgEditorAppUi::~CMsgEditorAppUi
       
   214 //
       
   215 // Destructor.
       
   216 // ---------------------------------------------------------
       
   217 //
       
   218 EXPORT_C CMsgEditorAppUi::~CMsgEditorAppUi()
       
   219     {
       
   220     delete iEditorShutter;
       
   221 
       
   222     Document()->SetEditorModelObserver( NULL );
       
   223 
       
   224     // remove resource file from CONE-maintained resource file list.
       
   225     if ( iResourceFileOffset )
       
   226         {
       
   227         iEikonEnv->DeleteResourceFile( iResourceFileOffset );
       
   228         }
       
   229 
       
   230     // call NotifyExit on completion of editing of an embedded document.
       
   231     if ( iDoorObserver )
       
   232         {
       
   233         MEBLOGGER_WRITEF( _L( "MEB: CMsgEditorAppUi: Closing with exit mode %d" ), iExitMode );
       
   234         iDoorObserver->NotifyExit( iExitMode );
       
   235         }
       
   236 
       
   237     delete iView;
       
   238     delete iLock;
       
   239     delete iNaviDecorator;
       
   240 
       
   241     // we are referring instance of nvaidecoratoir only
       
   242     // no need to delete, alreday deleted in  delete iNaviDecorator;
       
   243     //delete iIterator;
       
   244 
       
   245     // delete files from our temp directory.
       
   246     if ( iFileMan )
       
   247         {
       
   248         TFileName temppath;
       
   249         MsgAttachmentUtils::GetMsgEditorTempPath( temppath );
       
   250 
       
   251         /*TInt err =*/ iFileMan->Delete( temppath /*, CFileMan::ERecurse*/ );
       
   252         //TInt err2 = iFileMan->RmDir(temppath); // remove directory
       
   253         }
       
   254 
       
   255     delete iFileMan;
       
   256 
       
   257     // Uninitialize FeatureManager and members
       
   258     FeatureManager::UnInitializeLib();
       
   259     if( iMsgEditorAppUiExtension )
       
   260         {
       
   261         CAknEnv* env = iAvkonEnv;
       
   262         CAknSettingCache& cache = env->SettingCache();
       
   263         cache.DeRegisterPlugin( &( iMsgEditorAppUiExtension->iSettingCachePlugin ) );
       
   264         delete iMsgEditorAppUiExtension;
       
   265         }    
       
   266     }
       
   267 
       
   268 // ---------------------------------------------------------
       
   269 // CMsgEditorAppUi::HandleKeyEventL
       
   270 //
       
   271 // Route key events to view.
       
   272 // ---------------------------------------------------------
       
   273 //
       
   274 EXPORT_C TKeyResponse CMsgEditorAppUi::HandleKeyEventL(
       
   275     const TKeyEvent& aKeyEvent, TEventCode aType )
       
   276     {
       
   277     if ( iView )
       
   278         {
       
   279         return iView->OfferKeyEventL( aKeyEvent, aType );
       
   280         }
       
   281     return EKeyWasNotConsumed;
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------
       
   285 // CMsgEditorAppUi::HandleWsEventL
       
   286 //
       
   287 //
       
   288 // ---------------------------------------------------------
       
   289 //
       
   290 EXPORT_C void CMsgEditorAppUi::HandleWsEventL( const TWsEvent& aEvent,CCoeControl* aDestination )
       
   291     {
       
   292     TInt type = aEvent.Type();
       
   293 
       
   294     if ( type == EEventKey )
       
   295         {
       
   296         TKeyEvent* key = aEvent.Key();
       
   297         if ( ( key->iModifiers & EModifierShift ) &&
       
   298             ( key->iCode == EKeyBackspace ) )
       
   299             {
       
   300             if ( iView )
       
   301                 {
       
   302                 CMsgBodyControl* body = 
       
   303                         static_cast<CMsgBodyControl*>( iView->ControlById( EMsgComponentIdBody ) );
       
   304 
       
   305                 if ( body && body->IsReadOnly() )
       
   306                     {
       
   307                     TRAP_IGNORE( SaveBodyL( body ) );
       
   308                     }
       
   309                 }
       
   310 
       
   311             key->iModifiers &= ~EModifierShift;
       
   312             key->iCode = EKeyDelete;
       
   313             }
       
   314         }
       
   315         
       
   316     if ( type != KAknUidValueEndKeyCloseEvent ||
       
   317          iCloseWithEndKey )
       
   318         {
       
   319         CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
   320         }
       
   321     }
       
   322 
       
   323 // ---------------------------------------------------------
       
   324 // CMsgEditorAppUi::NextMessageL
       
   325 //
       
   326 // Set a specific exit code for opening next or previous message. Codes are
       
   327 // defined in MuiuMsgEmbeddedEditorWatchingOperation.h 
       
   328 // and handled by MCE after msg viewer has been closed.
       
   329 // ---------------------------------------------------------
       
   330 //
       
   331 EXPORT_C void CMsgEditorAppUi::NextMessageL( TBool aForward )
       
   332     {
       
   333     // Next is ETrue if layout is EAknLayoutIdABRW,
       
   334     // EFalse if EAknLayoutIdELAF or EAknLayoutIdAPAC
       
   335     if ( AknLayoutUtils::LayoutMirrored() )
       
   336         {
       
   337         aForward = !aForward;
       
   338         }
       
   339 
       
   340     iMsgNaviDirection = aForward;
       
   341     
       
   342     // Check if next/previous message 
       
   343     __ASSERT_DEBUG( iIterator != NULL, Panic( ENullPointer1 ) );
       
   344      if ( aForward )
       
   345          {
       
   346          iIterator->SetNextMessage();
       
   347          
       
   348          }
       
   349      else
       
   350          {
       
   351          iIterator->SetPreviousMessage();
       
   352          }
       
   353 
       
   354      RProperty::Set( KPSUidMuiu, KMuiuKeyNextMsg,
       
   355               iIterator->CurrentMessage().Id() );
       
   356          
       
   357 #ifdef RD_MSG_FAST_PREV_NEXT
       
   358     // Check if next/previous message can be fast opened by viewer
       
   359     
       
   360     if ( CanFastOpenL( *iIterator) )
       
   361         {
       
   362         // Load next/previous message
       
   363         TRAPD( err, Document()->SetEntryL( iIterator->CurrentMessage().Id() ) );
       
   364         // If fast open fails, view is incompletely constructed
       
   365         // Drop back to mce
       
   366         if( err == KErrCancel )
       
   367             {
       
   368             /* It is a known-valid failure(quick lauch cancelled in viewers due to heterogenous messages)
       
   369              * In that case, reset the current entry to original and exit with correct code so that message
       
   370              * will be launched completely from MCE.
       
   371              */
       
   372             if ( iMsgNaviDirection )
       
   373                 {
       
   374                 iIterator->SetPreviousMessage();
       
   375                 }
       
   376             else
       
   377                 {
       
   378                 iIterator->SetNextMessage();
       
   379                 }
       
   380             Document()->SetEntryWithoutNotificationL( iIterator->CurrentMessage().Id() );
       
   381             iExitMode = iMsgNaviDirection ?
       
   382                 MApaEmbeddedDocObserver::TExitMode(
       
   383                     CMsgEmbeddedEditorWatchingOperation::EMsgExitNext) :
       
   384                 MApaEmbeddedDocObserver::TExitMode(
       
   385                     CMsgEmbeddedEditorWatchingOperation::EMsgExitPrevious);
       
   386             Exit( iExitMode );
       
   387             }
       
   388         else if ( err != KErrNone )
       
   389             {
       
   390             // Reset the KMuiuKeyNextMsg to 0 
       
   391             RProperty::Set( KPSUidMuiu, KMuiuKeyNextMsg,0 );
       
   392             // Unknown error during quick launch.
       
   393             iCoeEnv->HandleError( err );
       
   394             iExitMode = MApaEmbeddedDocObserver::ENoChanges;
       
   395             Exit( EAknSoftkeyClose );
       
   396             }
       
   397         }
       
   398     else
       
   399 #endif // RD_MSG_FAST_PREV_NEXT
       
   400         {
       
   401         iExitMode = aForward ?
       
   402             MApaEmbeddedDocObserver::TExitMode(
       
   403                 CMsgEmbeddedEditorWatchingOperation::EMsgExitNext) :
       
   404             MApaEmbeddedDocObserver::TExitMode(
       
   405                 CMsgEmbeddedEditorWatchingOperation::EMsgExitPrevious);
       
   406         Exit( iExitMode );
       
   407         }
       
   408     iMsgNaviDirection = KErrNotFound;
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------
       
   412 // CMsgEditorAppUi::IsNextMessageAvailableL
       
   413 //
       
   414 // Check if next or previous msg is available.
       
   415 // ---------------------------------------------------------
       
   416 //
       
   417 EXPORT_C TBool CMsgEditorAppUi::IsNextMessageAvailableL( TBool aForward )
       
   418     {
       
   419     TBool ret = EFalse;
       
   420     
       
   421     if ( iEikonEnv->StartedAsServerApp() )
       
   422         {
       
   423         CMsgEditorDocument* doc = Document();
       
   424 
       
   425         //We should not create iterator here  navi pane iterator
       
   426         //will be refered  in  CMsgEditorAppUi
       
   427          
       
   428 
       
   429         // Next is ETrue if layout is EAknLayoutIdABRW,
       
   430         // EFalse if EAknLayoutIdELAF or EAknLayoutIdAPAC
       
   431         if ( AknLayoutUtils::LayoutMirrored() )
       
   432             {
       
   433             aForward = !aForward;
       
   434             }
       
   435 		if(iIterator)
       
   436 		{
       
   437         	if ( aForward )
       
   438             	{
       
   439             	if ( iIterator->NextMessageExists() )
       
   440                 	{
       
   441                 	ret = ETrue;
       
   442                 	}
       
   443             	}
       
   444         	else
       
   445             	{
       
   446             	if ( iIterator->PreviousMessageExists() )
       
   447                 	{
       
   448                 	ret = ETrue;
       
   449                 	}
       
   450             	}
       
   451 		}
       
   452 	
       
   453         }
       
   454         
       
   455     return ret;
       
   456     }
       
   457 
       
   458 // ---------------------------------------------------------
       
   459 // CMsgEditorAppUi::MessageIndexInFolderL
       
   460 //
       
   461 // Returns index of current msg and also total number of msgs in folder.
       
   462 // ---------------------------------------------------------
       
   463 //
       
   464 EXPORT_C void CMsgEditorAppUi::MessageIndexInFolderL( TInt& aCurrentIndex, 
       
   465                                                       TInt& aMsgsInFolder )
       
   466     {
       
   467     if ( iEikonEnv->StartedAsServerApp() )
       
   468         {
       
   469         CMsgEditorDocument* doc = Document();
       
   470         //We should not create iterator here, navi pane iterator
       
   471         //will be refered  in  CMsgEditorAppUi
       
   472         if(iIterator)
       
   473             {
       
   474         	aCurrentIndex = iIterator->CurrentMessageIndex();
       
   475         	aMsgsInFolder = iIterator->MessagesInFolder();
       
   476             }
       
   477         }
       
   478     else
       
   479         {
       
   480         aCurrentIndex = 0;
       
   481         aMsgsInFolder = 0;
       
   482         }
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------
       
   486 // CMsgEditorAppUi::MoveMessageEntryL
       
   487 //
       
   488 // Moves an entry to another location.
       
   489 // ---------------------------------------------------------
       
   490 //
       
   491 EXPORT_C TMsvId CMsgEditorAppUi::MoveMessageEntryL( TMsvId aTarget ) const
       
   492     {
       
   493     TMsvEntry msvEntry = Document()->Entry();
       
   494     TMsvId id = KMsvNullIndexEntryId;
       
   495 
       
   496     if ( msvEntry.Parent() != aTarget )
       
   497         {
       
   498         CAknInputBlock::NewLC();
       
   499 
       
   500         CMsvEntry* parentEntry = Document()->Session().GetEntryL( msvEntry.Parent() );
       
   501         CleanupStack::PushL( parentEntry );
       
   502 
       
   503         // -- Change sort parameters so that parentEntry->MoveL does not leave as the child is invisible.
       
   504         TMsvSelectionOrdering sort = parentEntry->SortType();
       
   505         sort.SetShowInvisibleEntries( ETrue );
       
   506         parentEntry->SetSortTypeL( sort );
       
   507 
       
   508         // Copy original from the parent to the new location.
       
   509         CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
   510 
       
   511         CMsvOperation* op = parentEntry->MoveL(
       
   512             msvEntry.Id(), aTarget, wait->iStatus );
       
   513         CleanupStack::PushL( op );
       
   514         wait->Start(); // wait for asynch operation
       
   515 
       
   516         TMsvLocalOperationProgress prog = McliUtils::GetLocalProgressL( *op );
       
   517         User::LeaveIfError( prog.iError );
       
   518         id = prog.iId;
       
   519 
       
   520         CleanupStack::PopAndDestroy( 4 );  // op, wait, parentEntry, absorber
       
   521         }
       
   522 
       
   523     return id;
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CMsgEditorAppUi::DeleteAndExitL
       
   528 //
       
   529 // Deletes current entry and then exits.
       
   530 // ---------------------------------------------------------
       
   531 //
       
   532 EXPORT_C void CMsgEditorAppUi::DeleteAndExitL()
       
   533     {
       
   534     DeleteCurrentEntryL();
       
   535     Exit( EAknSoftkeyBack );
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------
       
   539 // CMsgEditorAppUi::DeleteCurrentEntryL
       
   540 //
       
   541 // Deletes current entry.
       
   542 // ---------------------------------------------------------
       
   543 //
       
   544 EXPORT_C void CMsgEditorAppUi::DeleteCurrentEntryL()
       
   545     {
       
   546     CMsgEditorDocument* doc = Document();
       
   547     UnlockEntry();
       
   548 
       
   549     TInt msgStoreDrive = TInt( doc->Session().CurrentDriveL() );
       
   550     iCoeEnv->FsSession().GetReserveAccess( msgStoreDrive );
       
   551 
       
   552     if ( doc->CurrentEntry().OwningService() == KMsvLocalServiceIndexEntryId )
       
   553         {
       
   554         const TMsvId id = doc->Entry().Id();
       
   555         //doc->CurrentEntry().SetEntryL( doc->Entry().Parent() );
       
   556         TRAPD( 
       
   557                 err, 
       
   558                 {
       
   559                 doc->CurrentEntry().SetEntryL( doc->Entry().Parent() ); 
       
   560                 doc->CurrentEntry().DeleteL( id ); 
       
   561                 }
       
   562             );
       
   563         if ( err != KErrNone )
       
   564             {
       
   565             doc->Session().RemoveEntry( id );
       
   566             }
       
   567         }
       
   568     else
       
   569         {
       
   570         CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection;
       
   571         CleanupStack::PushL( sel );
       
   572         TMsvId id = doc->Entry().Id();
       
   573         sel->AppendL( id );
       
   574         doc->Mtm().SwitchCurrentEntryL( doc->Entry().Parent() );
       
   575 
       
   576         CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
   577 
       
   578         CMsvOperation* op = doc->MtmUi().DeleteFromL( *sel, wait->iStatus );
       
   579         CleanupStack::PushL( op );
       
   580 
       
   581         wait->Start();
       
   582 
       
   583         const TInt err = doc->MtmUi().DisplayProgressSummary( op->ProgressL() );
       
   584         CleanupStack::PopAndDestroy( 3, sel );  // sel, wait, op
       
   585         if ( err == KErrCancel )
       
   586             {
       
   587             doc->Mtm().SwitchCurrentEntryL( id );
       
   588             LockEntryL();
       
   589             return ;
       
   590             }
       
   591         User::LeaveIfError( err );
       
   592         }
       
   593 
       
   594     iCoeEnv->FsSession().ReleaseReserveAccess( msgStoreDrive );
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------
       
   598 // CMsgEditorAppUi::PrepareToExit
       
   599 //
       
   600 //
       
   601 // ---------------------------------------------------------
       
   602 //
       
   603 EXPORT_C void CMsgEditorAppUi::PrepareToExit()
       
   604     {
       
   605     CMsgEditorDocument* doc = Document();
       
   606 
       
   607     if ( doc->HasModel() )
       
   608         {
       
   609         if ( doc->Entry().InPreparation() )
       
   610             {
       
   611             doc->Session().RemoveEntry( doc->Entry().Id() );
       
   612             }
       
   613         }
       
   614 
       
   615     CEikAppUi::PrepareToExit();
       
   616     }
       
   617 
       
   618 // ---------------------------------------------------------
       
   619 // CMsgEditorAppUi::ReplyL
       
   620 //
       
   621 // Asynchronous Mtm reply command.
       
   622 // ---------------------------------------------------------
       
   623 //
       
   624 EXPORT_C void CMsgEditorAppUi::ReplyL(
       
   625     TMsvId aTarget, TBool aIncludeOriginal /*= ETrue*/ )
       
   626     {
       
   627     TMsvPartList parts =
       
   628         KMsvMessagePartDescription |
       
   629         KMsvMessagePartOriginator;
       
   630 
       
   631     if ( aIncludeOriginal )
       
   632         {
       
   633         parts |= KMsvMessagePartBody;
       
   634         }
       
   635 
       
   636     CBaseMtmUi& mtmUi = Document()->MtmUi();
       
   637 
       
   638     // to by-pass scanner warning about member variable being stored into
       
   639     // cleanup stack blocker is first stored into temporary variable. Storing
       
   640     // is allowed here as it is not owned.
       
   641 
       
   642     CMuiuOperationWait* wait =
       
   643         CMuiuOperationWait::NewLC( EActivePriorityWsEvents + 10 );
       
   644 
       
   645     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
       
   646     CMsvOperation* oper = mtmUi.ReplyL( aTarget, parts, wait->iStatus );
       
   647     CleanupStack::PushL( oper );
       
   648 
       
   649     wait->Start();
       
   650     
       
   651     CleanupStack::PopAndDestroy( 2 );  // absorber, wait, oper
       
   652     }
       
   653 
       
   654 // ---------------------------------------------------------
       
   655 // CMsgEditorAppUi::ReplyToAllL
       
   656 //
       
   657 // Asynchronous Mtm reply all command.
       
   658 // ---------------------------------------------------------
       
   659 //
       
   660 EXPORT_C void CMsgEditorAppUi::ReplyToAllL(
       
   661     TMsvId aTarget, TBool aIncludeOriginal /*= ETrue*/ )
       
   662     {
       
   663     TMsvPartList parts =
       
   664         KMsvMessagePartDescription |
       
   665         KMsvMessagePartRecipient |
       
   666         KMsvMessagePartOriginator ;
       
   667 
       
   668     if ( aIncludeOriginal )
       
   669         {
       
   670         parts |= KMsvMessagePartBody;
       
   671         }
       
   672 
       
   673     CBaseMtmUi& mtmUi = Document()->MtmUi();
       
   674     
       
   675     // to by-pass scanner warning about member variable being stored into
       
   676     // cleanup stack blocker is first stored into temporary variable. Storing
       
   677     // is allowed here as it is not owned.
       
   678     CAknInputBlock* blocker = CAknInputBlock::NewCancelHandlerLC( this );
       
   679     iInputBlocker = blocker;
       
   680 
       
   681     CMuiuOperationWait* wait =
       
   682         CMuiuOperationWait::NewLC( EActivePriorityWsEvents + 10 );
       
   683 
       
   684     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
       
   685     CMsvOperation* oper = mtmUi.ReplyL( aTarget, parts, wait->iStatus );
       
   686     CleanupStack::PushL( oper );
       
   687 
       
   688     wait->Start();
       
   689     
       
   690     CleanupStack::PopAndDestroy( 3, iInputBlocker );  // absorber, wait, oper
       
   691     iInputBlocker = NULL;
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------
       
   695 // CMsgEditorAppUi::ForwardL
       
   696 //
       
   697 // Asynchronous Mtm forward command.
       
   698 // ---------------------------------------------------------
       
   699 //
       
   700 EXPORT_C void CMsgEditorAppUi::ForwardL( TMsvId aTarget )
       
   701     {
       
   702     TMsvPartList parts =
       
   703         KMsvMessagePartBody |
       
   704         KMsvMessagePartDescription |
       
   705         KMsvMessagePartAttachments;
       
   706 
       
   707     CBaseMtmUi& mtmUi = Document()->MtmUi();
       
   708     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
       
   709     
       
   710     // to by-pass scanner warning about member variable being stored into
       
   711     // cleanup stack blocker is first stored into temporary variable. Storing
       
   712     // is allowed here as it is not owned.
       
   713     CAknInputBlock* blocker = CAknInputBlock::NewCancelHandlerLC( this );
       
   714     iInputBlocker = blocker;
       
   715     
       
   716     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC( EActivePriorityWsEvents + 10 );
       
   717     
       
   718     CMsvOperation* oper = mtmUi.ForwardL( aTarget, parts, wait->iStatus );
       
   719     CleanupStack::PushL( oper );
       
   720 
       
   721     wait->Start();
       
   722 
       
   723     CleanupStack::PopAndDestroy( 3, iInputBlocker );  // absorber, wait, oper
       
   724     iInputBlocker = NULL;
       
   725     }
       
   726 
       
   727 // ---------------------------------------------------------
       
   728 // CMsgEditorAppUi::InsertTemplate
       
   729 //
       
   730 //
       
   731 // ---------------------------------------------------------
       
   732 //
       
   733 EXPORT_C TInt CMsgEditorAppUi::InsertTemplateL( TInt aMaxChars /*= -1*/ )
       
   734     {
       
   735     __ASSERT_DEBUG( iView != NULL, Panic( ENullPointer1 ) );
       
   736 
       
   737     // get memo content from notepad to buffer.
       
   738     HBufC* title = iEikonEnv->AllocReadResourceLC( R_QTN_MAIL_POPUP_TEXT_SEL_TEMP );
       
   739 
       
   740     HBufC* buf = CNotepadApi::FetchTemplateL( title );
       
   741     CleanupStack::PushL( buf );
       
   742 
       
   743     TInt err = DoInsertTextL( buf, aMaxChars );
       
   744 
       
   745     CleanupStack::PopAndDestroy( 2, title ); // buf, title
       
   746     return err;
       
   747     }
       
   748 
       
   749 // ---------------------------------------------------------
       
   750 // CMsgEditorAppUi::InsertTextMemoL
       
   751 //
       
   752 //
       
   753 // ---------------------------------------------------------
       
   754 //
       
   755 EXPORT_C TInt CMsgEditorAppUi::InsertTextMemoL( TInt aMaxChars )
       
   756     {
       
   757     __ASSERT_DEBUG( iView != NULL, Panic( ENullPointer1 ) );
       
   758 
       
   759     // get memo content from notepad to buffer.
       
   760     HBufC* title = iEikonEnv->AllocReadResourceLC( R_QTN_NMAKE_FETCH_MEMO_PRMPT );
       
   761 
       
   762     HBufC* buf = CNotepadApi::FetchMemoL( title );
       
   763     CleanupStack::PushL( buf );
       
   764 
       
   765     TInt err = DoInsertTextL( buf, aMaxChars );
       
   766     
       
   767     CleanupStack::PopAndDestroy( 2, title ); // buf, title
       
   768     return err;
       
   769     }
       
   770 
       
   771 // ---------------------------------------------------------
       
   772 // CMsgEditorAppUi::DoInsertTextL
       
   773 //
       
   774 //
       
   775 // ---------------------------------------------------------
       
   776 //
       
   777 TInt CMsgEditorAppUi::DoInsertTextL( HBufC* aBuffer, TInt aMaxChars )
       
   778     {
       
   779     TInt err( KErrNone );
       
   780     if ( aBuffer )
       
   781         {
       
   782         TInt buflen = aBuffer->Length();
       
   783 
       
   784         if ( aMaxChars == -1 || buflen <= aMaxChars )
       
   785             {
       
   786             CMsgBodyControl* body = 
       
   787                     static_cast<CMsgBodyControl*>( iView->ControlById( EMsgComponentIdBody ) );
       
   788 
       
   789             if ( body )
       
   790                 {
       
   791                 CEikRichTextEditor& editor = body->Editor();
       
   792 
       
   793                 if ( body != iView->FocusedControl() )
       
   794                     {
       
   795                     editor.SetCursorPosL( editor.TextLength(), EFalse );
       
   796                     }
       
   797 
       
   798                 body->InsertTextL( *aBuffer );
       
   799 
       
   800                 iView->SetFocus( EMsgComponentIdBody );
       
   801 
       
   802                 Document()->SetChanged( ETrue );
       
   803                 }
       
   804             }
       
   805         else
       
   806             {
       
   807             err = KErrOverflow;
       
   808             }
       
   809         }
       
   810     else
       
   811         {
       
   812         err = KErrCancel;
       
   813         }
       
   814         
       
   815     return err;
       
   816     }
       
   817 
       
   818 // ---------------------------------------------------------
       
   819 // CMsgEditorAppUi::UpdateNaviPaneL
       
   820 //
       
   821 // Updates navi pane.
       
   822 // ---------------------------------------------------------
       
   823 //
       
   824 EXPORT_C void CMsgEditorAppUi::UpdateNaviPaneL(
       
   825     const CFbsBitmap* aBitmap     /*= NULL*/,
       
   826     const CFbsBitmap* aBitmapMask /*= NULL*/ )
       
   827     {
       
   828     UpdateNaviPaneL( EFalse, aBitmap, aBitmapMask );
       
   829     }
       
   830 
       
   831 // ---------------------------------------------------------
       
   832 // CMsgEditorAppUi::UpdateNaviPaneL
       
   833 //
       
   834 // Updates navi pane.
       
   835 // ---------------------------------------------------------
       
   836 //
       
   837 void CMsgEditorAppUi::UpdateNaviPaneL(
       
   838     TBool             aUpdateExisting,
       
   839     const CFbsBitmap* aBitmap     /*= NULL*/,
       
   840     const CFbsBitmap* aBitmapMask /*= NULL*/ )
       
   841     {
       
   842     if ( !iOwnNaviPane )
       
   843         {
       
   844         return;
       
   845         }
       
   846     TInt index = 0;
       
   847     TInt msgs = 0;
       
   848     HBufC* buf;
       
   849 
       
   850     MessageIndexInFolderL( index, msgs );
       
   851 
       
   852     TBool prevAvailable = IsNextMessageAvailableL( EFalse );
       
   853     TBool nextAvailable = IsNextMessageAvailableL( ETrue );
       
   854 
       
   855     CArrayFixFlat<TInt>* array = new( ELeave ) CArrayFixFlat<TInt>( 2 );
       
   856     CleanupStack::PushL( array );
       
   857 
       
   858     if ( msgs )
       
   859         {
       
   860         array->AppendL( index + 1 );
       
   861         array->AppendL( msgs );
       
   862         buf = StringLoader::LoadLC( R_QTN_STAT_MSG_NUMBER, *array, iCoeEnv );
       
   863         }
       
   864     else
       
   865         {
       
   866         // if no messages make empty message label.
       
   867         buf = HBufC::NewLC( 0 );
       
   868         prevAvailable = nextAvailable = 0;
       
   869         }
       
   870 
       
   871     if ( aUpdateExisting )
       
   872         {
       
   873         if ( iNaviDecorator )
       
   874             {
       
   875             CAknTabGroup* tabGroup =
       
   876                 static_cast<CAknTabGroup*>( iNaviDecorator->DecoratedControl() );
       
   877             tabGroup->ReplaceTabTextL( 0, *buf );
       
   878 
       
   879             iNaviDecorator->MakeScrollButtonVisible( ETrue );
       
   880             iNaviDecorator->SetScrollButtonDimmed(
       
   881                 CAknNavigationDecorator::ELeftButton,
       
   882                 !prevAvailable );
       
   883             iNaviDecorator->SetScrollButtonDimmed(
       
   884                 CAknNavigationDecorator::ERightButton,
       
   885                 !nextAvailable );
       
   886 
       
   887             iOwnNaviPane->PushL( *iNaviDecorator );
       
   888             }
       
   889         }
       
   890     else
       
   891         {
       
   892         delete iNaviDecorator;
       
   893         iNaviDecorator = NULL;
       
   894         iNaviDecorator = iOwnNaviPane->CreateTabGroupL();
       
   895         
       
   896         CAknTabGroup* tabGroup =
       
   897             static_cast<CAknTabGroup*>( iNaviDecorator->DecoratedControl() );
       
   898         tabGroup->AddTabL( 0, *buf );            
       
   899         tabGroup->SetActiveTabById( 0 );
       
   900         // does not leave with one tab.
       
   901         tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab );
       
   902 
       
   903         iNaviDecorator->MakeScrollButtonVisible( ETrue );
       
   904         iNaviDecorator->SetScrollButtonDimmed(
       
   905             CAknNavigationDecorator::ELeftButton,
       
   906             !prevAvailable );
       
   907         iNaviDecorator->SetScrollButtonDimmed(
       
   908             CAknNavigationDecorator::ERightButton,
       
   909             !nextAvailable );
       
   910 
       
   911         iOwnNaviPane->PushL( *iNaviDecorator );
       
   912 
       
   913         if ( aBitmap && aBitmapMask )
       
   914             {
       
   915             // replace tab with new one containing text and bitmaps.
       
   916             // this must be done after PushL because this transfers
       
   917             // ownership of caller's bitmaps to tab group.
       
   918             tabGroup->ReplaceTabL( 0, *buf, aBitmap, aBitmapMask );
       
   919             }
       
   920         }
       
   921     CleanupStack::PopAndDestroy( 2, array ); // buf, array
       
   922     }
       
   923 
       
   924 // ---------------------------------------------------------
       
   925 // CMsgEditorAppUi::HandleIteratorEventL
       
   926 //
       
   927 //
       
   928 // ---------------------------------------------------------
       
   929 //
       
   930 EXPORT_C void CMsgEditorAppUi::HandleIteratorEventL(
       
   931     TMessageIteratorEvent aEvent )
       
   932     {
       
   933     if ( aEvent == EFolderCountChanged )
       
   934         {
       
   935         UpdateNaviPaneL( ETrue );
       
   936         }
       
   937     }
       
   938 
       
   939 // ---------------------------------------------------------
       
   940 // CMsgEditorAppUi::CallToSenderQueryL
       
   941 //
       
   942 //
       
   943 // ---------------------------------------------------------
       
   944 //
       
   945 EXPORT_C TBool CMsgEditorAppUi::CallToSenderQueryL(
       
   946     const TDesC& aNumber, const TDesC& aAlias )
       
   947     {
       
   948     CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( 2 );
       
   949     CleanupStack::PushL( strings );
       
   950 
       
   951     strings->AppendL( aAlias );  // %0U
       
   952     strings->AppendL( aNumber ); // %1U
       
   953 
       
   954     HBufC* prompt = StringLoader::LoadLC(
       
   955         R_QTN_SMS_QUEST_CALL, *strings, iCoeEnv );
       
   956 
       
   957     CMsgSendKeyAcceptingQuery* dlg = CMsgSendKeyAcceptingQuery::NewL( *prompt );
       
   958     TInt ret = dlg->ExecuteLD( R_MEB_CALLBACK_QUERY );
       
   959 
       
   960     CleanupStack::PopAndDestroy( 2, strings ); // strings, prompt
       
   961 
       
   962     return ( ret != 0 ); // No = EFalse, others = ETrue.
       
   963     }
       
   964 
       
   965 // ---------------------------------------------------------
       
   966 // CMsgEditorAppUi::ProcessCommandParametersL
       
   967 //
       
   968 // Parses command line parameter and launch model accoring to them.
       
   969 // ---------------------------------------------------------
       
   970 //
       
   971 EXPORT_C TBool CMsgEditorAppUi::ProcessCommandParametersL(
       
   972     TApaCommand /*aCommand*/,
       
   973     TFileName& /*aDocumentName*/,
       
   974     const TDesC8& aTail )
       
   975     {
       
   976     CMsgEditorDocument& doc = *Document();
       
   977 
       
   978     if ( aTail.Length() > 0 )
       
   979         {
       
   980         // Get the parameters passed by the launching MTMUI.
       
   981         TPckgBuf<TEditorParameters> paramPack;
       
   982         const TInt paramSize = sizeof( TEditorParameters );
       
   983 
       
   984         __ASSERT_ALWAYS( aTail.Length() == paramSize, Panic( EInvalidArgument ) );
       
   985 
       
   986         paramPack.Copy( aTail );
       
   987         const TEditorParameters& params = paramPack();
       
   988         
       
   989         // to by-pass scanner warning about member variable being stored into
       
   990         // cleanup stack blocker is first stored into temporary variable. Storing
       
   991         // is allowed here as it is not owned.
       
   992         CAknInputBlock* blocker = CAknInputBlock::NewCancelHandlerLC( this );
       
   993         iInputBlocker = blocker;
       
   994 
       
   995         doc.LaunchParametersL( params );
       
   996         doc.EntryChangedL();  // notified after is unique (and unlocked).
       
   997         doc.PrepareToLaunchL( this );
       
   998 
       
   999         CleanupStack::PopAndDestroy( iInputBlocker );
       
  1000         iInputBlocker = NULL;
       
  1001         }
       
  1002     else
       
  1003         {
       
  1004         // no parameters enable TestEditor launching...
       
  1005         doc.PrepareToLaunchL( this );
       
  1006         }
       
  1007 
       
  1008     return EFalse;
       
  1009     }
       
  1010 
       
  1011 // ---------------------------------------------------------
       
  1012 // CMsgEditorAppUi::MenuBar
       
  1013 //
       
  1014 // Returns application menubar.
       
  1015 // ---------------------------------------------------------
       
  1016 //
       
  1017 EXPORT_C CEikMenuBar* CMsgEditorAppUi::MenuBar() const
       
  1018     {
       
  1019     return iEikonEnv->AppUiFactory()->MenuBar();
       
  1020     }
       
  1021 
       
  1022 // ---------------------------------------------------------
       
  1023 // CMsgEditorAppUi::SetEmphasis
       
  1024 //
       
  1025 // From MEikMenuObserver (called when menu is opened).
       
  1026 // ---------------------------------------------------------
       
  1027 //
       
  1028 EXPORT_C void CMsgEditorAppUi::SetEmphasis(
       
  1029     CCoeControl* aMenuControl, TBool aEmphasis )
       
  1030     {
       
  1031     if ( iView )
       
  1032         {
       
  1033         UpdateStackedControlFlags(
       
  1034             iView,
       
  1035             aEmphasis ? ECoeStackFlagRefusesFocus : 0,
       
  1036             ECoeStackFlagRefusesFocus );
       
  1037         }
       
  1038 
       
  1039     UpdateStackedControlFlags(
       
  1040         aMenuControl,
       
  1041         aEmphasis ? 0 : ECoeStackFlagRefusesFocus,
       
  1042         ECoeStackFlagRefusesFocus );
       
  1043 
       
  1044     HandleStackChanged();
       
  1045     }
       
  1046 
       
  1047 // ---------------------------------------------------------
       
  1048 // CMsgEditorAppUi::HandleEntryChangeL
       
  1049 //
       
  1050 // Default error handling for all messaging editors and viewers.
       
  1051 // HandleEntryChangeL is called when the currently open message
       
  1052 // has been modified by some other messaging client. The default
       
  1053 // action is "do nothing", but editors can define their own event
       
  1054 // processing by overriding this function.
       
  1055 // ---------------------------------------------------------
       
  1056 //
       
  1057 EXPORT_C void CMsgEditorAppUi::HandleEntryChangeL()
       
  1058     {
       
  1059     // no action
       
  1060     }
       
  1061 
       
  1062 // ---------------------------------------------------------
       
  1063 // CMsgEditorAppUi::HandleEntryDeletedL
       
  1064 //
       
  1065 // Default error handling for all messaging editors and viewers.
       
  1066 // HandleEntryDeletedL is called when the currently open message
       
  1067 // has been deleted by some other messaging client.
       
  1068 // ---------------------------------------------------------
       
  1069 //
       
  1070 EXPORT_C void CMsgEditorAppUi::HandleEntryDeletedL()
       
  1071     {
       
  1072     // TODO: get error code from errorres.
       
  1073     ViewErrorL(-7005);
       
  1074 
       
  1075     // close the application (and possible chain of viewers, editors and mce etc.).
       
  1076     ProcessCommandL( EAknCmdExit );
       
  1077     //Exit();
       
  1078     }
       
  1079 
       
  1080 // ---------------------------------------------------------
       
  1081 // CMsgEditorAppUi::HandleEntryMovedL
       
  1082 //
       
  1083 // Default error handling for all messaging editors and viewers.
       
  1084 // HandleEntryMovedL is called when the currently open message
       
  1085 // has been moved to some other folder, by some other messaging
       
  1086 // client.
       
  1087 // ---------------------------------------------------------
       
  1088 //
       
  1089 EXPORT_C void CMsgEditorAppUi::HandleEntryMovedL(
       
  1090     TMsvId /*aOldParent*/, TMsvId /*aNewParent*/ )
       
  1091     {
       
  1092     // refresh model content.
       
  1093     Document()->SetEntryWithoutNotificationL( Document()->Entry().Id() );
       
  1094     }
       
  1095 
       
  1096 // ---------------------------------------------------------
       
  1097 // CMsgEditorAppUi::HandleMtmGroupDeinstalledL
       
  1098 //
       
  1099 // Default error handling for all messaging editors and viewers.
       
  1100 // HandleMtmGroupDeinstalledL is called when the MTM Group used
       
  1101 // by the currently open message has been removed from the device.
       
  1102 // ---------------------------------------------------------
       
  1103 //
       
  1104 EXPORT_C void CMsgEditorAppUi::HandleMtmGroupDeinstalledL()
       
  1105     {
       
  1106     // TODO: get error code from errorres.
       
  1107     ViewErrorL( -7006 );
       
  1108 
       
  1109     // close the application (and possible chain of viewers, editors and mce etc.).
       
  1110     ProcessCommandL( EAknCmdExit );
       
  1111     //Exit();
       
  1112     }
       
  1113 
       
  1114 // ---------------------------------------------------------
       
  1115 // CMsgEditorAppUi::HandleGeneralErrorL
       
  1116 //
       
  1117 // Default error handling for all messaging editors and viewers.
       
  1118 // HandleGeneralErrorL is called when some unknown error has
       
  1119 // happened. The aErrorCode parameter contains the error code.
       
  1120 // ---------------------------------------------------------
       
  1121 //
       
  1122 EXPORT_C void CMsgEditorAppUi::HandleGeneralErrorL( TInt /*aErrorCode*/ )
       
  1123     {
       
  1124     // TODO: show note?
       
  1125 
       
  1126     // close the application (and possible chain of viewers, editors and mce etc.).
       
  1127     ProcessCommandL( EAknCmdExit );
       
  1128     //Exit();
       
  1129     }
       
  1130 
       
  1131 // ---------------------------------------------------------
       
  1132 // CMsgEditorAppUi::HandleCloseSessionL
       
  1133 //
       
  1134 // Default error handling for all messaging editors and viewers.
       
  1135 // HandleCloseSessionL is called when the messaging server wants
       
  1136 // to close the session (e.g. because it's closing down and wants
       
  1137 // to get rid of all messaging clients).
       
  1138 // ---------------------------------------------------------
       
  1139 //
       
  1140 EXPORT_C void CMsgEditorAppUi::HandleCloseSessionL()
       
  1141     {
       
  1142     // save changes and close the application.
       
  1143     DoMsgSaveExitL();
       
  1144     }
       
  1145 
       
  1146 // ---------------------------------------------------------
       
  1147 // CMsgEditorAppUi::HandleServerFailedToStartL
       
  1148 //
       
  1149 // Default error handling for all messaging editors and viewers.
       
  1150 // HandleServerFailedToStartL is called when the message server
       
  1151 // start-up was not successful.
       
  1152 // ---------------------------------------------------------
       
  1153 //
       
  1154 EXPORT_C void CMsgEditorAppUi::HandleServerFailedToStartL()
       
  1155     {
       
  1156     // TODO: get error code from errorres.
       
  1157     ViewErrorL( -7007 );
       
  1158 
       
  1159     // close the application (and possible chain of viewers, editors and mce etc.).
       
  1160     ProcessCommandL( EAknCmdExit );
       
  1161     //Exit();
       
  1162     }
       
  1163 
       
  1164 // ---------------------------------------------------------
       
  1165 // CMsgEditorAppUi::HandleServerTerminatedL
       
  1166 //
       
  1167 // Default error handling for all messaging editors and viewers.
       
  1168 // HandleServerTerminatedL is called when the messaging server has
       
  1169 // died. Application cannot use the message server session any more.
       
  1170 // ---------------------------------------------------------
       
  1171 //
       
  1172 EXPORT_C void CMsgEditorAppUi::HandleServerTerminatedL()
       
  1173     {
       
  1174     // TODO: get error code from errorres.
       
  1175     ViewErrorL( -7008 );
       
  1176 
       
  1177     // close the application (and possible chain of viewers, editors and mce etc.).
       
  1178     ProcessCommandL( EAknCmdExit );
       
  1179     //Exit();
       
  1180     }
       
  1181 
       
  1182 // ---------------------------------------------------------
       
  1183 // CMsgEditorAppUi::HandleMediaChangedL
       
  1184 //
       
  1185 // Default error handling for all messaging editors and viewers.
       
  1186 // HandleMediaChangedL is called when the messaging storage has
       
  1187 // been moved into another disk, This means that the current
       
  1188 // message entry is not valid any more. This function creates
       
  1189 // new entry in the new messaging store, in order to enable saving
       
  1190 // the message. The new entry is left in InPreparation state, so
       
  1191 // that it will be deleted if the application (e.g. viewer) does
       
  1192 // not save anything in it.
       
  1193 // ---------------------------------------------------------
       
  1194 //
       
  1195 EXPORT_C void CMsgEditorAppUi::HandleMediaChangedL()
       
  1196     {
       
  1197     if( iMmcFeatureSupported )
       
  1198         {
       
  1199         // create new InPreparation entry in the new messaging store.
       
  1200         CMsgEditorDocument* doc = Document();
       
  1201         doc->CreateNewL( doc->DefaultMsgService(), doc->DefaultMsgFolder() );
       
  1202         }
       
  1203     }
       
  1204 
       
  1205 // ---------------------------------------------------------
       
  1206 // CMsgEditorAppUi::HandleMediaUnavailableL
       
  1207 //
       
  1208 // Default error handling for all messaging editors and viewers.
       
  1209 // The media state is recorded in model and default action in AppUi
       
  1210 // is to display warning message to the user.
       
  1211 // ---------------------------------------------------------
       
  1212 //
       
  1213 EXPORT_C void CMsgEditorAppUi::HandleMediaUnavailableL()
       
  1214     {
       
  1215     if( iMmcFeatureSupported )
       
  1216         {
       
  1217         ProcessCommandL( EAknCmdExit );
       
  1218         }
       
  1219     }
       
  1220 
       
  1221 // ---------------------------------------------------------
       
  1222 // CMsgEditorAppUi::HandleMediaAvailableL
       
  1223 //
       
  1224 // Default error handling for all messaging editors and viewers.
       
  1225 // No action made by default, the media state is recorded in model.
       
  1226 // ---------------------------------------------------------
       
  1227 //
       
  1228 EXPORT_C void CMsgEditorAppUi::HandleMediaAvailableL()
       
  1229     {
       
  1230     // no action
       
  1231     }
       
  1232 
       
  1233 // ---------------------------------------------------------
       
  1234 // CMsgEditorAppUi::HandleMediaIncorrectL
       
  1235 //
       
  1236 // Default error handling for all messaging editors and viewers.
       
  1237 // The media state is recorded in model, and warning note is displayed
       
  1238 // to the user here.
       
  1239 // ---------------------------------------------------------
       
  1240 //
       
  1241 EXPORT_C void CMsgEditorAppUi::HandleMediaIncorrectL()
       
  1242     {
       
  1243     if( iMmcFeatureSupported )
       
  1244         {
       
  1245         ViewErrorL( KMsvMediaIncorrect );
       
  1246         }
       
  1247     }
       
  1248 
       
  1249 // ---------------------------------------------------------
       
  1250 // CMsgEditorAppUi::HandleCorruptedIndexRebuildingL
       
  1251 //
       
  1252 // Default error handling for all messaging editors and viewers.
       
  1253 // The default action is to put busy note on the screen. The busy
       
  1254 // note will be displayed while the index is being rebuilt - until
       
  1255 // we get "index rebuilt" event in HandleCorruptedIndexRebuiltL().
       
  1256 // ---------------------------------------------------------
       
  1257 //
       
  1258 EXPORT_C void CMsgEditorAppUi::HandleCorruptedIndexRebuildingL()
       
  1259     {
       
  1260     HBufC* line = iEikonEnv->AllocReadResourceLC( R_MEB_N_IN_REBUILDING_INDEX );
       
  1261     iEikonEnv->BusyMsgL( *line );
       
  1262     CleanupStack::PopAndDestroy( line );  // line
       
  1263     }
       
  1264 
       
  1265 // ---------------------------------------------------------
       
  1266 // CMsgEditorAppUi::HandleCorruptedIndexRebuiltL
       
  1267 //
       
  1268 // Default error handling for all messaging editors and viewers.
       
  1269 // The default action is to remove the busy note displayed when
       
  1270 // the index rebuilding event was received.
       
  1271 // ---------------------------------------------------------
       
  1272 //
       
  1273 EXPORT_C void CMsgEditorAppUi::HandleCorruptedIndexRebuiltL()
       
  1274     {
       
  1275     iEikonEnv->BusyMsgCancel();
       
  1276     }
       
  1277 
       
  1278 // ---------------------------------------------------------
       
  1279 // CMsgEditorAppUi::CreateCustomControlL
       
  1280 //
       
  1281 // Default implementation is NULL since viewers do not need this.
       
  1282 // ---------------------------------------------------------
       
  1283 //
       
  1284 EXPORT_C CMsgBaseControl* CMsgEditorAppUi::CreateCustomControlL( TInt /*aControlType*/ )
       
  1285     {
       
  1286     return NULL;
       
  1287     }
       
  1288 
       
  1289 // ---------------------------------------------------------
       
  1290 // CMsgEditorAppUi::IsLaunchedL
       
  1291 //
       
  1292 // Checks if document has finished launching.
       
  1293 // ---------------------------------------------------------
       
  1294 //
       
  1295 EXPORT_C TBool CMsgEditorAppUi::IsLaunchedL() const
       
  1296     {
       
  1297     return Document()->IsLaunched();
       
  1298     }
       
  1299 
       
  1300 // ---------------------------------------------------------
       
  1301 // CMsgEditorAppUi::EditorObserver
       
  1302 //
       
  1303 // Default implementation.
       
  1304 // ---------------------------------------------------------
       
  1305 //
       
  1306 EXPORT_C void CMsgEditorAppUi::EditorObserver(
       
  1307     TMsgEditorObserverFunc aFunc,
       
  1308     TAny* /*aArg1*/,
       
  1309     TAny* aArg2,
       
  1310     TAny* /*aArg3*/ )
       
  1311     {
       
  1312     switch (aFunc)
       
  1313         {
       
  1314         case EMsgDenyClipboardOperation:
       
  1315             {
       
  1316             TInt* ret = static_cast<TInt*>( aArg2 );
       
  1317             *ret = 0;
       
  1318             }
       
  1319             break;
       
  1320 
       
  1321         case EMsgHandleFocusChange:
       
  1322         default:
       
  1323             break;
       
  1324         }
       
  1325     }
       
  1326 
       
  1327 
       
  1328 // ---------------------------------------------------------
       
  1329 // CMsgEditorAppUi::DoMtmCmdL
       
  1330 //
       
  1331 // Get services from mtm's and offers them to APP UI.
       
  1332 // ---------------------------------------------------------
       
  1333 //
       
  1334 void CMsgEditorAppUi::DoMtmCmdL( const TUid& /*aQuery*/, TInt aCmd ) const
       
  1335     {
       
  1336     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1337     CleanupStack::PushL( selection );
       
  1338     selection->AppendL( Document()->Entry().Id() );
       
  1339     TBuf8<1> null;
       
  1340     TMsvId origMessageId = Document()->Entry().Id();
       
  1341     Document()->MtmUi().InvokeSyncFunctionL( aCmd, *selection, null );
       
  1342     CleanupStack::PopAndDestroy( selection );  // selection
       
  1343     Document()->SetEntryL( origMessageId );
       
  1344     }
       
  1345 
       
  1346 // ---------------------------------------------------------
       
  1347 // CMsgEditorAppUi::ViewErrorL
       
  1348 //
       
  1349 // Helper function for Handle... methods.
       
  1350 // ---------------------------------------------------------
       
  1351 //
       
  1352 void CMsgEditorAppUi::ViewErrorL( TInt aTitle )
       
  1353     {
       
  1354     // TODO: check if app in foreground and show error note only then.
       
  1355     CErrorUI* errorUI = CErrorUI::NewLC( *iCoeEnv );
       
  1356     errorUI->ShowGlobalErrorNoteL( aTitle );
       
  1357     CleanupStack::PopAndDestroy( errorUI ); // errorUI
       
  1358     }
       
  1359 
       
  1360 // ---------------------------------------------------------
       
  1361 // CMsgEditorAppUi::HandleResourceChangeL
       
  1362 //
       
  1363 //
       
  1364 // ---------------------------------------------------------
       
  1365 //
       
  1366 EXPORT_C void CMsgEditorAppUi::HandleResourceChangeL(TInt aType)
       
  1367     {
       
  1368     CAknAppUi::HandleResourceChangeL( aType );
       
  1369     if ( iView )
       
  1370         {
       
  1371         iView->HandleResourceChange( aType );
       
  1372         }
       
  1373     
       
  1374     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  1375         {
       
  1376         iStatusPaneRes = StatusPane()->CurrentLayoutResId();
       
  1377         }
       
  1378     }
       
  1379 
       
  1380 // ---------------------------------------------------------
       
  1381 // CMsgEditorAppUi::SaveBodyL
       
  1382 //
       
  1383 //
       
  1384 // ---------------------------------------------------------
       
  1385 //
       
  1386 void CMsgEditorAppUi::SaveBodyL( CMsgBodyControl* aBody )
       
  1387     {
       
  1388     CEikRichTextEditor* bodyEditor = &aBody->Editor();
       
  1389     if ( bodyEditor )
       
  1390         {
       
  1391         CRichText* richText = bodyEditor->RichText();
       
  1392         if ( richText )
       
  1393             {
       
  1394             TInt len = richText->DocumentLength();
       
  1395             if ( len )
       
  1396                 {
       
  1397                 HBufC* buf = HBufC::NewLC( len );
       
  1398                 TPtr ptr = buf->Des();
       
  1399                 richText->Extract( ptr, 0 );
       
  1400                 CNotepadApi::AddContentL( ptr );
       
  1401                 CleanupStack::PopAndDestroy( buf );
       
  1402                 }
       
  1403             }
       
  1404         } 
       
  1405     }
       
  1406 
       
  1407 // ---------------------------------------------------------
       
  1408 // CMsgEditorAppUi::ShowCloseQueryL
       
  1409 // ---------------------------------------------------------
       
  1410 //
       
  1411 EXPORT_C TInt CMsgEditorAppUi::ShowCloseQueryL()
       
  1412     {
       
  1413     TInt selectedIndex( 0 );
       
  1414     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
       
  1415     dlg->PrepareLC( R_MEB_CLOSE_QUERY );
       
  1416     if ( dlg->RunLD() )
       
  1417         {
       
  1418         return ( selectedIndex == 0 )
       
  1419             ? EMsgCloseSave
       
  1420             : EMsgCloseDelete;
       
  1421         }
       
  1422     else
       
  1423         {
       
  1424         return EMsgCloseCancel;
       
  1425         }
       
  1426     }
       
  1427 
       
  1428 // ---------------------------------------------------------
       
  1429 // CMsgEditorAppUi::CreateSubjectPrefixStringL
       
  1430 // ---------------------------------------------------------
       
  1431 //
       
  1432 EXPORT_C HBufC* CMsgEditorAppUi::CreateSubjectPrefixStringL(
       
  1433         const TDesC& aSubject,
       
  1434         TBool aReply )
       
  1435     {
       
  1436     HBufC* newSubject = NULL;
       
  1437     TInt subjectLength = aSubject.Length();
       
  1438     if ( subjectLength >= 0 )
       
  1439         {
       
  1440         TInt formatResource = aReply
       
  1441             ? R_MSG_REPLY_PREFIX
       
  1442             : R_MSG_FORWARD_PREFIX;
       
  1443 
       
  1444         HBufC* subjectFormat = StringLoader::LoadLC(
       
  1445             formatResource,
       
  1446             iCoeEnv );
       
  1447         
       
  1448         HBufC* filteredSubject = RemovePrefixesL( aSubject );    
       
  1449         CleanupStack::PushL( filteredSubject );
       
  1450         
       
  1451         if ( filteredSubject->Length() > 0 )
       
  1452         	{
       
  1453 	        // Create a buffer large enough to hold the re-formated subject
       
  1454 	        newSubject = HBufC::NewL( subjectLength + subjectFormat->Length());
       
  1455 	        
       
  1456 	        TPtr ptr( newSubject->Des() );            
       
  1457 	        ptr.Append( *subjectFormat );
       
  1458 	        ptr.Append( *filteredSubject );	        
       
  1459         	}
       
  1460         else
       
  1461         	{
       
  1462         	newSubject = HBufC::NewL( 0 );
       
  1463         	}
       
  1464         
       
  1465         CleanupStack::PopAndDestroy( filteredSubject );
       
  1466         CleanupStack::PopAndDestroy( subjectFormat );
       
  1467         }
       
  1468     return newSubject;
       
  1469     }
       
  1470 
       
  1471 // ---------------------------------------------------------
       
  1472 // CMsgEditorAppUi::RemovePrefixesL
       
  1473 // ---------------------------------------------------------
       
  1474 //
       
  1475 HBufC* CMsgEditorAppUi::RemovePrefixesL( const TDesC& aSubject )
       
  1476     {
       
  1477     // filter setup
       
  1478     RPointerArray<TDesC> prefixArray;
       
  1479     CleanupClosePushL( prefixArray );
       
  1480     
       
  1481     // add prefixes to remove
       
  1482     TPtrC filterRe( KMsgEditorAppUiFilterRe );
       
  1483     prefixArray.AppendL( &filterRe );  
       
  1484     
       
  1485     TPtrC filterFw( KMsgEditorAppUiFilterFw );
       
  1486     prefixArray.AppendL( &filterFw );
       
  1487     
       
  1488     TPtrC filterFwd( KMsgEditorAppUiFilterFwd );
       
  1489     prefixArray.AppendL( &filterFwd ); 
       
  1490     
       
  1491     // corresponding prefixes for the current language variant
       
  1492     HBufC* prefixReply = StringLoader::LoadLC( R_MSG_REPLY_PREFIX, iCoeEnv );
       
  1493     TPtr prefixReplyPtr = prefixReply->Des();
       
  1494     prefixReplyPtr.Trim();        
       
  1495     prefixArray.AppendL( &prefixReplyPtr );
       
  1496     
       
  1497     HBufC* prefixForward = StringLoader::LoadLC( R_MSG_FORWARD_PREFIX, iCoeEnv );
       
  1498     TPtr prefixForwardPtr = prefixForward->Des();
       
  1499     prefixForwardPtr.Trim();
       
  1500     prefixArray.AppendL( &prefixForwardPtr );
       
  1501     
       
  1502     // Remove prefixes 
       
  1503     HBufC* subject = aSubject.AllocL();
       
  1504     TPtr ptr( subject->Des() );
       
  1505     TBool prefixFound;
       
  1506     // Search until no prefixes found
       
  1507     do
       
  1508         {
       
  1509         // Loop all prefixes
       
  1510         prefixFound = EFalse;
       
  1511         ptr.TrimLeft();
       
  1512         for ( TInt i = 0; i < prefixArray.Count(); i++ )  
       
  1513             {
       
  1514             TPtrC prefix( *prefixArray[i] );
       
  1515             
       
  1516             // Remove prefixes while same prefix found at begining of subject    
       
  1517             while ( ptr.FindC( prefix ) == 0 )
       
  1518                 {
       
  1519                 ptr.Delete( 0, prefix.Length() ); 
       
  1520                 prefixFound = ETrue;
       
  1521                 ptr.TrimLeft();
       
  1522                 }
       
  1523             }
       
  1524         } while ( prefixFound );
       
  1525     
       
  1526     CleanupStack::PopAndDestroy(3, &prefixArray ); 
       
  1527     
       
  1528     return subject;        
       
  1529     }    
       
  1530 // ---------------------------------------------------------
       
  1531 // CMsgEditorAppUi::LockEntryL
       
  1532 //
       
  1533 //
       
  1534 // ---------------------------------------------------------
       
  1535 //
       
  1536 EXPORT_C void CMsgEditorAppUi::LockEntryL()
       
  1537     {
       
  1538     if ( iLock == NULL )
       
  1539         {
       
  1540         iLock = CLock::LockL( *Document() );
       
  1541         }
       
  1542     }
       
  1543 
       
  1544 // ---------------------------------------------------------
       
  1545 // CMsgEditorAppUi::UnlockEntry
       
  1546 //
       
  1547 //
       
  1548 // ---------------------------------------------------------
       
  1549 //
       
  1550 EXPORT_C void CMsgEditorAppUi::UnlockEntry()
       
  1551     {
       
  1552     delete iLock;
       
  1553     iLock = NULL;
       
  1554     }
       
  1555 
       
  1556 // ---------------------------------------------------------
       
  1557 // CMsgEditorAppUi::IsLockedEntry
       
  1558 //
       
  1559 //
       
  1560 // ---------------------------------------------------------
       
  1561 //
       
  1562 EXPORT_C TBool CMsgEditorAppUi::IsLockedEntry() const
       
  1563     {
       
  1564     return iLock != NULL;
       
  1565     }
       
  1566 
       
  1567 // ---------------------------------------------------------
       
  1568 // CMsgEditorAppUi::Exit
       
  1569 //
       
  1570 //
       
  1571 // ---------------------------------------------------------
       
  1572 //
       
  1573 EXPORT_C void CMsgEditorAppUi::Exit( TInt aReason /*= EEikCmdExit*/ )
       
  1574 	{
       
  1575 #ifdef RD_MSG_FAST_PREV_NEXT
       
  1576     // Communicate message id via publish and subscribe to MCE
       
  1577     RProperty::Set( KPSUidMuiu, KMuiuKeyCurrentMsg,
       
  1578         Document()->Entry().Id() );
       
  1579 #endif // RD_MSG_FAST_PREV_NEXT
       
  1580 
       
  1581 	CEikAppServer* server = iEikonEnv->AppServer();
       
  1582 	if ( server )
       
  1583         {
       
  1584 		server->NotifyServerExit( aReason );
       
  1585         }
       
  1586 	CEikAppUi::Exit();
       
  1587 	}
       
  1588 
       
  1589 // ---------------------------------------------------------
       
  1590 // CMsgEditorAppUi::HandleLocalZoomChangeL
       
  1591 // ---------------------------------------------------------
       
  1592 //
       
  1593 EXPORT_C void CMsgEditorAppUi::HandleLocalZoomChangeL( TMsgCommonCommands aNewZoom )
       
  1594     {
       
  1595     TInt localZoom = 0;
       
  1596     TInt oldLocalZoom = EAknUiZoomAutomatic;
       
  1597     CRepository* repository = CRepository::NewL( KCRUidMessagingUiSettings );
       
  1598     TInt ret = repository->Get( KMessagingEditorLocalUiZoom, oldLocalZoom );
       
  1599     if ( ret == KErrNone )
       
  1600         {
       
  1601         switch( aNewZoom )
       
  1602             {
       
  1603             case EMsgDispSizeAutomatic:
       
  1604                 {
       
  1605                 localZoom = EAknUiZoomAutomatic;
       
  1606                 break;
       
  1607                 }
       
  1608             case EMsgDispSizeLarge:
       
  1609                 {
       
  1610                 localZoom = EAknUiZoomLarge;
       
  1611                 break;
       
  1612                 }
       
  1613             case EMsgDispSizeNormal:
       
  1614                 {
       
  1615                 localZoom = EAknUiZoomNormal;
       
  1616                 break;
       
  1617                 }
       
  1618             case EMsgDispSizeSmall:
       
  1619                 {
       
  1620                 localZoom = EAknUiZoomSmall;
       
  1621                 break;
       
  1622                 }
       
  1623             default:
       
  1624                 break; 
       
  1625             }
       
  1626         if( oldLocalZoom != localZoom )
       
  1627             {
       
  1628             ret = repository->Set( KMessagingEditorLocalUiZoom, localZoom );
       
  1629             __ASSERT_DEBUG( !ret, Panic( EMsgRepositorySettingFailure ) );
       
  1630             TWsEvent event; 
       
  1631             event.SetType( KAknLocalZoomLayoutSwitch ); 
       
  1632             ret = iEikonEnv->WsSession().SendEventToAllWindowGroups( event );
       
  1633             }
       
  1634         }
       
  1635 
       
  1636     delete repository;          
       
  1637     }
       
  1638     
       
  1639 // ---------------------------------------------------------
       
  1640 // CMsgEditorAppUi::CreateViewerNaviPaneL
       
  1641 // ---------------------------------------------------------
       
  1642 //
       
  1643 EXPORT_C void CMsgEditorAppUi::CreateViewerNaviPaneL( TTime aTime, 
       
  1644                                                       TMsgEditorMsgPriority aPriority,
       
  1645                                                       TBool aUtcTime )
       
  1646     {
       
  1647     CAknNavigationControlContainer* naviContainer = 
       
  1648         static_cast<CAknNavigationControlContainer*>( StatusPane()->ControlL( 
       
  1649                                                             TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  1650     if ( !iNaviDecorator )
       
  1651         {
       
  1652         CMsgNaviPaneControl* naviPaneControl = CMsgNaviPaneControl::NewL( naviContainer );
       
  1653         naviPaneControl->SetNavigationControlObserver( this );
       
  1654         
       
  1655         // naviPaneControl ownership transferred to iNaviDecorator.
       
  1656         iNaviDecorator = CAknNavigationDecorator::NewL( naviContainer, naviPaneControl );
       
  1657         
       
  1658         naviPaneControl->SetTimeIndicatorL( aTime, aUtcTime );
       
  1659         naviPaneControl->SetPriorityIndicatorL( aPriority );
       
  1660         
       
  1661         CMsgEditorDocument* doc = Document();
       
  1662         naviPaneControl->SetNavigationIndicatorL( doc->Session(), doc->Entry() );
       
  1663         
       
  1664         // this function will always be called when viwer is launched
       
  1665         // always navi decorater will be created.
       
  1666         // refer navi decorator iterator instance here
       
  1667         iIterator =  naviPaneControl->GetMessageIterator();
       
  1668         iIterator->SetMessageIteratorObserver( this );
       
  1669         
       
  1670         iNaviDecorator->SetContainerWindowL( *naviContainer );
       
  1671         iNaviDecorator->MakeScrollButtonVisible( EFalse );
       
  1672         iNaviDecorator->SetComponentsToInheritVisibility( ETrue );
       
  1673         iOwnNaviPane = NULL;
       
  1674         }
       
  1675     else
       
  1676         {
       
  1677         User::Leave( KErrAlreadyExists );
       
  1678         }
       
  1679     }
       
  1680 
       
  1681 // ---------------------------------------------------------
       
  1682 // CMsgEditorAppUi::HandleNavigationControlEventL
       
  1683 // ---------------------------------------------------------
       
  1684 //
       
  1685 EXPORT_C void CMsgEditorAppUi::HandleNavigationControlEventL( TMsgNaviControlEventId aEvent )
       
  1686     {
       
  1687     if ( aEvent ==  MMsgNaviPaneControlObserver::EMsgNaviLeftArrowPressed ||
       
  1688          aEvent == MMsgNaviPaneControlObserver::EMsgNaviRightArrowPressed )
       
  1689         {
       
  1690         if ( IsNextMessageAvailableL( aEvent == MMsgNaviPaneControlObserver::EMsgNaviRightArrowPressed ) )
       
  1691             {
       
  1692             /* no need for separate checks for right and left arrows
       
  1693             because IsNextMessageAvailableL() and NextMessageL
       
  1694             are called with the truth-value of the same comparison */
       
  1695             NextMessageL( aEvent == MMsgNaviPaneControlObserver::EMsgNaviRightArrowPressed );
       
  1696             } 
       
  1697         }
       
  1698     }
       
  1699 
       
  1700 // ---------------------------------------------------------
       
  1701 // CMsgEditorAppUi::CLock::LockL
       
  1702 //
       
  1703 //
       
  1704 // ---------------------------------------------------------
       
  1705 //
       
  1706 CMsgEditorAppUi::CLock* CMsgEditorAppUi::CLock::LockL(
       
  1707     const CMsgEditorDocument& aDoc)
       
  1708     {
       
  1709     CLock* lock = new ( ELeave ) CLock();
       
  1710     CleanupStack::PushL( lock );
       
  1711     
       
  1712     lock->iStore = aDoc.CurrentEntry().EditStoreL();
       
  1713     lock->iStream.AssignL( *( lock->iStore ), KMsvEntryRichTextBody );
       
  1714     
       
  1715     CleanupStack::Pop( lock );
       
  1716     return lock;
       
  1717     }
       
  1718 
       
  1719 // ---------------------------------------------------------
       
  1720 // CMsgEditorAppUi::CLock::CLock
       
  1721 //
       
  1722 //
       
  1723 // ---------------------------------------------------------
       
  1724 //
       
  1725 CMsgEditorAppUi::CLock::CLock()
       
  1726     {
       
  1727     }
       
  1728 
       
  1729 // ---------------------------------------------------------
       
  1730 // CMsgEditorAppUi::CLock::~CLock
       
  1731 //
       
  1732 //
       
  1733 // ---------------------------------------------------------
       
  1734 //
       
  1735 CMsgEditorAppUi::CLock::~CLock()
       
  1736     {
       
  1737     if ( iStore != NULL )
       
  1738         {
       
  1739         iStream.Release();
       
  1740         iStream.Close();
       
  1741         iStore->Revert();
       
  1742         delete iStore;
       
  1743         }
       
  1744     }
       
  1745 
       
  1746 // ---------------------------------------------------------
       
  1747 // CMsgEditorAppUi::CanFastOpenL
       
  1748 // ---------------------------------------------------------
       
  1749 //
       
  1750 EXPORT_C TBool CMsgEditorAppUi::CanFastOpenL( const CMessageIterator& /*aIterator*/ )
       
  1751     {
       
  1752     return EFalse;
       
  1753     }
       
  1754 
       
  1755 // ---------------------------------------------------------
       
  1756 // CMsgEditorAppUi::AknInputBlockCancel
       
  1757 // ---------------------------------------------------------
       
  1758 //
       
  1759 EXPORT_C void CMsgEditorAppUi::AknInputBlockCancel()
       
  1760     {
       
  1761     if ( iInputBlocker )
       
  1762         {
       
  1763         iInputBlocker->MakeVisible( EFalse );
       
  1764         iInputBlocker->ControlEnv()->AppUi()->RemoveFromStack( iInputBlocker );
       
  1765         }
       
  1766     }
       
  1767 
       
  1768 // ---------------------------------------------------------
       
  1769 // CMsgEditorAppUi::SetTitleIconSizeL
       
  1770 // ---------------------------------------------------------
       
  1771 //
       
  1772 EXPORT_C void CMsgEditorAppUi::SetTitleIconSizeL( CFbsBitmap* aTitleBitmap )
       
  1773     {
       
  1774     TRect mainPane;
       
  1775     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, mainPane );
       
  1776     TAknLayoutRect titleIconPaneLayoutRect;
       
  1777     
       
  1778     if ( AknStatuspaneUtils::StaconPaneActive() )
       
  1779         {
       
  1780         titleIconPaneLayoutRect.LayoutRect( mainPane,
       
  1781                                             AknLayoutScalable_Avkon::title_pane_stacon_g1( 0 ).LayoutLine() );
       
  1782         }
       
  1783     else
       
  1784         {
       
  1785         titleIconPaneLayoutRect.LayoutRect( mainPane,
       
  1786                                             AknLayoutScalable_Avkon::title_pane_g2( 0 ).LayoutLine() );
       
  1787         }
       
  1788     
       
  1789     TSize iconSize = titleIconPaneLayoutRect.Rect().Size();
       
  1790 
       
  1791     User::LeaveIfError( AknIconUtils::SetSize( aTitleBitmap, iconSize, EAspectRatioPreserved ) );
       
  1792     }
       
  1793 
       
  1794 // ---------------------------------------------------------
       
  1795 // CMsgEditorAppUi::HandleStatusPaneSizeChange
       
  1796 //
       
  1797 // Performs layout switch on view area if statuspane is changed to 
       
  1798 // same statuspane that is used by CMsgEditorAppUi. This is for
       
  1799 // correcting the layout if layout switch was performed when 
       
  1800 // SMIL player or SMIL editor that use different statuspane
       
  1801 // were displayed. Without this the layout would be shown as if
       
  1802 // statuspane that SMIL components use would be used.
       
  1803 // ---------------------------------------------------------
       
  1804 //
       
  1805 EXPORT_C void CMsgEditorAppUi::HandleStatusPaneSizeChange()
       
  1806     {
       
  1807     CAknAppUi::HandleStatusPaneSizeChange();
       
  1808     
       
  1809     if ( iView &&
       
  1810          iStatusPaneRes == StatusPane()->CurrentLayoutResId() )
       
  1811         {
       
  1812         iView->HandleResourceChange( KEikDynamicLayoutVariantSwitch );
       
  1813         }
       
  1814     }
       
  1815 
       
  1816 //  End of File