author | Sebastian Brannstrom <sebastianb@symbian.org> |
Thu, 21 Oct 2010 18:52:18 +0100 | |
branch | RCL_3 |
changeset 264 | 6dfdf1d9da5c |
parent 243 | 44d205147a83 |
child 309 | d9f6395a50ea |
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> |
|
29 |
#include <gulicon.h> |
|
30 |
#include <eikenv.h> |
|
31 |
#include <e32const.h> |
|
32 |
#include <eikdialg.h> |
|
33 |
#include <aknquerydialog.h> |
|
34 |
#include <caknmemoryselectiondialog.h> |
|
35 |
#include <caknfilenamepromptdialog.h> |
|
36 |
#include <BAUTILS.H> |
|
37 |
#include <pathinfo.h> |
|
38 |
#include <f32file.h> |
|
39 |
#include <akntoolbarextension.h> |
|
40 |
||
41 |
const TInt KMaxFeedNameLength = 100; |
|
42 |
#define KMaxMessageLength 200 |
|
43 |
#define KMaxTitleLength 100 |
|
44 |
_LIT(KSearchResultFormat, "%d\t%S\t%S"); |
|
45 |
||
46 |
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) |
|
47 |
{ |
|
48 |
CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) |
|
54 |
{ |
|
55 |
CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); |
|
56 |
CleanupStack::PushL( self ); |
|
57 |
self->ConstructL(); |
|
58 |
return self; |
|
59 |
} |
|
60 |
||
61 |
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
62 |
{ |
|
63 |
} |
|
64 |
||
65 |
void CPodcastSearchView::ConstructL() |
|
66 |
{ |
|
67 |
BaseConstructL(R_PODCAST_SEARCHVIEW); |
|
68 |
CPodcastListView::ConstructL(); |
|
69 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
70 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
71 |
CleanupStack::PushL( icons ); |
|
72 |
||
73 |
CFbsBitmap* bitmap = NULL; |
|
74 |
CFbsBitmap* mask = NULL;// |
|
75 |
||
140 | 76 |
AknIconUtils::CreateIconL(bitmap, |
77 |
mask, |
|
78 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
79 |
EMbmPodcastFeed, |
|
80 |
EMbmPodcastFeed_mask); |
|
2 | 81 |
CleanupStack::PushL( bitmap ); |
82 |
CleanupStack::PushL( mask ); |
|
83 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
84 |
CleanupStack::Pop(2); // bitmap, mask |
|
85 |
||
86 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
87 |
CleanupStack::Pop(icons); // icons |
|
88 |
||
89 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
90 |
||
91 |
SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); |
|
92 |
} |
|
93 |
||
94 |
CPodcastSearchView::~CPodcastSearchView() |
|
95 |
{ |
|
96 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
97 |
||
98 |
} |
|
99 |
||
100 |
TUid CPodcastSearchView::Id() const |
|
101 |
{ |
|
102 |
return KUidPodcastSearchViewID; |
|
103 |
} |
|
104 |
||
105 |
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
106 |
TUid aCustomMessageId, |
|
107 |
const TDesC8& aCustomMessage) |
|
108 |
{ |
|
109 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
110 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
111 |
|
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
112 |
((CPodcastAppUi*)AppUi())->NaviSetTextL(R_SEARCH_RESULTS); |
56 | 113 |
|
114 |
UpdateListboxItemsL(); |
|
2 | 115 |
} |
116 |
||
117 |
void CPodcastSearchView::DoDeactivate() |
|
118 |
{ |
|
119 |
CPodcastListView::DoDeactivate(); |
|
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
113
diff
changeset
|
120 |
TRAP_IGNORE(((CPodcastAppUi*)AppUi())->NaviShowTabGroupL()); |
2 | 121 |
} |
122 |
||
123 |
||
124 |
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
125 |
{ |
|
126 |
DP("CPodcastSearchView::HandleListBoxEventL BEGIN"); |
|
127 |
switch(aEventType) |
|
128 |
{ |
|
129 |
case EEventEnterKeyPressed: |
|
137
eefed4bda2e2
Minor fixes to comply with single tap technical solution description. By this I consider bug 2056 closed.
teknolog
parents:
126
diff
changeset
|
130 |
case EEventItemSingleClicked: |
2 | 131 |
case EEventItemDoubleClicked: |
132 |
case EEventItemActioned: |
|
133 |
{ |
|
134 |
HandleCommandL(EPodcastAddSearchResult); |
|
135 |
} |
|
136 |
break; |
|
137 |
default: |
|
138 |
break; |
|
139 |
} |
|
140 |
DP("CPodcastSearchView::HandleListBoxEventL END"); |
|
141 |
} |
|
142 |
||
143 |
void CPodcastSearchView::UpdateListboxItemsL() |
|
144 |
{ |
|
145 |
DP("CPodcastSearchView::UpdateListboxItemsL BEGIN"); |
|
146 |
if(!iListContainer->IsVisible()) { |
|
147 |
DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)"); |
|
148 |
return; |
|
149 |
} |
|
150 |
const RFeedInfoArray* searchItems = NULL; |
|
151 |
searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); |
|
152 |
TInt len = searchItems->Count(); |
|
153 |
TListItemProperties itemProps; |
|
154 |
iListContainer->Listbox()->Reset(); |
|
155 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
156 |
iItemIdArray.Reset(); |
|
157 |
iItemArray->Reset(); |
|
158 |
||
159 |
if (len > 0) |
|
160 |
{ |
|
161 |
for (int i=0;i<len;i++) |
|
162 |
{ |
|
163 |
CFeedInfo *fi = (*searchItems)[i]; |
|
164 |
iItemIdArray.Append(fi->Uid()); |
|
165 |
TInt iconIndex = 0; |
|
166 |
||
167 |
TBuf<512> descr; |
|
168 |
descr.Copy(fi->Description().Left(512)); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
14
diff
changeset
|
169 |
PodcastUtils::RemoveAllFormatting(descr); |
2 | 170 |
iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); |
171 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
172 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); |
|
173 |
} |
|
174 |
} |
|
175 |
else |
|
176 |
{ |
|
177 |
TBuf<KMaxFeedNameLength> itemName; |
|
178 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); |
|
179 |
iItemArray->Reset(); |
|
180 |
iItemIdArray.Reset(); |
|
181 |
||
182 |
TListItemProperties itemProps; |
|
183 |
itemProps.SetDimmed(ETrue); |
|
184 |
itemProps.SetHiddenSelection(ETrue); |
|
185 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
|
186 |
} |
|
187 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
188 |
DP("CPodcastSearchView::UpdateListboxItemsL END"); |
|
189 |
} |
|
190 |
||
191 |
/** |
|
192 |
* Command handling function intended for overriding by sub classes. |
|
193 |
* Default implementation is empty. |
|
194 |
* @param aCommand ID of the command to respond to. |
|
195 |
*/ |
|
196 |
void CPodcastSearchView::HandleCommandL(TInt aCommand) |
|
197 |
{ |
|
198 |
//CloseToolbarExtension(); |
|
199 |
switch(aCommand) |
|
200 |
{ |
|
201 |
case EPodcastAddSearchResult: |
|
202 |
{ |
|
203 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
204 |
||
205 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
206 |
{ |
|
207 |
CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; |
|
208 |
||
209 |
// ask if user wants to add the feed |
|
210 |
TBuf<KMaxMessageLength> templ; |
|
211 |
TBuf<KMaxMessageLength> message; |
|
212 |
||
213 |
iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); |
|
214 |
message.Format(templ, &newInfo->Title()); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
215 |
if(ShowQueryMessageL(message)) { |
2 | 216 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); |
217 |
||
218 |
if (added) |
|
219 |
{ |
|
220 |
// ask if user wants to update it now |
|
221 |
TBuf<KMaxMessageLength> message; |
|
222 |
iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
223 |
if(ShowQueryMessageL(message)) |
2 | 224 |
{ |
225 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newInfo->Uid()); |
|
226 |
||
227 |
iPodcastModel.SetActiveFeedInfo(info); |
|
228 |
AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
229 |
iPodcastModel.FeedEngine().UpdateFeedL(info->Uid()); |
|
230 |
} |
|
231 |
} |
|
232 |
else |
|
233 |
{ |
|
234 |
TBuf<KMaxMessageLength> message; |
|
235 |
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:
24
diff
changeset
|
236 |
ShowErrorMessageL(message); |
2 | 237 |
} |
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
break; |
|
242 |
default: |
|
243 |
CPodcastListView::HandleCommandL(aCommand); |
|
244 |
break; |
|
245 |
} |
|
246 |
UpdateToolbar(); |
|
247 |
} |
|
248 |
||
7 | 249 |
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) |
2 | 250 |
{ |
251 |
DP("CPodcastSearchView::OpmlParsingComplete BEGIN"); |
|
56 | 252 |
|
2 | 253 |
DP("CPodcastSearchView::OpmlParsingComplete END"); |
254 |
} |