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