engine/src/FeedInfo.cpp
changeset 63 a8538f50e2ba
parent 60 bbf5c5204844
child 64 b52f6033af15
equal deleted inserted replaced
62:c06c2a75bb57 63:a8538f50e2ba
    15 * Description:
    15 * Description:
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include "FeedInfo.h"
    19 #include "FeedInfo.h"
       
    20 #include "FeedEngine.h"
       
    21 #include "PodcastModel.h"
    20 #include <e32hashtab.h>
    22 #include <e32hashtab.h>
    21 #include <fbs.h>
    23 #include <fbs.h>
       
    24 #include <bautils.h>
       
    25 #include <eikenv.h>
       
    26 _LIT(KMbmExtension, ".mbm");
    22 
    27 
    23 EXPORT_C CFeedInfo* CFeedInfo::NewL()
    28 EXPORT_C CFeedInfo* CFeedInfo::NewL()
    24 	{
    29 	{
    25 	CFeedInfo* self = new (ELeave) CFeedInfo();
    30 	CFeedInfo* self = new (ELeave) CFeedInfo();
    26 	CleanupStack::PushL(self);
    31 	CleanupStack::PushL(self);
    45 	copy->SetDescriptionL(Description());
    50 	copy->SetDescriptionL(Description());
    46 	copy->SetImageUrlL(ImageUrl());
    51 	copy->SetImageUrlL(ImageUrl());
    47 	copy->SetLinkL(Link());
    52 	copy->SetLinkL(Link());
    48 	copy->SetBuildDate(BuildDate());
    53 	copy->SetBuildDate(BuildDate());
    49 	copy->SetLastUpdated(LastUpdated());
    54 	copy->SetLastUpdated(LastUpdated());
       
    55 	copy->iFeedIcon->Duplicate(iFeedIcon->Handle());
    50 	copy->SetImageFileNameL(ImageFileName());
    56 	copy->SetImageFileNameL(ImageFileName());
    51 	copy->iFeedIcon->Duplicate(iFeedIcon->Handle());
       
    52 	if(CustomTitle())
    57 	if(CustomTitle())
    53 		{
    58 		{
    54 		copy->SetCustomTitle();
    59 		copy->SetCustomTitle();
    55 		}
    60 		}
    56 	
    61 	
    57 	copy->SetLastError(LastError());
    62 	copy->SetLastError(LastError());
    58 	copy->SetFeedIconIndex(FeedIconIndex());
    63 
    59 	CleanupStack::Pop(copy);
    64 	CleanupStack::Pop(copy);
    60 	return copy;
    65 	return copy;
    61 	}
    66 	}
    62 CFeedInfo::CFeedInfo()
    67 CFeedInfo::CFeedInfo()
    63 	{
    68 	{
    64 	iCustomTitle = EFalse;
    69 	iCustomTitle = EFalse;
    65 	iFeedIconIndex = -1;
       
    66 	}
    70 	}
    67 
    71 
    68 EXPORT_C CFeedInfo::~CFeedInfo()
    72 EXPORT_C CFeedInfo::~CFeedInfo()
    69 	{
    73 	{
    70 	delete iUrl;
    74 	delete iUrl;
   189 	return iImageFileName ? *iImageFileName : KNullDesC();
   193 	return iImageFileName ? *iImageFileName : KNullDesC();
   190 	}
   194 	}
   191 
   195 
   192 EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName)
   196 EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName)
   193 	{
   197 	{
       
   198 	TFileName cacheFileName;
       
   199 	
   194 	if (iImageFileName)
   200 	if (iImageFileName)
   195 		{
   201 		{
   196 		delete iImageFileName;
   202 		delete iImageFileName;
   197 		iImageFileName = NULL;
   203 		iImageFileName = NULL;
   198 		}
   204 		}
   199 	iImageFileName = aFileName.AllocL();	
   205 	iImageFileName = aFileName.AllocL();
   200 	}
   206 	TParsePtrC parser(*iImageFileName);
       
   207 	cacheFileName = parser.DriveAndPath();
       
   208 	cacheFileName.Append(parser.Name());
       
   209 	cacheFileName.Append(KMbmExtension());
       
   210 	if( iFeedIcon->SizeInPixels() == TSize(0,0) && BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) )
       
   211 		{
       
   212 		iFeedIcon = CEikonEnv::Static()->CreateBitmapL(cacheFileName, 0);
       
   213 		}	
       
   214 	} 
   201 
   215 
   202 EXPORT_C TBool CFeedInfo::CustomTitle() const
   216 EXPORT_C TBool CFeedInfo::CustomTitle() const
   203 	{
   217 	{
   204 	return iCustomTitle;
   218 	return iCustomTitle;
   205 	}
   219 	}
   227 EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone)
   241 EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone)
   228 	{
   242 	{
   229 	iFeedIcon->Duplicate(aBitmapToClone->Handle());
   243 	iFeedIcon->Duplicate(aBitmapToClone->Handle());
   230 	}
   244 	}
   231 
   245 
   232 void CFeedInfo::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/)
   246 void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/, CPodcastModel& aPodcastModel)
   233 	{
   247 	{		
   234 	
   248 	if (aError == KErrNone && iImageFileName && iFeedIcon)
   235 	}
   249 		{
   236 
   250 		TFileName cacheFileName;
   237 EXPORT_C TInt CFeedInfo::FeedIconIndex() const
   251 	
   238 	{
   252 		TParsePtrC parser(*iImageFileName);
   239 	return iFeedIconIndex;
   253 		cacheFileName = parser.DriveAndPath();
   240 	}
   254 		cacheFileName.Append(parser.Name());
   241 
   255 		cacheFileName.Append(KMbmExtension());		
   242 EXPORT_C void CFeedInfo::SetFeedIconIndex(TInt aIndex)
   256 		iFeedIcon->Save(cacheFileName);					
   243 	{
   257 		aPodcastModel.FeedEngine().NotifyFeedUpdateComplete(this->iUid, KErrNone);
   244 	iFeedIconIndex = aIndex;
   258 		}
   245 	}
   259 	}