Merged Jakl's fix for 2716 3rded
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 19 Jul 2010 16:51:10 +0100
branch3rded
changeset 191 a452d138726a
parent 190 76b81233473a
child 193 2a527c27fd09
Merged Jakl's fix for 2716
application/group/Podcast.mmp
engine/inc/FeedEngine.h
engine/src/FeedEngine.cpp
--- a/application/group/Podcast.mmp	Mon Jul 19 16:34:15 2010 +0100
+++ b/application/group/Podcast.mmp	Mon Jul 19 16:51:10 2010 +0100
@@ -108,3 +108,4 @@
 LIBRARY  commonui.lib  // CDocumentHandler
 LIBRARY estlib.lib
 //LIBRARY libc.lib
+LIBRARY centralrepository.lib
--- a/engine/inc/FeedEngine.h	Mon Jul 19 16:34:15 2010 +0100
+++ b/engine/inc/FeedEngine.h	Mon Jul 19 16:51:10 2010 +0100
@@ -29,6 +29,7 @@
 #include "FeedEngineObserver.h"
 #include "FeedTimer.h"
 #include "sqlite3.h"
+#include <centralrepository.h>
 
 class CPodcastModel;
 class COpmlParser;
@@ -54,6 +55,7 @@
 	ESearching
 };
 
+
 class CFeedEngine : public CBase, public MHttpClientObserver, public MFeedParserObserver
 {
 public:
@@ -95,6 +97,7 @@
 
 	IMPORT_C void OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded);
 	void NotifyFeedUpdateComplete(TInt aFeedUid, TInt aError);
+	
 protected:
 	
 	static TInt CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b);
@@ -155,6 +158,9 @@
     TBool newFeed;
     TUint showsAdded;
     
+    // offline mode detection
+    CRepository* iRepository;
+    
     sqlite3& iDB;
     
     TBuf<KDefaultSQLDataBufferLength> iSqlBuffer;
--- a/engine/src/FeedEngine.cpp	Mon Jul 19 16:34:15 2010 +0100
+++ b/engine/src/FeedEngine.cpp	Mon Jul 19 16:51:10 2010 +0100
@@ -27,9 +27,13 @@
 #include "PodcastUtils.h"
 #include <utf.h>
 #include "Podcatcher.pan"
+#include <centralrepository.h>
+#include <ProfileEngineSDKCRKeys.h>
+
 
 _LIT(KFeedParseStorePath, "feeds\\");
 
+
 CFeedEngine* CFeedEngine::NewL(CPodcastModel& aPodcastModel)
 	{
 	CFeedEngine* self = new (ELeave) CFeedEngine(aPodcastModel);
@@ -80,6 +84,10 @@
     	TRAP_IGNORE(ImportFeedsL(importFile));
 		}
     
+    
+    // offline profile support
+    iRepository = CRepository::NewL( KCRUidProfileEngine );
+    
 	RunFeedTimer();
 	}
 
@@ -102,6 +110,8 @@
 	delete iParser;
 	delete iFeedClient;
 	delete iOpmlParser;
+	//
+	delete iRepository;
 	}
 
 /**
@@ -148,9 +158,22 @@
 		{
 		User::Leave(KErrInUse);
 		}
-
+	// check for offline profile, done by polling here, perhpas CenRep notifier woudl be better
+	TInt currentProfileId = 0; // general profile
+	TBool isOfflineProfile = EFalse;
+	// Get ID of current profile
+	if(KErrNone == iRepository->Get( KProEngActiveProfile, currentProfileId ) ) // better to assume online then leave if CRep fails
+		{
+		// Check value to determine the active profile if no error
+		if ( 5 == currentProfileId)
+			{
+			// current profile is the offline profile
+			isOfflineProfile = ETrue;
+			}
+	    }
+	//
 	iAutoUpdatedInitiator = aAutoUpdate;
-	if (iFeedsUpdating.Count() > 0)
+	if ((iFeedsUpdating.Count() > 0) || (isOfflineProfile)) // cancel update if in offline mode
 		{
 		DP("Cancelling update");
 		iFeedClient->Stop();