engine/src/FeedEngine.cpp
changeset 35 66c5303f3610
parent 8 aab3aa4acdd6
child 36 e010fc411ddc
equal deleted inserted replaced
30:7bca37ba5fa9 35:66c5303f3610
   420 			}
   420 			}
   421 		}
   421 		}
   422 	return EFalse;	
   422 	return EFalse;	
   423 	}
   423 	}
   424 
   424 
   425 TBool CFeedEngine::DBUpdateFeed(const CFeedInfo &aItem)
   425 TBool CFeedEngine::DBUpdateFeedL(const CFeedInfo &aItem)
   426 	{
   426 	{
   427 	DP2("CFeedEngine::DBUpdateFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
   427 	DP2("CFeedEngine::DBUpdateFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
   428 	
   428 	
   429 	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
   429 	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
   430 	TPtr titlePtr(titleBuf->Des());
   430 	TPtr titlePtr(titleBuf->Des());
   510 				{
   510 				{
   511 				TTime time;
   511 				TTime time;
   512 				time.HomeTime();
   512 				time.HomeTime();
   513 				iActiveFeed->SetLastUpdated(time);
   513 				iActiveFeed->SetLastUpdated(time);
   514 				iActiveFeed->SetLastError(aError);
   514 				iActiveFeed->SetLastError(aError);
   515 				NotifyFeedUpdateComplete(aError);
   515 				NotifyFeedUpdateCompleteL(aError);
   516 				}
   516 				}
   517 			break;
   517 			break;
   518 		case EUpdatingFeed: 
   518 		case EUpdatingFeed: 
   519 		{
   519 		{
   520 		// Parse the feed. We need to trap this call since it could leave and then
   520 		// Parse the feed. We need to trap this call since it could leave and then
   577 						}
   577 						}
   578 					}
   578 					}
   579 				}break;
   579 				}break;
   580 			}
   580 			}
   581 		
   581 		
   582 			NotifyFeedUpdateComplete(aError);
   582 			NotifyFeedUpdateCompleteL(aError);
   583 	
   583 	
   584 			// we will wait until the image has been downloaded to start the next feed update.
   584 			// we will wait until the image has been downloaded to start the next feed update.
   585 			if (iClientState == EIdle)
   585 			if (iClientState == EIdle)
   586 				{
   586 				{
   587 				UpdateNextFeedL();	
   587 				UpdateNextFeedL();	
   590 		case EUpdatingImage:
   590 		case EUpdatingImage:
   591 			{
   591 			{
   592 			// change client state to not updating
   592 			// change client state to not updating
   593 			iClientState = EIdle;
   593 			iClientState = EIdle;
   594 	
   594 	
   595 			NotifyFeedUpdateComplete(aError);
   595 			NotifyFeedUpdateCompleteL(aError);
   596 			UpdateNextFeedL();
   596 			UpdateNextFeedL();
   597 			}break;
   597 			}break;
   598 		case ESearching: 
   598 		case ESearching: 
   599 			{
   599 			{
   600 			iClientState = EIdle;
   600 			iClientState = EIdle;
   610 				DP("Parsing OPML");
   610 				DP("Parsing OPML");
   611 				iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
   611 				iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
   612 				}
   612 				}
   613 			else
   613 			else
   614 				{
   614 				{
   615 				NotifyOpmlParsingComplete(aError, 0);
   615 				NotifyOpmlParsingCompleteL(aError, 0);
   616 				}
   616 				}
   617 			
   617 			
   618 			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
   618 			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
   619 			}break;
   619 			}break;
   620 		}
   620 		}
   621 	DP("CFeedEngine::CompleteL END");
   621 	DP("CFeedEngine::CompleteL END");
   622 	}
   622 	}
   623 
   623 
   624 void CFeedEngine::NotifyFeedUpdateComplete(TInt aError)
   624 void CFeedEngine::NotifyFeedUpdateCompleteL(TInt aError)
   625 	{
   625 	{
   626 	DP("CFeedEngine::NotifyFeedUpdateComplete");
   626 	DP("CFeedEngine::NotifyFeedUpdateComplete");
   627 	DBUpdateFeed(*iActiveFeed);
   627 	DBUpdateFeedL(*iActiveFeed);
   628 	for (TInt i=0;i<iObservers.Count();i++) 
   628 	for (TInt i=0;i<iObservers.Count();i++) 
   629 		{
   629 		{
   630 		TRAP_IGNORE(iObservers[i]->FeedDownloadFinishedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid(), aError));
   630 		TRAP_IGNORE(iObservers[i]->FeedDownloadFinishedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid(), aError));
   631 		}
   631 		}
   632 	}
   632 	}
  1003 	}
  1003 	}
  1004 	
  1004 	
  1005 	return feedInfo;
  1005 	return feedInfo;
  1006 }
  1006 }
  1007 
  1007 
  1008 EXPORT_C void CFeedEngine::UpdateFeed(CFeedInfo *aItem)
  1008 EXPORT_C void CFeedEngine::UpdateFeedL(CFeedInfo *aItem)
  1009 	{
  1009 	{
  1010 	DBUpdateFeed(*aItem);
  1010 	DBUpdateFeedL(*aItem);
  1011 	}
  1011 	}
  1012 
  1012 
  1013 EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString)
  1013 EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString)
  1014 	{
  1014 	{
  1015 	DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString);
  1015 	DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString);
  1061 	{
  1061 	{
  1062 	return iSearchResults;
  1062 	return iSearchResults;
  1063 	}
  1063 	}
  1064 
  1064 
  1065 
  1065 
  1066 EXPORT_C void CFeedEngine::OpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
  1066 EXPORT_C void CFeedEngine::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded)
  1067 	{
  1067 	{
  1068 	NotifyOpmlParsingComplete(aError, aNumFeedsAdded);
  1068 	NotifyOpmlParsingCompleteL(aError, aNumFeedsAdded);
  1069 	}
  1069 	}
  1070 
  1070 
  1071 void CFeedEngine::NotifyOpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
  1071 void CFeedEngine::NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded)
  1072 	{
  1072 	{
  1073 	for (TInt i=0;i<iObservers.Count();i++) 
  1073 	for (TInt i=0;i<iObservers.Count();i++) 
  1074 		{
  1074 		{
  1075 		iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded);
  1075 		iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded);
  1076 		}
  1076 		}