305 |
313 |
306 for( TInt e(0); e<aMarkedItems.Count();e++) |
314 for( TInt e(0); e<aMarkedItems.Count();e++) |
307 { |
315 { |
308 __LOG2("CUpnpContentServerHandler: received index[%d] = %d", |
316 __LOG2("CUpnpContentServerHandler: received index[%d] = %d", |
309 e, aMarkedItems[e] ); |
317 e, aMarkedItems[e] ); |
310 } |
318 } |
311 |
319 |
312 switch ( iHandlerState ) |
320 if ( iOngoingSharingType != KErrNotFound ) |
313 { |
321 { |
314 case ESchedulingSharing : |
322 // sharing process ongoing, check that if selection is changed |
315 { |
323 // to ongoing sharing type |
316 if ( aType == iBufferPosition ) |
324 if ( aType == iOngoingSharingType && iAo->SharingOngoing() ) |
317 { |
325 { |
318 if ( iSharingPhase != EShare ) |
326 // save pending request info |
319 { |
327 SavePendingRequestInfoL( aMarkedItems, aType ); |
320 SetSharingRequestL( aMarkedItems, aType ); |
328 // cancel Ao and create new sharing request in callback |
321 } |
329 iAo->StopSharing(); |
322 else // iSharingPhase == EShare |
330 } |
323 { |
331 else |
324 // sanity checks |
332 { |
325 delete iUnsharer; |
333 SetSharingRequestL( aMarkedItems, aType ); |
326 iUnsharer = NULL; |
334 } |
327 delete iContainerChecker; |
335 } |
328 iContainerChecker = NULL; |
336 else |
329 |
337 { |
330 if ( iAo ) |
338 // Not active, ie. no sharing ongoing |
|
339 SetSharingRequestL( aMarkedItems, aType ); |
|
340 iOngoingSharingType = aType; |
|
341 |
|
342 // start the sharing |
|
343 DoShare(); |
|
344 } |
|
345 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
346 } |
|
347 |
|
348 // -------------------------------------------------------------------------- |
|
349 // CUpnpContentServerHandler::RefreshShareContentL |
|
350 // ( other items are commented in header ) |
|
351 // -------------------------------------------------------------------------- |
|
352 // |
|
353 void CUpnpContentServerHandler::RefreshShareContentL( |
|
354 TInt aType ) |
|
355 { |
|
356 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
357 |
|
358 if ( ( aType == EImageAndVideo && iVisualSharingReq ) || |
|
359 ( aType == EPlaylist && iMusicSharingReq ) ) |
|
360 { |
|
361 // no refresh available if sharing is ongoing |
|
362 __LOG1( "Error: %d", __LINE__ ); |
|
363 User::Leave( KErrServerBusy ); |
|
364 } |
|
365 |
|
366 delete iReader; |
|
367 iReader = NULL; |
|
368 iReader = CUpnpSelectionReader::NewL(); |
|
369 |
|
370 if ( aType == EImageAndVideo ) |
|
371 { |
|
372 RArray<TInt> markedItems; |
|
373 CleanupClosePushL( markedItems ); |
|
374 |
|
375 // Get selected indexes and create new sharing request |
|
376 GetSelectionIndexesL( markedItems, aType ); |
|
377 SetSharingRequestL( markedItems, aType ); |
|
378 |
|
379 CleanupStack::PopAndDestroy( &markedItems ); |
|
380 } |
|
381 else if ( aType == EPlaylist ) |
|
382 { |
|
383 RArray<TInt> markedItems; |
|
384 CleanupClosePushL( markedItems ); |
|
385 |
|
386 // Get selected indexes and create new sharing request |
|
387 GetSelectionIndexesL( markedItems, aType ); |
|
388 SetSharingRequestL( markedItems, aType ); |
|
389 |
|
390 CleanupStack::PopAndDestroy( &markedItems ); |
|
391 } |
|
392 else |
|
393 { |
|
394 User::Leave( KErrArgument ); |
|
395 } |
|
396 |
|
397 // if no refreshes ongoing, start sharing |
|
398 if ( iOngoingSharingType == KErrNotFound ) |
|
399 { |
|
400 iOngoingSharingType = aType; |
|
401 DoShare(); |
|
402 } |
|
403 |
|
404 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
405 } |
|
406 |
|
407 // -------------------------------------------------------------------------- |
|
408 // CUpnpContentServerHandler::CanStop |
|
409 // ( other items are commented in header ) |
|
410 // -------------------------------------------------------------------------- |
|
411 // |
|
412 TBool CUpnpContentServerHandler::CanStop() const |
|
413 { |
|
414 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
415 TBool ret( EFalse ); |
|
416 if ( !( iVisualSharingReq || iMusicSharingReq ) ) |
|
417 { |
|
418 __LOG("CUpnpContentServerHandler: CanStop(): 1"); |
|
419 ret = ETrue; |
|
420 } |
|
421 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
422 return ret; |
|
423 } |
|
424 |
|
425 // -------------------------------------------------------------------------- |
|
426 // CUpnpContentServerHandler::CompleteSharingOperationL |
|
427 // This should be called from active objects owned by handler |
|
428 // -------------------------------------------------------------------------- |
|
429 // |
|
430 void CUpnpContentServerHandler::CompleteSharingOperationL( |
|
431 const TInt& aErr, const TInt& aType ) |
|
432 { |
|
433 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
434 |
|
435 switch ( aErr ) |
|
436 { |
|
437 case KErrNone: |
|
438 { |
|
439 iErrorToClient = KErrNone; |
|
440 if ( aType == EImageAndVideo ) |
|
441 { |
|
442 // Reset sharing request object |
|
443 delete iVisualSharingReq; |
|
444 iVisualSharingReq = NULL; |
|
445 |
|
446 // If there is pending music request, process it next |
|
447 if ( iMusicSharingReq ) |
331 { |
448 { |
332 // iAo cannot be deleted here, request stop instead |
449 iOngoingSharingType = EPlaylist; |
333 iAo->RequestStop( |
450 DoShare(); |
334 MUpnpSharingCallback::ESharingFullStop ); |
|
335 } |
|
336 // Get playlist Ids |
|
337 CDesCArray* ids = new (ELeave) CDesCArrayFlat(4); |
|
338 CleanupStack::PushL( ids ); |
|
339 CDesCArray* names = new (ELeave) CDesCArrayFlat(4); |
|
340 CleanupStack::PushL( names ); |
|
341 if ( aType == EImageAndVideo ) |
|
342 { |
|
343 iReader->CollectionIdsL( *ids, *names ); |
|
344 } |
451 } |
345 else |
452 else |
346 { |
453 { |
347 iReader->PlayListIdsL( *ids, *names ); |
454 iOngoingSharingType = KErrNotFound; |
348 } |
455 } |
349 // pendingSharingReq will be handled from callback |
456 } |
350 delete iPendingSharingReq; |
457 else if ( aType == EPlaylist ) |
351 iPendingSharingReq = NULL; |
458 { |
352 iPendingSharingReq = CUpnpSharingRequest::NewL( aType, |
459 // Reset sharing request object |
353 aMarkedItems, |
|
354 ids, |
|
355 names ); |
|
356 CleanupStack::Pop( names ); // ownership transferred |
|
357 CleanupStack::Pop( ids ); // ownership transferred |
|
358 } |
|
359 } |
|
360 else |
|
361 { |
|
362 SetSharingRequestL( aMarkedItems, aType ); |
|
363 } |
|
364 } |
|
365 break; |
|
366 case ENotActive : |
|
367 { |
|
368 |
|
369 delete iMetadata; |
|
370 iMetadata = NULL; |
|
371 iMetadata = CUpnpContentMetadataUtility::NewL(); |
|
372 iMetadata->SetCallback( this ); |
|
373 iReader->SetMetadata( iMetadata ); |
|
374 |
|
375 |
|
376 if ( iMetadata->RefreshOngoing() ) |
|
377 { |
|
378 __LOG("CUpnpContentServerHandler: Waiting refresh 3"); |
|
379 iWait.Start(); |
|
380 } |
|
381 SetSharingRequestL( aMarkedItems, aType ); |
|
382 |
|
383 iBufferPosition = aType; |
|
384 // Start sharing |
|
385 iHandlerState = ESchedulingSharing; |
|
386 |
|
387 iSharingPhase = ECheckDefaults; |
|
388 // start the sharing |
|
389 DoShareL(); |
|
390 |
|
391 } |
|
392 break; |
|
393 default : |
|
394 { |
|
395 __LOG1( "Error: %d", __LINE__ ); |
|
396 } |
|
397 break; |
|
398 |
|
399 } |
|
400 SetProgressL( KNoProgress ); |
|
401 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
402 } |
|
403 |
|
404 // -------------------------------------------------------------------------- |
|
405 // CUpnpContentServerHandler::RefreshShareContentL |
|
406 // ( other items are commented in header ) |
|
407 // -------------------------------------------------------------------------- |
|
408 // |
|
409 void CUpnpContentServerHandler::RefreshShareContentL( |
|
410 TInt aType ) |
|
411 { |
|
412 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
413 |
|
414 if ( ( aType == EImageAndVideo && iVisualSharingReq ) || |
|
415 ( aType == EPlaylist && iMusicSharingReq ) ) |
|
416 { |
|
417 // no refresh available if sharing is ongoing |
|
418 __LOG1( "Error: %d", __LINE__ ); |
|
419 User::Leave( KErrServerBusy ); |
|
420 } |
|
421 |
|
422 if ( iMetadata->RefreshOngoing() ) |
|
423 { |
|
424 __LOG("CUpnpContentServerHandler: Waiting refresh 1"); |
|
425 iWait.Start(); |
|
426 } |
|
427 |
|
428 delete iReader; |
|
429 iReader = NULL; |
|
430 iReader = CUpnpSelectionReader::NewL( iMetadata ); |
|
431 |
|
432 RArray<TInt> selectedItems; |
|
433 CleanupClosePushL( selectedItems ); |
|
434 CDesCArray* containers = new ( ELeave ) CDesCArrayFlat( 10 ); |
|
435 CleanupStack::PushL( containers ); |
|
436 iReader->FetchCollectionsL( containers ); |
|
437 GetSelectionIndexesL( selectedItems, aType ); |
|
438 CDesCArray* ids = new (ELeave) CDesCArrayFlat(4); |
|
439 CleanupStack::PushL( ids ); |
|
440 CDesCArray* names = new (ELeave) CDesCArrayFlat(4); |
|
441 CleanupStack::PushL( names ); |
|
442 iReader->CollectionIdsL( *ids, *names ); |
|
443 |
|
444 if ( aType == EImageAndVideo ) |
|
445 { |
|
446 iVisualSharingReq = CUpnpSharingRequest::NewL( aType, |
|
447 selectedItems, |
|
448 ids, |
|
449 names ); |
|
450 } |
|
451 else if ( aType == EPlaylist ) |
|
452 { |
|
453 iMusicSharingReq = CUpnpSharingRequest::NewL( aType, |
|
454 selectedItems, |
|
455 ids, |
|
456 names ); |
|
457 } |
|
458 else |
|
459 { |
|
460 User::Leave( KErrArgument ); |
|
461 } |
|
462 |
|
463 CleanupStack::Pop( names ); // ownership transferred |
|
464 CleanupStack::Pop( ids ); // ownership transferred |
|
465 ChangeShareContentL( selectedItems, aType ); |
|
466 |
|
467 selectedItems.Reset(); |
|
468 containers->Reset(); |
|
469 |
|
470 CleanupStack::PopAndDestroy( containers ); |
|
471 CleanupStack::PopAndDestroy( &selectedItems ); |
|
472 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
473 } |
|
474 |
|
475 // -------------------------------------------------------------------------- |
|
476 // CUpnpContentServerHandler::FillProgressInfoL |
|
477 // ( other items are commented in header ) |
|
478 // -------------------------------------------------------------------------- |
|
479 // |
|
480 void CUpnpContentServerHandler::FillProgressInfoL( |
|
481 RArray<TUpnpProgressInfo>& aArr, |
|
482 const TInt aType ) |
|
483 { |
|
484 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
485 CUpnpSharingRequest* sharingReq( NULL ); |
|
486 if( iPendingSharingReq && iPendingSharingReq->iKind == aType ) |
|
487 { |
|
488 sharingReq = iPendingSharingReq; |
|
489 } |
|
490 else |
|
491 { |
|
492 if ( aType == EImageAndVideo ) |
|
493 { |
|
494 sharingReq = iVisualSharingReq; |
|
495 } |
|
496 else if ( aType == EPlaylist ) |
|
497 { |
|
498 sharingReq = iMusicSharingReq; |
|
499 } |
|
500 } |
|
501 TUpnpProgressInfo progress; |
|
502 progress.iProgressKind = UpnpContentServer::TUpnpMediaType( aType ); |
|
503 if ( sharingReq ) |
|
504 { |
|
505 progress.iProgressType = TUpnpProgressInfo::ESharingProgress; |
|
506 if ( iBufferPosition == aType && |
|
507 iHandlerState == ESchedulingSharing && |
|
508 ( iAo || iUnsharer || iContainerChecker )) |
|
509 { |
|
510 // sharing ongoing for images |
|
511 TInt prog ( 0 ); |
|
512 TInt progRel( 0 ); |
|
513 if ( iAo && iSharingPhase == EShare ) |
|
514 { |
|
515 prog = iAo->SharingProgress( |
|
516 (TUpnpMediaType&)progress.iProgressKind ); |
|
517 progRel = ( prog * KMaxProgress ) / sharingReq->iItemCount; |
|
518 } |
|
519 if ( iUnsharer && iSharingPhase == EUnshare ) |
|
520 { |
|
521 prog = iUnsharer->UnSharingProgress(); |
|
522 TInt itemNum = iUnsharer->TotalItemsForUnShare(); |
|
523 if( itemNum > 0 ) |
|
524 { |
|
525 progRel = ( prog * KMaxProgress ) / itemNum; |
|
526 } |
|
527 } |
|
528 |
|
529 // check that progress is between 0 and 100 % |
|
530 if ( progRel < 0 ) |
|
531 { |
|
532 progRel = KNoProgress; |
|
533 __LOG1( "Error: %d", __LINE__ ); |
|
534 } |
|
535 else if ( progRel > KMaxProgress ) |
|
536 { |
|
537 progRel = KMaxProgress; |
|
538 __LOG1( "Error: %d", __LINE__ ); |
|
539 } |
|
540 progress.iProgress = progRel; |
|
541 } |
|
542 else |
|
543 { |
|
544 // buffer is pending |
|
545 progress.iProgressType = TUpnpProgressInfo::ESharingProgress; |
|
546 progress.iProgress = KNoProgress; |
|
547 } |
|
548 } |
|
549 else |
|
550 { |
|
551 progress.iProgressType = TUpnpProgressInfo::EVisualStatus; |
|
552 TInt state( EShareNone ); |
|
553 |
|
554 if ( aType == EImageAndVideo ) |
|
555 { |
|
556 iReader->GetVisualSharingStateL( state ); |
|
557 } |
|
558 else |
|
559 { |
|
560 iReader->GetMusicSharingStateL( state ); |
|
561 } |
|
562 |
|
563 progress.iProgress = state; |
|
564 } |
|
565 aArr.AppendL( progress ); |
|
566 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
567 } |
|
568 |
|
569 |
|
570 |
|
571 // -------------------------------------------------------------------------- |
|
572 // CUpnpContentServerHandler::CanStop |
|
573 // ( other items are commented in header ) |
|
574 // -------------------------------------------------------------------------- |
|
575 // |
|
576 TBool CUpnpContentServerHandler::CanStop() const |
|
577 { |
|
578 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
579 TBool ret( EFalse ); |
|
580 if ( !( iVisualSharingReq || iMusicSharingReq ) ) |
|
581 { |
|
582 __LOG("CUpnpContentServerHandler: CanStop(): 1"); |
|
583 ret = ETrue; |
|
584 } |
|
585 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
586 return ret; |
|
587 } |
|
588 |
|
589 // -------------------------------------------------------------------------- |
|
590 // CUpnpContentServerHandler::RefreshDoneL |
|
591 // ( other items are commented in header ) |
|
592 // -------------------------------------------------------------------------- |
|
593 // |
|
594 void CUpnpContentServerHandler::RefreshDoneL() |
|
595 { |
|
596 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
597 |
|
598 iMetadata->SetCallback( this ); |
|
599 if ( iWait.IsStarted() ) |
|
600 { |
|
601 iWait.AsyncStop(); |
|
602 } |
|
603 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
604 } |
|
605 |
|
606 // -------------------------------------------------------------------------- |
|
607 // CUpnpContentServerHandler::CompleteSharingOperationL |
|
608 // This should be called from active objects owned by handler |
|
609 // -------------------------------------------------------------------------- |
|
610 // |
|
611 void CUpnpContentServerHandler::CompleteSharingOperationL( |
|
612 const TInt& aErr, const TInt& aType ) |
|
613 { |
|
614 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
615 if ( aErr != KErrNone ) |
|
616 { |
|
617 __LOG1( "Error: %d", aErr ); |
|
618 } |
|
619 if ( iWait.IsStarted() ) |
|
620 { |
|
621 iWait.AsyncStop(); |
|
622 } |
|
623 else if ( iStartupCleaning ) |
|
624 { |
|
625 iStartupCleaning = EFalse; |
|
626 } |
|
627 |
|
628 else if ( aErr && aErr != KErrCancel ) |
|
629 { |
|
630 // Cancel is handled below |
|
631 HandleError( aErr ); |
|
632 } |
|
633 else |
|
634 { |
|
635 if ( iSharingPhase == ECheckDefaults ) |
|
636 { |
|
637 iHandlerState = ESchedulingSharing; |
|
638 iSharingPhase = EUnshare; |
|
639 } |
|
640 else if ( iSharingPhase == EUnshare ) |
|
641 { |
|
642 iHandlerState = ESchedulingSharing; |
|
643 iSharingPhase = EShare; |
|
644 |
|
645 } |
|
646 else if ( iSharingPhase == EShare ) |
|
647 { |
|
648 switch ( aType ) |
|
649 { |
|
650 case EImageAndVideo : |
|
651 { |
|
652 delete iVisualSharingReq; |
|
653 iVisualSharingReq = NULL; |
|
654 SetProgressL( KNoProgress ); |
|
655 } |
|
656 break; |
|
657 case EPlaylist : |
|
658 { |
|
659 delete iMusicSharingReq; |
460 delete iMusicSharingReq; |
660 iMusicSharingReq = NULL; |
461 iMusicSharingReq = NULL; |
661 SetProgressL( KNoProgress ); |
462 |
662 } |
463 // If there is pending music request, process it next |
663 break; |
464 if ( iVisualSharingReq ) |
664 default : |
465 { |
665 { |
466 iOngoingSharingType = EImageAndVideo; |
666 __LOG1( "Error: %d", __LINE__ ); |
467 DoShare(); |
667 } |
468 } |
668 break; |
469 else |
669 } |
470 { |
670 if ( aType != iBufferPosition ) |
471 iOngoingSharingType = KErrNotFound; |
671 { |
472 } |
672 __LOG1( "Error: %d", __LINE__ ); |
473 } |
673 } |
474 else |
674 |
475 { |
675 if ( aErr == KErrNone ) |
476 iOngoingSharingType = KErrNotFound; |
676 { |
477 } |
677 iErrorToClient = aErr; |
478 break; |
678 iBufferPosition = (iBufferPosition + 1)%KRequestBufferSize; |
479 } |
679 SetProgressL( KNoProgress ); |
480 case KErrCancel: |
|
481 { |
|
482 // User reselected currently ongoing sharing, handle it next |
|
483 if ( iPendingSharingReqInfo.iMarkedItems.Count() ) |
|
484 { |
|
485 // create sharing request from pending info |
|
486 TRAPD( |
|
487 err, |
|
488 SetSharingRequestL( |
|
489 iPendingSharingReqInfo.iMarkedItems, |
|
490 iPendingSharingReqInfo.iMediaType ) |
|
491 ); |
|
492 if ( err ) |
|
493 { |
|
494 HandleError( err ); |
|
495 } |
|
496 else |
|
497 { |
|
498 // no errors, reset the pending request info and start |
|
499 // sharing |
|
500 ResetPendingRequestInfo(); |
|
501 DoShare(); |
|
502 } |
680 } |
503 } |
681 else |
504 else |
682 { |
505 { |
683 if ( iPendingSharingReq ) |
506 iOngoingSharingType = KErrNotFound; |
684 { |
507 } |
685 if ( iPendingSharingReq->iKind == EImageAndVideo ) |
508 break; |
686 { |
509 } |
687 delete iVisualSharingReq; |
510 default: |
688 iVisualSharingReq = NULL; |
511 { |
689 iVisualSharingReq = iPendingSharingReq; |
512 __LOG1( "CompleteSharingOperationL: %d", aErr ); |
690 } |
513 HandleError( aErr ); |
691 else |
514 break; |
692 { |
515 } |
693 delete iMusicSharingReq; |
516 } |
694 iMusicSharingReq = NULL; |
517 |
695 iMusicSharingReq = iPendingSharingReq; |
518 if ( iOngoingSharingType == KErrNotFound ) |
696 } |
519 { |
697 iPendingSharingReq = NULL; |
520 // Reset the progress info to no progress. |
698 } |
521 TRAP_IGNORE( |
699 } |
522 SetProgressL( KNoProgress ) |
700 |
523 ); |
701 iDefaultContainerIds.Reset(); |
524 if ( CanStop() && iServer && !iContentSharingObserver ) |
702 if ( ! ( iVisualSharingReq || iMusicSharingReq )) |
525 { |
703 { |
526 // client application is exited, no sharing ongoing |
704 iHandlerState = ENotActive; |
527 // -> stop the server |
705 iSharingPhase = ESharingInActive; |
528 iServer->Stop(); |
706 if ( CanStop() && iServer && !iContentSharingObserver ) |
529 } |
707 { |
530 } |
708 // client application is exited, no sharing ongoing |
531 |
709 // -> stop the server |
|
710 iServer->Stop(); |
|
711 } |
|
712 } |
|
713 else |
|
714 { |
|
715 iSharingPhase = ECheckDefaults; |
|
716 iHandlerState = ESchedulingSharing; |
|
717 } |
|
718 } |
|
719 else |
|
720 { |
|
721 __LOG1( "Error: %d", __LINE__ ); |
|
722 } |
|
723 |
|
724 if ( iHandlerState != ENotActive ) |
|
725 { |
|
726 DoShareL(); |
|
727 } |
|
728 |
|
729 } |
|
730 |
|
731 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
532 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
732 } |
533 } |
733 |
534 |
734 // -------------------------------------------------------------------------- |
535 // -------------------------------------------------------------------------- |
735 // CUpnpContentServerHandler::CancelSharingOperationL |
536 // CUpnpContentServerHandler::CancelSharingOperationL |
739 void CUpnpContentServerHandler::CancelSharingOperationL( |
540 void CUpnpContentServerHandler::CancelSharingOperationL( |
740 const TInt& /*aErr*/ ) |
541 const TInt& /*aErr*/ ) |
741 { |
542 { |
742 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
543 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
743 |
544 |
744 |
|
745 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
545 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
746 } |
546 } |
747 |
547 |
748 // -------------------------------------------------------------------------- |
548 // -------------------------------------------------------------------------- |
749 // CUpnpContentServerHandler::SetProgressL |
549 // CUpnpContentServerHandler::SetProgressL |
750 // This should be called from active objects owned by handler |
550 // This should be called from active objects owned by handler |
751 // -------------------------------------------------------------------------- |
551 // -------------------------------------------------------------------------- |
752 // |
552 // |
753 void CUpnpContentServerHandler::SetProgressL( |
553 void CUpnpContentServerHandler::SetProgressL( const TInt& aProgress ) |
754 const TInt& aProgress ) |
554 { |
755 { |
555 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
756 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
556 |
757 CUpnpSharingRequest* sharingReq( NULL ); |
557 // Initilialize music sharing progress information |
758 if( iPendingSharingReq && iPendingSharingReq->iKind == iBufferPosition ) |
558 TUpnpProgressInfo playlistProg; |
759 { |
559 playlistProg.iProgress = KZeroProgress; |
760 sharingReq = iPendingSharingReq; |
560 playlistProg.iProgressKind = EPlaylist; |
|
561 playlistProg.iProgressType = TUpnpProgressInfo::EVisualStatus; |
|
562 |
|
563 // Set music sharing progress information |
|
564 if ( iMusicSharingReq && aProgress != KNoProgress ) |
|
565 { |
|
566 playlistProg.iProgressType = TUpnpProgressInfo::ESharingProgress; |
|
567 if ( iOngoingSharingType == EPlaylist ) |
|
568 { |
|
569 playlistProg.iProgress = aProgress; |
|
570 } |
761 } |
571 } |
762 else |
572 else |
763 { |
573 { |
764 if ( iBufferPosition == EPlaylist ) |
574 TInt state( EShareNone ); |
765 { |
575 iReader->GetMusicSharingStateL( state ); |
766 sharingReq = iMusicSharingReq; |
576 playlistProg.iProgress = state; |
767 } |
577 } |
768 else if ( iBufferPosition == EImageAndVideo ) |
578 |
769 { |
579 // Initilialize visual sharing progress information |
770 sharingReq = iVisualSharingReq; |
580 TUpnpProgressInfo visualProg; |
771 } |
581 visualProg.iProgress = KZeroProgress; |
772 } |
582 visualProg.iProgressKind = EImageAndVideo; |
773 |
583 visualProg.iProgressType = TUpnpProgressInfo::EVisualStatus; |
774 if ( sharingReq ) |
584 |
775 { |
585 // Set visual sharing progress information |
776 sharingReq->iProgress = aProgress; |
586 if ( iVisualSharingReq && aProgress != KNoProgress ) |
777 } |
587 { |
778 |
588 visualProg.iProgressType = TUpnpProgressInfo::ESharingProgress; |
779 TProgressInfos progressArr; |
589 if ( iOngoingSharingType == EImageAndVideo) |
780 CleanupClosePushL( progressArr ); |
590 { |
781 |
591 visualProg.iProgress = aProgress; |
782 FillProgressInfoL( progressArr, EImageAndVideo ); |
592 } |
783 FillProgressInfoL( progressArr, EPlaylist ); |
593 } |
784 |
594 else |
785 TUpnpProgress finalProg; |
595 { |
786 finalProg.iError = iErrorToClient; |
596 TInt state( EShareNone ); |
|
597 iReader->GetVisualSharingStateL( state ); |
|
598 visualProg.iProgress = state; |
|
599 } |
|
600 |
|
601 // Create total progress |
|
602 TUpnpProgress totalProg; |
|
603 totalProg.iError = iErrorToClient; |
787 iErrorToClient = KErrNone; |
604 iErrorToClient = KErrNone; |
788 finalProg.iImageVideoProgress = progressArr[ 0 ]; |
605 |
789 finalProg.iMusicProgress = progressArr[ 1 ]; |
606 totalProg.iImageVideoProgress = visualProg; |
790 |
607 totalProg.iMusicProgress = playlistProg; |
791 TPckgBuf<TUpnpProgress> progressBuf( finalProg ); |
608 |
792 |
609 // Set the progress property so that Ui updates itself |
|
610 TPckgBuf<TUpnpProgress> progressBuf( totalProg ); |
793 TInt err = iProgressProperty.Set( KUpnpContentServerCat, |
611 TInt err = iProgressProperty.Set( KUpnpContentServerCat, |
794 ESharingProgress, |
612 ESharingProgress, |
795 progressBuf ); |
613 progressBuf ); |
796 if ( err != KErrNone ) |
614 if ( err != KErrNone ) |
797 { |
615 { |
798 __LOG1( "Error: %d", err ); |
616 __LOG1( "Error: %d", err ); |
799 } |
617 } |
800 CleanupStack::PopAndDestroy( &progressArr ); |
618 |
801 |
619 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
802 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
620 } |
803 } |
621 |
804 |
622 // -------------------------------------------------------------------------- |
805 // -------------------------------------------------------------------------- |
623 // CUpnpContentServerHandler::DoShare |
806 // CUpnpContentServerHandler::DoShareL |
624 // ( other items are commented in header ) |
807 // ( other items are commented in header ) |
625 // -------------------------------------------------------------------------- |
808 // -------------------------------------------------------------------------- |
626 // |
809 // |
627 void CUpnpContentServerHandler::DoShare() |
810 void CUpnpContentServerHandler::DoShareL( ) |
628 { |
811 { |
629 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
812 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
630 |
813 TInt err( KErrNone ); |
631 switch( iOngoingSharingType ) |
814 |
632 { |
815 iHandlerState = ESchedulingSharing; |
|
816 |
|
817 if ( iSharingPhase == ECheckDefaults ) |
|
818 { |
|
819 iDefaultContainerIds.Reset(); |
|
820 delete iContainerChecker; |
|
821 iContainerChecker = NULL; |
|
822 iContainerChecker = new (ELeave) CUpnpContainerCheckerAo( this ); |
|
823 iContainerChecker->ValidateContainerStructureL( |
|
824 &iDefaultContainerIds ); |
|
825 } |
|
826 else if ( iSharingPhase == EUnshare ) |
|
827 { |
|
828 delete iContainerChecker; |
|
829 iContainerChecker = NULL; |
|
830 delete iUnsharer; |
|
831 iUnsharer = NULL; |
|
832 iUnsharer = new ( ELeave ) CUpnpUnsharerAo( |
|
833 this, |
|
834 CActive::EPriorityStandard ); |
|
835 TInt id = GetContainerId( iBufferPosition ); |
|
836 if ( id == KErrNotFound ) |
|
837 { |
|
838 User::Leave( KErrCorrupt ); |
|
839 } |
|
840 iUnsharer->EmptyContainer( id ); |
|
841 } |
|
842 else if ( iSharingPhase == EShare ) |
|
843 { |
|
844 delete iUnsharer; |
|
845 iUnsharer = NULL; |
|
846 delete iAo; |
|
847 iAo = NULL; |
|
848 iAo = CUpnpContentSharingAo::NewL( this, iMetadata ); |
|
849 TInt id = GetContainerId( iBufferPosition ); |
|
850 if ( id == KErrNotFound ) |
|
851 { |
|
852 User::Leave( KErrCorrupt ); |
|
853 } |
|
854 // iBufferPosition is updated in CompleteSharingOperationL |
|
855 switch( iBufferPosition ) |
|
856 { |
|
857 case EImageAndVideo : |
633 case EImageAndVideo : |
858 { |
634 { |
859 TRAP( err, iAo->InitializeL( ( TUpnpMediaType ) |
635 // start sharing and put progress |
860 iVisualSharingReq->iKind, |
636 iAo->StartSharing( iVisualSharingReq ); |
861 iVisualSharingReq->iSelections, |
637 break; |
862 *iVisualSharingReq->iObjectIds, |
638 } |
863 *iVisualSharingReq->iObjectNames, |
|
864 id )); |
|
865 // always show something in progress dialog -> add 1 |
|
866 TRAP( err, iVisualSharingReq->iItemCount = |
|
867 iAo->SelectionObjectCountL( |
|
868 ( TUpnpMediaType )iBufferPosition ) +1 ); |
|
869 iAo->ShareFiles(); // start sharing |
|
870 } |
|
871 break; |
|
872 case EPlaylist : |
639 case EPlaylist : |
873 { |
640 { |
874 TRAP( err, iAo->InitializeL( ( TUpnpMediaType ) |
641 // start sharing and put progress |
875 iMusicSharingReq->iKind, |
642 iAo->StartSharing( iMusicSharingReq ); |
876 iMusicSharingReq->iSelections, |
643 break; |
877 *iMusicSharingReq->iObjectIds, |
644 } |
878 *iMusicSharingReq->iObjectNames, |
|
879 id )); |
|
880 // always show something in progress dialog -> add 1 |
|
881 TRAP( err, iMusicSharingReq->iItemCount = |
|
882 iAo->SelectionObjectCountL( |
|
883 ( TUpnpMediaType )iBufferPosition ) +1); |
|
884 iAo->ShareFiles(); // start sharing |
|
885 } |
|
886 break; |
|
887 default: |
645 default: |
888 { |
646 { |
889 __LOG1( "Error: %d", __LINE__ ); |
647 __LOG1( "Error: %d", __LINE__ ); |
890 } |
648 break; |
891 break; |
649 } |
892 } |
650 } |
893 } |
|
894 else |
|
895 { |
|
896 __LOG1( "Error: %d", __LINE__ ); |
|
897 } |
|
898 |
|
899 |
651 |
900 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
652 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
901 } |
653 } |
902 |
654 |
903 // -------------------------------------------------------------------------- |
655 // -------------------------------------------------------------------------- |
1017 void CUpnpContentServerHandler::SetSharingRequestL( |
723 void CUpnpContentServerHandler::SetSharingRequestL( |
1018 const RArray<TInt>& aMarkedItems, |
724 const RArray<TInt>& aMarkedItems, |
1019 const TInt aType ) |
725 const TInt aType ) |
1020 { |
726 { |
1021 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
727 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
1022 CDesCArray* ids = new (ELeave) CDesCArrayFlat(4); |
728 |
1023 CleanupStack::PushL( ids ); |
729 // Create sharing request |
1024 CDesCArray* names = new (ELeave) CDesCArrayFlat(4); |
730 CreateSharingRequestL( aType, SharingType( aMarkedItems ) ); |
1025 CleanupStack::PushL( names ); |
731 |
|
732 // Get user selected filenames to be shared |
|
733 CDesCArray* filenamesToBeShared = |
|
734 new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
735 CleanupStack::PushL( filenamesToBeShared ); |
|
736 CDesCArray* clfIds = |
|
737 new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
738 CleanupStack::PushL( clfIds ); |
|
739 |
|
740 GetSelectionFilenamesL( |
|
741 aMarkedItems, |
|
742 aType, |
|
743 SharingType( aMarkedItems ), |
|
744 *filenamesToBeShared, |
|
745 *clfIds ); |
|
746 |
|
747 // Get currently shared filenames |
|
748 CUpnpCdsLiteObjectArray& currentlySharedContent = |
|
749 iSharingAlgorithm->ReadSharedContent(); |
|
750 |
|
751 // Compare and create unshare/share arrays |
|
752 RArray<TFileName>* shareArr = new ( ELeave ) RArray<TFileName>; |
|
753 CleanupStack::PushL( shareArr ); |
|
754 RArray<TFileName>* unshareArr = new ( ELeave ) RArray<TFileName>; |
|
755 CleanupStack::PushL( unshareArr ); |
|
756 |
|
757 CompareCdsToClfL( |
|
758 *filenamesToBeShared, |
|
759 currentlySharedContent, |
|
760 *shareArr, |
|
761 *unshareArr, |
|
762 (TUpnpMediaType)aType ); |
|
763 |
|
764 // Set sharing request information arrays: |
|
765 // shareArr, unshareArr and clfIds ownership transferred. |
|
766 SetSharingRequestInfo( |
|
767 aType, |
|
768 shareArr, |
|
769 unshareArr, |
|
770 clfIds ); |
|
771 |
|
772 // cleanup |
|
773 CleanupStack::Pop( unshareArr ); // ownership transferred to shar.request |
|
774 CleanupStack::Pop( shareArr ); // ownership transferred to shar.request |
|
775 CleanupStack::Pop( clfIds ); // ownership transferred to shar.request |
|
776 CleanupStack::PopAndDestroy( filenamesToBeShared ); |
|
777 |
|
778 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
779 } |
|
780 |
|
781 // -------------------------------------------------------------------------- |
|
782 // CUpnpContentServerHandler::HandleError |
|
783 // ( other items are commented in header ) |
|
784 // -------------------------------------------------------------------------- |
|
785 // |
|
786 |
|
787 void CUpnpContentServerHandler::HandleError( TInt aError ) |
|
788 { |
|
789 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
790 |
|
791 // cleanup if some error occurred while sharing |
|
792 if( iOngoingSharingType != KErrNotFound ) |
|
793 { |
|
794 Cleanup(); |
|
795 iErrorToClient = aError; |
|
796 // reset progress information |
|
797 TRAP_IGNORE( SetProgressL( KNoProgress ) ); |
|
798 } |
|
799 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
800 } |
|
801 |
|
802 // -------------------------------------------------------------------------- |
|
803 // CUpnpContentServerHandler::GetSelectionFilenamesL |
|
804 // ( other items are commented in header ) |
|
805 // -------------------------------------------------------------------------- |
|
806 // |
|
807 |
|
808 void CUpnpContentServerHandler::GetSelectionFilenamesL( |
|
809 const RArray<TInt>& aMarkedItems, |
|
810 const TInt aType, |
|
811 const TInt aSharingType, |
|
812 CDesCArray& aFilenames, |
|
813 CDesCArray& aClfIds ) |
|
814 { |
|
815 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
816 |
|
817 // Collect all the necessary filenames and clfIds depending on |
|
818 // the user selection. |
|
819 switch ( aSharingType ) |
|
820 { |
|
821 case EShareAll: |
|
822 { |
|
823 // All files of the selected playlists/albums should be |
|
824 // shared |
|
825 if ( aType == EImageAndVideo ) |
|
826 { |
|
827 GetAllImageAndVideoFilenamesL( aFilenames ); |
|
828 } |
|
829 else if ( aType == EPlaylist ) |
|
830 { |
|
831 GetAllMusicFilenamesL( aFilenames ); |
|
832 } |
|
833 break; |
|
834 } |
|
835 case EShareMany: |
|
836 { |
|
837 // Selected some of the playlists/albums |
|
838 if ( aType == EImageAndVideo ) |
|
839 { |
|
840 GetSelectedImgAndVideoFilenamesL( |
|
841 aMarkedItems, |
|
842 aFilenames, |
|
843 aClfIds ); |
|
844 } |
|
845 else if ( aType == EPlaylist ) |
|
846 { |
|
847 GetSelectedMusicFilenamesL( |
|
848 aMarkedItems, |
|
849 aFilenames, |
|
850 aClfIds ); |
|
851 } |
|
852 break; |
|
853 } |
|
854 case EShareNone: |
|
855 { |
|
856 // No selections, do nothing |
|
857 break; |
|
858 } |
|
859 default: |
|
860 { |
|
861 // do nothing |
|
862 break; |
|
863 } |
|
864 } |
|
865 |
|
866 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
867 } |
|
868 |
|
869 // -------------------------------------------------------------------------- |
|
870 // CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL |
|
871 // ( other items are commented in header ) |
|
872 // -------------------------------------------------------------------------- |
|
873 // |
|
874 |
|
875 void CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL( |
|
876 CDesCArray& aFilenames ) |
|
877 { |
|
878 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
879 |
|
880 // Fetch all the image files |
|
881 const MCLFItemListModel* imageFiles = iMetadata->ImageFiles(); |
|
882 if ( imageFiles ) |
|
883 { |
|
884 TInt imageCount = imageFiles->ItemCount(); |
|
885 __LOG1( "CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL \ |
|
886 imageCount=%d", imageCount ); |
|
887 |
|
888 // Append all image files to aFilenames |
|
889 for ( TInt i=0; i < imageCount; i++ ) |
|
890 { |
|
891 // get the filename from clf item |
|
892 TPtrC fullFilename; |
|
893 imageFiles->Item(i).GetField( |
|
894 ECLFFieldIdFileNameAndPath, |
|
895 fullFilename ); |
|
896 aFilenames.AppendL( fullFilename ); |
|
897 } |
|
898 } |
|
899 |
|
900 // Fetch all the video files |
|
901 const MCLFItemListModel* videoFiles = iMetadata->VideoFiles(); |
|
902 if ( videoFiles ) |
|
903 { |
|
904 TInt videoCount = videoFiles->ItemCount(); |
|
905 __LOG1( "CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL \ |
|
906 videoCount=%d", videoCount ); |
|
907 |
|
908 // Append all video files to aFilenames |
|
909 for ( TInt i=0; i < videoCount; i++ ) |
|
910 { |
|
911 // get the filename from clf item |
|
912 TPtrC fullFilename; |
|
913 videoFiles->Item(i).GetField( |
|
914 ECLFFieldIdFileNameAndPath, |
|
915 fullFilename ); |
|
916 aFilenames.AppendL( fullFilename ); |
|
917 } |
|
918 } |
|
919 |
|
920 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
921 } |
|
922 |
|
923 // -------------------------------------------------------------------------- |
|
924 // CUpnpContentServerHandler::GetAllMusicFilenamesL |
|
925 // ( other items are commented in header ) |
|
926 // -------------------------------------------------------------------------- |
|
927 // |
|
928 |
|
929 void CUpnpContentServerHandler::GetAllMusicFilenamesL( |
|
930 CDesCArray& aFilenames ) |
|
931 { |
|
932 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
933 |
|
934 // Fetch all the music files... |
|
935 const MCLFItemListModel* musicFiles = iMetadata->MusicFiles(); |
|
936 if ( musicFiles ) |
|
937 { |
|
938 TInt musicCount = musicFiles->ItemCount(); |
|
939 __LOG1( "CUpnpContentServerHandler::GetAllMusicFilenamesL \ |
|
940 musicCount=%d", musicCount ); |
|
941 |
|
942 // Append all music files to aFilenames |
|
943 for ( TInt i=0; i < musicCount; i++ ) |
|
944 { |
|
945 // get the filename from clf item |
|
946 TPtrC fullFilename; |
|
947 musicFiles->Item(i).GetField( |
|
948 ECLFFieldIdFileNameAndPath, |
|
949 fullFilename ); |
|
950 aFilenames.AppendL( fullFilename ); |
|
951 } |
|
952 } |
|
953 |
|
954 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
955 } |
|
956 |
|
957 // -------------------------------------------------------------------------- |
|
958 // CUpnpContentServerHandler::GetSelectedImgAndVideoFilenamesL |
|
959 // ( other items are commented in header ) |
|
960 // -------------------------------------------------------------------------- |
|
961 // |
|
962 |
|
963 void CUpnpContentServerHandler::GetSelectedImgAndVideoFilenamesL( |
|
964 const RArray<TInt>& aMarkedItems, |
|
965 CDesCArray& aFilenames, |
|
966 CDesCArray& aClfIds ) |
|
967 { |
|
968 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
969 |
|
970 // Go though all the selected collections and fetch collection ids and |
|
971 // items. |
|
972 TInt markedCount = aMarkedItems.Count(); |
|
973 for ( TInt i=0; i < markedCount; i++ ) |
|
974 { |
|
975 CDesCArray* collFilenames = |
|
976 new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
977 CleanupStack::PushL( collFilenames ); |
|
978 |
|
979 // find out collection id and items |
|
980 TPtrC collId = iReader->GetCollectionItemsL( |
|
981 aMarkedItems[i], |
|
982 *collFilenames ); |
|
983 if ( collId.Length() ) |
|
984 { |
|
985 // collection id found, append it to aClfIds |
|
986 aClfIds.AppendL( collId ); |
|
987 |
|
988 // append all collection items to aFilenames |
|
989 TInt collFileCount = collFilenames->Count(); |
|
990 for (TInt j=0; j < collFileCount; j++ ) |
|
991 { |
|
992 aFilenames.AppendL( collFilenames->MdcaPoint( j ) ); |
|
993 } |
|
994 } |
|
995 CleanupStack::PopAndDestroy( collFilenames ); |
|
996 } |
|
997 |
|
998 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
999 } |
|
1000 |
|
1001 // -------------------------------------------------------------------------- |
|
1002 // CUpnpContentServerHandler::GetSelectedMusicFilenamesL |
|
1003 // ( other items are commented in header ) |
|
1004 // -------------------------------------------------------------------------- |
|
1005 // |
|
1006 |
|
1007 void CUpnpContentServerHandler::GetSelectedMusicFilenamesL( |
|
1008 const RArray<TInt>& aMarkedItems, |
|
1009 CDesCArray& aFilenames, |
|
1010 CDesCArray& aClfIds ) |
|
1011 { |
|
1012 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
1013 |
|
1014 // Go though all the selected playlists and fetch playlist ids and |
|
1015 // items. |
|
1016 TInt markedCount = aMarkedItems.Count(); |
|
1017 for ( TInt i=0; i < markedCount; i++ ) |
|
1018 { |
|
1019 CDesCArray* plFilenames = |
|
1020 new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1021 CleanupStack::PushL( plFilenames ); |
|
1022 |
|
1023 // find out playlist id and items |
|
1024 TPtrC plId = iReader->GetPlaylistItemsL( |
|
1025 aMarkedItems[i], |
|
1026 *plFilenames ); |
|
1027 |
|
1028 if ( plId.Length() ) |
|
1029 { |
|
1030 // playlist id found, append it to aClfIds |
|
1031 aClfIds.AppendL( plId ); |
|
1032 |
|
1033 // append all playlist items to aFilenames |
|
1034 TInt plFileCount = plFilenames->Count(); |
|
1035 for (TInt j=0; j < plFileCount; j++ ) |
|
1036 { |
|
1037 aFilenames.AppendL( plFilenames->MdcaPoint( j ) ); |
|
1038 } |
|
1039 } |
|
1040 |
|
1041 CleanupStack::PopAndDestroy( plFilenames ); |
|
1042 } |
|
1043 |
|
1044 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
1045 } |
|
1046 |
|
1047 // -------------------------------------------------------------------------- |
|
1048 // CUpnpContentServerHandler::CompareCdsToClfL |
|
1049 // ( other items are commented in header ) |
|
1050 // -------------------------------------------------------------------------- |
|
1051 // |
|
1052 |
|
1053 void CUpnpContentServerHandler::CompareCdsToClfL( |
|
1054 CDesCArray& aClfFilePaths, |
|
1055 CUpnpCdsLiteObjectArray& aCdsObjects, |
|
1056 RArray<TFileName>& aToBeSharedFiles, |
|
1057 RArray<TFileName>& aToBeUnsharedSharedFiles, |
|
1058 const TUpnpMediaType aType ) |
|
1059 { |
|
1060 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
1061 |
|
1062 // See if files in the clffilenames can be found from cds structure. |
|
1063 // if they cna they are already shared. In they can't they need to be |
|
1064 // added to the list of "to be shared" items. |
|
1065 for (TInt i(0); i<aClfFilePaths.MdcaCount(); i++) |
|
1066 { |
|
1067 RBuf8 fileName; |
|
1068 CleanupClosePushL( fileName ); |
|
1069 fileName.CreateMaxL( aClfFilePaths.MdcaPoint(i).Length() ); |
|
1070 fileName.Copy( aClfFilePaths.MdcaPoint(i) ); |
|
1071 if( KErrNotFound == aCdsObjects.FindByName( fileName )) |
|
1072 { |
|
1073 // Not found cds-structure, so needs to be added to |
|
1074 // toBeSharedFiles. |
|
1075 aToBeSharedFiles.AppendL( aClfFilePaths.MdcaPoint(i) ); |
|
1076 } |
|
1077 else |
|
1078 { |
|
1079 // Shared already |
|
1080 } |
|
1081 CleanupStack::PopAndDestroy( &fileName ); |
|
1082 } |
|
1083 |
|
1084 // See if items in cds structure can be found from clffilenames. If |
|
1085 // they are found they need to be shared. If they are not found they |
|
1086 // need to be added to the list of "to be unshared" items. |
|
1087 for ( TInt j( 0 ); j<aCdsObjects.Count(); j++ ) |
|
1088 { |
|
1089 CUpnpCdsLiteObject& cdsObject = aCdsObjects.ObjectAtL( j ); |
|
1090 // resolve filetype in cds |
|
1091 const TDesC8& itemType = cdsObject.ObjectClass(); |
|
1092 |
|
1093 // compare only right type |
|
1094 if ( cdsObject.Type() == CUpnpCdsLiteObject::EItem && |
|
1095 ( ( ( itemType.Find( KVideo ) != KErrNotFound || |
|
1096 itemType.Find( KImage ) != KErrNotFound ) && |
|
1097 aType == EImageAndVideo ) || |
|
1098 ( itemType.Find( KAudio ) != KErrNotFound && |
|
1099 aType == EPlaylist ) ) ) |
|
1100 { |
|
1101 // get filename |
|
1102 HBufC* fileName = EscapeUtils::ConvertToUnicodeFromUtf8L( |
|
1103 cdsObject.Name() ); |
|
1104 CleanupStack::PushL( fileName ); |
|
1105 |
|
1106 TInt clfCount = aClfFilePaths.Count(); |
|
1107 TInt clfIndex( KErrNotFound ); |
|
1108 aClfFilePaths.Find( *fileName, clfIndex ); |
|
1109 if ( clfCount < 1 || clfIndex >= clfCount ) |
|
1110 { |
|
1111 // Must not be shared so add to the toBeUnsharedSharedFiles. |
|
1112 aToBeUnsharedSharedFiles.AppendL( *fileName ); |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 // Sharing wanted to that item |
|
1117 } |
|
1118 CleanupStack::PopAndDestroy( fileName ); |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
1123 } |
|
1124 |
|
1125 // -------------------------------------------------------------------------- |
|
1126 // CUpnpContentServerHandler::CreateSharingRequestL |
|
1127 // ( other items are commented in header ) |
|
1128 // -------------------------------------------------------------------------- |
|
1129 // |
|
1130 |
|
1131 void CUpnpContentServerHandler::CreateSharingRequestL( |
|
1132 TInt aType, |
|
1133 TInt aSharingType ) |
|
1134 { |
|
1135 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
1136 |
|
1137 // flag for indicating is it needed to set progress property |
|
1138 TBool setProgress( EFalse ); |
|
1139 |
|
1140 // Create the appropriate request depending on the sharing type. |
1026 if ( aType == EImageAndVideo ) |
1141 if ( aType == EImageAndVideo ) |
1027 { |
1142 { |
1028 iReader->CollectionIdsL( *ids, *names ); |
1143 // if music sharing is not ongoing, set progress |
|
1144 if ( !iMusicSharingReq || iOngoingSharingType != EPlaylist ) |
|
1145 { |
|
1146 setProgress = ETrue; |
|
1147 } |
|
1148 else |
|
1149 { |
|
1150 // force AO to set progress as soon as possible |
|
1151 iAo->ForceSetProgress(); |
|
1152 } |
|
1153 |
|
1154 // create image and video request |
1029 delete iVisualSharingReq; |
1155 delete iVisualSharingReq; |
1030 iVisualSharingReq = NULL; |
1156 iVisualSharingReq = NULL; |
1031 iVisualSharingReq = CUpnpSharingRequest::NewL( aType, |
1157 iVisualSharingReq = CUpnpSharingRequest::NewL( |
1032 aMarkedItems, |
1158 (TUpnpMediaType)aType, |
1033 ids, |
1159 aSharingType ); |
1034 names ); |
1160 if ( setProgress ) |
1035 } |
1161 { |
1036 else |
1162 // set progress so that ui updates itself |
1037 { |
1163 SetProgressL( KZeroProgress ); |
1038 iReader->PlayListIdsL( *ids, *names ); |
1164 } |
|
1165 } |
|
1166 else if ( aType == EPlaylist ) |
|
1167 { |
|
1168 // if visual sharing is not ongoing, set progress |
|
1169 if ( !iVisualSharingReq || iOngoingSharingType != EImageAndVideo ) |
|
1170 { |
|
1171 setProgress = ETrue; |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 // force AO to set progress as soon as possible |
|
1176 iAo->ForceSetProgress(); |
|
1177 } |
|
1178 |
|
1179 // create music request |
1039 delete iMusicSharingReq; |
1180 delete iMusicSharingReq; |
1040 iMusicSharingReq = NULL; |
1181 iMusicSharingReq = NULL; |
1041 iMusicSharingReq = CUpnpSharingRequest::NewL( aType, |
1182 iMusicSharingReq = CUpnpSharingRequest::NewL( |
1042 aMarkedItems, |
1183 (TUpnpMediaType)aType, |
1043 ids, |
1184 aSharingType ); |
1044 names ); |
1185 if ( setProgress ) |
1045 } |
1186 { |
1046 CleanupStack::Pop( names ); // ownership transferred |
1187 // set progress so that ui updates itself |
1047 CleanupStack::Pop( ids ); // ownership transferred |
1188 SetProgressL( KZeroProgress ); |
1048 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
1189 } |
1049 } |
1190 } |
1050 |
1191 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
1051 // -------------------------------------------------------------------------- |
1192 } |
1052 // CUpnpContentServerHandler::ValidateDefaultContainersL |
1193 |
1053 // ( other items are commented in header ) |
1194 // -------------------------------------------------------------------------- |
1054 // -------------------------------------------------------------------------- |
1195 // CUpnpContentServerHandler::SetSharingRequestInfo |
1055 // |
1196 // ( other items are commented in header ) |
1056 void CUpnpContentServerHandler::ValidateDefaultContainersL( ) |
1197 // -------------------------------------------------------------------------- |
1057 { |
1198 // |
1058 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
1199 |
1059 if ( iSharingPhase != ECheckDefaults ) |
1200 void CUpnpContentServerHandler::SetSharingRequestInfo( |
1060 { |
1201 TInt aType, |
1061 iStartupCleaning = ETrue; |
1202 RArray<TFileName>* aShareArray, |
1062 delete iContainerChecker; |
1203 RArray<TFileName>* aUnshareArray, |
1063 iContainerChecker = NULL; |
1204 CDesCArray* aClfIds ) |
1064 iContainerChecker = new (ELeave) CUpnpContainerCheckerAo( this ); |
1205 { |
1065 iContainerChecker->SetPriority( CActive::EPriorityUserInput ); |
1206 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
1066 iContainerChecker->ValidateContainerStructureL( |
1207 |
1067 NULL ); |
1208 // Sets the appropriate sharing request information arrays. |
1068 |
1209 // aShareArray, UnshareArray and aClfIds ownership transferred. |
1069 } |
1210 if ( aType == EImageAndVideo && iVisualSharingReq ) |
1070 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
1211 { |
1071 } |
1212 // image and video request |
1072 |
1213 iVisualSharingReq->SetSharingRequestInfo( |
1073 // -------------------------------------------------------------------------- |
1214 aShareArray, |
1074 // CUpnpContentServerHandler::HandleError |
1215 aUnshareArray, |
1075 // ( other items are commented in header ) |
1216 aClfIds ); |
1076 // -------------------------------------------------------------------------- |
1217 } |
1077 // |
1218 else if ( aType == EPlaylist && iMusicSharingReq ) |
1078 |
1219 { |
1079 void CUpnpContentServerHandler::HandleError( TInt aError ) |
1220 // music request |
1080 { |
1221 iMusicSharingReq->SetSharingRequestInfo( |
1081 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
1222 aShareArray, |
1082 if( iHandlerState != ENotActive ) |
1223 aUnshareArray, |
1083 { |
1224 aClfIds ); |
1084 Cleanup(); |
1225 } |
1085 iHandlerState = ENotActive; |
1226 |
1086 iSharingPhase = ECheckDefaults; |
1227 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
1087 iErrorToClient = aError; |
1228 } |
1088 TRAP_IGNORE( SetProgressL( KNoProgress ) ); |
1229 |
1089 } |
1230 // -------------------------------------------------------------------------- |
1090 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
1231 // CUpnpContentServerHandler::ResetPendingRequestInfo |
1091 } |
1232 // ( other items are commented in header ) |
1092 |
1233 // -------------------------------------------------------------------------- |
|
1234 // |
|
1235 |
|
1236 void CUpnpContentServerHandler::ResetPendingRequestInfo() |
|
1237 { |
|
1238 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
1239 |
|
1240 // Reset iPendingSharingReqInfo object |
|
1241 iPendingSharingReqInfo.iMediaType = KErrNotFound; |
|
1242 iPendingSharingReqInfo.iMarkedItems.Reset(); |
|
1243 |
|
1244 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
1245 } |
|
1246 |
|
1247 // -------------------------------------------------------------------------- |
|
1248 // CUpnpContentServerHandler::SavePendingRequestInfoL |
|
1249 // ( other items are commented in header ) |
|
1250 // -------------------------------------------------------------------------- |
|
1251 // |
|
1252 |
|
1253 void CUpnpContentServerHandler::SavePendingRequestInfoL( |
|
1254 const RArray<TInt>& aMarkedItems, |
|
1255 const TInt aType ) |
|
1256 { |
|
1257 __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ ); |
|
1258 |
|
1259 // reset pending request object |
|
1260 ResetPendingRequestInfo(); |
|
1261 |
|
1262 // Fill info of pending sharing request |
|
1263 iPendingSharingReqInfo.iMediaType = aType; |
|
1264 for ( TInt i = 0; i < aMarkedItems.Count(); i++ ) |
|
1265 { |
|
1266 iPendingSharingReqInfo.iMarkedItems.AppendL( aMarkedItems[i] ); |
|
1267 } |
|
1268 |
|
1269 __LOG8_1( "%s end.", __PRETTY_FUNCTION__ ); |
|
1270 } |
|
1271 |
|
1272 // -------------------------------------------------------------------------- |
|
1273 // CUpnpContentServerHandler::ResolveSharingType |
|
1274 // ( other items are commented in header ) |
|
1275 // -------------------------------------------------------------------------- |
|
1276 // |
|
1277 |
|
1278 TInt CUpnpContentServerHandler::SharingType( |
|
1279 const RArray<TInt>& aMarkedItems ) |
|
1280 { |
|
1281 // Resolve sharing type |
|
1282 TInt sharingType( EShareMany ); |
|
1283 if ( aMarkedItems.Find(0) != KErrNotFound ) |
|
1284 { |
|
1285 // share nothing marked |
|
1286 sharingType = EShareNone; |
|
1287 } |
|
1288 else if ( aMarkedItems.Find(1) != KErrNotFound ) |
|
1289 { |
|
1290 // share all marked |
|
1291 sharingType = EShareAll; |
|
1292 } |
|
1293 return sharingType; |
|
1294 } |
|
1295 |
1093 // End of file |
1296 // End of file |