author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 23 Oct 2010 15:36:23 +0100 | |
branch | RCL_3 |
changeset 272 | e6d095ba6756 |
parent 255 | a13c58ace598 |
child 328 | 75a70f4a4f6d |
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; |
220
cc381e129dd5
Fix for bug 3709
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
187
diff
changeset
|
176 |
if ((iFeedsUpdating.Count() > 0) || (isOfflineProfile && aAutoUpdate)) |
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 |
{ |
|
255
a13c58ace598
Merged fix for bug 3797
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
220
diff
changeset
|
302 |
DP1("NewShowL, aItem.Title()=%S", &aItem.Title()); |
2 | 303 |
HBufC* description = HBufC::NewLC(KMaxDescriptionLength); |
304 |
TPtr ptr(description->Des()); |
|
305 |
ptr.Copy(aItem.Description()); |
|
306 |
PodcastUtils::CleanHtmlL(ptr); |
|
8 | 307 |
|
308 |
aItem.SetDescriptionL(*description); |
|
2 | 309 |
CleanupStack::PopAndDestroy(description); |
310 |
||
126 | 311 |
if (newFeed) { |
312 |
// for new feeds, set all shows played |
|
313 |
aItem.SetPlayState(EPlayed); |
|
314 |
// except the first one |
|
315 |
if (showsAdded == 0) { |
|
316 |
aItem.SetPlayState(ENeverPlayed); |
|
2 | 317 |
} |
318 |
} |
|
319 |
||
111 | 320 |
TRAPD(err, iPodcastModel.ShowEngine().AddShowL(aItem)); |
2 | 321 |
|
111 | 322 |
if (err == KErrNone && aItem.PlayState() == ENeverPlayed && |
323 |
iPodcastModel.SettingsEngine().DownloadAutomatically()) |
|
2 | 324 |
{ |
325 |
iPodcastModel.ShowEngine().AddDownloadL(aItem); |
|
126 | 326 |
} |
327 |
||
328 |
showsAdded++; |
|
2 | 329 |
} |
330 |
||
331 |
void CFeedEngine::GetFeedImageL(CFeedInfo *aFeedInfo) |
|
332 |
{ |
|
333 |
DP("GetFeedImage"); |
|
334 |
||
335 |
TFileName filePath; |
|
336 |
filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); |
|
337 |
||
338 |
// create relative file name |
|
339 |
TFileName relPath; |
|
340 |
relPath.Copy(aFeedInfo->Title()); |
|
341 |
relPath.Append('\\'); |
|
342 |
||
343 |
TFileName fileName; |
|
344 |
PodcastUtils::FileNameFromUrl(aFeedInfo->ImageUrl(), fileName); |
|
345 |
relPath.Append(fileName); |
|
346 |
PodcastUtils::EnsureProperPathName(relPath); |
|
347 |
||
348 |
// complete file path is base dir + rel path |
|
349 |
filePath.Append(relPath); |
|
100
e0fc52a5df4d
Update to keep features from merge.
Lars Persson <lars.persson@embeddev.se>
parents:
99
diff
changeset
|
350 |
aFeedInfo->SetImageFileNameL(filePath, NULL); |
2 | 351 |
|
352 |
if(iFeedClient->GetL(aFeedInfo->ImageUrl(), filePath, ETrue)) |
|
353 |
{ |
|
354 |
iClientState = EUpdatingImage; |
|
355 |
} |
|
356 |
} |
|
357 |
||
358 |
EXPORT_C TBool CFeedEngine::AddFeedL(const CFeedInfo&aItem) |
|
359 |
{ |
|
360 |
DP2("CFeedEngine::AddFeed, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
|
361 |
for (TInt i=0;i<iSortedFeeds.Count();i++) |
|
362 |
{ |
|
363 |
if (iSortedFeeds[i]->Uid() == aItem.Uid()) |
|
364 |
{ |
|
365 |
DP1("Already have feed %S, discarding", &aItem.Url()); |
|
366 |
return EFalse; |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
371 |
CFeedInfo* newItem = aItem.CopyL(); |
|
372 |
CleanupStack::PushL(newItem); |
|
373 |
User::LeaveIfError(iSortedFeeds.InsertInOrder(newItem, sortOrder)); |
|
374 |
CleanupStack::Pop(newItem); |
|
375 |
||
376 |
||
377 |
// Save the feeds into DB |
|
378 |
DBAddFeedL(aItem); |
|
379 |
return ETrue; |
|
380 |
} |
|
381 |
||
109 | 382 |
void CFeedEngine::DBAddFeedL(const CFeedInfo& aItem) |
2 | 383 |
{ |
152 | 384 |
DP2("CFeedEngine::DBAddFeed BEGIN, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
2 | 385 |
|
109 | 386 |
CFeedInfo *info; |
387 |
||
116 | 388 |
TRAPD(err, info = DBGetFeedInfoByUidL(aItem.Uid())); |
109 | 389 |
|
390 |
if (err == KErrNone && info) { |
|
2 | 391 |
delete info; |
109 | 392 |
User::Leave(KErrAlreadyExists); |
2 | 393 |
} |
394 |
||
395 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
|
396 |
TPtr titlePtr(titleBuf->Des()); |
|
397 |
titlePtr.Copy(aItem.Title()); |
|
398 |
PodcastUtils::SQLEncode(titlePtr); |
|
399 |
||
400 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
|
401 |
TPtr descPtr(descBuf->Des()); |
|
402 |
descPtr.Copy(aItem.Description()); |
|
403 |
PodcastUtils::SQLEncode(descPtr); |
|
404 |
||
141
ee650bbb958e
Fix for bug 2836 - split string literals causing RVCT compile to fail
teknolog
parents:
126
diff
changeset
|
405 |
_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 | 406 |
iSqlBuffer.Format(KSqlStatement, |
407 |
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
|
408 |
aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError()); |
|
409 |
||
410 |
CleanupStack::PopAndDestroy(descBuf); |
|
411 |
CleanupStack::PopAndDestroy(titleBuf); |
|
412 |
||
413 |
sqlite3_stmt *st; |
|
414 |
||
415 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
416 |
||
417 |
if (rc==SQLITE_OK) |
|
418 |
{ |
|
109 | 419 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 420 |
rc = sqlite3_step(st); |
421 |
||
109 | 422 |
if (rc != SQLITE_DONE) |
2 | 423 |
{ |
109 | 424 |
User::Leave(KErrCorrupt); |
2 | 425 |
} |
109 | 426 |
CleanupStack::PopAndDestroy(); // st |
2 | 427 |
} |
109 | 428 |
else |
429 |
{ |
|
430 |
User::Leave(KErrCorrupt); |
|
431 |
} |
|
152 | 432 |
DP("CFeedEngine::DBAddFeed END"); |
2 | 433 |
} |
434 |
||
435 |
EXPORT_C void CFeedEngine::RemoveFeedL(TUint aUid) |
|
436 |
{ |
|
102
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
437 |
if (iActiveFeed && iActiveFeed->Uid() == aUid) |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
438 |
{ |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
439 |
User::Leave(KErrInUse); |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
440 |
} |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
441 |
|
2 | 442 |
for (int i=0;i<iSortedFeeds.Count();i++) |
443 |
{ |
|
444 |
if (iSortedFeeds[i]->Uid() == aUid) |
|
445 |
{ |
|
446 |
iPodcastModel.ShowEngine().DeleteAllShowsByFeedL(aUid); |
|
53 | 447 |
|
2 | 448 |
CFeedInfo* feedToRemove = iSortedFeeds[i]; |
449 |
||
450 |
//delete the image file if it exists |
|
451 |
if ((feedToRemove->ImageFileName().Length() >0) |
|
452 |
&& BaflUtils::FileExists(iPodcastModel.FsSession(), feedToRemove->ImageFileName())) |
|
453 |
{ |
|
454 |
iPodcastModel.FsSession().Delete(feedToRemove->ImageFileName()); |
|
455 |
} |
|
456 |
||
457 |
//delete the folder. It has the same name as the title. |
|
458 |
TFileName filePath; |
|
459 |
filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); |
|
460 |
filePath.Append(feedToRemove->Title()); |
|
461 |
filePath.Append('\\'); |
|
462 |
iPodcastModel.FsSession().RmDir(filePath); |
|
463 |
||
464 |
iSortedFeeds.Remove(i); |
|
465 |
delete feedToRemove; |
|
466 |
||
467 |
DP("Removed feed from array"); |
|
468 |
||
469 |
// now remove it from DB |
|
109 | 470 |
DBRemoveFeedL(aUid); |
2 | 471 |
} |
472 |
} |
|
473 |
} |
|
474 |
||
475 |
||
109 | 476 |
void CFeedEngine::DBRemoveFeedL(TUint aUid) |
2 | 477 |
{ |
152 | 478 |
DP("CFeedEngine::DBRemoveFeed BEGIN"); |
2 | 479 |
_LIT(KSqlStatement, "delete from feeds where uid=%u"); |
480 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
481 |
||
482 |
sqlite3_stmt *st; |
|
483 |
||
484 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
485 |
||
486 |
if (rc==SQLITE_OK) |
|
487 |
{ |
|
109 | 488 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 489 |
rc = sqlite3_step(st); |
490 |
||
109 | 491 |
if (rc != SQLITE_DONE) |
2 | 492 |
{ |
109 | 493 |
User::Leave(KErrNotFound); |
2 | 494 |
} |
109 | 495 |
|
496 |
CleanupStack::PopAndDestroy(); //st |
|
2 | 497 |
} |
109 | 498 |
else |
499 |
{ |
|
500 |
User::Leave(KErrCorrupt); |
|
501 |
} |
|
152 | 502 |
DP("CFeedEngine::DBRemoveFeed END"); |
2 | 503 |
} |
504 |
||
109 | 505 |
void CFeedEngine::DBUpdateFeedL(const CFeedInfo &aItem) |
2 | 506 |
{ |
152 | 507 |
DP2("CFeedEngine::DBUpdateFeed BEGIN, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
2 | 508 |
|
509 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
|
510 |
TPtr titlePtr(titleBuf->Des()); |
|
511 |
titlePtr.Copy(aItem.Title()); |
|
512 |
PodcastUtils::SQLEncode(titlePtr); |
|
513 |
||
514 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
|
515 |
TPtr descPtr(descBuf->Des()); |
|
516 |
descPtr.Copy(aItem.Description()); |
|
517 |
PodcastUtils::SQLEncode(descPtr); |
|
518 |
||
141
ee650bbb958e
Fix for bug 2836 - split string literals causing RVCT compile to fail
teknolog
parents:
126
diff
changeset
|
519 |
_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 | 520 |
iSqlBuffer.Format(KSqlStatement, |
521 |
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(), |
|
522 |
aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.Uid()); |
|
523 |
||
524 |
CleanupStack::PopAndDestroy(descBuf); |
|
525 |
CleanupStack::PopAndDestroy(titleBuf); |
|
526 |
||
527 |
sqlite3_stmt *st; |
|
528 |
||
529 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
530 |
||
531 |
if (rc==SQLITE_OK) |
|
532 |
{ |
|
109 | 533 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 534 |
rc = sqlite3_step(st); |
535 |
||
109 | 536 |
if (rc != SQLITE_DONE) |
2 | 537 |
{ |
109 | 538 |
User::Leave(KErrNotFound); |
2 | 539 |
} |
109 | 540 |
CleanupStack::PopAndDestroy(); //st |
2 | 541 |
} |
542 |
else |
|
543 |
{ |
|
109 | 544 |
User::Leave(KErrCorrupt); |
2 | 545 |
} |
152 | 546 |
DP("CFeedEngine::DBUpdateFeed END"); |
2 | 547 |
} |
548 |
||
549 |
void CFeedEngine::ParsingCompleteL(CFeedInfo *item) |
|
550 |
{ |
|
551 |
TBuf<KMaxLineLength> title; |
|
552 |
title.Copy(item->Title()); |
|
8 | 553 |
item->SetTitleL(title); // if this leaves we are out of memory |
2 | 554 |
} |
555 |
||
556 |
||
557 |
EXPORT_C void CFeedEngine::AddObserver(MFeedEngineObserver *observer) |
|
558 |
{ |
|
559 |
iObservers.Append(observer); |
|
560 |
} |
|
561 |
||
562 |
EXPORT_C void CFeedEngine::RemoveObserver(MFeedEngineObserver *observer) |
|
563 |
{ |
|
564 |
TInt index = iObservers.Find(observer); |
|
565 |
||
566 |
if (index > KErrNotFound) |
|
567 |
{ |
|
568 |
iObservers.Remove(index); |
|
569 |
} |
|
570 |
} |
|
571 |
||
572 |
void CFeedEngine::Connected(CHttpClient* /*aClient*/) |
|
573 |
{ |
|
574 |
} |
|
575 |
||
576 |
void CFeedEngine::Progress(CHttpClient* /*aHttpClient*/, TInt /*aBytes*/, TInt /*aTotalBytes*/) |
|
577 |
{ |
|
578 |
} |
|
579 |
||
580 |
void CFeedEngine::CompleteL(CHttpClient* /*aClient*/, TInt aError) |
|
581 |
{ |
|
582 |
DP2("CFeedEngine::CompleteL BEGIN, iClientState=%d, aSuccessful=%d", iClientState, aError); |
|
583 |
||
584 |
switch(iClientState) |
|
585 |
{ |
|
586 |
case EUpdatingFeed: |
|
587 |
{ |
|
588 |
iClientState = EIdle; |
|
589 |
switch (aError) |
|
590 |
{ |
|
591 |
case KErrCancel: |
|
592 |
{ |
|
593 |
iFeedsUpdating.Reset(); |
|
594 |
} |
|
595 |
break; |
|
596 |
case KErrCouldNotConnect: |
|
597 |
iFeedsUpdating.Reset(); |
|
598 |
break; |
|
599 |
default: |
|
600 |
{ |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
601 |
if (!iCancelRequested) { |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
602 |
iActiveFeed->SetLastError(aError); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
603 |
TTime time; |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
604 |
time.HomeTime(); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
605 |
iActiveFeed->SetLastUpdated(time); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
606 |
|
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
607 |
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
|
608 |
{ |
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 |
// 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
|
610 |
// 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
|
611 |
// 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
|
612 |
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
|
613 |
|
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
614 |
if(parserErr) |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
615 |
{ |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
616 |
// 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
|
617 |
iActiveFeed->SetLastError(parserErr); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
618 |
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
|
619 |
} |
126 | 620 |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
621 |
// 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
|
622 |
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
|
623 |
|
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
624 |
// 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
|
625 |
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
|
626 |
{ |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
627 |
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
|
628 |
(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
|
629 |
!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
|
630 |
iActiveFeed->ImageFileName()) ) |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
631 |
) |
2 | 632 |
{ |
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
633 |
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
|
634 |
if (error) |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
635 |
{ |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
636 |
// 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
|
637 |
// 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
|
638 |
iActiveFeed->SetLastError(parserErr); |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
639 |
iClientState = EIdle; |
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 |
} |
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
642 |
} |
2 | 643 |
} |
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
644 |
else |
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
645 |
{ |
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
646 |
// 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
|
647 |
iClientState = EIdle; |
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
648 |
} |
2 | 649 |
} |
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
8
diff
changeset
|
650 |
iCancelRequested = EFalse; |
2 | 651 |
}break; |
652 |
} |
|
107
af6475fdf8d6
Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents:
106
diff
changeset
|
653 |
DBUpdateFeedL(*iActiveFeed); |
96 | 654 |
NotifyFeedUpdateComplete(iActiveFeed->Uid(), aError); |
655 |
||
7 | 656 |
// we will wait until the image has been downloaded to start the next feed update. |
657 |
if (iClientState == EIdle) |
|
658 |
{ |
|
659 |
UpdateNextFeedL(); |
|
660 |
} |
|
661 |
}break; |
|
662 |
case EUpdatingImage: |
|
663 |
{ |
|
664 |
// change client state to not updating |
|
665 |
iClientState = EIdle; |
|
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
666 |
if(aError == KErrNone) |
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
667 |
{ |
109 | 668 |
// now the image has been downloaded, so we set it again in the FeedInfo to start |
669 |
// converting it |
|
110
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
teknolog
parents:
109
diff
changeset
|
670 |
HBufC *fileNameCopy = iActiveFeed->ImageFileName().AllocLC(); |
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
teknolog
parents:
109
diff
changeset
|
671 |
TRAP_IGNORE(iActiveFeed->SetImageFileNameL(*fileNameCopy, &iPodcastModel)); |
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
teknolog
parents:
109
diff
changeset
|
672 |
CleanupStack::PopAndDestroy(fileNameCopy); |
91
87cb33beeae2
Remove icon index. Start caching icons as mbms.
Lars Persson <lars.persson@embeddev.se>
parents:
32
diff
changeset
|
673 |
} |
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
|
674 |
DBUpdateFeedL(*iActiveFeed); |
96 | 675 |
NotifyFeedUpdateComplete(iActiveFeed->Uid(), aError); |
7 | 676 |
UpdateNextFeedL(); |
677 |
}break; |
|
678 |
case ESearching: |
|
2 | 679 |
{ |
7 | 680 |
iClientState = EIdle; |
681 |
||
682 |
DP2("Search complete, results in %S with error %d", &iSearchResultsFileName, aError); |
|
683 |
if(aError == KErrNone) |
|
2 | 684 |
{ |
7 | 685 |
if (!iOpmlParser) |
686 |
{ |
|
687 |
iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession()); |
|
688 |
} |
|
689 |
||
690 |
DP("Parsing OPML"); |
|
691 |
iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue); |
|
2 | 692 |
} |
7 | 693 |
else |
694 |
{ |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
695 |
NotifyOpmlParsingCompleteL(aError, 0); |
7 | 696 |
} |
697 |
||
698 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName); |
|
699 |
}break; |
|
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
700 |
case EIdle: |
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
701 |
UpdateNextFeedL(); |
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
702 |
break; |
102
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
703 |
default: |
114 | 704 |
Panic(EPodcatcherPanicFeedEngineState); |
102
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
705 |
break; |
2 | 706 |
} |
707 |
DP("CFeedEngine::CompleteL END"); |
|
708 |
} |
|
709 |
||
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
|
710 |
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
|
711 |
{ |
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 |
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
|
713 |
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
|
714 |
{ |
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 |
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
|
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 |
} |
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
|
718 |
|
2 | 719 |
void CFeedEngine::Disconnected(CHttpClient* /*aClient*/) |
720 |
{ |
|
721 |
} |
|
722 |
||
723 |
void CFeedEngine::DownloadInfo(CHttpClient* /*aHttpClient */, int /*aTotalBytes*/) |
|
724 |
{ |
|
725 |
} |
|
726 |
||
727 |
EXPORT_C void CFeedEngine::ImportFeedsL(const TDesC& aFile) |
|
728 |
{ |
|
729 |
TFileName opmlPath; |
|
730 |
opmlPath.Copy(aFile); |
|
731 |
||
732 |
if (!iOpmlParser) { |
|
733 |
iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession()); |
|
734 |
} |
|
735 |
||
736 |
iOpmlParser->ParseOpmlL(opmlPath, EFalse); |
|
737 |
} |
|
738 |
||
739 |
EXPORT_C TBool CFeedEngine::ExportFeedsL(TFileName& aFile) |
|
740 |
{ |
|
741 |
RFile rfile; |
|
742 |
TFileName privatePath; |
|
743 |
iPodcastModel.FsSession().PrivatePath(privatePath); |
|
744 |
TInt error = rfile.Temp(iPodcastModel.FsSession(), privatePath, aFile, EFileWrite); |
|
745 |
if (error != KErrNone) |
|
746 |
{ |
|
747 |
DP("CFeedEngine::ExportFeedsL()\tFailed to open file"); |
|
748 |
return EFalse; |
|
749 |
} |
|
750 |
CleanupClosePushL(rfile); |
|
751 |
||
752 |
HBufC* templ = HBufC::NewLC(KMaxLineLength); |
|
753 |
templ->Des().Copy(KOpmlFeed()); |
|
754 |
||
755 |
HBufC* line = HBufC::NewLC(KMaxLineLength); |
|
756 |
HBufC* xmlUrl = HBufC::NewLC(KMaxURLLength); |
|
757 |
HBufC* htmlUrl = HBufC::NewLC(KMaxURLLength); |
|
758 |
HBufC* desc = HBufC::NewLC(KMaxDescriptionLength); |
|
759 |
HBufC* title = HBufC::NewLC(KMaxTitleLength); |
|
760 |
||
761 |
HBufC8* utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(KOpmlHeader()); |
|
762 |
||
763 |
rfile.Write(*utf8line); |
|
764 |
delete utf8line; |
|
765 |
||
766 |
for (int i=0; i<iSortedFeeds.Count(); i++) |
|
767 |
{ |
|
768 |
CFeedInfo *info = iSortedFeeds[i]; |
|
769 |
DP1("Exporting feed '%S'", &iSortedFeeds[i]->Title()); |
|
770 |
||
771 |
// XML URL |
|
772 |
TPtr ptrXml(xmlUrl->Des()); |
|
773 |
if (info->Url() != KNullDesC) |
|
774 |
{ |
|
775 |
ptrXml.Copy(info->Url()); |
|
776 |
PodcastUtils::XMLEncode(ptrXml); |
|
777 |
} |
|
778 |
||
779 |
// Description |
|
780 |
TPtr ptrDesc(desc->Des()); |
|
781 |
ptrDesc.Zero(); |
|
782 |
if (info->Description() != KNullDesC) { |
|
783 |
ptrDesc.Copy(info->Description()); |
|
784 |
PodcastUtils::XMLEncode(ptrDesc); |
|
785 |
} |
|
786 |
||
787 |
// Title |
|
788 |
TPtr ptrTitle(title->Des()); |
|
789 |
ptrTitle.Zero(); |
|
790 |
||
791 |
if (info->Title() != KNullDesC) { |
|
792 |
ptrTitle.Copy(info->Title()); |
|
793 |
PodcastUtils::XMLEncode(ptrTitle); |
|
794 |
} |
|
795 |
||
796 |
// HTML URL |
|
797 |
TPtr ptrHtmlUrl(htmlUrl->Des()); |
|
798 |
ptrHtmlUrl.Zero(); |
|
799 |
||
800 |
if (info->Link() != KNullDesC) { |
|
801 |
ptrHtmlUrl.Copy(info->Link()); |
|
802 |
PodcastUtils::XMLEncode(ptrHtmlUrl); |
|
803 |
} |
|
804 |
// Write line to OPML file |
|
805 |
line->Des().Format(*templ, title, desc, xmlUrl, htmlUrl); |
|
806 |
utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*line); |
|
807 |
rfile.Write(*utf8line); |
|
808 |
delete utf8line; |
|
809 |
} |
|
810 |
||
811 |
utf8line = CnvUtfConverter::ConvertFromUnicodeToUtf8L(KOpmlFooter()); |
|
812 |
rfile.Write(*utf8line); |
|
813 |
delete utf8line; |
|
814 |
||
815 |
CleanupStack::PopAndDestroy(7);//destroy 6 bufs & close rfile |
|
816 |
||
817 |
return ETrue; |
|
818 |
} |
|
819 |
||
820 |
EXPORT_C CFeedInfo* CFeedEngine::GetFeedInfoByUid(TUint aFeedUid) |
|
821 |
{ |
|
822 |
TInt cnt = iSortedFeeds.Count(); |
|
823 |
for (TInt i=0;i<cnt;i++) |
|
824 |
{ |
|
825 |
if (iSortedFeeds[i]->Uid() == aFeedUid) |
|
826 |
{ |
|
827 |
return iSortedFeeds[i]; |
|
828 |
} |
|
829 |
} |
|
830 |
||
831 |
return NULL; |
|
832 |
} |
|
833 |
||
834 |
EXPORT_C const RFeedInfoArray& CFeedEngine::GetSortedFeeds() |
|
835 |
{ |
|
836 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
837 |
||
838 |
iSortedFeeds.Sort(sortOrder); |
|
839 |
return iSortedFeeds; |
|
840 |
} |
|
841 |
||
842 |
TInt CFeedEngine::CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b) |
|
843 |
{ |
|
844 |
//DP2("Comparing %S to %S", &a.Title(), &b.Title()); |
|
845 |
return a.Title().CompareF(b.Title()); |
|
846 |
} |
|
847 |
||
109 | 848 |
EXPORT_C void CFeedEngine::GetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed) |
2 | 849 |
{ |
109 | 850 |
//DP1("CFeedEngine::GetStatsByFeed, aFeedUid=%u", aFeedUid); |
851 |
DBGetStatsByFeedL(aFeedUid, aNumShows, aNumUnplayed); |
|
2 | 852 |
} |
853 |
||
109 | 854 |
void CFeedEngine::DBGetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed) |
2 | 855 |
{ |
856 |
//DP1("CFeedEngine::DBGetStatsByFeed, feedUid=%u", aFeedUid); |
|
857 |
_LIT(KSqlStatement, "select count(*) from shows where feeduid=%u"); |
|
858 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
859 |
||
860 |
sqlite3_stmt *st; |
|
861 |
||
862 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
863 |
||
109 | 864 |
if( rc==SQLITE_OK) |
865 |
{ |
|
866 |
Cleanup_sqlite3_finalize_PushL(st); |
|
2 | 867 |
rc = sqlite3_step(st); |
868 |
||
109 | 869 |
if (rc == SQLITE_ROW) |
870 |
{ |
|
2 | 871 |
aNumShows = sqlite3_column_int(st, 0); |
109 | 872 |
} |
873 |
else |
|
874 |
{ |
|
875 |
User::Leave(KErrNotFound); |
|
876 |
} |
|
877 |
CleanupStack::PopAndDestroy(); // st |
|
878 |
} |
|
879 |
else |
|
880 |
{ |
|
881 |
User::Leave(KErrCorrupt); |
|
882 |
} |
|
2 | 883 |
|
884 |
_LIT(KSqlStatement2, "select count(*) from shows where feeduid=%u and playstate=0"); |
|
885 |
iSqlBuffer.Format(KSqlStatement2, aFeedUid); |
|
886 |
||
887 |
rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
888 |
||
109 | 889 |
if(rc==SQLITE_OK) |
890 |
{ |
|
891 |
Cleanup_sqlite3_finalize_PushL(st); |
|
2 | 892 |
rc = sqlite3_step(st); |
893 |
||
109 | 894 |
if (rc == SQLITE_ROW) |
895 |
{ |
|
2 | 896 |
aNumUnplayed = sqlite3_column_int(st, 0); |
109 | 897 |
} |
898 |
else |
|
899 |
{ |
|
900 |
User::Leave(KErrNotFound); |
|
901 |
} |
|
902 |
CleanupStack::PopAndDestroy(); // st |
|
2 | 903 |
} |
904 |
} |
|
905 |
||
109 | 906 |
TUint CFeedEngine::DBGetFeedCountL() |
2 | 907 |
{ |
109 | 908 |
DP("DBGetFeedCount BEGIN"); |
909 |
sqlite3_stmt *st; |
|
910 |
int rc = sqlite3_prepare_v2(&iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); |
|
911 |
TUint size = 0; |
|
2 | 912 |
|
109 | 913 |
if( rc==SQLITE_OK ) |
914 |
{ |
|
915 |
Cleanup_sqlite3_finalize_PushL(st); |
|
916 |
rc = sqlite3_step(st); |
|
917 |
||
918 |
if (rc == SQLITE_ROW) |
|
919 |
{ |
|
2 | 920 |
size = sqlite3_column_int(st, 0); |
109 | 921 |
} |
922 |
else |
|
923 |
{ |
|
924 |
User::Leave(KErrCorrupt); |
|
925 |
} |
|
926 |
CleanupStack::PopAndDestroy(); // st |
|
927 |
} |
|
928 |
else |
|
929 |
{ |
|
930 |
User::Leave(KErrCorrupt); |
|
931 |
} |
|
932 |
||
933 |
DP1("DBGetFeedCount END=%d", size); |
|
934 |
return size; |
|
2 | 935 |
} |
936 |
||
937 |
void CFeedEngine::DBLoadFeedsL() |
|
938 |
{ |
|
939 |
DP("DBLoadFeeds BEGIN"); |
|
940 |
iSortedFeeds.Reset(); |
|
941 |
CFeedInfo *feedInfo = NULL; |
|
942 |
||
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
943 |
_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds"); |
2 | 944 |
iSqlBuffer.Format(KSqlStatement); |
945 |
||
946 |
sqlite3_stmt *st; |
|
947 |
||
948 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
949 |
||
950 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
|
951 |
||
109 | 952 |
if (rc==SQLITE_OK) |
953 |
{ |
|
954 |
Cleanup_sqlite3_finalize_PushL(st); |
|
2 | 955 |
rc = sqlite3_step(st); |
109 | 956 |
while(rc == SQLITE_ROW) |
957 |
{ |
|
2 | 958 |
feedInfo = CFeedInfo::NewLC(); |
959 |
||
960 |
const void *urlz = sqlite3_column_text16(st, 0); |
|
961 |
TPtrC16 url((const TUint16*)urlz); |
|
962 |
feedInfo->SetUrlL(url); |
|
963 |
||
964 |
const void *titlez = sqlite3_column_text16(st, 1); |
|
965 |
TPtrC16 title((const TUint16*)titlez); |
|
966 |
feedInfo->SetTitleL(title); |
|
967 |
||
968 |
const void *descz = sqlite3_column_text16(st, 2); |
|
969 |
TPtrC16 desc((const TUint16*)descz); |
|
970 |
feedInfo->SetDescriptionL(desc); |
|
971 |
||
972 |
const void *imagez = sqlite3_column_text16(st, 3); |
|
973 |
TPtrC16 image((const TUint16*)imagez); |
|
974 |
feedInfo->SetImageUrlL(image); |
|
975 |
||
976 |
const void *imagefilez = sqlite3_column_text16(st, 4); |
|
977 |
TPtrC16 imagefile((const TUint16*)imagefilez); |
|
109 | 978 |
if (imagefile.Length() > 0) |
979 |
{ |
|
980 |
feedInfo->SetImageFileNameL(imagefile, &iPodcastModel); |
|
981 |
} |
|
982 |
||
2 | 983 |
const void *linkz = sqlite3_column_text16(st, 5); |
984 |
TPtrC16 link((const TUint16*)linkz); |
|
985 |
feedInfo->SetDescriptionL(link); |
|
986 |
||
987 |
sqlite3_int64 built = sqlite3_column_int64(st, 6); |
|
988 |
TTime buildtime(built); |
|
989 |
feedInfo->SetBuildDate(buildtime); |
|
990 |
||
991 |
sqlite3_int64 lastupdated = sqlite3_column_int64(st, 7); |
|
992 |
TTime lastupdatedtime(lastupdated); |
|
993 |
feedInfo->SetLastUpdated(lastupdatedtime); |
|
994 |
||
995 |
sqlite3_int64 customtitle = sqlite3_column_int64(st, 10); |
|
109 | 996 |
if (customtitle) |
997 |
{ |
|
2 | 998 |
feedInfo->SetCustomTitle(); |
109 | 999 |
} |
2 | 1000 |
|
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
116
diff
changeset
|
1001 |
sqlite3_int64 lasterror = sqlite3_column_int(st, 11); |
2 | 1002 |
feedInfo->SetLastError(lasterror); |
1003 |
||
1004 |
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle); |
|
1005 |
||
1006 |
iSortedFeeds.InsertInOrder(feedInfo, sortOrder); |
|
1007 |
||
1008 |
CleanupStack::Pop(feedInfo); |
|
1009 |
||
1010 |
rc = sqlite3_step(st); |
|
109 | 1011 |
} |
1012 |
CleanupStack::PopAndDestroy();//st |
|
2 | 1013 |
} |
109 | 1014 |
else |
1015 |
{ |
|
1016 |
User::Leave(KErrCorrupt); |
|
1017 |
} |
|
2 | 1018 |
|
1019 |
DP("DBLoadFeeds END"); |
|
1020 |
} |
|
1021 |
||
1022 |
CFeedInfo* CFeedEngine::DBGetFeedInfoByUidL(TUint aFeedUid) |
|
1023 |
{ |
|
152 | 1024 |
DP("CFeedEngine::DBGetFeedInfoByUid BEGIN"); |
2 | 1025 |
CFeedInfo *feedInfo = NULL; |
1026 |
_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds where uid=%u"); |
|
1027 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
1028 |
||
1029 |
sqlite3_stmt *st; |
|
109 | 1030 |
|
2 | 1031 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*)iSqlBuffer.PtrZ() , -1, &st, (const void**) NULL); |
1032 |
||
109 | 1033 |
if (rc==SQLITE_OK) |
1034 |
{ |
|
2 | 1035 |
Cleanup_sqlite3_finalize_PushL(st); |
1036 |
rc = sqlite3_step(st); |
|
109 | 1037 |
if (rc == SQLITE_ROW) |
1038 |
{ |
|
2 | 1039 |
feedInfo = CFeedInfo::NewLC(); |
1040 |
||
1041 |
const void *urlz = sqlite3_column_text16(st, 0); |
|
1042 |
TPtrC16 url((const TUint16*)urlz); |
|
1043 |
feedInfo->SetUrlL(url); |
|
1044 |
||
1045 |
const void *titlez = sqlite3_column_text16(st, 1); |
|
1046 |
TPtrC16 title((const TUint16*)titlez); |
|
1047 |
feedInfo->SetTitleL(title); |
|
1048 |
||
1049 |
const void *descz = sqlite3_column_text16(st, 2); |
|
1050 |
TPtrC16 desc((const TUint16*)descz); |
|
1051 |
feedInfo->SetDescriptionL(desc); |
|
1052 |
||
1053 |
const void *imagez = sqlite3_column_text16(st, 3); |
|
1054 |
TPtrC16 image((const TUint16*)imagez); |
|
1055 |
feedInfo->SetImageUrlL(image); |
|
1056 |
||
1057 |
const void *imagefilez = sqlite3_column_text16(st, 4); |
|
1058 |
TPtrC16 imagefile((const TUint16*)imagefilez); |
|
1059 |
feedInfo->SetDescriptionL(imagefile); |
|
1060 |
||
1061 |
const void *linkz = sqlite3_column_text16(st, 5); |
|
1062 |
TPtrC16 link((const TUint16*)linkz); |
|
1063 |
feedInfo->SetDescriptionL(link); |
|
1064 |
||
1065 |
sqlite3_int64 built = sqlite3_column_int64(st, 6); |
|
1066 |
TTime buildtime(built); |
|
1067 |
feedInfo->SetBuildDate(buildtime); |
|
1068 |
||
1069 |
sqlite3_int64 lastupdated = sqlite3_column_int64(st, 7); |
|
1070 |
TTime lastupdatedtime(lastupdated); |
|
1071 |
feedInfo->SetLastUpdated(lastupdatedtime); |
|
1072 |
||
1073 |
sqlite3_int64 customtitle = sqlite3_column_int64(st, 10); |
|
1074 |
if (customtitle) { |
|
1075 |
feedInfo->SetCustomTitle(); |
|
1076 |
} |
|
1077 |
||
1078 |
TInt lasterror = sqlite3_column_int(st, 11); |
|
1079 |
feedInfo->SetLastError(lasterror); |
|
1080 |
||
1081 |
CleanupStack::Pop(feedInfo); |
|
109 | 1082 |
} |
1083 |
else |
|
1084 |
{ |
|
1085 |
User::Leave(KErrNotFound); |
|
1086 |
} |
|
2 | 1087 |
CleanupStack::PopAndDestroy();//st |
109 | 1088 |
} |
1089 |
else |
|
1090 |
{ |
|
1091 |
User::Leave(KErrNotFound); |
|
1092 |
} |
|
152 | 1093 |
DP("CFeedEngine::DBGetFeedInfoByUid END"); |
2 | 1094 |
return feedInfo; |
1095 |
} |
|
1096 |
||
102
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1097 |
EXPORT_C void CFeedEngine::UpdateFeedInfoL(CFeedInfo *aItem) |
2 | 1098 |
{ |
102
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1099 |
if (iActiveFeed && iActiveFeed->Uid() == aItem->Uid()) |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1100 |
{ |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1101 |
User::Leave(KErrInUse); |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1102 |
} |
04c6ccce8e7e
Fix for bug 2408. Improved feed engine robustness.
teknolog
parents:
100
diff
changeset
|
1103 |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1104 |
DBUpdateFeedL(*aItem); |
2 | 1105 |
} |
1106 |
||
1107 |
EXPORT_C void CFeedEngine::SearchForFeedL(TDesC& aSearchString) |
|
1108 |
{ |
|
1109 |
DP1("FeedEngine::SearchForFeedL BEGIN, aSearchString=%S", &aSearchString); |
|
1110 |
||
1111 |
if (iClientState != EIdle) { |
|
1112 |
User::Leave(KErrInUse); |
|
1113 |
} |
|
1114 |
TBuf<KMaxURLLength> ssBuf; |
|
1115 |
ssBuf.Copy(aSearchString); |
|
1116 |
PodcastUtils::ReplaceString(ssBuf, _L(" "), _L("%20")); |
|
1117 |
// prepare search URL |
|
1118 |
HBufC* templ = HBufC::NewLC(KMaxLineLength); |
|
1119 |
templ->Des().Copy(KSearchUrl()); |
|
1120 |
||
1121 |
HBufC* url = HBufC::NewLC(KMaxURLLength); |
|
1122 |
url->Des().Format(*templ, &ssBuf); |
|
1123 |
||
1124 |
DP1("SearchURL: %S", url); |
|
1125 |
||
1126 |
// crate path to store OPML search results |
|
1127 |
iPodcastModel.FsSession().PrivatePath(iSearchResultsFileName); |
|
1128 |
||
1129 |
iSearchResultsFileName.Append(KSearchResultsFileName); |
|
1130 |
iSearchResults.ResetAndDestroy(); |
|
1131 |
// run search |
|
1132 |
if(iFeedClient->GetL(*url, iSearchResultsFileName, iPodcastModel.SettingsEngine().SpecificIAP())) |
|
1133 |
{ |
|
1134 |
iClientState = ESearching; |
|
1135 |
} |
|
1136 |
else |
|
1137 |
{ |
|
1138 |
iClientState = EIdle; |
|
1139 |
User::Leave(KErrAbort); |
|
1140 |
} |
|
1141 |
||
1142 |
CleanupStack::PopAndDestroy(url); |
|
1143 |
CleanupStack::PopAndDestroy(templ); |
|
1144 |
||
1145 |
DP("FeedEngine::SearchForFeedL END"); |
|
1146 |
} |
|
1147 |
||
1148 |
EXPORT_C void CFeedEngine::AddSearchResultL(CFeedInfo *item) |
|
1149 |
{ |
|
1150 |
DP1("CFeedEngine::AddSearchResultL, item->Title()=%S", &(item->Title())); |
|
1151 |
iSearchResults.AppendL(item); |
|
1152 |
} |
|
1153 |
||
1154 |
EXPORT_C const RFeedInfoArray& CFeedEngine::GetSearchResults() |
|
1155 |
{ |
|
1156 |
return iSearchResults; |
|
1157 |
} |
|
1158 |
||
1159 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1160 |
EXPORT_C void CFeedEngine::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded) |
2 | 1161 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1162 |
NotifyOpmlParsingCompleteL(aError, aNumFeedsAdded); |
2 | 1163 |
} |
1164 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
1165 |
void CFeedEngine::NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded) |
2 | 1166 |
{ |
1167 |
for (TInt i=0;i<iObservers.Count();i++) |
|
1168 |
{ |
|
7 | 1169 |
iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded); |
2 | 1170 |
} |
1171 |
} |