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