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