videditor/TrimForMms/src/VeiTrimForMmsView.cpp
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 // System includes
       
    23 #include <aknviewappui.h>
       
    24 #include <akntitle.h>
       
    25 #include <aknnavi.h>        // CAknNavigationControlContainer
       
    26 #include <aknnavide.h>      // CAknNavigationDecorator
       
    27 #include <AknProgressDialog.h>      // CAknProgressDialog
       
    28 #include <aknsoundsystem.h>         // CAknKeySoundSystem
       
    29 #include <bautils.h>        // BaflUtils
       
    30 #include <barsread.h>
       
    31 #include <eikprogi.h>       // CEikProgressInfo
       
    32 #include <trimformms.rsg>
       
    33 #include <utf.h>        // CnvUtfConverter
       
    34 #include <sendui.h>     // CSendAppUi
       
    35 #include <SenduiMtmUids.h>
       
    36 #include <StringLoader.h>   // StringLoader 
       
    37 #include <CMessageData.h>
       
    38 // User includes
       
    39 #include "TrimForMms.hrh"
       
    40 #include "TrimForMmsAppUi.h"
       
    41 #include "VeiSettings.h"
       
    42 #include "VeiTrimForMmsView.h"
       
    43 #include "VeiTrimForMmsContainer.h"
       
    44 #include "VeiEditVideoLabelNavi.h"
       
    45 #include "VideoEditorCommon.h"
       
    46 #include "VeiTempMaker.h"
       
    47 #include "VideoEditorCommon.h"
       
    48 #include "VideoEditorDebugUtils.h"
       
    49 #include "VeiErrorUi.h"
       
    50 
       
    51 // CONSTANTS
       
    52 const TInt KVedVideoClipIndex(0);
       
    53 const TInt KProgressNoteMaxValue(100);
       
    54 const TInt KVedTrimForMmsDefaultCba( R_AVKON_SOFTKEYS_OPTIONS_BACK );
       
    55 
       
    56 
       
    57 CVeiTrimForMmsView* CVeiTrimForMmsView::NewL( CSendUi& aSendAppUi )
       
    58 	{
       
    59     CVeiTrimForMmsView* self = CVeiTrimForMmsView::NewLC( aSendAppUi );
       
    60     CleanupStack::Pop( self );
       
    61 
       
    62     return self;
       
    63 	}
       
    64 
       
    65 
       
    66 CVeiTrimForMmsView* CVeiTrimForMmsView::NewLC( CSendUi& aSendAppUi )
       
    67 	{
       
    68     CVeiTrimForMmsView* self = new (ELeave) CVeiTrimForMmsView( aSendAppUi );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71 
       
    72     return self;
       
    73 	}
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CVeiTrimForMmsView::ConstructL
       
    77 // Symbian 2nd phase constructor that can leave.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CVeiTrimForMmsView::ConstructL()
       
    81     {
       
    82     BaseConstructL( R_VEI_TRIM_FOR_MMS_VIEW );
       
    83 
       
    84     iErrorUi = CVeiErrorUI::NewL( *iCoeEnv );
       
    85 
       
    86 	iTempMaker = CVeiTempMaker::NewL();
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CVeiTrimForMmsView::CVeiTrimForMmsView( CSendUi& aSendAppUi )
       
    91 // C++ default constructor.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CVeiTrimForMmsView::CVeiTrimForMmsView( CSendUi& aSendAppUi ):
       
    95     iSendAppUi( aSendAppUi )
       
    96     {
       
    97     }
       
    98 
       
    99 
       
   100 CVeiTrimForMmsView::~CVeiTrimForMmsView()
       
   101     {
       
   102     if( iContainer )
       
   103         {
       
   104         AppUi()->RemoveFromStack( iContainer );
       
   105         delete iContainer;
       
   106         }
       
   107     if( iNaviDecorator )
       
   108         {
       
   109         delete iNaviDecorator;
       
   110         }
       
   111 
       
   112     if( iVedMovie )
       
   113         {
       
   114 		iVedMovie->UnregisterMovieObserver( this );
       
   115         delete iVedMovie;
       
   116         }
       
   117 
       
   118 	if ( iTempMaker )
       
   119 		{
       
   120 		delete iTempMaker;
       
   121 		iTempMaker = NULL;
       
   122 		}
       
   123 	if( iTempFile )
       
   124         {
       
   125 		TInt err = CCoeEnv::Static()->FsSession().Delete( *iTempFile );
       
   126 		if ( err ) 
       
   127 			{
       
   128 			// what to do when error occurs in destructor???
       
   129 			}
       
   130 
       
   131         delete iTempFile;
       
   132         }
       
   133 	
       
   134     delete iErrorUi;
       
   135     
       
   136     iProgressInfo = NULL;
       
   137     }
       
   138 
       
   139 
       
   140 TUid CVeiTrimForMmsView::Id() const
       
   141     {
       
   142     return TUid::Uid( EVeiTrimForMmsView );
       
   143     }
       
   144 
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CVeiTrimForMmsView::HandleCommandL( TInt aCommand )
       
   148 //
       
   149 //  
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 void CVeiTrimForMmsView::HandleCommandL( TInt aCommand )
       
   153     {
       
   154     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::HandleCommandL: In");
       
   155 	
       
   156 	TInt state;
       
   157 	state = iContainer->PreviewState();
       
   158 
       
   159     switch ( aCommand )
       
   160         {
       
   161         /**
       
   162          * Options -> Send via multimedia
       
   163          */
       
   164         case EVeiCmdSendViaMms:
       
   165             {
       
   166             CmdSendViaMultimediaL();
       
   167             break;
       
   168             }
       
   169         /**
       
   170          * Options -> Preview
       
   171          */
       
   172         case EVeiCmdPreview:
       
   173             {		
       
   174 			if(	state == EIdle || state == EStop ) 
       
   175 				{
       
   176 				SetTrimStateL( EFullPreview );
       
   177 				PlayPreviewL();
       
   178 				}
       
   179             break;
       
   180             }
       
   181         //
       
   182         // Options -> Help
       
   183         //
       
   184         case EVeiCmdTrimForMmsViewHelp:
       
   185             {
       
   186             AppUi()->HandleCommandL( aCommand );
       
   187             break;
       
   188             }
       
   189         /**
       
   190          * Options -> Back
       
   191          */
       
   192         case EAknSoftkeyBack:
       
   193             {
       
   194 			if( state != EFullPreview )
       
   195 				{
       
   196 				CmdSoftkeyBackL();
       
   197 				}
       
   198 			else
       
   199 				{
       
   200 				SetTrimStateL( ESeek );
       
   201 				}
       
   202             break;
       
   203             }
       
   204         /**
       
   205          * Adjust video length -> Ok
       
   206          */
       
   207         case EAknSoftkeyOk:
       
   208             {
       
   209 			if( state == EPause )
       
   210 				{
       
   211 				SetTrimStateL( ESeek );
       
   212 				iContainer->Stop( ETrue );
       
   213 				}
       
   214 			else
       
   215 				{	
       
   216 				CmdSoftkeyOkL();  
       
   217 				}
       
   218             break;
       
   219             }
       
   220         /**
       
   221          * Adjust video length -> Cancel
       
   222          */
       
   223         case EAknSoftkeyCancel:
       
   224             {
       
   225 			if( state == EPause )
       
   226 				{
       
   227 				SetTrimStateL( ESeek );
       
   228 				iContainer->Stop( ETrue );
       
   229 				}
       
   230 			else
       
   231 				{	
       
   232 				CmdSoftkeyCancelL();
       
   233 				}
       
   234             break;
       
   235             }
       
   236         default:
       
   237             {
       
   238             AppUi()->HandleCommandL( aCommand );
       
   239             break;
       
   240             }
       
   241         }
       
   242 
       
   243     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::HandleCommandL: Out");
       
   244     }
       
   245 
       
   246 
       
   247 // ----------------------------------------------------------------------------
       
   248 // CVeiTrimForMmsView::CmdSendViaMultimediaL()
       
   249 //  Function for handling the Send Via Multimedia command.
       
   250 //  
       
   251 // ----------------------------------------------------------------------------
       
   252 //
       
   253 void CVeiTrimForMmsView::CmdSendViaMultimediaL()
       
   254     {
       
   255     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: In");
       
   256 
       
   257         // Start processing the trimmed video
       
   258 	    // Possible leave codes:
       
   259 	    //	- KErrNoMemory if memory allocation fails
       
   260 	    //	- KErrAccessDenied if the file access is denied
       
   261 	    //	- KErrDiskFull if the disk is full
       
   262 	    //	- KErrWrite if not all data could be written
       
   263 	    //	- KErrBadName if the filename is bad
       
   264 	    //  - KErrDirFull if the directory is full
       
   265         // : If video clip is already processed and frame is in same position
       
   266         //       do not reprocess the movie.
       
   267 
       
   268 
       
   269 	UpdateNaviPaneSize();
       
   270 
       
   271 	TBool fileExists( ETrue );
       
   272 	RFs	fs = CCoeEnv::Static()->FsSession();
       
   273 
       
   274 	if ( iTempFile )
       
   275 		{
       
   276 		fileExists = BaflUtils::FileExists( fs, *iTempFile );
       
   277 		}
       
   278 
       
   279 	if ( !fileExists || ( !iTempFile  ) || iProcessNeeded )
       
   280 		{
       
   281 
       
   282 		if ( iTempFile && fileExists )
       
   283 			{
       
   284 			User::LeaveIfError( fs.Delete( *iTempFile ) );
       
   285 			delete iTempFile;
       
   286 			iTempFile = NULL;
       
   287 			}
       
   288 
       
   289 		iTempFile = HBufC::NewL(KMaxFileName);
       
   290 
       
   291 // @: check the quality setting. should we set it here to MMS compatible?
       
   292 
       
   293 		// Quality is taken from settings and set to engine.
       
   294 		ReadSettingsL( iMovieSaveSettings );
       
   295 
       
   296 		iTempMaker->GenerateTempFileName( *iTempFile, iMovieSaveSettings.MemoryInUse(), iVedMovie->Format() );
       
   297 
       
   298 		TEntry fileinfo;
       
   299 		// Rename movie from xxxx.$$$ to defaultfilename from settingsview.
       
   300 		// looks better in attachment list..
       
   301 
       
   302 		// Get default movie name from settings view
       
   303 		TPtr temppeet = iTempFile->Des();
       
   304 		TParse parse;
       
   305 
       
   306 		parse.Set( iMovieSaveSettings.DefaultVideoName(), &temppeet, NULL );
       
   307 
       
   308 		TFileName orgPathAndName = parse.FullName();
       
   309 		
       
   310 //		TVedVideoFormat movieQuality = iVedMovie->Format();
       
   311 		
       
   312 		orgPathAndName.Replace( orgPathAndName.Length()-4, 4, KExt3gp );
       
   313 
       
   314 		fs.Replace( *iTempFile, orgPathAndName );
       
   315 		iTempFile->Des() = orgPathAndName;
       
   316 		fs.Entry( *iTempFile, fileinfo );
       
   317 
       
   318 				
       
   319 		iVedMovie->SetQuality( CVedMovie::EQualityMMSInteroperability );
       
   320 		LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: 1, iTempFile:%S", iTempFile);
       
   321         TRAPD( processError, iVedMovie->ProcessL( *iTempFile, *this ) );
       
   322 		LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: 2");
       
   323         if( processError == KErrNone )
       
   324             {
       
   325             // Text for the progress note is loaded from TBUF resource
       
   326             HBufC* noteText;
       
   327             noteText = StringLoader::LoadLC( R_VED_PROCESSING_FOR_MMS, iEikonEnv );
       
   328 
       
   329             // Construct and execute progress note.
       
   330             iProgressNote = new(ELeave) CAknProgressDialog( REINTERPRET_CAST(CEikDialog**, 
       
   331                                                              &iProgressNote), ETrue);
       
   332 			iProgressNote->PrepareLC( R_VEI_PROGRESS_NOTE );
       
   333             iProgressNote->SetTextL( *noteText );
       
   334             
       
   335             iProgressInfo = iProgressNote->GetProgressInfoL();
       
   336 			iProgressInfo->SetFinalValue( KProgressNoteMaxValue );
       
   337             
       
   338             iProgressNote->RunLD(); 
       
   339 
       
   340             CleanupStack::PopAndDestroy( noteText );    // Pop and destroy the text
       
   341             }
       
   342             else 
       
   343             {
       
   344             // : add error handling here
       
   345             }
       
   346 
       
   347         }
       
   348     else
       
   349         {
       
   350         
       
   351 		RFs shareFServer;
       
   352 	   	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: shareFServer connect.");
       
   353 
       
   354 	 	User::LeaveIfError(shareFServer.Connect());
       
   355 	    shareFServer.ShareProtected();
       
   356 		
       
   357 		RFile openFileHandle;
       
   358     	
       
   359 		TInt err = openFileHandle.Open(shareFServer,*iTempFile,EFileRead|EFileShareReadersOnly);
       
   360 		if (KErrNone != err)
       
   361 			{
       
   362 			LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: Could not open file %S with EFileShareReadersOnly. Trying EFileShareAny", iTempFile);
       
   363 			User::LeaveIfError( openFileHandle.Open (shareFServer, *iTempFile, EFileRead|EFileShareAny) );
       
   364 			}
       
   365 		 
       
   366 		CMessageData* messageData = CMessageData::NewLC();	
       
   367 		 
       
   368 		 
       
   369 		messageData->AppendAttachmentHandleL( openFileHandle );
       
   370 
       
   371 		iSendAppUi.CreateAndSendMessageL( KSenduiMtmMmsUid, messageData, KNullUid, EFalse );	
       
   372 		
       
   373 		CleanupStack::PopAndDestroy( messageData );
       
   374 		 
       
   375         shareFServer.Close();
       
   376 	   	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: shareFServer closed.");
       
   377         }
       
   378 
       
   379     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::CmdSendViaMultimediaL: Out");
       
   380     }
       
   381 
       
   382 void CVeiTrimForMmsView::CmdSoftkeyBackL()
       
   383     {
       
   384     // Compare previous view's application uid to video editor uid.
       
   385     if( iPreviousViewId.iAppUid == KUidVideoEditor )
       
   386         {
       
   387 	    CEikStatusPane* statusPane = AppUi()->StatusPane();
       
   388 	    TUid naviPaneUid = TUid::Uid( EEikStatusPaneUidNavi );  // Navi pane UID
       
   389 
       
   390         CAknNavigationControlContainer *naviContainer = (CAknNavigationControlContainer*)statusPane->ControlL( naviPaneUid );
       
   391         naviContainer->Pop( iNaviDecorator );
       
   392         
       
   393         // Activate previous local view.
       
   394         AppUi()->ActivateLocalViewL( iPreviousViewId.iViewUid );
       
   395         }
       
   396     else
       
   397         {
       
   398         // Exit video editor
       
   399         AppUi()->HandleCommandL( EEikCmdExit);
       
   400         }
       
   401     }
       
   402 
       
   403 
       
   404 void CVeiTrimForMmsView::CmdSoftkeyOkL()
       
   405     {
       
   406     // Set CBA labels back to view default
       
   407     Cba()->SetCommandSetL( KVedTrimForMmsDefaultCba );
       
   408     Cba()->DrawDeferred();
       
   409 
       
   410     PushKeySoundL( R_VED_LEFT_RIGHT_SILENT_SKEY_LIST );
       
   411     }
       
   412 
       
   413 
       
   414 void CVeiTrimForMmsView::CmdSoftkeyCancelL()
       
   415     {
       
   416     // Set CBA labels back to view default
       
   417     Cba()->SetCommandSetL( KVedTrimForMmsDefaultCba );
       
   418     Cba()->DrawDeferred();
       
   419 
       
   420     PushKeySoundL( R_VED_LEFT_RIGHT_SILENT_SKEY_LIST );
       
   421     }
       
   422 
       
   423 
       
   424 void CVeiTrimForMmsView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   425                                         TUid /*aCustomMessageId*/,
       
   426                                         const TDesC8& aCustomMessage )
       
   427     {
       
   428     if( !iContainer ) 
       
   429         {
       
   430         iPreviousViewId = aPrevViewId;  // Save the previous view id
       
   431 
       
   432         // Disable left and right navi-key sounds
       
   433         PushKeySoundL( R_VED_LEFT_RIGHT_SILENT_SKEY_LIST );
       
   434 
       
   435         SetTitlePaneTextL();
       
   436         CreateNaviPaneL();
       
   437 		
       
   438         STATIC_CAST( CVeiEditVideoLabelNavi*, iNaviDecorator->DecoratedControl() )->SetState( CVeiEditVideoLabelNavi::EStateTrimForMmsView );
       
   439         
       
   440         TFileName inputFileName;
       
   441        	CnvUtfConverter::ConvertToUnicodeFromUtf8( inputFileName, aCustomMessage );
       
   442 
       
   443 
       
   444 		// TEST
       
   445 		if (inputFileName.Length() == 0)
       
   446 			{
       
   447 			inputFileName.Copy( _L("c:\\Data\\Videos\\test.mp4") );
       
   448 			}
       
   449 		// END TEST
       
   450 
       
   451     
       
   452         if( !iVedMovie )
       
   453             {
       
   454             iVedMovie = CVedMovie::NewL( NULL );
       
   455             iVedMovie->RegisterMovieObserverL( this );
       
   456             iVedMovie->InsertVideoClipL( inputFileName, KVedVideoClipIndex );
       
   457 			iVedMovie->SetQuality( CVedMovie::EQualityMMSInteroperability );
       
   458             }
       
   459 
       
   460         iContainer = CVeiTrimForMmsContainer::NewL( AppUi()->ClientRect(),
       
   461                                                     *iVedMovie, *this );
       
   462         iContainer->SetMopParent( this );
       
   463         
       
   464         AppUi()->AddToStackL( *this, iContainer );
       
   465         }
       
   466 
       
   467     }
       
   468 
       
   469 
       
   470 void CVeiTrimForMmsView::DoDeactivate()
       
   471     {
       
   472     if( iContainer )
       
   473         {
       
   474         AppUi()->RemoveFromStack( iContainer );
       
   475         delete iContainer;
       
   476         iContainer = NULL;
       
   477 
       
   478         if( iVedMovie )
       
   479             {
       
   480             iVedMovie->Reset();
       
   481             iVedMovie->UnregisterMovieObserver( this );
       
   482              delete iVedMovie;
       
   483             iVedMovie = NULL;
       
   484             }
       
   485         }
       
   486     }
       
   487 
       
   488 
       
   489 void CVeiTrimForMmsView::PushKeySoundL( const TInt aResourceId ) const
       
   490     {
       
   491     CAknKeySoundSystem* aknKeySoundSystem = AppUi()->KeySounds();
       
   492     aknKeySoundSystem->PushContextL( aResourceId );
       
   493     }
       
   494 
       
   495 
       
   496 void CVeiTrimForMmsView::PopKeySound() const
       
   497     {
       
   498     AppUi()->KeySounds()->PopContext();
       
   499     }
       
   500 
       
   501 
       
   502 void CVeiTrimForMmsView::SetTitlePaneTextL() const
       
   503     {
       
   504     TUid titleUid;
       
   505     titleUid.iUid = EEikStatusPaneUidTitle;
       
   506 
       
   507     CEikStatusPane* statusPane = AppUi()->StatusPane();
       
   508 
       
   509     CEikStatusPaneBase::TPaneCapabilities titlePaneCap = 
       
   510         statusPane->PaneCapabilities( titleUid );
       
   511 
       
   512     if( titlePaneCap.IsPresent() && titlePaneCap.IsAppOwned() )
       
   513         {
       
   514         CAknTitlePane* titlePane = 
       
   515             (CAknTitlePane*)statusPane->ControlL( titleUid );
       
   516 
       
   517 		TResourceReader reader;
       
   518 		iCoeEnv->CreateResourceReaderLC( reader,
       
   519             R_VEI_TRIM_FOR_MMS_VIEW_TITLE_NAME );
       
   520 		titlePane->SetFromResourceL( reader );
       
   521 
       
   522         CleanupStack::PopAndDestroy(); //reader
       
   523         }
       
   524 
       
   525     }
       
   526 
       
   527 
       
   528 void CVeiTrimForMmsView::CreateNaviPaneL()
       
   529     {
       
   530     TUid naviPaneUid = TUid::Uid( EEikStatusPaneUidNavi );  // Navi pane UID
       
   531 
       
   532     CEikStatusPane* statusPane = AppUi()->StatusPane();     // Get status pane
       
   533 
       
   534     CEikStatusPaneBase::TPaneCapabilities naviPaneCap =
       
   535         statusPane->PaneCapabilities( naviPaneUid );
       
   536 
       
   537     if( naviPaneCap.IsPresent() && naviPaneCap.IsAppOwned() )
       
   538         {
       
   539         CAknNavigationControlContainer *naviContainer = (CAknNavigationControlContainer*)statusPane->ControlL( naviPaneUid );
       
   540         
       
   541         CVeiEditVideoLabelNavi* editvideolabelnavi = CVeiEditVideoLabelNavi::NewLC();
       
   542         editvideolabelnavi->SetState( CVeiEditVideoLabelNavi::EStateInitializing );
       
   543 
       
   544         iNaviDecorator = 
       
   545             CAknNavigationDecorator::NewL( naviContainer, editvideolabelnavi,
       
   546                                        CAknNavigationDecorator::ENotSpecified );
       
   547         CleanupStack::Pop( editvideolabelnavi );
       
   548 
       
   549         iNaviDecorator->SetContainerWindowL( *naviContainer );		
       
   550 	    iNaviDecorator->MakeScrollButtonVisible( EFalse );
       
   551 
       
   552         naviContainer->PushL( *iNaviDecorator );
       
   553  
       
   554         }
       
   555     }
       
   556 
       
   557 void CVeiTrimForMmsView::UpdateNaviPaneSize()
       
   558     {
       
   559     if( iContainer )
       
   560         {
       
   561         iVedMovie->VideoClipSetCutInTime( KVedVideoClipIndex, iContainer->CutInTime() );
       
   562         iVedMovie->VideoClipSetCutOutTime( KVedVideoClipIndex, iContainer->CutOutTime() );
       
   563         }
       
   564     }
       
   565 void CVeiTrimForMmsView::SetNaviPaneSizeLabelL( const TInt& aSizeInBytes )
       
   566     {
       
   567     STATIC_CAST(CVeiEditVideoLabelNavi*,
       
   568         iNaviDecorator->DecoratedControl())->SetSizeLabelL( aSizeInBytes );
       
   569     }
       
   570 
       
   571 
       
   572 void CVeiTrimForMmsView::SetNaviPaneDurationLabelL(
       
   573                                     const TTimeIntervalMicroSeconds& aTime )
       
   574     {
       
   575     STATIC_CAST(CVeiEditVideoLabelNavi*, 
       
   576        iNaviDecorator->DecoratedControl())->SetDurationLabelL( aTime.Int64() );
       
   577     }
       
   578 
       
   579 void CVeiTrimForMmsView::UpdateNaviPaneL( const TInt& aSizeInBytes, 
       
   580 								const TTimeIntervalMicroSeconds& aTime )
       
   581 	{ 
       
   582 	TInt maxMmsSize = STATIC_CAST( CVeiEditVideoLabelNavi*, iNaviDecorator->DecoratedControl() )->GetMaxMmsSize();
       
   583 
       
   584 		// Navipanes MMS icon control. 
       
   585 	if( aSizeInBytes < maxMmsSize )
       
   586 		{
       
   587 		STATIC_CAST( CVeiEditVideoLabelNavi*, iNaviDecorator->DecoratedControl() )->SetMmsAvailableL( ETrue );
       
   588 		}
       
   589 	else 
       
   590 		{
       
   591 		STATIC_CAST( CVeiEditVideoLabelNavi*, iNaviDecorator->DecoratedControl() )->SetMmsAvailableL( EFalse );
       
   592 		}
       
   593 
       
   594     STATIC_CAST(CVeiEditVideoLabelNavi*,
       
   595         iNaviDecorator->DecoratedControl())->SetSizeLabelL( aSizeInBytes );
       
   596 	
       
   597     STATIC_CAST(CVeiEditVideoLabelNavi*, 
       
   598        iNaviDecorator->DecoratedControl())->SetDurationLabelL( aTime.Int64() );
       
   599  	}
       
   600 
       
   601 void CVeiTrimForMmsView::HandleResourceChange(TInt aType)
       
   602     {
       
   603     LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsView::HandleResourceChange() In, aType:%d", aType);
       
   604     
       
   605     if (KAknsMessageSkinChange == aType && iNaviDecorator)
       
   606         {
       
   607         // Handle skin change in the navi label controls - they do not receive 
       
   608         // it automatically since they are not in the control stack
       
   609         CCoeControl* navi = iNaviDecorator->DecoratedControl();
       
   610         if (navi)
       
   611         	{
       
   612         	navi->HandleResourceChange( aType );
       
   613         	}
       
   614         }
       
   615     
       
   616     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::HandleResourceChange() Out");
       
   617     }
       
   618 
       
   619 // ============= MVedMovieProcessingObserver FUNCTIONS START ==================
       
   620 
       
   621 // ----------------------------------------------------------------------------
       
   622 // CVeiTrimForMmsView::NotifyMovieProcessingStartedL( CVedMovie& aMovie )
       
   623 //
       
   624 // Called to notify that a new movie processing operation has been started.
       
   625 // ----------------------------------------------------------------------------
       
   626 //
       
   627 void CVeiTrimForMmsView::NotifyMovieProcessingStartedL( CVedMovie& /*aMovie*/ )
       
   628     {
       
   629     }
       
   630 
       
   631 
       
   632 // ----------------------------------------------------------------------------
       
   633 // CVeiTrimForMmsView::NotifyMovieProcessingProgressed( CVedMovie& aMovie,
       
   634 //                                                      TInt aPercentage )
       
   635 //
       
   636 // Called to inform about the current progress of the movie processing
       
   637 // operation.
       
   638 // ----------------------------------------------------------------------------
       
   639 //
       
   640 void CVeiTrimForMmsView::NotifyMovieProcessingProgressed( CVedMovie&/*aMovie*/,
       
   641                                                          TInt aPercentage )
       
   642     {
       
   643     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingProgressed(): In");
       
   644 
       
   645     // Increment the progress bar.
       
   646     iProgressInfo->SetAndDraw( aPercentage );
       
   647     }
       
   648 
       
   649 
       
   650 // ----------------------------------------------------------------------------
       
   651 // CVeiTrimForMmsView::NotifyMovieProcessingCompleted( CVedMovie& aMovie,
       
   652 //                                                     TInt aError )
       
   653 //
       
   654 // Called to notify that the movie processing operation has been completed.
       
   655 // ----------------------------------------------------------------------------
       
   656 //
       
   657 void CVeiTrimForMmsView::NotifyMovieProcessingCompleted( CVedMovie& /*aMovie*/,
       
   658                                                         TInt aError )
       
   659     {
       
   660     LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingCompleted(): In, aError:%d", aError);
       
   661 
       
   662 	if( !aError )
       
   663 		{
       
   664 		ProcessNeeded( EFalse );
       
   665 		}
       
   666 
       
   667     __ASSERT_ALWAYS( iProgressNote, User::Panic(_L("CVeiTrimForMmsView"),1) );
       
   668 
       
   669 	// Draw the progress bar to 100%.
       
   670     iProgressInfo->SetAndDraw( 100 );
       
   671 
       
   672     // Delete the note.
       
   673     TRAP_IGNORE( iProgressNote->ProcessFinishedL() );
       
   674 
       
   675 	RFs shareFServer;
       
   676 	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingCompleted: shareFServer connect.");
       
   677 
       
   678 	User::LeaveIfError(shareFServer.Connect());
       
   679 	shareFServer.ShareProtected();
       
   680 		
       
   681 	RFile openFileHandle;
       
   682 
       
   683 	TInt err = openFileHandle.Open(shareFServer,*iTempFile,EFileRead|EFileShareReadersOnly);
       
   684 	if (KErrNone != err)
       
   685 		{
       
   686 		LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingCompleted: Could not open file %S with EFileShareReadersOnly. Trying EFileShareAny", iTempFile);
       
   687 		User::LeaveIfError( openFileHandle.Open (shareFServer, *iTempFile, EFileRead|EFileShareAny) );
       
   688 		}
       
   689 
       
   690 	CMessageData* messageData = CMessageData::NewLC();	
       
   691 	messageData->AppendAttachmentHandleL( openFileHandle );
       
   692 
       
   693 	iSendAppUi.CreateAndSendMessageL( KSenduiMtmMmsUid, messageData, KNullUid, EFalse );	
       
   694 		
       
   695 	CleanupStack::PopAndDestroy( messageData );
       
   696 		 
       
   697     shareFServer.Close();
       
   698 
       
   699     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingCompleted: shareFServer closed.");
       
   700 	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyMovieProcessingCompleted(): Out");
       
   701     }
       
   702 
       
   703 // ============== MVedMovieProcessingObserver FUNCTIONS END ===================
       
   704 
       
   705 
       
   706 /**
       
   707  * Called to notify that a new video clip has been successfully
       
   708  * added to the movie. Note that the indices and the start and end times
       
   709  * of the video clips after the new clip have also changed as a result.
       
   710  * Note that the transitions may also have changed. 
       
   711  *
       
   712  * @param aMovie  movie
       
   713  * @param aIndex  index of video clip in movie
       
   714  */
       
   715 void CVeiTrimForMmsView::NotifyVideoClipAdded( CVedMovie& /*aMovie*/,
       
   716                                                TInt /*aIndex*/ )
       
   717     {
       
   718 		ProcessNeeded( ETrue );
       
   719     }
       
   720 
       
   721 
       
   722 /**
       
   723  * Called to notify that adding a new video clip to the movie has failed.
       
   724  *
       
   725  * Possible error codes:
       
   726  *	- <code>KErrNotFound</code> if there is no file with the specified name
       
   727  *    in the specified directory (but the directory exists)
       
   728  *	- <code>KErrPathNotFound</code> if the specified directory
       
   729  *    does not exist
       
   730  *	- <code>KErrUnknown</code> if the specified file is of unknown format
       
   731  *	- <code>KErrNotSupported</code> if the format of the file is recognized but
       
   732  *    adding it to the movie is not supported (e.g., it is of different resolution
       
   733  *    or format than the other clips)
       
   734  *
       
   735  * @param aMovie  movie
       
   736  * @param aError  one of the system wide error codes
       
   737  */
       
   738 void CVeiTrimForMmsView::NotifyVideoClipAddingFailed( CVedMovie& /*aMovie*/, 
       
   739                                                       TInt /*aError*/ )
       
   740     {
       
   741     User::Panic( _L("MmsView"), 20 );
       
   742     }
       
   743 
       
   744 
       
   745 void CVeiTrimForMmsView::NotifyVideoClipRemoved( CVedMovie& /*aMovie*/, 
       
   746                                                  TInt /*aIndex*/ )
       
   747     {
       
   748     }
       
   749 	
       
   750 
       
   751 void CVeiTrimForMmsView::NotifyVideoClipIndicesChanged( CVedMovie& /*aMovie*/,
       
   752                                                         TInt /*aOldIndex*/, 
       
   753 									                    TInt /*aNewIndex*/ )
       
   754     {
       
   755     }
       
   756 
       
   757 
       
   758 // ----------------------------------------------------------------------------
       
   759 // CVeiTrimForMmsView::NotifyVideoClipTimingsChanged( CVedMovie& aMovie, 
       
   760 //                                                    TInt aIndex )
       
   761 //
       
   762 // Called to notify that the timings (that is, the cut in or cut out time or
       
   763 // the speed and consequently the end time, edited duration, and possibly audio
       
   764 // settings) of a video clip have changed (but the index of the clip has 
       
   765 // not changed). Note that the start and end times of the video clips 
       
   766 // after the changed clip have also changed.
       
   767 // ----------------------------------------------------------------------------
       
   768 //
       
   769 void CVeiTrimForMmsView::NotifyVideoClipTimingsChanged( CVedMovie& /*aMovie*/,
       
   770             										    TInt /*aIndex*/ )
       
   771     {
       
   772     LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::NotifyVideoClipTimingsChanged()");
       
   773     }
       
   774 
       
   775 
       
   776 void CVeiTrimForMmsView::NotifyVideoClipColorEffectChanged( CVedMovie& /*aMovie*/,
       
   777 												   TInt /*aIndex*/ )
       
   778     {
       
   779     }
       
   780 
       
   781 	
       
   782 void CVeiTrimForMmsView::NotifyVideoClipAudioSettingsChanged( CVedMovie& /*aMovie*/,
       
   783 											         TInt /*aIndex*/ )
       
   784     {
       
   785     }
       
   786 
       
   787 
       
   788 void CVeiTrimForMmsView::NotifyVideoClipGeneratorSettingsChanged( CVedMovie& /*aMovie*/,
       
   789 											             TInt /*aIndex*/ )
       
   790     {
       
   791     }
       
   792 
       
   793 
       
   794 void CVeiTrimForMmsView::NotifyVideoClipDescriptiveNameChanged( CVedMovie& /*aMovie*/,
       
   795 																TInt /*aIndex*/ )
       
   796     {
       
   797     }
       
   798 
       
   799 
       
   800 void CVeiTrimForMmsView::NotifyStartTransitionEffectChanged( CVedMovie& /*aMovie*/ )
       
   801     {
       
   802     }
       
   803 
       
   804 
       
   805 void CVeiTrimForMmsView::NotifyMiddleTransitionEffectChanged( CVedMovie& /*aMovie*/, 
       
   806 													 TInt /*aIndex*/ )
       
   807     {
       
   808     }
       
   809 
       
   810 
       
   811 void CVeiTrimForMmsView::NotifyEndTransitionEffectChanged( CVedMovie& /*aMovie*/ )
       
   812     {
       
   813     }
       
   814 
       
   815 
       
   816 void CVeiTrimForMmsView::NotifyAudioClipAdded( CVedMovie& /*aMovie*/, TInt /*aIndex*/ )
       
   817     {
       
   818     }
       
   819 
       
   820 
       
   821 void CVeiTrimForMmsView::NotifyAudioClipAddingFailed( CVedMovie& /*aMovie*/, TInt /*aError*/ )
       
   822     {
       
   823     }
       
   824 
       
   825 
       
   826 void CVeiTrimForMmsView::NotifyAudioClipRemoved( CVedMovie& /*aMovie*/, TInt /*aIndex*/ )
       
   827     {
       
   828     }
       
   829 
       
   830 
       
   831 void CVeiTrimForMmsView::NotifyAudioClipIndicesChanged( CVedMovie& /*aMovie*/, TInt /*aOldIndex*/, 
       
   832 									           TInt /*aNewIndex*/ )
       
   833     {
       
   834     }
       
   835 
       
   836 
       
   837 void CVeiTrimForMmsView::NotifyAudioClipTimingsChanged( CVedMovie& /*aMovie*/,
       
   838 											   TInt /*aIndex*/ )
       
   839     {
       
   840     }
       
   841 
       
   842 
       
   843 void CVeiTrimForMmsView::NotifyMovieQualityChanged( CVedMovie& /*aMovie*/ )
       
   844     {
       
   845     }
       
   846 
       
   847 void CVeiTrimForMmsView::NotifyMovieReseted(CVedMovie& /*aMovie*/ )
       
   848     {
       
   849     }
       
   850 
       
   851 void CVeiTrimForMmsView::NotifyMovieOutputParametersChanged(CVedMovie& /*aMovie*/)
       
   852 	{
       
   853 	}
       
   854 
       
   855 void CVeiTrimForMmsView::NotifyAudioClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/, 
       
   856                                                          TInt /*aClipIndex*/, 
       
   857                                                          TInt /*aMarkIndex*/)
       
   858 	{
       
   859 	}
       
   860 
       
   861 void CVeiTrimForMmsView::NotifyAudioClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, 
       
   862                                                         TInt /*aClipIndex*/, 
       
   863                                                         TInt /*aMarkIndex*/)
       
   864 	{
       
   865 	}
       
   866 
       
   867 void CVeiTrimForMmsView::NotifyVideoClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/,
       
   868                                                          TInt /*aClipIndex*/, 
       
   869                                                          TInt /*aMarkIndex*/)
       
   870 	{
       
   871 	}
       
   872 
       
   873 void CVeiTrimForMmsView::NotifyVideoClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, 
       
   874                                                         TInt /*aClipIndex*/, 
       
   875                                                         TInt /*aMarkIndex*/)
       
   876 	{
       
   877 	}
       
   878 
       
   879 void CVeiTrimForMmsView::PlayPreviewL()
       
   880 	{
       
   881 	TRect rect( AppUi()->ApplicationRect() );
       
   882 	iContainer->SetRect( rect );
       
   883 	
       
   884 	iContainer->PlayL( iVedMovie->VideoClipInfo( 0 )->FileName(), rect  );
       
   885 	}
       
   886 
       
   887 void CVeiTrimForMmsView::HandleStatusPaneSizeChange()
       
   888 	{
       
   889 	if ( iContainer )
       
   890 		{
       
   891 		iContainer->SetRect( AppUi()->ClientRect() );
       
   892 		}
       
   893 
       
   894 	}
       
   895 void CVeiTrimForMmsView::SetTrimStateL( TTrimState aState )
       
   896 	{
       
   897 	iTrimState = aState;
       
   898 	CEikStatusPane *statusPane;
       
   899 	CAknTitlePane* titlePane;
       
   900 
       
   901 	TResourceReader reader1;
       
   902 
       
   903 	switch ( iTrimState )
       
   904         {
       
   905 	case EFullPreview:		               
       
   906 
       
   907 			Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY );
       
   908  			Cba()->DrawDeferred();
       
   909 			
       
   910 			break;
       
   911 
       
   912 		case ESeek:
       
   913 			iContainer->SetRect( AppUi()->ClientRect() );
       
   914 			statusPane = ( ( CAknAppUi* )iEikonEnv->EikAppUi() )->StatusPane(); 
       
   915 	
       
   916 			titlePane = (CAknTitlePane*) statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
       
   917    			iCoeEnv->CreateResourceReaderLC( reader1, R_VEI_TRIM_FOR_MMS_VIEW_TITLE_NAME );
       
   918 			titlePane->SetFromResourceL( reader1 );
       
   919 			CleanupStack::PopAndDestroy(); //reader1
       
   920 			
       
   921 			Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK );
       
   922  			Cba()->DrawDeferred();
       
   923 			
       
   924 			break;
       
   925 			
       
   926 		default:
       
   927 			{
       
   928 			break;
       
   929 			}
       
   930 
       
   931 		}
       
   932 	}
       
   933 
       
   934 void CVeiTrimForMmsView::DialogDismissedL( TInt aButtonId )
       
   935 	{
       
   936 	if ( aButtonId != EAknSoftkeyDone )
       
   937 		{	
       
   938 		iVedMovie->CancelProcessing();        
       
   939         }
       
   940     iProgressInfo = NULL;
       
   941 	}
       
   942 
       
   943 void CVeiTrimForMmsView::ProcessNeeded( TBool aProcessNeed )
       
   944 	{
       
   945 	iProcessNeeded = aProcessNeed;
       
   946 	}
       
   947 
       
   948 void CVeiTrimForMmsView::ShowGlobalErrorNoteL( const TInt aError ) const
       
   949 	{	
       
   950 	iErrorUi->ShowGlobalErrorNote( aError );
       
   951 	}	
       
   952 
       
   953 //=============================================================================
       
   954 void CVeiTrimForMmsView::ReadSettingsL( TVeiSettings& aSettings ) const
       
   955 	{
       
   956 	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::ReadSettingsL: in");
       
   957 
       
   958 	STATIC_CAST( CTrimForMmsAppUi*, AppUi() )->ReadSettingsL( aSettings );
       
   959 
       
   960 	LOG(KVideoEditorLogFile, "CVeiTrimForMmsView::ReadSettingsL: out");
       
   961 	}
       
   962 
       
   963 
       
   964 // End of File