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 #include <eikmenup.h> |
|
21 #include "VideoProvider.h" |
|
22 #include <AiwMenu.h> |
|
23 #include <AiwCommon.h> |
|
24 #include <AiwGenericParam.h> |
|
25 #include <eikenv.h> |
|
26 #include <VideoProviderInternal.rsg> |
|
27 #include <ImplementationProxy.h> |
|
28 #include "VideoProviderUids.hrh" |
|
29 #include "VideoProvider.rh" |
|
30 #include <aknutils.h> |
|
31 #include <bautils.h> |
|
32 #include <AknOpenFileService.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 #include <apgcli.h> |
|
35 #include <apmrec.h> |
|
36 #include <caf.h> // for DRM checks |
|
37 #include <e32property.h> |
|
38 #include <f32file.h> |
|
39 #include "VideoEditorCommon.h" |
|
40 #include "VideoEditorUtils.h" |
|
41 #include "VideoEditorDebugUtils.h" |
|
42 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
43 #include "SimpleVideoEditor.h" |
|
44 #endif |
|
45 |
|
46 using namespace ContentAccess; |
|
47 |
|
48 |
|
49 //============================================================================= |
|
50 CVideoProvider* CVideoProvider::NewL() |
|
51 { |
|
52 LOG(KVideoProviderLogFile, "CVideoProvider::NewL"); |
|
53 |
|
54 return new (ELeave) CVideoProvider(); |
|
55 } |
|
56 |
|
57 //============================================================================= |
|
58 CVideoProvider::CVideoProvider() : iResLoader(*CEikonEnv::Static()) |
|
59 { |
|
60 LOG(KVideoProviderLogFile, "CVideoProvider::CVideoProvider: In"); |
|
61 |
|
62 _LIT(KResourceFile, "VideoProviderInternal.rsc"); |
|
63 TFileName fileName; |
|
64 TParse p; |
|
65 |
|
66 Dll::FileName(fileName); |
|
67 p.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, &fileName); |
|
68 iResourceFile = p.FullName(); |
|
69 |
|
70 iResFileIsLoaded = EFalse; |
|
71 |
|
72 LOG(KVideoProviderLogFile, "CVideoProvider::CVideoProvider: Out"); |
|
73 } |
|
74 |
|
75 //============================================================================= |
|
76 CVideoProvider::~CVideoProvider() |
|
77 { |
|
78 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): In"); |
|
79 |
|
80 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
81 if (iSimpleVideoEditor) |
|
82 { |
|
83 iSimpleVideoEditor->Cancel(); |
|
84 } |
|
85 delete iSimpleVideoEditor; |
|
86 iSimpleVideoEditor = NULL; |
|
87 #endif |
|
88 |
|
89 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): 1"); |
|
90 CloseFsSession(); |
|
91 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): 2"); |
|
92 |
|
93 iAiwNotifyCallback = NULL; |
|
94 iInParamList->Reset(); |
|
95 delete iInParamList; |
|
96 iOutParamList->Reset(); |
|
97 delete iOutParamList; |
|
98 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): 3"); |
|
99 delete iOpenFileService; |
|
100 iOpenFileService = NULL; |
|
101 iResLoader.Close(); |
|
102 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): 4"); |
|
103 iSourceMGAlbumIdList.Close(); |
|
104 |
|
105 LOG(KVideoProviderLogFile, "CVideoProvider::~CVideoProvider(): Out"); |
|
106 } |
|
107 |
|
108 //============================================================================= |
|
109 void CVideoProvider::InitialiseL(MAiwNotifyCallback& /*aFrameworkCallback*/, |
|
110 const RCriteriaArray& /*aInterest*/) |
|
111 { |
|
112 LOG(KVideoProviderLogFile, "CVideoProvider::InitialiseL: in"); |
|
113 |
|
114 if (!iInParamList) |
|
115 { |
|
116 iInParamList = CAiwGenericParamList::NewL(); |
|
117 } |
|
118 |
|
119 if (!iOutParamList) |
|
120 { |
|
121 iOutParamList = CAiwGenericParamList::NewL(); |
|
122 } |
|
123 |
|
124 if ( !iResFileIsLoaded ) |
|
125 { |
|
126 BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), iResourceFile ); |
|
127 LOGFMT(KVideoProviderLogFile, "CVideoProvider::InitialiseL: Loading resource file: %S", &iResourceFile); |
|
128 iResLoader.OpenL( iResourceFile ); |
|
129 } |
|
130 |
|
131 iResFileIsLoaded = ETrue; |
|
132 |
|
133 // Publish & Subscribe API used for delivering document name from application to AIW provider |
|
134 // NOTE: this assumes only a single instance of video editor(s) at a time. |
|
135 TInt err = RProperty::Define(KUidVideoEditorProperties, VideoEditor::EPropertyFilename, RProperty::EText); |
|
136 if (err != KErrAlreadyExists) |
|
137 { |
|
138 LOGFMT(KVideoProviderLogFile, "CVideoProvider::InitialiseL: Calling RProperty::Define(KUidVideoEditorProperties, VideoEditor::EPropertyFilename, RProperty::EText): error %d", err); |
|
139 User::LeaveIfError(err); |
|
140 } |
|
141 |
|
142 LOG(KVideoProviderLogFile, "CVideoProvider::InitialiseL: out"); |
|
143 } |
|
144 |
|
145 //============================================================================= |
|
146 void CVideoProvider::InitializeMenuPaneL(CAiwMenuPane& aMenuPane, |
|
147 TInt aIndex, |
|
148 TInt /*aCascadeId*/, |
|
149 const CAiwGenericParamList& aInParamList) |
|
150 { |
|
151 LOGFMT2(KVideoProviderLogFile, "CVideoProvider::InitializeMenuPaneL: In (aIndex: %d, aInParamList.Count(): %d)", aIndex, aInParamList.Count()); |
|
152 |
|
153 #ifdef LOG_TIMING |
|
154 TTime startTime(0); |
|
155 startTime.UniversalTime(); |
|
156 TTime inputAnalyzedTime(0); |
|
157 TTime endTime(0); |
|
158 #endif // LOG_TIMING |
|
159 |
|
160 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
161 |
|
162 // First check what kin of files the parameter list contains |
|
163 // and what we can do with them |
|
164 TInt numberOfEditableVideoClips = 0; |
|
165 TInt numberOfEditableAudioClips = 0; |
|
166 TInt numberOfEditableImages = 0; |
|
167 |
|
168 // We trust that aInParamList is always the same, i.e. |
|
169 // - a few (seems to be 3) parameters in the begining |
|
170 // - after that, filename/mimetype pairs |
|
171 TInt paramCount = aInParamList.Count(); |
|
172 TInt fileCount = aInParamList.Count( EGenericParamFile ); |
|
173 |
|
174 if ( fileCount <= KAiwMaxNumberOfFilesSimultaneouslyHandled ) |
|
175 { |
|
176 for ( TInt i=0; i < paramCount ; i++ ) |
|
177 { |
|
178 TBool isDRMProtected( EFalse ); |
|
179 |
|
180 // Extract file names from the parameter list. |
|
181 const TAiwGenericParam& param = aInParamList[i]; |
|
182 if (param.SemanticId() == EGenericParamFile) |
|
183 { |
|
184 TPtrC fileName = param.Value().AsDes(); |
|
185 LOGFMT(KVideoProviderLogFile, "\tfile name: %S", &fileName); |
|
186 |
|
187 // Next we need to get the MIME typ of the file. |
|
188 TBuf<KMaxDataTypeLength> mimeType; |
|
189 RFile file; |
|
190 TInt err( file.Open( fs, fileName, EFileShareReadersOnly ) ); |
|
191 if( KErrNone != err ) |
|
192 { |
|
193 err = file.Open( fs, fileName, EFileShareAny ); |
|
194 } |
|
195 |
|
196 if( KErrNone == err ) |
|
197 { |
|
198 TDataRecognitionResult dataType; |
|
199 CleanupClosePushL( file ); |
|
200 // Check if the file is valid |
|
201 RApaLsSession lsSession; |
|
202 err = lsSession.Connect(); |
|
203 CleanupClosePushL( lsSession ); |
|
204 err = lsSession.RecognizeData( file, dataType ); |
|
205 if ( KErrNone == err ) |
|
206 { |
|
207 const TInt confidence( dataType.iConfidence ); |
|
208 if( CApaDataRecognizerType::ECertain == confidence || |
|
209 CApaDataRecognizerType::EProbable == confidence || |
|
210 CApaDataRecognizerType::EPossible == confidence ) |
|
211 { |
|
212 mimeType = dataType.iDataType.Des(); |
|
213 } |
|
214 } |
|
215 CleanupStack::PopAndDestroy( 2 ); // file, lsSession |
|
216 } |
|
217 |
|
218 // Based on the MIME type, decice whether we support this file. |
|
219 if (mimeType.Length()) |
|
220 { |
|
221 // Create CContent-object |
|
222 CContent* pContent = CContent::NewLC(fileName); |
|
223 // See if the content object is protected |
|
224 User::LeaveIfError( pContent->GetAttribute( EIsProtected, isDRMProtected ) ); |
|
225 |
|
226 CleanupStack::PopAndDestroy (pContent); |
|
227 if (!isDRMProtected) |
|
228 { |
|
229 if ( IsSupportedVideoFile(mimeType) ) |
|
230 { |
|
231 numberOfEditableVideoClips++; |
|
232 } |
|
233 else if ( IsSupportedAudioFile(mimeType) ) |
|
234 { |
|
235 numberOfEditableAudioClips++; |
|
236 } |
|
237 else if ( IsSupportedImageFile(mimeType) ) |
|
238 { |
|
239 numberOfEditableImages++; |
|
240 } |
|
241 } |
|
242 else |
|
243 { |
|
244 LOGFMT(KVideoProviderLogFile, "\tCannot edit DRM protected file: %S", &fileName); |
|
245 } |
|
246 } |
|
247 } |
|
248 } |
|
249 } |
|
250 else |
|
251 { |
|
252 LOGFMT(KVideoProviderLogFile, "CVideoProvider::InitialiseL: too many files to handle (%d). Ignored.", fileCount); |
|
253 } |
|
254 |
|
255 // When the content of the parameter list is analyzed, |
|
256 // add the appropriate menu items |
|
257 LOGFMT3(KVideoProviderLogFile, "CVideoProvider::InitializeMenuPaneL: AIW parameter list content analyzed: numberOfEditableVideoClips: %d, numberOfEditableAudioClips: %d, numberOfEditableImages: %d", numberOfEditableVideoClips,numberOfEditableAudioClips,numberOfEditableImages); |
|
258 |
|
259 #ifdef LOG_TIMING |
|
260 inputAnalyzedTime.UniversalTime(); |
|
261 #endif // LOG_TIMING |
|
262 |
|
263 // CASE 1: one video selected: all options available |
|
264 if (numberOfEditableVideoClips == 1 && (numberOfEditableAudioClips+numberOfEditableImages) == 0) |
|
265 { |
|
266 |
|
267 #if defined(INCLUDE_MANUAL_VIDEO_EDITOR) |
|
268 |
|
269 // Advanced (manual) editor |
|
270 aMenuPane.AddMenuItemsL( |
|
271 iResourceFile, |
|
272 R_VIDEOEDITORPROVIDER_ADVANCED_MENU, |
|
273 KAiwCmdEdit, |
|
274 aIndex ); |
|
275 |
|
276 #endif // INCLUDE_MANUAL_VIDEO_EDITOR |
|
277 |
|
278 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
279 |
|
280 // Simple Cut |
|
281 aMenuPane.AddMenuItemsL( |
|
282 iResourceFile, |
|
283 R_VIDEOEDITORPROVIDER_CUT_MENU, |
|
284 KAiwCmdEdit, |
|
285 aIndex ); |
|
286 |
|
287 // Simple Add text |
|
288 aMenuPane.AddMenuItemsL( |
|
289 iResourceFile, |
|
290 R_VIDEOEDITORPROVIDER_ADD_TEXT_MENU, |
|
291 KAiwCmdEdit, |
|
292 aIndex ); |
|
293 |
|
294 // Simple Add audio |
|
295 aMenuPane.AddMenuItemsL( |
|
296 iResourceFile, |
|
297 R_VIDEOEDITORPROVIDER_ADD_AUDIO_MENU, |
|
298 KAiwCmdEdit, |
|
299 aIndex ); |
|
300 |
|
301 // Simple merge |
|
302 aMenuPane.AddMenuItemsL( |
|
303 iResourceFile, |
|
304 R_VIDEOEDITORPROVIDER_MERGE_MENU, |
|
305 KAiwCmdEdit, |
|
306 aIndex ); |
|
307 |
|
308 // Sub-menu title "Edit" |
|
309 aMenuPane.AddMenuItemsL( |
|
310 iResourceFile, |
|
311 R_VIDEOEDITORPROVIDER_SUBMENU_TITLE, |
|
312 KAiwCmdEdit, |
|
313 aIndex ); |
|
314 |
|
315 #endif // INCLUDE_SIMPLE_VIDEO_EDITOR |
|
316 |
|
317 } |
|
318 |
|
319 #if defined(INCLUDE_MANUAL_VIDEO_EDITOR) |
|
320 |
|
321 // CASE 2: several video clips or other files selected: only manual editor available, |
|
322 // and only if there is at least one video. |
|
323 if (numberOfEditableVideoClips > 0 |
|
324 && (numberOfEditableVideoClips+numberOfEditableAudioClips+numberOfEditableImages) > 1) |
|
325 { |
|
326 // Advanced (manual) editor only |
|
327 aMenuPane.AddMenuItemsL( |
|
328 iResourceFile, |
|
329 R_VIDEOEDITORPROVIDER_EDIT_MENU, |
|
330 KAiwCmdEdit, |
|
331 aIndex ); |
|
332 } |
|
333 |
|
334 #endif // INCLUDE_MANUAL_VIDEO_EDITOR |
|
335 |
|
336 #ifdef LOG_TIMING |
|
337 endTime.UniversalTime(); |
|
338 |
|
339 TInt64 totalTime = endTime.Int64() - startTime.Int64(); |
|
340 TInt64 inputlistAnalyzingtime = inputAnalyzedTime.Int64() - startTime.Int64(); |
|
341 TInt64 menuPaneAddingTime = endTime.Int64() - inputAnalyzedTime.Int64(); |
|
342 |
|
343 _LIT(KText1, "AIW Parameter list contains %d files (total %d parameters). Times taken:"); |
|
344 _LIT(KText2, " Total: %Ld, Analyzing input param list: %Ld, Adding menu items: %Ld"); |
|
345 TFileName path(KLogsFolder); |
|
346 path.Append(KLogDir); |
|
347 path.Append(KBackslash); |
|
348 TFileName fileNameAndPath(path); |
|
349 fileNameAndPath.Append(_L("VideoProviderTiming.log")); |
|
350 if(BaflUtils::FolderExists(fs,path)) |
|
351 { |
|
352 TLogFileDes16OverflowHandler ofh; |
|
353 TBuf<KMaxLogLineLength> buf1; |
|
354 TBuf<KMaxLogLineLength> buf2; |
|
355 buf1.AppendFormat(KText1,&ofh,fileCount,paramCount); |
|
356 buf2.AppendFormat(KText2,&ofh,totalTime,inputlistAnalyzingtime,menuPaneAddingTime); |
|
357 CLogFile::StaticLog(fileNameAndPath,buf1); |
|
358 CLogFile::StaticLog(fileNameAndPath,buf2); |
|
359 } |
|
360 RDebug::Print(KText1, fileCount, paramCount); |
|
361 RDebug::Print(KText2, totalTime, inputlistAnalyzingtime, menuPaneAddingTime); |
|
362 #endif // LOG_TIMING |
|
363 |
|
364 LOG(KVideoProviderLogFile, "CVideoProvider::InitializeMenuPaneL: out"); |
|
365 } |
|
366 |
|
367 //============================================================================= |
|
368 void CVideoProvider::HandleServiceCmdL(const TInt& aCmdId, |
|
369 const CAiwGenericParamList& aInParamList, |
|
370 CAiwGenericParamList& aOutParamList, |
|
371 TUint aCmdOptions, |
|
372 const MAiwNotifyCallback* aCallback) |
|
373 { |
|
374 LOGFMT(KVideoProviderLogFile, "CVideoProvider::HandleServiceCmdL (%d)", aCmdId); |
|
375 HandleCmdsL(aCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback); |
|
376 } |
|
377 |
|
378 //============================================================================= |
|
379 void CVideoProvider::HandleMenuCmdL ( |
|
380 TInt aMenuCmdId, |
|
381 const CAiwGenericParamList & aInParamList, |
|
382 CAiwGenericParamList & aOutParamList, |
|
383 TUint aCmdOptions, |
|
384 const MAiwNotifyCallback * aCallback) |
|
385 |
|
386 { |
|
387 LOGFMT(KVideoProviderLogFile, "CVideoProvider::HandleMenuCmdL (%d)", aMenuCmdId); |
|
388 HandleCmdsL(aMenuCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback); |
|
389 } |
|
390 |
|
391 //============================================================================= |
|
392 void CVideoProvider::HandleCmdsL(TInt aMenuCmdId, |
|
393 const CAiwGenericParamList& aInParamList, |
|
394 CAiwGenericParamList& aOutParamList, |
|
395 TUint /*aCmdOptions*/, |
|
396 const MAiwNotifyCallback* aCallback) |
|
397 { |
|
398 LOGFMT(KVideoProviderLogFile, "CVideoProvider::HandleCmdsL (%d): In", aMenuCmdId); |
|
399 |
|
400 switch ( aMenuCmdId ) |
|
401 { |
|
402 case EVideoEditorProviderCmdMerge: |
|
403 case EVideoEditorProviderCmdAddAudio: |
|
404 case EVideoEditorProviderCmdAddText: |
|
405 case EVideoEditorProviderCmdCut: |
|
406 case EVideoEditorProviderCmdAdvanced: |
|
407 { |
|
408 // Store input parameters |
|
409 if (aCallback) |
|
410 { |
|
411 iAiwNotifyCallback = aCallback; |
|
412 iInParamList->Reset(); |
|
413 iInParamList->AppendL(aInParamList); |
|
414 iOutParamList->Reset(); |
|
415 iOutParamList->AppendL(aOutParamList); |
|
416 LOG(KVideoProviderLogFile, "CVideoProvider: Using AIW call back"); |
|
417 } |
|
418 else |
|
419 { |
|
420 iAiwNotifyCallback = NULL; |
|
421 } |
|
422 |
|
423 // Open file server session |
|
424 User::LeaveIfError(iSharableFS.Connect()); |
|
425 iSharableFS.ShareProtected(); |
|
426 |
|
427 // Find the first file on the generic param list... |
|
428 // There must be at least one file, and all the files must exist. |
|
429 TPtrC fileName; |
|
430 TInt count = aInParamList.Count(); |
|
431 iSourceMGAlbumIdList.Reset(); |
|
432 for (TInt i = count - 1; i >= 0; --i) |
|
433 { |
|
434 const TAiwGenericParam& param = aInParamList[i]; |
|
435 if (param.SemanticId() == EGenericParamFile) |
|
436 { |
|
437 fileName.Set(param.Value().AsDes()); |
|
438 |
|
439 // Check that that the file exists and is accessible. |
|
440 // The AIW consumer should provide us only valid files. |
|
441 // If this is not the case, just leave and let the consumer handle the error. |
|
442 TEntry entry; |
|
443 TInt err = iSharableFS.Entry( fileName, entry ); |
|
444 LOGFMT2(KVideoProviderLogFile, "CVideoProvider::HandleCmdsL: Could not open file: %S, error: %d", &fileName, err); |
|
445 User::LeaveIfError( err ); |
|
446 |
|
447 // Store the time stamp of the most recent file (needed later). |
|
448 TTime time = entry.iModified; |
|
449 if (iOriginalTimeStamp < time) |
|
450 { |
|
451 iOriginalTimeStamp = time; |
|
452 } |
|
453 |
|
454 // Find out whether the source file belongs to any albums |
|
455 VideoEditorUtils::GetMGAlbumsListForMediaFileL ( |
|
456 iSourceMGAlbumIdList, |
|
457 fileName ); |
|
458 } |
|
459 } |
|
460 |
|
461 // Launch the editor |
|
462 LaunchEditorL( aMenuCmdId, fileName, aInParamList); |
|
463 |
|
464 break; |
|
465 } |
|
466 default: |
|
467 { |
|
468 break; |
|
469 } |
|
470 } |
|
471 LOG(KVideoProviderLogFile, "CVideoProvider::HandleCmdsL: out"); |
|
472 } |
|
473 |
|
474 //============================================================================= |
|
475 void CVideoProvider::LaunchEditorL( |
|
476 TInt aMenuCmdId, |
|
477 const TDesC & aFileName, |
|
478 const CAiwGenericParamList & aInParamList |
|
479 ) |
|
480 { |
|
481 LOGFMT(KVideoProviderLogFile, "CVideoProvider::LaunchEditorL: file: %S", &aFileName); |
|
482 |
|
483 RFile fileHandle; |
|
484 TInt err = fileHandle.Open(iSharableFS,aFileName,EFileWrite|EFileShareReadersOrWriters); |
|
485 if (KErrNone != err) |
|
486 { |
|
487 LOG(KVideoEditorLogFile, "CVideoProvider::LaunchEditorL: Could not open file with EFileWrite. Trying EFileRead"); |
|
488 User::LeaveIfError( fileHandle.Open (iSharableFS,aFileName,EFileRead|EFileShareReadersOrWriters) ); |
|
489 } |
|
490 CleanupClosePushL (fileHandle); |
|
491 |
|
492 if (iAiwNotifyCallback) |
|
493 { |
|
494 const_cast<MAiwNotifyCallback*>(iAiwNotifyCallback)->HandleNotifyL(KAiwCmdEdit, KAiwEventStarted, *iOutParamList, *iInParamList); |
|
495 } |
|
496 |
|
497 switch ( aMenuCmdId ) |
|
498 { |
|
499 case EVideoEditorProviderCmdMerge: |
|
500 { |
|
501 LOG(KVideoProviderLogFile, "\tEVideoEditorProviderCmdMerge"); |
|
502 |
|
503 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
504 delete iSimpleVideoEditor; |
|
505 iSimpleVideoEditor = NULL; |
|
506 iSimpleVideoEditor = CSimpleVideoEditor::NewL( *this ); |
|
507 iSimpleVideoEditor->Merge (aFileName); |
|
508 #endif // INCLUDE_SIMPLE_VIDEO_EDITOR |
|
509 |
|
510 break; |
|
511 } |
|
512 case EVideoEditorProviderCmdAddAudio: |
|
513 { |
|
514 LOG(KVideoProviderLogFile, "\tEVideoEditorProviderCmdAddAudio"); |
|
515 |
|
516 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
517 delete iSimpleVideoEditor; |
|
518 iSimpleVideoEditor = NULL; |
|
519 iSimpleVideoEditor = CSimpleVideoEditor::NewL( *this ); |
|
520 iSimpleVideoEditor->ChangeAudio (aFileName); |
|
521 #endif // INCLUDE_SIMPLE_VIDEO_EDITOR |
|
522 |
|
523 break; |
|
524 } |
|
525 case EVideoEditorProviderCmdAddText: |
|
526 { |
|
527 LOG(KVideoProviderLogFile, "\tEVideoEditorProviderCmdAddText"); |
|
528 |
|
529 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
530 delete iSimpleVideoEditor; |
|
531 iSimpleVideoEditor = NULL; |
|
532 iSimpleVideoEditor = CSimpleVideoEditor::NewL( *this ); |
|
533 iSimpleVideoEditor->AddText (aFileName); |
|
534 #endif // INCLUDE_SIMPLE_VIDEO_EDITOR |
|
535 |
|
536 break; |
|
537 } |
|
538 case EVideoEditorProviderCmdCut: |
|
539 { |
|
540 LOG(KVideoProviderLogFile, "\tEVideoEditorProviderCmdCut"); |
|
541 iOpenFileService = CAknOpenFileService::NewL (KUidSimpleCutVideo,fileHandle,(MAknServerAppExitObserver *)this,&const_cast<CAiwGenericParamList &>(aInParamList)); |
|
542 break; |
|
543 } |
|
544 case EVideoEditorProviderCmdAdvanced: |
|
545 { |
|
546 LOG(KVideoProviderLogFile, "\tEVideoEditorProviderCmdAdvanced"); |
|
547 iOpenFileService = CAknOpenFileService::NewL (KUidVideoEditor,fileHandle,(MAknServerAppExitObserver *)this,&const_cast<CAiwGenericParamList &>(aInParamList)); |
|
548 break; |
|
549 } |
|
550 default: |
|
551 LOG(KVideoProviderLogFile, "\tUnknown command!"); |
|
552 break; |
|
553 } |
|
554 |
|
555 CleanupStack::PopAndDestroy( &fileHandle ); // close fileHandle |
|
556 |
|
557 LOG(KVideoProviderLogFile, "CVideoProvider::LaunchEditorL: out"); |
|
558 } |
|
559 |
|
560 //============================================================================= |
|
561 TBool CVideoProvider::IsSupportedVideoFile (const TDesC& aDataType) const |
|
562 { |
|
563 _LIT(KMime3gp, "video/3gpp"); |
|
564 _LIT(KMimeMp4, "video/mp4"); |
|
565 |
|
566 return aDataType.CompareF( KMime3gp ) == 0 || aDataType.CompareF( KMimeMp4 ) == 0; |
|
567 } |
|
568 |
|
569 //============================================================================= |
|
570 TBool CVideoProvider::IsSupportedAudioFile (const TDesC& aDataType) const |
|
571 { |
|
572 _LIT(KMimeAllAudio, "audio/"); |
|
573 return aDataType.Left(6).CompareF( KMimeAllAudio ) == 0; |
|
574 } |
|
575 |
|
576 //============================================================================= |
|
577 TBool CVideoProvider::IsSupportedImageFile (const TDesC& aDataType) const |
|
578 { |
|
579 _LIT(KMimeAllImages, "image/"); |
|
580 return aDataType.Left(6).CompareF( KMimeAllImages ) == 0; |
|
581 } |
|
582 |
|
583 //============================================================================= |
|
584 void CVideoProvider::HandleServerAppExit (TInt aReason) |
|
585 { |
|
586 LOGFMT(KVideoProviderLogFile, "CVideoProvider::HandleServerAppExit: In: %d", aReason); |
|
587 |
|
588 delete iOpenFileService; |
|
589 iOpenFileService = NULL; |
|
590 |
|
591 // Get the output file name provided by the editor application |
|
592 TFileName newFileName; |
|
593 (void) RProperty::Get(KUidVideoEditorProperties, VideoEditor::EPropertyFilename, newFileName); |
|
594 |
|
595 // Report new file to AIW consumer |
|
596 TRAP_IGNORE( FinalizeL (newFileName) ); |
|
597 MAknServerAppExitObserver::HandleServerAppExit(aReason); |
|
598 |
|
599 LOG(KVideoProviderLogFile, "CVideoProvider::HandleServerAppExit: Out"); |
|
600 } |
|
601 |
|
602 //============================================================================= |
|
603 void CVideoProvider::HandleSimpleVideoEditorExit (TInt DEBUGLOG_ARG(aReason), const TDesC& aResultFileName) |
|
604 { |
|
605 LOGFMT2(KVideoProviderLogFile, "CVideoProvider::HandleSimpleVideoEditorExitL: In: %d, %S", aReason, &aResultFileName); |
|
606 |
|
607 #if defined(INCLUDE_SIMPLE_VIDEO_EDITOR) |
|
608 |
|
609 // Report new file to AIW consumer |
|
610 TRAP_IGNORE( FinalizeL (aResultFileName) ); |
|
611 |
|
612 delete iSimpleVideoEditor; |
|
613 iSimpleVideoEditor = NULL; |
|
614 |
|
615 |
|
616 #endif // INCLUDE_SIMPLE_VIDEO_EDITOR |
|
617 |
|
618 LOG(KVideoProviderLogFile, "CVideoProvider::HandleSimpleVideoEditorExitL: Out"); |
|
619 } |
|
620 |
|
621 //============================================================================= |
|
622 void CVideoProvider::FinalizeL (const TDesC& aFileName) |
|
623 { |
|
624 LOGFMT(KVideoProviderLogFile, "CVideoProvider::FinalizeL: In: %S", &aFileName); |
|
625 |
|
626 #ifdef FILE_TIME_STAMP_UPDATE |
|
627 LOG(KVideoProviderLogFile, "CVideoProvider::FinalizeL: 2, executing FILE_TIME_STAMP_UPDATE"); |
|
628 // Set the timestamp of the saved file to original file's timestamp + 1 second. |
|
629 // The idea is to make the original and edited images appear next to each other. |
|
630 if( aFileName.Length() && BaflUtils::FileExists(iSharableFS,aFileName) ) |
|
631 { |
|
632 // The requirement is to increment the time by 1 second. |
|
633 // For some weird reason, setting Attribs to |
|
634 // iOriginalTimeStamp + TTimeIntervalSeconds (1) has no effect, |
|
635 // but 2 seconds works fine... |
|
636 TTime newTime = iOriginalTimeStamp + TTimeIntervalSeconds (2); |
|
637 |
|
638 CFileMan* fileMan = CFileMan::NewL( iSharableFS ); |
|
639 CleanupStack::PushL (fileMan); |
|
640 // do not set or clear any attribute, mofify time attribute |
|
641 fileMan->Attribs(aFileName, 0, 0, newTime); |
|
642 CleanupStack::PopAndDestroy (fileMan); |
|
643 } |
|
644 #endif |
|
645 |
|
646 iSourceMGAlbumIdList.Reset(); |
|
647 |
|
648 // Notify the AIW consumer |
|
649 if (iAiwNotifyCallback) |
|
650 { |
|
651 // Insert the file name to the output parameter list |
|
652 // (we assume that it is always the first item on the list) |
|
653 iOutParamList->Reset(); |
|
654 TAiwVariant variant(aFileName); |
|
655 TAiwGenericParam param(EGenericParamFile, variant); |
|
656 iOutParamList->AppendL(param); |
|
657 |
|
658 LOG(KVideoProviderLogFile, "CVideoProvider: Calling HandleNotifyL"); |
|
659 |
|
660 // Non-leaving function shall use TRAP |
|
661 TRAP_IGNORE ( |
|
662 const_cast<MAiwNotifyCallback*>(iAiwNotifyCallback)->HandleNotifyL(KAiwCmdEdit, KAiwEventCompleted, *iOutParamList, *iInParamList); |
|
663 const_cast<MAiwNotifyCallback*>(iAiwNotifyCallback)->HandleNotifyL(KAiwCmdEdit, KAiwEventStopped, *iOutParamList, *iInParamList); |
|
664 ); |
|
665 |
|
666 // Reset new filename property and out paramlist |
|
667 User::LeaveIfError(RProperty::Set(KUidVideoEditorProperties, VideoEditor::EPropertyFilename, KNullDesC)); |
|
668 iOutParamList->Reset(); |
|
669 } |
|
670 |
|
671 CloseFsSession(); |
|
672 |
|
673 LOG(KVideoProviderLogFile, "CVideoProvider::FinalizeL: Out"); |
|
674 } |
|
675 |
|
676 //============================================================================= |
|
677 void CVideoProvider::CloseFsSession() |
|
678 { |
|
679 LOG(KVideoProviderLogFile, "CVideoProvider::CloseFsSession(): In"); |
|
680 |
|
681 if (iSharableFS.Handle() != 0) |
|
682 { |
|
683 LOG(KVideoProviderLogFile, "\tClosing iSharableFS"); |
|
684 iSharableFS.Close(); |
|
685 } |
|
686 |
|
687 LOG(KVideoProviderLogFile, "CVideoProvider::CloseFsSession(): Out"); |
|
688 } |
|
689 |
|
690 |
|
691 // |
|
692 // Rest of the file is for ECom initialization. |
|
693 // |
|
694 |
|
695 // Map the interface UIDs to implementation factory functions |
|
696 LOCAL_D const TImplementationProxy ImplementationTable[] = |
|
697 { |
|
698 IMPLEMENTATION_PROXY_ENTRY( KVideoEditorProviderImplUid, CVideoProvider::NewL) |
|
699 }; |
|
700 |
|
701 // --------------------------------------------------------- |
|
702 // |
|
703 // Exported proxy for instantiation method resolution |
|
704 // --------------------------------------------------------- |
|
705 // |
|
706 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
707 { |
|
708 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
709 return ImplementationTable; |
|
710 } |
|
711 |
|
712 |
|
713 // End of file |
|