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