author | Brendan Donegan <brendand@symbian.org> |
Sat, 06 Mar 2010 10:22:09 +0000 | |
changeset 35 | 66c5303f3610 |
parent 8 | aab3aa4acdd6 |
child 36 | e010fc411ddc |
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 "FeedEngine.h" |
|
20 |
#include <f32file.h> |
|
21 |
#include <bautils.h> |
|
22 |
#include <s32file.h> |
|
23 |
#include "SettingsEngine.h" |
|
24 |
#include "ShowEngine.h" |
|
25 |
#include <e32hashtab.h> |
|
26 |
#include "OpmlParser.h" |
|
27 |
#include "PodcastUtils.h" |
|
28 |
#include <utf.h> |
|
29 |
||
30 |
// Cleanup stack macro for SQLite3 |
|
31 |
// TODO Move this to some common place. |
|
32 |
static void Cleanup_sqlite3_finalize_wrapper(TAny* handle) |
|
33 |
{ |
|
34 |
sqlite3_finalize(static_cast<sqlite3_stmt*>(handle)); |
|
35 |
} |
|
36 |
#define Cleanup_sqlite3_finalize_PushL(__handle) CleanupStack::PushL(TCleanupItem(&Cleanup_sqlite3_finalize_wrapper, __handle)) |
|
37 |
||
38 |
||
39 |
CFeedEngine* CFeedEngine::NewL(CPodcastModel& aPodcastModel) |
|
40 |
{ |
|
41 |
CFeedEngine* self = new (ELeave) CFeedEngine(aPodcastModel); |
|
42 |
CleanupStack::PushL(self); |
|
43 |
self->ConstructL(); |
|
44 |
CleanupStack::Pop(self); |
|
45 |
return self; |
|
46 |
} |
|
47 |
||
48 |
void CFeedEngine::ConstructL() |
|
49 |
{ |
|
50 |
iParser = new (ELeave) CFeedParser(*this, iPodcastModel.FsSession()); |
|
51 |
||
52 |
iFeedClient = CHttpClient::NewL(iPodcastModel, *this); |
|
53 |
iFeedTimer.ConstructL(); |
|
54 |
||
55 |
RunFeedTimer(); |
|
56 |
||
57 |
if (DBGetFeedCount() > 0) |
|
58 |
{ |
|
59 |
DP("Loading feeds from DB"); |
|
60 |
DBLoadFeedsL(); |
|
61 |
} |
|
62 |
||
63 |
if (iPodcastModel.IsFirstStartup()) { |
|
64 |
TFileName defaultFile = iPodcastModel.SettingsEngine().DefaultFeedsFileName(); |
|
65 |
DP1("Loading default feeds from %S", &defaultFile); |
|
66 |
if (BaflUtils::FileExists(iPodcastModel.FsSession(), defaultFile)) { |
|
67 |
ImportFeedsL(defaultFile); |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
TFileName importFile = iPodcastModel.SettingsEngine().ImportFeedsFileName(); |
|
72 |
if (BaflUtils::FileExists(iPodcastModel.FsSession(), importFile)) { |
|
73 |
DP("Importing feeds"); |
|
74 |
ImportFeedsL(importFile); |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
CFeedEngine::CFeedEngine(CPodcastModel& aPodcastModel) |
|
79 |
: iClientState(EIdle), |
|
80 |
iFeedTimer(this), |
|
81 |
iPodcastModel(aPodcastModel), |
|
82 |
iDB(*aPodcastModel.DB()) |
|
83 |
{ |
|
84 |
} |
|
85 |
||
86 |
CFeedEngine::~CFeedEngine() |
|
87 |
{ |
|
88 |
iObservers.Close(); |
|
89 |
||
90 |
iFeedsUpdating.Close(); |
|
91 |
iSortedFeeds.ResetAndDestroy(); |
|
92 |
iSearchResults.ResetAndDestroy(); |
|
93 |
||
94 |
delete iParser; |
|
95 |
delete iFeedClient; |
|
96 |
delete iOpmlParser; |
|
97 |
} |
|
98 |
||
99 |
/** |
|
100 |
* Returns the current internal state of the feed engine4 |
|
101 |
*/ |
|
102 |
EXPORT_C TClientState CFeedEngine::ClientState() |
|
103 |
{ |
|
104 |
return iClientState; |
|
105 |
} |
|
106 |
||
107 |
||
108 |
/** |
|
109 |
* Returns the current updating client UID if clientstate is != ENotUpdateing |
|
110 |
* @return TUint |
|
111 |
*/ |
|
112 |
EXPORT_C TUint CFeedEngine::ActiveClientUid() |
|
113 |
{ |
|
114 |
if(iActiveFeed != NULL) |
|
115 |
{ |
|
116 |
return iActiveFeed->Uid(); |
|
117 |
} |
|
118 |
return 0; |
|
119 |
} |
|
120 |
||
121 |
void CFeedEngine::RunFeedTimer() |
|
122 |
{ |
|
123 |
iFeedTimer.Cancel(); |
|
124 |
||
125 |
if (iPodcastModel.SettingsEngine().UpdateAutomatically() != EAutoUpdateOff) |
|
126 |
{ |
|
127 |
TInt interval = iPodcastModel.SettingsEngine().UpdateFeedInterval(); |
|
128 |
||
129 |
if (interval != 0) |
|
130 |
{ |
|
131 |
iFeedTimer.SetPeriod(interval); |
|
132 |
iFeedTimer.RunPeriodically(); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
EXPORT_C void CFeedEngine::UpdateAllFeedsL(TBool aAutoUpdate) |
|
138 |
{ |
|
139 |
iAutoUpdatedInitiator = aAutoUpdate; |
|
140 |
if (iFeedsUpdating.Count() > 0) |
|
141 |
{ |
|
142 |
DP("Cancelling update"); |
|
143 |
iFeedClient->Stop(); |
|
144 |
iFeedsUpdating.Reset(); |
|
145 |
return; |
|
146 |
} |
|
147 |
||
148 |
TInt cnt = iSortedFeeds.Count(); |
|
149 |
for (int i=0;i<cnt;i++) |
|
150 |
{ |
|
151 |
iFeedsUpdating.Append(iSortedFeeds[i]); |
|
152 |
} |
|
153 |
||
154 |
UpdateNextFeedL(); |
|
155 |
} |
|
156 |
||
157 |
EXPORT_C void CFeedEngine::CancelUpdateAllFeeds() |
|
158 |
{ |
|
159 |
if(iClientState != EIdle) |
|
160 |
{ |
|
161 |
iFeedsUpdating.Reset(); |
|
162 |
iFeedClient->Stop(); |
|
163 |
} |
|
164 |
} |
|
165 |
||
166 |
void CFeedEngine::UpdateNextFeedL() |
|
167 |
{ |
|
168 |
DP1("UpdateNextFeed. %d feeds left to update", iFeedsUpdating.Count()); |
|
169 |
||
170 |
if (iFeedsUpdating.Count() > 0) |
|
171 |
{ |
|
172 |
CFeedInfo *info = iFeedsUpdating[0]; |
|
173 |
iFeedsUpdating.Remove(0); |
|
174 |
TBool result = EFalse; |
|
175 |
//DP2("** UpdateNextFeed: %S, ID: %u", &(info->Url()), info->Uid()); |
|
176 |
TRAPD(error, result = UpdateFeedL(info->Uid())); |
|
177 |
||
178 |
if (error != KErrNone || !result) |
|
179 |
{ |
|
180 |
DP("Error while updating all feeds"); |
|
181 |
for (TInt i=0;i<iObservers.Count();i++) |
|
182 |
{ |
|
183 |
TRAP_IGNORE(iObservers[i]->FeedUpdateAllCompleteL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate)); |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
else |
|
188 |
{ |
|
189 |
iClientState = EIdle; |
|
190 |
for (TInt i=0;i<iObservers.Count();i++) |
|
191 |
{ |
|
192 |
TRAP_IGNORE(iObservers[i]->FeedUpdateAllCompleteL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate)); |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
EXPORT_C TBool CFeedEngine::UpdateFeedL(TUint aFeedUid) |
|
198 |
{ |
|
199 |
DP("FeedEngine::UpdateFeedL BEGIN"); |
|
200 |
iActiveFeed = GetFeedInfoByUid(aFeedUid); |
|
201 |
iCatchupCounter = 0; |
|
202 |
||
203 |
if (iActiveFeed->LastUpdated() == 0) |
|
204 |
{ |
|
205 |
iCatchupMode = ETrue; |
|
206 |
} |
|
207 |
||
208 |
iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); |
|
209 |
_LIT(KFileNameFormat, "%lu.xml"); |
|
210 |
iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid); |
|
211 |
||
212 |
if(iFeedClient->GetL(iActiveFeed->Url(), iUpdatingFeedFileName, iPodcastModel.SettingsEngine().SpecificIAP())) |
|
213 |
{ |
|
214 |
iClientState = EUpdatingFeed; |
|
215 |
||
216 |
for (TInt i=0;i<iObservers.Count();i++) |
|
217 |
{ |
|
218 |
TRAP_IGNORE(iObservers[i]->FeedDownloadStartedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid())); |
|
219 |
} |
|
220 |
||
221 |
DP("FeedEngine::UpdateFeedL END, return ETrue"); |
|
222 |
return ETrue; |
|
223 |
} |
|
224 |
else |
|
225 |
{ |
|
226 |
DP("FeedEngine::UpdateFeedL END, return EFalse"); |
|
227 |
return EFalse; |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
void CFeedEngine::NewShowL(CShowInfo& aItem) |
|
232 |
{ |
|
233 |
HBufC* description = HBufC::NewLC(KMaxDescriptionLength); |
|
234 |
TPtr ptr(description->Des()); |
|
235 |
ptr.Copy(aItem.Description()); |
|
236 |
PodcastUtils::CleanHtmlL(ptr); |
|
8 | 237 |
|
238 |
aItem.SetDescriptionL(*description); |
|
2 | 239 |
CleanupStack::PopAndDestroy(description); |
240 |
||
241 |
if (iCatchupMode) { |
|
242 |
// in catchup mode, we let one show be unplayed |
|
243 |
if (++iCatchupCounter > 1) { |
|
244 |
aItem.SetPlayState(EPlayed); |
|
245 |
} |
|
246 |
} |
|
247 |
||
248 |
TBool isShowAdded = iPodcastModel.ShowEngine().AddShowL(aItem); |
|
249 |
||
250 |
if (aItem.PlayState() == ENeverPlayed && isShowAdded && iPodcastModel.SettingsEngine().DownloadAutomatically()) |
|
251 |
{ |
|
252 |
iPodcastModel.ShowEngine().AddDownloadL(aItem); |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
void CFeedEngine::GetFeedImageL(CFeedInfo *aFeedInfo) |
|
257 |
{ |
|
258 |
DP("GetFeedImage"); |
|
259 |
||
260 |
TFileName filePath; |
|
261 |
filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); |
|
262 |
||
263 |
// create relative file name |
|
264 |
TFileName relPath; |
|
265 |
relPath.Copy(aFeedInfo->Title()); |
|
266 |
relPath.Append('\\'); |
|
267 |
||
268 |
TFileName fileName; |
|
269 |
PodcastUtils::FileNameFromUrl(aFeedInfo->ImageUrl(), fileName); |
|
270 |
relPath.Append(fileName); |
|
271 |
PodcastUtils::EnsureProperPathName(relPath); |
|
272 |
||
273 |
// complete file path is base dir + rel path |
|
274 |
filePath.Append(relPath); |
|
275 |
aFeedInfo->SetImageFileNameL(filePath); |
|
276 |
||
277 |
if(iFeedClient->GetL(aFeedInfo->ImageUrl(), filePath, ETrue)) |
|
278 |
{ |
|
279 |
iClientState = EUpdatingImage; |
|
280 |
} |
|
281 |
} |
|
282 |
||
283 |
EXPORT_C TBool CFeedEngine::AddFeedL(const CFeedInfo&aItem) |
|
284 |
{ |
|
285 |
DP2("CFeedEngine::AddFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
|
286 |
for (TInt i=0;i<iSortedFeeds.Count();i++) |
|
287 |
{ |
|
288 |
if (iSortedFeeds[i]->Uid() == aItem.Uid()) |
|
289 |
{ |
|
290 |
DP1("Already have feed %S, discarding", &aItem.Url()); |
|
291 |
return EFalse; |
|
292 |
} |
|
293 |
} |
|
294 |
||
295 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
296 |
CFeedInfo* newItem = aItem.CopyL(); |
|
297 |
CleanupStack::PushL(newItem); |
|
298 |
User::LeaveIfError(iSortedFeeds.InsertInOrder(newItem, sortOrder)); |
|
299 |
CleanupStack::Pop(newItem); |
|
300 |
||
301 |
||
302 |
// Save the feeds into DB |
|
303 |
DBAddFeedL(aItem); |
|
304 |
return ETrue; |
|
305 |
} |
|
306 |
||
307 |
TBool CFeedEngine::DBAddFeedL(const CFeedInfo& aItem) |
|
308 |
{ |
|
309 |
DP2("CFeedEngine::DBAddFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
|
310 |
||
311 |
CFeedInfo *info = DBGetFeedInfoByUidL(aItem.Uid()); |
|
312 |
if (info) { |
|
313 |
DP("Feed already exists!"); |
|
314 |
delete info; |
|
315 |
return EFalse; |
|
316 |
} |
|
317 |
||
318 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
|
319 |
TPtr titlePtr(titleBuf->Des()); |
|
320 |
titlePtr.Copy(aItem.Title()); |
|
321 |
PodcastUtils::SQLEncode(titlePtr); |
|
322 |
||
323 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
|
324 |
TPtr descPtr(descBuf->Des()); |
|
325 |
descPtr.Copy(aItem.Description()); |
|
326 |
PodcastUtils::SQLEncode(descPtr); |
|
327 |
||
328 |
_LIT(KSqlStatement, "insert into feeds (url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror)" |
|
329 |
" values (\"%S\",\"%S\", \"%S\", \"%S\", \"%S\", \"%S\", \"%Ld\", \"%Ld\", \"%u\", \"%u\", \"%u\", \"%d\")"); |
|
330 |
iSqlBuffer.Format(KSqlStatement, |
|
331 |
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
|
332 |
aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError()); |
|
333 |
||
334 |
CleanupStack::PopAndDestroy(descBuf); |
|
335 |
CleanupStack::PopAndDestroy(titleBuf); |
|
336 |
||
337 |
sqlite3_stmt *st; |
|
338 |
||
339 |
//DP1("SQL statement length=%d", iSqlBuffer.Length()); |
|
340 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
341 |
||
342 |
if (rc==SQLITE_OK) |
|
343 |
{ |
|
344 |
rc = sqlite3_step(st); |
|
345 |
||
346 |
if (rc == SQLITE_DONE) |
|
347 |
{ |
|
348 |
sqlite3_finalize(st); |
|
349 |
return ETrue; |
|
350 |
} |
|
351 |
else { |
|
352 |
sqlite3_finalize(st); |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
return EFalse; |
|
357 |
} |
|
358 |
||
359 |
EXPORT_C void CFeedEngine::RemoveFeedL(TUint aUid) |
|
360 |
{ |
|
361 |
for (int i=0;i<iSortedFeeds.Count();i++) |
|
362 |
{ |
|
363 |
if (iSortedFeeds[i]->Uid() == aUid) |
|
364 |
{ |
|
365 |
iPodcastModel.ShowEngine().DeleteAllShowsByFeedL(aUid); |
|
366 |
||
367 |
CFeedInfo* feedToRemove = iSortedFeeds[i]; |
|
368 |
||
369 |
//delete the image file if it exists |
|
370 |
if ((feedToRemove->ImageFileName().Length() >0) |
|
371 |
&& BaflUtils::FileExists(iPodcastModel.FsSession(), feedToRemove->ImageFileName())) |
|
372 |
{ |
|
373 |
iPodcastModel.FsSession().Delete(feedToRemove->ImageFileName()); |
|
374 |
} |
|
375 |
||
376 |
//delete the folder. It has the same name as the title. |
|
377 |
TFileName filePath; |
|
378 |
filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); |
|
379 |
filePath.Append(feedToRemove->Title()); |
|
380 |
filePath.Append('\\'); |
|
381 |
iPodcastModel.FsSession().RmDir(filePath); |
|
382 |
||
383 |
iSortedFeeds.Remove(i); |
|
384 |
delete feedToRemove; |
|
385 |
||
386 |
DP("Removed feed from array"); |
|
387 |
||
388 |
// now remove it from DB |
|
389 |
DBRemoveFeed(aUid); |
|
390 |
||
391 |
return; |
|
392 |
} |
|
393 |
} |
|
394 |
} |
|
395 |
||
396 |
||
397 |
TBool CFeedEngine::DBRemoveFeed(TUint aUid) |
|
398 |
{ |
|
399 |
DP("CFeedEngine::DBRemoveFeed"); |
|
400 |
_LIT(KSqlStatement, "delete from feeds where uid=%u"); |
|
401 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
402 |
||
403 |
sqlite3_stmt *st; |
|
404 |
||
405 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
406 |
||
407 |
if (rc==SQLITE_OK) |
|
408 |
{ |
|
409 |
rc = sqlite3_step(st); |
|
410 |
sqlite3_finalize(st); |
|
411 |
||
412 |
if (rc == SQLITE_DONE) |
|
413 |
{ |
|
414 |
DP("Feed removed from DB"); |
|
415 |
return ETrue; |
|
416 |
} |
|
417 |
else |
|
418 |
{ |
|
419 |
DP("Error when removing feed from DB"); |
|
420 |
} |
|
421 |
} |
|
422 |
return EFalse; |
|
423 |
} |
|
424 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
425 |
TBool CFeedEngine::DBUpdateFeedL(const CFeedInfo &aItem) |
2 | 426 |
{ |
427 |
DP2("CFeedEngine::DBUpdateFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
|
428 |
||
429 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
|
430 |
TPtr titlePtr(titleBuf->Des()); |
|
431 |
titlePtr.Copy(aItem.Title()); |
|
432 |
PodcastUtils::SQLEncode(titlePtr); |
|
433 |
||
434 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
|
435 |
TPtr descPtr(descBuf->Des()); |
|
436 |
descPtr.Copy(aItem.Description()); |
|
437 |
PodcastUtils::SQLEncode(descPtr); |
|
438 |
||
439 |
_LIT(KSqlStatement, "update feeds set url=\"%S\", title=\"%S\", description=\"%S\", imageurl=\"%S\", imagefile=\"%S\"," \ |
|
440 |
"link=\"%S\", built=\"%Lu\", lastupdated=\"%Lu\", feedtype=\"%u\", customtitle=\"%u\", lasterror=\"%d\" where uid=\"%u\""); |
|
441 |
iSqlBuffer.Format(KSqlStatement, |
|
442 |
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
|
443 |
aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.Uid()); |
|
444 |
||
445 |
CleanupStack::PopAndDestroy(descBuf); |
|
446 |
CleanupStack::PopAndDestroy(titleBuf); |
|
447 |
||
448 |
sqlite3_stmt *st; |
|
449 |
||
450 |
//DP1("SQL statement length=%d", iSqlBuffer.Length()); |
|
451 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
452 |
||
453 |
if (rc==SQLITE_OK) |
|
454 |
{ |
|
455 |
rc = sqlite3_step(st); |
|
456 |
sqlite3_finalize(st); |
|
457 |
||
458 |
if (rc == SQLITE_DONE) |
|
459 |
{ |
|
460 |
return ETrue; |
|
461 |
} |
|
462 |
} |
|
463 |
else |
|
464 |
{ |
|
465 |
DP1("SQLite rc=%d", rc); |
|
466 |
} |
|
467 |
||
468 |
return EFalse; |
|
469 |
} |
|
470 |
||
471 |
void CFeedEngine::ParsingCompleteL(CFeedInfo *item) |
|
472 |
{ |
|
473 |
TBuf<KMaxLineLength> title; |
|
474 |
title.Copy(item->Title()); |
|
8 | 475 |
item->SetTitleL(title); // if this leaves we are out of memory |
2 | 476 |
} |
477 |
||
478 |
||
479 |
EXPORT_C void CFeedEngine::AddObserver(MFeedEngineObserver *observer) |
|
480 |
{ |
|
481 |
iObservers.Append(observer); |
|
482 |
} |
|
483 |
||
484 |
EXPORT_C void CFeedEngine::RemoveObserver(MFeedEngineObserver *observer) |
|
485 |
{ |
|
486 |
TInt index = iObservers.Find(observer); |
|
487 |
||
488 |
if (index > KErrNotFound) |
|
489 |
{ |
|
490 |
iObservers.Remove(index); |
|
491 |
} |
|
492 |
} |
|
493 |
||
494 |
void CFeedEngine::Connected(CHttpClient* /*aClient*/) |
|
495 |
{ |
|
496 |
} |
|
497 |
||
498 |
void CFeedEngine::Progress(CHttpClient* /*aHttpClient*/, TInt /*aBytes*/, TInt /*aTotalBytes*/) |
|
499 |
{ |
|
500 |
} |
|
501 |
||
502 |
void CFeedEngine::CompleteL(CHttpClient* /*aClient*/, TInt aError) |
|
503 |
{ |
|
504 |
DP2("CFeedEngine::CompleteL BEGIN, iClientState=%d, aSuccessful=%d", iClientState, aError); |
|
505 |
||
506 |
switch(iClientState) |
|
507 |
{ |
|
508 |
default: |
|
509 |
if(iActiveFeed != NULL) |
|
510 |
{ |
|
511 |
TTime time; |
|
512 |
time.HomeTime(); |
|
513 |
iActiveFeed->SetLastUpdated(time); |
|
514 |
iActiveFeed->SetLastError(aError); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
515 |
NotifyFeedUpdateCompleteL(aError); |
2 | 516 |
} |
517 |
break; |
|
518 |
case EUpdatingFeed: |
|
519 |
{ |
|
520 |
// Parse the feed. We need to trap this call since it could leave and then |
|
521 |
// the whole update chain will be broken |
|
522 |
// change client state |
|
523 |
iClientState = EIdle; |
|
524 |
switch (aError) |
|
525 |
{ |
|
526 |
case KErrCancel: |
|
527 |
{ |
|
528 |
iFeedsUpdating.Reset(); |
|
529 |
} |
|
530 |
break; |
|
531 |
case KErrCouldNotConnect: |
|
532 |
iFeedsUpdating.Reset(); |
|
533 |
break; |
|
534 |
default: |
|
535 |
{ |
|
536 |
iActiveFeed->SetLastError(aError); |
|
537 |
TTime time; |
|
538 |
time.HomeTime(); |
|
539 |
iActiveFeed->SetLastUpdated(time); |
|
540 |
||
541 |
if( aError == KErrNone) |
|
542 |
{ |
|
543 |
TRAPD(parserErr, iParser->ParseFeedL(iUpdatingFeedFileName, iActiveFeed, iPodcastModel.SettingsEngine().MaxListItems())); |
|
544 |
||
545 |
if(parserErr) |
|
546 |
{ |
|
547 |
// we do not need to any special action on this error. |
|
548 |
iActiveFeed->SetLastError(parserErr); |
|
549 |
DP1("CFeedEngine::Complete()\t Failed to parse feed. Leave with error code=%d", parserErr); |
|
550 |
} |
|
551 |
else |
|
552 |
{ |
|
553 |
iPodcastModel.ShowEngine().DeleteOldShowsByFeed(iActiveFeed->Uid()); |
|
554 |
} |
|
555 |
||
556 |
// delete the downloaded XML file as it is no longer needed |
|
557 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(),iUpdatingFeedFileName); |
|
558 |
||
559 |
// if the feed has specified a image url. download it if we dont already have it |
|
560 |
if((iActiveFeed->ImageUrl().Length() > 0)) |
|
561 |
{ |
|
562 |
if ( (iActiveFeed->ImageFileName().Length() == 0) || |
|
563 |
(iActiveFeed->ImageFileName().Length() > 0 && |
|
564 |
!BaflUtils::FileExists(iPodcastModel.FsSession(), |
|
565 |
iActiveFeed->ImageFileName()) ) |
|
566 |
) |
|
567 |
{ |
|
568 |
TRAPD(error, GetFeedImageL(iActiveFeed)); |
|
569 |
if (error) |
|
570 |
{ |
|
571 |
// we have failed in a very early stage to fetch the image. |
|
572 |
// continue with next Feed update |
|
573 |
iActiveFeed->SetLastError(parserErr); |
|
574 |
iClientState = EIdle; |
|
575 |
} |
|
576 |
} |
|
577 |
} |
|
578 |
} |
|
579 |
}break; |
|
580 |
} |
|
581 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
582 |
NotifyFeedUpdateCompleteL(aError); |
7 | 583 |
|
584 |
// we will wait until the image has been downloaded to start the next feed update. |
|
585 |
if (iClientState == EIdle) |
|
586 |
{ |
|
587 |
UpdateNextFeedL(); |
|
588 |
} |
|
589 |
}break; |
|
590 |
case EUpdatingImage: |
|
591 |
{ |
|
592 |
// change client state to not updating |
|
593 |
iClientState = EIdle; |
|
594 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
595 |
NotifyFeedUpdateCompleteL(aError); |
7 | 596 |
UpdateNextFeedL(); |
597 |
}break; |
|
598 |
case ESearching: |
|
2 | 599 |
{ |
7 | 600 |
iClientState = EIdle; |
601 |
||
602 |
DP2("Search complete, results in %S with error %d", &iSearchResultsFileName, aError); |
|
603 |
if(aError == KErrNone) |
|
2 | 604 |
{ |
7 | 605 |
if (!iOpmlParser) |
606 |
{ |
|
607 |
iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession()); |
|
608 |
} |
|
609 |
||
610 |
DP("Parsing OPML"); |
|
611 |
iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue); |
|
2 | 612 |
} |
7 | 613 |
else |
614 |
{ |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
615 |
NotifyOpmlParsingCompleteL(aError, 0); |
7 | 616 |
} |
617 |
||
618 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName); |
|
619 |
}break; |
|
2 | 620 |
} |
621 |
DP("CFeedEngine::CompleteL END"); |
|
622 |
} |
|
623 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
624 |
void CFeedEngine::NotifyFeedUpdateCompleteL(TInt aError) |
2 | 625 |
{ |
626 |
DP("CFeedEngine::NotifyFeedUpdateComplete"); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
627 |
DBUpdateFeedL(*iActiveFeed); |
2 | 628 |
for (TInt i=0;i<iObservers.Count();i++) |
629 |
{ |
|
630 |
TRAP_IGNORE(iObservers[i]->FeedDownloadFinishedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid(), aError)); |
|
631 |
} |
|
632 |
} |
|
633 |
||
634 |
void CFeedEngine::Disconnected(CHttpClient* /*aClient*/) |
|
635 |
{ |
|
636 |
} |
|
637 |
||
638 |
void CFeedEngine::DownloadInfo(CHttpClient* /*aHttpClient */, int /*aTotalBytes*/) |
|
639 |
{ |
|
640 |
/*DP1("About to download %d bytes", aTotalBytes); |
|
641 |
if(aHttpClient == iShowClient && iShowDownloading != NULL && aTotalBytes != -1) { |
|
642 |
iShowDownloading->iShowSize = aTotalBytes; |
|
643 |
}*/ |
|
644 |
} |
|
645 |
||
646 |
EXPORT_C void CFeedEngine::ImportFeedsL(const TDesC& aFile) |
|
647 |
{ |
|
648 |
TFileName opmlPath; |
|
649 |
opmlPath.Copy(aFile); |
|
650 |
||
651 |
if (!iOpmlParser) { |
|
652 |
iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession()); |
|
653 |
} |
|
654 |
||
655 |
iOpmlParser->ParseOpmlL(opmlPath, EFalse); |
|
656 |
} |
|
657 |
||
658 |
EXPORT_C TBool CFeedEngine::ExportFeedsL(TFileName& aFile) |
|
659 |
{ |
|
660 |
RFile rfile; |
|
661 |
TFileName privatePath; |
|
662 |
iPodcastModel.FsSession().PrivatePath(privatePath); |
|
663 |
TInt error = rfile.Temp(iPodcastModel.FsSession(), privatePath, aFile, EFileWrite); |
|
664 |
if (error != KErrNone) |
|
665 |
{ |
|
666 |
DP("CFeedEngine::ExportFeedsL()\tFailed to open file"); |
|
667 |
return EFalse; |
|
668 |
} |
|
669 |
CleanupClosePushL(rfile); |
|
670 |
||
671 |
HBufC* templ = HBufC::NewLC(KMaxLineLength); |
|
672 |
templ->Des().Copy(KOpmlFeed()); |
|
673 |
||
674 |
HBufC* line = HBufC::NewLC(KMaxLineLength); |
|
675 |
HBufC* xmlUrl = HBufC::NewLC(KMaxURLLength); |
|
676 |
HBufC* htmlUrl = HBufC::NewLC(KMaxURLLength); |
|
677 |
HBufC* desc = HBufC::NewLC(KMaxDescriptionLength); |
|
678 |
HBufC* title = HBufC::NewLC(KMaxTitleLength); |
|
679 |
||
680 |
HBufC8* utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(KOpmlHeader()); |
|
681 |
||
682 |
rfile.Write(*utf8line); |
|
683 |
delete utf8line; |
|
684 |
||
685 |
for (int i=0; i<iSortedFeeds.Count(); i++) |
|
686 |
{ |
|
687 |
CFeedInfo *info = iSortedFeeds[i]; |
|
688 |
DP1("Exporting feed '%S'", &iSortedFeeds[i]->Title()); |
|
689 |
||
690 |
// XML URL |
|
691 |
TPtr ptrXml(xmlUrl->Des()); |
|
692 |
if (info->Url() != KNullDesC) |
|
693 |
{ |
|
694 |
ptrXml.Copy(info->Url()); |
|
695 |
PodcastUtils::XMLEncode(ptrXml); |
|
696 |
} |
|
697 |
||
698 |
// Description |
|
699 |
TPtr ptrDesc(desc->Des()); |
|
700 |
ptrDesc.Zero(); |
|
701 |
if (info->Description() != KNullDesC) { |
|
702 |
ptrDesc.Copy(info->Description()); |
|
703 |
PodcastUtils::XMLEncode(ptrDesc); |
|
704 |
} |
|
705 |
||
706 |
// Title |
|
707 |
TPtr ptrTitle(title->Des()); |
|
708 |
ptrTitle.Zero(); |
|
709 |
||
710 |
if (info->Title() != KNullDesC) { |
|
711 |
ptrTitle.Copy(info->Title()); |
|
712 |
PodcastUtils::XMLEncode(ptrTitle); |
|
713 |
} |
|
714 |
||
715 |
// HTML URL |
|
716 |
TPtr ptrHtmlUrl(htmlUrl->Des()); |
|
717 |
ptrHtmlUrl.Zero(); |
|
718 |
||
719 |
if (info->Link() != KNullDesC) { |
|
720 |
ptrHtmlUrl.Copy(info->Link()); |
|
721 |
PodcastUtils::XMLEncode(ptrHtmlUrl); |
|
722 |
} |
|
723 |
// Write line to OPML file |
|
724 |
line->Des().Format(*templ, title, desc, xmlUrl, htmlUrl); |
|
725 |
utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*line); |
|
726 |
rfile.Write(*utf8line); |
|
727 |
delete utf8line; |
|
728 |
} |
|
729 |
||
730 |
utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(KOpmlFooter()); |
|
731 |
rfile.Write(*utf8line); |
|
732 |
delete utf8line; |
|
733 |
||
734 |
CleanupStack::PopAndDestroy(7);//destroy 6 bufs & close rfile |
|
735 |
||
736 |
return ETrue; |
|
737 |
} |
|
738 |
||
739 |
EXPORT_C CFeedInfo* CFeedEngine::GetFeedInfoByUid(TUint aFeedUid) |
|
740 |
{ |
|
741 |
TInt cnt = iSortedFeeds.Count(); |
|
742 |
for (TInt i=0;i<cnt;i++) |
|
743 |
{ |
|
744 |
if (iSortedFeeds[i]->Uid() == aFeedUid) |
|
745 |
{ |
|
746 |
return iSortedFeeds[i]; |
|
747 |
} |
|
748 |
} |
|
749 |
||
750 |
return NULL; |
|
751 |
} |
|
752 |
||
753 |
EXPORT_C const RFeedInfoArray& CFeedEngine::GetSortedFeeds() |
|
754 |
{ |
|
755 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
756 |
||
757 |
iSortedFeeds.Sort(sortOrder); |
|
758 |
return iSortedFeeds; |
|
759 |
} |
|
760 |
||
761 |
TInt CFeedEngine::CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b) |
|
762 |
{ |
|
763 |
//DP2("Comparing %S to %S", &a.Title(), &b.Title()); |
|
764 |
return a.Title().CompareF(b.Title()); |
|
765 |
} |
|
766 |
||
767 |
EXPORT_C void CFeedEngine::GetDownloadedStats(TUint &aNumShows, TUint &aNumUnplayed) |
|
768 |
{ |
|
769 |
DP("CFeedEngine::GetDownloadedStats"); |
|
770 |
_LIT(KSqlStatement, "select count(*) from shows where downloadstate=%u"); |
|
771 |
iSqlBuffer.Format(KSqlStatement, EDownloaded); |
|
772 |
||
773 |
sqlite3_stmt *st; |
|
774 |
||
775 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
776 |
||
777 |
if( rc==SQLITE_OK ){ |
|
778 |
rc = sqlite3_step(st); |
|
779 |
||
780 |
if (rc == SQLITE_ROW) { |
|
781 |
aNumShows = sqlite3_column_int(st, 0); |
|
782 |
} |
|
783 |
} |
|
784 |
||
785 |
sqlite3_finalize(st); |
|
786 |
||
787 |
_LIT(KSqlStatement2, "select count(*) from shows where downloadstate=%u and playstate=%u"); |
|
788 |
iSqlBuffer.Format(KSqlStatement2, EDownloaded, ENeverPlayed); |
|
789 |
||
790 |
rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
791 |
||
792 |
if( rc==SQLITE_OK ){ |
|
793 |
rc = sqlite3_step(st); |
|
794 |
||
795 |
if (rc == SQLITE_ROW) { |
|
796 |
aNumUnplayed = sqlite3_column_int(st, 0); |
|
797 |
} |
|
798 |
} |
|
799 |
||
800 |
sqlite3_finalize(st); |
|
801 |
} |
|
802 |
||
803 |
EXPORT_C void CFeedEngine::GetStatsByFeed(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed) |
|
804 |
{ |
|
805 |
//DP1("CFeedEngine::GetStatsByFeed, aFeedUid=%u", aFeedUid); |
|
806 |
DBGetStatsByFeed(aFeedUid, aNumShows, aNumUnplayed); |
|
807 |
} |
|
808 |
||
809 |
void CFeedEngine::DBGetStatsByFeed(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed) |
|
810 |
{ |
|
811 |
//DP1("CFeedEngine::DBGetStatsByFeed, feedUid=%u", aFeedUid); |
|
812 |
_LIT(KSqlStatement, "select count(*) from shows where feeduid=%u"); |
|
813 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
814 |
||
815 |
sqlite3_stmt *st; |
|
816 |
||
817 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
818 |
||
819 |
if( rc==SQLITE_OK ){ |
|
820 |
rc = sqlite3_step(st); |
|
821 |
||
822 |
if (rc == SQLITE_ROW) { |
|
823 |
aNumShows = sqlite3_column_int(st, 0); |
|
824 |
} |
|
825 |
} |
|
826 |
||
827 |
sqlite3_finalize(st); |
|
828 |
||
829 |
_LIT(KSqlStatement2, "select count(*) from shows where feeduid=%u and playstate=0"); |
|
830 |
iSqlBuffer.Format(KSqlStatement2, aFeedUid); |
|
831 |
||
832 |
rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
833 |
||
834 |
if( rc==SQLITE_OK ){ |
|
835 |
rc = sqlite3_step(st); |
|
836 |
||
837 |
if (rc == SQLITE_ROW) { |
|
838 |
aNumUnplayed = sqlite3_column_int(st, 0); |
|
839 |
} |
|
840 |
} |
|
841 |
||
842 |
sqlite3_finalize(st); |
|
843 |
} |
|
844 |
||
845 |
TUint CFeedEngine::DBGetFeedCount() |
|
846 |
{ |
|
847 |
DP("DBGetFeedCount BEGIN"); |
|
848 |
sqlite3_stmt *st; |
|
849 |
int rc = sqlite3_prepare_v2(&iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); |
|
850 |
TUint size = 0; |
|
851 |
||
852 |
if( rc==SQLITE_OK ){ |
|
853 |
rc = sqlite3_step(st); |
|
854 |
||
855 |
if (rc == SQLITE_ROW) { |
|
856 |
size = sqlite3_column_int(st, 0); |
|
857 |
} |
|
858 |
} |
|
859 |
||
860 |
sqlite3_finalize(st); |
|
861 |
DP1("DBGetFeedCount END=%d", size); |
|
862 |
return size; |
|
863 |
} |
|
864 |
||
865 |
void CFeedEngine::DBLoadFeedsL() |
|
866 |
{ |
|
867 |
DP("DBLoadFeeds BEGIN"); |
|
868 |
iSortedFeeds.Reset(); |
|
869 |
CFeedInfo *feedInfo = NULL; |
|
870 |
||
871 |
_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle from feeds"); |
|
872 |
iSqlBuffer.Format(KSqlStatement); |
|
873 |
||
874 |
sqlite3_stmt *st; |
|
875 |
||
876 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
877 |
||
878 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
879 |
Cleanup_sqlite3_finalize_PushL(st); |
|
880 |
||
881 |
if (rc==SQLITE_OK) { |
|
882 |
rc = sqlite3_step(st); |
|
883 |
while(rc == SQLITE_ROW) { |
|
884 |
feedInfo = CFeedInfo::NewLC(); |
|
885 |
||
886 |
const void *urlz = sqlite3_column_text16(st, 0); |
|
887 |
TPtrC16 url((const TUint16*)urlz); |
|
888 |
feedInfo->SetUrlL(url); |
|
889 |
||
890 |
const void *titlez = sqlite3_column_text16(st, 1); |
|
891 |
TPtrC16 title((const TUint16*)titlez); |
|
892 |
feedInfo->SetTitleL(title); |
|
893 |
||
894 |
const void *descz = sqlite3_column_text16(st, 2); |
|
895 |
TPtrC16 desc((const TUint16*)descz); |
|
896 |
feedInfo->SetDescriptionL(desc); |
|
897 |
||
898 |
const void *imagez = sqlite3_column_text16(st, 3); |
|
899 |
TPtrC16 image((const TUint16*)imagez); |
|
900 |
feedInfo->SetImageUrlL(image); |
|
901 |
||
902 |
const void *imagefilez = sqlite3_column_text16(st, 4); |
|
903 |
TPtrC16 imagefile((const TUint16*)imagefilez); |
|
904 |
feedInfo->SetImageFileNameL(imagefile); |
|
905 |
||
906 |
const void *linkz = sqlite3_column_text16(st, 5); |
|
907 |
TPtrC16 link((const TUint16*)linkz); |
|
908 |
feedInfo->SetDescriptionL(link); |
|
909 |
||
910 |
sqlite3_int64 built = sqlite3_column_int64(st, 6); |
|
911 |
TTime buildtime(built); |
|
912 |
feedInfo->SetBuildDate(buildtime); |
|
913 |
||
914 |
sqlite3_int64 lastupdated = sqlite3_column_int64(st, 7); |
|
915 |
TTime lastupdatedtime(lastupdated); |
|
916 |
feedInfo->SetLastUpdated(lastupdatedtime); |
|
917 |
||
918 |
sqlite3_int64 customtitle = sqlite3_column_int64(st, 10); |
|
919 |
if (customtitle) { |
|
920 |
feedInfo->SetCustomTitle(); |
|
921 |
} |
|
922 |
||
923 |
TInt lasterror = sqlite3_column_int(st, 11); |
|
924 |
feedInfo->SetLastError(lasterror); |
|
925 |
||
926 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
927 |
||
928 |
iSortedFeeds.InsertInOrder(feedInfo, sortOrder); |
|
929 |
||
930 |
CleanupStack::Pop(feedInfo); |
|
931 |
||
932 |
rc = sqlite3_step(st); |
|
933 |
} |
|
934 |
} |
|
935 |
||
936 |
CleanupStack::PopAndDestroy();//st |
|
937 |
||
938 |
DP("DBLoadFeeds END"); |
|
939 |
} |
|
940 |
||
941 |
CFeedInfo* CFeedEngine::DBGetFeedInfoByUidL(TUint aFeedUid) |
|
942 |
{ |
|
943 |
DP("CFeedEngine::DBGetFeedInfoByUid"); |
|
944 |
CFeedInfo *feedInfo = NULL; |
|
945 |
_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds where uid=%u"); |
|
946 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
947 |
||
948 |
sqlite3_stmt *st; |
|
949 |
||
950 |
//DP1("SQL statement length=%d", iSqlBuffer.Length()); |
|
951 |
||
952 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
953 |
||
954 |
if (rc==SQLITE_OK) { |
|
955 |
Cleanup_sqlite3_finalize_PushL(st); |
|
956 |
rc = sqlite3_step(st); |
|
957 |
if (rc == SQLITE_ROW) { |
|
958 |
feedInfo = CFeedInfo::NewLC(); |
|
959 |
||
960 |
const void *urlz = sqlite3_column_text16(st, 0); |
|
961 |
TPtrC16 url((const TUint16*)urlz); |
|
962 |
feedInfo->SetUrlL(url); |
|
963 |
||
964 |
const void *titlez = sqlite3_column_text16(st, 1); |
|
965 |
TPtrC16 title((const TUint16*)titlez); |
|
966 |
feedInfo->SetTitleL(title); |
|
967 |
||
968 |
const void *descz = sqlite3_column_text16(st, 2); |
|
969 |
TPtrC16 desc((const TUint16*)descz); |
|
970 |
feedInfo->SetDescriptionL(desc); |
|
971 |
||
972 |
const void *imagez = sqlite3_column_text16(st, 3); |
|
973 |
TPtrC16 image((const TUint16*)imagez); |
|
974 |
feedInfo->SetImageUrlL(image); |
|
975 |
||
976 |
const void *imagefilez = sqlite3_column_text16(st, 4); |
|
977 |
TPtrC16 imagefile((const TUint16*)imagefilez); |
|
978 |
feedInfo->SetDescriptionL(imagefile); |
|
979 |
||
980 |
const void *linkz = sqlite3_column_text16(st, 5); |
|
981 |
TPtrC16 link((const TUint16*)linkz); |
|
982 |
feedInfo->SetDescriptionL(link); |
|
983 |
||
984 |
sqlite3_int64 built = sqlite3_column_int64(st, 6); |
|
985 |
TTime buildtime(built); |
|
986 |
feedInfo->SetBuildDate(buildtime); |
|
987 |
||
988 |
sqlite3_int64 lastupdated = sqlite3_column_int64(st, 7); |
|
989 |
TTime lastupdatedtime(lastupdated); |
|
990 |
feedInfo->SetLastUpdated(lastupdatedtime); |
|
991 |
||
992 |
sqlite3_int64 customtitle = sqlite3_column_int64(st, 10); |
|
993 |
if (customtitle) { |
|
994 |
feedInfo->SetCustomTitle(); |
|
995 |
} |
|
996 |
||
997 |
TInt lasterror = sqlite3_column_int(st, 11); |
|
998 |
feedInfo->SetLastError(lasterror); |
|
999 |
||
1000 |
CleanupStack::Pop(feedInfo); |
|
1001 |
} |
|
1002 |
CleanupStack::PopAndDestroy();//st |
|
1003 |
} |
|
1004 |
||
1005 |
return feedInfo; |
|
1006 |
} |
|
1007 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1008 |
EXPORT_C void CFeedEngine::UpdateFeedL(CFeedInfo *aItem) |
2 | 1009 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1010 |
DBUpdateFeedL(*aItem); |
2 | 1011 |
} |
1012 |
||
1013 |
EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString) |
|
1014 |
{ |
|
1015 |
DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString); |
|
1016 |
||
1017 |
if (iClientState != EIdle) { |
|
1018 |
User::Leave(KErrInUse); |
|
1019 |
} |
|
1020 |
TBuf<KMaxURLLength> ssBuf; |
|
1021 |
ssBuf.Copy(aSearchString); |
|
1022 |
PodcastUtils::ReplaceString(ssBuf, _L(" "), _L("%20")); |
|
1023 |
// prepare search URL |
|
1024 |
HBufC* templ = HBufC::NewLC(KMaxLineLength); |
|
1025 |
templ->Des().Copy(KSearchUrl()); |
|
1026 |
||
1027 |
HBufC* url = HBufC::NewLC(KMaxURLLength); |
|
1028 |
url->Des().Format(*templ, &ssBuf); |
|
1029 |
||
1030 |
DP1("SearchURL: %S", url); |
|
1031 |
||
1032 |
// crate path to store OPML search results |
|
1033 |
iPodcastModel.FsSession().PrivatePath(iSearchResultsFileName); |
|
1034 |
||
1035 |
iSearchResultsFileName.Append(KSearchResultsFileName); |
|
1036 |
iSearchResults.ResetAndDestroy(); |
|
1037 |
// run search |
|
1038 |
if(iFeedClient->GetL(*url, iSearchResultsFileName, iPodcastModel.SettingsEngine().SpecificIAP())) |
|
1039 |
{ |
|
1040 |
iClientState = ESearching; |
|
1041 |
} |
|
1042 |
else |
|
1043 |
{ |
|
1044 |
iClientState = EIdle; |
|
1045 |
User::Leave(KErrAbort); |
|
1046 |
} |
|
1047 |
||
1048 |
CleanupStack::PopAndDestroy(url); |
|
1049 |
CleanupStack::PopAndDestroy(templ); |
|
1050 |
||
1051 |
DP("FeedEngine::SearchForFeedL END"); |
|
1052 |
} |
|
1053 |
||
1054 |
EXPORT_C void CFeedEngine::AddSearchResultL(CFeedInfo *item) |
|
1055 |
{ |
|
1056 |
DP1("CFeedEngine::AddSearchResultL, item->Title()=%S", &(item->Title())); |
|
1057 |
iSearchResults.AppendL(item); |
|
1058 |
} |
|
1059 |
||
1060 |
EXPORT_C const RFeedInfoArray& CFeedEngine::GetSearchResults() |
|
1061 |
{ |
|
1062 |
return iSearchResults; |
|
1063 |
} |
|
1064 |
||
1065 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1066 |
EXPORT_C void CFeedEngine::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded) |
2 | 1067 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1068 |
NotifyOpmlParsingCompleteL(aError, aNumFeedsAdded); |
2 | 1069 |
} |
1070 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1071 |
void CFeedEngine::NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded) |
2 | 1072 |
{ |
1073 |
for (TInt i=0;i<iObservers.Count();i++) |
|
1074 |
{ |
|
7 | 1075 |
iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded); |
2 | 1076 |
} |
1077 |
} |