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