author | teknolog |
Sat, 13 Mar 2010 22:00:39 +0000 | |
changeset 56 | c5cd47bc11ef |
parent 50 | e7b10d6d7ba3 |
child 67 | 9c24c921ec35 |
child 113 | 50345a6ad0c3 |
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 |
const TInt KDefaultGran = 5; |
|
43 |
const TInt KNumberOfFilesMaxLength = 4; |
|
44 |
#define KMaxMessageLength 200 |
|
45 |
#define KMaxTitleLength 100 |
|
46 |
const TInt KMimeBufLength = 100; |
|
47 |
||
48 |
_LIT(KUnknownUpdateDateString, "?/?"); |
|
49 |
_LIT(KSearchResultFormat, "%d\t%S\t%S"); |
|
50 |
||
51 |
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) |
|
52 |
{ |
|
53 |
CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); |
|
54 |
CleanupStack::Pop( self ); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) |
|
59 |
{ |
|
60 |
CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); |
|
61 |
CleanupStack::PushL( self ); |
|
62 |
self->ConstructL(); |
|
63 |
return self; |
|
64 |
} |
|
65 |
||
66 |
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
67 |
{ |
|
68 |
} |
|
69 |
||
70 |
void CPodcastSearchView::ConstructL() |
|
71 |
{ |
|
72 |
BaseConstructL(R_PODCAST_SEARCHVIEW); |
|
73 |
CPodcastListView::ConstructL(); |
|
74 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
75 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
76 |
CleanupStack::PushL( icons ); |
|
77 |
||
78 |
// Load the bitmap for empty icon |
|
79 |
CFbsBitmap* bitmap = NULL; |
|
80 |
CFbsBitmap* mask = NULL;// |
|
81 |
||
82 |
// Load the bitmap for feed icon |
|
83 |
||
84 |
// Load svg.-image and mask with a single call |
|
85 |
AknIconUtils::CreateIconL(bitmap, |
|
86 |
mask, |
|
87 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
88 |
EMbmPodcastFeed, |
|
89 |
EMbmPodcastFeed_mask); |
|
90 |
/* |
|
91 |
bitmap = iEikonEnv->CreateBitmapL( _L("*"),EMbmPodcastFeed_40x40);*/ |
|
92 |
CleanupStack::PushL( bitmap ); |
|
93 |
// Load the mask for feed icon |
|
94 |
/*mask = iEikonEnv->CreateBitmapL( _L("*"),EMbmPodcastFeed_40x40m ); |
|
95 |
*/ |
|
96 |
CleanupStack::PushL( mask ); |
|
97 |
// Append the feed icon to icon array |
|
98 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
99 |
CleanupStack::Pop(2); // bitmap, mask |
|
100 |
||
101 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
102 |
CleanupStack::Pop(icons); // icons |
|
103 |
||
104 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
105 |
||
106 |
SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); |
|
107 |
} |
|
108 |
||
109 |
CPodcastSearchView::~CPodcastSearchView() |
|
110 |
{ |
|
111 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
112 |
||
113 |
if(iLongTapDetector) |
|
114 |
delete iLongTapDetector, iLongTapDetector = NULL; |
|
115 |
||
116 |
if(iStylusPopupMenu) |
|
117 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
118 |
||
119 |
} |
|
120 |
||
121 |
TUid CPodcastSearchView::Id() const |
|
122 |
{ |
|
123 |
return KUidPodcastSearchViewID; |
|
124 |
} |
|
125 |
||
126 |
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
127 |
TUid aCustomMessageId, |
|
128 |
const TDesC8& aCustomMessage) |
|
129 |
{ |
|
130 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
131 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
132 |
|
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
133 |
((CPodcastAppUi*)AppUi())->NaviSetTextL(R_SEARCH_RESULTS); |
56 | 134 |
|
135 |
UpdateListboxItemsL(); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
136 |
UpdateToolbar(); |
2 | 137 |
} |
138 |
||
139 |
void CPodcastSearchView::DoDeactivate() |
|
140 |
{ |
|
141 |
CPodcastListView::DoDeactivate(); |
|
24
ca50ea154990
Moved search result title to navipane. Fixed but 1832
teknolog
parents:
15
diff
changeset
|
142 |
((CPodcastAppUi*)AppUi())->NaviShowTabGroupL(); |
2 | 143 |
} |
144 |
||
145 |
||
146 |
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
147 |
{ |
|
148 |
DP("CPodcastSearchView::HandleListBoxEventL BEGIN"); |
|
149 |
switch(aEventType) |
|
150 |
{ |
|
151 |
case EEventEnterKeyPressed: |
|
152 |
case EEventItemDoubleClicked: |
|
153 |
case EEventItemActioned: |
|
154 |
{ |
|
155 |
HandleCommandL(EPodcastAddSearchResult); |
|
156 |
} |
|
157 |
break; |
|
158 |
default: |
|
159 |
break; |
|
160 |
} |
|
161 |
DP("CPodcastSearchView::HandleListBoxEventL END"); |
|
162 |
} |
|
163 |
||
164 |
void CPodcastSearchView::UpdateListboxItemsL() |
|
165 |
{ |
|
166 |
DP("CPodcastSearchView::UpdateListboxItemsL BEGIN"); |
|
167 |
if(!iListContainer->IsVisible()) { |
|
168 |
DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)"); |
|
169 |
return; |
|
170 |
} |
|
171 |
const RFeedInfoArray* searchItems = NULL; |
|
172 |
searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); |
|
173 |
TInt len = searchItems->Count(); |
|
174 |
TListItemProperties itemProps; |
|
175 |
iListContainer->Listbox()->Reset(); |
|
176 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
177 |
iItemIdArray.Reset(); |
|
178 |
iItemArray->Reset(); |
|
179 |
||
180 |
if (len > 0) |
|
181 |
{ |
|
182 |
for (int i=0;i<len;i++) |
|
183 |
{ |
|
184 |
CFeedInfo *fi = (*searchItems)[i]; |
|
185 |
iItemIdArray.Append(fi->Uid()); |
|
186 |
TInt iconIndex = 0; |
|
187 |
||
188 |
TBuf<512> descr; |
|
189 |
descr.Copy(fi->Description().Left(512)); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
14
diff
changeset
|
190 |
PodcastUtils::RemoveAllFormatting(descr); |
2 | 191 |
iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); |
192 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
193 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); |
|
194 |
} |
|
195 |
} |
|
196 |
else |
|
197 |
{ |
|
198 |
TBuf<KMaxFeedNameLength> itemName; |
|
199 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); |
|
200 |
iItemArray->Reset(); |
|
201 |
iItemIdArray.Reset(); |
|
202 |
||
203 |
TListItemProperties itemProps; |
|
204 |
itemProps.SetDimmed(ETrue); |
|
205 |
itemProps.SetHiddenSelection(ETrue); |
|
206 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
|
207 |
} |
|
208 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
209 |
DP("CPodcastSearchView::UpdateListboxItemsL END"); |
|
210 |
} |
|
211 |
||
212 |
/** |
|
213 |
* Command handling function intended for overriding by sub classes. |
|
214 |
* Default implementation is empty. |
|
215 |
* @param aCommand ID of the command to respond to. |
|
216 |
*/ |
|
217 |
void CPodcastSearchView::HandleCommandL(TInt aCommand) |
|
218 |
{ |
|
219 |
//CloseToolbarExtension(); |
|
220 |
switch(aCommand) |
|
221 |
{ |
|
222 |
case EPodcastAddSearchResult: |
|
223 |
{ |
|
224 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
225 |
||
226 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
227 |
{ |
|
228 |
CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; |
|
229 |
||
230 |
// ask if user wants to add the feed |
|
231 |
TBuf<KMaxMessageLength> templ; |
|
232 |
TBuf<KMaxMessageLength> message; |
|
233 |
||
234 |
iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); |
|
235 |
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
|
236 |
if(ShowQueryMessageL(message)) { |
2 | 237 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); |
238 |
||
239 |
if (added) |
|
240 |
{ |
|
241 |
// ask if user wants to update it now |
|
242 |
TBuf<KMaxMessageLength> message; |
|
243 |
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
|
244 |
if(ShowQueryMessageL(message)) |
2 | 245 |
{ |
246 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newInfo->Uid()); |
|
247 |
||
248 |
iPodcastModel.ActiveShowList().Reset(); |
|
249 |
iPodcastModel.SetActiveFeedInfo(info); |
|
250 |
AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
251 |
iPodcastModel.FeedEngine().UpdateFeedL(info->Uid()); |
|
252 |
} |
|
253 |
} |
|
254 |
else |
|
255 |
{ |
|
256 |
TBuf<KMaxMessageLength> message; |
|
257 |
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
|
258 |
ShowErrorMessageL(message); |
2 | 259 |
} |
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
break; |
|
264 |
default: |
|
265 |
CPodcastListView::HandleCommandL(aCommand); |
|
266 |
break; |
|
267 |
} |
|
268 |
UpdateToolbar(); |
|
269 |
} |
|
270 |
||
7 | 271 |
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) |
2 | 272 |
{ |
273 |
DP("CPodcastSearchView::OpmlParsingComplete BEGIN"); |
|
56 | 274 |
|
2 | 275 |
DP("CPodcastSearchView::OpmlParsingComplete END"); |
276 |
} |
|
277 |
||
13 | 278 |
void CPodcastSearchView::UpdateToolbar(TBool aVisible) |
2 | 279 |
{ |
280 |
TBool disableAdd = iItemArray->MdcaCount() == 0 || iSearchRunning; |
|
281 |
||
282 |
CAknToolbar* toolbar = Toolbar(); |
|
283 |
||
284 |
if (toolbar) |
|
285 |
{ |
|
14
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
286 |
if (iListContainer->IsVisible()) { |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
287 |
toolbar->SetToolbarVisibility(aVisible); |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
288 |
} |
2 | 289 |
toolbar->SetItemDimmed(EPodcastAddSearchResult, disableAdd, ETrue ); |
290 |
toolbar->HideItem(EPodcastSearch, iSearchRunning, ETrue ); |
|
291 |
toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iSearchRunning, ETrue); |
|
292 |
} |
|
293 |
} |