mobilemessaging/smsui/viewersrc/MsgSmsViewerAppUi.cpp
changeset 0 72b543305e3a
child 2 0bf1d54f37d9
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *     Sms Viewer Application UI
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 // UIKON/AVKON
       
    24 #include <akntitle.h>                   // CAknTitlePane
       
    25 #include <eikmenub.h>                   // CEikMenuBar
       
    26 #include <aknnotewrappers.h>            // AknNoteWrappers
       
    27 #include <txtrich.h>                    // Rich text ed
       
    28 #include <aknnavide.h>              // CAknNavigationDecorator
       
    29 // messaging editors
       
    30 #include <MsgBodyControl.h>             // CMsgBodyControl
       
    31 #include <eikrted.h>                    // CEikRichTextEditor
       
    32 #include <MsgEditorView.h>              // CMsgEditorView
       
    33 #include <MsgAddressControl.h>          // CMsgAddressControl
       
    34 #include <msgbiobodycontrol.h>          // CMsgBioBodyControl
       
    35 #include <MsgBioUids.h>                 // smart message type uids
       
    36 #include <msgbiocontrol.h>              // CMsgBioControl
       
    37 #include <CGmsWrapper.h>                // CGmsWrapper
       
    38 #include <MsgNaviPaneControl.h>
       
    39 // messaging
       
    40 #include <smuthdr.h>                    // CSmsHeader
       
    41 #include <smsclnt.h>                    // CSmsClientMtm
       
    42 #include <MsgFolderSelectionDialog.h>   // CMsgFolderSelectionDialog
       
    43 #include <MuiuMsvProgressReporterOperation.h>  // CMsvProgressReporterOperation
       
    44 #include <MtmExtendedCapabilities.hrh>	// function id of MessageInfo
       
    45 #include <MuiuOperationWait.h>              // MuiuOperationWait
       
    46 #include <mtclreg.h>
       
    47 #include <mtuireg.h>
       
    48 #include <mtmdef.h>
       
    49 #include <akninputblock.h>				// CAknInputBlock
       
    50 #include <MuiuMsvUiServiceUtilities.h>  // DiskSpaceBelowCriticalLevelL
       
    51 #include <muiumsvuiserviceutilitiesinternal.h>
       
    52 #include <messagingvariant.hrh>         // Local variation flags
       
    53 #include <smumutil.h>                   // SmumUtil
       
    54 #include <csmsemailfields.h>            // CSmsEmailFields
       
    55 #include <msgtextutils.h>
       
    56 // phone
       
    57 #include <commonphoneparser.h>          // Common phone number validity checker
       
    58 // resources
       
    59 #include <SmsViewer.rsg>                // resouce identifiers
       
    60 #include <msgeditor.mbg>                // bitmaps
       
    61 // local
       
    62 #include "MsgSmsViewer.hrh"             // application specific commands
       
    63 #include "MsgSmsViewerDoc.h"            // CMsgSmsViewerDocument
       
    64 #include "MsgSmsViewerAppUi.h"          // CMsgSmsViewerAppUi
       
    65 // Find item
       
    66 #include <FindItemmenu.rsg>             // find item resources
       
    67 #include <finditemmenu.h>               // CFindItemMenu
       
    68 #include <finditemdialog.h>             // CFindItemDialog
       
    69 #include <finditem.hrh>
       
    70 #include <ItemFinder.h>
       
    71 // Creating contact card via AIW
       
    72 #include <AiwServiceHandler.h>          // CAiwServiceHandler
       
    73 #include <AiwContactAssignDataTypes.h>  // AiwContactAssign
       
    74 // general
       
    75 #include <StringLoader.h>               // StringLoader
       
    76 #include <featmgr.h>                    // FeatureManager
       
    77 #include <SenduiMtmUids.h>
       
    78 #include <sendui.h>
       
    79 #include <CMessageData.h>               // for SendUi
       
    80 #include <data_caging_path_literals.hrh>
       
    81 #include <AknIconUtils.h>
       
    82 #include <centralrepository.h>
       
    83 #include <messaginginternalcrkeys.h>
       
    84 #include <CommonUiInternalCRKeys.h>
       
    85 #include <coreapplicationuisdomainpskeys.h>
       
    86 
       
    87 
       
    88 // help
       
    89 #include <csxhelp/sms.hlp.hrh>          // sms help context ids 
       
    90 #include <csxhelp/smart.hlp.hrh>
       
    91 #include <hlplch.h>                     // for HlpLauncher 
       
    92 
       
    93 #include <msgvoipextension.h>
       
    94 
       
    95 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension
       
    96 #include <MsgEditorSettingCacheUpdatePlugin.h>
       
    97 
       
    98 //Skinnable Title pane icon
       
    99 #include <AknStatuspaneUtils.h>     // AknStatuspaneUtils
       
   100 #include <aknlayoutscalable_apps.cdl.h>
       
   101 #include <aknlayoutscalable_avkon.cdl.h>
       
   102 #include <AknsUtils.h>
       
   103 #include <muiu.mbg>           // title icon
       
   104 #ifdef RD_MSG_FAST_PREV_NEXT
       
   105 #include <MuiuMessageIterator.h>
       
   106 #endif
       
   107 
       
   108 #ifdef RD_SCALABLE_UI_V2
       
   109 #include <aknnavide.h>              // pen support on navi pane
       
   110 #include <AknNaviObserver.h>        // pen support of volume control of navi pane
       
   111 #include <akntoolbar.h>     
       
   112 #include <eikcolib.h>		//Added for touchbar support
       
   113 #endif
       
   114 #include <aknclearer.h>     // CAknLocalScreenClearer
       
   115 // CONSTANTS
       
   116 
       
   117 // Sms Viewer Uid 
       
   118 const TUid KUidSmsViewer ={0x100058BD};
       
   119 // GMS Viewer Uid
       
   120 const TUid KUidGMSViewer ={0x101F4CDA};
       
   121 // Sms Mtm Service Uid
       
   122 const TUid KUidSmsMtm = {0x1000102c};
       
   123 // First free id
       
   124 const TInt EMsgImageControlId = EMsgComponentIdFirstFreeEditorSpecificId;
       
   125 
       
   126 // Size approxamations
       
   127 // TMsvEntry itself
       
   128 const TInt KApproxEmptyTMsvEntrySize = 200; // atleast when SC included to entry (Outbox)
       
   129 // Recipients
       
   130 const TInt KApproxRecipientSize = 80; // manually entered ~50 & fetched ~70
       
   131 // GMS msg with full 120 chars and whole picture (no recipients)
       
   132 const TInt KApproxFullGMS = 450; // full of text and whole picture
       
   133 
       
   134 _LIT( KSmsBitmapFileName, "muiu.mif" );
       
   135 
       
   136 // ================= MEMBER FUNCTIONS =======================
       
   137 
       
   138 // C++ default constructor can NOT contain any code, that
       
   139 // might leave.
       
   140 CMsgSmsViewerAppUi::CMsgSmsViewerAppUi()
       
   141     {
       
   142     // Put constructor code into function InitMembers() as it's
       
   143     // also called to prepare the viewer to show a new message.
       
   144     InitMembers();
       
   145     }
       
   146 
       
   147 // Initialize data members into a default state. Called from a constructor
       
   148 // and when a sms is loaded into a viewer to replace a current one.
       
   149 void CMsgSmsViewerAppUi::InitMembers()
       
   150     {
       
   151     // Initialize variables that cannot be zeroed or are initialized to a
       
   152     // non-zero value.
       
   153 
       
   154     // iFullyConstructed is only initialized in construction
       
   155     
       
   156     iNumber.Zero();
       
   157     iRecipientstring.Zero();
       
   158 
       
   159     // Initialize flags
       
   160     Mem::FillZ( &iFlags, sizeof(iFlags) );
       
   161 
       
   162     iControlId = 0;
       
   163     iClass0CBA = NULL;
       
   164     iFindItemMenu = NULL;
       
   165     iAiwServiceHandler = NULL;
       
   166     iGmsModel = NULL;
       
   167     iSmsHeader = NULL;
       
   168     iViewerOperation = NULL;
       
   169     iMsgVoIPExtension  = NULL;
       
   170     iSendUi = NULL;
       
   171     iCenRepSession = NULL;
       
   172     iNotifier = NULL;
       
   173     }
       
   174 
       
   175 // Symbian OS default constructor can leave.
       
   176 void CMsgSmsViewerAppUi::ConstructL()
       
   177     {
       
   178     CMsgEditorAppUi::ConstructL();
       
   179 
       
   180     ConstructMembersL();
       
   181 
       
   182 	if( !iEikonEnv->StartedAsServerApp( ) )
       
   183         { // If the app was not started as server app, we can call PrepareLaunchL
       
   184         Document()->PrepareToLaunchL( this );
       
   185         }        
       
   186     }   
       
   187 
       
   188 // ConstructL() without calling base class construct
       
   189 void CMsgSmsViewerAppUi::ConstructMembersL()
       
   190     {
       
   191     // Prepare FeatureManager, read values to members and uninitialize FeatureManager
       
   192     FeatureManager::InitializeLibL();
       
   193     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   194         {
       
   195         iFlags.iHelpFeatureSupported = ETrue;
       
   196         }
       
   197     // SMSGms variation flags
       
   198     if ( FeatureManager::FeatureSupported( KFeatureIdSmartmsgSMSGmsMessageReceiving ) )
       
   199         {
       
   200         iFlags.iSmartMsgSmsGmsMessageReceiving = ETrue;
       
   201         }
       
   202     if ( FeatureManager::FeatureSupported( KFeatureIdSmartmsgSMSGmsMessageSendingSupported ) )
       
   203         {
       
   204         iFlags.iSmartMsgSmsGmsMessageSending = ETrue;
       
   205         }
       
   206     if ( FeatureManager::FeatureSupported( KFeatureIdAudioMessaging ) )
       
   207         {
       
   208         iFlags.iAudioMsgSupported = ETrue;
       
   209         }
       
   210     FeatureManager::UnInitializeLib();
       
   211     
       
   212     //check unieditor restricted reply mode
       
   213     TInt features = 0;
       
   214     CRepository* repository = CRepository::NewLC( KCRUidMuiuVariation );   
       
   215     repository->Get( KMuiuUniEditorFeatures, features );
       
   216     CleanupStack::PopAndDestroy( repository );
       
   217     iFlags.iSmsRestrictedMode = ( features & KUniEditorFeatureIdRestrictedReplySms );
       
   218 		repository = NULL;
       
   219 	
       
   220 	//check autolock mode
       
   221     TInt value( KErrNotFound ); 
       
   222     RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, value );
       
   223     if ( value > EAutolockOff )
       
   224         {
       
   225         iFlags.iAutoLockEnabled = ETrue;
       
   226         }
       
   227     iMsgVoIPExtension = CMsgVoIPExtension::NewL();
       
   228 
       
   229     // Local variation flags
       
   230     if ( SmumUtil::CheckEmailOverSmsSupportL() )
       
   231         { // Email supported
       
   232         iFlags.iEmailFeatureSupported = ETrue;
       
   233         }
       
   234     //Middle softkey
       
   235     MenuBar()->SetContextMenuTitleResourceId( R_SMSV_CONTEXTMENUBAR );        
       
   236   	// Set path of bitmap file
       
   237   	TParse fileParse;
       
   238   	fileParse.Set( KSmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   239     
       
   240   	
       
   241     iAppIcon = AknsUtils::CreateGulIconL( 
       
   242         AknsUtils::SkinInstance(), 
       
   243         KAknsIIDQgnPropMceSmsTitle,
       
   244         fileParse.FullName(),
       
   245         EMbmMuiuQgn_prop_mce_sms_title,
       
   246         EMbmMuiuQgn_prop_mce_sms_title_mask );
       
   247         
       
   248             
       
   249 	iScreenClearer = CAknLocalScreenClearer::NewLC( EFalse );
       
   250 	CleanupStack::Pop( iScreenClearer );    
       
   251     iTypeMsg = CSmsPDU::ESmsDeliver; //for successful launch save the PDU Type.
       
   252 
       
   253 
       
   254     
       
   255     }
       
   256 
       
   257 // Destructor
       
   258 CMsgSmsViewerAppUi::~CMsgSmsViewerAppUi()
       
   259     {
       
   260     // Put destructor code into function DestructMembers() as it's
       
   261     // also called to prepare the viewer to show a new message.
       
   262     DestructMembers();
       
   263     }
       
   264 
       
   265 // Destruct data members. Called from a destructor and when a sms
       
   266 // is loaded into a viewer to replace a current one.
       
   267 void CMsgSmsViewerAppUi::DestructMembers()
       
   268     {
       
   269     // If operation is still active we must cancel it before exit
       
   270     if ( iViewerOperation ) 
       
   271         {
       
   272         iViewerOperation->Cancel();
       
   273         }
       
   274     delete iViewerOperation;
       
   275     iViewerOperation = NULL;
       
   276     delete iFindItemMenu;
       
   277     iFindItemMenu = NULL;
       
   278     delete iSendUi;
       
   279     iSendUi = NULL;    
       
   280     delete iAiwServiceHandler;
       
   281     iAiwServiceHandler = NULL;    
       
   282     delete iGmsModel;
       
   283     iGmsModel = NULL;
       
   284     delete iSmsHeader;
       
   285     iSmsHeader = NULL;
       
   286 
       
   287     if( iNotifier )
       
   288         {
       
   289         iNotifier->StopListening();
       
   290         delete iNotifier;
       
   291         iNotifier = NULL;
       
   292         }
       
   293     delete iCenRepSession; // don't delete before notifier
       
   294     iCenRepSession = NULL;
       
   295     delete iMsgVoIPExtension;
       
   296     iMsgVoIPExtension = NULL;
       
   297     // AppUi doesn't own iClass0CBA, so it's deleted elsewhere 
       
   298 	#ifdef RD_SCALABLE_UI_V2
       
   299 	if(iToolbar)
       
   300 		{
       
   301     	delete iToolbar;
       
   302     	iToolbar = NULL;
       
   303     	static_cast<CEikAppUiFactory*>( 
       
   304                 CEikonEnv::Static()->AppUiFactory() )->SetViewFixedToolbar( NULL );
       
   305   		}
       
   306 	#endif	
       
   307     delete iAppIcon;
       
   308     iAppIcon = NULL;
       
   309     delete iScreenClearer;
       
   310     iScreenClearer = NULL;
       
   311     }
       
   312 
       
   313 #ifdef RD_MSG_FAST_PREV_NEXT
       
   314 // ---------------------------------------------------------
       
   315 // CMsgSmsViewerAppUi::EntryChangedL
       
   316 // (other items were commented in a header).
       
   317 // ---------------------------------------------------------
       
   318 void CMsgSmsViewerAppUi::EntryChangedL()
       
   319     {
       
   320     // First call to EntryChangedL() comes before LaunchViewL() has been called by
       
   321     // document.
       
   322     if ( !iFullyConstructed )
       
   323         return;
       
   324 
       
   325     if( iMsgNaviDirection == KErrNotFound )
       
   326         {
       
   327         // Clear and redraw all controls
       
   328         iView->ResetControls();
       
   329         iView->DrawNow();
       
   330         
       
   331         DestructMembers();
       
   332         InitMembers();
       
   333         delete iView; iView = NULL;
       
   334         ConstructMembersL();
       
   335         LaunchViewL();
       
   336         }
       
   337     else
       
   338         {
       
   339         QuicklaunchViewL();
       
   340         }
       
   341     
       
   342     // Note: In smum (sms mtm UI), file smsu.cpp. Message is marked as read in
       
   343     // sim in case it's class 2 sms stored in sim. It is referenced as a fix to
       
   344     // an error SPAN-6B7K33. That piece of code could be executed here but is
       
   345     // left out because all sim messages are shown as read by default in sim folder
       
   346     // anyways.
       
   347     }
       
   348 #endif // RD_MSG_FAST_PREV_NEXT
       
   349 
       
   350 // ---------------------------------------------------------
       
   351 // CMsgSmsViewerAppUi::Document
       
   352 // (other items were commented in a header).
       
   353 // ---------------------------------------------------------
       
   354 CMsgSmsViewerDocument* CMsgSmsViewerAppUi::Document() const
       
   355     {
       
   356     return STATIC_CAST( CMsgSmsViewerDocument*, CMsgEditorAppUi::Document());
       
   357     }
       
   358 
       
   359 // ---------------------------------------------------------
       
   360 // CMsgSmsViewerAppUi::LaunchViewL
       
   361 // (other items were commented in a header).
       
   362 // ---------------------------------------------------------
       
   363 void CMsgSmsViewerAppUi::LaunchViewL()
       
   364     {
       
   365     CAknInputBlock::NewLC();
       
   366     // get hands on entry
       
   367     TMsvEntry msvEntry1;
       
   368     
       
   369     TRAPD( error, msvEntry1 = Document()->Entry() );
       
   370     
       
   371     if( error != KErrNone )
       
   372         {
       
   373         //Something wrong. Exit here
       
   374         DoMsgSaveExitL();
       
   375         return;
       
   376         }
       
   377     
       
   378 #ifdef RD_SCALABLE_UI_V2
       
   379     if ((!iToolbar)&& (AknLayoutUtils::PenEnabled() && !msvEntry1.iBioType && !iFlags.iGms) )
       
   380     	{
       
   381     	CEikAppUiFactory* appUiFactory = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() );
       
   382         CAknToolbar* oldFixedToolbar = appUiFactory->CurrentFixedToolbar();
       
   383 
       
   384         	iToolbar = CAknToolbar::NewL( R_SMSVIEWER_APP_TOOLBAR );
       
   385         	iToolbar->SetToolbarObserver( this );
       
   386         
       
   387 
       
   388         if ( oldFixedToolbar != iToolbar )
       
   389             {
       
   390             oldFixedToolbar->SetToolbarVisibility( EFalse );    
       
   391             }
       
   392         
       
   393         appUiFactory->SetViewFixedToolbar( iToolbar );    	
       
   394         iToolbar->SetToolbarVisibility( ETrue, EFalse ); 
       
   395 	    }
       
   396 	    
       
   397 	//handling the case of iToolbar already created [delete the toolbar incase of biomsgs]
       
   398 	else if((iToolbar)&&(AknLayoutUtils::PenEnabled() && msvEntry1.iBioType && iFlags.iGms)) 
       
   399 		{
       
   400 		    delete iToolbar;
       
   401     		iToolbar = NULL;
       
   402 		}
       
   403 	
       
   404 #endif	
       
   405     // Creating view (exits app immediately if fails)
       
   406     iView = CMsgEditorView::NewL( *this, CMsgEditorView::EMsgReadOnly );
       
   407     // get hands on entry
       
   408     const CMsgSmsViewerDocument* doc = Document();
       
   409     TMsvEntry msvEntry = doc->Entry();
       
   410     
       
   411     // Getting sender/receiver to From/To-field
       
   412     // (just copies the content of iDetails to To/From-field,
       
   413     // should work also with IR-messages...)
       
   414     
       
   415     //Copy only 50 chars with extremely long names
       
   416     iRecipientstring = msvEntry.iDetails.Left( KPhCltNameBufferLength );  
       
   417 
       
   418     __ASSERT_DEBUG(msvEntry.Id() != 
       
   419          KMsvNullIndexEntryId, Panic( EMsgSmsNoMessage ));
       
   420 
       
   421     iFlags.iGms = (msvEntry.iBioType == KMsgBioUidPictureMsg.iUid);
       
   422 
       
   423     // Instead of using Sms Mtm load the entry's values
       
   424     // using store. This is because Sms Viewer is also used
       
   425     // by bio messages and then sms mtm can't be used...
       
   426     CPlainText* nullString = CPlainText::NewL();
       
   427     CleanupStack::PushL( nullString );
       
   428     iSmsHeader = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *nullString );
       
   429     CMsvStore* store = doc->CurrentEntry().ReadStoreL();
       
   430     CleanupStack::PushL(store);
       
   431   
       
   432     // This TRAPping is needed to find out if the entry's store has
       
   433     // KUidMsvSMSHeaderStream. If it hasn't, we're most propably dealing
       
   434     // with non sms message and we can assume it is received message.
       
   435     TRAPD( err, iSmsHeader->RestoreL( *store ));
       
   436 
       
   437     // Check if we are dealing with E-mail sms message
       
   438     // We use TP-PID as the only validation rule
       
   439     CSmsPDU& pdu = iSmsHeader->Message().SmsPDU();
       
   440 	if( pdu.ProtocolIdentifierPresent() )
       
   441 		{
       
   442 		if(	pdu.PIDType() == TSmsProtocolIdentifier::ESmsPIDTelematicInterworking &&
       
   443 			pdu.TelematicDeviceIndicator() == TSmsProtocolIdentifier::ESmsTelematicDevice &&
       
   444 			pdu.TelematicDeviceType() == TSmsProtocolIdentifier::ESmsInternetElectronicMail )
       
   445 			{
       
   446 			iFlags.iIsEmailMessage = ETrue;
       
   447 			}
       
   448 		}
       
   449 
       
   450     if (err == KErrNone)
       
   451         {// Yes, it is sms based message
       
   452 
       
   453         // Original longish LaunchViewL-function is splitted to 3 parts;
       
   454         // LaunchViewL, SmsBasedMsgHandlingL & LaunchBioViewL
       
   455         SmsBasedMsgHandlingL( msvEntry.iBioType, store );
       
   456         }
       
   457     else
       
   458         {// No, this is not a sms and sms pdu can't be checked. However
       
   459         // this is most propably _received_ IR or BT message.
       
   460         iFlags.iIrBt = ETrue;
       
   461         iControlId = EMsgComponentIdFrom;
       
   462         iView->AddControlFromResourceL( 
       
   463             R_SMSV_FROM, 
       
   464             EMsgAddressControl, 
       
   465             EMsgAppendControl, 
       
   466             EMsgHeader);
       
   467         }
       
   468     CleanupStack::PopAndDestroy( 2 ); //store, nullString
       
   469 
       
   470     // Tests if Bio message
       
   471     if ( msvEntry.iBioType && !iFlags.iGms ) 
       
   472         {
       
   473 		// parse the number if wappush
       
   474 		if( msvEntry.iBioType == KMsgBioProvisioningMessage.iUid )
       
   475 		    {
       
   476 			    TPtrC tempNumber( msvEntry.iDetails );
       
   477 			    if(CommonPhoneParser::IsValidPhoneNumber( 
       
   478 			    	tempNumber, CommonPhoneParser::ESMSNumber ))
       
   479 			    {
       
   480 			    	iNumber = tempNumber;
       
   481 			    }	    	
       
   482 		    }
       
   483         // Original longish LaunchViewL-function is split into 3 parts;
       
   484         // LaunchViewL, SmsBasedMsgHandlingL & LaunchBioViewL
       
   485         LaunchBioViewL( msvEntry );
       
   486         }
       
   487     
       
   488     // Fill address ctrl
       
   489     if ( !iFlags.iIsEmailMessage && KErrNotFound != iNumber.Match( iRecipientstring ) )
       
   490         {
       
   491         iRecipientstring = KNullDesC;
       
   492         }
       
   493     CMsgBaseControl* addressBase = iView->ControlById( iControlId );
       
   494     CMsgAddressControl* addressControl = STATIC_CAST( CMsgAddressControl*, addressBase );
       
   495 
       
   496     MVPbkContactLink* link= NULL;
       
   497     addressControl->AddRecipientL( 
       
   498         iRecipientstring,
       
   499         iNumber,
       
   500         ETrue,
       
   501         link );
       
   502 
       
   503     // Message indication ( e.g. 2/32 )
       
   504 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
   505     // Fetch pointer to the default navi pane control
       
   506     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   507         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   508      
       
   509     if( !iNaviDecorator )
       
   510         {
       
   511         CreateViewerNaviPaneL( Document()->Entry().iDate, EMsgEditorMsgPriorityNormal, ETrue );    
       
   512         iNaviPane->PushL( *iNaviDecorator );  // <- This has nothing to do with cleanup-stack!    
       
   513         }
       
   514     else
       
   515         {
       
   516         //We end up here when fast msg opening is enabled
       
   517         CMsgNaviPaneControl* naviControl = static_cast<CMsgNaviPaneControl*>
       
   518             ( iNaviDecorator->DecoratedControl() );
       
   519         naviControl->SetTimeIndicatorL( Document()->Entry().iDate, ETrue );
       
   520         naviControl->SetNavigationIndicatorL( Document()->Session(), Document()->Entry() );
       
   521         }
       
   522     
       
   523 #else
       
   524 	UpdateNaviPaneL();
       
   525 #endif
       
   526 	//remove buttons from navipane
       
   527 	if( iNaviDecorator && iClass0CBA )
       
   528 	    {
       
   529 	    iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, ETrue );
       
   530    	    iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, ETrue );
       
   531 	    } 
       
   532 #ifdef RD_SCALABLE_UI_V2
       
   533     if ( AknLayoutUtils::PenEnabled() )
       
   534         {
       
   535        	iNaviDecorator->SetNaviDecoratorObserver( this );
       
   536        	if ( iToolbar )
       
   537        		{
       
   538        		//By Default make take touchbar invisible, dimmed and disabled
       
   539        		iToolbar->SetToolbarVisibility(EFalse, EFalse);
       
   540        		iToolbar->SetDimmed(ETrue);
       
   541        		iToolbar->DisableToolbarL( ETrue );
       
   542 
       
   543        		//Test that message type is normal SMS
       
   544        		if ( !iFlags.iBioMsg && !iFlags.iGms) 
       
   545        			{
       
   546        			//Enable the touchbar, make it visible and undimmed
       
   547        			iToolbar->DisableToolbarL( EFalse );
       
   548        			iToolbar->SetDimmed(EFalse);
       
   549        			iToolbar->SetToolbarVisibility(ETrue, EFalse);
       
   550 
       
   551                	// default state, nothing dimmed. Uncomment the below lines only if necessary to force set it dim again
       
   552                  /*
       
   553                		iToolbar->SetItemDimmed(ESmsViewerToolbarReply, EFalse, EFalse);
       
   554                		iToolbar->SetItemDimmed(ESmsViewerToolbarForward, EFalse, EFalse);
       
   555                		iToolbar->SetItemDimmed(ESmsViewerToolbarDelete, EFalse, ETrue);
       
   556                  */
       
   557 
       
   558             	//What buttons to dim
       
   559            		switch ( iSmsHeader->Type() )
       
   560                		{
       
   561                 	
       
   562                 		//Received Message
       
   563                 		case CSmsPDU::ESmsDeliver:
       
   564                 		//Nothing dimmed, unless sender unknown
       
   565                 			if (msvEntry.iDetails.Length() == 0 )
       
   566                 				iToolbar->SetItemDimmed(ESmsViewerToolbarReply, ETrue, ETrue);
       
   567                 				
       
   568                 			//Or not valid
       
   569                 			if (!iFlags.iValidSenderNumber)
       
   570                 				iToolbar->SetItemDimmed(ESmsViewerToolbarReply, ETrue, ETrue);               					
       
   571                 			break;
       
   572                 	
       
   573                 		//Sent Message
       
   574                 		case CSmsPDU::ESmsSubmit:
       
   575                 			//Dim the reply button, we would be replying to ourselves
       
   576                 			iToolbar->SetItemDimmed(ESmsViewerToolbarReply, ETrue, ETrue);
       
   577                 			break;
       
   578                 		
       
   579                 		//Some other cases we might consider dimming
       
   580                			//ESmsSubmitReport SMS-SUBMIT-REPORT, sent from SC to MS
       
   581                 		//ESmsStatusReport SMS-STATUS-REQUEST, sent from SC to MS
       
   582                 		//ESmsCommand      SMS-COMMAND, sent from MS to SC	
       
   583                 		//ESmsDeliverReport SMS-DELIVER-REPORT, sent from MS to SC
       
   584                 		
       
   585                 		//TODO Necessary?
       
   586                 		default:
       
   587                 			Panic( EMsgSmsViewerUnknownSmsPduType );
       
   588                 			break;
       
   589 
       
   590                 		}	// Switch
       
   591             		}	// if ( !iFlags.iBioMsg && !iFlags.iGms) 
       
   592             	}	// if ( iToolbar )
       
   593             }     // if ( AknLayoutUtils::PenEnabled() ) 	
       
   594 #endif	
       
   595     // set focus
       
   596     iView->ExecuteL( ClientRect(), iControlId );
       
   597 
       
   598     SetTitleIconL();
       
   599 		iFullyConstructed = ETrue;
       
   600 		
       
   601 		if ( !iFlags.iBioMsg && !iFlags.iGms )
       
   602     {
       
   603         // Read the value of automatic highlight sd-key
       
   604         ReadAutoHlSharedDataValueAndSetNotifyL();
       
   605         // Set the state of automatic highlighting for sms
       
   606         SetAutomaticHighlightL( iFlags.iAutomaticHlValue );
       
   607     }
       
   608     
       
   609     else 
       
   610     {
       
   611     	if ( iView && iView->ItemFinder() ) 
       
   612     		{
       
   613     	    iView->ItemFinder()->SetFindModeL( CItemFinder::ENoneSelected );
       
   614     		}
       
   615     	
       
   616     }
       
   617 		
       
   618 		delete iScreenClearer;
       
   619     iScreenClearer = NULL;
       
   620     CleanupStack::PopAndDestroy();// CAknInputBlock
       
   621     }
       
   622 
       
   623 // ---------------------------------------------------------
       
   624 // CMsgSmsViewerAppUi::SmsBasedMsgHandlingL
       
   625 // (other items were commented in a header).
       
   626 // ---------------------------------------------------------
       
   627 void CMsgSmsViewerAppUi::SmsBasedMsgHandlingL( 
       
   628     TInt32 aBioType, CMsvStore* aStore )
       
   629     {
       
   630     // Initialize the richtext object...
       
   631     CParaFormatLayer* paraFormat = iEikonEnv->SystemParaFormatLayerL(); // <- pointer only
       
   632     CCharFormatLayer* charFormat = iEikonEnv->SystemCharFormatLayerL(); // <- pointer only
       
   633     CRichText* textBody = CRichText::NewL( paraFormat, charFormat );
       
   634     CleanupStack::PushL( textBody );
       
   635     // ...and read bodytext
       
   636     aStore->RestoreBodyTextL( *textBody );
       
   637     
       
   638     if ( !aBioType || iFlags.iGms)
       
   639         {
       
   640         // message is ordinary sms message or Picture Message
       
   641         // so, let's get message body to viewer. 
       
   642         CMsgBaseControl* baseControl = iView->ControlById( 
       
   643             EMsgComponentIdBody );
       
   644         CMsgBodyControl* bodyControl = STATIC_CAST( 
       
   645             CMsgBodyControl*, 
       
   646             baseControl );
       
   647         
       
   648         if ( !iFlags.iGms )
       
   649             { // normal sms
       
   650             //the Title-pane text
       
   651             HBufC* text = StringLoader::LoadLC( R_QTN_TITLE_SMS, iCoeEnv );
       
   652             CAknTitlePane* title = STATIC_CAST( 
       
   653                 CAknTitlePane*, 
       
   654                 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
   655             title->SetTextL( *text );
       
   656             CleanupStack::PopAndDestroy(); // text
       
   657             
       
   658             CMsgTextUtils::ConvertLineBreaksL( *textBody, CMsgTextUtils::ECRLFtoLF );
       
   659             
       
   660             // body text
       
   661             bodyControl->SetTextContentL( *textBody );
       
   662             
       
   663             // Class 0 handling...
       
   664             TSmsDataCodingScheme::TSmsClass smsClass;
       
   665             if ( iSmsHeader->Message().SmsPDU().Class( smsClass ) 
       
   666                 && smsClass == TSmsDataCodingScheme::ESmsClass0 )
       
   667                 {
       
   668                 // Create new softkeys
       
   669                 iClass0CBA = Cba(); // <- pointer only
       
   670                 if (iClass0CBA) 
       
   671                     { // iClass0CBA shouldn't be NULL, but if....
       
   672                     iClass0CBA->SetCommandSetL( R_SMSVIEWER_CLASS0_SOFTKEYS_OPTIONS_EXIT__CONTEXTOPTIONS );  
       
   673                     //Middle softkey
       
   674     				MenuBar()->SetContextMenuTitleResourceId( R_SMSV_OPTIONSCONTEXTMENUBAR_CLASS0 );           
       
   675                     MenuBar()->SetMenuTitleResourceId( R_SMSV_OPTIONSMENUBAR_CLASS0 );        
       
   676                     MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);     
       
   677                     }
       
   678                 }
       
   679             }
       
   680         else
       
   681             { // picture message
       
   682             iGmsModel = CGmsWrapper::NewL(iCoeEnv->FsSession());
       
   683             iGmsModel->LoadMsgL(*textBody);
       
   684             bodyControl->SetTextContentL(*iGmsModel->GetTextLC());
       
   685             CleanupStack::PopAndDestroy(); // CRichText instance
       
   686             iGmsModel->AddPictureControlToViewL(*iView, EMsgImageControlId);
       
   687             iGmsModel->SetPictureMsgTitleL(*StatusPane(),
       
   688                 R_QTN_SM_TITLE_PICTURE_MESSAGE);
       
   689             }
       
   690 
       
   691         bodyControl->SetPlainTextMode( ETrue );
       
   692         }
       
   693     CleanupStack::PopAndDestroy(); //textBody
       
   694     
       
   695     // Deciding between To/From text in address control
       
   696     const CSmsPDU::TSmsPDUType pduType = iSmsHeader->Type();
       
   697     switch ( pduType )
       
   698         {
       
   699         case CSmsPDU::ESmsDeliver:
       
   700             {
       
   701             // Setting from-control
       
   702             iControlId = EMsgComponentIdFrom;
       
   703             iView->AddControlFromResourceL( 
       
   704                 R_SMSV_FROM, 
       
   705                 EMsgAddressControl, 
       
   706                 EMsgAppendControl, 
       
   707                 EMsgHeader );
       
   708             // take the number and verify it
       
   709             iNumber = iSmsHeader->FromAddress();
       
   710             if ( !iFlags.iIsEmailMessage )
       
   711                 {
       
   712                 iFlags.iValidSenderNumber = CommonPhoneParser::IsValidPhoneNumber(
       
   713                     iNumber, CommonPhoneParser::ESMSNumber );
       
   714 
       
   715                 if( !iFlags.iValidSenderNumber && iMsgVoIPExtension->IsVoIPSupported() )
       
   716                     {
       
   717                     if( MsvUiServiceUtilities::IsValidEmailAddressL( iNumber ) )
       
   718                         {
       
   719                         iFlags.iValidSenderNumber = ETrue;
       
   720                         iFlags.iVoIPNumber = ETrue;
       
   721                         }
       
   722                     }
       
   723                 // Replypath indication
       
   724                 if ( iSmsHeader->Deliver().ReplyPath() )
       
   725                     {
       
   726                     iView->AddControlFromResourceL( 
       
   727                         R_SMSV_REPLYPATH, 
       
   728                         EMsgExpandableControl, 
       
   729                         EMsgAppendControl, 
       
   730                         EMsgHeader );
       
   731                 
       
   732                     HBufC* text = StringLoader::LoadLC( R_QTN_SMS_HEADING_REPLY_PATH, iCoeEnv );
       
   733                     CRichText& replyPath = STATIC_CAST(CMsgExpandableControl*, 
       
   734                         iView->ControlById(EMsgComponentIdCc))->TextContent();
       
   735                     replyPath.Reset();
       
   736                     replyPath.InsertL( 0, *text ); 
       
   737                     CleanupStack::PopAndDestroy(); // text
       
   738                     }
       
   739                 }
       
   740             else
       
   741                 {
       
   742                 iFlags.iValidSenderNumber =
       
   743                     MsvUiServiceUtilities::IsValidEmailAddressL(
       
   744                         iRecipientstring );
       
   745                 }
       
   746             }
       
   747             break;
       
   748         case CSmsPDU::ESmsSubmit:
       
   749             // Setting To-control
       
   750             iControlId = EMsgComponentIdTo;
       
   751             iView->AddControlFromResourceL( 
       
   752                 R_SMSV_TO, 
       
   753                 EMsgAddressControl, 
       
   754                 EMsgAppendControl, 
       
   755                 EMsgHeader );
       
   756             // take the number
       
   757             iNumber = iSmsHeader->FromAddress();
       
   758             break;
       
   759         default:
       
   760 #if defined ( _DEBUG )
       
   761             Panic( EMsgSmsViewerUnknownSmsPduType );
       
   762 #else
       
   763             User::Leave( KErrNotSupported );
       
   764 #endif
       
   765             break;
       
   766         }
       
   767     // If we are dealing with Email message
       
   768     // we add subject control for Email type subject
       
   769     if ( iFlags.iIsEmailMessage )
       
   770         {
       
   771         TPtrC subj( iSmsHeader->EmailFields().Subject() );
       
   772         if ( subj.Length() )
       
   773             {
       
   774             // Add subject control
       
   775             AddSubjectControlL();
       
   776             // Set the Subject field text accordigly
       
   777             SetSubjectL( subj );
       
   778             }
       
   779         }
       
   780     iTypeMsg = pduType; //for successful launch save the PDU Type.
       
   781     }
       
   782 
       
   783 // ---------------------------------------------------------
       
   784 // CMsgSmsViewerAppUi::LaunchBioViewL
       
   785 // (other items were commented in a header).
       
   786 // ---------------------------------------------------------
       
   787 void CMsgSmsViewerAppUi::LaunchBioViewL( const TMsvEntry& aTMsvEntry )
       
   788     {
       
   789     // Picture Messages are not handled as Bio in this class.
       
   790     __ASSERT_DEBUG(!iFlags.iGms, Panic(EMsgSmsNotForGms));
       
   791 
       
   792     // Load in BioControl
       
   793     const TUid bioType={ aTMsvEntry.iBioType };
       
   794     CMsgBioBodyControl* bioBody = NULL;
       
   795     bioBody = CMsgBioBodyControl::NewL(
       
   796         *this,
       
   797         bioType,
       
   798         aTMsvEntry.Id(),
       
   799         EMsgBioViewerMode,
       
   800         Document()->Session()); //since this is the viewer application
       
   801     CleanupStack::PushL( bioBody );
       
   802     
       
   803     // Remove default body control and replace with Bio Control
       
   804     iView->DeleteControlL( EMsgComponentIdBody );
       
   805     iView->AddControlL(
       
   806         bioBody, 
       
   807         EMsgComponentIdBody,
       
   808         EMsgAppendControl, 
       
   809         EMsgBody );
       
   810     CleanupStack::Pop(); // bioBody
       
   811     
       
   812     //the Title-pane text
       
   813     HBufC* text = bioBody->HeaderTextL();
       
   814     CleanupStack::PushL( text );
       
   815     CAknTitlePane* title = STATIC_CAST( 
       
   816         CAknTitlePane*, 
       
   817         StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
   818     title->SetTextL( *text );
       
   819     CleanupStack::PopAndDestroy(); // text
       
   820     
       
   821     //current message is bio message
       
   822     iFlags.iBioMsg = ETrue;
       
   823     
       
   824     }
       
   825 
       
   826 // ---------------------------------------------------------
       
   827 // CMsgSmsViewerAppUi::AddBioCommandsToMenuL
       
   828 // (other items were commented in a header).
       
   829 // ---------------------------------------------------------
       
   830 void CMsgSmsViewerAppUi::AddBioCommandsToMenuL( 
       
   831     CEikMenuPane* aMenuPane )
       
   832     {
       
   833     BioBody().SetMenuCommandSetL( *aMenuPane );
       
   834     }
       
   835 
       
   836 // ---------------------------------------------------------
       
   837 // CMsgSmsViewerAppUi::OptionsMenuPermissionsBioL
       
   838 // (other items were commented in a header).
       
   839 // ---------------------------------------------------------
       
   840 TUint32 CMsgSmsViewerAppUi::OptionsMenuPermissionsBioL()
       
   841     {
       
   842     __ASSERT_DEBUG( iFlags.iBioMsg, Panic( EMsgSmsBioNotActive ));
       
   843     return BioBody().BioControl().OptionMenuPermissionsL();
       
   844     }
       
   845 
       
   846 // ---------------------------------------------------------
       
   847 // CMsgSmsViewerAppUi::DynInitMenuPaneL
       
   848 // (other items were commented in a header).
       
   849 // ---------------------------------------------------------
       
   850 void CMsgSmsViewerAppUi::DynInitMenuPaneL(
       
   851     TInt aMenuId, 
       
   852     CEikMenuPane* aMenuPane )
       
   853     {
       
   854     // Confirm app is running properly
       
   855     if ( !Document()->IsLaunched())
       
   856         {
       
   857         // If not, hide everything and return
       
   858         TInt amountOfItems = aMenuPane->NumberOfItemsInPane();
       
   859         if ( amountOfItems )
       
   860             {
       
   861             aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems-1 );
       
   862             return;
       
   863             }
       
   864         }
       
   865     // Init all needed objects
       
   866     // Creation delayed to speed up the
       
   867     // viewer's opening process
       
   868     if( !iSendUi )
       
   869         {
       
   870         iSendUi = CSendUi::NewL();
       
   871         }
       
   872     if ( !iFindItemMenu )
       
   873         {
       
   874         // Tests if normal message
       
   875         if ( !iFlags.iBioMsg || !iFlags.iGms ) 
       
   876             {
       
   877             // Prepare FindItem
       
   878             iFindItemMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
       
   879             iFindItemMenu->AttachItemFinderMenuL( R_SMSV_OPTIONSMENUPANE );
       
   880             }
       
   881         }
       
   882 
       
   883     // ...then construct the menu itself. There are two menu-resources,
       
   884     // one for contextmenu and one for normal optionsmenu. 
       
   885     switch ( aMenuId )
       
   886         {
       
   887         case R_SMSV_REPLY_MENU:
       
   888             {           			            
       
   889 	            TSendingCapabilities dummy;
       
   890 	            
       
   891 				//hide normal short message
       
   892 				aMenuPane->SetItemDimmed(
       
   893 	                    ESmsViewerReplyNormal, ETrue);
       
   894 				//hide mms
       
   895 	            aMenuPane->SetItemDimmed(
       
   896 	                    ESmsViewerReplyViaMms, ETrue); 	                    
       
   897 
       
   898 	            //if Audio msg supported
       
   899 	            if ( iFlags.iAudioMsgSupported )
       
   900 	                {
       
   901 	                aMenuPane->SetItemDimmed(
       
   902 	                    ESmsViewerReplyViaAudio, EFalse);
       
   903 	                }
       
   904                 
       
   905             // If this is from email and email settings are defined
       
   906             // we allow the user to reply via E-mail
       
   907             if ( iFlags.iIsEmailMessage &&
       
   908             	 iSendUi->ValidateServiceL( KSenduiMtmSmtpUid, dummy ) )
       
   909                 {
       
   910                 aMenuPane->SetItemDimmed(
       
   911                     ESmsViewerReplyViaEmail, EFalse);
       
   912                 }
       
   913             // If this is from PS number normal reply is dimmed    
       
   914             if ( iFlags.iVoIPNumber )
       
   915                 {
       
   916                 aMenuPane->SetItemDimmed(
       
   917                     ESmsViewerReplyViaEmail, EFalse);
       
   918                 aMenuPane->SetItemDimmed(
       
   919                     ESmsViewerReplyNormal, ETrue);
       
   920                 aMenuPane->SetItemDimmed(
       
   921                     ESmsViewerCreateCC, ETrue);    
       
   922                 }    
       
   923             }
       
   924             break;
       
   925         case R_SMSV_OPTIONSMENUPANE: 
       
   926             {
       
   927             //hide aiw menu item for calender,
       
   928             aMenuPane->SetItemDimmed( KAiwCmdSaveToCalendar, ETrue );
       
   929             
       
   930             if ( !iFlags.iBioMsg )
       
   931                 { // Normal sms or picture msg
       
   932                 DynInitNonBioOptionsMenuL( aMenuPane );
       
   933                 }
       
   934             else
       
   935                 { // Smart (BIO) msg
       
   936                 DynInitBioOptionsMenuL( aMenuId, aMenuPane );
       
   937                 }
       
   938             if ( iFlags.iBioMsg || iFlags.iGms )                
       
   939                 {
       
   940                 aMenuPane->SetItemDimmed( ESmsViewerSubmenuZoomCommands, ETrue );                
       
   941                 }
       
   942             }
       
   943             break;
       
   944         case R_SMSV_CONTEXTMENUPANE:
       
   945             {
       
   946             if ( !iFlags.iBioMsg )
       
   947                 { // Normal sms or picture msg
       
   948                 DynInitNonBioContextMenuL( aMenuPane );
       
   949                 }
       
   950             else
       
   951                 { // Smart (BIO) msg
       
   952                 DynInitBioContextMenuL( aMenuPane );
       
   953                 }
       
   954             }                
       
   955             break;
       
   956         case R_FINDITEMMENU_MENU:
       
   957             {
       
   958             iFindItemMenu->DisplayFindItemCascadeMenuL( *aMenuPane );
       
   959             }
       
   960             break;
       
   961         case R_SMSV_OPTIONSMENUPANE_CLASS0:
       
   962             {
       
   963             TPtrC senderNumber = KNullDesC();
       
   964             if ( iFlags.iValidSenderNumber )
       
   965                 {
       
   966                 senderNumber.Set( iNumber );
       
   967                 }
       
   968             //if autolock enabled, hide finditem-menu
       
   969             if ( iFlags.iAutoLockEnabled )
       
   970                 {
       
   971                 aMenuPane->DeleteMenuItem( EFindItemMenuPlaceHolder );
       
   972                 }
       
   973             else
       
   974 	            {              
       
   975 	            iFindItemMenu->AddItemFindMenuL( 
       
   976                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
   977                 aMenuPane, EFindItemMenuPlaceHolder,
       
   978                 senderNumber, 
       
   979                 iRecipientstring.Length() != 0 ? ETrue : EFalse,
       
   980                 EFalse );
       
   981                 }
       
   982             }
       
   983             break;
       
   984          case R_SMSV_OPTIONSCONTEXTMENUPANE_CLASS0:
       
   985             {
       
   986             TPtrC senderNumber = KNullDesC();
       
   987             if ( iFlags.iValidSenderNumber )
       
   988                 {
       
   989                 senderNumber.Set( iNumber );
       
   990                 }
       
   991             //if autolock enabled, hide finditem-menu
       
   992             if ( iFlags.iAutoLockEnabled )
       
   993                 {
       
   994                 aMenuPane->DeleteMenuItem( EFindItemContextMenuPlaceHolder );
       
   995                 }
       
   996             else
       
   997 	            {              
       
   998 	            iFindItemMenu->AddItemFindMenuL( 
       
   999                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
  1000                 aMenuPane, EFindItemContextMenuPlaceHolder,
       
  1001                 senderNumber, 
       
  1002                 iRecipientstring.Length() != 0 ? ETrue : EFalse,
       
  1003                 ETrue );
       
  1004                 }
       
  1005             }
       
  1006             break;
       
  1007         case R_SMSVIEWER_ZOOM_SUBMENU:
       
  1008             {
       
  1009             TInt zoomLevel = KErrGeneral;
       
  1010             iMsgEditorAppUiExtension->
       
  1011                 iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, zoomLevel );
       
  1012             switch ( zoomLevel )
       
  1013                 {
       
  1014                 case EAknUiZoomAutomatic:
       
  1015                     aMenuPane->SetItemButtonState( EMsgDispSizeAutomatic,
       
  1016                                      EEikMenuItemSymbolOn );
       
  1017                     break;
       
  1018                 case EAknUiZoomNormal:
       
  1019                     aMenuPane->SetItemButtonState( EMsgDispSizeNormal,
       
  1020                                      EEikMenuItemSymbolOn );
       
  1021                     break;
       
  1022                 case EAknUiZoomSmall:
       
  1023                     aMenuPane->SetItemButtonState( EMsgDispSizeSmall,
       
  1024                                      EEikMenuItemSymbolOn );
       
  1025                     break;
       
  1026                 case EAknUiZoomLarge:
       
  1027                     aMenuPane->SetItemButtonState( EMsgDispSizeLarge,
       
  1028                                      EEikMenuItemSymbolOn );
       
  1029                     break;
       
  1030                 default:
       
  1031                     break;
       
  1032                 }
       
  1033             }
       
  1034             break;
       
  1035         default:
       
  1036             if ( iFlags.iBioMsg || iFlags.iGms )
       
  1037                 {// for BIO & GMS; create contact card menu
       
  1038                 // If it's AIW sub-menu, let AIW initialize it
       
  1039                 InitAiwContactCardSubMenuL( aMenuPane );
       
  1040                 }
       
  1041             else
       
  1042                 {// for normal SMS; update the finder menu
       
  1043                 if( iFlags.iVoIPNumber )
       
  1044                     {
       
  1045                     iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
  1046                     }
       
  1047                 iFindItemMenu->UpdateItemFinderMenuL( aMenuId, aMenuPane );
       
  1048                 }
       
  1049             break;
       
  1050         }
       
  1051     }
       
  1052 
       
  1053 // ---------------------------------------------------------
       
  1054 // CMsgSmsViewerAppUi::DynInitNonBioOptionsMenuL
       
  1055 // (other items were commented in a header).
       
  1056 // ---------------------------------------------------------
       
  1057 void CMsgSmsViewerAppUi::DynInitNonBioOptionsMenuL( CEikMenuPane* aMenuPane )
       
  1058     {
       
  1059     if ( !iFlags.iGms )
       
  1060         { // normal sms
       
  1061     
       
  1062          //hide submenu if only item is "via message" or restricted mode ON
       
  1063         TSendingCapabilities dummy; 
       
  1064         if( iFlags.iSmsRestrictedMode ||
       
  1065         	( !iFlags.iAudioMsgSupported && 
       
  1066         	!iFlags.iVoIPNumber &&
       
  1067         	!(iFlags.iIsEmailMessage &&
       
  1068 	            	 iSendUi->ValidateServiceL( KSenduiMtmSmtpUid, dummy )) ))
       
  1069         	{       
       
  1070 			aMenuPane->DeleteMenuItem( ESmsViewerReply );
       
  1071 			aMenuPane->SetItemDimmed( ESmsViewerReplyNoSubMenu, EFalse );
       
  1072         	}        	
       
  1073 
       
  1074         // add automatic highlight menus
       
  1075         TPtrC senderNumber = KNullDesC();
       
  1076         if ( iFlags.iIsEmailMessage ) // SMS originating address is email address 
       
  1077             {  
       
  1078             senderNumber.Set( iRecipientstring );
       
  1079             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
  1080             }            
       
  1081         else 
       
  1082             {// SMS originating adddress is Phone number
       
  1083             if ( iFlags.iValidSenderNumber )
       
  1084                 {
       
  1085                 senderNumber.Set( iNumber );
       
  1086                 }
       
  1087             }
       
  1088         //Added to remove Copy-option when sender number is not valid (for example it has alphabets)    
       
  1089         if ( iFlags.iValidSenderNumber || IsBodyFocused() )
       
  1090         	{
       
  1091 	        if( !iFlags.iVoIPNumber )
       
  1092 	            {
       
  1093 	            iFindItemMenu->SetSenderHighlightStatus( 
       
  1094 	                iView->ControlById( EMsgComponentIdFrom ) == iView->FocusedControl() );
       
  1095 	            iFindItemMenu->SetSenderDisplayText( senderNumber );
       
  1096 	            iFindItemMenu->AddItemFindMenuL( 
       
  1097 	                IsBodyFocused() ? iView->ItemFinder() : 0,
       
  1098 	                aMenuPane, EFindItemMenuPlaceHolder,
       
  1099 	                senderNumber, 
       
  1100 	                iFlags.iIsEmailMessage ? EFalse : ( iRecipientstring.Length() != 0 ) );
       
  1101 	            }
       
  1102 	        else
       
  1103 	            {
       
  1104 	            iFindItemMenu->SetSenderHighlightStatus( 
       
  1105 	                iView->ControlById( EMsgComponentIdFrom ) == iView->FocusedControl() );
       
  1106 	            iFindItemMenu->SetSenderDisplayText( senderNumber );
       
  1107 	            iFindItemMenu->AddItemFindMenuL( 
       
  1108 	                IsBodyFocused() ? iView->ItemFinder() : 0,
       
  1109 	                aMenuPane, EFindItemMenuPlaceHolder,
       
  1110 	                senderNumber, 
       
  1111 	                ETrue );
       
  1112 	            }
       
  1113             }
       
  1114         else //Not valid sender number, dim the find item
       
  1115         	{
       
  1116         	aMenuPane->SetItemDimmed( EFindItemMenuPlaceHolder, ETrue);
       
  1117         	}
       
  1118             
       
  1119         // not needed in automatic highlight
       
  1120         aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
  1121         aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1122         }
       
  1123     else
       
  1124         { // GMS
       
  1125         // dim automatic highlight items
       
  1126         aMenuPane->SetItemDimmed( EFindItemMenuPlaceHolder, ETrue );
       
  1127         
       
  1128         // not supported in unified editor
       
  1129         aMenuPane->SetItemDimmed( ESmsViewerForward, ETrue );
       
  1130         
       
  1131         //dim the Add to Contacts menu if the number is already in address book
       
  1132         if (iRecipientstring.Length() != 0)
       
  1133         	{
       
  1134         	//Number is already in address book
       
  1135         	aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1136         	}
       
  1137         
       
  1138 		}
       
  1139 
       
  1140     // Remove "Call back to sender", "reply" and "create cc" from
       
  1141     // menu, if this is a sent message or sender number is unusable
       
  1142     if ( iControlId == EMsgComponentIdTo || !iFlags.iValidSenderNumber )
       
  1143         {
       
  1144         aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1145         if ( iFlags.iGms )
       
  1146             { // "create cc" and "call back to sender" valid only Gms
       
  1147             aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1148             aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
  1149             }
       
  1150         }
       
  1151     else if ( iFlags.iValidSenderNumber && iFlags.iGms )
       
  1152         {
       
  1153         // Number usable, request Phonebook2 to add menu items (AIW)
       
  1154         InitAiwContactCardMenuL( R_SMSV_OPTIONSMENUPANE, aMenuPane );
       
  1155         }
       
  1156     else
       
  1157         { // Lint
       
  1158         }    
       
  1159     
       
  1160     if ( iFlags.iVoIPNumber )
       
  1161         {
       
  1162         aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1163         aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1164         aMenuPane->SetItemDimmed( ESmsViewerForward, ETrue );
       
  1165         }
       
  1166     else
       
  1167         { // Lint
       
  1168         }
       
  1169 
       
  1170     // Help handling
       
  1171     aMenuPane->SetItemDimmed( EAknCmdHelp, !iFlags.iHelpFeatureSupported );
       
  1172     }
       
  1173     
       
  1174 // ---------------------------------------------------------
       
  1175 // CMsgSmsViewerAppUi::DynInitNonBioContextMenuL
       
  1176 // (other items were commented in a header).
       
  1177 // ---------------------------------------------------------
       
  1178 void CMsgSmsViewerAppUi::DynInitNonBioContextMenuL( CEikMenuPane* aMenuPane )
       
  1179     {
       
  1180     // Remove "Call back to sender" and "reply" from
       
  1181     // menu, if this is a sent message or sender number is not usable
       
  1182     
       
  1183     // if not GMS, dim following              
       
  1184     if ( !iFlags.iGms )
       
  1185         { // Sms
       
  1186         // add automatic highlight menus
       
  1187         TPtrC senderNumber = KNullDesC();
       
  1188         if ( iFlags.iIsEmailMessage ) // SMS originating address is email address 
       
  1189             {  
       
  1190             senderNumber.Set( iRecipientstring );
       
  1191             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
  1192             }            
       
  1193         else 
       
  1194             {// SMS originating adddress is Phone number
       
  1195             if ( iFlags.iValidSenderNumber )
       
  1196                 {
       
  1197                 senderNumber.Set( iNumber );
       
  1198                 }
       
  1199             }
       
  1200         if( !iFlags.iVoIPNumber )
       
  1201             {
       
  1202             iFindItemMenu->SetSenderHighlightStatus( 
       
  1203                 iView->ControlById( EMsgComponentIdFrom ) == iView->FocusedControl() );
       
  1204             iFindItemMenu->SetSenderDisplayText( senderNumber );
       
  1205             iFindItemMenu->AddItemFindMenuL( 
       
  1206                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
  1207                 aMenuPane, EFindItemContextMenuPlaceHolder,
       
  1208                 senderNumber, 
       
  1209                 iFlags.iIsEmailMessage ? EFalse : ( iRecipientstring.Length() != 0 ),
       
  1210                 ETrue );
       
  1211             }
       
  1212         else
       
  1213             {
       
  1214             iFindItemMenu->SetSenderHighlightStatus( 
       
  1215                 iView->ControlById( EMsgComponentIdFrom ) == iView->FocusedControl() );
       
  1216             iFindItemMenu->SetSenderDisplayText( senderNumber );
       
  1217             iFindItemMenu->AddItemFindMenuL( 
       
  1218                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
  1219                 aMenuPane, EFindItemContextMenuPlaceHolder,
       
  1220                 senderNumber, 
       
  1221                 ETrue,
       
  1222                 ETrue );
       
  1223             }
       
  1224         }
       
  1225     else 
       
  1226         { // Gms
       
  1227         // dim automatic highlight items
       
  1228         aMenuPane->SetItemDimmed( EFindItemContextMenuPlaceHolder, ETrue );
       
  1229         }
       
  1230     }
       
  1231 
       
  1232 // ---------------------------------------------------------
       
  1233 // CMsgSmsViewerAppUi::DynInitBioOptionsMenuL
       
  1234 // (other items were commented in a header).
       
  1235 // ---------------------------------------------------------
       
  1236 void CMsgSmsViewerAppUi::DynInitBioOptionsMenuL(
       
  1237     TInt aMenuId,
       
  1238     CEikMenuPane* aMenuPane )
       
  1239     {
       
  1240     // dim automatic highlight items
       
  1241     aMenuPane->SetItemDimmed( EFindItemMenuPlaceHolder, ETrue );
       
  1242     //dim the Add to Contacts menu if the number is already in address book
       
  1243     if (iRecipientstring.Length() != 0)
       
  1244     	{
       
  1245     	//Number is already in address book
       
  1246     	aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1247     	}
       
  1248     
       
  1249     if ( iControlId == EMsgComponentIdTo ) // Sent item
       
  1250         {
       
  1251         aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
  1252         aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1253         aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1254         aMenuPane->SetItemDimmed( ESmsViewerForward, ETrue );
       
  1255         }
       
  1256     else // Inbox item
       
  1257         {
       
  1258         AddBioCommandsToMenuL( aMenuPane );
       
  1259 
       
  1260         TUint32 permBio = OptionsMenuPermissionsBioL();        
       
  1261         
       
  1262         if ( !iFlags.iValidSenderNumber )
       
  1263             {
       
  1264             aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
  1265             aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1266             aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1267             }
       
  1268         else // Sender number is valid, check does biocontrol accept options
       
  1269             {
       
  1270             if ( !( permBio & EMsgBioReply ) )
       
  1271                 {
       
  1272                 aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1273                 }
       
  1274         
       
  1275             if ( !( permBio & EMsgBioCallBack ) || iFlags.iIrBt )
       
  1276                 {
       
  1277                 aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
  1278                 }
       
  1279 
       
  1280             if ( !( permBio & EMsgBioCreateCC) )
       
  1281                 {
       
  1282                 aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
  1283                 }
       
  1284             else
       
  1285                 {
       
  1286                 // Request Phonebook2 to add menu items (AIW)
       
  1287                 InitAiwContactCardMenuL( aMenuId, aMenuPane );
       
  1288                 }
       
  1289             }
       
  1290 
       
  1291         if ( !( permBio & EMsgBioForward ) )
       
  1292             {
       
  1293             aMenuPane->SetItemDimmed( ESmsViewerForward, ETrue );
       
  1294             }
       
  1295 
       
  1296         if ( !( permBio & EMsgBioDelete ))
       
  1297             {
       
  1298             aMenuPane->SetItemDimmed( ESmsViewerDelete, ETrue );
       
  1299             }
       
  1300 
       
  1301         if ( !( permBio & EMsgBioMessInfo ))
       
  1302             {
       
  1303             aMenuPane->SetItemDimmed( ESmsViewerMessInfo, ETrue );
       
  1304             }
       
  1305 
       
  1306         if ( !( permBio & EMsgBioMove ))
       
  1307             {
       
  1308             aMenuPane->SetItemDimmed( ESmsViewerMove, ETrue );
       
  1309             }
       
  1310         
       
  1311         // Help-handling
       
  1312         aMenuPane->SetItemDimmed( EAknCmdHelp, !iFlags.iHelpFeatureSupported || !( permBio & EMsgBioHelp ));
       
  1313         
       
  1314         if ( permBio & EMsgBioFindItem ) // This used to be else if. Mistake?
       
  1315             {
       
  1316             iFindItemMenu->DisplayFindItemMenuItemL( *aMenuPane, ESmsViewerCreateCC );
       
  1317             }
       
  1318         }
       
  1319     }
       
  1320 
       
  1321 // ---------------------------------------------------------
       
  1322 // CMsgSmsViewerAppUi::DynInitBioContextMenuL
       
  1323 // (other items were commented in a header).
       
  1324 // ---------------------------------------------------------
       
  1325 void CMsgSmsViewerAppUi::DynInitBioContextMenuL( CEikMenuPane* aMenuPane )
       
  1326     {
       
  1327     // dim automatic highlight items
       
  1328     aMenuPane->SetItemDimmed( EFindItemContextMenuPlaceHolder, ETrue );
       
  1329 
       
  1330     if ( iControlId == EMsgComponentIdTo )
       
  1331         {
       
  1332         //aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
  1333         }
       
  1334     else
       
  1335         {
       
  1336         AddBioCommandsToMenuL( aMenuPane );
       
  1337 
       
  1338         if ( !(OptionsMenuPermissionsBioL() & EMsgBioDelete )) 
       
  1339             {
       
  1340             //aMenuPane->SetItemDimmed( ESmsViewerDelete, ETrue );
       
  1341             }
       
  1342         }
       
  1343     }
       
  1344 
       
  1345 // ---------------------------------------------------------
       
  1346 // CMsgSmsViewerAppUi::HandleCommandL
       
  1347 // (other items were commented in a header).
       
  1348 // ---------------------------------------------------------
       
  1349 void CMsgSmsViewerAppUi::HandleCommandL(TInt aCommand )
       
  1350     {
       
  1351 
       
  1352     if ( aCommand != EEikCmdExit && !iFullyConstructed )
       
  1353     	{
       
  1354     	return;
       
  1355     	}
       
  1356     
       
  1357         
       
  1358     // is it find item command
       
  1359     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) && !iFlags.iGms && !iFlags.iBioMsg )
       
  1360         {
       
  1361         iFindItemMenu->HandleItemFinderCommandL( aCommand );
       
  1362         return;
       
  1363         }
       
  1364     
       
  1365     // Are we dealing with bio-message?
       
  1366     if ( iFlags.iBioMsg ) 
       
  1367         {
       
  1368         // let the biocontrol handle the command and check
       
  1369         // whether it was handled.
       
  1370         if ( aCommand==EAknCmdHelp )
       
  1371             {
       
  1372             LaunchHelpL();
       
  1373             return;
       
  1374             }
       
  1375 
       
  1376         if ( Document( )->IsLaunched( ) && BioBody().HandleBioCommandL( aCommand ))
       
  1377             {
       
  1378             return;// Bio control has handled the command.
       
  1379             }
       
  1380         }
       
  1381     
       
  1382     // find item
       
  1383     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) && ( iFlags.iGms || iFlags.iBioMsg ))
       
  1384         {
       
  1385         DoSearchL( aCommand );
       
  1386         }
       
  1387     
       
  1388     switch ( aCommand )
       
  1389         {
       
  1390         case ESmsViewerReplyNormal:	//normal sms
       
  1391             CheckDiskAndReplyForwardL( EFalse );
       
  1392 			if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1393                 {
       
  1394                 Exit( EAknSoftkeyClose );
       
  1395                 }
       
  1396             break;
       
  1397         case ESmsViewerReplyViaMms:
       
  1398             DoReplyViaL( ESmsViewerReplyViaMms );
       
  1399 			if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1400                 {
       
  1401                 Exit( EAknSoftkeyClose );
       
  1402                 }
       
  1403             break;
       
  1404         case ESmsViewerReplyViaEmail:
       
  1405             DoReplyViaL( ESmsViewerReplyViaEmail );
       
  1406             if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1407                 {
       
  1408                 Exit( EAknSoftkeyClose );
       
  1409                 }
       
  1410             break;
       
  1411         case ESmsViewerReplyViaAudio:
       
  1412             DoReplyViaL( ESmsViewerReplyViaAudio );
       
  1413             if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1414                 {
       
  1415                 Exit( EAknSoftkeyClose );
       
  1416                 }
       
  1417             break;
       
  1418         case ESmsViewerReplyNoSubMenu:  //unieditor, submenu hidden 
       
  1419             CheckDiskAndReplyForwardL( EFalse );
       
  1420             if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1421                 {
       
  1422                 Exit( EAknSoftkeyClose );
       
  1423             	}
       
  1424             break;
       
  1425         case ESmsViewerReplyViaMessage:  //unieditor
       
  1426             CheckDiskAndReplyForwardL( EFalse );
       
  1427 			if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1428                 {
       
  1429                 Exit( EAknSoftkeyClose );
       
  1430                 }
       
  1431             break;
       
  1432         case ESmsViewerForward:
       
  1433             CheckDiskAndReplyForwardL( ETrue );
       
  1434 			if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1435 				{
       
  1436 				Exit( EAknSoftkeyClose );
       
  1437 				}
       
  1438             break;
       
  1439         case ESmsViewerDelete:
       
  1440             DoFileDeleteL();
       
  1441             break;
       
  1442         case ESmsViewerMove:
       
  1443             DoMoveEntryL();
       
  1444             break;
       
  1445         case ESmsViewerSave:
       
  1446             SaveClass0SmsL( ETrue );
       
  1447             Exit( EAknSoftkeyClose );
       
  1448             break;
       
  1449         case ESmsViewerCallBack:
       
  1450             DoCallBackToSenderL();
       
  1451             break;
       
  1452         case ESmsViewerCreateCCNew:
       
  1453             // FALLTHROUGH
       
  1454         case ESmsViewerCreateCCExisting:
       
  1455             DoCreateContactCardL( aCommand );
       
  1456             break;
       
  1457         case ESmsViewerMessInfo:
       
  1458             DoMessageInfoL();
       
  1459             break;
       
  1460         case EAknSoftkeyBack:
       
  1461             Exit( EAknSoftkeyClose );
       
  1462             break;
       
  1463         case EEikCmdExit:
       
  1464             // system exit
       
  1465             DoMsgSaveExitL();
       
  1466             break;
       
  1467         case EAknSoftkeyExit: // called only with class 0 exit
       
  1468             DeleteAndExitL();
       
  1469             break;
       
  1470         case EAknCmdHelp:
       
  1471             LaunchHelpL();
       
  1472             break;
       
  1473         case EMsgDispSizeAutomatic:
       
  1474         case EMsgDispSizeLarge:
       
  1475         case EMsgDispSizeNormal:
       
  1476         case EMsgDispSizeSmall:
       
  1477             HandleLocalZoomChangeL( (TMsgCommonCommands)aCommand );
       
  1478             break;
       
  1479         default:
       
  1480             break;
       
  1481         }
       
  1482     }
       
  1483 
       
  1484 // ---------------------------------------------------------
       
  1485 // CMsgSmsViewerAppUi::BodyEditor
       
  1486 // (other items were commented in a header).
       
  1487 // ---------------------------------------------------------
       
  1488 CEikRichTextEditor& CMsgSmsViewerAppUi::BodyEditor() const
       
  1489     {
       
  1490      __ASSERT_DEBUG(  !iFlags.iBioMsg, Panic(EMsgSmsNotAllowedForBio));
       
  1491     return STATIC_CAST( CMsgBodyControl*, iView->ControlById( EMsgComponentIdBody ))->Editor();
       
  1492     }
       
  1493 
       
  1494 // ---------------------------------------------------------
       
  1495 // CMsgSmsViewerAppUi::BioBody
       
  1496 // (other items were commented in a header).
       
  1497 // ---------------------------------------------------------
       
  1498 CMsgBioBodyControl& CMsgSmsViewerAppUi::BioBody() const
       
  1499     {
       
  1500     __ASSERT_DEBUG( iFlags.iBioMsg, Panic( EMsgSmsBioBodyOnlyForBio )); 
       
  1501     return *STATIC_CAST( CMsgBioBodyControl*, iView->ControlById( EMsgComponentIdBody ));
       
  1502     }
       
  1503 
       
  1504 // ---------------------------------------------------------
       
  1505 // CMsgSmsViewerAppUi::FirstFreeCommand
       
  1506 // (other items were commented in a header).
       
  1507 // ---------------------------------------------------------
       
  1508 TInt CMsgSmsViewerAppUi::FirstFreeCommand() const
       
  1509     {
       
  1510     return ESmsViewerFirstFreeCmdId;
       
  1511     }
       
  1512 
       
  1513 // ---------------------------------------------------------
       
  1514 // CMsgSmsViewerAppUi::RequestHandleCommandL
       
  1515 // (other items were commented in a header).
       
  1516 // ---------------------------------------------------------
       
  1517 TInt CMsgSmsViewerAppUi::RequestHandleCommandL(
       
  1518     TMsgCommands /*aCommand*/ )
       
  1519     {
       
  1520     //Not used at the moment.
       
  1521     return KErrNotSupported;
       
  1522     }
       
  1523 
       
  1524 // ---------------------------------------------------------
       
  1525 // CMsgSmsViewerAppUi::IsCommandSupported
       
  1526 // (other items were commented in a header).
       
  1527 // ---------------------------------------------------------
       
  1528 TBool CMsgSmsViewerAppUi::IsCommandSupported(
       
  1529     TMsgCommands /*aCommand*/ ) const
       
  1530     {
       
  1531     //Nothing supported at the moment.
       
  1532     return EFalse;
       
  1533     }
       
  1534 
       
  1535 // ---------------------------------------------------------
       
  1536 // CMsgSmsViewerAppUi::IsBodyFocused
       
  1537 // (other items were commented in a header).
       
  1538 // ---------------------------------------------------------
       
  1539 TBool CMsgSmsViewerAppUi::IsBodyFocused() const
       
  1540     {
       
  1541     return (( iView->ControlById( EMsgComponentIdBody )) 
       
  1542         == iView->FocusedControl()); 
       
  1543     }
       
  1544 // ---------------------------------------------------------
       
  1545 // CMsgSmsViewerAppUi::IsSenderFocused
       
  1546 // (other items were commented in a header).
       
  1547 // ---------------------------------------------------------
       
  1548 TBool CMsgSmsViewerAppUi::IsSenderFocused() const
       
  1549     {
       
  1550     return (( iView->ControlById( EMsgComponentIdFrom )) 
       
  1551         == iView->FocusedControl()); 
       
  1552     }
       
  1553 
       
  1554 // ---------------------------------------------------------
       
  1555 // CMsgSmsViewerAppUi::HandleKeyEventL
       
  1556 // (other items were commented in a header).
       
  1557 // ---------------------------------------------------------
       
  1558 TKeyResponse CMsgSmsViewerAppUi::HandleKeyEventL(
       
  1559     const TKeyEvent& aKeyEvent, 
       
  1560     TEventCode aType )
       
  1561     {
       
  1562     
       
  1563     // Confirm app is running properly
       
  1564     if ( iView && ( aType == EEventKey ) && Document()->IsLaunched())
       
  1565         { 
       
  1566         // react with all sms classes
       
  1567         switch ( aKeyEvent.iCode )
       
  1568             {
       
  1569             case EKeyUpArrow:
       
  1570             case EKeyDownArrow:
       
  1571                 {
       
  1572                 // Base-editor handles scrolling
       
  1573                 iView->OfferKeyEventL( aKeyEvent, aType );
       
  1574                 return EKeyWasConsumed;
       
  1575                 }
       
  1576             case EKeyDevice3:
       
  1577             case EKeyEnter:	
       
  1578                 {// Selection-key checking (Context sensitive menu)
       
  1579                 // (with Class 0 just show the menu)
       
  1580                 if ( !iClass0CBA )
       
  1581                     {
       
  1582                     MenuBar()->SetMenuTitleResourceId( R_SMSV_CONTEXTMENUBAR );
       
  1583                     MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1584                     }
       
  1585                 MenuBar()->TryDisplayMenuBarL();
       
  1586                 if ( !iClass0CBA )
       
  1587                     {
       
  1588                     MenuBar()->SetMenuTitleResourceId( R_SMSV_OPTIONSMENUBAR );
       
  1589                     MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1590                     }
       
  1591                 return EKeyWasConsumed;
       
  1592                 }
       
  1593                 case EKeyYes:
       
  1594 	                {// Send-key checking
       
  1595 	                if ( !iFlags.iIrBt && !iFlags.iBioMsg && !iFlags.iGms && !iFlags.iIsEmailMessage &&
       
  1596 	                			!iFlags.iAutoLockEnabled )
       
  1597 	                    { // normal sms
       
  1598 	                    DoHandleSendKeyL();
       
  1599 	                    }
       
  1600 	                else if ( iFlags.iValidSenderNumber && !iFlags.iIrBt && !iFlags.iIsEmailMessage 
       
  1601 	                		&& !iFlags.iAutoLockEnabled )
       
  1602 	                    { // bio / gms - sms
       
  1603 	                    TBool okToQuery( ETrue );
       
  1604 	                    // Is it biocontrol?
       
  1605 	                    if ( iFlags.iBioMsg )
       
  1606 	                        {
       
  1607 	                        TUint32 permBio = OptionsMenuPermissionsBioL();
       
  1608 	                        okToQuery = ( permBio & EMsgBioCallBack ) ? ETrue : EFalse ;
       
  1609 	                        }
       
  1610 	                    // Launch confirmation query and start calling
       
  1611 	                    if ( okToQuery )
       
  1612 	                        {
       
  1613 	                        if ( iMsgVoIPExtension && 
       
  1614 	                            iMsgVoIPExtension->IsPreferredTelephonyVoIP() &&
       
  1615 	                            iMsgVoIPExtension->VoIPProfilesExistL() )
       
  1616 	                            {
       
  1617 	                            MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( iNumber, iRecipientstring, ETrue );  
       
  1618 	                            }
       
  1619 	                        else
       
  1620 	                            {
       
  1621 	                            MsvUiServiceUtilitiesInternal::CallToSenderQueryL( iNumber, iRecipientstring, ETrue );
       
  1622 	                            }
       
  1623 	                        }
       
  1624 	                    }
       
  1625 	                }
       
  1626             
       
  1627             default:
       
  1628                 break;
       
  1629             }
       
  1630         
       
  1631         if ( !iClass0CBA ) // ignore following events if class 0 sms
       
  1632             {
       
  1633             switch ( aKeyEvent.iCode )
       
  1634                 {
       
  1635                 case EKeyRightArrow:
       
  1636                     {// Show next message if possible
       
  1637                     if ( IsNextMessageAvailableL( ETrue ))
       
  1638                         {
       
  1639                         NextMessageL( ETrue );
       
  1640                         return EKeyWasConsumed;
       
  1641                         }
       
  1642                     }
       
  1643                     break;
       
  1644                 case EKeyLeftArrow:
       
  1645                     { // Show prev message if possible
       
  1646                     if ( IsNextMessageAvailableL( EFalse ))
       
  1647                         {
       
  1648                         NextMessageL( EFalse );
       
  1649                         return EKeyWasConsumed;
       
  1650                         }
       
  1651                     }
       
  1652                     break;
       
  1653                 case EKeyBackspace:
       
  1654                     {
       
  1655                     DoFileDeleteL();
       
  1656 	                return EKeyWasConsumed;
       
  1657 	                }
       
  1658                 default:
       
  1659                     break;
       
  1660                 }
       
  1661             }
       
  1662         else
       
  1663             { // class 0
       
  1664             return EKeyWasConsumed;
       
  1665             }
       
  1666         }
       
  1667     else // App is not running properly yet
       
  1668         {
       
  1669         return EKeyWasConsumed;
       
  1670         }
       
  1671     
       
  1672     return EKeyWasNotConsumed; 
       
  1673     }
       
  1674 
       
  1675 // ---------------------------------------------------------
       
  1676 // CMsgSmsViewerAppUi::DoMsgSaveExitL
       
  1677 // (other items were commented in a header).
       
  1678 // ---------------------------------------------------------
       
  1679 void CMsgSmsViewerAppUi::DoMsgSaveExitL() 
       
  1680     {
       
  1681     // exit in anycase
       
  1682     Exit();
       
  1683     }
       
  1684 
       
  1685 // ---------------------------------------------------------
       
  1686 // CMsgSmsViewerAppUi::DoFileDeleteL
       
  1687 // (other items were commented in a header).
       
  1688 // ---------------------------------------------------------
       
  1689 void CMsgSmsViewerAppUi::DoFileDeleteL()
       
  1690     {
       
  1691     // Load the texts from resources
       
  1692     HBufC* text = StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE_ME, iCoeEnv );
       
  1693     
       
  1694     // Confirm from user deletion of message and delete if needed.
       
  1695     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  1696     if ( dlg->ExecuteLD( R_DELETEMSGCONF_QUERY, *text ))
       
  1697         {
       
  1698         DeleteAndExitL();        
       
  1699         }
       
  1700 
       
  1701     CleanupStack::PopAndDestroy(); // text, confText
       
  1702     }
       
  1703 
       
  1704 // ---------------------------------------------------------
       
  1705 // CMsgSmsViewerAppUi::DoMoveEntryL
       
  1706 // (other items were commented in a header).
       
  1707 // ---------------------------------------------------------
       
  1708 void CMsgSmsViewerAppUi::DoMoveEntryL()
       
  1709     {
       
  1710     CMsvEntry& entry = Document()->CurrentEntry();
       
  1711     TMsvEntry msvEntry( entry.Entry());
       
  1712    
       
  1713     // When going in to SelectFolder-dialog folderId is
       
  1714     // the folder where message is, but when coming
       
  1715     // out (if selection done) it has the value of destination 
       
  1716     // folder.
       
  1717     TMsvId folderId = msvEntry.Parent();
       
  1718     HBufC* text = StringLoader::LoadLC( R_QTN_MCE_MOVE_MOVE_TO, iCoeEnv );
       
  1719     
       
  1720     // Launch moving-dialog and proceed if ok-returned
       
  1721     TBool moveIt = CMsgFolderSelectionDialog::SelectFolderL( folderId, *text );
       
  1722     CleanupStack::PopAndDestroy(); // text
       
  1723     if ( moveIt )
       
  1724         {
       
  1725         MoveMessageEntryL( folderId );
       
  1726         Exit( EAknSoftkeyClose );
       
  1727         }
       
  1728     }
       
  1729 
       
  1730 // ----------------------------------------------------
       
  1731 // CMsgSmsViewerAppUi::DoSearchL
       
  1732 // (other items were commented in a header).
       
  1733 // ----------------------------------------------------
       
  1734 void CMsgSmsViewerAppUi::DoSearchL( TInt aCommand )
       
  1735     {
       
  1736     __ASSERT_DEBUG(!iFlags.iBioMsg, Panic(EMsgSmsNotAllowedForBio));
       
  1737     CFindItemDialog* dlg;
       
  1738     
       
  1739     CMsgBodyControl* ctrl = STATIC_CAST( CMsgBodyControl*, 
       
  1740         iView->ControlById(
       
  1741         EMsgComponentIdBody ));
       
  1742     
       
  1743     dlg =  CFindItemDialog::NewL( 
       
  1744         ctrl->TextContent().Read( 0 ), 
       
  1745         iFindItemMenu->SearchCase( aCommand) );
       
  1746     
       
  1747     dlg->ExecuteLD();
       
  1748     }
       
  1749 
       
  1750 // ----------------------------------------------------
       
  1751 // CMsgSmsViewerAppUi::DoCallBackToSenderL
       
  1752 // (other items were commented in a header).
       
  1753 // ----------------------------------------------------
       
  1754 void CMsgSmsViewerAppUi::DoCallBackToSenderL()
       
  1755     {
       
  1756     if ( iFlags.iValidSenderNumber )
       
  1757         {
       
  1758         MsvUiServiceUtilitiesInternal::CallToSenderQueryL( iNumber, iRecipientstring );
       
  1759         }
       
  1760     }
       
  1761 
       
  1762 // ---------------------------------------------------------
       
  1763 // CMsgSmsViewerAppUi::DoCreateContactCardL
       
  1764 // (other items were commented in a header).
       
  1765 // ---------------------------------------------------------
       
  1766 void CMsgSmsViewerAppUi::DoCreateContactCardL( TInt aCommand )
       
  1767     {
       
  1768     CAiwGenericParamList& inList = iAiwServiceHandler->InParamListL();
       
  1769     InitAiwContactCardParamL( inList );
       
  1770     // Callback is not specified as we are not interested in the outcome of the assign
       
  1771     // operation.
       
  1772     iAiwServiceHandler->ExecuteMenuCmdL( aCommand, inList,
       
  1773         iAiwServiceHandler->OutParamListL(), 0, NULL);
       
  1774     }
       
  1775 
       
  1776 // ----------------------------------------------------
       
  1777 // CMsgSmsViewerAppUi::OpCompleted
       
  1778 // ----------------------------------------------------
       
  1779 void CMsgSmsViewerAppUi::OpCompleted(
       
  1780     CMsvSingleOpWatcher& aOpWatcher,
       
  1781     TInt aCompletionCode )
       
  1782     {
       
  1783     CMsvOperation* op = &aOpWatcher.Operation();
       
  1784     // Must be trapped because calls Leaving function
       
  1785     TRAP_IGNORE( DoOperationCompletedL( op, aCompletionCode ) );// Ignored as non critical block
       
  1786     // The only operation
       
  1787     delete iViewerOperation;
       
  1788     iViewerOperation = NULL;
       
  1789     }
       
  1790 
       
  1791 // ----------------------------------------------------
       
  1792 // CMsgSmsViewerAppUi::DoOperationCompletedL
       
  1793 // ----------------------------------------------------
       
  1794 void CMsgSmsViewerAppUi::DoOperationCompletedL(
       
  1795     CMsvOperation* aOperation,
       
  1796     TInt aCompletionCode )
       
  1797     {
       
  1798     __ASSERT_DEBUG( aOperation, Panic( EMsgSmsNullPointer ) );
       
  1799     if ( aOperation && aCompletionCode == EEikCmdExit )
       
  1800         {
       
  1801         CAknAppUi::ProcessCommandL( EAknCmdExit );
       
  1802         }
       
  1803     }
       
  1804 
       
  1805 // ---------------------------------------------------------
       
  1806 // CMsgSmsViewerAppUi::DoMessageInfoL
       
  1807 // (other items were commented in a header).
       
  1808 // ---------------------------------------------------------
       
  1809 void CMsgSmsViewerAppUi::DoMessageInfoL()
       
  1810     {
       
  1811     __ASSERT_DEBUG( !iViewerOperation, Panic( EMsgSmsNullPointer ) );
       
  1812     CMsvEntrySelection* selection = NULL; // Not used by KMtmUiFunctionMessageInfo
       
  1813     CAknInputBlock::NewLC();
       
  1814     CBaseMtmUi& uiMtm = Document()->MtmUiL();
       
  1815     TBuf8<1> dummy;
       
  1816     CMsvSingleOpWatcher* singleOpWatcher = CMsvSingleOpWatcher::NewL( *this );
       
  1817     CleanupStack::PushL( singleOpWatcher );
       
  1818 
       
  1819     CMsvOperation* op = uiMtm.InvokeAsyncFunctionL(
       
  1820                                 KMtmUiFunctionMessageInfo, 
       
  1821                                 *selection, 
       
  1822                                 singleOpWatcher->iStatus, 
       
  1823                                 dummy );
       
  1824     iViewerOperation = singleOpWatcher;
       
  1825     CleanupStack::Pop( 1 ); // singleOpWatcher
       
  1826     singleOpWatcher->SetOperation( op );
       
  1827 
       
  1828     CleanupStack::PopAndDestroy( 1 );// CAknInputBlock
       
  1829     }
       
  1830 
       
  1831 // ----------------------------------------------------
       
  1832 // CMsgSmsViewerAppUi::ForwardGmsL
       
  1833 // (other items were commented in a header).
       
  1834 // ----------------------------------------------------
       
  1835 void CMsgSmsViewerAppUi::ForwardGmsL(TMsvId aTarget)
       
  1836     {
       
  1837     DoFwdRepGmsL(aTarget, ETrue);
       
  1838     }
       
  1839 
       
  1840 // ----------------------------------------------------
       
  1841 // CMsgSmsViewerAppUi::ReplyGmsL
       
  1842 // (other items were commented in a header).
       
  1843 // ----------------------------------------------------
       
  1844 void CMsgSmsViewerAppUi::ReplyGmsL(TMsvId aTarget)
       
  1845     {
       
  1846     DoFwdRepGmsL(aTarget, EFalse);
       
  1847     }
       
  1848     
       
  1849 // ----------------------------------------------------
       
  1850 // CMsgSmsViewerAppUi::DoFwdRepGmsL
       
  1851 // (other items were commented in a header).
       
  1852 // ----------------------------------------------------
       
  1853 void CMsgSmsViewerAppUi::DoFwdRepGmsL(TMsvId aTarget, TBool aForward)
       
  1854     {
       
  1855     CMsgEditorDocument& document = *Document();
       
  1856     TMsvId origMsgId = document.Entry().Id();
       
  1857 
       
  1858     // Change the MTM type of msg temporarily
       
  1859     CMsvEntry* entry = 
       
  1860         document.Session().GetEntryL(origMsgId);
       
  1861     CleanupStack::PushL(entry);
       
  1862 
       
  1863     TMsvEntry tentry(entry->Entry());
       
  1864     const TUid OrigMtmUid = tentry.iMtm;
       
  1865     tentry.iMtm = KUidSmsMtm;
       
  1866         
       
  1867     // Trap errors, so we can try to restore the original MTM Uid
       
  1868     TRAPD(err, 
       
  1869         {
       
  1870         entry->ChangeL(tentry);
       
  1871         document.SetEntryWithoutNotificationL(origMsgId);
       
  1872         
       
  1873         if (aForward)
       
  1874             {
       
  1875             ForwardL(aTarget);
       
  1876             }
       
  1877         else
       
  1878             {
       
  1879             ReplyL(aTarget);
       
  1880             }
       
  1881         
       
  1882         });
       
  1883     // Restore original Mtm Uid
       
  1884     tentry = entry->Entry();
       
  1885     tentry.iMtm = OrigMtmUid;
       
  1886     entry->ChangeL(tentry);
       
  1887     document.SetEntryWithoutNotificationL(origMsgId);
       
  1888     
       
  1889     User::LeaveIfError(err);
       
  1890     CleanupStack::PopAndDestroy(entry);    
       
  1891     }
       
  1892 
       
  1893 // ----------------------------------------------------
       
  1894 // CMsgSmsViewerAppUi::SaveClass0SmsL
       
  1895 // (other items were commented in a header).
       
  1896 // ----------------------------------------------------
       
  1897 void CMsgSmsViewerAppUi::SaveClass0SmsL( TBool aShowNotes )
       
  1898     {
       
  1899     if ( aShowNotes )
       
  1900         { // Show global "Saved"-note
       
  1901         HBufC* text = StringLoader::LoadLC( R_QTN_MCE_CONF_MESSAGE_SAVED, iCoeEnv );
       
  1902         CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
  1903         note->ShowNoteL( EAknGlobalConfirmationNote, *text );
       
  1904         CleanupStack::PopAndDestroy( 2 ); // note, text
       
  1905         }
       
  1906     
       
  1907     // Get handle to entry
       
  1908     const CMsgSmsViewerDocument* doc = Document();
       
  1909     CMsvEntry& entry = doc->CurrentEntry();
       
  1910     TMsvEntry msvEntry( entry.Entry());
       
  1911     
       
  1912     // Read values from TMsvEntry
       
  1913     HBufC* details = msvEntry.iDetails.AllocLC();
       
  1914     HBufC* description = msvEntry.iDescription.AllocLC();
       
  1915     
       
  1916     // Ensure entry is not read only
       
  1917     msvEntry.SetReadOnly( EFalse );
       
  1918     entry.ChangeL( msvEntry );
       
  1919     
       
  1920     // Set class from 0 to 1 and save
       
  1921     CMsvStore* msvstore = entry.EditStoreL();
       
  1922     CleanupStack::PushL( msvstore );
       
  1923     iSmsHeader->Message().SmsPDU().SetClass(
       
  1924         ETrue, TSmsDataCodingScheme::ESmsClass1 );
       
  1925     iSmsHeader->StoreL( *msvstore );
       
  1926     msvstore->Commit();
       
  1927     CleanupStack::PopAndDestroy(); // msvstore
       
  1928     
       
  1929     // Put values back to TMsvEntry
       
  1930     msvEntry.iDetails.Set( *details );
       
  1931     msvEntry.iDescription.Set( *description );
       
  1932     
       
  1933     // Change entry back to read only and ensure it's visible
       
  1934     msvEntry.SetReadOnly( ETrue );
       
  1935     msvEntry.SetInPreparation( EFalse );
       
  1936     msvEntry.SetVisible( ETrue );
       
  1937     entry.ChangeL( msvEntry );
       
  1938     CleanupStack::PopAndDestroy( 2 ); // details, description
       
  1939     }
       
  1940 
       
  1941 // ---------------------------------------------------------
       
  1942 // CMsgSmsViewerAppUi::ApproximateReplyForwardSize
       
  1943 // (other items were commented in a header).
       
  1944 // ---------------------------------------------------------
       
  1945 TInt CMsgSmsViewerAppUi::ApproximateReplyForwardSize( TBool aForward )
       
  1946     {
       
  1947     //
       
  1948     // Approximate size
       
  1949     TInt approximatedSize = 0;
       
  1950     if ( aForward )
       
  1951         { // yes, forward
       
  1952         if ( iFlags.iGms )
       
  1953             { // picture msg
       
  1954             approximatedSize = KApproxEmptyTMsvEntrySize + KApproxFullGMS; 
       
  1955             }
       
  1956         else
       
  1957             { // normal sms
       
  1958             approximatedSize = KApproxEmptyTMsvEntrySize + STATIC_CAST( CMsgBodyControl*, iView->ControlById( EMsgComponentIdBody ))->Editor().TextLength()*2; // multiplied because of unicode saving
       
  1959             }
       
  1960         }
       
  1961     else
       
  1962         { // no, reply (same for normal sms and gms)
       
  1963         approximatedSize = KApproxEmptyTMsvEntrySize + KApproxRecipientSize;
       
  1964         }
       
  1965 
       
  1966     return approximatedSize;
       
  1967     }
       
  1968 
       
  1969 // ---------------------------------------------------------
       
  1970 // CMsgSmsViewerAppUi::CheckDiskAndReplyForwardL
       
  1971 // (other items were commented in a header).
       
  1972 // ---------------------------------------------------------
       
  1973 void CMsgSmsViewerAppUi::CheckDiskAndReplyForwardL( TBool aForward )
       
  1974     {
       
  1975     //
       
  1976     // Check disk
       
  1977     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( 
       
  1978     	Document()->Session(),
       
  1979         ApproximateReplyForwardSize( aForward  ))) 
       
  1980         {
       
  1981         User::Leave( KErrDiskFull );
       
  1982         }
       
  1983 
       
  1984     //to reduce flickering during closing
       
  1985 	if (!(iEditorBaseFeatures & EStayInViewerAfterReply ))
       
  1986         {
       
  1987         iView->MakeVisible( EFalse );
       
  1988         }
       
  1989         
       
  1990     TRAPD(err, DoReplyFwdL( aForward ));
       
  1991     if(!(err == KErrNone) )
       
  1992         {
       
  1993         iView->MakeVisible( ETrue );
       
  1994         }    
       
  1995     
       
  1996     }
       
  1997     
       
  1998 // ---------------------------------------------------------
       
  1999 // CMsgSmsViewerAppUi::DoReplyFwdL
       
  2000 // (other items were commented in a header).
       
  2001 // ---------------------------------------------------------
       
  2002 void CMsgSmsViewerAppUi::DoReplyFwdL( TBool aForward )
       
  2003     {
       
  2004     // Actual forward / reply
       
  2005     // Are we forwarding...
       
  2006     if ( aForward )
       
  2007         { //...yes, forwarding
       
  2008         if ( iFlags.iGms )
       
  2009             {
       
  2010             ForwardGmsL( Document()->DefaultMsgFolder());
       
  2011             }
       
  2012         else
       
  2013             {
       
  2014             ForwardL( Document()->DefaultMsgFolder());
       
  2015             }
       
  2016         }
       
  2017     else
       
  2018         { //...no, we're replying
       
  2019         if ( iFlags.iGms )
       
  2020             {
       
  2021             ReplyGmsL( Document()->DefaultMsgFolder());
       
  2022             }
       
  2023         else
       
  2024             {
       
  2025             ReplyL( Document()->DefaultMsgFolder());
       
  2026             }
       
  2027         }
       
  2028     }
       
  2029 
       
  2030 // ---------------------------------------------------------
       
  2031 // CMsgSmsViewerAppUi::HandleEntryDeletedL
       
  2032 // (other items were commented in a header).
       
  2033 // ---------------------------------------------------------
       
  2034 void CMsgSmsViewerAppUi::HandleEntryDeletedL()
       
  2035     {
       
  2036     Exit( EAknSoftkeyClose );
       
  2037     }
       
  2038 
       
  2039 // ----------------------------------------------------
       
  2040 // CMsgSmsViewerAppUi::LaunchHelpL
       
  2041 // launch help using context
       
  2042 // ----------------------------------------------------
       
  2043 void CMsgSmsViewerAppUi::LaunchHelpL()
       
  2044     {
       
  2045     if ( iFlags.iHelpFeatureSupported )
       
  2046         {
       
  2047         // activate Help application
       
  2048         CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL();
       
  2049         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
  2050         }
       
  2051     }
       
  2052 
       
  2053 
       
  2054 // ----------------------------------------------------
       
  2055 // CMsgSmsViewerAppUi::HelpContextL
       
  2056 // returns help context
       
  2057 // ----------------------------------------------------
       
  2058 CArrayFix<TCoeHelpContext>* CMsgSmsViewerAppUi::HelpContextL() const
       
  2059     {
       
  2060     // Check if not bio message or picture message
       
  2061     if ( !iFlags.iBioMsg && !iFlags.iGms )
       
  2062         {
       
  2063         // sms editor and sms viewer use same help file, in which 
       
  2064         // sms editor id is used
       
  2065         return CreateHelpContextArrayL(
       
  2066             TCoeHelpContext( KUidSmsViewer, KSMS_HLP_VIEWER()));
       
  2067         }
       
  2068     
       
  2069     // Help context of picture message
       
  2070     // GMS xhtml-help is now under smartmessaging
       
  2071     else if ( iFlags.iGms )
       
  2072         {
       
  2073         return CreateHelpContextArrayL(
       
  2074             TCoeHelpContext( KUidGMSViewer, KSMART_HLP_GMSVIEWER()));
       
  2075         }
       
  2076     
       
  2077     // Help context of bio messages
       
  2078     else
       
  2079         {
       
  2080         TCoeHelpContext bioControlHelpContext;
       
  2081         BioBody().BioControl().GetHelpContext( bioControlHelpContext );
       
  2082         if ( !bioControlHelpContext.IsNull())
       
  2083             {
       
  2084             return CreateHelpContextArrayL( bioControlHelpContext );
       
  2085             }
       
  2086         // if help context not available for bio control
       
  2087         else
       
  2088             {
       
  2089             return NULL;
       
  2090             }
       
  2091         }
       
  2092     }
       
  2093 
       
  2094 // ----------------------------------------------------
       
  2095 // CMsgSmsViewerAppUi::CreateHelpContextArrayL
       
  2096 // 
       
  2097 // ----------------------------------------------------
       
  2098 CArrayFix<TCoeHelpContext>* CMsgSmsViewerAppUi::CreateHelpContextArrayL( const TCoeHelpContext& aHelpContext ) const
       
  2099     {
       
  2100     CArrayFix<TCoeHelpContext>* r = new(ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
  2101     CleanupStack::PushL(r);
       
  2102     r->AppendL(aHelpContext);
       
  2103     CleanupStack::Pop(r);
       
  2104     return r;
       
  2105     }
       
  2106 
       
  2107 // ----------------------------------------------------
       
  2108 // CMsgSmsViewerAppUi::DoHandleSendKeyL
       
  2109 // 
       
  2110 // ----------------------------------------------------
       
  2111 void CMsgSmsViewerAppUi::DoHandleSendKeyL()
       
  2112     {
       
  2113     if ( !iMsgVoIPExtension )
       
  2114         {
       
  2115         return;
       
  2116         }
       
  2117     
       
  2118     TPtrC number = KNullDesC();
       
  2119     TPtrC alias = KNullDesC();
       
  2120     TPtrC focusedAddr = KNullDesC();
       
  2121 	TBool dailerDisabled = EFalse;
       
  2122     // sender-number
       
  2123     if ( iFlags.iValidSenderNumber )
       
  2124         {
       
  2125         number.Set( *&iNumber );
       
  2126         if ( iRecipientstring.Length() )
       
  2127             {
       
  2128             alias.Set( *&iRecipientstring );
       
  2129             }
       
  2130          if(IsSenderFocused())
       
  2131          {
       
  2132          	//Disabling the SendKey Event handling by Avkon
       
  2133     		iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort |  CAknAppUiBase::EDisableSendKeyLong );
       
  2134     		dailerDisabled = ETrue;	
       
  2135          }
       
  2136         }
       
  2137 
       
  2138     if ( IsBodyFocused() && iView->ItemFinder( ) )
       
  2139         {
       
  2140         const CItemFinder::CFindItemExt& item =
       
  2141             iView->ItemFinder( )->CurrentItemExt( );
       
  2142         if (    item.iItemDescriptor
       
  2143             &&  (   item.iItemType == CItemFinder::EPhoneNumber
       
  2144                 ||  item.iItemType == CItemFinder::EEmailAddress ) )
       
  2145             {
       
  2146             //Dialer is opened when creating a VoIP call from SMS via Call creation key
       
  2147             //Disabling the SendKey Event handling by Avkon
       
  2148             iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort |  CAknAppUiBase::EDisableSendKeyLong );
       
  2149             dailerDisabled = ETrue;
       
  2150             focusedAddr.Set( *(item.iItemDescriptor) );
       
  2151             }
       
  2152         }
       
  2153 
       
  2154 		if(dailerDisabled)
       
  2155 		{
       
  2156     MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( 
       
  2157             *iMsgVoIPExtension,
       
  2158             number,
       
  2159             alias,
       
  2160             focusedAddr,
       
  2161             ETrue,
       
  2162             iEikonEnv );    
       
  2163      }  
       
  2164     }
       
  2165 
       
  2166 // ----------------------------------------------------
       
  2167 // CMsgSmsViewerAppUi::SetAutomaticHighlightL
       
  2168 // 
       
  2169 // ----------------------------------------------------
       
  2170 void CMsgSmsViewerAppUi::SetAutomaticHighlightL( const TBool aSwitchON )
       
  2171     {
       
  2172     __ASSERT_DEBUG( !iFlags.iGms, Panic( EMsgSmsNotForGms ) );
       
  2173     __ASSERT_DEBUG( !iFlags.iBioMsg, Panic( EMsgSmsNotAllowedForBio ) );
       
  2174     if ( iView->ItemFinder() )
       
  2175         {
       
  2176         // content highlight
       
  2177         if ( aSwitchON )
       
  2178             { // switch ON
       
  2179             iView->ItemFinder()->SetFindModeL( 
       
  2180                 CItemFinder::EPhoneNumber |
       
  2181                 CItemFinder::EUrlAddress |
       
  2182                 CItemFinder::EEmailAddress );
       
  2183             }
       
  2184         else
       
  2185             { // switch OFF
       
  2186             iView->ItemFinder()->SetFindModeL( 
       
  2187                 CItemFinder::ENoneSelected );
       
  2188             }
       
  2189         // header highlight     
       
  2190         if ( iControlId != EMsgComponentIdTo && iFlags.iValidSenderNumber )
       
  2191             {
       
  2192              static_cast<CMsgAddressControl*>
       
  2193                  (iView->ControlById( iControlId ))->SetAddressFieldAutoHighlight( aSwitchON );
       
  2194 
       
  2195             }
       
  2196         }
       
  2197     }
       
  2198 
       
  2199 // ----------------------------------------------------
       
  2200 // CMsgSmsViewerAppUi::ReadAutoHlSharedDataValueL
       
  2201 // 
       
  2202 // ----------------------------------------------------
       
  2203 void CMsgSmsViewerAppUi::ReadAutoHlSharedDataValueAndSetNotifyL()
       
  2204     {
       
  2205     __ASSERT_DEBUG( !iFlags.iGms, Panic( EMsgSmsNotForGms ) );
       
  2206     __ASSERT_DEBUG( !iFlags.iBioMsg, Panic( EMsgSmsNotAllowedForBio ) );
       
  2207     if ( iFlags.iAutomaticHlInitialized )
       
  2208         return;
       
  2209     // Create the session
       
  2210     iCenRepSession = CRepository::NewL( KCRUidCommonUi );
       
  2211     if( iCenRepSession )
       
  2212         {
       
  2213         // Get the value of AutomaticHighlight key
       
  2214         TBool value = ETrue;
       
  2215         iCenRepSession->Get( KCuiAutomaticHighlight, value );
       
  2216         iFlags.iAutomaticHlValue = value;
       
  2217         // Create the notifer
       
  2218         iNotifier = 
       
  2219             CCenRepNotifyHandler::NewL( 
       
  2220                 *this, *iCenRepSession, CCenRepNotifyHandler::EIntKey,
       
  2221                 KCuiAutomaticHighlight );
       
  2222         // Start listening
       
  2223         iNotifier->StartListeningL();       
       
  2224         }
       
  2225     iFlags.iAutomaticHlInitialized = ETrue; // Done once per viewer
       
  2226     }
       
  2227 
       
  2228 // ----------------------------------------------------------------------------
       
  2229 // CMsgSmsViewerAppUi::HandleNotifyInt
       
  2230 // ----------------------------------------------------------------------------    
       
  2231 //
       
  2232 void CMsgSmsViewerAppUi::HandleNotifyInt( 
       
  2233     TUint32  /*aId*/, 
       
  2234     TInt aNewValue )
       
  2235     {   
       
  2236     // Notifies changes on KCuiAutomaticHighlight
       
  2237     iFlags.iAutomaticHlValue = aNewValue;
       
  2238     TRAP_IGNORE( SetAutomaticHighlightL( aNewValue ) ); 
       
  2239     }
       
  2240 
       
  2241 // ----------------------------------------------------------------------------
       
  2242 // CMsgSmsViewerAppUi::HandleNotifyError
       
  2243 // ----------------------------------------------------------------------------    
       
  2244 //
       
  2245 void CMsgSmsViewerAppUi::HandleNotifyError( 
       
  2246     TUint32 /*aId*/, 
       
  2247     TInt /* aError */, 
       
  2248     CCenRepNotifyHandler* /* aHandler */ )
       
  2249     {
       
  2250     // Remove session and notifier
       
  2251     if( iNotifier )
       
  2252         {
       
  2253         iNotifier->StopListening();       
       
  2254         delete iNotifier;
       
  2255         iNotifier = NULL;
       
  2256         }
       
  2257     delete iCenRepSession;    
       
  2258     iCenRepSession = NULL;
       
  2259     }
       
  2260         
       
  2261 // ----------------------------------------------------
       
  2262 // CMsgSmsViewerAppUi::DoReplyViaL
       
  2263 // 
       
  2264 // ----------------------------------------------------
       
  2265 void CMsgSmsViewerAppUi::DoReplyViaL( TInt aCase )
       
  2266     {
       
  2267     __ASSERT_DEBUG( iControlId != 
       
  2268         EMsgComponentIdTo, Panic( EMsgSmsNoSuchComponent ) );
       
  2269 
       
  2270     CMessageData* msgData = CMessageData::NewL();
       
  2271     CleanupStack::PushL( msgData );    
       
  2272     CMsgAddressControl* addressControl = 
       
  2273         static_cast<CMsgAddressControl*> ( iView->ControlById( iControlId ) );
       
  2274     if ( addressControl )
       
  2275         {
       
  2276         CMsgRecipientArray& recs = *addressControl->GetRecipientsL();
       
  2277         TInt count(recs.Count());
       
  2278         for (TInt index = 0; index < count; index++)
       
  2279             {
       
  2280             if ( iFlags.iIsEmailMessage )
       
  2281                 {
       
  2282                 msgData->AppendToAddressL( 
       
  2283 	                *recs.At( index )->Name(),
       
  2284 	                KNullDesC() );
       
  2285                 //sender->AppendL( *recs.At( index )->Name() );
       
  2286                 //alias->AppendL( KNullDesC() );
       
  2287                 }
       
  2288             else
       
  2289                 {
       
  2290                 msgData->AppendToAddressL( 
       
  2291 	                *recs.At( index )->Address(),
       
  2292 	                *recs.At( index )->Name() );
       
  2293                 }
       
  2294             }
       
  2295         }
       
  2296 	// Via MMS, Email, Audio or to Unieditor
       
  2297     TUid mtmUid;
       
  2298     switch( aCase )
       
  2299 		{
       
  2300 		case ESmsViewerReplyViaMms:
       
  2301 			mtmUid = KSenduiMtmMmsUid;
       
  2302             break;
       
  2303         case ESmsViewerReplyViaEmail:
       
  2304 			mtmUid = KSenduiMtmSmtpUid;
       
  2305             break;	
       
  2306 		case ESmsViewerReplyViaAudio:
       
  2307 			mtmUid = KSenduiMtmAudioMessageUid;
       
  2308             break;
       
  2309         case ESmsViewerReplyViaMessage:	//unieditor
       
  2310 			mtmUid = KSenduiMtmUniMessageUid;
       
  2311             break;            
       
  2312         default:
       
  2313             __ASSERT_DEBUG( EFalse, Panic( EMsgSmsNoSuchMtmUid ) );
       
  2314             mtmUid = KSenduiMtmUniMessageUid; // suppress compiler warning
       
  2315             break;
       
  2316 		}    
       
  2317     
       
  2318     
       
  2319     if ( iFlags.iEmailSubjectControlPresent )
       
  2320         {
       
  2321         if ( SubjectControl()->TextContent().DocumentLength() )
       
  2322             {
       
  2323             HBufC* buf = SubjectControl()->Editor().GetTextInHBufL();
       
  2324             CleanupStack::PushL( buf );
       
  2325             TInt length = buf->Length();
       
  2326             HBufC* replyFormat = StringLoader::LoadLC( R_QTN_SMS_REPLYFORMAT, iCoeEnv );
       
  2327 
       
  2328             _LIT( KSmsSubjectFormat, "%S" );
       
  2329             TInt formatPos = replyFormat->Find( KSmsSubjectFormat );
       
  2330 	    	TInt foundInSubj = KErrNotFound;
       
  2331 		    if ( formatPos > 0 )
       
  2332                 {
       
  2333                 // -1 to avoid % in the string
       
  2334 			    foundInSubj = buf->FindF( replyFormat->Left( formatPos-1 ) );
       
  2335                 }
       
  2336             HBufC* newSubject = NULL;
       
  2337 		    //append only when it is not in the beginning of the subject line or not found.
       
  2338 		    if ( foundInSubj==KErrNotFound || foundInSubj )
       
  2339 			    {
       
  2340 			    // Create a buffer large enough to hold the re-formated subject - need
       
  2341 		        // to subtract two from the prefix length (the %S).
       
  2342 		        length += replyFormat->Length() - 2;
       
  2343 		        newSubject = HBufC::NewLC(length);
       
  2344 		        TPtr ptr( newSubject->Des() );
       
  2345 		        // Format the reply subject
       
  2346 		        ptr.Format( replyFormat->Des(), buf );
       
  2347 			    }
       
  2348             else
       
  2349                 {
       
  2350                 newSubject = buf->Des().AllocLC();
       
  2351                 }
       
  2352             msgData->SetSubjectL( newSubject );
       
  2353             //CleanupStack::Pop( ); // newSubject
       
  2354             CleanupStack::PopAndDestroy( 3 ); // buf, replyFormat, newSubject
       
  2355             //CleanupStack::PushL( newSubject );
       
  2356             }
       
  2357         }        
       
  2358     iSendUi->CreateAndSendMessageL( mtmUid, msgData );
       
  2359     CleanupStack::PopAndDestroy( msgData ); // msgData
       
  2360     }
       
  2361     
       
  2362 // ----------------------------------------------------
       
  2363 //  CMsgSmsViewerAppUi::AddSubjectControlL()
       
  2364 //
       
  2365 // ----------------------------------------------------
       
  2366 void CMsgSmsViewerAppUi::AddSubjectControlL()
       
  2367     {
       
  2368     // Sanity
       
  2369     __ASSERT_DEBUG( iView, Panic( EMsgSmsNullPointer ) );
       
  2370     if ( !iFlags.iEmailSubjectControlPresent )
       
  2371         {
       
  2372         iView->AddControlFromResourceL( R_SMS_VIEWER_SUBJECT,
       
  2373                 EMsgExpandableControl, EMsgAppendControl, EMsgHeader );
       
  2374         // Mark the control creation
       
  2375         iFlags.iEmailSubjectControlPresent = ETrue;
       
  2376         }
       
  2377     }
       
  2378     
       
  2379 // ----------------------------------------------------
       
  2380 //  CMsgSmsViewerAppUi::SetSubjectL()
       
  2381 //  
       
  2382 // ----------------------------------------------------
       
  2383 void CMsgSmsViewerAppUi::SetSubjectL(const TDesC& aText)
       
  2384     {
       
  2385     CMsgExpandableControl* subjectControl = SubjectControl();
       
  2386     if (subjectControl)
       
  2387         {
       
  2388         CRichText& subject = subjectControl->TextContent();
       
  2389         subject.Reset();
       
  2390         subject.InsertL( 0, aText );
       
  2391         }
       
  2392     }
       
  2393 
       
  2394 // ----------------------------------------------------
       
  2395 //  CMsgSmsViewerAppUi::SubjectControl()
       
  2396 //  
       
  2397 // ----------------------------------------------------
       
  2398 CMsgExpandableControl* CMsgSmsViewerAppUi::SubjectControl() const
       
  2399     {
       
  2400     __ASSERT_DEBUG( iFlags.iEmailSubjectControlPresent, Panic( EMsgSmsNullPointer ));
       
  2401     return STATIC_CAST(CMsgExpandableControl*, 
       
  2402             iView->ControlById(EMsgComponentIdSubject));
       
  2403     }
       
  2404 
       
  2405 // ----------------------------------------------------
       
  2406 //  CMsgSmsViewerAppUi::InitAiwContactCardMenuL
       
  2407 //  
       
  2408 // ----------------------------------------------------
       
  2409 void CMsgSmsViewerAppUi::InitAiwContactCardMenuL( TInt aMenuId,
       
  2410     CEikMenuPane* aMenuPane )
       
  2411     {
       
  2412     if ( !iAiwServiceHandler)
       
  2413         {
       
  2414         // Create AIW service handler and attach to contact card menu item
       
  2415         iAiwServiceHandler = CAiwServiceHandler::NewL();
       
  2416         iAiwServiceHandler->AttachMenuL( aMenuId,
       
  2417             R_SMSV_AIW_CONTACT_INTEREST );
       
  2418         }
       
  2419 
       
  2420     // This menu should contain AIW menu placeholder
       
  2421     __ASSERT_DEBUG( iAiwServiceHandler->IsAiwMenu( aMenuId ),
       
  2422         Panic( EMsgSmsAiwMenu ) );
       
  2423 
       
  2424     CAiwGenericParamList& inList = iAiwServiceHandler->InParamListL();
       
  2425     InitAiwContactCardParamL( inList );
       
  2426     iAiwServiceHandler->InitializeMenuPaneL( *aMenuPane, aMenuId,
       
  2427         ESmsViewerCreateCCNew, inList );
       
  2428     }
       
  2429 
       
  2430 // ----------------------------------------------------
       
  2431 //  CMsgSmsViewerAppUi::InitAiwContactCardSubMenuL
       
  2432 //  
       
  2433 // ----------------------------------------------------
       
  2434 void CMsgSmsViewerAppUi::InitAiwContactCardSubMenuL( CEikMenuPane* aMenuPane )
       
  2435     {
       
  2436     // If menu is AIW sub-menu, AIW will initialize it
       
  2437     if ( iAiwServiceHandler &&
       
  2438          iAiwServiceHandler->HandleSubmenuL( *aMenuPane ) )
       
  2439         {
       
  2440         // We assume AIW inserts at most 2 items into the submenu.
       
  2441         // ESmsViewerCreateCCNew and ESmsViewerCreateCCExisting.
       
  2442         // Otherwise command codes will overlap
       
  2443 #ifdef _DEBUG
       
  2444         const TInt KMaxItems = 2;
       
  2445         __ASSERT_ALWAYS( aMenuPane->NumberOfItemsInPane() <=
       
  2446             KMaxItems, Panic( EMsgSmsAiwMenu ) );
       
  2447 #endif
       
  2448         }
       
  2449     }
       
  2450 
       
  2451 // ----------------------------------------------------
       
  2452 //  CMsgSmsViewerAppUi::InitAiwContactCardParamL()
       
  2453 //  
       
  2454 // ----------------------------------------------------
       
  2455 void CMsgSmsViewerAppUi::InitAiwContactCardParamL(
       
  2456     CAiwGenericParamList& aParamList ) const
       
  2457     {
       
  2458     using namespace AiwContactAssign;
       
  2459 
       
  2460     TAiwGenericParam param( EGenericParamContactAssignData );
       
  2461     TAiwSingleContactAssignDataV1 assignData;
       
  2462     assignData.SetFlags( 0 );
       
  2463     param.Value().Set( TAiwSingleContactAssignDataV1Pckg( assignData ) );
       
  2464     aParamList.AppendL( param );
       
  2465 
       
  2466     // Phone number
       
  2467     param.Reset();
       
  2468     param.SetSemanticId( EGenericParamPhoneNumber );
       
  2469     param.Value().Set( iNumber );
       
  2470     aParamList.AppendL( param );
       
  2471     }
       
  2472 
       
  2473 #ifdef RD_SCALABLE_UI_V2
       
  2474 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2475 
       
  2476 // -----------------------------------------------------------------------------
       
  2477 // handles the touch-ui related control events for next/previous message
       
  2478 // -----------------------------------------------------------------------------
       
  2479 //
       
  2480 void CMsgSmsViewerAppUi::HandleNaviDecoratorEventL( TInt aEventID )     
       
  2481     {
       
  2482     if( AknLayoutUtils::PenEnabled() &&
       
  2483         IsNextMessageAvailableL( aEventID == EAknNaviDecoratorEventRightTabArrow ) )
       
  2484         {
       
  2485         /* no need for separate checks for right and left arrows
       
  2486             because IsNextMessageAvailableL() and NextMessageL
       
  2487             are called with the truth-value of the same comparison */
       
  2488         NextMessageL( aEventID == EAknNaviDecoratorEventRightTabArrow );
       
  2489         }
       
  2490     }
       
  2491 #else
       
  2492 void CMsgSmsViewerAppUi::HandleNaviDecoratorEventL( TInt /* aEventID */)
       
  2493     {
       
  2494     }       
       
  2495 #endif // !RD_MSG_NAVIPANE_IMPROVEMENT
       
  2496 #else
       
  2497 void CMsgSmsViewerAppUi::HandleNaviDecoratorEventL( TInt /* aEventID */)
       
  2498     {
       
  2499     }
       
  2500 #endif
       
  2501 
       
  2502 #ifdef RD_MSG_FAST_PREV_NEXT
       
  2503 // ----------------------------------------------------
       
  2504 //  CMsgSmsViewerAppUi::CanFastOpenL
       
  2505 // ----------------------------------------------------
       
  2506 TBool CMsgSmsViewerAppUi::CanFastOpenL( const CMessageIterator& aIterator )
       
  2507     {
       
  2508     // Only sms messages can be fast opened. Bio message open is performed
       
  2509     // using bio mtm-server which parses the message before viewer is opened.
       
  2510     // Picture and configuration bio-messages seem to work without parsing by
       
  2511     // bio mtm-server. Vcards however do not work as there is no vcard attachment
       
  2512     // expected by the viewer unless message is parsed by the server first.
       
  2513     // Also, allow fast open only if currently sms is open. This ensures that
       
  2514     // the viewer is entered through sms mtm ui and before sms messages are viewed
       
  2515     // (CSmsMtmUi::CheckAndEnsureSmsServiceOkL() is executed).
       
  2516     TBool retVal = EFalse;
       
  2517     TMsvEntry msvEntry = Document()->Entry();
       
  2518     if( msvEntry.iMtm.iUid == KSenduiMtmSmsUidValue &&
       
  2519         aIterator.CurrentMessage().iMtm.iUid == KSenduiMtmSmsUidValue &&
       
  2520         !msvEntry.iBioType )
       
  2521         {
       
  2522         retVal = ETrue;
       
  2523         }
       
  2524     return retVal;
       
  2525     }
       
  2526 #endif
       
  2527 
       
  2528 // ---------------------------------------------------------
       
  2529 // OfferToolbarEventL
       
  2530 // ---------------------------------------------------------
       
  2531 //
       
  2532 #ifdef RD_SCALABLE_UI_V2
       
  2533 void CMsgSmsViewerAppUi::OfferToolbarEventL( TInt aCommand )
       
  2534     {
       
  2535     switch ( aCommand )
       
  2536         {
       
  2537         case ESmsViewerToolbarReply:
       
  2538                 HandleCommandL( ESmsViewerReplyViaMessage );
       
  2539             break;
       
  2540         case ESmsViewerToolbarForward:
       
  2541             HandleCommandL( ESmsViewerForward );
       
  2542             break;
       
  2543         case ESmsViewerToolbarDelete:
       
  2544             HandleCommandL( ESmsViewerDelete );
       
  2545             break;
       
  2546         }
       
  2547     }
       
  2548 
       
  2549 #endif
       
  2550 
       
  2551 // ---------------------------------------------------------
       
  2552 // CAudioMessageAppUi::HandleResourceChangeL
       
  2553 // ---------------------------------------------------------
       
  2554 //
       
  2555 
       
  2556 void CMsgSmsViewerAppUi::HandleResourceChangeL( TInt aType )
       
  2557     {
       
  2558      // Base class call must be first
       
  2559     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  2560     
       
  2561     if ( aType == KAknsMessageSkinChange )
       
  2562         {
       
  2563         if ( iAppIcon )
       
  2564             {
       
  2565             delete iAppIcon;
       
  2566             iAppIcon = NULL;
       
  2567             }
       
  2568     
       
  2569         // Set path of bitmap file
       
  2570   	    TParse fileParse;
       
  2571   	    fileParse.Set( KSmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
       
  2572     
       
  2573         iAppIcon = AknsUtils::CreateGulIconL( 
       
  2574             AknsUtils::SkinInstance(), 
       
  2575             KAknsIIDQgnPropMceSmsTitle,
       
  2576             fileParse.FullName(),
       
  2577             EMbmMuiuQgn_prop_mce_sms_title,
       
  2578             EMbmMuiuQgn_prop_mce_sms_title_mask );
       
  2579         SetTitleIconL();   
       
  2580         }
       
  2581      
       
  2582     }
       
  2583 
       
  2584 
       
  2585 // ---------------------------------------------------------
       
  2586 // CAudioMessageAppUi::SetTitleIconL
       
  2587 // ---------------------------------------------------------
       
  2588 //
       
  2589 void CMsgSmsViewerAppUi::SetTitleIconL()
       
  2590     {
       
  2591     SetTitleIconSize();
       
  2592     
       
  2593     // Create duplicates of the icon to be used
       
  2594     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  2595     CleanupStack::PushL( bitmap );
       
  2596     //SetTitleIconSizeL(bitmap);
       
  2597     
       
  2598     
       
  2599     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  2600     CleanupStack::PushL( bitmapMask );
       
  2601     
       
  2602     User::LeaveIfError( bitmap->Duplicate( iAppIcon->Bitmap()->Handle() ) );
       
  2603     User::LeaveIfError( bitmapMask->Duplicate( iAppIcon->Mask()->Handle() ) );
       
  2604     
       
  2605     CAknTitlePane* iTitlePane = STATIC_CAST( 
       
  2606             CAknTitlePane*, 
       
  2607             StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
  2608 
       
  2609     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  2610     iTitlePane->DrawNow();
       
  2611     
       
  2612     CleanupStack::Pop( bitmapMask );
       
  2613     CleanupStack::Pop( bitmap );
       
  2614     }
       
  2615 
       
  2616 
       
  2617 // ---------------------------------------------------------
       
  2618 // CAudioMessageAppUi::SetTitleIconSize
       
  2619 //
       
  2620 // Sets the correct size from LAF for title icon
       
  2621 // ---------------------------------------------------------
       
  2622 //
       
  2623 void CMsgSmsViewerAppUi::SetTitleIconSize()
       
  2624     {
       
  2625     TRect mainPane;
       
  2626     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, mainPane );
       
  2627     TAknLayoutRect titleIconPaneLayoutRect;
       
  2628     
       
  2629     if ( AknStatuspaneUtils::StaconPaneActive() )
       
  2630         {
       
  2631         titleIconPaneLayoutRect.LayoutRect( 
       
  2632             mainPane,
       
  2633             AknLayoutScalable_Avkon::title_pane_stacon_g1( 0 ).LayoutLine() );
       
  2634         }
       
  2635     else
       
  2636         {
       
  2637         titleIconPaneLayoutRect.LayoutRect( 
       
  2638             mainPane,
       
  2639             AknLayoutScalable_Avkon::title_pane_g2( 0 ).LayoutLine() );
       
  2640         }
       
  2641     
       
  2642     TSize iconSize = titleIconPaneLayoutRect.Rect().Size();
       
  2643     AknIconUtils::SetSize( iAppIcon->Bitmap(), iconSize, EAspectRatioPreserved );
       
  2644     }    
       
  2645     
       
  2646 // ---------------------------------------------------------
       
  2647 // CMsgSmsViewerAppUi::EditorObserver
       
  2648 // ---------------------------------------------------------
       
  2649 //
       
  2650 void CMsgSmsViewerAppUi::EditorObserver( TMsgEditorObserverFunc aFunc, TAny* aArg1,
       
  2651   TAny* aArg2, TAny* aArg3 )
       
  2652     {
       
  2653     TRAP_IGNORE( DoEditorObserverL( aFunc,aArg1,aArg2,aArg3 ) );
       
  2654     }
       
  2655 
       
  2656 // ---------------------------------------------------------
       
  2657 // CMsgSmsViewerAppUi::DoEditorObserverL
       
  2658 // ---------------------------------------------------------
       
  2659 //
       
  2660 void CMsgSmsViewerAppUi::DoEditorObserverL( TMsgEditorObserverFunc aFunc, TAny* aArg1,
       
  2661   TAny* aArg2, TAny*/* aArg3*/ )
       
  2662     {
       
  2663     
       
  2664         switch ( aFunc )
       
  2665         {
       
  2666          	    
       
  2667 #ifdef RD_SCALABLE_UI_V2	    
       
  2668 	    case MMsgEditorObserver::EMsgControlPointerEvent:
       
  2669             {
       
  2670            	CMsgBaseControl* control = static_cast<CMsgBaseControl*>( aArg1 );
       
  2671             if(control)
       
  2672 	          	{
       
  2673 	            	TInt id = control->ControlId();	            
       
  2674 								if(id == EMsgComponentIdFrom && iFlags.iValidSenderNumber)
       
  2675 									{     
       
  2676 									//disable dialer
       
  2677 									iAvkonAppUi->SetKeyEventFlags( 
       
  2678 				    					CAknAppUiBase::EDisableSendKeyShort | 
       
  2679 				    					CAknAppUiBase::EDisableSendKeyLong ); 								
       
  2680 									}
       
  2681 								else            
       
  2682 									{
       
  2683 	                	//enable dialer
       
  2684 									iAvkonAppUi->SetKeyEventFlags( 0x00);
       
  2685 									}
       
  2686 	            	}
       
  2687             }
       
  2688  		break;
       
  2689         
       
  2690 #endif //RD_SCALABLE_UI_V2  
       
  2691 			default:
       
  2692 				break;         
       
  2693         }
       
  2694  
       
  2695     }  
       
  2696 
       
  2697 
       
  2698 // ---------------------------------------------------------
       
  2699 // CMsgSmsViewerAppUi::QuicklaunchViewL
       
  2700 // This is quick launch based on already existing view. Hence this function should  
       
  2701 // be called only for Proper SMS Text message for fast and optimized navigation.
       
  2702 // In case called for any bio-type messages, this will leave with KErrCancel so that 
       
  2703 // caller will TRAP the leave and call LaunchViewL() for complete launch.
       
  2704 // ---------------------------------------------------------
       
  2705 void CMsgSmsViewerAppUi::QuicklaunchViewL()
       
  2706     {
       
  2707     CAknInputBlock::NewLC();
       
  2708     
       
  2709     /* Reset iFullyConstructed to false to avoid any irrational behaviours during quick launch
       
  2710      * And set back to true at the end of this function
       
  2711      */
       
  2712     iFullyConstructed = EFalse;
       
  2713 
       
  2714     // get hands on entry
       
  2715     const CMsgSmsViewerDocument* doc = Document();
       
  2716     TMsvEntry msvEntry = doc->Entry();
       
  2717     if ( msvEntry.iBioType )
       
  2718         {
       
  2719         /* If in case, any bio SMS while fast navigation, then leave immediately, so that MCE will 
       
  2720          * handle the navigation.
       
  2721          * Leave with correct code, so that MsgEditorAppUi will perform the appropriate action to 
       
  2722          * ensure the next/prev entry is launched from MCE.
       
  2723          */
       
  2724         User::Leave( KErrCancel );
       
  2725         }
       
  2726     
       
  2727     /* Reset all the necessary flags before proceeding further
       
  2728      * Other flags are either feature support types or based on bio-SMS types and hence 
       
  2729      * no need to set/reset here
       
  2730      */
       
  2731     iFlags.iIsEmailMessage = EFalse;
       
  2732     iFlags.iValidSenderNumber = EFalse;
       
  2733     iFlags.iVoIPNumber = EFalse;
       
  2734     SetAutomaticHighlightL( EFalse );
       
  2735     
       
  2736     // Getting sender/receiver to From/To-field
       
  2737     // (just copies the content of iDetails to To/From-field,
       
  2738     // should work also with IR-messages...)
       
  2739 
       
  2740     //Copy only 50 chars with extremely long names
       
  2741     iRecipientstring = msvEntry.iDetails.Left( KPhCltNameBufferLength );  
       
  2742 
       
  2743     __ASSERT_DEBUG(msvEntry.Id() != 
       
  2744          KMsvNullIndexEntryId, Panic( EMsgSmsNoMessage ));
       
  2745 
       
  2746     // Instead of using Sms Mtm, load the entry's values
       
  2747     // using store. This is because Sms Viewer is also used
       
  2748     // by bio messages and then sms mtm can't be used...
       
  2749     CPlainText* nullString = CPlainText::NewL();
       
  2750     CleanupStack::PushL( nullString );
       
  2751     delete iSmsHeader;
       
  2752     iSmsHeader = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *nullString );
       
  2753     CMsvStore* store = doc->CurrentEntry().ReadStoreL();
       
  2754     CleanupStack::PushL(store);
       
  2755 
       
  2756     // This TRAPping is needed to find out if the entry's store has
       
  2757     // KUidMsvSMSHeaderStream. If it hasn't, we're most propably dealing
       
  2758     // with non sms message and we can assume it is received message.
       
  2759     TRAPD( err, iSmsHeader->RestoreL( *store ));
       
  2760 
       
  2761     // Check if we are dealing with E-mail sms message
       
  2762     // We use TP-PID as the only validation rule
       
  2763     CSmsPDU& pdu = iSmsHeader->Message().SmsPDU();
       
  2764     if( pdu.ProtocolIdentifierPresent() )
       
  2765         {
       
  2766         if( pdu.PIDType() == TSmsProtocolIdentifier::ESmsPIDTelematicInterworking &&
       
  2767             pdu.TelematicDeviceIndicator() == TSmsProtocolIdentifier::ESmsTelematicDevice &&
       
  2768             pdu.TelematicDeviceType() == TSmsProtocolIdentifier::ESmsInternetElectronicMail )
       
  2769             {
       
  2770             iFlags.iIsEmailMessage = ETrue;
       
  2771             }
       
  2772         }
       
  2773 
       
  2774     if (err == KErrNone)
       
  2775         {
       
  2776         /* Yes, it is sms based message.
       
  2777          * Quick SMS msg handler shall set the body text and required control field without adding/removing
       
  2778          *  any controls everytime unless required(if absent/present across different messages).
       
  2779          */
       
  2780         QuickSmsMsgNaviHandlingL( store );
       
  2781         }
       
  2782     else
       
  2783         {
       
  2784         /* Something wrong. Ideally this part of the code should not be hit. 
       
  2785          * This is not a sms and sms pdu can't be checked. 
       
  2786          * However this is most propably _received_ IR or BT message.
       
  2787          */
       
  2788         iFlags.iIrBt = ETrue;
       
  2789         iControlId = EMsgComponentIdFrom;
       
  2790         }
       
  2791     CleanupStack::PopAndDestroy( 2 ); //store, nullString
       
  2792 
       
  2793     // Fill address ctrl
       
  2794     if ( !iFlags.iIsEmailMessage && KErrNotFound != iNumber.Match( iRecipientstring ) )
       
  2795         {
       
  2796         iRecipientstring = KNullDesC;
       
  2797         }
       
  2798 
       
  2799     CMsgBaseControl* addressBase = iView->ControlById( iControlId );
       
  2800     CMsgAddressControl* addressControl = STATIC_CAST( CMsgAddressControl*, addressBase );
       
  2801 
       
  2802     MVPbkContactLink* link= NULL;
       
  2803     addressControl->Reset();
       
  2804     addressControl->AddRecipientL( 
       
  2805         iRecipientstring,
       
  2806         iNumber,
       
  2807         ETrue,
       
  2808         link );
       
  2809 
       
  2810     // Message indication ( e.g. 2/32 )
       
  2811 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2812     // Fetch pointer to the default navi pane control
       
  2813     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
  2814         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  2815      
       
  2816     if( !iNaviDecorator )
       
  2817         {
       
  2818         CreateViewerNaviPaneL( Document()->Entry().iDate, EMsgEditorMsgPriorityNormal, ETrue );    
       
  2819         iNaviPane->PushL( *iNaviDecorator );  // <- This has nothing to do with cleanup-stack!    
       
  2820         }
       
  2821     else
       
  2822         {
       
  2823         //We end up here when fast msg opening is enabled
       
  2824         CMsgNaviPaneControl* naviControl = static_cast<CMsgNaviPaneControl*>
       
  2825             ( iNaviDecorator->DecoratedControl() );
       
  2826         naviControl->SetTimeIndicatorL( Document()->Entry().iDate, ETrue );
       
  2827         naviControl->SetNavigationIndicatorL( Document()->Session(), Document()->Entry() );
       
  2828         }
       
  2829 
       
  2830 #else
       
  2831     UpdateNaviPaneL();
       
  2832 #endif
       
  2833     //remove buttons from navipane
       
  2834     if( iNaviDecorator && iClass0CBA )
       
  2835         {
       
  2836         iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, ETrue );
       
  2837         iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, ETrue );
       
  2838         }
       
  2839 
       
  2840 #ifdef RD_SCALABLE_UI_V2
       
  2841     if ( AknLayoutUtils::PenEnabled() )
       
  2842         {
       
  2843         if ( iToolbar )
       
  2844             {
       
  2845             //What buttons to dim
       
  2846             switch ( iSmsHeader->Type() )
       
  2847                 {                    
       
  2848                 //Received Message(Inbox navigation)
       
  2849                 case CSmsPDU::ESmsDeliver:
       
  2850                     {
       
  2851                     //Dim reply item if sender is unknown
       
  2852                     if (msvEntry.iDetails.Length() == 0 || !iFlags.iValidSenderNumber )
       
  2853                         {
       
  2854                         iToolbar->SetItemDimmed(ESmsViewerToolbarReply, ETrue, ETrue);
       
  2855                         }
       
  2856                     else
       
  2857                         {
       
  2858                         iToolbar->SetItemDimmed(ESmsViewerToolbarReply, EFalse, ETrue);
       
  2859                         }
       
  2860                     
       
  2861                     break;
       
  2862                     }
       
  2863                 
       
  2864                 //Sent Message (Sent folder navigation)
       
  2865                 case CSmsPDU::ESmsSubmit:
       
  2866                     {
       
  2867                     //Dim the reply button, we would be replying to ourselves
       
  2868                     iToolbar->SetItemDimmed(ESmsViewerToolbarReply, ETrue, ETrue);
       
  2869                     break;
       
  2870                     }
       
  2871 
       
  2872                 default:
       
  2873                     {
       
  2874                     Panic( EMsgSmsViewerUnknownSmsPduType );
       
  2875                     break;
       
  2876                     }
       
  2877                 }   // Switch
       
  2878             }   // if ( iToolbar )
       
  2879         }     // if ( AknLayoutUtils::PenEnabled() )
       
  2880 #endif /* RD_SCALABLE_UI_V2 */
       
  2881     //Reset the focus to "from address" feild
       
  2882     iView->SetFocus( iControlId );
       
  2883     
       
  2884     // Set the state of automatic highlighting for sms
       
  2885     SetAutomaticHighlightL( iFlags.iAutomaticHlValue );
       
  2886     
       
  2887     iFullyConstructed = ETrue;
       
  2888     CleanupStack::PopAndDestroy();// CAknInputBlock
       
  2889     }
       
  2890 
       
  2891 // ---------------------------------------------------------
       
  2892 // CMsgSmsViewerAppUi::QuickSmsMsgNaviHandlingL
       
  2893 // This will set the body text and update the control fields if any changes
       
  2894 // as compared to previous SMS message. 
       
  2895 // This function is called only for non-bio text messages for fast preview during navigation
       
  2896 // ---------------------------------------------------------
       
  2897 void CMsgSmsViewerAppUi::QuickSmsMsgNaviHandlingL( CMsvStore* aStore )
       
  2898     {
       
  2899     // Initialize the richtext object...
       
  2900     CParaFormatLayer* paraFormat = iEikonEnv->SystemParaFormatLayerL(); // <- pointer only
       
  2901     CCharFormatLayer* charFormat = iEikonEnv->SystemCharFormatLayerL(); // <- pointer only
       
  2902     CRichText* textBody = CRichText::NewL( paraFormat, charFormat );
       
  2903     CleanupStack::PushL( textBody );
       
  2904     // ...and read bodytext
       
  2905     aStore->RestoreBodyTextL( *textBody );
       
  2906     
       
  2907     // message is ordinary sms message
       
  2908     // so, let's get message body to viewer. 
       
  2909     CMsgBaseControl* baseControl = iView->ControlById( EMsgComponentIdBody );
       
  2910     CMsgBodyControl* bodyControl = STATIC_CAST( CMsgBodyControl*, baseControl );
       
  2911     
       
  2912     CMsgTextUtils::ConvertLineBreaksL( *textBody, CMsgTextUtils::ECRLFtoLF );
       
  2913 	//First resetting the body control content
       
  2914     bodyControl->Reset();
       
  2915     // Set body text and update the screen
       
  2916     bodyControl->SetTextContentL( *textBody );
       
  2917     bodyControl->SetPlainTextMode( ETrue );
       
  2918     bodyControl->SetCursorPosL( 0 );
       
  2919     bodyControl->DrawNow();
       
  2920     CleanupStack::PopAndDestroy(); //textBody
       
  2921     
       
  2922     // Class 0 handling...
       
  2923     TSmsDataCodingScheme::TSmsClass smsClass;
       
  2924     if ( iSmsHeader->Message().SmsPDU().Class( smsClass ) 
       
  2925         && smsClass == TSmsDataCodingScheme::ESmsClass0 )
       
  2926         {
       
  2927         // Create new softkeys
       
  2928         iClass0CBA = Cba(); // <- pointer only
       
  2929         if (iClass0CBA) 
       
  2930             { // iClass0CBA shouldn't be NULL, but if....
       
  2931             iClass0CBA->SetCommandSetL( R_SMSVIEWER_CLASS0_SOFTKEYS_OPTIONS_EXIT__CONTEXTOPTIONS );  
       
  2932             //Middle softkey
       
  2933             MenuBar()->SetContextMenuTitleResourceId( R_SMSV_OPTIONSCONTEXTMENUBAR_CLASS0 );           
       
  2934             MenuBar()->SetMenuTitleResourceId( R_SMSV_OPTIONSMENUBAR_CLASS0 );        
       
  2935             MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);     
       
  2936             }
       
  2937         }
       
  2938     else if ( iClass0CBA ) 
       
  2939         {
       
  2940         //menubar and CBA is reset to the default resource. 
       
  2941         //if iClass0CBA is not NULL, then resource id has been changed, hence needs to be reset 
       
  2942         //setting the CBA to default
       
  2943         iClass0CBA->SetCommandSetL( R_SMSVIEWER_SOFTKEYS_OPTIONS_BACK__CONTEXTOPTIONS );
       
  2944         //Since CBA is set to default iClass0CBA is set NULL
       
  2945         iClass0CBA = NULL; 
       
  2946         //Setting the menubar to default
       
  2947         MenuBar()->SetContextMenuTitleResourceId( R_SMSV_CONTEXTMENUBAR  );           
       
  2948         MenuBar()->SetMenuTitleResourceId( R_SMSV_OPTIONSMENUBAR );        
       
  2949         MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  2950         }
       
  2951     
       
  2952     // Deciding between To/From text in address control
       
  2953     const CSmsPDU::TSmsPDUType pduType = iSmsHeader->Type();
       
  2954     switch ( pduType )
       
  2955         {
       
  2956         case CSmsPDU::ESmsDeliver:
       
  2957             {
       
  2958             // Setting from-control
       
  2959             iControlId = EMsgComponentIdFrom;
       
  2960             if(pduType!= iTypeMsg)
       
  2961                 {
       
  2962                 	iView->DeleteControlL(EMsgComponentIdTo);
       
  2963                 	iView->AddControlFromResourceL( 
       
  2964                 	R_SMSV_FROM, 
       
  2965                 	EMsgAddressControl, 
       
  2966                 	EMsgAppendControl, 
       
  2967                 	EMsgHeader );
       
  2968                 }            
       
  2969             // take the number and verify it
       
  2970             iNumber = iSmsHeader->FromAddress();
       
  2971             if ( !iFlags.iIsEmailMessage )
       
  2972                 {
       
  2973                 iFlags.iValidSenderNumber = CommonPhoneParser::IsValidPhoneNumber(
       
  2974                     iNumber, CommonPhoneParser::ESMSNumber );
       
  2975 
       
  2976                 if( !iFlags.iValidSenderNumber && iMsgVoIPExtension->IsVoIPSupported() )
       
  2977                     {
       
  2978                     if( MsvUiServiceUtilities::IsValidEmailAddressL( iNumber ) )
       
  2979                         {
       
  2980                         iFlags.iValidSenderNumber = ETrue;
       
  2981                         iFlags.iVoIPNumber = ETrue;
       
  2982                         }
       
  2983                     }
       
  2984                 
       
  2985                 // Replypath indication
       
  2986                 CMsgExpandableControl* replyPathControl = STATIC_CAST(CMsgExpandableControl*,
       
  2987                         iView->ControlById(EMsgComponentIdCc));
       
  2988                 if ( iSmsHeader->Deliver().ReplyPath() )
       
  2989                     {
       
  2990                     if( !replyPathControl )
       
  2991                         {
       
  2992                         iView->AddControlFromResourceL( 
       
  2993                             R_SMSV_REPLYPATH, 
       
  2994                             EMsgExpandableControl, 
       
  2995                             EMsgAppendControl, 
       
  2996                             EMsgHeader );
       
  2997                         }
       
  2998                 
       
  2999                     HBufC* text = StringLoader::LoadLC( R_QTN_SMS_HEADING_REPLY_PATH, iCoeEnv );
       
  3000                     CRichText& replyPath = STATIC_CAST(CMsgExpandableControl*, 
       
  3001                         iView->ControlById(EMsgComponentIdCc))->TextContent();
       
  3002                     replyPath.Reset();
       
  3003                     replyPath.InsertL( 0, *text ); 
       
  3004                     CleanupStack::PopAndDestroy(); // text
       
  3005                     }
       
  3006                 else if( replyPathControl )
       
  3007                     {
       
  3008                     // No reply path in curr SMS, if there was one in prev, remove the control
       
  3009                     iView->DeleteControlL( EMsgComponentIdCc );
       
  3010                     }
       
  3011                 }
       
  3012             else
       
  3013                 {
       
  3014                 iFlags.iValidSenderNumber =
       
  3015                     MsvUiServiceUtilities::IsValidEmailAddressL(
       
  3016                         iRecipientstring );
       
  3017                 }
       
  3018             }
       
  3019             break;
       
  3020         case CSmsPDU::ESmsSubmit:
       
  3021             // Setting To-control
       
  3022             iControlId = EMsgComponentIdTo;
       
  3023             if(pduType!= iTypeMsg)
       
  3024               {
       
  3025                 iView->DeleteControlL(EMsgComponentIdFrom);
       
  3026                 iView->AddControlFromResourceL( 
       
  3027                 R_SMSV_TO, 
       
  3028                 EMsgAddressControl, 
       
  3029                 EMsgAppendControl, 
       
  3030                 EMsgHeader );
       
  3031               }            
       
  3032             // take the number
       
  3033             iNumber = iSmsHeader->FromAddress();
       
  3034             break;
       
  3035         default:
       
  3036 #if defined ( _DEBUG )
       
  3037             Panic( EMsgSmsViewerUnknownSmsPduType );
       
  3038 #else
       
  3039             User::Leave( KErrNotSupported );
       
  3040 #endif
       
  3041             break;
       
  3042         }
       
  3043     // If we are dealing with Email message
       
  3044     // we add subject control for Email type subject
       
  3045     if ( iFlags.iIsEmailMessage )
       
  3046         {
       
  3047         TPtrC subj( iSmsHeader->EmailFields().Subject() );
       
  3048         if ( subj.Length() )
       
  3049             {
       
  3050             // Add subject control if not present
       
  3051             AddSubjectControlL();
       
  3052             // Set the Subject field text accordigly
       
  3053             SetSubjectL( subj );
       
  3054             }
       
  3055         }
       
  3056     else if( iFlags.iEmailSubjectControlPresent  && SubjectControl() )
       
  3057         {
       
  3058         //remove subject control if in case prev messages is email over SMS message with subject
       
  3059         iView->DeleteControlL( EMsgComponentIdSubject );
       
  3060         iFlags.iEmailSubjectControlPresent = EFalse;
       
  3061         }
       
  3062     iTypeMsg = pduType; //for successful launch save the PDU Type.
       
  3063     }
       
  3064 
       
  3065 //  End of File