changeset 84 | fbb6c20a24b5 |
parent 77 | 6284a24658d6 |
child 89 | 9d854792013a |
82:c70a6524a236 | 84:fbb6c20a24b5 |
---|---|
142 } |
142 } |
143 } |
143 } |
144 |
144 |
145 EXPORT_C void CFeedEngine::UpdateAllFeedsL(TBool aAutoUpdate) |
145 EXPORT_C void CFeedEngine::UpdateAllFeedsL(TBool aAutoUpdate) |
146 { |
146 { |
147 if (iClientState != EIdle) |
|
148 { |
|
149 User::Leave(KErrInUse); |
|
150 } |
|
151 |
|
147 iAutoUpdatedInitiator = aAutoUpdate; |
152 iAutoUpdatedInitiator = aAutoUpdate; |
148 if (iFeedsUpdating.Count() > 0) |
153 if (iFeedsUpdating.Count() > 0) |
149 { |
154 { |
150 DP("Cancelling update"); |
155 DP("Cancelling update"); |
151 iFeedClient->Stop(); |
156 iFeedClient->Stop(); |
173 } |
178 } |
174 |
179 |
175 void CFeedEngine::UpdateNextFeedL() |
180 void CFeedEngine::UpdateNextFeedL() |
176 { |
181 { |
177 DP1("UpdateNextFeed. %d feeds left to update", iFeedsUpdating.Count()); |
182 DP1("UpdateNextFeed. %d feeds left to update", iFeedsUpdating.Count()); |
183 |
|
184 if (iClientState != EIdle) |
|
185 { |
|
186 User::Leave(KErrInUse); |
|
187 } |
|
178 |
188 |
179 // reset active feed, will be set again in UpdateFeedL if needed |
189 // reset active feed, will be set again in UpdateFeedL if needed |
180 iActiveFeed = NULL; |
190 iActiveFeed = NULL; |
181 |
191 |
182 if (iFeedsUpdating.Count() > 0) |
192 if (iFeedsUpdating.Count() > 0) |
227 |
237 |
228 iCancelRequested = EFalse; |
238 iCancelRequested = EFalse; |
229 |
239 |
230 if (iActiveFeed->LastUpdated() == 0) |
240 if (iActiveFeed->LastUpdated() == 0) |
231 { |
241 { |
232 iCatchupMode = ETrue; |
242 newFeed = ETrue; |
233 iCatchupCounter = 0; |
243 } |
234 } |
244 |
245 showsAdded = 0; |
|
235 |
246 |
236 iActiveFeed->SetLastError(KErrNone); |
247 iActiveFeed->SetLastError(KErrNone); |
237 DBUpdateFeedL(*iActiveFeed); |
248 DBUpdateFeedL(*iActiveFeed); |
238 |
249 |
239 iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); |
250 iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); |
271 PodcastUtils::CleanHtmlL(ptr); |
282 PodcastUtils::CleanHtmlL(ptr); |
272 |
283 |
273 aItem.SetDescriptionL(*description); |
284 aItem.SetDescriptionL(*description); |
274 CleanupStack::PopAndDestroy(description); |
285 CleanupStack::PopAndDestroy(description); |
275 |
286 |
276 if (iCatchupMode) { |
287 if (newFeed) { |
277 // in catchup mode, we let one show be unplayed |
288 // for new feeds, set all shows played |
278 if (++iCatchupCounter > 1) { |
289 aItem.SetPlayState(EPlayed); |
279 aItem.SetPlayState(EPlayed); |
290 // except the first one |
291 if (showsAdded == 0) { |
|
292 aItem.SetPlayState(ENeverPlayed); |
|
280 } |
293 } |
281 } |
294 } |
282 |
295 |
283 TRAPD(err, iPodcastModel.ShowEngine().AddShowL(aItem)); |
296 TRAPD(err, iPodcastModel.ShowEngine().AddShowL(aItem)); |
284 |
297 |
285 if (err == KErrNone && aItem.PlayState() == ENeverPlayed && |
298 if (err == KErrNone && aItem.PlayState() == ENeverPlayed && |
286 iPodcastModel.SettingsEngine().DownloadAutomatically()) |
299 iPodcastModel.SettingsEngine().DownloadAutomatically()) |
287 { |
300 { |
288 iPodcastModel.ShowEngine().AddDownloadL(aItem); |
301 iPodcastModel.ShowEngine().AddDownloadL(aItem); |
289 } |
302 } |
303 |
|
304 showsAdded++; |
|
290 } |
305 } |
291 |
306 |
292 void CFeedEngine::GetFeedImageL(CFeedInfo *aFeedInfo) |
307 void CFeedEngine::GetFeedImageL(CFeedInfo *aFeedInfo) |
293 { |
308 { |
294 DP("GetFeedImage"); |
309 DP("GetFeedImage"); |
361 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
376 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
362 TPtr descPtr(descBuf->Des()); |
377 TPtr descPtr(descBuf->Des()); |
363 descPtr.Copy(aItem.Description()); |
378 descPtr.Copy(aItem.Description()); |
364 PodcastUtils::SQLEncode(descPtr); |
379 PodcastUtils::SQLEncode(descPtr); |
365 |
380 |
366 _LIT(KSqlStatement, "insert into feeds (url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%S\", \"%S\", \"%Ld\", \"%Ld\", \"%u\", \"%u\", \"%u\", \"%d\")"); |
381 _LIT(KSqlStatement, "insert into feeds (url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror)" |
382 " values (\"%S\",\"%S\", \"%S\", \"%S\", \"%S\", \"%S\", \"%Ld\", \"%Ld\", \"%u\", \"%u\", \"%u\", \"%d\")"); |
|
367 iSqlBuffer.Format(KSqlStatement, |
383 iSqlBuffer.Format(KSqlStatement, |
368 &aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
384 &aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
369 aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError()); |
385 aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError()); |
370 |
386 |
371 CleanupStack::PopAndDestroy(descBuf); |
387 CleanupStack::PopAndDestroy(descBuf); |
473 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
489 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
474 TPtr descPtr(descBuf->Des()); |
490 TPtr descPtr(descBuf->Des()); |
475 descPtr.Copy(aItem.Description()); |
491 descPtr.Copy(aItem.Description()); |
476 PodcastUtils::SQLEncode(descPtr); |
492 PodcastUtils::SQLEncode(descPtr); |
477 |
493 |
478 _LIT(KSqlStatement, "update feeds set url=\"%S\", title=\"%S\", description=\"%S\", imageurl=\"%S\", imagefile=\"%S\",link=\"%S\", built=\"%Lu\", lastupdated=\"%Lu\", feedtype=\"%u\", customtitle=\"%u\", lasterror=\"%d\" where uid=\"%u\""); |
494 _LIT(KSqlStatement, "update feeds set url=\"%S\", title=\"%S\", description=\"%S\", imageurl=\"%S\", imagefile=\"%S\"," \ |
495 "link=\"%S\", built=\"%Lu\", lastupdated=\"%Lu\", feedtype=\"%u\", customtitle=\"%u\", lasterror=\"%d\" where uid=\"%u\""); |
|
479 iSqlBuffer.Format(KSqlStatement, |
496 iSqlBuffer.Format(KSqlStatement, |
480 &aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
497 &aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
481 aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.Uid()); |
498 aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.Uid()); |
482 |
499 |
483 CleanupStack::PopAndDestroy(descBuf); |
500 CleanupStack::PopAndDestroy(descBuf); |