author | larspson |
Wed, 13 Oct 2010 20:14:00 +0200 | |
branch | podcatcher_qt_symbian4 |
changeset 234 | 05075131dd6a |
parent 228 | c553fa9dcbe5 |
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" |
|
93
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
20 |
#include "FeedEngine.h" |
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
21 |
#include "PodcastModel.h" |
2 | 22 |
#include <e32hashtab.h> |
23 |
#include <fbs.h> |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
24 |
#include <bautils.h> |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
25 |
#include <eikenv.h> |
228 | 26 |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
27 |
_LIT(KMbmExtension, ".mbm"); |
2 | 28 |
|
29 |
EXPORT_C CFeedInfo* CFeedInfo::NewL() |
|
30 |
{ |
|
31 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
32 |
CleanupStack::PushL(self); |
|
33 |
self->ConstructL(); |
|
34 |
CleanupStack::Pop(); |
|
35 |
return self; |
|
36 |
} |
|
37 |
||
38 |
EXPORT_C CFeedInfo* CFeedInfo::NewLC() |
|
39 |
{ |
|
40 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
41 |
CleanupStack::PushL(self); |
|
42 |
self->ConstructL(); |
|
43 |
return self; |
|
44 |
} |
|
45 |
||
46 |
EXPORT_C CFeedInfo* CFeedInfo::CopyL() const |
|
47 |
{ |
|
48 |
CFeedInfo* copy = CFeedInfo::NewLC(); |
|
49 |
copy->SetUrlL(Url()); |
|
50 |
copy->SetTitleL(Title()); |
|
51 |
copy->SetDescriptionL(Description()); |
|
52 |
copy->SetImageUrlL(ImageUrl()); |
|
53 |
copy->SetLinkL(Link()); |
|
54 |
copy->SetBuildDate(BuildDate()); |
|
55 |
copy->SetLastUpdated(LastUpdated()); |
|
109 | 56 |
if (iFeedIcon) { |
57 |
copy->SetFeedIcon(iFeedIcon); |
|
58 |
} |
|
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
59 |
copy->SetImageFileNameL(ImageFileName(), NULL); |
2 | 60 |
if(CustomTitle()) |
61 |
{ |
|
62 |
copy->SetCustomTitle(); |
|
63 |
} |
|
64 |
||
65 |
copy->SetLastError(LastError()); |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
66 |
|
2 | 67 |
CleanupStack::Pop(copy); |
68 |
return copy; |
|
69 |
} |
|
109 | 70 |
|
2 | 71 |
CFeedInfo::CFeedInfo() |
72 |
{ |
|
73 |
iCustomTitle = EFalse; |
|
74 |
} |
|
75 |
||
76 |
EXPORT_C CFeedInfo::~CFeedInfo() |
|
77 |
{ |
|
78 |
delete iUrl; |
|
79 |
delete iTitle; |
|
80 |
delete iDescription; |
|
81 |
delete iImageUrl; |
|
82 |
delete iImageFileName; |
|
83 |
delete iLink; |
|
84 |
delete iFeedIcon; |
|
85 |
} |
|
86 |
||
87 |
void CFeedInfo::ConstructL() |
|
88 |
{ |
|
109 | 89 |
//iFeedIcon = new (ELeave) CFbsBitmap; |
2 | 90 |
} |
91 |
||
92 |
EXPORT_C const TDesC& CFeedInfo::Url() const |
|
93 |
{ |
|
94 |
return iUrl ? *iUrl : KNullDesC(); |
|
95 |
} |
|
96 |
||
97 |
EXPORT_C void CFeedInfo::SetUrlL(const TDesC &aUrl) |
|
98 |
{ |
|
99 |
if (iUrl) |
|
100 |
{ |
|
101 |
delete iUrl; |
|
102 |
iUrl = NULL; |
|
103 |
} |
|
104 |
||
105 |
iUrl = aUrl.AllocL(); |
|
106 |
iUid = DefaultHash::Des16(Url()); |
|
107 |
} |
|
108 |
||
109 |
EXPORT_C const TDesC& CFeedInfo::Title() const |
|
110 |
{ |
|
111 |
return iTitle ? *iTitle : KNullDesC(); |
|
112 |
} |
|
113 |
||
114 |
EXPORT_C void CFeedInfo::SetTitleL(const TDesC &aTitle) |
|
115 |
{ |
|
116 |
if(iTitle) |
|
117 |
{ |
|
118 |
delete iTitle; |
|
119 |
iTitle = NULL; |
|
120 |
} |
|
121 |
iTitle = aTitle.AllocL(); |
|
122 |
} |
|
123 |
||
124 |
EXPORT_C const TDesC& CFeedInfo::Description() const |
|
125 |
{ |
|
126 |
return iDescription ? *iDescription : KNullDesC(); |
|
127 |
} |
|
128 |
||
129 |
EXPORT_C void CFeedInfo::SetDescriptionL(const TDesC &aDescription) |
|
130 |
{ |
|
131 |
if (iDescription) |
|
132 |
{ |
|
133 |
delete iDescription; |
|
134 |
iDescription = NULL; |
|
135 |
} |
|
136 |
||
137 |
iDescription = aDescription.AllocL(); |
|
138 |
} |
|
139 |
||
140 |
EXPORT_C const TDesC& CFeedInfo::ImageUrl() const |
|
141 |
{ |
|
142 |
return iImageUrl ? *iImageUrl : KNullDesC(); |
|
143 |
} |
|
144 |
||
145 |
EXPORT_C void CFeedInfo::SetImageUrlL(const TDesC &aImageUrl) |
|
146 |
{ |
|
147 |
if (iImageUrl) |
|
148 |
{ |
|
149 |
delete iImageUrl; |
|
150 |
iImageUrl = NULL; |
|
151 |
} |
|
152 |
iImageUrl = aImageUrl.AllocL(); |
|
153 |
} |
|
154 |
||
155 |
EXPORT_C const TDesC& CFeedInfo::Link() const |
|
156 |
{ |
|
157 |
return iLink ? *iLink : KNullDesC(); |
|
158 |
} |
|
159 |
||
160 |
EXPORT_C void CFeedInfo::SetLinkL(const TDesC& aLink) |
|
161 |
{ |
|
162 |
if (iLink) |
|
163 |
{ |
|
164 |
delete iLink; |
|
165 |
iLink = NULL; |
|
166 |
} |
|
167 |
iLink = aLink.AllocL(); |
|
168 |
} |
|
169 |
||
170 |
EXPORT_C TTime CFeedInfo::BuildDate() const |
|
171 |
{ |
|
172 |
return iBuildDate; |
|
173 |
} |
|
174 |
||
175 |
EXPORT_C void CFeedInfo::SetBuildDate(TTime aBuildDate) |
|
176 |
{ |
|
177 |
iBuildDate = aBuildDate; |
|
178 |
} |
|
179 |
||
180 |
EXPORT_C TTime CFeedInfo::LastUpdated() const |
|
181 |
{ |
|
182 |
return iLastUpdated; |
|
183 |
} |
|
184 |
||
185 |
EXPORT_C void CFeedInfo::SetLastUpdated(TTime aUpdated) |
|
186 |
{ |
|
187 |
iLastUpdated = aUpdated; |
|
188 |
} |
|
189 |
||
190 |
EXPORT_C TUint CFeedInfo::Uid() const |
|
191 |
{ |
|
192 |
return iUid; |
|
193 |
} |
|
194 |
||
195 |
EXPORT_C const TDesC& CFeedInfo::ImageFileName() const |
|
196 |
{ |
|
197 |
return iImageFileName ? *iImageFileName : KNullDesC(); |
|
198 |
} |
|
199 |
||
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
200 |
EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName, CPodcastModel* aPodcastModel) |
2 | 201 |
{ |
109 | 202 |
DP1("CFeedInfo::SetImageFileNameL BEGIN, aFileName=%S", &aFileName); |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
203 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
204 |
|
2 | 205 |
if (iImageFileName) |
206 |
{ |
|
207 |
delete iImageFileName; |
|
208 |
iImageFileName = NULL; |
|
209 |
} |
|
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
210 |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
211 |
iImageFileName = aFileName.AllocL(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
212 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
213 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
214 |
cacheFileName.Append(parser.Name()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
215 |
cacheFileName.Append(KMbmExtension()); |
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
216 |
|
109 | 217 |
if (iFeedIcon) { |
218 |
delete iFeedIcon; |
|
219 |
} |
|
220 |
||
221 |
if( BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) ) |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
222 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
223 |
iFeedIcon = CEikonEnv::Static()->CreateBitmapL(cacheFileName, 0); |
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
224 |
} |
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
225 |
else if(aPodcastModel && BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), ImageFileName() )) |
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
226 |
{ |
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
227 |
// If this fails, no reason to worry |
109 | 228 |
iFeedIcon = new CFbsBitmap(); |
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
229 |
TRAP_IGNORE(aPodcastModel->ImageHandler().LoadFileAndScaleL(FeedIcon(), ImageFileName(), TSize(64,56), *this, Uid())); |
109 | 230 |
} |
231 |
DP("CFeedInfo::SetImageFileNameL END"); |
|
93
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
232 |
} |
2 | 233 |
|
234 |
EXPORT_C TBool CFeedInfo::CustomTitle() const |
|
235 |
{ |
|
236 |
return iCustomTitle; |
|
237 |
} |
|
238 |
||
239 |
EXPORT_C void CFeedInfo::SetCustomTitle() |
|
240 |
{ |
|
241 |
iCustomTitle = ETrue; |
|
242 |
} |
|
243 |
||
244 |
EXPORT_C void CFeedInfo::SetLastError(TInt aLastError) |
|
245 |
{ |
|
246 |
iLastError = aLastError; |
|
247 |
} |
|
248 |
||
249 |
EXPORT_C TInt CFeedInfo::LastError() const |
|
250 |
{ |
|
251 |
return iLastError; |
|
252 |
} |
|
253 |
||
254 |
EXPORT_C CFbsBitmap* CFeedInfo::FeedIcon() const |
|
255 |
{ |
|
256 |
return iFeedIcon; |
|
257 |
} |
|
258 |
||
259 |
EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone) |
|
260 |
{ |
|
106
83752b9e3cb6
Fix for regression in icon handling. Minor fix for trailing backslash in podcast dir in settings pane. New udeb SISs.
teknolog
parents:
97
diff
changeset
|
261 |
if (iFeedIcon) |
83752b9e3cb6
Fix for regression in icon handling. Minor fix for trailing backslash in podcast dir in settings pane. New udeb SISs.
teknolog
parents:
97
diff
changeset
|
262 |
{ |
83752b9e3cb6
Fix for regression in icon handling. Minor fix for trailing backslash in podcast dir in settings pane. New udeb SISs.
teknolog
parents:
97
diff
changeset
|
263 |
delete iFeedIcon; |
83752b9e3cb6
Fix for regression in icon handling. Minor fix for trailing backslash in podcast dir in settings pane. New udeb SISs.
teknolog
parents:
97
diff
changeset
|
264 |
} |
83752b9e3cb6
Fix for regression in icon handling. Minor fix for trailing backslash in podcast dir in settings pane. New udeb SISs.
teknolog
parents:
97
diff
changeset
|
265 |
|
2 | 266 |
iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
267 |
} |
|
268 |
||
93
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
269 |
void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/, CPodcastModel& aPodcastModel) |
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
270 |
{ |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
271 |
if (aError == KErrNone && iImageFileName && iFeedIcon) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
272 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
273 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
274 |
|
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
275 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
276 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
277 |
cacheFileName.Append(parser.Name()); |
92
dc142c8740eb
Updated feedinfo handling some
Lars Persson <lars.persson@embeddev.se>
parents:
91
diff
changeset
|
278 |
cacheFileName.Append(KMbmExtension()); |
dc142c8740eb
Updated feedinfo handling some
Lars Persson <lars.persson@embeddev.se>
parents:
91
diff
changeset
|
279 |
iFeedIcon->Save(cacheFileName); |
93
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents:
92
diff
changeset
|
280 |
aPodcastModel.FeedEngine().NotifyFeedUpdateComplete(this->iUid, KErrNone); |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
281 |
} |
2 | 282 |
} |