mobilemessaging/mmsui/viewersrc/UniMmsViewerAppUi.cpp
changeset 0 72b543305e3a
child 1 d09ac5c1e252
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 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 *       Provides CMmsViewerAppUi class methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <gmxmlconstants.h>
       
    24 
       
    25 #include <e32keys.h>                // EStdKey*
       
    26 
       
    27 #include <eikmenup.h>               // CEikMenuPane
       
    28 #include <eikmenub.h>               // CEikMenuBar
       
    29 #include <eikrted.h>
       
    30 #include <MsgBodyControl.h>         // CMsgBodyControl
       
    31 #include <MsgEditorView.h>          // CMsgEditorView
       
    32 #include <MsgEditor.hrh>            // Base editor commands & enums
       
    33 #include <MsgEditorCommon.h>
       
    34 #include <MsgRecipientItem.h>
       
    35 #include <msgeditor.mbg>            // bitmap identifiers
       
    36 #include <MmsViewer.rsg>            // resouce identifiers
       
    37 #include <mmsui.mbg>
       
    38 #include <data_caging_path_literals.hrh> 
       
    39 
       
    40 #include <apgwgnam.h>                // CApaWindowGroupName
       
    41 
       
    42 #include <msvuids.h>
       
    43 #include <MsgAddressControl.h>
       
    44 #include <mtclbase.h>
       
    45 #include <MsgFolderSelectionDialog.h>   //Folder Selection dialog
       
    46 #include <MuiuMsvUiServiceUtilities.h>
       
    47 #include <muiumsvuiserviceutilitiesinternal.h>
       
    48 
       
    49 #include <MuiuOperationWait.h>          // CMuiuOperationWait
       
    50 #include <MuiuMsgEmbeddedEditorWatchingOperation.h>
       
    51 #include <akninputblock.h>              // CAknInputBlock
       
    52 #include <muiumsguploadparam.h>
       
    53 
       
    54 #include <avkon.hrh>
       
    55 #include <avkon.rsg>                // R_AVKON_SOFTKEYS_OPTIONS_BACK, R_AVKON_NAVI_PANE_VOLUME_INDICATOR
       
    56 #include <aknnavide.h>              // CAknNavigationDecorator
       
    57 #include <akntitle.h>               // CAknTitlePane
       
    58 #include <Aknvolumecontrol.h>       // CAknVolumeControl
       
    59 #include <AknQueryDialog.h>
       
    60 #include <AknWaitDialog.h>
       
    61 #include <aknnotewrappers.h>
       
    62 #include <aknlists.h>               // CAknSinglePopupMenuStyleListBox
       
    63 #include <aknPopup.h>               //
       
    64 #include <akntabgrp.h>              // CAknTabGroup
       
    65 #include <aknclearer.h>             // CAknLocalScreenClearer
       
    66 #include <AknsUtils.h>
       
    67 #include <AknsConstants.h>
       
    68 #include <AknStatuspaneUtils.h>
       
    69 
       
    70 #include <AiwGenericParam.h>           // CAiwGenericParamList
       
    71 
       
    72 #include <aknlayoutscalable_apps.cdl.h>
       
    73 #include <aknlayoutscalable_avkon.cdl.h>
       
    74 
       
    75 #include <cntdef.h>                         // KNullContactId
       
    76 
       
    77 #include <centralrepository.h>
       
    78 #include <cenrepnotifyhandler.h>
       
    79 #include <messaginginternalcrkeys.h>
       
    80 #include <CommonUiInternalCRKeys.h>
       
    81 #include <MusicPlayerInternalCRKeys.h>
       
    82 #include <ProfileEngineSDKCRKeys.h>   // silence mode status check
       
    83 #include <settingsinternalcrkeys.h>    // KCRUidRichCallSettings
       
    84 #include <messagingvariant.hrh>
       
    85  
       
    86 #include <Profile.hrh>              // silence mode status check
       
    87 
       
    88 #include <DocumentHandler.h>        // CDocumentHandler
       
    89 #include <commonphoneparser.h>      // CommonPhoneParser
       
    90 
       
    91 #include <FindItemmenu.rsg>         // Find item stuff
       
    92 #include <finditemmenu.h>           //
       
    93 #include <finditemdialog.h>         //
       
    94 #include <finditem.hrh>             //
       
    95 #include <ItemFinder.h>          //
       
    96 
       
    97 #include <StringLoader.h>           // StringLoader
       
    98 #include <ErrorUI.h>                // Default error notes
       
    99 
       
   100 #include <charconv.h>               // Character sets
       
   101 
       
   102 #include <basched.h>                // KErrExtended, KLeaveExit
       
   103 
       
   104 #include <eikbtgpc.h>
       
   105 #include <baclipb.h>
       
   106 #include <txtetext.h>
       
   107 #include <txtrich.h>
       
   108 
       
   109 #include <msvstd.h>                     // Message entries
       
   110 #include <msvapi.h>                     // MsvOperation
       
   111 #include <msvstore.h>                   // CMsvStore
       
   112 #include <MtmExtendedCapabilities.hrh>  // function id of MessageInfo
       
   113 
       
   114 #include <CSendingServiceInfo.h>
       
   115 #include <sendui.h>                 // SendUI (for Reply via SMS)
       
   116 #include <SenduiMtmUids.h>          // MTM Uids
       
   117 #include <CMessageData.h>
       
   118 
       
   119 #include <mdaaudiosampleplayer.h>
       
   120 #include <AudioPreference.h>
       
   121 #include <NpdApi.h>                 // CNotePadApi
       
   122 
       
   123 // DRM
       
   124 #include <DRMCommon.h>
       
   125 
       
   126 // SMIL Player
       
   127 #include <SmilPlayerDialog.h>
       
   128 
       
   129 // Features
       
   130 #include <featmgr.h>	
       
   131 #include <bldvariant.hrh>
       
   132 
       
   133 // Help
       
   134 #include <csxhelp/mms.hlp.hrh>
       
   135 #include <hlplch.h>                 // For HlpLauncher 
       
   136 
       
   137 #include "MmsMtmUi.h"               // Mms Mtm Ui
       
   138 
       
   139 #include "MsgAttachmentUtils.h"     // enumerations for objects view
       
   140 
       
   141 #include <msgtextutils.h>
       
   142 #include <MsgMedia.hrh>
       
   143 #include <MsgMediaInfo.h>
       
   144 #include <MsgVideoInfo.h>
       
   145 #include <MsgAttachmentInfo.h>
       
   146 
       
   147 #include <MmsConformance.h>
       
   148 #include <fileprotectionresolver.h>
       
   149 #include <msgmediacontrol.h>
       
   150 #include <msgimagecontrol.h>
       
   151 #include <msgaudiocontrol.h>
       
   152 #include <msgvideocontrol.h>
       
   153 #ifdef RD_SVGT_IN_MESSAGING
       
   154 #include <msgsvgcontrol.h>
       
   155 #endif
       
   156 #include <unidatamodel.h>           // CUniDataModel
       
   157 #include <unismilmodel.h>           // CUniSmilModel
       
   158 #include <unidatautils.h>           // enumerations
       
   159 #include <uniobject.h>
       
   160 #include <unimimeinfo.h>
       
   161 
       
   162 #include <unislideloader.h>
       
   163 
       
   164 #include <uniobjectsviewdialog.h>   // Common objects view implementation
       
   165 #include <uniobjectsmodel.h>        // Model part of the objects view
       
   166 #include <uniobjectlist.h>
       
   167 #include <unismillist.h>
       
   168 #include <uniobjectsinfo.h>
       
   169 
       
   170 #include <mmsclient.h>              // CMmsClientMtm, mmsconst.h
       
   171 #include <mmsgenutils.h>
       
   172 #include <mmsmsventry.h>
       
   173 
       
   174 #include "MmsViewer.hrh"            // application specific commands & enums
       
   175 #include "UniMmsViewerDocument.h"      // CMmsViewerDocument
       
   176 #include "UniMmsViewerAppUi.h"         // CMmsViewerAppUi
       
   177 #include "MmsViewerHeader.h"
       
   178 #include "MmsViewerLaunchOperation.h"
       
   179 #include "MmsViewerChangeSlideOperation.h"
       
   180 #include "MmsViewerSendReadReportOperation.h"
       
   181 
       
   182 #include "MmsMtmConst.h"            // File logger
       
   183 #include <msgvoipextension.h>
       
   184 
       
   185 #ifdef RD_SCALABLE_UI_V2
       
   186 #include <aknnavide.h>              // pen support on navi pane
       
   187 #include <AknNaviObserver.h>        // pen support of volume control of navi pane
       
   188 #endif
       
   189 #include <akntoolbar.h>             
       
   190 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension
       
   191 #include <MsgEditorSettingCacheUpdatePlugin.h>
       
   192 #include    <e32property.h>
       
   193 #include  <ctsydomainpskeys.h>
       
   194 // CONSTANTS
       
   195 
       
   196 // following is minimum value for player
       
   197 const TInt KVolumeControlMinValuePlayer = 0;      
       
   198 // following are minimum values for avkon volume indicator component
       
   199 const TInt KVolumeControlMinValue = 0;      //from "AKNVOLUMECONTROL.CPP"
       
   200 const TInt KVolumeControlMaxValue = 10;     //from "AKNVOLUMECONTROL.CPP"
       
   201 const TInt KVolumeDefault = 8;
       
   202 const TInt KVolumeLevels = 10;
       
   203 
       
   204 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   205 const TUint KNaviGranularity = 2;
       
   206 const TInt KIconDefaultColor = 0;
       
   207 #endif
       
   208 _LIT( KMmsUiMbmFile, "mmsui.mbm" );
       
   209 
       
   210 const TInt KReplyToSenderSize = 2048;
       
   211 const TInt KReplyToAllSize = 2048;
       
   212 const TMsvId KNewMessageFolder = KMsvDraftEntryIdValue;
       
   213 const TInt KInvalidResourceId = -1;
       
   214 
       
   215 // Fast swap window group
       
   216 #define KFastSwapAppUid TUid::Uid( 0x10207218 )
       
   217 #define KAknNotifyServerAppUid TUid::Uid( 0x10281ef2 )
       
   218 #define KScreenSaverAppUid TUid::Uid( 0x100056CF )
       
   219 
       
   220 _LIT( KMmsViewerSpace, " " );
       
   221 
       
   222 const TUid KNotepadUID3 = { KTextHandler };   // Notepad viever
       
   223 
       
   224 // Exiting in launch. Let this time to show error notes
       
   225 //const TInt  KDelayedExitShort = 100000;
       
   226 
       
   227 
       
   228 // ================= MEMBER FUNCTIONS =======================
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // C++ default constructor can NOT contain any code, that
       
   232 // might leave.
       
   233 // ---------------------------------------------------------
       
   234 //
       
   235 CMmsViewerAppUi::CMmsViewerAppUi( ) :
       
   236         iPendingNoteResource( KInvalidResourceId ),
       
   237         iViewerFlags( EInitialFlags ),
       
   238         iViewerState( ENormal )
       
   239     {
       
   240     LOGTIMESTAMP("CMmsViewerAppUi::CMmsViewerAppUi ");
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------
       
   244 // Symbian OS default constructor can leave.
       
   245 // ---------------------------------------------------------
       
   246 //
       
   247 void CMmsViewerAppUi::ConstructL( )
       
   248     {
       
   249     CMsgEditorAppUi::ConstructL( );
       
   250     
       
   251     // Disable task swapper from options menu during launch
       
   252     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
       
   253     
       
   254     LOGTEXT(_L8("CMmsViewerAppUi::ConstructL starting") );
       
   255 	FeatureManager::InitializeLibL( );
       
   256 	if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   257 		{
       
   258 		iSupportedFeatures |= EMmsFeatureHelp;
       
   259 		}
       
   260     if ( FeatureManager::FeatureSupported( KFeatureIdDrmFull ) )
       
   261         {
       
   262         iSupportedFeatures |= EMmsFeatureDrmFull;
       
   263         }
       
   264     if ( FeatureManager::FeatureSupported( KFeatureIdSideVolumeKeys ) )
       
   265         {
       
   266         iSupportedFeatures |= EMmsFeatureSVK;
       
   267         }
       
   268     if ( FeatureManager::FeatureSupported( KFeatureIdSenduiMmsUpload ) )
       
   269         {
       
   270         iSupportedFeatures |= EMmsFeatureUpload;
       
   271         }
       
   272     if ( FeatureManager::FeatureSupported( KFeatureIdAudioMessaging ) )
       
   273         {
       
   274         iSupportedFeatures |= EMmsFeatureAudioMessaging;
       
   275         }
       
   276     FeatureManager::UnInitializeLib( );
       
   277 
       
   278 #ifdef RD_SCALABLE_UI_V2
       
   279     // Creation of CMsgEditorView must be after toolbar is set visible otherwise layout things can go wrong. 
       
   280     // Toolbar itself seems to set itself invisible temporary at some startup time. Toolbar is set visible here, too.   
       
   281     if ( AknLayoutUtils::PenEnabled() )
       
   282         {
       
   283         iToolbar = CurrentFixedToolbar();  
       
   284         if ( iToolbar )
       
   285             {
       
   286             iToolbar->SetToolbarObserver( this );
       
   287             iToolbar->SetToolbarVisibility( ETrue, EFalse );
       
   288             }
       
   289         }
       
   290 #endif
       
   291         
       
   292     iView = CMsgEditorView::NewL( *this,
       
   293         CMsgEditorView::EMsgReadOnly |
       
   294         CMsgEditorView::EMsgDoNotUseDefaultBodyControl );
       
   295 
       
   296     iMtm = &(Document( )->Mtm( ));
       
   297     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   298         ( StatusPane( )->ControlL(  TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   299     iTitlePane = static_cast<CAknTitlePane*>
       
   300         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   301     iButtonGroup = Cba( );
       
   302     iSvkEvents = CMmsSvkEvents::NewL( *this );
       
   303 
       
   304     if ( !iButtonGroup || !iNaviPane || !iMtm )
       
   305         {
       
   306         User::Leave( KErrBadHandle );
       
   307         }
       
   308 
       
   309     TInt highlight = 0;
       
   310     TInt drmPlayback = 0;    
       
   311     // Volume level storage
       
   312     iMmsRepository = CRepository::NewL( KCRUidMmsui );
       
   313 
       
   314     // Automatic highlight setting storage and change notifications
       
   315     iCUiRepository = CRepository::NewL( KCRUidCommonUi );
       
   316     iCUiRepository->Get( KCuiAutomaticHighlight, highlight  );
       
   317     iNotifyHandler = CCenRepNotifyHandler::NewL( *this, 
       
   318                                                  *iCUiRepository, 
       
   319                                                  CCenRepNotifyHandler::EIntKey, 
       
   320                                                  KCuiAutomaticHighlight );
       
   321     iNotifyHandler->StartListeningL( );
       
   322 
       
   323     CRepository* repository = CRepository::NewLC( KCRUidMusicPlayerFeatures );
       
   324     repository->Get( KRequireDRMInPlayback, drmPlayback  );    
       
   325     
       
   326     if ( drmPlayback )
       
   327         {
       
   328         TBuf<1> tmp; // Magic: 1 char to get length of actual value
       
   329         TInt realLen = 0;
       
   330         TInt err = repository->Get( KPlaybackRestrictedMimeTypes,
       
   331                                     tmp,
       
   332                                     realLen );
       
   333                                     
       
   334         if ( err == KErrOverflow )
       
   335             {
       
   336             // Prepare list of blocked MIME types
       
   337             iProhibitMimeTypeBuffer = HBufC::NewL( realLen + KMmsViewerSpace().Length() );
       
   338             TPtr bufferPtr = iProhibitMimeTypeBuffer->Des();
       
   339             
       
   340             User::LeaveIfError( repository->Get( KPlaybackRestrictedMimeTypes, bufferPtr ) );
       
   341             bufferPtr.Append( KMmsViewerSpace );
       
   342             }
       
   343         else
       
   344             {
       
   345             User::LeaveIfError( err );
       
   346             }
       
   347         }
       
   348     
       
   349     CleanupStack::PopAndDestroy( repository );
       
   350     repository = NULL;
       
   351 
       
   352     TInt features(0);
       
   353     repository = CRepository::NewL( KCRUidMuiuVariation );
       
   354     
       
   355     repository->Get( KMuiuMmsFeatures, features );
       
   356     if ( features & KMmsFeatureIdDeliveryStatusDialog ) 
       
   357         {
       
   358         iSupportedFeatures |= EMmsFeatureDeliveryStatus;
       
   359         }
       
   360         
       
   361     repository->Get( KMuiuUniEditorFeatures, features );
       
   362     if ( features & KUniEditorFeatureIdRestrictedReplyMms )
       
   363         {
       
   364         iSupportedFeatures |= EMmsFeatureRestrictedReply;
       
   365         }
       
   366     delete repository;
       
   367         
       
   368     repository = CRepository::NewL( KCRUidUniEditor );
       
   369     repository->Get( KUniEditorMaxSlideCount, iMaxForwardSlideCount );    
       
   370     delete repository;
       
   371         
       
   372     // Set up highlighting
       
   373     if ( highlight == 0 )
       
   374         {
       
   375         iViewerFlags &= ~EAutohighLightEnabled;
       
   376         }
       
   377     else
       
   378         {
       
   379         iViewerFlags |= EAutohighLightEnabled;
       
   380         }
       
   381 
       
   382     if ( drmPlayback )
       
   383         {
       
   384         iViewerFlags |= EProhibitNonDrmMusic;
       
   385         }
       
   386 
       
   387     if ( Document( )->CreationMode( ) == EMmsCreationModeWarning )
       
   388         {
       
   389         iViewerFlags |= EShowGuidedConf;
       
   390         }
       
   391 
       
   392     iMmsConformance = CMmsConformance::NewL( );
       
   393 
       
   394   	// Set path of bitmap file
       
   395   	TParse fileParse;
       
   396   	fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
   397     
       
   398     iAppIcon = AknsUtils::CreateGulIconL( 
       
   399         AknsUtils::SkinInstance(), 
       
   400         KAknsIIDQgnPropMceMmsTitle,
       
   401         fileParse.FullName(),
       
   402         EMbmMmsuiQgn_prop_mce_mms_title,
       
   403         EMbmMmsuiQgn_prop_mce_mms_title_mask );
       
   404 
       
   405     // Get important window group ids
       
   406     GetNonStoppingWgIds( );
       
   407 
       
   408     // Priority must be lower than the priority of iWrappedWaitDialog
       
   409     // Constructed here to ensure exit on low memory situations.
       
   410     iIdle = CPeriodic::NewL( EPriorityNormal - 1);
       
   411 
       
   412 	if( !iEikonEnv->StartedAsServerApp( ) )
       
   413 		{
       
   414 	    Document( )->PrepareToLaunchL( this );
       
   415 		}
       
   416     LOGTEXT2(_L16("CMmsViewerAppUi::ConstructL read. iSupportedFeatures 0x%x"), iSupportedFeatures );
       
   417     }
       
   418 
       
   419 // ---------------------------------------------------------
       
   420 // Destructor
       
   421 // ---------------------------------------------------------
       
   422 //
       
   423 CMmsViewerAppUi::~CMmsViewerAppUi( )
       
   424     {
       
   425     LOGTEXT(_L8("CMmsViewerAppUi::~CMmsViewerAppUi starting") );
       
   426     iViewerFlags |= EViewerExiting;
       
   427     iViewerState = EReseted;
       
   428     EndActiveWait();
       
   429     // Input blocker is also deleted
       
   430     DeactivateInputBlocker();
       
   431     if ( iNotifyHandler )
       
   432         {        
       
   433         iNotifyHandler->StopListening( );
       
   434         }
       
   435     delete iNotifyHandler;
       
   436     delete iCUiRepository;
       
   437     delete iMmsRepository;
       
   438 
       
   439     //iMtm not owned - just a reference pointer
       
   440     //iSmilModel not owned - just a reference pointer
       
   441     //iNaviPane not owned - just a reference pointer
       
   442     //iButtonGroup not owned - just a reference pointer
       
   443 
       
   444 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   445     delete iNaviDecorator;
       
   446 #endif
       
   447     delete iVolumeDecorator;
       
   448     delete iWaitDialog;
       
   449     delete iFindItemMenu;
       
   450     delete iDocHandler;
       
   451 
       
   452     delete iHeader;
       
   453     delete iSlideLoader;
       
   454     delete iLaunchOperation;
       
   455     delete iChangeSlideOperation;
       
   456     delete iScreenClearer;
       
   457     iUploadServices.ResetAndDestroy( );
       
   458     delete iMmsVoIPExtension;
       
   459     delete iSvkEvents;
       
   460     delete iMmsConformance;
       
   461     delete iTitleIcon;
       
   462     
       
   463     delete iProhibitMimeTypeBuffer;
       
   464     delete iSendReadReportOperation;
       
   465     delete iIdle;
       
   466     delete iAppIcon;
       
   467 
       
   468     LOGTEXT(_L8("CMmsViewerAppUi::~CMmsViewerAppUi end") );
       
   469     }
       
   470 
       
   471 // ---------------------------------------------------------
       
   472 // CMmsViewerAppUi::Document
       
   473 // ---------------------------------------------------------
       
   474 //
       
   475 CMmsViewerDocument* CMmsViewerAppUi::Document( ) const
       
   476     {
       
   477     return static_cast<CMmsViewerDocument*>( CMsgEditorAppUi::Document( ) );
       
   478     }
       
   479 
       
   480 // ---------------------------------------------------------
       
   481 // CMmsViewerAppUi::MsgSaveExitL
       
   482 // framework function
       
   483 // ---------------------------------------------------------
       
   484 //
       
   485 void CMmsViewerAppUi::DoMsgSaveExitL( )
       
   486     {
       
   487     MediaStop( );
       
   488     iExitMode = MApaEmbeddedDocObserver::TExitMode(CMsgEmbeddedEditorWatchingOperation::EMsgExternalExit);
       
   489     Exit( );
       
   490     }
       
   491 
       
   492 
       
   493 // ---------------------------------------------------------
       
   494 // CMmsViewerAppUi::LaunchViewL
       
   495 // ---------------------------------------------------------
       
   496 //
       
   497 
       
   498 void CMmsViewerAppUi::LaunchViewL( )
       
   499     {
       
   500     __ASSERT_DEBUG( Document( )->Entry( ).Id( ) != KMsvNullIndexEntryId, Panic( EMmsViewerNoMessage ) );
       
   501     TBool exitViewer( EFalse );
       
   502     if ( iViewerFlags & EViewerExiting )
       
   503         {
       
   504         exitViewer = ETrue;
       
   505         }
       
   506     else
       
   507         {
       
   508         TRAPD( error, DoLaunchViewL() );
       
   509         
       
   510         if ( error != KErrNone )
       
   511             {
       
   512             iEikonEnv->HandleError( error );
       
   513             exitViewer = ETrue;
       
   514             }
       
   515         }
       
   516     
       
   517     if ( exitViewer )
       
   518         {
       
   519         // Start the delayed exit here if exit command was given before application was
       
   520         // ready to handle it or error happened when performing lauch view. 
       
   521         // Delayed exit is used as LauchViewL cannot make proper exit if Exit() is called here.
       
   522         DoDelayedExit( 0 );
       
   523         }
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CMmsViewerAppUi::DoLaunchViewL
       
   528 // ---------------------------------------------------------
       
   529 //
       
   530 void CMmsViewerAppUi::DoLaunchViewL()
       
   531     {
       
   532     // Exiting here leaves incomplete mms viewer view visible
       
   533     // Let the launch happen until ViewerOperationEvent()
       
   534     TRAPD( error, iMtm->LoadMessageL( ) );
       
   535     LOGTEXT2(_L16("CMmsViewerAppUi::LaunchViewL error %d"), error );
       
   536     if ( error )
       
   537         {
       
   538         if ( error != KErrNoMemory )
       
   539             {
       
   540             ShowErrorNoteL( R_MMSVIEWER_ERROR_MSG_CORRUPT );
       
   541             }
       
   542         User::Leave( error );
       
   543         }
       
   544 
       
   545     iViewerState = EBusy;
       
   546     iOpeningState = EOpeningMessage;
       
   547     LaunchWaitDialogL( 0 );
       
   548 
       
   549     // iWaitDialog was deleted in case of error. Is this needed ?
       
   550     iLaunchOperation = new ( ELeave ) CMmsViewerLaunchOperation(
       
   551                                         this,
       
   552                                         *this,
       
   553                                         *this,
       
   554                                         *Document( ),
       
   555                                         *iView,
       
   556                                         iCoeEnv->FsSession( ) );
       
   557     ActivateInputBlockerL( iLaunchOperation );
       
   558     iLaunchOperation ? iLaunchOperation->Launch( ) : User::Leave( KErrNoMemory );
       
   559     }
       
   560 
       
   561 // ---------------------------------------------------------
       
   562 // CMmsViewerAppUi::ChangeSlideL
       
   563 // ---------------------------------------------------------
       
   564 //
       
   565 void CMmsViewerAppUi::ChangeSlideL( TInt aSlideNumber, TBool aScreenClearer )
       
   566     {
       
   567     if ( aSlideNumber < 0 || aSlideNumber >= iSmilModel->SlideCount( ) )
       
   568         {
       
   569         User::Leave( KErrArgument );
       
   570         }
       
   571     MediaStop( );
       
   572     
       
   573     iViewerState = EBusy;
       
   574     iOpeningState = EOpeningSlide;
       
   575     iViewerFlags |= EVideoHasAudio;
       
   576     iVideo = NULL;
       
   577     iAudio = NULL;
       
   578     iImage = NULL;
       
   579 #ifdef RD_SVGT_IN_MESSAGING
       
   580     iSvgt = NULL;
       
   581 #endif    
       
   582     iPendingNoteResource = KInvalidResourceId;
       
   583     iPendingNotePriority = 0;
       
   584     iPendingNoteObject = NULL;
       
   585     iPendingNoteError = KErrNone;
       
   586     
       
   587     // use case: 
       
   588     // precondition: text on two slide and from field empty on the emulator
       
   589     // crash when: 
       
   590     // - goto slide 2 and take selection menu on text
       
   591     // - goto slide 1 and take selection menu on from field (which is empty) => crash
       
   592     // iFindItem contains 'deleted' objects
       
   593     delete iFindItemMenu;
       
   594     iFindItemMenu = NULL;
       
   595 
       
   596     UpdateMskL();
       
   597 
       
   598 
       
   599     if ( !iChangeSlideOperation )
       
   600         {
       
   601         iChangeSlideOperation = new ( ELeave )CMmsViewerChangeSlideOperation (
       
   602             *this,
       
   603             *( Document( ) ),
       
   604             *iHeader,
       
   605             *iSlideLoader,
       
   606             *iView,
       
   607             iCoeEnv->FsSession( ) );
       
   608         }
       
   609         
       
   610     iChangeSlideOperation ? iChangeSlideOperation->ChangeSlide( aSlideNumber ) : User::Leave( KErrNoMemory );
       
   611     
       
   612     if ( aScreenClearer )
       
   613         {
       
   614         iScreenClearer = CAknLocalScreenClearer::NewLC( EFalse );
       
   615         CleanupStack::Pop( iScreenClearer );
       
   616         iScreenClearer->SetExtent( iScreenClearer->Position(), ClientRect().Size() );
       
   617         }
       
   618     
       
   619     if ( aScreenClearer )
       
   620         {
       
   621         LaunchWaitDialogL( aSlideNumber );
       
   622         }
       
   623     ActivateInputBlockerL( iChangeSlideOperation );
       
   624     
       
   625     // TODO: Get rid of active wait!
       
   626     BeginActiveWait( iChangeSlideOperation );
       
   627     }
       
   628 
       
   629 // ---------------------------------------------------------
       
   630 // CMmsViewerAppUi::LaunchWaitDialogL
       
   631 // ---------------------------------------------------------
       
   632 //
       
   633 void CMmsViewerAppUi::LaunchWaitDialogL( TInt aParam )
       
   634     {
       
   635     if ( iWaitDialog )
       
   636         {
       
   637         delete iWaitDialog;
       
   638         iWaitDialog = NULL;
       
   639         }
       
   640  
       
   641     if ( iOpeningState == EOpeningMessage )
       
   642         {
       
   643         iWaitDialog = new ( ELeave ) CAknWaitDialog(
       
   644                 ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ),
       
   645                 ETrue );
       
   646         iWaitDialog->ExecuteLD( R_MMSVIEWER_WAIT_LOADING );
       
   647         }
       
   648     else if ( iOpeningState == EOpeningSlide )
       
   649         {
       
   650         iWaitDialog = new ( ELeave ) CAknWaitDialog(
       
   651                 ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ),
       
   652                 EFalse );
       
   653         CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>(2);
       
   654         CleanupStack::PushL( array );
       
   655         array->AppendL( aParam + 1 );
       
   656         array->AppendL( iSmilModel->SlideCount( ) );
       
   657         HBufC* string = StringLoader::LoadLC(
       
   658             R_MMSVIEWER_OPENING_PAGE,
       
   659             *array,
       
   660             iCoeEnv );
       
   661         iWaitDialog->SetTextL( *string );
       
   662         iWaitDialog->ExecuteLD( R_MMSVIEWER_WAIT_OPENING_PAGE );
       
   663         CleanupStack::PopAndDestroy( 2, array ); // + string
       
   664         }
       
   665     }
       
   666 
       
   667 
       
   668 // ---------------------------------------------------------
       
   669 // CMmsViewerAppUi::SetPendingNote
       
   670 // ---------------------------------------------------------
       
   671 //
       
   672 void CMmsViewerAppUi::SetPendingNote(   TInt                aResourceId, 
       
   673                                         CUniObject*         aObject,
       
   674                                         TInt                aError )
       
   675     {    
       
   676     TInt priority = 0;
       
   677     switch ( aResourceId )
       
   678         {
       
   679         case R_MMSVIEWER_DRM_ERROR:
       
   680             {
       
   681                 // do not show note during launch or slide change except for image
       
   682             if (   !aObject
       
   683                 || !aObject->MediaInfo( )
       
   684                 ||  (   (   iOpeningState == EOpeningMessage
       
   685                         ||  iOpeningState == EOpeningSlide )
       
   686                     &&  aObject->MediaType( ) != EMsgMediaImage ) )
       
   687                 {
       
   688                 return;
       
   689                 }                
       
   690             else if (   aObject->MediaType( ) == EMsgMediaImage
       
   691 #ifdef RD_SVGT_IN_MESSAGING
       
   692                     ||  aObject->MediaType( ) == EMsgMediaSvg
       
   693 #endif
       
   694                     )
       
   695                 {
       
   696                 if ( aObject->DrmInfo( ) )
       
   697                     {
       
   698                     TBool consumed = EFalse;
       
   699                     aObject->DrmInfo( )->EvaluateRights( consumed );
       
   700                     if ( consumed )
       
   701                         {
       
   702                         return;
       
   703                         }
       
   704                     }
       
   705                 else
       
   706                     {
       
   707                     // can't do anything without drm info
       
   708                     return;
       
   709                     }
       
   710                 }
       
   711             priority = 5;
       
   712             break;
       
   713             }
       
   714         case R_MMSVIEWER_DRM_PREVIEW_RIGHTS:
       
   715             priority = 4;  
       
   716             break;          
       
   717         case R_MMSVIEWER_DRM_OBJECT_REMOVED:
       
   718             if (!priority)
       
   719                 {
       
   720                 priority = 3;
       
   721                 }
       
   722             break;
       
   723         case R_MMSVIEWER_CANNOT_DISPLAY_OBJECTS:
       
   724             {
       
   725                     
       
   726                 // during launch only 
       
   727             if ( iOpeningState != EOpeningMessage )
       
   728                 {
       
   729                 return;
       
   730                 }
       
   731             if (!priority)
       
   732                 {
       
   733                 priority = 2;
       
   734                 }
       
   735             break;
       
   736             }
       
   737         case R_QTN_MMS_CANNOT_OPEN_CORRUPTED:
       
   738             {   
       
   739                 // during play only
       
   740             if ( iOpeningState != EOpeningNone )
       
   741                 {
       
   742                 return;
       
   743                 }
       
   744             priority = 1;
       
   745             break;
       
   746             }
       
   747         default:
       
   748             break;
       
   749         }
       
   750     if ( priority > iPendingNotePriority )
       
   751         {
       
   752         iPendingNotePriority = priority;
       
   753         iPendingNoteResource = aResourceId;
       
   754         iPendingNoteObject = aObject;
       
   755         iPendingNoteError = aError;
       
   756         }
       
   757     }
       
   758 
       
   759 // ---------------------------------------------------------
       
   760 // CMmsViewerAppUi::ShowPendingNoteL
       
   761 // ---------------------------------------------------------
       
   762 //
       
   763 void CMmsViewerAppUi::ShowPendingNoteL( )
       
   764     {
       
   765         // show note only once and after every control has been initialised
       
   766         // in order to show the highest priority note
       
   767     if ( !AreControlsReadyAndWaitNoteDismissedL() )
       
   768         {
       
   769         return;
       
   770         }
       
   771           
       
   772     iOpeningState = EOpeningNone;
       
   773 
       
   774     // It may occur that this code point is entered twice when control state changes take place
       
   775     // Temp variable is second action to avoid it. Resetting iPending* variables earlier in ReloadControlL
       
   776     // and ChangeSlide is first one
       
   777     TInt pendingNoteResource = iPendingNoteResource;
       
   778     iPendingNoteResource = KInvalidResourceId;
       
   779     switch ( pendingNoteResource )
       
   780         {
       
   781         case R_MMSVIEWER_DRM_ERROR:
       
   782             {
       
   783             if (    iPendingNoteObject 
       
   784                 &&  iPendingNoteObject->DrmInfo( ) )
       
   785                 {
       
   786                 TRAP_IGNORE( iPendingNoteObject->DrmInfo( )->HandleDrmErrorL( iPendingNoteError ) );
       
   787                 }
       
   788             break;
       
   789             }
       
   790         case R_MMSVIEWER_DRM_PREVIEW_RIGHTS:
       
   791         case R_MMSVIEWER_DRM_OBJECT_REMOVED:
       
   792         case R_MMSVIEWER_CANNOT_DISPLAY_OBJECTS:
       
   793         case R_QTN_MMS_CANNOT_OPEN_CORRUPTED:
       
   794             {
       
   795             ShowInformationNoteL( pendingNoteResource );
       
   796             }
       
   797             break;
       
   798         case KInvalidResourceId:
       
   799         default:
       
   800             break;
       
   801         }    
       
   802     iPendingNotePriority = 0;
       
   803     iPendingNoteObject = NULL;
       
   804     iPendingNoteError = KErrNone;
       
   805     }
       
   806 
       
   807 
       
   808 // ---------------------------------------------------------
       
   809 // CMmsViewerAppUi::InitNavipaneL
       
   810 // ---------------------------------------------------------
       
   811 //
       
   812 void CMmsViewerAppUi::InitNavipaneL( )
       
   813     {
       
   814 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
   815     if ( !iNaviDecorator )
       
   816         {
       
   817         TMsgEditorMsgPriority priority = EMsgEditorMsgPriorityNormal;
       
   818     
       
   819         if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
   820             {
       
   821             priority = EMsgEditorMsgPriorityHigh;
       
   822             }
       
   823         else if ( iMtm->MessagePriority() == EMmsPriorityLow )
       
   824             {
       
   825             priority = EMsgEditorMsgPriorityLow;
       
   826             }
       
   827         
       
   828         CreateViewerNaviPaneL( Document()->Entry().iDate, priority, ETrue );
       
   829         }
       
   830         
       
   831     if ( MediaIsRunning( iAudio ) ||
       
   832          MediaIsRunning( iVideo ) )
       
   833         {
       
   834         iNaviPane->PushL( *iVolumeDecorator );  
       
   835         }
       
   836     else
       
   837         {
       
   838         iNaviPane->PushL( *iNaviDecorator );  
       
   839         }
       
   840 #else
       
   841     TInt indexInFolder = 0;
       
   842     TInt msgsInFolder = 0;
       
   843     MessageIndexInFolderL( indexInFolder, msgsInFolder );
       
   844 
       
   845     if (    indexInFolder < 0
       
   846         ||  msgsInFolder == 0 )
       
   847         {
       
   848         // this may occur when viewer is used in cover ui. Viewer is started as 
       
   849         // stand alone without current folder and '1/0' would be visible. 
       
   850         iNaviPane->PushDefaultL( );
       
   851         return;
       
   852         }
       
   853 
       
   854     CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>(KNaviGranularity);
       
   855     CleanupStack::PushL( array );
       
   856     array->AppendL( indexInFolder + 1 );
       
   857     array->AppendL( msgsInFolder );
       
   858 
       
   859     HBufC* buf = StringLoader::LoadLC( R_MMSVIEWER_ORDINAL_NUMBER, *array, iCoeEnv );
       
   860     //Pushed into CleanupStack
       
   861 
       
   862     //Creates iNaviDecorator
       
   863     CreateTabGroupL( *buf );
       
   864     CleanupStack::PopAndDestroy( 2, array ); // + buf
       
   865 
       
   866     iNaviDecorator->MakeScrollButtonVisible( ETrue );
       
   867 
       
   868     //NaviButtons are dimmed by default
       
   869     if ( IsNextMessageAvailableL( ETrue ) )
       
   870         {
       
   871         iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, EFalse );
       
   872         }
       
   873     if ( IsNextMessageAvailableL( EFalse ) )
       
   874         {
       
   875         iNaviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, EFalse );
       
   876         }
       
   877 
       
   878     if (    !MediaIsRunning( iAudio ) 
       
   879         &&  !MediaIsRunning( iVideo ) )
       
   880         {
       
   881         iNaviPane->PushL( *iNaviDecorator );  
       
   882         }
       
   883 #endif
       
   884     }
       
   885 
       
   886 
       
   887 // ---------------------------------------------------------
       
   888 // CMmsViewerAppUi::UpdatePanesL
       
   889 // ---------------------------------------------------------
       
   890 //
       
   891 void CMmsViewerAppUi::UpdatePanesL( TBool aAudioPlaying, TBool aVideoPlaying )
       
   892     {
       
   893     if ( aAudioPlaying || aVideoPlaying )
       
   894         {
       
   895         // Silent mode is handled in DoChangeVolumeL
       
   896         TInt newVolume = DoChangeVolumeL( 0, ETrue, aAudioPlaying ); 
       
   897         if ( newVolume >= KVolumeControlMinValue )
       
   898             {
       
   899             // Show the volume
       
   900             ShowVolumeL( newVolume, aAudioPlaying );
       
   901             }
       
   902         if ( aAudioPlaying )
       
   903             {
       
   904             iButtonGroup->SetCommandSetL( R_MMSVIEWER_SOFTKEYS_EMPTY_STOP );
       
   905             }
       
   906         else if ( aVideoPlaying )
       
   907             {
       
   908             iButtonGroup->SetCommandSetL( R_MMSVIEWER_SOFTKEYS_EMPTY_STOPVIDEO );
       
   909             }
       
   910         else
       
   911             {
       
   912             iButtonGroup->SetCommandSetL( R_MMSVIEWER_SOFTKEYS_OPTIONS_BACK_EMPTY );
       
   913             }
       
   914 
       
   915         if (    iNaviDecorator
       
   916             &&  iNaviPane->Top( ) == iNaviDecorator )
       
   917             {
       
   918             // Silent mode is ON or video has not audio
       
   919             // Hide navi pane during playback
       
   920             iNaviPane->PushDefaultL( );
       
   921             } 
       
   922         }
       
   923     else 
       
   924         {
       
   925         iButtonGroup->SetCommandSetL( R_MMSVIEWER_SOFTKEYS_OPTIONS_BACK_EMPTY );
       
   926         if ( iNaviDecorator )
       
   927             {
       
   928             iNaviPane->PushL( *iNaviDecorator );
       
   929             }
       
   930         else
       
   931             {
       
   932             iNaviPane->PushDefaultL( );
       
   933             }
       
   934         }
       
   935     // forces to update MSK, which was overridden here
       
   936     iMskId = 0;
       
   937     iButtonGroup->DrawNow( );
       
   938 #ifdef RD_SCALABLE_UI_V2
       
   939     SetToolBarItemVisibilities();
       
   940 #endif
       
   941     }
       
   942 
       
   943 
       
   944 // ---------------------------------------------------------
       
   945 // CMmsViewerAppUi::CreateTabGroupL
       
   946 // ---------------------------------------------------------
       
   947 //
       
   948 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   949 void CMmsViewerAppUi::CreateTabGroupL( const TDesC& aText )
       
   950     {
       
   951     if ( !iNaviDecorator )
       
   952         {
       
   953         // Create TabGroup
       
   954         iNaviDecorator = iNaviPane->CreateTabGroupL();
       
   955         }
       
   956     
       
   957 #ifdef RD_SCALABLE_UI_V2
       
   958     if ( AknLayoutUtils::PenEnabled() )
       
   959         {
       
   960 	    iNaviDecorator->SetNaviDecoratorObserver( this );
       
   961         }
       
   962 #endif
       
   963     
       
   964     CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( iNaviDecorator->DecoratedControl() );
       
   965     // Create message priority bitmap
       
   966     if ( iMtm->MessagePriority() == EMmsPriorityHigh || 
       
   967          iMtm->MessagePriority() == EMmsPriorityLow )
       
   968         {
       
   969         TRect naviPane;
       
   970         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ENaviPane, naviPane );
       
   971         
       
   972         TAknLayoutRect naviTabsPane;
       
   973         naviTabsPane.LayoutRect( naviPane,
       
   974                                  AknLayoutScalable_Avkon::navi_navi_tabs_pane().LayoutLine() );
       
   975         
       
   976         TAknLayoutRect navi2TabsPane;
       
   977         navi2TabsPane.LayoutRect( naviTabsPane.Rect(),
       
   978                                   AknLayoutScalable_Avkon::navi_tabs_2_pane().LayoutLine() );
       
   979 
       
   980         TAknLayoutRect tabs2ActivePane;
       
   981         tabs2ActivePane.LayoutRect( navi2TabsPane.Rect(),
       
   982                                     AknLayoutScalable_Avkon::tabs_2_active_pane( 0 ).LayoutLine() );
       
   983 
       
   984         TAknLayoutRect tabs2ActivePaneIcon;
       
   985         tabs2ActivePaneIcon.LayoutRect( tabs2ActivePane.Rect(),
       
   986                                         AknLayoutScalable_Avkon::tabs_2_active_pane_g1().LayoutLine() );
       
   987 
       
   988         TSize indicatorIconSize( tabs2ActivePaneIcon.Rect().Size() );
       
   989     
       
   990         // Set path of bitmap file
       
   991         TParse fileParse;
       
   992         fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
   993         
       
   994         CFbsBitmap* bitmapPriority = NULL;
       
   995         CFbsBitmap* maskPriority = NULL;
       
   996     
       
   997         if ( iMtm->MessagePriority() == EMmsPriorityHigh )
       
   998             {
       
   999             // Create high priority bitmap
       
  1000             AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
       
  1001                                          KAknsIIDQgnIndiMcePriorityHigh,
       
  1002                                          KAknsIIDQsnIconColors,
       
  1003                                          EAknsCIQsnIconColorsCG7,
       
  1004                                          bitmapPriority,
       
  1005                                          maskPriority,
       
  1006                                          fileParse.FullName(),
       
  1007                                          EMbmMmsuiQgn_indi_mce_priority_high,
       
  1008                                          EMbmMmsuiQgn_indi_mce_priority_high_mask,
       
  1009                                          AKN_LAF_COLOR( KIconDefaultColor ),
       
  1010                                          indicatorIconSize,
       
  1011                                          EAspectRatioPreserved );    
       
  1012             }
       
  1013         else
       
  1014             {
       
  1015             // Create low priority bitmap
       
  1016             AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
       
  1017                                          KAknsIIDQgnIndiMcePriorityLow,
       
  1018                                          KAknsIIDQsnIconColors,
       
  1019                                          EAknsCIQsnIconColorsCG7,
       
  1020                                          bitmapPriority,
       
  1021                                          maskPriority,
       
  1022                                          fileParse.FullName(),
       
  1023                                          EMbmMmsuiQgn_indi_mce_priority_low,
       
  1024                                          EMbmMmsuiQgn_indi_mce_priority_low_mask,
       
  1025                                          AKN_LAF_COLOR( KIconDefaultColor ),
       
  1026                                          indicatorIconSize,                                         
       
  1027                                          EAspectRatioPreserved ); 
       
  1028             }
       
  1029             
       
  1030         if ( !bitmapPriority )            
       
  1031             {
       
  1032             User::Leave( KErrNotFound );
       
  1033             }
       
  1034             
       
  1035         CleanupStack::PushL( bitmapPriority );
       
  1036         CleanupStack::PushL( maskPriority );
       
  1037         
       
  1038         if ( tabGroup->TabCount() == 0 )
       
  1039             {
       
  1040             tabGroup->AddTabL( 0, aText, bitmapPriority, maskPriority );
       
  1041             }
       
  1042         else
       
  1043             {
       
  1044             tabGroup->ReplaceTabL( 0, aText, bitmapPriority, maskPriority );
       
  1045             }
       
  1046             
       
  1047         CleanupStack::Pop( maskPriority ); // ownership tranferred to tabgroup
       
  1048         CleanupStack::Pop( bitmapPriority ); // ownership tranferred to tabgroup
       
  1049         }
       
  1050     else
       
  1051         {
       
  1052         // Set <message-index>/<message count>
       
  1053         if ( tabGroup->TabCount() == 0 )
       
  1054             {
       
  1055             tabGroup->AddTabL( 0, aText ); 
       
  1056             }
       
  1057         else
       
  1058             {
       
  1059             tabGroup->ReplaceTabL( 0, aText );
       
  1060             }
       
  1061         }
       
  1062 
       
  1063     tabGroup->SetActiveTabById( 0 );
       
  1064     tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab );
       
  1065     }
       
  1066 #endif // !RD_MSG_NAVIPANE_IMPROVEMENT
       
  1067 
       
  1068 // ---------------------------------------------------------
       
  1069 // CMmsViewerAppUi::DynInitMenuPaneL
       
  1070 // ---------------------------------------------------------
       
  1071 //
       
  1072 void CMmsViewerAppUi::DynInitMenuPaneL( TInt aMenuId, CEikMenuPane* aMenuPane )
       
  1073     {
       
  1074     TInt amountOfItems( aMenuPane->NumberOfItemsInPane( ) );
       
  1075     if ( !IsLaunched( )  )
       
  1076         {
       
  1077         if ( amountOfItems )
       
  1078             {
       
  1079             aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems - 1 );
       
  1080             }
       
  1081         return;
       
  1082         }
       
  1083 
       
  1084     if ( !iFindItemMenu )
       
  1085         {
       
  1086         iFindItemMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
       
  1087         if ( iHeader->SenderType( ) == EMuiuAddressTypeEmail )
       
  1088             {
       
  1089             // Set sender type to find menu
       
  1090             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
  1091             }
       
  1092         }
       
  1093 
       
  1094     if ( iSupportedFeatures & EMmsFeatureUpload &&
       
  1095         !( iViewerFlags & EUploadInitialized ) )
       
  1096         {
       
  1097         iViewerFlags |= EUploadInitialized;
       
  1098         CSendUi* sendui = CSendUi::NewLC( );
       
  1099         sendui->AvailableServicesL( iUploadServices, KMmsDirectUpload );
       
  1100         sendui->AvailableServicesL( iUploadServices, KMmsIndirectUpload );
       
  1101         CleanupStack::PopAndDestroy( sendui );
       
  1102         }
       
  1103 
       
  1104 
       
  1105     switch ( aMenuId )
       
  1106         {
       
  1107         case R_MMSVIEWER_SELECTIONMENU:
       
  1108             {
       
  1109             // No find item for recipient fields in Sent folder
       
  1110             if ( !IsOwnMessage( ) )
       
  1111                 {    
       
  1112                 if( (FocusedControlId( ) == EMsgComponentIdFrom) && ( ( iMtm->Sender( ) ).Length() ) )
       
  1113                     {
       
  1114                     iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
  1115                     iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );
       
  1116                     }
       
  1117 	            else
       
  1118 	     	        {
       
  1119                     iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
  1120 		            }
       
  1121                 }
       
  1122 			iFindItemMenu->AddItemFindMenuL( 
       
  1123                 ( FocusedControlId( ) == EMsgComponentIdBody ) ? iView->ItemFinder( ) : 0,
       
  1124 				aMenuPane, 
       
  1125                 EFindItemContextMenuPlaceHolder,
       
  1126                 TMmsGenUtils::PureAddress( iMtm->Sender( ) ),
       
  1127                 iHeader->Alias( ) && !iHeader->IsRemoteAlias( ) ? ETrue : EFalse, //"Is sender known"
       
  1128 				ETrue );
       
  1129 
       
  1130            
       
  1131             break;
       
  1132             }
       
  1133         case R_MMSVIEWER_OPTIONSMENU:
       
  1134             {
       
  1135             
       
  1136             if ( iViewerState == EReseted )
       
  1137                 {
       
  1138                 //Exit is the last item... leave it there.
       
  1139                 aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems - 2 );
       
  1140                 return;
       
  1141                 }
       
  1142                     
       
  1143             TInt focusedControl = FocusedControlId( ); 
       
  1144             if ( !IsOwnMessage( ) )
       
  1145                 {    
       
  1146                 if( (FocusedControlId( ) == EMsgComponentIdFrom) && ( ( iMtm->Sender( ) ).Length() ) )
       
  1147                     {
       
  1148                     iFindItemMenu->SetSenderHighlightStatus( ETrue );
       
  1149                     iFindItemMenu->SetSenderDisplayText( TMmsGenUtils::PureAddress( iMtm->Sender( ) ) );                
       
  1150                     }
       
  1151 	            else
       
  1152 	     	        {
       
  1153                     iFindItemMenu->SetSenderHighlightStatus( EFalse );
       
  1154 		            }
       
  1155                 }
       
  1156  			iFindItemMenu->AddItemFindMenuL( 
       
  1157                 ( focusedControl == EMsgComponentIdBody ) ? iView->ItemFinder( ) : 0,
       
  1158                 aMenuPane, 
       
  1159                 EFindItemMenuPlaceHolder,
       
  1160                 TMmsGenUtils::PureAddress( iMtm->Sender( ) ),
       
  1161                 iHeader->Alias( ) && !iHeader->IsRemoteAlias( ) ? ETrue : EFalse, //"Is sender known"
       
  1162                 EFalse );
       
  1163                 
       
  1164             const TMsvEntry& context = Document( )->Entry( );
       
  1165             // local variation for MMS Delivery Status dialog feature
       
  1166             if (! (     iSupportedFeatures & EMmsFeatureDeliveryStatus  
       
  1167                     && ( ( context.iMtmData2 & KMmsDeliveryStatusMask) != KMmsDeliveryStatusNotRequested ) ) )
       
  1168                 {
       
  1169                 aMenuPane->DeleteMenuItem(EMmsViewerDeliveryStatus);
       
  1170                 }
       
  1171 
       
  1172             if ( iSmilModel->SlideCount( ) > iMaxForwardSlideCount )
       
  1173                 {
       
  1174                 aMenuPane->SetItemDimmed( EMmsViewerForward, ETrue );
       
  1175                 }
       
  1176                                 
       
  1177             if ( !  (    Document( )->SmilType( ) == EMmsSmil  
       
  1178                     &&   focusedControl == EMsgComponentIdImage
       
  1179                     &&   iImage 
       
  1180                     &&   MediaInitializedL( iImage ) ) )
       
  1181                 {
       
  1182                 aMenuPane->SetItemDimmed( EMmsViewerViewImage, ETrue );
       
  1183                 }
       
  1184             if ( ! (    focusedControl == EMsgComponentIdAudio
       
  1185                     &&  iAudio
       
  1186                     &&  MediaInitializedL( iAudio ) ) )
       
  1187                 {
       
  1188                 aMenuPane->SetItemDimmed( EMmsViewerPlayAudio, ETrue );
       
  1189                 }
       
  1190             if ( ! (    focusedControl == EMsgComponentIdVideo
       
  1191                     &&  iVideo
       
  1192                     &&  MediaInitializedL( iVideo ) ) )
       
  1193                 {
       
  1194                 aMenuPane->SetItemDimmed( EMmsViewerPlayVideo, ETrue );
       
  1195                 }
       
  1196 #ifdef RD_SVGT_IN_MESSAGING              
       
  1197             if ( !  ( Document( )->SmilType( ) == EMmsSmil  
       
  1198                     &&  focusedControl == EMsgComponentIdSvg
       
  1199                     &&  iSvgt
       
  1200                     &&  MediaInitializedL( iSvgt ) ) )
       
  1201                 {
       
  1202                 aMenuPane->SetItemDimmed( EMmsViewerPlaySvg, ETrue );
       
  1203                 }                
       
  1204 #endif                 
       
  1205             if ( ! (    Document( )->SmilType( ) == EMmsSmil 
       
  1206                    &&   (  focusedControl == EMsgComponentIdBody 
       
  1207                         || focusedControl == EMsgComponentIdImage 
       
  1208                         || focusedControl == EMsgComponentIdAudio 
       
  1209 #ifdef RD_SVGT_IN_MESSAGING              
       
  1210                         ||  focusedControl == EMsgComponentIdSvg
       
  1211 #endif
       
  1212                         || focusedControl == EMsgComponentIdVideo ) ) )
       
  1213                 {
       
  1214                 aMenuPane->SetItemDimmed( EMmsViewerSaveObject, ETrue );
       
  1215                 }
       
  1216                 
       
  1217             if (    ! ( iSupportedFeatures & EMmsFeatureUpload )
       
  1218                 ||  !iUploadServices.Count( ) )
       
  1219                 {
       
  1220                 aMenuPane->SetItemDimmed( EMmsViewerUpload, ETrue );
       
  1221                 }            
       
  1222                             
       
  1223             // Set help menu-item visibility according featureManager
       
  1224             if ( !( iSupportedFeatures & EMmsFeatureHelp ) )
       
  1225                 {
       
  1226                 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1227                 }
       
  1228             if ( !Document( )->SmilList( )->Count( ) )
       
  1229                 {
       
  1230                 aMenuPane->SetItemDimmed( EMmsViewerShowMessage, ETrue );
       
  1231                 aMenuPane->SetItemDimmed( EMmsViewerShowPresentation, ETrue );
       
  1232                 }
       
  1233             else 
       
  1234                 {
       
  1235                 if ( Document( )->SmilType( ) != EMmsSmil )
       
  1236                     {
       
  1237                     aMenuPane->SetItemDimmed( EMmsViewerShowMessage, ETrue );
       
  1238                     }
       
  1239                 if (    Document( )->SmilType( ) == EMmsSmil 
       
  1240                     ||  (   Document( )->SmilType( ) != EMmsSmil
       
  1241 			            &&  focusedControl != EMsgComponentIdImage ) )
       
  1242                     {
       
  1243                     aMenuPane->SetItemDimmed( EMmsViewerShowPresentation, ETrue );
       
  1244     				}
       
  1245 				}
       
  1246 
       
  1247             if ( !ShowReplyMenu( ) )
       
  1248                 {
       
  1249                 aMenuPane->SetItemDimmed( EMmsViewerReplyMenu, ETrue );
       
  1250                 }
       
  1251                 
       
  1252             if ( Document( )->ObjectList( )->Count( ) == 0 &&
       
  1253                 Document( )->AttachmentList( )->Count( ) == 0 )
       
  1254                 {
       
  1255                 aMenuPane->SetItemDimmed( EMmsViewerObjects, ETrue );
       
  1256                 }    
       
  1257             break;
       
  1258             }
       
  1259         case R_MMSVIEWER_REPLY_SUBMENU:
       
  1260             {
       
  1261             if (   IsOwnMessage( )
       
  1262                 || !HasSender( ) )
       
  1263                 {
       
  1264                 aMenuPane->SetItemDimmed( EMmsViewerReplyToSender, ETrue );
       
  1265                 }
       
  1266             if ( !ShowReplyToAll( ) )
       
  1267                 {
       
  1268                 aMenuPane->SetItemDimmed( EMmsViewerReplyToAll, ETrue );
       
  1269                 }
       
  1270             if (   !( iSupportedFeatures & EMmsFeatureAudioMessaging )
       
  1271                 || IsOwnMessage( )
       
  1272                 || !HasSender( )
       
  1273                 ||  iSupportedFeatures & EMmsFeatureRestrictedReply )
       
  1274                 {
       
  1275                 aMenuPane->SetItemDimmed( EMmsViewerReplyViaAudio, ETrue );
       
  1276                 }
       
  1277                 
       
  1278             if ( IsOwnMessage( ) || 
       
  1279                  iHeader->SenderType( ) != EMuiuAddressTypeEmail ||
       
  1280                 iSupportedFeatures & EMmsFeatureRestrictedReply ||
       
  1281                  MsvUiServiceUtilitiesInternal::DefaultServiceForMTML(
       
  1282                     Document( )->Session( ),
       
  1283                     KSenduiMtmSmtpUid,
       
  1284                     ETrue )
       
  1285                     == KMsvUnknownServiceIndexEntryId )
       
  1286                 {
       
  1287                 // "Reply via e-mail" feature
       
  1288                 aMenuPane->SetItemDimmed( EMmsViewerReplyViaMail, ETrue );
       
  1289                 }
       
  1290             break;
       
  1291             }
       
  1292         case R_MMSVIEWER_ZOOM_SUBMENU:
       
  1293             {
       
  1294             TInt zoomLevel = KErrGeneral;
       
  1295             iMsgEditorAppUiExtension->
       
  1296                 iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, zoomLevel );
       
  1297             switch ( zoomLevel )
       
  1298                 {
       
  1299                 case EAknUiZoomAutomatic:
       
  1300                     aMenuPane->SetItemButtonState( EMsgDispSizeAutomatic,
       
  1301                                      EEikMenuItemSymbolOn );
       
  1302                     break;
       
  1303                 case EAknUiZoomNormal:
       
  1304                     aMenuPane->SetItemButtonState( EMsgDispSizeNormal,
       
  1305                                      EEikMenuItemSymbolOn );
       
  1306                     break;
       
  1307                 case EAknUiZoomSmall:
       
  1308                     aMenuPane->SetItemButtonState( EMsgDispSizeSmall,
       
  1309                                      EEikMenuItemSymbolOn );
       
  1310                     break;
       
  1311                 case EAknUiZoomLarge:
       
  1312                     aMenuPane->SetItemButtonState( EMsgDispSizeLarge,
       
  1313                                      EEikMenuItemSymbolOn );
       
  1314                     break;
       
  1315                 default:
       
  1316                     break;
       
  1317                 }
       
  1318             }
       
  1319             break;
       
  1320         default: // we are in FindItem submenu
       
  1321             {
       
  1322             // this does nothing if we're not, so this is safe
       
  1323 			iFindItemMenu->UpdateItemFinderMenuL( aMenuId, aMenuPane );
       
  1324             break;
       
  1325             }
       
  1326         }
       
  1327     }
       
  1328 
       
  1329 
       
  1330 // ---------------------------------------------------------
       
  1331 // CMmsViewerAppUi::UploadL
       
  1332 // ---------------------------------------------------------
       
  1333 //
       
  1334 void CMmsViewerAppUi::UploadL( )
       
  1335     {
       
  1336     TInt count = iUploadServices.Count( );
       
  1337     
       
  1338     TInt selectedIndex = 0;
       
  1339     CAknListQueryDialog* dlg = new ( ELeave )
       
  1340         CAknListQueryDialog( &selectedIndex );
       
  1341     dlg->PrepareLC( R_MMSVIEWER_UPLOAD_LIST_QUERY );
       
  1342 
       
  1343     // Populate list query array
       
  1344     CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( 4 );
       
  1345     CleanupStack::PushL( array );
       
  1346     for ( TInt i = 0; i < count; i++ )
       
  1347         {
       
  1348         array->AppendL( iUploadServices[ i ]->ServiceMenuName( ) );
       
  1349         }
       
  1350     dlg->SetItemTextArray( array );
       
  1351     CleanupStack::Pop( array ); 
       
  1352 
       
  1353     if ( dlg->RunLD( ) )
       
  1354 	    {
       
  1355         CSendingServiceInfo* info = iUploadServices[ selectedIndex ];
       
  1356         TMsgUploadParameters uploadParams;
       
  1357         uploadParams.iDirect = ( info->ServiceProviderId( ) == KMmsDirectUpload );
       
  1358         uploadParams.iRealAddress = info->ServiceAddress( );
       
  1359         uploadParams.iAlias = info->ServiceName( );
       
  1360 
       
  1361         // Pack upload parameters
       
  1362         TPckgBuf<TMsgUploadParameters> param( uploadParams );
       
  1363 
       
  1364         MediaStop( );
       
  1365         ResetViewL( );
       
  1366 
       
  1367         //These are not used! They just have to be there.
       
  1368         CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1369         CleanupStack::PushL( selection );
       
  1370 
       
  1371         CAknInputBlock::NewLC( );
       
  1372         CMuiuOperationWait* wait =
       
  1373             CMuiuOperationWait::NewLC( EActivePriorityWsEvents + 10 );
       
  1374 
       
  1375         CMsvOperation* oper = Document( )->MtmUiL( ).InvokeAsyncFunctionL(
       
  1376             KMtmUiFunctionUpload,
       
  1377             *selection,
       
  1378             wait->iStatus,
       
  1379             param );
       
  1380 
       
  1381         CleanupStack::PushL( oper );
       
  1382 
       
  1383         wait->Start( );
       
  1384 
       
  1385         CleanupStack::PopAndDestroy( 4, selection );  // absorber, wait, oper, selection
       
  1386         Exit( EAknSoftkeyClose );
       
  1387 	    }
       
  1388     }
       
  1389 
       
  1390 
       
  1391 // ---------------------------------------------------------
       
  1392 // CMmsViewerAppUi::ProcessCommandL
       
  1393 // ---------------------------------------------------------
       
  1394 //
       
  1395 void CMmsViewerAppUi::ProcessCommandL( TInt aCommand )
       
  1396     {    
       
  1397     if (    aCommand == EAknSoftkeyOptions
       
  1398         &&  iViewerState == EBusy)
       
  1399         {
       
  1400         LOGTEXT(_L8("CMmsViewerAppUi::ProcessCommandL returns immediately..."));
       
  1401         return;
       
  1402         }            
       
  1403     CAknAppUi::ProcessCommandL( aCommand );
       
  1404     }
       
  1405 
       
  1406 // ---------------------------------------------------------
       
  1407 // CMmsViewerAppUi::HandleCommandL
       
  1408 // ---------------------------------------------------------
       
  1409 //
       
  1410 void CMmsViewerAppUi::HandleCommandL( TInt aCommand )
       
  1411     {
       
  1412 #ifdef USE_LOGGER
       
  1413     LOGTEXT2(_L16("CMmsViewerAppUi::HandleCommandL in. Command %d"), aCommand );
       
  1414     TRAPD(error, DoHandleCommandL( aCommand ) );
       
  1415     LOGTEXT2(_L16("CMmsViewerAppUi::HandleCommandL %d"), error );
       
  1416     User::LeaveIfError( error );
       
  1417 #else
       
  1418     DoHandleCommandL( aCommand );
       
  1419 #endif
       
  1420     }
       
  1421 
       
  1422 
       
  1423 // ---------------------------------------------------------
       
  1424 // CMmsViewerAppUi::DoHandleCommandL
       
  1425 // ---------------------------------------------------------
       
  1426 //
       
  1427 void CMmsViewerAppUi::DoHandleCommandL( TInt aCommand )
       
  1428     {
       
  1429     if ( !IsLaunched() )
       
  1430         {
       
  1431         if ( aCommand == EEikCmdExit )
       
  1432             {
       
  1433             LOGTEXT(_L8("CMmsViewerAppUi::DoHandleCommandL Setting iViewerFlags |= EViewerExiting"));
       
  1434             iViewerFlags |= EViewerExiting;
       
  1435             }
       
  1436         return;
       
  1437         }
       
  1438 
       
  1439     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) )
       
  1440 		{
       
  1441 		iFindItemMenu->HandleItemFinderCommandL( aCommand );
       
  1442 		return;
       
  1443 		}		
       
  1444     //MediaStop( );
       
  1445     switch ( aCommand )
       
  1446         {
       
  1447         case EMmsViewerShowPresentation:
       
  1448         case EMmsViewerShowMessage:
       
  1449             DoShowPresentationL( );
       
  1450             break;
       
  1451         case EMmsViewerForward:
       
  1452             if ( !ShowOutOfDiskNoteIfBelowCriticalLevelL(
       
  1453                  Document( )->MessageSize( ) ) )
       
  1454                 {
       
  1455                 DoForwardL( );
       
  1456                 }
       
  1457             break;
       
  1458         case EMmsViewerDelete:
       
  1459             DoDeleteAndExitL( );
       
  1460             break;
       
  1461         case EMmsViewerViewImage:
       
  1462             MediaPlayL( iImage );
       
  1463             break;
       
  1464         case EMmsViewerPlayAudio:
       
  1465             MediaPlayL( iAudio );
       
  1466             break;
       
  1467         case EMmsViewerPlayVideo:
       
  1468             MediaPlayL( iVideo );
       
  1469             break;
       
  1470 #ifdef RD_SVGT_IN_MESSAGING
       
  1471         case EMmsViewerPlaySvg:
       
  1472             MediaPlayL( iSvgt );            
       
  1473             break;
       
  1474 #endif            
       
  1475         case EMmsViewerObjects:
       
  1476             DoObjectsL( );
       
  1477             break;
       
  1478         case EMmsViewerMessageInfo:
       
  1479             DoMessageInfoL( );
       
  1480             break;
       
  1481         case EMmsViewerDeliveryStatus:
       
  1482             OpenDeliveryPopupL( );    
       
  1483             break;
       
  1484         case EMmsViewerMove:
       
  1485             DoMoveMessageL( );
       
  1486             break;
       
  1487         case EMmsViewerReplyToSender:
       
  1488             if ( !ShowOutOfDiskNoteIfBelowCriticalLevelL(
       
  1489                  KReplyToSenderSize ) )
       
  1490                 {
       
  1491                 DoReplyL( ETrue );
       
  1492                 }
       
  1493             break;
       
  1494         case EMmsViewerReplyToAll:
       
  1495             if ( !ShowOutOfDiskNoteIfBelowCriticalLevelL(
       
  1496                  KReplyToAllSize ) )
       
  1497                 {
       
  1498                 DoReplyL( EFalse );
       
  1499                 }
       
  1500             break;
       
  1501         case EMmsViewerReplyViaAudio:
       
  1502         case EMmsViewerReplyViaMail:
       
  1503             if ( !ShowOutOfDiskNoteIfBelowCriticalLevelL(
       
  1504                  KReplyToAllSize ) )
       
  1505                 {
       
  1506                 DoReplyViaL( aCommand );
       
  1507                 }
       
  1508             break;
       
  1509 
       
  1510         case EMmsViewerSoftStopVideo:
       
  1511             MediaStop(iVideo);
       
  1512             break;
       
  1513 #ifdef RD_SVGT_IN_MESSAGING            
       
  1514         case EMmsViewerSoftStopSvg:
       
  1515             MediaStop( iSvgt );
       
  1516             break;
       
  1517 #endif            
       
  1518                         
       
  1519         case EMmsViewerSaveObject:
       
  1520             SaveObjectL( );
       
  1521             break;   
       
  1522                      
       
  1523         case EMmsViewerUpload:
       
  1524             {
       
  1525             UploadL( );
       
  1526             break;
       
  1527             }
       
  1528 
       
  1529         case EMmsViewerSoftStopAudio:
       
  1530             MediaStop(iAudio);
       
  1531             break;
       
  1532         case EMsgDispSizeAutomatic:
       
  1533         case EMsgDispSizeLarge:
       
  1534         case EMsgDispSizeNormal:
       
  1535         case EMsgDispSizeSmall:
       
  1536             HandleLocalZoomChangeL( (TMsgCommonCommands)aCommand );
       
  1537             break;
       
  1538         case EAknCmdHelp:
       
  1539             LaunchHelpL( );
       
  1540             break;
       
  1541 
       
  1542         case EAknSoftkeyBack:
       
  1543             MediaStop( );
       
  1544             Exit( EAknSoftkeyClose );                
       
  1545             break;
       
  1546         case EEikCmdExit:
       
  1547             {
       
  1548             DoMsgSaveExitL( );
       
  1549             break;
       
  1550             }
       
  1551         default:
       
  1552             break;
       
  1553         }
       
  1554     }
       
  1555 
       
  1556 // ---------------------------------------------------------
       
  1557 // CMmsViewerAppUi::HandleKeyEventL
       
  1558 // ---------------------------------------------------------
       
  1559 //
       
  1560 TKeyResponse CMmsViewerAppUi::HandleKeyEventL(
       
  1561     const TKeyEvent& aKeyEvent,
       
  1562     TEventCode aType )
       
  1563     {
       
  1564     if ( !IsLaunched( ) )
       
  1565         {
       
  1566         return EKeyWasNotConsumed;
       
  1567         }
       
  1568     if ( aType != EEventKey )
       
  1569         {
       
  1570         return EKeyWasNotConsumed;
       
  1571         }
       
  1572                 
       
  1573     if (    iViewerState == EBusy
       
  1574         ||  iViewerState == EReseted )
       
  1575         {
       
  1576         return EKeyWasConsumed;
       
  1577         }
       
  1578     switch ( aKeyEvent.iCode )
       
  1579         {
       
  1580         case EKeyLeftArrow:
       
  1581             {
       
  1582             if (    iVolumeDecorator
       
  1583                 &&  iNaviPane->Top( ) == iVolumeDecorator )
       
  1584                 {
       
  1585                 if( !( iSupportedFeatures & EMmsFeatureSVK ) )
       
  1586                     {
       
  1587                     ChangeVolumeL( -1, ETrue );                
       
  1588                     }
       
  1589                 else if ( IsNextMessageAvailableL( EFalse ) )
       
  1590                     {
       
  1591                     // playing audio/video is stopped by destructor
       
  1592                     NextMessageL( EFalse );
       
  1593                     }	
       
  1594                 }
       
  1595             else if (   iNaviDecorator
       
  1596                     &&  iNaviPane->Top( ) == iNaviDecorator )
       
  1597                 {
       
  1598                 if ( IsNextMessageAvailableL( EFalse ) )
       
  1599                     {
       
  1600                     NextMessageL( EFalse );
       
  1601                     }
       
  1602                 }
       
  1603             }
       
  1604             break;
       
  1605         case EKeyRightArrow:
       
  1606             {
       
  1607             if (    iVolumeDecorator
       
  1608                 &&  iNaviPane->Top( ) == iVolumeDecorator )
       
  1609                 {
       
  1610                 if( !( iSupportedFeatures & EMmsFeatureSVK ) )
       
  1611                     {
       
  1612                     ChangeVolumeL( +1, ETrue );
       
  1613                     }
       
  1614                 else if ( IsNextMessageAvailableL( ETrue ) )
       
  1615                     {
       
  1616                     // playing audio/video is stopped by destructor
       
  1617                     NextMessageL( ETrue );
       
  1618                     }
       
  1619                 }
       
  1620             else if (   iNaviDecorator
       
  1621                     &&  iNaviPane->Top( ) == iNaviDecorator )
       
  1622                 {
       
  1623                 if ( IsNextMessageAvailableL( ETrue ) )
       
  1624                     {
       
  1625                     NextMessageL( ETrue );
       
  1626                     }
       
  1627                 }
       
  1628             }
       
  1629             break;
       
  1630         case EKeyDevice3:       //Selection key
       
  1631         case EKeyEnter:         //Enter Key
       
  1632             {           
       
  1633             TInt focusedControl = FocusedControlId( );
       
  1634             CMsgMediaControl* control = MediaControlById(focusedControl);
       
  1635             if (control)
       
  1636                 {
       
  1637                 if ( MediaCanStop( control ) )
       
  1638                     {
       
  1639                     MediaStop(control);
       
  1640                     }
       
  1641                 else
       
  1642                     {
       
  1643                     MediaOpenL(control);
       
  1644                     }
       
  1645                 }
       
  1646             else if( focusedControl == EMsgComponentIdAttachment ) 
       
  1647                 {
       
  1648             	DoObjectsL( );
       
  1649                 }
       
  1650             else if (    Document( )->SmilType( ) != EMmsSmil
       
  1651                     &&  focusedControl == EMsgComponentIdImage )
       
  1652                 {
       
  1653                 DoShowPresentationL( );
       
  1654                 }
       
  1655             else if ( iViewerState == ENormal )
       
  1656                 {
       
  1657                 MenuBar( )->SetMenuTitleResourceId( R_MMSVIEWER_SELECTMENU );
       
  1658                 MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1659                 TRAP_IGNORE( MenuBar( )->TryDisplayMenuBarL( ) );
       
  1660                 MenuBar( )->SetMenuTitleResourceId( R_MMSVIEWER_MENU );
       
  1661                 MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);              
       
  1662                 }
       
  1663             break;
       
  1664             }
       
  1665         case EKeyYes:   //Send key
       
  1666             DoHandleSendKeyL( );
       
  1667             break;
       
  1668         case EKeyBackspace: // clear key
       
  1669             if ( !MediaIsRunning( iAudio ) &&
       
  1670                  !MediaIsRunning( iVideo ) )
       
  1671                 {
       
  1672                 DoDeleteAndExitL( );
       
  1673                 }
       
  1674             break;
       
  1675         case EKeyNo: // End key
       
  1676             {
       
  1677             LOGTEXT(_L8("CMmsViewerAppUi::HandleKeyEventL EKeyNo"));
       
  1678             if ( MediaIsRunning( iAudio ) )
       
  1679                 {
       
  1680                 MediaStop(iAudio);
       
  1681                 }
       
  1682             else if ( MediaIsRunning( iVideo ) ) 
       
  1683                 {
       
  1684                 MediaStop(iVideo);
       
  1685                 }
       
  1686             // fall through
       
  1687             }
       
  1688         default:
       
  1689             // - Audio countdown & audio play cancelled on
       
  1690             //   HandleViewDeactivation event!!!
       
  1691             //
       
  1692             //Power key
       
  1693             //Apps key
       
  1694             //End key
       
  1695             //Up key
       
  1696             //Down key
       
  1697             //Numeric keys
       
  1698             //Clear key
       
  1699             //Shift key
       
  1700             return iView->OfferKeyEventL( aKeyEvent, aType );
       
  1701         }
       
  1702     return EKeyWasConsumed;
       
  1703     }
       
  1704 
       
  1705 // ---------------------------------------------------------
       
  1706 // CMmsViewerAppUi::HandleWsEventL
       
  1707 // ---------------------------------------------------------
       
  1708 //
       
  1709 void CMmsViewerAppUi::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
  1710     {
       
  1711   	TInt type = aEvent.Type( );
       
  1712     switch ( type )
       
  1713         {
       
  1714         case EEventFocusGroupChanged:
       
  1715             {
       
  1716             if ( !iIsStopPlaybackWgId )
       
  1717                 {
       
  1718                 ResolveCurrentWgIdL( );
       
  1719                 
       
  1720                 // Stop only if temporary change e.g. a waiting note etc.
       
  1721                 if ( iIsStopPlaybackWgId )
       
  1722               	    {
       
  1723                     MediaStop(iAudio);
       
  1724                     MediaStop(iVideo);
       
  1725                     StopAnimation( );
       
  1726               	    }
       
  1727                 }
       
  1728           	// else - no need to stop
       
  1729             break;
       
  1730             }
       
  1731         case EEventFocusGained:
       
  1732             {
       
  1733             if ( iIsStopPlaybackWgId )
       
  1734                 {
       
  1735                 iIsStopPlaybackWgId = EFalse;
       
  1736                 StartAnimationL( );
       
  1737                 };
       
  1738             break;
       
  1739             }
       
  1740         // case EEventFocusLost:
       
  1741         default:
       
  1742             break;
       
  1743         }
       
  1744     CMsgEditorAppUi::HandleWsEventL(aEvent, aDestination);
       
  1745     }
       
  1746 
       
  1747 // ---------------------------------------------------------
       
  1748 // CMmsViewerAppUi::CreateCustomControlL
       
  1749 // ---------------------------------------------------------
       
  1750 //
       
  1751 CMsgBaseControl* CMmsViewerAppUi::CreateCustomControlL(
       
  1752     TInt /*aControlType*/ )
       
  1753     {
       
  1754     return NULL;
       
  1755     }
       
  1756 
       
  1757 // ---------------------------------------------------------
       
  1758 // CMmsViewerAppUi::ShowInformationNoteL
       
  1759 // ---------------------------------------------------------
       
  1760 //
       
  1761 void CMmsViewerAppUi::ShowInformationNoteL( TInt aResourceId )
       
  1762     {
       
  1763     HBufC* string = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  1764     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
  1765     note->ExecuteLD( *string );
       
  1766     CleanupStack::PopAndDestroy( string ); 
       
  1767     }
       
  1768 
       
  1769 // ---------------------------------------------------------
       
  1770 // CMmsViewerAppUi::ShowErrorNoteL
       
  1771 // ---------------------------------------------------------
       
  1772 //
       
  1773 void CMmsViewerAppUi::ShowErrorNoteL( TInt aResourceId )
       
  1774     {
       
  1775     HBufC* string = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  1776     CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue );
       
  1777     note->ExecuteLD( *string );
       
  1778     CleanupStack::PopAndDestroy( string ); 
       
  1779     }
       
  1780 
       
  1781 
       
  1782 // ---------------------------------------------------------
       
  1783 // CMmsViewerAppUi::ShowConfirmationQueryL
       
  1784 // ---------------------------------------------------------
       
  1785 //
       
  1786 TInt CMmsViewerAppUi::ShowConfirmationQueryL(   TInt aResourceId ) const
       
  1787     {
       
  1788     HBufC* queryString = StringLoader::LoadLC(
       
  1789         aResourceId,
       
  1790         iCoeEnv );
       
  1791     CAknQueryDialog* dlg = CAknQueryDialog::NewL( );
       
  1792     TInt retVal = dlg->ExecuteLD( R_MMSVIEWER_CONFIRMATION_QUERY, *queryString );
       
  1793     CleanupStack::PopAndDestroy( queryString );
       
  1794     return retVal;
       
  1795     }
       
  1796 
       
  1797 
       
  1798 // ---------------------------------------------------------
       
  1799 // CMmsViewerAppUi::ShowConfirmationQueryL
       
  1800 // ---------------------------------------------------------
       
  1801 //
       
  1802 TInt CMmsViewerAppUi::ShowConfirmationQueryL(   TInt            aResourceId,
       
  1803                                                 const TDesC&    aString) const
       
  1804     {
       
  1805     HBufC* queryString = StringLoader::LoadLC(
       
  1806         aResourceId,
       
  1807         aString,
       
  1808         iCoeEnv );
       
  1809     CAknQueryDialog* dlg = CAknQueryDialog::NewL( );
       
  1810     TInt retVal = dlg->ExecuteLD( R_MMSVIEWER_CONFIRMATION_QUERY, *queryString );
       
  1811     CleanupStack::PopAndDestroy( queryString );
       
  1812     return retVal;
       
  1813     }
       
  1814 
       
  1815 // ---------------------------------------------------------
       
  1816 // ShowGuidedModeConfirmationQueryL
       
  1817 // ---------------------------------------------------------
       
  1818 //
       
  1819 TInt CMmsViewerAppUi::ShowGuidedModeConfirmationQueryL( TInt aResourceID )
       
  1820     {
       
  1821     TInt retVal = EFalse;
       
  1822     if ( iViewerFlags & EShowGuidedConf )
       
  1823         {
       
  1824         retVal = ShowConfirmationQueryL( aResourceID );
       
  1825         if ( retVal )
       
  1826             {
       
  1827             iViewerFlags &= ~EShowGuidedConf;
       
  1828             }
       
  1829 
       
  1830         }
       
  1831     else
       
  1832         {
       
  1833         retVal = ( Document( )->CreationMode( ) != EMmsCreationModeRestricted );
       
  1834         }
       
  1835     return retVal;
       
  1836     }
       
  1837 
       
  1838 // ---------------------------------------------------------
       
  1839 // CMmsViewerAppUi::ShowOutOfDiskNoteIfBelowCriticalLevelL
       
  1840 // ---------------------------------------------------------
       
  1841 //
       
  1842 TBool CMmsViewerAppUi::ShowOutOfDiskNoteIfBelowCriticalLevelL( TInt aSize )
       
  1843     {
       
  1844     //Check whether there is enough free disk
       
  1845     //to create a copy of the message.
       
  1846     if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(
       
  1847         Document( )->Session( ),
       
  1848         aSize ) )
       
  1849         {
       
  1850         CErrorUI* errorUI = CErrorUI::NewLC( *iCoeEnv );
       
  1851         errorUI->ShowGlobalErrorNoteL( KErrDiskFull );
       
  1852         //Returns TInt! (ETrue if note was displayed, EFalse otherwise)
       
  1853         //...ignored...
       
  1854         CleanupStack::PopAndDestroy( errorUI ); 
       
  1855         return ETrue;
       
  1856         }
       
  1857     else
       
  1858         {
       
  1859         return EFalse;
       
  1860         }
       
  1861     }
       
  1862 
       
  1863 
       
  1864 // ---------------------------------------------------------
       
  1865 // CMmsViewerAppUi::DoReplyL
       
  1866 // ---------------------------------------------------------
       
  1867 //
       
  1868 void CMmsViewerAppUi::DoReplyL( TBool aReplyToSender )
       
  1869     {
       
  1870     iViewerState = EBusy;
       
  1871     TRAPD ( error,
       
  1872         {
       
  1873         if ( !(iEditorBaseFeatures & EStayInViewerAfterReply )) 
       
  1874             {
       
  1875         	MediaStop( );
       
  1876             ResetViewL( );
       
  1877             }
       
  1878 
       
  1879         if ( iToolbar )
       
  1880             {
       
  1881             iToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  1882             }
       
  1883         
       
  1884         // Enable Dialer as MMS Settings dialog may be launched
       
  1885         iAvkonAppUi->SetKeyEventFlags( 0x00 );	    
       
  1886     
       
  1887         if ( aReplyToSender )
       
  1888             {
       
  1889             ReplyL( KNewMessageFolder );  //Draft
       
  1890             }
       
  1891         else
       
  1892             {
       
  1893             ReplyToAllL( KNewMessageFolder );  //Draft
       
  1894             }
       
  1895 
       
  1896         if (!(iEditorBaseFeatures & EStayInViewerAfterReply))
       
  1897             {
       
  1898             Exit( EAknSoftkeyClose );
       
  1899             }
       
  1900 
       
  1901         if ( iToolbar )
       
  1902             {
       
  1903             iToolbar->HideItemsAndDrawOnlyBackground( EFalse );
       
  1904             }
       
  1905         iViewerState = ENormal;
       
  1906         }); //end TRAP
       
  1907     if ( error )
       
  1908         {
       
  1909         LOGTEXT2(_L16("CMmsViewerAppUi::DoReplyL error %d"), error );
       
  1910         iViewerState = EReseted;
       
  1911         User::Leave( error );
       
  1912         }
       
  1913     }
       
  1914 
       
  1915 // ---------------------------------------------------------
       
  1916 // CMmsViewerAppUi::DoForwardL
       
  1917 // ---------------------------------------------------------
       
  1918 //
       
  1919 void CMmsViewerAppUi::DoForwardL( )
       
  1920     {
       
  1921     TInt resourceId = 0;
       
  1922     Document()->DataModel().FinalizeMediaParse();
       
  1923     if ( !CanForwardL( resourceId ) )
       
  1924         {
       
  1925         // This if cannot be combined with the above
       
  1926         // one. -> Else would not work correctly.
       
  1927         if ( resourceId )
       
  1928             {
       
  1929             ShowInformationNoteL( resourceId );
       
  1930             }
       
  1931         }
       
  1932     else
       
  1933         {
       
  1934         iViewerState = EBusy;
       
  1935         TRAPD ( error,
       
  1936             {
       
  1937             if ( !(iEditorBaseFeatures & EStayInViewerAfterReply )) 
       
  1938 	            {
       
  1939 	            MediaStop( );
       
  1940 	            ResetViewL( );
       
  1941 	            }
       
  1942             if ( iToolbar )
       
  1943                 {
       
  1944                 iToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  1945                 }
       
  1946 
       
  1947             // Enable Dialer as MMS Settings dialog may be launched
       
  1948             iAvkonAppUi->SetKeyEventFlags( 0x00 );	    
       
  1949             
       
  1950             if(iFindItemMenu)
       
  1951 			{
       
  1952 				delete iFindItemMenu;
       
  1953 				iFindItemMenu = NULL;
       
  1954 			}   
       
  1955     
       
  1956             ForwardL( KNewMessageFolder );  //Draft
       
  1957             
       
  1958             if ( !(iEditorBaseFeatures & EStayInViewerAfterReply )) 
       
  1959 	            {
       
  1960 	        	Exit( EAknSoftkeyClose );
       
  1961 	            }
       
  1962 
       
  1963             if ( iToolbar )
       
  1964                 {
       
  1965                 iToolbar->HideItemsAndDrawOnlyBackground( EFalse );
       
  1966                 }
       
  1967 	        iViewerState = ENormal;    
       
  1968             } ); //end TRAP
       
  1969         if ( error )
       
  1970             {
       
  1971             LOGTEXT2(_L16("CMmsViewerAppUi::DoForwardL error %d"), error );
       
  1972             iViewerState = EReseted;
       
  1973             User::Leave( error );
       
  1974             }
       
  1975         }
       
  1976     }
       
  1977 
       
  1978 // ---------------------------------------------------------
       
  1979 // CMmsViewerAppUi::CanForward
       
  1980 // ---------------------------------------------------------
       
  1981 //
       
  1982 TBool CMmsViewerAppUi::CanForwardL( TInt& aResourceId )
       
  1983     {
       
  1984 
       
  1985     TInt msgSize = Document( )->MessageSize( );
       
  1986     if ( msgSize > TInt32( Document( )->MaxMessageSize( ) ) )
       
  1987         {
       
  1988         // This could happen if MaxReceiveSize > MaxSendSize
       
  1989         aResourceId = R_MMSVIEWER_CANNOT_FW_BIG;
       
  1990         return EFalse;
       
  1991         }
       
  1992 
       
  1993     if ( Document( )->CreationMode( ) == EMmsCreationModeRestricted )
       
  1994         {
       
  1995         if ( Document( )->SmilType( ) != EMmsSmil ||
       
  1996              iViewerFlags & ESuspiciousSmil )
       
  1997             {
       
  1998             aResourceId = ( iMmsConformance->CreationModeUserChangeable( ) &&
       
  1999                             !iMmsConformance->CreationMode( ) ) ?
       
  2000                         R_MMSVIEWER_RMODE_CANNOT_FW_PRES:
       
  2001                         R_MMSVIEWER_CANNOT_FW_PRES;
       
  2002             return EFalse;
       
  2003             }
       
  2004         else if ( msgSize > KClassMaxSizeVideoRich )
       
  2005             {
       
  2006             aResourceId = R_MMSVIEWER_CANNOT_FW_BIG;
       
  2007             return EFalse;
       
  2008             }
       
  2009         }
       
  2010     TBool objectsOk = CanForwardObjectsL( aResourceId );
       
  2011     if ( objectsOk && Document( )->CreationMode( ) == EMmsCreationModeWarning )
       
  2012         {
       
  2013         if ( Document( )->SmilType( ) != EMmsSmil ||
       
  2014              iViewerFlags & ESuspiciousSmil )
       
  2015             {
       
  2016             aResourceId = 0;
       
  2017             return ShowGuidedModeConfirmationQueryL( R_MMSVIEWER_QUEST_GUIDED_PRESENTATION );
       
  2018             }
       
  2019         else if ( msgSize > KClassMaxSizeVideoRich )
       
  2020             {
       
  2021             aResourceId = 0;
       
  2022             return ShowGuidedModeConfirmationQueryL( R_MMSVIEWER_QUEST_GUIDED_INC_OBJ );
       
  2023             }
       
  2024         }
       
  2025     return objectsOk;
       
  2026     }
       
  2027 
       
  2028 // ---------------------------------------------------------
       
  2029 // CMmsViewerAppUi::CanForwardObjectsInListL
       
  2030 // ---------------------------------------------------------
       
  2031 //
       
  2032 void CMmsViewerAppUi::CanForwardObjectsInListL( 
       
  2033                                                 CUniObjectList* aObjectList, 
       
  2034                                                 TInt& aSdCount, 
       
  2035                                                 TInt& aFlCount, 
       
  2036                                                 TInt& aNonConfCount, 
       
  2037                                                 TInt& aNormalCount,
       
  2038                                                 TInt& aResourceId ) const
       
  2039     {
       
  2040     __ASSERT_ALWAYS( aObjectList, Panic( EMmsViewerNullPointer ) );
       
  2041     for ( TInt i = aObjectList->Count( ); --i >= 0; )
       
  2042         {
       
  2043         TUint32 confStatus( EMmsConfOk );
       
  2044 
       
  2045         CUniObject* obj = aObjectList->GetByIndex( i );
       
  2046         if (    obj
       
  2047             &&  obj->MediaInfo( ) )
       
  2048             {
       
  2049             TMmsConformance conf = iMmsConformance->MediaConformance( * ( obj->MediaInfo( ) ) );
       
  2050             confStatus = conf.iConfStatus;
       
  2051             }
       
  2052         if ( confStatus & EMmsConfNokTooBig )
       
  2053             {
       
  2054             aFlCount++;
       
  2055             continue;
       
  2056             }
       
  2057 
       
  2058         if ( confStatus == EMmsConfOk )
       
  2059             {
       
  2060             aNormalCount++;
       
  2061             continue;
       
  2062             }
       
  2063 
       
  2064         if ( iSupportedFeatures & EMmsFeatureDrmFull &&
       
  2065             obj->MediaInfo( )->Protection( ) & EFileProtSuperDistributable )
       
  2066             {
       
  2067             aSdCount++;
       
  2068             continue;
       
  2069             }
       
  2070 
       
  2071         if ( confStatus & EMmsConfNokDRM )
       
  2072             {
       
  2073             
       
  2074             
       
  2075             aResourceId = ( iSupportedFeatures & EMmsFeatureDrmFull )
       
  2076                 ? R_MMSVIEWER_CANNOT_FW_DRM
       
  2077                 : R_MMSVIEWER_CANNOT_FW_OBJECTS;
       
  2078 
       
  2079             if (    aResourceId == R_MMSVIEWER_CANNOT_FW_OBJECTS
       
  2080                 &&  (   iMmsConformance->CreationModeUserChangeable( ) &&
       
  2081                         !iMmsConformance->CreationMode( ) ) )
       
  2082                 {
       
  2083                 aResourceId = R_MMSVIEWER_RMODE_CANNOT_FW_OBJECTS;
       
  2084                 }
       
  2085             
       
  2086             aFlCount++;
       
  2087             continue;
       
  2088             }
       
  2089 
       
  2090         if ( confStatus != EMmsConfOk )
       
  2091             {
       
  2092             aNonConfCount++;
       
  2093             }
       
  2094         }
       
  2095     }
       
  2096 
       
  2097 
       
  2098 // ---------------------------------------------------------
       
  2099 // CMmsViewerAppUi::CanForwardObjects
       
  2100 // ---------------------------------------------------------
       
  2101 //
       
  2102 TBool CMmsViewerAppUi::CanForwardObjectsL( TInt& aResourceId )
       
  2103     {
       
  2104 
       
  2105     TInt normalCount = 0;
       
  2106     TInt sdCount = 0;
       
  2107     TInt deniedCount = 0;
       
  2108     TInt nonConfCount = 0;
       
  2109 
       
  2110     CanForwardObjectsInListL( Document( )->ObjectList( ), 
       
  2111                              sdCount, 
       
  2112                              deniedCount, 
       
  2113                              nonConfCount, 
       
  2114                              normalCount,
       
  2115                              aResourceId );
       
  2116     CanForwardObjectsInListL( Document( )->AttachmentList( ), 
       
  2117                              sdCount, 
       
  2118                              deniedCount, 
       
  2119                              nonConfCount, 
       
  2120                              normalCount,
       
  2121                              aResourceId );
       
  2122 
       
  2123     if ( deniedCount )
       
  2124         {
       
  2125         // resource ID set by CanForwardObjectsInListL
       
  2126         return EFalse;
       
  2127         }
       
  2128 
       
  2129     switch ( Document( )->CreationMode( ) )
       
  2130         {
       
  2131         case EMmsCreationModeRestricted:
       
  2132             if ( sdCount || nonConfCount )
       
  2133                 {
       
  2134                 aResourceId = ( iMmsConformance->CreationModeUserChangeable( ) &&
       
  2135                                 !iMmsConformance->CreationMode( ) ) ?
       
  2136                                 R_MMSVIEWER_RMODE_CANNOT_FW_OBJECTS:
       
  2137                                 R_MMSVIEWER_CANNOT_FW_OBJECTS;
       
  2138                 return EFalse;
       
  2139                 }
       
  2140             break;
       
  2141         case EMmsCreationModeWarning:
       
  2142             {
       
  2143             if ( nonConfCount == 1 )
       
  2144                 {
       
  2145                 aResourceId = 0;
       
  2146                 return ShowGuidedModeConfirmationQueryL( R_MMSVIEWER_QUEST_GUIDED_INC_OBJ );
       
  2147                 }
       
  2148             else if ( nonConfCount )
       
  2149                 {
       
  2150                 aResourceId = 0;
       
  2151                 return ShowGuidedModeConfirmationQueryL( R_MMSVIEWER_QUEST_GUIDED_INC_OBJS );
       
  2152                 }
       
  2153             }
       
  2154             // Fallthrough
       
  2155         case EMmsCreationModeFree:
       
  2156         default:
       
  2157             {
       
  2158             if ( sdCount )
       
  2159                 {
       
  2160                 // default singular 
       
  2161                 TInt everyWoRights = R_MMSVIEWER_QUEST_SEND_ONE_WO_RIGHTS;
       
  2162                 if ( sdCount > 1)
       
  2163                     {
       
  2164                     // plural
       
  2165                     everyWoRights = R_MMSVIEWER_QUEST_SEND_EVERY_WO_RIGHTS;
       
  2166                     }
       
  2167                 
       
  2168                 aResourceId = 0; //Make sure resource id is zero.
       
  2169                 return ( ShowConfirmationQueryL( normalCount
       
  2170                     ? R_MMSVIEWER_QUEST_SEND_SOME_WO_RIGHTS 
       
  2171                     :  everyWoRights ) );
       
  2172                 }
       
  2173             }
       
  2174             break;
       
  2175         }
       
  2176 
       
  2177     return ETrue;
       
  2178     }
       
  2179 
       
  2180 // ---------------------------------------------------------
       
  2181 // CMmsViewerAppUi::DoReplyViaL
       
  2182 // ---------------------------------------------------------
       
  2183 //
       
  2184 void CMmsViewerAppUi::DoReplyViaL( TInt aCase )
       
  2185     {
       
  2186     if ( iHeader->SenderType( ) != EMuiuAddressTypeNone )
       
  2187         {
       
  2188         TInt cleanupCount = 0;
       
  2189 
       
  2190 	    CMessageData* msgData = CMessageData::NewLC( );
       
  2191         cleanupCount++;
       
  2192 
       
  2193 	    // Add address and alias
       
  2194 	    // Basically alias is taken from TMsvEntry.iDetails (see MmsViewerHeader.cpp)
       
  2195 	    // Alias can be one of the following in precedence order
       
  2196 	    // 1) local alias
       
  2197 	    // 2) remote alias. Remote alias maybe available when message arrives from 
       
  2198 	    //    email address
       
  2199 	    // 3) sender's address 
       
  2200 	    const TPtrC sender = iMtm->Sender( );
       
  2201 	    
       
  2202 	    if ( sender != KNullDesC( ) )
       
  2203 	        {
       
  2204 	        if ( iHeader->Alias( ) )
       
  2205 	            {
       
  2206 	            //const TPtrC alias = iHeader->Alias( );
       
  2207 	            msgData->AppendToAddressL( TMmsGenUtils::PureAddress( sender ), *iHeader->Alias( ) );
       
  2208 	            }
       
  2209 	        else
       
  2210 	            {
       
  2211 	            msgData->AppendToAddressL( TMmsGenUtils::PureAddress( sender ) );
       
  2212 	            }
       
  2213 	        }
       
  2214 
       
  2215 		TUid mtmUid( KSenduiMtmAudioMessageUid );
       
  2216     	switch( aCase )
       
  2217     		{
       
  2218     		case EMmsViewerReplyViaAudio:
       
  2219     		    // default value OK
       
  2220                 break;
       
  2221     		case EMmsViewerReplyViaMail:
       
  2222     		    if ( iHeader->SenderType( ) == EMuiuAddressTypePhoneNumber )
       
  2223                     {
       
  2224                     __ASSERT_DEBUG( EFalse, Panic( EMmsViewerUnexpectedReplyEvent ) );
       
  2225                     }
       
  2226                 mtmUid = KSenduiMtmSmtpUid;
       
  2227                 break;
       
  2228             default:
       
  2229                 __ASSERT_DEBUG( EFalse, Panic( EMmsViewerUnexpectedReplyEvent ) );
       
  2230                 break;
       
  2231     		}
       
  2232 
       
  2233         // audio message has not subject field
       
  2234         if ( mtmUid == KSenduiMtmSmtpUid )
       
  2235             {
       
  2236             HBufC* prefixSubject = CreateSubjectPrefixStringL( iMtm->SubjectL( ), ETrue );
       
  2237             CleanupStack::PushL( prefixSubject ); 
       
  2238             if ( prefixSubject )
       
  2239                 {
       
  2240                 msgData->SetSubjectL( prefixSubject );
       
  2241                 }
       
  2242             else
       
  2243                 {
       
  2244 	            TPtrC subjectDes = iMtm->SubjectL( );
       
  2245 	            msgData->SetSubjectL( &subjectDes );
       
  2246                 }
       
  2247             CleanupStack::PopAndDestroy( prefixSubject ); 
       
  2248             }
       
  2249 
       
  2250         CSendUi* sendUi = CSendUi::NewLC( );
       
  2251         cleanupCount++;
       
  2252 
       
  2253         iViewerState = EBusy;
       
  2254         if ( iToolbar )
       
  2255             {
       
  2256             iToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  2257             }
       
  2258 
       
  2259         // Enable Dialer as MMS Settings dialog may be launched
       
  2260         iAvkonAppUi->SetKeyEventFlags( 0x00 );	    
       
  2261          
       
  2262         TRAPD ( error,
       
  2263             {
       
  2264             if ( !(iEditorBaseFeatures & EStayInViewerAfterReply ))
       
  2265             	{
       
  2266 	            MediaStop( );
       
  2267 	            ResetViewL( );	
       
  2268             	}
       
  2269             
       
  2270             sendUi->CreateAndSendMessageL(
       
  2271 	            mtmUid,
       
  2272 	            msgData);
       
  2273             
       
  2274             } ); //TRAPD
       
  2275 		CleanupStack::PopAndDestroy( cleanupCount );
       
  2276 
       
  2277         if ( error )
       
  2278             {
       
  2279             LOGTEXT2(_L16("CMmsViewerAppUi::DoReplyViaL error %d"), error );
       
  2280             iViewerState = EReseted;
       
  2281             User::Leave( error );
       
  2282             }
       
  2283 		else if ( !(iEditorBaseFeatures & EStayInViewerAfterReply )) 
       
  2284             {
       
  2285         	Exit( EAknSoftkeyClose );
       
  2286             }
       
  2287         if ( iToolbar )
       
  2288             {
       
  2289             iToolbar->HideItemsAndDrawOnlyBackground( EFalse );
       
  2290             }
       
  2291         iViewerState = ENormal;
       
  2292         }
       
  2293     }
       
  2294 
       
  2295 // ---------------------------------------------------------
       
  2296 // CMmsViewerAppUi::DoObjectsL
       
  2297 // ---------------------------------------------------------
       
  2298 //
       
  2299 void CMmsViewerAppUi::DoObjectsL( )
       
  2300     {
       
  2301     MediaClose( iVideo );
       
  2302     CUniObjectsModel& objectsViewModel =
       
  2303         static_cast<CUniObjectsModel&>( Document( )->AttachmentModel( ) );
       
  2304 
       
  2305     iViewerState = EBusy;
       
  2306 
       
  2307     if ( iToolbar )
       
  2308         {
       
  2309         iToolbar->HideItemsAndDrawOnlyBackground( ETrue );
       
  2310         }
       
  2311     // Enable Dialer 
       
  2312     iAvkonAppUi->SetKeyEventFlags( 0x00 );	    
       
  2313        
       
  2314     TUniObjectsDialogExitCmd dlgRet = EUniObjectsViewBack;
       
  2315 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2316     iNoTitlePaneUpdate = ETrue;
       
  2317 #endif
       
  2318 
       
  2319     iViewerFlags |= EInObjectsView;
       
  2320     TRAP_IGNORE (  CUniObjectsViewDialog::ObjectsViewL (
       
  2321                         CUniObjectsViewDialog::EViewer, 
       
  2322                     objectsViewModel,
       
  2323                         iEikonEnv,
       
  2324                         dlgRet, 
       
  2325                         Document()->DataModel( ) ) );
       
  2326 
       
  2327     iViewerFlags &= ~EInObjectsView;
       
  2328 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2329     iNoTitlePaneUpdate = EFalse;
       
  2330 #endif
       
  2331     objectsViewModel.Reset();
       
  2332 
       
  2333     if ( !IsAppShutterRunning() )
       
  2334         {
       
  2335         if ( iToolbar )
       
  2336             {
       
  2337             iToolbar->HideItemsAndDrawOnlyBackground( EFalse );
       
  2338             }
       
  2339         iViewerState = ENormal;
       
  2340         if ( dlgRet == EUniObjectsViewBack )
       
  2341             {
       
  2342             if ( iVideo )
       
  2343                 {
       
  2344                 CUniObject* videoObject = ObjectByBaseControl( *iVideo );
       
  2345                 if ( videoObject )
       
  2346                     {
       
  2347                     ReloadControlL( iVideo, *videoObject );
       
  2348                     }
       
  2349                 }
       
  2350             }
       
  2351                
       
  2352             InitNavipaneL( );
       
  2353            
       
  2354         }
       
  2355     }
       
  2356 
       
  2357 // ---------------------------------------------------------
       
  2358 // CMmsViewerAppUi::DoShowPresentationL
       
  2359 // ---------------------------------------------------------
       
  2360 //
       
  2361 void CMmsViewerAppUi::DoShowPresentationL( )
       
  2362     {
       
  2363     TMsvAttachmentId smilId = Document( )->SmilList( )->GetSmilAttachmentByIndex( 0 );
       
  2364 
       
  2365     if ( smilId )
       
  2366         {
       
  2367         MediaClose();
       
  2368 
       
  2369         // Finish parsing media objects
       
  2370         Document()->DataModel().FinalizeMediaParse();
       
  2371 
       
  2372         if ( Document( )->SmilType( ) == EMmsSmil &&
       
  2373             !( iViewerFlags & ESuspiciousSmil ) )
       
  2374             {
       
  2375             if ( !iSmilModel->ChangeLayoutL( Document( )->DataModel().Dom( ) ) )
       
  2376                 {
       
  2377                 Document( )->DataModel().SetDom( iSmilModel->ComposeL( ) );
       
  2378                 }
       
  2379 
       
  2380             if ( !iSmilModel->CorrectTimingL( Document( )->DataModel().Dom( ) ) )
       
  2381                 {
       
  2382                 Document( )->DataModel().SetDom( iSmilModel->ComposeL( ) );
       
  2383                 }
       
  2384             }
       
  2385                     
       
  2386         CUniObjectList* objectList = Document( )->ObjectList( );            
       
  2387         TInt expiredCount = 0;
       
  2388         TInt norightsCount = 0;
       
  2389         
       
  2390         iViewerFlags &= (~EPresentationHasAudio);
       
  2391         for ( TInt index = 0; index < objectList->Count( ); index++ )
       
  2392             {
       
  2393             CUniObject* current = objectList->GetByIndex( index );
       
  2394             TBool ignoreConsumed (EFalse );
       
  2395             TInt result = KErrNone;
       
  2396             if (    current
       
  2397                 &&  current->DrmInfo( ) )
       
  2398                 {
       
  2399                 result = current->DrmInfo( )->EvaluateRights( ignoreConsumed );
       
  2400                 }
       
  2401             
       
  2402             LOGTEXT2(_L16("CMmsViewerAppUi::DoShowPresentationL result %d"), result );
       
  2403             if ( result == DRMCommon::ENoRights )
       
  2404                 {
       
  2405                 norightsCount++;
       
  2406                 }
       
  2407             else if ( result == DRMCommon::ERightsExpired )
       
  2408                 {
       
  2409                 expiredCount++;
       
  2410                 }
       
  2411             else if ( current )
       
  2412                 {
       
  2413                 // Rights exist
       
  2414                 // Smil player needs info whether audio clip is present or (one of the) video clip(s)
       
  2415                 // has audio stream
       
  2416         		TMsgMediaType media = current->MediaType( );
       
  2417         		if ( media == EMsgMediaAudio )
       
  2418         			{
       
  2419         			iViewerFlags |= EPresentationHasAudio;
       
  2420         			}
       
  2421         		else if ( media == EMsgMediaVideo &&
       
  2422         				  static_cast<CMsgVideoInfo*>( current->MediaInfo() )->IsAudio() )
       
  2423         			{
       
  2424                         // existence of audio is checked after initialisation
       
  2425         			iViewerFlags |= EPresentationHasAudio;
       
  2426         			}
       
  2427                 }
       
  2428             }
       
  2429 
       
  2430         if ( norightsCount > 0 )
       
  2431             {
       
  2432             ShowInformationNoteL( R_QTN_DRM_NO_RIGHTS_FOR_SOME );
       
  2433             }
       
  2434         else if ( expiredCount > 0 )
       
  2435             {
       
  2436             ShowInformationNoteL( R_QTN_DRM_GEN_RIGHTS_EXP );
       
  2437             }
       
  2438             
       
  2439         delete iSvkEvents;
       
  2440         iSvkEvents = NULL;
       
  2441         //EJJN-7MY3SM::MMS viewer, ReTe, RM505_MeDo_ivalo_rnd: Panic with note 
       
  2442         //"Application closed: Multimedia" occurs after some operation.
       
  2443         
       
  2444         CEikButtonGroupContainer* cba1 = CEikButtonGroupContainer::Current();
       
  2445         if (cba1)
       
  2446             {
       
  2447              cba1->MakeVisible(EFalse);
       
  2448             }
       
  2449        
       
  2450         if ( iToolbar )
       
  2451             {
       
  2452             iToolbar->SetToolbarVisibility(EFalse, EFalse);
       
  2453             }
       
  2454         // Enable Dialer 
       
  2455         iAvkonAppUi->SetKeyEventFlags( 0x00 );	    
       
  2456  
       
  2457         CSmilPlayerDialog* dialog = CSmilPlayerDialog::NewL(
       
  2458                             Document( )->DataModel().Dom( ),
       
  2459                             Document( )->ObjectList( ),
       
  2460 			                KNullDesC( ),
       
  2461 			                EFalse,
       
  2462 			                iViewerFlags & EPresentationHasAudio );
       
  2463                             
       
  2464         iViewerState = EBusy;
       
  2465         TRAPD( error, dialog->ExecuteLD( ) );
       
  2466 
       
  2467         CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>( iEikonEnv->EikAppUi( ) );
       
  2468         TRAP_IGNORE( appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationAutomatic ) );            
       
  2469         
       
  2470         if ( iToolbar )
       
  2471             {
       
  2472             iToolbar->SetToolbarVisibility(ETrue, EFalse);
       
  2473             }
       
  2474 
       
  2475         iViewerState = ENormal;
       
  2476         
       
  2477         // re-calculate all pos and dimensions of layout's widgets, after
       
  2478         // status pane is set back to usual and fixed-toolbar is made visible.
       
  2479         HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
       
  2480         
       
  2481         if ( !IsAppShutterRunning() )
       
  2482             {
       
  2483             ReloadSlideL( );
       
  2484             }
       
  2485         else
       
  2486             {    
       
  2487             InitNavipaneL( );
       
  2488             }
       
  2489 
       
  2490         iSvkEvents = CMmsSvkEvents::NewL( *this );
       
  2491         
       
  2492         User::LeaveIfError( error );
       
  2493         }
       
  2494     }
       
  2495     
       
  2496 // ---------------------------------------------------------
       
  2497 // CMmsViewerAppUi::DoHandleSendKeyL
       
  2498 // ---------------------------------------------------------
       
  2499 //
       
  2500 void CMmsViewerAppUi::DoHandleSendKeyL( )
       
  2501     {
       
  2502     if ( MediaIsRunning( iAudio ) ||
       
  2503          MediaIsRunning( iVideo ) )
       
  2504         {
       
  2505         //-> inactive
       
  2506         return;
       
  2507         }
       
  2508 
       
  2509     if ( !iMmsVoIPExtension )
       
  2510         {
       
  2511         iMmsVoIPExtension = CMsgVoIPExtension::NewL( );    
       
  2512         }
       
  2513     
       
  2514     TPtrC senderAddr = KNullDesC( );
       
  2515     TPtrC senderAlias = KNullDesC( );
       
  2516     TBool dialerDisabled = EFalse;
       
  2517 
       
  2518     senderAddr.Set( TMmsGenUtils::PureAddress( iMtm->Sender() ) );
       
  2519     if ( iHeader->Alias( ) )
       
  2520         {
       
  2521         senderAlias.Set( *( iHeader->Alias( ) ) );
       
  2522         }
       
  2523 
       
  2524     TPtrC focusedAddr = KNullDesC( );
       
  2525     if ( FocusedControlId( ) == EMsgComponentIdBody &&
       
  2526         iView->ItemFinder( ) )
       
  2527         {
       
  2528         const CItemFinder::CFindItemExt& item =
       
  2529             iView->ItemFinder( )->CurrentItemExt( );
       
  2530         if (    item.iItemDescriptor
       
  2531             &&  (   item.iItemType == CItemFinder::EPhoneNumber
       
  2532                 ||  item.iItemType == CItemFinder::EEmailAddress ) )
       
  2533             {
       
  2534             	 //Dialer is opened when creating a VoIP call from MMS via Call creation key
       
  2535             	 //Disabling the dialer when send is pressed
       
  2536                 iAvkonAppUi->SetKeyEventFlags( 
       
  2537                     CAknAppUiBase::EDisableSendKeyShort | 
       
  2538                     CAknAppUiBase::EDisableSendKeyLong );		
       
  2539                 dialerDisabled = ETrue;    
       
  2540                 focusedAddr.Set( *(item.iItemDescriptor) );
       
  2541             }
       
  2542         }
       
  2543 
       
  2544     if ( FocusedControlId( ) == EMsgComponentIdFrom && 
       
  2545          senderAddr.Length() && 
       
  2546          iHeader->SenderType( ) == EMuiuAddressTypePhoneNumber )    
       
  2547         {
       
  2548         // Disable dialer
       
  2549         iAvkonAppUi->SetKeyEventFlags( 
       
  2550             CAknAppUiBase::EDisableSendKeyShort | 
       
  2551             CAknAppUiBase::EDisableSendKeyLong );	
       
  2552         dialerDisabled = ETrue;            
       
  2553         }
       
  2554     // Only when dialer is disabled try placing the call    
       
  2555     if ( dialerDisabled )
       
  2556         {        
       
  2557         MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( 
       
  2558             *iMmsVoIPExtension,
       
  2559             senderAddr,
       
  2560             senderAlias,
       
  2561             focusedAddr,
       
  2562             ETrue,
       
  2563             iEikonEnv );
       
  2564         }
       
  2565     }
       
  2566 
       
  2567 // ---------------------------------------------------------
       
  2568 // CMmsViewerAppUi::DoMessageInfoL
       
  2569 // ---------------------------------------------------------
       
  2570 //
       
  2571 void CMmsViewerAppUi::DoMessageInfoL( )
       
  2572     {
       
  2573     TPckgBuf<TInt> nullParam( 0 );
       
  2574     
       
  2575     //These are not used! They just have to be there.
       
  2576     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  2577     CleanupStack::PushL( selection );
       
  2578 
       
  2579     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document( ) );
       
  2580     CMsvOperation* op = Document( )->MtmUiL( ).InvokeAsyncFunctionL(
       
  2581         KMtmUiFunctionMessageInfo,
       
  2582         *selection,
       
  2583         watch->iStatus,
       
  2584         nullParam );
       
  2585     CleanupStack::Pop( watch ); 
       
  2586     Document( )->AddSingleOperationL( op, watch );
       
  2587 
       
  2588     CleanupStack::PopAndDestroy( selection ); 
       
  2589     }
       
  2590 
       
  2591 // ---------------------------------------------------------
       
  2592 // CMmsViewerAppUi::DoDeleteAndExitL
       
  2593 // ---------------------------------------------------------
       
  2594 //
       
  2595 void CMmsViewerAppUi::DoDeleteAndExitL( )
       
  2596     {
       
  2597     // Confirm from user deletion of message and delete if needed.
       
  2598     if ( ShowConfirmationQueryL( R_MMSVIEWER_QUEST_DELETE_MESSAGE ) )
       
  2599         {
       
  2600         MediaStop( );
       
  2601         //Reset view (i.e. close all files!)
       
  2602         //If image is open, extra delay needs to be added that
       
  2603         //server side components can finish their tasks 
       
  2604         iViewerState = EReseted;
       
  2605         ResetViewL( );
       
  2606         // create delay, because every media object is not necessary closed immediately
       
  2607         Document( )->DeleteModel( );
       
  2608         User::After(50000);
       
  2609         DeleteAndExitL( );
       
  2610         }
       
  2611     }
       
  2612 
       
  2613 
       
  2614 // ---------------------------------------------------------
       
  2615 // CMmsViewerAppUi::DoMoveMessageL
       
  2616 // ---------------------------------------------------------
       
  2617 //
       
  2618 void CMmsViewerAppUi::DoMoveMessageL( )
       
  2619     {
       
  2620     //ask folder with a dialog (from muiu)
       
  2621     TMsvId target = Document( )->Entry( ).Parent( );
       
  2622     HBufC* title = StringLoader::LoadLC( R_MMSVIEWER_MOVE_TEXT, iCoeEnv );
       
  2623     TBool success = CMsgFolderSelectionDialog::SelectFolderL(target, *title);
       
  2624     CleanupStack::PopAndDestroy( title ); 
       
  2625     if (success)
       
  2626         {
       
  2627         MediaStop( );
       
  2628         iViewerState = EReseted;
       
  2629         ResetViewL( );
       
  2630         iViewerState = EBusy;
       
  2631         TInt error(KErrNone);
       
  2632         TRAP(error, MoveMessageEntryL( target ) );
       
  2633         iViewerState = EReseted;
       
  2634         
       
  2635         LOGTEXT2(_L16("CMmsViewerAppUi::DoMoveMessageL %d"), error );
       
  2636         User::LeaveIfError( error );
       
  2637         Exit( EAknSoftkeyClose );
       
  2638         }
       
  2639     }
       
  2640 
       
  2641 
       
  2642 // ---------------------------------------------------------
       
  2643 // CMmsViewerAppUi::IsOwnMessage
       
  2644 // ---------------------------------------------------------
       
  2645 //
       
  2646 TBool CMmsViewerAppUi::IsOwnMessage( ) const
       
  2647     {
       
  2648     const TMmsMsvEntry* mmsEntry =
       
  2649         static_cast<const TMmsMsvEntry*>( &Document( )->Entry( ) );
       
  2650     return ( !(mmsEntry->IsMobileTerminated( ) ) );
       
  2651     }
       
  2652 
       
  2653 // ---------------------------------------------------------
       
  2654 // CMmsViewerAppUi::HasSender
       
  2655 // ---------------------------------------------------------
       
  2656 //
       
  2657 TBool CMmsViewerAppUi::HasSender( ) const
       
  2658     {
       
  2659     return ( iMtm->Sender( ).Length( ) > 0 );
       
  2660     }
       
  2661 
       
  2662 // ---------------------------------------------------------
       
  2663 // CMmsViewerAppUi::ShowReplyToAll
       
  2664 // ---------------------------------------------------------
       
  2665 //
       
  2666 TBool CMmsViewerAppUi::ShowReplyToAll( ) const
       
  2667     {
       
  2668     return ( iMtm->AddresseeList( ).Count( ) > 
       
  2669         ( IsOwnMessage( ) ? 0 : 1 ) );
       
  2670     }
       
  2671 
       
  2672 // ---------------------------------------------------------
       
  2673 // CMmsViewerAppUi::ShowReplyMenu
       
  2674 // ---------------------------------------------------------
       
  2675 //
       
  2676 TBool CMmsViewerAppUi::ShowReplyMenu( ) const
       
  2677     {
       
  2678     if ( Document( )->IsUpload( ) )
       
  2679         {
       
  2680         return EFalse;
       
  2681         }
       
  2682     else
       
  2683         {
       
  2684         return ( HasSender( ) || ShowReplyToAll( ) );
       
  2685         }
       
  2686     }
       
  2687 
       
  2688 // ---------------------------------------------------------
       
  2689 // CMmsViewerAppUi::ResetViewL
       
  2690 // ---------------------------------------------------------
       
  2691 //
       
  2692 void CMmsViewerAppUi::ResetViewL( )
       
  2693     {
       
  2694     iVideo = NULL;
       
  2695     iAudio = NULL;
       
  2696     iImage = NULL;
       
  2697 #ifdef RD_SVGT_IN_MESSAGING
       
  2698     iSvgt = NULL;
       
  2699 #endif    
       
  2700 
       
  2701     if ( iSlideLoader )
       
  2702         {
       
  2703         iSlideLoader->ResetViewL( );
       
  2704         }
       
  2705     // When attachments view is visible but not focused, eye striking focus movement takes
       
  2706     // place to attachments field e.g durign forwarding. 
       
  2707     iHeader->RemoveAttachmentL(); 
       
  2708     iHeader->RemoveFromViewL( );
       
  2709     }
       
  2710 
       
  2711 // ---------------------------------------------------------
       
  2712 // CMmsViewerAppUi::EditorObserver
       
  2713 // ---------------------------------------------------------
       
  2714 //
       
  2715 void CMmsViewerAppUi::EditorObserver(TMsgEditorObserverFunc aFunc, TAny* aArg1, TAny* aArg2, TAny* aArg3)
       
  2716     {
       
  2717     TRAP_IGNORE(DoEditorObserverL(aFunc,aArg1,aArg2,aArg3 ) );
       
  2718     }
       
  2719 
       
  2720 
       
  2721 // ---------------------------------------------------------
       
  2722 // CMmsViewerAppUi::EditorObserver
       
  2723 // ---------------------------------------------------------
       
  2724 //
       
  2725 void CMmsViewerAppUi::DoEditorObserverL(TMsgEditorObserverFunc aFunc, TAny* aArg1, TAny* aArg2, TAny* aArg3)
       
  2726     {
       
  2727     TInt slides = iSmilModel->SlideCount( );
       
  2728     TBool multiSlide =
       
  2729         ( Document( )->SmilType( ) == EMmsSmil && slides > 1 );
       
  2730     switch ( aFunc )
       
  2731         {
       
  2732         case EMsgScrollParts:
       
  2733             {
       
  2734             if ( multiSlide )
       
  2735                 {
       
  2736                 TInt* parts = static_cast<TInt*>( aArg1 );
       
  2737                 *parts = slides;
       
  2738                 }
       
  2739             }
       
  2740             break;
       
  2741         case EMsgHandleFocusChange:
       
  2742             {
       
  2743             // Enable Dialer 
       
  2744             iAvkonAppUi->SetKeyEventFlags( 0x00 );
       
  2745             
       
  2746             TMsgFocusEvent event =
       
  2747                 *( static_cast<TMsgFocusEvent*>( aArg1 ) );
       
  2748             TMsgAfterFocusEventFunc* after =
       
  2749                 static_cast<TMsgAfterFocusEventFunc*>( aArg2 );
       
  2750             TInt* currPart =
       
  2751                 static_cast<TInt*>( aArg3 );
       
  2752 
       
  2753             switch (event)
       
  2754                 {
       
  2755                 case EMsgFocusAtBottom:
       
  2756 #ifdef RD_SCALABLE_UI_V2
       
  2757                     // check the legality of slide change
       
  2758                     if ( multiSlide && *currPart > Document( )->CurrentSlide( ) )
       
  2759                         {
       
  2760                         TInt moveToSlide( *currPart );
       
  2761                         if ( moveToSlide >= slides )
       
  2762                             {
       
  2763                             moveToSlide = slides - 1;
       
  2764                             }
       
  2765                         
       
  2766                         ChangeSlideL( moveToSlide, ETrue );
       
  2767                         *after = EMsgCursorToBodyBeginning;
       
  2768                         }
       
  2769                     else
       
  2770                         {
       
  2771                         *after = EMsgAfterFocusNone;
       
  2772                         }
       
  2773                     *currPart = Document( )->CurrentSlide( );
       
  2774 #else
       
  2775                     if ( multiSlide && Document( )->CurrentSlide( ) + 1 < slides )
       
  2776                         {
       
  2777                         ChangeSlideL( Document( )->CurrentSlide( ) + 1, ETrue);
       
  2778                         *after = EMsgCursorToBodyBeginning;
       
  2779                         *currPart = Document( )->CurrentSlide( );
       
  2780                         }
       
  2781 #endif
       
  2782                     break;
       
  2783                 case EMsgFocusAtTop:
       
  2784 #ifdef RD_SCALABLE_UI_V2
       
  2785                     // check the legality of slide change
       
  2786                     if ( multiSlide && *currPart < Document( )->CurrentSlide( ) )
       
  2787                         {
       
  2788                         TInt moveToSlide( *currPart );
       
  2789                         if ( moveToSlide < 0 )
       
  2790                             {
       
  2791                             moveToSlide = 0;
       
  2792                             }
       
  2793                         
       
  2794                         ChangeSlideL( moveToSlide, ETrue);
       
  2795                         *after = EMsgCursorToBodyEnd;
       
  2796                         }
       
  2797                     else
       
  2798                         {
       
  2799                         *after = EMsgAfterFocusNone;
       
  2800                         }
       
  2801                     *currPart = Document( )->CurrentSlide( );
       
  2802 #else
       
  2803                     if ( multiSlide && Document( )->CurrentSlide( ) > 0 )
       
  2804                         {
       
  2805                         ChangeSlideL( Document( )->CurrentSlide( ) - 1, ETrue);
       
  2806                         *after = EMsgCursorToBodyEnd;
       
  2807                         *currPart = Document( )->CurrentSlide( );
       
  2808                         }
       
  2809 #endif
       
  2810                     break;
       
  2811                 case EMsgFocusMovingFrom:
       
  2812                     {
       
  2813                     if ( MediaIsRunning( iVideo ) )
       
  2814                         {
       
  2815                         MediaStop( iVideo );
       
  2816                         }
       
  2817                     break;
       
  2818                     }
       
  2819                 case EMsgFocusMovedTo:
       
  2820                     {
       
  2821                     StartAnimationL( );
       
  2822                     UpdateMskL( );
       
  2823                     break;
       
  2824                     }
       
  2825                 case EMsgFocusToBody:
       
  2826                 case EMsgFocusToHeader:
       
  2827                 default:
       
  2828                     break;
       
  2829                 }
       
  2830             }
       
  2831             break;
       
  2832         case EMsgControlPointerEvent:
       
  2833             {
       
  2834 #ifdef RD_SCALABLE_UI_V2
       
  2835             if ( AknLayoutUtils::PenEnabled() )
       
  2836                 {
       
  2837                 TPointerEvent* pointerEvent = static_cast<TPointerEvent*>( aArg2 );
       
  2838                 CMsgBaseControl* baseControl = static_cast<CMsgBaseControl*>( aArg1 );
       
  2839 
       
  2840                 if (    pointerEvent
       
  2841                     &&  pointerEvent->iType == TPointerEvent::EButton1Down )
       
  2842                     {
       
  2843                     // We are looking for a valid tap (button down and up)
       
  2844                     // on a focused object.
       
  2845                     iPointerTarget =
       
  2846                         baseControl && baseControl->IsFocused() ? baseControl : NULL;
       
  2847                     }
       
  2848                 else if (   pointerEvent
       
  2849                         &&  pointerEvent->iType == TPointerEvent::EButton1Up )
       
  2850                     {
       
  2851                     if ( baseControl && iPointerTarget == baseControl )
       
  2852                         {
       
  2853                         switch( iMskId )
       
  2854                             {
       
  2855                             // Tapping on selected object functions as a
       
  2856                             // selection key was pressed. But command set
       
  2857                             // is limited to ones below.
       
  2858                             case R_MMSVIEWER_MSK_BUTTON_PLAY_PRESENTATION: // fallthrough
       
  2859                             case R_MMSVIEWER_MSK_BUTTON_PLAY_AUDIO: // fallthrough
       
  2860                             case R_MMSVIEWER_MSK_BUTTON_OPEN_IMAGE: // fallthrough
       
  2861                             case R_MMSVIEWER_MSK_BUTTON_PLAY_VIDEO: // fallthrough
       
  2862                             case R_MMSVIEWER_MSK_BUTTON_STOP_AUDIO:
       
  2863                             case R_MMSVIEWER_MSK_BUTTON_STOP_VIDEO:
       
  2864                             case R_MMSVIEWER_MSK_BUTTON_OPEN_OBJECTS:
       
  2865 #ifdef RD_SVGT_IN_MESSAGING                 	
       
  2866                             case R_MMSVIEWER_MSK_BUTTON_PLAY_SVG:
       
  2867 #endif                
       
  2868                                 {
       
  2869                                 // Read current MSK resource to get a command id
       
  2870                                 // to execute.
       
  2871                                 TResourceReader reader;
       
  2872                                 iEikonEnv->CreateResourceReaderLC(
       
  2873                                     reader, iMskId );
       
  2874                                 reader.ReadInt8(); // version
       
  2875                                 HandleCommandL( reader.ReadUint16() );
       
  2876                                 CleanupStack::PopAndDestroy(); // resource buffer
       
  2877                                 *static_cast<TBool*>( aArg3 ) = ETrue;  // handled
       
  2878                                 }
       
  2879                             default:
       
  2880                                 ;
       
  2881                             }
       
  2882                         }
       
  2883                     iPointerTarget = NULL;
       
  2884                     }
       
  2885                 }
       
  2886 #endif // RD_SCALABLE_UI_V2
       
  2887             break;
       
  2888             }
       
  2889         case EMsgButtonEvent:
       
  2890             {    
       
  2891 #ifdef RD_SCALABLE_UI_V2
       
  2892             if ( AknLayoutUtils::PenEnabled() )
       
  2893                 {                    
       
  2894                 if ( iHeader->AttachmentControl( ) == static_cast<CMsgBaseControl*>( aArg1 ) )
       
  2895                     {
       
  2896                     DoObjectsL();
       
  2897                     }
       
  2898                 }
       
  2899 #endif // RD_SCALABLE_UI_V2
       
  2900             break;
       
  2901             }
       
  2902         default:
       
  2903             break;
       
  2904         }
       
  2905     }
       
  2906 
       
  2907 // ---------------------------------------------------------
       
  2908 // CMmsViewerAppUi::HandleNotifyInt
       
  2909 //
       
  2910 // Notification from central repository
       
  2911 // ---------------------------------------------------------
       
  2912 //
       
  2913 void CMmsViewerAppUi::HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue )
       
  2914     {    
       
  2915     if ( aNewValue == 0 )
       
  2916         {
       
  2917         iViewerFlags &= ~EAutohighLightEnabled;
       
  2918         }
       
  2919     else
       
  2920         {
       
  2921         iViewerFlags |= EAutohighLightEnabled;
       
  2922         }
       
  2923     TRAP_IGNORE( SetFindModeL( iViewerFlags & EAutohighLightEnabled ) );
       
  2924     }
       
  2925 
       
  2926 // ---------------------------------------------------------
       
  2927 // CMmsViewerAppUi::HandleNotifyGeneric
       
  2928 // ---------------------------------------------------------
       
  2929 //
       
  2930 void CMmsViewerAppUi::HandleNotifyGeneric( TUint32 /*aId*/ )
       
  2931     {
       
  2932     //Nothing.
       
  2933     }
       
  2934     
       
  2935 // ---------------------------------------------------------
       
  2936 // CMmsViewerAppUi::HandleNotifyError
       
  2937 // ---------------------------------------------------------
       
  2938 //
       
  2939 void CMmsViewerAppUi::HandleNotifyError( TUint32 /*aId*/, TInt /*error*/, CCenRepNotifyHandler* /*aHandler*/ )
       
  2940     {
       
  2941     //Nothing.
       
  2942     }
       
  2943   
       
  2944 //  
       
  2945 // NOTICE:
       
  2946 //
       
  2947 // Startup observer moved to own class because Publish & Subscribe
       
  2948 // requires an active object for event handling.
       
  2949 //
       
  2950 
       
  2951 // ---------------------------------------------------------
       
  2952 // CMmsViewerAppUi::HandleIteratorEventL
       
  2953 // ---------------------------------------------------------
       
  2954 //
       
  2955 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  2956 void CMmsViewerAppUi::HandleIteratorEventL( TMessageIteratorEvent aEvent )
       
  2957     {
       
  2958     if (    aEvent == EFolderCountChanged 
       
  2959         &&  iViewerState == ENormal 
       
  2960         &&  !iNoTitlePaneUpdate )
       
  2961         {
       
  2962         InitNavipaneL( );
       
  2963         }
       
  2964     }
       
  2965 #endif
       
  2966 
       
  2967 // ---------------------------------------------------------
       
  2968 // MmsSvkChangeVolumeL
       
  2969 // ---------------------------------------------------------
       
  2970 // Callback function
       
  2971 void CMmsViewerAppUi::MmsSvkChangeVolumeL( TInt aVolumeChange )
       
  2972     {    
       
  2973     ChangeVolumeL( aVolumeChange, ETrue );
       
  2974     }
       
  2975 
       
  2976 // ---------------------------------------------------------
       
  2977 // ChangeVolumeL
       
  2978 // ---------------------------------------------------------
       
  2979 //
       
  2980 void CMmsViewerAppUi::ChangeVolumeL( TInt aVolume, TBool aChange )
       
  2981     {    
       
  2982     TBool audioPlaying ( MediaCanStop( iAudio ) );
       
  2983     TBool videoPlaying =
       
  2984         ( ( MediaCanStop( iVideo ) ) &&
       
  2985         ( FocusedControlId( ) == EMsgComponentIdVideo ) );
       
  2986 
       
  2987     if ( audioPlaying || videoPlaying )
       
  2988         {
       
  2989         TInt newVolume = DoChangeVolumeL( aVolume, aChange, audioPlaying );
       
  2990         if ( newVolume >= KVolumeControlMinValue )
       
  2991             {
       
  2992             // Finally show the volume
       
  2993             ShowVolumeL( newVolume, audioPlaying );
       
  2994             }
       
  2995         }
       
  2996     }
       
  2997 
       
  2998 // ---------------------------------------------------------
       
  2999 // CMmsViewerAppUi::DoChangeVolumeL
       
  3000 // ---------------------------------------------------------
       
  3001 // 
       
  3002 TInt CMmsViewerAppUi::DoChangeVolumeL( TInt aVolume, TBool aChange, TBool aAudioPlaying )
       
  3003     {
       
  3004 #ifdef _DEBUG
       
  3005     if ( aAudioPlaying )
       
  3006         {
       
  3007         __ASSERT_DEBUG( iAudio, Panic( EMmsViewerNullPointer ) );
       
  3008         }
       
  3009     else
       
  3010         {
       
  3011         __ASSERT_DEBUG( iVideo, Panic( EMmsViewerNullPointer ) );
       
  3012         }
       
  3013 #endif
       
  3014     TInt newVolume = aVolume;
       
  3015     // In practise the variable indicates whether volume indicator is shown in the navi pane
       
  3016     // and whether audio can be heard
       
  3017     TBool updateIntoCenRepAllowed( aAudioPlaying );
       
  3018 
       
  3019     // Changes the volume level into the CenRep, if:
       
  3020     // 1) audio is playing or
       
  3021     // 2) video is playing and video has audio and silent mode is not On
       
  3022     // 
       
  3023     // Sets the volume level into audio/video player if 
       
  3024     // 1) as above
       
  3025     // 2) video is playing and silent mode is On
       
  3026     // 
       
  3027     if (    aAudioPlaying 
       
  3028         ||  (   !aAudioPlaying 
       
  3029             &&  iViewerFlags & EVideoHasAudio ) )
       
  3030         {
       
  3031         if (    !aAudioPlaying
       
  3032             &&  iViewerFlags & EVideoHasAudio
       
  3033             &&  !IsSilenceL( ) )
       
  3034             {
       
  3035             updateIntoCenRepAllowed = ETrue;
       
  3036             }
       
  3037         else if ( !aAudioPlaying )
       
  3038             {
       
  3039             updateIntoCenRepAllowed = EFalse;
       
  3040             }
       
  3041         
       
  3042         // First determine new value to be written into Cenrep
       
  3043         TInt currVolume( KVolumeDefault );
       
  3044         if ( aChange )
       
  3045             {
       
  3046             iMmsRepository->Get( KMmsuiHandsfreeVolume, currVolume );
       
  3047             newVolume = currVolume+aVolume;
       
  3048             }
       
  3049         else
       
  3050             {
       
  3051             // force change
       
  3052             currVolume = KErrNotFound;
       
  3053             }
       
  3054         // else - newVolume has correct value and currVolume forces always change
       
  3055 
       
  3056         newVolume = Max( KVolumeControlMinValue,
       
  3057                         Min( KVolumeControlMaxValue, newVolume ) );
       
  3058         if (    updateIntoCenRepAllowed 
       
  3059             &&  newVolume != currVolume )
       
  3060             {
       
  3061             iMmsRepository->Set( KMmsuiHandsfreeVolume, newVolume );
       
  3062             }
       
  3063 
       
  3064         // Then write the value into control
       
  3065         if ( aAudioPlaying )
       
  3066             {
       
  3067             if (iAudio)
       
  3068                 {            
       
  3069                 TInt maxVolume = reinterpret_cast<CMsgAudioControl*>(iAudio)->MaxVolume( );
       
  3070                 reinterpret_cast<CMsgAudioControl*>(iAudio)->
       
  3071                     SetVolume( ( newVolume * maxVolume ) / KVolumeLevels );
       
  3072                 }
       
  3073             }
       
  3074         else
       
  3075             {
       
  3076             if ( iVideo )
       
  3077                 {
       
  3078                 if ( !updateIntoCenRepAllowed )
       
  3079                     {
       
  3080                     newVolume = KVolumeControlMinValuePlayer;
       
  3081                     }
       
  3082                 
       
  3083                 TInt maxVolume = reinterpret_cast<CMsgVideoControl*>( iVideo )->MaxVolume( );
       
  3084                 TInt dummy(KErrNone);
       
  3085                 TRAP( dummy, 
       
  3086                     reinterpret_cast<CMsgVideoControl*>(iVideo)->
       
  3087                         SetVolumeL( ( newVolume * maxVolume ) / KVolumeLevels ) );
       
  3088                 }
       
  3089             }
       
  3090         }
       
  3091     if ( !updateIntoCenRepAllowed )
       
  3092         {
       
  3093         newVolume = KErrNotFound;
       
  3094         }
       
  3095     return newVolume;
       
  3096     }
       
  3097 
       
  3098 // ---------------------------------------------------------
       
  3099 // ShowVolumeL
       
  3100 // ---------------------------------------------------------
       
  3101 //
       
  3102 void CMmsViewerAppUi::ShowVolumeL(  TInt  aNewVolume,
       
  3103                                     TBool aAudioPlaying )
       
  3104     {
       
  3105     // Shows volume control, if:
       
  3106     // 1) audio is playing or
       
  3107     // 2) video is playing and (either or both of the below conditions is ETrue )
       
  3108     //   - silent mode is not On or 
       
  3109     //   - video has audio
       
  3110     if (    aAudioPlaying 
       
  3111         ||  (   !aAudioPlaying 
       
  3112             &&  (    iViewerFlags & EVideoHasAudio )
       
  3113                 ||  !IsSilenceL( ) ) )
       
  3114         {
       
  3115         if ( !iVolumeDecorator )
       
  3116             {
       
  3117             iVolumeDecorator = iNaviPane->CreateVolumeIndicatorL( R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
       
  3118 
       
  3119 #ifdef RD_SCALABLE_UI_V2
       
  3120             if ( AknLayoutUtils::PenEnabled() )
       
  3121                 {
       
  3122                 static_cast<CAknVolumeControl*>
       
  3123                     ( iVolumeDecorator->DecoratedControl() )->SetObserver( this );
       
  3124                 }
       
  3125 #endif
       
  3126             }
       
  3127 
       
  3128         if ( ! ( iViewerFlags & EVolumeControlTriggered ) )
       
  3129             {
       
  3130             // Set new volume and show it
       
  3131             static_cast<CAknVolumeControl*>
       
  3132                 ( iVolumeDecorator->DecoratedControl() )->SetValue( aNewVolume );
       
  3133             }
       
  3134         iNaviPane->PushL( *iVolumeDecorator );
       
  3135         }
       
  3136     }
       
  3137 
       
  3138 // ---------------------------------------------------------
       
  3139 // CMmsViewerAppUi::MsgAsyncControlStateChanged
       
  3140 // ---------------------------------------------------------
       
  3141 //
       
  3142 void CMmsViewerAppUi::MsgAsyncControlStateChanged(   
       
  3143                                     CMsgBaseControl& aControl,
       
  3144                                     TMsgAsyncControlState aNewState,
       
  3145                                     TMsgAsyncControlState aOldState )
       
  3146 
       
  3147     {
       
  3148     switch ( aControl.ControlId( ) )
       
  3149         {
       
  3150         case EMsgComponentIdAudio:
       
  3151         case EMsgComponentIdVideo:
       
  3152         case EMsgComponentIdImage:
       
  3153         case EMsgComponentIdSvg:
       
  3154             // Must be derived from CMsgMediaControl
       
  3155             TRAP_IGNORE( DoMsgMediaControlStateChangedL( 
       
  3156                             static_cast<CMsgMediaControl&>( aControl ), 
       
  3157                             aNewState, 
       
  3158                             aOldState ) );
       
  3159             break;
       
  3160         default:
       
  3161             // not derived from CMsgMediaControl
       
  3162             break;
       
  3163         }
       
  3164     }
       
  3165 
       
  3166 // ---------------------------------------------------------
       
  3167 // CMmsViewerAppUi::MsgAsyncControlStateChanged
       
  3168 // ---------------------------------------------------------
       
  3169 void CMmsViewerAppUi::MsgAsyncControlResourceChanged( CMsgBaseControl& aControl, TInt aType )
       
  3170     {
       
  3171     if ( aType == KEikDynamicLayoutVariantSwitch &&
       
  3172          aControl.ControlType() == EMsgImageControl )
       
  3173         {
       
  3174         CMsgImageControl& imageControl = static_cast<CMsgImageControl&>( aControl );
       
  3175         
       
  3176         if ( imageControl.IconBitmapId() == EMbmMmsuiQgn_graf_mms_play )
       
  3177             {
       
  3178             // 3GPP icons needs to be handled by ourself
       
  3179             TAknLayoutRect iconLayout;
       
  3180             iconLayout.LayoutRect( MsgEditorCommons::MsgDataPane(),
       
  3181                                    AknLayoutScalable_Apps::msg_data_pane_g4().LayoutLine() );
       
  3182     
       
  3183             TRAP_IGNORE( imageControl.SetIconSizeL( iconLayout.Rect().Size() ) );
       
  3184             }
       
  3185         }
       
  3186     }
       
  3187     
       
  3188 // ---------------------------------------------------------
       
  3189 // CMmsViewerAppUi::DoMsgMediaControlStateChangingL
       
  3190 // ---------------------------------------------------------
       
  3191 //
       
  3192 void CMmsViewerAppUi::DoMsgMediaControlStateChangedL(   
       
  3193                                     CMsgMediaControl&        aControl,
       
  3194                                     TMsgAsyncControlState   aNewState,
       
  3195                                     TMsgAsyncControlState   aOldState )
       
  3196     {
       
  3197 #ifdef USE_LOGGER
       
  3198     switch ( aControl.ControlId( ) )
       
  3199         {
       
  3200         case EMsgComponentIdAudio:
       
  3201             LOGTEXT2(_L16("CMmsViewerAppUi::MsgMediaControlStateChanged. Audio: Old state %d"), aOldState );
       
  3202             LOGTEXT2(_L16("                                              Audio: new state %d"), aNewState );
       
  3203             LOGTEXT2(_L16("                                              Audio: error %d"), aControl.Error() );
       
  3204             if ( aNewState == EMsgAsyncControlStateReady )
       
  3205                 {
       
  3206                 LOGTIMESTAMP("CMmsViewerAppUi::DoMsgMediaControlStateChangedL Audio is ready ");
       
  3207                 }
       
  3208             break;
       
  3209         case EMsgComponentIdVideo:
       
  3210             LOGTEXT2(_L16("CMmsViewerAppUi::MsgMediaControlStateChanged. Video: Old state %d"), aOldState );
       
  3211             LOGTEXT2(_L16("                                              Video: new state %d"), aNewState );
       
  3212             LOGTEXT2(_L16("                                              Video: error %d"), aControl.Error() );
       
  3213             if ( aNewState == EMsgAsyncControlStateReady )
       
  3214                 {
       
  3215                 LOGTIMESTAMP("CMmsViewerAppUi::DoMsgMediaControlStateChangedL Video is ready ");
       
  3216                 }
       
  3217             break;
       
  3218         case EMsgComponentIdImage:
       
  3219             LOGTEXT2(_L16("CMmsViewerAppUi::MsgMediaControlStateChanged. Image: Old state %d"), aOldState );
       
  3220             LOGTEXT2(_L16("                                              Image: new state %d"), aNewState );
       
  3221             LOGTEXT2(_L16("                                              Image: error %d"), aControl.Error() );
       
  3222             if ( aNewState == EMsgAsyncControlStateReady )
       
  3223                 {
       
  3224                 LOGTIMESTAMP("CMmsViewerAppUi::DoMsgMediaControlStateChangedL Image is ready ");
       
  3225                 }
       
  3226             break;
       
  3227         case EMsgComponentIdSvg:
       
  3228             LOGTEXT2(_L16("CMmsViewerAppUi::MsgMediaControlStateChanged. Svg: Old state %d"), aOldState );
       
  3229             LOGTEXT2(_L16("                                              Svg: new state %d"), aNewState );
       
  3230             LOGTEXT2(_L16("                                              Svg: error %d"), aControl.Error() );
       
  3231             if ( aNewState == EMsgAsyncControlStateReady )
       
  3232                 {
       
  3233                 LOGTIMESTAMP("CMmsViewerAppUi::DoMsgMediaControlStateChangedL Svg is ready ");
       
  3234                 }
       
  3235             break;
       
  3236         default:
       
  3237             // not derived from CMsgMediaControl
       
  3238             break;
       
  3239         }
       
  3240 #endif
       
  3241 
       
  3242     // Resets iOpeningState
       
  3243     ShowPendingNoteL( );
       
  3244 
       
  3245     // component independent
       
  3246     switch ( aNewState )
       
  3247         {
       
  3248         case EMsgAsyncControlStatePlaying:
       
  3249             UpdatePanesL( MediaIsRunning( iAudio ) ,MediaIsRunning( iVideo ) );
       
  3250             break;
       
  3251 
       
  3252         case EMsgAsyncControlStateStopped:
       
  3253         case EMsgAsyncControlStateNoRights:
       
  3254         case EMsgAsyncControlStateCorrupt:
       
  3255             UpdatePanesL( EFalse, EFalse );
       
  3256             break;
       
  3257 
       
  3258         default:
       
  3259             break;
       
  3260         }
       
  3261 
       
  3262     // Keep UpdateMskL() after UpdatePanesL( )
       
  3263     UpdateMskL( );    
       
  3264 
       
  3265     // component specific
       
  3266     switch ( aControl.ControlId( ) )
       
  3267         {
       
  3268         case EMsgComponentIdVideo:
       
  3269             {
       
  3270             if ( aNewState == EMsgAsyncControlStateReady &&
       
  3271                  !static_cast<CMsgVideoControl&>( aControl ).HasAudioL() )
       
  3272                 {
       
  3273                 iViewerFlags &= ~EVideoHasAudio;
       
  3274                 }
       
  3275             else if ( aNewState == EMsgAsyncControlStateReady )
       
  3276                 {
       
  3277                 // Lie that video is playing to set initial volume level.
       
  3278                 DoChangeVolumeL( 0, ETrue, EFalse ); 
       
  3279                 }
       
  3280 #ifdef USE_LOGGER
       
  3281 			if ( aNewState == EMsgAsyncControlStateReady )
       
  3282 				{
       
  3283 				LOGTEXT2(_L16("CMmsViewerAppUi::DoMsgMediaControlStateChangedL. Video: HasAudioL()? %d"), static_cast<CMsgVideoControl&>( aControl ).HasAudioL() );
       
  3284 				}
       
  3285 #endif
       
  3286             if (    aNewState == EMsgAsyncControlStateStopped
       
  3287                 ||  aNewState == EMsgAsyncControlStateNoRights
       
  3288                 ||  aNewState == EMsgAsyncControlStateCorrupt  )
       
  3289                 {
       
  3290                 CUniObject* object = ObjectByMediaControl( aControl );
       
  3291                 if (    object
       
  3292                     &&  object->DrmInfo( ) )
       
  3293                     {
       
  3294                     TInt err = object->DrmInfo( )->ReleaseRights( );
       
  3295                     }
       
  3296                 }
       
  3297             break;
       
  3298             }
       
  3299             // fall through
       
  3300         case EMsgComponentIdAudio:
       
  3301             {
       
  3302             if ( aNewState == EMsgAsyncControlStateReady )
       
  3303                 {
       
  3304                 // Lie that audio is playing to set initial volume level.
       
  3305                 DoChangeVolumeL( 0, ETrue, ETrue ); 
       
  3306                 }
       
  3307             if (    aNewState == EMsgAsyncControlStateStopped
       
  3308                 ||  aNewState == EMsgAsyncControlStateNoRights
       
  3309                 ||  aNewState == EMsgAsyncControlStateCorrupt )
       
  3310                 {
       
  3311                 CUniObject* object = ObjectByMediaControl( aControl );
       
  3312                 if (    object
       
  3313                     &&  object->DrmInfo( ) )
       
  3314                     {
       
  3315                     TInt err = object->DrmInfo( )->ReleaseRights( );
       
  3316                     }
       
  3317                 }
       
  3318             break;
       
  3319             }
       
  3320         case EMsgComponentIdImage:
       
  3321             StartAnimationL();
       
  3322             // fall through
       
  3323         case EMsgComponentIdSvg:
       
  3324             if ( aNewState == EMsgAsyncControlStateIdle )
       
  3325                 {
       
  3326                 CUniObject* object = ObjectByMediaControl( aControl );
       
  3327                 if (    object
       
  3328                     &&  object->DrmInfo( ) )
       
  3329                     {
       
  3330                     TInt err = object->DrmInfo( )->ReleaseRights( );
       
  3331                     }
       
  3332                 }
       
  3333             break;
       
  3334         default:
       
  3335             break;
       
  3336         }
       
  3337     }
       
  3338 
       
  3339 // ---------------------------------------------------------
       
  3340 // CMmsViewerAppUi::LaunchHelpL
       
  3341 // ---------------------------------------------------------
       
  3342 //
       
  3343 void CMmsViewerAppUi::LaunchHelpL( )
       
  3344     {
       
  3345     // activate Help application
       
  3346     
       
  3347 	if ( iSupportedFeatures & EMmsFeatureHelp )
       
  3348 		{
       
  3349 	    CArrayFix<TCoeHelpContext>* helpContext = AppHelpContextL( );
       
  3350 		HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession( ), helpContext );
       
  3351 		}
       
  3352     }
       
  3353 
       
  3354 
       
  3355 // ---------------------------------------------------------
       
  3356 // CMmsViewerAppUi::HelpContextL
       
  3357 // ---------------------------------------------------------
       
  3358 //
       
  3359 CArrayFix<TCoeHelpContext>* CMmsViewerAppUi::HelpContextL( ) const
       
  3360     {
       
  3361 	if ( iSupportedFeatures & EMmsFeatureHelp )
       
  3362 		{
       
  3363 	    CArrayFix<TCoeHelpContext>* r = new ( ELeave ) CArrayFixFlat<TCoeHelpContext>(1);
       
  3364 		CleanupStack::PushL( r );     
       
  3365 	    r->AppendL( TCoeHelpContext( KUidMmsViewer, KMMS_HLP_MMS_VIEWER( ) ) );
       
  3366 		CleanupStack::Pop( r );
       
  3367 		return r;
       
  3368 		}
       
  3369 	return NULL;
       
  3370     }
       
  3371 
       
  3372 // ---------------------------------------------------------
       
  3373 // CMmsViewerAppUi::SetFindModeL
       
  3374 // ---------------------------------------------------------
       
  3375 //
       
  3376 void CMmsViewerAppUi::SetFindModeL( TBool aEnable )
       
  3377     {
       
  3378     if ( iView )
       
  3379         {
       
  3380         if ( iView->ItemFinder( ) )
       
  3381             {
       
  3382             TInt findMode = aEnable ?
       
  3383                 CItemFinder::EPhoneNumber |
       
  3384                 CItemFinder::EUrlAddress |
       
  3385                 CItemFinder::EEmailAddress :
       
  3386                 CItemFinder::ENoneSelected;
       
  3387             iView->ItemFinder( )->SetFindModeL( findMode );
       
  3388             }
       
  3389         CMsgBaseControl* fromControl = iView->ControlById( EMsgComponentIdFrom );
       
  3390         if ( fromControl && iMtm->Sender( ).Length( ) )
       
  3391             {
       
  3392             static_cast<CMsgAddressControl*>( fromControl )
       
  3393                 ->SetAddressFieldAutoHighlight( aEnable );
       
  3394             }
       
  3395         }
       
  3396     }
       
  3397 
       
  3398 
       
  3399 // ---------------------------------------------------------
       
  3400 // CMmsViewerAppUi::MediaOpenL
       
  3401 // for single control
       
  3402 // ---------------------------------------------------------
       
  3403 // This function is entered when selection key is pressed.
       
  3404 // Actions allowed are play, embedded play, activate and get rights.
       
  3405 void CMmsViewerAppUi::MediaOpenL( CMsgMediaControl* aMedia )
       
  3406     {
       
  3407     if ( aMedia )
       
  3408         {
       
  3409         if ( MediaInitializedL( aMedia ) )
       
  3410             {
       
  3411             MediaPlayL( aMedia );
       
  3412             }
       
  3413         }
       
  3414     } 
       
  3415 
       
  3416 
       
  3417 // ---------------------------------------------------------
       
  3418 // CMmsViewerAppUi::MediaPlayL
       
  3419 // for single control
       
  3420 // ---------------------------------------------------------
       
  3421 void CMmsViewerAppUi::MediaPlayL(CMsgMediaControl* aMedia)
       
  3422     {
       
  3423     if ( aMedia )
       
  3424         {        
       
  3425         CUniObject* currObject = ObjectByMediaControl( *aMedia );
       
  3426         if (    currObject
       
  3427             &&  currObject->Corrupted() )
       
  3428             {
       
  3429             UpdatePanesL( MediaIsRunning( iAudio ) ,MediaIsRunning( iVideo ) );
       
  3430             UpdateMskL( );
       
  3431             ShowInformationNoteL( R_QTN_MMS_CANNOT_OPEN_CORRUPTED );
       
  3432             return;
       
  3433             }
       
  3434 #ifdef RD_SVGT_IN_MESSAGING
       
  3435         if ( aMedia == iSvgt || aMedia == iImage )
       
  3436             {
       
  3437             ViewImageL( *aMedia );
       
  3438             }
       
  3439 #else        
       
  3440         if (aMedia == iImage)
       
  3441             {
       
  3442             ViewImageL( reinterpret_cast< CMsgImageControl& >( *aMedia ) );
       
  3443             }
       
  3444 #endif            
       
  3445         else 
       
  3446             {
       
  3447             if (aMedia == iVideo)
       
  3448                 {
       
  3449                 if(IsVideoCall())
       
  3450                 {
       
  3451                 	ShowInformationNoteL( R_MMSVIEWER_CANNOT_PLAY_VIDEOCALL_ONGOING );
       
  3452                 	return;                
       
  3453                 }
       
  3454                 reinterpret_cast<CMsgVideoControl*>(aMedia)->ContinueOnFocus( ETrue );
       
  3455                 }
       
  3456             else if (   aMedia == iAudio )
       
  3457                 {
       
  3458                 __ASSERT_ALWAYS(    ObjectByMediaControl( *iAudio ) || ObjectByMediaControl( *iAudio )->MediaInfo( ), 
       
  3459                                     Panic( EMmsViewerNullPointer ) );
       
  3460                 CUniObject* obj = ObjectByMediaControl( *iAudio );
       
  3461                 if (    iViewerFlags & EProhibitNonDrmMusic 
       
  3462                     &&  !( obj->MediaInfo( )->Protection( ) &
       
  3463                         ( EFileProtSuperDistributable | EFileProtForwardLocked ) ) )
       
  3464                     {
       
  3465                     // Prepare buffer for aMimeType
       
  3466                     HBufC* mimeBuffer = HBufC::NewLC( obj->MimeType().Length() + KMmsViewerSpace().Length() );
       
  3467                     TPtr mimeBufferPtr = mimeBuffer->Des();
       
  3468                     mimeBufferPtr.Copy( obj->MimeType() );
       
  3469 
       
  3470                     // FindF() would find "audio/3gpp" in "audio/3gpp2" without
       
  3471                     // the added space.
       
  3472                     mimeBufferPtr.Append( KMmsViewerSpace );
       
  3473 
       
  3474                     // If result is not KErrNotFound, this MIME-type is indeed on blocked list.
       
  3475                     if ( iProhibitMimeTypeBuffer->FindF( mimeBufferPtr ) >= 0 ) 
       
  3476                         {
       
  3477                         ShowInformationNoteL( R_MMSVIEWER_PLAIN_MUSIC_PROHIBITED );
       
  3478                          /* Allocated buffer must be destroyed and pop'd !!! */
       
  3479                         CleanupStack::PopAndDestroy( mimeBuffer );
       
  3480                         return;
       
  3481                         }
       
  3482                          /* Allocated buffer must be destroyed and pop'd !!! */
       
  3483                         CleanupStack::PopAndDestroy( mimeBuffer );
       
  3484                     }
       
  3485                 if (    IsSilenceL( ) 
       
  3486                     &&  !ShowConfirmationQueryL( R_QTN_MMS_OBEY_SILENT_MODE ) )
       
  3487                     {
       
  3488                     return;
       
  3489                     }
       
  3490                 }
       
  3491                 
       
  3492             if ( !HandleConsumeRightsL( *aMedia ) )
       
  3493                 {
       
  3494                 UpdatePanesL( MediaIsRunning( iAudio ) ,MediaIsRunning( iVideo ) );
       
  3495                 UpdateMskL( );
       
  3496                 return;
       
  3497                 }
       
  3498             aMedia->PlayL( );
       
  3499             }
       
  3500         }
       
  3501     } 
       
  3502 
       
  3503 // ---------------------------------------------------------
       
  3504 // CMmsViewerAppUi::MediaStop
       
  3505 // for every control
       
  3506 // ---------------------------------------------------------
       
  3507 //
       
  3508 void CMmsViewerAppUi::MediaStop( )
       
  3509     {
       
  3510     MediaStop( iImage );
       
  3511     MediaStop( iAudio );
       
  3512     MediaStop( iVideo );
       
  3513 #ifdef RD_SVGT_IN_MESSAGING
       
  3514     MediaStop( iSvgt );
       
  3515 #endif
       
  3516     } 
       
  3517 
       
  3518 
       
  3519 // ---------------------------------------------------------
       
  3520 // CMmsViewerAppUi::MediaStop
       
  3521 // for single control
       
  3522 // ---------------------------------------------------------
       
  3523 //
       
  3524 void CMmsViewerAppUi::MediaStop(CMsgMediaControl* aMedia )
       
  3525     {
       
  3526     if ( MediaCanStop( aMedia ) )
       
  3527         {
       
  3528         if (aMedia == iVideo)
       
  3529             {
       
  3530             reinterpret_cast<CMsgVideoControl*>( aMedia )->ContinueOnFocus( EFalse );
       
  3531             }
       
  3532         CUniObject* object = ObjectByMediaControl( *aMedia );
       
  3533         if (    object
       
  3534             &&  object->DrmInfo( ) )
       
  3535             {
       
  3536             TInt err = object->DrmInfo( )->ReleaseRights( );
       
  3537             }
       
  3538         aMedia->Stop( );
       
  3539         }    
       
  3540     } 
       
  3541 
       
  3542 
       
  3543 // ---------------------------------------------------------
       
  3544 // CMmsViewerAppUi::MediaClose
       
  3545 // for every control
       
  3546 // ---------------------------------------------------------
       
  3547 //
       
  3548 void CMmsViewerAppUi::MediaClose( )
       
  3549     {
       
  3550     MediaClose( iImage );
       
  3551     MediaClose( iAudio );
       
  3552     MediaClose( iVideo );
       
  3553 #ifdef RD_SVGT_IN_MESSAGING
       
  3554     MediaClose( iSvgt );
       
  3555 #endif    
       
  3556     } 
       
  3557 
       
  3558 // ---------------------------------------------------------
       
  3559 // CMmsViewerAppUi::MediaClose
       
  3560 // for single control
       
  3561 // ---------------------------------------------------------
       
  3562 //
       
  3563 void CMmsViewerAppUi::MediaClose(CMsgMediaControl* aMedia)
       
  3564     {    
       
  3565     if ( aMedia )
       
  3566         {
       
  3567         if ( MediaCanStop ( aMedia ) )
       
  3568             {
       
  3569             aMedia->Stop( );
       
  3570             }    
       
  3571         
       
  3572         // Release rights - image only
       
  3573         if (    aMedia
       
  3574             &&  iImage == aMedia )
       
  3575             {                    
       
  3576             CUniObject* object = ObjectByMediaControl( *aMedia );
       
  3577             if (    object
       
  3578                 &&  object->DrmInfo( ) )
       
  3579                 {
       
  3580                 TInt err = object->DrmInfo( )->ReleaseRights( );
       
  3581                 }
       
  3582             }
       
  3583         aMedia->Close( );
       
  3584         }    
       
  3585     } 
       
  3586 
       
  3587 // ---------------------------------------------------------
       
  3588 // CMmsViewerAppUi::ReloadSlideL
       
  3589 // for every control
       
  3590 // ---------------------------------------------------------
       
  3591 //
       
  3592 void CMmsViewerAppUi::ReloadSlideL( )
       
  3593     {
       
  3594     LOGTEXT(_L8("CMmsViewerAppUi::ReloadSlideL"));
       
  3595     // Get focused control to restore focus after other view
       
  3596     if ( iView->FocusedControl( ) )
       
  3597         {                
       
  3598         iFocusedControlId = iView->FocusedControl( )->ControlId();  
       
  3599         if ( iFocusedControlId )
       
  3600             {
       
  3601             // Disable autofind temporarily, if On, because when slide is reloaded
       
  3602             // focus moves to From: field temporarily.
       
  3603             // Autohighlight is disabled temporarily
       
  3604             if (    !IsOwnMessage( )
       
  3605                 &&  iFocusedControlId != EMsgComponentIdFrom )
       
  3606                 {
       
  3607                 // Get highlight status        
       
  3608                 TInt highlight = 0;
       
  3609                 iCUiRepository->Get( KCuiAutomaticHighlight, highlight  );
       
  3610                 if ( highlight )
       
  3611                     {
       
  3612                     SetFindModeL( EFalse );
       
  3613                     }
       
  3614                 }  
       
  3615             }
       
  3616         }
       
  3617 
       
  3618     if ( Document( )->SmilType( ) == EMmsSmil )
       
  3619         {
       
  3620         ChangeSlideL( Document( )->CurrentSlide( ), EFalse );
       
  3621         }
       
  3622         SetFindModeL( iViewerFlags & EAutohighLightEnabled );
       
  3623 
       
  3624     InitNavipaneL( );
       
  3625     } 
       
  3626 
       
  3627 // ---------------------------------------------------------
       
  3628 // CMmsViewerAppUi::ReloadControlL
       
  3629 // ---------------------------------------------------------
       
  3630 //
       
  3631 void CMmsViewerAppUi::ReloadControlL( CMsgMediaControl* aControl, CUniObject& aObject )
       
  3632     {
       
  3633     LOGTEXT(_L8("CMmsViewerAppUi::ReloadControlL"));
       
  3634     if (    aControl
       
  3635         &&  Document( )->SmilType( ) == EMmsSmil )
       
  3636         {
       
  3637         // Get focused control to restore focus after other view
       
  3638         if ( iView->FocusedControl( ) )
       
  3639             {                
       
  3640             iFocusedControlId = iView->FocusedControl( )->ControlId();  
       
  3641             if ( iFocusedControlId )
       
  3642                 {
       
  3643                 // Disable autofind temporarily, if On, because when slide is reloaded
       
  3644                 // focus moves to From: field temporarily.
       
  3645                 // Autohighlight is disabled temporarily
       
  3646                 if (    !IsOwnMessage( )
       
  3647                     &&  iFocusedControlId != EMsgComponentIdFrom )
       
  3648                     {
       
  3649                     // Get highlight status        
       
  3650                     TInt highlight = 0;
       
  3651                     iCUiRepository->Get( KCuiAutomaticHighlight, highlight  );
       
  3652                     if ( highlight )
       
  3653                         {
       
  3654                         SetFindModeL( EFalse );
       
  3655                         }
       
  3656                     }  
       
  3657                 }
       
  3658             }
       
  3659 
       
  3660         MediaStop( );
       
  3661 
       
  3662         if (    iVideo 
       
  3663             &&  iVideo == aControl )
       
  3664             {
       
  3665             iScreenClearer = CAknLocalScreenClearer::NewLC( EFalse );
       
  3666             CleanupStack::Pop( iScreenClearer );
       
  3667             }
       
  3668         
       
  3669         iViewerState = EBusy;
       
  3670         iOpeningState = EOpeningSlide;
       
  3671         iViewerFlags |= EVideoHasAudio;
       
  3672         iVideo = NULL;
       
  3673         iAudio = NULL;
       
  3674         iImage = NULL;
       
  3675     #ifdef RD_SVGT_IN_MESSAGING
       
  3676         iSvgt = NULL;
       
  3677     #endif    
       
  3678         iPendingNoteResource = KInvalidResourceId;
       
  3679         iPendingNotePriority = 0;
       
  3680         iPendingNoteObject = NULL;
       
  3681         iPendingNoteError = KErrNone;
       
  3682 
       
  3683         delete iFindItemMenu;
       
  3684         iFindItemMenu = NULL;
       
  3685 
       
  3686         UpdateMskL();
       
  3687 
       
  3688         if ( !iChangeSlideOperation )
       
  3689             {
       
  3690             iChangeSlideOperation = new ( ELeave )CMmsViewerChangeSlideOperation (
       
  3691                 *this,
       
  3692                 *( Document( ) ),
       
  3693                 *iHeader,
       
  3694                 *iSlideLoader,
       
  3695                 *iView,
       
  3696                 iCoeEnv->FsSession( ) );
       
  3697             }
       
  3698             
       
  3699         ActivateInputBlockerL( iChangeSlideOperation );
       
  3700         iChangeSlideOperation->ReLoadControlL( aControl, &aObject );
       
  3701         
       
  3702         // TODO: Get rid of active wait!
       
  3703         BeginActiveWait( iChangeSlideOperation );
       
  3704         InitNavipaneL( );
       
  3705         }
       
  3706     } 
       
  3707 
       
  3708 
       
  3709 // ---------------------------------------------------------
       
  3710 // CMmsViewerAppUi::StopAnimation
       
  3711 // ---------------------------------------------------------
       
  3712 //
       
  3713 void CMmsViewerAppUi::StopAnimation( )
       
  3714     {
       
  3715     if (    iImage
       
  3716         &&  iImage->IsAnimation( ) )
       
  3717         {        
       
  3718         iImage->Stop( );
       
  3719         }    
       
  3720     } 
       
  3721 
       
  3722 // ---------------------------------------------------------
       
  3723 // CMmsViewerAppUi::StartAnimationL
       
  3724 // ---------------------------------------------------------
       
  3725 //
       
  3726 void CMmsViewerAppUi::StartAnimationL( )
       
  3727     {
       
  3728     if (    iImage
       
  3729         &&  iImage->IsAnimation( ) )
       
  3730         {            
       
  3731         TMsgAsyncControlState state = iImage->State( );        
       
  3732         if (    state == EMsgAsyncControlStateReady 
       
  3733             ||  state == EMsgAsyncControlStatePaused
       
  3734             ||  state == EMsgAsyncControlStateStopped )
       
  3735             {
       
  3736             iImage->PlayL( );
       
  3737             }    
       
  3738         }
       
  3739     } 
       
  3740 
       
  3741 // ---------------------------------------------------------
       
  3742 // CMmsViewerAppUi::ViewerOperationEvent
       
  3743 // ---------------------------------------------------------
       
  3744 //
       
  3745 void CMmsViewerAppUi::ViewerOperationEvent(
       
  3746         TMmsViewerOperationType     aOperation,
       
  3747         TMmsViewerOperationEvent    aEvent,
       
  3748         TInt                        aError)
       
  3749     {
       
  3750     if ( aEvent == EMmsViewerOperationCancel )
       
  3751         {
       
  3752         LOGTEXT(_L8("CMmsViewerAppUi::ViewerOperationEvent EMmsViewerOperationCancel") );
       
  3753         // Operation by operation should be considered what is proper action 
       
  3754         // in Cancel situation
       
  3755         ResetOperationState();
       
  3756         return;
       
  3757         }  
       
  3758 
       
  3759     if (    aOperation == EMmsViewerOperationReadReport
       
  3760         &&  aEvent == EMmsViewerOperationError )
       
  3761         {
       
  3762         // Not worth exiting
       
  3763         aError = KErrNone;
       
  3764         }
       
  3765 
       
  3766     TInt error(aError);
       
  3767     if ( !error )
       
  3768         {
       
  3769 
       
  3770         TRAP( error, DoViewerOperationEventL( aOperation, aEvent ) );
       
  3771         if ( aEvent == EMmsViewerOperationCancel )
       
  3772             {
       
  3773             // ignore errors
       
  3774             error = KErrNone;
       
  3775             }
       
  3776         }
       
  3777     else
       
  3778         {
       
  3779         ResetOperationState();
       
  3780         if ( error == KErrCorrupt )
       
  3781             {
       
  3782             TRAP_IGNORE( ShowErrorNoteL( R_MMSVIEWER_ERROR_MSG_CORRUPT ) );
       
  3783             }
       
  3784         }
       
  3785     
       
  3786     if ( error )
       
  3787         {
       
  3788         MediaStop( );
       
  3789         Exit( error );
       
  3790         }
       
  3791     }
       
  3792 
       
  3793 // ---------------------------------------------------------
       
  3794 // CMmsViewerAppUi::ViewerOperationEvent
       
  3795 // ---------------------------------------------------------
       
  3796 //
       
  3797 void CMmsViewerAppUi::DoViewerOperationEventL(
       
  3798         TMmsViewerOperationType     aOperation,
       
  3799         TMmsViewerOperationEvent    aEvent )
       
  3800     {
       
  3801     TInt error( KErrNone );
       
  3802     switch ( aOperation )
       
  3803         {
       
  3804         case EMmsViewerOperationChangeSlide:
       
  3805             {
       
  3806             EndActiveWait( );
       
  3807             // restore focus
       
  3808             if ( iFocusedControlId > EMsgComponentIdNull )
       
  3809                 {
       
  3810                 if ( FocusedControlId( ) != iFocusedControlId )
       
  3811                     {
       
  3812                     CMsgBaseControl* control = iView->ControlById( iFocusedControlId ) ;
       
  3813                     if ( control )
       
  3814                         {
       
  3815                         iView->SetFocus( iFocusedControlId );
       
  3816                         }
       
  3817                     }
       
  3818                 iFocusedControlId = EMsgComponentIdNull;
       
  3819                 }
       
  3820             iImage = reinterpret_cast< CMsgImageControl* > 
       
  3821                         ( iView->ControlById( EMsgComponentIdImage ) );
       
  3822             HandleImageNoRightsInLaunch( );
       
  3823             StartAnimationL( );
       
  3824             iAudio = reinterpret_cast< CMsgAudioControl* > 
       
  3825                         ( iView->ControlById( EMsgComponentIdAudio ) );
       
  3826             iVideo = reinterpret_cast< CMsgVideoControl* > 
       
  3827                         ( iView->ControlById( EMsgComponentIdVideo ) );
       
  3828 #ifdef RD_SVGT_IN_MESSAGING
       
  3829             iSvgt =  reinterpret_cast< CMsgSvgControl* > 
       
  3830                         ( iView->ControlById( EMsgComponentIdSvg ) );                        
       
  3831 #endif                        
       
  3832             break;
       
  3833             }
       
  3834         case EMmsViewerOperationLaunch:
       
  3835             {
       
  3836             if ( aEvent == EMmsViewerOperationCancel )
       
  3837                 {
       
  3838                 return;
       
  3839                 }
       
  3840             else
       
  3841                 {       
       
  3842                 LOGTEXT(_L8("CMmsViewerAppUi::DoViewerOperationEventL DoViewerOperationEventLaunchL in "));
       
  3843                 TRAP( error, DoViewerOperationEventLaunchL( ) );
       
  3844                 LOGTEXT(_L8("CMmsViewerAppUi::DoViewerOperationEventL DoViewerOperationEventLaunchL out "));
       
  3845                 }
       
  3846             break;
       
  3847             }
       
  3848         case EMmsViewerOperationReadReport:
       
  3849             // free resources
       
  3850             DeactivateInputBlocker();
       
  3851             delete iSendReadReportOperation;
       
  3852             iSendReadReportOperation = NULL;
       
  3853             // Viewer is already running normally
       
  3854             return;            
       
  3855             
       
  3856         default:
       
  3857             break;
       
  3858         }
       
  3859     
       
  3860     ResetOperationState();
       
  3861     User::LeaveIfError( error );
       
  3862 
       
  3863     SetFindModeL( iViewerFlags & EAutohighLightEnabled );
       
  3864     ShowPendingNoteL( );
       
  3865 
       
  3866     // iViewer state must be ENormal.
       
  3867     // UpdateMskL() must be after UpdatePanesL()
       
  3868     UpdatePanesL( EFalse, EFalse );
       
  3869     UpdateMskL( );             
       
  3870 
       
  3871     // Call of SendReadReportL cannot be in DoViewerOperationEventLaunchL, because
       
  3872     // ResetOperationState() deletes the input blocker launched from SendReadReportL
       
  3873     if (    aOperation == EMmsViewerOperationLaunch
       
  3874         &&  aEvent == EMmsViewerOperationComplete )
       
  3875         {
       
  3876         // Less important stuff follows.
       
  3877         // It is OK, that flags and state indicate successful launch
       
  3878 #ifndef USE_LOGGER
       
  3879         TRAP_IGNORE( SendReadReportL( aOperation, aEvent ) );
       
  3880 #else
       
  3881         TRAPD( error, SendReadReportL( aOperation, aEvent  ) );
       
  3882         if ( error )
       
  3883             {
       
  3884             LOGTEXT2(_L16("CMmsViewerAppUi::DoViewerOperationEventLaunchL SendReadReportL error %d"), error );
       
  3885             }
       
  3886 #endif  // USE_LOGGER
       
  3887         }
       
  3888     }
       
  3889 
       
  3890 // ---------------------------------------------------------
       
  3891 // DoViewerOperationEventLaunchL
       
  3892 // ---------------------------------------------------------
       
  3893 //
       
  3894 void CMmsViewerAppUi::DoViewerOperationEventLaunchL( )
       
  3895     {
       
  3896     if ( Document( )->ParseResult( ) &
       
  3897         ( ERegionMediaTypeMismatch | EBadlyReferencedObjects ) )
       
  3898         {
       
  3899         iViewerFlags |= ESuspiciousSmil;
       
  3900         }
       
  3901     
       
  3902     iSmilModel = Document( )->SmilModel( );
       
  3903     iHeader = iLaunchOperation->DetachHeader( );
       
  3904     iSlideLoader = iLaunchOperation->DetachSlideLoader( );
       
  3905    
       
  3906     TMsvEntry entry = iMtm->Entry( ).Entry( );
       
  3907     if ( entry.iMtmData1 & EMmsDrmCorruptedAttachment )
       
  3908         {
       
  3909         SetPendingNote( R_MMSVIEWER_DRM_OBJECT_REMOVED );
       
  3910         }
       
  3911     
       
  3912     // Condition was EUnsupportedObjects, but region may be resolved even
       
  3913     // if it is set. 
       
  3914     if ( Document( )->ParseResult( ) & EBadlyReferencedObjects  )
       
  3915         {
       
  3916         SetPendingNote( R_MMSVIEWER_CANNOT_DISPLAY_OBJECTS );
       
  3917         }
       
  3918 
       
  3919     if ( Document( )->AttachmentList( )->Count( ) )
       
  3920         {
       
  3921         SetPendingNote( R_MMSVIEWER_CANNOT_DISPLAY_OBJECTS );
       
  3922         }
       
  3923     
       
  3924     ResolveDrmWaitingNotes( );   // e.g. R_MMSVIEWER_DRM_PREVIEW_RIGHTS
       
  3925 
       
  3926     TInt focusedControl = ( Document( )->SmilType( ) != EMmsSmil )
       
  3927         ? EMsgComponentIdImage
       
  3928         : EMsgComponentIdNull;
       
  3929     iView->ExecuteL( ClientRect( ), focusedControl );
       
  3930 
       
  3931     SetTitleIconL();
       
  3932     InitNavipaneL( );    
       
  3933     TRAP_IGNORE( CheckAndSetDescriptionL( ) );
       
  3934 
       
  3935     if (focusedControl != EMsgComponentIdImage )
       
  3936         {
       
  3937         // 3GPP icon is not assigned
       
  3938         iImage = reinterpret_cast< CMsgImageControl* > 
       
  3939                     ( iView->ControlById( EMsgComponentIdImage ) );
       
  3940         HandleImageNoRightsInLaunch( );
       
  3941         StartAnimationL( );
       
  3942         }
       
  3943     iAudio = reinterpret_cast< CMsgAudioControl* > 
       
  3944                 ( iView->ControlById( EMsgComponentIdAudio ) );
       
  3945     iVideo = reinterpret_cast< CMsgVideoControl* > 
       
  3946                 ( iView->ControlById( EMsgComponentIdVideo ) );
       
  3947 #ifdef RD_SVGT_IN_MESSAGING             
       
  3948     iSvgt = reinterpret_cast< CMsgSvgControl* > 
       
  3949                 ( iView->ControlById( EMsgComponentIdSvg ) );
       
  3950 #endif                    
       
  3951     // Enable task swapper to options menu after launch has been completed.
       
  3952     MenuBar()->SetMenuType( CEikMenuBar::EMenuOptions );
       
  3953     
       
  3954 #ifdef RD_SCALABLE_UI_V2
       
  3955     if ( iToolbar )
       
  3956         { 
       
  3957         SetToolBarItemVisibilities();
       
  3958         }
       
  3959 #endif
       
  3960     }
       
  3961 
       
  3962 // ---------------------------------------------------------
       
  3963 // BeginActiveWait
       
  3964 // ---------------------------------------------------------
       
  3965 //
       
  3966 void CMmsViewerAppUi::BeginActiveWait( CMmsViewerOperation* aOperation )
       
  3967     {
       
  3968     if( iWait.IsStarted() )
       
  3969         {
       
  3970         if ( iActiveOperation )
       
  3971             {
       
  3972             iActiveOperation->Cancel();
       
  3973             }
       
  3974         else
       
  3975             {
       
  3976             return;
       
  3977             }                
       
  3978         }
       
  3979     iActiveOperation = aOperation;
       
  3980     iWait.Start();
       
  3981     }
       
  3982 
       
  3983 // ---------------------------------------------------------
       
  3984 // EndActiveWait
       
  3985 // ---------------------------------------------------------
       
  3986 //
       
  3987 void CMmsViewerAppUi::EndActiveWait( )
       
  3988     {
       
  3989     if( !iWait.IsStarted( ) )
       
  3990         {
       
  3991         return;
       
  3992         }
       
  3993     iWait.AsyncStop( );
       
  3994     iActiveOperation = NULL;
       
  3995     }
       
  3996 
       
  3997 
       
  3998 // ---------------------------------------------------------
       
  3999 // CMmsViewerAppUi::FocusedControlId
       
  4000 // ---------------------------------------------------------
       
  4001 //
       
  4002 TInt CMmsViewerAppUi::FocusedControlId( )
       
  4003     {
       
  4004     TInt controlType = EMsgComponentIdNull;
       
  4005     if ( iView && iView->FocusedControl( ) )
       
  4006         {
       
  4007         controlType = iView->FocusedControl( )->ControlId( );
       
  4008         }
       
  4009     return controlType;
       
  4010     }
       
  4011 
       
  4012 // ---------------------------------------------------------
       
  4013 // CMmsViewerAppUi::MediaControlById
       
  4014 // ---------------------------------------------------------
       
  4015 //
       
  4016 CMsgMediaControl* CMmsViewerAppUi::MediaControlById(TInt aControl)
       
  4017     {
       
  4018     CMsgMediaControl* control = NULL;
       
  4019     switch (aControl)
       
  4020         {
       
  4021         case EMsgComponentIdVideo:
       
  4022             control = iVideo;
       
  4023             break;
       
  4024         case EMsgComponentIdAudio:
       
  4025             control = iAudio;
       
  4026             break;
       
  4027         case EMsgComponentIdImage:
       
  4028             control = iImage;
       
  4029             break;
       
  4030 #ifdef RD_SVGT_IN_MESSAGING
       
  4031         case EMsgComponentIdSvg:
       
  4032             control = iSvgt;
       
  4033             break;
       
  4034 #endif            
       
  4035         default:
       
  4036             break;
       
  4037         }
       
  4038     return control;
       
  4039     } 
       
  4040     
       
  4041 // ---------------------------------------------------------
       
  4042 // CMmsViewerAppUi::MediaInitializedL
       
  4043 // ---------------------------------------------------------
       
  4044 //
       
  4045 TBool CMmsViewerAppUi::MediaInitializedL( CMsgMediaControl* aMedia )
       
  4046     {
       
  4047     if ( aMedia )
       
  4048         {
       
  4049         TBool noRights( EFalse );        
       
  4050         CUniObject* currObject = ObjectByMediaControl( *aMedia );
       
  4051         // test has two purpose
       
  4052         // If object has not rights, assume it is initialised.
       
  4053         // Image: If rights have not been consumed, object had not rights.
       
  4054         // Other objects: DRM rights do not matter, because they are handled separately  during
       
  4055         // 'launch'.
       
  4056         if (    currObject 
       
  4057             &&  currObject->DrmInfo() )
       
  4058             {
       
  4059             if (    aMedia == iImage )
       
  4060                 {
       
  4061                 noRights = !IsRightsConsumed( *currObject );
       
  4062                 }
       
  4063             else
       
  4064                 {
       
  4065                 noRights =  (   !IsRightsConsumed( *currObject ) 
       
  4066                             &&  !IsRightsNow( *currObject ) );
       
  4067                 }
       
  4068             }
       
  4069 
       
  4070         if ( noRights || MediaCanPlay( aMedia, currObject ) )
       
  4071             {
       
  4072             return ETrue;
       
  4073             }
       
  4074         else
       
  4075             {
       
  4076             return EFalse;
       
  4077             }
       
  4078         }
       
  4079     // else - no media - assume initialized
       
  4080     return ETrue;
       
  4081     }
       
  4082 
       
  4083 // ---------------------------------------------------------
       
  4084 // CMmsViewerAppUi::MediaCanPlay( )
       
  4085 // ---------------------------------------------------------
       
  4086 //
       
  4087 TBool CMmsViewerAppUi::MediaCanPlay(const CMsgMediaControl* aMedia,
       
  4088                                     const CUniObject* aMmsObject ) const
       
  4089     {
       
  4090     TBool corrupted( EFalse );
       
  4091     if (    aMmsObject
       
  4092         &&  aMmsObject->Corrupted() )
       
  4093         {
       
  4094         corrupted = ETrue;
       
  4095         }
       
  4096     
       
  4097     if ( aMedia )
       
  4098         {        
       
  4099         TMsgAsyncControlState state = aMedia->State( );
       
  4100         if (    state == EMsgAsyncControlStateReady 
       
  4101             ||  state == EMsgAsyncControlStatePaused
       
  4102             ||  state == EMsgAsyncControlStateStopped
       
  4103             ||  state == EMsgAsyncControlStateNoRights
       
  4104             ||  state == EMsgAsyncControlStateCorrupt
       
  4105             ||  corrupted     
       
  4106             ||  (   aMedia == iImage
       
  4107                 &&  (   state == EMsgAsyncControlStatePlaying
       
  4108                     ||  state == EMsgAsyncControlStatePaused )
       
  4109                 &&  iImage->IsAnimation() ) )
       
  4110             {
       
  4111             return ETrue;
       
  4112             }
       
  4113         }
       
  4114     return EFalse;
       
  4115     }
       
  4116 
       
  4117 // ---------------------------------------------------------
       
  4118 // CMmsViewerAppUi::MediaCanStop( )
       
  4119 // ---------------------------------------------------------
       
  4120 //
       
  4121 TBool CMmsViewerAppUi::MediaCanStop(CMsgMediaControl* aMedia)
       
  4122     {
       
  4123     if ( aMedia )
       
  4124         {
       
  4125         TMsgAsyncControlState state = aMedia->State( );
       
  4126         if (    state == EMsgAsyncControlStateAboutToPlay
       
  4127             ||  state == EMsgAsyncControlStateBuffering
       
  4128             ||  state == EMsgAsyncControlStatePlaying
       
  4129             ||  state == EMsgAsyncControlStatePaused )
       
  4130             {
       
  4131             return ETrue;
       
  4132             }
       
  4133         }
       
  4134     return EFalse;
       
  4135     }
       
  4136 
       
  4137 
       
  4138 // ---------------------------------------------------------
       
  4139 // CMmsViewerAppUi::MediaIsRunning( )
       
  4140 // ---------------------------------------------------------
       
  4141 //
       
  4142 TBool CMmsViewerAppUi::MediaIsRunning(CMsgMediaControl* aMedia)
       
  4143     {
       
  4144     if ( aMedia )
       
  4145         {
       
  4146         TMsgAsyncControlState state = aMedia->State( );
       
  4147         if ( state == EMsgAsyncControlStatePlaying )
       
  4148             {
       
  4149             return ETrue;
       
  4150             }
       
  4151         }
       
  4152     return EFalse;
       
  4153     }
       
  4154 
       
  4155 
       
  4156 
       
  4157 // ---------------------------------------------------------
       
  4158 // CMmsViewerAppUi::ResolveDrmWaitingNotes( )
       
  4159 // ---------------------------------------------------------
       
  4160 //
       
  4161 void CMmsViewerAppUi::ResolveDrmWaitingNotes( )
       
  4162     {
       
  4163         // resolve need of R_MMSVIEWER_DRM_PREVIEW_RIGHTS
       
  4164     TBool jumpOut(EFalse);
       
  4165     
       
  4166         // go through all recipients
       
  4167     CUniObjectList* objectList = Document( )->ObjectList( );
       
  4168     TInt objectCount = 0;
       
  4169     if (objectList)
       
  4170         {
       
  4171         objectCount = objectList->Count( );
       
  4172         }
       
  4173         
       
  4174     for ( TInt i = 0; i < objectCount && !jumpOut; i++ )
       
  4175         {
       
  4176         CUniObject* obj = objectList->GetByIndex( i );
       
  4177         if ( obj )
       
  4178             {
       
  4179             switch ( obj->Region( ) )
       
  4180                 {
       
  4181                 case EUniRegionImage:
       
  4182                     // fall through
       
  4183                 case EUniRegionAudio:
       
  4184                     if (    obj->DrmInfo( )
       
  4185                         &&  obj->DrmInfo( )->IsDrmWithOnePreview( ) )
       
  4186                         {
       
  4187                         SetPendingNote( R_MMSVIEWER_DRM_PREVIEW_RIGHTS, obj );
       
  4188                         jumpOut = ETrue;
       
  4189                         }
       
  4190                     break;
       
  4191                 case EUniRegionText:
       
  4192                 case EUniRegionUnresolved:
       
  4193                 default:
       
  4194                     // not interested
       
  4195                     break;
       
  4196                 }
       
  4197             }
       
  4198         }
       
  4199     }
       
  4200 
       
  4201 // ---------------------------------------------------------
       
  4202 // CMmsViewerAppUi::SaveObjectL( )
       
  4203 // ---------------------------------------------------------
       
  4204 //
       
  4205 void CMmsViewerAppUi::SaveObjectL( )
       
  4206     {
       
  4207     // returns only image, audio, video and svg controls
       
  4208     CMsgMediaControl* mediaControl = MediaControlById( FocusedControlId( ) );
       
  4209     CMsgBaseControl* control = mediaControl;
       
  4210     if ( !control )
       
  4211         {
       
  4212         if (    iView->FocusedControl()
       
  4213             &&  iView->FocusedControl()->ControlType() == EMsgXhtmlBodyControl )
       
  4214             {
       
  4215             control = iView->FocusedControl();
       
  4216             }
       
  4217         }
       
  4218 
       
  4219     if ( control )
       
  4220         {
       
  4221         // if-branch intended for multimedia and xHTML
       
  4222         CUniObject* obj = ObjectByBaseControl( *control );
       
  4223         if ( obj )
       
  4224             {   
       
  4225             DoSaveObjectL( *obj );
       
  4226             }
       
  4227         }
       
  4228     else if (FocusedControlId( ) == EMsgComponentIdBody )
       
  4229         {
       
  4230         CUniObject* textObj = NULL;
       
  4231         TUint objectCount = iSmilModel->SlideObjectCount( Document( )->CurrentSlide( ) );
       
  4232         for ( TUint i = 0; i < objectCount; i++ )
       
  4233             {
       
  4234             CUniObject* obj = iSmilModel->GetObjectByIndex( Document( )->CurrentSlide( ), i );
       
  4235             if ( obj->Region( ) == EUniRegionText )
       
  4236                 {
       
  4237                 // found
       
  4238                 textObj = obj;
       
  4239                 break;
       
  4240                 }
       
  4241             }
       
  4242 
       
  4243         if (    textObj
       
  4244             &&  textObj->MediaType( ) == EMsgMediaText )
       
  4245             {
       
  4246             // Save text files directly to Notepad.
       
  4247             // This is needed because automatic character set recognation
       
  4248             // is not too reliable.
       
  4249             TUint mibCharset = textObj->MimeInfo( )->Charset( );
       
  4250             if ( !mibCharset )
       
  4251                 {
       
  4252                 //assume US-ASCII - mandated by RFC 2046
       
  4253                 mibCharset = KCharacterSetMIBEnumUsAscii;
       
  4254                 }
       
  4255 
       
  4256             TUint charconvCharsetID = Document( )->DataUtils( )->MibIdToCharconvIdL( mibCharset );
       
  4257             RFile textFile = Document( )->GetAttachmentFileL( *textObj );
       
  4258 
       
  4259             CleanupClosePushL( textFile );
       
  4260             
       
  4261             CNotepadApi::SaveFileAsMemoL(
       
  4262                 textFile, 
       
  4263                 charconvCharsetID );
       
  4264 
       
  4265             CleanupStack::PopAndDestroy(&textFile);
       
  4266 
       
  4267             // Show confirmation note
       
  4268             RApaLsSession appList;
       
  4269             if ( appList.Connect( ) == KErrNone )
       
  4270                 {
       
  4271                 TApaAppInfo appInfo;
       
  4272                 if ( appList.GetAppInfo( appInfo, KNotepadUID3 ) == KErrNone )
       
  4273                     {
       
  4274                     textObj->SetSaved( ETrue );
       
  4275                     HBufC* text = StringLoader::LoadLC( R_MMS_FILE_SAVED_TO, appInfo.iCaption );
       
  4276                     CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
  4277                     note->ExecuteLD( *text );
       
  4278                     CleanupStack::PopAndDestroy( text );
       
  4279                     }
       
  4280                 appList.Close( );
       
  4281                 }
       
  4282             }
       
  4283         }
       
  4284     }
       
  4285 
       
  4286 
       
  4287 // ---------------------------------------------------------
       
  4288 // CMmsViewerAppUi::DoSaveObjectL( )
       
  4289 // ---------------------------------------------------------
       
  4290 //
       
  4291 void CMmsViewerAppUi::DoSaveObjectL(CUniObject& aObject )
       
  4292     {
       
  4293     CMsgMediaInfo* media = aObject.MediaInfo( );
       
  4294     if ( media )
       
  4295         {                
       
  4296         TParsePtrC plainFileName( media->FullFilePath( ) );
       
  4297         const TPtrC newName = plainFileName.NameAndExt( );
       
  4298         TDataType dataType( aObject.MimeType( ) );
       
  4299   
       
  4300         CDocumentHandler* docHandler = CDocumentHandler::NewL( );
       
  4301         CleanupStack::PushL(docHandler);
       
  4302 
       
  4303         RFile mediaFile = Document( )->GetAttachmentFileL( aObject );
       
  4304         CleanupClosePushL( mediaFile );
       
  4305         
       
  4306         TInt ret = docHandler->CopyL(   mediaFile, 
       
  4307                                         newName, 
       
  4308                                         dataType, 
       
  4309                                         KEntryAttNormal );
       
  4310         if ( ret != KErrNone && ret != KUserCancel )
       
  4311             {
       
  4312             User::LeaveIfError( ret );
       
  4313             }
       
  4314         else if (   ret == KErrNone ) 
       
  4315             {
       
  4316             aObject.SetSaved( ETrue );
       
  4317             }
       
  4318 
       
  4319         CleanupStack::PopAndDestroy(2, docHandler); // + mediaFile
       
  4320         }
       
  4321     }
       
  4322 
       
  4323         
       
  4324 // ----------------------------------------------------
       
  4325 // IsSilenceL
       
  4326 // 
       
  4327 // ----------------------------------------------------
       
  4328 TBool CMmsViewerAppUi:: IsSilenceL( )
       
  4329     {
       
  4330     TBool result( EFalse );
       
  4331     
       
  4332     CRepository* repository = CRepository::NewLC( KCRUidProfileEngine );
       
  4333     
       
  4334     TInt ringType( EProfileRingingTypeRinging );
       
  4335     User::LeaveIfError( repository->Get( KProEngActiveRingingType, ringType ) );
       
  4336     CleanupStack::PopAndDestroy( repository );
       
  4337     
       
  4338     if ( ringType == EProfileRingingTypeSilent )
       
  4339         {
       
  4340         result = ETrue;
       
  4341         }
       
  4342     return result;
       
  4343     }
       
  4344 
       
  4345 
       
  4346 // ---------------------------------------------------------
       
  4347 // CMmsViewerAppUi::OpenDeliveryPopupL( )
       
  4348 // Forwards the request to the MMS UI 
       
  4349 // ---------------------------------------------------------
       
  4350 //
       
  4351 void CMmsViewerAppUi::OpenDeliveryPopupL( )
       
  4352     {
       
  4353    
       
  4354    //These are not used! They just have to be there.
       
  4355     TPckgBuf<TInt> param( 0 ); 
       
  4356     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  4357     CleanupStack::PushL( selection );
       
  4358 
       
  4359     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *Document( ) );
       
  4360     CMsvOperation* op = Document( )->MtmUiL( ).InvokeAsyncFunctionL( 
       
  4361         KMtmUiFunctionDeliveryStatus,
       
  4362         *selection,
       
  4363         watch->iStatus,
       
  4364         param ); // launch the dialog through MMSUI
       
  4365     CleanupStack::Pop( watch ); 
       
  4366     Document( )->AddSingleOperationL( op, watch );
       
  4367 
       
  4368     CleanupStack::PopAndDestroy( selection );
       
  4369     }
       
  4370 
       
  4371 
       
  4372 // ---------------------------------------------------------
       
  4373 // CMmsViewerAppUi::HandleResourceChangeL
       
  4374 // ---------------------------------------------------------
       
  4375 //
       
  4376 void CMmsViewerAppUi::HandleResourceChangeL(TInt aType)
       
  4377     {
       
  4378     // Base class call must be first
       
  4379     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  4380 
       
  4381     if ( iHeader )
       
  4382         {
       
  4383         iHeader->HandleResourceChange(aType);
       
  4384         }
       
  4385 
       
  4386     if ( aType == KAknsMessageSkinChange )
       
  4387         {
       
  4388         if ( iAppIcon )
       
  4389             {
       
  4390             delete iAppIcon;
       
  4391             iAppIcon = NULL;
       
  4392             }
       
  4393     
       
  4394       	// Set path of bitmap file
       
  4395       	TParse fileParse;
       
  4396       	fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL );
       
  4397         
       
  4398         iAppIcon = AknsUtils::CreateGulIconL( 
       
  4399             AknsUtils::SkinInstance(), 
       
  4400             KAknsIIDQgnPropMceMmsTitle,
       
  4401             fileParse.FullName(),
       
  4402             EMbmMmsuiQgn_prop_mce_mms_title,
       
  4403             EMbmMmsuiQgn_prop_mce_mms_title_mask );
       
  4404         SetTitleIconL();   
       
  4405         }
       
  4406     else if ( aType == KEikDynamicLayoutVariantSwitch && IsLaunched() )
       
  4407         {
       
  4408         SetTitleIconL();   
       
  4409         }
       
  4410     }
       
  4411 
       
  4412 // ---------------------------------------------------------
       
  4413 // IsLaunched
       
  4414 // ---------------------------------------------------------
       
  4415 inline TBool CMmsViewerAppUi::IsLaunched( ) const
       
  4416     {
       
  4417     return ( iViewerFlags & ELaunchSuccessful );
       
  4418     }
       
  4419 
       
  4420 
       
  4421 // ---------------------------------------------------------
       
  4422 // PrepareToExit
       
  4423 // ---------------------------------------------------------
       
  4424 void  CMmsViewerAppUi::PrepareToExit( )
       
  4425     {
       
  4426     CEikAppUi::PrepareToExit( );
       
  4427     }
       
  4428     
       
  4429 // ---------------------------------------------------------
       
  4430 // ObjectByMediaControl
       
  4431 // ---------------------------------------------------------
       
  4432 CUniObject* CMmsViewerAppUi::ObjectByMediaControl( CMsgMediaControl& aControl )
       
  4433     {  
       
  4434     TInt controlId = aControl.ControlId( );
       
  4435     if (    controlId == EMsgComponentIdImage
       
  4436         ||  controlId == EMsgComponentIdAudio
       
  4437         ||  controlId == EMsgComponentIdVideo 
       
  4438 #ifdef RD_SVGT_IN_MESSAGING
       
  4439         ||  controlId == EMsgComponentIdSvg
       
  4440 #endif            
       
  4441         )
       
  4442         {
       
  4443         return ObjectByBaseControl( aControl );
       
  4444         }
       
  4445     else
       
  4446         {
       
  4447         return NULL;
       
  4448         }
       
  4449     
       
  4450     }
       
  4451 
       
  4452 // ---------------------------------------------------------
       
  4453 // ObjectByBaseControl
       
  4454 // ---------------------------------------------------------
       
  4455 CUniObject* CMmsViewerAppUi::ObjectByBaseControl( CMsgBaseControl& aControl )
       
  4456     {    
       
  4457     TInt controlId = aControl.ControlId( );
       
  4458     TUniRegion region( EUniRegionUnresolved );
       
  4459     switch ( controlId )
       
  4460         {
       
  4461         case EMsgComponentIdImage:
       
  4462             region = EUniRegionImage;
       
  4463             break;
       
  4464         case EMsgComponentIdAudio:
       
  4465             region = EUniRegionAudio;
       
  4466             break;
       
  4467         case EMsgComponentIdVideo:
       
  4468             region = EUniRegionImage;
       
  4469             break;
       
  4470 #ifdef RD_SVGT_IN_MESSAGING
       
  4471         case EMsgComponentIdSvg:
       
  4472             region = EUniRegionImage;
       
  4473             break;
       
  4474 #endif            
       
  4475         case EMsgComponentIdBody:
       
  4476             region = EUniRegionText;
       
  4477             break;
       
  4478         default:
       
  4479             break;
       
  4480         }
       
  4481     if ( region == EUniRegionUnresolved )
       
  4482         {
       
  4483         return NULL;
       
  4484         }
       
  4485               
       
  4486     if ( iSmilModel )
       
  4487         {         
       
  4488         TInt countObjectsOnSlide( 
       
  4489                 iSmilModel->SlideObjectCount( Document( )->CurrentSlide( ) ) );
       
  4490         for ( TInt i = 0;  i < countObjectsOnSlide; i++ )
       
  4491             {
       
  4492             CUniObject* object = iSmilModel->GetObject( 
       
  4493                                     Document( )->CurrentSlide( ), region );
       
  4494             if ( object )
       
  4495                 {
       
  4496                 return object;
       
  4497                 }
       
  4498             }
       
  4499         }
       
  4500     return NULL;
       
  4501     }
       
  4502 
       
  4503     
       
  4504 // ---------------------------------------------------------
       
  4505 // CMmsViewerAppUi::SetAndSaveDescriptionL
       
  4506 // ---------------------------------------------------------
       
  4507 //
       
  4508 void CMmsViewerAppUi::CheckAndSetDescriptionL( )
       
  4509     {    
       
  4510     TMsvEntry tEntry = Document( )->Entry( );
       
  4511     if( !tEntry.iDescription.Length( ) )
       
  4512         {
       
  4513         // is it on current slide
       
  4514         CMsgBodyControl* bodyControl = static_cast<CMsgBodyControl*>
       
  4515             ( iView->ControlById( EMsgComponentIdBody ) );
       
  4516         if ( bodyControl )
       
  4517             {
       
  4518             SetAndSaveDescriptionL(bodyControl->TextContent( ));
       
  4519             }
       
  4520         else 
       
  4521             {
       
  4522             // Continue searching from other slides
       
  4523             // Take first text attachment     
       
  4524             CUniSmilModel* smilModel = Document( )->SmilModel( );
       
  4525             if ( smilModel )
       
  4526                 {
       
  4527                 // search for first text attachment
       
  4528                 TInt slideCount = smilModel->SlideCount( );
       
  4529                 for (TInt slideI = 1; slideI < slideCount ; slideI++ )
       
  4530                     {
       
  4531                     TInt objectCountOnSlide = smilModel->SlideObjectCount( slideI );
       
  4532                     for (TInt objectI = 0; objectI < objectCountOnSlide ; objectI++ )
       
  4533                         {
       
  4534                         CUniObject* obj = smilModel->GetObjectByIndex( slideI, objectI );
       
  4535                         if (    obj 
       
  4536                             &&  obj->Region( ) == EUniRegionText )
       
  4537                             {
       
  4538                             TUint attaCharset = obj->MimeInfo( )->Charset( );
       
  4539                             if ( !attaCharset )
       
  4540                                 {
       
  4541                                 //assume US-ASCII - mandated by RFC 2046
       
  4542                                 attaCharset = KMmsUsAscii;
       
  4543                                 }
       
  4544 
       
  4545                             TUint charconvCharsetID = 0;
       
  4546                             charconvCharsetID = Document( )->DataUtils()->MibIdToCharconvIdL( attaCharset );
       
  4547                             RFile file = Document( )->GetAttachmentFileL( *obj );
       
  4548                             CleanupClosePushL( file );
       
  4549                             
       
  4550                             RFileReadStream stream( file );
       
  4551                             CleanupClosePushL( stream );
       
  4552                             
       
  4553                             CPlainText::TImportExportParam param;
       
  4554                             param.iForeignEncoding = charconvCharsetID;
       
  4555                             param.iOrganisation = CPlainText::EOrganiseByParagraph; 
       
  4556                             
       
  4557                             CPlainText::TImportExportResult result;
       
  4558                                                 
       
  4559                             CPlainText* plainText = CPlainText::NewL( );
       
  4560                             CleanupStack::PushL( plainText );
       
  4561                             
       
  4562                             plainText->ImportTextL( 0, stream, param, result );
       
  4563                             SetAndSaveDescriptionL( *plainText );
       
  4564                             
       
  4565                             CleanupStack::PopAndDestroy( 3, &file ); // plainText, file, stream
       
  4566                             break;
       
  4567                             } // else - no object or wrong type of object
       
  4568                         } // for - objects of one slide
       
  4569                     } // for - slides
       
  4570                 }// else - no smil model
       
  4571             } // else - no body text on first slide
       
  4572         } // else - description exists
       
  4573     }
       
  4574     
       
  4575 // ---------------------------------------------------------
       
  4576 // CMmsViewerAppUi::SetAndSaveDescriptionL
       
  4577 // ---------------------------------------------------------
       
  4578 //
       
  4579 void CMmsViewerAppUi::SetAndSaveDescriptionL(const CPlainText& aText)
       
  4580     {
       
  4581     TBuf<KMmsMaxDescription> description;
       
  4582     description.Zero( );
       
  4583     aText.Extract( description, 0, KMmsMaxDescription );
       
  4584     TInt length( description.Length( ) );
       
  4585     while( length-- )
       
  4586         {
       
  4587 
       
  4588         if (    description[length] == CEditableText::ETabCharacter
       
  4589             ||  description[length] == CEditableText::EPageBreak
       
  4590             ||  description[length] == CEditableText::ENonBreakingSpace
       
  4591             ||  description[length] == CEditableText::EHyphen
       
  4592             ||  description[length] == CEditableText::ENonBreakingHyphen
       
  4593             ||  description[length] == CEditableText::ELeftSingleQuote
       
  4594             ||  description[length] == CEditableText::ERightSingleQuote
       
  4595             ||  description[length] == CEditableText::ELeftDoubleQuote
       
  4596             ||  description[length] == CEditableText::ERightDoubleQuote
       
  4597             ||  description[length] == CEditableText::EBullet
       
  4598             ||  description[length] == CEditableText::EEllipsis
       
  4599             ||  description[length] == CEditableText::ELineBreak
       
  4600             ||  description[length] == CEditableText::EParagraphDelimiter 
       
  4601             ||  description[length] == CEditableText::EPictureCharacter
       
  4602             ||  description[length] == CEditableText::EZeroWidthNoBreakSpace
       
  4603             ||  description[length] == CEditableText::EByteOrderMark
       
  4604             ||  description[length] == CEditableText::EReversedByteOrderMark            
       
  4605             ||  description[length] == '\n' )
       
  4606             {
       
  4607             description[length] = ' ';
       
  4608             }
       
  4609         }
       
  4610     description.Trim( );
       
  4611 
       
  4612     if ( description.Length( ) > 0 )
       
  4613         {
       
  4614         TMsvEntry tEntry = Document( )->Entry( );        
       
  4615         tEntry.iDescription.Set( description );
       
  4616         Document( )->CurrentEntry( ).ChangeL( tEntry );
       
  4617         }
       
  4618     }
       
  4619 
       
  4620 
       
  4621 
       
  4622 // ---------------------------------------------------------
       
  4623 // CMmsViewerAppUi::ViewImageL
       
  4624 // ---------------------------------------------------------
       
  4625 //
       
  4626 void CMmsViewerAppUi::ViewImageL( CMsgMediaControl& aMediaCtrl )
       
  4627     {
       
  4628     CUniObject* launchObject = ObjectByMediaControl( aMediaCtrl );
       
  4629     if ( !launchObject )
       
  4630         {
       
  4631         return;
       
  4632         }
       
  4633       
       
  4634     if ( !iDocHandler )
       
  4635         {
       
  4636         iDocHandler = CDocumentHandler::NewL( );
       
  4637         iDocHandler->SetExitObserver( this );
       
  4638         }
       
  4639     
       
  4640     if ( &aMediaCtrl == iImage && 
       
  4641         ( reinterpret_cast< CMsgImageControl& >( aMediaCtrl ).IsAnimation() ) )       
       
  4642         {
       
  4643         aMediaCtrl.Stop( );
       
  4644         }
       
  4645     
       
  4646     if ( launchObject->DrmInfo() )
       
  4647         {
       
  4648         launchObject->DrmInfo()->ReleaseRights();
       
  4649         }
       
  4650         
       
  4651     TDataType mimeDataType( launchObject->MimeType() );
       
  4652 
       
  4653     RFile sharedFile = Document( )->GetAttachmentFileL( *launchObject );
       
  4654     CleanupClosePushL( sharedFile );
       
  4655     
       
  4656     CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();   
       
  4657     if ( !launchObject->IsSaved() )
       
  4658         {
       
  4659         TAiwGenericParam genericParamAllowSave
       
  4660             ( EGenericParamAllowSave, ETrue);
       
  4661         paramList->AppendL( genericParamAllowSave );
       
  4662         }
       
  4663 
       
  4664     TInt err( KErrNone );
       
  4665     TRAP( err, err = iDocHandler->OpenFileEmbeddedL(    sharedFile,
       
  4666                                                         mimeDataType,
       
  4667                                                         *paramList ) );
       
  4668     LOGTEXT2(_L16("CMmsViewerAppUi::ViewImageL error %d"), err );
       
  4669     CleanupStack::PopAndDestroy( 2, &sharedFile );  // + paramList
       
  4670     }
       
  4671 
       
  4672 // ---------------------------------------------------------
       
  4673 // CMmsViewerAppUi::HandleServerAppExit
       
  4674 // ---------------------------------------------------------
       
  4675 //
       
  4676 void CMmsViewerAppUi::HandleServerAppExit(TInt /*aReason*/)
       
  4677     {
       
  4678     // Currently only image is possible
       
  4679     if (    iImage 
       
  4680         &&  iImage->IsAnimation() )
       
  4681         {
       
  4682         TRAP_IGNORE( iImage->PlayL( ) );
       
  4683         }
       
  4684     }
       
  4685     
       
  4686 // ---------------------------------------------------------
       
  4687 // CMmsViewerAppUi::HandleConsumeRightsL
       
  4688 // ---------------------------------------------------------
       
  4689 //
       
  4690 TBool CMmsViewerAppUi::HandleConsumeRightsL( CMsgMediaControl& aMedia ) 
       
  4691     {        
       
  4692     TBool result( ETrue );
       
  4693 
       
  4694     CUniObject* object = ObjectByMediaControl( aMedia);
       
  4695     TBuf<ContentAccess::KMaxCafUniqueId> defaultContent( ContentAccess::KDefaultContentObject( ) );
       
  4696     if (    object
       
  4697         &&  object->DrmInfo( )
       
  4698         &&  defaultContent == aMedia.UniqueContentId( ) )
       
  4699         {
       
  4700         TInt err = object->DrmInfo( )->ConsumeRights( );
       
  4701         switch ( err )
       
  4702             {
       
  4703             case KErrNone:
       
  4704                 break;
       
  4705             case DRMCommon::EGeneralError:
       
  4706             case DRMCommon::EUnknownMIME:
       
  4707             case DRMCommon::EVersionNotSupported:
       
  4708             case DRMCommon::ESessionError:
       
  4709             case DRMCommon::ENoRights:
       
  4710             case DRMCommon::ERightsDBCorrupted:
       
  4711             case DRMCommon::EUnsupported:
       
  4712             case DRMCommon::ERightsExpired:
       
  4713             case DRMCommon::EInvalidRights:
       
  4714                 SetPendingNote( R_MMSVIEWER_DRM_ERROR, 
       
  4715                                 object, 
       
  4716                                 err );
       
  4717                 result = EFalse;
       
  4718                 break;
       
  4719             default: 
       
  4720                 SetPendingNote(R_QTN_MMS_CANNOT_OPEN_CORRUPTED);
       
  4721                 object->SetCorrupted( ETrue );            
       
  4722                 result = EFalse;
       
  4723                 break;
       
  4724             }
       
  4725         }
       
  4726 
       
  4727     if ( !result )
       
  4728         {
       
  4729         iSlideLoader->UpdateControlIconL( aMedia, object );
       
  4730         aMedia.DrawDeferred();
       
  4731         ShowPendingNoteL( );
       
  4732         }
       
  4733     return result; 
       
  4734     }
       
  4735 
       
  4736 // ---------------------------------------------------------
       
  4737 // CMmsViewerAppUi::HandleImageNoRightsInLaunch
       
  4738 // ---------------------------------------------------------
       
  4739 //
       
  4740 void CMmsViewerAppUi::HandleImageNoRightsInLaunch( ) 
       
  4741     {        
       
  4742     if ( iImage )
       
  4743         {
       
  4744         CUniObject* object = ObjectByMediaControl( *iImage );
       
  4745         if (    object
       
  4746             &&  object->DrmInfo( ) )
       
  4747             {
       
  4748             TBool ignoreConsumed ( EFalse );
       
  4749             TInt err = object->DrmInfo( )->EvaluateRights( ignoreConsumed );
       
  4750             switch ( err )
       
  4751                 {
       
  4752                 case KErrNone:
       
  4753                     break;
       
  4754                 case DRMCommon::EGeneralError:
       
  4755                 case DRMCommon::EUnknownMIME:
       
  4756                 case DRMCommon::EVersionNotSupported:
       
  4757                 case DRMCommon::ESessionError:
       
  4758                 case DRMCommon::ENoRights:
       
  4759                 case DRMCommon::ERightsDBCorrupted:
       
  4760                 case DRMCommon::EUnsupported:
       
  4761                 case DRMCommon::ERightsExpired:
       
  4762                 case DRMCommon::EInvalidRights:
       
  4763                     SetPendingNote( R_MMSVIEWER_DRM_ERROR, 
       
  4764                                     object, 
       
  4765                                     err );
       
  4766                     break;
       
  4767                 default: 
       
  4768                     break;
       
  4769                 }
       
  4770             }
       
  4771         }
       
  4772     }
       
  4773 
       
  4774 // ---------------------------------------------------------
       
  4775 // CMmsViewerAppUi::UpdateMskL
       
  4776 // ---------------------------------------------------------
       
  4777 void CMmsViewerAppUi::UpdateMskL( )
       
  4778     {
       
  4779 	TInt resId = (-1);
       
  4780     if ( iView && iViewerState == ENormal ) 
       
  4781         {
       
  4782         CMsgBaseControl* ctrl = iView->FocusedControl();
       
  4783         if ( ctrl )
       
  4784             {
       
  4785             // If entered here, some command must be set even empty
       
  4786             switch ( ctrl->ControlId() )
       
  4787                 {
       
  4788                 case EMsgComponentIdAttachment:
       
  4789                     resId = R_MMSVIEWER_MSK_BUTTON_OPEN_OBJECTS;
       
  4790                     break;
       
  4791                 case EMsgComponentIdImage:
       
  4792                     if ( Document( )->SmilType( ) != EMmsSmil )
       
  4793                         {
       
  4794                         resId = R_MMSVIEWER_MSK_BUTTON_PLAY_PRESENTATION;
       
  4795                         }
       
  4796                     else if (   MediaInitializedL( iImage ) )
       
  4797                         {    
       
  4798                         resId = R_MMSVIEWER_MSK_BUTTON_OPEN_IMAGE;
       
  4799                         }
       
  4800                     else
       
  4801                         {
       
  4802                         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4803                         }
       
  4804                     break;
       
  4805                 case EMsgComponentIdAudio:
       
  4806                     if ( MediaIsRunning( iAudio ) )
       
  4807                         {
       
  4808                         resId = R_MMSVIEWER_MSK_BUTTON_STOP_AUDIO;
       
  4809                         }                        
       
  4810                     else if (   MediaInitializedL( iAudio ) )
       
  4811                         {
       
  4812                         resId = R_MMSVIEWER_MSK_BUTTON_PLAY_AUDIO;
       
  4813                         }
       
  4814                     else
       
  4815                         {
       
  4816                         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4817                         }
       
  4818                 	break;
       
  4819                 case EMsgComponentIdVideo:
       
  4820                     if ( MediaIsRunning( iVideo ) )
       
  4821                         {
       
  4822                         resId = R_MMSVIEWER_MSK_BUTTON_STOP_VIDEO;
       
  4823                         }
       
  4824                     else if (   MediaInitializedL( iVideo ) )
       
  4825                         {
       
  4826                         resId = R_MMSVIEWER_MSK_BUTTON_PLAY_VIDEO;
       
  4827                         }
       
  4828                     else
       
  4829                         {
       
  4830                         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4831                         }
       
  4832                 	break;
       
  4833 #ifdef RD_SVGT_IN_MESSAGING                 	
       
  4834                 case EMsgComponentIdSvg:
       
  4835                     if ( MediaIsRunning( iSvgt ) )
       
  4836                         {
       
  4837                         resId = R_MMSVIEWER_MSK_BUTTON_STOP_SVG;
       
  4838                         }
       
  4839                     else if (   MediaInitializedL( iSvgt ) )
       
  4840                         {
       
  4841                         resId = R_MMSVIEWER_MSK_BUTTON_PLAY_SVG;
       
  4842                         }
       
  4843                     else
       
  4844                         {
       
  4845                         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4846                         }
       
  4847                 	break;                
       
  4848 #endif                
       
  4849                 default: 
       
  4850                     {
       
  4851                     
       
  4852                     if (    iWaitDialog
       
  4853                         &&  (   iOpeningState == EOpeningMessage
       
  4854                             ||  iOpeningState == EOpeningSlide ) )
       
  4855                         {
       
  4856                         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4857                         }
       
  4858                     else
       
  4859                         {                                                    
       
  4860                         resId = R_MMSVIEWER_MSK_BUTTON_CONTEXT_MENU;
       
  4861                         if ( resId != iMskId )
       
  4862                             { 
       
  4863         		            MenuBar()->SetContextMenuTitleResourceId(
       
  4864         		                R_MMSVIEWER_SELECTMENU );
       
  4865                             }
       
  4866                         }
       
  4867                     break;
       
  4868                     }
       
  4869                 }
       
  4870             }
       
  4871         }
       
  4872     else if ( iView ) 
       
  4873         {
       
  4874         resId = R_MMSVIEWER_MSK_NO_COMMAND_EMPTY_TEXT;
       
  4875         }
       
  4876 
       
  4877     if (    resId != iMskId 
       
  4878         &&  resId != (-1) )
       
  4879         {
       
  4880         const TInt KMskPosition = 3;
       
  4881         CEikButtonGroupContainer* cba = Cba();
       
  4882         if ( cba )
       
  4883             {            
       
  4884             if( resId != 0 )
       
  4885             	{
       
  4886     	        cba->SetCommandL( KMskPosition, resId );
       
  4887             	}
       
  4888             else
       
  4889             	{ // nullify the command
       
  4890     	        cba->SetCommandL( KMskPosition, 0, KNullDesC( ) );
       
  4891             	}
       
  4892             cba->DrawDeferred( );
       
  4893             iMskId = resId;
       
  4894             }
       
  4895         }
       
  4896     return;
       
  4897     }
       
  4898 
       
  4899 // -----------------------------------------------------------------------------
       
  4900 // MediaHasNoDrmRights
       
  4901 // -----------------------------------------------------------------------------
       
  4902 //
       
  4903 TInt CMmsViewerAppUi::MediaHasNoDrmRights(CMsgMediaControl* aMedia)
       
  4904     {
       
  4905     TInt result = KErrNone;
       
  4906     if ( aMedia )
       
  4907         {
       
  4908         CUniObject* object = ObjectByMediaControl( *aMedia);
       
  4909         TBuf<ContentAccess::KMaxCafUniqueId> defaultContent( ContentAccess::KDefaultContentObject( ) );
       
  4910 
       
  4911         TBool ignoreConsumed (EFalse );
       
  4912         if (    object
       
  4913             &&  object->DrmInfo( ) )
       
  4914             {
       
  4915             result = object->DrmInfo( )->EvaluateRights( ignoreConsumed );
       
  4916             switch ( result )
       
  4917                 {
       
  4918                 case DRMCommon::EGeneralError:
       
  4919                 case DRMCommon::EUnknownMIME:
       
  4920                 case DRMCommon::EVersionNotSupported:
       
  4921                 case DRMCommon::ESessionError:
       
  4922                 case DRMCommon::ENoRights:
       
  4923                 case DRMCommon::ERightsDBCorrupted:
       
  4924                 case DRMCommon::EUnsupported:
       
  4925                 case DRMCommon::ERightsExpired:
       
  4926                 case DRMCommon::EInvalidRights:
       
  4927                     break;
       
  4928                 default:
       
  4929                     result = KErrNone;
       
  4930                     break;
       
  4931                 }
       
  4932             }
       
  4933         }
       
  4934     return result;
       
  4935     }
       
  4936 
       
  4937 // -----------------------------------------------------------------------------
       
  4938 // handles the touch-ui related control events for next/previous message
       
  4939 // -----------------------------------------------------------------------------
       
  4940 //
       
  4941 #ifdef RD_SCALABLE_UI_V2
       
  4942 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
  4943 void CMmsViewerAppUi::HandleNaviDecoratorEventL( TInt aEventID )     
       
  4944     {
       
  4945     if ( AknLayoutUtils::PenEnabled() )
       
  4946         {
       
  4947         if (    iNaviDecorator
       
  4948             &&  iNaviPane->Top( ) == iNaviDecorator )
       
  4949             {
       
  4950             if( IsNextMessageAvailableL( aEventID == EAknNaviDecoratorEventRightTabArrow ) )
       
  4951                 {
       
  4952                 /* no need for separate checks for right and left arrows
       
  4953                     because IsNextMessageAvailableL() and NextMessageL
       
  4954                     are called with the truth-value of the same comparison */
       
  4955                 NextMessageL( aEventID == EAknNaviDecoratorEventRightTabArrow );
       
  4956                 }
       
  4957             }
       
  4958         }
       
  4959     }
       
  4960 #endif // !RD_MSG_NAVIPANE_IMPROVEMENT
       
  4961 #endif // RD_SCALABLE_UI_V2
       
  4962 
       
  4963 // -----------------------------------------------------------------------------
       
  4964 // SendReadReportL
       
  4965 // -----------------------------------------------------------------------------
       
  4966 //
       
  4967 void CMmsViewerAppUi::SendReadReportL(  TMmsViewerOperationType     aOperation,
       
  4968                                         TMmsViewerOperationEvent    aEvent )
       
  4969     {
       
  4970     // send read report
       
  4971     if (    aOperation == EMmsViewerOperationLaunch
       
  4972         &&  aEvent == EMmsViewerOperationComplete 
       
  4973         &&  Document( )->LaunchFlags() & EMsgUnreadMessage )
       
  4974         {
       
  4975         iSendReadReportOperation = new (ELeave ) CMmsViewerSendReadReportOperation(
       
  4976                                                     *this,
       
  4977                                                     *Document( ),
       
  4978                                                     iCoeEnv->FsSession( ) );
       
  4979         ActivateInputBlockerL( iSendReadReportOperation );
       
  4980         iSendReadReportOperation->SendReadReportL( );
       
  4981         }
       
  4982     }
       
  4983 
       
  4984 // -----------------------------------------------------------------------------
       
  4985 // HandleControlEventL
       
  4986 // -----------------------------------------------------------------------------
       
  4987 //
       
  4988 #ifdef RD_SCALABLE_UI_V2
       
  4989 void CMmsViewerAppUi::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType )
       
  4990 #else
       
  4991 void CMmsViewerAppUi::HandleControlEventL(CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/)
       
  4992 #endif
       
  4993     {
       
  4994 #ifdef RD_SCALABLE_UI_V2
       
  4995     if ( AknLayoutUtils::PenEnabled() )
       
  4996         {
       
  4997         if (    iVolumeDecorator
       
  4998             &&  iNaviPane->Top( ) == iVolumeDecorator 
       
  4999             &&  aControl == iVolumeDecorator->DecoratedControl()
       
  5000             &&  aEventType >= MAknNavigationObserver::ENaviEventHandleNavigation
       
  5001             &&  aEventType <= MAknNavigationObserver::ENaviEventAlreadyRightmostItem )
       
  5002             {
       
  5003             iViewerFlags |= EVolumeControlTriggered;
       
  5004             TRAP_IGNORE( ChangeVolumeL(   
       
  5005                             static_cast<CAknVolumeControl*>
       
  5006                                 ( iVolumeDecorator->DecoratedControl() )->Value( ), 
       
  5007                             EFalse ) );
       
  5008             iViewerFlags &= ( ~EVolumeControlTriggered );
       
  5009             }
       
  5010         }
       
  5011 
       
  5012 #endif
       
  5013     }
       
  5014 
       
  5015 // -----------------------------------------------------------------------------
       
  5016 // GetNonStoppingWGIdsL
       
  5017 // -----------------------------------------------------------------------------
       
  5018 //
       
  5019 void CMmsViewerAppUi::GetNonStoppingWgIds( )
       
  5020     {
       
  5021     iMmsViewerWgId = iCoeEnv->RootWin().Identifier();
       
  5022     CApaWindowGroupName::FindByAppUid(
       
  5023         KFastSwapAppUid,
       
  5024         iCoeEnv->WsSession(),
       
  5025         iFastSwapWgId );
       
  5026     CApaWindowGroupName::FindByAppUid(
       
  5027         KAknNotifyServerAppUid,
       
  5028         iCoeEnv->WsSession(),
       
  5029         iAknNotifyServerWgId );
       
  5030     CApaWindowGroupName::FindByAppUid(
       
  5031         KScreenSaverAppUid,
       
  5032         iCoeEnv->WsSession(),
       
  5033         iScreenSaverWgId );        
       
  5034     // start receivingn events
       
  5035     iCoeEnv->RootWin().EnableFocusChangeEvents();
       
  5036     }
       
  5037 
       
  5038 // -----------------------------------------------------------------------------
       
  5039 // ResolveCurrentWgIdL
       
  5040 // -----------------------------------------------------------------------------
       
  5041 //
       
  5042 void CMmsViewerAppUi::ResolveCurrentWgIdL( )
       
  5043     {
       
  5044     // magic constant
       
  5045     const TInt KSystemAppWgId( 4 );
       
  5046   	TInt windowGroupId = iEikonEnv->WsSession().GetFocusWindowGroup();
       
  5047 
       
  5048 /*#ifdef USE_LOGGER
       
  5049     CApaWindowGroupName* winGroupInfo = CApaWindowGroupName::NewL(iCoeEnv->WsSession() );
       
  5050     CleanupStack::PushL( winGroupInfo );
       
  5051     winGroupInfo->ConstructFromWgIdL( windowGroupId );
       
  5052     TUid uid = winGroupInfo->AppUid( );
       
  5053     TPtrC caption = winGroupInfo->Caption( );
       
  5054 
       
  5055     LOGTEXT2(_L16("HandleWsEventL EEventFocusLost winGroup: %d"), windowGroupId );
       
  5056     LOGTEXT2(_L16("HandleWsEventL EEventFocusLost appUid: 0x%x"), uid );
       
  5057     LOGTEXT2(_L16("HandleWsEventL EEventFocusLost caption: %S"), &caption );
       
  5058 
       
  5059     CleanupStack::PopAndDestroy( winGroupInfo );
       
  5060 #endif*/
       
  5061 
       
  5062     // Stop only if temporary change e.g. a waiting note etc.
       
  5063     if ( !  (   windowGroupId == iFastSwapWgId 
       
  5064             ||  windowGroupId == KSystemAppWgId 
       
  5065             ||  windowGroupId == iAknNotifyServerWgId 
       
  5066             ||  windowGroupId == iMmsViewerWgId 
       
  5067             ||  windowGroupId == iScreenSaverWgId ) )
       
  5068   	    {
       
  5069         iIsStopPlaybackWgId = ETrue;
       
  5070   	    }
       
  5071     }
       
  5072 
       
  5073 // ---------------------------------------------------------
       
  5074 // ActivateInputBlockerL
       
  5075 // ---------------------------------------------------------
       
  5076 //
       
  5077 void CMmsViewerAppUi::ActivateInputBlockerL( CActive* aActiveObjectToCancel )
       
  5078     {
       
  5079     LOGTEXT(_L8("CMmsViewerAppUi::ActivateInputBlockerL"));
       
  5080     delete iInputBlocker;
       
  5081     iInputBlocker = NULL;
       
  5082     
       
  5083     iInputBlocker = CAknInputBlock::NewLC();    
       
  5084     CleanupStack::Pop( iInputBlocker );
       
  5085     
       
  5086     if ( aActiveObjectToCancel )
       
  5087         {
       
  5088         iInputBlocker->SetCancelActive( aActiveObjectToCancel );
       
  5089         }
       
  5090     }
       
  5091  
       
  5092 // ---------------------------------------------------------
       
  5093 // DeactivateInputBlocker
       
  5094 // ---------------------------------------------------------
       
  5095 //
       
  5096 void CMmsViewerAppUi::DeactivateInputBlocker()
       
  5097     {
       
  5098     if ( iInputBlocker )
       
  5099         {
       
  5100         LOGTEXT(_L8("CMmsViewerAppUi::DeactivateInputBlockerL"));
       
  5101         iInputBlocker->SetCancelActive( NULL );    
       
  5102         delete iInputBlocker;
       
  5103         iInputBlocker = NULL;
       
  5104         }
       
  5105     }
       
  5106 
       
  5107 // ---------------------------------------------------------
       
  5108 // ResetOperationState
       
  5109 // ---------------------------------------------------------
       
  5110 //
       
  5111 void CMmsViewerAppUi::ResetOperationState()
       
  5112     {
       
  5113     // Operation by operation should be considered what is proper action 
       
  5114     // in Cancel situation
       
  5115     DeactivateInputBlocker();
       
  5116 
       
  5117     EndActiveWait();
       
  5118     delete iWaitDialog;
       
  5119     iWaitDialog = NULL;
       
  5120          
       
  5121     delete iScreenClearer;
       
  5122     iScreenClearer = NULL;
       
  5123 
       
  5124     // Following takes place also in Cancel event to enable 
       
  5125     // exit through HandleCommandL()
       
  5126     iViewerState = ENormal;
       
  5127     iOpeningState = EOpeningNone;
       
  5128     iViewerFlags |= ELaunchSuccessful;
       
  5129     }
       
  5130 
       
  5131 // ---------------------------------------------------------
       
  5132 // DoDelayedExit
       
  5133 // ---------------------------------------------------------
       
  5134 //
       
  5135 void CMmsViewerAppUi::DoDelayedExit( TInt aDelayTime )
       
  5136     {
       
  5137     LOGTEXT(_L8("CMmsViewerAppUi::DoDelayedExit in ") );
       
  5138     iIdle->Start( aDelayTime,
       
  5139                   aDelayTime, 
       
  5140                   TCallBack( DelayedExitL, this ));
       
  5141     }
       
  5142 
       
  5143 // ---------------------------------------------------------
       
  5144 // DelayedExit
       
  5145 // ---------------------------------------------------------
       
  5146 //
       
  5147 TInt CMmsViewerAppUi::DelayedExitL( TAny* aThis )
       
  5148     {
       
  5149     CMmsViewerAppUi* viewer = static_cast<CMmsViewerAppUi*>( aThis );
       
  5150     viewer->DoMsgSaveExitL();
       
  5151     return KErrNone;
       
  5152     }
       
  5153 // ---------------------------------------------------------
       
  5154 // IsVideoCall
       
  5155 // ---------------------------------------------------------
       
  5156 //
       
  5157  TBool CMmsViewerAppUi::IsVideoCall()
       
  5158  {
       
  5159     TInt callType;
       
  5160 
       
  5161     RProperty::Get( KPSUidCtsyCallInformation,
       
  5162                      KCTsyCallType,
       
  5163                      callType );// Ignore errors
       
  5164  
       
  5165      TBool videoCall = ( callType == EPSCTsyCallTypeH324Multimedia );   
       
  5166       
       
  5167      return videoCall;
       
  5168  }
       
  5169 // ---------------------------------------------------------
       
  5170 // DynInitToolbarL
       
  5171 // ---------------------------------------------------------
       
  5172 //
       
  5173 #ifdef RD_SCALABLE_UI_V2
       
  5174 void CMmsViewerAppUi::DynInitToolbarL(  TInt            /*aResourceId*/, 
       
  5175                                         CAknToolbar*    /*aToolbar*/ )
       
  5176     {
       
  5177     }
       
  5178 #endif        
       
  5179 // ---------------------------------------------------------
       
  5180 // OfferToolbarEventL
       
  5181 // ---------------------------------------------------------
       
  5182 //
       
  5183 #ifdef RD_SCALABLE_UI_V2
       
  5184 void CMmsViewerAppUi::OfferToolbarEventL( TInt aCommand )
       
  5185     {
       
  5186     switch ( aCommand )
       
  5187         {
       
  5188         case EMmsViewerToolbarReply:
       
  5189             if ( IsOwnMessage( ) )
       
  5190                 {
       
  5191                 HandleCommandL( EMmsViewerReplyToAll );
       
  5192                 }
       
  5193             else
       
  5194                 {
       
  5195                 HandleCommandL( EMmsViewerReplyToSender );
       
  5196                 }
       
  5197             
       
  5198             break;
       
  5199 
       
  5200         case EMmsViewerToolbarForward:
       
  5201             HandleCommandL( EMmsViewerForward );
       
  5202             break;
       
  5203 
       
  5204         case EMmsViewerToolbarDelete:
       
  5205             HandleCommandL( EMmsViewerDelete );
       
  5206             break;
       
  5207 
       
  5208         default:
       
  5209             break;
       
  5210         }
       
  5211     }
       
  5212 
       
  5213 // ---------------------------------------------------------
       
  5214 // SetToolBarItemVisibilities
       
  5215 // ---------------------------------------------------------
       
  5216 //
       
  5217 void CMmsViewerAppUi::SetToolBarItemVisibilities()
       
  5218     {
       
  5219     TBool replyDimming( EFalse );
       
  5220     TBool forwardDimming( EFalse );
       
  5221     TBool deleteDimming( EFalse );
       
  5222     
       
  5223     if ( iToolbar )
       
  5224         {                
       
  5225         CEikButtonGroupContainer* cba = Cba();
       
  5226         if (    cba
       
  5227             &&  !cba->ControlOrNull( EAknSoftkeyOptions ) )
       
  5228             {
       
  5229             // dim every item            
       
  5230             replyDimming = ETrue;
       
  5231             forwardDimming = ETrue;
       
  5232             deleteDimming = ETrue;
       
  5233             }
       
  5234         else
       
  5235             {
       
  5236             if ( IsOwnMessage( ) )
       
  5237                 {
       
  5238                 if (    !ShowReplyToAll( ) 
       
  5239                     ||  Document( )->IsUpload( ) )
       
  5240                     {
       
  5241                     replyDimming = ETrue;
       
  5242                     }
       
  5243                 }
       
  5244             else if ( !HasSender( ) )
       
  5245                 {
       
  5246                 replyDimming = ETrue;
       
  5247                 }
       
  5248             if ( iSmilModel->SlideCount( ) > iMaxForwardSlideCount )
       
  5249                 {
       
  5250                 forwardDimming = ETrue;
       
  5251                 }
       
  5252             }
       
  5253         iToolbar->SetItemDimmed(    EMmsViewerToolbarReply,
       
  5254                                     replyDimming,
       
  5255                                     ETrue );
       
  5256         iToolbar->SetItemDimmed(    EMmsViewerToolbarForward,
       
  5257                                     forwardDimming,
       
  5258                                     ETrue );
       
  5259         iToolbar->SetItemDimmed(    EMmsViewerToolbarDelete,
       
  5260                                     deleteDimming,
       
  5261                                     ETrue );
       
  5262         }
       
  5263     }
       
  5264 #endif
       
  5265 
       
  5266 // ---------------------------------------------------------
       
  5267 // AreControlsReadyAndWaitNoteDismissedL
       
  5268 // ---------------------------------------------------------
       
  5269 //
       
  5270 TBool CMmsViewerAppUi::AreControlsReadyAndWaitNoteDismissedL( )
       
  5271     {
       
  5272     if (    
       
  5273             MediaInitializedL( iImage ) 
       
  5274         &&  MediaInitializedL( iAudio ) 
       
  5275         &&  MediaInitializedL( iVideo )
       
  5276 #ifdef RD_SVGT_IN_MESSAGING
       
  5277         &&  MediaInitializedL( iSvgt )        
       
  5278 #endif        
       
  5279         &&  !iWaitDialog )
       
  5280         {
       
  5281         return ETrue;
       
  5282         }
       
  5283     return EFalse;
       
  5284     }
       
  5285 
       
  5286 
       
  5287 // ---------------------------------------------------------
       
  5288 // IsRightsConsumed
       
  5289 // ---------------------------------------------------------
       
  5290 //
       
  5291 TBool CMmsViewerAppUi::IsRightsConsumed( CUniObject& aObject ) const
       
  5292     {
       
  5293     TBool consumed( EFalse );
       
  5294     if (  aObject.DrmInfo( ) )
       
  5295         {
       
  5296         aObject.DrmInfo( )->EvaluateRights( consumed );
       
  5297         }
       
  5298     LOGTEXT2(_L16("CMmsViewerAppUi::IsRightsConsumed consumed %d"), consumed );
       
  5299     return consumed;
       
  5300     }
       
  5301 
       
  5302 // ---------------------------------------------------------
       
  5303 // IsRightsNow
       
  5304 // ---------------------------------------------------------
       
  5305 //
       
  5306 TBool CMmsViewerAppUi::IsRightsNow( CUniObject& aObject ) const
       
  5307     {
       
  5308     TBool rightsNow( EFalse );
       
  5309     if (  aObject.DrmInfo( ) )
       
  5310         {
       
  5311         TInt consumed( EFalse );
       
  5312         // KErrNone: rights exist
       
  5313         rightsNow = !aObject.DrmInfo( )->EvaluateRights( consumed );
       
  5314 
       
  5315         /*TBool rightsNow2( EFalse );
       
  5316         rightsNow2 = aObject.DrmInfo( )->RightsValidL( ETrue );
       
  5317         TInt j;
       
  5318         j++;*/
       
  5319         }
       
  5320     LOGTEXT2(_L16("CMmsViewerAppUi::IsRightsNow rightsNow %d"), rightsNow );
       
  5321 
       
  5322 
       
  5323     return rightsNow;
       
  5324     }
       
  5325     
       
  5326 // ---------------------------------------------------------
       
  5327 // IsDrmRightsWhenLoaded
       
  5328 // ---------------------------------------------------------
       
  5329 //
       
  5330 TBool CMmsViewerAppUi::IsDrmRightsWhenLoaded( CUniObject& aObject ) const
       
  5331     {
       
  5332     // Separate function just because of LOG traces
       
  5333     TBool rightsWhenLoaded = aObject.IsDrmRightsWhenLoaded();
       
  5334     LOGTEXT2(_L16("CMmsViewerAppUi::IsDrmRightsWhenLoaded rightsWhenLoaded %d"), rightsWhenLoaded );
       
  5335     return rightsWhenLoaded;
       
  5336     }
       
  5337            
       
  5338 // ---------------------------------------------------------
       
  5339 // HandleUniObjectEvent from MUniObjectObserver
       
  5340 // ---------------------------------------------------------
       
  5341 //
       
  5342 void  CMmsViewerAppUi::HandleUniObjectEvent(    CUniObject&    aUniObject,
       
  5343                                                 TUniObjectEvent aUniEvent )
       
  5344     {
       
  5345     LOGTEXT(_L8("CMmsViewerAppUi::HandleUniObjectEvent in ") );
       
  5346     // SVG is different. Drm rights are not consumed by us at all but external viewer
       
  5347     CMsgMediaControl* control = MediaControlByObject( aUniObject );
       
  5348     if (        aUniEvent == EUniObjectEventDrmRightsChanged
       
  5349             &&  control
       
  5350             &&  !(   control == iVideo 
       
  5351                 &&  iViewerFlags & EInObjectsView )
       
  5352             &&  aUniObject.DrmInfo( )
       
  5353             &&  (   
       
  5354                     (   IsDrmRightsWhenLoaded( aUniObject )
       
  5355                     &&  !IsRightsConsumed( aUniObject )
       
  5356                     &&  !IsRightsNow( aUniObject ) )
       
  5357                 ||  (   !IsDrmRightsWhenLoaded( aUniObject )
       
  5358                     &&  !IsRightsConsumed( aUniObject )
       
  5359                     &&  IsRightsNow( aUniObject ) )
       
  5360                 ) 
       
  5361         )
       
  5362         {
       
  5363 #ifdef RD_SVGT_IN_MESSAGING
       
  5364         if ( control == iSvgt )
       
  5365             {
       
  5366             // SVG is different. DRM rights are not consumed ever by us but thumbnail may be visible
       
  5367             // Thus, if SVG thumbnail becomes ever visible, don't remove it
       
  5368             if (    IsDrmRightsWhenLoaded( aUniObject )
       
  5369                 &&  !IsRightsConsumed( aUniObject )
       
  5370                 &&  !IsRightsNow( aUniObject ) )
       
  5371                 {
       
  5372                 return;
       
  5373                 }
       
  5374             }
       
  5375 #endif
       
  5376 
       
  5377         //          - Rights were initially when slide was loaded 
       
  5378         //      &&  - they were not consumed by us
       
  5379         //      &&  - they were consumed by someone else
       
  5380         // or       - Rights were not initially when slide was loaded 
       
  5381         //      &&  - they are not consumed by us
       
  5382         //      &&  - now there are rights
       
  5383         if (    !iViewerFlags & EInObjectsView
       
  5384             &&  IsDisplayingDialog() )
       
  5385             {
       
  5386             TKeyEvent keyEvent;
       
  5387             keyEvent.iCode = EKeyEscape;
       
  5388             keyEvent.iScanCode = EStdKeyEscape;
       
  5389             keyEvent.iModifiers = 0;
       
  5390             keyEvent.iRepeats = 0;
       
  5391             TRAP_IGNORE( iEikonEnv->SimulateKeyEventL(keyEvent,EEventKey) );
       
  5392             }
       
  5393         TRAP_IGNORE( ReloadControlL( control, aUniObject ) );
       
  5394         }
       
  5395     LOGTEXT(_L8("CMmsViewerAppUi::HandleUniObjectEvent out ") );
       
  5396     }
       
  5397 
       
  5398 // ---------------------------------------------------------
       
  5399 // SimulateUniObjectEventL
       
  5400 // ---------------------------------------------------------
       
  5401 //
       
  5402 void CMmsViewerAppUi::SimulateUniObjectEventL( )
       
  5403     {
       
  5404     iIdle->Cancel();
       
  5405     TInt j = 4;
       
  5406     CMsgMediaControl* control = NULL;
       
  5407     if (    j == 1
       
  5408         &&  iImage )
       
  5409         control = iImage;
       
  5410     if (    j == 2
       
  5411         &&  iAudio )
       
  5412         control = iAudio;
       
  5413     if (    j == 3
       
  5414         &&  iVideo )
       
  5415         control = iVideo;
       
  5416 #ifdef RD_SVGT_IN_MESSAGING              
       
  5417     if (    j == 4
       
  5418         &&  iSvgt )
       
  5419         control = iSvgt;
       
  5420 #endif        
       
  5421     if ( control )
       
  5422         {
       
  5423         CUniObject* uniObject = ObjectByBaseControl( *control );
       
  5424         if ( uniObject )
       
  5425             {
       
  5426             ReloadControlL( control, *uniObject );
       
  5427             }
       
  5428         }
       
  5429     }
       
  5430 
       
  5431 
       
  5432 // ---------------------------------------------------------
       
  5433 // MediaControlByObject
       
  5434 // ---------------------------------------------------------
       
  5435 CMsgMediaControl* CMmsViewerAppUi::MediaControlByObject( CUniObject&    aUniObject )
       
  5436     {    
       
  5437     CMsgMediaControl* control = NULL;
       
  5438     switch ( aUniObject.MediaType( ) )
       
  5439         {
       
  5440         case EMsgMediaImage:
       
  5441             control = iImage;
       
  5442             break;
       
  5443         case EMsgMediaAudio:
       
  5444             control = iAudio;
       
  5445             break;
       
  5446         case EMsgMediaVideo:
       
  5447             control = iVideo;
       
  5448             break;
       
  5449 #ifdef RD_SVGT_IN_MESSAGING
       
  5450         case EMsgMediaSvg:
       
  5451             control = iSvgt;
       
  5452             break;
       
  5453 #endif
       
  5454         default:
       
  5455             break;
       
  5456         }
       
  5457     return control;
       
  5458     
       
  5459     }
       
  5460 
       
  5461 
       
  5462 // ---------------------------------------------------------
       
  5463 // SetTitleIconL
       
  5464 // ---------------------------------------------------------
       
  5465 //
       
  5466 void CMmsViewerAppUi::SetTitleIconL()
       
  5467     {
       
  5468     SetTitleIconSizeL( iAppIcon->Bitmap() );
       
  5469     // Create duplicates of the icon to be used
       
  5470     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  5471     CleanupStack::PushL( bitmap );
       
  5472     
       
  5473     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  5474     CleanupStack::PushL( bitmapMask );
       
  5475     
       
  5476     User::LeaveIfError( bitmap->Duplicate( iAppIcon->Bitmap()->Handle() ) );
       
  5477     User::LeaveIfError( bitmapMask->Duplicate( iAppIcon->Mask()->Handle() ) );
       
  5478 
       
  5479     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  5480     iTitlePane->DrawNow();
       
  5481     
       
  5482     CleanupStack::Pop( bitmapMask );
       
  5483     CleanupStack::Pop( bitmap );
       
  5484     }
       
  5485 
       
  5486 //  End of File
       
  5487