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()); |
50 copy->SetImageFileNameL(ImageFileName()); |
55 if (iFeedIcon) { |
51 copy->iFeedIcon->Duplicate(iFeedIcon->Handle()); |
56 copy->SetFeedIcon(iFeedIcon); |
|
57 } |
|
58 copy->SetImageFileNameL(ImageFileName(), NULL); |
52 if(CustomTitle()) |
59 if(CustomTitle()) |
53 { |
60 { |
54 copy->SetCustomTitle(); |
61 copy->SetCustomTitle(); |
55 } |
62 } |
56 |
63 |
57 copy->SetLastError(LastError()); |
64 copy->SetLastError(LastError()); |
58 copy->SetFeedIconIndex(FeedIconIndex()); |
65 |
59 CleanupStack::Pop(copy); |
66 CleanupStack::Pop(copy); |
60 return copy; |
67 return copy; |
61 } |
68 } |
|
69 |
62 CFeedInfo::CFeedInfo() |
70 CFeedInfo::CFeedInfo() |
63 { |
71 { |
64 iCustomTitle = EFalse; |
72 iCustomTitle = EFalse; |
65 iFeedIconIndex = -1; |
|
66 } |
73 } |
67 |
74 |
68 EXPORT_C CFeedInfo::~CFeedInfo() |
75 EXPORT_C CFeedInfo::~CFeedInfo() |
69 { |
76 { |
70 delete iUrl; |
77 delete iUrl; |
187 EXPORT_C const TDesC& CFeedInfo::ImageFileName() const |
194 EXPORT_C const TDesC& CFeedInfo::ImageFileName() const |
188 { |
195 { |
189 return iImageFileName ? *iImageFileName : KNullDesC(); |
196 return iImageFileName ? *iImageFileName : KNullDesC(); |
190 } |
197 } |
191 |
198 |
192 EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName) |
199 EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName, CPodcastModel* aPodcastModel) |
193 { |
200 { |
|
201 DP1("CFeedInfo::SetImageFileNameL BEGIN, aFileName=%S", &aFileName); |
|
202 TFileName cacheFileName; |
|
203 |
194 if (iImageFileName) |
204 if (iImageFileName) |
195 { |
205 { |
196 delete iImageFileName; |
206 delete iImageFileName; |
197 iImageFileName = NULL; |
207 iImageFileName = NULL; |
198 } |
208 } |
199 iImageFileName = aFileName.AllocL(); |
209 |
200 } |
210 iImageFileName = aFileName.AllocL(); |
|
211 TParsePtrC parser(*iImageFileName); |
|
212 cacheFileName = parser.DriveAndPath(); |
|
213 cacheFileName.Append(parser.Name()); |
|
214 cacheFileName.Append(KMbmExtension()); |
|
215 |
|
216 if (iFeedIcon) { |
|
217 delete iFeedIcon; |
|
218 } |
|
219 |
|
220 if( BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) ) |
|
221 { |
|
222 iFeedIcon = CEikonEnv::Static()->CreateBitmapL(cacheFileName, 0); |
|
223 } |
|
224 else if(aPodcastModel && BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), ImageFileName() )) |
|
225 { |
|
226 // If this fails, no reason to worry |
|
227 iFeedIcon = new CFbsBitmap(); |
|
228 TRAP_IGNORE(aPodcastModel->ImageHandler().LoadFileAndScaleL(FeedIcon(), ImageFileName(), TSize(64,56), *this, Uid())); |
|
229 } |
|
230 DP("CFeedInfo::SetImageFileNameL END"); |
|
231 } |
201 |
232 |
202 EXPORT_C TBool CFeedInfo::CustomTitle() const |
233 EXPORT_C TBool CFeedInfo::CustomTitle() const |
203 { |
234 { |
204 return iCustomTitle; |
235 return iCustomTitle; |
205 } |
236 } |
224 return iFeedIcon; |
255 return iFeedIcon; |
225 } |
256 } |
226 |
257 |
227 EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone) |
258 EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone) |
228 { |
259 { |
|
260 if (iFeedIcon) |
|
261 { |
|
262 delete iFeedIcon; |
|
263 } |
|
264 |
229 iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
265 iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
230 } |
266 } |
231 |
267 |
232 void CFeedInfo::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/) |
268 void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/, CPodcastModel& aPodcastModel) |
233 { |
269 { |
234 |
270 if (aError == KErrNone && iImageFileName && iFeedIcon) |
235 } |
271 { |
236 |
272 TFileName cacheFileName; |
237 EXPORT_C TInt CFeedInfo::FeedIconIndex() const |
273 |
238 { |
274 TParsePtrC parser(*iImageFileName); |
239 return iFeedIconIndex; |
275 cacheFileName = parser.DriveAndPath(); |
240 } |
276 cacheFileName.Append(parser.Name()); |
241 |
277 cacheFileName.Append(KMbmExtension()); |
242 EXPORT_C void CFeedInfo::SetFeedIconIndex(TInt aIndex) |
278 iFeedIcon->Save(cacheFileName); |
243 { |
279 aPodcastModel.FeedEngine().NotifyFeedUpdateComplete(this->iUid, KErrNone); |
244 iFeedIconIndex = aIndex; |
280 } |
245 } |
281 } |