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