videditor/SimpleCutVideo/src/VeiSimpleCutVideoAppUi.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 // INCLUDE FILES
       
    22 // System includes
       
    23 #include <avkon.hrh>
       
    24 #include <eikmenup.h>
       
    25 #include <eikenv.h>
       
    26 #include <hlplch.h>     // HlpLauncher
       
    27 #include <VedSimpleCutVideo.rsg>
       
    28 #include <stringloader.h>
       
    29 #include <bautils.h>
       
    30 #include <mgfetch.h> 
       
    31 #include <data_caging_path_literals.hrh>
       
    32 
       
    33 // User includes
       
    34 #include "VedSimpleCutVideo.hrh"
       
    35 #include "veisimplecutvideoappui.h"
       
    36 #include "veisimplecutvideoview.h"
       
    37 
       
    38 #include "VeiTempMaker.h"
       
    39 #include "VideoEditorCommon.h"
       
    40 
       
    41 // ================= MEMBER FUNCTIONS =======================
       
    42 //
       
    43 // ----------------------------------------------------------
       
    44 // CVeiSimpleCutVideoAppUi::ConstructL()
       
    45 // ?implementation_description
       
    46 // ----------------------------------------------------------
       
    47 //
       
    48 void CVeiSimpleCutVideoAppUi::ConstructL()
       
    49     {
       
    50     LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::ConstructL: In");
       
    51 
       
    52    	BaseConstructL( EAppOrientationAutomatic|EAknEnableSkin|EAknEnableMSK );
       
    53 	
       
    54 	CVeiTempMaker* maker = CVeiTempMaker::NewL();
       
    55 	maker->EmptyTempFolder();
       
    56 	delete maker;
       
    57 	
       
    58 /*
       
    59 *	Cut video view and Cut audio view are references to edit video view and
       
    60 *	ownerships must be transfered(AddViewL(...)) to CAknViewAppUi(this) 
       
    61 *	AFTER references are taken to edit video view. Otherwise exit is not clean.
       
    62 */
       
    63 
       
    64 
       
    65 // Cut Video view	    
       
    66 	/*iSimpleMergeView = CVeiSimpleCutVideoView::NewLC( ClientRect() );
       
    67 	AddViewL( iSimpleMergeView );  // transfer ownership to CAknViewAppUi
       
    68 	CleanupStack::Pop( iSimpleMergeView );
       
    69 	*/
       
    70 
       
    71     LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::ConstructL: Out");
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------
       
    75 // CVeiSimpleCutVideoAppUi::~CVeiSimpleCutVideoAppUi()
       
    76 // Destructor
       
    77 // Frees reserved resources
       
    78 // ----------------------------------------------------
       
    79 //
       
    80 CVeiSimpleCutVideoAppUi::~CVeiSimpleCutVideoAppUi()
       
    81     {
       
    82     LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::~CVeiSimpleCutVideoAppUi()");
       
    83 	}
       
    84 	
       
    85 void CVeiSimpleCutVideoAppUi::Exit()
       
    86 	{
       
    87 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::Exit(): In");
       
    88 
       
    89 	TRAP_IGNORE ( 
       
    90 		CVeiTempMaker* maker = CVeiTempMaker::NewL();
       
    91 		maker->EmptyTempFolder();
       
    92 		delete maker; 
       
    93 		);
       
    94 
       
    95 	CAknAppUiBase::Exit();
       
    96 	
       
    97 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::Exit(): Out");
       
    98 	}
       
    99 
       
   100 //=============================================================================
       
   101 CVeiSimpleCutVideoAppUi::CVeiSimpleCutVideoAppUi()
       
   102 	{
       
   103 	}
       
   104 
       
   105 //=============================================================================
       
   106 void CVeiSimpleCutVideoAppUi::CutVideoL( TBool aDoOpen, const RFile& aFile )
       
   107 	{
       
   108     LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::CutVideoL: In");
       
   109 
       
   110 	// Cut Video view
       
   111 	if ( !iSimpleCutVideoView )
       
   112 		{		
       
   113 		CVeiSimpleCutVideoView* simpleCutVideoView = 
       
   114 		    new (ELeave) CVeiSimpleCutVideoView;
       
   115 		CleanupStack::PushL( simpleCutVideoView );
       
   116 		simpleCutVideoView->ConstructL();
       
   117 		iSimpleCutVideoView = simpleCutVideoView;
       
   118 	    TFileName filename;
       
   119 	    User::LeaveIfError( aFile.FullName(filename) );
       
   120 	    simpleCutVideoView->AddClipL( filename, aDoOpen );
       
   121 		
       
   122 		AddViewL(simpleCutVideoView);
       
   123 		CleanupStack::Pop( simpleCutVideoView );
       
   124 		iVolume = -1;		// Volume not set
       
   125 
       
   126 	   	iCoeEnv->RootWin().EnableScreenChangeEvents(); 
       
   127 
       
   128 		SetDefaultViewL( *simpleCutVideoView );   
       
   129 		ActivateLocalViewL(simpleCutVideoView->Id());		
       
   130 		}
       
   131 
       
   132 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::CutVideoL: Out");
       
   133 	}
       
   134 
       
   135 // ----------------------------------------------------
       
   136 // CVeiSimpleCutVideoAppUi::HandleKeyEventL(
       
   137 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   138 // ?implementation_description
       
   139 // ----------------------------------------------------
       
   140 //
       
   141 TKeyResponse CVeiSimpleCutVideoAppUi::HandleKeyEventL(
       
   142     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   143     {
       
   144     return EKeyWasNotConsumed;
       
   145     }
       
   146 
       
   147 
       
   148 // ----------------------------------------------------
       
   149 // CVeiSimpleCutVideoAppUi::HandleCommandL(TInt aCommand)
       
   150 // ?implementation_description
       
   151 // ----------------------------------------------------
       
   152 //
       
   153 void CVeiSimpleCutVideoAppUi::HandleCommandL( TInt aCommand )
       
   154     {
       
   155     LOGFMT(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleCommandL( %d ): In", aCommand);
       
   156     
       
   157     switch ( aCommand )
       
   158         {
       
   159         //
       
   160         // Context Sensitive Help launching for:
       
   161         //  -'Settings' view
       
   162         //  -'Trim for MMS' view
       
   163         //  -'Edit video' view
       
   164         //  -'Cut video' view
       
   165         //  -'Cut audio' view
       
   166         //
       
   167     case EAknCmdHelp:        
       
   168     case EVeiCmdCutVideoViewHelp:
       
   169             {
       
   170             // Get the current context
       
   171             CArrayFix<TCoeHelpContext>* context = AppHelpContextL();
       
   172 
       
   173             // Launch the help application with current context topic
       
   174             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   175                                                  context );
       
   176             break;
       
   177             }
       
   178     case EAknSoftkeyBack:
       
   179     case EEikCmdExit:
       
   180     case EAknSoftkeyExit:
       
   181     case EAknCmdExit:
       
   182             {
       
   183             iOnTheWayToDestruction = ETrue;
       
   184             
       
   185             CVeiTempMaker* maker = CVeiTempMaker::NewL();
       
   186             maker->EmptyTempFolder();
       
   187             delete maker;
       
   188 				
       
   189             Exit();
       
   190             break;
       
   191             }
       
   192         default:
       
   193             break;      
       
   194         }
       
   195         LOG(KVideoEditorLogFile, "CVeiAppUi::HandleCommandL: Out");
       
   196     }
       
   197 
       
   198 //=============================================================================
       
   199 void CVeiSimpleCutVideoAppUi::ReadSettingsL( TVeiSettings& aSettings ) const
       
   200 	{
       
   201 	LOG(KVideoEditorLogFile, "CVeiAppUi::ReadSettingsL: in");
       
   202 	CDictionaryStore* store = Application()->OpenIniFileLC( iCoeEnv->FsSession() );
       
   203 
       
   204 	TBool storePresent = store->IsPresentL( KUidVideoEditor );	// UID has an associated stream?
       
   205 
       
   206 	if( storePresent ) 
       
   207 		{
       
   208 		RDictionaryReadStream readStream;
       
   209 		readStream.OpenLC( *store, KUidVideoEditor );
       
   210 
       
   211 		readStream >> aSettings;	// Internalize data to TVeiSettings.
       
   212 		
       
   213 		CleanupStack::PopAndDestroy( &readStream );
       
   214 		}
       
   215 	else {
       
   216 		// In the case of simple cut, the video name is generated automatically
       
   217 		// when saving is started.
       
   218 		aSettings.DefaultVideoName() = KNullDesC;
       
   219 
       
   220 		/* Read the default snapshot filename from resource */
       
   221 		const CFont* myFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont );
       
   222 		HBufC*	snapshotName = iEikonEnv->AllocReadResourceLC( R_VEI_SETTINGS_VIEW_SETTINGS_ITEM2_VALUE );
       
   223 		aSettings.DefaultSnapshotName() = AknTextUtils::ChooseScalableText(snapshotName->Des(), *myFont, 400 );
       
   224 		CleanupStack::PopAndDestroy( snapshotName );
       
   225 
       
   226 		/* Memory card is used as a default target */
       
   227 		aSettings.MemoryInUse() = CAknMemorySelectionDialog::EMemoryCard;
       
   228 
       
   229          /* Set save quality to "Auto" by default. */
       
   230         aSettings.SaveQuality() = TVeiSettings::EAuto;
       
   231 
       
   232 		RDictionaryWriteStream writeStream;
       
   233 		writeStream.AssignLC( *store, KUidVideoEditor );
       
   234 
       
   235 		writeStream << aSettings;
       
   236 
       
   237 		writeStream.CommitL();
       
   238 
       
   239 		store->CommitL();
       
   240 		
       
   241 		CleanupStack::PopAndDestroy( &writeStream );	
       
   242 		}
       
   243 	CleanupStack::PopAndDestroy( store );
       
   244 	LOG(KVideoEditorLogFile, "CVeiAppUi::ReadSettingsL: out");
       
   245 	}
       
   246 
       
   247 //=============================================================================
       
   248 void CVeiSimpleCutVideoAppUi::WriteSettingsL( const TVeiSettings& aSettings ) 
       
   249 	{
       
   250 	LOG(KVideoEditorLogFile, "CVeiAppUi::WriteSettingsL: in");
       
   251 	CDictionaryStore* store = Application()->OpenIniFileLC( iCoeEnv->FsSession() );
       
   252 
       
   253 	RDictionaryWriteStream writeStream;
       
   254 	writeStream.AssignLC( *store, KUidVideoEditor );
       
   255 	writeStream << aSettings;
       
   256 	writeStream.CommitL();
       
   257 
       
   258 	store->CommitL();
       
   259 
       
   260 	CleanupStack::PopAndDestroy( &writeStream );
       
   261 	CleanupStack::PopAndDestroy( store );
       
   262 	LOG(KVideoEditorLogFile, "CVeiAppUi::WriteSettingsL: out");
       
   263 	}
       
   264 
       
   265 //=============================================================================
       
   266 void CVeiSimpleCutVideoAppUi::HandleScreenDeviceChangedL()
       
   267 	{
       
   268 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleScreenDeviceChangedL: In");
       
   269 
       
   270 	CAknAppUi::HandleScreenDeviceChangedL();
       
   271 
       
   272 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleScreenDeviceChangedL: Out");
       
   273 	}
       
   274 
       
   275 //=============================================================================
       
   276 void CVeiSimpleCutVideoAppUi::HandleResourceChangeL(TInt aType)
       
   277 	{
       
   278 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleResourceChangeL: In");
       
   279 	CAknAppUi::HandleResourceChangeL(aType);
       
   280 	if ( iSimpleCutVideoView )
       
   281 		{
       
   282 		iSimpleCutVideoView->HandleResourceChange(aType);
       
   283 		}
       
   284 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleResourceChangeL: Out");
       
   285 	}
       
   286 
       
   287 //=============================================================================
       
   288 void CVeiSimpleCutVideoAppUi::HandleFileNotificationEventL()
       
   289 	{
       
   290 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleFileNotificationEventL: In");
       
   291 	/*if ( iSimpleCutVideoView )
       
   292 		{
       
   293 		if( iSimpleCutVideoView->WaitMode() == CVeiEditVideoView::EProcessingMovieSaveThenQuit )
       
   294 			{
       
   295 			HandleCommandL( EAknCmdExit );
       
   296 			}
       
   297 		}*/
       
   298 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleFileNotificationEventL: Out");
       
   299 	}
       
   300 
       
   301 //=============================================================================
       
   302 void CVeiSimpleCutVideoAppUi::HandleForegroundEventL  ( TBool aForeground )
       
   303 	{
       
   304 	LOGFMT(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleForegroundEventL: In: %d", aForeground);
       
   305 	CAknViewAppUi::HandleForegroundEventL( aForeground );
       
   306 	if ( !aForeground )
       
   307 		{
       
   308 		// Set the priority to low. This is needed to handle the situations 
       
   309 		// where the engine is performing heavy processing while the application 
       
   310 		// is in background.
       
   311 		RProcess myProcess;
       
   312 		iOriginalProcessPriority = myProcess.Priority();
       
   313 		LOGFMT3(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleForegroundEventL: changing priority of process %Ld from %d to %d", myProcess.Id().Id(), iOriginalProcessPriority, EPriorityLow);
       
   314 		myProcess.SetPriority( EPriorityLow );
       
   315 		iProcessPriorityAltered = ETrue;
       
   316 		}
       
   317 	else if ( iProcessPriorityAltered )
       
   318 		{
       
   319 		// Return to normal priority.
       
   320 		RProcess myProcess;
       
   321 		TProcessPriority priority = myProcess.Priority();
       
   322 		if ( priority < iOriginalProcessPriority )
       
   323 			{
       
   324 			myProcess.SetPriority( iOriginalProcessPriority );
       
   325 			}
       
   326 		iProcessPriorityAltered = EFalse;
       
   327 		LOGFMT2(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleForegroundEventL: process %Ld back to normal priority %d", myProcess.Id().Id(), priority);
       
   328 		}
       
   329 
       
   330 	LOG(KVideoEditorLogFile, "CVeiSimpleCutVideoAppUi::HandleForegroundEventL: Out");
       
   331 	}
       
   332 
       
   333 // End of File