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