engine/src/FeedInfo.cpp
changeset 58 87cb33beeae2
parent 32 26a3f2dfba08
child 59 dc142c8740eb
--- a/engine/src/FeedInfo.cpp	Thu Mar 11 20:53:00 2010 +0100
+++ b/engine/src/FeedInfo.cpp	Wed Mar 31 08:19:35 2010 +0200
@@ -19,6 +19,9 @@
 #include "FeedInfo.h"
 #include <e32hashtab.h>
 #include <fbs.h>
+#include <bautils.h>
+#include <eikenv.h>
+_LIT(KMbmExtension, ".mbm");
 
 EXPORT_C CFeedInfo* CFeedInfo::NewL()
 	{
@@ -55,14 +58,13 @@
 		}
 	
 	copy->SetLastError(LastError());
-	copy->SetFeedIconIndex(FeedIconIndex());
+
 	CleanupStack::Pop(copy);
 	return copy;
 	}
 CFeedInfo::CFeedInfo()
 	{
 	iCustomTitle = EFalse;
-	iFeedIconIndex = -1;
 	}
 
 EXPORT_C CFeedInfo::~CFeedInfo()
@@ -191,12 +193,22 @@
 
 EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName)
 	{
+	TFileName cacheFileName;
+	
 	if (iImageFileName)
 		{
 		delete iImageFileName;
 		iImageFileName = NULL;
 		}
-	iImageFileName = aFileName.AllocL();	
+	iImageFileName = aFileName.AllocL();
+	TParsePtrC parser(*iImageFileName);
+	cacheFileName = parser.DriveAndPath();
+	cacheFileName.Append(parser.Name());
+	cacheFileName.Append(KMbmExtension());
+	if( BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) )
+		{
+		iFeedIcon = CEikonEnv::Static()->CreateBitmapL(cacheFileName, 0);
+		}	
 	}
 
 EXPORT_C TBool CFeedInfo::CustomTitle() const
@@ -229,17 +241,21 @@
 	iFeedIcon->Duplicate(aBitmapToClone->Handle());
 	}
 
-void CFeedInfo::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/)
-	{
-	
-	}
-
-EXPORT_C TInt CFeedInfo::FeedIconIndex() const
+void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/)
 	{
-	return iFeedIconIndex;
+		
+	if (aError == KErrNone && iImageFileName && iFeedIcon)
+		{
+		TFileName cacheFileName;
+	
+		TParsePtrC parser(*iImageFileName);
+		cacheFileName = parser.DriveAndPath();
+		cacheFileName.Append(parser.Name());
+		cacheFileName.Append(KMbmExtension());
+		if( !BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) )
+			{
+			iFeedIcon->Save(cacheFileName);
+			}
+			
+		}
 	}
-
-EXPORT_C void CFeedInfo::SetFeedIconIndex(TInt aIndex)
-	{
-	iFeedIconIndex = aIndex;
-	}