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