author | Lars Persson <lars.persson@embeddev.se> |
Wed, 31 Mar 2010 08:19:35 +0200 | |
changeset 91 | 87cb33beeae2 |
parent 32 | 26a3f2dfba08 |
child 92 | dc142c8740eb |
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" |
|
20 |
#include <e32hashtab.h> |
|
21 |
#include <fbs.h> |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
22 |
#include <bautils.h> |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
23 |
#include <eikenv.h> |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
24 |
_LIT(KMbmExtension, ".mbm"); |
2 | 25 |
|
26 |
EXPORT_C CFeedInfo* CFeedInfo::NewL() |
|
27 |
{ |
|
28 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
29 |
CleanupStack::PushL(self); |
|
30 |
self->ConstructL(); |
|
31 |
CleanupStack::Pop(); |
|
32 |
return self; |
|
33 |
} |
|
34 |
||
35 |
EXPORT_C CFeedInfo* CFeedInfo::NewLC() |
|
36 |
{ |
|
37 |
CFeedInfo* self = new (ELeave) CFeedInfo(); |
|
38 |
CleanupStack::PushL(self); |
|
39 |
self->ConstructL(); |
|
40 |
return self; |
|
41 |
} |
|
42 |
||
43 |
EXPORT_C CFeedInfo* CFeedInfo::CopyL() const |
|
44 |
{ |
|
45 |
CFeedInfo* copy = CFeedInfo::NewLC(); |
|
46 |
copy->SetUrlL(Url()); |
|
47 |
copy->SetTitleL(Title()); |
|
48 |
copy->SetDescriptionL(Description()); |
|
49 |
copy->SetImageUrlL(ImageUrl()); |
|
50 |
copy->SetLinkL(Link()); |
|
51 |
copy->SetBuildDate(BuildDate()); |
|
52 |
copy->SetLastUpdated(LastUpdated()); |
|
53 |
copy->SetImageFileNameL(ImageFileName()); |
|
54 |
copy->iFeedIcon->Duplicate(iFeedIcon->Handle()); |
|
55 |
if(CustomTitle()) |
|
56 |
{ |
|
57 |
copy->SetCustomTitle(); |
|
58 |
} |
|
59 |
||
60 |
copy->SetLastError(LastError()); |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
61 |
|
2 | 62 |
CleanupStack::Pop(copy); |
63 |
return copy; |
|
64 |
} |
|
65 |
CFeedInfo::CFeedInfo() |
|
66 |
{ |
|
67 |
iCustomTitle = EFalse; |
|
68 |
} |
|
69 |
||
70 |
EXPORT_C CFeedInfo::~CFeedInfo() |
|
71 |
{ |
|
72 |
delete iUrl; |
|
73 |
delete iTitle; |
|
74 |
delete iDescription; |
|
75 |
delete iImageUrl; |
|
76 |
delete iImageFileName; |
|
77 |
delete iLink; |
|
78 |
delete iFeedIcon; |
|
79 |
} |
|
80 |
||
81 |
void CFeedInfo::ConstructL() |
|
82 |
{ |
|
83 |
iFeedIcon = new (ELeave) CFbsBitmap; |
|
84 |
} |
|
85 |
||
86 |
EXPORT_C const TDesC& CFeedInfo::Url() const |
|
87 |
{ |
|
88 |
return iUrl ? *iUrl : KNullDesC(); |
|
89 |
} |
|
90 |
||
91 |
EXPORT_C void CFeedInfo::SetUrlL(const TDesC &aUrl) |
|
92 |
{ |
|
93 |
if (iUrl) |
|
94 |
{ |
|
95 |
delete iUrl; |
|
96 |
iUrl = NULL; |
|
97 |
} |
|
98 |
||
99 |
iUrl = aUrl.AllocL(); |
|
100 |
iUid = DefaultHash::Des16(Url()); |
|
101 |
} |
|
102 |
||
103 |
EXPORT_C const TDesC& CFeedInfo::Title() const |
|
104 |
{ |
|
105 |
return iTitle ? *iTitle : KNullDesC(); |
|
106 |
} |
|
107 |
||
108 |
EXPORT_C void CFeedInfo::SetTitleL(const TDesC &aTitle) |
|
109 |
{ |
|
110 |
if(iTitle) |
|
111 |
{ |
|
112 |
delete iTitle; |
|
113 |
iTitle = NULL; |
|
114 |
} |
|
115 |
iTitle = aTitle.AllocL(); |
|
116 |
} |
|
117 |
||
118 |
EXPORT_C const TDesC& CFeedInfo::Description() const |
|
119 |
{ |
|
120 |
return iDescription ? *iDescription : KNullDesC(); |
|
121 |
} |
|
122 |
||
123 |
EXPORT_C void CFeedInfo::SetDescriptionL(const TDesC &aDescription) |
|
124 |
{ |
|
125 |
if (iDescription) |
|
126 |
{ |
|
127 |
delete iDescription; |
|
128 |
iDescription = NULL; |
|
129 |
} |
|
130 |
||
131 |
iDescription = aDescription.AllocL(); |
|
132 |
} |
|
133 |
||
134 |
EXPORT_C const TDesC& CFeedInfo::ImageUrl() const |
|
135 |
{ |
|
136 |
return iImageUrl ? *iImageUrl : KNullDesC(); |
|
137 |
} |
|
138 |
||
139 |
EXPORT_C void CFeedInfo::SetImageUrlL(const TDesC &aImageUrl) |
|
140 |
{ |
|
141 |
if (iImageUrl) |
|
142 |
{ |
|
143 |
delete iImageUrl; |
|
144 |
iImageUrl = NULL; |
|
145 |
} |
|
146 |
iImageUrl = aImageUrl.AllocL(); |
|
147 |
} |
|
148 |
||
149 |
EXPORT_C const TDesC& CFeedInfo::Link() const |
|
150 |
{ |
|
151 |
return iLink ? *iLink : KNullDesC(); |
|
152 |
} |
|
153 |
||
154 |
EXPORT_C void CFeedInfo::SetLinkL(const TDesC& aLink) |
|
155 |
{ |
|
156 |
if (iLink) |
|
157 |
{ |
|
158 |
delete iLink; |
|
159 |
iLink = NULL; |
|
160 |
} |
|
161 |
iLink = aLink.AllocL(); |
|
162 |
} |
|
163 |
||
164 |
EXPORT_C TTime CFeedInfo::BuildDate() const |
|
165 |
{ |
|
166 |
return iBuildDate; |
|
167 |
} |
|
168 |
||
169 |
EXPORT_C void CFeedInfo::SetBuildDate(TTime aBuildDate) |
|
170 |
{ |
|
171 |
iBuildDate = aBuildDate; |
|
172 |
} |
|
173 |
||
174 |
EXPORT_C TTime CFeedInfo::LastUpdated() const |
|
175 |
{ |
|
176 |
return iLastUpdated; |
|
177 |
} |
|
178 |
||
179 |
EXPORT_C void CFeedInfo::SetLastUpdated(TTime aUpdated) |
|
180 |
{ |
|
181 |
iLastUpdated = aUpdated; |
|
182 |
} |
|
183 |
||
184 |
EXPORT_C TUint CFeedInfo::Uid() const |
|
185 |
{ |
|
186 |
return iUid; |
|
187 |
} |
|
188 |
||
189 |
EXPORT_C const TDesC& CFeedInfo::ImageFileName() const |
|
190 |
{ |
|
191 |
return iImageFileName ? *iImageFileName : KNullDesC(); |
|
192 |
} |
|
193 |
||
194 |
EXPORT_C void CFeedInfo::SetImageFileNameL(const TDesC& aFileName) |
|
195 |
{ |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
196 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
197 |
|
2 | 198 |
if (iImageFileName) |
199 |
{ |
|
200 |
delete iImageFileName; |
|
201 |
iImageFileName = NULL; |
|
202 |
} |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
203 |
iImageFileName = aFileName.AllocL(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
204 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
205 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
206 |
cacheFileName.Append(parser.Name()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
207 |
cacheFileName.Append(KMbmExtension()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
208 |
if( BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) ) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
209 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
210 |
iFeedIcon = CEikonEnv::Static()->CreateBitmapL(cacheFileName, 0); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
211 |
} |
2 | 212 |
} |
213 |
||
214 |
EXPORT_C TBool CFeedInfo::CustomTitle() const |
|
215 |
{ |
|
216 |
return iCustomTitle; |
|
217 |
} |
|
218 |
||
219 |
EXPORT_C void CFeedInfo::SetCustomTitle() |
|
220 |
{ |
|
221 |
iCustomTitle = ETrue; |
|
222 |
} |
|
223 |
||
224 |
EXPORT_C void CFeedInfo::SetLastError(TInt aLastError) |
|
225 |
{ |
|
226 |
iLastError = aLastError; |
|
227 |
} |
|
228 |
||
229 |
EXPORT_C TInt CFeedInfo::LastError() const |
|
230 |
{ |
|
231 |
return iLastError; |
|
232 |
} |
|
233 |
||
234 |
EXPORT_C CFbsBitmap* CFeedInfo::FeedIcon() const |
|
235 |
{ |
|
236 |
return iFeedIcon; |
|
237 |
} |
|
238 |
||
239 |
EXPORT_C void CFeedInfo::SetFeedIcon(CFbsBitmap* aBitmapToClone) |
|
240 |
{ |
|
241 |
iFeedIcon->Duplicate(aBitmapToClone->Handle()); |
|
242 |
} |
|
243 |
||
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
244 |
void CFeedInfo::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/) |
2 | 245 |
{ |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
246 |
|
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
247 |
if (aError == KErrNone && iImageFileName && iFeedIcon) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
248 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
249 |
TFileName cacheFileName; |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
250 |
|
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
251 |
TParsePtrC parser(*iImageFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
252 |
cacheFileName = parser.DriveAndPath(); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
253 |
cacheFileName.Append(parser.Name()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
254 |
cacheFileName.Append(KMbmExtension()); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
255 |
if( !BaflUtils::FileExists(CEikonEnv::Static()->FsSession(), cacheFileName) ) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
256 |
{ |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
257 |
iFeedIcon->Save(cacheFileName); |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
258 |
} |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
259 |
|
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
260 |
} |
2 | 261 |
} |