mobilemessaging/unieditor/application/src/UniEditorAppUi.cpp
branchRCL_3
changeset 27 7fdbb852d323
child 28 fc3320e39880
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Provides Uni Editor App UI methods. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19  
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 // Symbian OS
       
    23 #include <apmstd.h>                 // TDataType, KMaxDataTypeLength 
       
    24 #include <data_caging_path_literals.hrh> 
       
    25 #include <eiklbv.h>
       
    26 
       
    27 // Messaging
       
    28 #include <msvapi.h>
       
    29 #include <msvuids.h>                // Msgs Uids
       
    30 #include <msvstd.hrh>               // KUidMsvMessageEntryValue
       
    31 #include <mtmdef.h>                 // TMsvPartList
       
    32 #include <mtmuidef.hrh>             // EMtmUiFlagEditorPreferEmbedded
       
    33 #include <MtmExtendedCapabilities.hrh>  // function id of MessageInfo
       
    34 
       
    35 // Eikon
       
    36 #include <eikedwin.h>               // Editor TextLenght etc
       
    37 #include <eikrted.h>                // for CEikRichTextEditor
       
    38 #include <eikcolib.h>
       
    39 #include <DocumentHandler.h>
       
    40 
       
    41 // Avkon
       
    42 #include <aknenv.h>
       
    43 #include <aknnavi.h>
       
    44 #include <aknnavide.h>              // CAknNavigationDecorator
       
    45 #include <aknnavilabel.h>
       
    46 #include <aknEditStateIndicator.h> 
       
    47 #include <AknIndicatorContainer.h> 
       
    48 #include <akntitle.h>
       
    49 #include <aknclearer.h>
       
    50 #include <AknsConstants.h>
       
    51 #include <AknInfoPopupNoteController.h>
       
    52 #include <akninputblock.h>            // for CAknInputBlock
       
    53 #include <aknbutton.h>
       
    54 
       
    55 #include <aknlayoutscalable_apps.cdl.h>
       
    56 #include <aknlayoutscalable_avkon.cdl.h>
       
    57 
       
    58 #include <aknnotewrappers.h>        // CAknNoteWrappers
       
    59 #include <aknnotedialog.h>          // CAknNoteDialog
       
    60 #include <AknQueryDialog.h>         // CAknQueryDialog
       
    61 #include <AknWaitDialog.h>          // CAknWaitDialog
       
    62 #include <akncheckboxsettingpage.h>     // also CSelectionItemList and CSelectableItem
       
    63 #include <aknsettingpage.h>         // for Priority bit dialog
       
    64 #include <aknradiobuttonsettingpage.h>
       
    65 #include <akntoolbar.h>
       
    66 #include <akntoolbarextension.h>
       
    67 #include <AknIconArray.h>           // CAknIconArray
       
    68 #include <avkon.mbg>                // 
       
    69 #include <AknStatuspaneUtils.h>     // AknStatuspaneUtils
       
    70 #include <AknUtils.h>
       
    71 
       
    72 #include <AknFepGlobalEnums.h>              // Global Fep enums (ELatin, ENumber)
       
    73 #include <AknFepInternalCRKeys.h>
       
    74 
       
    75 // Misc
       
    76 #include <txtrich.h>                // for CRichText
       
    77 #include <badesca.h>                // CDesC16Array
       
    78 #include <barsread.h>               // TResReader
       
    79 
       
    80 // MUIU
       
    81 #include <MuiuOperationWait.h>      // CMuiuOperationWait
       
    82 #include <MuiuMsvUiServiceUtilities.h>  //Disk space check, offline check
       
    83 #include <muiumsvuiserviceutilitiesinternal.h> 
       
    84 
       
    85 #include <fileprotectionresolver.h>
       
    86 
       
    87 // Common components
       
    88 #include <StringLoader.h>           // for StringLoader (load and foramt strings from resources)
       
    89 #include <AiwGenericParam.h>        // CAiwGenericParamList
       
    90 
       
    91 // Base editor 
       
    92 #include <MsgRecipientItem.h>       // for CMsgRecipientItem
       
    93 #include <MsgAttachmentUtils.h>     // for MsgAttachmentUtils
       
    94 #include <MsgBaseControl.h>         // for CMsgBaseControl
       
    95 #include <MsgBodyControl.h>         // for CMsgBodyControl
       
    96 #include <MsgAddressControl.h>      // for CMsgAddressControl
       
    97 #include <MsgEditorView.h>          // for CMsgEditorView
       
    98 #include <MsgEditor.hrh>            // for TMsgIndicatorFlags
       
    99 #include <msgimagecontrol.h>        // for CMsgImageControl
       
   100 #include <MsgAttachmentModel.h>     // for CMsgAttachmentModel
       
   101 #include <MsgEditorCommon.h>
       
   102 
       
   103 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension
       
   104 #include <MsgEditorSettingCacheUpdatePlugin.h>
       
   105 
       
   106 // MmsEngine
       
   107 #include <mmsgenutils.h>
       
   108 
       
   109 // Features
       
   110 #include <featmgr.h>    
       
   111 #include <messagingvariant.hrh>
       
   112 
       
   113 #include <centralrepository.h>    // link against centralrepository.lib
       
   114 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
   115 #include <CoreApplicationUIsSDKCRKeys.h>
       
   116 
       
   117 #include <RCustomerServiceProfileCache.h>   // CSP bits
       
   118 
       
   119 // HELP
       
   120 #include <hlplch.h>
       
   121 #include <csxhelp/unif.hlp.hrh>
       
   122 
       
   123 // SMIL Player
       
   124 #include <MMediaFactoryFileInfo.h>
       
   125 #include <SmilPlayerDialog.h>
       
   126 
       
   127 // Other SMIL stuff
       
   128 #include <gmxmldocument.h>
       
   129 
       
   130 // MsgMedia
       
   131 #include <MsgMimeTypes.h>
       
   132 #include <MsgAudioInfo.h>
       
   133 #include <MsgVideoInfo.h>
       
   134 #include <MsgImageInfo.h>
       
   135 #include <MsgTextInfo.h>
       
   136 #include <MsgMediaResolver.h>
       
   137 #include <MsgMedia.hrh>
       
   138 #include <MmsConformance.h>
       
   139 
       
   140 // Resource identifiers
       
   141 #include <UniEditor.rsg>
       
   142 #include <MsgEditorAppUi.rsg>
       
   143 
       
   144 #include <akndiscreetpopup.h>
       
   145 #include <aknsconstants.hrh>
       
   146 
       
   147 #include "UniSendingSettings.h"
       
   148 #include "UniPluginApi.h"
       
   149 #include "UniSmsPlugin.h"
       
   150 #include "UniClientMtm.h"
       
   151 
       
   152 /// UniEditor other component
       
   153 #include "uniutils.h"               // Object type flags, MBM filename
       
   154 #include <uniutils.mbg>  
       
   155 #include <unimsventry.h>          
       
   156 #include "unislideloader.h"
       
   157 #include "unidatautils.h"
       
   158 #include "uniobjectlist.h"
       
   159 #include "unidatamodel.h"             // CUniDataModel
       
   160 #include "unismilmodel.h"           // CUniSmilModel
       
   161 #include "unimodelconst.h"          // Uni constants
       
   162 #include "uniobjectsmodel.h"        // Model part of the objects view 
       
   163 #include "unitextobject.h"
       
   164 #include "unimimeinfo.h"
       
   165 #include "uniobjectsviewdialog.h"
       
   166 #include "unidrminfo.h"
       
   167 
       
   168 // This must be included after unidatamodel.h as both GMXMParserxxx and this define KNewLine
       
   169 #include <aknconsts.h>              // KAvkonBitmapFile
       
   170 
       
   171 // UniEditor application
       
   172 #include "UniEditorApp.h"           // To get app UID
       
   173 #include "UniEditorEnum.h"          // Panic codes
       
   174 #include "UniEditorApp.hrh"            // application specific commands
       
   175 #include "UniEditorAppUi.h"         // MmsEditorAppUi class
       
   176 #include "UniEditorHeader.h"
       
   177 #include "UniEditorChangeSlideOperation.h"
       
   178 #include "UniEditorInsertOperation.h"
       
   179 #include "UniEditorLaunchOperation.h"
       
   180 #include "UniEditorSaveOperation.h"
       
   181 #include "UniEditorSendOperation.h"
       
   182 #include "UniEditorVCardOperation.h"
       
   183 #include "UniEditorAddHeaderDialog.h"
       
   184 #include "UniSendingSettingsDialog.h"
       
   185 #include "UniEditorLogging.h"
       
   186 
       
   187 #include <gsmuelem.h>     // Turkish SMS-PREQ2265 specific
       
   188 #include <aknstyluspopupmenu.h> //Added for displaying object specific stylus menus in editor
       
   189 // ========== LOCAL CONSTANTS AND MACROS ===================
       
   190 
       
   191 // SMS related
       
   192 
       
   193 // Character count used in unicode check buffer
       
   194 const TInt KUnicodeCheckChars = 10;
       
   195 
       
   196 // Downwards arrow with tip leftwards
       
   197 // This does not count as unconvertible character as it will be
       
   198 // replaced by paragraph separator or line feed by UI
       
   199 const TUint KSmsDownwardsArrowLeft = 0x21B2;
       
   200 
       
   201 const TInt  KSmsEdPDUInfoCalcReplaceCharacterCount = 2;
       
   202 const TUint KSmsEdUnicodeLFSupportedByBasicPhones = 0x000A;
       
   203 const TUint KSmsEnterCharacter = 0x2029;
       
   204 // Unicode char codes for GSM 03.38 7 bit ext table characters 
       
   205 const TUint KUniEdEuroSymbol = 0x20ac;
       
   206 const TUint KUniEdLeftSquareBracket = 0x5b;
       
   207 const TUint KUniEdReverseSolidus = 0x5c;
       
   208 const TUint KUniEdRightSquareBracket = 0x5d;
       
   209 const TUint KUniEdCircumflexAccent = 0x5e;
       
   210 const TUint KUniEdLeftCurlyBracket = 0x7b;
       
   211 const TUint KUniEdVerticalLine = 0x7c;
       
   212 const TUint KUniEdRightCurlyBracket = 0x7d;
       
   213 const TUint KUniEdTilde = 0x7e;
       
   214 const TUid  KUniEditorAppId = { 0x102072D8 };
       
   215 
       
   216 // Amount of chars reserved for msg length and message count indication text
       
   217 const TInt KMsgLengthIndicationBuffer = 64;
       
   218 
       
   219 // Bytes. Estimated disk space needed in addition to filesize when file is created as an attachment.
       
   220 const TInt  KUniAttachmentOverhead          = 1024; 
       
   221 
       
   222 // Some functions determine and return the info note 
       
   223 // resource id at error situations. When not determined
       
   224 // this value is returned.  
       
   225 const TInt  KUniInvalidResourceId           = -1;   
       
   226 
       
   227 // Non-empty par tag + one media object takes ~90 bytes
       
   228 const TInt  KEmptySlideSize                 = 90;  
       
   229 
       
   230 // Kilobyte is 1024 not 1000 bytes 
       
   231 const TInt  KBytesInKilo                    = 1024; 
       
   232 
       
   233 // Kilobyte limit when to stop showing message size
       
   234 // with kilo accuracy 
       
   235 const TInt  KOneDigitLimit                  = 10;   
       
   236 
       
   237 // BodyText + subject, needed when counted the message size
       
   238 const TInt KUniEdNumberOfEditors            = 2; 
       
   239 
       
   240 // Extra length added to SMS length when there's subject
       
   241 const TInt KUniEdExtraLenCausedBySubject    = 2; 
       
   242 
       
   243 const TInt KUniEdMaxSubjectLen              = 40;
       
   244 
       
   245 // For creation of checkbox list
       
   246 _LIT(KItemStart, "1\t");                    
       
   247 
       
   248 // Exiting in launch. Let this time to show error notes
       
   249 const TInt  KDelayedExitShort = 100000;
       
   250 
       
   251 // ========== MODULE DATA STRUCTURES =======================
       
   252 
       
   253 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
   254 
       
   255 // ========== LOCAL FUNCTIONS ==============================
       
   256 
       
   257 // ========== MEMBER FUNCTIONS ==============================
       
   258 
       
   259 // ---------------------------------------------------------
       
   260 // CUniEditorAppUi::CUniEditorAppUi
       
   261 // C++ default constructor can NOT contain any code, that
       
   262 // might leave.
       
   263 // ---------------------------------------------------------
       
   264 //
       
   265 CUniEditorAppUi::CUniEditorAppUi() :   
       
   266     iDisplaySize( -1 ),
       
   267     iWaitResId( -1 ),
       
   268     iOriginalSlide( -1 ),
       
   269     iNextFocus( EMsgComponentIdNull ),
       
   270     iPopupChangedMmsBuffer(NULL),
       
   271     iPopupChangedSmsBuffer(NULL),
       
   272     iEditorFlags( EShowInfoPopups ),
       
   273     iMskResId( R_UNIEDITOR_OPTIONS_CLOSE ),
       
   274     iOptimizedFlow(EFalse),
       
   275     iSingleJpegImageProcessing(EFalse)
       
   276     {
       
   277     }
       
   278     
       
   279 // ---------------------------------------------------------
       
   280 // CUniEditorAppUi::ConstructL
       
   281 // Second phase contructor
       
   282 // NOTE: Don't call here any function that uses iMtm 
       
   283 //       and/or iSmilModel members, because they are 
       
   284 //       initialized at LaunchViewL.
       
   285 // ---------------------------------------------------------
       
   286 //
       
   287 void CUniEditorAppUi::ConstructL()
       
   288     {
       
   289     iFinalizeLaunchL = EFalse;
       
   290     // We don't have any app ui if launched from idle
       
   291     if ( iEikonEnv->EikAppUi() )
       
   292         {
       
   293         ActivateInputBlockerL( NULL );
       
   294         }
       
   295         
       
   296     CMsgEditorAppUi::ConstructL();
       
   297 
       
   298 	SetKeyEventFlags( EDisableSendKeyShort | EDisableSendKeyLong );
       
   299     SetCloseWithEndKey( ETrue );
       
   300     
       
   301     FeatureManager::InitializeLibL();
       
   302     
       
   303     // Get supported features from feature manager.    
       
   304     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   305         {
       
   306         iSupportedFeatures |= EUniFeatureHelp;
       
   307         }
       
   308     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   309         {
       
   310         iSupportedFeatures |= EUniFeatureOffline;
       
   311         }
       
   312     if ( FeatureManager::FeatureSupported( KFeatureIdDrmFull ) )
       
   313         {
       
   314         iSupportedFeatures |= EUniFeatureDrmFull;
       
   315         }
       
   316     if ( FeatureManager::FeatureSupported( KFeatureIdCamera ) )
       
   317         {
       
   318         iSupportedFeatures |= EUniFeatureCamcorder;
       
   319         }
       
   320     if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   321         {
       
   322         iSupportedFeatures |= EUniFeatureJapanese;
       
   323         }
       
   324     //Turkish SMS-PREQ2265 specific
       
   325     if( FeatureManager::FeatureSupported( KFeatureIdNltSupport ) )
       
   326         {
       
   327         iNLTFeatureSupport = ETrue;
       
   328         }
       
   329     else
       
   330         {
       
   331         iNLTFeatureSupport = EFalse;
       
   332         }
       
   333     
       
   334     FeatureManager::UnInitializeLib();
       
   335 
       
   336     iMuiuSettRepository = CRepository::NewL( KCRUidMuiuSettings );
       
   337 
       
   338     TInt featureBitmask = 0;
       
   339     
       
   340     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
       
   341     repository->Get( KMuiuMmsFeatures, featureBitmask );
       
   342     
       
   343     if ( featureBitmask & KMmsFeatureIdEditorSubjectField )
       
   344         {
       
   345         iSupportedFeatures |= EUniFeatureSubject;
       
   346         }
       
   347         
       
   348     if ( featureBitmask & KMmsFeatureIdPrioritySupport )
       
   349         {
       
   350         iSupportedFeatures |= EUniFeaturePriority;
       
   351         }    
       
   352     
       
   353     iInputTxtLangRepository = CRepository::NewL(  KCRUidAknFep   );     
       
   354     iNotifyHandler = CCenRepNotifyHandler::NewL( *this,
       
   355                                                  *iInputTxtLangRepository,                                                 
       
   356                                                  CCenRepNotifyHandler::EIntKey,
       
   357                                                  KAknFepInputTxtLang );
       
   358     featureBitmask = 0;    
       
   359     repository->Get( KMuiuUniEditorFeatures, featureBitmask );
       
   360     
       
   361     if ( featureBitmask & KUniEditorFeatureIdHideMsgTypeChangedPopup )
       
   362         {
       
   363         iEditorFlags &= ~EShowInfoPopups;
       
   364         }    
       
   365         
       
   366     if ( featureBitmask & KUniEditorFeatureIdHideSizeCounter )
       
   367         {
       
   368         iEditorFlags |= EHideSizeCounter;
       
   369         }    
       
   370     if ( featureBitmask & KUniEditorFeatureIdHideMessageTypeOption )
       
   371 		{
       
   372 		iEditorFlags |= EHideMessageTypeOption;
       
   373 		}     
       
   374     repository->Get( KMuiuSmsFeatures, featureBitmask );
       
   375     
       
   376     if ( featureBitmask & KSmsFeatureIdShowConcatenatedQuery )
       
   377         {
       
   378         iEditorFlags |= EShowSmsSentInManyParts;
       
   379         }  
       
   380        
       
   381     delete repository;  
       
   382     
       
   383     iNotifyHandler->StartListeningL();    
       
   384     // Disable task swapper from options menu during launch
       
   385     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
       
   386     
       
   387     iTitleSms = StringLoader::LoadL( R_UNIEDITOR_TITLE_SMS, iCoeEnv );    
       
   388     iTitleMms = StringLoader::LoadL( R_UNIEDITOR_TITLE_MMS, iCoeEnv );    
       
   389     
       
   390     // Load msg length format string from resource
       
   391     iSmsLengthFormatBuffer = StringLoader::LoadL( R_UNIEDITOR_SMS_LENGTH, iCoeEnv );
       
   392     iMmsLengthFormatBuffer = StringLoader::LoadL( R_UNIEDITOR_MMS_LENGTH, iCoeEnv );
       
   393 
       
   394     CEikStatusPane* statusPane = StatusPane();
       
   395     
       
   396     // Set generic title text as message type is not known yet.
       
   397     HBufC* titleString = StringLoader::LoadLC( R_UNIEDITOR_TITLE, iCoeEnv );    
       
   398         
       
   399     iTitlePane = static_cast<CAknTitlePane*>( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   400     iTitlePane->SetTextL( titleString->Des(), ETrue );
       
   401     
       
   402     CleanupStack::PopAndDestroy( titleString );
       
   403     
       
   404     iNaviPane = static_cast<CAknNavigationControlContainer*>( statusPane->ControlL( 
       
   405                                                                 TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   406     
       
   407     iNaviDecorator = iNaviPane->CreateEditorIndicatorContainerL();
       
   408     
       
   409     TParse fileParse;
       
   410     fileParse.Set( KUniUtilsMBMFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   411 
       
   412     iIconSms = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(),
       
   413                                           KAknsIIDQgnPropMceSmsTitle,
       
   414                                           fileParse.FullName(),
       
   415                                           EMbmUniutilsQgn_prop_mce_sms_title,
       
   416                                           EMbmUniutilsQgn_prop_mce_sms_title_mask );
       
   417 
       
   418     iIconMms = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(),
       
   419                                           KAknsIIDQgnPropMceMmsTitle,
       
   420                                           fileParse.FullName(),
       
   421                                           EMbmUniutilsQgn_prop_mce_mms_title,
       
   422                                           EMbmUniutilsQgn_prop_mce_mms_title_mask );
       
   423     
       
   424     SetTitleIconsSizeL();
       
   425     
       
   426     if ( Document()->CreationMode() == EMmsCreationModeWarning )
       
   427         {
       
   428         iEditorFlags |= EShowGuidedConf;
       
   429         }
       
   430         
       
   431     // Prepare to launch msgeditorview to display the message
       
   432     if ( !iEikonEnv->StartedAsServerApp() )
       
   433         {
       
   434         Document()->PrepareToLaunchL( this );
       
   435         }
       
   436 
       
   437     iScreenClearer = CAknLocalScreenClearer::NewLC( ETrue );
       
   438     CleanupStack::Pop( iScreenClearer );        
       
   439 	CreateFixedToolbarL( ETrue);
       
   440     
       
   441     // Priority must be lower than the priority of iWrappedWaitDialog
       
   442     // Constructed here to ensure exit on low memory situations.
       
   443     iIdle = CPeriodic::NewL( EPriorityNormal - 1 );
       
   444     
       
   445 #ifdef RD_SCALABLE_UI_V2
       
   446     if ( AknLayoutUtils::PenEnabled() )
       
   447         {
       
   448             User::LeaveIfError( iPeninputServer.Connect() );
       
   449             iPeninputServer.AddPenUiActivationHandler( this, EPluginInputModeAll );
       
   450             iPrevSmsLength = -1;    
       
   451             iMsgLenToVKB = ETrue; 
       
   452         }
       
   453 #endif
       
   454     	iLongTapDetector = CAknLongTapDetector::NewL( this );
       
   455 		iLongTapDetector->SetTimeDelayBeforeAnimation( KUniLongTapStartDelay );
       
   456 		iLongTapDetector->SetLongTapDelay( KUniLongTapTimeDelay );
       
   457 		iTapConsumed = EFalse;
       
   458 
       
   459 		//Korean Req: 415-5434
       
   460 		if ( iEditorFlags & EShowInfoPopups )
       
   461      		{
       
   462 	        iPopupNote = CAknInfoPopupNoteController::NewL();
       
   463             iPopupNote->SetTimeDelayBeforeShow( 0 );
       
   464             iPopupNote->SetTimePopupInView( 3000 );
       
   465 
       
   466 			iPopupSmsSizeAboveLimitBuffer = StringLoader::LoadL( R_UNIEDITOR_POPUP_SMS_SIZE_ABOVE_LIMIT, Document()->SmsSizeWarningBytes(), iCoeEnv );
       
   467 			iPopupSmsSizeBelowLimitBuffer = StringLoader::LoadL( R_UNIEDITOR_POPUP_SMS_SIZE_UNDER_LIMIT, Document()->SmsSizeWarningBytes(), iCoeEnv );		
       
   468 	    	}
       
   469 
       
   470     }
       
   471 
       
   472 
       
   473 // ---------------------------------------------------------
       
   474 // CUniEditorAppUi::~CUniEditorAppUi
       
   475 // Destructor
       
   476 // ---------------------------------------------------------
       
   477 //
       
   478 CUniEditorAppUi::~CUniEditorAppUi()
       
   479     {
       
   480     iEditorFlags |= EEditorExiting;
       
   481     
       
   482 	//sendui+jepg optimization changes
       
   483     if(iLaunchOperation)
       
   484         {
       
   485         // check Is iLaunchOperation still attached to 
       
   486         // iSlideLoader / iHeader
       
   487         // Set the CUniEditorAppUi
       
   488         // instance to NULL, to avoid crash.
       
   489         if(iLaunchOperation->GetHeader())
       
   490             {
       
   491             iHeader = NULL;            
       
   492             }
       
   493         if(iLaunchOperation->GetSlideLoader())
       
   494             {
       
   495             iSlideLoader = NULL;            
       
   496             }
       
   497         }
       
   498     if ( iView )
       
   499         {
       
   500         // To prevent focus changes caused by input blocker deletion & toolbar extension
       
   501         // closing.
       
   502         iEikonEnv->EikAppUi()->RemoveFromStack( iView );
       
   503         
       
   504         if ( iEditorFlags & ELaunchSuccessful )
       
   505             {    
       
   506             TInt id( EMsgComponentIdNull );
       
   507             
       
   508             // remember input mode:
       
   509             // observer does not get event, if editor is closed 
       
   510             CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
   511             if ( ctrl )
       
   512                 {
       
   513                 id = ctrl->ControlId();
       
   514                 if ( iHeader &&  
       
   515                      !iHeader->IsAddressControl( id ) )
       
   516                     {
       
   517                     id = EMsgComponentIdNull;
       
   518                     }
       
   519                 }
       
   520                 
       
   521             if ( id == EMsgComponentIdNull )
       
   522                 { 
       
   523                 id = EMsgComponentIdTo;
       
   524                 }
       
   525             
       
   526             CUniBaseHeader::THeaderFields headerField = CUniBaseHeader::EHeaderAddressTo;
       
   527             
       
   528             if ( id == EMsgComponentIdCc )
       
   529                 {
       
   530                 headerField = CUniBaseHeader::EHeaderAddressCc;
       
   531                 }
       
   532             else if ( id == EMsgComponentIdBcc )
       
   533                 {
       
   534                 headerField = CUniBaseHeader::EHeaderAddressBcc;
       
   535                 }
       
   536             
       
   537             CMsgAddressControl* rec = 
       
   538                 iHeader ? static_cast<CMsgAddressControl*>( iHeader->AddressControl( headerField ) ) :
       
   539                         NULL;
       
   540 
       
   541             if ( rec ) 
       
   542                 {
       
   543                 TInt inputMode = rec->Editor().AknEditorCurrentInputMode();
       
   544                 
       
   545                 if ( iMuiuSettRepository )
       
   546                     {
       
   547                     iMuiuSettRepository->Set( KMuiuToInputMode, inputMode );
       
   548                     }
       
   549                 }
       
   550             }
       
   551         }
       
   552     
       
   553     delete iLaunchOperation;
       
   554     delete iSaveOperation;
       
   555     delete iSendOperation;
       
   556     delete iInsertOperation;
       
   557     delete iChangeSlideOperation;
       
   558     delete iVCardOperation;
       
   559     
       
   560     delete iParser;
       
   561     delete iDom;
       
   562     
       
   563     delete iInputBlocker;
       
   564 
       
   565 #ifdef RD_SCALABLE_UI_V2
       
   566     if ( AknLayoutUtils::PenEnabled() )
       
   567          {
       
   568           iPeninputServer.Close();
       
   569          }
       
   570 #endif
       
   571     
       
   572     delete iTitleSms;
       
   573     delete iTitleMms;
       
   574 
       
   575     delete iIconSms;
       
   576     delete iIconMms;
       
   577     
       
   578     delete iSmsLengthFormatBuffer;
       
   579     delete iMmsLengthFormatBuffer;
       
   580     
       
   581     delete iPopupNote;
       
   582     delete iPopupChangedMmsBuffer;
       
   583     delete iPopupChangedSmsBuffer;
       
   584     
       
   585     delete iMuiuSettRepository;
       
   586 
       
   587     delete iWaitDialog;
       
   588     delete iIdle;
       
   589 
       
   590     delete iInsertingMedia;
       
   591     delete iHeader;
       
   592     delete iSlideLoader;
       
   593     delete iScreenClearer;
       
   594 
       
   595     delete iDocHandler;
       
   596     delete iStoredBodyControl;
       
   597     
       
   598     delete iFixedToolbar;
       
   599     if( iNotifyHandler )
       
   600         {
       
   601          iNotifyHandler->StopListening();         
       
   602           delete iNotifyHandler;
       
   603          }
       
   604     
       
   605    if(iInputTxtLangRepository)
       
   606     {
       
   607     delete iInputTxtLangRepository;
       
   608     }
       
   609   if(iNLTFeatureSupport)
       
   610     {   
       
   611     delete iPrevBuffer;
       
   612     }
       
   613 
       
   614     delete iPopupSmsSizeAboveLimitBuffer;
       
   615     delete iPopupSmsSizeBelowLimitBuffer;
       
   616 	if(iLongTapDetector)
       
   617 	{
       
   618     delete iLongTapDetector;
       
   619 	}
       
   620 	if(iEmbeddedObjectStylusPopup)
       
   621 	{
       
   622     delete iEmbeddedObjectStylusPopup;
       
   623 	iEmbeddedObjectStylusPopup = NULL;
       
   624 	}
       
   625    
       
   626     }
       
   627 
       
   628 // ---------------------------------------------------------
       
   629 // CUniEditorAppUi::LaunchViewL
       
   630 //
       
   631 // Called by the document when application view launch should be
       
   632 // started.
       
   633 // ---------------------------------------------------------
       
   634 //
       
   635 void CUniEditorAppUi::LaunchViewL()
       
   636     {
       
   637 
       
   638     // Initialize these members here.
       
   639     iMtm = &( Document()->Mtm() );
       
   640 
       
   641     const TMsvEntry& entry = Document()->Entry();
       
   642     if ( entry.iType.iUid != KUidMsvMessageEntryValue )
       
   643         {
       
   644         // Fixing: JHUA-5SCF8W
       
   645         // Backup / Restore restarts editor without proper
       
   646         // context. Leave with KErrGeneral.
       
   647         User::Leave( KErrGeneral );
       
   648         }
       
   649         
       
   650     if ( entry.Parent() != KMsvDraftEntryIdValue )
       
   651         {
       
   652         User::Leave( KErrNotSupported );
       
   653         }
       
   654     if ( !( Document()->LaunchFlags() & EMsgCreateNewMessage ) )
       
   655         {
       
   656         TRAPD( error, iMtm->LoadMessageL() );
       
   657         if ( error )
       
   658             {
       
   659             if ( error != KErrNoMemory &&
       
   660                  error != KErrDiskFull )
       
   661                 {
       
   662                 ShowErrorNoteL( R_UNIEDITOR_ERROR_MSG_CORRUPT, ETrue );
       
   663                 }
       
   664             User::Leave( error );
       
   665             }
       
   666         }    
       
   667     
       
   668     Document()->SetMessageType();
       
   669 
       
   670     if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
   671         {
       
   672         Document()->SetCreationMode( EMmsCreationModeFree );
       
   673         
       
   674         if ( iFixedToolbar )
       
   675             {
       
   676             iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarAddRecipient, ETrue, EFalse );
       
   677             }
       
   678         }
       
   679     
       
   680     iView = CMsgEditorView::NewL( *this, CMsgEditorView::EMsgDoNotUseDefaultBodyControl );
       
   681     iView->SetEdwinObserverL( this );
       
   682     
       
   683 
       
   684     iLaunchOperation = CUniEditorLaunchOperation::NewL( *this,
       
   685                                                         *this,
       
   686                                                         *Document(),
       
   687                                                         *iView,
       
   688                                                         *this,
       
   689                                                         FsSession() );
       
   690 
       
   691     iLaunchOperation->Launch();
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------
       
   695 // CUniEditorAppUi::FinalizeLaunchL
       
   696 //
       
   697 // Performs all the last actions before editor launch ends.
       
   698 // ---------------------------------------------------------
       
   699 //
       
   700 void CUniEditorAppUi::FinalizeLaunchL()
       
   701     {
       
   702 	// In all normal cases other then Sendui+Jepeg
       
   703 	// iOptimizedFlow will be false and flow should be 
       
   704 	// same as the normal launch
       
   705     if(iOptimizedFlow)
       
   706         {
       
   707 		//if iOptimizedFlow is True, it means
       
   708 		//sendui+Jepg and this is partial complete call
       
   709         iSingleJpegImageProcessing = ETrue;
       
   710         }
       
   711 		
       
   712     iFinalizeLaunchL = ETrue;
       
   713     iSmilModel = &Document()->DataModel()->SmilModel();
       
   714 	
       
   715     if(!iOptimizedFlow)
       
   716         {
       
   717 		//detach the iHeader and iSlideLoader
       
   718         iHeader = iLaunchOperation->DetachHeader();
       
   719         iSlideLoader = iLaunchOperation->DetachSlideLoader();
       
   720         }
       
   721     else
       
   722         {
       
   723 		// get reference to complete partial lauch operation
       
   724         iHeader = iLaunchOperation->GetHeader();
       
   725         iSlideLoader = iLaunchOperation->GetSlideLoader();
       
   726         }
       
   727     
       
   728     SetMessageTypeLockingL();
       
   729     
       
   730     TInt headersVariation = iHeader->AddHeadersVariation();
       
   731 
       
   732     if ( Document()->EmailOverSmsSupported() ||
       
   733          ( headersVariation & EUniFeatureSubject && 
       
   734            !( headersVariation & EUniFeatureSubjectConfigurable ) ) )
       
   735         { 
       
   736         // Enable subject in SMS when it's not selectable in additional headers
       
   737         // and when EmailOverSms is supported
       
   738         iEditorFlags |= ESubjectOkInSms;
       
   739         }
       
   740     
       
   741     SetAddressSize();
       
   742     SetSubjectSize();
       
   743     
       
   744     // "Remember input mode" feature
       
   745     TInt inputMode = EAknEditorNumericInputMode;
       
   746     if ( iMuiuSettRepository->Get( KMuiuToInputMode, inputMode ) != KErrNone )
       
   747         {
       
   748         inputMode = EAknEditorNumericInputMode;
       
   749         }
       
   750 
       
   751     SetInputModeToAddressFields( inputMode );
       
   752     
       
   753     CheckLockedSmsWithAttaL();
       
   754     
       
   755     if ( iSupportedFeatures & EUniFeatureJapanese &&
       
   756          Document()->MessageType() != EUniForward )
       
   757         {
       
   758         // Image first layout is always used in Japanese variant when dealing
       
   759         // with any other messages than those that where originally forwarded by user.
       
   760         // With forwarded messages the original layout is kept unchanged.
       
   761         ChangeOrderL( EUniImageFirst );
       
   762         iSmilModel->SetLayoutL( EUniImageFirst );
       
   763         }
       
   764     
       
   765     TMsgControlId focusedControlId = ResolveLaunchFocusedControlL();
       
   766             
       
   767     
       
   768     CEikStatusPane* statusPane = StatusPane();
       
   769     
       
   770     if ( focusedControlId == EMsgComponentIdBody )
       
   771         {
       
   772         BodyCtrl()->SetCursorPosL( BodyCtrlEditor()->TextLength() );
       
   773         }
       
   774     
       
   775     if( iNLTFeatureSupport )
       
   776         {
       
   777         iPrevBuffer = NULL;
       
   778         //Turskish SMS-PREQ2265 specific
       
   779         TSmsEncoding alternateEncodingType;
       
   780         TUniMessageCharSetSupport charSet;
       
   781         TInt inputLang = iAvkonEnv->SettingCache().InputLanguage();
       
   782         CUniEditorDocument* doc = Document();
       
   783         
       
   784         alternateEncodingType = doc->GetLanguageSpecificAltEncodingType(inputLang);
       
   785         charSet = doc->CharSetSupport();
       
   786         
       
   787         doc->SetAlternativeEncodingType(alternateEncodingType);
       
   788         if(SmsPlugin())
       
   789             {
       
   790             //Initialize corresponding language alternative encoding types and character set selected
       
   791             SmsPlugin()->SetEncodingSettings(EFalse, alternateEncodingType, charSet);
       
   792             }
       
   793         }
       
   794     
       
   795     CheckBodyForMessageTypeL();
       
   796     CheckHeaderForMessageTypeL();
       
   797     
       
   798     SetOrRemoveMaxSizeInEdwin();
       
   799     
       
   800     InitNaviPaneL();
       
   801     SetTitleL();
       
   802     if ( Document()->MessageType() == EUniSendUi )
       
   803         {
       
   804         // Show invalid contact notes and verify unvalidated addresses.
       
   805         iHeader->ShowInvalidContactNotesL();
       
   806         
       
   807         TBool unused;
       
   808         VerifyAddressesL( unused );
       
   809         }
       
   810         
       
   811     if ( iEditorFlags & EShowInfoPopups )
       
   812         {
       
   813         iPopupChangedMmsBuffer = StringLoader::LoadL( R_UNIEDITOR_POPUP_MSG_CHANGED_MMS, iCoeEnv );
       
   814 		iPopupChangedSmsBuffer = StringLoader::LoadL( R_UNIEDITOR_POPUP_MSG_CHANGED_SMS, iCoeEnv );
       
   815 
       
   816         }
       
   817 
       
   818     CheckMaxRecipientsAndShowNoteL();
       
   819     
       
   820     // Enable task swapper to options menu after launch has been completed.
       
   821     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptions );
       
   822     
       
   823     UpdateToolbarL();
       
   824 
       
   825 	// partial launch need to call execute to make
       
   826 	//the editor visible
       
   827     if(iOptimizedFlow)
       
   828         {
       
   829         iView->ExecuteL( ClientRect(), focusedControlId );
       
   830         }
       
   831     else// not optmized Flow, common flow
       
   832         {
       
   833         // partial launch, dont set the flag
       
   834         iEditorFlags |= ELaunchSuccessful;
       
   835         
       
   836 		// in case of sendui+jepg , again finalize launch will be called 
       
   837 		//after image processing, no need to call iView->ExecuteL
       
   838 		// slide will be loaded already by slide loader.
       
   839         if(!iSingleJpegImageProcessing)
       
   840             {
       
   841 			//normal flow
       
   842             iView->ExecuteL( ClientRect(), focusedControlId );
       
   843             }
       
   844         
       
   845         //after the lauch complete for sendui+jepg
       
   846         //rest it.
       
   847         iSingleJpegImageProcessing = EFalse;        
       
   848         }
       
   849     
       
   850     delete iScreenClearer;
       
   851     iScreenClearer = NULL;
       
   852    
       
   853     // show note inserting 
       
   854     if(iOptimizedFlow)
       
   855         {
       
   856         ShowWaitNoteL( R_QTN_UNI_WAIT_INSERTING );
       
   857         }
       
   858  
       
   859 	
       
   860     }
       
   861     
       
   862 // ---------------------------------------------------------
       
   863 // CUniEditorAppUi::ShowLaunchNotesL
       
   864 //
       
   865 // Tries to resolve correct note(s) to be shown when editor is
       
   866 // launched. First disables showing of guided conformance note if
       
   867 // message is forwarded with non-conformant content as viewer should
       
   868 // be responsible of showing this. After this goes through 
       
   869 // error list and sets correct error resource depending of 
       
   870 // editor mode and message content. Priority & plural solving
       
   871 // is performed on SetErrorResource function. Some notes can
       
   872 // be grouped together so that if error notes from different
       
   873 // groups are set then general error note should be shown instead.
       
   874 // After correct error note resource is resolved then notes 
       
   875 // related to conformance are shown. Do note that there is 
       
   876 // a EShowGuidedConf flag that controls the visibility of guided
       
   877 // note. After this if still appropriate and specified
       
   878 // error note is shown to user.
       
   879 // ---------------------------------------------------------
       
   880 //
       
   881 void CUniEditorAppUi::ShowLaunchNotesL( TBool& aShutDown )
       
   882     {
       
   883     TInt errRes( KErrNotFound );
       
   884     
       
   885     if ( Document()->LaunchFlags() & EMsgForwardMessage &&
       
   886          ( Document()->UpdatedNonConformantCount() > 0 || 
       
   887            Document()->DataModel()->SmilType() == ETemplateSmil ||
       
   888            Document()->DataModel()->SmilType() == E3GPPSmil ) )
       
   889         {
       
   890         iEditorFlags &= ~EShowGuidedConf;
       
   891         }
       
   892     
       
   893     // Tells whether message has files included.
       
   894     TBool containsFiles = Document()->DataModel()->ObjectList().Count() > 0 || 
       
   895                           Document()->DataModel()->AttachmentList().Count() > 0;
       
   896     
       
   897     TBool useRModeStrings = Document()->CreationModeUserChangeable() &&
       
   898                             Document()->CreationMode() == EMmsCreationModeRestricted;
       
   899     
       
   900     CArrayFixFlat<TInt>* errors = iLaunchOperation->GetErrors();
       
   901     
       
   902     if ( Document()->DataModel()->ParseResult() & EObjectRemoved )
       
   903         {
       
   904         SetErrorResource( errRes, R_UNIEDITOR_INFO_MAX_SLIDES_SOME );
       
   905         }
       
   906     
       
   907     for ( TInt i = 0; i < errors->Count(); i++ )
       
   908         {
       
   909         switch ( errors->At( i ) )
       
   910             {
       
   911             case KUniLaunchAbortPresRestricted:
       
   912                 {
       
   913                 // Set only for 3GPP or template SMIL presentations when creation
       
   914                 // mode is restricted.
       
   915                 if ( useRModeStrings )
       
   916                     {
       
   917                     SetErrorResource( errRes, R_UNIEDITOR_ERROR_RMODE_CANNOT_OPEN );
       
   918                     }
       
   919                 else
       
   920                     {
       
   921                     SetErrorResource( errRes, R_UNIEDITOR_ERROR_CANNOT_OPEN );
       
   922                     }
       
   923                     
       
   924                 break;
       
   925                 }
       
   926             case KUniLaunchPresGuided:
       
   927                 {
       
   928                 // Set only for 3GPP or template SMIL presentations when creation
       
   929                 // mode is guided.
       
   930                 SetErrorResource( errRes, R_UNIEDITOR_QUEST_GUIDED_PRESENTATION );
       
   931                 break;
       
   932                 }
       
   933             case EUniProcessImgOutOfMemory:
       
   934             case EUniProcessImgOutOfDisk:
       
   935             case EUniProcessImgNotFound:
       
   936             case EUniProcessImgNonConformant:
       
   937             case EUniProcessImgScalingFailed:
       
   938             case EUniProcessImgCompressFailed:
       
   939             case EUniProcessImgCouldNotScale:
       
   940                 {                
       
   941                 if ( useRModeStrings )
       
   942                     {
       
   943                     SetErrorResource( errRes, R_UNIEDITOR_INFO_RMODE_SCALING_FAILED );
       
   944                     }
       
   945                 else
       
   946                     {
       
   947                     SetErrorResource( errRes, R_UNIEDITOR_INFO_SCALING_FAILED );
       
   948                     }    
       
   949                 break;
       
   950                 }
       
   951             case EUniSendUiUnsupported:
       
   952                 {                
       
   953                 if ( containsFiles )
       
   954                     {
       
   955                     if ( useRModeStrings )
       
   956                         {
       
   957                         SetErrorResource( errRes, R_UNIEDITOR_INFO_RMODE_SOME_NOT_SUPPORTED );
       
   958                         }
       
   959                     else
       
   960                         {
       
   961                         SetErrorResource( errRes, R_UNIEDITOR_INFO_SOME_NOT_SUPPORTED );
       
   962                         }   
       
   963                     }
       
   964                 else
       
   965                     {
       
   966                     if ( useRModeStrings )
       
   967                         {
       
   968                         SetErrorResource( errRes, R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT );
       
   969                         }
       
   970                     else
       
   971                         {
       
   972                         SetErrorResource( errRes, R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT );
       
   973                         }   
       
   974                     }
       
   975                 break;
       
   976                 }
       
   977             case EUniSendUiForbidden:
       
   978                 {
       
   979                 // Note showing should be handled by SendUI in this case.
       
   980                 break;
       
   981                 }
       
   982             case EUniSendUiTooBig:
       
   983                 {
       
   984                 if ( containsFiles )
       
   985                     {
       
   986                     SetErrorResource( errRes, R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG );
       
   987                     }
       
   988                 else
       
   989                     {
       
   990                     SetErrorResource( errRes, R_UNIEDITOR_INFO_OBJECT_TOO_BIG );
       
   991                     }
       
   992                     
       
   993                 break;
       
   994                 }
       
   995             case EUniEditorExit:
       
   996             case EUniProcessImgUserAbort:
       
   997                 {
       
   998                 // Program error or user has selected to abort image processing at some stage.
       
   999                 // -> shutdown immediatelly.
       
  1000                 aShutDown = ETrue;  
       
  1001                 return;
       
  1002                 }
       
  1003             default:
       
  1004                 {
       
  1005                 // e.g leave in startup 
       
  1006                 break;
       
  1007                 }
       
  1008             }
       
  1009         }
       
  1010         
       
  1011     if ( errRes == R_UNIEDITOR_ERROR_CANNOT_OPEN ||
       
  1012          errRes == R_UNIEDITOR_ERROR_RMODE_CANNOT_OPEN )
       
  1013         {
       
  1014         // Message cannot be opened.
       
  1015         ShowConfirmableInfoL( errRes );
       
  1016         
       
  1017         aShutDown = ETrue;
       
  1018         return;
       
  1019         }   
       
  1020     else if ( errRes == R_UNIEDITOR_INFO_OBJECT_TOO_BIG ||
       
  1021               errRes == R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT ||
       
  1022               errRes == R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECTS ||
       
  1023               errRes == R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT ||
       
  1024               errRes == R_UNIEDITOR_INFO_UNSUPPORTED_OBJECTS )
       
  1025         {
       
  1026         ShowInformationNoteL( errRes, ETrue );
       
  1027         
       
  1028         aShutDown = ETrue;
       
  1029         return;
       
  1030         }
       
  1031     else if ( errRes == R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG || 
       
  1032               errRes == R_UNIEDITOR_INFO_RMODE_SOME_NOT_SUPPORTED ||
       
  1033               errRes == R_UNIEDITOR_INFO_SOME_NOT_SUPPORTED )
       
  1034         {
       
  1035         ShowInformationNoteL( errRes, ETrue );
       
  1036         }
       
  1037     else if ( errRes == R_UNIEDITOR_INFO_MAX_SLIDES_SOME )
       
  1038         {
       
  1039         ShowConfirmableInfoL( errRes );
       
  1040         }
       
  1041     
       
  1042     if ( errRes == R_UNIEDITOR_QUEST_GUIDED_PRESENTATION )
       
  1043         {
       
  1044         if ( !ShowGuidedModeConfirmationQueryL( errRes ) ) 
       
  1045             {
       
  1046             aShutDown = ETrue;
       
  1047             }
       
  1048         }
       
  1049     else
       
  1050         {
       
  1051         if ( Document()->CreationMode() != EMmsCreationModeFree )
       
  1052             {
       
  1053             TInt nonConformantObjects = iLaunchOperation->ParseResult();
       
  1054             
       
  1055             if ( nonConformantObjects > 0 )
       
  1056                 {
       
  1057                 if ( Document()->CreationMode() == EMmsCreationModeRestricted )
       
  1058                     {
       
  1059                     if ( Document()->CreationModeUserChangeable() )
       
  1060                         {
       
  1061                         ShowConfirmableInfoL( R_UNIEDITOR_ERROR_RMODE_CANNOT_OPEN );
       
  1062                         }
       
  1063                     else
       
  1064                         {
       
  1065                         ShowConfirmableInfoL( R_UNIEDITOR_ERROR_CANNOT_OPEN );
       
  1066                         }
       
  1067                         
       
  1068                     aShutDown = ETrue;
       
  1069                     return;
       
  1070                     }
       
  1071                 else if ( Document()->SuperDistributableObjectCount() == 0 ||  
       
  1072                           Document()->MessageType() != EUniSendUi )
       
  1073                     {
       
  1074                     // Not shown if DRM note has been shown already by SendUi.
       
  1075                     TInt confRes( KErrNotFound );
       
  1076                     
       
  1077                     if ( Document()->Saved() )
       
  1078                         {
       
  1079                         confRes = R_UNIEDITOR_QUEST_GUIDED_INC_OBJ;
       
  1080                         if ( nonConformantObjects > 1 )
       
  1081                             {
       
  1082                             confRes = R_UNIEDITOR_QUEST_GUIDED_INC_OBJS;
       
  1083                             }
       
  1084                         }
       
  1085                     else
       
  1086                         {
       
  1087                         confRes = R_UNIEDITOR_QUEST_GUIDED_OBJ;
       
  1088                         if ( nonConformantObjects > 1 )
       
  1089                             {
       
  1090                             confRes = R_UNIEDITOR_QUEST_GUIDED_OBJS;
       
  1091                             }
       
  1092                         }
       
  1093                     
       
  1094                     if ( !ShowGuidedModeConfirmationQueryL( confRes ) ) 
       
  1095                         {
       
  1096                         // Query not accepted
       
  1097                         aShutDown = ETrue;
       
  1098                         return;
       
  1099                         }
       
  1100                     }
       
  1101                 }
       
  1102             }
       
  1103         }
       
  1104         
       
  1105     if ( errRes == R_UNIEDITOR_INFO_RMODE_SCALING_FAILED ||
       
  1106          errRes == R_UNIEDITOR_INFO_SCALING_FAILED )
       
  1107         {
       
  1108         ShowInformationNoteL( errRes, ETrue );
       
  1109         }
       
  1110     }
       
  1111 
       
  1112 // ---------------------------------------------------------
       
  1113 // CUniEditorAppUi::InsertPresentation
       
  1114 // ---------------------------------------------------------
       
  1115 //
       
  1116 void CUniEditorAppUi::InsertPresentationL( TBool aEditable )
       
  1117     {
       
  1118     if ( Document()->DataModel()->SmilType() != EMmsSmil )
       
  1119         {
       
  1120         //Delete body control. OK if dooesn't exist.
       
  1121         iView->DeleteControlL( EMsgComponentIdBody );
       
  1122         
       
  1123         CMsgImageControl* imgCtrl = CMsgImageControl::NewL( *iView,
       
  1124                                                             this );
       
  1125         CleanupStack::PushL( imgCtrl );
       
  1126         
       
  1127         TAknsItemID id = KAknsIIDQgnGrafMmsUnedit;
       
  1128         TInt icon = EMbmUniutilsQgn_graf_mms_unedit;
       
  1129         TInt mask = EMbmUniutilsQgn_graf_mms_unedit_mask;
       
  1130 
       
  1131         if ( aEditable )
       
  1132             {
       
  1133             id.Set( KAknsIIDQgnGrafMmsEdit );
       
  1134             icon = EMbmUniutilsQgn_graf_mms_edit;
       
  1135             mask = EMbmUniutilsQgn_graf_mms_edit_mask;
       
  1136             }
       
  1137 
       
  1138         TParse fileParse;
       
  1139         fileParse.Set( KUniUtilsMBMFileName, &KDC_APP_BITMAP_DIR, NULL );
       
  1140         imgCtrl->LoadIconL( fileParse.FullName(), id, icon, mask );
       
  1141         
       
  1142         TAknLayoutRect iconLayout;
       
  1143         iconLayout.LayoutRect( MsgEditorCommons::MsgDataPane(),
       
  1144                                AknLayoutScalable_Apps::msg_data_pane_g4().LayoutLine() );
       
  1145         
       
  1146         imgCtrl->SetIconSizeL( iconLayout.Rect().Size() );
       
  1147         
       
  1148         //Draw it
       
  1149         imgCtrl->SetIconVisible( ETrue );
       
  1150         iView->AddControlL( imgCtrl, EMsgComponentIdImage, EMsgFirstControl, EMsgBody );
       
  1151 
       
  1152         CleanupStack::Pop( imgCtrl );
       
  1153         }
       
  1154     else
       
  1155         {
       
  1156         User::Leave( KErrNotSupported );
       
  1157         }
       
  1158     }
       
  1159 
       
  1160 // ---------------------------------------------------------
       
  1161 // CUniEditorAppUi::MsgLengthToNavipaneL
       
  1162 // ---------------------------------------------------------
       
  1163 //
       
  1164 void CUniEditorAppUi::MsgLengthToNavipaneL( TBool aForceDraw )
       
  1165     {
       
  1166     UNILOGGER_WRITE( "-> CUniEditorAppUi::MsgLengthToNavipaneL" );
       
  1167     
       
  1168     TBuf<KMsgLengthIndicationBuffer> sizeString;
       
  1169 
       
  1170     // If message is SMS type, iSmsBodyLength + iSmsSubjectLnegth will be used as length
       
  1171     // If EUnicodeMode is set, they will be handled as unicode length
       
  1172     if ( !( iEditorFlags & EHideSizeCounter ) )
       
  1173         { 
       
  1174         CUniEditorDocument* doc = Document();
       
  1175         
       
  1176         // It's ok to show the counter
       
  1177         if ( doc->UniState() == EUniSms )
       
  1178             {
       
  1179            
       
  1180             CUniDataModel* model = doc->DataModel();           
       
  1181                        
       
  1182          
       
  1183                 TInt charsLeft,msgsParts;
       
  1184                 TInt lengthOne = 0;
       
  1185                 TInt lengthMany = 0;
       
  1186                 
       
  1187                 doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  1188                 TInt maxSmsCharacters = doc->AbsoluteMaxSmsCharacters();
       
  1189                 TInt maxSmsParts = doc->AbsoluteMaxSmsParts();
       
  1190                  
       
  1191                 if ( maxSmsCharacters <= 0 )
       
  1192                     {
       
  1193                     // No absolute maximum characters defined -> Calculate
       
  1194                     // character maximum using maximum SMS part limit.
       
  1195 
       
  1196                     if( maxSmsParts > 1 )
       
  1197                         {
       
  1198                         maxSmsCharacters = maxSmsParts * lengthMany;
       
  1199                         }
       
  1200                     else
       
  1201                         {
       
  1202 						// for korean variant
       
  1203                         maxSmsCharacters = lengthOne;
       
  1204                         }
       
  1205 
       
  1206                     }
       
  1207                 CalculateSMSMsgLen(charsLeft,msgsParts);
       
  1208                 if( model->ObjectList().Count() == 0 &&
       
  1209                     model->AttachmentList().Count() == 1 &&
       
  1210                     iSmilModel->SlideCount() == 1 &&
       
  1211                     iSmsSubjectLength == 0)
       
  1212                         {
       
  1213                      
       
  1214                          sizeString.AppendNum( msgsParts );                        
       
  1215                         
       
  1216                         }
       
  1217                 else if ( maxSmsCharacters <= lengthOne )
       
  1218                     {
       
  1219                     // Maximum less or equal to length of
       
  1220                     // one part -> show only characters left value.
       
  1221                     sizeString.AppendNum( charsLeft );
       
  1222                     }
       
  1223                 else
       
  1224                     {
       
  1225                     HBufC* tempBuf = iSmsLengthFormatBuffer;
       
  1226 
       
  1227                     if ( AknLayoutUtils::LayoutMirrored() )
       
  1228                         { 
       
  1229                         // Add the RTL marker in the format buffer
       
  1230                         tempBuf = iSmsLengthFormatBuffer->AllocL();
       
  1231                         tempBuf = tempBuf->ReAllocL( tempBuf->Length() + 2 );
       
  1232                         CleanupStack::PushL( tempBuf );
       
  1233                         TPtr tempPtr = tempBuf->Des();
       
  1234                         TChar KUniRLMUnicode( 0x200F ); // Right to Left Marker
       
  1235                         TBuf<1> charBuf;
       
  1236                         charBuf.Append(KUniRLMUnicode);
       
  1237                         tempPtr.Insert( 4, charBuf );
       
  1238                         tempPtr.Insert( 9, charBuf );
       
  1239                         }
       
  1240 
       
  1241                     StringLoader::Format( sizeString, tempBuf->Des(), 0, charsLeft );
       
  1242 
       
  1243                     if( tempBuf != iSmsLengthFormatBuffer )
       
  1244                         {
       
  1245                         CleanupStack::PopAndDestroy( tempBuf );
       
  1246                         }
       
  1247                         
       
  1248                     HBufC* temp = sizeString.AllocLC();
       
  1249                     
       
  1250                     StringLoader::Format( sizeString, *temp, 1, msgsParts );
       
  1251 
       
  1252                     CleanupStack::PopAndDestroy( temp );
       
  1253                     }
       
  1254                 iEditorFlags |= ESmsCounterShownLast;
       
  1255                 
       
  1256                 // Now the string is in buf     
       
  1257                 
       
  1258 #ifdef RD_SCALABLE_UI_V2
       
  1259                 if ( ( AknLayoutUtils::PenEnabled() && iPrevSmsLength != charsLeft ) || ( AknLayoutUtils::PenEnabled() &&  aForceDraw ))
       
  1260                     {
       
  1261                     if(!(iPrevSmsLength == -1 && !UpdateMsgLenToPenInput() ) ) // converted from MMS back to SMS
       
  1262                         {                     
       
  1263 	                    iPrevSmsLength = charsLeft;
       
  1264 	                    iPeninputServer.UpdateAppInfo( sizeString, EAppIndicatorMsg );
       
  1265                         }
       
  1266                     }
       
  1267 #endif
       
  1268                
       
  1269             // Reset this so that MMS size is drawn when it's shown next time
       
  1270             iDisplaySize = 0; 
       
  1271             }
       
  1272         else
       
  1273             { 
       
  1274             // OK we are dealing with MMS now
       
  1275             // Just take the size of the whole message and show it in the navipane
       
  1276             TInt bytes = MessageSizeInBytes();   
       
  1277 
       
  1278             TInt integer = iDisplaySize / 10;
       
  1279             TInt fragment = iDisplaySize % 10;
       
  1280 
       
  1281             CreateMmsNaviSizeStringL(      bytes,      sizeString,
       
  1282                                         integer,    fragment );
       
  1283 
       
  1284             TInt tempDispSize = integer * 10 + fragment;
       
  1285 
       
  1286             if ( !aForceDraw && iDisplaySize == tempDispSize && !( iEditorFlags & ESmsCounterShownLast ) )
       
  1287                 {
       
  1288                 // No changes to navipane
       
  1289                 return;
       
  1290                 }
       
  1291 #ifdef RD_SCALABLE_UI_V2
       
  1292             if (  AknLayoutUtils::PenEnabled() && (iEditorFlags & ESmsCounterShownLast ))
       
  1293                 {
       
  1294                      iPeninputServer.UpdateAppInfo( KNullDesC, EAppIndicatorMsg );
       
  1295                      iPrevSmsLength = -1;
       
  1296                 }
       
  1297 #endif
       
  1298 
       
  1299             iEditorFlags &= ~ESmsCounterShownLast;
       
  1300             iDisplaySize = tempDispSize;
       
  1301         
       
  1302             }
       
  1303         }
       
  1304 
       
  1305     // Update both Edwin indicator pane and navi indicator pane
       
  1306     MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  1307     
       
  1308     CAknIndicatorContainer* naviIndi = 
       
  1309         static_cast<CAknIndicatorContainer*>( iNaviDecorator->DecoratedControl() );
       
  1310     
       
  1311     if( editIndi )
       
  1312         {
       
  1313         CAknIndicatorContainer* indiContainer = editIndi->IndicatorContainer();
       
  1314         if ( indiContainer )
       
  1315             {
       
  1316             if( iEditorFlags & EHideSizeCounter )
       
  1317                 { 
       
  1318                 // Just hide it
       
  1319                 indiContainer->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), 
       
  1320                         EAknIndicatorStateOff);
       
  1321                 }
       
  1322             else
       
  1323                 {
       
  1324                 indiContainer->SetIndicatorValueL(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), sizeString);
       
  1325                 indiContainer->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), 
       
  1326                         EAknIndicatorStateOn);
       
  1327                 }            
       
  1328             }
       
  1329         }
       
  1330         
       
  1331     if( naviIndi )
       
  1332         {
       
  1333         if( iEditorFlags & EHideSizeCounter )
       
  1334             { 
       
  1335             // Just hide it
       
  1336             naviIndi->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), 
       
  1337                     EAknIndicatorStateOff);
       
  1338             }
       
  1339         else
       
  1340             {
       
  1341             naviIndi->SetIndicatorValueL(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), sizeString);
       
  1342             naviIndi->SetIndicatorState(TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), 
       
  1343                         EAknIndicatorStateOn);
       
  1344             }
       
  1345         }
       
  1346     
       
  1347     UNILOGGER_WRITE( "<- CUniEditorAppUi::MsgLengthToNavipaneL" );
       
  1348     }
       
  1349 
       
  1350 // ---------------------------------------------------------
       
  1351 // CUniEditorAppUi::CalculateSMSMsgLen
       
  1352 // ---------------------------------------------------------
       
  1353 //
       
  1354 void CUniEditorAppUi::CalculateSMSMsgLen(TInt& charsLeft, TInt& msgsParts)
       
  1355     {
       
  1356     CUniEditorDocument* doc = Document();
       
  1357     if ( doc->UniState() == EUniSms ) 
       
  1358         {
       
  1359         CUniDataModel* model = doc->DataModel();
       
  1360         TInt lengthOne = 0;
       
  1361         TInt lengthMany = 0;
       
  1362         
       
  1363         doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  1364         
       
  1365         TInt totalLen = iSmsBodyLength + iSmsSubjectLength;
       
  1366 
       
  1367         if ( doc->EmailOverSmsSupported()  )
       
  1368             { 
       
  1369             // Email over Sms so get the longest email address from To field
       
  1370             TInt emailLen = iHeader->LongestEmailAddress();
       
  1371             if ( emailLen > 0 )
       
  1372                 { 
       
  1373                 // increase by one so that the separator sign is included too
       
  1374                 emailLen++;
       
  1375                 }
       
  1376                 
       
  1377             totalLen += emailLen;
       
  1378             }
       
  1379         
       
  1380         TInt maxSmsCharacters = doc->AbsoluteMaxSmsCharacters();
       
  1381         TInt maxSmsParts = doc->AbsoluteMaxSmsParts();
       
  1382         
       
  1383         if ( maxSmsCharacters <= 0 )
       
  1384             {                    
       
  1385              // maxSmsCharacters is set to minimum lengthOne.            
       
  1386              if( maxSmsParts > 1 )
       
  1387              	{
       
  1388                 maxSmsCharacters = maxSmsParts * lengthMany;
       
  1389                 }
       
  1390              else
       
  1391                 {
       
  1392                 maxSmsCharacters = lengthOne;
       
  1393                 }
       
  1394             }
       
  1395             
       
  1396         TInt thisPartChars = 0;
       
  1397         TInt maxThisPartChars = 0;
       
  1398    
       
  1399         if( iNLTFeatureSupport )
       
  1400             {
       
  1401             //Turkish SMS-PREQ2265 specific
       
  1402             msgsParts = iNumOfPDUs;
       
  1403             maxThisPartChars = iCharsLeft;
       
  1404             thisPartChars = totalLen;
       
  1405 
       
  1406             if(msgsParts > 1)
       
  1407                 {
       
  1408                 // More characters than one SMS segment.                    
       
  1409                 // Calculate characters that are located on this part.
       
  1410                 thisPartChars = lengthMany - maxThisPartChars;
       
  1411                 }                
       
  1412             }
       
  1413         else
       
  1414             {
       
  1415             if ( totalLen <= lengthOne )
       
  1416                 {
       
  1417                 // Less or equal characters than one SMS segment.
       
  1418                 
       
  1419                 // All the characters are located in this part
       
  1420                 thisPartChars = totalLen;
       
  1421                 
       
  1422                 maxThisPartChars = lengthOne - thisPartChars;
       
  1423                 msgsParts = 1;
       
  1424                 }
       
  1425             else
       
  1426                 {
       
  1427                 // More characters than one SMS segment.
       
  1428                 
       
  1429                 // Calculate characters that are located on
       
  1430                 // this part.
       
  1431                 thisPartChars = totalLen % lengthMany;
       
  1432                 
       
  1433                 if ( thisPartChars == 0 )
       
  1434                     {
       
  1435                     // Last part has maximum characters.
       
  1436                     thisPartChars = lengthMany;
       
  1437                     }
       
  1438                     
       
  1439                 maxThisPartChars = lengthMany - thisPartChars;
       
  1440                 
       
  1441                 msgsParts = totalLen / lengthMany;
       
  1442                 if ( thisPartChars != lengthMany )
       
  1443                     { 
       
  1444                     // Chars in this part so lets add one part.
       
  1445                     msgsParts++;
       
  1446                     }
       
  1447                 }                
       
  1448             }
       
  1449              
       
  1450         if ( totalLen <= maxSmsCharacters )
       
  1451             { 
       
  1452             // Calculate the characters left in this part.
       
  1453             charsLeft = maxSmsCharacters -  ( msgsParts - 1 ) * lengthMany - thisPartChars;
       
  1454             // Bound check.
       
  1455             charsLeft = Min( charsLeft, maxThisPartChars );
       
  1456             }
       
  1457         else
       
  1458             { 
       
  1459             // More than max -> show -xx(yy)
       
  1460             charsLeft = maxSmsCharacters - totalLen;
       
  1461             }
       
  1462         if( model->ObjectList().Count() == 0 &&
       
  1463             model->AttachmentList().Count() == 1 &&
       
  1464             iSmilModel->SlideCount() == 1 &&
       
  1465             iSmsSubjectLength == 0)
       
  1466             {                     
       
  1467             charsLeft =  msgsParts;                        
       
  1468             }      
       
  1469         }
       
  1470     }
       
  1471     
       
  1472 
       
  1473 // ---------------------------------------------------------
       
  1474 // CUniEditorAppUi::HandleCommandL
       
  1475 // ---------------------------------------------------------
       
  1476 //
       
  1477 void CUniEditorAppUi::HandleCommandL( TInt aCommand )
       
  1478     {
       
  1479     if ( iFixedToolbar )
       
  1480         {
       
  1481         SetFixedToolbarDimmed();
       
  1482         }
       
  1483      if ( !IsLaunched() || ( iEditorFlags & ( EEditorClosing | EEditorExiting ) ) )
       
  1484         {
       
  1485         if ( aCommand == EEikCmdExit )
       
  1486             {           
       
  1487             TRAPD( error, DoHandleCommandL( EEikCmdExit ) );
       
  1488             User::LeaveIfError(error);                     
       
  1489             }
       
  1490         }   
       
  1491      else
       
  1492         {                
       
  1493         TRAPD( error, DoHandleCommandL( aCommand ) );
       
  1494         
       
  1495         if ( iFixedToolbar )
       
  1496             {
       
  1497             UpdateToolbarL();
       
  1498             }
       
  1499         
       
  1500         User::LeaveIfError( error );
       
  1501         }
       
  1502     }
       
  1503 
       
  1504 // ---------------------------------------------------------
       
  1505 // CUniEditorAppUi::DoHandleCommandL
       
  1506 // ---------------------------------------------------------
       
  1507 //
       
  1508 void CUniEditorAppUi::DoHandleCommandL( TInt aCommand )
       
  1509     {
       
  1510     if ( !IsLaunched() || ( iEditorFlags & ( EEditorClosing | EEditorExiting | EMsgEditInProgress ) ) )
       
  1511         {
       
  1512         if ( aCommand != EEikCmdExit )
       
  1513             {
       
  1514             // Do not handle other than exit command if application has not
       
  1515             // finished launching.
       
  1516             return;
       
  1517             }
       
  1518         }
       
  1519 
       
  1520     switch (aCommand)
       
  1521         {
       
  1522         // Main options menu commands
       
  1523         case EUniCmdViewImage:
       
  1524         case EUniCmdPlayAudio:
       
  1525         case EUniCmdPlayVideo:
       
  1526         case EUniCmdPlaySvg:
       
  1527         case EUniCmdPlayPres:
       
  1528             {
       
  1529             PlayFocusedItemL();
       
  1530             break;
       
  1531             }
       
  1532         case EUniCmdRemovePres:
       
  1533             {
       
  1534             RemoveTemplateL();
       
  1535             break;
       
  1536             }
       
  1537         case EUniCmdSendSMS:
       
  1538         case EUniCmdSendMMS:
       
  1539             {
       
  1540             if ( iHeader->HasRecipients() > 0 )
       
  1541                 {
       
  1542                 // has addresses -> Send
       
  1543                 DoUserSendL();
       
  1544                 }
       
  1545             else
       
  1546                 {
       
  1547                 DoUserAddRecipientL();
       
  1548                 }
       
  1549             break;
       
  1550             }
       
  1551         case EUniCmdAddRecipient:
       
  1552             {
       
  1553             DoUserAddRecipientL();
       
  1554             break;
       
  1555             }
       
  1556         case EUniCmdAddRecipientMSK:
       
  1557             {
       
  1558             // Call this function so that check name functionality is called first
       
  1559             DoSelectionKeyL();
       
  1560             break;
       
  1561             }
       
  1562         case EUniCmdInsertMedia:
       
  1563             {
       
  1564             DoUserInsertMediaL();
       
  1565             break;
       
  1566             }
       
  1567         case EUniCmdInsertTemplateText:
       
  1568             {
       
  1569             DoUserInsertTextL( ETemplateText );
       
  1570             break;
       
  1571             }
       
  1572         case EUniCmdInsertNote:
       
  1573             {
       
  1574             DoUserInsertTextL( EMemoText );
       
  1575             break;
       
  1576             }
       
  1577         case EUniCmdPlaceTextFirst:
       
  1578             {
       
  1579             DoUserChangeOrderL( EUniTextFirst );
       
  1580             break;
       
  1581             }
       
  1582         case EUniCmdPlaceTextSecond:
       
  1583             {
       
  1584             DoUserChangeOrderL( EUniImageFirst );
       
  1585             break;
       
  1586             }
       
  1587         case EUniCmdMovePage:
       
  1588             {
       
  1589             DoUserMoveOrSelectPageL( ETrue );
       
  1590             break;
       
  1591             }
       
  1592         case EUniCmdSelectPage:
       
  1593             {
       
  1594             DoUserMoveOrSelectPageL( EFalse );
       
  1595             break;
       
  1596             }
       
  1597         case EUniCmdAddHeaders:
       
  1598             {
       
  1599             DoUserAddHeadersL();
       
  1600             break;
       
  1601             }
       
  1602         case EUniCmdObjects:
       
  1603             {
       
  1604             DoUserObjectsViewL( EFalse );
       
  1605             break;
       
  1606             }
       
  1607         case EUniCmdObjectsAttachment:
       
  1608             {
       
  1609             DoUserObjectsViewL( ETrue );
       
  1610             break;
       
  1611             }
       
  1612         case EUniCmdSendingOptions:
       
  1613             {
       
  1614             DoUserSendingOptionsL();
       
  1615             break;
       
  1616             }
       
  1617         case EUniCmdMessageInfo:
       
  1618             {
       
  1619             DoUserMessageInfoL();
       
  1620             break;
       
  1621             }
       
  1622         case EUniCmdRemovePage:
       
  1623             {
       
  1624             DoUserRemoveSlideL();
       
  1625             break;
       
  1626             }
       
  1627         case EUniCmdRemoveText:
       
  1628             {
       
  1629             RemoveCurrentTextObjectL();
       
  1630             break;
       
  1631             }
       
  1632         case EUniCmdChangePriority:
       
  1633             {
       
  1634             DoEditMmsPriorityL();
       
  1635             break;        
       
  1636             }
       
  1637         case EUniCmdRemoveImage:
       
  1638             {
       
  1639             DoUserRemoveMediaL( EMsgComponentIdImage, EUniRegionImage );
       
  1640             break;
       
  1641             }
       
  1642         case EUniCmdRemoveAudio:
       
  1643             {
       
  1644             DoUserRemoveMediaL( EMsgComponentIdAudio, EUniRegionAudio );
       
  1645             break;
       
  1646             }
       
  1647         case EUniCmdRemoveVideo:
       
  1648             {
       
  1649             DoUserRemoveMediaL( EMsgComponentIdVideo, EUniRegionImage );
       
  1650             break;
       
  1651             }
       
  1652         case EUniCmdRemoveSvg:
       
  1653             {
       
  1654             DoUserRemoveMediaL( EMsgComponentIdSvg, EUniRegionImage );
       
  1655             break;
       
  1656             }
       
  1657         case EUniCmdRemove:
       
  1658             {
       
  1659             CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
  1660 			if(ctrl)
       
  1661 			{
       
  1662             TMsgControlId controlId = TMsgControlId(ctrl->ControlId()); 
       
  1663 			if(controlId == EMsgComponentIdAudio)
       
  1664 			{
       
  1665                 DoUserRemoveMediaL( controlId, EUniRegionAudio );
       
  1666 			}
       
  1667             else if ( controlId == EMsgComponentIdImage ||
       
  1668 			          controlId == EMsgComponentIdVideo ||
       
  1669                       controlId == EMsgComponentIdSvg )
       
  1670 			{
       
  1671 				if( (Document()->DataModel()->SmilType() == ETemplateSmil) || (Document()->DataModel()->SmilType() == E3GPPSmil))
       
  1672 				   {
       
  1673 				     // focus is on SMIL presentation icon
       
  1674 				      RemoveTemplateL();
       
  1675 				   }
       
  1676 				else
       
  1677 				    {
       
  1678                 		DoUserRemoveMediaL( controlId, EUniRegionImage );
       
  1679 				    }
       
  1680 			}
       
  1681 			} 
       
  1682             break;
       
  1683             }
       
  1684         case EMsgDispSizeAutomatic:
       
  1685         case EMsgDispSizeLarge:
       
  1686         case EMsgDispSizeNormal:
       
  1687         case EMsgDispSizeSmall:
       
  1688             {
       
  1689             HandleLocalZoomChangeL( (TMsgCommonCommands)aCommand );
       
  1690             break;
       
  1691             }
       
  1692         case EEikCmdExit:
       
  1693             {
       
  1694             RemoveWaitNote();
       
  1695             ExitAndSaveL();
       
  1696             break;
       
  1697             }
       
  1698         case EAknSoftkeyClose:
       
  1699             {
       
  1700             DoBackSaveL();
       
  1701             break;
       
  1702             }
       
  1703         case EAknCmdHelp:
       
  1704             {
       
  1705             LaunchHelpL();
       
  1706             break;
       
  1707             }
       
  1708         default:
       
  1709             {
       
  1710             CMsgEditorAppUi::HandleCommandL(aCommand);
       
  1711             break;
       
  1712             }
       
  1713         }
       
  1714     }
       
  1715 
       
  1716 // ---------------------------------------------------------
       
  1717 // CUniEditorAppUi::EditorObserver
       
  1718 // ---------------------------------------------------------
       
  1719 //
       
  1720 void CUniEditorAppUi::EditorObserver( TMsgEditorObserverFunc aFunc, 
       
  1721                                       TAny* aArg1, 
       
  1722                                       TAny* aArg2, 
       
  1723                                       TAny* aArg3)
       
  1724     {
       
  1725     TRAPD( error, DoEditorObserverL( aFunc, aArg1, aArg2, aArg3 ) );
       
  1726     if ( error == KLeaveExit )
       
  1727         {
       
  1728         User::Leave( KLeaveExit );
       
  1729         }
       
  1730     }
       
  1731 
       
  1732 // ---------------------------------------------------------
       
  1733 // CUniEditorAppUi::DoEditorObserverL
       
  1734 // ---------------------------------------------------------
       
  1735 //
       
  1736 void CUniEditorAppUi::DoEditorObserverL( TMsgEditorObserverFunc aFunc, 
       
  1737                                          TAny* aArg1, 
       
  1738                                          TAny* aArg2, 
       
  1739                                          TAny* aArg3)
       
  1740     {
       
  1741     
       
  1742     UNILOGGER_WRITE( "-> CUniEditorAppUi::DoEditorObserverL" );
       
  1743     TInt slides = iSmilModel->SlideCount();
       
  1744     TInt currSlide = Document()->CurrentSlide();
       
  1745 
       
  1746     switch( aFunc )
       
  1747         {
       
  1748         case EMsgScrollParts:
       
  1749             {
       
  1750             TInt* parts = static_cast<TInt*>( aArg1 );
       
  1751             *parts = slides;
       
  1752             break;
       
  1753             }
       
  1754         case MMsgEditorObserver::EMsgHandleFocusChange:
       
  1755             {
       
  1756             TMsgFocusEvent* event = static_cast<TMsgFocusEvent*>( aArg1 );
       
  1757             TMsgAfterFocusEventFunc* after = static_cast<TMsgAfterFocusEventFunc*>( aArg2 );
       
  1758             TInt* currPart = static_cast<TInt*>( aArg3 );
       
  1759 
       
  1760             *after = EMsgAfterFocusNone;
       
  1761             UNILOGGER_WRITE( "-> DoEditorObserverL ->MMsgEditorObserver::EMsgHandleFocusChange " );
       
  1762             
       
  1763             switch ( *event )
       
  1764                 {
       
  1765                 case EMsgFocusAtBottom:
       
  1766                     {
       
  1767                     UNILOGGER_WRITE( "-> DoEditorObserverL ->EMsgFocusAtBottom ");
       
  1768                     if ( currSlide + 1 < slides )
       
  1769                         {
       
  1770 #ifdef RD_SCALABLE_UI_V2
       
  1771                         DoUserChangeSlideL( *currPart );
       
  1772                         *after = EMsgCursorToBodyBeginning;
       
  1773                         *currPart = Document()->CurrentSlide();
       
  1774 #else
       
  1775                         DoUserChangeSlideL( currSlide + 1 );
       
  1776                         *after = EMsgCursorToBodyBeginning;
       
  1777                         *currPart = currSlide + 1;
       
  1778 #endif
       
  1779                         }
       
  1780                     break;
       
  1781                     }
       
  1782                 case EMsgFocusAtTop:
       
  1783                     {
       
  1784                      UNILOGGER_WRITE( "-> DoEditorObserverL ->EMsgFocusAtTop ");
       
  1785                     if ( currSlide > 0 )
       
  1786                         {
       
  1787 #ifdef RD_SCALABLE_UI_V2
       
  1788                         DoUserChangeSlideL( *currPart );
       
  1789                         *after = EMsgCursorToBodyEnd;
       
  1790                         *currPart = Document()->CurrentSlide();
       
  1791 #else
       
  1792                          DoUserChangeSlideL( currSlide - 1 );
       
  1793                         *after = EMsgCursorToBodyEnd;
       
  1794                         *currPart = currSlide - 1;
       
  1795 #endif
       
  1796                         }
       
  1797                     break;
       
  1798                     }
       
  1799                 case EMsgFocusMovingFrom:
       
  1800                     {
       
  1801                     UNILOGGER_WRITE( "-> DoEditorObserverL ->EMsgFocusMovingFrom ");
       
  1802                     TInt id( EMsgComponentIdNull );
       
  1803                     CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
  1804                     if ( !ctrl )
       
  1805                         {
       
  1806                         break;
       
  1807                         }
       
  1808 
       
  1809                     id = ctrl->ControlId();
       
  1810                     if ( id == EMsgComponentIdAudio ||
       
  1811                          id == EMsgComponentIdImage ||
       
  1812                          id == EMsgComponentIdVideo )
       
  1813                         {
       
  1814                         break;
       
  1815                         }
       
  1816 
       
  1817                     // not in first slide -> return
       
  1818                     if ( currSlide > 0 )
       
  1819                         {
       
  1820                         break;
       
  1821                         }
       
  1822                         
       
  1823                     if ( iHeader &&  
       
  1824                          iHeader->IsAddressControl( id ) )
       
  1825                         {
       
  1826                         // We are moving from address control -> set max edwin sizes..
       
  1827                         SetOrRemoveMaxSizeInEdwin();
       
  1828                         
       
  1829                         CMsgAddressControl* rec = iView ? 
       
  1830                             static_cast<CMsgAddressControl*>( iView->ControlById( id ) ) :
       
  1831                             NULL;
       
  1832 
       
  1833                         if ( rec ) 
       
  1834                             {
       
  1835                             TInt inputMode = rec->Editor().AknEditorCurrentInputMode();
       
  1836                             SetInputModeToAddressFields( inputMode );
       
  1837                             }
       
  1838                         }
       
  1839                     break;
       
  1840                     }
       
  1841                 case EMsgFocusMovedTo:
       
  1842                     {
       
  1843                     UNILOGGER_WRITE( "-> DoEditorObserverL ->EMsgFocusMovedTo ");
       
  1844                     TInt id( EMsgComponentIdNull );
       
  1845                     CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
  1846                     if ( !ctrl )
       
  1847                         {
       
  1848                         break;
       
  1849                         }
       
  1850                     
       
  1851                     id = ctrl->ControlId();
       
  1852                     if ( id == EMsgComponentIdAudio ||
       
  1853                          id == EMsgComponentIdImage ||
       
  1854                          id == EMsgComponentIdVideo ||
       
  1855                          id == EMsgComponentIdAttachment ||
       
  1856                          id == EMsgComponentIdSvg )
       
  1857                         {
       
  1858                         iNaviPane->PushL( *iNaviDecorator );
       
  1859                         }
       
  1860                         
       
  1861                     UpdateMiddleSoftkeyL();
       
  1862                     break;
       
  1863                     }
       
  1864                 case EMsgFocusToBody:
       
  1865                 case EMsgFocusToHeader:
       
  1866                     {
       
  1867                     UNILOGGER_WRITE( "-> DoEditorObserverL ->EMsgFocusToBody or EMsgFocusToHeader  ");
       
  1868                     
       
  1869                     SmsMsgLenToPenInputL();
       
  1870                     UpdateMiddleSoftkeyL(); // fallthrough
       
  1871                     break;
       
  1872                     }
       
  1873                 default:
       
  1874                     {
       
  1875                     break;
       
  1876                     }
       
  1877                 }
       
  1878             break;
       
  1879             }
       
  1880         case MMsgEditorObserver::EMsgControlPointerEvent:
       
  1881             {
       
  1882             TPointerEvent* event = static_cast<TPointerEvent*>( aArg2 );
       
  1883             CMsgBaseControl* control = static_cast<CMsgBaseControl*>( aArg1 );
       
  1884             TWsEvent* wsEvent = static_cast<TWsEvent*>(aArg2);
       
  1885             if ( event->iType == TPointerEvent::EButton1Down )
       
  1886                 {
       
  1887                 iFocusedControl = control;
       
  1888                 if ( control && 
       
  1889                         ( control->ControlId() == EMsgComponentIdAudio ||
       
  1890                                 control->ControlId() == EMsgComponentIdImage ||
       
  1891                                 control->ControlId() == EMsgComponentIdVideo ||
       
  1892                                 control->ControlId() == EMsgComponentIdAttachment ||
       
  1893                                 control->ControlId() == EMsgComponentIdSvg ) )
       
  1894                     {
       
  1895                     if(iLongTapDetector)
       
  1896                         {
       
  1897                         iLongTapDetector->EnableLongTapAnimation(ETrue);
       
  1898                         iLongTapDetector->PointerEventL( *event );
       
  1899                         }
       
  1900                     }
       
  1901                 iTapConsumed = EFalse;
       
  1902                 }
       
  1903             else if ( (!iTapConsumed) && (event->iType == TPointerEvent::EButton1Up) )
       
  1904                 {
       
  1905                 iLongTapDetector->MonitorWsMessage(*wsEvent);
       
  1906                 iTapConsumed = ETrue;
       
  1907                 if ( control && 
       
  1908                      iFocusedControl == control &&
       
  1909                      ( control->ControlId() == EMsgComponentIdAudio ||
       
  1910                        control->ControlId() == EMsgComponentIdImage ||
       
  1911                        control->ControlId() == EMsgComponentIdVideo ||
       
  1912                        control->ControlId() == EMsgComponentIdAttachment ||
       
  1913                        control->ControlId() == EMsgComponentIdSvg ) )
       
  1914                     {
       
  1915                     DoSelectionKeyL();
       
  1916                     }
       
  1917                 }
       
  1918             break;
       
  1919             }
       
  1920         case MMsgEditorObserver::EMsgButtonEvent:
       
  1921             {
       
  1922             CMsgBaseControl* control = static_cast<CMsgBaseControl*>( aArg1 );
       
  1923             
       
  1924             if ( control &&
       
  1925                  ( control->ControlId() != EMsgComponentIdAttachment ||
       
  1926                    iFocusedControl != control ) )
       
  1927                 {
       
  1928                 DoSelectionKeyL();
       
  1929                 }
       
  1930             break;
       
  1931             }
       
  1932         default:
       
  1933             {
       
  1934             // Other events not handled.
       
  1935             break;
       
  1936             }
       
  1937         }
       
  1938     }
       
  1939 
       
  1940 // ---------------------------------------------------------
       
  1941 // CUniEditorAppUi::FetchFileL
       
  1942 // ---------------------------------------------------------
       
  1943 //
       
  1944 TBool CUniEditorAppUi::FetchFileL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType )
       
  1945     {
       
  1946     // do not start if()ing. Sets parameter always
       
  1947     TAiwVariant sizeLimit( Document()->MaxMessageSize() 
       
  1948                             - ( MessageSizeInBytes() + KUniAttachmentOverhead ) );
       
  1949     TAiwGenericParam sizeLimitParam( EGenericParamMMSSizeLimit, sizeLimit );
       
  1950 
       
  1951     CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
       
  1952     paramList->AppendL( sizeLimitParam );
       
  1953     
       
  1954     CDesCArrayFlat* files = new( ELeave ) CDesC16ArrayFlat( 1 );
       
  1955     CleanupStack::PushL( files );
       
  1956     
       
  1957     TBool fetchOK = MsgAttachmentUtils::FetchFileL( aFetchType,
       
  1958                                                     *files,
       
  1959                                                     paramList,
       
  1960                                                     EFalse, // disk space checked in VerifySelectionL or CUniEditorInsertOperation, if image scaled/compressed
       
  1961                                                     EFalse,
       
  1962                                                     this );
       
  1963 
       
  1964     switch ( aFetchType )
       
  1965         {
       
  1966         case MsgAttachmentUtils::ENewImage:
       
  1967         case MsgAttachmentUtils::ENewAudio:
       
  1968         case MsgAttachmentUtils::ENewVideo:
       
  1969         case MsgAttachmentUtils::ENote:
       
  1970             {
       
  1971             if ( fetchOK )
       
  1972                 {
       
  1973                 TFileName* fileName = new( ELeave ) TFileName;
       
  1974                 CleanupStack::PushL( fileName );
       
  1975     
       
  1976                 if ( files->MdcaCount() > 0 )
       
  1977                     {
       
  1978                     *fileName = files->MdcaPoint( 0 );
       
  1979                     }
       
  1980                     
       
  1981                 // Something was fetched
       
  1982                 __ASSERT_DEBUG( !iInsertingMedia, Panic( EUniIllegalMediaObject ) );
       
  1983                 fetchOK = CreateMediaInfoForInsertL( iInsertingType, *fileName ) ? ETrue : 
       
  1984                                                                                    EFalse;
       
  1985                 CleanupStack::PopAndDestroy( fileName );
       
  1986                 }
       
  1987             break;
       
  1988             }
       
  1989         case MsgAttachmentUtils::EImage:
       
  1990         case MsgAttachmentUtils::EAudio:
       
  1991         case MsgAttachmentUtils::EVideo:
       
  1992         case MsgAttachmentUtils::ESVG:
       
  1993         default:
       
  1994             {
       
  1995             // CreateMediaInfoForInsertL is called in VeritySelectionL
       
  1996             break;
       
  1997             }
       
  1998         }
       
  1999     
       
  2000     CleanupStack::PopAndDestroy( 2, paramList );    // + files
       
  2001     
       
  2002     return fetchOK;
       
  2003     }
       
  2004 
       
  2005 // ---------------------------------------------------------
       
  2006 // CUniEditorAppUi::VerifySelectionL
       
  2007 // ---------------------------------------------------------
       
  2008 //
       
  2009 TBool CUniEditorAppUi::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
  2010     {
       
  2011     CAknInputBlock::NewLC();
       
  2012 
       
  2013     TBool ret = EFalse;
       
  2014     if ( aSelectedFiles->MdcaCount() == 1 )
       
  2015         {
       
  2016         __ASSERT_DEBUG( !iInsertingMedia, Panic( EUniIllegalMediaObject ) );
       
  2017         if ( CreateMediaInfoForInsertL( iInsertingType, aSelectedFiles->MdcaPoint( 0 ) ) )
       
  2018             {
       
  2019             ret = ETrue;
       
  2020             }
       
  2021         }
       
  2022     
       
  2023     CleanupStack::PopAndDestroy(); // CAknInputBlock
       
  2024     return ret;
       
  2025     }
       
  2026 
       
  2027 // ---------------------------------------------------------
       
  2028 // CUniEditorAppUi::DynInitToolbarL
       
  2029 // ---------------------------------------------------------
       
  2030 //
       
  2031 void CUniEditorAppUi::DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar )
       
  2032     {
       
  2033     if ( aResourceId == EUniCmdFixedToolbarInsert )
       
  2034         {
       
  2035         CAknToolbarExtension* extension = aToolbar->ToolbarExtension();
       
  2036         
       
  2037         if ( iSmilModel )
       
  2038             {
       
  2039             if ( iSmilModel->SlideCount() >= iSmilModel->MaxSlideCount() )
       
  2040                 {
       
  2041                 if ( ObjectsAvailable() & ( EUniImageFlag |  EUniSvgFlag | EUniVideoFlag ) )
       
  2042                     {
       
  2043                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertImage, ETrue );
       
  2044                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewImage, ETrue );
       
  2045                     }
       
  2046                else
       
  2047                     {
       
  2048                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertImage, EFalse );
       
  2049                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewImage, EFalse );
       
  2050                     }
       
  2051                     
       
  2052                 if ( ObjectsAvailable() & ( EUniImageFlag |  EUniSvgFlag | EUniVideoFlag | EUniAudioFlag ) )
       
  2053                     {
       
  2054                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertVideo, ETrue );
       
  2055                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewVideo, ETrue );
       
  2056                     }
       
  2057                 else
       
  2058                     {
       
  2059                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertVideo, EFalse );
       
  2060                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewVideo, EFalse );
       
  2061                     }
       
  2062                 
       
  2063                 if ( ObjectsAvailable() & ( EUniVideoFlag | EUniAudioFlag | EUniSvgFlag ) )
       
  2064                     {
       
  2065                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertAudio, ETrue );
       
  2066                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewAudio, ETrue );
       
  2067                     }
       
  2068                 else 
       
  2069                     {
       
  2070                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertAudio, EFalse );
       
  2071                     SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewAudio, EFalse );
       
  2072                     }
       
  2073                 
       
  2074                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertSlide, ETrue );
       
  2075                 }
       
  2076             else 
       
  2077                 {
       
  2078                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertImage, EFalse );
       
  2079                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewImage, EFalse );
       
  2080                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertVideo, EFalse );
       
  2081                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewVideo, EFalse );
       
  2082                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertAudio, EFalse );
       
  2083                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewAudio, EFalse );
       
  2084                 SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtInsertSlide, EFalse );                
       
  2085                 }
       
  2086             }
       
  2087         
       
  2088         if ( !( iSupportedFeatures & EUniFeatureCamcorder ) )
       
  2089             {
       
  2090             SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewImage, ETrue );
       
  2091             SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewVideo, ETrue );
       
  2092             }
       
  2093 
       
  2094         if ( Document()->CreationMode() == EMmsCreationModeRestricted )
       
  2095              {
       
  2096              SetExtensionButtonDimmed( extension, EUniCmdFixedToolbarExtNewSmil, ETrue );             
       
  2097              }
       
  2098         }
       
  2099     }
       
  2100 
       
  2101 // ---------------------------------------------------------
       
  2102 // CUniEditorAppUi::OfferToolbarEventL
       
  2103 // ---------------------------------------------------------
       
  2104 //        
       
  2105 void CUniEditorAppUi::OfferToolbarEventL( TInt aCommand )
       
  2106     {
       
  2107     if ( iFixedToolbar )
       
  2108         {
       
  2109         iFixedToolbar->ToolbarExtension()->SetShown( EFalse );
       
  2110         }
       
  2111             
       
  2112     TRAPD( error, DoOfferToolbarEventL( aCommand ) );
       
  2113             
       
  2114     User::LeaveIfError( error );
       
  2115     }
       
  2116 
       
  2117         
       
  2118 // ---------------------------------------------------------
       
  2119 // CUniEditorAppUi::DoOfferToolbarEventL
       
  2120 // ---------------------------------------------------------
       
  2121 //        
       
  2122 void CUniEditorAppUi::DoOfferToolbarEventL( TInt aCommand )
       
  2123     {
       
  2124     switch( aCommand )
       
  2125         {
       
  2126         case EUniCmdFixedToolbarSend:
       
  2127             {
       
  2128             DoHandleCommandL( EUniCmdSendSMS );
       
  2129             break;
       
  2130             }
       
  2131         case EUniCmdFixedToolbarInsert:
       
  2132             {
       
  2133             DoHandleCommandL( EUniCmdInsertMedia );
       
  2134             break;
       
  2135             }
       
  2136         case EUniCmdFixedToolbarAddRecipient:
       
  2137             {
       
  2138             DoHandleCommandL( EUniCmdAddRecipient );
       
  2139             break;
       
  2140             }
       
  2141         case EUniCmdFixedToolbarExtInsertImage:
       
  2142             {
       
  2143             DoUserInsertImageL( MsgAttachmentUtils::EImage );
       
  2144             break;
       
  2145             }
       
  2146         case EUniCmdFixedToolbarExtInsertVideo:
       
  2147             {
       
  2148             DoUserInsertVideoL( MsgAttachmentUtils::EVideo );
       
  2149             break;
       
  2150             }
       
  2151         case EUniCmdFixedToolbarExtInsertAudio:
       
  2152             {
       
  2153             DoUserInsertAudioL( MsgAttachmentUtils::EAudio );
       
  2154             break;
       
  2155             }
       
  2156         case EUniCmdFixedToolbarExtNewImage:
       
  2157             {
       
  2158             DoUserInsertImageL( MsgAttachmentUtils::ENewImage );
       
  2159             break;
       
  2160             }
       
  2161         case EUniCmdFixedToolbarExtNewVideo:
       
  2162             {
       
  2163             DoUserInsertVideoL( MsgAttachmentUtils::ENewVideo );
       
  2164             break;
       
  2165             }
       
  2166         case EUniCmdFixedToolbarExtNewAudio:
       
  2167             {
       
  2168             DoUserInsertAudioL( MsgAttachmentUtils::ENewAudio );
       
  2169             break;
       
  2170             }
       
  2171         case EUniCmdFixedToolbarExtInsertSlide:
       
  2172             {
       
  2173             DoUserInsertSlideL();
       
  2174             break;
       
  2175             }
       
  2176         case EUniCmdFixedToolbarExtInsertTemplate:
       
  2177             {
       
  2178             DoUserInsertTextL( ETemplateText );
       
  2179             break;
       
  2180             }
       
  2181         case EUniCmdFixedToolbarExtInsertNote:
       
  2182             {
       
  2183             DoUserInsertTextL( EMemoText );
       
  2184             break;
       
  2185             }
       
  2186         case EUniCmdFixedToolbarExtInsertvCard:
       
  2187             {
       
  2188             DoUserInsertVCardL();
       
  2189             break;
       
  2190             }
       
  2191         case EUniCmdFixedToolbarExtOther:
       
  2192             {
       
  2193             DoToolbarInsertOtherL();
       
  2194             break;
       
  2195             }
       
  2196         default:
       
  2197             {
       
  2198             break;
       
  2199             }
       
  2200         }
       
  2201     }
       
  2202 
       
  2203 // ---------------------------------------------------------
       
  2204 // CUniEditorAppUi::HandleServerAppExit
       
  2205 // ---------------------------------------------------------
       
  2206 // 
       
  2207 void CUniEditorAppUi::HandleServerAppExit( TInt /*aReason*/ )
       
  2208     {
       
  2209     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  2210 
       
  2211     if ( ctrl )
       
  2212         {
       
  2213         TUniRegion region = EUniRegionImage;
       
  2214         
       
  2215         switch ( ctrl->ControlId() )
       
  2216             {
       
  2217             case EMsgComponentIdAudio:
       
  2218                 {
       
  2219                 region = EUniRegionAudio;
       
  2220                 // Fallthrough.
       
  2221                 }
       
  2222             case EMsgComponentIdVideo:
       
  2223                 {
       
  2224                 CUniObject* object = iSmilModel->GetObject( Document()->CurrentSlide(), region );
       
  2225                 
       
  2226                 // Coverty fix, Null pointer return, http://ousrv057/cov.cgi?cid=37172
       
  2227                 if ( object )
       
  2228                 	{
       
  2229                     if ( object->DrmInfo() )
       
  2230                        {
       
  2231                        object->DrmInfo()->FreezeRights();
       
  2232                        }
       
  2233                     }
       
  2234                 
       
  2235                 TRAP_IGNORE( iSlideLoader->UpdateControlIconL( 
       
  2236                                                   *static_cast<CMsgMediaControl*>( ctrl ), 
       
  2237                                                   object ) );
       
  2238                 ctrl->DrawNow();
       
  2239                 break;
       
  2240                 }
       
  2241             default:
       
  2242                 {
       
  2243                 break;
       
  2244                 }
       
  2245             }
       
  2246         }
       
  2247     iEditorFlags &= ~EMsgEditInProgress;
       
  2248     DeactivateInputBlocker();
       
  2249     }
       
  2250 
       
  2251 // ---------------------------------------------------------
       
  2252 // CUniEditorAppUi::HandleEdwinEventL
       
  2253 //
       
  2254 // Performs character counter updating if neccessary. This is needed
       
  2255 // for supporting on-screen keyboard. Normally character input
       
  2256 // is handled already on OfferKeyEventL function but it does no
       
  2257 // harm to do it here again. Character input is not handled if editor
       
  2258 // is not fully launched or it is about to close. Modified flag is turned
       
  2259 // on here since control state change event that should turn it on might 
       
  2260 // come after this event and HandleCharInputL will not work correctly if 
       
  2261 // modified flag is not set. Text update event is expected to come only
       
  2262 // in such cases that control is modified.
       
  2263 // ---------------------------------------------------------
       
  2264 //
       
  2265 void CUniEditorAppUi::HandleEdwinEventL( CEikEdwin* /*aEdwin*/, TEdwinEvent aEventType )
       
  2266     {
       
  2267     if ( aEventType == MEikEdwinObserver::EEventTextUpdate &&
       
  2268          !( iEditorFlags & EEditorClosing ||
       
  2269             iEditorFlags & EEditorExiting ) &&
       
  2270          IsLaunched() )
       
  2271         {
       
  2272         CMsgBaseControl* focusedControl = iView->FocusedControl();
       
  2273         if ( focusedControl )
       
  2274             {
       
  2275             focusedControl->SetModified( ETrue );
       
  2276             
       
  2277             HandleCharInputL();            
       
  2278             }
       
  2279         }
       
  2280     }
       
  2281 
       
  2282 // ---------------------------------------------------------
       
  2283 // CUniEditorAppUi::HandleEntryMovedL
       
  2284 // ---------------------------------------------------------
       
  2285 //
       
  2286 void CUniEditorAppUi::HandleEntryMovedL( TMsvId /*aOldParent*/, TMsvId /*aNewParent*/ )
       
  2287     {
       
  2288     }
       
  2289 
       
  2290 // ---------------------------------------------------------
       
  2291 // CUniEditorAppUi::HandleKeyEventL
       
  2292 // ---------------------------------------------------------
       
  2293 //
       
  2294 TKeyResponse CUniEditorAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, 
       
  2295                                                TEventCode aType )
       
  2296     {
       
  2297     if ( !IsLaunched() )
       
  2298         {
       
  2299         // Still launching
       
  2300         return EKeyWasNotConsumed;
       
  2301         }
       
  2302         
       
  2303     if ( !IsDisplayingMenuOrDialog() &&
       
  2304          !( iEditorFlags & EEditorClosing ||
       
  2305             iEditorFlags & EEditorExiting ) )
       
  2306         {
       
  2307         switch ( aKeyEvent.iCode )
       
  2308             {
       
  2309             case EKeyEnter:
       
  2310                 {
       
  2311                 if ( DoEnterKeyL() )
       
  2312                     {
       
  2313                     return EKeyWasConsumed;
       
  2314                     }
       
  2315                 break;
       
  2316                 }
       
  2317             case EKeyOK:
       
  2318                 {
       
  2319                 // Selection key: Show context menus
       
  2320                 DoSelectionKeyL();
       
  2321                 return EKeyWasConsumed;
       
  2322                 }
       
  2323             case EKeyYes:
       
  2324                 {
       
  2325                 // CallCreationKey: Send message if recipients.
       
  2326                 //                  Otherwise fetch recipients
       
  2327                 if ( iHeader->HasRecipients() )
       
  2328                     {
       
  2329                     // has addresses -> Send
       
  2330                     DoUserSendL();
       
  2331                     }
       
  2332                 else
       
  2333                     {
       
  2334                     DoUserAddRecipientL();
       
  2335                     }
       
  2336                 return EKeyWasConsumed;
       
  2337                 }
       
  2338             case EKeyBackspace:
       
  2339             case EKeyDelete:
       
  2340                 {
       
  2341                 CMsgBaseControl* ctrl = iView->FocusedControl();
       
  2342                 if ( ctrl )
       
  2343                     {
       
  2344                     switch( ctrl->ControlId() )
       
  2345                         {
       
  2346                         case EMsgComponentIdImage:
       
  2347                             {
       
  2348                             switch ( Document()->DataModel()->SmilType() )
       
  2349                                 {
       
  2350                                 case ETemplateSmil:
       
  2351                                 case E3GPPSmil:
       
  2352                                     {
       
  2353                                     // focus is on SMIL presentation icon
       
  2354                                     RemoveTemplateL();
       
  2355                                     break;
       
  2356                                     }
       
  2357                                 default:
       
  2358                                     {
       
  2359                                     // real image
       
  2360                                     DoUserRemoveMediaL( EMsgComponentIdImage, EUniRegionImage );
       
  2361                                     break;
       
  2362                                     }
       
  2363                                 }
       
  2364                                 
       
  2365                             return EKeyWasConsumed;
       
  2366                             }
       
  2367                         case EMsgComponentIdAudio:
       
  2368                             {
       
  2369                             DoUserRemoveMediaL( EMsgComponentIdAudio, EUniRegionAudio );
       
  2370                             return EKeyWasConsumed;
       
  2371                             }
       
  2372                         case EMsgComponentIdVideo:
       
  2373                             {
       
  2374                             DoUserRemoveMediaL( EMsgComponentIdVideo, EUniRegionImage );
       
  2375                             return EKeyWasConsumed;
       
  2376                             }
       
  2377                         case EMsgComponentIdSvg:
       
  2378                             {
       
  2379                             DoUserRemoveMediaL( EMsgComponentIdSvg, EUniRegionImage );
       
  2380                             return EKeyWasConsumed;
       
  2381                             }
       
  2382                         default:
       
  2383                             {
       
  2384                             break;
       
  2385                             }
       
  2386                         }
       
  2387                     }
       
  2388                 break;
       
  2389                 }
       
  2390             default:
       
  2391                 {
       
  2392                 break;
       
  2393                 }
       
  2394             }
       
  2395             
       
  2396         switch ( aKeyEvent.iScanCode )
       
  2397             {
       
  2398             case EStdKeyUpArrow:
       
  2399             case EStdKeyDownArrow:
       
  2400             case EStdKeyLeftArrow:
       
  2401             case EStdKeyRightArrow:
       
  2402             case EStdKeyDevice1: // Close key                
       
  2403             case EStdKeyRightShift: // Shift
       
  2404             case EStdKeyApplication0: // Task switching
       
  2405                 {
       
  2406                 return CMsgEditorAppUi::HandleKeyEventL( aKeyEvent, aType );
       
  2407                 }
       
  2408             default:
       
  2409                 {
       
  2410                 break;
       
  2411                 }
       
  2412             }
       
  2413 
       
  2414         TKeyResponse resp = CMsgEditorAppUi::HandleKeyEventL( aKeyEvent, aType );
       
  2415 
       
  2416         if ( aType == EEventKeyUp )
       
  2417             {
       
  2418             // Check if character inserted to controls
       
  2419             HandleCharInputL();
       
  2420             }
       
  2421 
       
  2422         return resp;
       
  2423         }
       
  2424     else
       
  2425         {
       
  2426         return CMsgEditorAppUi::HandleKeyEventL(aKeyEvent, aType);
       
  2427         }
       
  2428     }
       
  2429 
       
  2430 // ---------------------------------------------------------
       
  2431 // CUniEditorAppUi::HandleCharInputL
       
  2432 // Updates model
       
  2433 // ---------------------------------------------------------
       
  2434 //
       
  2435 void CUniEditorAppUi::HandleCharInputL()
       
  2436     {
       
  2437     if ( IsLaunched() )
       
  2438         {
       
  2439         CMsgBaseControl* ctrl = iView->FocusedControl();
       
  2440         TBool changed = EFalse;
       
  2441 
       
  2442         if ( ctrl )
       
  2443             {
       
  2444             switch ( ctrl->ControlId() )
       
  2445                 {
       
  2446                 case EMsgComponentIdTo:
       
  2447                 case EMsgComponentIdCc:
       
  2448                 case EMsgComponentIdBcc:
       
  2449                     {
       
  2450                     if ( ctrl->IsModified() )
       
  2451                         {
       
  2452                         Document()->SetHeaderModified( ETrue );
       
  2453                         CheckHeaderForMessageTypeL();
       
  2454                         changed = ETrue;
       
  2455                         }
       
  2456                     SetAddressSize();
       
  2457                     break;
       
  2458                     }
       
  2459                 case EMsgComponentIdSubject:
       
  2460                     {
       
  2461                     if ( ctrl->IsModified() )
       
  2462                         {
       
  2463                         Document()->SetHeaderModified( ETrue );
       
  2464                         changed = ETrue;
       
  2465                         }
       
  2466                         
       
  2467                     SetSubjectSize();
       
  2468                     CheckBodyForMessageTypeL();
       
  2469                     CheckMaxSmsSizeAndShowNoteL();
       
  2470                     SetOrRemoveMaxSizeInEdwin();
       
  2471                     break;
       
  2472                     }
       
  2473                 case EMsgComponentIdBody:
       
  2474                     {
       
  2475                     if ( ctrl->IsModified() )
       
  2476                         {
       
  2477                         UpdateSmilTextAttaL();
       
  2478                         Document()->SetBodyModified( ETrue );
       
  2479                         CheckBodyForMessageTypeL();
       
  2480                         CheckMaxSmsSizeAndShowNoteL();
       
  2481                         SetOrRemoveMaxSizeInEdwin();
       
  2482                         changed = ETrue;
       
  2483                         }
       
  2484                     break;
       
  2485                     }
       
  2486                 default:
       
  2487                     {
       
  2488                     // Text control not focused.
       
  2489                     break;
       
  2490                     }
       
  2491                 }
       
  2492             }
       
  2493             
       
  2494         if ( changed )
       
  2495             {
       
  2496             MsgLengthToNavipaneL();
       
  2497             }
       
  2498         }
       
  2499     }
       
  2500 
       
  2501 // ---------------------------------------------------------
       
  2502 // CUniEditorAppUi::HandleForegroundEventL
       
  2503 // 
       
  2504 // Updates navipane at editor start when launched from 
       
  2505 // ---------------------------------------------------------
       
  2506 //
       
  2507 void CUniEditorAppUi::HandleForegroundEventL( TBool aForeground )
       
  2508     {
       
  2509     UNILOGGER_WRITE( "-> CUniEditorAppUi::HandleForegroundEventL" );
       
  2510     
       
  2511     CAknAppUi::HandleForegroundEventL( aForeground );
       
  2512     
       
  2513     if ( IsLaunched() &&
       
  2514          aForeground && 
       
  2515          !IsDisplayingDialog() &&
       
  2516          !( iEditorFlags & ( EEditorExiting | EEditorClosing ) ) )
       
  2517         {
       
  2518         // This must be init.. not MsgLen... Otherwise returning
       
  2519         // from embedded app loses msglength
       
  2520         InitNaviPaneL();
       
  2521         }
       
  2522     
       
  2523     UNILOGGER_WRITE( "-> CUniEditorAppUi::HandleForegroundEventL" );
       
  2524     }
       
  2525 
       
  2526 // ---------------------------------------------------------
       
  2527 // CUniEditorAppUi::UpdateSmilTextAttaL
       
  2528 // 
       
  2529 // NOTE: This function should only be called when text is 
       
  2530 //       added/removed to/from bodycontrol.
       
  2531 // ---------------------------------------------------------
       
  2532 //
       
  2533 void CUniEditorAppUi::UpdateSmilTextAttaL()
       
  2534     {
       
  2535     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  2536     
       
  2537     TInt slideNum = Document()->CurrentSlide();
       
  2538     if ( slideNum < 0 || slideNum >= iSmilModel->SlideCount() )
       
  2539         {
       
  2540         return;
       
  2541         }
       
  2542     
       
  2543     // Update smilmodel
       
  2544     if ( !BodyCtrl() || 
       
  2545          BodyCtrl()->TextContent().DocumentLength() == 0 )
       
  2546         {
       
  2547         // Body control does not exist or it is empty
       
  2548         CUniObject* obj = iSmilModel->GetObject( slideNum, EUniRegionText );
       
  2549         if ( obj )
       
  2550             {
       
  2551             // If there is text atta in presentation it should be removed.
       
  2552             // Note: Text atta is not removed from store at this point (removed in save)
       
  2553             iSmilModel->RemoveObjectL( slideNum, obj );
       
  2554             }
       
  2555         }
       
  2556     else
       
  2557         {
       
  2558         // Text added -> see if model already has text atta
       
  2559         if ( !iSmilModel->GetObject( slideNum, EUniRegionText ) )
       
  2560             {
       
  2561             if ( !iSmilModel->IsSlide( slideNum ) )
       
  2562                 {
       
  2563                 // Add slide
       
  2564                 iSmilModel->AddSlideL( slideNum );
       
  2565                 }
       
  2566             iSmilModel->AddTextObjectL( slideNum,
       
  2567                                         &( BodyCtrl()->Editor() ) );
       
  2568             }
       
  2569         }
       
  2570     }
       
  2571 
       
  2572 // ---------------------------------------------------------
       
  2573 // CUniEditorAppUi::DynInitMenuPaneL
       
  2574 // ---------------------------------------------------------
       
  2575 //
       
  2576 void CUniEditorAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
  2577     {
       
  2578     // Confirm app is running properly (needed atleast now)
       
  2579     if ( !IsLaunched() )
       
  2580         {
       
  2581         // If not, hide everything and return
       
  2582         TInt amountOfItems = aMenuPane->NumberOfItemsInPane();
       
  2583         if ( amountOfItems )
       
  2584             {
       
  2585             aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems-1 );
       
  2586             }
       
  2587         return;
       
  2588         }
       
  2589 
       
  2590     TUint32 objects = ObjectsAvailable();
       
  2591 
       
  2592     switch ( aResourceId ) 
       
  2593         {
       
  2594         case R_UNIEDITOR_MAIN_MENU:
       
  2595             {
       
  2596             // Features always visible:
       
  2597             // EEikCmdExit
       
  2598             // EUniCmdSendingOptions
       
  2599             // EUniCmdMessageInfo
       
  2600 
       
  2601             // Features checked commonly
       
  2602             if ( !( iSupportedFeatures & EUniFeatureHelp ) )
       
  2603                 { 
       
  2604                 // Help
       
  2605                 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  2606                 }
       
  2607                 
       
  2608             // Features in locked SMS mode
       
  2609             if ( IsHardcodedSms() )
       
  2610                 { 
       
  2611                 // Dim these items always in locked SMS mode
       
  2612 
       
  2613                 aMenuPane->SetItemDimmed( EUniCmdPlayPreview, ETrue );
       
  2614                 aMenuPane->SetItemDimmed( EUniCmdSendMMS, ETrue );
       
  2615                 aMenuPane->SetItemDimmed( EUniCmdInsertMedia, ETrue );
       
  2616                 aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2617                 aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );
       
  2618                 aMenuPane->SetItemDimmed( EUniCmdMovePage, ETrue );
       
  2619                 aMenuPane->SetItemDimmed( EUniCmdSelectPage, ETrue );
       
  2620                 aMenuPane->SetItemDimmed( EUniCmdChangePriority, ETrue );
       
  2621                 
       
  2622                 if ( Document()->DataModel()->ObjectList().Count() == 0 &&
       
  2623                      Document()->DataModel()->AttachmentList().Count() == 0 )
       
  2624                     {   
       
  2625                     // If no objects -> hide the option
       
  2626                     aMenuPane->SetItemDimmed( EUniCmdObjects, ETrue );
       
  2627                     }
       
  2628                 
       
  2629                 if ( !Document()->EmailOverSmsSupported() ||
       
  2630                      ( iHeader &&  
       
  2631                        !( iHeader->AddHeadersVariation() & EUniFeatureSubjectConfigurable ) ) )
       
  2632                     { 
       
  2633                     // Locked SMS and no email over sms or email over SMS without selectable subject.
       
  2634                     aMenuPane->SetItemDimmed( EUniCmdAddHeaders, ETrue );
       
  2635                     }
       
  2636                 
       
  2637                 if ( !BodyCtrl() )
       
  2638                     {
       
  2639                     aMenuPane->SetItemDimmed( EUniCmdRemoveSubmenu, ETrue );                    
       
  2640                     aMenuPane->SetItemDimmed( EUniCmdInsertSubmenu, ETrue );
       
  2641                     }
       
  2642                 else if ( BodyCtrlEditor()->TextLength() == 0 )
       
  2643                     {
       
  2644                     aMenuPane->SetItemDimmed( EUniCmdRemoveSubmenu, ETrue );                    
       
  2645                     }
       
  2646                 }
       
  2647             else if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  2648                 {
       
  2649                 // MMS upload message
       
  2650                 aMenuPane->SetItemDimmed( EUniCmdInsertSubmenu, ETrue );
       
  2651                 aMenuPane->SetItemDimmed( EUniCmdAddHeaders, ETrue );
       
  2652                 aMenuPane->SetItemDimmed( EUniCmdAddRecipient, ETrue );                                    
       
  2653                 aMenuPane->SetItemDimmed( EUniCmdChangePriority, ETrue );
       
  2654                 
       
  2655                 if ( Document()->DataModel()->ObjectList().Count() == 0 &&
       
  2656                      Document()->DataModel()->AttachmentList().Count() == 0 )
       
  2657                     {   
       
  2658                     // If no objects -> hide the option
       
  2659                     aMenuPane->SetItemDimmed( EUniCmdObjects, ETrue );
       
  2660                     }
       
  2661                     
       
  2662                 DynInitFocusedMediaBasedOptionsL( aMenuPane );
       
  2663                 }
       
  2664             else 
       
  2665                 {
       
  2666                 // It's automatic mode
       
  2667                 aMenuPane->SetItemDimmed( EUniCmdInsertSubmenu, ETrue );
       
  2668                 
       
  2669                 if ( Document()->DataModel()->ObjectList().Count() == 0 &&
       
  2670                      Document()->DataModel()->AttachmentList().Count() == 0 )
       
  2671                     {   // If no objects -> hide the option
       
  2672                     aMenuPane->SetItemDimmed( EUniCmdObjects, ETrue );
       
  2673                     }
       
  2674                     
       
  2675                 if ( Document()->UniState() == EUniSms )
       
  2676                     {
       
  2677                     // It's currently a SMS message
       
  2678 
       
  2679                     aMenuPane->SetItemDimmed( EUniCmdPlayPreview, ETrue );
       
  2680                     aMenuPane->SetItemDimmed( EUniCmdSendMMS, ETrue );
       
  2681                     aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2682                     aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );
       
  2683                     aMenuPane->SetItemDimmed( EUniCmdPlayPreview, ETrue );                    
       
  2684                     aMenuPane->SetItemDimmed( EUniCmdMovePage, ETrue );  
       
  2685                     aMenuPane->SetItemDimmed( EUniCmdSelectPage, ETrue );                    
       
  2686                     aMenuPane->SetItemDimmed( EUniCmdChangePriority, ETrue );
       
  2687                     if ( !BodyCtrlEditor() || BodyCtrlEditor()->TextLength() == 0 )
       
  2688                         {
       
  2689                         aMenuPane->SetItemDimmed( EUniCmdRemoveSubmenu, ETrue );                    
       
  2690                         }
       
  2691                     }
       
  2692                 else
       
  2693                     { 
       
  2694                     // It's currently a MMS message
       
  2695 					/*
       
  2696                      * Do not show "Sending Options" menu item if:
       
  2697                      * 1. It is a MMS and
       
  2698                      * 2. The feature flag MpMessagingHideMessageTypeId is set
       
  2699                      * This is because when we are composing a MMS, 
       
  2700                      * "Character Support" option is not displayed in "Sending Options"
       
  2701                      * and because of this flag, we are not going to show "Message Type"
       
  2702                      * option as well - resulting in an empty "Sendings Options" dialog.
       
  2703                      * Therefore, it was decided to hide this menu option when
       
  2704                      * composing a MMS (if flag is defined)
       
  2705                      */
       
  2706                     if ( iEditorFlags & EHideMessageTypeOption ||
       
  2707                          iMtm->MessageTypeLocking() == EUniMessageTypeLocked )
       
  2708                         {
       
  2709                         // Also, if message is permanently locked ( to mms ) -> no sending options
       
  2710                         aMenuPane->SetItemDimmed( EUniCmdSendingOptions, ETrue );
       
  2711                         }
       
  2712                         
       
  2713                     if ( !(iSupportedFeatures & EUniFeaturePriority) )
       
  2714                         {
       
  2715                         aMenuPane->SetItemDimmed( EUniCmdChangePriority, ETrue );
       
  2716                         }
       
  2717                         
       
  2718                     // Always visible in MMS message:
       
  2719                     // EUniCmdAddRecipient
       
  2720                     if ( iHeader &&  
       
  2721                          !iHeader->AddHeadersVariation() )
       
  2722                         {
       
  2723                         aMenuPane->SetItemDimmed( EUniCmdAddHeaders, ETrue );
       
  2724                         }
       
  2725                         
       
  2726                     DynInitFocusedMediaBasedOptionsL( aMenuPane );
       
  2727                     }
       
  2728                 }
       
  2729             break;
       
  2730             }
       
  2731         case R_UNIEDITOR_REMOVE_SUBMENU:
       
  2732             {
       
  2733             // Remove submenu is visible only for MMS SMIL messages
       
  2734             if ( !( objects & EUniImageFlag &&
       
  2735                     Document()->DataModel()->SmilType() == EMmsSmil ) )
       
  2736                 {
       
  2737                 aMenuPane->SetItemDimmed( EUniCmdRemoveImage, ETrue );
       
  2738                 }
       
  2739             if ( !( objects & EUniAudioFlag ) ) 
       
  2740                 {
       
  2741                 aMenuPane->SetItemDimmed( EUniCmdRemoveAudio, ETrue );
       
  2742                 }
       
  2743             if ( !( objects & EUniVideoFlag ) ) 
       
  2744                 {
       
  2745                 aMenuPane->SetItemDimmed( EUniCmdRemoveVideo, ETrue );
       
  2746                 }
       
  2747             if ( !( objects & EUniTextFlag ) ) 
       
  2748                 {
       
  2749                 aMenuPane->SetItemDimmed( EUniCmdRemoveText, ETrue );
       
  2750                 }
       
  2751             if ( !( objects & EUniSvgFlag ) ) 
       
  2752                 {
       
  2753                 aMenuPane->SetItemDimmed( EUniCmdRemoveSvg, ETrue );
       
  2754                 }
       
  2755                 
       
  2756             if ( Document()->DataModel()->SmilType() != ETemplateSmil &&
       
  2757                  Document()->DataModel()->SmilType() != E3GPPSmil )
       
  2758                 {
       
  2759                 aMenuPane->SetItemDimmed( EUniCmdRemovePres, ETrue );
       
  2760                 }
       
  2761                 
       
  2762             if ( iSmilModel->SlideCount() <= 1 )
       
  2763                 {
       
  2764                 aMenuPane->SetItemDimmed( EUniCmdRemovePage, ETrue );
       
  2765                 }
       
  2766                 
       
  2767             break;
       
  2768             }
       
  2769         case R_UNIEDITOR_CONTEXT_MENU:
       
  2770             {
       
  2771             if ( Document()->UniState() == EUniSms )
       
  2772                 {
       
  2773                 aMenuPane->SetItemDimmed( EUniCmdSendMMS, ETrue );
       
  2774                 }
       
  2775             else
       
  2776                 {
       
  2777                 aMenuPane->SetItemDimmed( EUniCmdSendSMS, ETrue );
       
  2778                 }
       
  2779             
       
  2780             if ( IsHardcodedSms() )
       
  2781                 {
       
  2782                 aMenuPane->SetItemDimmed( EUniCmdInsertMedia, ETrue );
       
  2783                 }
       
  2784             
       
  2785             if ( !( iSupportedFeatures & EUniFeatureJapanese ) ||
       
  2786                  iSmilModel->SlideCount() <= 1 )
       
  2787                 {
       
  2788                 // Only shown on Japanese variant.
       
  2789                 aMenuPane->SetItemDimmed( EUniCmdSelectPage, ETrue );
       
  2790                 }
       
  2791             
       
  2792             break;
       
  2793             }
       
  2794         case R_UNIEDITOR_ZOOM_SUBMENU:
       
  2795             {
       
  2796             TInt zoomLevel = KErrGeneral;
       
  2797             iMsgEditorAppUiExtension->iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, 
       
  2798                                                                     zoomLevel );
       
  2799             switch ( zoomLevel )
       
  2800                 {
       
  2801                 case EAknUiZoomAutomatic:
       
  2802                     {
       
  2803                     aMenuPane->SetItemButtonState( EMsgDispSizeAutomatic,
       
  2804                                                    EEikMenuItemSymbolOn );
       
  2805                     break;
       
  2806                     }
       
  2807                 case EAknUiZoomNormal:
       
  2808                     {
       
  2809                     aMenuPane->SetItemButtonState( EMsgDispSizeNormal,
       
  2810                                                    EEikMenuItemSymbolOn );
       
  2811                     break;
       
  2812                     }
       
  2813                 case EAknUiZoomSmall:
       
  2814                     {
       
  2815                     aMenuPane->SetItemButtonState( EMsgDispSizeSmall,
       
  2816                                                    EEikMenuItemSymbolOn );
       
  2817                     break;
       
  2818                     }
       
  2819                 case EAknUiZoomLarge:
       
  2820                     {
       
  2821                     aMenuPane->SetItemButtonState( EMsgDispSizeLarge,
       
  2822                                                    EEikMenuItemSymbolOn );
       
  2823                     break;
       
  2824                     }
       
  2825                 default:
       
  2826                     {
       
  2827                     break;
       
  2828                     }
       
  2829                 }
       
  2830             break;
       
  2831             }
       
  2832         default:
       
  2833             {
       
  2834             break;
       
  2835             }
       
  2836         }
       
  2837     }
       
  2838 
       
  2839 // ---------------------------------------------------------
       
  2840 // CUniEditorAppUi::DynInitFocusedMediaBasedOptionsL
       
  2841 // ---------------------------------------------------------
       
  2842 //
       
  2843 void CUniEditorAppUi::DynInitFocusedMediaBasedOptionsL( CEikMenuPane* aMenuPane )
       
  2844     {
       
  2845     // Lets dim all the context sensitive options first
       
  2846 
       
  2847     aMenuPane->SetItemDimmed( EUniCmdPlayPreview, ETrue );                    
       
  2848     aMenuPane->SetItemDimmed( EUniCmdSendSMS, ETrue );
       
  2849     
       
  2850     // Completely dim PlaceTextFirst and PlaceTextSecond from options menu
       
  2851     aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2852     aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );
       
  2853 
       
  2854     if ( Document()->DataModel()->SmilType() != EMmsSmil ) 
       
  2855         { 
       
  2856         // It's 3GPP presentation
       
  2857         aMenuPane->SetItemDimmed( EUniCmdInsertMedia, ETrue );    
       
  2858         }
       
  2859     
       
  2860     
       
  2861     /* This code can be used if PlaceTextFirst and PlaceTextSecond 
       
  2862      * functionality is needed.
       
  2863      if ( Document()->DataModel()->SmilType() != EMmsSmil ) 
       
  2864         { 
       
  2865         // It's 3GPP presentation
       
  2866         aMenuPane->SetItemDimmed( EUniCmdInsertMedia, ETrue );
       
  2867         aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2868         aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );
       
  2869         }
       
  2870       
       
  2871      else if ( iSupportedFeatures & EUniFeatureJapanese )
       
  2872         {
       
  2873         // Not shown on japanese variant ever.
       
  2874         aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2875         aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );        
       
  2876         }
       
  2877      else
       
  2878         {
       
  2879         if ( iSmilModel->Layout() == EUniImageFirst )
       
  2880             {
       
  2881             aMenuPane->SetItemDimmed( EUniCmdPlaceTextSecond, ETrue );
       
  2882             }
       
  2883         else
       
  2884             {
       
  2885             aMenuPane->SetItemDimmed( EUniCmdPlaceTextFirst, ETrue );
       
  2886             }
       
  2887         } */
       
  2888 
       
  2889     if ( Document()->DataModel()->SmilType() != EMmsSmil || 
       
  2890          iSmilModel->SlideCount() <= 1 )
       
  2891         { 
       
  2892         // No move if not MmsSmil or only one page
       
  2893         aMenuPane->SetItemDimmed( EUniCmdMovePage, ETrue );
       
  2894         aMenuPane->SetItemDimmed( EUniCmdSelectPage, ETrue );
       
  2895         }
       
  2896     else if ( !( iSupportedFeatures & EUniFeatureJapanese ) )
       
  2897         {
       
  2898         // Only shown on Japanese variant.
       
  2899         aMenuPane->SetItemDimmed( EUniCmdSelectPage, ETrue );
       
  2900         }
       
  2901     
       
  2902     if( Document()->DataModel()->SmilType() == EMmsSmil &&
       
  2903         Document()->DataModel()->ObjectList().Count() == 0 && 
       
  2904         iSmilModel->SlideCount() == 1 )
       
  2905         {
       
  2906         aMenuPane->SetItemDimmed( EUniCmdRemoveSubmenu, ETrue );
       
  2907         }
       
  2908     }
       
  2909 
       
  2910 // ---------------------------------------------------------
       
  2911 // CUniEditorAppUi::IsMessageEmpty
       
  2912 // ---------------------------------------------------------
       
  2913 //
       
  2914 TBool CUniEditorAppUi::IsMessageEmpty() const 
       
  2915     {
       
  2916     TBool smil = EFalse;
       
  2917     if ( Document()->DataModel()->SmilType() != EMmsSmil &&
       
  2918          Document()->DataModel()->SmilList().Count() > 0 )
       
  2919         {
       
  2920         smil = ETrue;
       
  2921         }
       
  2922     return !smil &&
       
  2923            IsHeaderEmpty() &&
       
  2924            IsBodyEmpty() &&
       
  2925            Document()->DataModel()->AttachmentList().Count() == 0;
       
  2926     }
       
  2927 
       
  2928 
       
  2929 // ---------------------------------------------------------
       
  2930 // CUniEditorAppUi::DoUserSendL
       
  2931 //
       
  2932 // Message must be unlocked before coming here.
       
  2933 // ---------------------------------------------------------
       
  2934 //
       
  2935 void CUniEditorAppUi::DoUserSendL()
       
  2936     {
       
  2937     // Force FEP Update done only when SMIL is not 3GPP SMIL
       
  2938     if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
  2939         {
       
  2940         if ( BodyCtrl() )
       
  2941             {
       
  2942             BodyCtrl()->SetFocus( EFalse );
       
  2943             }
       
  2944             
       
  2945         iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
  2946         }
       
  2947     
       
  2948     TUniState currentState = Document()->UniState();
       
  2949     if(currentState == EUniMms)
       
  2950         {
       
  2951         TInt PrevSlidecount = iSmilModel->SlideCount();
       
  2952         iSmilModel->RemoveEmptySlides();
       
  2953         if( PrevSlidecount != iSmilModel->SlideCount() )
       
  2954             {
       
  2955             Document()->SetBodyModified( ETrue );
       
  2956             CheckBodyForMessageTypeL();  
       
  2957             }
       
  2958         }
       
  2959     
       
  2960     TBool modified( EFalse );
       
  2961     if ( !VerifyAddressesL( modified ) )
       
  2962         {
       
  2963         // Invalid recipient found  -> abort sending.
       
  2964         return;
       
  2965         }
       
  2966     
       
  2967     if ( modified &&
       
  2968          currentState != Document()->UniState() )
       
  2969         {
       
  2970         if ( !ShowConfirmationQueryL( R_UNIEDITOR_MSG_TYPE_CHANGED_WHILE_SENDING ) )
       
  2971             {
       
  2972             return;
       
  2973             }
       
  2974         }
       
  2975     
       
  2976     // Check MMS message size
       
  2977     if ( TUint( MessageSizeInBytes() ) > Document()->MaxMessageSize() )
       
  2978         {
       
  2979         TInt maxInKilos = ( Document()->MaxMessageSize() + KBytesInKilo - 1 ) / KBytesInKilo;
       
  2980         HBufC* string = StringLoader::LoadLC( R_UNIEDITOR_SEND_BIG_TEXT, 
       
  2981                                               maxInKilos, 
       
  2982                                               iCoeEnv );
       
  2983                                               
       
  2984         CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
       
  2985         note->ExecuteLD( *string );
       
  2986         CleanupStack::PopAndDestroy( string );
       
  2987         return;
       
  2988         }
       
  2989 
       
  2990     // Check the max sms size
       
  2991     CheckMaxSmsSizeAndShowNoteL( ETrue );
       
  2992 
       
  2993     if( iEditorFlags & EMaxSmsSizeNoteShown )
       
  2994         { 
       
  2995         // This flag was set by the funtion call above and it means an error note was shown to user
       
  2996         return;
       
  2997         }
       
  2998 
       
  2999     if( !CheckMaxRecipientsAndShowNoteL( ETrue ) )
       
  3000         { 
       
  3001         // Too many recipients. Info was shown so just return
       
  3002         return;
       
  3003         }
       
  3004     
       
  3005     CUniEditorPlugin* plugin = NULL;
       
  3006     TInt resourceId = NULL;
       
  3007     
       
  3008     // Get the plugin
       
  3009     if( Document()->UniState() == EUniSms )
       
  3010         {
       
  3011         plugin = SmsPlugin();
       
  3012         resourceId = R_QTN_MSG_WAIT_SENDING_SMS;
       
  3013         
       
  3014         // Ask if it's ok to send the message in N parts
       
  3015         if( !ConfirmSmsSendInMultiplePartsL() )
       
  3016             {
       
  3017             return;
       
  3018             }
       
  3019         }
       
  3020     else
       
  3021         {
       
  3022         plugin = MmsPlugin();
       
  3023         resourceId = R_QTN_MSG_WAIT_SENDING_MMS;
       
  3024         }
       
  3025 
       
  3026     if( plugin )
       
  3027         {
       
  3028         TBool checkEmailSettings = EFalse;
       
  3029         if( Document()->EmailOverSmsSupported() && iHeader->LongestEmailAddress() )
       
  3030             {
       
  3031             checkEmailSettings = ETrue;
       
  3032             }
       
  3033         
       
  3034         if ( iFixedToolbar && !plugin->IsServiceValidL() )
       
  3035             {
       
  3036             iFixedToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  3037             }
       
  3038         
       
  3039         iEditorFlags |= EToolbarHidden;
       
  3040         CleanupStack::PushL( TCleanupItem( EnableFixedToolbar, this ) );
       
  3041         if (!plugin->IsServiceValidL())
       
  3042         	{
       
  3043         		SetKeyEventFlags(0);
       
  3044         	}
       
  3045             
       
  3046         CleanupStack::PushL( TCleanupItem( DisableSendKey, this ) );
       
  3047         
       
  3048         iMsgLenToVKB = EFalse;
       
  3049         TBool serviceValid( plugin->ValidateServiceL( checkEmailSettings ) );
       
  3050         
       
  3051         CleanupStack::PopAndDestroy(2); //DisableSendKey,EnableFixedToolbar
       
  3052         
       
  3053         if( !serviceValid )
       
  3054             { 
       
  3055             // Settings are not valid (AP/SC missing)
       
  3056             iMsgLenToVKB = ETrue;
       
  3057             return;
       
  3058             }
       
  3059         }
       
  3060     else
       
  3061         {
       
  3062         // The plugin is not ok -> cannot send the message
       
  3063         return;
       
  3064         }
       
  3065 
       
  3066     if( IsPhoneOfflineL() )
       
  3067         {
       
  3068         resourceId = R_QTN_WAIT_MSG_SAVED_OUTBOX;
       
  3069         }
       
  3070 
       
  3071     if (IsObjectsPathValidL())
       
  3072         {
       
  3073     	iSendOperation = CUniEditorSendOperation::NewL( *this,
       
  3074                                                     	*Document(),
       
  3075                                                     	*iHeader,
       
  3076                                                     	*plugin,
       
  3077                                                     	*iView,
       
  3078                                                     	FsSession() );
       
  3079         ActivateInputBlockerL(iSendOperation);
       
  3080 
       
  3081         ShowWaitNoteL(resourceId);
       
  3082 
       
  3083         iEditorFlags |= EEditorClosing;
       
  3084 
       
  3085         iSendOperation->Send();
       
  3086         }
       
  3087     else
       
  3088         {
       
  3089         if (ShowConfirmationQueryL(R_UNIEDITOR_QUEST_CLOSE_OOD))
       
  3090             {
       
  3091             // Exit without saving.
       
  3092             Exit(EAknSoftkeyClose);
       
  3093             }
       
  3094         //else nothing.
       
  3095         }
       
  3096     }
       
  3097 
       
  3098 
       
  3099 // ---------------------------------------------------------
       
  3100 // CUniEditorAppUi::DoMsgSaveExitL
       
  3101 // Exit from option menu 
       
  3102 // ---------------------------------------------------------
       
  3103 //
       
  3104 void CUniEditorAppUi::DoMsgSaveExitL() 
       
  3105     {
       
  3106     if ( CAknEnv::AppWithShutterRunning() )
       
  3107         {
       
  3108         iEditorFlags |= ERunAppShutterAtExit;
       
  3109         }
       
  3110     
       
  3111     delete iLaunchOperation;
       
  3112     iLaunchOperation = NULL;
       
  3113     
       
  3114     delete iSendOperation;
       
  3115     iSendOperation = NULL;
       
  3116     
       
  3117     delete iInsertOperation;
       
  3118     iInsertOperation = NULL;        
       
  3119     
       
  3120     delete iChangeSlideOperation;
       
  3121     iChangeSlideOperation = NULL;
       
  3122     
       
  3123     delete iVCardOperation;
       
  3124     iVCardOperation = NULL;
       
  3125     
       
  3126     if ( IsMessageEmpty() )
       
  3127         {
       
  3128         DeleteCurrentEntryL();
       
  3129         }
       
  3130     else if ( ( Document()->Modified() || 
       
  3131                 Document()->PrevSaveType() < EClosingSave ) && 
       
  3132               CanSaveMessageL())
       
  3133         {
       
  3134         // Needs saving
       
  3135         if ( IsForeground() )
       
  3136             {
       
  3137             TInt resId = Document()->Saved() ? R_QTN_UNI_WAIT_SAVING_MESSAGE : 
       
  3138                                                R_QTN_UNI_WAIT_SAVING_MESSAGE_NEW;
       
  3139             // Cannot trap call below.
       
  3140             DoSaveL( EClosingSave );
       
  3141             iEditorFlags |= EEditorClosing;
       
  3142             
       
  3143             ShowWaitNoteL( resId );
       
  3144             }
       
  3145         else
       
  3146             {
       
  3147             TInt err(KErrNone);
       
  3148             TRAP( err, DoSaveL( EClosingSave ) );
       
  3149             }
       
  3150             
       
  3151         BeginActiveWait( iSaveOperation );
       
  3152         if ( iEditorFlags & ERunAppShutterAtExit )
       
  3153             {
       
  3154             RunAppShutter();
       
  3155             }
       
  3156         }
       
  3157     }
       
  3158 
       
  3159 // ---------------------------------------------------------
       
  3160 // CUniEditorAppUi::ExitAndSaveL
       
  3161 // ---------------------------------------------------------
       
  3162 //
       
  3163 void CUniEditorAppUi::ExitAndSaveL()
       
  3164     {
       
  3165     if ( iEditorFlags & EEditorClosing )
       
  3166         {
       
  3167         Exit( EAknSoftkeyClose );
       
  3168         return;
       
  3169         }
       
  3170         
       
  3171     if ( CAknEnv::AppWithShutterRunning() )
       
  3172         {
       
  3173         iEditorFlags |= ERunAppShutterAtExit;
       
  3174         }
       
  3175     if (IsObjectsPathValidL())
       
  3176         {
       
  3177         if (iEditorFlags & ELaunchSuccessful && Document()->MediaAvailable())
       
  3178             {
       
  3179             DoMsgSaveExitL();
       
  3180             }
       
  3181 
       
  3182         Exit();
       
  3183         }
       
  3184     else
       
  3185         {
       
  3186         if (ShowConfirmationQueryL(R_UNIEDITOR_QUEST_CLOSE_OOD))
       
  3187             {
       
  3188             // Exit without saving.
       
  3189             Exit(EAknSoftkeyClose);
       
  3190             }
       
  3191         }
       
  3192     
       
  3193     }
       
  3194 
       
  3195 // ---------------------------------------------------------
       
  3196 // CUniEditorAppUi::DoBackSaveL
       
  3197 // Back button implementation
       
  3198 // ---------------------------------------------------------
       
  3199 //
       
  3200 void CUniEditorAppUi::DoBackSaveL()
       
  3201     {
       
  3202     if ( IsMessageEmpty() ) 
       
  3203         {
       
  3204         if ( iMtm->Entry().Entry().Visible() )
       
  3205             {
       
  3206             ShowInformationNoteL( R_UNIEDITOR_INFO_DELETED, ETrue );
       
  3207             }
       
  3208         DeleteAndExitL();
       
  3209         }
       
  3210     else
       
  3211         {
       
  3212         TInt closeVal = ShowCloseQueryL();
       
  3213         if ( closeVal == EMsgCloseCancel )
       
  3214             {
       
  3215             return;
       
  3216             }
       
  3217         else if ( closeVal == EMsgCloseDelete )
       
  3218             {
       
  3219             ReleaseImage( ETrue );
       
  3220             DeleteAndExitL();
       
  3221             }
       
  3222         else // closeVal == EMsgCloseSave
       
  3223             {
       
  3224             // Message has data
       
  3225             if ( Document()->Modified() || Document()->PrevSaveType() < EClosingSave )
       
  3226                 {
       
  3227                 if ( CanSaveMessageL() && IsObjectsPathValidL())                    
       
  3228                     {
       
  3229                     TInt resId = Document()->Saved() ? R_QTN_UNI_WAIT_SAVING_MESSAGE : 
       
  3230                                                        R_QTN_UNI_WAIT_SAVING_MESSAGE_NEW;
       
  3231                     DoSaveL( EClosingSave );
       
  3232                     iEditorFlags |= EEditorClosing;
       
  3233                     
       
  3234                     ShowWaitNoteL( resId );
       
  3235                     }
       
  3236                 else
       
  3237                     {
       
  3238                     if ( ShowConfirmationQueryL( R_UNIEDITOR_QUEST_CLOSE_OOD ) )
       
  3239                         {
       
  3240                         // Exit without saving.
       
  3241                         Exit( EAknSoftkeyClose );
       
  3242                         }
       
  3243                     //else nothing.
       
  3244                     }
       
  3245                 }
       
  3246             else
       
  3247                 {
       
  3248                 // No changes -> just go away.
       
  3249                 Exit( EAknSoftkeyClose );
       
  3250                 }
       
  3251             }
       
  3252         }
       
  3253     }   
       
  3254 
       
  3255 // ---------------------------------------------------------
       
  3256 // CUniEditorAppUi::CanSaveMessageL
       
  3257 // Checks whether there's enough diskspace to save the
       
  3258 // message.
       
  3259 // ---------------------------------------------------------
       
  3260 //
       
  3261 TBool CUniEditorAppUi::CanSaveMessageL() const
       
  3262     {
       
  3263     TInt bytes = Document()->AddressSize() + Document()->SubjectSize();
       
  3264     
       
  3265     if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
  3266         {
       
  3267         bytes += Document()->DataModel()->ObjectList().SpaceNeededForSaveAll();
       
  3268         bytes += Document()->DataModel()->AttachmentList().SpaceNeededForSaveAll();
       
  3269         bytes += iSmilModel->SmilComposeSize();
       
  3270         }
       
  3271         
       
  3272     return !( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( Document()->Session(),
       
  3273                                                                    bytes ) );
       
  3274     }
       
  3275 
       
  3276 // ---------------------------------------------------------
       
  3277 // CUniEditorAppUi::DoSaveL
       
  3278 // Saves message to OUTBOX.
       
  3279 // Message should be unlocked before coming here.
       
  3280 // ---------------------------------------------------------
       
  3281 //
       
  3282 void CUniEditorAppUi::DoSaveL( TUniSaveType aSaveType ) 
       
  3283     {
       
  3284     if ( iSaveOperation && 
       
  3285          iSaveOperation->IsActive() )
       
  3286         {
       
  3287         // To avoid starting save operation when there is already one running.
       
  3288         return;
       
  3289         }
       
  3290         
       
  3291     if ( !CanSaveMessageL() )
       
  3292         {
       
  3293         User::Leave( KErrDiskFull );
       
  3294         }
       
  3295 
       
  3296     delete iSaveOperation;
       
  3297     iSaveOperation = NULL;
       
  3298     iSaveOperation = CUniEditorSaveOperation::NewL(
       
  3299         *this,
       
  3300         *Document(),
       
  3301         *iHeader,
       
  3302         *iView,
       
  3303         FsSession() );
       
  3304     
       
  3305     iSaveOperation->Save( aSaveType );
       
  3306     
       
  3307     ActivateInputBlockerL( iSaveOperation );
       
  3308     }
       
  3309 
       
  3310 // ---------------------------------------------------------
       
  3311 // CUniEditorAppUi::VerifyAddressesL
       
  3312 //
       
  3313 // Walks thru addresses in addresscontrol and counts errors. 
       
  3314 // If unverified address is valid, marks it validated (verified now). 
       
  3315 // Stops to first error.
       
  3316 // ---------------------------------------------------------
       
  3317 //
       
  3318 TBool CUniEditorAppUi::VerifyAddressesL( TBool& aModified )
       
  3319     {
       
  3320     if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  3321         {
       
  3322         // Don't check the recipient in "Upload" case.
       
  3323         return ETrue;
       
  3324         }
       
  3325         
       
  3326     iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
  3327     
       
  3328     aModified = EFalse;
       
  3329 
       
  3330     TBool retVal = iHeader->VerifyAddressesL( aModified, AcceptEmailAddresses() );
       
  3331 
       
  3332     if ( aModified )
       
  3333         {
       
  3334         Document()->SetHeaderModified( ETrue );
       
  3335         CheckHeaderForMessageTypeL();
       
  3336         
       
  3337         SetAddressSize();
       
  3338         MsgLengthToNavipaneL();
       
  3339         }
       
  3340 
       
  3341     if ( !retVal )
       
  3342         {        
       
  3343         //We'll get here if there's illegal addresses
       
  3344         //when selecting send from not-first slide 
       
  3345         for (TInt i = CUniEditorHeader::EHeaderAddressTo; 
       
  3346             i <= CUniEditorHeader::EHeaderAddressBcc; i++ )
       
  3347             { 
       
  3348             TBool jumpOut( EFalse );
       
  3349             if ( iHeader->AddressControl( static_cast<CUniEditorHeader::THeaderFields>( i ) ) )               
       
  3350                 {
       
  3351                 // Search first invalid address
       
  3352                 CMsgRecipientArray* recipients = iHeader->AddressControl( static_cast<CUniEditorHeader::THeaderFields>( i ) )->GetRecipientsL();
       
  3353                 TInt addrCnt = recipients->Count();
       
  3354 
       
  3355                 for ( TInt k = 0; k < addrCnt ; k++ )
       
  3356                     {
       
  3357                     CMsgRecipientItem* addrItem = recipients->At(k);
       
  3358                     
       
  3359                     if (    addrItem 
       
  3360                         &&  !addrItem->IsValidated() )
       
  3361                         {     
       
  3362                         iNextFocus =  iHeader->AddressControlId( 
       
  3363                                         static_cast<CUniEditorHeader::THeaderFields>( i ) );
       
  3364                         if ( Document()->CurrentSlide() )
       
  3365                             {
       
  3366                             DoUserChangeSlideL( 0 );
       
  3367                             }
       
  3368                         else
       
  3369                             {
       
  3370                             DoSetFocusL();
       
  3371                             }
       
  3372                             
       
  3373                         TInt ret = iHeader->AddressControl( static_cast<CUniEditorHeader::THeaderFields> (i ) )
       
  3374                                         ->HighlightUnvalidatedStringL();
       
  3375                         if ( !ret )
       
  3376                             {
       
  3377                             // highlight succeeded
       
  3378                             jumpOut = ETrue;
       
  3379                             break;
       
  3380                             }
       
  3381                         // else - highlight failed. Should not occur...
       
  3382                         }
       
  3383                     }
       
  3384                     // else - recipient OK. Continue searching
       
  3385                 if ( jumpOut )
       
  3386                     {
       
  3387                     break;
       
  3388                     }
       
  3389                 }
       
  3390             // else - address control does not exist
       
  3391             }
       
  3392         }
       
  3393     // else - addresses OK
       
  3394 
       
  3395     return retVal;
       
  3396     }
       
  3397 
       
  3398 // ---------------------------------------------------------
       
  3399 // CUniEditorAppUi::DoUserMoveOrSelectPageL
       
  3400 // ---------------------------------------------------------
       
  3401 //
       
  3402 void CUniEditorAppUi::DoUserMoveOrSelectPageL( TBool aMovePage )
       
  3403     {
       
  3404     // Create listbox    
       
  3405     CAknSingleGraphicPopupMenuStyleListBox* listBox = new (ELeave) CAknSingleGraphicPopupMenuStyleListBox;
       
  3406     CleanupStack::PushL( listBox );
       
  3407     
       
  3408     // Create popup
       
  3409     CAknPopupList* popup = CAknPopupList::NewL(  listBox, 
       
  3410                                                  R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, 
       
  3411                                                  AknPopupLayouts::EMenuGraphicWindow );
       
  3412     CleanupStack::PushL( popup );
       
  3413 
       
  3414     // Construct listbox
       
  3415     listBox->ConstructL( popup, CEikListBox::ELeftDownInViewRect );
       
  3416     listBox->CreateScrollBarFrameL( ETrue );
       
  3417     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
  3418                                                         CEikScrollBarFrame::EAuto );
       
  3419     
       
  3420     if( iSmilModel->SlideCount() > 6 )
       
  3421         {
       
  3422         listBox->CreateScrollBarFrameL( ETrue );
       
  3423         listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
  3424                                                             CEikScrollBarFrame::EAuto );
       
  3425         }
       
  3426   
       
  3427     TInt oldSlide = Document()->CurrentSlide();
       
  3428 
       
  3429     // Set title    
       
  3430     HBufC* title = NULL;
       
  3431     if ( aMovePage )
       
  3432         {
       
  3433         title = StringLoader::LoadLC( R_UNI_MOVE_PAGE_TITLE, oldSlide+1, iCoeEnv );
       
  3434         }
       
  3435     else
       
  3436         {
       
  3437         title = StringLoader::LoadLC( R_UNI_SELECT_PAGE_TITLE, iCoeEnv );
       
  3438         }
       
  3439     popup->SetTitleL( title->Des() );
       
  3440     CleanupStack::PopAndDestroy( title );
       
  3441 
       
  3442     CAknIconArray* iconArray = RadioButtonArrayL();
       
  3443     listBox->ItemDrawer()->FormattedCellData()->SetIconArray( iconArray ); // FormattedCellData owns
       
  3444 
       
  3445     listBox->HandleItemAdditionL();
       
  3446 
       
  3447     CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( 5 );
       
  3448     CleanupStack::PushL( array );
       
  3449     
       
  3450     for ( TInt i = 0; i < iSmilModel->SlideCount(); i++ )
       
  3451         {
       
  3452         HBufC* buf = StringLoader::LoadLC( R_UNIEDITOR_MOVE_PAGE, i + 1, iCoeEnv );
       
  3453 
       
  3454         TBuf<20> itemString;
       
  3455         if( oldSlide == i )
       
  3456             { // This one is selected
       
  3457             itemString.AppendNum( 1 );
       
  3458             }
       
  3459         else
       
  3460             {
       
  3461             itemString.AppendNum( 0 );
       
  3462             }
       
  3463         itemString.Append( _L("\t") );
       
  3464         itemString.Append( buf->Des() );
       
  3465         array->AppendL( itemString );
       
  3466         
       
  3467         CleanupStack::PopAndDestroy( buf );
       
  3468         buf = NULL;
       
  3469         }
       
  3470 
       
  3471     CTextListBoxModel* model = listBox->Model();
       
  3472     model->SetItemTextArray( array );
       
  3473     model->SetOwnershipType( ELbmOwnsItemArray );
       
  3474     CleanupStack::Pop( array ); // model owns it now
       
  3475 
       
  3476     listBox->SetCurrentItemIndexAndDraw( oldSlide );
       
  3477 
       
  3478     TInt result = popup->ExecuteLD();
       
  3479 
       
  3480     if ( result )
       
  3481         {
       
  3482         // OK, user chose a new page
       
  3483         TInt newSlide = listBox->CurrentItemIndex();
       
  3484          
       
  3485         if( oldSlide != newSlide )
       
  3486             {
       
  3487             if ( aMovePage )
       
  3488                 {
       
  3489                 iSmilModel->MoveSlideL( Document()->CurrentSlide(), newSlide );
       
  3490                 }
       
  3491 
       
  3492             //Set current slide to invalid in order
       
  3493             //to prevent false events coming to wrong slides
       
  3494             Document()->SetCurrentSlide( -1 );
       
  3495             iView->SetScrollParts( iSmilModel->SlideCount() );
       
  3496             iView->SetCurrentPart( newSlide );
       
  3497 
       
  3498             DoUserChangeSlideL( newSlide );
       
  3499             
       
  3500             if ( aMovePage )
       
  3501                 {
       
  3502                 Document()->SetBodyModified( ETrue );
       
  3503                 }
       
  3504             }
       
  3505         }
       
  3506 
       
  3507     CleanupStack::Pop(); // for popup
       
  3508     CleanupStack::PopAndDestroy( listBox );
       
  3509     }
       
  3510 
       
  3511 // ---------------------------------------------------------
       
  3512 // CUniEditorAppUi::DoUserObjectsViewL
       
  3513 // ---------------------------------------------------------
       
  3514 //
       
  3515 void CUniEditorAppUi::DoUserObjectsViewL( TBool aFocusAttachments )
       
  3516     {
       
  3517     CUniObjectsModel& objectsViewModel =
       
  3518         static_cast<CUniObjectsModel&>( Document()->AttachmentModel() );
       
  3519 
       
  3520     CAknInputBlock::NewLC();
       
  3521 
       
  3522     if ( Document()->DataModel()->SmilType() == EMmsSmil && 
       
  3523          Document()->BodyModified() )
       
  3524         {
       
  3525         delete iSaveOperation;
       
  3526         iSaveOperation = NULL;
       
  3527         
       
  3528         iSaveOperation = CUniEditorSaveOperation::NewL(
       
  3529             *this,
       
  3530             *Document(),
       
  3531             *iHeader,
       
  3532             *iView,
       
  3533             FsSession() );
       
  3534         
       
  3535         
       
  3536         // Save current slide text object as content needs to be up-to-date when
       
  3537         // it is opened from object's view.
       
  3538         CUniObject* textObject = iSmilModel->GetObject( Document()->CurrentSlide(), EUniRegionText );
       
  3539         if ( textObject )
       
  3540             {
       
  3541             iSaveOperation->SaveL( *textObject );
       
  3542             BeginActiveWait( iSaveOperation );
       
  3543             }
       
  3544         }
       
  3545 
       
  3546     CMsgBaseControl* imageBase = iView->ControlById( EMsgComponentIdImage );
       
  3547     if ( imageBase )
       
  3548         {
       
  3549         //Close image file (share flag conflict)
       
  3550         CMsgImageControl* imageControl =
       
  3551             static_cast<CMsgImageControl*>( imageBase );
       
  3552         //Closes image, no matter if animation or not
       
  3553         imageControl->Stop();
       
  3554         //No need to reopen image file
       
  3555         }
       
  3556 
       
  3557     iOriginalSlide = Document()->CurrentSlide();
       
  3558   
       
  3559     TUniObjectsDialogExitCmd dlgRet = EUniObjectsViewBack;
       
  3560     // Flag is also used to judge whether toolbar update is done 
       
  3561     iEditorFlags |= EDoNotUpdateTitlePane;
       
  3562     
       
  3563     CUniObjectsViewDialog::TUniObjectsDialogType dialogType;
       
  3564     if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
  3565         {
       
  3566         dialogType = CUniObjectsViewDialog::EEditor;
       
  3567         }
       
  3568     else
       
  3569         {
       
  3570         dialogType = CUniObjectsViewDialog::EForward;
       
  3571         }
       
  3572     
       
  3573     TInt focusedItemIndex = -1;
       
  3574     if ( aFocusAttachments )
       
  3575         {
       
  3576         TInt objectCount = Document()->DataModel()->ObjectList().Count();
       
  3577         if ( objectCount == 0 )
       
  3578             {
       
  3579             focusedItemIndex = 1;
       
  3580             }
       
  3581         else
       
  3582             {
       
  3583             focusedItemIndex = objectCount;
       
  3584             }
       
  3585         }
       
  3586     
       
  3587     if ( iFixedToolbar )
       
  3588         {
       
  3589         SetFixedToolbarDimmed();
       
  3590         }
       
  3591     
       
  3592     CleanupStack::PushL( TCleanupItem( UpdateFixedToolbar, this ) );
       
  3593    	SetKeyEventFlags(0);
       
  3594     
       
  3595     CleanupStack::PushL( TCleanupItem( DisableSendKey, this ) );
       
  3596     
       
  3597     CUniObjectsViewDialog::ObjectsViewL(
       
  3598             dialogType, 
       
  3599             objectsViewModel,
       
  3600             iEikonEnv,
       
  3601             dlgRet,
       
  3602             *Document()->DataModel(),
       
  3603             focusedItemIndex );
       
  3604     
       
  3605     CleanupStack::PopAndDestroy(2); //DisableSendKey,EnableFixedToolbar
       
  3606     
       
  3607     iEditorFlags &= ~EDoNotUpdateTitlePane;
       
  3608 
       
  3609     Document()->SetCurrentSlide( iOriginalSlide );
       
  3610     iOriginalSlide = -1;
       
  3611 
       
  3612     // Check if msg type was changed
       
  3613     CheckBodyForMessageTypeL(); 
       
  3614     
       
  3615     // Update navipane here instead of AddObjectL callback otherwise it 
       
  3616     // gets drawn while in objectsview
       
  3617     UpdateIndicatorIconsL();
       
  3618     
       
  3619     CheckLockedSmsWithAttaL();
       
  3620     
       
  3621     CleanupStack::PopAndDestroy(); // CAknInputBlock
       
  3622     
       
  3623     objectsViewModel.Reset();
       
  3624     MsgLengthToNavipaneL( ETrue );
       
  3625     }
       
  3626 
       
  3627 // ---------------------------------------------------------
       
  3628 // CUniEditorAppUi::DoUserAddRecipientL
       
  3629 // Fetch an address from phonebook
       
  3630 // ---------------------------------------------------------
       
  3631 //
       
  3632 void CUniEditorAppUi::DoUserAddRecipientL()
       
  3633     {
       
  3634     TBool invalid = EFalse;
       
  3635     // We remove this flag so that it can be shown after the adding operation
       
  3636     iEditorFlags &= ~EMaxRecipientShown;
       
  3637 
       
  3638 	if(iEditorFlags & EMsgEditInProgress)
       
  3639         {
       
  3640         return;
       
  3641         }
       
  3642     if ( iFixedToolbar )
       
  3643         {
       
  3644         SetFixedToolbarDimmed();    
       
  3645         }
       
  3646 
       
  3647     iEditorFlags |= (EMsgEditInProgress);
       
  3648     CleanupStack::PushL( TCleanupItem( UpdateFixedToolbar, this ) );
       
  3649     
       
  3650     SetKeyEventFlags(0);    
       
  3651     CleanupStack::PushL( TCleanupItem( DisableSendKey, this ) );
       
  3652     // add to current control or To control
       
  3653     TBool addressesAdded(EFalse);
       
  3654     TRAPD( err, addressesAdded = iHeader->AddRecipientL(  iView->FocusedControl(), 
       
  3655                                                     iView, 
       
  3656                                                     AcceptEmailAddresses(),
       
  3657                                                     invalid ) );
       
  3658     if( err == KLeaveExit )
       
  3659         {
       
  3660         CAknEnv::RunAppShutter();
       
  3661         }
       
  3662 
       
  3663     CleanupStack::PopAndDestroy(2);//DisableSendKey,UpdateFixedToolbar
       
  3664     iEditorFlags &= ~EMsgEditInProgress;
       
  3665 
       
  3666     TInt focused = iHeader->FocusedAddressField( iView->FocusedControl() );
       
  3667 
       
  3668     if ( addressesAdded )
       
  3669         {
       
  3670         Document()->SetHeaderModified( ETrue );
       
  3671 
       
  3672         if ( Document()->CurrentSlide() )
       
  3673             {
       
  3674             // Addresses were (tried to be) added
       
  3675             // -> Change to first slide
       
  3676             iNextFocus = EMsgComponentIdTo;
       
  3677             DoUserChangeSlideL( 0 );
       
  3678             }
       
  3679 
       
  3680         SetAddressSize(); 
       
  3681         MsgLengthToNavipaneL();
       
  3682         
       
  3683         if ( focused == KErrNotFound ||
       
  3684              iEditorFlags & ELockedSmsWithAtta )
       
  3685             {
       
  3686             if ( focused != CUniBaseHeader::EHeaderAddressTo )
       
  3687                 {
       
  3688                 // Focus was not in address control -> Move it
       
  3689                 iView->SetFocus( EMsgComponentIdTo );
       
  3690                 }
       
  3691                 
       
  3692             // Set bodytext cursor location to start of the text
       
  3693             CMsgBodyControl* bodyCtrl = BodyCtrl();
       
  3694             if ( bodyCtrl )
       
  3695                 {
       
  3696                 bodyCtrl->SetCursorPosL( 0 );
       
  3697                 }
       
  3698             focused = CUniBaseHeader::EHeaderAddressTo;
       
  3699             }
       
  3700         else 
       
  3701             {
       
  3702         // Increase by one so it will be in the next field
       
  3703             switch( focused+1 )
       
  3704                 {
       
  3705                 case CUniBaseHeader::EHeaderAddressCc:
       
  3706                     {
       
  3707                     if( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressCc ) )
       
  3708                         {
       
  3709                         iView->SetFocus( EMsgComponentIdCc );
       
  3710                         break;
       
  3711                         }
       
  3712                     } // otherwise fall through
       
  3713                 case CUniBaseHeader::EHeaderAddressBcc:
       
  3714                     {
       
  3715                     if( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressBcc ) )
       
  3716                         {
       
  3717                         iView->SetFocus( EMsgComponentIdBcc );
       
  3718                         break;
       
  3719                         }
       
  3720                     } // otherwise fall through
       
  3721                 case CUniBaseHeader::EHeaderSubject:
       
  3722                     {
       
  3723                     if( iHeader->SubjectControl() )
       
  3724                         {
       
  3725                         iView->SetFocus( EMsgComponentIdSubject );
       
  3726                         break;
       
  3727                         }
       
  3728                     } // otherwise fall through
       
  3729                 default:
       
  3730                     {
       
  3731                     if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
  3732                         {
       
  3733                         iView->SetFocus( EMsgComponentIdBody );                    
       
  3734                         
       
  3735                         // Set bodytext cursor location to end of the text
       
  3736                         CMsgBodyControl* bodyCtrl = BodyCtrl();
       
  3737                         if ( bodyCtrl )
       
  3738                             {
       
  3739                             bodyCtrl->SetCursorPosL( bodyCtrl->Editor().TextLength() );
       
  3740                             }
       
  3741                         }
       
  3742                     else
       
  3743                         {
       
  3744                         iView->SetFocus( EMsgComponentIdImage );
       
  3745                         }
       
  3746                     }
       
  3747                 }
       
  3748             }
       
  3749         }
       
  3750     // Check max recipients anyway
       
  3751     CheckHeaderForMessageTypeL();
       
  3752     MsgLengthToNavipaneL();
       
  3753 
       
  3754     CheckMaxRecipientsAndShowNoteL();
       
  3755 
       
  3756     if( iEditorFlags & EMaxRecipientShown && addressesAdded )
       
  3757         { // A note was shown so return the focus back to the original location
       
  3758         TInt returnFocusTo = EMsgComponentIdTo;
       
  3759         if( focused == CUniBaseHeader::EHeaderAddressCc )
       
  3760             {
       
  3761             returnFocusTo = EMsgComponentIdCc;
       
  3762             }
       
  3763         else if( focused == CUniBaseHeader::EHeaderAddressBcc )
       
  3764             {
       
  3765             returnFocusTo = EMsgComponentIdBcc;
       
  3766             }
       
  3767         iView->SetFocus( returnFocusTo );
       
  3768         }
       
  3769     }
       
  3770 
       
  3771 // ---------------------------------------------------------
       
  3772 // CUniEditorAppUi::DoUserMessageInfoL
       
  3773 // 
       
  3774 // Invokes message info from UI MTM.
       
  3775 // Message must be unlocked before coming here.
       
  3776 // ---------------------------------------------------------
       
  3777 //
       
  3778 void CUniEditorAppUi::DoUserMessageInfoL()
       
  3779     {
       
  3780     CUniEditorDocument* doc = Document();
       
  3781     
       
  3782     CUniMtmUi& uiMtm = doc->MtmUiL();
       
  3783 
       
  3784     CAknInputBlock::NewLC();
       
  3785 
       
  3786     iHeader->CopyHeadersToMtmL( doc->HeaderModified(),
       
  3787                                 ETrue );
       
  3788 
       
  3789     // Lets put the current message type into TMsvEntry
       
  3790     TMsvEntry tEntry = doc->Entry();
       
  3791 
       
  3792     TUniMessageCurrentType curType = EUniMessageCurrentTypeSms;
       
  3793     if( doc->UniState() == EUniMms )
       
  3794         {
       
  3795         curType = EUniMessageCurrentTypeMms;
       
  3796         
       
  3797         CUniEditorPlugin* mmsPlugin = doc->MmsPlugin();
       
  3798             
       
  3799         if ( mmsPlugin )
       
  3800             {
       
  3801             TUniSendingSettings settings;
       
  3802             mmsPlugin->GetSendingSettingsL( settings );
       
  3803             switch ( settings.iPriority )
       
  3804                 {
       
  3805                 case TUniSendingSettings::EUniPriorityHigh:
       
  3806                     {
       
  3807                     tEntry.SetPriority( EMsvHighPriority );
       
  3808                     break;
       
  3809                     }
       
  3810                 case TUniSendingSettings::EUniPriorityLow:
       
  3811                     {
       
  3812                     tEntry.SetPriority( EMsvLowPriority );
       
  3813                     break;
       
  3814                     }
       
  3815                 default:
       
  3816                     {
       
  3817                     tEntry.SetPriority( EMsvMediumPriority );
       
  3818                     break;
       
  3819                     }
       
  3820                 }
       
  3821             }
       
  3822         }
       
  3823 
       
  3824     TUniMsvEntry::SetCurrentMessageType( tEntry, curType );
       
  3825     
       
  3826     doc->CurrentEntry().ChangeL( tEntry );
       
  3827     
       
  3828     if ( !iMtm->Entry().HasStoreL() )
       
  3829         {
       
  3830         iMtm->SaveMessageL();
       
  3831         }
       
  3832     
       
  3833     // Pack message size
       
  3834     TInt sizeInKilos = ( MessageSizeInBytes() + KBytesInKilo - 1 ) / KBytesInKilo;
       
  3835     TPckgBuf<TInt> param( sizeInKilos );
       
  3836 
       
  3837     //These are not used! They just have to be there
       
  3838     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  3839     CleanupStack::PushL( selection );
       
  3840 
       
  3841     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document() );
       
  3842     CMsvOperation* op = uiMtm.InvokeAsyncFunctionL(
       
  3843         KMtmUiFunctionMessageInfo,
       
  3844         *selection,
       
  3845         watch->iStatus,
       
  3846         param );
       
  3847     CleanupStack::Pop(); // watch
       
  3848     Document()->AddSingleOperationL( op, watch );
       
  3849 
       
  3850     CleanupStack::PopAndDestroy( 2 ); // selection, CAknInputBlock
       
  3851 
       
  3852     MsgLengthToNavipaneL();
       
  3853     }
       
  3854 
       
  3855 // ---------------------------------------------------------
       
  3856 // CUniEditorAppUi::DoUserSendingOptionsL
       
  3857 // 
       
  3858 // Invokes Sending Options from UI MTM.
       
  3859 // ---------------------------------------------------------
       
  3860 //
       
  3861 void CUniEditorAppUi::DoUserSendingOptionsL()
       
  3862     {
       
  3863     TInt flags = 0;
       
  3864 
       
  3865     TUniSendingSettings settings;
       
  3866     
       
  3867     CUniEditorPlugin* plugin = SmsPlugin();
       
  3868 
       
  3869     TBool currentlyLockedToSms = EFalse;
       
  3870 
       
  3871     if( plugin )
       
  3872         { 
       
  3873         // This should be available as if it's not -> sending options not available
       
  3874         plugin->GetSendingSettingsL( settings );
       
  3875         }
       
  3876 
       
  3877     //TUniSendingSettings::TUniMessageType origMessageType = settings.iMessageType;
       
  3878     
       
  3879     if( iMtm->MessageTypeLocking() == EUniMessageTypeLocked )
       
  3880         { 
       
  3881         // Pre-locked to SMS (We never get here in permanent MMS)
       
  3882         flags |= EUniSettingsPermanentSms;
       
  3883         currentlyLockedToSms = ETrue;
       
  3884         }
       
  3885     else if( iMtm->MessageTypeSetting() == EUniMessageTypeSettingSms && 
       
  3886              settings.iMessageType != TUniSendingSettings::EUniMessageTypeAutomatic &&
       
  3887              settings.iMessageType != TUniSendingSettings::EUniMessageTypeMultimedia )
       
  3888         { 
       
  3889         // msg type is temporarily locked to sms
       
  3890         currentlyLockedToSms = ETrue;
       
  3891         }
       
  3892     else
       
  3893         { 
       
  3894         if( iMtm->MessageTypeSetting() == EUniMessageTypeSettingMms )
       
  3895             {
       
  3896             settings.iMessageType = TUniSendingSettings::EUniMessageTypeMultimedia;
       
  3897             }
       
  3898         else if( iMtm->MessageTypeSetting() == EUniMessageTypeSettingAutomatic )
       
  3899             {
       
  3900             settings.iMessageType = TUniSendingSettings::EUniMessageTypeAutomatic;
       
  3901             }
       
  3902         }
       
  3903 
       
  3904     CUniEditorDocument* doc = Document();
       
  3905 
       
  3906     if ( !( IsBodySmsCompatibleL( EFalse ) && iHeader->IsHeaderSmsL() ) )
       
  3907         {
       
  3908         flags |= EUniSettingsContentNeedsMms;
       
  3909         }
       
  3910       
       
  3911     TUniSendingSettings::TUniCharSupport origCharSet = TUniSendingSettings::EUniCharSupportReduced;
       
  3912       
       
  3913     settings.iCharSupport = TUniSendingSettings::EUniCharSupportReduced;
       
  3914     
       
  3915     if ( doc->CharSetSupport() == EUniMessageCharSetFullLocked ||
       
  3916          doc->CharSetSupport() == EUniMessageCharSetReducedLocked )
       
  3917         {
       
  3918         flags |= EUniSettingsHideCharSet;
       
  3919         }
       
  3920     else if( doc->CharSetSupport() == EUniMessageCharSetFull )
       
  3921         {
       
  3922         settings.iCharSupport = TUniSendingSettings::EUniCharSupportFull;
       
  3923         origCharSet = TUniSendingSettings::EUniCharSupportFull;
       
  3924         }
       
  3925 
       
  3926     if( !( doc->CSPBits() & RMobilePhone::KCspProtocolID ) )
       
  3927         {
       
  3928         flags |= EUniSettingsCSPBitsOn;
       
  3929         }
       
  3930 
       
  3931     if ( iEditorFlags & EHideMessageTypeOption )
       
  3932         {
       
  3933         flags |= EUniSettingsHideMessageTypeOption;
       
  3934         }
       
  3935     TUniState oldState = doc->UniState();
       
  3936   
       
  3937     CUniSendingSettingsDialog::TUniExitCode exitCode = CUniSendingSettingsDialog::EUniBack;
       
  3938     
       
  3939     CUniSendingSettingsDialog* dlg = new ( ELeave ) CUniSendingSettingsDialog( flags, settings, exitCode, *iTitlePane );
       
  3940     CleanupStack::PushL( dlg );
       
  3941     
       
  3942     dlg->ConstructL( R_UNI_SENDINGSETTINGS_DIALOG_MENUBAR );
       
  3943 
       
  3944     // Flag is also used to judge whether toolbar update is done 
       
  3945     iEditorFlags |= EDoNotUpdateTitlePane;
       
  3946     
       
  3947     CleanupStack::Pop( dlg );
       
  3948     
       
  3949     if ( iFixedToolbar )
       
  3950         {
       
  3951         SetFixedToolbarDimmed();
       
  3952         }
       
  3953     
       
  3954   
       
  3955     CleanupStack::PushL( TCleanupItem( UpdateFixedToolbar, this ) );
       
  3956     SetKeyEventFlags(0);    
       
  3957     CleanupStack::PushL( TCleanupItem( DisableSendKey, this ) );  
       
  3958     
       
  3959     dlg->ExecuteLD( R_UNI_SENDINGSETTINGS_DIALOG );
       
  3960     
       
  3961     CleanupStack::PopAndDestroy(2); //DisableSendKey,UpdateFixedToolbar
       
  3962     
       
  3963     iEditorFlags &= ~EDoNotUpdateTitlePane;
       
  3964 
       
  3965     // Now store the changed settings into sms plugin if it exists
       
  3966     // (there's no need to save them in mms plugin as user cannot change anything there)
       
  3967     if( plugin )
       
  3968         {
       
  3969         plugin->SetSendingSettingsL( settings );
       
  3970         }
       
  3971 
       
  3972     TBool unhideConfigurableFields = EFalse;
       
  3973 
       
  3974     if ( !( flags & EUniSettingsHideCharSet ) )
       
  3975         { 
       
  3976         // Ok, it was possible to change the charset in the first place
       
  3977         if ( settings.iCharSupport != origCharSet )
       
  3978             { 
       
  3979             // CharSet has changed -> create new converter
       
  3980             TUniMessageCharSetSupport charSetSupport = EUniMessageCharSetFull;
       
  3981             if ( settings.iCharSupport == TUniSendingSettings::EUniCharSupportReduced )
       
  3982                 {
       
  3983                 charSetSupport = EUniMessageCharSetReduced;
       
  3984                 } 
       
  3985             doc->CreateCharConverterL( charSetSupport ); 
       
  3986             if( iNLTFeatureSupport )
       
  3987                 {
       
  3988                	iSettingsChanged = ETrue;                
       
  3989                 //Turkish SMS-PREQ2265 specific
       
  3990                 if(plugin)
       
  3991                     {
       
  3992                     //Update the new charset support selected by user.
       
  3993                     //Reset uniCode mode flag to EFalse(Restarts encoding algorithm in smsPlugin for optimal length calculation) 
       
  3994                     plugin->SetEncodingSettings(EFalse, doc->AlternativeEncodingType(), charSetSupport); 
       
  3995                     }                
       
  3996                 }
       
  3997             }
       
  3998         }
       
  3999 
       
  4000     // Now lets see the msg type changes
       
  4001 
       
  4002     if( iMtm->MessageTypeLocking() == EUniMessageTypeLocked )
       
  4003         { 
       
  4004         // First lets handle pre locked sms
       
  4005         // no operation here because the msg type does not change
       
  4006         // but just the bit in the message settings
       
  4007         }
       
  4008     else if( settings.iMessageType == TUniSendingSettings::EUniMessageTypeAutomatic )
       
  4009         { 
       
  4010         // Message type is now automatic
       
  4011         iMtm->SetMessageTypeSetting( EUniMessageTypeSettingAutomatic );
       
  4012         
       
  4013         if ( IsBodySmsCompatibleL() )
       
  4014             {
       
  4015             doc->SetBodyUniState( EUniSms );
       
  4016             }
       
  4017         else
       
  4018             {
       
  4019             doc->SetBodyUniState( EUniMms );
       
  4020             }
       
  4021         
       
  4022         if ( iHeader->IsHeaderSmsL() )
       
  4023             {
       
  4024             doc->SetHeaderUniState( EUniSms );
       
  4025             }
       
  4026         else
       
  4027             {            
       
  4028             doc->SetHeaderUniState( EUniMms );
       
  4029             }
       
  4030     
       
  4031         if ( currentlyLockedToSms )
       
  4032             { 
       
  4033             // Show the fields again
       
  4034             unhideConfigurableFields = ETrue;
       
  4035             }
       
  4036         }
       
  4037     else if ( settings.iMessageType == TUniSendingSettings::EUniMessageTypeMultimedia )
       
  4038         {
       
  4039         iMtm->SetMessageTypeSetting( EUniMessageTypeSettingMms );
       
  4040         if ( IsBodySmsCompatibleL() )
       
  4041             {
       
  4042             doc->SetBodyUniState( EUniSms );
       
  4043             }
       
  4044         else
       
  4045             {
       
  4046             doc->SetBodyUniState( EUniMms );
       
  4047             }
       
  4048             
       
  4049         if ( currentlyLockedToSms )
       
  4050             { 
       
  4051             // Show the fields again
       
  4052             unhideConfigurableFields = ETrue;
       
  4053             }
       
  4054         }
       
  4055     else
       
  4056         { 
       
  4057         // Settings is one of the sms conversions (none, fax, pager)
       
  4058         if ( iMtm->MessageTypeSetting() != EUniMessageTypeSettingSms )
       
  4059             {
       
  4060             iMtm->SetMessageTypeSetting( EUniMessageTypeSettingSms );
       
  4061             // Also remove those additional headers that need to be removed
       
  4062             TInt removeHeaders( 0 ); 
       
  4063             if ( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressCc ) )
       
  4064                 {
       
  4065                 removeHeaders |= EUniFeatureCc;
       
  4066                 }
       
  4067             if ( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressBcc ) )
       
  4068                 {
       
  4069                 removeHeaders |= EUniFeatureBcc;
       
  4070                 }
       
  4071             if ( !(iEditorFlags & ESubjectOkInSms ) && iHeader->SubjectControl() )
       
  4072                 {
       
  4073                 removeHeaders |= EUniFeatureSubject;
       
  4074                 }
       
  4075             iHeader->AddHeadersDeleteL( removeHeaders, EFalse );
       
  4076             }
       
  4077         // We can change this here because if it was not then SMS/Fax/Pager would not have been available in options
       
  4078         // This is needed here in case SMS soft and hard limits are different so we have to "hardcode" the type to SMS
       
  4079         doc->SetBodyUniState( EUniSms );
       
  4080         doc->SetHeaderUniState( EUniSms );
       
  4081         }
       
  4082 
       
  4083     if ( unhideConfigurableFields )
       
  4084         { 
       
  4085         // Read the current situation
       
  4086         TInt addHeaders = iHeader->AddHeadersConfigL();
       
  4087         // Add them to header
       
  4088         iHeader->AddHeadersAddL( addHeaders );
       
  4089         }
       
  4090 
       
  4091     if ( oldState != doc->UniState() )
       
  4092         {  
       
  4093          // If the state is not the same anymore, show popup
       
  4094         UpdateIndicatorIconsL();
       
  4095         ShowPopupNoteL( doc->UniState() == EUniMms ? ETrue : EFalse );
       
  4096         }
       
  4097     
       
  4098     CheckLockedSmsWithAttaL();
       
  4099     
       
  4100     UpdateToolbarL();
       
  4101     
       
  4102     SetTitleL();
       
  4103     MsgLengthToNavipaneL();
       
  4104 
       
  4105     // Removes or sets the max size according to the settings
       
  4106     SetOrRemoveMaxSizeInEdwin();
       
  4107     
       
  4108     if ( exitCode != CUniSendingSettingsDialog::EUniBack )
       
  4109         {
       
  4110         CAknAppUi::ProcessCommandL( EAknCmdExit );
       
  4111         return;
       
  4112         }
       
  4113 
       
  4114     UpdateMiddleSoftkeyL();
       
  4115     UpdateIndicatorIconsL();
       
  4116     }
       
  4117 
       
  4118 // ---------------------------------------------------------
       
  4119 // CUniEditorAppUi::DoUserInsertMediaL
       
  4120 // ---------------------------------------------------------
       
  4121 //
       
  4122 void CUniEditorAppUi::DoUserInsertMediaL()
       
  4123     {
       
  4124     RArray<TInt> disabledItems;
       
  4125     CleanupClosePushL( disabledItems );  
       
  4126 
       
  4127     if ( !( iSupportedFeatures & EUniFeatureCamcorder ) )
       
  4128         {
       
  4129         disabledItems.Append( EUniCmdInsertMediaNewVideo );
       
  4130         disabledItems.Append( EUniCmdInsertMediaNewImage );
       
  4131         }
       
  4132     
       
  4133     TInt selectedIndex( 0 );
       
  4134     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
       
  4135     dlg->PrepareLC( R_UNIEDITOR_INSERT_QUERY );
       
  4136     
       
  4137     CEikFormattedCellListBox* listbox = dlg->ListControl()->Listbox();
       
  4138     CDesCArray* itemArray = static_cast<CDesCArray*>( listbox->Model()->ItemTextArray() );
       
  4139     
       
  4140     if ( disabledItems.Count() > 0 )
       
  4141         {
       
  4142         for ( TInt currentItem = 0; currentItem < disabledItems.Count(); currentItem++ )
       
  4143             {
       
  4144             itemArray->Delete( disabledItems[ currentItem ] );
       
  4145             listbox->HandleItemRemovalL();
       
  4146             }
       
  4147         }
       
  4148         
       
  4149     if ( dlg->RunLD() )
       
  4150         {
       
  4151         for ( TInt currentItem = disabledItems.Count() - 1; currentItem >= 0 ; currentItem-- )
       
  4152             {
       
  4153             if ( selectedIndex >= disabledItems[ currentItem ] )
       
  4154                 {
       
  4155                 selectedIndex++;
       
  4156                 }
       
  4157             }
       
  4158                 
       
  4159         switch ( selectedIndex )    
       
  4160             {
       
  4161             case EUniCmdInsertMediaImage:
       
  4162                 {
       
  4163                 DoUserInsertImageL( MsgAttachmentUtils::EImage );
       
  4164                 break;
       
  4165                 } 
       
  4166             case EUniCmdInsertMediaNewImage:
       
  4167                 {
       
  4168                 DoUserInsertImageL( MsgAttachmentUtils::ENewImage );
       
  4169                 break;
       
  4170                 } 
       
  4171             case EUniCmdInsertMediaVideo:
       
  4172                 {
       
  4173                 DoUserInsertVideoL( MsgAttachmentUtils::EVideo );
       
  4174                 break;
       
  4175                 } 
       
  4176             case EUniCmdInsertMediaNewVideo:
       
  4177                 {
       
  4178                 DoUserInsertVideoL( MsgAttachmentUtils::ENewVideo );
       
  4179                 break;
       
  4180                 } 
       
  4181             case EUniCmdInsertMediaAudio:
       
  4182                 {
       
  4183                 DoUserInsertAudioL( MsgAttachmentUtils::EAudio );
       
  4184                 break;
       
  4185                 } 
       
  4186             case EUniCmdInsertMediaNewAudio:
       
  4187                 {
       
  4188                 DoUserInsertAudioL( MsgAttachmentUtils::ENewAudio );
       
  4189                 break;
       
  4190                 } 
       
  4191             case EUniCmdInsertMediavCard:
       
  4192                 {
       
  4193                 DoUserInsertVCardL();
       
  4194                 break;
       
  4195                 }
       
  4196             case EUniCmdInsertMediaSlide:
       
  4197                 {
       
  4198                 DoUserInsertSlideL();
       
  4199                 break;
       
  4200                 }
       
  4201             case EUniCmdInsertMediaNote:
       
  4202                 {
       
  4203                 DoUserInsertTextL( EMemoText );
       
  4204                 break;
       
  4205                 }
       
  4206             case EUniCmdInsertMediaTextAtta:
       
  4207                 {
       
  4208                 DoUserInsertOtherFileL( ETextFile );
       
  4209                 break;
       
  4210                 }
       
  4211             case EUniCmdInsertMediaTemplate:
       
  4212                 {
       
  4213                 DoUserInsertTextL( ETemplateText );
       
  4214                 break;
       
  4215                 }
       
  4216 //            case EUniCmdInsertMediaSVG:
       
  4217 //                {
       
  4218 //                DoUserInsertSvgL();
       
  4219 //                break;
       
  4220 //                }
       
  4221             case EUniCmdInsertMediaOtherFile:
       
  4222                 {
       
  4223                 DoUserInsertOtherFileL( EOtherFile );
       
  4224                 break;
       
  4225                 }
       
  4226             default: 
       
  4227                 {
       
  4228                 __ASSERT_DEBUG( EFalse, Panic( EUniUnsupportedCommand ) );
       
  4229                 break;
       
  4230                 }
       
  4231             }
       
  4232         }
       
  4233         
       
  4234     CleanupStack::PopAndDestroy( &disabledItems );
       
  4235     }
       
  4236 
       
  4237 // ---------------------------------------------------------
       
  4238 // CUniEditorAppUi::DoStartInsertL
       
  4239 // ---------------------------------------------------------
       
  4240 //
       
  4241 void CUniEditorAppUi::DoStartInsertL( TBool aAddSlide, TBool aAddAsAttachment )
       
  4242     {
       
  4243     if ( aAddSlide &&
       
  4244          iSmilModel->MaxSlideCountReached() )
       
  4245        {
       
  4246        ShowConfirmableInfoL( R_UNIEDITOR_INFO_MAX_SLIDES_ALL );
       
  4247        iEditorFlags &= ~EMsgEditInProgress;
       
  4248        }
       
  4249    else
       
  4250        {
       
  4251         if ( !iInsertOperation )
       
  4252             {
       
  4253             iInsertOperation = CUniEditorInsertOperation::NewL(
       
  4254                 *this,
       
  4255                 *Document(),
       
  4256                 *iHeader,
       
  4257                 *iSlideLoader,
       
  4258                 *iView,
       
  4259                 FsSession() );
       
  4260             }
       
  4261         
       
  4262         if ( aAddSlide )
       
  4263             {
       
  4264             iEditorFlags |= EInsertAddsSlide;
       
  4265             }
       
  4266         else
       
  4267             {
       
  4268             iEditorFlags &= ~EInsertAddsSlide;
       
  4269             }
       
  4270             
       
  4271         ShowWaitNoteL( R_QTN_UNI_WAIT_INSERTING );
       
  4272         
       
  4273         iInsertOperation->Insert(
       
  4274             iInsertingMedia,
       
  4275             aAddSlide,
       
  4276             aAddAsAttachment );
       
  4277         
       
  4278         ActivateInputBlockerL( iInsertOperation );
       
  4279         
       
  4280         iInsertingMedia = NULL;
       
  4281        }
       
  4282        // Enable the toolbar since inputblockers will take care now
       
  4283       if( iFixedToolbar )
       
  4284         {
       
  4285         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  4286         }
       
  4287     }
       
  4288 
       
  4289 
       
  4290 // ---------------------------------------------------------
       
  4291 // CreateMediaInfoForInsertL
       
  4292 // ---------------------------------------------------------
       
  4293 //
       
  4294 TBool CUniEditorAppUi::CreateMediaInfoForInsertL( TMsgMediaType aMediaType,
       
  4295                                                   const TDesC& aFileName )
       
  4296     {
       
  4297     RFile file = Document()->DataModel()->MediaResolver().FileHandleL( aFileName );
       
  4298     CleanupClosePushL( file );
       
  4299     
       
  4300     delete iInsertingMedia;
       
  4301     iInsertingMedia = NULL;
       
  4302     
       
  4303     iInsertingMedia = Document()->DataModel()->MediaResolver().CreateMediaInfoL( file );
       
  4304 
       
  4305     Document()->DataModel()->MediaResolver().ParseInfoDetailsL( iInsertingMedia, file );
       
  4306     
       
  4307     TMmsConformance conformance = 
       
  4308         Document()->DataModel()->MmsConformance().MediaConformance( *iInsertingMedia );
       
  4309     
       
  4310     CleanupStack::PopAndDestroy( &file );
       
  4311     
       
  4312     TInt errResId = KUniInvalidResourceId;
       
  4313     TInt confStatus = conformance.iConfStatus;
       
  4314 
       
  4315     // Supported type check
       
  4316     if ( confStatus & EMmsConfNokNotSupported ||
       
  4317         ( Document()->CreationMode() == EMmsCreationModeRestricted &&
       
  4318           confStatus & EMmsConfNokFreeModeOnly ) )
       
  4319         {
       
  4320         errResId = R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT;
       
  4321         if( Document()->CreationModeUserChangeable() &&
       
  4322            !Document()->CreationMode() )
       
  4323             {
       
  4324             errResId = R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT;
       
  4325             }
       
  4326         }
       
  4327     else if ( confStatus & EMmsConfNokDRM )
       
  4328         {
       
  4329         // DRM check
       
  4330         errResId = R_UNIEDITOR_INFO_SEND_FORBID_1;
       
  4331         }
       
  4332     else if ( aMediaType != EMsgMediaUnknown && 
       
  4333               iInsertingMedia->MediaType() != aMediaType )
       
  4334         {
       
  4335         // Keep this after DRM check!
       
  4336         errResId = R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT;
       
  4337         if( Document()->CreationModeUserChangeable() &&
       
  4338             !Document()->CreationMode() )
       
  4339             {
       
  4340             errResId = R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT;
       
  4341             }
       
  4342         }
       
  4343     else if ( !conformance.iCanAdapt &&
       
  4344         ( confStatus & EMmsConfNokTooBig ||
       
  4345         TUint( MessageSizeInBytes() + iInsertingMedia->FileSize() )
       
  4346         > Document()->MaxMessageSize() ) )
       
  4347         {
       
  4348         // File is too big and it cannot be adapted (e.g. scaled down)
       
  4349         errResId = R_UNIEDITOR_INFO_OBJECT_TOO_BIG;
       
  4350         }
       
  4351 
       
  4352     if ( errResId != KUniInvalidResourceId )
       
  4353         {
       
  4354         delete iInsertingMedia;
       
  4355         iInsertingMedia = NULL;
       
  4356         ShowInformationNoteL( errResId, EFalse );
       
  4357         return EFalse;
       
  4358         }
       
  4359 
       
  4360     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( Document()->Session(),
       
  4361                                                               iInsertingMedia->FileSize() ) )
       
  4362         {
       
  4363          delete iInsertingMedia;
       
  4364          iInsertingMedia = NULL;       
       
  4365          ShowConfirmableInfoL( R_UNIEDITOR_NOT_ENOUGH_MEMORY );
       
  4366          return EFalse;             
       
  4367         }
       
  4368         
       
  4369     return ETrue;
       
  4370     }
       
  4371 
       
  4372 // ---------------------------------------------------------
       
  4373 // CUniEditorAppUi::SuperDistributionCheckForInsertL
       
  4374 // ---------------------------------------------------------
       
  4375 //
       
  4376 TBool CUniEditorAppUi::SuperDistributionCheckForInsertL()
       
  4377     {
       
  4378     // SuperDistribution check & query
       
  4379     if ( iSupportedFeatures & EUniFeatureDrmFull &&
       
  4380          iInsertingMedia->Protection() & EFileProtSuperDistributable )
       
  4381         {
       
  4382         if ( !ShowConfirmationQueryL( R_UNIEDITOR_QUEST_SEND_WO_RIGHTS ) )
       
  4383             {
       
  4384             delete iInsertingMedia;
       
  4385             iInsertingMedia = NULL;
       
  4386             return EFalse;
       
  4387             }
       
  4388         }
       
  4389     return ETrue;
       
  4390     }
       
  4391 
       
  4392 // ---------------------------------------------------------
       
  4393 // CUniEditorAppUi::CheckMediaInfoForInsertL
       
  4394 // ---------------------------------------------------------
       
  4395 //
       
  4396 TBool CUniEditorAppUi::CheckMediaInfoForInsertL()
       
  4397     {
       
  4398     __ASSERT_DEBUG( iInsertingMedia, Panic( EUniNullPointer ) );
       
  4399 
       
  4400     TMmsConformance conformance = 
       
  4401         Document()->DataModel()->MmsConformance().MediaConformance( *iInsertingMedia );
       
  4402     
       
  4403     TInt errResId = KUniInvalidResourceId;
       
  4404     TInt confStatus = conformance.iConfStatus;
       
  4405     
       
  4406     // In "free" mode user can insert images that are larger by dimensions than allowed by conformance
       
  4407     if ( Document()->CreationMode() != EMmsCreationModeRestricted )
       
  4408         {
       
  4409         //Mask "Corrupted" away in free & guided mode.
       
  4410         confStatus &= ~EMmsConfNokCorrupt;
       
  4411         
       
  4412         // If user answers yes to Guided mode confirmation query he/she moves to free mode
       
  4413         if ( ( confStatus & ( EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded ) ) &&
       
  4414              !( confStatus & ~( EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded ) ) )
       
  4415             {
       
  4416             if ( iInsertingMedia->Protection() & EFileProtSuperDistributable )
       
  4417                 {
       
  4418                 // SuperDistribution not checked here
       
  4419                 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
       
  4420                 confStatus &= ~EMmsConfNokFreeModeOnly;
       
  4421                 confStatus &= ~EMmsConfNokScalingNeeded;
       
  4422                 }
       
  4423             else if ( ShowGuidedModeConfirmationQueryL( R_UNIEDITOR_QUEST_GUIDED_OBJ ) )
       
  4424                 {
       
  4425                 // Guided query accepted.
       
  4426                 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
       
  4427                 confStatus &= ~EMmsConfNokFreeModeOnly;
       
  4428                 confStatus &= ~EMmsConfNokScalingNeeded;
       
  4429                 }
       
  4430             else
       
  4431                 {
       
  4432                 // Guided query not accepted. Stop insertion.
       
  4433                 delete iInsertingMedia;
       
  4434                 iInsertingMedia = NULL;
       
  4435                 return EFalse;
       
  4436                 }
       
  4437             }
       
  4438         }
       
  4439 
       
  4440     if ( confStatus & EMmsConfNokTooBig ||
       
  4441         TUint( MessageSizeInBytes() + iInsertingMedia->FileSize() )
       
  4442         > Document()->MaxMessageSize() )
       
  4443         {
       
  4444         // Size check
       
  4445         errResId = R_UNIEDITOR_INFO_OBJECT_TOO_BIG;
       
  4446         }
       
  4447     else if ( confStatus != EMmsConfOk )
       
  4448         {
       
  4449         // Sanity check
       
  4450         errResId = R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT;
       
  4451         if( Document()->CreationModeUserChangeable() &&
       
  4452             !Document()->CreationMode() )
       
  4453             {
       
  4454             errResId = R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT;
       
  4455             }
       
  4456         }
       
  4457 
       
  4458     if ( errResId != KUniInvalidResourceId )
       
  4459         {
       
  4460         delete iInsertingMedia;
       
  4461         iInsertingMedia = NULL;
       
  4462         ShowInformationNoteL( errResId, EFalse );
       
  4463         return EFalse;
       
  4464         }
       
  4465         
       
  4466     return ETrue;
       
  4467     }
       
  4468 
       
  4469 
       
  4470 // ---------------------------------------------------------
       
  4471 // CUniEditorAppUi::DoUserInsertSlideL
       
  4472 // ---------------------------------------------------------
       
  4473 //
       
  4474 void CUniEditorAppUi::DoUserInsertSlideL()
       
  4475     {
       
  4476     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4477 
       
  4478     if ( TUint( MessageSizeInBytes() + KEmptySlideSize ) > Document()->MaxMessageSize() )
       
  4479         {
       
  4480         ShowConfirmableInfoL( R_UNIEDITOR_INFO_OBJECT_TOO_BIG );
       
  4481         }
       
  4482     else if ( iSmilModel->MaxSlideCountReached() )
       
  4483         {
       
  4484         ShowConfirmableInfoL( R_UNIEDITOR_INFO_MAX_SLIDES_ALL );
       
  4485         }
       
  4486     else
       
  4487         {
       
  4488         TInt index = Document()->CurrentSlide() + 1;
       
  4489         iSmilModel->AddSlideL( index );
       
  4490         Document()->SetBodyModified( ETrue );
       
  4491         DoUserChangeSlideL( index );
       
  4492         }
       
  4493     }
       
  4494 
       
  4495 // ---------------------------------------------------------
       
  4496 // CUniEditorAppUi::DoUserRemoveSlideL
       
  4497 // ---------------------------------------------------------
       
  4498 //
       
  4499 void CUniEditorAppUi::DoUserRemoveSlideL()
       
  4500     {
       
  4501     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4502 
       
  4503     if ( ShowConfirmationQueryL( R_UNIEDITOR_QUEST_REMOVE_PAGE ) ) 
       
  4504         {
       
  4505         DoRemoveSlideL();
       
  4506         }
       
  4507         
       
  4508     Document()->SetBodyModified( ETrue ); 
       
  4509     }
       
  4510 
       
  4511 // ---------------------------------------------------------
       
  4512 // CUniEditorAppUi::DoRemoveSlideL
       
  4513 // ---------------------------------------------------------
       
  4514 //
       
  4515 void CUniEditorAppUi::DoRemoveSlideL()
       
  4516     {
       
  4517     TInt currSlide = Document()->CurrentSlide();
       
  4518     TMsgControlId focusedControl( EMsgComponentIdNull );
       
  4519     
       
  4520     if( Document()->DataModel()->SmilType() == EMmsSmil &&
       
  4521         ( currSlide == 0 || currSlide == 1 ) )
       
  4522         { 
       
  4523         if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
  4524             {
       
  4525             CMsgAddressControl* to = iHeader->AddressControl( CUniEditorHeader::EHeaderAddressTo );
       
  4526             CMsgAddressControl* cc = iHeader->AddressControl( CUniEditorHeader::EHeaderAddressCc );
       
  4527             CMsgAddressControl* bcc = iHeader->AddressControl( CUniEditorHeader::EHeaderAddressBcc );
       
  4528             
       
  4529             if( to && to->GetRecipientsL()->Count() == 0 )
       
  4530                 {
       
  4531                 focusedControl = EMsgComponentIdTo;
       
  4532                 }
       
  4533             else if( cc && cc->GetRecipientsL()->Count() == 0 )
       
  4534                 {
       
  4535                 focusedControl = EMsgComponentIdCc;
       
  4536                 }
       
  4537             else if( bcc && bcc->GetRecipientsL()->Count() == 0 )
       
  4538                 {
       
  4539                 focusedControl = EMsgComponentIdBcc;
       
  4540                 }
       
  4541             else if( iSupportedFeatures & EUniFeatureSubject &&
       
  4542                      SubjectCtrl() &&
       
  4543                      SubjectCtrl()->TextContent().DocumentLength() == 0 )
       
  4544                 {
       
  4545                 focusedControl = EMsgComponentIdSubject;
       
  4546                 }
       
  4547             }
       
  4548         }
       
  4549     
       
  4550     TInt objCount = iSmilModel->SlideObjectCount( currSlide );
       
  4551     ReleaseImage( ETrue );
       
  4552     
       
  4553     for ( TInt i = 0; i < objCount; i++ )
       
  4554         {
       
  4555         iSmilModel->RemoveObjectByIndexL( currSlide, 0 );
       
  4556         }
       
  4557     iSmilModel->RemoveSlide( currSlide );
       
  4558     TInt nextSlide = currSlide;
       
  4559     if ( nextSlide )
       
  4560         {
       
  4561         nextSlide--;
       
  4562         }
       
  4563     //Set current slide to invalid in order
       
  4564     //to prevent false events coming to wrong slides
       
  4565     Document()->SetCurrentSlide( -1 );
       
  4566     iView->SetScrollParts( iSmilModel->SlideCount() );
       
  4567     iView->SetCurrentPart( nextSlide );
       
  4568     iNextFocus = focusedControl;
       
  4569     DoUserChangeSlideL( nextSlide );
       
  4570     }
       
  4571 
       
  4572 // ---------------------------------------------------------
       
  4573 // CUniEditorAppUi::DoUserChangeSlideL
       
  4574 //
       
  4575 // If change is made from first slide containing address fields into
       
  4576 // some other slide and address control is currently focused set
       
  4577 // the current input mode into all address fields. This enables
       
  4578 // correct input mode to be used if focus is set to different
       
  4579 // address field when returning to first slide and also if
       
  4580 // message is closed from different slide.
       
  4581 // After input mode is set operation is created if necessary and
       
  4582 // activated.
       
  4583 // ---------------------------------------------------------
       
  4584 //
       
  4585 void CUniEditorAppUi::DoUserChangeSlideL( TInt aSlideNum )
       
  4586     {
       
  4587     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4588     
       
  4589     CMsgBaseControl* ctrl = iView->FocusedControl();  // ctrl can be NULL.
       
  4590     if ( ctrl &&
       
  4591          Document()->CurrentSlide() == 0 &&
       
  4592          iHeader->IsAddressControl( ctrl->ControlId() ) )
       
  4593         {
       
  4594         SetInputModeToAddressFields( static_cast<CMsgAddressControl*>( ctrl )->Editor().AknEditorCurrentInputMode() );
       
  4595         }
       
  4596     
       
  4597     if ( !iChangeSlideOperation )
       
  4598         {
       
  4599         iChangeSlideOperation = CUniEditorChangeSlideOperation::NewL(
       
  4600             *this,
       
  4601             *Document(),
       
  4602             *iHeader,
       
  4603             *iSlideLoader,
       
  4604             *iView,
       
  4605             FsSession() );
       
  4606         }
       
  4607     
       
  4608     iChangeSlideOperation->ChangeSlide(  aSlideNum );
       
  4609 
       
  4610     iNextSlide = aSlideNum;
       
  4611     
       
  4612     iScreenClearer = CAknLocalScreenClearer::NewLC( EFalse );
       
  4613     CleanupStack::Pop();
       
  4614     iScreenClearer->SetExtent( iScreenClearer->Position(), ClientRect().Size() );
       
  4615     
       
  4616     ShowWaitNoteL( R_QTN_UNI_WAIT_SLIDE_CHANGE );
       
  4617     
       
  4618     ActivateInputBlockerL( iChangeSlideOperation );
       
  4619         
       
  4620     BeginActiveWait( iChangeSlideOperation );
       
  4621     }
       
  4622 
       
  4623 
       
  4624 // ---------------------------------------------------------
       
  4625 // CUniEditorAppUi::DoSetFocusL
       
  4626 // ---------------------------------------------------------
       
  4627 //
       
  4628 void CUniEditorAppUi::DoSetFocusL()
       
  4629     {
       
  4630     // 1. to To: control, if empty and exists
       
  4631     // 2. if not empty, to Subject: control, if empty and exists
       
  4632     // 3. otherwise to body    
       
  4633     TMsgControlId focusedControl( EMsgComponentIdTo );
       
  4634     if ( iNextFocus != EMsgComponentIdNull )
       
  4635         {
       
  4636         // iNextFocus is set when changing slide
       
  4637         focusedControl = iNextFocus;
       
  4638         iNextFocus = EMsgComponentIdNull;
       
  4639         }
       
  4640     else
       
  4641         {
       
  4642         // To first empty field. Cc and Bcc are not supported here
       
  4643         CMsgAddressControl* to = ToCtrl();
       
  4644         
       
  4645         if ( Document()->DataModel()->SmilType() == EMmsSmil &&  
       
  4646              ( !to || 
       
  4647                to->GetRecipientsL()->Count() > 0 ) )
       
  4648             {
       
  4649             // No To-control or there are recipients
       
  4650             // -> focus to end of bodytext or to Subject field if empty
       
  4651             focusedControl = EMsgComponentIdBody;
       
  4652             if ( iSupportedFeatures & EUniFeatureSubject )
       
  4653                 {
       
  4654                 CMsgExpandableControl* subj = SubjectCtrl();
       
  4655                 if ( subj && 
       
  4656                      subj->TextContent().DocumentLength() == 0 )
       
  4657                     {
       
  4658                     focusedControl = EMsgComponentIdSubject;
       
  4659                     }
       
  4660                 }
       
  4661             
       
  4662             if ( !BodyCtrl() )
       
  4663                 {
       
  4664                 focusedControl = EMsgComponentIdTo;
       
  4665                 }
       
  4666                 
       
  4667             if ( focusedControl == EMsgComponentIdBody )
       
  4668                 {
       
  4669                 BodyCtrl()->SetCursorPosL( BodyCtrlEditor()->TextLength() );
       
  4670                 }
       
  4671             }
       
  4672         }
       
  4673     iView->SetFocus( focusedControl );
       
  4674     }
       
  4675 
       
  4676 // ---------------------------------------------------------
       
  4677 // CUniEditorAppUi::SetTitleL
       
  4678 // ---------------------------------------------------------
       
  4679 //
       
  4680 void CUniEditorAppUi::SetTitleL()
       
  4681     {
       
  4682     // If titlepane exists -> set the right title
       
  4683     HBufC* titleString = Document()->UniState() == EUniMms ? iTitleMms : 
       
  4684                                                              iTitleSms;
       
  4685     iTitlePane->SetTextL( titleString->Des(), ETrue );
       
  4686         
       
  4687     CGulIcon* image = Document()->UniState() == EUniMms? iIconMms : 
       
  4688                                                          iIconSms;
       
  4689     
       
  4690     // Create duplicates of the icon to be used
       
  4691     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  4692     CleanupStack::PushL( bitmap );
       
  4693     
       
  4694     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  4695     CleanupStack::PushL( bitmapMask );
       
  4696     
       
  4697     User::LeaveIfError( bitmap->Duplicate( image->Bitmap()->Handle() ) );
       
  4698     User::LeaveIfError( bitmapMask->Duplicate( image->Mask()->Handle() ) );
       
  4699 
       
  4700     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  4701     if(!iFinalizeLaunchL)
       
  4702     iTitlePane->DrawNow();
       
  4703     
       
  4704     CleanupStack::Pop( 2, bitmap );
       
  4705     }
       
  4706 
       
  4707 // ---------------------------------------------------------
       
  4708 // CUniEditorAppUi::DoUserInsertImageL
       
  4709 // ---------------------------------------------------------
       
  4710 //
       
  4711 void CUniEditorAppUi::DoUserInsertImageL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType )
       
  4712     {
       
  4713     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4714     
       
  4715     if( iFixedToolbar )
       
  4716         {
       
  4717         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  4718         }
       
  4719     iInsertingType = EMsgMediaImage;
       
  4720     
       
  4721     TBool fetchFile( ETrue );
       
  4722     TBool enabletoolbarext = ETrue;
       
  4723     while ( fetchFile )
       
  4724         {
       
  4725         fetchFile = EFalse;
       
  4726         iEditorFlags |= EMsgEditInProgress;
       
  4727         TBool stat= EFalse;
       
  4728         TRAPD(Err,stat = FetchFileL( aFetchType ));
       
  4729          if (Err == KErrNone && stat)        
       
  4730             {
       
  4731             if ( SuperDistributionCheckForInsertL() )
       
  4732                 {
       
  4733                 // CheckMediaInfoForInsertL() done in CUniEditorInsertOperation
       
  4734                 TBool addSlide = EFalse;
       
  4735                 if ( ObjectsAvailable() & 
       
  4736                     ( EUniImageFlag | EUniVideoFlag | EUniSvgFlag ) )
       
  4737                     {
       
  4738                     addSlide = ETrue;
       
  4739                     }
       
  4740 
       
  4741                 DoStartInsertL( addSlide, EFalse );
       
  4742                 enabletoolbarext = EFalse;
       
  4743                 }
       
  4744             else
       
  4745                 {
       
  4746                 fetchFile = ETrue;
       
  4747                 }
       
  4748             }
       
  4749          else if(Err == KLeaveExit)
       
  4750              {
       
  4751               User::Leave( Err );
       
  4752              }
       
  4753          else
       
  4754             {
       
  4755             iEditorFlags &= ~EMsgEditInProgress;           
       
  4756             }
       
  4757         }
       
  4758         if(enabletoolbarext)
       
  4759             {
       
  4760                 //Enable the insert toolbar 
       
  4761             if( iFixedToolbar )
       
  4762                 {
       
  4763                 iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );
       
  4764                 HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
       
  4765                 }
       
  4766             }
       
  4767                                  
       
  4768     }
       
  4769 
       
  4770 // ---------------------------------------------------------
       
  4771 // CUniEditorAppUi::DoUserInsertVideoL
       
  4772 // ---------------------------------------------------------
       
  4773 //
       
  4774 void CUniEditorAppUi::DoUserInsertVideoL( MsgAttachmentUtils::TMsgAttachmentFetchType  aFetchType )
       
  4775     {
       
  4776     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4777     
       
  4778    if( iFixedToolbar )
       
  4779         {
       
  4780         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  4781         }
       
  4782     iInsertingType = EMsgMediaVideo;
       
  4783     
       
  4784     TBool fetchFile( ETrue );
       
  4785     TBool enabletoolbarext = ETrue;
       
  4786     while ( fetchFile )
       
  4787         {
       
  4788         fetchFile = EFalse;
       
  4789         iEditorFlags |= EMsgEditInProgress;
       
  4790         TBool stat= EFalse;
       
  4791         TRAPD(Err,stat = FetchFileL( aFetchType ));
       
  4792         if (Err == KErrNone && stat)        
       
  4793             {
       
  4794             if ( SuperDistributionCheckForInsertL() )
       
  4795                 {
       
  4796                 if ( CheckMediaInfoForInsertL() )
       
  4797                     {
       
  4798                     TBool addSlide = EFalse;
       
  4799                 
       
  4800                     if ( ObjectsAvailable() & 
       
  4801                         ( EUniAudioFlag | EUniImageFlag | EUniVideoFlag | EUniSvgFlag ) )
       
  4802                         {
       
  4803                         addSlide = ETrue;
       
  4804                         }
       
  4805                     DoStartInsertL( addSlide, EFalse );
       
  4806                     enabletoolbarext = EFalse;
       
  4807                     }
       
  4808                 else
       
  4809                     {
       
  4810                      iEditorFlags &= ~EMsgEditInProgress;
       
  4811                     }
       
  4812                 }
       
  4813             else
       
  4814                 {
       
  4815                 fetchFile = ETrue;
       
  4816                 }
       
  4817             }
       
  4818         else if(Err == KLeaveExit)
       
  4819             {
       
  4820              User::Leave( Err );
       
  4821             }
       
  4822         else
       
  4823             {
       
  4824             iEditorFlags &= ~EMsgEditInProgress;
       
  4825             }
       
  4826         }
       
  4827       if(enabletoolbarext)
       
  4828             {
       
  4829                 //Enable the insert toolbar 
       
  4830             if( iFixedToolbar )
       
  4831                 {
       
  4832                 iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  4833                 HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
       
  4834                 }
       
  4835             }
       
  4836                          
       
  4837     }
       
  4838 
       
  4839 // ---------------------------------------------------------
       
  4840 // CUniEditorAppUi::DoUserInsertAudioL
       
  4841 // ---------------------------------------------------------
       
  4842 //
       
  4843 void CUniEditorAppUi::DoUserInsertAudioL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType )
       
  4844     {
       
  4845     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4846     
       
  4847    if( iFixedToolbar )
       
  4848         {
       
  4849         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  4850         }
       
  4851     iInsertingType = EMsgMediaAudio;
       
  4852     
       
  4853     TBool fetchFile( ETrue );
       
  4854     TBool enabletoolbarext = ETrue;
       
  4855     while ( fetchFile )
       
  4856         {
       
  4857         fetchFile = EFalse;
       
  4858         iEditorFlags |= EMsgEditInProgress;
       
  4859         TBool stat= EFalse;
       
  4860         TRAPD(Err,stat = FetchFileL( aFetchType ));
       
  4861         if (Err == KErrNone && stat)        
       
  4862             {
       
  4863             if ( SuperDistributionCheckForInsertL() )
       
  4864                 {
       
  4865                 if ( CheckMediaInfoForInsertL() )
       
  4866                     {
       
  4867                     TBool addSlide = EFalse;
       
  4868                     if ( ObjectsAvailable() & 
       
  4869                         ( EUniAudioFlag | EUniVideoFlag | EUniSvgFlag ) )
       
  4870                         {
       
  4871                         addSlide = ETrue;
       
  4872                         }
       
  4873                     DoStartInsertL( addSlide, EFalse );
       
  4874                     enabletoolbarext = EFalse ; 
       
  4875                     }
       
  4876                 else
       
  4877                     {
       
  4878                      iEditorFlags &= ~EMsgEditInProgress;
       
  4879                     }
       
  4880                 }
       
  4881             else
       
  4882                 {
       
  4883                 fetchFile = ETrue;
       
  4884                 }
       
  4885             }
       
  4886         else if(Err == KLeaveExit)
       
  4887             {
       
  4888              User::Leave( Err );
       
  4889             }
       
  4890          else
       
  4891             {
       
  4892             iEditorFlags &= ~EMsgEditInProgress;
       
  4893             }
       
  4894         }
       
  4895         if(enabletoolbarext)
       
  4896             {
       
  4897                 //Enable the insert toolbar 
       
  4898             if( iFixedToolbar )
       
  4899                 {
       
  4900                 iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  4901                 HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
       
  4902                 }
       
  4903             }
       
  4904                          
       
  4905     }
       
  4906 
       
  4907 // ---------------------------------------------------------
       
  4908 // CUniEditorAppUi::DoUserInsertTextL
       
  4909 // ---------------------------------------------------------
       
  4910 //
       
  4911 void CUniEditorAppUi::DoUserInsertTextL( TUniEditorInsertTextType aType )
       
  4912     {
       
  4913     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  4914     TInt err( KErrNone );
       
  4915     TInt errResId = KUniInvalidResourceId;
       
  4916     TInt sizeLimit( Document()->MaxMessageSize() - MessageSizeInBytes() ); 
       
  4917 
       
  4918      if( iFixedToolbar ) 
       
  4919         {
       
  4920         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  4921         }
       
  4922     if ( aType == ETemplateText )
       
  4923         {
       
  4924         InsertTemplateL();
       
  4925         }
       
  4926     else
       
  4927         {
       
  4928         err = InsertTextMemoL( sizeLimit );
       
  4929         }
       
  4930         
       
  4931     if( iFixedToolbar )
       
  4932         {
       
  4933         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, EFalse );    
       
  4934         }
       
  4935     if ( err == KErrOverflow)
       
  4936         {
       
  4937         errResId = R_UNIEDITOR_INFO_OBJECT_TOO_BIG;
       
  4938         ShowConfirmableInfoL( errResId );
       
  4939         }
       
  4940     else
       
  4941         {
       
  4942     UpdateSmilTextAttaL();
       
  4943     
       
  4944     Document()->SetBodyModified( ETrue );
       
  4945     CheckBodyForMessageTypeL();
       
  4946     
       
  4947     MsgLengthToNavipaneL();
       
  4948     CheckMaxSmsSizeAndShowNoteL();
       
  4949     SetOrRemoveMaxSizeInEdwin();
       
  4950         }
       
  4951     }
       
  4952 
       
  4953 // ---------------------------------------------------------
       
  4954 // CUniEditorAppUi::DoUserInsertOtherFileL
       
  4955 // ---------------------------------------------------------
       
  4956 //
       
  4957 void CUniEditorAppUi::DoUserInsertOtherFileL( TUniEditorInsertOtherType aType )
       
  4958     {
       
  4959     TBool addAttachment( EFalse );
       
  4960      if( iFixedToolbar )
       
  4961         {
       
  4962         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  4963         }
       
  4964     
       
  4965     TBool enabletoolbarext = ETrue;
       
  4966     if ( aType == ETextFile )
       
  4967         {
       
  4968         iInsertingType = EMsgMediaText;
       
  4969         TBool stat= EFalse;
       
  4970         TRAPD(Err,stat = FetchFileL( MsgAttachmentUtils::ENote ));
       
  4971         if (Err == KErrNone && stat)  
       
  4972             {            
       
  4973             addAttachment = ETrue;
       
  4974             }
       
  4975         }
       
  4976     else
       
  4977         {
       
  4978         TFileName* fileName = new( ELeave ) TFileName;
       
  4979         CleanupStack::PushL( fileName );
       
  4980             
       
  4981         if ( MsgAttachmentUtils::FetchAnyFileL( *fileName, *iEikonEnv ) )
       
  4982             {
       
  4983             Document()->DataModel()->MediaResolver().SetCharacterSetRecognition( ETrue );
       
  4984             
       
  4985             TRAPD( error, CreateMediaInfoForInsertL( EMsgMediaUnknown, *fileName ) );
       
  4986             
       
  4987             Document()->DataModel()->MediaResolver().SetCharacterSetRecognition( EFalse );
       
  4988             
       
  4989             User::LeaveIfError( error );
       
  4990             
       
  4991             addAttachment = ETrue;
       
  4992             }
       
  4993         
       
  4994         CleanupStack::PopAndDestroy( fileName );
       
  4995         }
       
  4996   
       
  4997     if ( addAttachment && iInsertingMedia )
       
  4998         {
       
  4999         iInsertingType = iInsertingMedia->MediaType();
       
  5000         if (    SuperDistributionCheckForInsertL() )
       
  5001             {
       
  5002             // CheckMediaInfoForInsertL() for images done in CUniEditorInsertOperation
       
  5003             if (    iInsertingType == EMsgMediaImage
       
  5004                 ||  CheckMediaInfoForInsertL() )
       
  5005                 {
       
  5006                 TBool addSlide( EFalse );
       
  5007                 TBool addAsAttachment( ETrue );
       
  5008                                 
       
  5009                 if ( iInsertingType != EMsgMediaText &&
       
  5010                      iInsertingType != EMsgMediaXhtml && 
       
  5011                      iSmilModel->IsSupportedMediaType( iInsertingType ) )
       
  5012                     {
       
  5013                     addAsAttachment = EFalse;
       
  5014                     if ( ( ( iInsertingType == EMsgMediaImage || 
       
  5015                              iInsertingType == EMsgMediaVideo ||
       
  5016                              iInsertingType == EMsgMediaAnimation ||
       
  5017                              iInsertingType == EMsgMediaSvg ) &&
       
  5018                            ( ObjectsAvailable() & ( EUniImageFlag | EUniVideoFlag | EUniSvgFlag ) ) )||
       
  5019                          ( iInsertingType == EMsgMediaAudio &&
       
  5020                            ( ObjectsAvailable() & ( EUniAudioFlag | EUniVideoFlag | EUniSvgFlag ) ) ) )
       
  5021                         {
       
  5022                         addSlide = ETrue;
       
  5023                         }
       
  5024                     }
       
  5025                 DoStartInsertL( addSlide, addAsAttachment );
       
  5026                 enabletoolbarext = EFalse ; 
       
  5027                 }
       
  5028             }
       
  5029         }
       
  5030         if(enabletoolbarext)
       
  5031             {
       
  5032             if( iFixedToolbar )
       
  5033                 {
       
  5034                 iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  5035                 }
       
  5036             }
       
  5037     }
       
  5038 
       
  5039 // ---------------------------------------------------------
       
  5040 // CUniEditorAppUi::DoUserInsertVCardL
       
  5041 // ---------------------------------------------------------
       
  5042 //
       
  5043 void CUniEditorAppUi::DoUserInsertVCardL()
       
  5044     {
       
  5045     if ( !iVCardOperation )
       
  5046         {
       
  5047         iVCardOperation = CUniEditorVCardOperation::NewL( *this,
       
  5048                                                           *Document(),
       
  5049                                                           FsSession() );
       
  5050         }
       
  5051     
       
  5052     if ( iFixedToolbar )
       
  5053         {
       
  5054           iFixedToolbar->HideItem( EUniCmdFixedToolbarSend, ETrue, ETrue );
       
  5055           iFixedToolbar->HideItem( EUniCmdFixedToolbarAddRecipient, ETrue, ETrue );        
       
  5056           iFixedToolbar->HideItem( EUniCmdFixedToolbarInsert, ETrue, ETrue );      
       
  5057         }
       
  5058 
       
  5059     iEditorFlags |= EToolbarHidden;
       
  5060     
       
  5061     iVCardOperation->Start();    
       
  5062         
       
  5063     ActivateInputBlockerL( iVCardOperation );
       
  5064     }
       
  5065 
       
  5066 // ---------------------------------------------------------
       
  5067 // CUniEditorAppUi::DoUserInsertSvgL
       
  5068 // ---------------------------------------------------------
       
  5069 //
       
  5070 //void CUniEditorAppUi::DoUserInsertSvgL()
       
  5071 //    {
       
  5072 //    __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  5073 //    
       
  5074 //     if( iFixedToolbar ) 
       
  5075 //        {
       
  5076 //        iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );    
       
  5077 //        }
       
  5078 //    iInsertingType = EMsgMediaSvg;
       
  5079 //    
       
  5080 //    TBool fetchFile( ETrue );
       
  5081 //    TBool enabletoolbarext = ETrue;
       
  5082 //    while ( fetchFile )
       
  5083 //        {
       
  5084 //        fetchFile = EFalse;
       
  5085 //        TBool stat= EFalse;
       
  5086 //        TRAPD(Err,stat = FetchFileL( MsgAttachmentUtils::ESVG ));
       
  5087 //        if (Err == KErrNone && stat)  
       
  5088 //            {
       
  5089 //            if ( SuperDistributionCheckForInsertL() )
       
  5090 //                {
       
  5091 //                if ( CheckMediaInfoForInsertL() )
       
  5092 //                    {
       
  5093 //                    TBool addSlide = EFalse;
       
  5094 //                    if ( ObjectsAvailable() & 
       
  5095 //                        ( EUniAudioFlag | EUniVideoFlag | EUniImageFlag | EUniSvgFlag ) )
       
  5096 //                        {
       
  5097 //                        addSlide = ETrue;
       
  5098 //                        }
       
  5099 //                    
       
  5100 //                    DoStartInsertL( addSlide, EFalse );
       
  5101 //                    enabletoolbarext = EFalse; 
       
  5102 //                    }
       
  5103 //                }
       
  5104 //            else
       
  5105 //                {
       
  5106 //                fetchFile = ETrue;
       
  5107 //                }
       
  5108 //            }
       
  5109 //        }
       
  5110 //        if(enabletoolbarext)
       
  5111 //            {
       
  5112 //                //Enable the insert toolbar 
       
  5113 //            if( iFixedToolbar )
       
  5114 //                {
       
  5115 //                iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  5116 //                }
       
  5117 //            }
       
  5118 //    }
       
  5119     
       
  5120 // ---------------------------------------------------------
       
  5121 // CUniEditorAppUi::InitNaviPaneL
       
  5122 // Draws navipane.
       
  5123 // ---------------------------------------------------------
       
  5124 //
       
  5125 void CUniEditorAppUi::InitNaviPaneL()
       
  5126     {
       
  5127     UNILOGGER_WRITE( "-> CUniEditorAppUi::InitNaviPaneL" );
       
  5128     
       
  5129     UpdateIndicatorIconsL();
       
  5130     
       
  5131     TInt charsLeft = 0;
       
  5132     TInt msgsParts = 0;               
       
  5133     CalculateSMSMsgLen(charsLeft,msgsParts);
       
  5134     iPrevSmsLength = charsLeft;
       
  5135     MsgLengthToNavipaneL( EFalse );            
       
  5136     
       
  5137     UNILOGGER_WRITE( "<- CUniEditorAppUi::InitNaviPaneL" );
       
  5138     }
       
  5139 
       
  5140 // ---------------------------------------------------------
       
  5141 // CUniEditorAppUi::UpdateIndicatorIconsL
       
  5142 //
       
  5143 // ---------------------------------------------------------
       
  5144 //
       
  5145 void CUniEditorAppUi::UpdateIndicatorIconsL()
       
  5146     {
       
  5147     UNILOGGER_WRITE( "-> CUniEditorAppUi::UpdateIndicatorIconsL" );
       
  5148     
       
  5149     TInt priorityHigh;
       
  5150     TInt priorityLow;
       
  5151 
       
  5152     if( Document()->UniState() == EUniSms )
       
  5153         { 
       
  5154         UNILOGGER_WRITE( "-> CUniEditorAppUi::UpdateIndicatorIconsL SMS" );
       
  5155         
       
  5156         // If dealing with SMS -> disable them
       
  5157         priorityHigh = EAknIndicatorStateOff;
       
  5158         priorityLow = EAknIndicatorStateOff;
       
  5159         }
       
  5160     else 
       
  5161         {
       
  5162         TUniSendingSettings settings;
       
  5163         CUniEditorPlugin* plugin = MmsPlugin();
       
  5164 
       
  5165         if ( plugin )
       
  5166             {
       
  5167             plugin->GetSendingSettingsL( settings );
       
  5168             }
       
  5169 
       
  5170         if ( settings.iPriority == TUniSendingSettings::EUniPriorityLow )
       
  5171             {
       
  5172             priorityHigh = EAknIndicatorStateOff;
       
  5173             priorityLow = EAknIndicatorStateOn;
       
  5174             }
       
  5175         else if ( settings.iPriority == TUniSendingSettings::EUniPriorityHigh )
       
  5176             {
       
  5177             priorityHigh = EAknIndicatorStateOn;
       
  5178             priorityLow = EAknIndicatorStateOff;
       
  5179             }
       
  5180         else
       
  5181             {
       
  5182             priorityHigh = EAknIndicatorStateOff;
       
  5183             priorityLow = EAknIndicatorStateOff;
       
  5184             }
       
  5185         }
       
  5186     
       
  5187     if ( iSupportedFeatures & EUniFeaturePriority) 
       
  5188         {
       
  5189         UNILOGGER_WRITE( "-> CUniEditorAppUi::UpdateIndicatorIconsL priority" );
       
  5190         
       
  5191         MAknEditingStateIndicator* editIndi = iAvkonEnv->EditingStateIndicator();
       
  5192         
       
  5193         CAknIndicatorContainer* naviIndi = 
       
  5194             static_cast<CAknIndicatorContainer*>( iNaviDecorator->DecoratedControl() );
       
  5195     
       
  5196         // Update the Edwin indicator pane
       
  5197         if ( editIndi )
       
  5198             {
       
  5199             CAknIndicatorContainer* indiContainer = editIndi->IndicatorContainer();
       
  5200             if ( indiContainer )
       
  5201                 {
       
  5202                 indiContainer->SetIndicatorState( TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityHigh), 
       
  5203                                                   priorityHigh );
       
  5204                 indiContainer->SetIndicatorState( TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityLow), 
       
  5205                                                   priorityLow );
       
  5206                 }
       
  5207             }
       
  5208             
       
  5209         // Update the navi indicator pane
       
  5210         if ( naviIndi )
       
  5211             {
       
  5212             naviIndi->SetIndicatorState( TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityHigh), 
       
  5213                                          priorityHigh );
       
  5214             naviIndi->SetIndicatorState( TUid::Uid(EAknNaviPaneEditorIndicatorMcePriorityLow), 
       
  5215                                          priorityLow );
       
  5216             }
       
  5217 
       
  5218         }
       
  5219     
       
  5220     UNILOGGER_WRITE( "<- CUniEditorAppUi::UpdateIndicatorIconsL" );
       
  5221     }
       
  5222 
       
  5223 // ---------------------------------------------------------
       
  5224 // CUniEditorAppUi::ShowInformationNoteL
       
  5225 // ---------------------------------------------------------
       
  5226 //
       
  5227 void CUniEditorAppUi::ShowInformationNoteL( TInt aResourceID, TBool aWaiting )
       
  5228     {
       
  5229     HBufC* prompt = NULL;
       
  5230     
       
  5231     switch ( aResourceID )
       
  5232         {
       
  5233         case R_UNIEDITOR_INFO_OBJECT_TOO_BIG:
       
  5234         case R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG:
       
  5235             {
       
  5236             // These are not anymore information notes
       
  5237             ShowConfirmableInfoL( aResourceID );
       
  5238             return;
       
  5239             }
       
  5240         default:
       
  5241             {
       
  5242             prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  5243             break;
       
  5244             }
       
  5245         }
       
  5246 
       
  5247     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( aWaiting );
       
  5248     note->ExecuteLD( *prompt );
       
  5249     
       
  5250     CleanupStack::PopAndDestroy( prompt );
       
  5251     }
       
  5252 
       
  5253 // ---------------------------------------------------------
       
  5254 // CUniEditorAppUi::ShowErrorNoteL
       
  5255 // ---------------------------------------------------------
       
  5256 //
       
  5257 void CUniEditorAppUi::ShowErrorNoteL( TInt aResourceID, TBool aWaiting )
       
  5258     {
       
  5259     HBufC* prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  5260     
       
  5261     CAknErrorNote* note = new ( ELeave ) CAknErrorNote( aWaiting );
       
  5262     note->ExecuteLD( *prompt );
       
  5263     
       
  5264     CleanupStack::PopAndDestroy( prompt );
       
  5265     }
       
  5266 
       
  5267 // ---------------------------------------------------------
       
  5268 // CUniEditorAppUi::ShowConfirmationQueryL
       
  5269 // ---------------------------------------------------------
       
  5270 //
       
  5271 TInt CUniEditorAppUi::ShowConfirmationQueryL( TInt aResourceID )
       
  5272     {
       
  5273     HBufC* prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  5274     
       
  5275     TInt retVal = ShowConfirmationQueryL( *prompt );
       
  5276     
       
  5277     CleanupStack::PopAndDestroy( prompt );
       
  5278     
       
  5279     return retVal;
       
  5280     }
       
  5281 
       
  5282 // ---------------------------------------------------------
       
  5283 // CUniEditorAppUi::ShowConfirmationQueryL
       
  5284 // ---------------------------------------------------------
       
  5285 TInt CUniEditorAppUi::ShowConfirmationQueryL( const TDesC& aText ) const
       
  5286     {
       
  5287     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  5288     return dlg->ExecuteLD( R_UNIEDITOR_CONFIRMATION_QUERY, aText );    
       
  5289     }
       
  5290 
       
  5291 // ---------------------------------------------------------
       
  5292 // CUniEditorAppUi::ShowConfirmationNoQuestionQueryL
       
  5293 // ---------------------------------------------------------
       
  5294 TInt CUniEditorAppUi::ShowConfirmationNoQuestionQueryL( const TDesC& aText ) const
       
  5295     {
       
  5296     // Utilize OK and CANCEL softkeys in confirmation query. Required when 
       
  5297     // the query does not include a question.
       
  5298     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  5299     return dlg->ExecuteLD( R_UNIEDITOR_CONFIRMATION_NO_QUESTION_QUERY, aText );    
       
  5300     }
       
  5301 
       
  5302 // ---------------------------------------------------------
       
  5303 // CUniEditorAppUi::ShowConfirmableInfoL
       
  5304 // ---------------------------------------------------------
       
  5305 //
       
  5306 TInt CUniEditorAppUi::ShowConfirmableInfoL( TInt aResourceID )
       
  5307     {
       
  5308     HBufC* prompt = NULL;
       
  5309     
       
  5310     switch ( aResourceID )
       
  5311         {
       
  5312         case R_UNIEDITOR_INFO_OBJECT_TOO_BIG:
       
  5313         case R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG:
       
  5314             {
       
  5315             TInt maxInKilos = ( Document()->MaxMessageSize() + KBytesInKilo - 1 ) / KBytesInKilo;
       
  5316             prompt = StringLoader::LoadLC( aResourceID, maxInKilos, iCoeEnv  );
       
  5317             break;
       
  5318             }
       
  5319         case R_UNIEDITOR_INFO_MAX_SLIDES_ALL:
       
  5320         case R_UNIEDITOR_INFO_MAX_SLIDES_SOME:
       
  5321             {
       
  5322             prompt = StringLoader::LoadLC( aResourceID, Document()->DataModel()->SmilModel().MaxSlideCount(), iCoeEnv  );            
       
  5323             break;
       
  5324             }
       
  5325         default:
       
  5326             {
       
  5327             prompt = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  5328             break;
       
  5329             }
       
  5330         }
       
  5331         
       
  5332     TInt retVal = KErrNone;
       
  5333     switch ( aResourceID )
       
  5334         {
       
  5335         case R_UNIEDITOR_ERROR_RMODE_CANNOT_OPEN:
       
  5336             retVal = ShowConfirmableInfoErrorL( *prompt );
       
  5337             break;        
       
  5338         default:
       
  5339             retVal = ShowConfirmableInfoL( *prompt );
       
  5340         }
       
  5341         
       
  5342     CleanupStack::PopAndDestroy( prompt );
       
  5343     return retVal;
       
  5344     }
       
  5345 
       
  5346 // ---------------------------------------------------------
       
  5347 // CUniEditorAppUi::ShowConfirmableInfoL
       
  5348 // ---------------------------------------------------------
       
  5349 //
       
  5350 TInt CUniEditorAppUi::ShowConfirmableInfoL( const TDesC& aText ) const
       
  5351     {
       
  5352     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  5353     return dlg->ExecuteLD( R_UNIEDITOR_CONFIRMABLE_INFO, aText );
       
  5354     }
       
  5355 
       
  5356 // ---------------------------------------------------------
       
  5357 // CUniEditorAppUi::ShowConfirmableInfoErrorL
       
  5358 // ---------------------------------------------------------
       
  5359 //
       
  5360 TInt CUniEditorAppUi::ShowConfirmableInfoErrorL( const TDesC& aText ) const
       
  5361     {
       
  5362     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  5363     return dlg->ExecuteLD( R_UNIEDITOR_CONFIRMABLE_INFO_ERROR, aText );
       
  5364     }
       
  5365 
       
  5366 // ---------------------------------------------------------
       
  5367 // CUniEditorAppUi::ShowGuidedModeConfirmationQueryL
       
  5368 // ---------------------------------------------------------
       
  5369 //
       
  5370 TInt CUniEditorAppUi::ShowGuidedModeConfirmationQueryL( TInt aResourceID )
       
  5371     {
       
  5372     TInt retVal = EFalse;
       
  5373     if ( iEditorFlags & EShowGuidedConf )
       
  5374         {
       
  5375         TInt waitResId( KErrNotFound );
       
  5376         if ( iWaitDialog )
       
  5377             {
       
  5378             // Remove wait note for the confirmation query duration.
       
  5379             waitResId = iWaitResId;
       
  5380             RemoveWaitNote();
       
  5381             }
       
  5382             
       
  5383         retVal = ShowConfirmationQueryL( aResourceID );
       
  5384         
       
  5385         if ( retVal )
       
  5386             {
       
  5387             iEditorFlags &= ~EShowGuidedConf;
       
  5388             }
       
  5389             
       
  5390         if ( waitResId != KErrNotFound )
       
  5391             {
       
  5392             // Set the wait not again visible after confirmation query is shown
       
  5393             // if it was visible before.
       
  5394             ShowWaitNoteL( waitResId );
       
  5395             }
       
  5396         }
       
  5397     else
       
  5398         {
       
  5399         retVal = ( Document()->CreationMode() != EMmsCreationModeRestricted );
       
  5400         }
       
  5401         
       
  5402     return retVal;
       
  5403     }
       
  5404 
       
  5405 
       
  5406 // ---------------------------------------------------------
       
  5407 // CUniEditorAppUi::ShowWaitNoteL
       
  5408 // ---------------------------------------------------------
       
  5409 //
       
  5410 TBool CUniEditorAppUi::ShowWaitNoteL( TInt aResourceId )
       
  5411     {
       
  5412     TInt waitNoteResource = R_UNIEDITOR_WAIT_NOTE;
       
  5413     TBool waitNoteDelayOff = EFalse;
       
  5414     
       
  5415     if ( aResourceId == R_QTN_MSG_WAIT_SENDING_MMS )
       
  5416         {
       
  5417         waitNoteResource = R_UNIEDITOR_WAIT_NOTE_MMS_ICON;
       
  5418         }
       
  5419     else if ( aResourceId == R_QTN_MSG_WAIT_SENDING_SMS )
       
  5420         {
       
  5421         waitNoteResource = R_UNIEDITOR_WAIT_NOTE_SMS_ICON;
       
  5422         }
       
  5423         
       
  5424     HBufC* string = NULL;
       
  5425 
       
  5426     switch ( aResourceId )
       
  5427         {
       
  5428         case R_QTN_MSG_WAIT_SENDING_MMS:
       
  5429         case R_QTN_MSG_WAIT_SENDING_SMS:
       
  5430         case R_QTN_WAIT_MSG_SAVED_OUTBOX:
       
  5431         case R_QTN_UNI_WAIT_SAVING_MESSAGE_NEW:
       
  5432             {
       
  5433             waitNoteDelayOff = ETrue;
       
  5434             }
       
  5435         case R_QTN_UNI_WAIT_OPENING_EDITOR:
       
  5436         case R_QTN_UNI_WAIT_SAVING_MESSAGE:
       
  5437         case R_QTN_UNI_WAIT_INSERTING:
       
  5438             {
       
  5439             string = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  5440             break;
       
  5441             }
       
  5442         case R_QTN_UNI_WAIT_SLIDE_CHANGE:
       
  5443             {
       
  5444             CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 2 );
       
  5445             CleanupStack::PushL( array );
       
  5446             
       
  5447             array->AppendL( iNextSlide + 1 );
       
  5448             array->AppendL( iSmilModel->SlideCount() );
       
  5449             
       
  5450             string = StringLoader::LoadL( R_QTN_UNI_WAIT_SLIDE_CHANGE,
       
  5451                                           *array,
       
  5452                                           iCoeEnv );
       
  5453             
       
  5454             CleanupStack::PopAndDestroy( array );
       
  5455             CleanupStack::PushL( string );
       
  5456             break;
       
  5457             }
       
  5458         default:
       
  5459             {
       
  5460             break;
       
  5461             }
       
  5462         }
       
  5463 
       
  5464     iWaitDialog = new( ELeave ) CAknWaitDialog( reinterpret_cast<CEikDialog**>( &iWaitDialog ),
       
  5465                                                 waitNoteDelayOff );
       
  5466                                                 
       
  5467     // Coverty Fix, Forward Null, http://ousrv057/cov.cgi?cid=35691                                            
       
  5468     if(string)
       
  5469     	{
       
  5470     	iWaitDialog->SetTextL( *string );
       
  5471     	CleanupStack::PopAndDestroy( string ); 
       
  5472     	}
       
  5473     
       
  5474     iWaitDialog->SetCallback( this );
       
  5475     
       
  5476     iWaitResId = aResourceId;
       
  5477     
       
  5478     iWaitDialog->PrepareLC( waitNoteResource );
       
  5479     return iWaitDialog->RunLD();
       
  5480     }
       
  5481 
       
  5482 // ---------------------------------------------------------
       
  5483 // CUniEditorAppUi::DialogDismissedL
       
  5484 //
       
  5485 // This is a bit tricky. DialogDismissedL is called when wait dialog
       
  5486 // is really dismissed from the screen. Wait dialog is not neccessary
       
  5487 // dismmissed at once the ProcessFinishedL function is called. This 
       
  5488 // is because of some minimum delayes etc. tied to the visibility of
       
  5489 // wait dialog. But this more complex than that as wait dialog can be dismissed
       
  5490 // by end key or escape key from the screen before the operation has really been
       
  5491 // completed or cancelled. This needs to be taken into account here.
       
  5492 // ---------------------------------------------------------
       
  5493 //
       
  5494 void CUniEditorAppUi::DialogDismissedL( TInt dismissed )
       
  5495     {
       
  5496     if ( dismissed == EAknSoftkeyDone )
       
  5497         {
       
  5498         switch ( iWaitResId )
       
  5499             {
       
  5500             case R_QTN_MSG_WAIT_SENDING_MMS:
       
  5501             case R_QTN_MSG_WAIT_SENDING_SMS:
       
  5502             case R_QTN_WAIT_MSG_SAVED_OUTBOX:
       
  5503                 {
       
  5504                 DoSendComplete2ndPhase();
       
  5505                 break;
       
  5506                 }
       
  5507             case R_QTN_UNI_WAIT_SAVING_MESSAGE_NEW:
       
  5508             case R_QTN_UNI_WAIT_SAVING_MESSAGE:
       
  5509                 {
       
  5510                 DoSavingComplete2ndPhase();
       
  5511                 break;
       
  5512                 }
       
  5513             case R_QTN_UNI_WAIT_OPENING_EDITOR:
       
  5514             case R_QTN_UNI_WAIT_INSERTING:
       
  5515                 {
       
  5516                 break;
       
  5517                 }
       
  5518             case R_QTN_UNI_WAIT_SLIDE_CHANGE:
       
  5519                 {
       
  5520                 break;
       
  5521                 }
       
  5522             default:
       
  5523                 {
       
  5524                 break;
       
  5525                 }
       
  5526             }
       
  5527         }
       
  5528     else if ( dismissed == EEikBidCancel )
       
  5529         {
       
  5530         iWaitDialog = NULL;
       
  5531         }
       
  5532     }
       
  5533 
       
  5534 // ---------------------------------------------------------
       
  5535 // CUniEditorAppUi::RemoveWaitNote
       
  5536 // ---------------------------------------------------------
       
  5537 //
       
  5538 void CUniEditorAppUi::RemoveWaitNote()
       
  5539     {
       
  5540     delete iWaitDialog;
       
  5541     iWaitDialog = NULL;
       
  5542     iWaitResId = -1;
       
  5543     }
       
  5544 
       
  5545 // ---------------------------------------------------------
       
  5546 // CUniEditorAppUi::SetAddressSize
       
  5547 // ---------------------------------------------------------
       
  5548 //
       
  5549 void CUniEditorAppUi::SetAddressSize()
       
  5550     {
       
  5551     if ( !iView )
       
  5552         {
       
  5553         return;
       
  5554         }
       
  5555     
       
  5556     TInt tempBytes( 0 );
       
  5557     TInt entryCnt( 0 );
       
  5558     TInt sizeInBytes( 0 );
       
  5559     for ( TInt i = CUniEditorHeader::EHeaderAddressTo; 
       
  5560           i <= CUniEditorHeader::EHeaderAddressBcc; 
       
  5561           i++ )
       
  5562         {    
       
  5563         if ( iHeader->AddressControl( static_cast<CUniEditorHeader::THeaderFields> (i) ) )
       
  5564             {
       
  5565             iHeader->AddressControl( 
       
  5566                 static_cast<CUniEditorHeader::THeaderFields> (i) )->GetSizeOfAddresses( entryCnt, 
       
  5567                                                                                         tempBytes );
       
  5568             sizeInBytes += tempBytes;
       
  5569             }
       
  5570         }
       
  5571         
       
  5572     Document()->SetAddressSize( sizeInBytes );
       
  5573     }
       
  5574 
       
  5575 // ---------------------------------------------------------
       
  5576 // CUniEditorAppUi::SetSubjectSize
       
  5577 // ---------------------------------------------------------
       
  5578 //
       
  5579 void CUniEditorAppUi::SetSubjectSize()
       
  5580     {
       
  5581     if ( !iView )
       
  5582         {
       
  5583         return;
       
  5584         }
       
  5585         
       
  5586     CMsgExpandableControl* subj = iHeader->SubjectControl();
       
  5587     
       
  5588     if ( subj )
       
  5589         {
       
  5590         TPtrC subject = subj->TextContent().Read( 0, subj->TextContent().DocumentLength() );
       
  5591         Document()->SetSubjectSize( CUniDataUtils::UTF8Size( subject ) );
       
  5592         } 
       
  5593         else
       
  5594         {
       
  5595         Document()->SetSubjectSize( 0 );
       
  5596         }
       
  5597     }
       
  5598 
       
  5599 // ---------------------------------------------------------
       
  5600 // CUniEditorAppUi::RemoveObjectL
       
  5601 // 
       
  5602 // Intended to be called from Objectsview. Updates screen
       
  5603 // when object removed in Objectsview. Objectsview has already
       
  5604 // delete atta from msgstore if needed.
       
  5605 // ---------------------------------------------------------
       
  5606 //
       
  5607 void CUniEditorAppUi::RemoveObjectL( TUniRegion aRegion, 
       
  5608                                      TUniLayout aLayout )
       
  5609     {
       
  5610     if ( iOriginalSlide != -1 && 
       
  5611          Document()->CurrentSlide() != iOriginalSlide )
       
  5612         {
       
  5613         //nothing to do if the modified slide is not
       
  5614         //visible
       
  5615         return;
       
  5616         }
       
  5617 
       
  5618     TBool removeCtrlFocused( EFalse ); 
       
  5619     CMsgBaseControl* ctrl = NULL;
       
  5620     TInt ctrlType = EMsgComponentIdNull;
       
  5621     
       
  5622     switch ( aRegion )
       
  5623         {
       
  5624         case EUniRegionImage:
       
  5625             {
       
  5626             ctrl = iView->RemoveControlL( EMsgComponentIdImage );
       
  5627             if( !ctrl )
       
  5628                 { // Also video clip is located in image region so if no image -> check video control
       
  5629                 ctrl = iView->RemoveControlL( EMsgComponentIdVideo );
       
  5630                 }
       
  5631             if ( !ctrl )
       
  5632                 { // Also SVG presentation is located in image region so if no image -> check SVG control
       
  5633                 ctrl = iView->RemoveControlL( EMsgComponentIdSvg );
       
  5634                 }
       
  5635             
       
  5636             if( ctrl )
       
  5637                 {
       
  5638                 removeCtrlFocused = ctrl->IsFocused();
       
  5639                 ctrlType = ctrl->ControlId();
       
  5640                 }
       
  5641                 
       
  5642             delete ctrl;
       
  5643             break;
       
  5644             }
       
  5645         case EUniRegionAudio:
       
  5646             {
       
  5647             ctrl = iView->RemoveControlL( EMsgComponentIdAudio );
       
  5648             
       
  5649             if( ctrl )
       
  5650                 {
       
  5651                 removeCtrlFocused = ctrl->IsFocused();
       
  5652                 ctrlType = ctrl->ControlId();
       
  5653                 }
       
  5654                 
       
  5655             delete ctrl;
       
  5656             break;
       
  5657             }
       
  5658         case EUniRegionText:
       
  5659             {
       
  5660             // Clear control content
       
  5661             ctrl = BodyCtrl();
       
  5662             
       
  5663             if ( ctrl )
       
  5664                 {
       
  5665                 ctrl->Reset();
       
  5666                 ctrlType = ctrl->ControlId();
       
  5667                 }
       
  5668                 
       
  5669             // Move control position if needed. Move focus & cursor position
       
  5670             CMsgImageControl* imgCtrl = ImageCtrl();
       
  5671 
       
  5672             if ( imgCtrl && ( aLayout == EUniTextFirst ) )
       
  5673                 {
       
  5674                 // Move text control after the image. Cursor loc in text should be ok.
       
  5675                 CMsgBaseControl* bodyCtrl = iView->RemoveControlL( EMsgComponentIdBody );
       
  5676                 iView->AddControlL( bodyCtrl, EMsgComponentIdBody, EMsgAppendControl, EMsgBody );
       
  5677                 }
       
  5678             break;
       
  5679             }
       
  5680         case EUniRegionUnresolved:
       
  5681         default:
       
  5682             {
       
  5683             // Should never be here!
       
  5684             __ASSERT_DEBUG( EFalse, Panic( EUniIllegalComponentType ) );
       
  5685             break;
       
  5686             }
       
  5687         }   
       
  5688         
       
  5689     if ( ( aRegion == EUniRegionImage || 
       
  5690            aRegion == EUniRegionAudio ) )
       
  5691         {
       
  5692         // Change focus to the beginning that scroll bar is updated
       
  5693         // and text editor area removes extra lines
       
  5694         if ( ToCtrl() )
       
  5695             {
       
  5696             iView->SetFocus( EMsgComponentIdTo );
       
  5697             }
       
  5698         else if ( iView->ControlById( EMsgComponentIdAudio ) )
       
  5699             {
       
  5700             //Audio is always first
       
  5701             iView->SetFocus( EMsgComponentIdAudio );
       
  5702             }
       
  5703         else if ( iSmilModel->Layout() == EUniImageFirst &&  
       
  5704                   ImageCtrl() )
       
  5705             {
       
  5706             // should not be need to update focus anymore
       
  5707             iView->SetFocus( EMsgComponentIdImage );
       
  5708             }    
       
  5709         else 
       
  5710             {
       
  5711             // should not be need to update focus anymore
       
  5712             iView->SetFocus( EMsgComponentIdBody );
       
  5713             }
       
  5714 
       
  5715         CMsgBaseControl* focusedControl = iView->FocusedControl();
       
  5716         if ( focusedControl )
       
  5717             {
       
  5718             if ( removeCtrlFocused &&  
       
  5719                  focusedControl->ControlId() != EMsgComponentIdImage &&  
       
  5720                  ctrlType == EMsgComponentIdAudio &&  
       
  5721                  iSmilModel->Layout() == EUniImageFirst &&  
       
  5722                  ImageCtrl() )
       
  5723                 {
       
  5724                 iView->SetFocus( EMsgComponentIdImage );
       
  5725                 }
       
  5726             else  if ( focusedControl->ControlId() != EMsgComponentIdBody )
       
  5727                 {
       
  5728                 iView->SetFocus( EMsgComponentIdBody );            
       
  5729                 }
       
  5730 
       
  5731             if ( ctrlType == EMsgComponentIdAudio &&  
       
  5732                  focusedControl->ControlId() == EMsgComponentIdImage )
       
  5733                 {
       
  5734                 // Set focus here so that imagecontrol will draw navipane if focused.
       
  5735                 iView->FocusedControl()->SetFocus( ETrue, EDrawNow );
       
  5736                 }
       
  5737             }
       
  5738         }
       
  5739     }
       
  5740 
       
  5741 // ---------------------------------------------------------
       
  5742 // CUniEditorAppUi::DoUserChangeOrderL
       
  5743 // ---------------------------------------------------------
       
  5744 //
       
  5745 void CUniEditorAppUi::DoUserChangeOrderL( TUniLayout aLayout )
       
  5746     {
       
  5747     // Both image and video are located in image region so there's only need to check it
       
  5748     CUniObject* img = iSmilModel->GetObject( Document()->CurrentSlide(), EUniRegionImage );
       
  5749 
       
  5750     if ( img )
       
  5751         {
       
  5752         CAknLocalScreenClearer::NewLC( EFalse );
       
  5753         
       
  5754         ChangeOrderL( aLayout );
       
  5755         
       
  5756         CleanupStack::PopAndDestroy(); //clearer
       
  5757         }
       
  5758 
       
  5759     iSmilModel->SetLayoutL( aLayout );
       
  5760     Document()->SetBodyModified( ETrue );
       
  5761     if ( !img )
       
  5762         {
       
  5763         TInt noteId = ( aLayout == EUniTextFirst ) ? R_UNIEDITOR_CONF_TEXTS_FIRST : 
       
  5764                                                      R_UNIEDITOR_CONF_TEXTS_SECOND;
       
  5765         ShowInformationNoteL( noteId, EFalse );
       
  5766         }
       
  5767     }
       
  5768 
       
  5769 // ---------------------------------------------------------
       
  5770 // CUniEditorAppUi::ChangeOrderL
       
  5771 // 
       
  5772 // Intended to be called from Objectsview. Updates screen
       
  5773 // when object order changed. SmilModel should already 
       
  5774 // contain correct layout. Also called by AppUi
       
  5775 // ---------------------------------------------------------
       
  5776 //
       
  5777 void CUniEditorAppUi::ChangeOrderL( TUniLayout aLayout )
       
  5778     {
       
  5779     TInt focusedId = EMsgComponentIdNull;
       
  5780     if ( iView && iView->FocusedControl() )
       
  5781         {
       
  5782         focusedId = iView->FocusedControl()->ControlId();
       
  5783         }
       
  5784         
       
  5785     TInt index = EMsgAppendControl;
       
  5786     // Coverty fix: Forward NULL, http://ousrv057/cov.cgi?cid=35695
       
  5787     if(iView)
       
  5788     	{
       
  5789     CMsgBaseControl* ctrl = iView->RemoveControlL( EMsgComponentIdBody ); // Does not leave
       
  5790 
       
  5791     if ( ctrl ) 
       
  5792         {
       
  5793         switch( aLayout )
       
  5794             {
       
  5795             case EUniImageFirst:
       
  5796                 {
       
  5797                 index = EMsgAppendControl;
       
  5798                 break;
       
  5799                 }
       
  5800             case EUniTextFirst:
       
  5801                 {
       
  5802                 if ( iView->ControlById ( EMsgComponentIdAudio ) )
       
  5803                     {
       
  5804                     index = EMsgFirstControl + 1;
       
  5805                     }
       
  5806                 else
       
  5807                     {
       
  5808                     index = EMsgFirstControl;
       
  5809                     }
       
  5810                 break;
       
  5811                 }
       
  5812             case EUniUndefinedLayout:
       
  5813             default:
       
  5814                 {
       
  5815                 __ASSERT_DEBUG( EFalse, Panic( EUniIllegalLayout ) );
       
  5816                 break;
       
  5817                 }
       
  5818             }
       
  5819             
       
  5820         iView->AddControlL( ctrl, EMsgComponentIdBody, index, EMsgBody );
       
  5821         }
       
  5822       }
       
  5823     
       
  5824     if ( !( iHeader->IsAddressControl( focusedId ) ||  
       
  5825             focusedId == EMsgComponentIdSubject ||
       
  5826             focusedId == EMsgComponentIdAttachment ) &&
       
  5827          iEditorFlags & ELaunchSuccessful )
       
  5828         {
       
  5829         SetFocusToBodyBeginningL();
       
  5830         }
       
  5831     //else -> keep focus as is
       
  5832     }
       
  5833 
       
  5834 // ---------------------------------------------------------
       
  5835 // CUniEditorAppUi::ReleaseImage
       
  5836 // 
       
  5837 // If there is image control, sets image lock according 
       
  5838 // to parameter. Otherwise does nothing.
       
  5839 // ---------------------------------------------------------
       
  5840 //
       
  5841 void CUniEditorAppUi::ReleaseImage( TBool aRelease )
       
  5842     {
       
  5843     CMsgImageControl* ctrl = ImageCtrl();
       
  5844     
       
  5845     if ( ctrl && aRelease )
       
  5846         {
       
  5847         ctrl->SetImageFileClosed();
       
  5848         }
       
  5849     }
       
  5850 
       
  5851 // ---------------------------------------------------------
       
  5852 // CUniEditorAppUi::MessageSizeInBytes
       
  5853 // ---------------------------------------------------------
       
  5854 //
       
  5855 TInt CUniEditorAppUi::MessageSizeInBytes()
       
  5856     {
       
  5857     TBool useEstimate = EFalse;
       
  5858     
       
  5859     if ( Document()->DataModel()->SmilType() == EMmsSmil &&
       
  5860         ( Document()->BodyModified() || 
       
  5861           iEditorFlags & EUseEstimatedSmilSize ) )
       
  5862         {
       
  5863         useEstimate = ETrue;
       
  5864         iEditorFlags |= EUseEstimatedSmilSize;
       
  5865         }
       
  5866 
       
  5867     TInt size = Document()->MessageSize( useEstimate );
       
  5868     CEikRichTextEditor* bodyEditor = BodyCtrlEditor();
       
  5869     
       
  5870     if ( bodyEditor )
       
  5871         {
       
  5872         TInt limit = ( TUint( size ) >= Document()->MaxMessageSize() ) ? 
       
  5873             BodyCtrl()->TextContent().DocumentLength() : 
       
  5874             KMaxTInt;
       
  5875         bodyEditor->SetTextLimit( limit );
       
  5876         }
       
  5877     return size;
       
  5878     }
       
  5879 
       
  5880 // ---------------------------------------------------------
       
  5881 // CUniEditorAppUi::DoSelectionKeyL
       
  5882 // ---------------------------------------------------------
       
  5883 //
       
  5884 void CUniEditorAppUi::DoSelectionKeyL()
       
  5885     {
       
  5886     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  5887 
       
  5888     if ( ctrl )
       
  5889         {
       
  5890         switch ( ctrl->ControlId() )
       
  5891             {
       
  5892             case EMsgComponentIdTo:
       
  5893             case EMsgComponentIdCc:
       
  5894             case EMsgComponentIdBcc:
       
  5895                 {
       
  5896                 if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  5897                     {
       
  5898                     break;
       
  5899                     }
       
  5900                     
       
  5901                 // Check is there any recipients in address ctrl
       
  5902                 TBool modified = EFalse;
       
  5903                 if ( iHeader->HasRecipients() )
       
  5904                     {
       
  5905                     // Recipients found. Verify addresses.
       
  5906                     if ( !VerifyAddressesL( modified ) )
       
  5907                         {
       
  5908                         // Illegal address found.
       
  5909                         modified = ETrue;
       
  5910                         }
       
  5911                     }
       
  5912                     
       
  5913                 if ( !modified )//else
       
  5914                     {
       
  5915                     // Nothing changed on the UI. Open PhoneBook.
       
  5916                     DoUserAddRecipientL();
       
  5917                     }
       
  5918                     
       
  5919                 break;
       
  5920                 }
       
  5921             case EMsgComponentIdAttachment:
       
  5922                 {
       
  5923                 DoUserObjectsViewL( ETrue );                
       
  5924                 break;
       
  5925                 }
       
  5926             case EMsgComponentIdImage:
       
  5927                 {
       
  5928                 if ( Document()->DataModel()->SmilType() == E3GPPSmil )
       
  5929                     {
       
  5930                     // focus is on "no-edit" SMIL icon
       
  5931                     PlayPresentationL();
       
  5932                     break;
       
  5933                     } 
       
  5934                 if( Document()->DataModel()->SmilType() == ETemplateSmil )
       
  5935                     {
       
  5936                     break;
       
  5937                     }
       
  5938                 // Otherwise fallthrough
       
  5939                 }
       
  5940             case EMsgComponentIdVideo:
       
  5941             case EMsgComponentIdAudio:
       
  5942             case EMsgComponentIdSvg:
       
  5943                 {
       
  5944                 PlayFocusedItemL();
       
  5945                 break;
       
  5946                 }
       
  5947             case EMsgComponentIdBody:
       
  5948                 {
       
  5949                 MenuBar()->SetMenuTitleResourceId( R_UNIEDITOR_CONTEXT_MENUBAR );
       
  5950                 MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  5951                 
       
  5952                 TRAPD( err, MenuBar()->TryDisplayMenuBarL() ); 
       
  5953                 
       
  5954                 MenuBar()->SetMenuTitleResourceId( R_UNIEDITOR_MENUBAR );
       
  5955                 MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  5956                 
       
  5957                 User::LeaveIfError( err );                
       
  5958                 break;
       
  5959                 }
       
  5960             case EMsgComponentIdSubject:
       
  5961             default:
       
  5962                 {
       
  5963                 break;
       
  5964                 }
       
  5965             }
       
  5966         }
       
  5967     }
       
  5968 
       
  5969 // ---------------------------------------------------------
       
  5970 // CUniEditorAppUi::SetErrorResource
       
  5971 //
       
  5972 // This is a function where error id priorities
       
  5973 // can be defined.
       
  5974 // ---------------------------------------------------------
       
  5975 //
       
  5976 void CUniEditorAppUi::SetErrorResource( TInt& aStoreId, TInt aNewId )
       
  5977     {
       
  5978     if ( ErrorPriority( aNewId ) >= ErrorPriority( aStoreId ) )
       
  5979         {
       
  5980         if ( ( aStoreId == R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT ||  
       
  5981                aStoreId == R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT ) &&
       
  5982              ( aNewId == R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT ||  
       
  5983                aNewId == R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT ||  
       
  5984                aNewId == R_UNIEDITOR_INFO_UNSUPPORTED_OBJECTS ||  
       
  5985                aNewId == R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECTS ) )
       
  5986             {
       
  5987             // Set plural
       
  5988             aStoreId = R_UNIEDITOR_INFO_UNSUPPORTED_OBJECTS;
       
  5989             if ( Document()->CreationModeUserChangeable() &&
       
  5990                  !Document()->CreationMode() )
       
  5991                 {
       
  5992                 aStoreId = R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECTS;
       
  5993                 }
       
  5994             }
       
  5995         else if ( aStoreId == R_UNIEDITOR_QUEST_GUIDED_OBJ &&
       
  5996                   ( aNewId == R_UNIEDITOR_QUEST_GUIDED_OBJ ||
       
  5997                     aNewId == R_UNIEDITOR_QUEST_GUIDED_OBJS ) )
       
  5998             {
       
  5999             // Set plural
       
  6000             aStoreId = R_UNIEDITOR_QUEST_GUIDED_OBJS;
       
  6001             }
       
  6002         else if ( aStoreId == R_UNIEDITOR_QUEST_GUIDED_INC_OBJ &&
       
  6003                   ( aNewId == R_UNIEDITOR_QUEST_GUIDED_INC_OBJ ||
       
  6004                     aNewId == R_UNIEDITOR_QUEST_GUIDED_INC_OBJS ) )
       
  6005             {
       
  6006             // Set plural
       
  6007             aStoreId = R_UNIEDITOR_QUEST_GUIDED_INC_OBJS;
       
  6008             }
       
  6009         else if ( aStoreId != -1 && 
       
  6010                   aStoreId != aNewId )
       
  6011             {
       
  6012             aStoreId = aNewId;
       
  6013             }
       
  6014         else
       
  6015             {
       
  6016             aStoreId = aNewId;
       
  6017             }
       
  6018         }
       
  6019     }
       
  6020     
       
  6021 // ---------------------------------------------------------
       
  6022 // CUniEditorAppUi::ErrorPriority
       
  6023 //
       
  6024 // This is a function where error id priorities
       
  6025 // can be defined.
       
  6026 // ---------------------------------------------------------
       
  6027 //
       
  6028 TInt CUniEditorAppUi::ErrorPriority( TInt aErrorId )
       
  6029     {
       
  6030     TInt priority = 0;
       
  6031     
       
  6032     switch ( aErrorId )
       
  6033         {
       
  6034         case R_UNIEDITOR_INFO_SEND_FORBID_1:
       
  6035             {
       
  6036             priority++; // Fallthrough
       
  6037             }
       
  6038         case R_UNIEDITOR_INFO_OBJECT_TOO_BIG:
       
  6039         case R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG:
       
  6040             {
       
  6041             priority++; // Fallthrough
       
  6042             }
       
  6043         case R_UNIEDITOR_INFO_MAX_SLIDES_SOME:
       
  6044         case R_UNIEDITOR_INFO_MAX_SLIDES_ALL:
       
  6045             {
       
  6046             priority++; // Fallthrough
       
  6047             }
       
  6048         case R_UNIEDITOR_QUEST_GUIDED_PRESENTATION:
       
  6049         case R_UNIEDITOR_ERROR_CANNOT_OPEN:
       
  6050         case R_UNIEDITOR_ERROR_RMODE_CANNOT_OPEN:
       
  6051             {
       
  6052             priority++; // Fallthrough
       
  6053             }
       
  6054         case R_UNIEDITOR_QUEST_GUIDED_OBJ:
       
  6055         case R_UNIEDITOR_QUEST_GUIDED_OBJS:
       
  6056             {
       
  6057             priority++; // Fallthrough
       
  6058             }
       
  6059         case R_UNIEDITOR_QUEST_GUIDED_INC_OBJ:
       
  6060         case R_UNIEDITOR_QUEST_GUIDED_INC_OBJS:
       
  6061             {
       
  6062             priority++; // Fallthrough
       
  6063             }
       
  6064         case R_UNIEDITOR_INFO_SCALING_FAILED:
       
  6065         case R_UNIEDITOR_INFO_RMODE_SCALING_FAILED:
       
  6066             {
       
  6067             priority++; // Fallthrough
       
  6068             }
       
  6069         case R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT:
       
  6070         case R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT:
       
  6071         case R_UNIEDITOR_INFO_UNSUPPORTED_OBJECTS:
       
  6072         case R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECTS:
       
  6073         case R_UNIEDITOR_INFO_SOME_NOT_SUPPORTED:
       
  6074         case R_UNIEDITOR_INFO_RMODE_SOME_NOT_SUPPORTED:
       
  6075             {
       
  6076             priority++;
       
  6077             break;
       
  6078             }
       
  6079         default:
       
  6080             {
       
  6081             break;
       
  6082             }
       
  6083         }
       
  6084         
       
  6085     return priority;
       
  6086     }
       
  6087     
       
  6088 // ---------------------------------------------------------
       
  6089 // CUniEditorAppUi::IsPhoneOfflineL
       
  6090 // ---------------------------------------------------------
       
  6091 //
       
  6092 TBool CUniEditorAppUi::IsPhoneOfflineL() const
       
  6093     {
       
  6094     if ( iSupportedFeatures & EUniFeatureOffline )
       
  6095         {    
       
  6096         return MsvUiServiceUtilitiesInternal::IsPhoneOfflineL();
       
  6097         }
       
  6098     else
       
  6099         {
       
  6100         return EFalse;
       
  6101         }       
       
  6102     }
       
  6103 
       
  6104 // ---------------------------------------------------------
       
  6105 // CUniEditorAppUi::LaunchHelpL
       
  6106 // ---------------------------------------------------------
       
  6107 //
       
  6108 void CUniEditorAppUi::LaunchHelpL()
       
  6109     {
       
  6110     // activate Help application
       
  6111     if ( iSupportedFeatures & EUniFeatureHelp )
       
  6112         {
       
  6113         CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL();
       
  6114         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
  6115         }
       
  6116     }
       
  6117 
       
  6118 // ---------------------------------------------------------
       
  6119 // CUniEditorAppUi::HelpContextL
       
  6120 // ---------------------------------------------------------
       
  6121 //
       
  6122 CArrayFix<TCoeHelpContext>* CUniEditorAppUi::HelpContextL() const
       
  6123     {
       
  6124     CArrayFix<TCoeHelpContext>* array = new( ELeave ) CArrayFixFlat<TCoeHelpContext>( 1 );
       
  6125     CleanupStack::PushL( array ); 
       
  6126   
       
  6127     array->AppendL(TCoeHelpContext(KUniEditorAppId, KUNIFIED_HLP_EDITOR()));
       
  6128     
       
  6129     CleanupStack::Pop( array );
       
  6130     return array;
       
  6131     }
       
  6132 
       
  6133 
       
  6134 // ---------------------------------------------------------
       
  6135 // CUniEditorAppUi::PlayPresentationL
       
  6136 // ---------------------------------------------------------
       
  6137 //
       
  6138 void CUniEditorAppUi::PlayPresentationL()
       
  6139     {
       
  6140     RFile smilFile = Document()->DataModel()->SmilList().GetSmilFileByIndexL( 0 );
       
  6141     if ( !iParser )
       
  6142         {        
       
  6143         iParser = CMDXMLParser::NewL( this );
       
  6144         }
       
  6145     
       
  6146     iParser->ParseFile( smilFile );
       
  6147     // Continues in ParseFileCompleteL
       
  6148     
       
  6149     ActivateInputBlockerL( iParser );
       
  6150     }
       
  6151 
       
  6152 // ---------------------------------------------------------
       
  6153 // CUniEditorAppUi::ParseFileCompleteL
       
  6154 // ---------------------------------------------------------
       
  6155 //
       
  6156 void CUniEditorAppUi::ParseFileCompleteL()
       
  6157     {
       
  6158     // Detach the dom from parser
       
  6159     if ( iDom )
       
  6160         {
       
  6161         delete iDom;
       
  6162         iDom = NULL;
       
  6163         }
       
  6164         
       
  6165     iDom = iParser->DetachXMLDoc();
       
  6166 
       
  6167     // Delete inputBlocker
       
  6168     DeactivateInputBlocker();
       
  6169 
       
  6170     // Start playing the presentation    
       
  6171     DoCompletePlayPresentationL();
       
  6172     }
       
  6173 
       
  6174 // ---------------------------------------------------------
       
  6175 // CUniEditorAppUi::PlayPresentationL
       
  6176 //
       
  6177 // First go through every object in the presentation to find out
       
  6178 // whether audio should be enabled. After this launch SMIL player.
       
  6179 // ---------------------------------------------------------
       
  6180 //
       
  6181 void CUniEditorAppUi::DoCompletePlayPresentationL()
       
  6182     {
       
  6183     TBool audio = EFalse;
       
  6184     CUniObjectList& objects = Document()->DataModel()->ObjectList();
       
  6185     TInt count = objects.Count();
       
  6186     while ( count-- )
       
  6187         {
       
  6188         CUniObject* object = objects.GetByIndex( count );
       
  6189         TMsgMediaType media = object->MediaType();
       
  6190         
       
  6191         if ( media == EMsgMediaAudio )
       
  6192             {
       
  6193             audio = ETrue;
       
  6194             break;
       
  6195             }
       
  6196         else if ( media == EMsgMediaVideo )
       
  6197             {
       
  6198             CMsgVideoInfo* info = static_cast<CMsgVideoInfo*>( object->MediaInfo() );
       
  6199             if ( !info ||
       
  6200                  info->IsAudio() )
       
  6201                 {
       
  6202                 audio = ETrue;
       
  6203                 break;
       
  6204                 }
       
  6205             }
       
  6206         }
       
  6207         
       
  6208     CSmilPlayerDialog* smilPlayer = CSmilPlayerDialog::NewL( iDom,
       
  6209                                                              &objects,
       
  6210                                                              KNullDesC(),
       
  6211                                                              ETrue,
       
  6212                                                              audio );
       
  6213     
       
  6214     if ( iFixedToolbar )
       
  6215         {
       
  6216         iFixedToolbar->SetToolbarVisibility(EFalse, EFalse);
       
  6217         }
       
  6218     
       
  6219     iEditorFlags |= EToolbarHidden;
       
  6220     CleanupStack::PushL( TCleanupItem( EnableFixedToolbar, this ) );
       
  6221     
       
  6222     SetKeyEventFlags(0);
       
  6223     
       
  6224     CleanupStack::PushL( TCleanupItem( DisableSendKey, this ) );
       
  6225     smilPlayer->ExecuteLD();
       
  6226     
       
  6227     CleanupStack::PopAndDestroy(2);// DisableSendKey,EnableFixedToolbar
       
  6228     
       
  6229     if ( iFixedToolbar )
       
  6230         {
       
  6231         iFixedToolbar->SetToolbarVisibility(ETrue, EFalse);
       
  6232         }
       
  6233     // re-calculate all pos and dimensions of layout's widgets, after
       
  6234     // status pane is set back to usual and fixed-toolbar is made visible.
       
  6235     HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
       
  6236     }
       
  6237 
       
  6238 // ---------------------------------------------------------
       
  6239 // CUniEditorAppUi::RemoveTemplateL
       
  6240 // 
       
  6241 // First confirms the operation from user. After user has 
       
  6242 // confirmed the operation remove all the objects and SMILs
       
  6243 // from the message. Enable toolbar and set modified flag on. 
       
  6244 // Then replace the presentation icon with body text control and add
       
  6245 // single slide is no slides exists. Finally check the message type and
       
  6246 // update statuspane according to current message type.
       
  6247 // ---------------------------------------------------------
       
  6248 //
       
  6249 void CUniEditorAppUi::RemoveTemplateL()
       
  6250     {
       
  6251     if ( ShowConfirmationQueryL( R_UNIEDITOR_QUEST_REMOVE_TEMPLATE ) )
       
  6252         {
       
  6253         CUniObjectList& objectList = Document()->DataModel()->ObjectList();
       
  6254         objectList.RemoveAllObjectsL();
       
  6255         
       
  6256         CMsvStore* editStore = Document()->Mtm().Entry().EditStoreL();
       
  6257         CleanupStack::PushL( editStore );            
       
  6258         Document()->DataModel()->SmilList().RemoveSmilL( *editStore );
       
  6259         editStore->CommitL();
       
  6260         CleanupStack::PopAndDestroy( editStore );
       
  6261 
       
  6262         Document()->DataModel()->SetSmilType( EMmsSmil );
       
  6263         
       
  6264         UpdateToolbarL();
       
  6265         
       
  6266         Document()->SetBodyModified( ETrue );
       
  6267 
       
  6268         // Delete icon
       
  6269         iView->DeleteControlL( EMsgComponentIdImage );  // Does not leave
       
  6270         
       
  6271         // Add body
       
  6272         CMsgBodyControl* bodyC = CMsgBodyControl::NewL(iView);
       
  6273         CleanupStack::PushL( bodyC );
       
  6274         
       
  6275         iView->AddControlL( bodyC, EMsgComponentIdBody, EMsgAppendControl, EMsgBody );
       
  6276         
       
  6277         CleanupStack::Pop( bodyC );
       
  6278         
       
  6279         iView->SetFocus( EMsgComponentIdBody );
       
  6280 
       
  6281         if ( !iSmilModel->SlideCount() )
       
  6282             {
       
  6283             iSmilModel->AddSlideL();
       
  6284             }
       
  6285             
       
  6286         CheckBodyForMessageTypeL();
       
  6287         InitNaviPaneL();
       
  6288         SetTitleL();
       
  6289         }
       
  6290     }
       
  6291 
       
  6292 // ---------------------------------------------------------
       
  6293 // CUniEditorAppUi::SetFocusToBodyBeginningL
       
  6294 // ---------------------------------------------------------
       
  6295 //
       
  6296 void CUniEditorAppUi::SetFocusToBodyBeginningL()
       
  6297     {
       
  6298     if ( ToCtrl() )
       
  6299         {
       
  6300         // Set focus always first to "To" in order to 
       
  6301         // make "To" field visible
       
  6302         iView->SetFocus( EMsgComponentIdTo );
       
  6303         }
       
  6304         
       
  6305     if ( BodyCtrl() )
       
  6306         {
       
  6307         BodyCtrl()->SetCursorPosL( 0 );
       
  6308         }
       
  6309         
       
  6310     TBool focusId = EMsgComponentIdBody;
       
  6311     
       
  6312     if ( iView->ControlById( EMsgComponentIdAudio ) )
       
  6313         {
       
  6314         //Audio is always first
       
  6315         focusId = EMsgComponentIdAudio;
       
  6316         } 
       
  6317     // When this is called from DoUserChangerOrderL the new layout is not
       
  6318     // yet updated in SmilModel -> that's why the if's below seem to be mixed
       
  6319     else if ( iSmilModel->Layout() == EUniTextFirst &&
       
  6320               iView->ControlById( EMsgComponentIdImage ) )
       
  6321         {
       
  6322         focusId = EMsgComponentIdImage;
       
  6323         }
       
  6324     else if ( iSmilModel->Layout() == EUniTextFirst &&
       
  6325               iView->ControlById( EMsgComponentIdVideo ) )
       
  6326         {
       
  6327         focusId = EMsgComponentIdVideo;
       
  6328         }
       
  6329     //else -> EMsgComponentIdBody
       
  6330 
       
  6331     iView->SetFocus( focusId );
       
  6332     }
       
  6333 
       
  6334 // ---------------------------------------------------------
       
  6335 // CUniEditorAppUi::DoInsertCompleteL
       
  6336 // ---------------------------------------------------------
       
  6337 //
       
  6338 void CUniEditorAppUi::DoInsertCompleteL( TUniEditorOperationEvent aEvent )
       
  6339     {
       
  6340     // focus and cursor positions handling
       
  6341     TBool insertedAsAttachment = EFalse;
       
  6342     
       
  6343     if ( aEvent == EUniEditorOperationComplete )
       
  6344         {  
       
  6345         if ( iInsertOperation->IsAddedAsAttachment() )
       
  6346             {
       
  6347             Document()->SetHeaderModified( ETrue );
       
  6348             insertedAsAttachment = ETrue;
       
  6349             }
       
  6350         else
       
  6351             {
       
  6352            SetFocusToBodyBeginningL();
       
  6353             
       
  6354             switch ( iInsertingType )
       
  6355                 {
       
  6356                 case EMsgMediaImage:
       
  6357                     {
       
  6358                     // Set the focus to Text field so that user will be able to
       
  6359 					// Type the text when image height is too big
       
  6360                     CMsgBodyControl* bodyCtrl = BodyCtrl();
       
  6361                     if ( bodyCtrl )
       
  6362                         {
       
  6363 						// Put the cursor at the end of Text.
       
  6364                         bodyCtrl->SetCursorPosL( bodyCtrl->Editor().TextLength() );
       
  6365                         iView->SetFocus( EMsgComponentIdBody );                           
       
  6366                         }
       
  6367                     break;
       
  6368                     }
       
  6369                 case EMsgMediaAudio:
       
  6370                     {
       
  6371                     // Set focus always first to the audio control
       
  6372                     iView->SetFocus( EMsgComponentIdAudio );
       
  6373                     break;
       
  6374                     }
       
  6375                 case EMsgMediaVideo:
       
  6376                     {
       
  6377                     // Set focus always first to the audio control
       
  6378                     iView->SetFocus( EMsgComponentIdVideo );
       
  6379                     break;
       
  6380                     }
       
  6381                 case EMsgMediaSvg:
       
  6382                     {
       
  6383                     // Set focus always first to the audio control
       
  6384                     iView->SetFocus( EMsgComponentIdSvg );
       
  6385                     break;
       
  6386                     }
       
  6387                 default:
       
  6388                     {
       
  6389                     // nothing to do
       
  6390                     break;
       
  6391                     }
       
  6392                 } 
       
  6393             }
       
  6394             
       
  6395         iInsertingType = EMsgMediaUnknown;
       
  6396         }
       
  6397         
       
  6398     TUniState oldState = Document()->UniState();
       
  6399     DoInsertComplete2ndPhaseL();
       
  6400     
       
  6401     // Lit up display backlight in case it has gone off due to a long operation
       
  6402     User::ResetInactivityTime();
       
  6403     
       
  6404     if( insertedAsAttachment && 
       
  6405         ( oldState == Document()->UniState() ||  
       
  6406           !iPopupNote ) )
       
  6407         {   
       
  6408         // The message type did not change or change popup note is not shown
       
  6409         // so show the attachment added note
       
  6410         ShowInformationNoteL( R_UNIEDITOR_QTN_UNIFIED_ATTACHMENT_ADDED, EFalse );
       
  6411         }
       
  6412     
       
  6413     }
       
  6414 
       
  6415 // ---------------------------------------------------------
       
  6416 // CUniEditorAppUi::DoInsertComplete2ndPhaseL
       
  6417 // ---------------------------------------------------------
       
  6418 //
       
  6419 void CUniEditorAppUi::DoInsertComplete2ndPhaseL()
       
  6420     {
       
  6421     RemoveWaitNote();
       
  6422     
       
  6423     delete iScreenClearer;
       
  6424     iScreenClearer = NULL;
       
  6425     
       
  6426     CheckBodyForMessageTypeL();
       
  6427     SetTitleL();
       
  6428     InitNaviPaneL();
       
  6429     ShowInsertErrorsL();
       
  6430     }
       
  6431 
       
  6432 // ---------------------------------------------------------
       
  6433 // CUniEditorAppUi::ShowInsertErrorsL
       
  6434 // ---------------------------------------------------------
       
  6435 //
       
  6436 void CUniEditorAppUi::ShowInsertErrorsL()
       
  6437     {
       
  6438     TInt errRes( KErrNotFound );
       
  6439     
       
  6440     CArrayFixFlat<TInt>* errors = iInsertOperation->GetErrors();
       
  6441     
       
  6442     for ( TInt i = 0; i < errors->Count(); i++ )
       
  6443         {
       
  6444         switch ( errors->At( i ) )
       
  6445             {
       
  6446             case EUniProcessImgOutOfMemory:
       
  6447             case EUniProcessImgOutOfDisk:
       
  6448             case EUniProcessImgNotFound:
       
  6449             case EUniProcessImgNonConformant:
       
  6450             case EUniProcessImgScalingFailed:
       
  6451             case EUniProcessImgCompressFailed:
       
  6452             case EUniProcessImgCouldNotScale:
       
  6453                 {
       
  6454                 if( Document()->CreationModeUserChangeable() &&
       
  6455                     Document()->CreationMode() == EMmsCreationModeRestricted )
       
  6456                     {
       
  6457                     SetErrorResource( errRes, R_UNIEDITOR_INFO_RMODE_SCALING_FAILED );
       
  6458                     }
       
  6459                 else
       
  6460                     {
       
  6461                     SetErrorResource( errRes, R_UNIEDITOR_INFO_SCALING_FAILED );
       
  6462                     }
       
  6463                 break;
       
  6464                 }
       
  6465             case EUniInsertTooBig:
       
  6466                 {
       
  6467                 SetErrorResource( errRes, R_UNIEDITOR_INFO_OBJECT_TOO_BIG );
       
  6468                 break;
       
  6469                 }
       
  6470             case EUniProcessImgUserAbort:
       
  6471             case EUniInsertUserGuidedAbort:
       
  6472                 {
       
  6473                 return;
       
  6474                 }
       
  6475             case EUniInsertNotSupported:
       
  6476             case EUniInsertSlideChangeFailed:
       
  6477                 {
       
  6478                 if( Document()->CreationModeUserChangeable() &&
       
  6479                     Document()->CreationMode() == EMmsCreationModeRestricted )
       
  6480                     {
       
  6481                     SetErrorResource( errRes, R_UNIEDITOR_INFO_RMODE_UNSUPPORTED_OBJECT );
       
  6482                     }
       
  6483                 else
       
  6484                     {
       
  6485                     SetErrorResource( errRes, R_UNIEDITOR_INFO_UNSUPPORTED_OBJECT );
       
  6486                     }
       
  6487                 break;
       
  6488                 }
       
  6489             default:
       
  6490                 {
       
  6491                 break;
       
  6492                 }
       
  6493             }
       
  6494         }
       
  6495         
       
  6496     if ( errRes != KErrNotFound )
       
  6497         {
       
  6498         ShowInformationNoteL( errRes, EFalse );
       
  6499         }
       
  6500     }
       
  6501 
       
  6502 // ---------------------------------------------------------
       
  6503 // CUniEditorAppUi::EditorOperationEvent
       
  6504 //
       
  6505 // This is marked as non-leaving function since this is leaving with
       
  6506 // KLeaveExit only (also Exit() is not leaving even if it is leaving).
       
  6507 // ---------------------------------------------------------
       
  6508 //
       
  6509 void CUniEditorAppUi::EditorOperationEvent( TUniEditorOperationType aOperation,
       
  6510                                             TUniEditorOperationEvent aEvent )
       
  6511     {
       
  6512     if ( iEditorFlags & EEditorExiting )
       
  6513         {
       
  6514         // Do not handle any event if we are exiting from editor.
       
  6515 		// rest values.
       
  6516         iOptimizedFlow = EFalse;
       
  6517         iSingleJpegImageProcessing = EFalse;
       
  6518         return;
       
  6519         }
       
  6520     
       
  6521     if ( aEvent == EUniEditorOperationComplete ||  
       
  6522          aEvent == EUniEditorOperationError ||
       
  6523          aEvent == EUniEditorOperationCancel )
       
  6524         {
       
  6525 		// set iOptimizedFlow
       
  6526         if( aOperation == EUniEditorOperationLaunch)
       
  6527             {
       
  6528             if(iLaunchOperation)
       
  6529                 {
       
  6530                 iOptimizedFlow = iLaunchOperation->IsOptimizedFlagSet();
       
  6531                 }
       
  6532             }
       
  6533 		// sendui+jepg-> this required after image processing 
       
  6534         if(!iOptimizedFlow)
       
  6535             {
       
  6536             DeactivateInputBlocker();
       
  6537             iEditorFlags &= ~EMsgEditInProgress;   
       
  6538             }
       
  6539         if ( aEvent == EUniEditorOperationCancel &&
       
  6540              aOperation != EUniEditorOperationSend )
       
  6541             {
       
  6542             // Operation by operation should be considered what is proper action 
       
  6543             // in Cancel situation. Send operation handles the removing of wait note
       
  6544             // correctly. When this is done with all operations operation checking
       
  6545             // can be removed.
       
  6546             EndActiveWait();
       
  6547             RemoveWaitNote();
       
  6548         
       
  6549             delete iScreenClearer;
       
  6550             iScreenClearer = NULL;
       
  6551             }    
       
  6552         }
       
  6553         
       
  6554     TRAPD( error, DoEditorOperationEventL( aOperation, aEvent ) );
       
  6555     if ( error != KErrNone )
       
  6556         {
       
  6557 		// error handling
       
  6558         if(iOptimizedFlow)
       
  6559             {
       
  6560             DeactivateInputBlocker();
       
  6561             iEditorFlags &= ~EMsgEditInProgress;   
       
  6562             }
       
  6563         iOptimizedFlow = EFalse;
       
  6564         iSingleJpegImageProcessing = EFalse;
       
  6565         
       
  6566         // Handle operation handling error.
       
  6567         if ( error == KLeaveExit )
       
  6568             {
       
  6569             // Leaving with KLeaveExit does not make function leavable. See Exit()
       
  6570             User::Leave( error );
       
  6571             }
       
  6572         else 
       
  6573             {
       
  6574             iEikonEnv->HandleError( error );
       
  6575             
       
  6576             if ( aOperation == EUniEditorOperationLaunch )
       
  6577                 {
       
  6578                 Exit( EAknSoftkeyClose );
       
  6579                 }
       
  6580             }
       
  6581         }
       
  6582     //sendui+jepg-> after first call to finallizelauch,rest
       
  6583 	// it, so that next call will cover the code finallizelaunch
       
  6584 	//as happened for other launch cases.
       
  6585     iOptimizedFlow = EFalse;
       
  6586     }
       
  6587 
       
  6588 // ---------------------------------------------------------
       
  6589 // CUniEditorAppUi::DoEditorOperationEventL
       
  6590 // ---------------------------------------------------------
       
  6591 //
       
  6592 void CUniEditorAppUi::DoEditorOperationEventL( TUniEditorOperationType aOperation,
       
  6593                                                TUniEditorOperationEvent aEvent )
       
  6594     {
       
  6595     switch ( aOperation )
       
  6596         {
       
  6597         case EUniEditorOperationChangeSlide:
       
  6598             {
       
  6599             DoChangeSlideCompleteL();
       
  6600             break;
       
  6601             }
       
  6602         case EUniEditorOperationInsert:
       
  6603             {
       
  6604             if ( aEvent == EUniEditorOperationProcessing )
       
  6605                 {
       
  6606                 if ( iEditorFlags & EInsertAddsSlide )
       
  6607                     {
       
  6608                     iScreenClearer = CAknLocalScreenClearer::NewLC( EFalse );
       
  6609                     CleanupStack::Pop();
       
  6610                     }
       
  6611                 }
       
  6612             else
       
  6613                 {
       
  6614                 DoInsertCompleteL( aEvent );
       
  6615                 }
       
  6616             break;
       
  6617             }
       
  6618         case EUniEditorOperationLaunch:
       
  6619             {
       
  6620             if ( aEvent == EUniEditorOperationComplete )
       
  6621                 {
       
  6622                 DoLaunchCompleteL();
       
  6623                 }
       
  6624             else
       
  6625                 {
       
  6626                 DoDelayedExit( 0 );
       
  6627                 iEditorFlags |= EEditorClosing;
       
  6628                 }
       
  6629             break;
       
  6630             }
       
  6631         case EUniEditorOperationSave:
       
  6632             {
       
  6633             DoSaveCompleteL();
       
  6634             break;
       
  6635             }
       
  6636         case EUniEditorOperationSend:
       
  6637             {
       
  6638             DoSendCompleteL();
       
  6639             break;
       
  6640             }
       
  6641         case EUniEditorOperationVCard:
       
  6642             {
       
  6643             DoVCardCompleteL();
       
  6644             break;
       
  6645             }
       
  6646         case EUniEditorOperationPreview:
       
  6647             {
       
  6648             // Expecting 'processing' but in case of error, other states are aacceptable, too.
       
  6649             RemoveWaitNote();
       
  6650             break;
       
  6651             }
       
  6652         default:
       
  6653             {
       
  6654             // nothing to do
       
  6655             break;
       
  6656             }
       
  6657         }
       
  6658     }
       
  6659     
       
  6660 // ---------------------------------------------------------
       
  6661 // CUniEditorAppUi::EditorOperationQuery
       
  6662 // ---------------------------------------------------------
       
  6663 //
       
  6664 TBool CUniEditorAppUi::EditorOperationQuery( TUniEditorOperationType aOperation,
       
  6665                                              TUniEditorOperationQuery aQuery )
       
  6666     {
       
  6667     TBool ret( EFalse );
       
  6668     TRAP_IGNORE( ret = DoEditorOperationQueryL( aOperation, aQuery ) );
       
  6669     return ret;
       
  6670     }
       
  6671 
       
  6672 // ---------------------------------------------------------
       
  6673 // CUniEditorAppUi::DoEditorOperationQueryL
       
  6674 // ---------------------------------------------------------
       
  6675 //
       
  6676 TBool CUniEditorAppUi::DoEditorOperationQueryL( TUniEditorOperationType /*aOperation*/,
       
  6677                                                 TUniEditorOperationQuery aQuery )
       
  6678     {
       
  6679     switch ( aQuery )
       
  6680         {
       
  6681         case EMEOQueryGuidedInsertLarge:
       
  6682             {
       
  6683             return ShowGuidedModeConfirmationQueryL( R_UNIEDITOR_QUEST_INSERT_LARGE );
       
  6684             }
       
  6685         case EMEOQueryGuidedObject:
       
  6686             {
       
  6687             return ShowGuidedModeConfirmationQueryL( R_UNIEDITOR_QUEST_GUIDED_OBJ );
       
  6688             }
       
  6689         default:
       
  6690             {
       
  6691             break;
       
  6692             }
       
  6693         }
       
  6694     return ETrue;
       
  6695     }
       
  6696 
       
  6697 // ---------------------------------------------------------
       
  6698 // CUniEditorAppUi::DoChangeSlideCompleteL
       
  6699 // ---------------------------------------------------------
       
  6700 //
       
  6701 void CUniEditorAppUi::DoChangeSlideCompleteL()
       
  6702     {
       
  6703     EndActiveWait();
       
  6704     RemoveWaitNote();
       
  6705     
       
  6706     if ( iChangeSlideOperation->GetErrors()->Count() )
       
  6707         {
       
  6708         delete iScreenClearer;
       
  6709         iScreenClearer = NULL;
       
  6710         
       
  6711         ExitAndSaveL();
       
  6712         }
       
  6713     else
       
  6714         {
       
  6715         DoSetFocusL();
       
  6716         
       
  6717         delete iScreenClearer;
       
  6718         iScreenClearer = NULL;
       
  6719         
       
  6720         CheckBodyForMessageTypeL();
       
  6721         SetTitleL();
       
  6722         InitNaviPaneL();
       
  6723         }
       
  6724     }
       
  6725 
       
  6726 // ---------------------------------------------------------
       
  6727 // CUniEditorAppUi::DoLaunchCompleteL
       
  6728 //
       
  6729 // First removes wait note from the screen. After this launch 
       
  6730 // relating note processing is done and if lanch should be aborted
       
  6731 // immediatelly performs delayed exit (i.e. starts idle timer
       
  6732 // to call Exit() function on it's callback). Rest of the launching
       
  6733 // related processing is done at the FinalizeLaunch function.
       
  6734 // ---------------------------------------------------------
       
  6735 //
       
  6736 void CUniEditorAppUi::DoLaunchCompleteL()
       
  6737     {
       
  6738 	//sendui+jepg -> this required after image processing 
       
  6739     if(!iOptimizedFlow)
       
  6740         {
       
  6741         // Does no harm to call this even if no wait note is set.
       
  6742         RemoveWaitNote();        
       
  6743         }
       
  6744 		
       
  6745     TBool shutDown( EFalse );
       
  6746 	// sendui+jepg-> this required after image processing 
       
  6747     if(!iOptimizedFlow)
       
  6748 		{
       
  6749         ShowLaunchNotesL( shutDown );
       
  6750 		}
       
  6751     
       
  6752     if ( shutDown )
       
  6753         {
       
  6754         // Avoid direct Exit(). It causes actually leaving with -1003. 
       
  6755         // If non-conformant object is sent from sendui and user is not
       
  6756         // willing to allow free moded Exit() was called previously and
       
  6757         // caused CMmsEditorLaunchOperation to leave, because this function
       
  6758         // is called inside RunL()
       
  6759         // give time to show notes
       
  6760         DoDelayedExit( KDelayedExitShort );
       
  6761         iEditorFlags |= EEditorClosing;
       
  6762         }
       
  6763     else
       
  6764         {
       
  6765         FinalizeLaunchL();
       
  6766      // check is Unieditor is launched from conversation by Addachemnt option 
       
  6767         if( Document()->IsLaunchFromCvAttachment())
       
  6768             {
       
  6769             iFixedToolbar->ToolbarExtension()->SetShown(ETrue);
       
  6770             }
       
  6771         }
       
  6772     }
       
  6773 
       
  6774 // ---------------------------------------------------------
       
  6775 // CUniEditorAppUi::DoDelayedExit
       
  6776 // ---------------------------------------------------------
       
  6777 //
       
  6778 void CUniEditorAppUi::DoDelayedExit( TInt aDelayTime )
       
  6779     {
       
  6780     iIdle->Cancel();
       
  6781     iIdle->Start( aDelayTime,
       
  6782                   aDelayTime, 
       
  6783                   TCallBack( DelayedExitL, this ));
       
  6784     }
       
  6785 
       
  6786 // ---------------------------------------------------------
       
  6787 // CUniEditorAppUi::DelayedExit
       
  6788 // ---------------------------------------------------------
       
  6789 //
       
  6790 TInt CUniEditorAppUi::DelayedExitL( TAny* aThis )
       
  6791     {
       
  6792     UNILOGGER_WRITE( "-> CUniEditorAppUi::DelayedExitL" );
       
  6793     
       
  6794     CUniEditorAppUi* editor = static_cast<CUniEditorAppUi*>( aThis );
       
  6795     editor->ExitAndSaveL();
       
  6796     
       
  6797     UNILOGGER_WRITE( "<- CUniEditorAppUi::DelayedExitL" );
       
  6798     
       
  6799     return KErrNone;
       
  6800     }
       
  6801 
       
  6802 // ---------------------------------------------------------
       
  6803 // CUniEditorAppUi::DoSaveCompleteL
       
  6804 // ---------------------------------------------------------
       
  6805 //
       
  6806 void CUniEditorAppUi::DoSaveCompleteL()
       
  6807     {
       
  6808     UNILOGGER_WRITE( "-> CUniEditorAppUi::DoSaveCompleteL" );
       
  6809 
       
  6810     if ( iWaitDialog )
       
  6811         {
       
  6812         // Processing continued at DialogDismissedL when wait note
       
  6813         // has dismissed itself.
       
  6814         iWaitDialog->ProcessFinishedL();
       
  6815         }    
       
  6816     else
       
  6817         {
       
  6818         DoSavingComplete2ndPhase();
       
  6819         }
       
  6820     
       
  6821     UNILOGGER_WRITE( "<- CUniEditorAppUi::DoSaveCompleteL" );
       
  6822     }
       
  6823     
       
  6824 // ---------------------------------------------------------
       
  6825 // CUniEditorAppUi::DoSavingComplete2ndPhase
       
  6826 // ---------------------------------------------------------
       
  6827 //
       
  6828 void CUniEditorAppUi::DoSavingComplete2ndPhase()
       
  6829     {
       
  6830     //TODO: Update prev save type!
       
  6831     CMDXMLDocument* dom = iSaveOperation->DetachDom();
       
  6832     if ( dom )
       
  6833         {
       
  6834         Document()->DataModel()->SetDom( dom );
       
  6835         }
       
  6836 
       
  6837     EndActiveWait();
       
  6838     
       
  6839     if ( iEditorFlags & EEditorClosing )
       
  6840         {
       
  6841         if ( Document()->UniState() == EUniMms )
       
  6842             {              
       
  6843             CUniEditorPlugin* mmsPlugin = Document()->MmsPlugin();  
       
  6844             TRAP_IGNORE(mmsPlugin->ConvertToL( Document()->Mtm().Entry().EntryId()));
       
  6845             }
       
  6846         else if ( Document()->UniState() == EUniSms )
       
  6847             {
       
  6848             CUniEditorPlugin* smsPlugin = Document()->SmsPlugin();  
       
  6849             TRAP_IGNORE(smsPlugin->ConvertToL( Document()->Mtm().Entry().EntryId()));            
       
  6850             }
       
  6851             
       
  6852         DoDelayedExit( 0 );
       
  6853         }
       
  6854     }
       
  6855 
       
  6856 // ---------------------------------------------------------
       
  6857 // CUniEditorAppUi::DoSendCompleteL
       
  6858 //
       
  6859 // Sending operation completed. If wait note is still available
       
  6860 // (i.e. it is not cancelled from the screen by some external event)
       
  6861 // we call ProcessFinishedL so that prosessing is finished. Otherwise 
       
  6862 // we have to complete the operation by ourself.
       
  6863 // ---------------------------------------------------------
       
  6864 //
       
  6865 void CUniEditorAppUi::DoSendCompleteL()
       
  6866     {
       
  6867     UNILOGGER_WRITE( "-> CUniEditorAppUi::DoSendCompleteL" );
       
  6868 
       
  6869     if ( iWaitDialog )
       
  6870         {
       
  6871         // Processing continued at DialogDismissedL when wait note
       
  6872         // has dismissed itself.
       
  6873         iWaitDialog->ProcessFinishedL();
       
  6874         }    
       
  6875     else
       
  6876         {
       
  6877         DoSendComplete2ndPhase();
       
  6878         }
       
  6879     
       
  6880     UNILOGGER_WRITE( "<- CUniEditorAppUi::DoSendCompleteL" );
       
  6881     }
       
  6882 
       
  6883 // ---------------------------------------------------------
       
  6884 // CUniEditorAppUi::DoSendComplete2ndPhase
       
  6885 //
       
  6886 // Performs the real send operation completing code.
       
  6887 // ---------------------------------------------------------
       
  6888 //
       
  6889 void CUniEditorAppUi::DoSendComplete2ndPhase()
       
  6890     {
       
  6891     UNILOGGER_WRITE( "-> CUniEditorAppUi::DoSendComplete2ndPhase" );
       
  6892 
       
  6893     // Get errors from send operation
       
  6894     CArrayFixFlat<TInt>* errors = iSendOperation->GetErrors();
       
  6895     
       
  6896     if ( errors->Count() > 0 )
       
  6897         {
       
  6898         iEikonEnv->HandleError( errors->At( 0 ) );
       
  6899         iEditorFlags &= ~EEditorClosing;
       
  6900         return;
       
  6901         }
       
  6902         
       
  6903     DoDelayedExit( 0 );
       
  6904     
       
  6905     UNILOGGER_WRITE( "<- CUniEditorAppUi::DoSendComplete2ndPhase" );
       
  6906     }
       
  6907 
       
  6908 // ---------------------------------------------------------
       
  6909 // CUniEditorAppUi::DoVCardCompleteL
       
  6910 // ---------------------------------------------------------
       
  6911 //
       
  6912 void CUniEditorAppUi::DoVCardCompleteL()
       
  6913     {
       
  6914     if ( iFixedToolbar )
       
  6915         {
       
  6916           iFixedToolbar->HideItem( EUniCmdFixedToolbarSend, EFalse, ETrue );
       
  6917           iFixedToolbar->HideItem( EUniCmdFixedToolbarAddRecipient, EFalse, ETrue );        
       
  6918           iFixedToolbar->HideItem( EUniCmdFixedToolbarInsert, EFalse, ETrue );    
       
  6919         }
       
  6920     
       
  6921     iEditorFlags &= ~EToolbarHidden;
       
  6922     
       
  6923     TInt addedVCardCount = iVCardOperation->AddedVCardCount();
       
  6924     TBool oldState = Document()->UniState();
       
  6925 
       
  6926     // Update navipane and type of message        
       
  6927     CheckBodyForMessageTypeL();
       
  6928     MsgLengthToNavipaneL();
       
  6929     if (AknLayoutUtils::PenEnabled() )
       
  6930         {
       
  6931            iPeninputServer.UpdateAppInfo( KNullDesC, EAppIndicatorMsg );    
       
  6932         }
       
  6933     
       
  6934     if ( addedVCardCount > 0 )
       
  6935         {
       
  6936         Document()->SetHeaderModified( ETrue );
       
  6937         }
       
  6938     
       
  6939     if ( !( oldState != Document()->UniState() && iPopupNote ) )
       
  6940         {
       
  6941         // Popup note is not shown, so we can show error or attachment(s)
       
  6942         // added note. When popup note is not shown, it doesn't matter
       
  6943         // whether message type was changed or not.
       
  6944         CArrayFixFlat<TInt>* errors = iVCardOperation->GetErrors();
       
  6945         
       
  6946         if ( errors->Count() )
       
  6947             {
       
  6948             for ( TInt i = 0; i < errors->Count(); i++ )
       
  6949                 {
       
  6950                 if ( errors->At( i ) == EUniInsertTooBig )
       
  6951                     {
       
  6952                     // Tell user that one or more vCards could not be inserted.
       
  6953                     addedVCardCount > 0 ?
       
  6954                         ShowInformationNoteL( R_UNIEDITOR_INFO_OBJECT_SEND_AS_TOO_BIG, EFalse ) :
       
  6955                         ShowInformationNoteL( R_UNIEDITOR_INFO_OBJECT_TOO_BIG, EFalse );
       
  6956                     break;
       
  6957                     }
       
  6958                 }
       
  6959             }
       
  6960         else if ( addedVCardCount > 0 )
       
  6961             {
       
  6962             // Show attachment(s) added note if no errors.
       
  6963             addedVCardCount == 1 ? 
       
  6964                 ShowInformationNoteL( R_UNIEDITOR_QTN_UNIFIED_ATTACHMENT_ADDED, EFalse ) :
       
  6965                 ShowInformationNoteL( R_UNIEDITOR_QTN_UNIFIED_ATTACHMENTS_ADDED, EFalse );
       
  6966             }
       
  6967         }
       
  6968     }
       
  6969 
       
  6970 // ---------------------------------------------------------
       
  6971 // CUniEditorAppUi::BeginActiveWait
       
  6972 // ---------------------------------------------------------
       
  6973 //
       
  6974 void CUniEditorAppUi::BeginActiveWait( CUniEditorOperation* aOperation )
       
  6975     {
       
  6976     if( iWait.IsStarted() )
       
  6977         {
       
  6978         // If there is data in recipient and body text fields,
       
  6979         // presentation is created and read key is pressed in smil editor,
       
  6980         // smil editor dialog is dismissed and change slide operation starts
       
  6981         // in NewTemplateL() ( any kind error code is not supplied).
       
  6982         // After that Exit comes to editor HandleCommandL, which would cause start of
       
  6983         // save operation. Change slide operation must be terminated first.
       
  6984         if ( iActiveOperation )
       
  6985             {
       
  6986             iActiveOperation->Cancel();
       
  6987             }
       
  6988         return;
       
  6989         }
       
  6990         
       
  6991     iActiveOperation = aOperation;
       
  6992     iWait.Start();
       
  6993     }
       
  6994 
       
  6995 // ---------------------------------------------------------
       
  6996 // CUniEditorAppUi::EndActiveWait
       
  6997 // ---------------------------------------------------------
       
  6998 //
       
  6999 void CUniEditorAppUi::EndActiveWait()
       
  7000     {
       
  7001     if( !iWait.IsStarted() )
       
  7002         {
       
  7003         return;
       
  7004         }
       
  7005         
       
  7006     iWait.AsyncStop();
       
  7007     iActiveOperation = NULL;
       
  7008     }
       
  7009 
       
  7010 // ---------------------------------------------------------
       
  7011 // CUniEditorAppUi::ObjectsAvailable
       
  7012 // ---------------------------------------------------------
       
  7013 //
       
  7014 TUint32 CUniEditorAppUi::ObjectsAvailable()
       
  7015     {
       
  7016     TUint32 objects = EUniNoneFlag;
       
  7017     if ( BodyCtrl() && BodyCtrl()->TextContent().DocumentLength() )
       
  7018         {
       
  7019         // This flag is not currently used for anything.
       
  7020         objects |= EUniTextFlag;
       
  7021         }
       
  7022     if ( iView->ControlById( EMsgComponentIdAudio ) )
       
  7023         {
       
  7024         objects |= EUniAudioFlag;
       
  7025         }
       
  7026     if ( iView->ControlById( EMsgComponentIdImage ) )
       
  7027         {
       
  7028         objects |= EUniImageFlag;
       
  7029         }
       
  7030     if ( iView->ControlById( EMsgComponentIdVideo ) )
       
  7031         {
       
  7032         objects |= EUniVideoFlag;
       
  7033         }
       
  7034     if ( iView->ControlById( EMsgComponentIdSvg ) )
       
  7035         {
       
  7036         objects |= EUniSvgFlag;
       
  7037         }
       
  7038     return objects;
       
  7039     }
       
  7040 
       
  7041 
       
  7042 // ---------------------------------------------------------
       
  7043 // CUniEditorAppUi::DoUserAddHeadersL
       
  7044 // ---------------------------------------------------------
       
  7045 //
       
  7046 void CUniEditorAppUi::DoUserAddHeadersL()
       
  7047     {
       
  7048     if ( !iHeader )
       
  7049         {
       
  7050         return;
       
  7051         }
       
  7052     
       
  7053     TInt headersVariation = iHeader->AddHeadersVariation();
       
  7054     TInt headersConfig = 0;
       
  7055     
       
  7056     // Check which fields are visible:
       
  7057     
       
  7058     // TInt headersConfig = iHeader->AddHeadersConfigL();
       
  7059     if ( iHeader->SubjectControl() )
       
  7060         {
       
  7061         headersConfig |= EUniFeatureSubject;
       
  7062         }
       
  7063     if ( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressCc ) )
       
  7064         {
       
  7065         headersConfig |= EUniFeatureCc;
       
  7066         }
       
  7067     if ( iHeader->AddressControl( CUniBaseHeader::EHeaderAddressBcc ) )
       
  7068         {
       
  7069         headersConfig |= EUniFeatureBcc;
       
  7070         }
       
  7071 
       
  7072     if ( IsHardcodedSms() && Document()->EmailOverSmsSupported() )
       
  7073         { 
       
  7074         // Locked SMS and EmailOverSms -> enable only subject field
       
  7075         if ( headersVariation & EUniFeatureSubjectConfigurable )
       
  7076             {
       
  7077             headersVariation = EUniFeatureSubject;
       
  7078             headersVariation |= EUniFeatureSubjectConfigurable;
       
  7079             }
       
  7080         else
       
  7081             {
       
  7082             // Should not happen as add headers command should be invisible at this case.
       
  7083             headersVariation = EUniFeatureSubject;
       
  7084             }
       
  7085         }
       
  7086 
       
  7087     // Contains indexes of additional header flags in
       
  7088     // headersIn array; KErrNotFound if not visible in the UI
       
  7089     // index: 0 = CC, 1 = BCC, 3 = subject
       
  7090     CArrayFixFlat<TInt>* indexes = new( ELeave ) CArrayFixFlat<TInt>( 3 );
       
  7091     CleanupStack::PushL( indexes );
       
  7092     
       
  7093     CListBoxView::CSelectionIndexArray* headersOut = 
       
  7094                                     new( ELeave ) CArrayFixFlat<TInt>( 3 );
       
  7095     CleanupStack::PushL( headersOut );
       
  7096 
       
  7097     CListBoxView::CSelectionIndexArray* headersIn = 
       
  7098                                     new( ELeave ) CArrayFixFlat<TInt>( 3 );
       
  7099     CleanupStack::PushL( headersIn );
       
  7100     
       
  7101     CUniEditorAddHeaderDialog* dlg = new( ELeave ) CUniEditorAddHeaderDialog( headersOut );
       
  7102     
       
  7103     // Pushes the dialog into stack
       
  7104     dlg->PrepareLC( R_UNIEDITOR_ADD_HEADERS_LIST_QUERY );
       
  7105 
       
  7106     // Order matters. See Pop below
       
  7107     CDesCArrayFlat* headerStringsIn = new( ELeave ) CDesCArrayFlat( 3 );
       
  7108     CleanupStack::PushL( headerStringsIn );
       
  7109     
       
  7110     TInt index( 0 );
       
  7111     for ( TInt i = 0; i < 3; i++ )
       
  7112         {
       
  7113         TInt flag( EUniFeatureCc );
       
  7114         TInt resource( R_UNIEDITOR_QTN_MSG_HEADERS_CC );
       
  7115         
       
  7116         if ( i == 1 )
       
  7117             {
       
  7118             flag = EUniFeatureBcc;
       
  7119             resource = R_UNIEDITOR_QTN_MSG_HEADERS_BCC;
       
  7120             }
       
  7121         else if ( i == 2 )
       
  7122             {
       
  7123             flag = EUniFeatureSubjectConfigurable;
       
  7124             resource = R_UNIEDITOR_QTN_MSG_HEADERS_SUBJECT;
       
  7125             }
       
  7126         
       
  7127         if ( headersVariation & flag )
       
  7128             {
       
  7129             HBufC* fieldTemp = StringLoader::LoadLC( resource, iCoeEnv );
       
  7130             
       
  7131             // We need to add the "1\"
       
  7132             HBufC* fieldBuf = HBufC::NewMaxLC( fieldTemp->Des().Length() + 2 );
       
  7133 
       
  7134             TPtr field = fieldBuf->Des();
       
  7135             field.Copy( KItemStart );
       
  7136             field.Append( fieldTemp->Des() );
       
  7137             
       
  7138             // FieldBuf will be owned by headersIn 
       
  7139             headerStringsIn->AppendL( field );
       
  7140 
       
  7141             CleanupStack::PopAndDestroy( 2, fieldTemp );  //  + fieldBuf  
       
  7142             
       
  7143             if ( flag == EUniFeatureSubjectConfigurable )
       
  7144                 {
       
  7145                 flag = EUniFeatureSubject;
       
  7146                 }
       
  7147             
       
  7148             if ( headersConfig & flag )
       
  7149                 {   
       
  7150                 // Mark it selected
       
  7151                 dlg->ListBox()->View()->SelectItemL( index );
       
  7152                 headersIn->AppendL( ETrue );
       
  7153                 }
       
  7154             else
       
  7155                 {
       
  7156                 headersIn->AppendL( EFalse );
       
  7157                 }
       
  7158                 
       
  7159             indexes->AppendL( index );
       
  7160             index++;
       
  7161             }
       
  7162         else
       
  7163             {
       
  7164             indexes->AppendL( KErrNotFound );
       
  7165             }
       
  7166         }
       
  7167         
       
  7168     dlg->SetItemTextArray( headerStringsIn );
       
  7169     dlg->SetOwnershipType( ELbmOwnsItemArray );
       
  7170     CleanupStack::Pop( headerStringsIn );
       
  7171 
       
  7172     if ( dlg->RunLD() )
       
  7173         {
       
  7174         TInt newSelectionHeaders( 0 ); 
       
  7175         TInt removeHeaders( 0 ); 
       
  7176         TInt removeHeadersWithWarning( 0 ); 
       
  7177         TInt addHeaders( 0 ); 
       
  7178 
       
  7179         TInt countItems( headersOut->Count() );
       
  7180 
       
  7181         // Check if the out selection is the same as in selection
       
  7182         TBool theSame = ETrue;
       
  7183 
       
  7184         index = 0;
       
  7185         for ( TInt i = 0; i < 3; i++ )
       
  7186             {
       
  7187             if ( indexes->At( i ) != KErrNotFound )
       
  7188                 { 
       
  7189                 // i was one of the choices available in the dialog
       
  7190                 if ( headersIn->At( index ) )
       
  7191                     { 
       
  7192                     // It was originally selected
       
  7193                     if ( countItems < 1 )
       
  7194                         {
       
  7195                         theSame = EFalse;
       
  7196                         }
       
  7197                         
       
  7198                     TBool foundIt = EFalse;
       
  7199                     for ( TInt j = 0; j < countItems; j++ )
       
  7200                         { 
       
  7201                         // Lets see the current selection
       
  7202                         if ( headersOut->At( j ) == index )
       
  7203                             { 
       
  7204                             // It's selected after the dialog
       
  7205                             foundIt = ETrue;
       
  7206                             }
       
  7207                         }
       
  7208                         
       
  7209                     if ( !foundIt )
       
  7210                         { 
       
  7211                         // Originally it was selected so it's not the same selection anymore
       
  7212                         theSame = EFalse;
       
  7213                         }
       
  7214                     }
       
  7215                 else
       
  7216                     { 
       
  7217                     // It was originally not selected
       
  7218                     TBool foundIt = EFalse;
       
  7219                     for ( TInt j = 0; j < countItems; j++ )
       
  7220                         { 
       
  7221                         // Lets see the current selection
       
  7222                         if ( headersOut->At( j ) == index )
       
  7223                             { 
       
  7224                             // It's selected after the dialog
       
  7225                             foundIt = ETrue;
       
  7226                             }
       
  7227                         }
       
  7228                         
       
  7229                     if ( foundIt )
       
  7230                         { 
       
  7231                         // Originally it was not selected so it's not the same selection anymore
       
  7232                         theSame = EFalse;
       
  7233                         }
       
  7234                     }
       
  7235                 index++;                
       
  7236                 }
       
  7237             }
       
  7238             
       
  7239         CleanupStack::PopAndDestroy( headersIn );
       
  7240 
       
  7241         if ( theSame )
       
  7242             { 
       
  7243             // no changes were done so don't proceed with this..
       
  7244             // we return here so that we don't save incorrect configuration
       
  7245             // it might happen for example if we have opened reply to all and there are 
       
  7246             // unselected fields used in the replied message
       
  7247             CleanupStack::PopAndDestroy( 2, indexes ); // + headersOut
       
  7248             return;
       
  7249             }
       
  7250         
       
  7251         // Indicates selected fields
       
  7252         CArrayFixFlat<TInt>* indexesOut = new( ELeave ) CArrayFixFlat<TInt>( 3 );
       
  7253         CleanupStack::PushL( indexesOut );
       
  7254         
       
  7255         indexesOut->AppendL( EFalse );
       
  7256         indexesOut->AppendL( EFalse );
       
  7257         indexesOut->AppendL( EFalse );
       
  7258         
       
  7259         for ( TInt i = 0; i < countItems; i++ )
       
  7260             {
       
  7261             TInt selected = headersOut->At(i);
       
  7262             for ( TInt j = 0; j < 3; j++ )
       
  7263                 {
       
  7264                 if ( indexes->At( j ) == selected )
       
  7265                     {
       
  7266                     indexesOut->At( j ) = ETrue;
       
  7267                     break;
       
  7268                     }
       
  7269                 }
       
  7270             }
       
  7271 
       
  7272         AddHeadersCollectStatisticsL( *indexesOut,
       
  7273                                       headersVariation,
       
  7274                                       newSelectionHeaders,
       
  7275                                       removeHeaders,
       
  7276                                       removeHeadersWithWarning,
       
  7277                                       addHeaders );
       
  7278                                       
       
  7279         CleanupStack::PopAndDestroy( indexesOut );
       
  7280         
       
  7281         TInt countRemove = AddHeadersCount( removeHeadersWithWarning );
       
  7282         
       
  7283         TInt res ( 0 );
       
  7284         if ( countRemove > 1 )
       
  7285             {
       
  7286             res = R_UNIEDITOR_QTN_MSG_QRY_HEADERS_REMOVE;
       
  7287             }
       
  7288         else if ( countRemove == 1 )
       
  7289             {
       
  7290             res = R_UNIEDITOR_QTN_MSG_QRY_HEADER_REMOVE;
       
  7291             }
       
  7292             
       
  7293         if ( res )
       
  7294             {
       
  7295             // Confirmation specified for header removing
       
  7296             if ( ShowConfirmationQueryL( res ) )
       
  7297                 {
       
  7298                 // Remove all headers 
       
  7299                 iHeader->AddHeadersDeleteL( removeHeaders, ETrue );
       
  7300                 Document()->SetHeaderModified( ETrue );
       
  7301                 SetAddressSize();
       
  7302                 SetSubjectSize();
       
  7303                 }
       
  7304             else
       
  7305                 {
       
  7306                 // Remove empty headers
       
  7307                 removeHeaders &= ( ~removeHeadersWithWarning );
       
  7308                 
       
  7309                 if ( removeHeaders )
       
  7310                     { 
       
  7311                     // Still something left to delete
       
  7312                     iHeader->AddHeadersDeleteL( removeHeaders, ETrue );
       
  7313                     }
       
  7314                     
       
  7315                 // But keep the ones that have some content
       
  7316                 newSelectionHeaders |= removeHeadersWithWarning;
       
  7317                 }
       
  7318             }
       
  7319         else if ( removeHeaders )
       
  7320             {
       
  7321             // Remove one or more headers but none of the removed do not contain any data
       
  7322             iHeader->AddHeadersDeleteL( removeHeaders, EFalse );            
       
  7323             }
       
  7324 
       
  7325         iHeader->SaveAddHeadersConfigL( newSelectionHeaders );
       
  7326         
       
  7327         // Add new headers
       
  7328         if ( addHeaders )
       
  7329             {
       
  7330             iHeader->AddHeadersAddL(addHeaders);
       
  7331             }    
       
  7332             
       
  7333          // Change focus
       
  7334         if ( addHeaders || removeHeaders )
       
  7335             {
       
  7336             iNextFocus = EMsgComponentIdNull;
       
  7337             
       
  7338             // Add headers override removing
       
  7339             if ( addHeaders )
       
  7340                 {
       
  7341                 if ( addHeaders & EUniFeatureCc )
       
  7342                     {
       
  7343                     iNextFocus = EMsgComponentIdCc;
       
  7344                     }
       
  7345                 else if ( addHeaders & EUniFeatureBcc )
       
  7346                     {
       
  7347                     iNextFocus = EMsgComponentIdBcc;
       
  7348                     }
       
  7349                 else if ( addHeaders & EUniFeatureSubject )
       
  7350                     {
       
  7351                     iNextFocus = EMsgComponentIdSubject;
       
  7352                     }
       
  7353                 }
       
  7354             else
       
  7355                 {
       
  7356                 CUniEditorHeader::THeaderFields start( CUniEditorHeader::EHeaderAddressBcc );
       
  7357                 
       
  7358                 if ( removeHeaders & EUniFeatureSubject )
       
  7359                     {
       
  7360                     start = CUniEditorHeader::EHeaderAddressBcc;
       
  7361                     }                
       
  7362                 else if ( removeHeaders & EUniFeatureBcc )
       
  7363                     {
       
  7364                     start = CUniEditorHeader::EHeaderAddressCc;
       
  7365                     }
       
  7366                 else if ( removeHeaders & EUniFeatureCc )
       
  7367                     {
       
  7368                     start = CUniEditorHeader::EHeaderAddressTo;
       
  7369                     }
       
  7370                     
       
  7371                 // Search for the first existing header
       
  7372                 for ( TInt i = start; i >= CUniEditorHeader::EHeaderAddressTo; i-- )
       
  7373                     {
       
  7374                     if ( iHeader->AddressControl( static_cast<CUniBaseHeader::THeaderFields> ( i ) ) )
       
  7375                         {
       
  7376                         iNextFocus = iHeader->AddressControlId( 
       
  7377                                                     static_cast<CUniBaseHeader::THeaderFields> ( i ) );
       
  7378                         break;
       
  7379                         }
       
  7380                     }
       
  7381                 }
       
  7382                 
       
  7383             if ( ToCtrl() )
       
  7384                 {
       
  7385                 DoSetFocusL();
       
  7386                 }
       
  7387             else
       
  7388                 { 
       
  7389                 DoUserChangeSlideL( 0 );
       
  7390                 }
       
  7391                 
       
  7392             CheckHeaderForMessageTypeL();
       
  7393             
       
  7394             // Also iSmsSubjectLength needs updating..
       
  7395             CheckBodyForMessageTypeL();
       
  7396             MsgLengthToNavipaneL();
       
  7397             }
       
  7398         }
       
  7399     else
       
  7400         {
       
  7401         CleanupStack::PopAndDestroy( headersIn );
       
  7402         }
       
  7403         
       
  7404     CleanupStack::PopAndDestroy( 2, indexes ); // + headersOut
       
  7405     }
       
  7406                                             
       
  7407 
       
  7408 // ---------------------------------------------------------
       
  7409 // CUniEditorAppUi::AddHeadersRemovedWithDataFlags
       
  7410 // ---------------------------------------------------------
       
  7411 //
       
  7412 void CUniEditorAppUi::AddHeadersCollectStatisticsL( CArrayFix<TInt>& aIndexesOut, 
       
  7413                                                     TInt aVariation,
       
  7414                                                     TInt& aNewSelectionFlags,
       
  7415                                                     TInt& aRemoveFlags,
       
  7416                                                     TInt& aRemoveWarningFlags,
       
  7417                                                     TInt& aAddFlags ) const
       
  7418     {        
       
  7419     // now we know selected ones 
       
  7420     for ( TInt i = 0; i < 3; i++ )  // maximum three three
       
  7421         {
       
  7422         if (i == 0 || i == 1 )
       
  7423             {
       
  7424             CMsgAddressControl* control = NULL;                
       
  7425             TInt flag = EUniFeatureCc;
       
  7426             if ( i == 0 )
       
  7427                 {
       
  7428                 control = iHeader->AddressControl( 
       
  7429                     static_cast<CUniBaseHeader::THeaderFields> 
       
  7430                         (CUniBaseHeader::EHeaderAddressCc) );
       
  7431                 }
       
  7432             else if ( i == 1 )
       
  7433                 {
       
  7434                 flag = EUniFeatureBcc;
       
  7435                 control = iHeader->AddressControl( 
       
  7436                     static_cast<CUniBaseHeader::THeaderFields> 
       
  7437                         (CUniBaseHeader::EHeaderAddressBcc) );
       
  7438                 }
       
  7439             
       
  7440             if ( !aIndexesOut[i] )
       
  7441                 {
       
  7442                 if ( control )
       
  7443                     {
       
  7444                     aRemoveFlags |= flag;
       
  7445                     CMsgRecipientArray* recipients = control->GetRecipientsL();
       
  7446                     if (    recipients 
       
  7447                        &&   recipients->Count() )
       
  7448                         {
       
  7449                         aRemoveWarningFlags |= flag;
       
  7450                         }
       
  7451                     // else - control, no recipients, no selection => remove
       
  7452                     }
       
  7453                 // else - no control, no selection => status quo
       
  7454                 }
       
  7455             else
       
  7456                 {
       
  7457                 aNewSelectionFlags |= flag;
       
  7458                 if ( !control )
       
  7459                     {
       
  7460                     // no control, selection
       
  7461                     aAddFlags |= flag;
       
  7462                     }
       
  7463                 // else - control and selection => status quo
       
  7464                 }
       
  7465             }
       
  7466         else if ( i== 2 )
       
  7467             {
       
  7468             if( aVariation & EUniFeatureSubject && aVariation & EUniFeatureSubjectConfigurable )
       
  7469                 { // OK, subject field supported and configured
       
  7470                 CMsgExpandableControl* subject = iHeader->SubjectControl();
       
  7471                 if ( !aIndexesOut[i] )
       
  7472                     {
       
  7473                     if ( subject )
       
  7474                         {
       
  7475                         aRemoveFlags |= EUniFeatureSubject;
       
  7476                         if ( subject->TextContent().DocumentLength() )
       
  7477                             {
       
  7478                             aRemoveWarningFlags |= EUniFeatureSubject;
       
  7479                             }
       
  7480                         // else - control, no subject text, no selection => remove
       
  7481                         }
       
  7482                     // else - no control, no selection => status quo
       
  7483                     }
       
  7484                 else
       
  7485                     {
       
  7486                     aNewSelectionFlags |= EUniFeatureSubject;
       
  7487                     if ( !subject )
       
  7488                         {
       
  7489                         // no control, selection
       
  7490                         aAddFlags |= EUniFeatureSubject;
       
  7491                         }
       
  7492                     // else - control and selection => status quo
       
  7493                     }
       
  7494                 }
       
  7495             }
       
  7496         }
       
  7497     }
       
  7498 
       
  7499 // ---------------------------------------------------------
       
  7500 // CUniEditorAppUi::AddHeadersCount
       
  7501 // ---------------------------------------------------------
       
  7502 //
       
  7503 TInt CUniEditorAppUi::AddHeadersCount( TInt aFlag ) const
       
  7504     {
       
  7505     TInt count( 0 );
       
  7506     if ( aFlag & EUniFeatureCc )
       
  7507         {
       
  7508         count++;
       
  7509         }
       
  7510     if ( aFlag & EUniFeatureBcc )
       
  7511         {
       
  7512         count++;
       
  7513         }
       
  7514     if ( aFlag & EUniFeatureSubject )
       
  7515         {
       
  7516         count++;
       
  7517         }
       
  7518     return count;
       
  7519     }
       
  7520 
       
  7521 // ---------------------------------------------------------
       
  7522 // CUniEditorAppUi::SetCursorPositionsForInsertL
       
  7523 // ---------------------------------------------------------
       
  7524 //
       
  7525 void CUniEditorAppUi::SetCursorPositionsForInsertL()
       
  7526     {
       
  7527     // Set body control cursor position, so that scrolling after
       
  7528     // insert goes ok.
       
  7529     if ( BodyCtrl() )
       
  7530         {
       
  7531         TInt cursorPos = iSmilModel->Layout() == EUniImageFirst ? 0 : 
       
  7532                                                                   BodyCtrlEditor()->TextLength(); 
       
  7533         BodyCtrl()->SetCursorPosL( cursorPos );
       
  7534         }
       
  7535     }
       
  7536 
       
  7537 // ---------------------------------------------------------
       
  7538 // CUniEditorAppUi::DoUserRemoveMediaL
       
  7539 // ---------------------------------------------------------
       
  7540 //
       
  7541 void CUniEditorAppUi::DoUserRemoveMediaL( TMsgControlId aMediaControlId,
       
  7542                                           TUniRegion aRegion )
       
  7543     {
       
  7544     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  7545 
       
  7546     CMsgBaseControl* ctrl = iView->ControlById( aMediaControlId );
       
  7547     CUniObject* obj = iSmilModel->GetObject( Document()->CurrentSlide(), aRegion );
       
  7548 
       
  7549     __ASSERT_DEBUG( ( ctrl && obj ), Panic( EUniNullPointer ) );
       
  7550     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  7551 
       
  7552     TUint32 objects = ObjectsAvailable(); 
       
  7553 
       
  7554     TParsePtrC fileN( obj->MediaInfo()->FullFilePath() );
       
  7555 
       
  7556     HBufC* queryText = StringLoader::LoadLC( R_UNIEDITOR_QUEST_REMOVE_COMMON, fileN.NameAndExt() );
       
  7557 
       
  7558     if ( ShowConfirmationQueryL( *queryText ) ) 
       
  7559         {  
       
  7560         iSmilModel->RemoveObjectL( Document()->CurrentSlide(), obj );
       
  7561         Document()->SetBodyModified( ETrue );
       
  7562 
       
  7563         TBool removeCtrlFocused = ctrl->IsFocused();
       
  7564 
       
  7565         // Delete icon
       
  7566         iView->DeleteControlL( ctrl->ControlId() );
       
  7567         
       
  7568         MsgLengthToNavipaneL();
       
  7569 
       
  7570         // Change focus to the beginning that scroll bar is updated
       
  7571         // and text editor area removes extra lines
       
  7572         if ( ToCtrl() )
       
  7573             {
       
  7574             iView->SetFocus( EMsgComponentIdTo );
       
  7575             }
       
  7576         else if ( iView->ControlById( EMsgComponentIdAudio ) )
       
  7577             {
       
  7578             //Audio is always first
       
  7579             iView->SetFocus( EMsgComponentIdAudio );
       
  7580             }
       
  7581         else if ( iSmilModel->Layout() == EUniImageFirst &&  
       
  7582                   ImageCtrl() )
       
  7583             {
       
  7584             // should not be need to update focus anymore
       
  7585             iView->SetFocus( EMsgComponentIdImage );
       
  7586             }    
       
  7587         else 
       
  7588             {
       
  7589             // should not be need to update focus anymore
       
  7590             iView->SetFocus( EMsgComponentIdBody );
       
  7591             }
       
  7592  
       
  7593         // Put focus back to right place
       
  7594         CMsgBaseControl* focusedControl = iView->FocusedControl();
       
  7595         if ( focusedControl )
       
  7596             {
       
  7597             if ( removeCtrlFocused &&  
       
  7598                  focusedControl->ControlId() != EMsgComponentIdImage &&  
       
  7599                  iSmilModel->Layout() == EUniImageFirst &&  
       
  7600                  ImageCtrl() )
       
  7601                 {
       
  7602                 iView->SetFocus( EMsgComponentIdImage );
       
  7603                 }
       
  7604             else if ( removeCtrlFocused &&        
       
  7605                       aMediaControlId == EMsgComponentIdAudio && 
       
  7606                       iSmilModel->Layout() == EUniImageFirst && 
       
  7607                       ImageCtrl() )
       
  7608                 {
       
  7609                 iView->SetFocus( EMsgComponentIdImage );
       
  7610                 }
       
  7611             else if ( focusedControl->ControlId() != EMsgComponentIdBody )
       
  7612                 {
       
  7613                 CMsgBodyControl* bodyCtrl = BodyCtrl();
       
  7614                 if ( bodyCtrl && 
       
  7615                      aRegion == EUniRegionImage && 
       
  7616                      ( objects & EUniVideoFlag | removeCtrlFocused ) )
       
  7617                     { 
       
  7618                     if ( iSmilModel->Layout() == EUniImageFirst )
       
  7619                         {
       
  7620                         // If video was removed, always place the cursor in the end
       
  7621                         bodyCtrl->SetCursorPosL( 0 );
       
  7622                         }
       
  7623                     else
       
  7624                         {
       
  7625                         // If video was removed, always place the cursor in the end
       
  7626                         bodyCtrl->SetCursorPosL( bodyCtrl->Editor().TextLength() );
       
  7627                         }
       
  7628                     }
       
  7629                 
       
  7630                 // Needs to be done after cursor setting to ensure that view is 
       
  7631                 // showing the correct position.
       
  7632                 iView->SetFocus( EMsgComponentIdBody );
       
  7633                 }
       
  7634 
       
  7635             if ( focusedControl->ControlId() == EMsgComponentIdImage )
       
  7636                 {
       
  7637                 // Set focus here so that imagecontrol will draw navipane if focused.
       
  7638                 iView->FocusedControl()->SetFocus( ETrue, EDrawNow );
       
  7639                 }
       
  7640             }
       
  7641         }
       
  7642         
       
  7643     CleanupStack::PopAndDestroy( queryText );
       
  7644     if(!ObjectsAvailable() && Document()->CurrentSlide())
       
  7645         {
       
  7646         DoRemoveSlideL();
       
  7647         Document()->SetBodyModified( ETrue ); 
       
  7648         }   
       
  7649     CheckBodyForMessageTypeL();
       
  7650     MsgLengthToNavipaneL();
       
  7651     }
       
  7652 
       
  7653 // ---------------------------------------------------------
       
  7654 // CUniEditorAppUi::RemoveCurrentTextObjectL
       
  7655 // ---------------------------------------------------------
       
  7656 //
       
  7657 void CUniEditorAppUi::RemoveCurrentTextObjectL()
       
  7658     {
       
  7659     __ASSERT_DEBUG( Document()->DataModel()->SmilType() == EMmsSmil, Panic( EUniIllegalSmilType ) );
       
  7660     
       
  7661     if ( ShowConfirmationQueryL( R_UNIEDITOR_QUEST_REMOVE_TEXT ) ) 
       
  7662         {
       
  7663         if ( BodyCtrl() || 
       
  7664              BodyCtrl()->TextContent().DocumentLength() )
       
  7665             {
       
  7666             BodyCtrl()->Reset();
       
  7667             
       
  7668             Document()->SetBodyModified( ETrue );
       
  7669             
       
  7670             UpdateSmilTextAttaL();
       
  7671             }        
       
  7672         if((Document()->UniState() == EUniMms) &&(!ObjectsAvailable() && Document()->CurrentSlide()))
       
  7673             {
       
  7674             DoRemoveSlideL();
       
  7675             Document()->SetBodyModified( ETrue ); 
       
  7676             }        
       
  7677         CheckBodyForMessageTypeL();
       
  7678         MsgLengthToNavipaneL();
       
  7679         SetOrRemoveMaxSizeInEdwin();
       
  7680         }
       
  7681     }
       
  7682 
       
  7683 // ---------------------------------------------------------
       
  7684 // CUniEditorAppUi::MsgAsyncControlStateChanged
       
  7685 // ---------------------------------------------------------
       
  7686 //
       
  7687 void CUniEditorAppUi::MsgAsyncControlStateChanged( CMsgBaseControl& /*aControl*/,
       
  7688                                                    TMsgAsyncControlState /*aNewState*/,
       
  7689                                                    TMsgAsyncControlState /*aOldState*/ )
       
  7690     {
       
  7691     // OK to leave this empty, needed only in Viewer side
       
  7692     }
       
  7693 
       
  7694 // ---------------------------------------------------------
       
  7695 // CUniEditorAppUi::MsgAsyncControlResourceChanged
       
  7696 // ---------------------------------------------------------
       
  7697 //
       
  7698 void CUniEditorAppUi::MsgAsyncControlResourceChanged( CMsgBaseControl& aControl, TInt aType )
       
  7699     {
       
  7700     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  7701         {
       
  7702         if ( aControl.ControlType() == EMsgImageControl )
       
  7703             {
       
  7704             CMsgImageControl& imageControl = static_cast<CMsgImageControl&>( aControl );
       
  7705             
       
  7706             if ( imageControl.IconBitmapId() == EMbmUniutilsQgn_graf_mms_unedit ||
       
  7707                  imageControl.IconBitmapId() == EMbmUniutilsQgn_graf_mms_edit )
       
  7708                 {
       
  7709                 // 3GPP icons layout setting needs to be handled by ourself
       
  7710                 TAknLayoutRect iconLayout;
       
  7711                 iconLayout.LayoutRect( MsgEditorCommons::MsgDataPane(),
       
  7712                                        AknLayoutScalable_Apps::msg_data_pane_g4().LayoutLine() );
       
  7713                 
       
  7714                 TRAP_IGNORE( imageControl.SetIconSizeL( iconLayout.Rect().Size() ) );
       
  7715                 }
       
  7716             }
       
  7717         }
       
  7718     }
       
  7719 
       
  7720 // ---------------------------------------------------------
       
  7721 // CUniEditorAppUi::HandleResourceChangeL
       
  7722 // ---------------------------------------------------------
       
  7723 //
       
  7724 void CUniEditorAppUi::HandleResourceChangeL( TInt aType )
       
  7725     {
       
  7726     // Base class call must be first
       
  7727     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  7728     
       
  7729     if ( iHeader )
       
  7730         {
       
  7731         iHeader->HandleResourceChange( aType );
       
  7732         }
       
  7733     
       
  7734     if ( aType == KEikDynamicLayoutVariantSwitch && IsLaunched() )
       
  7735         { 
       
  7736         // Resize the title icon
       
  7737         CreateFixedToolbarL( EFalse );
       
  7738         
       
  7739         if( !( iEditorFlags & EDoNotUpdateTitlePane ) )
       
  7740             {
       
  7741             UpdateToolbarL();
       
  7742 
       
  7743             SetTitleIconsSizeL();
       
  7744             
       
  7745             // Redraw it again
       
  7746             SetTitleL();
       
  7747             }        
       
  7748         }
       
  7749     else if ( aType == KAknsMessageSkinChange )
       
  7750         {
       
  7751         TParse fileParse;
       
  7752         fileParse.Set( KUniUtilsMBMFileName, &KDC_APP_BITMAP_DIR, NULL );
       
  7753         
       
  7754         delete iIconSms;
       
  7755         iIconSms = NULL;
       
  7756         iIconSms = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(),
       
  7757                 KAknsIIDQgnPropMceSmsTitle,
       
  7758                 fileParse.FullName(),
       
  7759                 EMbmUniutilsQgn_prop_mce_sms_title,
       
  7760                 EMbmUniutilsQgn_prop_mce_sms_title_mask );
       
  7761 
       
  7762         delete iIconMms;
       
  7763         iIconMms = NULL;
       
  7764         iIconMms = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(),
       
  7765                         KAknsIIDQgnPropMceMmsTitle,
       
  7766                         fileParse.FullName(),
       
  7767                         EMbmUniutilsQgn_prop_mce_mms_title,
       
  7768                         EMbmUniutilsQgn_prop_mce_mms_title_mask );
       
  7769         
       
  7770         SetTitleIconsSizeL();
       
  7771         
       
  7772         if ( IsLaunched() && !( iEditorFlags & EDoNotUpdateTitlePane ) )
       
  7773             {
       
  7774             SetTitleL();
       
  7775             }
       
  7776         }
       
  7777     }
       
  7778 
       
  7779 // ---------------------------------------------------------
       
  7780 // CUniEditorAppUi::IsBodySmsCompatibleL
       
  7781 // ---------------------------------------------------------
       
  7782 //
       
  7783 TBool CUniEditorAppUi::IsBodySmsCompatibleL( TBool aInAutoMode /*= ETrue*/ )
       
  7784     {
       
  7785     CUniEditorDocument* doc = Document();
       
  7786 
       
  7787     CUniDataModel* model = doc->DataModel();
       
  7788 
       
  7789     if ( Document()->DataModel()->SmilType() != EMmsSmil )
       
  7790         { // There's 3GPP presentation or something else..
       
  7791         return EFalse;
       
  7792         }
       
  7793 
       
  7794     // This sets iSmsLength and possible unicode character mode
       
  7795     CheckSmsSizeAndUnicodeL();
       
  7796 
       
  7797     if( model->ObjectList().Count() == 0 &&
       
  7798         model->AttachmentList().Count() == 1 &&
       
  7799         iSmilModel->SlideCount() == 1 &&
       
  7800         iSmsSubjectLength == 0)
       
  7801         {
       
  7802         CUniObject* obj = model->AttachmentList().GetByIndex( 0 );
       
  7803         if ( obj &&  
       
  7804              obj->MimeType().Length() > 0 &&   
       
  7805              ( obj->MimeType().CompareF( KMsgMimeVCard ) == 0 ||  
       
  7806 #if defined (__I_CAL_SUPPORT) && defined (RD_MESSAGING_ICAL_IMPORT)
       
  7807                obj->MimeType().CompareF( KMsgMimeICal ) == 0 ||
       
  7808 #endif
       
  7809                obj->MimeType().CompareF( KMsgMimeVCal ) == 0 ) )
       
  7810             { 
       
  7811             // There's only either VCard, VCal or ICal if it is supported.
       
  7812             iSmsBodyLength = obj->Size();
       
  7813             
       
  7814             TInt maxParts = doc->MaxSmsParts();
       
  7815              if( !aInAutoMode )
       
  7816                 { // Checking if the message fits in "absolute maximum"
       
  7817                 maxParts = doc->AbsoluteMaxSmsParts();
       
  7818                 }
       
  7819             TInt lengthOne( 0 );
       
  7820             TInt lengthMany( 0 );    
       
  7821             doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  7822             return (iSmsBodyLength > lengthMany * maxParts )?  EFalse :  ETrue;
       
  7823             }
       
  7824         }
       
  7825     
       
  7826     if( model->ObjectList().Count() > 1 ||
       
  7827         model->AttachmentList().Count() > 0 ||
       
  7828         iSmilModel->SlideCount() > 1 )
       
  7829         { // If more than 1 object or an attachment or a slide -> MMS
       
  7830         return EFalse;
       
  7831         }
       
  7832     // OK, there's just one object
       
  7833     
       
  7834     if( model->ObjectList().Count() == 1 &&
       
  7835         model->ObjectList().GetByIndex(0)->MediaType() != EMsgMediaText )
       
  7836         { // Just one object and it's not text -> MMS
       
  7837         return EFalse;
       
  7838         }
       
  7839         
       
  7840     // Lets check the length of the body
       
  7841     if( !(iEditorFlags & ESubjectOkInSms ) && iSmsSubjectLength > 0 )
       
  7842         {
       
  7843         return EFalse;
       
  7844         }
       
  7845     
       
  7846     TInt lengthOne( 0 );
       
  7847     TInt lengthMany( 0 );
       
  7848     
       
  7849     doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  7850 
       
  7851     TInt maxLen = lengthOne;
       
  7852 
       
  7853     TInt maxParts = doc->MaxSmsParts();
       
  7854     
       
  7855     if( !aInAutoMode )
       
  7856         { // Checking if the message fits in "absolute maximum"
       
  7857         maxParts = doc->AbsoluteMaxSmsParts();
       
  7858         }
       
  7859   
       
  7860     if( maxParts > 1 )
       
  7861         {
       
  7862         maxLen = maxParts*lengthMany;
       
  7863         }
       
  7864     
       
  7865     if ( doc->AbsoluteMaxSmsCharacters() > 0 )
       
  7866         {
       
  7867         maxLen = doc->AbsoluteMaxSmsCharacters();
       
  7868         }
       
  7869     
       
  7870     TInt emailAddrLen = iHeader->LongestEmailAddress();
       
  7871     
       
  7872     if( emailAddrLen )
       
  7873         {
       
  7874         emailAddrLen++; // one extra char needed by separator char
       
  7875         }
       
  7876 
       
  7877     if( iSmsBodyLength + iSmsSubjectLength + emailAddrLen <= maxLen )
       
  7878         {
       
  7879         //Korean Req: 415-5434
       
  7880         //get the size limit in bytes
       
  7881         TInt warnCharLength = doc->SmsSizeWarningBytes();
       
  7882 
       
  7883         if( warnCharLength > 0 )
       
  7884             {
       
  7885             //convert the size limit w.r.t characters based on encoding type
       
  7886             if ( doc->UnicodeCharacterMode() )
       
  7887                 {
       
  7888                 warnCharLength =  warnCharLength / 2 ;
       
  7889                 }
       
  7890             else
       
  7891                 {
       
  7892                 warnCharLength = (warnCharLength * 8) / 7;
       
  7893                 }
       
  7894             
       
  7895             if( iSmsBodyLength + iSmsSubjectLength + emailAddrLen > warnCharLength )
       
  7896                 {
       
  7897                 //show "limit exceed" note if not shown already
       
  7898                 if( !( iEditorFlags & ESmsSizeWarningNoteShown ) )
       
  7899                     {
       
  7900                     //set the bit to indicate limit exceeded and note shown
       
  7901                     iEditorFlags |= ESmsSizeWarningNoteShown;
       
  7902                     if( iPopupNote )
       
  7903                         {
       
  7904 						ShowDiscreetPopUpL(iPopupSmsSizeAboveLimitBuffer->Des());
       
  7905                         }
       
  7906                     }
       
  7907                 }
       
  7908             else
       
  7909                 {
       
  7910                 //show "back to below limit" note if not shown already(only in case of size transiton from above limit to below limit)
       
  7911                 if( iEditorFlags & ESmsSizeWarningNoteShown )
       
  7912                     {
       
  7913                     //reset the bit to indicate size is below limit and note for transition is showed
       
  7914                     iEditorFlags &= ~ESmsSizeWarningNoteShown;
       
  7915                     if( iPopupNote )
       
  7916                         {
       
  7917                         ShowDiscreetPopUpL(iPopupSmsSizeBelowLimitBuffer->Des());
       
  7918                         }                
       
  7919                     }
       
  7920                 }          
       
  7921             }
       
  7922         
       
  7923         return ETrue;
       
  7924         }
       
  7925   
       
  7926     // text (body + possible subject) is too long -> body is not sms compatible
       
  7927     return EFalse;  
       
  7928     }
       
  7929 
       
  7930 // ---------------------------------------------------------
       
  7931 // CUniEditorAppUi::CheckSmsSizeAndUnicodeL
       
  7932 // ---------------------------------------------------------
       
  7933 //
       
  7934 void CUniEditorAppUi::CheckSmsSizeAndUnicodeL()
       
  7935     {
       
  7936     UNILOGGER_WRITE_TIMESTAMP("CUniEditorAppUi::CheckSmsSizeAndUnicodeL Start <<<---- ");
       
  7937     CUniEditorDocument* doc = Document();
       
  7938 
       
  7939     if( iNLTFeatureSupport )
       
  7940         {
       
  7941         //Turkish SMS-PREQ2265 specific
       
  7942         TInt numOfPDUs = 0, numOfRemainingChars = 0, subjectLength = 0;
       
  7943         TBool unicodeMode = EFalse;
       
  7944         TSmsEncoding alternativeEncodingType;
       
  7945         CUniEditorPlugin* plugin = NULL;
       
  7946        
       
  7947         plugin = SmsPlugin();
       
  7948         if ( plugin )
       
  7949             { 
       
  7950             HBufC* editorTxt = NULL;
       
  7951             
       
  7952             if ( BodyCtrlEditor() )
       
  7953                 {
       
  7954                 editorTxt = BodyCtrlEditor()->GetTextInHBufL();
       
  7955                 }
       
  7956 
       
  7957             //Concatenate subject buffer and body buffer before calculating PDU info.
       
  7958             if ( SubjectCtrlEditor() )
       
  7959                 {
       
  7960                 HBufC* subjectTxt = SubjectCtrlEditor()->GetTextInHBufL();
       
  7961                 if( subjectTxt )
       
  7962                     {
       
  7963                     if( editorTxt )
       
  7964                         {
       
  7965                         CleanupStack::PushL( subjectTxt );
       
  7966                         //If both, body text and suject text is present
       
  7967                         //Reallocate editor text to include subject buffer and additional chars for subject 
       
  7968                         TInt reallocLength;
       
  7969                         reallocLength = editorTxt->Length() + subjectTxt->Length() + KUniEdExtraLenCausedBySubject;
       
  7970                         editorTxt = editorTxt->ReAllocL(reallocLength);
       
  7971                         
       
  7972                         //Modify the editor text to insert subject buffer and additional chars at the begining
       
  7973                         //Buffer Format is:: "(subject...)body..."
       
  7974                         TPtr editorBuffPtr = editorTxt->Des();
       
  7975                         subjectLength = 0;
       
  7976                         editorBuffPtr.Insert(subjectLength, _L("("));
       
  7977                         subjectLength += 1;
       
  7978                         editorBuffPtr.Insert(subjectLength, *subjectTxt);
       
  7979                         subjectLength += subjectTxt->Length();
       
  7980                         editorBuffPtr.Insert(subjectLength, _L(")"));
       
  7981                         subjectLength += 1;
       
  7982                         //total subject length is actual subject + extra chars '(' and ')'
       
  7983                         CleanupStack::PopAndDestroy( subjectTxt );                    
       
  7984                         }
       
  7985                     else
       
  7986                         {
       
  7987                         //if only subject text is present                   
       
  7988                         //Modify subject buffer directly                    
       
  7989                         //Reallocate subject text to include subject buffer and additional chars for subject 
       
  7990                         subjectLength = subjectTxt->Length() + KUniEdExtraLenCausedBySubject;
       
  7991                         subjectTxt = subjectTxt->ReAllocL(subjectLength);
       
  7992 
       
  7993                         //Modify the editor text to insert additional chars at the begining and end 
       
  7994                         //Buffer Format is:: "(subject...)"
       
  7995                         TPtr subjectBuffPtr = subjectTxt->Des();
       
  7996                         subjectBuffPtr.Insert(0, _L("("));
       
  7997                         //total subject length is actual subject + extra chars '(' and ')'
       
  7998                         subjectBuffPtr.Insert(subjectLength - 1, _L(")"));
       
  7999                         //Use subject buffer as editor buffer
       
  8000                         editorTxt = subjectTxt;
       
  8001                         }
       
  8002                     }
       
  8003                 }
       
  8004             
       
  8005             if ( editorTxt )
       
  8006                 {
       
  8007                 TPtr inputBuff = editorTxt->Des();
       
  8008                 TInt buffLength = editorTxt->Length();
       
  8009                 TInt prevBuffLength = 0;
       
  8010                 //replace enter char(enter will be downgraded anyways) with space, before calculating PDU info.
       
  8011                 //This char will be later replaced with line feed or paragraph separator
       
  8012                 TBuf<KSmsEdPDUInfoCalcReplaceCharacterCount> replaceChars;
       
  8013                 replaceChars.Zero();
       
  8014                 replaceChars.Append( KSmsEnterCharacter );
       
  8015                 replaceChars.Append( KSmsDownwardsArrowLeft );
       
  8016                 AknTextUtils::ReplaceCharacters(
       
  8017                     inputBuff, 
       
  8018                     replaceChars, 
       
  8019                     KSmsEdUnicodeLFSupportedByBasicPhones );
       
  8020                 if( iPrevBuffer )
       
  8021                     {
       
  8022                     prevBuffLength = iPrevBuffer->Length();
       
  8023                     if(( prevBuffLength == buffLength )&&(!iSettingsChanged) )
       
  8024                     {
       
  8025                         UNILOGGER_WRITE_TIMESTAMP("CUniEditorAppUi::CheckSmsSizeAndUnicodeL Compare Start <<<---- ");                        
       
  8026                         if( iPrevBuffer->Compare(*editorTxt) == 0 )
       
  8027                             {
       
  8028                             UNILOGGER_WRITE_TIMESTAMP("CUniEditorAppUi::CheckSmsSizeAndUnicodeL Compare TRUE End ---->>> ");                        
       
  8029                             /* Identical buffer, previously calculated values are good enough
       
  8030                              * Hence do nothing. 
       
  8031                              */
       
  8032                             delete iPrevBuffer;
       
  8033                             iPrevBuffer = editorTxt;
       
  8034                             return;
       
  8035                     }
       
  8036                         UNILOGGER_WRITE_TIMESTAMP("CUniEditorAppUi::CheckSmsSizeAndUnicodeL Compare FALSE End ---->>> ");                        
       
  8037                         }
       
  8038                     }
       
  8039                 //This char will be later replaced with line feed or paragraph separator
       
  8040 	          if( buffLength <= prevBuffLength )
       
  8041                     {
       
  8042         	  	//Reset the settings back, in case if any unicode/turkish chars were entered and erased 
       
  8043             	       	//or if entry type is T9 method(multiple key presses to get different chars)
       
  8044     	               	plugin->SetEncodingSettings(EFalse, doc->AlternativeEncodingType(), doc->CharSetSupport());
       
  8045                     }                
       
  8046                 //Call the plugin SMS adaptation API to get PDU Info
       
  8047                TRAPD( err, plugin->GetNumPDUsL( inputBuff, numOfRemainingChars, numOfPDUs, unicodeMode, alternativeEncodingType) );
       
  8048                if ( err == KErrOverflow )
       
  8049                     {
       
  8050                             iSmsBodyLength = buffLength;
       
  8051                             delete iPrevBuffer;
       
  8052                             iPrevBuffer = editorTxt;
       
  8053                             return;                          
       
  8054                     }
       
  8055                 else if ( err != KErrNone )
       
  8056                     {
       
  8057                 	        User::Leave(err);
       
  8058                 	}
       
  8059                 	  				     
       
  8060                 //save current buffer 
       
  8061                 delete iPrevBuffer;
       
  8062                 iPrevBuffer = editorTxt;
       
  8063                 iSettingsChanged = EFalse;
       
  8064                 }
       
  8065             else
       
  8066                 {
       
  8067                 //Reset the settings back, in case if any unicode chars were entered and erased
       
  8068                 plugin->SetEncodingSettings(EFalse, doc->AlternativeEncodingType(), doc->CharSetSupport());
       
  8069                 // Bodytext is zero -> check input language
       
  8070                 delete iPrevBuffer;
       
  8071                 iPrevBuffer = NULL;
       
  8072                 TInt inputLang = iAvkonEnv->SettingCache().InputLanguage();
       
  8073                 switch ( inputLang )
       
  8074                     {
       
  8075                     case ELangArabic:
       
  8076                     case ELangHebrew:
       
  8077                     case ELangThai:
       
  8078                     case ELangVietnamese:
       
  8079                     case ELangFarsi:
       
  8080                     case ELangHindi:
       
  8081                     case ELangUrdu:
       
  8082                     case ELangRussian:
       
  8083                     case ELangBulgarian:
       
  8084                     case ELangUkrainian:
       
  8085                     case ELangTaiwanChinese:
       
  8086                     case ELangHongKongChinese:
       
  8087                     case ELangPrcChinese:
       
  8088                     case ELangJapanese:
       
  8089                         {
       
  8090                         // If the InputLanguage is one of above,
       
  8091                         // we must check the current input mode too 
       
  8092                         if ( BodyCtrlEditor() )
       
  8093                             {
       
  8094                             if ( BodyCtrlEditor()->AknEditorCurrentInputMode() == 
       
  8095                                                                 EAknEditorHalfWidthTextInputMode )
       
  8096                                 {
       
  8097                                 //Unicode Not required. Characters are within western text set.
       
  8098                                 unicodeMode = EFalse;
       
  8099                                 }
       
  8100                             else
       
  8101                                 {
       
  8102                                 //Unicode Mode
       
  8103                                 unicodeMode = ETrue;
       
  8104                                 }       
       
  8105                             }                        
       
  8106                         break;
       
  8107                         }
       
  8108                     default:
       
  8109                         {
       
  8110                         break; 
       
  8111                         }
       
  8112                     }
       
  8113                 }
       
  8114             }        
       
  8115         TInt lengthOne = 0;
       
  8116         TInt lengthMany = 0;
       
  8117 
       
  8118         doc->SetUnicodeCharacterMode( unicodeMode );    
       
  8119         doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  8120 
       
  8121         if(numOfPDUs == 0)
       
  8122             {
       
  8123             //Empty buffer, need to calculate correct values of "num of PDUs" and "remaining characters" on our own.
       
  8124             numOfPDUs = 1;
       
  8125             numOfRemainingChars = lengthOne;
       
  8126             }
       
  8127         iNumOfPDUs = numOfPDUs;
       
  8128         iCharsLeft = numOfRemainingChars;
       
  8129 
       
  8130         if(iNumOfPDUs == 1)
       
  8131             {
       
  8132             iSmsBodyLength = lengthOne - iCharsLeft - subjectLength;
       
  8133             }
       
  8134         else
       
  8135             {
       
  8136             iSmsBodyLength = lengthMany*iNumOfPDUs - iCharsLeft - subjectLength;
       
  8137             }
       
  8138         
       
  8139         iSmsSubjectLength = subjectLength;
       
  8140         
       
  8141         }
       
  8142     else
       
  8143         {
       
  8144         TInt extendedChars = 0;
       
  8145         TInt extendedBodyChars = 0;
       
  8146         TInt extendedSubjectChars = 0;
       
  8147         TBool westernText = ETrue;
       
  8148 
       
  8149         CCnvCharacterSetConverter* conv = doc->CharConverter();    
       
  8150 
       
  8151         if ( conv )
       
  8152             { 
       
  8153             for( TInt index = 0; index < KUniEdNumberOfEditors; index++ )
       
  8154                 {
       
  8155                 HBufC* editorTxt = NULL;
       
  8156                 extendedChars = 0;
       
  8157                 
       
  8158                 if ( index == 0 )
       
  8159                     {
       
  8160                     if ( BodyCtrlEditor() )
       
  8161                         {
       
  8162                         editorTxt = BodyCtrlEditor()->GetTextInHBufL();
       
  8163                         }
       
  8164                     }
       
  8165                 else
       
  8166                     {
       
  8167                     if ( SubjectCtrlEditor() )
       
  8168                         {
       
  8169                         editorTxt = SubjectCtrlEditor()->GetTextInHBufL();
       
  8170                         }
       
  8171                     }
       
  8172 
       
  8173                 if ( editorTxt )
       
  8174                     {
       
  8175                     CleanupStack::PushL( editorTxt );
       
  8176                     
       
  8177                     TPtr string = editorTxt->Des();
       
  8178                     TUint uChar;
       
  8179                     TBuf8<KUnicodeCheckChars> notUsed;
       
  8180 
       
  8181                     TPtrC remainderOfInputString( string );
       
  8182                     
       
  8183                     for ( TInt i = 0; i < remainderOfInputString.Length(); i++ )
       
  8184                         {
       
  8185                         uChar = TUint( remainderOfInputString[i] );
       
  8186                         switch ( uChar )
       
  8187                             {
       
  8188                             case KUniEdLeftSquareBracket:
       
  8189                             case KUniEdReverseSolidus:
       
  8190                             case KUniEdRightSquareBracket:
       
  8191                             case KUniEdCircumflexAccent:
       
  8192                             case KUniEdLeftCurlyBracket:
       
  8193                             case KUniEdVerticalLine:
       
  8194                             case KUniEdRightCurlyBracket:
       
  8195                             case KUniEdTilde:
       
  8196                             case KUniEdEuroSymbol:
       
  8197                                 {
       
  8198                                 extendedChars++;
       
  8199                                 break;
       
  8200                                 }
       
  8201                             default:
       
  8202                                 {
       
  8203                                 break;
       
  8204                                 }
       
  8205                             }
       
  8206                         }
       
  8207                     
       
  8208                     // This is needed in case there's KSmsDownwardsArrowLeft in the end and no other unicode chars
       
  8209                     TBool unicodeWasInUse = EFalse;
       
  8210                     
       
  8211                     while ( remainderOfInputString.Length() )
       
  8212                         {
       
  8213                         TInt numberOfUnconvertibleCharacters = 0;
       
  8214                         const TInt returnValue = conv->ConvertFromUnicode( notUsed,
       
  8215                                                                            remainderOfInputString, 
       
  8216                                                                            numberOfUnconvertibleCharacters );
       
  8217 
       
  8218                         if ( numberOfUnconvertibleCharacters > 0 )
       
  8219                                 {
       
  8220                                 for ( TInt i = 0; 
       
  8221                                       i < remainderOfInputString.Length() && numberOfUnconvertibleCharacters > 0;
       
  8222                                       i++ )
       
  8223                                     {
       
  8224                                     uChar = TUint(remainderOfInputString[i]);
       
  8225                                     if ( uChar == KSmsDownwardsArrowLeft )
       
  8226                                         {
       
  8227                                         // these will be converted to paragraph separators later
       
  8228                                         numberOfUnconvertibleCharacters--; 
       
  8229                                         if ( doc->UnicodeCharacterMode() )
       
  8230                                             {
       
  8231                                             unicodeWasInUse = ETrue;
       
  8232                                             }
       
  8233                                         }
       
  8234                                     }
       
  8235                                 }
       
  8236                                 
       
  8237                         if ( returnValue < 0 || 
       
  8238                              numberOfUnconvertibleCharacters > 0 || 
       
  8239                              ( unicodeWasInUse && 
       
  8240                                numberOfUnconvertibleCharacters == 0 ) ) 
       
  8241                             {
       
  8242                             // if there was an error in trying to do the conversion, or if there was an
       
  8243                             // unconvertible character (e.g. a Chinese character)
       
  8244                             westernText = EFalse;
       
  8245                             break;
       
  8246                             }
       
  8247                             
       
  8248                         remainderOfInputString.Set( remainderOfInputString.Right( returnValue ) );
       
  8249                         }
       
  8250 
       
  8251                     if ( index == 0 )
       
  8252                         {
       
  8253                         extendedBodyChars = extendedChars;
       
  8254                         }
       
  8255                     else
       
  8256                         {
       
  8257                         extendedSubjectChars = extendedChars;
       
  8258                         }
       
  8259                         
       
  8260                     CleanupStack::PopAndDestroy( editorTxt );
       
  8261                     }
       
  8262                 else if ( index == 0 )
       
  8263                     { 
       
  8264                     // Bodytext is zero -> check input language
       
  8265                     TInt inputLang = iAvkonEnv->SettingCache().InputLanguage();
       
  8266                     switch ( inputLang )
       
  8267                         {
       
  8268                         case ELangArabic:
       
  8269                         case ELangHebrew:
       
  8270                         case ELangThai:
       
  8271                         case ELangVietnamese:
       
  8272                         case ELangFarsi:
       
  8273                         case ELangHindi:
       
  8274                         case ELangUrdu:
       
  8275                         case ELangRussian:
       
  8276                         case ELangBulgarian:
       
  8277                         case ELangUkrainian:
       
  8278                         case ELangTaiwanChinese:
       
  8279                         case ELangHongKongChinese:
       
  8280                         case ELangPrcChinese:
       
  8281                         case ELangJapanese:
       
  8282                             {
       
  8283                             // If the InputLanguage is one of above,
       
  8284                             // we must check the current input mode too 
       
  8285                             if ( BodyCtrlEditor() )
       
  8286                                 {
       
  8287                                 if ( BodyCtrlEditor()->AknEditorCurrentInputMode() == 
       
  8288                                                                     EAknEditorHalfWidthTextInputMode )
       
  8289                                     {
       
  8290                                     westernText = ETrue;
       
  8291                                     }
       
  8292                                 else
       
  8293                                     {
       
  8294                                     westernText = EFalse;
       
  8295                                     }       
       
  8296                                 }                        
       
  8297                             break;
       
  8298                             }
       
  8299                         default:
       
  8300                             {
       
  8301                             break; 
       
  8302                             }
       
  8303                         }
       
  8304                     }            
       
  8305                 }
       
  8306                 // Now we have westernText and extendedChars set
       
  8307             }
       
  8308             
       
  8309         if ( westernText )
       
  8310             {
       
  8311             // Might not infact change the unicode character mode
       
  8312             // if maximum SMS character limit is set that forces
       
  8313             // the mode to be always unicode.
       
  8314             doc->SetUnicodeCharacterMode( EFalse );
       
  8315             }
       
  8316         else
       
  8317             {
       
  8318             // Unicode mode
       
  8319             doc->SetUnicodeCharacterMode( ETrue );
       
  8320             
       
  8321             // We need unicode so discard extended chars
       
  8322             extendedBodyChars = 0; 
       
  8323             extendedSubjectChars = 0;
       
  8324             }
       
  8325 
       
  8326         static_cast<CUniSmsPlugin*>( SmsPlugin() )->SetUnicodeMode( doc->UnicodeCharacterMode() );
       
  8327         
       
  8328         if ( BodyCtrlEditor() )
       
  8329             {
       
  8330             iSmsBodyLength = BodyCtrlEditor()->TextLength() + extendedBodyChars;
       
  8331             }
       
  8332         else
       
  8333             {
       
  8334             iSmsBodyLength = 0;
       
  8335             }
       
  8336             
       
  8337         iSmsSubjectLength = 0;
       
  8338         
       
  8339         if( SubjectCtrlEditor() && 
       
  8340             SubjectCtrlEditor()->TextLength() )
       
  8341             { 
       
  8342             // EmailOverSms is supported if when end up here
       
  8343             iSmsSubjectLength = SubjectCtrlEditor()->TextLength() 
       
  8344                                 + extendedSubjectChars
       
  8345                                 + KUniEdExtraLenCausedBySubject; // the extra because of '(' and ')'
       
  8346             }        
       
  8347         }
       
  8348     UNILOGGER_WRITE_TIMESTAMP("CUniEditorAppUi::CheckSmsSizeAndUnicodeL End ---->>> ");
       
  8349     }
       
  8350 
       
  8351 // ---------------------------------------------------------
       
  8352 // CUniEditorAppUi::CheckHeaderForMessageTypeL
       
  8353 // ---------------------------------------------------------
       
  8354 //
       
  8355 void CUniEditorAppUi::CheckHeaderForMessageTypeL()
       
  8356     {
       
  8357     CUniEditorDocument* doc = Document();
       
  8358     
       
  8359     if( iMtm->MessageTypeSetting() != EUniMessageTypeSettingAutomatic )
       
  8360         { // We are in locked mode so refresh email addr length and return
       
  8361         iHeader->RefreshLongestEmailAddressL();
       
  8362         return;
       
  8363         }
       
  8364 
       
  8365     // We are in automatic mode so lets check everything
       
  8366     TUniState oldState = doc->UniState();
       
  8367 
       
  8368     if( iHeader->IsHeaderSmsL() )
       
  8369         {   // Set current header state as sms
       
  8370         doc->SetHeaderUniState( EUniSms );
       
  8371         }
       
  8372     else
       
  8373         {   // Set current header state as mms
       
  8374         doc->SetHeaderUniState( EUniMms );
       
  8375         }
       
  8376 
       
  8377     if( oldState != doc->UniState() )
       
  8378         {   // If the state is not the same anymore, update title and show popup
       
  8379         SetTitleL();
       
  8380         UpdateIndicatorIconsL();
       
  8381         ShowPopupNoteL( doc->UniState()==EUniMms?ETrue:EFalse );
       
  8382         UpdateToolbarL();
       
  8383         }
       
  8384     }
       
  8385 
       
  8386 // ---------------------------------------------------------
       
  8387 // CUniEditorAppUi::CheckBodyForMessageTypeL
       
  8388 // ---------------------------------------------------------
       
  8389 //
       
  8390 void CUniEditorAppUi::CheckBodyForMessageTypeL()
       
  8391     {
       
  8392     CUniEditorDocument* doc = Document();
       
  8393     
       
  8394     TUniMessageTypeSetting setting = iMtm->MessageTypeSetting();
       
  8395 
       
  8396     if( IsHardcodedSms() )
       
  8397         { // Just update iSmsLength and possible unicode mode
       
  8398         CheckSmsSizeAndUnicodeL();
       
  8399         return;
       
  8400         }
       
  8401     
       
  8402     if( setting == EUniMessageTypeSettingMms )
       
  8403         { // We are in locked mode so just leave
       
  8404         UpdateToolbarL();
       
  8405         return;
       
  8406         }
       
  8407 
       
  8408     TUniState oldState = doc->UniState();
       
  8409 
       
  8410     if( IsBodySmsCompatibleL() )
       
  8411         {   // Set current body state as sms
       
  8412         doc->SetBodyUniState( EUniSms );
       
  8413         }
       
  8414     else
       
  8415         {   // Set current body state as mms
       
  8416         doc->SetBodyUniState( EUniMms );
       
  8417         }
       
  8418 
       
  8419     if( oldState != doc->UniState() )
       
  8420         {   // If the state is not the same anymore, update title and show popup
       
  8421         SetTitleL();
       
  8422         UpdateIndicatorIconsL();
       
  8423         ShowPopupNoteL( doc->UniState()==EUniMms?ETrue:EFalse );
       
  8424         UpdateToolbarL();
       
  8425         
       
  8426         if( iNLTFeatureSupport )
       
  8427             {
       
  8428             //Turkish SMS-PREQ2265 specific
       
  8429             if(doc->UniState() == EUniSms)
       
  8430                 {
       
  8431                 //If the new state is SMS, Reset the SMS Settings and update the message length info 
       
  8432                 if(doc->SmsPlugin())
       
  8433                     {
       
  8434                     doc->SmsPlugin()->SetEncodingSettings(EFalse, doc->AlternativeEncodingType(), doc->CharSetSupport());
       
  8435                     }
       
  8436                 //Force to recalculate the SMS PDU info
       
  8437                 CheckSmsSizeAndUnicodeL();
       
  8438                 MsgLengthToNavipaneL( );
       
  8439                 }
       
  8440             }
       
  8441         }
       
  8442     }
       
  8443 
       
  8444 // ----------------------------------------------------
       
  8445 // CUniEditorAppUi::CreateMmsNaviSizeStringL
       
  8446 // 
       
  8447 // Rounds always up
       
  8448 // 0.00000 -> 0
       
  8449 // 0.00001 -> 0.1
       
  8450 // ..
       
  8451 // 0.10000 -> 0.1
       
  8452 // 0.10001 -> 0.2
       
  8453 // ..
       
  8454 // 9.89999 -> 9.9
       
  8455 // 9.90000 -> 9.9
       
  8456 // 9.90001 -> 10
       
  8457 //
       
  8458 // ----------------------------------------------------
       
  8459 //
       
  8460 void CUniEditorAppUi::CreateMmsNaviSizeStringL( const TInt aSizeInBytes,
       
  8461                                                 TDes& aSize,
       
  8462                                                 TInt& aInteger,
       
  8463                                                 TInt& aFragment )
       
  8464     {
       
  8465     aSize.Zero();
       
  8466 
       
  8467     // Integer part
       
  8468     aInteger = aSizeInBytes / KBytesInKilo;
       
  8469     // Up rounded fragment part -> can be 10:
       
  8470     aFragment = ( ( aSizeInBytes % KBytesInKilo ) * 10 + KBytesInKilo - 1) / KBytesInKilo;
       
  8471 
       
  8472     if ( aFragment >= 10 )
       
  8473         {
       
  8474         aInteger++;
       
  8475         aFragment = 0;
       
  8476         }
       
  8477 
       
  8478     if ( aInteger >= KOneDigitLimit )
       
  8479         {
       
  8480         // Show msg size without one digit accuracy
       
  8481         if ( aFragment )
       
  8482             {
       
  8483             aInteger++;
       
  8484             aFragment = 0;
       
  8485             }
       
  8486         MsgAttachmentUtils::FileSizeToStringL( aSize, aInteger * KBytesInKilo, ETrue );
       
  8487         }
       
  8488     else if ( aInteger != 0 || aFragment != 0 )
       
  8489         {
       
  8490         // There is some content and size is between 0 - 10 kB
       
  8491         TLocale loc;
       
  8492         TBuf<1> sep;
       
  8493         sep.Append( loc.DecimalSeparator() );
       
  8494 
       
  8495         StringLoader::Format( aSize, *iMmsLengthFormatBuffer, 0, aInteger );
       
  8496         HBufC* temp = aSize.AllocLC();
       
  8497         StringLoader::Format( aSize, *temp, 2, aFragment );
       
  8498         CleanupStack::PopAndDestroy();
       
  8499         temp = aSize.AllocLC();
       
  8500         StringLoader::Format( aSize, *temp, 1, sep );
       
  8501         CleanupStack::PopAndDestroy();
       
  8502         temp = NULL;
       
  8503         }
       
  8504     else
       
  8505         {
       
  8506         // Empty msg
       
  8507         MsgAttachmentUtils::FileSizeToStringL( aSize, 0, ETrue );
       
  8508         }
       
  8509     }
       
  8510                                         
       
  8511 // ---------------------------------------------------------
       
  8512 // CUniEditorAppUi::DoToolbarInsertOtherL
       
  8513 // ---------------------------------------------------------
       
  8514 //
       
  8515 void CUniEditorAppUi::DoToolbarInsertOtherL()
       
  8516     {
       
  8517     RArray<TInt> disabledItems;
       
  8518     CleanupClosePushL( disabledItems );
       
  8519     
       
  8520     TInt toolbarResourceId( KErrNotFound );
       
  8521     
       
  8522     if ( AknLayoutUtils::PenEnabled() )
       
  8523         {
       
  8524         toolbarResourceId = R_UNIEDITOR_INSERT_OTHER_QUERY;
       
  8525 
       
  8526 //        if ( Document()->CreationMode() == EMmsCreationModeRestricted )
       
  8527 //            {
       
  8528 //            disabledItems.Append( EUniCmdToolbarOtherFetchSVG );
       
  8529 //            }        
       
  8530         }    
       
  8531     
       
  8532     TInt selectedIndex( 0 );
       
  8533     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
       
  8534     dlg->PrepareLC( toolbarResourceId );
       
  8535     
       
  8536     CEikFormattedCellListBox* listbox = dlg->ListControl()->Listbox();
       
  8537     CDesCArray* itemArray = static_cast<CDesCArray*>( listbox->Model()->ItemTextArray() );
       
  8538     
       
  8539     if ( disabledItems.Count() > 0 )
       
  8540         {
       
  8541         for ( TInt currentItem = 0; currentItem < disabledItems.Count(); currentItem++ )
       
  8542             {
       
  8543             itemArray->Delete( disabledItems[ currentItem ] );
       
  8544             listbox->HandleItemRemovalL();
       
  8545             }
       
  8546         }
       
  8547         
       
  8548     if ( dlg->RunLD() )
       
  8549         {
       
  8550         for ( TInt currentItem = disabledItems.Count() - 1; currentItem >= 0 ; currentItem-- )
       
  8551             {
       
  8552             if ( selectedIndex >= disabledItems[ currentItem ] )
       
  8553                 {
       
  8554                 selectedIndex++;
       
  8555                 }
       
  8556             }
       
  8557         
       
  8558         switch ( selectedIndex )    
       
  8559             {
       
  8560 //            case EUniCmdToolbarOtherFetchSVG:
       
  8561 //                {
       
  8562 //                DoUserInsertSvgL();
       
  8563 //                break;
       
  8564 //                }
       
  8565             case EUniCmdToolbarOtherFetchTextAtta:
       
  8566                 {
       
  8567                 DoUserInsertOtherFileL( ETextFile );
       
  8568                 break;
       
  8569                 }
       
  8570             case EUniCmdToolbarOtherFetchOtherFiles:
       
  8571                 {
       
  8572                 DoUserInsertOtherFileL( EOtherFile );
       
  8573                 break;
       
  8574                 }
       
  8575             default:
       
  8576                 {
       
  8577                 __ASSERT_DEBUG( EFalse, Panic( EUniUnsupportedCommand ) );
       
  8578                 break;
       
  8579                 }
       
  8580             }
       
  8581         }
       
  8582         
       
  8583     CleanupStack::PopAndDestroy( &disabledItems );
       
  8584     }
       
  8585 
       
  8586 // ---------------------------------------------------------
       
  8587 // CUniEditorAppUi::ShowListQueryL
       
  8588 // ---------------------------------------------------------
       
  8589 //
       
  8590 TBool CUniEditorAppUi::ShowListQueryL( TInt aResourceID, TInt& aSelectedIndex ) const
       
  8591     {
       
  8592     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &aSelectedIndex );
       
  8593     dlg->PrepareLC( aResourceID );
       
  8594     return dlg->RunLD();
       
  8595     }
       
  8596 
       
  8597 // ---------------------------------------------------------
       
  8598 // CUniEditorAppUi::HidePopupNote
       
  8599 // ---------------------------------------------------------
       
  8600 //
       
  8601 void CUniEditorAppUi::HidePopupNote()
       
  8602     {
       
  8603     if( iPopupNote )
       
  8604         {
       
  8605         iPopupNote->HideInfoPopupNote();    
       
  8606         }
       
  8607     }
       
  8608     
       
  8609 // ---------------------------------------------------------
       
  8610 // CUniEditorAppUi::ShowPopupNoteL
       
  8611 // ---------------------------------------------------------
       
  8612 //
       
  8613 void CUniEditorAppUi::ShowPopupNoteL( TBool aMms )
       
  8614     {
       
  8615     if( iPopupNote && iPopupChangedMmsBuffer )
       
  8616         {
       
  8617         // additional check  iPopupChangedMmsBuffer is required as iPopupNote
       
  8618         // will be intialized in ConstructL but not iPopupChangedMmsBuffer.
       
  8619         // This change is done as part of Korean req.
       
  8620             ShowDiscreetPopUpL(aMms? iPopupChangedMmsBuffer->Des(): iPopupChangedSmsBuffer->Des());
       
  8621         }
       
  8622     }
       
  8623  
       
  8624 // ---------------------------------------------------------
       
  8625 // CUniEditorAppUi::PlayFocusedItemL
       
  8626 // ---------------------------------------------------------
       
  8627 //
       
  8628 void CUniEditorAppUi::PlayFocusedItemL()
       
  8629     {
       
  8630     if ( Document()->DataModel()->SmilType() == E3GPPSmil ||
       
  8631          Document()->DataModel()->SmilType() == ETemplateSmil )
       
  8632         { 
       
  8633         // There's presentation focused -> play it        
       
  8634         PlayPresentationL();
       
  8635         return;
       
  8636         }
       
  8637 
       
  8638     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  8639 
       
  8640     TUniRegion region = EUniRegionImage;
       
  8641 
       
  8642     if ( ctrl )
       
  8643         {
       
  8644         switch ( ctrl->ControlId() )
       
  8645             {
       
  8646             case EMsgComponentIdAudio:
       
  8647                 {
       
  8648                 region = EUniRegionAudio;
       
  8649                 }
       
  8650             case EMsgComponentIdImage:
       
  8651             case EMsgComponentIdVideo:
       
  8652             case EMsgComponentIdSvg:
       
  8653                 {
       
  8654                 CUniObject* obj = iSmilModel->GetObject( Document()->CurrentSlide(), region );
       
  8655                 // Coverty fix, Null pointer return , http://ousrv057/cov.cgi?cid=37100
       
  8656                 if(obj)
       
  8657                 {
       
  8658                   if( obj->Corrupted() )
       
  8659                     { // Object is corrupt -> just show note
       
  8660                     ShowInformationNoteL( R_UNIEDITOR_CANNOT_OPEN_CORRUPT, EFalse );
       
  8661                     }
       
  8662                   else
       
  8663                     {
       
  8664                     RFile file = CUniDataUtils::GetAttachmentFileL( Document()->DataModel()->Mtm(), obj->AttachmentId() );
       
  8665                     CleanupClosePushL( file );
       
  8666                     TDataType dataType( obj->MimeType() );
       
  8667                     
       
  8668                     if ( !iDocHandler )
       
  8669                         {
       
  8670                         iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() );
       
  8671                         iDocHandler->SetExitObserver( this );
       
  8672                         }
       
  8673                     
       
  8674                     if ( obj->DrmInfo() )
       
  8675                         {
       
  8676                         obj->DrmInfo()->ReleaseRights();
       
  8677                         }
       
  8678                     
       
  8679                    // Since Activating input blockers will block the command CEIkCmdEXit. So used the flag 
       
  8680                    //ActivateInputBlockerL( NULL );
       
  8681                     iEditorFlags |= EMsgEditInProgress;
       
  8682                     TRAPD(ret,iDocHandler->OpenFileEmbeddedL( file, dataType ));
       
  8683                     
       
  8684                     CleanupStack::PopAndDestroy( &file );
       
  8685                     
       
  8686                     if(ret != KErrNone)
       
  8687                         {
       
  8688                          iEditorFlags &= ~EMsgEditInProgress;   
       
  8689                          //  DeactivateInputBlocker();
       
  8690                         }
       
  8691                     }
       
  8692                   }
       
  8693                 break;
       
  8694                 }
       
  8695             default:
       
  8696                 {
       
  8697                 break;
       
  8698                 }
       
  8699             }
       
  8700         }
       
  8701     }
       
  8702 
       
  8703 // ---------------------------------------------------------
       
  8704 // CUniEditorAppUi::CheckMaxSmsSizeAndShowNoteL
       
  8705 // ---------------------------------------------------------
       
  8706 //
       
  8707 void CUniEditorAppUi::CheckMaxSmsSizeAndShowNoteL( TBool aSendCheck /*= EFalse*/ )
       
  8708     {
       
  8709     CUniEditorDocument* doc = Document();
       
  8710 
       
  8711     if( !aSendCheck )
       
  8712         {
       
  8713         if( !IsHardcodedSms() )
       
  8714             { // Just return
       
  8715             iEditorFlags &= ~EMaxSmsSizeNoteShown;
       
  8716             return;
       
  8717             }
       
  8718         }
       
  8719     else
       
  8720         {
       
  8721         if( Document()->UniState() != EUniSms )
       
  8722             { // UniState is MMS -> just return
       
  8723             iEditorFlags &= ~EMaxSmsSizeNoteShown;
       
  8724             return;
       
  8725             }
       
  8726         }
       
  8727     
       
  8728     TInt lengthOne( 0 );
       
  8729     TInt lengthMany( 0 );
       
  8730     
       
  8731     doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  8732 
       
  8733     TInt maxLen = lengthOne;
       
  8734   
       
  8735     if( doc->AbsoluteMaxSmsParts() > 1 )
       
  8736         {
       
  8737         maxLen = doc->AbsoluteMaxSmsParts()*lengthMany;
       
  8738         }
       
  8739     
       
  8740     if ( doc->AbsoluteMaxSmsCharacters() > 0 )
       
  8741         {
       
  8742         maxLen = doc->AbsoluteMaxSmsCharacters();
       
  8743         }
       
  8744     
       
  8745     TInt totalLen = iSmsBodyLength + iSmsSubjectLength;
       
  8746 
       
  8747     if( doc->EmailOverSmsSupported() )
       
  8748         {
       
  8749         // This length is needed by recipient and subject separator chars
       
  8750         TInt separatorLen = 0;
       
  8751 
       
  8752         TInt emailAddrLen = iHeader->LongestEmailAddress();
       
  8753         
       
  8754         if( emailAddrLen )
       
  8755             {
       
  8756             separatorLen++; // one extra char needed by separator char
       
  8757             }
       
  8758 
       
  8759         totalLen += emailAddrLen + separatorLen;
       
  8760         }
       
  8761 
       
  8762     if( totalLen <= maxLen-1 )
       
  8763         { // Length is under the max size -> just return
       
  8764         iEditorFlags &= ~EMaxSmsSizeNoteShown;
       
  8765         return;
       
  8766         }
       
  8767 
       
  8768     if( !aSendCheck && iEditorFlags & EMaxSmsSizeNoteShown )
       
  8769         { // The note has been shown -> just return
       
  8770         return;                
       
  8771         }
       
  8772 
       
  8773     iEditorFlags |= EMaxSmsSizeNoteShown;
       
  8774     
       
  8775     if( totalLen == maxLen )
       
  8776         { 
       
  8777         if( aSendCheck )
       
  8778             { // SMS is max length so it can still be sent
       
  8779             iEditorFlags &= ~EMaxSmsSizeNoteShown;
       
  8780             return;
       
  8781             }
       
  8782         else
       
  8783             { 
       
  8784             if( iEditorFlags & EShowSmsSizeNoteNextTime )
       
  8785                 {
       
  8786                 // Show "Cannot add text"
       
  8787                 ShowConfirmableInfoL( R_UNIEDITOR_SMS_LENGTH_EXCEEDED );
       
  8788                 // We remove this flag already now
       
  8789                 iEditorFlags &= ~EShowSmsSizeNoteNextTime;
       
  8790                 }
       
  8791             else
       
  8792                 {
       
  8793                 // Show the note next time
       
  8794                 iEditorFlags |= EShowSmsSizeNoteNextTime;
       
  8795                 // Remove this as it's not shown already
       
  8796                 iEditorFlags &= ~EMaxSmsSizeNoteShown;                
       
  8797                 }
       
  8798             }
       
  8799         }
       
  8800     else if( totalLen == maxLen+1 )
       
  8801         { // Show "Cannot send. Remove 1"
       
  8802         ShowConfirmableInfoL( R_UNIEDITOR_SMS_LENGTH_EXCEEDED_1 );
       
  8803         }
       
  8804     else
       
  8805         { // Show "Cannot send. Remove N"
       
  8806         if( doc->UnicodeCharacterMode() )
       
  8807             {
       
  8808             ShowConfirmableInfoL( R_UNIEDITOR_SMS_LENGTH_EXCEEDED_MANY_UNICODE );
       
  8809             }
       
  8810         else
       
  8811             {
       
  8812             TInt howMany = totalLen - maxLen;
       
  8813             HBufC* warningString = 
       
  8814                 StringLoader::LoadLC( R_UNIEDITOR_SMS_LENGTH_EXCEEDED_MANY, howMany, iCoeEnv );
       
  8815             ShowConfirmableInfoL( *warningString );
       
  8816             CleanupStack::PopAndDestroy( warningString );
       
  8817             }
       
  8818 
       
  8819         }
       
  8820     }
       
  8821  
       
  8822 // ---------------------------------------------------------
       
  8823 // CUniEditorAppUi::SetOrRemoveMaxSizeInEdwin
       
  8824 // ---------------------------------------------------------
       
  8825 //
       
  8826 void CUniEditorAppUi::SetOrRemoveMaxSizeInEdwin()
       
  8827     {
       
  8828     CUniEditorDocument* doc = Document();
       
  8829     
       
  8830     if( !IsHardcodedSms() )
       
  8831         { 
       
  8832         // No max limit so set the max TInt
       
  8833         if( BodyCtrlEditor() )
       
  8834             {
       
  8835             BodyCtrlEditor()->SetTextLimit( KMaxTInt );
       
  8836             }
       
  8837         return;
       
  8838         }
       
  8839         
       
  8840     // OK, message type is SMS
       
  8841     
       
  8842     TInt lengthOne( 0 );
       
  8843     TInt lengthMany( 0 );
       
  8844     
       
  8845     doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  8846 
       
  8847     TInt maxLen = lengthOne;
       
  8848   
       
  8849     if( doc->AbsoluteMaxSmsParts() > 1 )
       
  8850         {
       
  8851         maxLen = doc->AbsoluteMaxSmsParts()*lengthMany;
       
  8852         }
       
  8853     
       
  8854     if ( doc->AbsoluteMaxSmsCharacters() > 0 )
       
  8855         {
       
  8856         maxLen = doc->AbsoluteMaxSmsCharacters();
       
  8857         }
       
  8858     
       
  8859     CEikEdwin* bodyEd = BodyCtrlEditor();
       
  8860     CEikEdwin* subjEd = SubjectCtrlEditor();
       
  8861     
       
  8862     if( !bodyEd )
       
  8863         { 
       
  8864         // There's no body editor available -> just return
       
  8865         return;
       
  8866         }
       
  8867 
       
  8868     // This length is needed by recipient and subject separator chars
       
  8869     TInt separatorLen = 0;
       
  8870 
       
  8871     TInt emailAddrLen = iHeader->LongestEmailAddress();
       
  8872     
       
  8873     if( emailAddrLen )
       
  8874         {
       
  8875         separatorLen++; // one extra char needed by separator char
       
  8876         }
       
  8877 
       
  8878     // Max subject length is maxLen decreased by longest email address and body length
       
  8879     TInt maxSubjectLen = maxLen - emailAddrLen - iSmsBodyLength - separatorLen;
       
  8880     
       
  8881     if( maxSubjectLen > KUniEdMaxSubjectLen )
       
  8882         {
       
  8883         maxSubjectLen = KUniEdMaxSubjectLen;
       
  8884         }
       
  8885 
       
  8886     // Max body length is maxLen decreased by longest email address and subject length
       
  8887     TInt maxBodyLen = maxLen - emailAddrLen - iSmsSubjectLength - separatorLen;
       
  8888     
       
  8889     if( bodyEd->TextLength() > maxBodyLen )
       
  8890         { 
       
  8891         // If there's already too long body field -> increase the limit to avoid panic in edwin
       
  8892         maxBodyLen = bodyEd->TextLength();
       
  8893         }
       
  8894     
       
  8895     bodyEd->SetTextLimit( maxBodyLen );
       
  8896     
       
  8897     if( subjEd )
       
  8898         {
       
  8899         if( subjEd->TextLength() > maxSubjectLen )
       
  8900             { 
       
  8901             // If there's already too long subject field -> increase the limit to avoid panic in edwin
       
  8902             maxSubjectLen = subjEd->TextLength();
       
  8903             }
       
  8904         subjEd->SetTextLimit( maxSubjectLen );
       
  8905         }
       
  8906     }
       
  8907 
       
  8908 // ---------------------------------------------------------
       
  8909 // CUniEditorAppUi::CheckMaxRecipientsAndShowNoteL
       
  8910 // ---------------------------------------------------------
       
  8911 //
       
  8912 TBool CUniEditorAppUi::CheckMaxRecipientsAndShowNoteL( TBool aSendCheck /*= EFalse*/ )
       
  8913     {
       
  8914     
       
  8915     TInt maxRecipients = 0;
       
  8916     
       
  8917     CUniEditorDocument* doc = Document();
       
  8918     
       
  8919     TUniState state = doc->UniState();
       
  8920     
       
  8921     if( IsHardcodedSms() )
       
  8922         {
       
  8923         maxRecipients = doc->MaxSmsRecipients();
       
  8924         }
       
  8925     else
       
  8926         {
       
  8927         maxRecipients = doc->MaxMmsRecipients();
       
  8928         }
       
  8929     
       
  8930     TInt recipientCount = 0;
       
  8931     
       
  8932     CMsgAddressControl* addrCntrl = ToCtrl();
       
  8933     
       
  8934     if( addrCntrl )
       
  8935         {
       
  8936         recipientCount = addrCntrl->GetRecipientsL()->Count();
       
  8937         }
       
  8938     
       
  8939     if( state == EUniMms ) // If the current state is mms,
       
  8940         { // add also possible CC and BCC recipients
       
  8941         addrCntrl = iView->ControlById( EMsgComponentIdCc )?
       
  8942             static_cast<CMsgAddressControl*>(iView->ControlById( EMsgComponentIdCc ) ):NULL;
       
  8943         if( addrCntrl )
       
  8944             {
       
  8945             recipientCount += addrCntrl->GetRecipientsL()->Count();
       
  8946             }
       
  8947         addrCntrl = iView->ControlById( EMsgComponentIdBcc )?
       
  8948             static_cast<CMsgAddressControl*>(iView->ControlById( EMsgComponentIdBcc ) ):NULL;
       
  8949         if( addrCntrl )
       
  8950             {
       
  8951             recipientCount += addrCntrl->GetRecipientsL()->Count();
       
  8952             }
       
  8953         }
       
  8954 
       
  8955     if( recipientCount <= maxRecipients )
       
  8956         { // ok number of recipients
       
  8957         iEditorFlags &= ~EMaxRecipientShown;
       
  8958         return ETrue;
       
  8959         }
       
  8960         
       
  8961 /* This is to be removed from UI spec (max recipients reached
       
  8962     if( !aSendCheck )
       
  8963         {
       
  8964         if( iEditorFlags & EMaxRecipientShown )
       
  8965             { // Note is already shown
       
  8966             return EFalse;
       
  8967             }
       
  8968         if( recipientCount == maxRecipients )
       
  8969             {
       
  8970             ShowConfirmableInfoL( R_UNIEDITOR_MAX_RECIPIENTS_REACHED );
       
  8971             iEditorFlags |= EMaxRecipientShown;
       
  8972             return EFalse;
       
  8973             }
       
  8974         }
       
  8975   
       
  8976         
       
  8977     if( recipientCount == maxRecipients )
       
  8978         { // This time aSendCheck is certainly ETrue so no note is needed
       
  8979         return ETrue;
       
  8980         }*/
       
  8981   
       
  8982     if( iEditorFlags & EMaxRecipientShown && !aSendCheck )
       
  8983         { // Note is already shown and this is not send check
       
  8984         return EFalse;
       
  8985         }
       
  8986     
       
  8987     iEditorFlags |= EMaxRecipientShown;
       
  8988     
       
  8989     TInt waitRes( KErrNotFound );
       
  8990     
       
  8991     if ( iWaitDialog )
       
  8992         {
       
  8993         waitRes = iWaitResId;
       
  8994         RemoveWaitNote();
       
  8995         }   
       
  8996     
       
  8997     if( recipientCount == maxRecipients + 1 )
       
  8998         {
       
  8999         ShowConfirmableInfoL( R_UNIEDITOR_MAX_RECIPIENTS_EXCEEDED_1 );
       
  9000         }
       
  9001     else
       
  9002         {
       
  9003         HBufC* warningString = 
       
  9004             StringLoader::LoadLC( R_UNIEDITOR_MAX_RECIPIENTS_EXCEEDED_MANY, 
       
  9005                                   recipientCount - maxRecipients, 
       
  9006                                   iCoeEnv );
       
  9007             
       
  9008         ShowConfirmableInfoL( *warningString );
       
  9009         
       
  9010         CleanupStack::PopAndDestroy( warningString );
       
  9011         }
       
  9012     
       
  9013     if ( waitRes != KErrNotFound )
       
  9014         {
       
  9015         ShowWaitNoteL( waitRes );
       
  9016         }
       
  9017     
       
  9018     return EFalse;
       
  9019     }
       
  9020 
       
  9021 // ---------------------------------------------------------
       
  9022 // CUniEditorAppUi::UpdateMiddleSoftkeyL
       
  9023 // ---------------------------------------------------------
       
  9024 //
       
  9025 void CUniEditorAppUi::UpdateMiddleSoftkeyL()
       
  9026     {
       
  9027     /* This is just a placeholder so far */
       
  9028     TInt resId = 0;
       
  9029 
       
  9030     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  9031 
       
  9032     if ( ctrl )
       
  9033         {
       
  9034         switch ( ctrl->ControlId() )
       
  9035             {
       
  9036             case EMsgComponentIdTo:
       
  9037             case EMsgComponentIdCc:
       
  9038             case EMsgComponentIdBcc:
       
  9039                 {
       
  9040                    if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  9041                     {
       
  9042                     break;
       
  9043                     }
       
  9044                 
       
  9045                 resId = R_UNI_MSK_BUTTON_ADD;
       
  9046                 }
       
  9047                 break;
       
  9048             case EMsgComponentIdAttachment:
       
  9049                 {
       
  9050                 resId = R_UNI_MSK_BUTTON_OBJECTS;
       
  9051                 break;
       
  9052                 }
       
  9053             case EMsgComponentIdImage:
       
  9054                 if ( Document()->DataModel()->SmilType() == E3GPPSmil )
       
  9055                     { // focus is on "no-edit" SMIL icon
       
  9056                     resId = R_UNI_MSK_BUTTON_PLAY_PRES;
       
  9057                     } 
       
  9058                 else
       
  9059                     { // ordinary image
       
  9060                     resId = R_UNI_MSK_BUTTON_VIEW_IMAGE;
       
  9061                     }
       
  9062                 break;
       
  9063             case EMsgComponentIdVideo:
       
  9064                 {
       
  9065                 resId = R_UNI_MSK_BUTTON_PLAY_VIDEO;
       
  9066                 break;
       
  9067                 }
       
  9068             case EMsgComponentIdAudio:
       
  9069                 {
       
  9070                 resId = R_UNI_MSK_BUTTON_PLAY_AUDIO;
       
  9071                 break;
       
  9072                 }
       
  9073             case EMsgComponentIdSvg:
       
  9074                 {
       
  9075                 resId = R_UNI_MSK_BUTTON_PLAY_SVG;
       
  9076                 break;
       
  9077                 }
       
  9078             case EMsgComponentIdBody:
       
  9079                 {
       
  9080                 resId = R_UNI_MSK_BUTTON_CONTEXT_MENU;
       
  9081                 MenuBar()->SetContextMenuTitleResourceId( R_UNIEDITOR_CONTEXT_MENUBAR );
       
  9082                 break;
       
  9083                 }
       
  9084 
       
  9085             case EMsgComponentIdSubject:
       
  9086             default:
       
  9087                 break;
       
  9088             }
       
  9089         }
       
  9090 
       
  9091     if ( resId != iMskResId )
       
  9092         {
       
  9093         const TInt KMskPosition = 3;
       
  9094         CEikButtonGroupContainer* cba = Cba();
       
  9095         if( resId != 0 )
       
  9096             {
       
  9097             cba->SetCommandL( KMskPosition, resId );
       
  9098             }
       
  9099         else
       
  9100             { // nullify the command
       
  9101             cba->SetCommandL( KMskPosition, 0, KNullDesC() );
       
  9102             }
       
  9103         cba->DrawNow();
       
  9104         iMskResId = resId;
       
  9105         }
       
  9106     return;
       
  9107     }
       
  9108 
       
  9109 // ---------------------------------------------------------
       
  9110 // CUniEditorAppUi::SetInputModeToAddressFields
       
  9111 // ---------------------------------------------------------
       
  9112 //
       
  9113 void CUniEditorAppUi::SetInputModeToAddressFields( TInt aInputMode )
       
  9114     {
       
  9115     for (TInt i = CUniEditorHeader::EHeaderAddressTo; 
       
  9116         i <= CUniEditorHeader::EHeaderAddressBcc; i++ )
       
  9117         {    
       
  9118         if ( iHeader &&  
       
  9119              iHeader->AddressControl( static_cast<CUniEditorHeader::THeaderFields> (i) ) )
       
  9120             {
       
  9121             iHeader->AddressControl( 
       
  9122                 static_cast<CUniEditorHeader::THeaderFields> (i) )
       
  9123                     ->Editor().SetAknEditorCurrentInputMode( aInputMode );
       
  9124             }
       
  9125         }
       
  9126     
       
  9127     }
       
  9128 
       
  9129 // ---------------------------------------------------------
       
  9130 // CUniEditorAppUi::DoEditMmsPriorityL
       
  9131 // ---------------------------------------------------------
       
  9132 //
       
  9133 void CUniEditorAppUi::DoEditMmsPriorityL()
       
  9134     {
       
  9135 
       
  9136     TUniSendingSettings settings;
       
  9137     CUniEditorPlugin* plugin = MmsPlugin();
       
  9138 
       
  9139     if( plugin )
       
  9140         {
       
  9141         plugin->GetSendingSettingsL( settings );
       
  9142         }
       
  9143 
       
  9144     TInt currentlySelected = 0;
       
  9145     switch( settings.iPriority )
       
  9146         {
       
  9147         case TUniSendingSettings::EUniPriorityNormal:
       
  9148             currentlySelected = 1;
       
  9149             break;
       
  9150         case TUniSendingSettings::EUniPriorityLow:
       
  9151             currentlySelected = 2;
       
  9152             break;
       
  9153         default:
       
  9154             break;
       
  9155         }
       
  9156     
       
  9157     // Create listbox    
       
  9158     CAknSingleGraphicPopupMenuStyleListBox* listBox = new (ELeave) CAknSingleGraphicPopupMenuStyleListBox;
       
  9159     CleanupStack::PushL( listBox );
       
  9160     
       
  9161     // Create popup
       
  9162     CAknPopupList* popup = CAknPopupList::NewL( 
       
  9163                 listBox, 
       
  9164                 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, 
       
  9165                 AknPopupLayouts::EMenuGraphicWindow );
       
  9166     CleanupStack::PushL( popup );
       
  9167 
       
  9168     // Construct listbox
       
  9169     listBox->ConstructL( popup, CEikListBox::ELeftDownInViewRect );
       
  9170     listBox->CreateScrollBarFrameL( ETrue );
       
  9171     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
  9172                                                       CEikScrollBarFrame::EAuto );
       
  9173   
       
  9174     // Set title    
       
  9175     HBufC* title = StringLoader::LoadLC( R_UNIEDITOR_PRIORITY_TITLE, iCoeEnv );
       
  9176     popup->SetTitleL( title->Des() );
       
  9177     CleanupStack::PopAndDestroy( title );
       
  9178 
       
  9179     CAknIconArray* iconArray = RadioButtonArrayL();
       
  9180     listBox->ItemDrawer()->FormattedCellData()->SetIconArray( iconArray ); // FormattedCellData owns
       
  9181 
       
  9182     listBox->HandleItemAdditionL();
       
  9183 
       
  9184     TResourceReader reader;
       
  9185     iEikonEnv->CreateResourceReaderLC( reader, R_UNI_PRIORITY_LIST );
       
  9186     
       
  9187     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KSettingsGranularity );
       
  9188     CleanupStack::PushL( items );
       
  9189 
       
  9190     // Get the labels from resources
       
  9191     const TInt count = reader.ReadInt16();
       
  9192 
       
  9193     for ( TInt loop = 0; loop < count; loop++ )
       
  9194         {
       
  9195         HBufC* label = reader.ReadHBufCL();        
       
  9196         CleanupStack::PushL( label );
       
  9197         TPtr pLabel = label->Des();
       
  9198         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( pLabel );
       
  9199         
       
  9200         TBuf<20> itemString;
       
  9201         if( currentlySelected == loop )
       
  9202             { // This one is selected
       
  9203             itemString.AppendNum( 1 );
       
  9204             }
       
  9205         else
       
  9206             {
       
  9207             itemString.AppendNum( 0 );
       
  9208             }
       
  9209 
       
  9210         itemString.Append( _L("\t") );
       
  9211         itemString.Append( pLabel );
       
  9212         items->AppendL( itemString );
       
  9213         
       
  9214         CleanupStack::PopAndDestroy( label );
       
  9215         label = NULL;
       
  9216         }
       
  9217 
       
  9218     CTextListBoxModel* model = listBox->Model();
       
  9219     model->SetItemTextArray( items );
       
  9220     model->SetOwnershipType( ELbmOwnsItemArray );
       
  9221     CleanupStack::Pop( items ); // model owns it now
       
  9222     CleanupStack::PopAndDestroy(); // reader 
       
  9223 
       
  9224     listBox->SetCurrentItemIndexAndDraw( currentlySelected );
       
  9225 
       
  9226     TInt result = popup->ExecuteLD();
       
  9227 
       
  9228     if( result )
       
  9229         {
       
  9230         // OK, user chose the priority bit
       
  9231         switch( listBox->CurrentItemIndex() )
       
  9232             {
       
  9233             case 0:
       
  9234                 {
       
  9235                 settings.iPriority = TUniSendingSettings::EUniPriorityHigh;
       
  9236                 break;
       
  9237                 }
       
  9238             case 1:
       
  9239                 {
       
  9240                 settings.iPriority = TUniSendingSettings::EUniPriorityNormal;
       
  9241                 break;
       
  9242                 }
       
  9243             default:
       
  9244                 {
       
  9245                 settings.iPriority = TUniSendingSettings::EUniPriorityLow;
       
  9246                 break;
       
  9247                 }
       
  9248             }
       
  9249             
       
  9250         if( plugin )
       
  9251             {
       
  9252             plugin->SetSendingSettingsL( settings );
       
  9253             }
       
  9254             
       
  9255         UpdateIndicatorIconsL();
       
  9256         }
       
  9257     CleanupStack::Pop(); // for popup
       
  9258     CleanupStack::PopAndDestroy( listBox ); 
       
  9259     }
       
  9260 
       
  9261 // ---------------------------------------------------------
       
  9262 // CUniEditorAppUi::RadioButtonArrayL
       
  9263 // ---------------------------------------------------------
       
  9264 //
       
  9265 CAknIconArray* CUniEditorAppUi::RadioButtonArrayL()
       
  9266     {
       
  9267     TFileName* fileName = new( ELeave ) TFileName;
       
  9268     CleanupStack::PushL( fileName );
       
  9269     
       
  9270     fileName->Copy( KAvkonBitmapFile );
       
  9271 
       
  9272     CAknIconArray* iconArray = new (ELeave) CAknIconArray( 2 );
       
  9273     CleanupStack::PushL( iconArray ); 
       
  9274 
       
  9275     CFbsBitmap* bitmap = NULL;
       
  9276     CFbsBitmap* mask = NULL;
       
  9277     CGulIcon* icon = NULL;
       
  9278 
       
  9279     TAknsItemID skinId = KAknsIIDQgnPropRadiobuttOff;
       
  9280     TInt bitmapId = EMbmAvkonQgn_prop_radiobutt_off;
       
  9281 
       
  9282     AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
  9283                             skinId,
       
  9284                             bitmap,
       
  9285                             mask,
       
  9286                             *fileName,
       
  9287                             bitmapId,
       
  9288                             bitmapId+1 );
       
  9289         
       
  9290     CleanupStack::PushL( bitmap );
       
  9291     CleanupStack::PushL( mask );
       
  9292     icon = CGulIcon::NewL( bitmap, mask );
       
  9293     CleanupStack::Pop( 2, bitmap );
       
  9294     CleanupStack::PushL( icon ); 
       
  9295     iconArray->AppendL( icon );
       
  9296     CleanupStack::Pop();   // icon
       
  9297 
       
  9298     skinId = KAknsIIDQgnPropRadiobuttOn;
       
  9299     bitmapId = EMbmAvkonQgn_prop_radiobutt_on;
       
  9300 
       
  9301     AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
  9302                             skinId,
       
  9303                             bitmap,
       
  9304                             mask,
       
  9305                             *fileName,
       
  9306                             bitmapId,
       
  9307                             bitmapId+1 );
       
  9308         
       
  9309     CleanupStack::PushL( bitmap );
       
  9310     CleanupStack::PushL( mask );
       
  9311     
       
  9312     icon = CGulIcon::NewL( bitmap, mask );
       
  9313     CleanupStack::Pop( 2 );
       
  9314     CleanupStack::PushL( icon ); 
       
  9315     
       
  9316     iconArray->AppendL( icon );
       
  9317     CleanupStack::Pop();   // icon
       
  9318 
       
  9319     CleanupStack::Pop( iconArray );
       
  9320     CleanupStack::PopAndDestroy( fileName );
       
  9321     return iconArray;
       
  9322     }
       
  9323 
       
  9324 
       
  9325 // ---------------------------------------------------------
       
  9326 // CUniEditorAppUi::ConfirmSmsSendInMultiplePartsL
       
  9327 // ---------------------------------------------------------
       
  9328 //
       
  9329 TBool CUniEditorAppUi::ConfirmSmsSendInMultiplePartsL()
       
  9330     {
       
  9331     // If it's variated off -> return ETrue
       
  9332     if( !( iEditorFlags & EShowSmsSentInManyParts ) )
       
  9333         {
       
  9334         return ETrue;
       
  9335         }
       
  9336     
       
  9337     CUniEditorDocument* doc = Document();
       
  9338     
       
  9339     TInt lengthOne( 0 );
       
  9340     TInt lengthMany( 0 );
       
  9341     
       
  9342     doc->SmsCharacterLimits( lengthOne, lengthMany );
       
  9343 
       
  9344     TInt totalLen = iSmsBodyLength + iSmsSubjectLength;
       
  9345 
       
  9346     if ( doc->EmailOverSmsSupported() )
       
  9347         {
       
  9348         // This length is needed by recipient and subject separator chars
       
  9349         TInt separatorLen = 0;
       
  9350 
       
  9351         TInt emailAddrLen = iHeader->LongestEmailAddress();
       
  9352         
       
  9353         if( emailAddrLen )
       
  9354             {
       
  9355             separatorLen++; // one extra char needed by separator char
       
  9356             }
       
  9357 
       
  9358         totalLen += emailAddrLen + separatorLen;
       
  9359         }
       
  9360 
       
  9361     if( totalLen <= lengthOne )
       
  9362         { // All fits in one message -> return ETrue
       
  9363         return ETrue;
       
  9364         }
       
  9365 
       
  9366     TInt messages = totalLen/lengthMany;
       
  9367     
       
  9368     if( totalLen%lengthMany )
       
  9369         { // If remainder is not zero -> add one
       
  9370         messages++;
       
  9371         }
       
  9372 
       
  9373     HBufC* qry = StringLoader::LoadLC( R_UNIEDITOR_SMS_SEND_MULTIPLE_PARTS, messages );
       
  9374     
       
  9375     if( ShowConfirmationNoQuestionQueryL( *qry ) )
       
  9376         {
       
  9377         CleanupStack::PopAndDestroy( qry );
       
  9378         return ETrue;
       
  9379         }
       
  9380         
       
  9381     CleanupStack::PopAndDestroy( qry );
       
  9382     return EFalse;
       
  9383     }
       
  9384 
       
  9385 // ---------------------------------------------------------
       
  9386 // CUniEditorAppUi::SetTitleIconsSizeL
       
  9387 //
       
  9388 // Sets the correct size from LAF for title MMS & SMS title icons
       
  9389 // ---------------------------------------------------------
       
  9390 //
       
  9391 void CUniEditorAppUi::SetTitleIconsSizeL()
       
  9392     {
       
  9393     SetTitleIconSizeL( iIconSms->Bitmap() );
       
  9394     SetTitleIconSizeL( iIconMms->Bitmap() );    
       
  9395     }
       
  9396  
       
  9397 // ---------------------------------------------------------
       
  9398 // CUniEditorAppUi::AcceptEmailAddresses
       
  9399 // ---------------------------------------------------------
       
  9400 //
       
  9401 TBool CUniEditorAppUi::AcceptEmailAddresses()
       
  9402     {
       
  9403     TBool retVal = ETrue;
       
  9404 
       
  9405     if( IsHardcodedSms() && !Document()->EmailOverSmsSupported() )
       
  9406         { // We are in locked SMS mode and no email over sms -> accept only numbers
       
  9407           retVal = EFalse;
       
  9408         }
       
  9409 
       
  9410     return retVal;
       
  9411     }
       
  9412 
       
  9413 // ---------------------------------------------------------
       
  9414 // CUniEditorAppUi::IsHardcodedSms
       
  9415 // ---------------------------------------------------------
       
  9416 //
       
  9417 TBool CUniEditorAppUi::IsHardcodedSms()
       
  9418     {
       
  9419     TBool hardSms = EFalse;
       
  9420 
       
  9421     if( iMtm->MessageTypeLocking() == EUniMessageTypeLocked )
       
  9422         { // the message type is pre-locked
       
  9423         if( iMtm->MessageTypeSetting() == EUniMessageTypeSettingSms )
       
  9424             { // to sms
       
  9425             hardSms = ETrue;
       
  9426             }
       
  9427         }
       
  9428     else if( iMtm->MessageTypeSetting() == EUniMessageTypeSettingSms )
       
  9429            { // message is not pre-locked, but manually locked to sms
       
  9430            hardSms = ETrue;
       
  9431            }
       
  9432 
       
  9433     return hardSms;    
       
  9434     }
       
  9435 
       
  9436 // ---------------------------------------------------------
       
  9437 // CUniEditorAppUi::ResolveLaunchFocusedControlL
       
  9438 // 
       
  9439 // Resolves the control id of control that should be focused after
       
  9440 // launch. Normal case is that first existing and empty control from To, Subject,
       
  9441 // body text control and image control is focused in this order.
       
  9442 //
       
  9443 // Exeptions to this is:
       
  9444 //
       
  9445 // Reply -> Body text field always focused.
       
  9446 // Locked SMS with vCard/vCal -> To address field always focused.
       
  9447 // ---------------------------------------------------------
       
  9448 //
       
  9449 TMsgControlId CUniEditorAppUi::ResolveLaunchFocusedControlL()
       
  9450     {
       
  9451     TMsgControlId result = EMsgComponentIdNull;
       
  9452     
       
  9453     if ( Document()->MessageType() == EUniReply )
       
  9454         {
       
  9455         result = EMsgComponentIdBody;
       
  9456         }
       
  9457     else if ( iEditorFlags & ELockedSmsWithAtta )
       
  9458         {
       
  9459         result = EMsgComponentIdTo;
       
  9460         }
       
  9461     else
       
  9462         {
       
  9463         CMsgAddressControl* toControl = ToCtrl();
       
  9464     
       
  9465         if ( toControl &&
       
  9466              toControl->GetRecipientsL()->Count() == 0 )
       
  9467             {
       
  9468             result = EMsgComponentIdTo;
       
  9469             }
       
  9470         else
       
  9471             {
       
  9472             if ( iSupportedFeatures & EUniFeatureSubject )
       
  9473                 {
       
  9474                 CMsgExpandableControl* subj = SubjectCtrl();
       
  9475                 if ( subj && 
       
  9476                      subj->TextContent().DocumentLength() == 0 )
       
  9477                     {
       
  9478                     result = EMsgComponentIdSubject;
       
  9479                     }
       
  9480                 }
       
  9481             
       
  9482             if ( result == EMsgComponentIdNull )
       
  9483                 {
       
  9484                 if ( BodyCtrl() )
       
  9485                     {
       
  9486                     result = EMsgComponentIdBody;
       
  9487                     }
       
  9488                 else if ( ImageCtrl() )
       
  9489                     {
       
  9490                     result = EMsgComponentIdImage;
       
  9491                     }
       
  9492                 
       
  9493                 }
       
  9494             }
       
  9495         }
       
  9496         
       
  9497     return result;
       
  9498     }
       
  9499  
       
  9500 // ---------------------------------------------------------
       
  9501 // CUniEditorAppUi::SetMessageTypeLockingL
       
  9502 // ---------------------------------------------------------
       
  9503 //
       
  9504 void CUniEditorAppUi::SetMessageTypeLockingL()
       
  9505     {
       
  9506     if ( SmsPlugin() && !MmsPlugin() )
       
  9507         { 
       
  9508         // Sms found, no mms
       
  9509         iMtm->SetMessageTypeSetting( EUniMessageTypeSettingSms );
       
  9510         iMtm->SetMessageTypeLocking( EUniMessageTypeLocked );
       
  9511         }
       
  9512     else if ( !SmsPlugin() && MmsPlugin() )
       
  9513         { 
       
  9514         // Mms found, no sms
       
  9515         iMtm->SetMessageTypeSetting( EUniMessageTypeSettingMms );
       
  9516         iMtm->SetMessageTypeLocking( EUniMessageTypeLocked );
       
  9517         }
       
  9518     else
       
  9519         { 
       
  9520         // If we are here, both sms and mms exist
       
  9521         if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  9522             { 
       
  9523             // If opening upload message -> lock is as mms
       
  9524             iMtm->SetMessageTypeSetting( EUniMessageTypeSettingMms );
       
  9525             iMtm->SetMessageTypeLocking( EUniMessageTypeLocked );
       
  9526             }
       
  9527         else
       
  9528             {
       
  9529             if ( iMtm->MessageTypeLocking() == EUniMessageTypeLockingNotSet )
       
  9530                 { 
       
  9531                 // It's not yet set -> check the settings of SMS conversion
       
  9532                 iMtm->SetMessageTypeLocking( EUniMessageTypeNotLocked );
       
  9533                 
       
  9534                 TUniSendingSettings settings;
       
  9535                 SmsPlugin()->GetSendingSettingsL( settings );
       
  9536 
       
  9537                 if ( settings.iMessageType == TUniSendingSettings::EUniMessageTypeFax  ||
       
  9538                      settings.iMessageType == TUniSendingSettings::EUniMessageTypePaging )
       
  9539                     { 
       
  9540                     // It's temporary locked to sms sub type (fax or pager)
       
  9541                     iMtm->SetMessageTypeSetting( EUniMessageTypeSettingSms );
       
  9542                     }
       
  9543                 else
       
  9544                     { 
       
  9545                     // Otherwise set it to automatic
       
  9546                     iMtm->SetMessageTypeSetting( EUniMessageTypeSettingAutomatic );
       
  9547                     }
       
  9548                 }
       
  9549             }
       
  9550         }
       
  9551     }
       
  9552  
       
  9553 // ---------------------------------------------------------
       
  9554 // CUniEditorAppUi::ActivateInputBlockerL
       
  9555 // ---------------------------------------------------------
       
  9556 //
       
  9557 void CUniEditorAppUi::ActivateInputBlockerL( CActive* aActiveObjectToCancel )
       
  9558     {
       
  9559     delete iInputBlocker;
       
  9560     iInputBlocker = NULL;
       
  9561     
       
  9562     iInputBlocker = CAknInputBlock::NewLC();    
       
  9563     CleanupStack::Pop( iInputBlocker );
       
  9564     
       
  9565     if ( aActiveObjectToCancel )
       
  9566         {
       
  9567         iInputBlocker->SetCancelActive( aActiveObjectToCancel );
       
  9568         }
       
  9569     }
       
  9570  
       
  9571 // ---------------------------------------------------------
       
  9572 // CUniEditorAppUi::DeactivateInputBlocker
       
  9573 // ---------------------------------------------------------
       
  9574 //
       
  9575 void CUniEditorAppUi::DeactivateInputBlocker()
       
  9576     {
       
  9577     if ( iInputBlocker )
       
  9578         {
       
  9579         iInputBlocker->SetCancelActive( NULL );    
       
  9580         delete iInputBlocker;
       
  9581         iInputBlocker = NULL;
       
  9582         }
       
  9583     }
       
  9584 
       
  9585 // ---------------------------------------------------------
       
  9586 // CUniEditorAppUi::UpdateToolbarL
       
  9587 // ---------------------------------------------------------
       
  9588 //
       
  9589 void CUniEditorAppUi::UpdateToolbarL()
       
  9590     {
       
  9591     if ( iFixedToolbar && !iFixedToolbar->IsDimmed()  )
       
  9592         {
       
  9593         iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarSend, EFalse, EFalse );
       
  9594         
       
  9595         if ( TUniMsvEntry::IsMmsUpload( Document()->Entry() ) )
       
  9596             {
       
  9597             iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarAddRecipient, ETrue, EFalse );
       
  9598             }
       
  9599         else
       
  9600             {
       
  9601             iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarAddRecipient, EFalse, EFalse );
       
  9602             }
       
  9603         
       
  9604         if ( IsHardcodedSms() ||
       
  9605              ( Document()->UniState() == EUniMms &&
       
  9606                Document()->DataModel()->SmilType() != EMmsSmil ) )
       
  9607 
       
  9608             {
       
  9609             iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, EFalse );
       
  9610             }
       
  9611         else
       
  9612             {
       
  9613             iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, EFalse, EFalse );
       
  9614             }
       
  9615         
       
  9616         iFixedToolbar->DrawNow();
       
  9617         }
       
  9618     }
       
  9619 
       
  9620 // ---------------------------------------------------------
       
  9621 // CUniEditorAppUi::CheckLockedSmsWithAttaL
       
  9622 // 
       
  9623 // Checks whether message is on locked SMS state with single
       
  9624 // vCard or vCal attachment. In this state text is not allowed
       
  9625 // to be entered into message. First performs state detection.
       
  9626 // If we are on locked SMS with attachment state focus is 
       
  9627 // moved away from subject or body control. Then both subject and
       
  9628 // body text controls are removed. If we are not in locked SMS
       
  9629 // with attachment state subject and body text ccontrol are added
       
  9630 // if appropriate (i.e. they have been removed due to locked SMS
       
  9631 // with attachment state and has not yet been added).
       
  9632 // ---------------------------------------------------------
       
  9633 //
       
  9634 void CUniEditorAppUi::CheckLockedSmsWithAttaL()
       
  9635     {
       
  9636     CUniDataModel* model = Document()->DataModel();
       
  9637     
       
  9638     TBool lockedSmsWithAtta( EFalse );
       
  9639     
       
  9640     if ( IsHardcodedSms() &&
       
  9641          model->AttachmentList().Count() == 1 )
       
  9642         {
       
  9643         CUniObject* obj = model->AttachmentList().GetByIndex( 0 );
       
  9644         if ( obj &&  
       
  9645              obj->MimeType().Length() > 0 &&   
       
  9646              ( obj->MimeType().CompareF( KMsgMimeVCard  ) == 0 || 
       
  9647 #if defined (__I_CAL_SUPPORT) && defined (RD_MESSAGING_ICAL_IMPORT)
       
  9648                obj->MimeType().CompareF( KMsgMimeICal  ) == 0 ||
       
  9649 #endif
       
  9650                obj->MimeType().CompareF( KMsgMimeVCal  ) == 0 ) )
       
  9651             {
       
  9652             lockedSmsWithAtta = ETrue;
       
  9653             }
       
  9654         } 
       
  9655     
       
  9656     if ( lockedSmsWithAtta )
       
  9657         {
       
  9658         iEditorFlags |= ELockedSmsWithAtta;
       
  9659         
       
  9660         CMsgBaseControl* focusedCtrl = iView->FocusedControl();
       
  9661         if ( focusedCtrl && 
       
  9662              ( focusedCtrl->ControlId() == EMsgComponentIdSubject ||
       
  9663                focusedCtrl->ControlId() == EMsgComponentIdBody ) )
       
  9664             {
       
  9665             iView->SetFocus( EMsgComponentIdTo );
       
  9666             }
       
  9667         
       
  9668         if ( iEditorFlags & ESubjectOkInSms &&
       
  9669              SubjectCtrl() )
       
  9670             {
       
  9671             iHeader->AddHeadersDeleteL( EUniFeatureSubject, EFalse );
       
  9672             }
       
  9673     
       
  9674         if ( !iStoredBodyControl )
       
  9675             {   
       
  9676             iStoredBodyControl = iView->RemoveControlL( EMsgComponentIdBody );
       
  9677             }
       
  9678         }
       
  9679     else
       
  9680         {  
       
  9681         if ( iEditorFlags & ELockedSmsWithAtta )
       
  9682             {
       
  9683             if ( iEditorFlags & ESubjectOkInSms &&
       
  9684                  !SubjectCtrl() )
       
  9685                 {
       
  9686                 // Determine if subject field is needed if subject is ok in SMS 
       
  9687                 // and there is no subject field.
       
  9688                 TInt headersVariation = iHeader->AddHeadersVariation();
       
  9689                 TInt headerConfig = iHeader->AddHeadersConfigL();
       
  9690                 
       
  9691                 if ( !( headersVariation & EUniFeatureSubjectConfigurable ) ||
       
  9692                       ( headersVariation & EUniFeatureSubject &&
       
  9693                         headerConfig & EUniFeatureSubject ) )
       
  9694                     {
       
  9695                     // Insert subject to SMS if it is always visible or selected
       
  9696                     // and configured on.
       
  9697                     iHeader->AddHeadersAddL( EUniFeatureSubject );
       
  9698                     }
       
  9699                 }
       
  9700             
       
  9701             if ( iStoredBodyControl )
       
  9702                 {   
       
  9703                 iView->AddControlL( iStoredBodyControl, EMsgComponentIdBody, EMsgFirstControl, EMsgBody );
       
  9704                 iStoredBodyControl = NULL;
       
  9705                 }
       
  9706             }
       
  9707         
       
  9708         iEditorFlags &= ~ELockedSmsWithAtta;
       
  9709         }
       
  9710     }
       
  9711      
       
  9712 
       
  9713 // ---------------------------------------------------------
       
  9714 // CUniEditorAppUi::SetFixedToolbarDimmed
       
  9715 // ---------------------------------------------------------
       
  9716 // 
       
  9717 void CUniEditorAppUi::SetFixedToolbarDimmed()
       
  9718     {
       
  9719     iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarSend, ETrue, ETrue );
       
  9720     iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarAddRecipient, ETrue, ETrue );        
       
  9721     iFixedToolbar->SetItemDimmed( EUniCmdFixedToolbarInsert, ETrue, ETrue );
       
  9722     }
       
  9723 
       
  9724 // ---------------------------------------------------------
       
  9725 // CUniEditorAppUi::EnableFixedToolbar
       
  9726 // ---------------------------------------------------------
       
  9727 // 
       
  9728 void CUniEditorAppUi::EnableFixedToolbar( TAny* aAny )
       
  9729     {
       
  9730     static_cast<CUniEditorAppUi*>( aAny )->DoEnableFixedToolbar();
       
  9731     }
       
  9732 // ---------------------------------------------------------
       
  9733 // CUniEditorAppUi::UpdateFixedToolbar
       
  9734 // ---------------------------------------------------------
       
  9735 // 
       
  9736 void CUniEditorAppUi::UpdateFixedToolbar( TAny* aAny )
       
  9737     {
       
  9738     static_cast<CUniEditorAppUi*>( aAny )->DoUpdateFixedToolbar();      
       
  9739     }
       
  9740 // ---------------------------------------------------------
       
  9741 // CUniEditorAppUi::DisableSendKey
       
  9742 // ---------------------------------------------------------
       
  9743 // 
       
  9744 void CUniEditorAppUi::DisableSendKey(TAny* aAny)
       
  9745 {
       
  9746 	static_cast<CUniEditorAppUi*>( aAny )->SetKeyEventFlags( EDisableSendKeyShort | EDisableSendKeyLong );
       
  9747 }
       
  9748 
       
  9749 // CUniEditorAppUi::CreateFixedToolbarL
       
  9750 // ---------------------------------------------------------
       
  9751 // 
       
  9752 void CUniEditorAppUi::CreateFixedToolbarL( TBool aSetDimmed )
       
  9753     {
       
  9754 #ifdef RD_SCALABLE_UI_V2
       
  9755     if ( AknLayoutUtils::PenEnabled() )
       
  9756         {        
       
  9757         if ( !iFixedToolbar )
       
  9758             {
       
  9759             iFixedToolbar = CAknToolbar::NewL( R_UNIEDITOR_TOOLBAR );
       
  9760             iFixedToolbar->SetToolbarObserver( this );            
       
  9761             
       
  9762              if ( aSetDimmed )
       
  9763                 {
       
  9764                 SetFixedToolbarDimmed();
       
  9765                 }
       
  9766             if ( !( iEditorFlags & EToolbarHidden ) )
       
  9767                 {
       
  9768                 iFixedToolbar->SetToolbarVisibility( ETrue, EFalse );
       
  9769                 }
       
  9770             }
       
  9771         
       
  9772         CEikAppUiFactory* appUiFactory = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() );
       
  9773         
       
  9774         CAknToolbar* oldFixedToolbar = appUiFactory->CurrentFixedToolbar();
       
  9775         if ( oldFixedToolbar != iFixedToolbar )
       
  9776             {
       
  9777             oldFixedToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  9778             appUiFactory->SetViewFixedToolbar( iFixedToolbar );     
       
  9779             }
       
  9780         
       
  9781        
       
  9782         }
       
  9783     else
       
  9784         {
       
  9785         static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() )->SetViewFixedToolbar( NULL );
       
  9786         
       
  9787         delete iFixedToolbar;
       
  9788         iFixedToolbar = NULL;
       
  9789         }
       
  9790 #endif // RD_SCALABLE_UI_V2
       
  9791     }
       
  9792 
       
  9793 // ---------------------------------------------------------
       
  9794 // CUniEditorAppUi::SetExtensionButtonDimmed
       
  9795 // ---------------------------------------------------------
       
  9796 // 
       
  9797 void CUniEditorAppUi::SetExtensionButtonDimmed( CAknToolbarExtension* aExtension, 
       
  9798                                                 TInt aButtonId, 
       
  9799                                                 TBool aDimmed )
       
  9800     { 
       
  9801     CAknButton* buttonControl = static_cast<CAknButton*>( aExtension->ControlOrNull( aButtonId ) );
       
  9802     if ( buttonControl &&
       
  9803          buttonControl->IsDimmed() != aDimmed )
       
  9804         {
       
  9805         buttonControl->SetDimmed( aDimmed );             
       
  9806         }
       
  9807     }
       
  9808 
       
  9809 // ---------------------------------------------------------
       
  9810 // CUniEditorAppUi::DoEnableFixedToolbar
       
  9811 // ---------------------------------------------------------
       
  9812 //
       
  9813 void CUniEditorAppUi::DoEnableFixedToolbar()
       
  9814     {
       
  9815     if ( iFixedToolbar )
       
  9816         {
       
  9817         iFixedToolbar->HideItemsAndDrawOnlyBackground( EFalse );
       
  9818         }
       
  9819     
       
  9820     iEditorFlags &= ~EToolbarHidden;
       
  9821     }
       
  9822 
       
  9823 // ---------------------------------------------------------
       
  9824 // CUniEditorAppUi::DoUpdateFixedToolbar
       
  9825 // Update the Toolbar which was dimmed while launching
       
  9826 // the Dialog 
       
  9827 // ---------------------------------------------------------
       
  9828 //
       
  9829 void CUniEditorAppUi::DoUpdateFixedToolbar()
       
  9830     {
       
  9831      TRAP_IGNORE(UpdateToolbarL());    
       
  9832     }
       
  9833 // ---------------------------------------------------------
       
  9834 // CUniEditorAppUi::DoEnterKeyL
       
  9835 //
       
  9836 // Performs a special handling for enter key when certain control is
       
  9837 // focused. Enter key presses are mapped to selection key presses in
       
  9838 // thse controls.
       
  9839 // ---------------------------------------------------------
       
  9840 // 
       
  9841 TBool CUniEditorAppUi::DoEnterKeyL()
       
  9842     {
       
  9843     TBool result( EFalse );
       
  9844     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  9845 
       
  9846     if ( ctrl )
       
  9847         {
       
  9848         switch ( ctrl->ControlId() )
       
  9849             {
       
  9850             case EMsgComponentIdAttachment:
       
  9851             case EMsgComponentIdImage:
       
  9852             case EMsgComponentIdVideo:
       
  9853             case EMsgComponentIdAudio:
       
  9854             case EMsgComponentIdSvg:
       
  9855                 {
       
  9856                 DoSelectionKeyL();
       
  9857                 result = ETrue;
       
  9858                 break;
       
  9859                 }
       
  9860             default:
       
  9861                 {
       
  9862                 break;
       
  9863                 }
       
  9864             }
       
  9865         }
       
  9866     
       
  9867     return result;
       
  9868     }
       
  9869 
       
  9870 // ---------------------------------------------------------
       
  9871 // CUniEditorAppUi::HandleNotifyInt
       
  9872 // ---------------------------------------------------------
       
  9873 //
       
  9874 void CUniEditorAppUi::HandleNotifyInt( TUint32 /*aId*/, TInt /*aNewValue*/ )
       
  9875     {
       
  9876     if( iNLTFeatureSupport )
       
  9877         {
       
  9878         //Turkish SMS-PREQ2265 specific
       
  9879         //Get the new lang id and corresponding alternative encoding if any
       
  9880         CUniEditorDocument *doc = Document();
       
  9881         TInt inputLang;
       
  9882               
       
  9883         //Update the setting cache, so that new language id is returned correctly
       
  9884         iAvkonEnv->SettingCache().Update(KEikInputLanguageChange);
       
  9885         inputLang = iAvkonEnv->SettingCache().InputLanguage();
       
  9886         iSettingsChanged = ETrue;
       
  9887         
       
  9888         TSmsEncoding alternateEncoding = doc->GetLanguageSpecificAltEncodingType(inputLang);
       
  9889         
       
  9890         doc->SetAlternativeEncodingType(alternateEncoding);
       
  9891         //Reset unicode mode to False and set the corresponding language alternative encoding type accordingly
       
  9892         if(doc->SmsPlugin())
       
  9893             {
       
  9894             doc->SmsPlugin()->SetEncodingSettings(EFalse, alternateEncoding, doc->CharSetSupport());
       
  9895             }        
       
  9896         }
       
  9897 	//TODO :: Should add check size and show note???
       
  9898     TRAP_IGNORE(
       
  9899         {
       
  9900         CheckSmsSizeAndUnicodeL();
       
  9901         MsgLengthToNavipaneL();
       
  9902         } );
       
  9903     }
       
  9904 
       
  9905 #ifdef RD_SCALABLE_UI_V2
       
  9906 // ---------------------------------------------------------
       
  9907 // CUniEditorAppUi::OnPeninputUiActivated
       
  9908 // ---------------------------------------------------------
       
  9909 // 
       
  9910 void CUniEditorAppUi::OnPeninputUiActivated()
       
  9911     {
       
  9912     TRAP_IGNORE( SmsMsgLenToPenInputL() );
       
  9913     }
       
  9914 
       
  9915 // ---------------------------------------------------------
       
  9916 // CUniEditorAppUi::OnPeninputUiDeactivated
       
  9917 // ---------------------------------------------------------
       
  9918 //
       
  9919 void CUniEditorAppUi::OnPeninputUiDeactivated()
       
  9920     {
       
  9921      if (AknLayoutUtils::PenEnabled() )
       
  9922         {
       
  9923            iPeninputServer.UpdateAppInfo( KNullDesC, EAppIndicatorMsg );    
       
  9924         }
       
  9925     }
       
  9926 #else
       
  9927 // ---------------------------------------------------------
       
  9928 // CUniEditorAppUi::OnPeninputUiActivated
       
  9929 // ---------------------------------------------------------
       
  9930 //
       
  9931 void CUniEditorAppUi::OnPeninputUiActivated()
       
  9932     {
       
  9933     }
       
  9934 
       
  9935 // ---------------------------------------------------------
       
  9936 // CUniEditorAppUi::OnPeninputUiDeactivated
       
  9937 // ---------------------------------------------------------
       
  9938 //
       
  9939 void CUniEditorAppUi::OnPeninputUiDeactivated()
       
  9940     {
       
  9941     }
       
  9942 #endif    
       
  9943 
       
  9944 // ---------------------------------------------------------
       
  9945 // CUniEditorAppUi::SmsMsgLenToPenInputL
       
  9946 // ---------------------------------------------------------
       
  9947 //
       
  9948 void CUniEditorAppUi::SmsMsgLenToPenInputL()
       
  9949     {
       
  9950     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  9951     CUniEditorDocument* doc = Document();
       
  9952            
       
  9953     if ( doc->UniState() == EUniSms && ctrl && iMsgLenToVKB)
       
  9954         {
       
  9955         if ( UpdateMsgLenToPenInput() )                      
       
  9956             {
       
  9957             MsgLengthToNavipaneL( ETrue );
       
  9958             }        
       
  9959         }
       
  9960     else
       
  9961         { 
       
  9962         if (AknLayoutUtils::PenEnabled() )
       
  9963             {
       
  9964             iPeninputServer.UpdateAppInfo( KNullDesC, EAppIndicatorMsg );    
       
  9965             }     
       
  9966         }        
       
  9967     }
       
  9968 TBool CUniEditorAppUi::UpdateMsgLenToPenInput()
       
  9969     {
       
  9970     CMsgBaseControl* ctrl = iView->FocusedControl();
       
  9971     if ( ctrl->ControlId() == EMsgComponentIdBody || 
       
  9972        ( ctrl->ControlId() == EMsgComponentIdSubject && iEditorFlags & ESubjectOkInSms ) )                      
       
  9973        {
       
  9974        return ETrue;
       
  9975        }
       
  9976     else
       
  9977        {
       
  9978        return EFalse;           
       
  9979        }
       
  9980         
       
  9981     }
       
  9982 
       
  9983 // ---------------------------------------------------------
       
  9984 // CUniEditorAppUi::ExitWithoutSave
       
  9985 //	Exits from the Unified Editor whne there is not sufficient memory to continue
       
  9986 // ---------------------------------------------------------
       
  9987 //
       
  9988 void CUniEditorAppUi::ExitWithoutSave()
       
  9989     {
       
  9990      DeactivateInputBlocker();
       
  9991      EndActiveWait();
       
  9992      RemoveWaitNote();
       
  9993      TRAP_IGNORE(ShowConfirmableInfoL( R_UNIEDITOR_NOT_ENOUGH_MEMORY));     
       
  9994      Exit( EAknSoftkeyClose );
       
  9995     }
       
  9996 // ---------------------------------------------------------
       
  9997 // CUniEditorAppUi::HandleLongTapEventL
       
  9998 //  Function for handling the long tap events
       
  9999 // ---------------------------------------------------------
       
 10000 //
       
 10001 void CUniEditorAppUi::HandleLongTapEventL(const TPoint& aPenEventLocation, 
       
 10002 										  const TPoint& aPenEventScreenLocation )
       
 10003     {
       
 10004     CMsgBaseControl* ctrl = iView->FocusedControl(); // ctrl can be NULL.
       
 10005     if ( ctrl && 
       
 10006          ( ctrl->ControlId() == EMsgComponentIdAudio ||
       
 10007                  ctrl->ControlId() == EMsgComponentIdImage ||
       
 10008                  ctrl->ControlId() == EMsgComponentIdVideo ||
       
 10009                  ctrl->ControlId() == EMsgComponentIdSvg ) )
       
 10010         {
       
 10011         TRect rect = ctrl->Rect();
       
 10012 
       
 10013         if ((!iTapConsumed)&&rect.Contains(aPenEventLocation))
       
 10014             {
       
 10015             if (iEmbeddedObjectStylusPopup)
       
 10016                 {
       
 10017                 delete iEmbeddedObjectStylusPopup;
       
 10018                 iEmbeddedObjectStylusPopup = NULL;
       
 10019                 }
       
 10020             iEmbeddedObjectStylusPopup = CAknStylusPopUpMenu::NewL(this,aPenEventLocation);
       
 10021             TResourceReader reader;
       
 10022             iCoeEnv->CreateResourceReaderLC(reader,R_UNIEDITOR_EMBEDDED_OBJECT_STYLUS_MENU );
       
 10023             iEmbeddedObjectStylusPopup->ConstructFromResourceL(reader);
       
 10024             CleanupStack::PopAndDestroy();
       
 10025             iEmbeddedObjectStylusPopup->SetPosition(aPenEventLocation);
       
 10026             iEmbeddedObjectStylusPopup->ShowMenu();
       
 10027             iTapConsumed = ETrue;
       
 10028             }
       
 10029         }   
       
 10030     }
       
 10031 
       
 10032 // ---------------------------------------------------------
       
 10033 // CUniEditorAppUi::IsObjectPathValidL
       
 10034 // Checks whether all inserted object's path are valid
       
 10035 // message.
       
 10036 // ---------------------------------------------------------
       
 10037 //
       
 10038 TBool CUniEditorAppUi::IsObjectsPathValidL() const
       
 10039     {
       
 10040     TBool bCanSave = ETrue;  
       
 10041     if ( Document()->DataModel()->SmilType() == EMmsSmil )
       
 10042         {
       
 10043         bCanSave = Document()->DataModel()->ObjectList().IsListValid();
       
 10044         
       
 10045         if(bCanSave)
       
 10046             {
       
 10047             bCanSave = Document()->DataModel()->AttachmentList().IsListValid();
       
 10048             }
       
 10049         }      
       
 10050     return bCanSave;
       
 10051     }
       
 10052 
       
 10053 // ---------------------------------------------------------
       
 10054 // CUniEditorAppUi::ShowDiscreetPopUpL
       
 10055 // Shows the Popup note in ITUT, when message size exceeds or deceeds 
       
 10056 // a certain limit or it changes from sms to mms and vice versa
       
 10057 // ---------------------------------------------------------
       
 10058 //
       
 10059 void CUniEditorAppUi::ShowDiscreetPopUpL(const TDesC& aMessage)
       
 10060 	{
       
 10061 	TInt  bitmapId = KErrNotFound;
       
 10062 	TInt  maskId = KErrNotFound;
       
 10063    
       
 10064    // No discreet popup => Uid 0
       
 10065    const TUid KDiscreetPopupUidNone =
       
 10066 	   {
       
 10067 	   0x0
       
 10068 	   };
       
 10069 	
       
 10070 	CAknDiscreetPopup::ShowGlobalPopupL(aMessage, // 1st text row
       
 10071 			KNullDesC, // second text row
       
 10072 			KAknsIIDDefault, // icon skin id
       
 10073 			KNullDesC, // bitmap file path
       
 10074 			bitmapId, // bitmap id
       
 10075 			maskId, // mask id
       
 10076 			KAknDiscreetPopupDurationLong, // flags
       
 10077 			0, // command id
       
 10078 			NULL, // command observer
       
 10079 			KDiscreetPopupUidNone, // application to be launched
       
 10080 			KDiscreetPopupUidNone); // view to be activated
       
 10081 	}
       
 10082 
       
 10083 // End of file
       
 10084