engine/src/FeedEngine.cpp
branchsymbian1
changeset 83 daef3a71bac5
parent 67 9c24c921ec35
child 88 f4b512d870e8
equal deleted inserted replaced
80:ea2321db6cb6 83:daef3a71bac5
   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");