62 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
63 // Destructor. |
62 // Destructor. |
64 // ---------------------------------------------------------------------------- |
63 // ---------------------------------------------------------------------------- |
65 // |
64 // |
66 CVcxMyVideosAsyncFileOperations::~CVcxMyVideosAsyncFileOperations() |
65 CVcxMyVideosAsyncFileOperations::~CVcxMyVideosAsyncFileOperations() |
67 { |
66 { |
68 MPX_FUNC("CVcxMyVideosAsyncFileOperations::~CVcxMyVideosAsyncFileOperations"); |
|
69 |
|
70 iOperationIdArray.Close(); |
67 iOperationIdArray.Close(); |
71 iOperationResult.Close(); |
68 iOperationResult.Close(); |
|
69 delete iFileCopier; |
|
70 delete iMediaForMoveOp; |
|
71 delete iMediaForCopyOp; |
72 } |
72 } |
73 |
73 |
74 // ---------------------------------------------------------------------------- |
74 // ---------------------------------------------------------------------------- |
75 // Constructor. |
75 // Constructor. |
76 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
77 // |
77 // |
78 CVcxMyVideosAsyncFileOperations::CVcxMyVideosAsyncFileOperations( CVcxMyVideosCollectionPlugin& aCollection ) |
78 CVcxMyVideosAsyncFileOperations::CVcxMyVideosAsyncFileOperations( CVcxMyVideosCollectionPlugin& aCollection ) |
79 : iCollection( aCollection ) |
79 : iCollection( aCollection ) |
80 { |
80 { |
81 MPX_FUNC("CVcxMyVideosAsyncFileOperations::CVcxMyVideosAsyncFileOperations"); |
|
82 } |
81 } |
83 |
82 |
84 // ---------------------------------------------------------------------------- |
83 // ---------------------------------------------------------------------------- |
85 // Symbian 2nd phase constructor can leave. |
84 // Symbian 2nd phase constructor can leave. |
86 // ---------------------------------------------------------------------------- |
85 // ---------------------------------------------------------------------------- |
87 // |
86 // |
88 void CVcxMyVideosAsyncFileOperations::ConstructL () |
87 void CVcxMyVideosAsyncFileOperations::ConstructL () |
89 { |
88 { |
90 MPX_FUNC("CVcxMyVideosAsyncFileOperations::ConstructL"); |
89 iFileCopier = CVcxMyVideosAsyncFileCopy::NewL( iCollection.iFs ); |
91 } |
90 } |
92 |
91 |
93 // ---------------------------------------------------------------------------- |
92 // ---------------------------------------------------------------------------- |
94 // CVcxMyVideosCollectionPlugin::DeleteVideoL |
93 // CVcxMyVideosCollectionPlugin::DeleteVideoL |
95 // ---------------------------------------------------------------------------- |
94 // ---------------------------------------------------------------------------- |
228 User::ResetInactivityTime(); |
227 User::ResetInactivityTime(); |
229 |
228 |
230 CMPXMedia& cmd = iCollection.iActiveTask->GetCommand(); |
229 CMPXMedia& cmd = iCollection.iActiveTask->GetCommand(); |
231 |
230 |
232 TBool done; |
231 TBool done; |
233 |
232 |
234 TBool isMoveOperation = EFalse; |
233 if ( iCurrentOperationIndex == 0 && !iFileCopier->CopyIsOngoing() ) |
235 TUint32 cmdId = cmd.ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId ); |
234 { |
236 if ( cmdId == KVcxCommandMyVideosMove ) |
235 InitMoveOrCopyOperationsL( cmd ); |
237 { |
|
238 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move operation"); |
|
239 isMoveOperation = ETrue; |
|
240 } |
|
241 |
|
242 // Start operations |
|
243 if ( iCurrentOperationIndex == 0 ) |
|
244 { |
|
245 if ( !cmd.IsSupported( KMPXMediaArrayContents ) ) |
|
246 { |
|
247 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: error, no array defined"); |
|
248 User::Leave( KErrArgument ); |
|
249 } |
|
250 |
|
251 CMPXMediaArray* idMediaArray = cmd.Value<CMPXMediaArray>( |
|
252 KMPXMediaArrayContents ); |
|
253 |
|
254 if ( idMediaArray->Count() == 0 ) |
|
255 { |
|
256 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: error, no items in array "); |
|
257 User::Leave( KErrArgument ); |
|
258 } |
|
259 |
|
260 iTargetDrive = cmd.ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
261 |
|
262 TMPXItemId mpxId; |
|
263 iOperationIdArray.Reset(); |
|
264 TInt count = idMediaArray->Count(); |
|
265 for ( TInt i = 0; i < count; i++ ) |
|
266 { |
|
267 mpxId = idMediaArray->AtL( i )-> |
|
268 ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
269 MPX_DEBUG3("CVcxMyVideosAsyncFileOperations:: MPX ID: (%d, %d) will be moved ", |
|
270 mpxId.iId1, |
|
271 mpxId.iId2); |
|
272 iOperationIdArray.AppendL( idMediaArray->AtL( i )-> |
|
273 ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId ).iId1 ); |
|
274 } |
|
275 |
|
276 iCollection.SendMyVideosMessageL( KVcxMessageMyVideosMoveOrCopyStarted, &cmd ); |
|
277 |
|
278 iOperationResult.Reset(); |
|
279 } |
236 } |
280 |
237 |
281 TRAPD( err, MoveOrCopyVideoL( iOperationIdArray[iCurrentOperationIndex], |
238 TRAPD( err, MoveOrCopyVideoL( iOperationIdArray[iCurrentOperationIndex], |
282 iTargetDrive, isMoveOperation )); |
239 iTargetDrive )); |
283 |
240 |
|
241 if ( iFileCopier->CopyIsOngoing() && err == KErrNone ) |
|
242 { |
|
243 // copy didnt finish yet, lets do some more steps before jumping to next file |
|
244 return EFalse; |
|
245 } |
|
246 |
284 iOperationResult.AppendL( err ); |
247 iOperationResult.AppendL( err ); |
285 |
248 |
286 iCurrentOperationIndex++; |
249 iCurrentOperationIndex++; |
287 |
250 |
288 // End operations |
251 // End operations |
289 if ( iCurrentOperationIndex > (iOperationIdArray.Count() - 1) ) |
252 if ( iCurrentOperationIndex > (iOperationIdArray.Count() - 1) ) |
290 { |
253 { |
291 iCurrentOperationIndex = 0; |
254 iCurrentOperationIndex = 0; |
292 done = ETrue; |
255 done = ETrue; |
293 if ( isMoveOperation ) |
256 if ( iIsMoveOperation ) |
294 { |
257 { |
295 SendOperationRespL( KVcxMessageMyVideosMoveResp ); |
258 SendOperationRespL( KVcxMessageMyVideosMoveResp ); |
296 } |
259 } |
297 else |
260 else |
298 { |
261 { |
305 } |
268 } |
306 |
269 |
307 return done; |
270 return done; |
308 } |
271 } |
309 |
272 |
|
273 // ---------------------------------------------------------------------------- |
|
274 // CVcxMyVideosAsyncFileOperations::InitMoveOrCopyOperationsL |
|
275 // ---------------------------------------------------------------------------- |
|
276 // |
|
277 void CVcxMyVideosAsyncFileOperations::InitMoveOrCopyOperationsL( CMPXMedia& aCmd ) |
|
278 { |
|
279 if ( !aCmd.IsSupported( KMPXMediaArrayContents ) ) |
|
280 { |
|
281 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: error, no array defined"); |
|
282 User::Leave( KErrArgument ); |
|
283 } |
|
284 |
|
285 CMPXMediaArray* idMediaArray = aCmd.Value<CMPXMediaArray>( |
|
286 KMPXMediaArrayContents ); |
|
287 |
|
288 if ( idMediaArray->Count() == 0 ) |
|
289 { |
|
290 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: error, no items in array "); |
|
291 User::Leave( KErrArgument ); |
|
292 } |
|
293 |
|
294 TUint32 cmdId = aCmd.ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId ); |
|
295 if ( cmdId == KVcxCommandMyVideosMove ) |
|
296 { |
|
297 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move operation"); |
|
298 iIsMoveOperation = ETrue; |
|
299 } |
|
300 else |
|
301 { |
|
302 iIsMoveOperation = EFalse; |
|
303 } |
|
304 |
|
305 iTargetDrive = aCmd.ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
306 |
|
307 TMPXItemId mpxId; |
|
308 iOperationIdArray.Reset(); |
|
309 TInt count = idMediaArray->Count(); |
|
310 for ( TInt i = 0; i < count; i++ ) |
|
311 { |
|
312 mpxId = idMediaArray->AtL( i )-> |
|
313 ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
314 MPX_DEBUG3("CVcxMyVideosAsyncFileOperations:: MPX ID: (%d, %d) will be moved ", |
|
315 mpxId.iId1, |
|
316 mpxId.iId2); |
|
317 iOperationIdArray.AppendL( idMediaArray->AtL( i )-> |
|
318 ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId ).iId1 ); |
|
319 } |
|
320 |
|
321 iCollection.SendMyVideosMessageL( KVcxMessageMyVideosMoveOrCopyStarted, &aCmd ); |
|
322 |
|
323 iOperationResult.Reset(); |
|
324 } |
|
325 |
310 // ---------------------------------------------------------------------------- |
326 // ---------------------------------------------------------------------------- |
311 // CVcxMyVideosAsyncFileOperations::CancelOperationL |
327 // CVcxMyVideosAsyncFileOperations::CancelOperationL |
312 // Called when leave or cancel occurs for the operation, generates resp msg. |
328 // Called when leave or cancel occurs for the operation, generates resp msg. |
313 // ---------------------------------------------------------------------------- |
329 // ---------------------------------------------------------------------------- |
314 // |
330 // |
315 void CVcxMyVideosAsyncFileOperations::CancelOperationL( TInt aErr ) |
331 void CVcxMyVideosAsyncFileOperations::CancelOperationL( TInt aErr ) |
316 { |
332 { |
317 if ( iCollection.iActiveTask->IsActive() ) |
333 if ( iCollection.iActiveTask->IsActive() ) |
318 { |
334 { |
319 TInt mvCmdId = -1; |
335 TInt mvCmdId = -1; |
320 CMPXMedia& cmd = iCollection.iActiveTask->GetCommand(); |
336 CMPXMedia& cmd = iCollection.iActiveTask->GetCommand(); |
321 TMPXCommandId commandId = *cmd.Value<TMPXCommandId>( KMPXCommandGeneralId ); |
337 TMPXCommandId commandId = *cmd.Value<TMPXCommandId>( KMPXCommandGeneralId ); |
411 |
438 |
412 // ---------------------------------------------------------------------------- |
439 // ---------------------------------------------------------------------------- |
413 // CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL |
440 // CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL |
414 // ---------------------------------------------------------------------------- |
441 // ---------------------------------------------------------------------------- |
415 // |
442 // |
416 void CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL( TUint32 aMdsId, TInt aTargetDrive, |
443 void CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL( TUint32 aMdsId, TInt aTargetDrive ) |
417 TBool aMove ) |
444 { |
418 { |
445 if ( iFileCopier->CopyIsOngoing() ) |
419 MPX_FUNC("CVcxMyVideosAsyncFileOperations::MoveOrCopyVideoL"); |
446 { |
420 |
447 TInt err = iFileCopier->DoNextBlockCopy(); |
421 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: mds id = %d", aMdsId); |
448 if ( err != KErrNone || !iFileCopier->CopyIsOngoing() ) |
422 |
449 { |
|
450 HandleFileCopyCompletedL( err ); |
|
451 } |
|
452 return; |
|
453 } |
|
454 |
|
455 //New file copy starts -> do sanity checks and mds and collection preparations |
|
456 InitSingleMoveOrCopyL( aMdsId, aTargetDrive ); |
|
457 |
|
458 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: copying: %S", &iSourcePath); |
|
459 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: to : %S", &iTargetPath); |
|
460 |
|
461 TBool completed = ETrue; // set to avoid warning |
|
462 TRAPD( err, completed = iFileCopier->CopyL( iSourcePath, iTargetPath ) ); |
|
463 |
|
464 if ( completed || err ) |
|
465 { |
|
466 HandleFileCopyCompletedL( err ); |
|
467 } |
|
468 } |
|
469 |
|
470 // ---------------------------------------------------------------------------- |
|
471 // CVcxMyVideosAsyncFileOperations::InitSingleMoveOrCopyL |
|
472 // ---------------------------------------------------------------------------- |
|
473 // |
|
474 void CVcxMyVideosAsyncFileOperations::InitSingleMoveOrCopyL( TUint32 aMdsId, TInt aTargetDrive ) |
|
475 { |
423 //get media from cache or mds |
476 //get media from cache or mds |
424 TInt pos; |
477 TInt pos; |
425 CMPXMedia* videoInCache = iCollection.iCache->FindVideoByMdsIdL( aMdsId, pos ); |
478 CMPXMedia* videoInCache = iCollection.iCache->FindVideoByMdsIdL( aMdsId, pos ); |
426 |
479 |
427 CMPXMedia* video = NULL; |
480 CMPXMedia* video = NULL; |
448 { |
501 { |
449 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: file is being downloaded, fail, leaving with KErrInUse code."); |
502 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: file is being downloaded, fail, leaving with KErrInUse code."); |
450 User::Leave( KErrInUse ); |
503 User::Leave( KErrInUse ); |
451 } |
504 } |
452 |
505 |
453 const TInt KMaxPathLength = 255; |
506 iSourcePath = video->ValueText( KMPXMediaGeneralUri ); |
454 TBuf<KMaxPathLength> sourcePath( video->ValueText( KMPXMediaGeneralUri ) ); |
|
455 |
507 |
456 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: source path = %S", &sourcePath); |
508 if ( !DriveHasEnoughFreeSpaceL( iSourcePath, aTargetDrive ) ) |
457 |
|
458 if ( !DriveHasEnoughFreeSpaceL( sourcePath, aTargetDrive ) ) |
|
459 { |
509 { |
460 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: target drive full -> skipping"); |
510 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: target drive full -> skipping"); |
461 User::Leave( KErrDiskFull ); |
511 User::Leave( KErrDiskFull ); |
462 } |
512 } |
463 |
513 |
|
514 TUint att = 0; |
|
515 iCollection.iFs.Att( iSourcePath, att); |
|
516 if ( iIsMoveOperation && (att & KEntryAttReadOnly) ) |
|
517 { |
|
518 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move operation and source file is read only -> skipping"); |
|
519 User::Leave( KErrAccessDenied ); |
|
520 } |
|
521 |
464 TInt sourceDrive; |
522 TInt sourceDrive; |
465 User::LeaveIfError( iCollection.iFs.CharToDrive( sourcePath[0], sourceDrive ) ); |
523 User::LeaveIfError( iCollection.iFs.CharToDrive( iSourcePath[0], sourceDrive ) ); |
466 |
524 |
467 if ( sourceDrive == aTargetDrive ) |
525 if ( sourceDrive == aTargetDrive ) |
468 { |
526 { |
469 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: source and target drives are the same, doing nothing."); |
527 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: source and target drives are the same, leaving with KErrAlreadyExists."); |
470 CleanupStack::PopAndDestroy( video ); // <-1 |
528 CleanupStack::PopAndDestroy( video ); // <-1 |
471 return; |
529 User::Leave( KErrAlreadyExists ); |
472 } |
530 } |
473 |
531 |
474 TBuf<KMaxPathLength> targetPath; |
532 GenerateTargetPathForMoveOrCopyL( iSourcePath, iTargetPath, aTargetDrive ); |
475 |
533 |
476 GenerateTargetPathForMoveOrCopyL( sourcePath, targetPath, aTargetDrive ); |
534 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: target path = %S", &iTargetPath ); |
477 |
|
478 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: target path = %S", &targetPath ); |
|
479 |
535 |
480 // update mds and cache |
536 // update mds and cache |
481 CMPXMedia* mediaForMoveOp = NULL; |
537 delete iMediaForMoveOp; |
482 CMPXMedia* mediaForCopyOp = NULL; |
538 iMediaForMoveOp = NULL; |
483 if ( aMove ) |
539 delete iMediaForCopyOp; |
|
540 iMediaForCopyOp = NULL; |
|
541 |
|
542 if ( iIsMoveOperation ) |
484 { |
543 { |
485 // Update existing media. |
544 // Update existing media. |
486 // Create new media object with only KMPXMediaGeneralId, and KMPXMediaGeneralUri |
545 // Create new media object with only KMPXMediaGeneralId, and KMPXMediaGeneralUri |
487 // attributes set, that way update is lighter operation. |
546 // attributes set, that way update is lighter operation. |
488 mediaForMoveOp = CMPXMedia::NewL(); |
547 iMediaForMoveOp = CMPXMedia::NewL(); |
489 CleanupStack::PushL( mediaForMoveOp ); // 2-> |
548 iMediaForMoveOp->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, |
490 mediaForMoveOp->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, |
|
491 video->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
549 video->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
492 mediaForMoveOp->SetTextValueL( KMPXMediaGeneralUri, targetPath ); |
550 iMediaForMoveOp->SetTextValueL( KMPXMediaGeneralUri, iTargetPath ); |
493 |
551 |
494 iCollection.SetVideoL( *mediaForMoveOp ); |
552 iCollection.SetVideoL( *iMediaForMoveOp ); |
495 } |
553 } |
496 else |
554 else |
497 { |
555 { |
498 // Create new media. |
556 // Create new media. |
499 mediaForCopyOp = CMPXMedia::CopyL( *video ); |
557 iMediaForCopyOp = CMPXMedia::CopyL( *video ); |
500 CleanupStack::PushL( mediaForCopyOp ); // 2-> |
558 iMediaForCopyOp->SetTextValueL( KMPXMediaGeneralUri, iTargetPath ); |
501 mediaForCopyOp->SetTextValueL( KMPXMediaGeneralUri, targetPath ); |
559 iCollection.AddVideoToMdsAndCacheL( *iMediaForCopyOp ); |
502 iCollection.AddVideoToMdsAndCacheL( *mediaForCopyOp ); |
560 } |
503 } |
561 |
504 |
562 CleanupStack::PopAndDestroy( video ); // <-1 |
505 //copy file, delete original if move case |
563 } |
506 TRAPD( err, BaflUtils::EnsurePathExistsL( iCollection.iFs, targetPath ) ); |
564 |
507 |
565 |
508 TUint att = 0; |
566 // ---------------------------------------------------------------------------- |
509 iCollection.iFs.Att( sourcePath, att); |
567 // CVcxMyVideosAsyncFileOperations::HandleFileCopyCompletedL |
510 if ( aMove && (att & KEntryAttReadOnly) ) |
568 // ---------------------------------------------------------------------------- |
511 { |
569 // |
512 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move operation and source file is read only -> skipping"); |
570 void CVcxMyVideosAsyncFileOperations::HandleFileCopyCompletedL( TInt aErr ) |
513 err = KErrAccessDenied; |
571 { |
514 } |
572 if ( aErr == KErrNone ) |
515 |
573 { |
516 if ( err == KErrNone ) |
574 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: Copy succeeded"); |
517 { |
575 if ( iIsMoveOperation ) |
518 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: copying: %S", &sourcePath); |
576 { |
519 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: to : %S", &targetPath); |
577 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move case"); |
520 err = BaflUtils::CopyFile( iCollection.iFs, sourcePath, targetPath ); |
578 aErr = BaflUtils::DeleteFile( iCollection.iFs, iSourcePath ); |
521 if ( err == KErrNone ) |
579 if ( aErr != KErrNone ) |
522 { |
|
523 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: Copy succeeded"); |
|
524 if ( aMove ) |
|
525 { |
580 { |
526 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: move case"); |
581 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: delete for source file failed: %d", aErr ); |
527 err = BaflUtils::DeleteFile( iCollection.iFs, sourcePath ); |
582 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: deleting target file"); |
528 if ( err != KErrNone ) |
583 TInt delErr = BaflUtils::DeleteFile( iCollection.iFs, iTargetPath ); |
|
584 if ( delErr != KErrNone ) |
529 { |
585 { |
530 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: delete for source file failed: %d", err ); |
586 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: delete for target file failed: %d", delErr ); |
531 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: deleting target file"); |
|
532 TInt delErr = BaflUtils::DeleteFile( iCollection.iFs, targetPath ); |
|
533 if ( delErr != KErrNone ) |
|
534 { |
|
535 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: delete for target file failed: %d", delErr ); |
|
536 } |
|
537 } |
587 } |
538 } |
588 } |
539 } |
589 } |
|
590 } |
|
591 else |
|
592 { |
|
593 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: CopyFile failed: %d", aErr); |
|
594 } |
|
595 |
|
596 // roll mds and cache back if file operations failed |
|
597 if ( aErr != KErrNone ) |
|
598 { |
|
599 if ( iIsMoveOperation ) |
|
600 { |
|
601 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: move failed %d", aErr ); |
|
602 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: setting media path back and leaving." ); |
|
603 iMediaForMoveOp->SetTextValueL( KMPXMediaGeneralUri, iSourcePath ); |
|
604 iCollection.SetVideoL( *iMediaForMoveOp ); |
|
605 } |
540 else |
606 else |
541 { |
607 { |
542 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: CopyFile failed: %d", err); |
608 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: copy failed %d", aErr ); |
543 } |
|
544 } |
|
545 |
|
546 // roll mds and cache back if file operations failed |
|
547 if ( err != KErrNone ) |
|
548 { |
|
549 if ( aMove ) |
|
550 { |
|
551 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: move failed %d", err ); |
|
552 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: setting media path back and leaving." ); |
|
553 mediaForMoveOp->SetTextValueL( KMPXMediaGeneralUri, sourcePath ); |
|
554 iCollection.SetVideoL( *mediaForMoveOp ); |
|
555 } |
|
556 else |
|
557 { |
|
558 MPX_DEBUG2("CVcxMyVideosAsyncFileOperations:: copy failed %d", err ); |
|
559 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: deleting the added media object and leaving"); |
609 MPX_DEBUG1("CVcxMyVideosAsyncFileOperations:: deleting the added media object and leaving"); |
560 iCollection.iMyVideosMdsDb->RemoveVideo( mediaForCopyOp->ValueTObjectL<TMPXItemId>( |
610 iCollection.iMyVideosMdsDb->RemoveVideo( iMediaForCopyOp->ValueTObjectL<TMPXItemId>( |
561 KMPXMediaGeneralId ).iId1 ); |
611 KMPXMediaGeneralId ).iId1 ); |
562 } |
612 } |
563 User::Leave( err ); |
613 } |
564 } |
614 |
565 |
615 delete iMediaForMoveOp; |
566 if ( aMove ) |
616 iMediaForMoveOp = NULL; |
567 { |
617 delete iMediaForCopyOp; |
568 CleanupStack::PopAndDestroy( mediaForMoveOp ); // <-2 |
618 iMediaForCopyOp = NULL; |
569 } |
619 |
570 else |
620 User::LeaveIfError( aErr ); |
571 { |
621 |
572 CleanupStack::PopAndDestroy( mediaForCopyOp ); // <-2 |
622 } |
573 } |
623 |
574 CleanupStack::PopAndDestroy( video ); // <-1 |
|
575 } |
|
576 |
|
577 // ---------------------------------------------------------------------------- |
624 // ---------------------------------------------------------------------------- |
578 // CVcxMyVideosAsyncFileOperations::DriveHasEnoughFreeSpaceL |
625 // CVcxMyVideosAsyncFileOperations::DriveHasEnoughFreeSpaceL |
579 // ---------------------------------------------------------------------------- |
626 // ---------------------------------------------------------------------------- |
580 // |
627 // |
581 TBool CVcxMyVideosAsyncFileOperations::DriveHasEnoughFreeSpaceL( const TDesC& aPath, TInt aDrive ) |
628 TBool CVcxMyVideosAsyncFileOperations::DriveHasEnoughFreeSpaceL( const TDesC& aPath, TInt aDrive ) |