| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Sun, 14 Nov 2010 13:05:37 +0000 | |
| branch | RCL_3 | 
| changeset 367 | 4b75876aa85a | 
| parent 318 | a231cc388498 | 
| permissions | -rw-r--r-- | 
| 2 | 1 | /* | 
| 2 | * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB | |
| 3 | * | |
| 4 | * All rights reserved. | |
| 5 | * This component and the accompanying materials are made available | |
| 6 | * under the terms of the License "Eclipse Public License v1.0" | |
| 7 | * which accompanies this distribution, and is available | |
| 8 | * at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
| 9 | * | |
| 10 | * Initial Contributors: | |
| 11 | * EmbedDev AB - initial contribution. | |
| 12 | * | |
| 13 | * Contributors: | |
| 14 | * | |
| 15 | * Description: | |
| 16 | * | |
| 17 | */ | |
| 18 | ||
| 19 | #include "PodcastSearchView.h" | |
| 20 | #include "PodcastAppUi.h" | |
| 21 | #include "FeedEngine.h" | |
| 22 | #include "ShowEngine.h" | |
| 23 | #include "SettingsEngine.h" | |
| 24 | #include "PodcastApp.h" | |
| 25 | #include "PodcastUtils.h" | |
| 26 | #include <caknfileselectiondialog.h> | |
| 27 | #include <podcast.rsg> | |
| 28 | #include <podcast.mbg> | |
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 29 | #include <akntitle.h> | 
| 2 | 30 | #include <gulicon.h> | 
| 31 | #include <eikenv.h> | |
| 32 | #include <e32const.h> | |
| 33 | #include <eikdialg.h> | |
| 34 | #include <aknquerydialog.h> | |
| 35 | #include <caknmemoryselectiondialog.h> | |
| 36 | #include <caknfilenamepromptdialog.h> | |
| 37 | #include <BAUTILS.H> | |
| 38 | #include <pathinfo.h> | |
| 39 | #include <f32file.h> | |
| 40 | #include <akntoolbarextension.h> | |
| 41 | ||
| 42 | const TInt KMaxFeedNameLength = 100; | |
| 43 | #define KMaxMessageLength 200 | |
| 44 | #define KMaxTitleLength 100 | |
| 45 | _LIT(KSearchResultFormat, "%d\t%S\t%S"); | |
| 316 | 46 | _LIT(KSearchResultFormatLandscape, "%d\t%S"); | 
| 2 | 47 | |
| 48 | CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) | |
| 49 |     {
 | |
| 50 | CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); | |
| 51 | CleanupStack::Pop( self ); | |
| 52 | return self; | |
| 53 | } | |
| 54 | ||
| 55 | CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) | |
| 56 |     {
 | |
| 57 | CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); | |
| 58 | CleanupStack::PushL( self ); | |
| 59 | self->ConstructL(); | |
| 60 | return self; | |
| 61 | } | |
| 62 | ||
| 63 | CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) | |
| 64 | {
 | |
| 65 | } | |
| 66 | ||
| 67 | void CPodcastSearchView::ConstructL() | |
| 68 | {
 | |
| 69 | BaseConstructL(R_PODCAST_SEARCHVIEW); | |
| 70 | CPodcastListView::ConstructL(); | |
| 71 | iPodcastModel.FeedEngine().AddObserver(this); | |
| 72 | CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); | |
| 73 | CleanupStack::PushL( icons ); | |
| 74 | ||
| 75 | CFbsBitmap* bitmap = NULL; | |
| 76 | CFbsBitmap* mask = NULL;// | |
| 77 | ||
| 140 | 78 | AknIconUtils::CreateIconL(bitmap, | 
| 79 | mask, | |
| 80 | iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), | |
| 81 | EMbmPodcastFeed, | |
| 82 | EMbmPodcastFeed_mask); | |
| 2 | 83 | CleanupStack::PushL( bitmap ); | 
| 84 | CleanupStack::PushL( mask ); | |
| 85 | icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); | |
| 86 | CleanupStack::Pop(2); // bitmap, mask | |
| 87 | ||
| 313 
0f30a75610de
First implementation of two listboxes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
312diff
changeset | 88 | iListContainer->SetListboxIcons(icons); | 
| 2 | 89 | CleanupStack::Pop(icons); // icons | 
| 90 | ||
| 91 | SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); | |
| 92 | } | |
| 93 | ||
| 94 | CPodcastSearchView::~CPodcastSearchView() | |
| 95 |     {
 | |
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 96 | 	DP("CPodcastSearchView::~CPodcastSearchView BEGIN");
 | 
| 2 | 97 | iPodcastModel.FeedEngine().RemoveObserver(this); | 
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 98 | 	DP("CPodcastSearchView::~CPodcastSearchView END");
 | 
| 2 | 99 | } | 
| 100 | ||
| 101 | TUid CPodcastSearchView::Id() const | |
| 102 | {
 | |
| 103 | return KUidPodcastSearchViewID; | |
| 104 | } | |
| 105 | ||
| 106 | void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, | |
| 107 | TUid aCustomMessageId, | |
| 108 | const TDesC8& aCustomMessage) | |
| 109 | {
 | |
| 110 | CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); | |
| 111 | iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); | |
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 112 | |
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 113 | HBufC* text = iEikonEnv->AllocReadResourceLC(R_SEARCH_RESULTS); | 
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 114 | |
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 115 | CAknTitlePane* titlePane = static_cast<CAknTitlePane*> | 
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 116 | ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); | 
| 49 
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
 teknolog parents: 
24diff
changeset | 117 | |
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 118 | titlePane->SetTextL(*text , ETrue ); | 
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 119 | CleanupStack::PopAndDestroy(text); | 
| 56 | 120 | UpdateListboxItemsL(); | 
| 367 
4b75876aa85a
Added new shows list
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
318diff
changeset | 121 | ((CPodcastAppUi*)AppUi())->SetTabsDimmed(ETrue); | 
| 2 | 122 | } | 
| 123 | ||
| 124 | void CPodcastSearchView::DoDeactivate() | |
| 125 | {
 | |
| 126 | CPodcastListView::DoDeactivate(); | |
| 309 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 127 | |
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 128 | CAknTitlePane* titlePane = static_cast<CAknTitlePane*> | 
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 129 | ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); | 
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 130 | |
| 
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
243diff
changeset | 131 | titlePane->SetTextToDefaultL(); | 
| 367 
4b75876aa85a
Added new shows list
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
318diff
changeset | 132 | ((CPodcastAppUi*)AppUi())->SetTabsDimmed(EFalse); | 
| 2 | 133 | } | 
| 134 | ||
| 135 | ||
| 136 | void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) | |
| 137 | {
 | |
| 138 | 	DP("CPodcastSearchView::HandleListBoxEventL BEGIN");
 | |
| 139 | switch(aEventType) | |
| 140 | 	{
 | |
| 141 | case EEventEnterKeyPressed: | |
| 137 
eefed4bda2e2
Minor fixes to comply with single tap technical solution description. By this I consider bug 2056 closed.
 teknolog parents: 
126diff
changeset | 142 | case EEventItemSingleClicked: | 
| 2 | 143 | case EEventItemDoubleClicked: | 
| 144 | case EEventItemActioned: | |
| 145 | 		{
 | |
| 146 | HandleCommandL(EPodcastAddSearchResult); | |
| 147 | } | |
| 148 | break; | |
| 149 | default: | |
| 150 | break; | |
| 151 | } | |
| 152 | 	DP("CPodcastSearchView::HandleListBoxEventL END");
 | |
| 153 | } | |
| 154 | ||
| 155 | void CPodcastSearchView::UpdateListboxItemsL() | |
| 156 | 	{
 | |
| 157 | 	DP("CPodcastSearchView::UpdateListboxItemsL BEGIN");
 | |
| 158 | 	if(!iListContainer->IsVisible()) {
 | |
| 159 | 		DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)");
 | |
| 160 | return; | |
| 161 | } | |
| 162 | const RFeedInfoArray* searchItems = NULL; | |
| 163 | searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); | |
| 164 | TInt len = searchItems->Count(); | |
| 165 | TListItemProperties itemProps; | |
| 166 | iListContainer->Listbox()->Reset(); | |
| 317 
5afc95a6ad83
Stability fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
316diff
changeset | 167 | //iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); | 
| 2 | 168 | iItemIdArray.Reset(); | 
| 169 | iItemArray->Reset(); | |
| 170 | ||
| 171 | if (len > 0) | |
| 172 | 		{
 | |
| 173 | for (int i=0;i<len;i++) | |
| 174 | 			{				
 | |
| 175 | CFeedInfo *fi = (*searchItems)[i]; | |
| 176 | iItemIdArray.Append(fi->Uid()); | |
| 177 | TInt iconIndex = 0; | |
| 178 | ||
| 179 | TBuf<512> descr; | |
| 180 | descr.Copy(fi->Description().Left(512)); | |
| 15 
93d9f66bf50b
Cleaning description better for second line in search results
 teknolog parents: 
14diff
changeset | 181 | PodcastUtils::RemoveAllFormatting(descr); | 
| 2 | 182 | iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); | 
| 183 | iItemArray->AppendL(iListboxFormatbuffer); | |
| 317 
5afc95a6ad83
Stability fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
316diff
changeset | 184 | iListboxFormatbufferShort.Format(KSearchResultFormatLandscape(), iconIndex, &fi->Title()); | 
| 316 | 185 | iItemArrayShort->AppendL(iListboxFormatbufferShort); | 
| 317 
5afc95a6ad83
Stability fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
316diff
changeset | 186 | //iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); | 
| 2 | 187 | } | 
| 188 | } | |
| 189 | else | |
| 190 | 		{					
 | |
| 191 | TBuf<KMaxFeedNameLength> itemName; | |
| 192 | iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); | |
| 193 | iItemArray->Reset(); | |
| 316 | 194 | iItemArrayShort->Reset(); | 
| 2 | 195 | iItemIdArray.Reset(); | 
| 196 | ||
| 197 | TListItemProperties itemProps; | |
| 198 | itemProps.SetDimmed(ETrue); | |
| 199 | itemProps.SetHiddenSelection(ETrue); | |
| 317 
5afc95a6ad83
Stability fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
316diff
changeset | 200 | //iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); | 
| 2 | 201 | } | 
| 202 | iListContainer->Listbox()->HandleItemAdditionL(); | |
| 203 | 	DP("CPodcastSearchView::UpdateListboxItemsL END");
 | |
| 204 | } | |
| 205 | ||
| 206 | /** | |
| 207 | * Command handling function intended for overriding by sub classes. | |
| 208 | * Default implementation is empty. | |
| 209 | * @param aCommand ID of the command to respond to. | |
| 210 | */ | |
| 211 | void CPodcastSearchView::HandleCommandL(TInt aCommand) | |
| 212 | 	{
 | |
| 213 | //CloseToolbarExtension(); | |
| 214 | switch(aCommand) | |
| 215 | 		{
 | |
| 216 | case EPodcastAddSearchResult: | |
| 217 | 			{
 | |
| 218 | TInt index = iListContainer->Listbox()->CurrentItemIndex(); | |
| 219 | ||
| 220 | if(index < iItemArray->MdcaCount() && index >= 0) | |
| 221 | 				{
 | |
| 222 | CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; | |
| 223 | ||
| 224 | // ask if user wants to add the feed | |
| 225 | TBuf<KMaxMessageLength> templ; | |
| 226 | TBuf<KMaxMessageLength> message; | |
| 227 | ||
| 228 | iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); | |
| 229 | message.Format(templ, &newInfo->Title()); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
24diff
changeset | 230 | 				if(ShowQueryMessageL(message)) {
 | 
| 2 | 231 | TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); | 
| 232 | ||
| 233 | if (added) | |
| 312 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 234 | 						{
 | 
| 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 235 | // this is a bit of a hack, first we activate the feeds view normally | 
| 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 236 | AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(0), KNullDesC8); | 
| 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 237 | // and then we send the UID of the recently added feed back to feed view for updating | 
| 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 238 | // this is needed so the update? query comes on top of feed view, not search view | 
| 
2faae209e72b
More elegant view handling between search view and feeds view
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
309diff
changeset | 239 | AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(newInfo->Uid()), KNullDesC8); | 
| 2 | 240 | } | 
| 241 | else | |
| 242 | 						{
 | |
| 243 | TBuf<KMaxMessageLength> message; | |
| 244 | iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
24diff
changeset | 245 | ShowErrorMessageL(message); | 
| 2 | 246 | } | 
| 247 | } | |
| 248 | } | |
| 249 | } | |
| 250 | break; | |
| 251 | default: | |
| 252 | CPodcastListView::HandleCommandL(aCommand); | |
| 253 | break; | |
| 254 | } | |
| 255 | UpdateToolbar(); | |
| 256 | } | |
| 257 | ||
| 7 | 258 | void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) | 
| 2 | 259 | 	{
 | 
| 260 | 	DP("CPodcastSearchView::OpmlParsingComplete BEGIN");
 | |
| 56 | 261 | |
| 2 | 262 | 	DP("CPodcastSearchView::OpmlParsingComplete END");
 | 
| 263 | } |