author | Sebastian Brannstrom <sebastianb@symbian.org> |
Wed, 28 Jul 2010 14:18:09 +0100 | |
branch | RCL_3 |
changeset 248 | 31659d49b2e7 |
parent 109 | 223f270fa7ff |
child 228 | c553fa9dcbe5 |
child 311 | 606f4f6babf6 |
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> |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
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()); |
|
109 | 55 |
if (iFeedIcon) { |
56 |
copy->SetFeedIcon(iFeedIcon); |
|
57 |
} |
|
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
58 |
copy->SetImageFileNameL(ImageFileName(), NULL); |
2 | 59 |
if(CustomTitle()) |
60 |
{ |
|
61 |
copy->SetCustomTitle(); |
|
62 |
} |
|
63 |
||
64 |
copy->SetLastError(LastError()); |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
65 |
|
2 | 66 |
CleanupStack::Pop(copy); |
67 |
return copy; |
|
68 |
} |
|
109 | 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 |
{ |
|
109 | 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 |
||
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
199 |
EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName, CPodcastModel* aPodcastModel) |
2 | 200 |
{ |
109 | 201 |
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
|
202 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
203 |
|
2 | 204 |
if (iImageFileName) |
205 |
{ |
|
206 |
delete iImageFileName; |
|
207 |
iImageFileName = NULL; |
|
208 |
} |
|
97
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
209 |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
210 |
iImageFileName = aFileName.AllocL(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
211 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
212 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
213 |
cacheFileName.Append(parser.Name()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
214 |
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
|
215 |
|
109 | 216 |
if (iFeedIcon) { |
217 |
delete iFeedIcon; |
|
218 |
} |
|
219 |
||
220 |
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
|
221 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
222 |
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
|
223 |
} |
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
224 |
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
|
225 |
{ |
b52f6033af15
Add so image conversion is done in feedinfo if image already exist.
Lars Persson <lars.persson@embeddev.se>
parents:
93
diff
changeset
|
226 |
// If this fails, no reason to worry |
109 | 227 |
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
|
228 |
TRAP_IGNORE(aPodcastModel->ImageHandler().LoadFileAndScaleL(FeedIcon(), ImageFileName(), TSize(64,56), *this, Uid())); |
109 | 229 |
} |
230 |
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
|
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 |
{ |
|
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
|
260 |
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
|
261 |
{ |
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 |
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
|
263 |
} |
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 |
|
2 | 265 |
iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
266 |
} |
|
267 |
||
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
|
268 |
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
|
269 |
{ |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
270 |
if (aError == KErrNone && iImageFileName && iFeedIcon) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
271 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
272 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
273 |
|
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
274 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
275 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
276 |
cacheFileName.Append(parser.Name()); |
92
dc142c8740eb
Updated feedinfo handling some
Lars Persson <lars.persson@embeddev.se>
parents:
91
diff
changeset
|
277 |
cacheFileName.Append(KMbmExtension()); |
dc142c8740eb
Updated feedinfo handling some
Lars Persson <lars.persson@embeddev.se>
parents:
91
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
} |
2 | 281 |
} |