engine/src/FeedEngine.cpp
branchsymbian1
changeset 41 56821195bd44
parent 36 e010fc411ddc
child 53 b778853e60a7
child 65 bcd88ba95046
equal deleted inserted replaced
40:bf37b9711f0a 41:56821195bd44
   206 		{
   206 		{
   207 		iCatchupMode = ETrue;
   207 		iCatchupMode = ETrue;
   208 		}
   208 		}
   209 	
   209 	
   210 	iActiveFeed->SetLastError(KErrNone);
   210 	iActiveFeed->SetLastError(KErrNone);
   211 	DBUpdateFeed(*iActiveFeed);
   211 	DBUpdateFeedL(*iActiveFeed);
   212 	
   212 	
   213 	iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ());
   213 	iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ());
   214 	_LIT(KFileNameFormat, "%lu.xml");
   214 	_LIT(KFileNameFormat, "%lu.xml");
   215 	iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid);
   215 	iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid);
   216 	
   216 	
   425 			}
   425 			}
   426 		}
   426 		}
   427 	return EFalse;	
   427 	return EFalse;	
   428 	}
   428 	}
   429 
   429 
   430 TBool CFeedEngine::DBUpdateFeed(const CFeedInfo &aItem)
   430 TBool CFeedEngine::DBUpdateFeedL(const CFeedInfo &aItem)
   431 	{
   431 	{
   432 	DP2("CFeedEngine::DBUpdateFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
   432 	DP2("CFeedEngine::DBUpdateFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
   433 	
   433 	
   434 	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
   434 	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
   435 	TPtr titlePtr(titleBuf->Des());
   435 	TPtr titlePtr(titleBuf->Des());
   515 				{
   515 				{
   516 				TTime time;
   516 				TTime time;
   517 				time.HomeTime();
   517 				time.HomeTime();
   518 				iActiveFeed->SetLastUpdated(time);
   518 				iActiveFeed->SetLastUpdated(time);
   519 				iActiveFeed->SetLastError(aError);
   519 				iActiveFeed->SetLastError(aError);
   520 				NotifyFeedUpdateComplete(aError);
   520 				NotifyFeedUpdateCompleteL(aError);
   521 				}
   521 				}
   522 			break;
   522 			break;
   523 		case EUpdatingFeed: 
   523 		case EUpdatingFeed: 
   524 		{
   524 		{
   525 		// Parse the feed. We need to trap this call since it could leave and then
   525 		// Parse the feed. We need to trap this call since it could leave and then
   585 					}
   585 					}
   586 				iCancelRequested = EFalse;
   586 				iCancelRequested = EFalse;
   587 				}break;
   587 				}break;
   588 			}
   588 			}
   589 		
   589 		
   590 			NotifyFeedUpdateComplete(aError);
   590 			NotifyFeedUpdateCompleteL(aError);
   591 	
   591 	
   592 			// we will wait until the image has been downloaded to start the next feed update.
   592 			// we will wait until the image has been downloaded to start the next feed update.
   593 			if (iClientState == EIdle)
   593 			if (iClientState == EIdle)
   594 				{
   594 				{
   595 				UpdateNextFeedL();	
   595 				UpdateNextFeedL();	
   598 		case EUpdatingImage:
   598 		case EUpdatingImage:
   599 			{
   599 			{
   600 			// change client state to not updating
   600 			// change client state to not updating
   601 			iClientState = EIdle;
   601 			iClientState = EIdle;
   602 	
   602 	
   603 			NotifyFeedUpdateComplete(aError);
   603 			NotifyFeedUpdateCompleteL(aError);
   604 			UpdateNextFeedL();
   604 			UpdateNextFeedL();
   605 			}break;
   605 			}break;
   606 		case ESearching: 
   606 		case ESearching: 
   607 			{
   607 			{
   608 			iClientState = EIdle;
   608 			iClientState = EIdle;
   618 				DP("Parsing OPML");
   618 				DP("Parsing OPML");
   619 				iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
   619 				iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
   620 				}
   620 				}
   621 			else
   621 			else
   622 				{
   622 				{
   623 				NotifyOpmlParsingComplete(aError, 0);
   623 				NotifyOpmlParsingCompleteL(aError, 0);
   624 				}
   624 				}
   625 			
   625 			
   626 			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
   626 			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
   627 			}break;
   627 			}break;
   628 		}
   628 		}
   629 	DP("CFeedEngine::CompleteL END");
   629 	DP("CFeedEngine::CompleteL END");
   630 	}
   630 	}
   631 
   631 
   632 void CFeedEngine::NotifyFeedUpdateComplete(TInt aError)
   632 void CFeedEngine::NotifyFeedUpdateCompleteL(TInt aError)
   633 	{
   633 	{
   634 	DP("CFeedEngine::NotifyFeedUpdateComplete");
   634 	DP("CFeedEngine::NotifyFeedUpdateComplete");
   635 	DBUpdateFeed(*iActiveFeed);
   635 	DBUpdateFeedL(*iActiveFeed);
   636 	for (TInt i=0;i<iObservers.Count();i++) 
   636 	for (TInt i=0;i<iObservers.Count();i++) 
   637 		{
   637 		{
   638 		TRAP_IGNORE(iObservers[i]->FeedDownloadFinishedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid(), aError));
   638 		TRAP_IGNORE(iObservers[i]->FeedDownloadFinishedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid(), aError));
   639 		}
   639 		}
   640 	}
   640 	}
  1011 	}
  1011 	}
  1012 	
  1012 	
  1013 	return feedInfo;
  1013 	return feedInfo;
  1014 }
  1014 }
  1015 
  1015 
  1016 EXPORT_C void CFeedEngine::UpdateFeed(CFeedInfo *aItem)
  1016 EXPORT_C void CFeedEngine::UpdateFeedL(CFeedInfo *aItem)
  1017 	{
  1017 	{
  1018 	DBUpdateFeed(*aItem);
  1018 	DBUpdateFeedL(*aItem);
  1019 	}
  1019 	}
  1020 
  1020 
  1021 EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString)
  1021 EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString)
  1022 	{
  1022 	{
  1023 	DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString);
  1023 	DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString);
  1069 	{
  1069 	{
  1070 	return iSearchResults;
  1070 	return iSearchResults;
  1071 	}
  1071 	}
  1072 
  1072 
  1073 
  1073 
  1074 EXPORT_C void CFeedEngine::OpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
  1074 EXPORT_C void CFeedEngine::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded)
  1075 	{
  1075 	{
  1076 	NotifyOpmlParsingComplete(aError, aNumFeedsAdded);
  1076 	NotifyOpmlParsingCompleteL(aError, aNumFeedsAdded);
  1077 	}
  1077 	}
  1078 
  1078 
  1079 void CFeedEngine::NotifyOpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
  1079 void CFeedEngine::NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded)
  1080 	{
  1080 	{
  1081 	for (TInt i=0;i<iObservers.Count();i++) 
  1081 	for (TInt i=0;i<iObservers.Count();i++) 
  1082 		{
  1082 		{
  1083 		iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded);
  1083 		iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded);
  1084 		}
  1084 		}