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 <manualvideoeditor.rsg> |
|
28 #include <sendui.h> // CSendAppUi |
|
29 #include <stringloader.h> |
|
30 #include <bautils.h> |
|
31 #include <apparc.h> |
|
32 |
|
33 // User includes |
|
34 #include "manualvideoeditor.hrh" |
|
35 #include "VeiAppUi.h" |
|
36 #include "VeiEditVideoView.h" |
|
37 #include "VeiSettingsView.h" |
|
38 #include "VeiCutVideoView.h" |
|
39 #include "VeiCutAudioView.h" |
|
40 #include "VeiTrimForMmsView.h" |
|
41 #include "VeiTempMaker.h" |
|
42 #include "VideoEditorCommon.h" |
|
43 |
|
44 |
|
45 // ================= MEMBER FUNCTIONS ======================= |
|
46 // |
|
47 // ---------------------------------------------------------- |
|
48 // CVeiAppUi::ConstructL() |
|
49 // ?implementation_description |
|
50 // ---------------------------------------------------------- |
|
51 // |
|
52 void CVeiAppUi::ConstructL() |
|
53 { |
|
54 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL In" ); |
|
55 |
|
56 BaseConstructL( EAppOrientationAutomatic | EAknEnableSkin ); |
|
57 |
|
58 CVeiTempMaker* maker = CVeiTempMaker::NewL(); |
|
59 maker->EmptyTempFolder(); |
|
60 delete maker; |
|
61 |
|
62 iSendAppUi = CSendUi::NewL(); |
|
63 /* |
|
64 * Cut video view and Cut audio view are references to edit video view and |
|
65 * ownerships must be transfered(AddViewL(...)) to CAknViewAppUi(this) |
|
66 * AFTER references are taken to edit video view. Otherwise exit is not clean. |
|
67 */ |
|
68 |
|
69 // Cut Video view |
|
70 iCutVideoView = new( ELeave )CVeiCutVideoView; |
|
71 iCutVideoView->ConstructL(); |
|
72 |
|
73 // Cut Audio view |
|
74 iCutAudioView = CVeiCutAudioView::NewL(); |
|
75 |
|
76 // Edit Video view |
|
77 iEditVideoView = CVeiEditVideoView::NewL( *iCutVideoView, * iCutAudioView, * iSendAppUi ); |
|
78 |
|
79 AddViewL( iEditVideoView ); // transfer ownership to CAknViewAppUi |
|
80 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL EditVideoView OK" ); |
|
81 |
|
82 AddViewL( iCutAudioView ); |
|
83 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL CutAudioView OK" ); |
|
84 |
|
85 AddViewL( iCutVideoView ); // transfer ownership to CAknViewAppUi |
|
86 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL CutVideoView OK" ); |
|
87 |
|
88 //Trim for MMS view |
|
89 iTrimForMmsView = CVeiTrimForMmsView::NewL( *iSendAppUi ); |
|
90 AddViewL( iTrimForMmsView ); // Transfer ownership to CAknViewAppUi |
|
91 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL TrimForMmsView OK" ); |
|
92 |
|
93 //Settings view |
|
94 iSettingsView = CVeiSettingsView::NewL(); |
|
95 AddViewL( iSettingsView ); // Transfer ownership to CAknViewAppUi |
|
96 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL SettingsView OK" ); |
|
97 |
|
98 iVolume = - 1; // Volume not set |
|
99 |
|
100 iCoeEnv->RootWin().EnableScreenChangeEvents(); |
|
101 |
|
102 SetDefaultViewL( *iEditVideoView ); |
|
103 |
|
104 LOG( KVideoEditorLogFile, "CVeiAppUi::ConstructL Out" ); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------- |
|
108 // CVeiAppUi::~CVeiAppUi() |
|
109 // Destructor |
|
110 // Frees reserved resources |
|
111 // ---------------------------------------------------- |
|
112 // |
|
113 CVeiAppUi::~CVeiAppUi() |
|
114 { |
|
115 LOG( KVideoEditorLogFile, "CVeiAppUi::~CVeiAppUi: In" ); |
|
116 |
|
117 delete iSendAppUi; |
|
118 |
|
119 LOG( KVideoEditorLogFile, "CVeiAppUi::~CVeiAppUi: Out" ); |
|
120 } |
|
121 |
|
122 //============================================================================= |
|
123 CVeiAppUi::CVeiAppUi() |
|
124 { |
|
125 } |
|
126 |
|
127 //============================================================================= |
|
128 void CVeiAppUi::InsertVideoClipToMovieL( TBool aDoOpen, const TDesC& aFilename ) |
|
129 { |
|
130 LOGFMT( KVideoEditorLogFile, "CVeiAppUi::InsertVideoClipTomovieL (%S)", &aFilename ); |
|
131 |
|
132 |
|
133 if ( iEditVideoView ) |
|
134 { |
|
135 iEditVideoView->AddClipL( aFilename, aDoOpen ); |
|
136 } |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------- |
|
140 // CVeiAppUi::HandleKeyEventL( |
|
141 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) |
|
142 // ?implementation_description |
|
143 // ---------------------------------------------------- |
|
144 // |
|
145 TKeyResponse CVeiAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/, |
|
146 TEventCode /*aType*/ ) |
|
147 { |
|
148 return EKeyWasNotConsumed; |
|
149 } |
|
150 |
|
151 |
|
152 // ---------------------------------------------------- |
|
153 // CVeiAppUi::HandleCommandL(TInt aCommand) |
|
154 // ?implementation_description |
|
155 // ---------------------------------------------------- |
|
156 // |
|
157 void CVeiAppUi::HandleCommandL( TInt aCommand ) |
|
158 { |
|
159 LOGFMT( KVideoEditorLogFile, "CVeiAppUi::HandleCommandL( %d ): In", aCommand ); |
|
160 |
|
161 switch ( aCommand ) |
|
162 { |
|
163 // |
|
164 // Context Sensitive Help launching for: |
|
165 // -'Settings' view |
|
166 // -'Trim for MMS' view |
|
167 // -'Edit video' view |
|
168 // -'Cut video' view |
|
169 // -'Cut audio' view |
|
170 // |
|
171 case EAknCmdHelp: |
|
172 case EVeiCmdSettingsViewHelp: |
|
173 case EVeiCmdTrimForMmsViewHelp: |
|
174 case EVeiCmdEditVideoViewHelp: |
|
175 case EVeiCmdCutVideoViewHelp: |
|
176 { |
|
177 // Get the current context |
|
178 CArrayFix < TCoeHelpContext > * context = AppHelpContextL(); |
|
179 |
|
180 // Launch the help application with current context topic |
|
181 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
182 context ); |
|
183 break; |
|
184 } |
|
185 case EAknSoftkeyBack: |
|
186 case EEikCmdExit: |
|
187 case EAknSoftkeyExit: |
|
188 case EAknCmdExit: |
|
189 { |
|
190 iOnTheWayToDestruction = ETrue; |
|
191 |
|
192 CVeiTempMaker* maker = CVeiTempMaker::NewL(); |
|
193 maker->EmptyTempFolder(); |
|
194 delete maker; |
|
195 |
|
196 iEditVideoView->HandleCommandL( EAknSoftkeyOk ); |
|
197 Exit(); |
|
198 break; |
|
199 } |
|
200 default: |
|
201 break; |
|
202 } |
|
203 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleCommandL: Out" ); |
|
204 } |
|
205 |
|
206 //============================================================================= |
|
207 void CVeiAppUi::ReadSettingsL( TVeiSettings& aSettings )const |
|
208 { |
|
209 LOG( KVideoEditorLogFile, "CVeiAppUi::ReadSettingsL: in" ); |
|
210 CDictionaryStore* store = Application()->OpenIniFileLC( iCoeEnv->FsSession() ); |
|
211 |
|
212 |
|
213 TBool storePresent = store->IsPresentL( KUidVideoEditor ); // UID has an associated stream? |
|
214 |
|
215 if ( storePresent ) |
|
216 { |
|
217 RDictionaryReadStream readStream; |
|
218 readStream.OpenLC( *store, KUidVideoEditor ); |
|
219 |
|
220 readStream >> aSettings; // Internalize data to TVeiSettings. |
|
221 |
|
222 CleanupStack::PopAndDestroy( &readStream ); |
|
223 } |
|
224 else |
|
225 { |
|
226 /* Read the default filenames from resources */ |
|
227 HBufC* videoName = iEikonEnv->AllocReadResourceLC( R_VEI_SETTINGS_VIEW_SETTINGS_ITEM_VALUE ); |
|
228 |
|
229 const CFont* myFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont ); |
|
230 |
|
231 aSettings.DefaultVideoName() = AknTextUtils::ChooseScalableText( videoName->Des(), * myFont, 400 ); |
|
232 CleanupStack::PopAndDestroy( videoName ); |
|
233 |
|
234 HBufC* snapshotName = iEikonEnv->AllocReadResourceLC( R_VEI_SETTINGS_VIEW_SETTINGS_ITEM2_VALUE ); |
|
235 |
|
236 aSettings.DefaultSnapshotName() = AknTextUtils::ChooseScalableText( snapshotName->Des(), * myFont, 400 ); |
|
237 CleanupStack::PopAndDestroy( snapshotName ); |
|
238 |
|
239 /* Memory card is used as a default target */ |
|
240 aSettings.MemoryInUse() = CAknMemorySelectionDialog::EMemoryCard; |
|
241 |
|
242 /* Set save quality to "Auto" by default. */ |
|
243 aSettings.SaveQuality() = TVeiSettings::EAuto; |
|
244 |
|
245 RDictionaryWriteStream writeStream; |
|
246 writeStream.AssignLC( *store, KUidVideoEditor ); |
|
247 |
|
248 writeStream << aSettings; |
|
249 |
|
250 writeStream.CommitL(); |
|
251 |
|
252 store->CommitL(); |
|
253 |
|
254 CleanupStack::PopAndDestroy( &writeStream ); |
|
255 } |
|
256 CleanupStack::PopAndDestroy( store ); |
|
257 LOG( KVideoEditorLogFile, "CVeiAppUi::ReadSettingsL: out" ); |
|
258 } |
|
259 |
|
260 //============================================================================= |
|
261 void CVeiAppUi::WriteSettingsL( const TVeiSettings& aSettings )const |
|
262 { |
|
263 LOG( KVideoEditorLogFile, "CVeiAppUi::WriteSettingsL: in" ); |
|
264 CDictionaryStore* store = Application()->OpenIniFileLC( iCoeEnv->FsSession() ); |
|
265 |
|
266 RDictionaryWriteStream writeStream; |
|
267 writeStream.AssignLC( *store, KUidVideoEditor ); |
|
268 writeStream << aSettings; |
|
269 writeStream.CommitL(); |
|
270 |
|
271 store->CommitL(); |
|
272 |
|
273 CleanupStack::PopAndDestroy( &writeStream ); |
|
274 CleanupStack::PopAndDestroy( &store ); |
|
275 LOG( KVideoEditorLogFile, "CVeiAppUi::WriteSettingsL: out" ); |
|
276 } |
|
277 |
|
278 //============================================================================= |
|
279 void CVeiAppUi::HandleScreenDeviceChangedL() |
|
280 { |
|
281 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleScreenDeviceChangedL: In" ); |
|
282 CAknViewAppUi::HandleScreenDeviceChangedL(); |
|
283 if ( iEditVideoView ) |
|
284 { |
|
285 iEditVideoView->HandleScreenDeviceChangedL(); |
|
286 } |
|
287 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleScreenDeviceChangedL: Out" ); |
|
288 } |
|
289 |
|
290 //============================================================================= |
|
291 void CVeiAppUi::HandleResourceChangeL( TInt aType ) |
|
292 { |
|
293 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleResourceChangeL: In" ); |
|
294 CAknAppUi::HandleResourceChangeL( aType ); |
|
295 if ( iEditVideoView ) |
|
296 { |
|
297 iEditVideoView->HandleResourceChange( aType ); |
|
298 } |
|
299 if ( iCutVideoView ) |
|
300 { |
|
301 iCutVideoView->HandleResourceChange( aType ); |
|
302 } |
|
303 if ( iCutAudioView ) |
|
304 { |
|
305 iCutAudioView->HandleResourceChange( aType ); |
|
306 } |
|
307 if ( iTrimForMmsView ) |
|
308 { |
|
309 iTrimForMmsView->HandleResourceChange( aType ); |
|
310 } |
|
311 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleResourceChangeL: Out" ); |
|
312 } |
|
313 |
|
314 //============================================================================= |
|
315 void CVeiAppUi::HandleFileNotificationEventL() |
|
316 { |
|
317 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleFileNotificationEventL: In" ); |
|
318 if ( iEditVideoView ) |
|
319 { |
|
320 if ( iEditVideoView->WaitMode() == CVeiEditVideoView ::EProcessingMovieSaveThenQuit ) |
|
321 { |
|
322 HandleCommandL( EAknCmdExit ); |
|
323 } |
|
324 } |
|
325 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleFileNotificationEventL: Out" ); |
|
326 } |
|
327 |
|
328 //============================================================================= |
|
329 void CVeiAppUi::HandleForegroundEventL( TBool aForeground ) |
|
330 { |
|
331 LOGFMT( KVideoEditorLogFile, "CVeiAppUi::HandleForegroundEventL: In: %d", aForeground ); |
|
332 CAknViewAppUi::HandleForegroundEventL( aForeground ); |
|
333 if ( !aForeground ) |
|
334 { |
|
335 // Set the priority to low. This is needed to handle the situations |
|
336 // where the engine is performing heavy processing while the application |
|
337 // is in background. |
|
338 RProcess myProcess; |
|
339 iOriginalProcessPriority = myProcess.Priority(); |
|
340 LOGFMT3( KVideoEditorLogFile, |
|
341 "CVeiAppUi::HandleForegroundEventL: changing priority of process %Ld from %d to %d", myProcess.Id().Id(), iOriginalProcessPriority, EPriorityLow ); |
|
342 myProcess.SetPriority( EPriorityLow ); |
|
343 iProcessPriorityAltered = ETrue; |
|
344 } |
|
345 else if ( iProcessPriorityAltered ) |
|
346 { |
|
347 // Return to normal priority. |
|
348 RProcess myProcess; |
|
349 TProcessPriority priority = myProcess.Priority(); |
|
350 if ( priority < iOriginalProcessPriority ) |
|
351 { |
|
352 myProcess.SetPriority( iOriginalProcessPriority ); |
|
353 } |
|
354 iProcessPriorityAltered = EFalse; |
|
355 LOGFMT2( KVideoEditorLogFile, |
|
356 "CVeiAppUi::HandleForegroundEventL: process %Ld back to normal priority %d", myProcess.Id().Id(), priority ); |
|
357 } |
|
358 |
|
359 LOG( KVideoEditorLogFile, "CVeiAppUi::HandleForegroundEventL: Out" ); |
|
360 } |
|
361 |
|
362 //============================================================================= |
|
363 TErrorHandlerResponse CVeiAppUi::HandleError ( TInt aError, |
|
364 const SExtendedError & aExtErr, |
|
365 TDes & aErrorText, |
|
366 TDes & aContextText ) |
|
367 { |
|
368 LOGFMT( KVideoEditorLogFile, "CVeiAppUi::HandleError: %d", aError ); |
|
369 |
|
370 // Let the framework handle errors |
|
371 return CAknViewAppUi::HandleError ( aError, aExtErr, aErrorText, aContextText ); |
|
372 } |
|
373 |
|
374 // End of File |
|