Bug 2865 - added option to search or enter URL for feed adding 3rded
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 26 Jul 2010 17:03:11 +0100
branch3rded
changeset 206 9c3ebab9d24f
parent 205 628cdeed25ff
child 219 3aa0b93477b5
Bug 2865 - added option to search or enter URL for feed adding
application/data/PodcastClient_english.rls
application/data/PodcastFeedView.ra
application/data/PodcastStrings.ra
application/inc/PodcastFeedView.h
application/src/PodcastFeedView.cpp
--- a/application/data/PodcastClient_english.rls	Mon Jul 26 17:10:03 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 "(%d) Queue"
 
 // 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'?"
@@ -153,7 +153,10 @@
 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"
 rls_string STRING_r_view_feed_feed_menu "Manage feeds"
 rls_string STRING_r_view_shows_show_menu "Show"
 rls_string STRING_r_view_queue_show_menu "Queue"
--- a/application/data/PodcastFeedView.ra	Mon Jul 26 17:10:03 2010 +0100
+++ b/application/data/PodcastFeedView.ra	Mon Jul 26 17:03:11 2010 +0100
@@ -158,6 +158,36 @@
 		};
 	}
 
+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
+                };
+            };
+        }
+    };
+}
+
+
 RESOURCE AVKON_VIEW r_podcast_feedview
 {
 	hotkeys = r_podcast_feedview_hotkeys;
--- a/application/data/PodcastStrings.ra	Mon Jul 26 17:10:03 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;}
 
--- a/application/inc/PodcastFeedView.h	Mon Jul 26 17:10:03 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();
--- a/application/src/PodcastFeedView.cpp	Mon Jul 26 17:10:03 2010 +0100
+++ b/application/src/PodcastFeedView.cpp	Mon Jul 26 17:03:11 2010 +0100
@@ -539,68 +539,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<KFeedUrlLength> 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<KMaxMessageLength> 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<KMaxMessageLength> message;
+			iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
+			ShowErrorMessageL(message);
+			}		
+		
+		CleanupStack::PopAndDestroy(newFeedInfo);
+		}
+	}
+
+void CPodcastFeedView::HandleAddFeedSearchL()
+	{
+	TBuf<KFeedUrlLength> 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<KMaxMessageLength> 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<KMaxMessageLength> 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;
 			}
 		}
 	}