537 DP("CPodcastFeedView::HandleCommandL END"); |
537 DP("CPodcastFeedView::HandleCommandL END"); |
538 } |
538 } |
539 |
539 |
540 void CPodcastFeedView::HandleAddFeedL() |
540 void CPodcastFeedView::HandleAddFeedL() |
541 { |
541 { |
|
542 TInt selection; |
|
543 CDesCArrayFlat* array = iCoeEnv->ReadDesC16ArrayResourceL(R_FEEDVIEW_ADD_URL_OR_SEARCH_ARRAY ); |
|
544 CleanupStack::PushL( array ); |
|
545 |
|
546 CAknListQueryDialog* dialog = new ( ELeave ) CAknListQueryDialog( &selection ); |
|
547 CleanupStack::PushL( dialog ); |
|
548 dialog->PrepareLC( R_FEEDVIEW_ADD_URL_OR_SEARCH ); |
|
549 CleanupStack::Pop( dialog ); |
|
550 |
|
551 dialog->SetItemTextArray( array ); |
|
552 dialog->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
553 |
|
554 if ( dialog->RunLD() ) |
|
555 { |
|
556 if (selection == 0) |
|
557 { |
|
558 // Enter URL selected |
|
559 HandleAddFeedUrlL(); |
|
560 } |
|
561 else |
|
562 { |
|
563 // Search selected |
|
564 HandleAddFeedSearchL(); |
|
565 } |
|
566 } |
|
567 CleanupStack::PopAndDestroy( array ); |
|
568 } |
|
569 |
|
570 void CPodcastFeedView::HandleAddFeedUrlL() |
|
571 { |
542 TBuf<KFeedUrlLength> url; |
572 TBuf<KFeedUrlLength> url; |
543 url.Copy(_L("http://")); |
573 url.Copy(_L("http://")); |
|
574 |
544 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
575 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
545 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
576 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
|
577 |
546 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); |
578 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); |
547 dlg->SetPromptL(*prompt); |
579 dlg->SetPromptL(*prompt); |
548 CleanupStack::PopAndDestroy(prompt); |
580 CleanupStack::PopAndDestroy(prompt); |
549 |
581 |
550 if(dlg->RunLD()) |
582 if(dlg->RunLD()) |
551 { |
583 { |
552 |
584 PodcastUtils::FixProtocolsL(url); |
553 // if no :// we do a search |
585 |
554 if (url.Find(_L("://")) == KErrNotFound) |
586 CFeedInfo* newFeedInfo = CFeedInfo::NewL(); |
555 { |
587 CleanupStack::PushL(newFeedInfo); |
556 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); |
588 newFeedInfo->SetUrlL(url); |
557 ShowWaitDialogL(*waitText); |
589 newFeedInfo->SetTitleL(newFeedInfo->Url()); |
558 CleanupStack::PopAndDestroy(waitText); |
590 |
559 |
591 TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); |
560 iOpmlState = EOpmlSearching; |
592 |
561 TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); |
593 if (added) |
|
594 { |
|
595 UpdateListboxItemsL(); |
562 |
596 |
563 if (err != KErrNone) |
597 // ask if users wants to update it now |
564 { |
598 TBuf<KMaxMessageLength> message; |
565 delete iWaitDialog; |
599 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
566 iOpmlState = EOpmlIdle; |
600 if(ShowQueryMessageL(message)) |
|
601 { |
|
602 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
|
603 |
|
604 iPodcastModel.SetActiveFeedInfo(info); |
|
605 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
606 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
567 } |
607 } |
568 } |
608 } |
569 else |
609 else |
570 { |
610 { |
571 PodcastUtils::FixProtocolsL(url); |
611 TBuf<KMaxMessageLength> message; |
572 |
612 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
573 CFeedInfo* newFeedInfo = CFeedInfo::NewL(); |
613 ShowErrorMessageL(message); |
574 CleanupStack::PushL(newFeedInfo); |
614 } |
575 newFeedInfo->SetUrlL(url); |
615 |
576 newFeedInfo->SetTitleL(newFeedInfo->Url()); |
616 CleanupStack::PopAndDestroy(newFeedInfo); |
577 |
617 } |
578 TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); |
618 } |
579 |
619 |
580 if (added) |
620 void CPodcastFeedView::HandleAddFeedSearchL() |
581 { |
621 { |
582 UpdateListboxItemsL(); |
622 TBuf<KFeedUrlLength> url; |
583 |
623 |
584 // ask if users wants to update it now |
624 CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
585 TBuf<KMaxMessageLength> message; |
625 dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
586 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
626 |
587 if(ShowQueryMessageL(message)) |
627 HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_SEARCHFEED_PROMPT); |
588 { |
628 dlg->SetPromptL(*prompt); |
589 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
629 CleanupStack::PopAndDestroy(prompt); |
590 |
630 |
591 iPodcastModel.SetActiveFeedInfo(info); |
631 if(dlg->RunLD()) |
592 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
632 { |
593 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
633 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); |
594 } |
634 ShowWaitDialogL(*waitText); |
595 } |
635 CleanupStack::PopAndDestroy(waitText); |
596 else |
636 |
597 { |
637 iOpmlState = EOpmlSearching; |
598 TBuf<KMaxMessageLength> message; |
638 TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); |
599 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
639 |
600 ShowErrorMessageL(message); |
640 if (err != KErrNone) |
601 } |
641 { |
602 |
642 delete iWaitDialog; |
603 CleanupStack::PopAndDestroy(newFeedInfo); |
643 iOpmlState = EOpmlIdle; |
604 } |
644 } |
605 } |
645 } |
606 } |
646 } |
607 |
647 |
608 void CPodcastFeedView::HandleEditFeedL() |
648 void CPodcastFeedView::HandleEditFeedL() |