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