| author | teknolog | 
| Mon, 05 Apr 2010 13:54:26 +0100 | |
| changeset 84 | 3b59b88b089e | 
| parent 83 | a2e43aa1ad11 | 
| child 85 | b03018fb3418 | 
| 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 | //#include <mpxmedia.h> | |
| 31 | //#include <mpxattribute.h> | |
| 32 | //#include <mpxmediageneraldefs.h> | |
| 33 | ||
| 34 | const TUint KMaxDownloadErrors = 3; | |
| 35 | const TInt KMimeBufLength = 100; | |
| 36 | ||
| 37 | CShowEngine::CShowEngine(CPodcastModel& aPodcastModel) : | |
| 38 | iPodcastModel(aPodcastModel), | |
| 39 | iDB(*aPodcastModel.DB()) | |
| 40 | 	{
 | |
| 41 | } | |
| 42 | ||
| 43 | EXPORT_C CShowEngine::~CShowEngine() | |
| 44 | 	{	
 | |
| 45 | delete iShowClient; | |
| 46 | iObservers.Close(); | |
| 47 | delete iShowDownloading; | |
| 48 | delete iMetaDataReader; | |
| 49 | iApaSession.Close(); | |
| 50 | } | |
| 51 | ||
| 52 | EXPORT_C CShowEngine* CShowEngine::NewL(CPodcastModel& aPodcastModel) | |
| 53 | 	{
 | |
| 54 | CShowEngine* self = new (ELeave) CShowEngine(aPodcastModel); | |
| 55 | CleanupStack::PushL(self); | |
| 56 | self->ConstructL(); | |
| 57 | CleanupStack::Pop(self); | |
| 58 | return self; | |
| 59 | } | |
| 60 | ||
| 61 | EXPORT_C void CShowEngine::GetMimeType(const TDesC& aFileName, TDes& aMimeType) | |
| 62 | 	{
 | |
| 63 | aMimeType.Zero(); | |
| 64 | RFile file; | |
| 65 | if (file.Open(iPodcastModel.FsSession(), aFileName, 0) == KErrNone) | |
| 66 | 		{
 | |
| 67 | if (file.Read(iRecogBuffer) == KErrNone) | |
| 68 | 			{
 | |
| 69 | TDataRecognitionResult result; | |
| 70 | if (iApaSession.RecognizeData(aFileName, iRecogBuffer, result) | |
| 71 | == KErrNone) | |
| 72 | 				{
 | |
| 73 | aMimeType.Copy(result.iDataType.Des()); | |
| 74 | } | |
| 75 | ||
| 76 | } | |
| 77 | } | |
| 78 | file.Close(); | |
| 79 | } | |
| 80 | ||
| 81 | void CShowEngine::ConstructL() | |
| 82 | 	{	
 | |
| 83 | iShowClient = CHttpClient::NewL(iPodcastModel, *this); | |
| 84 | iShowClient->SetResumeEnabled(ETrue); | |
| 85 | iMetaDataReader = new (ELeave) CMetaDataReader(*this, iPodcastModel.FsSession()); | |
| 86 | iMetaDataReader->ConstructL(); | |
| 87 | User::LeaveIfError(iApaSession.Connect()); | |
| 88 | } | |
| 89 | ||
| 90 | EXPORT_C void CShowEngine::SuspendDownloads() | |
| 91 | 	{
 | |
| 92 | iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); | |
| 93 | iShowClient->Stop(); | |
| 94 | } | |
| 95 | ||
| 96 | EXPORT_C void CShowEngine::ResumeDownloadsL() | |
| 97 | 	{
 | |
| 98 | 	DP("CShowEngine::ResumeDownloadsL BEGIN");
 | |
| 99 | if (iPodcastModel.SettingsEngine().DownloadSuspended()) | |
| 100 | 		{
 | |
| 101 | iPodcastModel.SettingsEngine().SetDownloadSuspended(EFalse); | |
| 102 | iDownloadErrors = 0; | |
| 103 | DownloadNextShowL(); | |
| 104 | } | |
| 105 | 	DP("CShowEngine::ResumeDownloadsL END");
 | |
| 106 | } | |
| 107 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 108 | EXPORT_C void CShowEngine::RemoveAllDownloadsL() | 
| 2 | 109 | 	{
 | 
| 110 | if (!iPodcastModel.SettingsEngine().DownloadSuspended()) | |
| 111 | 		{
 | |
| 112 | SuspendDownloads(); | |
| 113 | } | |
| 114 | ||
| 78 | 115 | DBRemoveAllDownloadsL(); | 
| 22 | 116 | NotifyDownloadQueueUpdatedL(); | 
| 2 | 117 | } | 
| 118 | ||
| 78 | 119 | EXPORT_C void CShowEngine::RemoveDownloadL(TUint aUid) | 
| 2 | 120 | 	{
 | 
| 78 | 121 | 	DP("CShowEngine::RemoveDownloadL BEGIN");
 | 
| 2 | 122 | |
| 123 | TBool resumeAfterRemove = EFalse; | |
| 124 | // if trying to remove the present download, we first stop it | |
| 125 | if (!iPodcastModel.SettingsEngine().DownloadSuspended() && iShowDownloading != NULL | |
| 126 | && iShowDownloading->Uid() == aUid) | |
| 127 | 		{
 | |
| 128 | 		DP("CShowEngine::RemoveDownload\t This is the active download, we suspend downloading");
 | |
| 129 | SuspendDownloads(); | |
| 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 | } | |
| 78 | 140 | |
| 141 | DBRemoveDownloadL(aUid); | |
| 2 | 142 | |
| 143 | // partial downloads should be removed | |
| 144 | if (iShowDownloading) | |
| 145 | 		{
 | |
| 146 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), iShowDownloading->FileName()); | |
| 147 | } | |
| 148 | ||
| 83 | 149 | if (resumeAfterRemove) | 
| 150 | 		{
 | |
| 2 | 151 | ResumeDownloadsL(); | 
| 83 | 152 | } | 
| 153 | else | |
| 154 | 		{
 | |
| 155 | NotifyShowDownloadUpdatedL(-1, -1); | |
| 156 | NotifyDownloadQueueUpdatedL(); | |
| 157 | } | |
| 2 | 158 | |
| 159 | DownloadNextShowL(); | |
| 78 | 160 | 	DP("CShowEngine::RemoveDownloadL END");
 | 
| 2 | 161 | } | 
| 162 | ||
| 163 | void CShowEngine::Connected(CHttpClient* /*aClient*/) | |
| 164 | 	{
 | |
| 165 | ||
| 166 | } | |
| 167 | ||
| 168 | void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes, | |
| 169 | TInt aTotalBytes) | |
| 170 | 	{	
 | |
| 171 | iShowDownloading->SetShowSize(aTotalBytes); | |
| 172 | TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes)); | |
| 173 | } | |
| 174 | ||
| 175 | void CShowEngine::Disconnected(CHttpClient* /*aClient */) | |
| 176 | 	{
 | |
| 177 | } | |
| 178 | ||
| 179 | void CShowEngine::DownloadInfo(CHttpClient* aHttpClient, TInt aTotalBytes) | |
| 180 | 	{
 | |
| 181 | 	DP1("About to download %d bytes", aTotalBytes);
 | |
| 182 | if (aHttpClient == iShowClient && iShowDownloading != NULL | |
| 183 | && aTotalBytes != -1) | |
| 184 | 		{
 | |
| 185 | iShowDownloading->SetShowSize(aTotalBytes); | |
| 186 | } | |
| 187 | } | |
| 188 | ||
| 78 | 189 | void CShowEngine::GetShowL(CShowInfo *info) | 
| 2 | 190 | 	{
 | 
| 191 | CFeedInfo *feedInfo = iPodcastModel.FeedEngine().GetFeedInfoByUid( | |
| 192 | info->FeedUid()); | |
| 78 | 193 | |
| 2 | 194 | TFileName filePath; | 
| 195 | filePath.Copy(iPodcastModel.SettingsEngine().BaseDir()); | |
| 196 | ||
| 197 | TFileName relPath; | |
| 198 | relPath.Copy(feedInfo->Title()); | |
| 199 | 	relPath.Append('\\');
 | |
| 200 | ||
| 201 | TFileName fileName; | |
| 202 | PodcastUtils::FileNameFromUrl(info->Url(), fileName); | |
| 203 | relPath.Append(fileName); | |
| 204 | PodcastUtils::EnsureProperPathName(relPath); | |
| 205 | ||
| 206 | // complete file path is base dir + rel path | |
| 207 | filePath.Append(relPath); | |
| 208 | info->SetFileNameL(filePath); | |
| 209 | ||
| 78 | 210 | User::LeaveIfError(iShowClient->GetL(info->Url(), filePath)); | 
| 2 | 211 | } | 
| 212 | ||
| 78 | 213 | EXPORT_C void CShowEngine::AddShowL(const CShowInfo& aItem) | 
| 2 | 214 | 	{
 | 
| 215 | 	DP1("CShowEngine::AddShowL, title=%S", &aItem.Title());
 | |
| 216 | CShowInfo *showInfo = DBGetShowByUidL(aItem.Uid()); | |
| 217 | ||
| 218 | if (showInfo == NULL) | |
| 219 | 		{
 | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 220 | DBAddShowL(aItem); | 
| 2 | 221 | } | 
| 222 | else | |
| 223 | 		{
 | |
| 224 | delete showInfo; | |
| 78 | 225 | User::Leave(KErrAlreadyExists); | 
| 2 | 226 | } | 
| 227 | } | |
| 228 | ||
| 229 | EXPORT_C void CShowEngine::AddObserver(MShowEngineObserver *observer) | |
| 230 | 	{
 | |
| 231 | iObservers.Append(observer); | |
| 232 | } | |
| 233 | ||
| 234 | EXPORT_C void CShowEngine::RemoveObserver(MShowEngineObserver *observer) | |
| 235 | 	{
 | |
| 236 | TInt index = iObservers.Find(observer); | |
| 237 | ||
| 238 | if (index > KErrNotFound) | |
| 239 | 		{
 | |
| 240 | iObservers.Remove(index); | |
| 241 | } | |
| 242 | } | |
| 243 | ||
| 244 | void CShowEngine::AddShowToMpxCollection(CShowInfo &/*aShowInfo*/) | |
| 245 | 	{
 | |
| 246 | /* RArray<TInt> contentIDs; | |
| 247 | contentIDs.AppendL( KMPXMediaIdGeneral ); | |
| 248 | ||
| 249 | CMPXMedia* media = CMPXMedia::NewL( contentIDs.Array() ); | |
| 250 | CleanupStack::PushL( media ); | |
| 251 | contentIDs.Close(); | |
| 252 | CleanupStack::PopAndDestroy(media); */ | |
| 253 | } | |
| 254 | ||
| 255 | void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) | |
| 256 | 	{
 | |
| 257 | if (iShowDownloading != NULL) | |
| 258 | 		{
 | |
| 82 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 259 | 		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);		
 | 
| 2 | 260 | if(aError != KErrCouldNotConnect) | 
| 261 | 			{
 | |
| 6 | 262 | if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended()) | 
| 263 | 				{
 | |
| 2 | 264 | // no error if disconnect happened because of suspended downloading | 
| 6 | 265 | } | 
| 266 | else | |
| 267 | 				{
 | |
| 2 | 268 | iShowDownloading->SetLastError(aError); | 
| 6 | 269 | } | 
| 2 | 270 | |
| 271 | if (aError == KErrNone) | |
| 272 | 				{
 | |
| 273 | TBuf<KMimeBufLength> mimeType; | |
| 274 | GetMimeType(iShowDownloading->FileName(), mimeType); | |
| 275 | _LIT(KMimeAudio,"audio"); | |
| 276 | _LIT(KMimeVideo,"video"); | |
| 277 | if (mimeType.Left(5) == KMimeAudio) | |
| 278 | 					{
 | |
| 279 | iShowDownloading->SetShowType(EAudioPodcast); | |
| 280 | } | |
| 281 | else if (mimeType.Left(5) == KMimeVideo) | |
| 282 | 					{
 | |
| 283 | iShowDownloading->SetShowType(EVideoPodcast); | |
| 284 | } | |
| 285 | ||
| 286 | iShowDownloading->SetDownloadState(EDownloaded); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 287 | DBUpdateShowL(*iShowDownloading); | 
| 78 | 288 | DBRemoveDownloadL(iShowDownloading->Uid()); | 
| 2 | 289 | AddShowToMpxCollection(*iShowDownloading); | 
| 290 | NotifyShowFinishedL(aError); | |
| 15 
93d9f66bf50b
Cleaning description better for second line in search results
 teknolog parents: 
6diff
changeset | 291 | iDownloadErrors = 0; | 
| 2 | 292 | delete iShowDownloading; | 
| 293 | iShowDownloading = NULL; | |
| 294 | } | |
| 295 | else | |
| 296 | 				{
 | |
| 297 | // 400 and 500 series errors are serious errors on which probably another download will fail | |
| 298 | if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) | |
| 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); | 
| 78 | 302 | DBRemoveDownloadL(iShowDownloading->Uid()); | 
| 2 | 303 | NotifyShowFinishedL(aError); | 
| 304 | ||
| 305 | delete iShowDownloading; | |
| 306 | iShowDownloading = NULL; | |
| 307 | } | |
| 82 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 308 | else if (aError == KErrDiskFull) | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 309 | 					{
 | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 310 | // stop downloading immediately if disk is full | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 311 | iShowDownloading->SetDownloadState(EQueued); | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 312 | DBUpdateShowL(*iShowDownloading); | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 313 | iDownloadErrors = KMaxDownloadErrors; | 
| 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 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 | ||
| 82 
d87e984bd8b8
Even more robustness improvements for HTTP client - specifically disk full problems
 teknolog parents: 
79diff
changeset | 321 | NotifyDownloadQueueUpdatedL(); | 
| 2 | 322 | iDownloadErrors++; | 
| 84 
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
 teknolog parents: 
83diff
changeset | 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 | } | |
| 78 | 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 | 		{
 | |
| 78 | 485 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 486 | rc = sqlite3_step(st); | 
| 78 | 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 | } | |
| 78 | 525 | else | 
| 526 | 			{
 | |
| 527 | User::Leave(KErrUnknown); | |
| 528 | } | |
| 2 | 529 | CleanupStack::PopAndDestroy();//st | 
| 530 | } | |
| 78 | 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 | ||
| 545 | #ifndef DONT_SORT_SQL | |
| 546 | _LIT(KSqlOrderByDate, " order by pubdate desc"); | |
| 547 | iSqlBuffer.Append(KSqlOrderByDate); | |
| 548 | #endif | |
| 549 | ||
| 550 | sqlite3_stmt *st; | |
| 551 | ||
| 552 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 553 | &st, (const void**) NULL); | |
| 554 | ||
| 555 | if (rc == SQLITE_OK) | |
| 556 | 		{
 | |
| 557 | rc = sqlite3_step(st); | |
| 558 | Cleanup_sqlite3_finalize_PushL(st); | |
| 559 | while (rc == SQLITE_ROW) | |
| 560 | 			{
 | |
| 561 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 562 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 563 | aShowArray.Append(showInfo); | |
| 564 | CleanupStack::Pop(showInfo); | |
| 565 | rc = sqlite3_step(st); | |
| 566 | } | |
| 567 | CleanupStack::PopAndDestroy();//st | |
| 568 | } | |
| 78 | 569 | else | 
| 570 | 		{
 | |
| 571 | User::Leave(KErrCorrupt); | |
| 572 | } | |
| 2 | 573 | 	DP("CShowEngine::DBGetShowsByFeed END");
 | 
| 574 | } | |
| 575 | ||
| 78 | 576 | TUint CShowEngine::DBGetDownloadsCountL() | 
| 2 | 577 | 	{
 | 
| 578 | 	DP("CShowEngine::DBGetDownloadsCount");
 | |
| 579 | ||
| 580 | _LIT(KSqlStatement, "select count(*) from downloads"); | |
| 581 | iSqlBuffer.Format(KSqlStatement); | |
| 582 | ||
| 583 | sqlite3_stmt *st; | |
| 584 | TUint count = 0; | |
| 585 | ||
| 586 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 587 | &st, (const void**) NULL); | |
| 588 | ||
| 589 | if (rc == SQLITE_OK) | |
| 590 | 		{
 | |
| 78 | 591 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 592 | rc = sqlite3_step(st); | 
| 593 | ||
| 594 | if (rc == SQLITE_ROW) | |
| 595 | 			{
 | |
| 596 | count = sqlite3_column_int(st, 0); | |
| 597 | } | |
| 78 | 598 | else | 
| 599 | 			{
 | |
| 600 | User::Leave(KErrUnknown); | |
| 601 | } | |
| 602 | ||
| 603 | CleanupStack::PopAndDestroy(); //st | |
| 604 | } | |
| 605 | else | |
| 606 | 		{
 | |
| 607 | User::Leave(KErrCorrupt); | |
| 2 | 608 | } | 
| 609 | return count; | |
| 610 | } | |
| 611 | ||
| 612 | void CShowEngine::DBGetDownloadedShowsL(RShowInfoArray& aShowArray) | |
| 613 | 	{
 | |
| 614 | 	DP("CShowEngine::DBGetDownloadedShows");
 | |
| 615 | _LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where downloadstate=%u"); | |
| 616 | iSqlBuffer.Format(KSqlStatement, EDownloaded); | |
| 617 | ||
| 618 | #ifndef DONT_SORT_SQL | |
| 619 | _LIT(KSqlSort, " order by title"); | |
| 620 | iSqlBuffer.Append(KSqlSort); | |
| 621 | #endif | |
| 622 | ||
| 623 | sqlite3_stmt *st; | |
| 624 | ||
| 625 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 626 | &st, (const void**) NULL); | |
| 627 | ||
| 628 | if (rc == SQLITE_OK) | |
| 629 | 		{
 | |
| 630 | rc = sqlite3_step(st); | |
| 631 | Cleanup_sqlite3_finalize_PushL(st); | |
| 632 | while (rc == SQLITE_ROW) | |
| 633 | 			{
 | |
| 634 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 635 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 636 | aShowArray.Append(showInfo); | |
| 637 | CleanupStack::Pop(showInfo); | |
| 638 | rc = sqlite3_step(st); | |
| 639 | } | |
| 640 | CleanupStack::PopAndDestroy();//st | |
| 641 | } | |
| 78 | 642 | else | 
| 643 | 		{
 | |
| 644 | User::Leave(KErrCorrupt); | |
| 645 | } | |
| 2 | 646 | } | 
| 647 | ||
| 648 | void CShowEngine::DBGetNewShowsL(RShowInfoArray& aShowArray) | |
| 649 | 	{
 | |
| 650 | 	DP("CShowEngine::DBGetNewShows");
 | |
| 651 | _LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where playstate=%u"); | |
| 652 | iSqlBuffer.Format(KSqlStatement, ENeverPlayed); | |
| 653 | ||
| 654 | sqlite3_stmt *st; | |
| 655 | ||
| 656 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 657 | &st, (const void**) NULL); | |
| 658 | ||
| 659 | if (rc == SQLITE_OK) | |
| 660 | 		{
 | |
| 661 | rc = sqlite3_step(st); | |
| 662 | Cleanup_sqlite3_finalize_PushL(st); | |
| 663 | while (rc == SQLITE_ROW) | |
| 664 | 			{
 | |
| 665 | CShowInfo* showInfo = CShowInfo::NewLC(); | |
| 666 | DBFillShowInfoFromStmtL(st, showInfo); | |
| 667 | aShowArray.Append(showInfo); | |
| 668 | CleanupStack::Pop(showInfo); | |
| 669 | rc = sqlite3_step(st); | |
| 670 | } | |
| 671 | CleanupStack::PopAndDestroy();//st | |
| 672 | } | |
| 78 | 673 | else | 
| 674 | 		{
 | |
| 675 | User::Leave(KErrCorrupt); | |
| 676 | } | |
| 2 | 677 | } | 
| 678 | ||
| 78 | 679 | void CShowEngine::DBDeleteOldShowsByFeedL(TUint aFeedUid) | 
| 2 | 680 | 	{
 | 
| 681 | 	DP("CShowEngine::DBDeleteOldShows");
 | |
| 682 | ||
| 683 | // what we do: | |
| 684 | // 1. sort shows by pubdate | |
| 685 | // 2. select the first MaxListItems shows | |
| 686 | // 3. delete the rest if downloadstate is ENotDownloaded | |
| 687 | ||
| 688 | _LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in " \ | |
| 689 | "(select uid from shows where feeduid=%u order by pubdate desc limit %u)"); | |
| 690 | iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems()); | |
| 691 | ||
| 692 | sqlite3_stmt *st; | |
| 693 | ||
| 694 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 695 | &st, (const void**) NULL); | |
| 696 | ||
| 697 | if (rc == SQLITE_OK) | |
| 698 | 		{
 | |
| 699 | rc = sqlite3_step(st); | |
| 700 | sqlite3_finalize(st); | |
| 701 | } | |
| 78 | 702 | else | 
| 703 | 		{
 | |
| 704 | User::Leave(KErrCorrupt); | |
| 705 | } | |
| 2 | 706 | |
| 707 | _LIT(KSqlStatement2, "delete from downloads where uid not in (select downloads.uid from shows, downloads where shows.uid=downloads.uid)"); | |
| 708 | iSqlBuffer.Format(KSqlStatement2); | |
| 709 | ||
| 710 | rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, (const void**) NULL); | |
| 711 | ||
| 712 | if (rc == SQLITE_OK) | |
| 713 | 		{
 | |
| 714 | rc = sqlite3_step(st); | |
| 715 | sqlite3_finalize(st); | |
| 716 | } | |
| 78 | 717 | else | 
| 718 | 		{
 | |
| 719 | User::Leave(KErrCorrupt); | |
| 720 | } | |
| 2 | 721 | } | 
| 722 | ||
| 723 | void CShowEngine::DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo) | |
| 724 | 	{
 | |
| 725 | const void *urlz = sqlite3_column_text16(st, 0); | |
| 726 | TPtrC16 url((const TUint16*) urlz); | |
| 727 | showInfo->SetUrlL(url); | |
| 728 | ||
| 729 | const void *titlez = sqlite3_column_text16(st, 1); | |
| 730 | TPtrC16 title((const TUint16*) titlez); | |
| 731 | showInfo->SetTitleL(title); | |
| 732 | ||
| 733 | const void *descz = sqlite3_column_text16(st, 2); | |
| 734 | TPtrC16 desc((const TUint16*) descz); | |
| 735 | showInfo->SetDescriptionL(desc); | |
| 736 | ||
| 737 | const void *filez = sqlite3_column_text16(st, 3); | |
| 738 | TPtrC16 file((const TUint16*) filez); | |
| 739 | showInfo->SetFileNameL(file); | |
| 740 | ||
| 741 | sqlite3_int64 pos = sqlite3_column_int64(st, 4); | |
| 742 | TTimeIntervalMicroSeconds position(pos); | |
| 743 | showInfo->SetPosition(position); | |
| 744 | ||
| 745 | TUint playtime = sqlite3_column_int(st, 5); | |
| 746 | showInfo->SetPlayTime(playtime); | |
| 747 | ||
| 748 | TUint playstate = sqlite3_column_int(st, 6); | |
| 749 | showInfo->SetPlayState((TPlayState) playstate); | |
| 750 | ||
| 751 | TUint downloadstate = sqlite3_column_int(st, 7); | |
| 752 | showInfo->SetDownloadState((TDownloadState) downloadstate); | |
| 753 | ||
| 754 | TUint feeduid = sqlite3_column_int(st, 8); | |
| 755 | showInfo->SetFeedUid(feeduid); | |
| 756 | ||
| 757 | TUint uid = sqlite3_column_int(st, 9); | |
| 758 | showInfo->SetUid(uid); | |
| 759 | ||
| 760 | TUint showsize = sqlite3_column_int(st, 10); | |
| 761 | showInfo->SetShowSize(showsize); | |
| 762 | ||
| 763 | TUint trackno = sqlite3_column_int(st, 11); | |
| 764 | showInfo->SetTrackNo((TShowType) trackno); | |
| 765 | ||
| 766 | sqlite3_int64 pubdate = sqlite3_column_int64(st, 12); | |
| 767 | TTime timepubdate(pubdate); | |
| 768 | showInfo->SetPubDate(timepubdate); | |
| 769 | ||
| 770 | TUint showtype = sqlite3_column_int(st, 13); | |
| 771 | showInfo->SetShowType((TShowType) showtype); | |
| 772 | ||
| 773 | TInt lasterror = sqlite3_column_int(st, 14); | |
| 774 | showInfo->SetLastError(lasterror); | |
| 775 | } | |
| 776 | ||
| 78 | 777 | void CShowEngine::DBAddShowL(const CShowInfo& aItem) | 
| 2 | 778 | 	{
 | 
| 779 | 	DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
 | |
| 780 | ||
| 21 | 781 | HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); | 
| 782 | TPtr titlePtr(titleBuf->Des()); | |
| 783 | titlePtr.Copy(aItem.Title()); | |
| 784 | PodcastUtils::SQLEncode(titlePtr); | |
| 785 | ||
| 786 | HBufC* descBuf = HBufC::NewLC(KMaxLineLength); | |
| 787 | TPtr descPtr(descBuf->Des()); | |
| 788 | descPtr.Copy(aItem.Description()); | |
| 789 | PodcastUtils::SQLEncode(descPtr); | |
| 790 | ||
| 2 | 791 | _LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype)" | 
| 792 | " values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\")"); | |
| 21 | 793 | |
| 794 | iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, | |
| 2 | 795 | &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), | 
| 796 | aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), | |
| 797 | aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(), | |
| 798 | aItem.PubDate().Int64(), aItem.ShowType()); | |
| 799 | ||
| 21 | 800 | CleanupStack::PopAndDestroy(descBuf); | 
| 801 | CleanupStack::PopAndDestroy(titleBuf); | |
| 802 | ||
| 2 | 803 | sqlite3_stmt *st; | 
| 804 | ||
| 805 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 806 | &st, (const void**) NULL); | |
| 78 | 807 | |
| 2 | 808 | if (rc == SQLITE_OK) | 
| 809 | 		{
 | |
| 78 | 810 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 811 | rc = sqlite3_step(st); | 
| 78 | 812 | if (rc != SQLITE_DONE) | 
| 2 | 813 | 			{
 | 
| 78 | 814 | User::Leave(KErrAlreadyExists); | 
| 2 | 815 | } | 
| 78 | 816 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 817 | } | 
| 818 | else | |
| 819 | 		{
 | |
| 78 | 820 | User::Leave(KErrCorrupt); | 
| 2 | 821 | } | 
| 822 | } | |
| 823 | ||
| 78 | 824 | void CShowEngine::DBAddDownloadL(TUint aUid) | 
| 2 | 825 | 	{
 | 
| 826 | 	DP1("CShowEngine::DBAddDownload, aUid=%u", aUid);
 | |
| 827 | ||
| 828 | _LIT(KSqlStatement, "insert into downloads (uid) values (%u)"); | |
| 829 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 830 | sqlite3_stmt *st; | |
| 831 | ||
| 832 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 833 | &st, (const void**) NULL); | |
| 834 | ||
| 835 | if (rc == SQLITE_OK) | |
| 836 | 		{
 | |
| 78 | 837 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 838 | rc = sqlite3_step(st); | 
| 83 | 839 | if (rc != SQLITE_DONE) | 
| 78 | 840 | 			{
 | 
| 841 | User::Leave(KErrUnknown); | |
| 842 | } | |
| 843 | CleanupStack::PopAndDestroy(); // st | |
| 2 | 844 | } | 
| 78 | 845 | else | 
| 846 | 		{
 | |
| 847 | User::Leave(KErrCorrupt); | |
| 848 | } | |
| 2 | 849 | } | 
| 850 | ||
| 78 | 851 | void CShowEngine::DBUpdateShowL(CShowInfo& aItem) | 
| 2 | 852 | 	{
 | 
| 853 | 	DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title());
 | |
| 854 | ||
| 30 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 855 | HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 856 | TPtr titlePtr(titleBuf->Des()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 857 | titlePtr.Copy(aItem.Title()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 858 | PodcastUtils::SQLEncode(titlePtr); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 859 | |
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 860 | HBufC* descBuf = HBufC::NewLC(KMaxLineLength); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 861 | TPtr descPtr(descBuf->Des()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 862 | descPtr.Copy(aItem.Description()); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 863 | PodcastUtils::SQLEncode(descPtr); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 864 | |
| 2 | 865 | _LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\"," | 
| 866 | "playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\"," | |
| 867 | "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 | 868 | iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, | 
| 2 | 869 | &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), | 
| 870 | aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), | |
| 871 | aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(), | |
| 872 | aItem.ShowType(), aItem.LastError(), aItem.Uid()); | |
| 873 | ||
| 30 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 874 | CleanupStack::PopAndDestroy(descBuf); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 875 | CleanupStack::PopAndDestroy(titleBuf); | 
| 
7bca37ba5fa9
Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
 teknolog parents: 
22diff
changeset | 876 | |
| 2 | 877 | sqlite3_stmt *st; | 
| 878 | ||
| 879 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 880 | &st, (const void**) NULL); | |
| 881 | ||
| 882 | if (rc == SQLITE_OK) | |
| 883 | 		{
 | |
| 78 | 884 | Cleanup_sqlite3_finalize_PushL(st); | 
| 885 | rc = sqlite3_step(st); | |
| 2 | 886 | |
| 83 | 887 | if (rc != SQLITE_DONE) | 
| 2 | 888 | 			{
 | 
| 78 | 889 | User::Leave(KErrUnknown); | 
| 2 | 890 | } | 
| 78 | 891 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 892 | } | 
| 893 | else | |
| 894 | 		{
 | |
| 78 | 895 | User::Leave(KErrCorrupt); | 
| 2 | 896 | } | 
| 897 | } | |
| 898 | ||
| 78 | 899 | void CShowEngine::DBDeleteShowL(TUint aUid) | 
| 2 | 900 | 	{
 | 
| 901 | 	DP("CShowEngine::DBDeleteShow");
 | |
| 902 | ||
| 903 | _LIT(KSqlStatement, "delete from shows where uid=%u"); | |
| 904 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 905 | ||
| 906 | sqlite3_stmt *st; | |
| 907 | ||
| 908 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 909 | &st, (const void**) NULL); | |
| 910 | ||
| 911 | if (rc == SQLITE_OK) | |
| 912 | 		{
 | |
| 78 | 913 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 914 | rc = sqlite3_step(st); | 
| 915 | ||
| 83 | 916 | if (rc != SQLITE_DONE) | 
| 2 | 917 | 			{
 | 
| 78 | 918 | User::Leave(KErrUnknown); | 
| 2 | 919 | } | 
| 78 | 920 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 921 | } | 
| 922 | else | |
| 923 | 		{
 | |
| 78 | 924 | User::Leave(KErrCorrupt); | 
| 2 | 925 | } | 
| 926 | } | |
| 927 | ||
| 78 | 928 | void CShowEngine::DBDeleteAllShowsByFeedL(TUint aFeedUid) | 
| 2 | 929 | 	{
 | 
| 930 | 	DP("CShowEngine::DBDeleteAllShowsByFeed");
 | |
| 931 | ||
| 932 | _LIT(KSqlStatement, "delete from shows where feeduid=%u"); | |
| 933 | iSqlBuffer.Format(KSqlStatement, aFeedUid); | |
| 934 | ||
| 935 | sqlite3_stmt *st; | |
| 936 | ||
| 937 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 938 | &st, (const void**) NULL); | |
| 939 | ||
| 940 | if (rc == SQLITE_OK) | |
| 941 | 		{
 | |
| 78 | 942 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 943 | rc = sqlite3_step(st); | 
| 944 | ||
| 83 | 945 | if (rc != SQLITE_DONE) | 
| 2 | 946 | 			{
 | 
| 78 | 947 | User::Leave(KErrUnknown); | 
| 2 | 948 | } | 
| 78 | 949 | CleanupStack::PopAndDestroy(); // st | 
| 2 | 950 | } | 
| 951 | else | |
| 952 | 		{
 | |
| 78 | 953 | User::Leave(KErrCorrupt); | 
| 2 | 954 | } | 
| 955 | } | |
| 956 | ||
| 78 | 957 | void CShowEngine::DBRemoveAllDownloadsL() | 
| 2 | 958 | 	{
 | 
| 959 | 	DP("CShowEngine::DBRemoveAllDownloads");
 | |
| 960 | ||
| 961 | _LIT(KSqlStatement, "delete from downloads"); | |
| 962 | iSqlBuffer.Format(KSqlStatement); | |
| 963 | ||
| 964 | sqlite3_stmt *st; | |
| 965 | ||
| 966 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 967 | &st, (const void**) NULL); | |
| 968 | ||
| 969 | if (rc == SQLITE_OK) | |
| 970 | 		{
 | |
| 971 | rc = sqlite3_step(st); | |
| 972 | sqlite3_finalize(st); | |
| 973 | } | |
| 78 | 974 | else | 
| 975 | 		{
 | |
| 976 | User::Leave(KErrCorrupt); | |
| 977 | } | |
| 2 | 978 | |
| 979 | _LIT(KSqlStatement2, "update shows set downloadstate=0 where downloadstate=1"); | |
| 980 | iSqlBuffer.Format(KSqlStatement2); | |
| 981 | ||
| 982 | rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st, | |
| 983 | (const void**) NULL); | |
| 984 | ||
| 985 | if (rc == SQLITE_OK) | |
| 986 | 		{
 | |
| 78 | 987 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 988 | rc = sqlite3_step(st); | 
| 83 | 989 | if (rc != SQLITE_DONE) | 
| 78 | 990 | 			{
 | 
| 991 | User::Leave(KErrUnknown); | |
| 992 | } | |
| 993 | CleanupStack::PopAndDestroy(); // st | |
| 994 | } | |
| 995 | else | |
| 996 | 		{
 | |
| 997 | User::Leave(KErrCorrupt); | |
| 2 | 998 | } | 
| 999 | ||
| 1000 | } | |
| 1001 | ||
| 78 | 1002 | void CShowEngine::DBRemoveDownloadL(TUint aUid) | 
| 2 | 1003 | 	{
 | 
| 1004 | 	DP("CShowEngine::DBRemoveDownload");
 | |
| 1005 | ||
| 1006 | _LIT(KSqlStatement, "delete from downloads where uid=%u"); | |
| 1007 | iSqlBuffer.Format(KSqlStatement, aUid); | |
| 1008 | ||
| 1009 | sqlite3_stmt *st; | |
| 1010 | ||
| 1011 | int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, | |
| 1012 | &st, (const void**) NULL); | |
| 1013 | ||
| 1014 | if (rc == SQLITE_OK) | |
| 1015 | 		{
 | |
| 78 | 1016 | Cleanup_sqlite3_finalize_PushL(st); | 
| 2 | 1017 | rc = sqlite3_step(st); | 
| 83 | 1018 | if (rc != SQLITE_DONE) | 
| 78 | 1019 | 			{
 | 
| 1020 | User::Leave(KErrUnknown); | |
| 1021 | } | |
| 1022 | CleanupStack::PopAndDestroy(); // st | |
| 1023 | } | |
| 1024 | else | |
| 1025 | 		{
 | |
| 1026 | User::Leave(KErrCorrupt); | |
| 2 | 1027 | } | 
| 1028 | } | |
| 1029 | ||
| 1030 | EXPORT_C CShowInfo* CShowEngine::GetNextShowByTrackL(CShowInfo* aShowInfo) | |
| 1031 | 	{
 | |
| 1032 | CShowInfo* nextShow = NULL; | |
| 1033 | RShowInfoArray array; | |
| 1034 | DBGetShowsByFeedL(array, aShowInfo->FeedUid()); | |
| 1035 | TUint diff = KMaxTInt; | |
| 1036 | for (TInt loop = 0; loop < array.Count(); loop++) | |
| 1037 | 		{
 | |
| 1038 | if (aShowInfo->TrackNo() < array[loop]->TrackNo()) | |
| 1039 | 			{
 | |
| 1040 | if ((array[loop]->TrackNo() - aShowInfo->TrackNo()) < diff) | |
| 1041 | 				{
 | |
| 1042 | diff = array[loop]->TrackNo() - aShowInfo->TrackNo(); | |
| 1043 | nextShow = array[loop]; | |
| 1044 | } | |
| 1045 | } | |
| 1046 | } | |
| 1047 | array.ResetAndDestroy(); | |
| 1048 | return nextShow; | |
| 1049 | } | |
| 1050 | ||
| 1051 | TBool CShowEngine::CompareShowsByUid(const CShowInfo &a, const CShowInfo &b) | |
| 1052 | 	{
 | |
| 1053 | return a.Uid() == b.Uid(); | |
| 1054 | } | |
| 1055 | ||
| 1056 | TInt CShowEngine::CompareShowsByDate(const CShowInfo &a, const CShowInfo &b) | |
| 1057 | 	{
 | |
| 1058 | if (a.PubDate() > b.PubDate()) | |
| 1059 | 		{
 | |
| 1060 | 		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
 | |
| 1061 | return -1; | |
| 1062 | } | |
| 1063 | else if (a.PubDate() == b.PubDate()) | |
| 1064 | 		{
 | |
| 1065 | 		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
 | |
| 1066 | return 0; | |
| 1067 | } | |
| 1068 | else | |
| 1069 | 		{
 | |
| 1070 | 		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
 | |
| 1071 | return 1; | |
| 1072 | } | |
| 1073 | } | |
| 1074 | ||
| 1075 | TInt CShowEngine::CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b) | |
| 1076 | 	{
 | |
| 1077 | if (a.TrackNo() < b.TrackNo()) | |
| 1078 | 		{
 | |
| 1079 | return -1; | |
| 1080 | } | |
| 1081 | else if (a.TrackNo() == b.TrackNo()) | |
| 1082 | 		{
 | |
| 1083 | return 0; | |
| 1084 | } | |
| 1085 | else | |
| 1086 | 		{
 | |
| 1087 | return 1; | |
| 1088 | } | |
| 1089 | } | |
| 1090 | ||
| 1091 | TInt CShowEngine::CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b) | |
| 1092 | 	{
 | |
| 1093 | if (a.Title() < b.Title()) | |
| 1094 | 		{
 | |
| 1095 | 		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
 | |
| 1096 | return -1; | |
| 1097 | } | |
| 1098 | else if (a.Title() == b.Title()) | |
| 1099 | 		{
 | |
| 1100 | 		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
 | |
| 1101 | return 0; | |
| 1102 | } | |
| 1103 | else | |
| 1104 | 		{
 | |
| 1105 | 		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
 | |
| 1106 | return 1; | |
| 1107 | } | |
| 1108 | } | |
| 1109 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1110 | EXPORT_C void CShowEngine::DeletePlayedShowsL(RShowInfoArray &aShowInfoArray) | 
| 2 | 1111 | 	{
 | 
| 1112 | for (TInt i = 0; i < aShowInfoArray.Count(); i++) | |
| 1113 | 		{
 | |
| 1114 | if (aShowInfoArray[i]->PlayState() == EPlayed | |
| 1115 | && aShowInfoArray[i]->FileName().Length() > 0) | |
| 1116 | 			{
 | |
| 1117 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName()); | |
| 1118 | aShowInfoArray[i]->SetDownloadState(ENotDownloaded); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1119 | DBUpdateShowL(*aShowInfoArray[i]); | 
| 2 | 1120 | } | 
| 1121 | } | |
| 1122 | } | |
| 1123 | ||
| 1124 | EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles) | |
| 1125 | 	{
 | |
| 1126 | RShowInfoArray array; | |
| 1127 | DBGetShowsByFeedL(array, aFeedUid); | |
| 1128 | ||
| 1129 | const TInt count = array.Count(); | |
| 1130 | ||
| 1131 | for (TInt i = count - 1; i >= 0; i--) | |
| 1132 | 		{
 | |
| 52 | 1133 | if (iShowDownloading && iShowDownloading->Uid() == array[i]->Uid()) | 
| 1134 | 			{
 | |
| 1135 | // trying to delete the active download | |
| 1136 | RemoveDownloadL(iShowDownloading->Uid()); | |
| 1137 | } | |
| 1138 | ||
| 1139 | // delete downloaded file | |
| 2 | 1140 | if (array[i]->FileName().Length() > 0) | 
| 1141 | 			{
 | |
| 1142 | if (aDeleteFiles) | |
| 1143 | 				{
 | |
| 1144 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), array[i]->FileName()); | |
| 1145 | } | |
| 1146 | } | |
| 1147 | } | |
| 1148 | array.ResetAndDestroy(); | |
| 52 | 1149 | |
| 1150 | // delete all shows from DB | |
| 78 | 1151 | DBDeleteAllShowsByFeedL(aFeedUid); | 
| 52 | 1152 | |
| 1153 | // this will clear out deleted shows from the download queue | |
| 1154 | DBGetAllDownloadsL(array); | |
| 1155 | array.ResetAndDestroy(); | |
| 1156 | ||
| 1157 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1158 | } | 
| 1159 | ||
| 78 | 1160 | EXPORT_C void CShowEngine::DeleteOldShowsByFeedL(TUint aFeedUid) | 
| 2 | 1161 | 	{
 | 
| 78 | 1162 | DBDeleteOldShowsByFeedL(aFeedUid); | 
| 2 | 1163 | } | 
| 1164 | ||
| 1165 | EXPORT_C void CShowEngine::DeleteShowL(TUint aShowUid, TBool aRemoveFile) | |
| 1166 | 	{
 | |
| 1167 | ||
| 1168 | CShowInfo *info = DBGetShowByUidL(aShowUid); | |
| 1169 | ||
| 1170 | if (info != NULL) | |
| 1171 | 		{
 | |
| 1172 | if (info->FileName().Length() > 0 && aRemoveFile) | |
| 1173 | 			{
 | |
| 1174 | BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName()); | |
| 1175 | } | |
| 1176 | ||
| 1177 | info->SetDownloadState(ENotDownloaded); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1178 | DBUpdateShowL(*info); | 
| 2 | 1179 | delete info; | 
| 1180 | } | |
| 1181 | } | |
| 1182 | ||
| 1183 | EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) | |
| 1184 | 	{
 | |
| 1185 | 	DP("CShowEngine::GetShowsByFeed");
 | |
| 1186 | DBGetShowsByFeedL(aShowArray, aFeedUid); | |
| 1187 | } | |
| 1188 | ||
| 1189 | EXPORT_C void CShowEngine::GetAllShowsL(RShowInfoArray &aArray) | |
| 1190 | 	{
 | |
| 1191 | 	DP("CShowEngine::GetAllShows");
 | |
| 1192 | DBGetAllShowsL(aArray); | |
| 1193 | } | |
| 1194 | ||
| 1195 | EXPORT_C void CShowEngine::GetShowsDownloadedL(RShowInfoArray &aArray) | |
| 1196 | 	{
 | |
| 1197 | 	DP("CShowEngine::GetShowsDownloaded");
 | |
| 1198 | DBGetDownloadedShowsL(aArray); | |
| 1199 | } | |
| 1200 | ||
| 1201 | EXPORT_C void CShowEngine::GetNewShowsL(RShowInfoArray &aArray) | |
| 1202 | 	{
 | |
| 1203 | 	DP("CShowEngine::GetNewShows");
 | |
| 1204 | DBGetNewShowsL(aArray); | |
| 1205 | } | |
| 1206 | ||
| 1207 | EXPORT_C void CShowEngine::GetShowsDownloadingL(RShowInfoArray &aArray) | |
| 1208 | 	{
 | |
| 1209 | 	DP("CShowEngine::GetShowsDownloading");
 | |
| 1210 | DBGetAllDownloadsL(aArray); | |
| 1211 | } | |
| 1212 | ||
| 1213 | EXPORT_C TInt CShowEngine::GetNumDownloadingShows() | |
| 1214 | 	{
 | |
| 83 | 1215 | TUint count = 0; | 
| 78 | 1216 | TRAP_IGNORE(count = DBGetDownloadsCountL()); | 
| 1217 | ||
| 1218 | return (const TInt) count; | |
| 2 | 1219 | } | 
| 1220 | ||
| 1221 | EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo) | |
| 1222 | 	{
 | |
| 1223 | aInfo.SetDownloadState(EQueued); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1224 | DBUpdateShowL(aInfo); | 
| 78 | 1225 | DBAddDownloadL(aInfo.Uid()); | 
| 2 | 1226 | DownloadNextShowL(); | 
| 1227 | } | |
| 1228 | ||
| 1229 | void CShowEngine::DownloadNextShowL() | |
| 1230 | 	{
 | |
| 1231 | 	DP("CShowEngine::DownloadNextShowL BEGIN");
 | |
| 1232 | // Check if we have anything in the download queue | |
| 78 | 1233 | const TInt count = DBGetDownloadsCountL(); | 
| 2 | 1234 | 	DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count);
 | 
| 1235 | ||
| 1236 | if (count > 0) | |
| 1237 | 		{
 | |
| 1238 | if (iPodcastModel.SettingsEngine().DownloadSuspended()) | |
| 1239 | 			{
 | |
| 1240 | 			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
 | |
| 34 | 1241 | // Inform the observers | 
| 1242 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1243 | return; | 
| 1244 | } | |
| 1245 | else if (iShowClient->IsActive()) | |
| 1246 | 			{
 | |
| 1247 | 			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
 | |
| 34 | 1248 | // Inform the observers | 
| 1249 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1250 | return; | 
| 1251 | } | |
| 1252 | else | |
| 1253 | 			{
 | |
| 83 | 1254 | 			if (iShowDownloading) {
 | 
| 1255 | delete iShowDownloading; | |
| 1256 | } | |
| 1257 | ||
| 2 | 1258 | // Start the download | 
| 83 | 1259 | iShowDownloading = DBGetNextDownloadL(); | 
| 1260 | ||
| 1261 | while(iShowDownloading != NULL) | |
| 2 | 1262 | 				{
 | 
| 83 | 1263 | 				DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(iShowDownloading->Title()));
 | 
| 1264 | iShowDownloading->SetDownloadState(EDownloading); | |
| 1265 | iShowDownloading->SetLastError(KErrNone); | |
| 1266 | DBUpdateShowL(*iShowDownloading); | |
| 34 | 1267 | // Inform the observers | 
| 1268 | // important to do this after we change download state | |
| 1269 | NotifyDownloadQueueUpdatedL(); | |
| 1270 | ||
| 83 | 1271 | TRAPD(error,GetShowL(iShowDownloading)); | 
| 1272 | if (error == KErrNone) | |
| 2 | 1273 | 					{
 | 
| 1274 | break; | |
| 1275 | } | |
| 83 | 1276 | else | 
| 1277 | 					{
 | |
| 1278 | iShowDownloading->SetDownloadState(EFailedDownload); | |
| 1279 | DBRemoveDownloadL(iShowDownloading->Uid()); | |
| 1280 | DBUpdateShowL(*iShowDownloading); | |
| 1281 | CleanupStack::PopAndDestroy(iShowDownloading); | |
| 1282 | ||
| 1283 | iShowDownloading = DBGetNextDownloadL(); | |
| 1284 | if(iShowDownloading == NULL) | |
| 1285 | 						{
 | |
| 1286 | iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); | |
| 1287 | } | |
| 1288 | } | |
| 2 | 1289 | } | 
| 1290 | } | |
| 1291 | } | |
| 1292 | else | |
| 1293 | 		{
 | |
| 34 | 1294 | // Inform the observers | 
| 1295 | NotifyDownloadQueueUpdatedL(); | |
| 2 | 1296 | 		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
 | 
| 1297 | } | |
| 1298 | 	DP("CShowEngine::DownloadNextShowL END");
 | |
| 1299 | } | |
| 1300 | ||
| 1301 | void CShowEngine::NotifyDownloadQueueUpdatedL() | |
| 1302 | 	{
 | |
| 1303 | const TInt count = iObservers.Count(); | |
| 1304 | for (TInt i = 0; i < count; i++) | |
| 1305 | 		{
 | |
| 78 | 1306 | iObservers[i]->DownloadQueueUpdatedL(1, DBGetDownloadsCountL() - 1); | 
| 2 | 1307 | } | 
| 1308 | } | |
| 1309 | ||
| 1310 | void CShowEngine::NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal) | |
| 1311 | 	{
 | |
| 1312 | const TInt count = iObservers.Count(); | |
| 1313 | for (TInt i = 0; i < count; i++) | |
| 1314 | 		{
 | |
| 1315 | iObservers[i]->ShowDownloadUpdatedL(aBytesOfCurrentDownload, aBytesTotal); | |
| 1316 | } | |
| 1317 | } | |
| 1318 | ||
| 1319 | void CShowEngine::NotifyShowFinishedL(TInt aError) | |
| 1320 | 	{
 | |
| 1321 | const TInt count = iObservers.Count(); | |
| 1322 | for (TInt i = 0; i < count; i++) | |
| 1323 | 			{
 | |
| 1324 | iObservers[i]->ShowDownloadFinishedL(iShowDownloading?iShowDownloading->Uid():0, aError); | |
| 1325 | } | |
| 1326 | } | |
| 1327 | ||
| 1328 | EXPORT_C void CShowEngine::NotifyShowListUpdatedL() | |
| 1329 | 	{
 | |
| 1330 | for (TInt i = 0; i < iObservers.Count(); i++) | |
| 1331 | 		{
 | |
| 1332 | iObservers[i]->ShowListUpdatedL(); | |
| 1333 | } | |
| 1334 | } | |
| 1335 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1336 | void CShowEngine::ReadMetaDataL(CShowInfo& aShowInfo) | 
| 2 | 1337 | 	{
 | 
| 1338 | 	//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 | 1339 | DBUpdateShowL(aShowInfo); | 
| 2 | 1340 | } | 
| 1341 | ||
| 1342 | void CShowEngine::ReadMetaDataCompleteL() | |
| 1343 | 	{
 | |
| 1344 | NotifyShowListUpdatedL(); | |
| 1345 | MetaDataReader().SetIgnoreTrackNo(EFalse); | |
| 1346 | } | |
| 1347 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1348 | EXPORT_C void CShowEngine::UpdateShowL(CShowInfo& aInfo) | 
| 2 | 1349 | 	{
 | 
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
30diff
changeset | 1350 | DBUpdateShowL(aInfo); | 
| 2 | 1351 | } | 
| 1352 | ||
| 1353 | EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader() | |
| 1354 | 	{
 | |
| 1355 | return *iMetaDataReader; | |
| 1356 | } | |
| 1357 | ||
| 1358 | void CShowEngine::FileError(TUint /*aError*/) | |
| 1359 | 	{
 | |
| 1360 | iDownloadErrors = KMaxDownloadErrors; | |
| 1361 | } |