author | Sebastian Brannstrom <sebastianb@symbian.org> |
Mon, 15 Nov 2010 22:54:58 +0000 | |
branch | newlist |
changeset 354 | a2713e6a41a9 |
parent 340 | 37610dda6102 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* This component and the accompanying materials are made available |
|
6 |
* under the terms of the License "Eclipse Public License v1.0" |
|
7 |
* which accompanies this distribution, and is available |
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 |
* |
|
10 |
* Initial Contributors: |
|
11 |
* EmbedDev AB - initial contribution. |
|
12 |
* |
|
13 |
* Contributors: |
|
14 |
* |
|
15 |
* Description: |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include "FeedInfo.h" |
|
60 | 20 |
#include "FeedEngine.h" |
21 |
#include "PodcastModel.h" |
|
2 | 22 |
#include <e32hashtab.h> |
23 |
#include <fbs.h> |
|
60 | 24 |
#include <bautils.h> |
25 |
#include <eikenv.h> |
|
26 |
_LIT(KMbmExtension, ".mbm"); |
|
2 | 27 |
|
28 |
EXPORT_C CFeedInfo* CFeedInfo::NewL() |
|
29 |
{ |
|
30 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
31 |
CleanupStack::PushL(self); |
|
32 |
self->ConstructL(); |
|
33 |
CleanupStack::Pop(); |
|
34 |
return self; |
|
35 |
} |
|
36 |
||
37 |
EXPORT_C CFeedInfo* CFeedInfo::NewLC() |
|
38 |
{ |
|
39 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
40 |
CleanupStack::PushL(self); |
|
41 |
self->ConstructL(); |
|
42 |
return self; |
|
43 |
} |
|
44 |
||
45 |
EXPORT_C CFeedInfo* CFeedInfo::CopyL() const |
|
46 |
{ |
|
47 |
CFeedInfo* copy = CFeedInfo::NewLC(); |
|
48 |
copy->SetUrlL(Url()); |
|
49 |
copy->SetTitleL(Title()); |
|
50 |
copy->SetDescriptionL(Description()); |
|
51 |
copy->SetImageUrlL(ImageUrl()); |
|
52 |
copy->SetLinkL(Link()); |
|
53 |
copy->SetBuildDate(BuildDate()); |
|
54 |
copy->SetLastUpdated(LastUpdated()); |
|
60 | 55 |
if (iFeedIcon) { |
56 |
copy->SetFeedIcon(iFeedIcon); |
|
57 |
} |
|
58 |
copy->SetImageFileNameL(ImageFileName(), NULL); |
|
2 | 59 |
if(CustomTitle()) |
60 |
{ |
|
61 |
copy->SetCustomTitle(); |
|
62 |
} |
|
63 |
||
64 |
copy->SetLastError(LastError()); |
|
60 | 65 |
|
2 | 66 |
CleanupStack::Pop(copy); |
67 |
return copy; |
|
68 |
} |
|
60 | 69 |
|
2 | 70 |
CFeedInfo::CFeedInfo() |
71 |
{ |
|
72 |
iCustomTitle = EFalse; |
|
73 |
} |
|
74 |
||
75 |
EXPORT_C CFeedInfo::~CFeedInfo() |
|
76 |
{ |
|
77 |
delete iUrl; |
|
78 |
delete iTitle; |
|
79 |
delete iDescription; |
|
80 |
delete iImageUrl; |
|
81 |
delete iImageFileName; |
|
82 |
delete iLink; |
|
83 |
delete iFeedIcon; |
|
84 |
} |
|
85 |
||
86 |
void CFeedInfo::ConstructL() |
|
87 |
{ |
|
60 | 88 |
//iFeedIcon = new (ELeave) CFbsBitmap; |
2 | 89 |
} |
90 |
||
91 |
EXPORT_C const TDesC& CFeedInfo::Url() const |
|
92 |
{ |
|
93 |
return iUrl ? *iUrl : KNullDesC(); |
|
94 |
} |
|
95 |
||
96 |
EXPORT_C void CFeedInfo::SetUrlL(const TDesC &aUrl) |
|
97 |
{ |
|
98 |
if (iUrl) |
|
99 |
{ |
|
100 |
delete iUrl; |
|
101 |
iUrl = NULL; |
|
102 |
} |
|
103 |
||
104 |
iUrl = aUrl.AllocL(); |
|
105 |
iUid = DefaultHash::Des16(Url()); |
|
106 |
} |
|
107 |
||
108 |
EXPORT_C const TDesC& CFeedInfo::Title() const |
|
109 |
{ |
|
110 |
return iTitle ? *iTitle : KNullDesC(); |
|
111 |
} |
|
112 |
||
113 |
EXPORT_C void CFeedInfo::SetTitleL(const TDesC &aTitle) |
|
114 |
{ |
|
115 |
if(iTitle) |
|
116 |
{ |
|
117 |
delete iTitle; |
|
118 |
iTitle = NULL; |
|
119 |
} |
|
120 |
iTitle = aTitle.AllocL(); |
|
121 |
} |
|
122 |
||
123 |
EXPORT_C const TDesC& CFeedInfo::Description() const |
|
124 |
{ |
|
125 |
return iDescription ? *iDescription : KNullDesC(); |
|
126 |
} |
|
127 |
||
128 |
EXPORT_C void CFeedInfo::SetDescriptionL(const TDesC &aDescription) |
|
129 |
{ |
|
130 |
if (iDescription) |
|
131 |
{ |
|
132 |
delete iDescription; |
|
133 |
iDescription = NULL; |
|
134 |
} |
|
135 |
||
136 |
iDescription = aDescription.AllocL(); |
|
137 |
} |
|
138 |
||
139 |
EXPORT_C const TDesC& CFeedInfo::ImageUrl() const |
|
140 |
{ |
|
141 |
return iImageUrl ? *iImageUrl : KNullDesC(); |
|
142 |
} |
|
143 |
||
144 |
EXPORT_C void CFeedInfo::SetImageUrlL(const TDesC &aImageUrl) |
|
145 |
{ |
|
146 |
if (iImageUrl) |
|
147 |
{ |
|
148 |
delete iImageUrl; |
|
149 |
iImageUrl = NULL; |
|
150 |
} |
|
151 |
iImageUrl = aImageUrl.AllocL(); |
|
152 |
} |
|
153 |
||
154 |
EXPORT_C const TDesC& CFeedInfo::Link() const |
|
155 |
{ |
|
156 |
return iLink ? *iLink : KNullDesC(); |
|
157 |
} |
|
158 |
||
159 |
EXPORT_C void CFeedInfo::SetLinkL(const TDesC& aLink) |
|
160 |
{ |
|
161 |
if (iLink) |
|
162 |
{ |
|
163 |
delete iLink; |
|
164 |
iLink = NULL; |
|
165 |
} |
|
166 |
iLink = aLink.AllocL(); |
|
167 |
} |
|
168 |
||
169 |
EXPORT_C TTime CFeedInfo::BuildDate() const |
|
170 |
{ |
|
171 |
return iBuildDate; |
|
172 |
} |
|
173 |
||
174 |
EXPORT_C void CFeedInfo::SetBuildDate(TTime aBuildDate) |
|
175 |
{ |
|
176 |
iBuildDate = aBuildDate; |
|
177 |
} |
|
178 |
||
179 |
EXPORT_C TTime CFeedInfo::LastUpdated() const |
|
180 |
{ |
|
181 |
return iLastUpdated; |
|
182 |
} |
|
183 |
||
184 |
EXPORT_C void CFeedInfo::SetLastUpdated(TTime aUpdated) |
|
185 |
{ |
|
186 |
iLastUpdated = aUpdated; |
|
187 |
} |
|
188 |
||
189 |
EXPORT_C TUint CFeedInfo::Uid() const |
|
190 |
{ |
|
191 |
return iUid; |
|
192 |
} |
|
193 |
||
194 |
EXPORT_C const TDesC& CFeedInfo::ImageFileName() const |
|
195 |
{ |
|
196 |
return iImageFileName ? *iImageFileName : KNullDesC(); |
|
197 |
} |
|
198 |
||
60 | 199 |
EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName, CPodcastModel* aPodcastModel) |
2 | 200 |
{ |
60 | 201 |
DP1("CFeedInfo::SetImageFileNameL BEGIN, aFileName=%S", &aFileName); |
202 |
TFileName cacheFileName; |
|
203 |
||
2 | 204 |
if (iImageFileName) |
205 |
{ |
|
206 |
delete iImageFileName; |
|
207 |
iImageFileName = NULL; |
|
208 |
} |
|
60 | 209 |
|
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; |
|
2 | 218 |
} |
60 | 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(); |
|
336
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
60
diff
changeset
|
228 |
TRAP_IGNORE(aPodcastModel->ImageHandler().LoadFileAndScaleL(FeedIcon(), ImageFileName(), TSize(128,128), *this, Uid())); |
60 | 229 |
} |
230 |
DP("CFeedInfo::SetImageFileNameL END"); |
|
231 |
} |
|
2 | 232 |
|
233 |
EXPORT_C TBool CFeedInfo::CustomTitle() const |
|
234 |
{ |
|
235 |
return iCustomTitle; |
|
236 |
} |
|
237 |
||
238 |
EXPORT_C void CFeedInfo::SetCustomTitle() |
|
239 |
{ |
|
240 |
iCustomTitle = ETrue; |
|
241 |
} |
|
242 |
||
243 |
EXPORT_C void CFeedInfo::SetLastError(TInt aLastError) |
|
244 |
{ |
|
245 |
iLastError = aLastError; |
|
246 |
} |
|
247 |
||
248 |
EXPORT_C TInt CFeedInfo::LastError() const |
|
249 |
{ |
|
250 |
return iLastError; |
|
251 |
} |
|
252 |
||
253 |
EXPORT_C CFbsBitmap* CFeedInfo::FeedIcon() const |
|
254 |
{ |
|
255 |
return iFeedIcon; |
|
256 |
} |
|
257 |
||
258 |
EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone) |
|
259 |
{ |
|
60 | 260 |
if (iFeedIcon) |
261 |
{ |
|
262 |
delete iFeedIcon; |
|
263 |
} |
|
264 |
||
2 | 265 |
iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
266 |
} |
|
267 |
||
60 | 268 |
void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/, CPodcastModel& aPodcastModel) |
269 |
{ |
|
270 |
if (aError == KErrNone && iImageFileName && iFeedIcon) |
|
271 |
{ |
|
272 |
TFileName cacheFileName; |
|
2 | 273 |
|
60 | 274 |
TParsePtrC parser(*iImageFileName); |
275 |
cacheFileName = parser.DriveAndPath(); |
|
276 |
cacheFileName.Append(parser.Name()); |
|
277 |
cacheFileName.Append(KMbmExtension()); |
|
278 |
iFeedIcon->Save(cacheFileName); |
|
279 |
aPodcastModel.FeedEngine().NotifyFeedUpdateComplete(this->iUid, KErrNone); |
|
280 |
} |
|
2 | 281 |
} |
340
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
282 |
|
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
283 |
|
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
284 |
EXPORT_C TInt CFeedInfo::FeedFileSize() const |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
285 |
{ |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
286 |
return iFeedSize; |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
287 |
} |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
288 |
|
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
289 |
EXPORT_C void CFeedInfo::SetFeedFileSize(TInt aSize) |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
290 |
{ |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
291 |
iFeedSize = aSize; |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
292 |
} |
37610dda6102
Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
336
diff
changeset
|
293 |