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