author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 23 Oct 2010 17:11:38 +0100 | |
branch | 3rded |
changeset 278 | e6aa20533d01 |
parent 167 | 4bfc2fcec5f6 |
child 212 | 713bd6cc0b7a |
child 279 | 5a44ec2f6f4d |
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 "ShowEngine.h" |
|
20 |
#include "FeedEngine.h" |
|
21 |
#include "FeedInfo.h" |
|
22 |
#include <bautils.h> |
|
23 |
#include <s32file.h> |
|
24 |
#include "SettingsEngine.h" |
|
25 |
#include <e32hashtab.h> |
|
26 |
#include <httperr.h> |
|
27 |
#include "debug.h" |
|
28 |
#include "PodcastUtils.h" |
|
29 |
||
30 |
const TUint KMaxDownloadErrors = 3; |
|
31 |
const TInt KMimeBufLength = 100; |
|
32 |
||
33 |
CShowEngine::CShowEngine(CPodcastModel& aPodcastModel) : |
|
34 |
iPodcastModel(aPodcastModel), |
|
35 |
iDB(*aPodcastModel.DB()) |
|
36 |
{ |
|
37 |
} |
|
38 |
||
39 |
EXPORT_C CShowEngine::~CShowEngine() |
|
40 |
{ |
|
41 |
delete iShowClient; |
|
42 |
iObservers.Close(); |
|
43 |
delete iShowDownloading; |
|
44 |
delete iMetaDataReader; |
|
45 |
iApaSession.Close(); |
|
46 |
} |
|
47 |
||
48 |
EXPORT_C CShowEngine* CShowEngine::NewL(CPodcastModel& aPodcastModel) |
|
49 |
{ |
|
50 |
CShowEngine* self = new (ELeave) CShowEngine(aPodcastModel); |
|
51 |
CleanupStack::PushL(self); |
|
52 |
self->ConstructL(); |
|
53 |
CleanupStack::Pop(self); |
|
54 |
return self; |
|
55 |
} |
|
56 |
||
57 |
EXPORT_C void CShowEngine::GetMimeType(const TDesC& aFileName, TDes& aMimeType) |
|
58 |
{ |
|
59 |
aMimeType.Zero(); |
|
60 |
RFile file; |
|
61 |
if (file.Open(iPodcastModel.FsSession(), aFileName, 0) == KErrNone) |
|
62 |
{ |
|
63 |
if (file.Read(iRecogBuffer) == KErrNone) |
|
64 |
{ |
|
65 |
TDataRecognitionResult result; |
|
66 |
if (iApaSession.RecognizeData(aFileName, iRecogBuffer, result) |
|
67 |
== KErrNone) |
|
68 |
{ |
|
69 |
aMimeType.Copy(result.iDataType.Des()); |
|
70 |
} |
|
71 |
||
72 |
} |
|
73 |
} |
|
74 |
file.Close(); |
|
75 |
} |
|
76 |
||
77 |
void CShowEngine::ConstructL() |
|
78 |
{ |
|
79 |
iShowClient = CHttpClient::NewL(iPodcastModel, *this); |
|
80 |
iShowClient->SetResumeEnabled(ETrue); |
|
81 |
iMetaDataReader = new (ELeave) CMetaDataReader(*this, iPodcastModel.FsSession()); |
|
82 |
iMetaDataReader->ConstructL(); |
|
83 |
User::LeaveIfError(iApaSession.Connect()); |
|
84 |
} |
|
85 |
||
86 |
EXPORT_C void CShowEngine::SuspendDownloads() |
|
87 |
{ |
|
88 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
89 |
iShowClient->Stop(); |
|
90 |
} |
|
91 |
||
92 |
EXPORT_C void CShowEngine::ResumeDownloadsL() |
|
93 |
{ |
|
94 |
DP("CShowEngine::ResumeDownloadsL BEGIN"); |
|
95 |
if (iPodcastModel.SettingsEngine().DownloadSuspended()) |
|
96 |
{ |
|
97 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(EFalse); |
|
98 |
iDownloadErrors = 0; |
|
99 |
DownloadNextShowL(); |
|
100 |
} |
|
101 |
DP("CShowEngine::ResumeDownloadsL END"); |
|
102 |
} |
|
103 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
104 |
EXPORT_C void CShowEngine::RemoveAllDownloadsL() |
2 | 105 |
{ |
106 |
if (!iPodcastModel.SettingsEngine().DownloadSuspended()) |
|
107 |
{ |
|
108 |
SuspendDownloads(); |
|
109 |
} |
|
110 |
||
60 | 111 |
DBRemoveAllDownloadsL(); |
22 | 112 |
NotifyDownloadQueueUpdatedL(); |
2 | 113 |
} |
114 |
||
60 | 115 |
EXPORT_C void CShowEngine::RemoveDownloadL(TUint aUid) |
2 | 116 |
{ |
60 | 117 |
DP("CShowEngine::RemoveDownloadL BEGIN"); |
2 | 118 |
|
119 |
TBool resumeAfterRemove = EFalse; |
|
120 |
// if trying to remove the present download, we first stop it |
|
121 |
if (!iPodcastModel.SettingsEngine().DownloadSuspended() && iShowDownloading != NULL |
|
122 |
&& iShowDownloading->Uid() == aUid) |
|
123 |
{ |
|
124 |
DP("CShowEngine::RemoveDownload\t This is the active download, we suspend downloading"); |
|
125 |
SuspendDownloads(); |
|
60 | 126 |
|
127 |
// partial downloads should be removed |
|
128 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), iShowDownloading->FileName()); |
|
129 |
||
2 | 130 |
resumeAfterRemove = ETrue; |
131 |
} |
|
132 |
||
133 |
CShowInfo *info = DBGetShowByUidL(aUid); |
|
134 |
if (info != NULL) |
|
135 |
{ |
|
136 |
info->SetDownloadState(ENotDownloaded); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
137 |
DBUpdateShowL(*info); |
2 | 138 |
delete info; |
139 |
} |
|
60 | 140 |
|
141 |
DBRemoveDownloadL(aUid); |
|
2 | 142 |
|
60 | 143 |
if (resumeAfterRemove) |
2 | 144 |
{ |
60 | 145 |
ResumeDownloadsL(); |
2 | 146 |
} |
60 | 147 |
else |
148 |
{ |
|
149 |
NotifyShowDownloadUpdatedL(-1, -1); |
|
150 |
NotifyDownloadQueueUpdatedL(); |
|
151 |
} |
|
2 | 152 |
|
153 |
DownloadNextShowL(); |
|
60 | 154 |
DP("CShowEngine::RemoveDownloadL END"); |
2 | 155 |
} |
156 |
||
157 |
void CShowEngine::Connected(CHttpClient* /*aClient*/) |
|
158 |
{ |
|
159 |
||
160 |
} |
|
161 |
||
162 |
void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes, |
|
163 |
TInt aTotalBytes) |
|
164 |
{ |
|
165 |
iShowDownloading->SetShowSize(aTotalBytes); |
|
166 |
TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes)); |
|
167 |
} |
|
168 |
||
169 |
void CShowEngine::Disconnected(CHttpClient* /*aClient */) |
|
170 |
{ |
|
171 |
} |
|
172 |
||
173 |
void CShowEngine::DownloadInfo(CHttpClient* aHttpClient, TInt aTotalBytes) |
|
174 |
{ |
|
167
4bfc2fcec5f6
Proposed fix for bug 2931
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
175 |
DP1("CShowEngine::DownloadInfo, About to download %d bytes", aTotalBytes); |
2 | 176 |
} |
177 |
||
60 | 178 |
void CShowEngine::GetShowL(CShowInfo *info) |
2 | 179 |
{ |
180 |
CFeedInfo *feedInfo = iPodcastModel.FeedEngine().GetFeedInfoByUid( |
|
181 |
info->FeedUid()); |
|
60 | 182 |
|
2 | 183 |
TFileName filePath; |
184 |
filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); |
|
185 |
||
186 |
TFileName relPath; |
|
187 |
relPath.Copy(feedInfo->Title()); |
|
188 |
relPath.Append('\\'); |
|
189 |
||
190 |
TFileName fileName; |
|
191 |
PodcastUtils::FileNameFromUrl(info->Url(), fileName); |
|
192 |
relPath.Append(fileName); |
|
193 |
PodcastUtils::EnsureProperPathName(relPath); |
|
194 |
||
195 |
// complete file path is base dir + rel path |
|
196 |
filePath.Append(relPath); |
|
197 |
info->SetFileNameL(filePath); |
|
198 |
||
60 | 199 |
User::LeaveIfError(iShowClient->GetL(info->Url(), filePath)); |
2 | 200 |
} |
201 |
||
60 | 202 |
EXPORT_C void CShowEngine::AddShowL(const CShowInfo& aItem) |
2 | 203 |
{ |
204 |
DP1("CShowEngine::AddShowL, title=%S", &aItem.Title()); |
|
205 |
CShowInfo *showInfo = DBGetShowByUidL(aItem.Uid()); |
|
206 |
||
207 |
if (showInfo == NULL) |
|
208 |
{ |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
209 |
DBAddShowL(aItem); |
2 | 210 |
} |
211 |
else |
|
212 |
{ |
|
213 |
delete showInfo; |
|
60 | 214 |
User::Leave(KErrAlreadyExists); |
2 | 215 |
} |
216 |
} |
|
217 |
||
218 |
EXPORT_C void CShowEngine::AddObserver(MShowEngineObserver *observer) |
|
219 |
{ |
|
220 |
iObservers.Append(observer); |
|
221 |
} |
|
222 |
||
223 |
EXPORT_C void CShowEngine::RemoveObserver(MShowEngineObserver *observer) |
|
224 |
{ |
|
225 |
TInt index = iObservers.Find(observer); |
|
226 |
||
227 |
if (index > KErrNotFound) |
|
228 |
{ |
|
229 |
iObservers.Remove(index); |
|
230 |
} |
|
231 |
} |
|
232 |
||
233 |
void CShowEngine::AddShowToMpxCollection(CShowInfo &/*aShowInfo*/) |
|
234 |
{ |
|
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
149
diff
changeset
|
235 |
// do nothing (right now) |
2 | 236 |
} |
237 |
||
238 |
void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) |
|
239 |
{ |
|
240 |
if (iShowDownloading != NULL) |
|
241 |
{ |
|
60 | 242 |
DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError); |
2 | 243 |
if(aError != KErrCouldNotConnect) |
244 |
{ |
|
6 | 245 |
if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended()) |
246 |
{ |
|
2 | 247 |
// no error if disconnect happened because of suspended downloading |
6 | 248 |
} |
249 |
else |
|
250 |
{ |
|
2 | 251 |
iShowDownloading->SetLastError(aError); |
6 | 252 |
} |
2 | 253 |
|
254 |
if (aError == KErrNone) |
|
255 |
{ |
|
256 |
TBuf<KMimeBufLength> mimeType; |
|
257 |
GetMimeType(iShowDownloading->FileName(), mimeType); |
|
258 |
_LIT(KMimeAudio,"audio"); |
|
259 |
_LIT(KMimeVideo,"video"); |
|
260 |
if (mimeType.Left(5) == KMimeAudio) |
|
261 |
{ |
|
262 |
iShowDownloading->SetShowType(EAudioPodcast); |
|
263 |
} |
|
264 |
else if (mimeType.Left(5) == KMimeVideo) |
|
265 |
{ |
|
266 |
iShowDownloading->SetShowType(EVideoPodcast); |
|
267 |
} |
|
268 |
||
269 |
iShowDownloading->SetDownloadState(EDownloaded); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
270 |
DBUpdateShowL(*iShowDownloading); |
60 | 271 |
DBRemoveDownloadL(iShowDownloading->Uid()); |
2 | 272 |
AddShowToMpxCollection(*iShowDownloading); |
273 |
NotifyShowFinishedL(aError); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
6
diff
changeset
|
274 |
iDownloadErrors = 0; |
2 | 275 |
delete iShowDownloading; |
276 |
iShowDownloading = NULL; |
|
277 |
} |
|
278 |
else |
|
279 |
{ |
|
280 |
// 400 and 500 series errors are serious errors on which probably another download will fail |
|
281 |
if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) |
|
282 |
{ |
|
283 |
iShowDownloading->SetDownloadState(EFailedDownload); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
284 |
DBUpdateShowL(*iShowDownloading); |
60 | 285 |
DBRemoveDownloadL(iShowDownloading->Uid()); |
2 | 286 |
NotifyShowFinishedL(aError); |
287 |
||
288 |
delete iShowDownloading; |
|
289 |
iShowDownloading = NULL; |
|
290 |
} |
|
60 | 291 |
else if (aError == KErrDiskFull) |
292 |
{ |
|
293 |
// stop downloading immediately if disk is full |
|
294 |
iShowDownloading->SetDownloadState(EQueued); |
|
295 |
DBUpdateShowL(*iShowDownloading); |
|
296 |
iDownloadErrors = KMaxDownloadErrors; |
|
297 |
} |
|
2 | 298 |
else // other kind of error, missing network etc, reque this show |
299 |
{ |
|
300 |
iShowDownloading->SetDownloadState(EQueued); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
301 |
DBUpdateShowL(*iShowDownloading); |
2 | 302 |
} |
303 |
||
60 | 304 |
NotifyDownloadQueueUpdatedL(); |
2 | 305 |
iDownloadErrors++; |
60 | 306 |
if (iDownloadErrors >= KMaxDownloadErrors) |
2 | 307 |
{ |
308 |
DP("Too many downloading errors, suspending downloads"); |
|
309 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
310 |
NotifyShowFinishedL(aError); |
|
311 |
} |
|
312 |
} |
|
313 |
DownloadNextShowL(); |
|
314 |
} |
|
315 |
||
316 |
else |
|
317 |
{ |
|
318 |
// Connection error |
|
319 |
if(iShowDownloading) |
|
320 |
{ |
|
321 |
iShowDownloading->SetDownloadState(EQueued); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
322 |
DBUpdateShowL(*iShowDownloading); |
2 | 323 |
} |
324 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
325 |
NotifyShowFinishedL(aError); |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
||
330 |
EXPORT_C CShowInfo* CShowEngine::ShowDownloading() |
|
331 |
{ |
|
332 |
return iShowDownloading; |
|
333 |
} |
|
334 |
||
335 |
EXPORT_C CShowInfo* CShowEngine::GetShowByUidL(TUint aShowUid) |
|
336 |
{ |
|
337 |
return DBGetShowByUidL(aShowUid); |
|
338 |
} |
|
339 |
CShowInfo* CShowEngine::DBGetShowByUidL(TUint aUid) |
|
340 |
{ |
|
341 |
DP("CShowEngine::DBGetShowByUid"); |
|
342 |
CShowInfo *showInfo = NULL; |
|
343 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows where uid=%u"); |
|
344 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
345 |
||
346 |
sqlite3_stmt *st; |
|
347 |
||
348 |
//DP1("SQL: %S", &iSqlBuffer.Left(KSqlDPLen)); |
|
349 |
||
350 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
351 |
&st, (const void**) NULL); |
|
352 |
||
353 |
if (rc == SQLITE_OK) |
|
354 |
{ |
|
355 |
rc = sqlite3_step(st); |
|
356 |
Cleanup_sqlite3_finalize_PushL(st); |
|
357 |
if (rc == SQLITE_ROW) |
|
358 |
{ |
|
359 |
showInfo = CShowInfo::NewLC(); |
|
360 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
361 |
CleanupStack::Pop(showInfo); |
|
362 |
} |
|
363 |
CleanupStack::PopAndDestroy();//st |
|
364 |
} |
|
365 |
||
366 |
return showInfo; |
|
367 |
} |
|
368 |
||
369 |
EXPORT_C CShowInfo* CShowEngine::DBGetShowByFileNameL(TFileName aFileName) |
|
370 |
{ |
|
371 |
DP("CShowEngine::DBGetShowByUid"); |
|
372 |
CShowInfo *showInfo = NULL; |
|
373 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows where filename=\"%S\""); |
|
374 |
iSqlBuffer.Format(KSqlStatement, &aFileName); |
|
375 |
||
376 |
sqlite3_stmt *st; |
|
377 |
||
378 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
379 |
&st, (const void**) NULL); |
|
380 |
||
381 |
if (rc == SQLITE_OK) |
|
382 |
{ |
|
383 |
rc = sqlite3_step(st); |
|
384 |
Cleanup_sqlite3_finalize_PushL(st); |
|
385 |
if (rc == SQLITE_ROW) |
|
386 |
{ |
|
387 |
showInfo = CShowInfo::NewLC(); |
|
388 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
389 |
CleanupStack::Pop(showInfo); |
|
390 |
} |
|
391 |
CleanupStack::PopAndDestroy();//st |
|
392 |
} |
|
393 |
||
394 |
return showInfo; |
|
395 |
} |
|
396 |
||
397 |
void CShowEngine::DBGetAllShowsL(RShowInfoArray& aShowArray) |
|
398 |
{ |
|
399 |
DP("CShowEngine::DBGetAllShows"); |
|
400 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows"); |
|
401 |
iSqlBuffer.Format(KSqlStatement); |
|
402 |
||
403 |
sqlite3_stmt *st; |
|
404 |
||
405 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
406 |
&st, (const void**) NULL); |
|
407 |
||
408 |
if (rc == SQLITE_OK) |
|
409 |
{ |
|
410 |
rc = sqlite3_step(st); |
|
411 |
Cleanup_sqlite3_finalize_PushL(st); |
|
412 |
while (rc == SQLITE_ROW) |
|
413 |
{ |
|
414 |
CShowInfo* showInfo = CShowInfo::NewLC(); |
|
415 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
416 |
aShowArray.Append(showInfo); |
|
417 |
CleanupStack::Pop(showInfo); |
|
418 |
rc = sqlite3_step(st); |
|
419 |
} |
|
420 |
CleanupStack::PopAndDestroy();//st |
|
421 |
} |
|
422 |
||
423 |
} |
|
424 |
||
425 |
void CShowEngine::DBGetAllDownloadsL(RShowInfoArray& aShowArray) |
|
426 |
{ |
|
427 |
DP("CShowEngine::DBGetAllDownloads"); |
|
428 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror from downloads, shows where downloads.uid=shows.uid"); |
|
429 |
iSqlBuffer.Format(KSqlStatement); |
|
430 |
||
431 |
#ifndef DONT_SORT_SQL |
|
432 |
_LIT(KSqlSort, " order by dl_index"); |
|
433 |
iSqlBuffer.Append(KSqlSort); |
|
434 |
#endif |
|
435 |
sqlite3_stmt *st; |
|
436 |
||
437 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
438 |
&st, (const void**) NULL); |
|
439 |
||
440 |
if (rc == SQLITE_OK) |
|
441 |
{ |
|
442 |
rc = sqlite3_step(st); |
|
443 |
Cleanup_sqlite3_finalize_PushL(st); |
|
444 |
while (rc == SQLITE_ROW) |
|
445 |
{ |
|
446 |
CShowInfo* showInfo = CShowInfo::NewLC(); |
|
447 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
448 |
aShowArray.Append(showInfo); |
|
449 |
CleanupStack::Pop(showInfo); |
|
450 |
rc = sqlite3_step(st); |
|
451 |
} |
|
452 |
CleanupStack::PopAndDestroy();//st |
|
453 |
} |
|
60 | 454 |
else |
455 |
{ |
|
456 |
User::Leave(KErrCorrupt); |
|
457 |
} |
|
2 | 458 |
|
459 |
// delete downloads that don't have a show |
|
460 |
||
461 |
_LIT(KSqlStatement2, "delete from downloads where uid not in (select downloads.uid from shows, downloads where shows.uid=downloads.uid)"); |
|
462 |
iSqlBuffer.Format(KSqlStatement2); |
|
463 |
||
464 |
rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, (const void**) NULL); |
|
465 |
||
466 |
if (rc == SQLITE_OK) |
|
467 |
{ |
|
60 | 468 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 469 |
rc = sqlite3_step(st); |
60 | 470 |
CleanupStack::PopAndDestroy(); // st |
471 |
} |
|
472 |
else |
|
473 |
{ |
|
474 |
User::Leave(KErrCorrupt); |
|
2 | 475 |
} |
476 |
} |
|
477 |
||
478 |
CShowInfo* CShowEngine::DBGetNextDownloadL() |
|
479 |
{ |
|
480 |
DP("CShowEngine::DBGetNextDownload"); |
|
481 |
CShowInfo *showInfo = NULL; |
|
482 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror from downloads, shows where downloads.uid=shows.uid"); |
|
483 |
iSqlBuffer.Format(KSqlStatement); |
|
484 |
||
485 |
#ifdef DONT_SORT_SQL |
|
486 |
_LIT(KSqlSort, " limit 1"); |
|
487 |
iSqlBuffer.Append(KSqlSort); |
|
488 |
#else |
|
489 |
_LIT(KSqlNoSort, " order by dl_index limit 1"); |
|
490 |
iSqlBuffer.Append(KSqlNoSort); |
|
491 |
#endif |
|
492 |
||
493 |
sqlite3_stmt *st; |
|
494 |
||
495 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
496 |
&st, (const void**) NULL); |
|
497 |
||
498 |
if (rc == SQLITE_OK) |
|
499 |
{ |
|
500 |
rc = sqlite3_step(st); |
|
501 |
Cleanup_sqlite3_finalize_PushL(st); |
|
502 |
if (rc == SQLITE_ROW) |
|
503 |
{ |
|
504 |
showInfo = CShowInfo::NewLC(); |
|
505 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
506 |
CleanupStack::Pop(showInfo); |
|
507 |
} |
|
60 | 508 |
else |
509 |
{ |
|
510 |
User::Leave(KErrUnknown); |
|
511 |
} |
|
2 | 512 |
CleanupStack::PopAndDestroy();//st |
513 |
} |
|
60 | 514 |
else |
515 |
{ |
|
516 |
User::Leave(KErrCorrupt); |
|
517 |
} |
|
2 | 518 |
|
519 |
return showInfo; |
|
520 |
} |
|
521 |
||
522 |
void CShowEngine::DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) |
|
523 |
{ |
|
524 |
DP1("CShowEngine::DBGetShowsByFeed BEGIN, feedUid=%u", aFeedUid); |
|
525 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where feeduid=%u"); |
|
526 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
527 |
||
130
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
528 |
if (iShowFilter == ENewShows) |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
529 |
{ |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
530 |
_LIT(KSqlStatementNewShows, " and playstate = 0"); // ENeverPlayed |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
531 |
iSqlBuffer.Append(KSqlStatementNewShows); |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
532 |
} |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
533 |
else if (iShowFilter == EDownloadedShows) |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
534 |
{ |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
535 |
_LIT(KSqlStatementDownloadedShows, " and downloadstate = 4"); // EDownloaded |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
536 |
iSqlBuffer.Append(KSqlStatementDownloadedShows); |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
537 |
} |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
538 |
else if (iShowFilter == ENewAndDownloadedShows) |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
539 |
{ |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
540 |
_LIT(KSqlStatementDownloadedAndNewShows, " and (downloadstate = 4 or playstate = 0)"); // EDownloaded or ENeverPlayed |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
541 |
iSqlBuffer.Append(KSqlStatementDownloadedAndNewShows); |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
542 |
|
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
543 |
} |
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
544 |
|
2 | 545 |
#ifndef DONT_SORT_SQL |
546 |
_LIT(KSqlOrderByDate, " order by pubdate desc"); |
|
547 |
iSqlBuffer.Append(KSqlOrderByDate); |
|
548 |
#endif |
|
549 |
||
550 |
sqlite3_stmt *st; |
|
551 |
||
552 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
553 |
&st, (const void**) NULL); |
|
554 |
||
555 |
if (rc == SQLITE_OK) |
|
556 |
{ |
|
557 |
rc = sqlite3_step(st); |
|
558 |
Cleanup_sqlite3_finalize_PushL(st); |
|
559 |
while (rc == SQLITE_ROW) |
|
560 |
{ |
|
561 |
CShowInfo* showInfo = CShowInfo::NewLC(); |
|
562 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
563 |
aShowArray.Append(showInfo); |
|
564 |
CleanupStack::Pop(showInfo); |
|
565 |
rc = sqlite3_step(st); |
|
566 |
} |
|
567 |
CleanupStack::PopAndDestroy();//st |
|
568 |
} |
|
60 | 569 |
else |
570 |
{ |
|
571 |
User::Leave(KErrCorrupt); |
|
572 |
} |
|
2 | 573 |
DP("CShowEngine::DBGetShowsByFeed END"); |
574 |
} |
|
575 |
||
60 | 576 |
TUint CShowEngine::DBGetDownloadsCountL() |
2 | 577 |
{ |
578 |
DP("CShowEngine::DBGetDownloadsCount"); |
|
579 |
||
580 |
_LIT(KSqlStatement, "select count(*) from downloads"); |
|
581 |
iSqlBuffer.Format(KSqlStatement); |
|
582 |
||
583 |
sqlite3_stmt *st; |
|
584 |
TUint count = 0; |
|
585 |
||
586 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
587 |
&st, (const void**) NULL); |
|
588 |
||
589 |
if (rc == SQLITE_OK) |
|
590 |
{ |
|
60 | 591 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 592 |
rc = sqlite3_step(st); |
593 |
||
594 |
if (rc == SQLITE_ROW) |
|
595 |
{ |
|
596 |
count = sqlite3_column_int(st, 0); |
|
597 |
} |
|
60 | 598 |
else |
599 |
{ |
|
600 |
User::Leave(KErrUnknown); |
|
601 |
} |
|
602 |
||
603 |
CleanupStack::PopAndDestroy(); //st |
|
604 |
} |
|
605 |
else |
|
606 |
{ |
|
607 |
User::Leave(KErrCorrupt); |
|
2 | 608 |
} |
609 |
return count; |
|
610 |
} |
|
611 |
||
612 |
void CShowEngine::DBGetDownloadedShowsL(RShowInfoArray& aShowArray) |
|
613 |
{ |
|
614 |
DP("CShowEngine::DBGetDownloadedShows"); |
|
615 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where downloadstate=%u"); |
|
616 |
iSqlBuffer.Format(KSqlStatement, EDownloaded); |
|
617 |
||
618 |
#ifndef DONT_SORT_SQL |
|
619 |
_LIT(KSqlSort, " order by title"); |
|
620 |
iSqlBuffer.Append(KSqlSort); |
|
621 |
#endif |
|
622 |
||
623 |
sqlite3_stmt *st; |
|
624 |
||
625 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
626 |
&st, (const void**) NULL); |
|
627 |
||
628 |
if (rc == SQLITE_OK) |
|
629 |
{ |
|
630 |
rc = sqlite3_step(st); |
|
631 |
Cleanup_sqlite3_finalize_PushL(st); |
|
632 |
while (rc == SQLITE_ROW) |
|
633 |
{ |
|
634 |
CShowInfo* showInfo = CShowInfo::NewLC(); |
|
635 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
636 |
aShowArray.Append(showInfo); |
|
637 |
CleanupStack::Pop(showInfo); |
|
638 |
rc = sqlite3_step(st); |
|
639 |
} |
|
640 |
CleanupStack::PopAndDestroy();//st |
|
641 |
} |
|
60 | 642 |
else |
643 |
{ |
|
644 |
User::Leave(KErrCorrupt); |
|
645 |
} |
|
2 | 646 |
} |
647 |
||
648 |
void CShowEngine::DBGetNewShowsL(RShowInfoArray& aShowArray) |
|
649 |
{ |
|
650 |
DP("CShowEngine::DBGetNewShows"); |
|
651 |
_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where playstate=%u"); |
|
652 |
iSqlBuffer.Format(KSqlStatement, ENeverPlayed); |
|
653 |
||
654 |
sqlite3_stmt *st; |
|
655 |
||
656 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
657 |
&st, (const void**) NULL); |
|
658 |
||
659 |
if (rc == SQLITE_OK) |
|
660 |
{ |
|
661 |
rc = sqlite3_step(st); |
|
662 |
Cleanup_sqlite3_finalize_PushL(st); |
|
663 |
while (rc == SQLITE_ROW) |
|
664 |
{ |
|
665 |
CShowInfo* showInfo = CShowInfo::NewLC(); |
|
666 |
DBFillShowInfoFromStmtL(st, showInfo); |
|
667 |
aShowArray.Append(showInfo); |
|
668 |
CleanupStack::Pop(showInfo); |
|
669 |
rc = sqlite3_step(st); |
|
670 |
} |
|
671 |
CleanupStack::PopAndDestroy();//st |
|
672 |
} |
|
60 | 673 |
else |
674 |
{ |
|
675 |
User::Leave(KErrCorrupt); |
|
676 |
} |
|
2 | 677 |
} |
678 |
||
60 | 679 |
void CShowEngine::DBDeleteOldShowsByFeedL(TUint aFeedUid) |
2 | 680 |
{ |
681 |
DP("CShowEngine::DBDeleteOldShows"); |
|
682 |
||
683 |
// what we do: |
|
684 |
// 1. sort shows by pubdate |
|
685 |
// 2. select the first MaxListItems shows |
|
686 |
// 3. delete the rest if downloadstate is ENotDownloaded |
|
687 |
||
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
149
diff
changeset
|
688 |
_LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in (select uid from shows where feeduid=%u order by pubdate desc limit %u)"); |
2 | 689 |
iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems()); |
690 |
||
691 |
sqlite3_stmt *st; |
|
692 |
||
693 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
694 |
&st, (const void**) NULL); |
|
695 |
||
696 |
if (rc == SQLITE_OK) |
|
697 |
{ |
|
698 |
rc = sqlite3_step(st); |
|
699 |
sqlite3_finalize(st); |
|
700 |
} |
|
60 | 701 |
else |
702 |
{ |
|
703 |
User::Leave(KErrCorrupt); |
|
704 |
} |
|
2 | 705 |
|
706 |
_LIT(KSqlStatement2, "delete from downloads where uid not in (select downloads.uid from shows, downloads where shows.uid=downloads.uid)"); |
|
707 |
iSqlBuffer.Format(KSqlStatement2); |
|
708 |
||
709 |
rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, (const void**) NULL); |
|
710 |
||
711 |
if (rc == SQLITE_OK) |
|
712 |
{ |
|
713 |
rc = sqlite3_step(st); |
|
714 |
sqlite3_finalize(st); |
|
715 |
} |
|
60 | 716 |
else |
717 |
{ |
|
718 |
User::Leave(KErrCorrupt); |
|
719 |
} |
|
2 | 720 |
} |
721 |
||
722 |
void CShowEngine::DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo) |
|
723 |
{ |
|
724 |
const void *urlz = sqlite3_column_text16(st, 0); |
|
725 |
TPtrC16 url((const TUint16*) urlz); |
|
726 |
showInfo->SetUrlL(url); |
|
727 |
||
728 |
const void *titlez = sqlite3_column_text16(st, 1); |
|
729 |
TPtrC16 title((const TUint16*) titlez); |
|
730 |
showInfo->SetTitleL(title); |
|
731 |
||
732 |
const void *descz = sqlite3_column_text16(st, 2); |
|
733 |
TPtrC16 desc((const TUint16*) descz); |
|
734 |
showInfo->SetDescriptionL(desc); |
|
735 |
||
736 |
const void *filez = sqlite3_column_text16(st, 3); |
|
737 |
TPtrC16 file((const TUint16*) filez); |
|
738 |
showInfo->SetFileNameL(file); |
|
739 |
||
740 |
sqlite3_int64 pos = sqlite3_column_int64(st, 4); |
|
741 |
TTimeIntervalMicroSeconds position(pos); |
|
742 |
showInfo->SetPosition(position); |
|
743 |
||
744 |
TUint playtime = sqlite3_column_int(st, 5); |
|
745 |
showInfo->SetPlayTime(playtime); |
|
746 |
||
747 |
TUint playstate = sqlite3_column_int(st, 6); |
|
748 |
showInfo->SetPlayState((TPlayState) playstate); |
|
749 |
||
750 |
TUint downloadstate = sqlite3_column_int(st, 7); |
|
751 |
showInfo->SetDownloadState((TDownloadState) downloadstate); |
|
752 |
||
753 |
TUint feeduid = sqlite3_column_int(st, 8); |
|
754 |
showInfo->SetFeedUid(feeduid); |
|
755 |
||
756 |
TUint uid = sqlite3_column_int(st, 9); |
|
757 |
showInfo->SetUid(uid); |
|
758 |
||
759 |
TUint showsize = sqlite3_column_int(st, 10); |
|
760 |
showInfo->SetShowSize(showsize); |
|
761 |
||
762 |
TUint trackno = sqlite3_column_int(st, 11); |
|
763 |
showInfo->SetTrackNo((TShowType) trackno); |
|
764 |
||
765 |
sqlite3_int64 pubdate = sqlite3_column_int64(st, 12); |
|
766 |
TTime timepubdate(pubdate); |
|
767 |
showInfo->SetPubDate(timepubdate); |
|
768 |
||
769 |
TUint showtype = sqlite3_column_int(st, 13); |
|
770 |
showInfo->SetShowType((TShowType) showtype); |
|
771 |
||
772 |
TInt lasterror = sqlite3_column_int(st, 14); |
|
773 |
showInfo->SetLastError(lasterror); |
|
774 |
} |
|
775 |
||
60 | 776 |
void CShowEngine::DBAddShowL(const CShowInfo& aItem) |
2 | 777 |
{ |
778 |
DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
|
779 |
||
21 | 780 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
781 |
TPtr titlePtr(titleBuf->Des()); |
|
782 |
titlePtr.Copy(aItem.Title()); |
|
783 |
PodcastUtils::SQLEncode(titlePtr); |
|
784 |
||
785 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
|
786 |
TPtr descPtr(descBuf->Des()); |
|
787 |
descPtr.Copy(aItem.Description()); |
|
788 |
PodcastUtils::SQLEncode(descPtr); |
|
789 |
||
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
149
diff
changeset
|
790 |
_LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\")"); |
21 | 791 |
|
792 |
iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
|
2 | 793 |
&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
794 |
aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
|
795 |
aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(), |
|
796 |
aItem.PubDate().Int64(), aItem.ShowType()); |
|
797 |
||
21 | 798 |
CleanupStack::PopAndDestroy(descBuf); |
799 |
CleanupStack::PopAndDestroy(titleBuf); |
|
800 |
||
2 | 801 |
sqlite3_stmt *st; |
802 |
||
803 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
804 |
&st, (const void**) NULL); |
|
60 | 805 |
|
2 | 806 |
if (rc == SQLITE_OK) |
807 |
{ |
|
60 | 808 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 809 |
rc = sqlite3_step(st); |
60 | 810 |
if (rc != SQLITE_DONE) |
2 | 811 |
{ |
60 | 812 |
User::Leave(KErrAlreadyExists); |
2 | 813 |
} |
60 | 814 |
CleanupStack::PopAndDestroy(); // st |
2 | 815 |
} |
816 |
else |
|
817 |
{ |
|
60 | 818 |
User::Leave(KErrCorrupt); |
2 | 819 |
} |
820 |
} |
|
821 |
||
60 | 822 |
void CShowEngine::DBAddDownloadL(TUint aUid) |
2 | 823 |
{ |
824 |
DP1("CShowEngine::DBAddDownload, aUid=%u", aUid); |
|
825 |
||
826 |
_LIT(KSqlStatement, "insert into downloads (uid) values (%u)"); |
|
827 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
828 |
sqlite3_stmt *st; |
|
829 |
||
830 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
831 |
&st, (const void**) NULL); |
|
832 |
||
833 |
if (rc == SQLITE_OK) |
|
834 |
{ |
|
60 | 835 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 836 |
rc = sqlite3_step(st); |
60 | 837 |
if (rc != SQLITE_DONE) |
838 |
{ |
|
839 |
User::Leave(KErrUnknown); |
|
840 |
} |
|
841 |
CleanupStack::PopAndDestroy(); // st |
|
2 | 842 |
} |
60 | 843 |
else |
844 |
{ |
|
845 |
User::Leave(KErrCorrupt); |
|
846 |
} |
|
2 | 847 |
} |
848 |
||
60 | 849 |
void CShowEngine::DBUpdateShowL(CShowInfo& aItem) |
2 | 850 |
{ |
851 |
DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title()); |
|
852 |
||
30
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
853 |
HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
854 |
TPtr titlePtr(titleBuf->Des()); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
855 |
titlePtr.Copy(aItem.Title()); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
856 |
PodcastUtils::SQLEncode(titlePtr); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
857 |
|
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
858 |
HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
859 |
TPtr descPtr(descBuf->Des()); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
860 |
descPtr.Copy(aItem.Description()); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
861 |
PodcastUtils::SQLEncode(descPtr); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
862 |
|
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
149
diff
changeset
|
863 |
_LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\", playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\",pubdate=\"%Lu\", showtype=\"%d\", lasterror=\"%d\" where uid=\"%u\""); |
30
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
864 |
iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
2 | 865 |
&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
866 |
aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
|
867 |
aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(), |
|
868 |
aItem.ShowType(), aItem.LastError(), aItem.Uid()); |
|
869 |
||
30
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
870 |
CleanupStack::PopAndDestroy(descBuf); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
871 |
CleanupStack::PopAndDestroy(titleBuf); |
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents:
22
diff
changeset
|
872 |
|
2 | 873 |
sqlite3_stmt *st; |
874 |
||
875 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
876 |
&st, (const void**) NULL); |
|
877 |
||
878 |
if (rc == SQLITE_OK) |
|
879 |
{ |
|
60 | 880 |
Cleanup_sqlite3_finalize_PushL(st); |
881 |
rc = sqlite3_step(st); |
|
2 | 882 |
|
60 | 883 |
if (rc != SQLITE_DONE) |
2 | 884 |
{ |
60 | 885 |
User::Leave(KErrUnknown); |
2 | 886 |
} |
60 | 887 |
CleanupStack::PopAndDestroy(); // st |
2 | 888 |
} |
889 |
else |
|
890 |
{ |
|
60 | 891 |
User::Leave(KErrCorrupt); |
2 | 892 |
} |
893 |
} |
|
894 |
||
60 | 895 |
void CShowEngine::DBDeleteShowL(TUint aUid) |
2 | 896 |
{ |
897 |
DP("CShowEngine::DBDeleteShow"); |
|
898 |
||
899 |
_LIT(KSqlStatement, "delete from shows where uid=%u"); |
|
900 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
901 |
||
902 |
sqlite3_stmt *st; |
|
903 |
||
904 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
905 |
&st, (const void**) NULL); |
|
906 |
||
907 |
if (rc == SQLITE_OK) |
|
908 |
{ |
|
60 | 909 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 910 |
rc = sqlite3_step(st); |
911 |
||
60 | 912 |
if (rc != SQLITE_DONE) |
2 | 913 |
{ |
60 | 914 |
User::Leave(KErrUnknown); |
2 | 915 |
} |
60 | 916 |
CleanupStack::PopAndDestroy(); // st |
2 | 917 |
} |
918 |
else |
|
919 |
{ |
|
60 | 920 |
User::Leave(KErrCorrupt); |
2 | 921 |
} |
922 |
} |
|
923 |
||
60 | 924 |
void CShowEngine::DBDeleteAllShowsByFeedL(TUint aFeedUid) |
2 | 925 |
{ |
926 |
DP("CShowEngine::DBDeleteAllShowsByFeed"); |
|
927 |
||
928 |
_LIT(KSqlStatement, "delete from shows where feeduid=%u"); |
|
929 |
iSqlBuffer.Format(KSqlStatement, aFeedUid); |
|
930 |
||
931 |
sqlite3_stmt *st; |
|
932 |
||
933 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
934 |
&st, (const void**) NULL); |
|
935 |
||
936 |
if (rc == SQLITE_OK) |
|
937 |
{ |
|
60 | 938 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 939 |
rc = sqlite3_step(st); |
940 |
||
60 | 941 |
if (rc != SQLITE_DONE) |
2 | 942 |
{ |
60 | 943 |
User::Leave(KErrUnknown); |
2 | 944 |
} |
60 | 945 |
CleanupStack::PopAndDestroy(); // st |
2 | 946 |
} |
947 |
else |
|
948 |
{ |
|
60 | 949 |
User::Leave(KErrCorrupt); |
2 | 950 |
} |
951 |
} |
|
952 |
||
60 | 953 |
void CShowEngine::DBRemoveAllDownloadsL() |
2 | 954 |
{ |
955 |
DP("CShowEngine::DBRemoveAllDownloads"); |
|
956 |
||
957 |
_LIT(KSqlStatement, "delete from downloads"); |
|
958 |
iSqlBuffer.Format(KSqlStatement); |
|
959 |
||
960 |
sqlite3_stmt *st; |
|
961 |
||
962 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
963 |
&st, (const void**) NULL); |
|
964 |
||
965 |
if (rc == SQLITE_OK) |
|
966 |
{ |
|
967 |
rc = sqlite3_step(st); |
|
968 |
sqlite3_finalize(st); |
|
969 |
} |
|
60 | 970 |
else |
971 |
{ |
|
972 |
User::Leave(KErrCorrupt); |
|
973 |
} |
|
2 | 974 |
|
975 |
_LIT(KSqlStatement2, "update shows set downloadstate=0 where downloadstate=1"); |
|
976 |
iSqlBuffer.Format(KSqlStatement2); |
|
977 |
||
978 |
rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, |
|
979 |
(const void**) NULL); |
|
980 |
||
981 |
if (rc == SQLITE_OK) |
|
982 |
{ |
|
60 | 983 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 984 |
rc = sqlite3_step(st); |
60 | 985 |
if (rc != SQLITE_DONE) |
986 |
{ |
|
987 |
User::Leave(KErrUnknown); |
|
988 |
} |
|
989 |
CleanupStack::PopAndDestroy(); // st |
|
990 |
} |
|
991 |
else |
|
992 |
{ |
|
993 |
User::Leave(KErrCorrupt); |
|
2 | 994 |
} |
995 |
||
996 |
} |
|
997 |
||
60 | 998 |
void CShowEngine::DBRemoveDownloadL(TUint aUid) |
2 | 999 |
{ |
1000 |
DP("CShowEngine::DBRemoveDownload"); |
|
1001 |
||
1002 |
_LIT(KSqlStatement, "delete from downloads where uid=%u"); |
|
1003 |
iSqlBuffer.Format(KSqlStatement, aUid); |
|
1004 |
||
1005 |
sqlite3_stmt *st; |
|
1006 |
||
1007 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
|
1008 |
&st, (const void**) NULL); |
|
1009 |
||
1010 |
if (rc == SQLITE_OK) |
|
1011 |
{ |
|
60 | 1012 |
Cleanup_sqlite3_finalize_PushL(st); |
2 | 1013 |
rc = sqlite3_step(st); |
60 | 1014 |
if (rc != SQLITE_DONE) |
1015 |
{ |
|
1016 |
User::Leave(KErrUnknown); |
|
1017 |
} |
|
1018 |
CleanupStack::PopAndDestroy(); // st |
|
1019 |
} |
|
1020 |
else |
|
1021 |
{ |
|
1022 |
User::Leave(KErrCorrupt); |
|
2 | 1023 |
} |
1024 |
} |
|
1025 |
||
145
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1026 |
void CShowEngine::DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1027 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1028 |
DP("CShowEngine::DBSwapDownloadsL"); |
149
70b2f592a460
Enabled Brendan's download queue operations; Fixed minor bug in queue swapping method
teknolog
parents:
148
diff
changeset
|
1029 |
_LIT(KSqlStatement, "update downloads set uid=%u where dl_index=%d"); |
145
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1030 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1031 |
iSqlBuffer.Format(KSqlStatement, aFirstDL.iUid, aSecondDL.iIndex); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1032 |
sqlite3_stmt *st; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1033 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1034 |
&st, (const void**) NULL); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1035 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1036 |
if (rc == SQLITE_OK) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1037 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1038 |
Cleanup_sqlite3_finalize_PushL(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1039 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1040 |
if (rc != SQLITE_DONE) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1041 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1042 |
User::Leave(KErrUnknown); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1043 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1044 |
CleanupStack::PopAndDestroy(); // st |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1045 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1046 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1047 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1048 |
User::Leave(KErrCorrupt); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1049 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1050 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1051 |
iSqlBuffer.Format(KSqlStatement, aSecondDL.iUid, aFirstDL.iIndex); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1052 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1053 |
rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1054 |
&st, (const void**) NULL); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1055 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1056 |
if (rc == SQLITE_OK) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1057 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1058 |
Cleanup_sqlite3_finalize_PushL(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1059 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1060 |
if (rc != SQLITE_DONE) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1061 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1062 |
User::Leave(KErrUnknown); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1063 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1064 |
CleanupStack::PopAndDestroy(); // st |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1065 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1066 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1067 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1068 |
User::Leave(KErrCorrupt); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1069 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1070 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1071 |
|
2 | 1072 |
EXPORT_C CShowInfo* CShowEngine::GetNextShowByTrackL(CShowInfo* aShowInfo) |
1073 |
{ |
|
1074 |
CShowInfo* nextShow = NULL; |
|
1075 |
RShowInfoArray array; |
|
1076 |
DBGetShowsByFeedL(array, aShowInfo->FeedUid()); |
|
1077 |
TUint diff = KMaxTInt; |
|
1078 |
for (TInt loop = 0; loop < array.Count(); loop++) |
|
1079 |
{ |
|
1080 |
if (aShowInfo->TrackNo() < array[loop]->TrackNo()) |
|
1081 |
{ |
|
1082 |
if ((array[loop]->TrackNo() - aShowInfo->TrackNo()) < diff) |
|
1083 |
{ |
|
1084 |
diff = array[loop]->TrackNo() - aShowInfo->TrackNo(); |
|
1085 |
nextShow = array[loop]; |
|
1086 |
} |
|
1087 |
} |
|
1088 |
} |
|
1089 |
array.ResetAndDestroy(); |
|
1090 |
return nextShow; |
|
1091 |
} |
|
1092 |
||
1093 |
TBool CShowEngine::CompareShowsByUid(const CShowInfo &a, const CShowInfo &b) |
|
1094 |
{ |
|
1095 |
return a.Uid() == b.Uid(); |
|
1096 |
} |
|
1097 |
||
1098 |
TInt CShowEngine::CompareShowsByDate(const CShowInfo &a, const CShowInfo &b) |
|
1099 |
{ |
|
1100 |
if (a.PubDate() > b.PubDate()) |
|
1101 |
{ |
|
1102 |
// DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle); |
|
1103 |
return -1; |
|
1104 |
} |
|
1105 |
else if (a.PubDate() == b.PubDate()) |
|
1106 |
{ |
|
1107 |
// DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle); |
|
1108 |
return 0; |
|
1109 |
} |
|
1110 |
else |
|
1111 |
{ |
|
1112 |
// DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle); |
|
1113 |
return 1; |
|
1114 |
} |
|
1115 |
} |
|
1116 |
||
1117 |
TInt CShowEngine::CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b) |
|
1118 |
{ |
|
1119 |
if (a.TrackNo() < b.TrackNo()) |
|
1120 |
{ |
|
1121 |
return -1; |
|
1122 |
} |
|
1123 |
else if (a.TrackNo() == b.TrackNo()) |
|
1124 |
{ |
|
1125 |
return 0; |
|
1126 |
} |
|
1127 |
else |
|
1128 |
{ |
|
1129 |
return 1; |
|
1130 |
} |
|
1131 |
} |
|
1132 |
||
1133 |
TInt CShowEngine::CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b) |
|
1134 |
{ |
|
1135 |
if (a.Title() < b.Title()) |
|
1136 |
{ |
|
1137 |
// DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle); |
|
1138 |
return -1; |
|
1139 |
} |
|
1140 |
else if (a.Title() == b.Title()) |
|
1141 |
{ |
|
1142 |
// DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle); |
|
1143 |
return 0; |
|
1144 |
} |
|
1145 |
else |
|
1146 |
{ |
|
1147 |
// DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle); |
|
1148 |
return 1; |
|
1149 |
} |
|
1150 |
} |
|
1151 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1152 |
EXPORT_C void CShowEngine::DeletePlayedShowsL(RShowInfoArray &aShowInfoArray) |
2 | 1153 |
{ |
1154 |
for (TInt i = 0; i < aShowInfoArray.Count(); i++) |
|
1155 |
{ |
|
1156 |
if (aShowInfoArray[i]->PlayState() == EPlayed |
|
1157 |
&& aShowInfoArray[i]->FileName().Length() > 0) |
|
1158 |
{ |
|
1159 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName()); |
|
1160 |
aShowInfoArray[i]->SetDownloadState(ENotDownloaded); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1161 |
DBUpdateShowL(*aShowInfoArray[i]); |
2 | 1162 |
} |
1163 |
} |
|
1164 |
} |
|
1165 |
||
1166 |
EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles) |
|
1167 |
{ |
|
1168 |
RShowInfoArray array; |
|
1169 |
DBGetShowsByFeedL(array, aFeedUid); |
|
1170 |
||
1171 |
const TInt count = array.Count(); |
|
1172 |
||
1173 |
for (TInt i = count - 1; i >= 0; i--) |
|
1174 |
{ |
|
53 | 1175 |
if (iShowDownloading && iShowDownloading->Uid() == array[i]->Uid()) |
1176 |
{ |
|
1177 |
// trying to delete the active download |
|
1178 |
RemoveDownloadL(iShowDownloading->Uid()); |
|
1179 |
} |
|
1180 |
||
1181 |
// delete downloaded file |
|
2 | 1182 |
if (array[i]->FileName().Length() > 0) |
1183 |
{ |
|
1184 |
if (aDeleteFiles) |
|
1185 |
{ |
|
1186 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), array[i]->FileName()); |
|
1187 |
} |
|
1188 |
} |
|
1189 |
} |
|
1190 |
array.ResetAndDestroy(); |
|
53 | 1191 |
|
1192 |
// delete all shows from DB |
|
60 | 1193 |
DBDeleteAllShowsByFeedL(aFeedUid); |
53 | 1194 |
|
1195 |
// this will clear out deleted shows from the download queue |
|
1196 |
DBGetAllDownloadsL(array); |
|
1197 |
array.ResetAndDestroy(); |
|
1198 |
||
1199 |
NotifyDownloadQueueUpdatedL(); |
|
2 | 1200 |
} |
1201 |
||
60 | 1202 |
EXPORT_C void CShowEngine::DeleteOldShowsByFeedL(TUint aFeedUid) |
2 | 1203 |
{ |
60 | 1204 |
DBDeleteOldShowsByFeedL(aFeedUid); |
2 | 1205 |
} |
1206 |
||
1207 |
EXPORT_C void CShowEngine::DeleteShowL(TUint aShowUid, TBool aRemoveFile) |
|
1208 |
{ |
|
1209 |
||
1210 |
CShowInfo *info = DBGetShowByUidL(aShowUid); |
|
1211 |
||
1212 |
if (info != NULL) |
|
1213 |
{ |
|
1214 |
if (info->FileName().Length() > 0 && aRemoveFile) |
|
1215 |
{ |
|
1216 |
BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName()); |
|
1217 |
} |
|
1218 |
||
1219 |
info->SetDownloadState(ENotDownloaded); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1220 |
DBUpdateShowL(*info); |
2 | 1221 |
delete info; |
1222 |
} |
|
1223 |
} |
|
1224 |
||
1225 |
EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) |
|
1226 |
{ |
|
1227 |
DP("CShowEngine::GetShowsByFeed"); |
|
1228 |
DBGetShowsByFeedL(aShowArray, aFeedUid); |
|
1229 |
} |
|
1230 |
||
1231 |
EXPORT_C void CShowEngine::GetAllShowsL(RShowInfoArray &aArray) |
|
1232 |
{ |
|
1233 |
DP("CShowEngine::GetAllShows"); |
|
1234 |
DBGetAllShowsL(aArray); |
|
1235 |
} |
|
1236 |
||
1237 |
EXPORT_C void CShowEngine::GetShowsDownloadedL(RShowInfoArray &aArray) |
|
1238 |
{ |
|
1239 |
DP("CShowEngine::GetShowsDownloaded"); |
|
1240 |
DBGetDownloadedShowsL(aArray); |
|
1241 |
} |
|
1242 |
||
1243 |
EXPORT_C void CShowEngine::GetNewShowsL(RShowInfoArray &aArray) |
|
1244 |
{ |
|
1245 |
DP("CShowEngine::GetNewShows"); |
|
1246 |
DBGetNewShowsL(aArray); |
|
1247 |
} |
|
1248 |
||
1249 |
EXPORT_C void CShowEngine::GetShowsDownloadingL(RShowInfoArray &aArray) |
|
1250 |
{ |
|
1251 |
DP("CShowEngine::GetShowsDownloading"); |
|
1252 |
DBGetAllDownloadsL(aArray); |
|
1253 |
} |
|
1254 |
||
1255 |
EXPORT_C TInt CShowEngine::GetNumDownloadingShows() |
|
1256 |
{ |
|
60 | 1257 |
TUint count = 0; |
1258 |
TRAP_IGNORE(count = DBGetDownloadsCountL()); |
|
1259 |
||
1260 |
return (const TInt) count; |
|
2 | 1261 |
} |
1262 |
||
1263 |
EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo) |
|
1264 |
{ |
|
1265 |
aInfo.SetDownloadState(EQueued); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1266 |
DBUpdateShowL(aInfo); |
60 | 1267 |
DBAddDownloadL(aInfo.Uid()); |
2 | 1268 |
DownloadNextShowL(); |
1269 |
} |
|
1270 |
||
1271 |
void CShowEngine::DownloadNextShowL() |
|
1272 |
{ |
|
1273 |
DP("CShowEngine::DownloadNextShowL BEGIN"); |
|
1274 |
// Check if we have anything in the download queue |
|
60 | 1275 |
const TInt count = DBGetDownloadsCountL(); |
2 | 1276 |
DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count); |
1277 |
||
1278 |
if (count > 0) |
|
1279 |
{ |
|
1280 |
if (iPodcastModel.SettingsEngine().DownloadSuspended()) |
|
1281 |
{ |
|
1282 |
DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING"); |
|
34 | 1283 |
// Inform the observers |
1284 |
NotifyDownloadQueueUpdatedL(); |
|
2 | 1285 |
return; |
1286 |
} |
|
1287 |
else if (iShowClient->IsActive()) |
|
1288 |
{ |
|
1289 |
DP("CShowEngine::DownloadNextShow\tDownload process is already active."); |
|
34 | 1290 |
// Inform the observers |
1291 |
NotifyDownloadQueueUpdatedL(); |
|
2 | 1292 |
return; |
1293 |
} |
|
1294 |
else |
|
1295 |
{ |
|
60 | 1296 |
if (iShowDownloading) { |
1297 |
delete iShowDownloading; |
|
1298 |
} |
|
2 | 1299 |
|
60 | 1300 |
// Start the download |
1301 |
iShowDownloading = DBGetNextDownloadL(); |
|
2 | 1302 |
|
60 | 1303 |
while(iShowDownloading != NULL) |
2 | 1304 |
{ |
60 | 1305 |
DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(iShowDownloading->Title())); |
1306 |
iShowDownloading->SetDownloadState(EDownloading); |
|
1307 |
iShowDownloading->SetLastError(KErrNone); |
|
1308 |
DBUpdateShowL(*iShowDownloading); |
|
34 | 1309 |
// Inform the observers |
1310 |
// important to do this after we change download state |
|
1311 |
NotifyDownloadQueueUpdatedL(); |
|
1312 |
||
60 | 1313 |
TRAPD(error,GetShowL(iShowDownloading)); |
1314 |
if (error == KErrNone) |
|
2 | 1315 |
{ |
1316 |
break; |
|
1317 |
} |
|
60 | 1318 |
else |
1319 |
{ |
|
1320 |
iShowDownloading->SetDownloadState(EFailedDownload); |
|
1321 |
DBRemoveDownloadL(iShowDownloading->Uid()); |
|
1322 |
DBUpdateShowL(*iShowDownloading); |
|
1323 |
CleanupStack::PopAndDestroy(iShowDownloading); |
|
1324 |
||
1325 |
iShowDownloading = DBGetNextDownloadL(); |
|
1326 |
if(iShowDownloading == NULL) |
|
1327 |
{ |
|
1328 |
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
|
1329 |
} |
|
1330 |
} |
|
2 | 1331 |
} |
1332 |
} |
|
1333 |
} |
|
1334 |
else |
|
1335 |
{ |
|
34 | 1336 |
// Inform the observers |
1337 |
NotifyDownloadQueueUpdatedL(); |
|
2 | 1338 |
iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download"); |
1339 |
} |
|
1340 |
DP("CShowEngine::DownloadNextShowL END"); |
|
1341 |
} |
|
1342 |
||
1343 |
void CShowEngine::NotifyDownloadQueueUpdatedL() |
|
1344 |
{ |
|
1345 |
const TInt count = iObservers.Count(); |
|
1346 |
for (TInt i = 0; i < count; i++) |
|
1347 |
{ |
|
60 | 1348 |
iObservers[i]->DownloadQueueUpdatedL(1, DBGetDownloadsCountL() - 1); |
2 | 1349 |
} |
1350 |
} |
|
1351 |
||
1352 |
void CShowEngine::NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal) |
|
1353 |
{ |
|
1354 |
const TInt count = iObservers.Count(); |
|
1355 |
for (TInt i = 0; i < count; i++) |
|
1356 |
{ |
|
1357 |
iObservers[i]->ShowDownloadUpdatedL(aBytesOfCurrentDownload, aBytesTotal); |
|
1358 |
} |
|
1359 |
} |
|
1360 |
||
1361 |
void CShowEngine::NotifyShowFinishedL(TInt aError) |
|
1362 |
{ |
|
1363 |
const TInt count = iObservers.Count(); |
|
1364 |
for (TInt i = 0; i < count; i++) |
|
1365 |
{ |
|
1366 |
iObservers[i]->ShowDownloadFinishedL(iShowDownloading?iShowDownloading->Uid():0, aError); |
|
1367 |
} |
|
1368 |
} |
|
1369 |
||
1370 |
EXPORT_C void CShowEngine::NotifyShowListUpdatedL() |
|
1371 |
{ |
|
1372 |
for (TInt i = 0; i < iObservers.Count(); i++) |
|
1373 |
{ |
|
1374 |
iObservers[i]->ShowListUpdatedL(); |
|
1375 |
} |
|
1376 |
} |
|
1377 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1378 |
void CShowEngine::ReadMetaDataL(CShowInfo& aShowInfo) |
2 | 1379 |
{ |
1380 |
//DP1("Read %S", &(aShowInfo->Title())); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1381 |
DBUpdateShowL(aShowInfo); |
2 | 1382 |
} |
1383 |
||
1384 |
void CShowEngine::ReadMetaDataCompleteL() |
|
1385 |
{ |
|
1386 |
NotifyShowListUpdatedL(); |
|
1387 |
MetaDataReader().SetIgnoreTrackNo(EFalse); |
|
1388 |
} |
|
1389 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1390 |
EXPORT_C void CShowEngine::UpdateShowL(CShowInfo& aInfo) |
2 | 1391 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
30
diff
changeset
|
1392 |
DBUpdateShowL(aInfo); |
2 | 1393 |
} |
1394 |
||
1395 |
EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader() |
|
1396 |
{ |
|
1397 |
return *iMetaDataReader; |
|
1398 |
} |
|
1399 |
||
1400 |
void CShowEngine::FileError(TUint /*aError*/) |
|
1401 |
{ |
|
1402 |
iDownloadErrors = KMaxDownloadErrors; |
|
1403 |
} |
|
60 | 1404 |
|
1405 |
EXPORT_C void CShowEngine::CheckForDeletedShows(TUint aFeedUid) |
|
1406 |
{ |
|
1407 |
RShowInfoArray shows; |
|
1408 |
||
1409 |
TRAPD(err, DBGetShowsByFeedL(shows, aFeedUid)); |
|
1410 |
||
1411 |
if (err != KErrNone) |
|
1412 |
{ |
|
1413 |
// probably a catastrophic error, but it doesn't |
|
1414 |
// matter for this method |
|
1415 |
return; |
|
1416 |
} |
|
1417 |
||
1418 |
for (int i=0;i<shows.Count();i++) |
|
1419 |
{ |
|
1420 |
if (shows[i]->DownloadState() == EDownloaded && shows[i]->FileName() != KNullDesC) |
|
1421 |
{ |
|
1422 |
if(!BaflUtils::FileExists(iPodcastModel.FsSession(),shows[i]->FileName())) |
|
1423 |
{ |
|
1424 |
// file doesn't exist anymore, assume it was deleted from outside |
|
1425 |
DP1("Show %S does not exist on disk, flagging as non downloaded", &shows[i]->FileName()); |
|
1426 |
shows[i]->SetDownloadState(ENotDownloaded); |
|
1427 |
shows[i]->SetPlayState(EPlayed); |
|
1428 |
TRAP_IGNORE(DBUpdateShowL(*shows[i])); |
|
1429 |
} |
|
1430 |
} |
|
1431 |
} |
|
1432 |
} |
|
1433 |
||
148
e3f9b65d6910
Cleanup from the merge
Brendan Donegan <brendand@symbian.org>
parents:
147
diff
changeset
|
1434 |
EXPORT_C void CShowEngine::SetShowFilter(TShowFilter aFilter) |
e3f9b65d6910
Cleanup from the merge
Brendan Donegan <brendand@symbian.org>
parents:
147
diff
changeset
|
1435 |
{ |
e3f9b65d6910
Cleanup from the merge
Brendan Donegan <brendand@symbian.org>
parents:
147
diff
changeset
|
1436 |
iShowFilter = aFilter; |
e3f9b65d6910
Cleanup from the merge
Brendan Donegan <brendand@symbian.org>
parents:
147
diff
changeset
|
1437 |
} |
e3f9b65d6910
Cleanup from the merge
Brendan Donegan <brendand@symbian.org>
parents:
147
diff
changeset
|
1438 |
|
145
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1439 |
EXPORT_C void CShowEngine::MoveDownloadUpL(TUint aUid) |
130
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
1440 |
{ |
145
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1441 |
DP("CShowEngine::MoveDownLoadUpL"); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1442 |
_LIT(KSqlStatement, "select * from downloads"); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1443 |
iSqlBuffer.Format(KSqlStatement); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1444 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1445 |
sqlite3_stmt *st; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1446 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1447 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1448 |
&st, (const void**) NULL); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1449 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1450 |
if (rc == SQLITE_OK) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1451 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1452 |
RArray<TDownload> downloads; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1453 |
CleanupClosePushL(downloads); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1454 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1455 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1456 |
Cleanup_sqlite3_finalize_PushL(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1457 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1458 |
TInt selectedIdx = -1; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1459 |
while (rc == SQLITE_ROW && selectedIdx == -1) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1460 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1461 |
TDownload download; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1462 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1463 |
download.iIndex = sqlite3_column_int(st, 0); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1464 |
download.iUid = sqlite3_column_int(st, 1); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1465 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1466 |
downloads.Append(download); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1467 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1468 |
if (download.iUid == aUid) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1469 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1470 |
selectedIdx = downloads.Count()-1; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1471 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1472 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1473 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1474 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1475 |
CleanupStack::PopAndDestroy();//st, downloads |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1476 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1477 |
// If the selected download was found in the database |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1478 |
if (selectedIdx != -1) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1479 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1480 |
// Swap the specified download with the one above it |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1481 |
TDownload selectedDownload = downloads[selectedIdx]; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1482 |
TDownload previousDownload = downloads[selectedIdx - 1]; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1483 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1484 |
// SQL - Update index (with index of selected download) where uid is of previous download |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1485 |
// and update index (with index of previous download) where uid if of selected download |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1486 |
DBSwapDownloadsL(selectedDownload, previousDownload); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1487 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1488 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1489 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1490 |
User::Leave(KErrNotFound); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1491 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1492 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1493 |
CleanupStack::PopAndDestroy(); // downloads |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1494 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1495 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1496 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1497 |
User::Leave(KErrCorrupt); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1498 |
} |
130
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
teknolog
parents:
67
diff
changeset
|
1499 |
} |
145
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1500 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1501 |
EXPORT_C void CShowEngine::MoveDownloadDownL(TUint aUid) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1502 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1503 |
DP("CShowEngine::MoveDownLoadDownL"); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1504 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1505 |
// An upside-down list will result in the download moving down |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1506 |
_LIT(KSqlStatement, "select * from downloads order by dl_index desc"); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1507 |
iSqlBuffer.Format(KSqlStatement); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1508 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1509 |
sqlite3_stmt *st; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1510 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1511 |
int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1512 |
&st, (const void**) NULL); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1513 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1514 |
if (rc == SQLITE_OK) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1515 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1516 |
RArray<TDownload> downloads; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1517 |
CleanupClosePushL(downloads); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1518 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1519 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1520 |
Cleanup_sqlite3_finalize_PushL(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1521 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1522 |
TInt selectedIdx = -1; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1523 |
while (rc == SQLITE_ROW && selectedIdx == -1) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1524 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1525 |
TDownload download; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1526 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1527 |
download.iIndex = sqlite3_column_int(st, 0); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1528 |
download.iUid = sqlite3_column_int(st, 1); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1529 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1530 |
downloads.Append(download); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1531 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1532 |
if (download.iUid == aUid) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1533 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1534 |
selectedIdx = downloads.Count()-1; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1535 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1536 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1537 |
rc = sqlite3_step(st); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1538 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1539 |
CleanupStack::PopAndDestroy();//st, downloads |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1540 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1541 |
// If the selected download was found in the database |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1542 |
if (selectedIdx != -1) |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1543 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1544 |
// Swap the specified download with the one above it |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1545 |
TDownload selectedDownload = downloads[selectedIdx]; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1546 |
TDownload previousDownload = downloads[selectedIdx - 1]; |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1547 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1548 |
// SQL - Update index (with index of selected download) where uid is of previous download |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1549 |
// and update index (with index of previous download) where uid if of selected download |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1550 |
DBSwapDownloadsL(selectedDownload, previousDownload); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1551 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1552 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1553 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1554 |
User::Leave(KErrNotFound); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1555 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1556 |
|
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1557 |
CleanupStack::PopAndDestroy(); // downloads |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1558 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1559 |
else |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1560 |
{ |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1561 |
User::Leave(KErrCorrupt); |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1562 |
} |
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
Brendan Donegan <brendand@symbian.org>
parents:
67
diff
changeset
|
1563 |
} |