568 DP("CPodcastFeedView::UpdateToolbar END"); |
568 DP("CPodcastFeedView::UpdateToolbar END"); |
569 } |
569 } |
570 |
570 |
571 void CPodcastFeedView::HandleAddFeedL() |
571 void CPodcastFeedView::HandleAddFeedL() |
572 { |
572 { |
|
573 TInt selection; |
|
574 CDesCArrayFlat* array = iCoeEnv->ReadDesC16ArrayResourceL(R_FEEDVIEW_ADD_URL_OR_SEARCH_ARRAY ); |
|
575 CleanupStack::PushL( array ); |
|
576 |
|
577 CAknListQueryDialog* dialog = new ( ELeave ) CAknListQueryDialog( &selection ); |
|
578 CleanupStack::PushL( dialog ); |
|
579 dialog->PrepareLC( R_FEEDVIEW_ADD_URL_OR_SEARCH ); |
|
580 CleanupStack::Pop( dialog ); |
|
581 |
|
582 dialog->SetItemTextArray( array ); |
|
583 dialog->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
584 |
|
585 if ( dialog->RunLD() ) |
|
586 { |
|
587 if (selection == 0) |
|
588 { |
|
589 // Enter URL selected |
|
590 HandleAddFeedUrlL(); |
|
591 } |
|
592 else |
|
593 { |
|
594 // Search selected |
|
595 HandleAddFeedSearchL(); |
|
596 } |
|
597 } |
|
598 CleanupStack::PopAndDestroy( array ); |
|
599 } |
|
600 |
|
601 void CPodcastFeedView::HandleAddFeedUrlL() |
|
602 { |
573 TBuf<KFeedUrlLength> url; |
603 TBuf<KFeedUrlLength> url; |
574 url.Copy(_L("http://")); |
604 url.Copy(_L("http://")); |
|
605 |
575 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
606 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
576 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
607 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
|
608 |
577 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); |
609 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); |
578 dlg->SetPromptL(*prompt); |
610 dlg->SetPromptL(*prompt); |
579 CleanupStack::PopAndDestroy(prompt); |
611 CleanupStack::PopAndDestroy(prompt); |
580 |
612 |
581 if(dlg->RunLD()) |
613 if(dlg->RunLD()) |
582 { |
614 { |
583 |
615 PodcastUtils::FixProtocolsL(url); |
584 // if no :// we do a search |
616 |
585 if (url.Find(_L("://")) == KErrNotFound) |
617 CFeedInfo* newFeedInfo = CFeedInfo::NewL(); |
586 { |
618 CleanupStack::PushL(newFeedInfo); |
587 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); |
619 newFeedInfo->SetUrlL(url); |
588 ShowWaitDialogL(*waitText); |
620 newFeedInfo->SetTitleL(newFeedInfo->Url()); |
589 CleanupStack::PopAndDestroy(waitText); |
621 |
590 |
622 TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); |
591 iOpmlState = EOpmlSearching; |
623 |
592 TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); |
624 if (added) |
|
625 { |
|
626 UpdateListboxItemsL(); |
593 |
627 |
594 if (err != KErrNone) |
628 // ask if users wants to update it now |
595 { |
629 TBuf<KMaxMessageLength> message; |
596 delete iWaitDialog; |
630 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
597 iOpmlState = EOpmlIdle; |
631 if(ShowQueryMessageL(message)) |
|
632 { |
|
633 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
|
634 |
|
635 iPodcastModel.SetActiveFeedInfo(info); |
|
636 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
637 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
598 } |
638 } |
599 } |
639 } |
600 else |
640 else |
601 { |
641 { |
602 PodcastUtils::FixProtocolsL(url); |
642 TBuf<KMaxMessageLength> message; |
603 |
643 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
604 CFeedInfo* newFeedInfo = CFeedInfo::NewL(); |
644 ShowErrorMessageL(message); |
605 CleanupStack::PushL(newFeedInfo); |
645 } |
606 newFeedInfo->SetUrlL(url); |
646 |
607 newFeedInfo->SetTitleL(newFeedInfo->Url()); |
647 CleanupStack::PopAndDestroy(newFeedInfo); |
608 |
648 } |
609 TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); |
649 } |
610 |
650 |
611 if (added) |
651 void CPodcastFeedView::HandleAddFeedSearchL() |
612 { |
652 { |
613 UpdateListboxItemsL(); |
653 TBuf<KFeedUrlLength> url; |
614 |
654 |
615 // ask if users wants to update it now |
655 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
616 TBuf<KMaxMessageLength> message; |
656 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
617 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
657 |
618 if(ShowQueryMessageL(message)) |
658 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_SEARCHFEED_PROMPT); |
619 { |
659 dlg->SetPromptL(*prompt); |
620 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
660 CleanupStack::PopAndDestroy(prompt); |
621 |
661 |
622 iPodcastModel.SetActiveFeedInfo(info); |
662 if(dlg->RunLD()) |
623 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
663 { |
624 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
664 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); |
625 } |
665 ShowWaitDialogL(*waitText); |
626 } |
666 CleanupStack::PopAndDestroy(waitText); |
627 else |
667 |
628 { |
668 iOpmlState = EOpmlSearching; |
629 TBuf<KMaxMessageLength> message; |
669 TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); |
630 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
670 |
631 ShowErrorMessageL(message); |
671 if (err != KErrNone) |
632 } |
672 { |
633 |
673 delete iWaitDialog; |
634 CleanupStack::PopAndDestroy(newFeedInfo); |
674 iOpmlState = EOpmlIdle; |
635 } |
675 } |
636 } |
676 } |
637 } |
677 } |
638 |
678 |
639 void CPodcastFeedView::HandleEditFeedL() |
679 void CPodcastFeedView::HandleEditFeedL() |