| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Fri, 19 Nov 2010 01:27:00 +0000 | |
| branch | symbian1 | 
| changeset 375 | 82f59b3393b3 | 
| parent 371 | 5077ef63bce2 | 
| child 381 | 29e277559820 | 
| 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: 
354diff
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: 
354diff
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: 
30diff
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: 
30diff
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: 
167diff
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: 
164diff
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: 
212diff
changeset | 194 | |
| 
140a404c6b53
Fix for bug 3626 - show filenames are now generated from UIDs
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
212diff
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: 
246diff
changeset | 196 | |
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
246diff
changeset | 198 | |
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
246diff
changeset | 200 | 		{
 | 
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
246diff
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: 
246diff
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: 
246diff
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: 
246diff
changeset | 205 | |
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
246diff
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: 
246diff
changeset | 208 | } | 
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
246diff
changeset | 210 | 		{
 | 
| 
e6a88732eb8f
For for a potential crash bug when a show URL does not contain a period
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
246diff
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: 
287diff
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: 
246diff
changeset | 213 | } | 
| 246 
140a404c6b53
Fix for bug 3626 - show filenames are now generated from UIDs
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
212diff
changeset | 214 | |
| 
140a404c6b53
Fix for bug 3626 - show filenames are now generated from UIDs
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
212diff
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: 
30diff
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: 
149diff
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: 
167diff
changeset | 265 | 		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);
 | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
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: 
167diff
changeset | 292 | |
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 293 | // setting file size | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 294 | TEntry entry; | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 295 | TInt err = iPodcastModel.FsSession().Entry(iShowDownloading->FileName(), entry); | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 296 | if (err == KErrNone) | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 297 | 					{
 | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 298 | iShowDownloading->SetShowSize(entry.iSize); | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
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: 
30diff
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: 
6diff
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: 
167diff
changeset | 312 | if (aError == HTTPStatus::ERequestedRangeNotSatisfiable) | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 313 | 					{
 | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 314 | 					DP("ERequestedRangeNotSatisfiable, resetting download");
 | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
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: 
167diff
changeset | 316 | BaflUtils::DeleteFile(iPodcastModel.FsSession(),iShowDownloading->FileName()); | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 317 | iShowDownloading->SetDownloadState(EQueued); | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
changeset | 318 | DBUpdateShowL(*iShowDownloading); | 
| 
713bd6cc0b7a
Fix for bug 3042
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
167diff
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: 
167diff
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: 
30diff
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: 
30diff
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: 
30diff
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: 
336diff
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: 
336diff
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: 
336diff
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: 
336diff
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: 
336diff
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: 
336diff
changeset | 519 | void CShowEngine::DBGetOldShowsL(RShowInfoArray& aShowArray) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 520 | 	{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 521 | 	DP("CShowEngine::DBGetOldShowsL BEGIN");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 522 | TTime now; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 523 | now.HomeTime(); | 
| 354 
a2713e6a41a9
Further UI tweaks
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
352diff
changeset | 524 | // TTimeIntervalYears years(5); | 
| 
a2713e6a41a9
Further UI tweaks
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
352diff
changeset | 525 | // now += years; | 
| 
a2713e6a41a9
Further UI tweaks
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
352diff
changeset | 526 | |
| 375 
82f59b3393b3
Fix for bug 3959 part 2, shows being deleted directly after download
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
371diff
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: 
352diff
changeset | 528 | iSqlBuffer.Format(KSqlStatement, EDownloaded, now.Int64()); | 
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 529 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 530 | sqlite3_stmt *st; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 531 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 532 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 533 | &st, (const void**) NULL); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 534 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 535 | if (rc == SQLITE_OK) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 536 | 		{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 537 | rc = sqlite3_step(st); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 538 | Cleanup_sqlite3_finalize_PushL(st); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 539 | while (rc == SQLITE_ROW) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 540 | 			{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 541 | CShowInfo* showInfo = CShowInfo::NewLC(); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 542 | |
| 354 
a2713e6a41a9
Further UI tweaks
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
352diff
changeset | 543 | const void *filez = sqlite3_column_text16(st, 0); | 
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 544 | TPtrC16 file((const TUint16*) filez); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 545 | showInfo->SetFileNameL(file); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 546 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 547 | aShowArray.Append(showInfo); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 548 | CleanupStack::Pop(showInfo); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 549 | rc = sqlite3_step(st); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 550 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 551 | CleanupStack::PopAndDestroy();//st | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 552 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 553 | else | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 554 | 		{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 555 | User::Leave(KErrCorrupt); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 556 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 557 | 	DP("CShowEngine::DBGetOldShowsL END");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 558 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 559 | |
| 2 | 560 | CShowInfo* CShowEngine::DBGetNextDownloadL() | 
| 561 | 	{
 | |
| 562 | 	DP("CShowEngine::DBGetNextDownload");
 | |
| 563 | CShowInfo *showInfo = NULL; | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 564 | _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 | 565 | iSqlBuffer.Format(KSqlStatement); | 
| 566 | ||
| 567 | #ifdef DONT_SORT_SQL | |
| 568 | _LIT(KSqlSort, " limit 1"); | |
| 569 | iSqlBuffer.Append(KSqlSort); | |
| 570 | #else | |
| 571 | _LIT(KSqlNoSort, " order by dl_index limit 1"); | |
| 572 | iSqlBuffer.Append(KSqlNoSort); | |
| 573 | #endif | |
| 574 | ||
| 575 | sqlite3_stmt *st; | |
| 576 | ||
| 577 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 578 | &st, (const void**) NULL); | |
| 579 | ||
| 580 | if (rc == SQLITE_OK) | |
| 581 | 		{
 | |
| 582 | rc = sqlite3_step(st); | |
| 583 | Cleanup_sqlite3_finalize_PushL(st); | |
| 584 | if (rc == SQLITE_ROW) | |
| 585 | 			{
 | |
| 586 | showInfo = CShowInfo::NewLC(); | |
| 587 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 588 | CleanupStack::Pop(showInfo); | |
| 589 | } | |
| 60 | 590 | else | 
| 591 | 			{
 | |
| 592 | User::Leave(KErrUnknown); | |
| 593 | } | |
| 2 | 594 | CleanupStack::PopAndDestroy();//st | 
| 595 | } | |
| 60 | 596 | else | 
| 597 | 		{
 | |
| 598 | User::Leave(KErrCorrupt); | |
| 599 | } | |
| 2 | 600 | |
| 601 | return showInfo; | |
| 602 | } | |
| 603 | ||
| 604 | void CShowEngine::DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) | |
| 605 | 	{
 | |
| 606 | 	DP1("CShowEngine::DBGetShowsByFeed BEGIN, feedUid=%u", aFeedUid);
 | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 607 | _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 | 608 | iSqlBuffer.Format(KSqlStatement, aFeedUid); | 
| 130 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
67diff
changeset | 609 | |
| 2 | 610 | #ifndef DONT_SORT_SQL | 
| 611 | _LIT(KSqlOrderByDate, " order by pubdate desc"); | |
| 612 | iSqlBuffer.Append(KSqlOrderByDate); | |
| 613 | #endif | |
| 614 | ||
| 615 | sqlite3_stmt *st; | |
| 616 | ||
| 617 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 618 | &st, (const void**) NULL); | |
| 619 | ||
| 620 | if (rc == SQLITE_OK) | |
| 621 | 		{
 | |
| 622 | rc = sqlite3_step(st); | |
| 623 | Cleanup_sqlite3_finalize_PushL(st); | |
| 624 | while (rc == SQLITE_ROW) | |
| 625 | 			{
 | |
| 626 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 627 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 628 | aShowArray.Append(showInfo); | |
| 629 | CleanupStack::Pop(showInfo); | |
| 630 | rc = sqlite3_step(st); | |
| 631 | } | |
| 632 | CleanupStack::PopAndDestroy();//st | |
| 633 | } | |
| 60 | 634 | else | 
| 635 | 		{
 | |
| 636 | User::Leave(KErrCorrupt); | |
| 637 | } | |
| 2 | 638 | 	DP("CShowEngine::DBGetShowsByFeed END");
 | 
| 639 | } | |
| 640 | ||
| 60 | 641 | TUint CShowEngine::DBGetDownloadsCountL() | 
| 2 | 642 | 	{
 | 
| 643 | 	DP("CShowEngine::DBGetDownloadsCount");
 | |
| 644 | ||
| 645 | _LIT(KSqlStatement, "select count(*) from downloads"); | |
| 646 | iSqlBuffer.Format(KSqlStatement); | |
| 647 | ||
| 648 | sqlite3_stmt *st; | |
| 649 | TUint count = 0; | |
| 650 | ||
| 651 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 652 | &st, (const void**) NULL); | |
| 653 | ||
| 654 | if (rc == SQLITE_OK) | |
| 655 | 		{
 | |
| 60 | 656 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 657 | rc = sqlite3_step(st); | 
| 658 | ||
| 659 | if (rc == SQLITE_ROW) | |
| 660 | 			{
 | |
| 661 | count = sqlite3_column_int(st, 0); | |
| 662 | } | |
| 60 | 663 | else | 
| 664 | 			{
 | |
| 665 | User::Leave(KErrUnknown); | |
| 666 | } | |
| 667 | ||
| 668 | CleanupStack::PopAndDestroy(); //st | |
| 669 | } | |
| 670 | else | |
| 671 | 		{
 | |
| 672 | User::Leave(KErrCorrupt); | |
| 2 | 673 | } | 
| 674 | return count; | |
| 675 | } | |
| 676 | ||
| 677 | void CShowEngine::DBGetDownloadedShowsL(RShowInfoArray& aShowArray) | |
| 678 | 	{
 | |
| 679 | 	DP("CShowEngine::DBGetDownloadedShows");
 | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 680 | _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 | 681 | iSqlBuffer.Format(KSqlStatement, EDownloaded); | 
| 682 | ||
| 683 | #ifndef DONT_SORT_SQL | |
| 684 | _LIT(KSqlSort, " order by title"); | |
| 685 | iSqlBuffer.Append(KSqlSort); | |
| 686 | #endif | |
| 687 | ||
| 688 | sqlite3_stmt *st; | |
| 689 | ||
| 690 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 691 | &st, (const void**) NULL); | |
| 692 | ||
| 693 | if (rc == SQLITE_OK) | |
| 694 | 		{
 | |
| 695 | rc = sqlite3_step(st); | |
| 696 | Cleanup_sqlite3_finalize_PushL(st); | |
| 697 | while (rc == SQLITE_ROW) | |
| 698 | 			{
 | |
| 699 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 700 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 701 | aShowArray.Append(showInfo); | |
| 702 | CleanupStack::Pop(showInfo); | |
| 703 | rc = sqlite3_step(st); | |
| 704 | } | |
| 705 | CleanupStack::PopAndDestroy();//st | |
| 706 | } | |
| 60 | 707 | else | 
| 708 | 		{
 | |
| 709 | User::Leave(KErrCorrupt); | |
| 710 | } | |
| 2 | 711 | } | 
| 712 | ||
| 713 | void CShowEngine::DBGetNewShowsL(RShowInfoArray& aShowArray) | |
| 714 | 	{
 | |
| 715 | 	DP("CShowEngine::DBGetNewShows");
 | |
| 351 
a5e419ee2bb3
New shows now list newest shows on top
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
350diff
changeset | 716 | _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: 
350diff
changeset | 717 | |
| 2 | 718 | iSqlBuffer.Format(KSqlStatement, ENeverPlayed); | 
| 719 | ||
| 720 | sqlite3_stmt *st; | |
| 721 | ||
| 722 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 723 | &st, (const void**) NULL); | |
| 724 | ||
| 725 | if (rc == SQLITE_OK) | |
| 726 | 		{
 | |
| 727 | rc = sqlite3_step(st); | |
| 728 | Cleanup_sqlite3_finalize_PushL(st); | |
| 729 | while (rc == SQLITE_ROW) | |
| 730 | 			{
 | |
| 731 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 732 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 733 | aShowArray.Append(showInfo); | |
| 734 | CleanupStack::Pop(showInfo); | |
| 735 | rc = sqlite3_step(st); | |
| 736 | } | |
| 737 | CleanupStack::PopAndDestroy();//st | |
| 738 | } | |
| 60 | 739 | else | 
| 740 | 		{
 | |
| 741 | User::Leave(KErrCorrupt); | |
| 742 | } | |
| 2 | 743 | } | 
| 744 | ||
| 60 | 745 | void CShowEngine::DBDeleteOldShowsByFeedL(TUint aFeedUid) | 
| 2 | 746 | 	{
 | 
| 747 | 	DP("CShowEngine::DBDeleteOldShows");
 | |
| 748 | ||
| 749 | // what we do: | |
| 750 | // 1. sort shows by pubdate | |
| 751 | // 2. select the first MaxListItems shows | |
| 752 | // 3. delete the rest if downloadstate is ENotDownloaded | |
| 753 | ||
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
149diff
changeset | 754 | _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 | 755 | iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems()); | 
| 756 | ||
| 757 | sqlite3_stmt *st; | |
| 758 | ||
| 759 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 760 | &st, (const void**) NULL); | |
| 761 | ||
| 762 | if (rc == SQLITE_OK) | |
| 763 | 		{
 | |
| 764 | rc = sqlite3_step(st); | |
| 765 | sqlite3_finalize(st); | |
| 766 | } | |
| 60 | 767 | else | 
| 768 | 		{
 | |
| 769 | User::Leave(KErrCorrupt); | |
| 770 | } | |
| 2 | 771 | |
| 772 | _LIT(KSqlStatement2, "delete from downloads where uid not in (select downloads.uid from shows, downloads where shows.uid=downloads.uid)"); | |
| 773 | iSqlBuffer.Format(KSqlStatement2); | |
| 774 | ||
| 775 | rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, (const void**) NULL); | |
| 776 | ||
| 777 | if (rc == SQLITE_OK) | |
| 778 | 		{
 | |
| 779 | rc = sqlite3_step(st); | |
| 780 | sqlite3_finalize(st); | |
| 781 | } | |
| 60 | 782 | else | 
| 783 | 		{
 | |
| 784 | User::Leave(KErrCorrupt); | |
| 785 | } | |
| 2 | 786 | } | 
| 787 | ||
| 788 | void CShowEngine::DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo) | |
| 789 | 	{
 | |
| 790 | const void *urlz = sqlite3_column_text16(st, 0); | |
| 791 | TPtrC16 url((const TUint16*) urlz); | |
| 792 | showInfo->SetUrlL(url); | |
| 793 | ||
| 794 | const void *titlez = sqlite3_column_text16(st, 1); | |
| 795 | TPtrC16 title((const TUint16*) titlez); | |
| 796 | showInfo->SetTitleL(title); | |
| 797 | ||
| 798 | const void *descz = sqlite3_column_text16(st, 2); | |
| 799 | TPtrC16 desc((const TUint16*) descz); | |
| 800 | showInfo->SetDescriptionL(desc); | |
| 801 | ||
| 802 | const void *filez = sqlite3_column_text16(st, 3); | |
| 803 | TPtrC16 file((const TUint16*) filez); | |
| 804 | showInfo->SetFileNameL(file); | |
| 805 | ||
| 806 | sqlite3_int64 pos = sqlite3_column_int64(st, 4); | |
| 807 | TTimeIntervalMicroSeconds position(pos); | |
| 808 | showInfo->SetPosition(position); | |
| 809 | ||
| 810 | TUint playtime = sqlite3_column_int(st, 5); | |
| 811 | showInfo->SetPlayTime(playtime); | |
| 812 | ||
| 813 | TUint playstate = sqlite3_column_int(st, 6); | |
| 814 | showInfo->SetPlayState((TPlayState) playstate); | |
| 815 | ||
| 816 | TUint downloadstate = sqlite3_column_int(st, 7); | |
| 817 | showInfo->SetDownloadState((TDownloadState) downloadstate); | |
| 818 | ||
| 819 | TUint feeduid = sqlite3_column_int(st, 8); | |
| 820 | showInfo->SetFeedUid(feeduid); | |
| 821 | ||
| 822 | TUint uid = sqlite3_column_int(st, 9); | |
| 823 | showInfo->SetUid(uid); | |
| 824 | ||
| 825 | TUint showsize = sqlite3_column_int(st, 10); | |
| 826 | showInfo->SetShowSize(showsize); | |
| 827 | ||
| 828 | TUint trackno = sqlite3_column_int(st, 11); | |
| 829 | showInfo->SetTrackNo((TShowType) trackno); | |
| 830 | ||
| 831 | sqlite3_int64 pubdate = sqlite3_column_int64(st, 12); | |
| 832 | TTime timepubdate(pubdate); | |
| 833 | showInfo->SetPubDate(timepubdate); | |
| 834 | ||
| 835 | TUint showtype = sqlite3_column_int(st, 13); | |
| 836 | showInfo->SetShowType((TShowType) showtype); | |
| 837 | ||
| 838 | TInt lasterror = sqlite3_column_int(st, 14); | |
| 839 | showInfo->SetLastError(lasterror); | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 840 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 841 | sqlite3_int64 deletedate = sqlite3_column_int64(st, 15); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 842 | TTime timedeletedate(deletedate); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 843 | showInfo->SetDeleteDate(timedeletedate); | 
| 2 | 844 | } | 
| 845 | ||
| 60 | 846 | void CShowEngine::DBAddShowL(const CShowInfo& aItem) | 
| 2 | 847 | 	{
 | 
| 848 | 	DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
 | |
| 849 | ||
| 21 | 850 | HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); | 
| 851 | TPtr titlePtr(titleBuf->Des()); | |
| 852 | titlePtr.Copy(aItem.Title()); | |
| 853 | PodcastUtils::SQLEncode(titlePtr); | |
| 854 | ||
| 855 | HBufC* descBuf = HBufC::NewLC(KMaxLineLength); | |
| 856 | TPtr descPtr(descBuf->Des()); | |
| 857 | descPtr.Copy(aItem.Description()); | |
| 858 | PodcastUtils::SQLEncode(descPtr); | |
| 859 | ||
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 860 | _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 | 861 | |
| 862 | iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, | |
| 2 | 863 | &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), | 
| 864 | aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), | |
| 865 | aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(), | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 866 | aItem.PubDate().Int64(), aItem.ShowType(), aItem.DeleteDate().Int64()); | 
| 2 | 867 | |
| 21 | 868 | CleanupStack::PopAndDestroy(descBuf); | 
| 869 | CleanupStack::PopAndDestroy(titleBuf); | |
| 870 | ||
| 2 | 871 | sqlite3_stmt *st; | 
| 872 | ||
| 873 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 874 | &st, (const void**) NULL); | |
| 60 | 875 | |
| 2 | 876 | if (rc == SQLITE_OK) | 
| 877 | 		{
 | |
| 60 | 878 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 879 | rc = sqlite3_step(st); | 
| 60 | 880 | if (rc != SQLITE_DONE) | 
| 2 | 881 | 			{
 | 
| 60 | 882 | User::Leave(KErrAlreadyExists); | 
| 2 | 883 | } | 
| 60 | 884 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 885 | } | 
| 886 | else | |
| 887 | 		{
 | |
| 60 | 888 | User::Leave(KErrCorrupt); | 
| 2 | 889 | } | 
| 890 | } | |
| 891 | ||
| 60 | 892 | void CShowEngine::DBAddDownloadL(TUint aUid) | 
| 2 | 893 | 	{
 | 
| 894 | 	DP1("CShowEngine::DBAddDownload, aUid=%u", aUid);
 | |
| 895 | ||
| 896 | _LIT(KSqlStatement, "insert into downloads (uid) values (%u)"); | |
| 897 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 898 | sqlite3_stmt *st; | |
| 899 | ||
| 900 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 901 | &st, (const void**) NULL); | |
| 902 | ||
| 903 | if (rc == SQLITE_OK) | |
| 904 | 		{
 | |
| 60 | 905 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 906 | rc = sqlite3_step(st); | 
| 60 | 907 | if (rc != SQLITE_DONE) | 
| 908 | 			{
 | |
| 909 | User::Leave(KErrUnknown); | |
| 910 | } | |
| 911 | CleanupStack::PopAndDestroy(); // st | |
| 2 | 912 | } | 
| 60 | 913 | else | 
| 914 | 		{
 | |
| 915 | User::Leave(KErrCorrupt); | |
| 916 | } | |
| 2 | 917 | } | 
| 918 | ||
| 60 | 919 | void CShowEngine::DBUpdateShowL(CShowInfo& aItem) | 
| 2 | 920 | 	{
 | 
| 921 | 	DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title());
 | |
| 922 | ||
| 30 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 923 | HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 924 | TPtr titlePtr(titleBuf->Des()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 925 | titlePtr.Copy(aItem.Title()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 926 | PodcastUtils::SQLEncode(titlePtr); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 927 | |
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 928 | HBufC* descBuf = HBufC::NewLC(KMaxLineLength); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 929 | TPtr descPtr(descBuf->Des()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 930 | descPtr.Copy(aItem.Description()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 931 | PodcastUtils::SQLEncode(descPtr); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 932 | |
| 350 
9c4fd008e20f
Updated icons and other UI fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
349diff
changeset | 933 | _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: 
22diff
changeset | 934 | iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, | 
| 2 | 935 | &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), | 
| 936 | aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), | |
| 937 | aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(), | |
| 352 
31f9864a37ac
Various fixes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
351diff
changeset | 938 | aItem.ShowType(), aItem.LastError(), aItem.DeleteDate().Int64(), aItem.Uid()); | 
| 2 | 939 | |
| 30 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 940 | CleanupStack::PopAndDestroy(descBuf); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 941 | CleanupStack::PopAndDestroy(titleBuf); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 942 | |
| 2 | 943 | sqlite3_stmt *st; | 
| 944 | ||
| 945 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 946 | &st, (const void**) NULL); | |
| 947 | ||
| 948 | if (rc == SQLITE_OK) | |
| 949 | 		{
 | |
| 60 | 950 | Cleanup_sqlite3_finalize_PushL(st); | 
| 951 | rc = sqlite3_step(st); | |
| 2 | 952 | |
| 60 | 953 | if (rc != SQLITE_DONE) | 
| 2 | 954 | 			{
 | 
| 60 | 955 | User::Leave(KErrUnknown); | 
| 2 | 956 | } | 
| 60 | 957 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 958 | } | 
| 959 | else | |
| 960 | 		{
 | |
| 60 | 961 | User::Leave(KErrCorrupt); | 
| 2 | 962 | } | 
| 963 | } | |
| 964 | ||
| 60 | 965 | void CShowEngine::DBDeleteShowL(TUint aUid) | 
| 2 | 966 | 	{
 | 
| 967 | 	DP("CShowEngine::DBDeleteShow");
 | |
| 968 | ||
| 969 | _LIT(KSqlStatement, "delete from shows where uid=%u"); | |
| 970 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 971 | ||
| 972 | sqlite3_stmt *st; | |
| 973 | ||
| 974 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 975 | &st, (const void**) NULL); | |
| 976 | ||
| 977 | if (rc == SQLITE_OK) | |
| 978 | 		{
 | |
| 60 | 979 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 980 | rc = sqlite3_step(st); | 
| 981 | ||
| 60 | 982 | if (rc != SQLITE_DONE) | 
| 2 | 983 | 			{
 | 
| 60 | 984 | User::Leave(KErrUnknown); | 
| 2 | 985 | } | 
| 60 | 986 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 987 | } | 
| 988 | else | |
| 989 | 		{
 | |
| 60 | 990 | User::Leave(KErrCorrupt); | 
| 2 | 991 | } | 
| 992 | } | |
| 993 | ||
| 60 | 994 | void CShowEngine::DBDeleteAllShowsByFeedL(TUint aFeedUid) | 
| 2 | 995 | 	{
 | 
| 996 | 	DP("CShowEngine::DBDeleteAllShowsByFeed");
 | |
| 997 | ||
| 998 | _LIT(KSqlStatement, "delete from shows where feeduid=%u"); | |
| 999 | iSqlBuffer.Format(KSqlStatement, aFeedUid); | |
| 1000 | ||
| 1001 | sqlite3_stmt *st; | |
| 1002 | ||
| 1003 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 1004 | &st, (const void**) NULL); | |
| 1005 | ||
| 1006 | if (rc == SQLITE_OK) | |
| 1007 | 		{
 | |
| 60 | 1008 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 1009 | rc = sqlite3_step(st); | 
| 1010 | ||
| 60 | 1011 | if (rc != SQLITE_DONE) | 
| 2 | 1012 | 			{
 | 
| 60 | 1013 | User::Leave(KErrUnknown); | 
| 2 | 1014 | } | 
| 60 | 1015 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 1016 | } | 
| 1017 | else | |
| 1018 | 		{
 | |
| 60 | 1019 | User::Leave(KErrCorrupt); | 
| 2 | 1020 | } | 
| 1021 | } | |
| 1022 | ||
| 60 | 1023 | void CShowEngine::DBRemoveAllDownloadsL() | 
| 2 | 1024 | 	{
 | 
| 1025 | 	DP("CShowEngine::DBRemoveAllDownloads");
 | |
| 1026 | ||
| 1027 | _LIT(KSqlStatement, "delete from downloads"); | |
| 1028 | iSqlBuffer.Format(KSqlStatement); | |
| 1029 | ||
| 1030 | sqlite3_stmt *st; | |
| 1031 | ||
| 1032 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 1033 | &st, (const void**) NULL); | |
| 1034 | ||
| 1035 | if (rc == SQLITE_OK) | |
| 1036 | 		{
 | |
| 1037 | rc = sqlite3_step(st); | |
| 1038 | sqlite3_finalize(st); | |
| 1039 | } | |
| 60 | 1040 | else | 
| 1041 | 		{
 | |
| 1042 | User::Leave(KErrCorrupt); | |
| 1043 | } | |
| 2 | 1044 | |
| 1045 | _LIT(KSqlStatement2, "update shows set downloadstate=0 where downloadstate=1"); | |
| 1046 | iSqlBuffer.Format(KSqlStatement2); | |
| 1047 | ||
| 1048 | rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, | |
| 1049 | (const void**) NULL); | |
| 1050 | ||
| 1051 | if (rc == SQLITE_OK) | |
| 1052 | 		{
 | |
| 60 | 1053 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 1054 | rc = sqlite3_step(st); | 
| 60 | 1055 | if (rc != SQLITE_DONE) | 
| 1056 | 			{
 | |
| 1057 | User::Leave(KErrUnknown); | |
| 1058 | } | |
| 1059 | CleanupStack::PopAndDestroy(); // st | |
| 1060 | } | |
| 1061 | else | |
| 1062 | 		{
 | |
| 1063 | User::Leave(KErrCorrupt); | |
| 2 | 1064 | } | 
| 1065 | ||
| 1066 | } | |
| 1067 | ||
| 60 | 1068 | void CShowEngine::DBRemoveDownloadL(TUint aUid) | 
| 2 | 1069 | 	{
 | 
| 1070 | 	DP("CShowEngine::DBRemoveDownload");
 | |
| 1071 | ||
| 1072 | _LIT(KSqlStatement, "delete from downloads where uid=%u"); | |
| 1073 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 1074 | ||
| 1075 | sqlite3_stmt *st; | |
| 1076 | ||
| 1077 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 1078 | &st, (const void**) NULL); | |
| 1079 | ||
| 1080 | if (rc == SQLITE_OK) | |
| 1081 | 		{
 | |
| 60 | 1082 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 1083 | rc = sqlite3_step(st); | 
| 60 | 1084 | if (rc != SQLITE_DONE) | 
| 1085 | 			{
 | |
| 1086 | User::Leave(KErrUnknown); | |
| 1087 | } | |
| 1088 | CleanupStack::PopAndDestroy(); // st | |
| 1089 | } | |
| 1090 | else | |
| 1091 | 		{
 | |
| 1092 | User::Leave(KErrCorrupt); | |
| 2 | 1093 | } | 
| 1094 | } | |
| 1095 | ||
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1096 | 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: 
67diff
changeset | 1097 | 	{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1098 | 	DP("CShowEngine::DBSwapDownloadsL");
 | 
| 149 
70b2f592a460
Enabled Brendan's download queue operations; Fixed minor bug in queue swapping method
 teknolog parents: 
148diff
changeset | 1099 | _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: 
67diff
changeset | 1100 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1101 | 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: 
67diff
changeset | 1102 | sqlite3_stmt *st; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1103 | 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: 
67diff
changeset | 1104 | &st, (const void**) NULL); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1105 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1106 | if (rc == SQLITE_OK) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1107 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1108 | 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: 
67diff
changeset | 1109 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1110 | if (rc != SQLITE_DONE) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1111 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1112 | User::Leave(KErrUnknown); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1113 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1114 | CleanupStack::PopAndDestroy(); // st | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1115 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1116 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1117 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1118 | User::Leave(KErrCorrupt); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1119 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1120 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1121 | 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: 
67diff
changeset | 1122 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1123 | 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: 
67diff
changeset | 1124 | &st, (const void**) NULL); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1125 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1126 | if (rc == SQLITE_OK) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1127 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1128 | 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: 
67diff
changeset | 1129 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1130 | if (rc != SQLITE_DONE) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1131 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1132 | User::Leave(KErrUnknown); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1133 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1134 | CleanupStack::PopAndDestroy(); // st | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1135 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1136 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1137 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1138 | User::Leave(KErrCorrupt); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1139 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1140 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1141 | |
| 2 | 1142 | EXPORT_C CShowInfo* CShowEngine::GetNextShowByTrackL(CShowInfo* aShowInfo) | 
| 1143 | 	{
 | |
| 1144 | CShowInfo* nextShow = NULL; | |
| 1145 | RShowInfoArray array; | |
| 1146 | DBGetShowsByFeedL(array, aShowInfo->FeedUid()); | |
| 1147 | TUint diff = KMaxTInt; | |
| 1148 | for (TInt loop = 0; loop < array.Count(); loop++) | |
| 1149 | 		{
 | |
| 1150 | if (aShowInfo->TrackNo() < array[loop]->TrackNo()) | |
| 1151 | 			{
 | |
| 1152 | if ((array[loop]->TrackNo() - aShowInfo->TrackNo()) < diff) | |
| 1153 | 				{
 | |
| 1154 | diff = array[loop]->TrackNo() - aShowInfo->TrackNo(); | |
| 1155 | nextShow = array[loop]; | |
| 1156 | } | |
| 1157 | } | |
| 1158 | } | |
| 1159 | array.ResetAndDestroy(); | |
| 1160 | return nextShow; | |
| 1161 | } | |
| 1162 | ||
| 1163 | TBool CShowEngine::CompareShowsByUid(const CShowInfo &a, const CShowInfo &b) | |
| 1164 | 	{
 | |
| 1165 | return a.Uid() == b.Uid(); | |
| 1166 | } | |
| 1167 | ||
| 1168 | TInt CShowEngine::CompareShowsByDate(const CShowInfo &a, const CShowInfo &b) | |
| 1169 | 	{
 | |
| 1170 | if (a.PubDate() > b.PubDate()) | |
| 1171 | 		{
 | |
| 1172 | 		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
 | |
| 1173 | return -1; | |
| 1174 | } | |
| 1175 | else if (a.PubDate() == b.PubDate()) | |
| 1176 | 		{
 | |
| 1177 | 		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
 | |
| 1178 | return 0; | |
| 1179 | } | |
| 1180 | else | |
| 1181 | 		{
 | |
| 1182 | 		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
 | |
| 1183 | return 1; | |
| 1184 | } | |
| 1185 | } | |
| 1186 | ||
| 1187 | TInt CShowEngine::CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b) | |
| 1188 | 	{
 | |
| 1189 | if (a.TrackNo() < b.TrackNo()) | |
| 1190 | 		{
 | |
| 1191 | return -1; | |
| 1192 | } | |
| 1193 | else if (a.TrackNo() == b.TrackNo()) | |
| 1194 | 		{
 | |
| 1195 | return 0; | |
| 1196 | } | |
| 1197 | else | |
| 1198 | 		{
 | |
| 1199 | return 1; | |
| 1200 | } | |
| 1201 | } | |
| 1202 | ||
| 1203 | TInt CShowEngine::CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b) | |
| 1204 | 	{
 | |
| 1205 | if (a.Title() < b.Title()) | |
| 1206 | 		{
 | |
| 1207 | 		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
 | |
| 1208 | return -1; | |
| 1209 | } | |
| 1210 | else if (a.Title() == b.Title()) | |
| 1211 | 		{
 | |
| 1212 | 		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
 | |
| 1213 | return 0; | |
| 1214 | } | |
| 1215 | else | |
| 1216 | 		{
 | |
| 1217 | 		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
 | |
| 1218 | return 1; | |
| 1219 | } | |
| 1220 | } | |
| 1221 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1222 | EXPORT_C void CShowEngine::DeletePlayedShowsL(RShowInfoArray &aShowInfoArray) | 
| 2 | 1223 | 	{
 | 
| 1224 | for (TInt i = 0; i < aShowInfoArray.Count(); i++) | |
| 1225 | 		{
 | |
| 1226 | if (aShowInfoArray[i]->PlayState() == EPlayed | |
| 1227 | && aShowInfoArray[i]->FileName().Length() > 0) | |
| 1228 | 			{
 | |
| 1229 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName()); | |
| 1230 | aShowInfoArray[i]->SetDownloadState(ENotDownloaded); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1231 | DBUpdateShowL(*aShowInfoArray[i]); | 
| 2 | 1232 | } | 
| 1233 | } | |
| 1234 | } | |
| 1235 | ||
| 1236 | EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles) | |
| 1237 | 	{
 | |
| 1238 | RShowInfoArray array; | |
| 1239 | DBGetShowsByFeedL(array, aFeedUid); | |
| 1240 | ||
| 1241 | const TInt count = array.Count(); | |
| 1242 | ||
| 1243 | for (TInt i = count - 1; i >= 0; i--) | |
| 1244 | 		{
 | |
| 53 | 1245 | if (iShowDownloading && iShowDownloading->Uid() == array[i]->Uid()) | 
| 1246 | 			{
 | |
| 1247 | // trying to delete the active download | |
| 1248 | RemoveDownloadL(iShowDownloading->Uid()); | |
| 1249 | } | |
| 1250 | ||
| 1251 | // delete downloaded file | |
| 2 | 1252 | if (array[i]->FileName().Length() > 0) | 
| 1253 | 			{
 | |
| 1254 | if (aDeleteFiles) | |
| 1255 | 				{
 | |
| 1256 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), array[i]->FileName()); | |
| 1257 | } | |
| 1258 | } | |
| 1259 | } | |
| 1260 | array.ResetAndDestroy(); | |
| 53 | 1261 | |
| 1262 | // delete all shows from DB | |
| 60 | 1263 | DBDeleteAllShowsByFeedL(aFeedUid); | 
| 53 | 1264 | |
| 1265 | // this will clear out deleted shows from the download queue | |
| 1266 | DBGetAllDownloadsL(array); | |
| 1267 | array.ResetAndDestroy(); | |
| 1268 | ||
| 1269 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1270 | } | 
| 1271 | ||
| 60 | 1272 | EXPORT_C void CShowEngine::DeleteOldShowsByFeedL(TUint aFeedUid) | 
| 2 | 1273 | 	{
 | 
| 60 | 1274 | DBDeleteOldShowsByFeedL(aFeedUid); | 
| 2 | 1275 | } | 
| 1276 | ||
| 1277 | EXPORT_C void CShowEngine::DeleteShowL(TUint aShowUid, TBool aRemoveFile) | |
| 1278 | 	{
 | |
| 1279 | ||
| 1280 | CShowInfo *info = DBGetShowByUidL(aShowUid); | |
| 1281 | ||
| 1282 | if (info != NULL) | |
| 1283 | 		{
 | |
| 1284 | if (info->FileName().Length() > 0 && aRemoveFile) | |
| 1285 | 			{
 | |
| 1286 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName()); | |
| 1287 | } | |
| 1288 | ||
| 1289 | info->SetDownloadState(ENotDownloaded); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1290 | DBUpdateShowL(*info); | 
| 2 | 1291 | delete info; | 
| 1292 | } | |
| 1293 | } | |
| 1294 | ||
| 1295 | EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) | |
| 1296 | 	{
 | |
| 1297 | 	DP("CShowEngine::GetShowsByFeed");
 | |
| 1298 | DBGetShowsByFeedL(aShowArray, aFeedUid); | |
| 1299 | } | |
| 1300 | ||
| 1301 | EXPORT_C void CShowEngine::GetAllShowsL(RShowInfoArray &aArray) | |
| 1302 | 	{
 | |
| 1303 | 	DP("CShowEngine::GetAllShows");
 | |
| 1304 | DBGetAllShowsL(aArray); | |
| 1305 | } | |
| 1306 | ||
| 1307 | EXPORT_C void CShowEngine::GetShowsDownloadedL(RShowInfoArray &aArray) | |
| 1308 | 	{
 | |
| 1309 | 	DP("CShowEngine::GetShowsDownloaded");
 | |
| 1310 | DBGetDownloadedShowsL(aArray); | |
| 1311 | } | |
| 1312 | ||
| 1313 | EXPORT_C void CShowEngine::GetNewShowsL(RShowInfoArray &aArray) | |
| 1314 | 	{
 | |
| 1315 | 	DP("CShowEngine::GetNewShows");
 | |
| 1316 | DBGetNewShowsL(aArray); | |
| 1317 | } | |
| 1318 | ||
| 1319 | EXPORT_C void CShowEngine::GetShowsDownloadingL(RShowInfoArray &aArray) | |
| 1320 | 	{
 | |
| 1321 | 	DP("CShowEngine::GetShowsDownloading");
 | |
| 1322 | DBGetAllDownloadsL(aArray); | |
| 1323 | } | |
| 1324 | ||
| 1325 | EXPORT_C TInt CShowEngine::GetNumDownloadingShows() | |
| 1326 | 	{
 | |
| 60 | 1327 | TUint count = 0; | 
| 1328 | TRAP_IGNORE(count = DBGetDownloadsCountL()); | |
| 1329 | ||
| 1330 | return (const TInt) count; | |
| 2 | 1331 | } | 
| 1332 | ||
| 1333 | EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo) | |
| 1334 | 	{
 | |
| 1335 | aInfo.SetDownloadState(EQueued); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1336 | DBUpdateShowL(aInfo); | 
| 60 | 1337 | DBAddDownloadL(aInfo.Uid()); | 
| 2 | 1338 | DownloadNextShowL(); | 
| 1339 | } | |
| 1340 | ||
| 1341 | void CShowEngine::DownloadNextShowL() | |
| 1342 | 	{
 | |
| 1343 | 	DP("CShowEngine::DownloadNextShowL BEGIN");
 | |
| 1344 | // Check if we have anything in the download queue | |
| 60 | 1345 | const TInt count = DBGetDownloadsCountL(); | 
| 2 | 1346 | 	DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count);
 | 
| 1347 | ||
| 1348 | if (count > 0) | |
| 1349 | 		{
 | |
| 1350 | if (iPodcastModel.SettingsEngine().DownloadSuspended()) | |
| 1351 | 			{
 | |
| 1352 | 			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
 | |
| 34 | 1353 | // Inform the observers | 
| 1354 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1355 | return; | 
| 1356 | } | |
| 1357 | else if (iShowClient->IsActive()) | |
| 1358 | 			{
 | |
| 1359 | 			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
 | |
| 34 | 1360 | // Inform the observers | 
| 1361 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1362 | return; | 
| 1363 | } | |
| 1364 | else | |
| 1365 | 			{
 | |
| 60 | 1366 | 			if (iShowDownloading) {
 | 
| 1367 | delete iShowDownloading; | |
| 1368 | } | |
| 2 | 1369 | |
| 60 | 1370 | // Start the download | 
| 1371 | iShowDownloading = DBGetNextDownloadL(); | |
| 2 | 1372 | |
| 60 | 1373 | while(iShowDownloading != NULL) | 
| 2 | 1374 | 				{
 | 
| 60 | 1375 | 				DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(iShowDownloading->Title()));
 | 
| 1376 | iShowDownloading->SetDownloadState(EDownloading); | |
| 1377 | iShowDownloading->SetLastError(KErrNone); | |
| 1378 | DBUpdateShowL(*iShowDownloading); | |
| 34 | 1379 | // Inform the observers | 
| 1380 | // important to do this after we change download state | |
| 1381 | NotifyDownloadQueueUpdatedL(); | |
| 1382 | ||
| 60 | 1383 | TRAPD(error,GetShowL(iShowDownloading)); | 
| 1384 | if (error == KErrNone) | |
| 2 | 1385 | 					{
 | 
| 1386 | break; | |
| 1387 | } | |
| 60 | 1388 | else | 
| 1389 | 					{
 | |
| 1390 | iShowDownloading->SetDownloadState(EFailedDownload); | |
| 1391 | DBRemoveDownloadL(iShowDownloading->Uid()); | |
| 1392 | DBUpdateShowL(*iShowDownloading); | |
| 1393 | CleanupStack::PopAndDestroy(iShowDownloading); | |
| 1394 | ||
| 1395 | iShowDownloading = DBGetNextDownloadL(); | |
| 1396 | if(iShowDownloading == NULL) | |
| 1397 | 						{
 | |
| 1398 | iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); | |
| 1399 | } | |
| 1400 | } | |
| 2 | 1401 | } | 
| 1402 | } | |
| 1403 | } | |
| 1404 | else | |
| 1405 | 		{
 | |
| 34 | 1406 | // Inform the observers | 
| 1407 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1408 | 		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
 | 
| 1409 | } | |
| 1410 | 	DP("CShowEngine::DownloadNextShowL END");
 | |
| 1411 | } | |
| 1412 | ||
| 1413 | void CShowEngine::NotifyDownloadQueueUpdatedL() | |
| 1414 | 	{
 | |
| 1415 | const TInt count = iObservers.Count(); | |
| 1416 | for (TInt i = 0; i < count; i++) | |
| 1417 | 		{
 | |
| 60 | 1418 | iObservers[i]->DownloadQueueUpdatedL(1, DBGetDownloadsCountL() - 1); | 
| 2 | 1419 | } | 
| 1420 | } | |
| 1421 | ||
| 1422 | void CShowEngine::NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal) | |
| 1423 | 	{
 | |
| 1424 | const TInt count = iObservers.Count(); | |
| 1425 | for (TInt i = 0; i < count; i++) | |
| 1426 | 		{
 | |
| 1427 | iObservers[i]->ShowDownloadUpdatedL(aBytesOfCurrentDownload, aBytesTotal); | |
| 1428 | } | |
| 1429 | } | |
| 1430 | ||
| 1431 | void CShowEngine::NotifyShowFinishedL(TInt aError) | |
| 1432 | 	{
 | |
| 1433 | const TInt count = iObservers.Count(); | |
| 1434 | for (TInt i = 0; i < count; i++) | |
| 1435 | 			{
 | |
| 1436 | iObservers[i]->ShowDownloadFinishedL(iShowDownloading?iShowDownloading->Uid():0, aError); | |
| 1437 | } | |
| 1438 | } | |
| 1439 | ||
| 1440 | EXPORT_C void CShowEngine::NotifyShowListUpdatedL() | |
| 1441 | 	{
 | |
| 1442 | for (TInt i = 0; i < iObservers.Count(); i++) | |
| 1443 | 		{
 | |
| 1444 | iObservers[i]->ShowListUpdatedL(); | |
| 1445 | } | |
| 1446 | } | |
| 1447 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1448 | void CShowEngine::ReadMetaDataL(CShowInfo& aShowInfo) | 
| 2 | 1449 | 	{
 | 
| 1450 | 	//DP1("Read %S", &(aShowInfo->Title()));
 | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1451 | DBUpdateShowL(aShowInfo); | 
| 2 | 1452 | } | 
| 1453 | ||
| 1454 | void CShowEngine::ReadMetaDataCompleteL() | |
| 1455 | 	{
 | |
| 1456 | NotifyShowListUpdatedL(); | |
| 1457 | MetaDataReader().SetIgnoreTrackNo(EFalse); | |
| 1458 | } | |
| 1459 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1460 | EXPORT_C void CShowEngine::UpdateShowL(CShowInfo& aInfo) | 
| 2 | 1461 | 	{
 | 
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1462 | DBUpdateShowL(aInfo); | 
| 375 
82f59b3393b3
Fix for bug 3959 part 2, shows being deleted directly after download
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
371diff
changeset | 1463 | |
| 
82f59b3393b3
Fix for bug 3959 part 2, shows being deleted directly after download
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
371diff
changeset | 1464 | // 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: 
371diff
changeset | 1465 | 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: 
371diff
changeset | 1466 | 		{
 | 
| 
82f59b3393b3
Fix for bug 3959 part 2, shows being deleted directly after download
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
371diff
changeset | 1467 | iShowDownloading->SetPlayState(aInfo.PlayState()); | 
| 
82f59b3393b3
Fix for bug 3959 part 2, shows being deleted directly after download
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
371diff
changeset | 1468 | } | 
| 2 | 1469 | } | 
| 1470 | ||
| 1471 | EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader() | |
| 1472 | 	{
 | |
| 1473 | return *iMetaDataReader; | |
| 1474 | } | |
| 1475 | ||
| 1476 | void CShowEngine::FileError(TUint /*aError*/) | |
| 1477 | 	{
 | |
| 1478 | iDownloadErrors = KMaxDownloadErrors; | |
| 1479 | } | |
| 60 | 1480 | |
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1481 | EXPORT_C void CShowEngine::ExpireOldShows() | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1482 | 	{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1483 | 	DP("CShowEngine::ExpireOldShows BEGIN");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1484 | RShowInfoArray oldShowsArray; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1485 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1486 | TRAPD(err, DBGetOldShowsL(oldShowsArray)); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1487 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1488 | if (err == KErrNone) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1489 | 		{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1490 | for (int i=0;i<oldShowsArray.Count();i++) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1491 | 			{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1492 | 			DP1("    deleting %S", &oldShowsArray[i]->FileName());
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1493 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), oldShowsArray[i]->FileName()); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1494 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1495 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1496 | 	DP("CShowEngine::ExpireOldShows END");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1497 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1498 | |
| 60 | 1499 | EXPORT_C void CShowEngine::CheckForDeletedShows(TUint aFeedUid) | 
| 1500 | 	{
 | |
| 1501 | RShowInfoArray shows; | |
| 1502 | ||
| 1503 | TRAPD(err, DBGetShowsByFeedL(shows, aFeedUid)); | |
| 1504 | ||
| 1505 | if (err != KErrNone) | |
| 1506 | 		{
 | |
| 1507 | // probably a catastrophic error, but it doesn't | |
| 1508 | // matter for this method | |
| 1509 | return; | |
| 1510 | } | |
| 1511 | ||
| 1512 | for (int i=0;i<shows.Count();i++) | |
| 1513 | 		{
 | |
| 1514 | if (shows[i]->DownloadState() == EDownloaded && shows[i]->FileName() != KNullDesC) | |
| 1515 | 			{
 | |
| 1516 | if(!BaflUtils::FileExists(iPodcastModel.FsSession(),shows[i]->FileName())) | |
| 1517 | 				{
 | |
| 1518 | // file doesn't exist anymore, assume it was deleted from outside | |
| 1519 | 				DP1("Show %S does not exist on disk, flagging as non downloaded", &shows[i]->FileName());
 | |
| 1520 | shows[i]->SetDownloadState(ENotDownloaded); | |
| 1521 | shows[i]->SetPlayState(EPlayed); | |
| 1522 | TRAP_IGNORE(DBUpdateShowL(*shows[i])); | |
| 1523 | } | |
| 1524 | } | |
| 1525 | } | |
| 1526 | } | |
| 1527 | ||
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1528 | 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: 
67diff
changeset | 1529 | 	{
 | 
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1530 | 	DP("CShowEngine::MoveDownLoadUpL");
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1531 | _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: 
67diff
changeset | 1532 | iSqlBuffer.Format(KSqlStatement); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1533 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1534 | sqlite3_stmt *st; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1535 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1536 | 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: 
67diff
changeset | 1537 | &st, (const void**) NULL); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1538 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1539 | if (rc == SQLITE_OK) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1540 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1541 | RArray<TDownload> downloads; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1542 | CleanupClosePushL(downloads); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1543 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1544 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1545 | 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: 
67diff
changeset | 1546 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1547 | TInt selectedIdx = -1; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1548 | 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: 
67diff
changeset | 1549 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1550 | TDownload download; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1551 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1552 | 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: 
67diff
changeset | 1553 | 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: 
67diff
changeset | 1554 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1555 | downloads.Append(download); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1556 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1557 | if (download.iUid == aUid) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1558 | 				{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1559 | selectedIdx = downloads.Count()-1; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1560 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1561 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1562 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1563 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1564 | CleanupStack::PopAndDestroy();//st, downloads | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1565 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1566 | // 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: 
67diff
changeset | 1567 | if (selectedIdx != -1) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1568 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1569 | // 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: 
67diff
changeset | 1570 | TDownload selectedDownload = downloads[selectedIdx]; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1571 | 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: 
67diff
changeset | 1572 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1573 | // 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: 
67diff
changeset | 1574 | // 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: 
67diff
changeset | 1575 | DBSwapDownloadsL(selectedDownload, previousDownload); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1576 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1577 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1578 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1579 | User::Leave(KErrNotFound); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1580 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1581 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1582 | CleanupStack::PopAndDestroy(); // downloads | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1583 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1584 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1585 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1586 | User::Leave(KErrCorrupt); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1587 | } | 
| 130 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
67diff
changeset | 1588 | } | 
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1589 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1590 | 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: 
67diff
changeset | 1591 | 	{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1592 | 	DP("CShowEngine::MoveDownLoadDownL");
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1593 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1594 | // 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: 
67diff
changeset | 1595 | _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: 
67diff
changeset | 1596 | iSqlBuffer.Format(KSqlStatement); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1597 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1598 | sqlite3_stmt *st; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1599 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1600 | 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: 
67diff
changeset | 1601 | &st, (const void**) NULL); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1602 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1603 | if (rc == SQLITE_OK) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1604 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1605 | RArray<TDownload> downloads; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1606 | CleanupClosePushL(downloads); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1607 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1608 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1609 | 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: 
67diff
changeset | 1610 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1611 | TInt selectedIdx = -1; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1612 | 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: 
67diff
changeset | 1613 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1614 | TDownload download; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1615 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1616 | 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: 
67diff
changeset | 1617 | 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: 
67diff
changeset | 1618 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1619 | downloads.Append(download); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1620 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1621 | if (download.iUid == aUid) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1622 | 				{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1623 | selectedIdx = downloads.Count()-1; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1624 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1625 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1626 | rc = sqlite3_step(st); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1627 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1628 | CleanupStack::PopAndDestroy();//st, downloads | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1629 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1630 | // 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: 
67diff
changeset | 1631 | if (selectedIdx != -1) | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1632 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1633 | // 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: 
67diff
changeset | 1634 | TDownload selectedDownload = downloads[selectedIdx]; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1635 | 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: 
67diff
changeset | 1636 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1637 | // 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: 
67diff
changeset | 1638 | // 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: 
67diff
changeset | 1639 | DBSwapDownloadsL(selectedDownload, previousDownload); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1640 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1641 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1642 | 			{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1643 | User::Leave(KErrNotFound); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1644 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1645 | |
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1646 | CleanupStack::PopAndDestroy(); // downloads | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1647 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1648 | else | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1649 | 		{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1650 | User::Leave(KErrCorrupt); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1651 | } | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
67diff
changeset | 1652 | } | 
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1653 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1654 | EXPORT_C void CShowEngine::PostPlayHandling(CShowInfo *aShow) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1655 | 	{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1656 | 	DP("CShowEngine::PostPlayHandling BEGIN");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1657 | if (!aShow) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1658 | return; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1659 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1660 | aShow->SetPlayState(EPlayed); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1661 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1662 | TAutoDeleteSetting deleteSetting = iPodcastModel.SettingsEngine().DeleteAutomatically(); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1663 | TTimeIntervalDays daysAhead; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1664 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1665 | switch (deleteSetting) | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1666 | 		{
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1667 | case EAutoDeleteOff: | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1668 | break; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1669 | case EAutoDeleteAfter1Day: | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1670 | daysAhead = 1; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1671 | break; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1672 | case EAutoDeleteAfter7Days: | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1673 | daysAhead = 7; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1674 | break; | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1675 | } | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1676 | |
| 371 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1677 | if (daysAhead.Int() > 0) | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1678 | 		{
 | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1679 | TTime deleteDate; | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1680 | deleteDate.HomeTime(); | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1681 | deleteDate += daysAhead; | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1682 | aShow->SetDeleteDate(deleteDate); | 
| 
5077ef63bce2
Fix for bug in handling of automatic deletes
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
364diff
changeset | 1683 | } | 
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1684 | |
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1685 | UpdateShowL(*aShow); | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1686 | 	DP("CShowEngine::PostPlayHandling END");
 | 
| 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 1687 | } |