author | Brendan Donegan <brendand@symbian.org> |
Fri, 12 Mar 2010 09:53:46 +0000 | |
branch | Symbian3 |
changeset 51 | 3a22449b5c73 |
parent 37 | 1644b7cd063e |
parent 50 | e7b10d6d7ba3 |
child 65 | bcd88ba95046 |
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 "PodcastFeedView.h" |
|
20 |
#include "PodcastAppUi.h" |
|
21 |
#include "ShowEngine.h" |
|
22 |
#include "SettingsEngine.h" |
|
23 |
#include "PodcastApp.h" |
|
24 |
#include "PodcastUtils.h" |
|
25 |
#include "PodcastFeedViewUpdater.h" |
|
26 |
#include "Podcast.hrh" |
|
27 |
#include <caknfileselectiondialog.h> |
|
28 |
#include <podcast.rsg> |
|
29 |
#include <podcast.mbg> |
|
30 |
#include <gulicon.h> |
|
31 |
#include <aknquerydialog.h> |
|
32 |
#include <caknmemoryselectiondialog.h> |
|
33 |
#include <caknfilenamepromptdialog.h> |
|
34 |
#include <BAUTILS.H> |
|
35 |
#include <pathinfo.h> |
|
36 |
||
37 |
const TInt KMaxFeedNameLength = 100; |
|
38 |
const TInt KMaxUnplayedFeedsLength =64; |
|
39 |
const TInt KADayInHours = 24; |
|
40 |
const TInt KDefaultGran = 5; |
|
41 |
const TInt KNumberOfFilesMaxLength = 4; |
|
42 |
#define KMaxMessageLength 200 |
|
43 |
#define KMaxTitleLength 100 |
|
44 |
const TInt KMimeBufLength = 100; |
|
45 |
||
46 |
_LIT(KFeedFormat, "%d\t%S\t%S%S"); |
|
47 |
enum |
|
48 |
{ |
|
49 |
EFeedIcon |
|
50 |
}; |
|
51 |
||
52 |
CPodcastFeedView* CPodcastFeedView::NewL(CPodcastModel& aPodcastModel) |
|
53 |
{ |
|
54 |
CPodcastFeedView* self = CPodcastFeedView::NewLC(aPodcastModel); |
|
55 |
CleanupStack::Pop( self ); |
|
56 |
return self; |
|
57 |
} |
|
58 |
||
59 |
CPodcastFeedView* CPodcastFeedView::NewLC(CPodcastModel& aPodcastModel) |
|
60 |
{ |
|
61 |
CPodcastFeedView* self = new ( ELeave ) CPodcastFeedView(aPodcastModel); |
|
62 |
CleanupStack::PushL( self ); |
|
63 |
self->ConstructL(); |
|
64 |
return self; |
|
65 |
} |
|
66 |
||
67 |
CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
68 |
{ |
|
69 |
iFirstActivateAfterLaunch = ETrue; |
|
70 |
} |
|
71 |
#define KAsterisk iEikonEnv->EikAppUi()->Application()->BitmapStoreName() |
|
72 |
void CPodcastFeedView::ConstructL() |
|
73 |
{ |
|
74 |
DP("CPodcastFeedView::ConstructL BEGIN"); |
|
75 |
//_LIT(KAsterisk, "*"); |
|
76 |
BaseConstructL(R_PODCAST_FEEDVIEW); |
|
77 |
iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED); |
|
78 |
iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT); |
|
79 |
CPodcastListView::ConstructL(); |
|
80 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
81 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
82 |
CleanupStack::PushL( icons ); |
|
83 |
||
84 |
CFbsBitmap* bitmap = NULL; |
|
85 |
CFbsBitmap* mask = NULL; |
|
86 |
// Load the bitmap for empty icon |
|
87 |
TFileName fname = KAsterisk; |
|
88 |
TParsePtr parser(fname); |
|
89 |
||
90 |
SetEmptyTextL(R_PODCAST_NO_FEEDS); |
|
91 |
||
92 |
// Load svg.-image and mask with a single call |
|
37
1644b7cd063e
Create Symbian3 branch with updates for SBSv2
Brendan Donegan <brendand@symbian.org>
parents:
36
diff
changeset
|
93 |
AknIconUtils::CreateIconL(bitmap, mask, iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
1644b7cd063e
Create Symbian3 branch with updates for SBSv2
Brendan Donegan <brendand@symbian.org>
parents:
36
diff
changeset
|
94 |
EMbmPodcastFeed, EMbmPodcastFeed_mask); |
2 | 95 |
|
96 |
/*bitmap = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40); |
|
97 |
* */ |
|
98 |
CleanupStack::PushL( bitmap ); |
|
99 |
// Load the mask for feed icon |
|
100 |
//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m ); |
|
101 |
CleanupStack::PushL( mask ); |
|
102 |
// Append the feed icon to icon array |
|
103 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
104 |
CleanupStack::Pop(2); // bitmap, mask |
|
105 |
||
106 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
107 |
CleanupStack::Pop(icons); // icons |
|
108 |
||
109 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
110 |
||
111 |
iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0)); |
|
112 |
TResourceReader reader; |
|
113 |
iCoeEnv->CreateResourceReaderLC(reader,R_FEEDVIEW_POPUP_MENU); |
|
114 |
iStylusPopupMenu->ConstructFromResourceL(reader); |
|
115 |
CleanupStack::PopAndDestroy(); |
|
116 |
||
117 |
iUpdater = CPodcastFeedViewUpdater::NewL(*this); |
|
118 |
DP("CPodcastFeedView::ConstructL END"); |
|
119 |
} |
|
120 |
||
121 |
CPodcastFeedView::~CPodcastFeedView() |
|
122 |
{ |
|
123 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
124 |
delete iFeedsFormat; |
|
125 |
delete iNeverUpdated; |
|
126 |
delete iStylusPopupMenu; |
|
127 |
delete iUpdater; |
|
128 |
} |
|
129 |
||
130 |
void CPodcastFeedView::UpdateItemL(TInt aIndex) |
|
131 |
{ |
|
132 |
_LIT(KPanicCategory, "CPodcastFeedView::UpdateItemL"); |
|
133 |
__ASSERT_DEBUG(iListContainer->IsVisible(), User::Panic(KPanicCategory, 0)); |
|
134 |
__ASSERT_ALWAYS(iItemIdArray.Count() > aIndex, User::Panic(KPanicCategory, 1)); |
|
135 |
||
136 |
const RFeedInfoArray& sortedItems = iPodcastModel.FeedEngine().GetSortedFeeds(); |
|
137 |
__ASSERT_ALWAYS(sortedItems.Count() > aIndex, User::Panic(KPanicCategory, 2)); |
|
138 |
||
139 |
// Update UID of for the feed at aIndex |
|
140 |
iItemIdArray[aIndex] = sortedItems[aIndex]->Uid(); |
|
141 |
||
142 |
// Prepare data to update the listbox item with |
|
143 |
FormatFeedInfoListBoxItemL(*sortedItems[aIndex], EFalse); |
|
144 |
||
145 |
// If nothing has changed, we are done here |
|
146 |
if (iListboxFormatbuffer == iItemArray->MdcaPoint(aIndex)) |
|
147 |
{ |
|
148 |
return; |
|
149 |
} |
|
150 |
||
151 |
// Something has changed, update the listbox item |
|
152 |
TListItemProperties itemProps; |
|
153 |
itemProps.SetDimmed(EFalse); |
|
154 |
iItemArray->Delete(aIndex); |
|
155 |
iItemArray->InsertL(aIndex, iListboxFormatbuffer); |
|
156 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps); |
|
157 |
// If item is visible, redraw it |
|
158 |
if (iListContainer->Listbox()->TopItemIndex() <= aIndex |
|
159 |
&& iListContainer->Listbox()->BottomItemIndex() >= aIndex) |
|
160 |
{ |
|
161 |
iListContainer->Listbox()->DrawItem(aIndex); |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
TUid CPodcastFeedView::Id() const |
|
166 |
{ |
|
167 |
return KUidPodcastFeedViewID; |
|
168 |
} |
|
169 |
||
170 |
void CPodcastFeedView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
171 |
TUid aCustomMessageId, |
|
172 |
const TDesC8& aCustomMessage) |
|
173 |
{ |
|
174 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
33
diff
changeset
|
175 |
|
25
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
176 |
if (aPrevViewId.iViewUid == KUidPodcastShowsViewID) |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
177 |
{ |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
178 |
// back key from shows view |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
179 |
iViewingShows = EFalse; |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
180 |
} |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
181 |
|
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
32
diff
changeset
|
182 |
UpdateListboxItemsL(); |
25
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
183 |
UpdateToolbar(); |
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
184 |
|
50 | 185 |
if (iFirstActivateAfterLaunch) |
186 |
{ |
|
187 |
iFirstActivateAfterLaunch = EFalse; |
|
188 |
} |
|
2 | 189 |
} |
190 |
||
191 |
void CPodcastFeedView::DoDeactivate() |
|
192 |
{ |
|
193 |
iUpdater->StopUpdate(); |
|
194 |
CPodcastListView::DoDeactivate(); |
|
195 |
} |
|
196 |
||
197 |
||
198 |
void CPodcastFeedView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
199 |
{ |
|
200 |
DP("CPodcastFeedView::HandleListBoxEventL BEGIN"); |
|
201 |
||
202 |
switch(aEventType) |
|
203 |
{ |
|
26 | 204 |
case EEventPenDownOnItem: |
205 |
DP("PEN DOWN"); |
|
206 |
break; |
|
207 |
||
37
1644b7cd063e
Create Symbian3 branch with updates for SBSv2
Brendan Donegan <brendand@symbian.org>
parents:
36
diff
changeset
|
208 |
#ifndef SYMBIAN1_UI |
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
19
diff
changeset
|
209 |
case EEventItemClicked: |
26 | 210 |
DP("SINGLE TAP"); |
37
1644b7cd063e
Create Symbian3 branch with updates for SBSv2
Brendan Donegan <brendand@symbian.org>
parents:
36
diff
changeset
|
211 |
#endif |
17
4bcc91e70483
Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents:
14
diff
changeset
|
212 |
case EEventEnterKeyPressed: |
2 | 213 |
case EEventItemDoubleClicked: |
17
4bcc91e70483
Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents:
14
diff
changeset
|
214 |
case EEventItemActioned: |
26 | 215 |
DP("DOUBLE TAP"); |
2 | 216 |
{ |
217 |
const RFeedInfoArray* sortedItems = NULL; |
|
218 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
219 |
sortedItems = &iPodcastModel.FeedEngine().GetSortedFeeds(); |
|
220 |
||
221 |
if(index >= 0 && index < sortedItems->Count()) |
|
222 |
{ |
|
223 |
iPodcastModel.ActiveShowList().Reset(); |
|
224 |
iPodcastModel.SetActiveFeedInfo((*sortedItems)[index]); |
|
25
ae65906c4347
Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents:
24
diff
changeset
|
225 |
iViewingShows = ETrue; |
2 | 226 |
AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
227 |
} |
|
228 |
} |
|
229 |
break; |
|
230 |
default: |
|
231 |
break; |
|
232 |
} |
|
233 |
DP("CPodcastFeedView::HandleListBoxEventL END"); |
|
234 |
} |
|
235 |
||
236 |
void CPodcastFeedView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
|
237 |
{ |
|
238 |
iUpdatingAllRunning = EFalse; |
|
239 |
UpdateToolbar(); |
|
240 |
} |
|
241 |
||
242 |
void CPodcastFeedView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid) |
|
243 |
{ |
|
244 |
// Update status text |
|
245 |
UpdateFeedInfoStatusL(aFeedUid, ETrue); |
|
246 |
||
247 |
UpdateToolbar(); |
|
248 |
} |
|
249 |
||
250 |
void CPodcastFeedView::FeedDownloadFinishedL(TFeedState aState,TUint aFeedUid, TInt aError) |
|
251 |
{ |
|
252 |
switch(aError) |
|
253 |
{ |
|
254 |
case KErrCouldNotConnect: |
|
255 |
{ |
|
256 |
if(aState == MFeedEngineObserver::EFeedManualUpdate) |
|
257 |
{ |
|
258 |
TBuf<KMaxMessageLength> message; |
|
259 |
iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
260 |
ShowErrorMessageL(message); |
2 | 261 |
} |
262 |
} |
|
263 |
break; |
|
264 |
default: // Do nothing |
|
265 |
break; |
|
266 |
} |
|
267 |
UpdateFeedInfoStatusL(aFeedUid, EFalse); |
|
268 |
} |
|
269 |
||
270 |
void CPodcastFeedView::UpdateFeedInfoStatusL(TUint aFeedUid, TBool aIsUpdating) |
|
271 |
{ |
|
272 |
const RFeedInfoArray& feeds = iPodcastModel.FeedEngine().GetSortedFeeds(); |
|
273 |
||
274 |
// Find the index for the feed i both the feed-array and the listbox |
|
275 |
TInt feedsIdx = KErrNotFound; |
|
276 |
TInt listboxIdx = KErrNotFound; |
|
277 |
for (TInt i = 0; i < feeds.Count(); i++) |
|
278 |
{ |
|
279 |
if (feeds[i]->Uid() == aFeedUid) |
|
280 |
{ |
|
281 |
feedsIdx = i; |
|
282 |
break; |
|
283 |
} |
|
284 |
} |
|
285 |
for (TInt j = 0; j < iItemIdArray.Count(); j++) |
|
286 |
{ |
|
287 |
if (iItemIdArray[j] == aFeedUid) |
|
288 |
{ |
|
289 |
listboxIdx = j; |
|
290 |
break; |
|
291 |
} |
|
292 |
} |
|
293 |
||
294 |
if (feedsIdx != KErrNotFound && listboxIdx != KErrNotFound) |
|
295 |
{ |
|
296 |
// TODO In the long run we want to move the sorting resposibility from |
|
297 |
// CFeedEngine to CPodcastFeedView. |
|
298 |
// Hackish fix to make sure the listbox is sorted. |
|
299 |
if (listboxIdx != feedsIdx) |
|
300 |
{ |
|
301 |
iItemIdArray.Remove(listboxIdx); |
|
302 |
iItemIdArray.InsertL(aFeedUid, feedsIdx); |
|
303 |
iItemArray->Delete(listboxIdx); |
|
304 |
iItemArray->InsertL(feedsIdx, KNullDesC); |
|
305 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
306 |
} |
|
307 |
// Update the listbox info |
|
308 |
UpdateFeedInfoDataL(feeds[feedsIdx], feedsIdx, aIsUpdating); |
|
309 |
//TODO sort the listbox after update |
|
310 |
} |
|
311 |
// Update all visible listbox items that are affected by sorting and update. |
|
312 |
TInt minIdx = Max(Min(feedsIdx, listboxIdx), iListContainer->Listbox()->TopItemIndex()); |
|
313 |
TInt maxIdx = Min(Max(feedsIdx, listboxIdx), iListContainer->Listbox()->BottomItemIndex()); |
|
314 |
for (TInt k = minIdx; k <= maxIdx; k++) |
|
315 |
{ |
|
316 |
iListContainer->Listbox()->DrawItem(k); |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
void CPodcastFeedView::FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating) |
|
321 |
{ |
|
322 |
TBuf<KMaxShortDateFormatSpec*2> updatedDate; |
|
323 |
TBuf<KMaxUnplayedFeedsLength> unplayedShows; |
|
324 |
TUint unplayedCount = 0; |
|
325 |
TUint showCount = 0; |
|
326 |
TInt iconIndex = EFeedIcon; |
|
327 |
||
328 |
if(aIsUpdating) |
|
329 |
{ |
|
330 |
iEikonEnv->ReadResourceL(updatedDate, R_PODCAST_FEEDS_IS_UPDATING); |
|
331 |
unplayedShows = KNullDesC(); |
|
332 |
} |
|
333 |
else |
|
334 |
{ |
|
335 |
iPodcastModel.FeedEngine().GetStatsByFeed(aFeedInfo.Uid(), showCount, unplayedCount); |
|
336 |
||
337 |
if (unplayedCount) { |
|
338 |
unplayedShows.Format(*iFeedsFormat, unplayedCount); |
|
339 |
} else { |
|
340 |
unplayedShows.Zero(); |
|
341 |
} |
|
342 |
||
343 |
if (aFeedInfo.LastUpdated().Int64() == 0) |
|
344 |
{ |
|
345 |
updatedDate.Copy(*iNeverUpdated); |
|
346 |
unplayedShows.Zero(); |
|
347 |
} |
|
348 |
else |
|
349 |
{ |
|
350 |
TTime now; |
|
351 |
TTimeIntervalHours interval; |
|
352 |
now.HomeTime(); |
|
353 |
now.HoursFrom(aFeedInfo.LastUpdated(), interval); |
|
354 |
if (interval.Int() < KADayInHours) |
|
355 |
{ |
|
356 |
aFeedInfo.LastUpdated().FormatL(updatedDate, KTimeFormat()); |
|
357 |
} |
|
358 |
else |
|
359 |
{ |
|
360 |
aFeedInfo.LastUpdated().FormatL(updatedDate, KDateFormatShort()); |
|
361 |
} |
|
362 |
} |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
363 |
|
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
364 |
if(aFeedInfo.LastError() != KErrNone) |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
365 |
{ |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
366 |
GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
367 |
} |
2 | 368 |
} |
369 |
CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray(); |
|
370 |
||
371 |
if (aFeedInfo.FeedIconIndex() != -1) { |
|
372 |
iconIndex = aFeedInfo.FeedIconIndex(); |
|
373 |
} else { |
|
374 |
if(aFeedInfo.FeedIcon() != NULL && |
|
375 |
aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 && |
|
376 |
aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0) |
|
377 |
{ |
|
378 |
// Hopefully temporary haxx to prevent double delete. I would prefer if |
|
379 |
// this could be solved with a little better design. |
|
380 |
CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap; |
|
381 |
CleanupStack::PushL(bmpCopy); |
|
382 |
bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle()); |
|
383 |
icons->AppendL( CGulIcon::NewL(bmpCopy, NULL)); |
|
384 |
CleanupStack::Pop(bmpCopy); |
|
385 |
iconIndex = icons->Count()-1; |
|
386 |
aFeedInfo.SetFeedIconIndex(iconIndex); |
|
387 |
} |
|
388 |
else { |
|
389 |
if(BaflUtils::FileExists(iPodcastModel.FsSession(), aFeedInfo.ImageFileName())) |
|
390 |
{ |
|
391 |
// If this fails, no reason to worry |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
392 |
TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this, aFeedInfo.Uid())); |
2 | 393 |
} |
394 |
} |
|
395 |
} |
|
396 |
||
397 |
if (unplayedShows.Length() > 0) { |
|
398 |
unplayedShows.Insert(0,_L(", ")); |
|
399 |
} |
|
400 |
||
401 |
iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); |
|
402 |
} |
|
403 |
||
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
404 |
void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle) |
2 | 405 |
{ |
406 |
if (aError == KErrNone) { |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
26
diff
changeset
|
407 |
UpdateFeedInfoStatusL(aHandle, EFalse); |
2 | 408 |
} |
409 |
} |
|
410 |
||
411 |
void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating ) |
|
412 |
{ |
|
413 |
TListItemProperties itemProps; |
|
414 |
itemProps.SetDimmed(aIsUpdating); |
|
415 |
FormatFeedInfoListBoxItemL(*aFeedInfo, aIsUpdating); |
|
416 |
||
417 |
TPtrC compareTo((*iItemArray)[aIndex]); |
|
418 |
||
419 |
if (iListboxFormatbuffer.Compare(compareTo) != 0) { |
|
420 |
iItemArray->Delete(aIndex); |
|
421 |
if(aIndex>= iItemArray->MdcaCount()) |
|
422 |
{ |
|
423 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
424 |
} |
|
425 |
else |
|
426 |
{ |
|
427 |
iItemArray->InsertL(aIndex, iListboxFormatbuffer); |
|
428 |
} |
|
429 |
} |
|
430 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps); |
|
431 |
} |
|
432 |
||
433 |
||
434 |
void CPodcastFeedView::UpdateListboxItemsL() |
|
435 |
{ |
|
436 |
// No reason to do any work if it isn't going to show.. |
|
437 |
if(!iListContainer->IsVisible()) |
|
438 |
{ |
|
439 |
return; |
|
440 |
} |
|
441 |
||
442 |
TInt nbrItems = iPodcastModel.FeedEngine().GetSortedFeeds().Count(); |
|
443 |
if (nbrItems > 0) |
|
444 |
{ |
|
445 |
// Ensure that there are as many elements in iItemIdArray as in FeedEngine |
|
446 |
while (iItemIdArray.Count() < nbrItems) |
|
447 |
{ |
|
448 |
iItemIdArray.AppendL(0); |
|
449 |
} |
|
450 |
while (iItemIdArray.Count() > nbrItems) |
|
451 |
{ |
|
452 |
iItemIdArray.Remove(iItemIdArray.Count() - 1); |
|
453 |
} |
|
454 |
||
455 |
// Ensure that there are as many elements in iItemArray as in FeedEngine |
|
456 |
while (iItemArray->Count() < nbrItems) |
|
457 |
{ |
|
458 |
iItemArray->AppendL(KNullDesC); |
|
459 |
TListItemProperties itemProps; |
|
460 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(iItemArray->Count() - 1, itemProps); |
|
461 |
} |
|
462 |
while (iItemArray->Count() > nbrItems) |
|
463 |
{ |
|
464 |
iItemArray->Delete(iItemArray->Count() - 1); |
|
465 |
} |
|
466 |
iUpdater->StartUpdate(nbrItems); |
|
467 |
} |
|
468 |
else |
|
469 |
{ |
|
470 |
// No feeds at all in the list , add dummy list item |
|
471 |
TBuf<KMaxFeedNameLength> itemName; |
|
472 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_FEEDS_NO_FEEDS); |
|
473 |
iItemArray->Reset(); |
|
474 |
iItemIdArray.Reset(); |
|
475 |
||
476 |
TListItemProperties itemProps; |
|
477 |
itemProps.SetDimmed(ETrue); |
|
478 |
itemProps.SetHiddenSelection(ETrue); |
|
479 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
|
480 |
} |
|
481 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
482 |
} |
|
483 |
||
484 |
/** |
|
485 |
* Command handling function intended for overriding by sub classes. |
|
486 |
* Default implementation is empty. |
|
487 |
* @param aCommand ID of the command to respond to. |
|
488 |
*/ |
|
489 |
void CPodcastFeedView::HandleCommandL(TInt aCommand) |
|
490 |
{ |
|
491 |
//CloseToolbarExtension(); |
|
492 |
switch(aCommand) |
|
493 |
{ |
|
494 |
case EPodcastHide: |
|
495 |
AppUi()->HandleCommandL(EEikCmdExit); |
|
496 |
break; |
|
497 |
case EPodcastAddFeed: |
|
498 |
HandleAddFeedL(); |
|
499 |
break; |
|
500 |
case EPodcastImportFeeds: |
|
501 |
HandleImportFeedsL(); |
|
502 |
break; |
|
503 |
case EPodcastExportFeeds: |
|
504 |
HandleExportFeedsL(); |
|
505 |
break; |
|
506 |
case EPodcastEditFeed: |
|
507 |
HandleEditFeedL(); |
|
508 |
break; |
|
509 |
case EPodcastDeleteFeedHardware: |
|
510 |
case EPodcastDeleteFeed: |
|
511 |
HandleRemoveFeedL(); |
|
512 |
break; |
|
513 |
case EPodcastUpdateAllFeeds: |
|
514 |
{ |
|
515 |
iUpdatingAllRunning = ETrue; |
|
516 |
iPodcastModel.FeedEngine().UpdateAllFeedsL(); |
|
517 |
UpdateToolbar(); |
|
518 |
}break; |
|
519 |
case EPodcastUpdateFeed: |
|
520 |
{ |
|
521 |
HandleUpdateFeedL(); |
|
522 |
}break; |
|
523 |
case EPodcastCancelUpdateAllFeeds: |
|
524 |
{ |
|
525 |
if(iUpdatingAllRunning) |
|
526 |
{ |
|
527 |
iUpdatingAllRunning = EFalse; |
|
528 |
iPodcastModel.FeedEngine().CancelUpdateAllFeeds(); |
|
529 |
} |
|
530 |
}break; |
|
531 |
case EAknSoftkeyExit: |
|
532 |
{ |
|
533 |
RShowInfoArray dlQueue; |
|
534 |
iPodcastModel.ShowEngine().GetShowsDownloadingL(dlQueue); |
|
535 |
TUint queueCount = dlQueue.Count(); |
|
536 |
dlQueue.ResetAndDestroy(); |
|
537 |
dlQueue.Close(); |
|
538 |
||
539 |
if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended()) |
|
540 |
{ |
|
541 |
TBuf<KMaxMessageLength> message; |
|
542 |
iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
543 |
if(ShowQueryMessageL(message)) |
2 | 544 |
{ |
545 |
// pass it on to AppUi, which will exit for us |
|
546 |
CPodcastListView::HandleCommandL(aCommand); |
|
547 |
} |
|
548 |
} |
|
549 |
else |
|
550 |
{ |
|
551 |
// nothing in queue, or downloading suspended |
|
552 |
CPodcastListView::HandleCommandL(aCommand); |
|
553 |
} |
|
554 |
} |
|
555 |
break; |
|
556 |
default: |
|
557 |
CPodcastListView::HandleCommandL(aCommand); |
|
558 |
break; |
|
559 |
} |
|
26 | 560 |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
561 |
iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping |
2 | 562 |
UpdateToolbar(); |
563 |
} |
|
564 |
||
13 | 565 |
void CPodcastFeedView::UpdateToolbar(TBool aVisible) |
2 | 566 |
{ |
567 |
CAknToolbar* toolbar = Toolbar(); |
|
568 |
||
569 |
if (toolbar) |
|
570 |
{ |
|
14
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
571 |
if (iListContainer->IsVisible()) { |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
572 |
toolbar->SetToolbarVisibility(aVisible); |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
573 |
} |
2 | 574 |
toolbar->HideItem(EPodcastUpdateAllFeeds, iUpdatingAllRunning, ETrue); |
575 |
toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iUpdatingAllRunning, ETrue ); |
|
576 |
toolbar->SetItemDimmed(EPodcastAddFeed, iUpdatingAllRunning, ETrue ); |
|
577 |
toolbar->SetItemDimmed(EPodcastSettings, iUpdatingAllRunning, ETrue ); |
|
578 |
} |
|
579 |
} |
|
580 |
||
581 |
void CPodcastFeedView::HandleAddFeedL() |
|
582 |
{ |
|
583 |
TBuf<KFeedUrlLength> url; |
|
584 |
url.Copy(_L("http://")); |
|
585 |
CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url); |
|
586 |
dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG); |
|
587 |
HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT); |
|
588 |
dlg->SetPromptL(*prompt); |
|
589 |
CleanupStack::PopAndDestroy(prompt); |
|
590 |
||
591 |
if(dlg->RunLD()) |
|
592 |
{ |
|
593 |
||
594 |
// if no :// we do a search |
|
595 |
if (url.Find(_L("://")) == KErrNotFound) |
|
596 |
{ |
|
597 |
HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING); |
|
598 |
ShowWaitDialogL(*waitText); |
|
599 |
CleanupStack::PopAndDestroy(waitText); |
|
600 |
||
601 |
iOpmlState = EOpmlSearching; |
|
602 |
iPodcastModel.FeedEngine().SearchForFeedL(url); |
|
603 |
} |
|
604 |
else |
|
605 |
{ |
|
606 |
PodcastUtils::FixProtocolsL(url); |
|
607 |
||
608 |
CFeedInfo* newFeedInfo = CFeedInfo::NewL(); |
|
609 |
CleanupStack::PushL(newFeedInfo); |
|
610 |
newFeedInfo->SetUrlL(url); |
|
611 |
newFeedInfo->SetTitleL(newFeedInfo->Url()); |
|
612 |
||
613 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo); |
|
614 |
||
615 |
if (added) |
|
616 |
{ |
|
617 |
UpdateListboxItemsL(); |
|
618 |
||
619 |
// ask if users wants to update it now |
|
620 |
TBuf<KMaxMessageLength> message; |
|
621 |
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:
26
diff
changeset
|
622 |
if(ShowQueryMessageL(message)) |
2 | 623 |
{ |
624 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
|
625 |
||
626 |
iPodcastModel.ActiveShowList().Reset(); |
|
627 |
iPodcastModel.SetActiveFeedInfo(info); |
|
628 |
AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
629 |
iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
|
630 |
} |
|
631 |
} |
|
632 |
else |
|
633 |
{ |
|
634 |
TBuf<KMaxMessageLength> message; |
|
635 |
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:
26
diff
changeset
|
636 |
ShowErrorMessageL(message); |
2 | 637 |
} |
638 |
||
639 |
CleanupStack::PopAndDestroy(newFeedInfo); |
|
640 |
} |
|
641 |
} |
|
642 |
} |
|
643 |
||
644 |
void CPodcastFeedView::HandleEditFeedL() |
|
645 |
{ |
|
646 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
647 |
||
648 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
649 |
{ |
|
650 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index]; |
|
651 |
||
652 |
TBuf<KFeedTitleLength> title; |
|
653 |
title.Copy(info->Title()); |
|
654 |
TBuf<KFeedUrlLength> url; |
|
655 |
url.Copy(info->Url()); |
|
656 |
CAknMultiLineDataQueryDialog *dlg = CAknMultiLineDataQueryDialog ::NewL(title, url); |
|
657 |
||
658 |
if (dlg->ExecuteLD(R_PODCAST_EDIT_FEED_DLG)) |
|
659 |
{ |
|
660 |
||
661 |
if(info->Url().Compare(url) != 0) |
|
662 |
{ |
|
663 |
TBuf<KMaxMessageLength> dlgMessage; |
|
664 |
iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE); |
|
665 |
||
666 |
// Ask the user if it is OK to remove all shows |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
667 |
if ( ShowQueryMessageL(dlgMessage)) |
2 | 668 |
{ |
669 |
PodcastUtils::FixProtocolsL(url); |
|
670 |
||
671 |
//----- HACK ---- // |
|
672 |
CFeedInfo* temp = CFeedInfo::NewLC(); |
|
673 |
temp->SetUrlL(url); |
|
674 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*temp); |
|
675 |
if (added) { |
|
676 |
// The Feed URL did not exist |
|
677 |
// Remove the temp entry so that the correct entry could be changed |
|
678 |
iPodcastModel.FeedEngine().RemoveFeedL(temp->Uid()); |
|
679 |
||
12 | 680 |
// we remove the existing feed |
681 |
iPodcastModel.FeedEngine().RemoveFeedL(info->Uid()); |
|
682 |
||
683 |
CFeedInfo* newFeed = CFeedInfo::NewLC(); |
|
684 |
newFeed->SetUrlL(url); |
|
685 |
newFeed->SetTitleL(title); |
|
686 |
||
687 |
iPodcastModel.FeedEngine().AddFeedL(*newFeed); |
|
688 |
CleanupStack::PopAndDestroy(newFeed); |
|
2 | 689 |
UpdateListboxItemsL(); |
690 |
} else { |
|
691 |
// the feed existed. Object deleted in AddFeed. |
|
692 |
TBuf<KMaxMessageLength> dlgMessage; |
|
693 |
iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
694 |
ShowErrorMessageL(dlgMessage); |
2 | 695 |
} |
696 |
CleanupStack::PopAndDestroy(temp); |
|
697 |
} |
|
698 |
} else { // no url change, maybe title? |
|
699 |
// Update the title |
|
700 |
if (info->Title().Compare(title) != 0) |
|
701 |
{ |
|
702 |
info->SetTitleL(title); |
|
703 |
info->SetCustomTitle(); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
704 |
iPodcastModel.FeedEngine().UpdateFeedL(info); |
2 | 705 |
UpdateListboxItemsL(); |
706 |
} |
|
707 |
} |
|
708 |
} |
|
709 |
} |
|
710 |
} |
|
711 |
||
712 |
void CPodcastFeedView::HandleRemoveFeedL() |
|
713 |
{ |
|
714 |
if(iListContainer->Listbox() != NULL) |
|
715 |
{ |
|
716 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
717 |
||
718 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
719 |
{ |
|
720 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]); |
|
721 |
TBuf<KMaxMessageLength> templ; |
|
722 |
TBuf<KMaxMessageLength> message; |
|
723 |
iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT); |
|
724 |
message.Format(templ, &info->Title()); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
725 |
if(ShowQueryMessageL(message)) |
2 | 726 |
{ |
727 |
iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]); |
|
728 |
iItemArray->Delete(index); |
|
729 |
iItemIdArray.Remove(index); |
|
730 |
iListContainer->Listbox()->HandleItemRemovalL(); |
|
731 |
iListContainer->Listbox()->DrawNow(); |
|
732 |
} |
|
733 |
} |
|
734 |
UpdateListboxItemsL(); |
|
735 |
} |
|
736 |
} |
|
737 |
||
738 |
void CPodcastFeedView::HandleUpdateFeedL() |
|
739 |
{ |
|
740 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
741 |
||
742 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
743 |
{ |
|
744 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index]; |
|
745 |
iPodcastModel.FeedEngine().UpdateFeedL(info->Uid()); |
|
746 |
} |
|
747 |
} |
|
748 |
||
749 |
void CPodcastFeedView::HandleImportFeedsL() |
|
750 |
{ |
|
751 |
CAknMemorySelectionDialog* memDlg = |
|
752 |
CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue); |
|
753 |
CleanupStack::PushL(memDlg); |
|
754 |
CAknMemorySelectionDialog::TMemory memory = |
|
755 |
CAknMemorySelectionDialog::EPhoneMemory; |
|
756 |
||
757 |
if (memDlg->ExecuteL(memory)) |
|
758 |
{ |
|
759 |
TFileName importName; |
|
760 |
||
761 |
if (memory==CAknMemorySelectionDialog::EMemoryCard) |
|
762 |
{ |
|
763 |
importName = PathInfo:: MemoryCardRootPath(); |
|
764 |
} |
|
765 |
else |
|
766 |
{ |
|
767 |
importName = PathInfo:: PhoneMemoryRootPath(); |
|
768 |
} |
|
769 |
||
770 |
CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal, R_PODCAST_IMPORT_PODCAST); |
|
771 |
CleanupStack::PushL(dlg); |
|
772 |
||
773 |
dlg->SetDefaultFolderL(importName); |
|
774 |
||
775 |
if(dlg->ExecuteL(importName)) |
|
776 |
{ |
|
777 |
if(importName.Length()>0) |
|
778 |
{ |
|
779 |
HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING); |
|
780 |
iOpmlState = EOpmlImporting; |
|
781 |
ShowWaitDialogL(*waitText); |
|
782 |
CleanupStack::PopAndDestroy(waitText); |
|
783 |
||
784 |
TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName)); |
|
785 |
||
786 |
if (err != KErrNone) { |
|
787 |
TBuf<KMaxMessageLength> message; |
|
788 |
iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
789 |
ShowErrorMessageL(message); |
2 | 790 |
} |
791 |
} |
|
792 |
||
793 |
} |
|
794 |
CleanupStack::PopAndDestroy(dlg); |
|
795 |
} |
|
796 |
CleanupStack::PopAndDestroy(memDlg); |
|
797 |
} |
|
798 |
||
799 |
void CPodcastFeedView::HandleExportFeedsL() |
|
800 |
{ |
|
801 |
CAknMemorySelectionDialog* memDlg = |
|
802 |
CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue); |
|
803 |
CleanupStack::PushL(memDlg); |
|
804 |
CAknMemorySelectionDialog::TMemory memory = |
|
805 |
CAknMemorySelectionDialog::EPhoneMemory; |
|
806 |
||
807 |
if (memDlg->ExecuteL(memory)) |
|
808 |
{ |
|
809 |
TFileName pathName; |
|
810 |
||
811 |
if (memory==CAknMemorySelectionDialog::EMemoryCard) |
|
812 |
{ |
|
813 |
pathName = PathInfo::MemoryCardRootPath(); |
|
814 |
} |
|
815 |
else |
|
816 |
{ |
|
817 |
pathName = PathInfo::PhoneMemoryRootPath(); |
|
818 |
} |
|
819 |
||
820 |
CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_EXPORT_FEEDS); |
|
821 |
CleanupStack::PushL(dlg); |
|
822 |
||
823 |
if(dlg->ExecuteL(pathName)) |
|
824 |
{ |
|
825 |
CAknFileNamePromptDialog *fileDlg = CAknFileNamePromptDialog::NewL(R_PODCAST_FILENAME_PROMPT_DIALOG); |
|
826 |
CleanupStack::PushL(fileDlg); |
|
827 |
fileDlg->SetPathL(pathName); |
|
828 |
TFileName fileName; |
|
829 |
if (fileDlg->ExecuteL(fileName) && fileName.Length() > 0) |
|
830 |
{ |
|
831 |
pathName.Append(fileName); |
|
832 |
TFileName temp; |
|
833 |
TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp)); |
|
834 |
BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, pathName); |
|
835 |
BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp); |
|
836 |
if (err == KErrNone) |
|
837 |
{ |
|
838 |
UpdateListboxItemsL(); |
|
839 |
TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count(); |
|
840 |
||
841 |
TBuf<KMaxMessageLength> message; |
|
842 |
TBuf<KMaxMessageLength> templ; |
|
843 |
iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS); |
|
844 |
message.Format(templ, numFeeds); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
845 |
ShowOkMessageL(message); |
2 | 846 |
} |
847 |
else |
|
848 |
{ |
|
849 |
TBuf<KMaxMessageLength> message; |
|
850 |
iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
851 |
ShowErrorMessageL(message); |
2 | 852 |
} |
853 |
} |
|
854 |
CleanupStack::PopAndDestroy(fileDlg); |
|
855 |
} |
|
856 |
CleanupStack::PopAndDestroy(dlg); |
|
857 |
} |
|
858 |
CleanupStack::PopAndDestroy(memDlg); |
|
859 |
} |
|
860 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
861 |
void CPodcastFeedView::CheckResumeDownloadL() |
2 | 862 |
{ |
863 |
// if there are shows queued for downloading, ask if we should resume now |
|
864 |
RShowInfoArray showsDownloading; |
|
865 |
iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading); |
|
866 |
||
867 |
if (showsDownloading.Count() > 0) |
|
868 |
{ |
|
869 |
TBuf<KMaxMessageLength> msg; |
|
870 |
iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT); |
|
871 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
872 |
if (ShowQueryMessageL(msg)) |
2 | 873 |
{ |
874 |
// need to suspend downloads before ResumeDownloadL will work :) |
|
875 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
876 |
// resume downloading if user says yes |
|
877 |
iPodcastModel.ShowEngine().ResumeDownloadsL(); |
|
878 |
} |
|
879 |
else |
|
880 |
{ |
|
881 |
// we disable downloading if user says no |
|
882 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
883 |
} |
|
884 |
} |
|
885 |
||
886 |
// if no shows in queue, we keep whichever state suspend is in |
|
887 |
showsDownloading.ResetAndDestroy(); |
|
888 |
} |
|
889 |
||
7 | 890 |
void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported) |
2 | 891 |
{ |
892 |
DP("CPodcastFeedView::OpmlParsingComplete BEGIN"); |
|
893 |
||
7 | 894 |
switch (aError) |
2 | 895 |
{ |
7 | 896 |
case KErrCouldNotConnect: |
2 | 897 |
{ |
898 |
TBuf<KMaxMessageLength> message; |
|
7 | 899 |
iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR); |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
900 |
ShowErrorMessageL(message); |
2 | 901 |
} |
902 |
break; |
|
7 | 903 |
case KErrNone: |
904 |
default: // we don't do more error handling here, just show 0 imported feeds |
|
905 |
switch (iOpmlState) |
|
906 |
{ |
|
907 |
case EOpmlIdle: |
|
908 |
break; |
|
909 |
case EOpmlImporting: |
|
2 | 910 |
{ |
7 | 911 |
UpdateListboxItemsL(); |
912 |
delete iWaitDialog; |
|
913 |
iOpmlState = EOpmlIdle; |
|
914 |
||
2 | 915 |
TBuf<KMaxMessageLength> message; |
7 | 916 |
TBuf<KMaxMessageLength> templ; |
917 |
iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS); |
|
918 |
message.Format(templ, aNumFeedsImported); |
|
919 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
920 |
if(ShowQueryMessageL(message)) |
7 | 921 |
{ |
922 |
HandleCommandL(EPodcastUpdateAllFeeds); |
|
923 |
} |
|
2 | 924 |
} |
7 | 925 |
break; |
926 |
case EOpmlSearching: |
|
927 |
delete iWaitDialog; |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
928 |
iWaitDialog = NULL; |
7 | 929 |
if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0) |
930 |
{ |
|
931 |
TBuf<KMaxMessageLength> message; |
|
932 |
iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
933 |
ShowErrorMessageL(message); |
7 | 934 |
} |
935 |
else |
|
936 |
{ |
|
937 |
AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID, TUid::Uid(0), KNullDesC8()); |
|
938 |
} |
|
939 |
iOpmlState = EOpmlIdle; |
|
940 |
break; |
|
941 |
default: |
|
942 |
break; |
|
943 |
} |
|
2 | 944 |
} |
945 |
||
946 |
DP("CPodcastFeedView::OpmlParsingComplete END"); |
|
947 |
} |
|
948 |
||
949 |
void CPodcastFeedView::DialogDismissedL(TInt /*aButtonId*/) |
|
950 |
{ |
|
951 |
iPodcastModel.FeedEngine().CancelUpdateAllFeeds(); |
|
952 |
} |
|
5 | 953 |
|
954 |
void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode) |
|
955 |
{ |
|
956 |
iEikonEnv->GetErrorText(aErrorMessage, aErrorCode); |
|
957 |
} |
|
8 | 958 |
|
959 |
void CPodcastFeedView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
|
960 |
{ |
|
961 |
DP("CPodcastListView::HandleLongTapEventL BEGIN"); |
|
26 | 962 |
|
8 | 963 |
if (iUpdatingAllRunning) { |
964 |
return; // we don't allow feed manipulation while update is running |
|
965 |
} |
|
26 | 966 |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
26
diff
changeset
|
967 |
iListContainer->SetLongTapDetectedL(ETrue); |
26 | 968 |
|
8 | 969 |
const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1 |
970 |
TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems( |
|
971 |
iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight; |
|
972 |
||
973 |
if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight) |
|
974 |
{ |
|
975 |
iStylusPopupMenu->ShowMenu(); |
|
976 |
iStylusPopupMenu->SetPosition(aPenEventLocation); |
|
977 |
} |
|
978 |
DP("CPodcastListView::HandleLongTapEventL END"); |
|
979 |
} |
|
45
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
980 |
|
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
981 |
TBool CPodcastFeedView::ViewingShows() |
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
982 |
{ |
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
983 |
return iViewingShows; |
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
984 |
} |