# HG changeset patch # User Sebastian Brannstrom # Date 1280160191 -3600 # Node ID e82411ba16466f64af1a860194af34b4103fe8ea # Parent 1457ec698c2bb2b2bae31a94bc86b46a6d002757 Bug 2865 - added option to search or enter URL for feed adding diff -r 1457ec698c2b -r e82411ba1646 application/data/PodcastClient_english.rls --- a/application/data/PodcastClient_english.rls Mon Jul 26 17:02:05 2010 +0100 +++ b/application/data/PodcastClient_english.rls Mon Jul 26 17:03:11 2010 +0100 @@ -38,7 +38,7 @@ rls_string STRING_r_tabgroup_queue_counter "Queue (%d)" // Question dialogs -rls_string STRING_r_add_feed_prompt "Enter search terms or feed address" +rls_string STRING_r_add_feed_prompt "Enter feed address" rls_string STRING_r_edit_feed_prompt "Feed address" rls_string STRING_r_add_feed_title_prompt "Feed title" rls_string STRING_r_remove_feed_prompt "Remove feed '%S'?" @@ -156,4 +156,7 @@ rls_string STRING_r_error_general "Error: General error %d" rls_string STRING_r_error_http "Error: HTTP error %d" rls_string STRING_r_error_disk_full "Error: Disk full" - +rls_string STRING_r_add_url_or_search "Add feed" +rls_string STRING_r_add_url "Enter URL" +rls_string STRING_r_add_search "Search for feed" +rls_string STRING_r_search_feed_prompt "Enter search terms" diff -r 1457ec698c2b -r e82411ba1646 application/data/PodcastFeedView.ra --- a/application/data/PodcastFeedView.ra Mon Jul 26 17:02:05 2010 +0100 +++ b/application/data/PodcastFeedView.ra Mon Jul 26 17:03:11 2010 +0100 @@ -270,3 +270,33 @@ } }; } + +RESOURCE ARRAY r_feedview_add_url_or_search_array +{ + items = + { + LBUF { txt = STRING_r_add_url; }, + LBUF { txt = STRING_r_add_search; } + }; +} + +RESOURCE AVKON_LIST_QUERY r_feedview_add_url_or_search +{ + softkeys=R_AVKON_SOFTKEYS_SELECT_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control = AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + heading = STRING_r_add_url_or_search; + listbox = AVKON_LIST_QUERY_LIST + { + // array of items will be defined dynamically + }; + }; + } + }; +} + diff -r 1457ec698c2b -r e82411ba1646 application/data/PodcastStrings.ra --- a/application/data/PodcastStrings.ra Mon Jul 26 17:02:05 2010 +0100 +++ b/application/data/PodcastStrings.ra Mon Jul 26 17:03:11 2010 +0100 @@ -77,4 +77,5 @@ RESOURCE TBUF r_error_disk_full {buf = STRING_r_error_disk_full; } RESOURCE TBUF r_about_text {buf = STRING_r_about_text_s60;} RESOURCE TBUF r_error_playback_failed {buf = STRING_r_error_playback_failed; } +RESOURCE TBUF r_podcast_searchfeed_prompt {buf = STRING_r_search_feed_prompt;} diff -r 1457ec698c2b -r e82411ba1646 application/inc/PodcastFeedView.h --- a/application/inc/PodcastFeedView.h Mon Jul 26 17:02:05 2010 +0100 +++ b/application/inc/PodcastFeedView.h Mon Jul 26 17:03:11 2010 +0100 @@ -103,6 +103,8 @@ private: void FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating = EFalse); void HandleAddFeedL(); + void HandleAddFeedUrlL(); + void HandleAddFeedSearchL(); void HandleEditFeedL(); void HandleRemoveFeedL(); void HandleImportFeedsL(); diff -r 1457ec698c2b -r e82411ba1646 application/src/PodcastFeedView.cpp --- a/application/src/PodcastFeedView.cpp Mon Jul 26 17:02:05 2010 +0100 +++ b/application/src/PodcastFeedView.cpp Mon Jul 26 17:03:11 2010 +0100 @@ -569,68 +569,108 @@ void CPodcastFeedView::HandleAddFeedL() { + TInt selection; + CDesCArrayFlat* array = iCoeEnv->ReadDesC16ArrayResourceL(R_FEEDVIEW_ADD_URL_OR_SEARCH_ARRAY ); + CleanupStack::PushL( array ); + + CAknListQueryDialog* dialog = new ( ELeave ) CAknListQueryDialog( &selection ); + CleanupStack::PushL( dialog ); + dialog->PrepareLC( R_FEEDVIEW_ADD_URL_OR_SEARCH ); + CleanupStack::Pop( dialog ); + + dialog->SetItemTextArray( array ); + dialog->SetOwnershipType( ELbmDoesNotOwnItemArray ); + + if ( dialog->RunLD() ) + { + if (selection == 0) + { + // Enter URL selected + HandleAddFeedUrlL(); + } + else + { + // Search selected + HandleAddFeedSearchL(); + } + } + CleanupStack::PopAndDestroy( array ); + } + +void CPodcastFeedView::HandleAddFeedUrlL() + { TBuf url; url.Copy(_L("http://")); + CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); + HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); dlg->SetPromptL(*prompt); CleanupStack::PopAndDestroy(prompt); if(dlg->RunLD()) { + PodcastUtils::FixProtocolsL(url); + + CFeedInfo* newFeedInfo = CFeedInfo::NewL(); + CleanupStack::PushL(newFeedInfo); + newFeedInfo->SetUrlL(url); + newFeedInfo->SetTitleL(newFeedInfo->Url()); - // if no :// we do a search - if (url.Find(_L("://")) == KErrNotFound) + TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); + + if (added) { - HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); - ShowWaitDialogL(*waitText); - CleanupStack::PopAndDestroy(waitText); - - iOpmlState = EOpmlSearching; - TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); + UpdateListboxItemsL(); - if (err != KErrNone) + // ask if users wants to update it now + TBuf message; + iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); + if(ShowQueryMessageL(message)) { - delete iWaitDialog; - iOpmlState = EOpmlIdle; + CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); + + iPodcastModel.SetActiveFeedInfo(info); + AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); + iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); } } else { - PodcastUtils::FixProtocolsL(url); + TBuf message; + iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); + ShowErrorMessageL(message); + } + + CleanupStack::PopAndDestroy(newFeedInfo); + } + } + +void CPodcastFeedView::HandleAddFeedSearchL() + { + TBuf url; - CFeedInfo* newFeedInfo = CFeedInfo::NewL(); - CleanupStack::PushL(newFeedInfo); - newFeedInfo->SetUrlL(url); - newFeedInfo->SetTitleL(newFeedInfo->Url()); - - TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); - - if (added) - { - UpdateListboxItemsL(); - - // ask if users wants to update it now - TBuf message; - iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); - if(ShowQueryMessageL(message)) - { - CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); - - iPodcastModel.SetActiveFeedInfo(info); - AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); - iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); - } - } - else - { - TBuf message; - iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); - ShowErrorMessageL(message); - } - - CleanupStack::PopAndDestroy(newFeedInfo); + CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); + dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); + + HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_SEARCHFEED_PROMPT); + dlg->SetPromptL(*prompt); + CleanupStack::PopAndDestroy(prompt); + + if(dlg->RunLD()) + { + HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); + ShowWaitDialogL(*waitText); + CleanupStack::PopAndDestroy(waitText); + + iOpmlState = EOpmlSearching; + TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url)); + + if (err != KErrNone) + { + delete iWaitDialog; + iOpmlState = EOpmlIdle; } } }