engine/src/FeedEngine.cpp
changeset 187 45e21fd808cd
parent 172 c2a99fe1afd0
child 220 cc381e129dd5
equal deleted inserted replaced
185:92eadaba67e6 187:45e21fd808cd
    25 #include <e32hashtab.h>
    25 #include <e32hashtab.h>
    26 #include "OpmlParser.h"
    26 #include "OpmlParser.h"
    27 #include "PodcastUtils.h"
    27 #include "PodcastUtils.h"
    28 #include <utf.h>
    28 #include <utf.h>
    29 #include "Podcatcher.pan"
    29 #include "Podcatcher.pan"
       
    30 #include <centralrepository.h>
       
    31 #include <ProfileEngineSDKCRKeys.h>
       
    32 
    30 
    33 
    31 _LIT(KFeedParseStorePath, "feeds\\");
    34 _LIT(KFeedParseStorePath, "feeds\\");
       
    35 
    32 
    36 
    33 CFeedEngine* CFeedEngine::NewL(CPodcastModel& aPodcastModel)
    37 CFeedEngine* CFeedEngine::NewL(CPodcastModel& aPodcastModel)
    34 	{
    38 	{
    35 	CFeedEngine* self = new (ELeave) CFeedEngine(aPodcastModel);
    39 	CFeedEngine* self = new (ELeave) CFeedEngine(aPodcastModel);
    36 	CleanupStack::PushL(self);
    40 	CleanupStack::PushL(self);
    78     if (BaflUtils::FileExists(iPodcastModel.FsSession(), importFile)) {
    82     if (BaflUtils::FileExists(iPodcastModel.FsSession(), importFile)) {
    79     	DP("Importing feeds");
    83     	DP("Importing feeds");
    80     	TRAP_IGNORE(ImportFeedsL(importFile));
    84     	TRAP_IGNORE(ImportFeedsL(importFile));
    81 		}
    85 		}
    82     
    86     
       
    87     
       
    88     // offline profile support
       
    89     iRepository = CRepository::NewL( KCRUidProfileEngine );
       
    90     
    83 	RunFeedTimer();
    91 	RunFeedTimer();
    84 	}
    92 	}
    85 
    93 
    86 CFeedEngine::CFeedEngine(CPodcastModel& aPodcastModel)
    94 CFeedEngine::CFeedEngine(CPodcastModel& aPodcastModel)
    87 		: iClientState(EIdle),
    95 		: iClientState(EIdle),
   100 	iSearchResults.ResetAndDestroy();
   108 	iSearchResults.ResetAndDestroy();
   101 	
   109 	
   102 	delete iParser;
   110 	delete iParser;
   103 	delete iFeedClient;
   111 	delete iFeedClient;
   104 	delete iOpmlParser;
   112 	delete iOpmlParser;
       
   113 	//
       
   114 	delete iRepository;
   105 	}
   115 	}
   106 
   116 
   107 /**
   117 /**
   108  * Returns the current internal state of the feed engine4
   118  * Returns the current internal state of the feed engine4
   109  */
   119  */
   146 	{
   156 	{
   147 	if (iClientState != EIdle)
   157 	if (iClientState != EIdle)
   148 		{
   158 		{
   149 		User::Leave(KErrInUse);
   159 		User::Leave(KErrInUse);
   150 		}
   160 		}
   151 
   161 	// check for offline profile, done by polling here, perhpas CenRep notifier woudl be better
       
   162 	TInt currentProfileId = 0; // general profile
       
   163 	TBool isOfflineProfile = EFalse;
       
   164 	// Get ID of current profile
       
   165 	if(KErrNone == iRepository->Get( KProEngActiveProfile, currentProfileId ) ) // better to assume online then leave if CRep fails
       
   166 		{
       
   167 		// Check value to determine the active profile if no error
       
   168 		if ( 5 == currentProfileId)
       
   169 			{
       
   170 			// current profile is the offline profile
       
   171 			isOfflineProfile = ETrue;
       
   172 			}
       
   173 	    }
       
   174 	//
   152 	iAutoUpdatedInitiator = aAutoUpdate;
   175 	iAutoUpdatedInitiator = aAutoUpdate;
   153 	if (iFeedsUpdating.Count() > 0)
   176 	if ((iFeedsUpdating.Count() > 0) || (isOfflineProfile)) // cancel update if in offline mode
   154 		{
   177 		{
   155 		DP("Cancelling update");
   178 		DP("Cancelling update");
   156 		iFeedClient->Stop();
   179 		iFeedClient->Stop();
   157 		iFeedsUpdating.Reset();
   180 		iFeedsUpdating.Reset();
   158 		return;
   181 		return;