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