engine/src/ShowEngine.cpp
author teknolog
Wed, 10 Mar 2010 23:26:17 +0000
branchsymbian1
changeset 44 f6f9647922ba
parent 36 e010fc411ddc
child 53 b778853e60a7
child 65 bcd88ba95046
permissions -rw-r--r--
Removed unused SoundEngine
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"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
//#include <mpxmedia.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
//#include <mpxattribute.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
//#include <mpxmediageneraldefs.h>
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
const TUint KMaxDownloadErrors = 3;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
const TInt KMimeBufLength = 100;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
// Cleanup stack macro for SQLite3
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
// TODO Move this to some common place.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
static void Cleanup_sqlite3_finalize_wrapper(TAny* handle)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
	sqlite3_finalize(static_cast<sqlite3_stmt*>(handle));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
#define Cleanup_sqlite3_finalize_PushL(__handle) CleanupStack::PushL(TCleanupItem(&Cleanup_sqlite3_finalize_wrapper, __handle))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
CShowEngine::CShowEngine(CPodcastModel& aPodcastModel) :
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	iPodcastModel(aPodcastModel),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	iDB(*aPodcastModel.DB())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	}
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
EXPORT_C CShowEngine::~CShowEngine()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	delete iShowClient;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	iObservers.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
	delete iShowDownloading;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
	delete iMetaDataReader;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
	iApaSession.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
	}
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
EXPORT_C CShowEngine* CShowEngine::NewL(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
	CShowEngine* self = new (ELeave) CShowEngine(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
	CleanupStack::PushL(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
	self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
	CleanupStack::Pop(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
	return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
	}
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
EXPORT_C void CShowEngine::GetMimeType(const TDesC& aFileName, TDes& aMimeType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	aMimeType.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	RFile file;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	if (file.Open(iPodcastModel.FsSession(), aFileName, 0) == KErrNone)
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
		if (file.Read(iRecogBuffer) == KErrNone)
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
			TDataRecognitionResult result;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
			if (iApaSession.RecognizeData(aFileName, iRecogBuffer, result)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
					== KErrNone)
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
				aMimeType.Copy(result.iDataType.Des());
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	file.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	}
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
void CShowEngine::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	iShowClient = CHttpClient::NewL(iPodcastModel, *this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	iShowClient->SetResumeEnabled(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
	iMetaDataReader = new (ELeave) CMetaDataReader(*this, iPodcastModel.FsSession());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
	iMetaDataReader->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
	User::LeaveIfError(iApaSession.Connect());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
	}
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
EXPORT_C void CShowEngine::SuspendDownloads()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	iShowClient->Stop();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
EXPORT_C void CShowEngine::ResumeDownloadsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	DP("CShowEngine::ResumeDownloadsL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	if (iPodcastModel.SettingsEngine().DownloadSuspended())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
		iPodcastModel.SettingsEngine().SetDownloadSuspended(EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
		iDownloadErrors = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
		DownloadNextShowL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
	DP("CShowEngine::ResumeDownloadsL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   117
EXPORT_C void CShowEngine::RemoveAllDownloadsL()
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
	if (!iPodcastModel.SettingsEngine().DownloadSuspended())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
		SuspendDownloads();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
		}
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
	DBRemoveAllDownloads();
22
3243c9461520 Clear download queue now notifies UI
teknolog
parents: 21
diff changeset
   125
	NotifyDownloadQueueUpdatedL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
EXPORT_C TBool CShowEngine::RemoveDownloadL(TUint aUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
	DP("CShowEngine::RemoveDownload\t Trying to remove download");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
	TBool retVal = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
	TBool resumeAfterRemove = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
	// if trying to remove the present download, we first stop it
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
	if (!iPodcastModel.SettingsEngine().DownloadSuspended() && iShowDownloading != NULL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
			&& iShowDownloading->Uid() == aUid)
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
		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
   139
		SuspendDownloads();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
		resumeAfterRemove = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
	CShowInfo *info = DBGetShowByUidL(aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
	if (info != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
		info->SetDownloadState(ENotDownloaded);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   147
		DBUpdateShowL(*info);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
		delete info;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
	DBRemoveDownload(aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
	// partial downloads should be removed
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
	if (iShowDownloading)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
		BaflUtils::DeleteFile(iPodcastModel.FsSession(), iShowDownloading->FileName());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
		}
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
	NotifyShowDownloadUpdatedL(-1, -1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
	NotifyDownloadQueueUpdatedL();
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
	if (resumeAfterRemove) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
		ResumeDownloadsL();
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
	DownloadNextShowL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
	retVal = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
	return retVal;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
void CShowEngine::Connected(CHttpClient* /*aClient*/)
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
	}
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
void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
		TInt aTotalBytes)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
	{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
	iShowDownloading->SetShowSize(aTotalBytes);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
	TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes));
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
void CShowEngine::Disconnected(CHttpClient* /*aClient */)
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
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
void CShowEngine::DownloadInfo(CHttpClient* aHttpClient, TInt aTotalBytes)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
	DP1("About to download %d bytes", aTotalBytes);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
	if (aHttpClient == iShowClient && iShowDownloading != NULL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
			&& aTotalBytes != -1)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
		iShowDownloading->SetShowSize(aTotalBytes);
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
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
TBool CShowEngine::GetShowL(CShowInfo *info)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
	CFeedInfo *feedInfo = iPodcastModel.FeedEngine().GetFeedInfoByUid(
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
			info->FeedUid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
	if (feedInfo == NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
		DP("Feed not found for this show!");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
		return EFalse;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
	TFileName filePath;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
	filePath.Copy(iPodcastModel.SettingsEngine().BaseDir());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
	TFileName relPath;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
	relPath.Copy(feedInfo->Title());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
	relPath.Append('\\');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
	TFileName fileName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
	PodcastUtils::FileNameFromUrl(info->Url(), fileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
	relPath.Append(fileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
	PodcastUtils::EnsureProperPathName(relPath);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
	// complete file path is base dir + rel path
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
	filePath.Append(relPath);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
	info->SetFileNameL(filePath);
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
	return iShowClient->GetL(info->Url(), filePath);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
EXPORT_C TBool CShowEngine::AddShowL(const CShowInfo& aItem)
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
	DP1("CShowEngine::AddShowL, title=%S", &aItem.Title());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
	CShowInfo *showInfo = DBGetShowByUidL(aItem.Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	if (showInfo == NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
		{
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   233
		DBAddShowL(aItem);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
		return ETrue;
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
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
		delete showInfo;	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
		return EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
		}	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
EXPORT_C void CShowEngine::AddObserver(MShowEngineObserver *observer)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
	iObservers.Append(observer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
	}
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
EXPORT_C void CShowEngine::RemoveObserver(MShowEngineObserver *observer)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
	TInt index = iObservers.Find(observer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
	if (index > KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
		iObservers.Remove(index);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
void CShowEngine::AddShowToMpxCollection(CShowInfo &/*aShowInfo*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
/*	RArray<TInt> contentIDs;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
	contentIDs.AppendL( KMPXMediaIdGeneral );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
	CMPXMedia* media = CMPXMedia::NewL( contentIDs.Array() );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
	CleanupStack::PushL( media );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
	contentIDs.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
	CleanupStack::PopAndDestroy(media);   */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
	if (iShowDownloading != NULL)
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
		DP1("CShowEngine::Complete\tDownload of file: %S is complete", &iShowDownloading->FileName());		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
		if(aError != KErrCouldNotConnect)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
			{
6
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   276
			if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended())
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   277
				{
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
				// no error if disconnect happened because of suspended downloading
6
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   279
				}
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   280
			else
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   281
				{
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
				iShowDownloading->SetLastError(aError);
6
e211a78d3037 Fix for incorrect error handling of show downloads
teknolog
parents: 2
diff changeset
   283
				}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
			if (aError == KErrNone)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
				TBuf<KMimeBufLength> mimeType;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
				GetMimeType(iShowDownloading->FileName(), mimeType);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
				_LIT(KMimeAudio,"audio");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   290
				_LIT(KMimeVideo,"video");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
				if (mimeType.Left(5) == KMimeAudio)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
					iShowDownloading->SetShowType(EAudioPodcast);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
				else if (mimeType.Left(5) == KMimeVideo)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   297
					iShowDownloading->SetShowType(EVideoPodcast);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
				iShowDownloading->SetDownloadState(EDownloaded);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   301
				DBUpdateShowL(*iShowDownloading);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
				DBRemoveDownload(iShowDownloading->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
				AddShowToMpxCollection(*iShowDownloading);				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
				NotifyShowFinishedL(aError);
15
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 6
diff changeset
   305
				iDownloadErrors = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
				delete iShowDownloading;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
				iShowDownloading = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   308
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
			else
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
				// 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
   312
				if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200)
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
					iShowDownloading->SetDownloadState(EFailedDownload);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   315
					DBUpdateShowL(*iShowDownloading);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   316
					DBRemoveDownload(iShowDownloading->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
					NotifyShowFinishedL(aError);
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
					delete iShowDownloading;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
					iShowDownloading = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
				else // other kind of error, missing network etc, reque this show
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
					iShowDownloading->SetDownloadState(EQueued);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   325
					DBUpdateShowL(*iShowDownloading);
2
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
				iDownloadErrors++;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
				if (iDownloadErrors > KMaxDownloadErrors)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
					DP("Too many downloading errors, suspending downloads");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
					iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
					NotifyShowFinishedL(aError);
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
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
			DownloadNextShowL();
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
		else
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
			// Connection error
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
			if(iShowDownloading)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   344
				iShowDownloading->SetDownloadState(EQueued);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   345
				DBUpdateShowL(*iShowDownloading);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
			NotifyShowFinishedL(aError);
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
		}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
EXPORT_C CShowInfo* CShowEngine::ShowDownloading()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   354
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   355
	return iShowDownloading;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   358
EXPORT_C CShowInfo* CShowEngine::GetShowByUidL(TUint aShowUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   359
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
	return DBGetShowByUidL(aShowUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
CShowInfo* CShowEngine::DBGetShowByUidL(TUint aUid)
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
	DP("CShowEngine::DBGetShowByUid");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
	CShowInfo *showInfo = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   366
	_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
   367
	iSqlBuffer.Format(KSqlStatement, aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   368
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   370
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   371
	//DP1("SQL: %S", &iSqlBuffer.Left(KSqlDPLen));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   372
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   373
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   374
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
		if (rc == SQLITE_ROW)
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
			showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   384
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   385
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   386
		CleanupStack::PopAndDestroy();//st
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   387
		}
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
	return showInfo;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   390
	}
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
EXPORT_C CShowInfo* CShowEngine::DBGetShowByFileNameL(TFileName aFileName)
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
	DP("CShowEngine::DBGetShowByUid");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   395
	CShowInfo *showInfo = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   396
	_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
   397
	iSqlBuffer.Format(KSqlStatement, &aFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   398
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   399
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   400
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   401
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   402
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   405
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   406
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   407
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   408
		if (rc == SQLITE_ROW)
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
			showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   411
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   412
			CleanupStack::Pop(showInfo);
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
		CleanupStack::PopAndDestroy();//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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   417
	return showInfo;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   420
void CShowEngine::DBGetAllShowsL(RShowInfoArray& aShowArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   421
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   422
	DP("CShowEngine::DBGetAllShows");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   423
	_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
   424
	iSqlBuffer.Format(KSqlStatement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   427
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   428
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   434
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   435
		while (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   436
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
			CShowInfo* showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
			aShowArray.Append(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
			rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   443
		CleanupStack::PopAndDestroy();//st
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   444
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   445
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
	}
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
void CShowEngine::DBGetAllDownloadsL(RShowInfoArray& aShowArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   449
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
	DP("CShowEngine::DBGetAllDownloads");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
	_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
   452
	iSqlBuffer.Format(KSqlStatement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   453
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   454
#ifndef DONT_SORT_SQL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   455
	_LIT(KSqlSort, " order by dl_index");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   456
	iSqlBuffer.Append(KSqlSort);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   457
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   458
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   459
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   460
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   461
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   464
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   466
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
		while (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
			CShowInfo* showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
			aShowArray.Append(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   473
			rc = sqlite3_step(st);
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
		CleanupStack::PopAndDestroy();//st
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   478
	// delete downloads that don't have a show
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   479
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   480
	_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
   481
	iSqlBuffer.Format(KSqlStatement2);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   482
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   483
	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
   484
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   485
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   488
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   489
		}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   492
CShowInfo* CShowEngine::DBGetNextDownloadL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   493
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   494
	DP("CShowEngine::DBGetNextDownload");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   495
	CShowInfo *showInfo = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
	_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
   497
	iSqlBuffer.Format(KSqlStatement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   499
#ifdef DONT_SORT_SQL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   500
	_LIT(KSqlSort, " limit 1");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   501
	iSqlBuffer.Append(KSqlSort);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   502
#else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   503
	_LIT(KSqlNoSort, " order by dl_index limit 1");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
	iSqlBuffer.Append(KSqlNoSort);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   506
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   507
	sqlite3_stmt *st;
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
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   510
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   512
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   513
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   514
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   515
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   516
		if (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   517
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   518
			showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   519
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   520
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   521
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   522
		CleanupStack::PopAndDestroy();//st
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   523
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   524
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   525
	return showInfo;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   526
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   527
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   528
void CShowEngine::DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid)
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
	DP1("CShowEngine::DBGetShowsByFeed BEGIN, feedUid=%u", aFeedUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   531
	_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
   532
	iSqlBuffer.Format(KSqlStatement, aFeedUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   533
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   534
#ifndef DONT_SORT_SQL	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   535
	_LIT(KSqlOrderByDate, " order by pubdate desc");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   536
	iSqlBuffer.Append(KSqlOrderByDate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   537
#endif
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
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   540
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   541
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   542
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   547
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   548
		while (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   549
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   550
			CShowInfo* showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   551
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   552
			aShowArray.Append(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   553
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   554
			rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   555
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   556
		CleanupStack::PopAndDestroy();//st
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   557
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   558
	DP("CShowEngine::DBGetShowsByFeed END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   559
	}
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
TUint CShowEngine::DBGetDownloadsCount()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   562
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   563
	DP("CShowEngine::DBGetDownloadsCount");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   564
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   565
	_LIT(KSqlStatement, "select count(*) from downloads");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   566
	iSqlBuffer.Format(KSqlStatement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   567
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   568
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   569
	TUint count = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   570
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   571
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   572
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   575
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   576
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   577
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   578
		if (rc == SQLITE_ROW)
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
			count = sqlite3_column_int(st, 0);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   581
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   582
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   583
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   584
	return count;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   585
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   586
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   587
void CShowEngine::DBGetDownloadedShowsL(RShowInfoArray& aShowArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   588
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   589
	DP("CShowEngine::DBGetDownloadedShows");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   590
	_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
   591
	iSqlBuffer.Format(KSqlStatement, EDownloaded);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   592
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   593
#ifndef DONT_SORT_SQL
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   594
	_LIT(KSqlSort, " order by title");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   595
	iSqlBuffer.Append(KSqlSort);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   596
#endif	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   597
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   598
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   599
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   600
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   601
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   606
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   607
		while (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   608
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   609
			CShowInfo* showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   610
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   611
			aShowArray.Append(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   612
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   613
			rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   614
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   615
		CleanupStack::PopAndDestroy();//st
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
	}
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
void CShowEngine::DBGetNewShowsL(RShowInfoArray& aShowArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   620
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   621
	DP("CShowEngine::DBGetNewShows");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   622
	_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
   623
	iSqlBuffer.Format(KSqlStatement, ENeverPlayed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   624
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   625
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   626
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   627
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   628
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   629
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   630
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   631
		{
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
		Cleanup_sqlite3_finalize_PushL(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   634
		while (rc == SQLITE_ROW)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   635
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   636
			CShowInfo* showInfo = CShowInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   637
			DBFillShowInfoFromStmtL(st, showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   638
			aShowArray.Append(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   639
			CleanupStack::Pop(showInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   640
			rc = sqlite3_step(st);
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
		CleanupStack::PopAndDestroy();//st
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
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   645
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   646
void CShowEngine::DBDeleteOldShowsByFeed(TUint aFeedUid)
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
	DP("CShowEngine::DBDeleteOldShows");
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
	// what we do:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   651
	// 1. sort shows by pubdate
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   652
	// 2. select the first MaxListItems shows
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   653
	// 3. delete the rest if downloadstate is ENotDownloaded
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
	_LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in " \
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   656
			"(select uid from shows where feeduid=%u order by pubdate desc limit %u)");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   657
	iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems());
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
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   660
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   661
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   662
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   663
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   664
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   665
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   666
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   667
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   668
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   669
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   670
	_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
   671
	iSqlBuffer.Format(KSqlStatement2);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   672
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   673
	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
   674
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   675
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   678
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   679
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   680
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   681
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   682
void CShowEngine::DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   683
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   684
	const void *urlz = sqlite3_column_text16(st, 0);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   685
	TPtrC16 url((const TUint16*) urlz);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   686
	showInfo->SetUrlL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   687
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   688
	const void *titlez = sqlite3_column_text16(st, 1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   689
	TPtrC16 title((const TUint16*) titlez);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   690
	showInfo->SetTitleL(title);
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
	const void *descz = sqlite3_column_text16(st, 2);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   693
	TPtrC16 desc((const TUint16*) descz);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   694
	showInfo->SetDescriptionL(desc);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   695
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   696
	const void *filez = sqlite3_column_text16(st, 3);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   697
	TPtrC16 file((const TUint16*) filez);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   698
	showInfo->SetFileNameL(file);
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
	sqlite3_int64 pos = sqlite3_column_int64(st, 4);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   701
	TTimeIntervalMicroSeconds position(pos);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   702
	showInfo->SetPosition(position);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   703
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   704
	TUint playtime = sqlite3_column_int(st, 5);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   705
	showInfo->SetPlayTime(playtime);
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
	TUint playstate = sqlite3_column_int(st, 6);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   708
	showInfo->SetPlayState((TPlayState) playstate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   709
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   710
	TUint downloadstate = sqlite3_column_int(st, 7);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   711
	showInfo->SetDownloadState((TDownloadState) downloadstate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   712
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   713
	TUint feeduid = sqlite3_column_int(st, 8);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   714
	showInfo->SetFeedUid(feeduid);
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
	TUint uid = sqlite3_column_int(st, 9);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   717
	showInfo->SetUid(uid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   718
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   719
	TUint showsize = sqlite3_column_int(st, 10);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   720
	showInfo->SetShowSize(showsize);
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
	TUint trackno = sqlite3_column_int(st, 11);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   723
	showInfo->SetTrackNo((TShowType) trackno);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   724
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   725
	sqlite3_int64 pubdate = sqlite3_column_int64(st, 12);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   726
	TTime timepubdate(pubdate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   727
	showInfo->SetPubDate(timepubdate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   728
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   729
	TUint showtype = sqlite3_column_int(st, 13);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   730
	showInfo->SetShowType((TShowType) showtype);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   731
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   732
	TInt lasterror = sqlite3_column_int(st, 14);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   733
	showInfo->SetLastError(lasterror);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   734
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   735
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   736
TBool CShowEngine::DBAddShowL(const CShowInfo& aItem)
2
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
	DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   739
21
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   740
	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   741
	TPtr titlePtr(titleBuf->Des());
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   742
	titlePtr.Copy(aItem.Title());
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   743
	PodcastUtils::SQLEncode(titlePtr);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   744
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   745
	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   746
	TPtr descPtr(descBuf->Des());
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   747
	descPtr.Copy(aItem.Description());
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   748
	PodcastUtils::SQLEncode(descPtr);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   749
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   750
	_LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype)"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   751
			" 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
   752
	
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   753
	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   754
			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   755
			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   756
			aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   757
			aItem.PubDate().Int64(), aItem.ShowType());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   758
21
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   759
	CleanupStack::PopAndDestroy(descBuf);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   760
	CleanupStack::PopAndDestroy(titleBuf);
420a1b4930da SQLEncoding for showinfo added
teknolog
parents: 15
diff changeset
   761
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   762
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   763
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   764
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   765
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   766
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   767
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   768
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   769
		if (rc == SQLITE_DONE)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   770
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   771
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   772
			return ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   773
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   774
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   775
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   776
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   777
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   778
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   779
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   780
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   781
		DP1("SQLite rc=%d", rc);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   782
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   783
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   784
	return EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   785
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   786
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   787
void CShowEngine::DBAddDownload(TUint aUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   788
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   789
	DP1("CShowEngine::DBAddDownload, aUid=%u", aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   790
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   791
	_LIT(KSqlStatement, "insert into downloads (uid) values (%u)");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   792
	iSqlBuffer.Format(KSqlStatement, aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   793
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   794
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   795
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   796
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   797
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   798
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   799
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   800
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   801
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   802
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   803
	sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   804
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   805
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
   806
TBool CShowEngine::DBUpdateShowL(CShowInfo& aItem)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   807
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   808
	DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   809
30
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   810
	HBufC* titleBuf = HBufC::NewLC(KMaxLineLength);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   811
	TPtr titlePtr(titleBuf->Des());
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   812
	titlePtr.Copy(aItem.Title());
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   813
	PodcastUtils::SQLEncode(titlePtr);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   814
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   815
	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   816
	TPtr descPtr(descBuf->Des());
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   817
	descPtr.Copy(aItem.Description());
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   818
	PodcastUtils::SQLEncode(descPtr);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   819
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   820
	_LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\","
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   821
			"playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\","
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   822
			"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
   823
	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   824
			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   825
			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   826
			aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   827
			aItem.ShowType(), aItem.LastError(), aItem.Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   828
30
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   829
	CleanupStack::PopAndDestroy(descBuf);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   830
	CleanupStack::PopAndDestroy(titleBuf);
7bca37ba5fa9 Added SQLEncoding for update of showinfo. Removed ABLD.BAT from repo
teknolog
parents: 22
diff changeset
   831
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   832
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   833
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   834
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   835
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   836
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   837
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   838
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   839
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   840
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   841
		if (rc == SQLITE_DONE)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   842
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   843
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   844
			return ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   845
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   846
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   847
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   848
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   849
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   850
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   851
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   852
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   853
		DP1("SQLite rc=%d", rc);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   854
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   855
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   856
	return EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   857
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   858
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   859
TBool CShowEngine::DBDeleteShow(TUint aUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   860
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   861
	DP("CShowEngine::DBDeleteShow");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   862
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   863
	_LIT(KSqlStatement, "delete from shows where uid=%u");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   864
	iSqlBuffer.Format(KSqlStatement, aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   865
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   866
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   867
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   868
	//DP1("SQL: %S", &iSqlBuffer.Left(KSqlDPLen));
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
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   874
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   875
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   876
		if (rc == SQLITE_DONE)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   877
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   878
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   879
			return ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   880
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   881
		else
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
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   884
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   885
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   886
	else
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
		DP1("SQLite rc=%d", rc);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   889
		}
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
	return EFalse;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   894
TBool CShowEngine::DBDeleteAllShowsByFeed(TUint aFeedUid)
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
	DP("CShowEngine::DBDeleteAllShowsByFeed");
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
	_LIT(KSqlStatement, "delete from shows where feeduid=%u");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   899
	iSqlBuffer.Format(KSqlStatement, aFeedUid);
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
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   902
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   903
	//DP1("SQL: %S", &iSqlBuffer.Left(KSqlDPLen));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   904
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   905
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   906
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   907
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   908
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   909
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   910
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   911
		if (rc == SQLITE_DONE)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   912
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   913
			sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   914
			return ETrue;
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
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   917
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   918
			sqlite3_finalize(st);
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
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   921
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   922
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   923
		DP1("SQLite rc=%d", rc);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   926
	return EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   927
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   928
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   929
void CShowEngine::DBRemoveAllDownloads()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   930
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   931
	DP("CShowEngine::DBRemoveAllDownloads");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   932
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   933
	_LIT(KSqlStatement, "delete from downloads");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   934
	iSqlBuffer.Format(KSqlStatement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   935
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   936
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   937
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   938
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   939
			&st, (const void**) NULL);
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
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   942
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   943
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   944
		sqlite3_finalize(st);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   947
	_LIT(KSqlStatement2, "update shows set downloadstate=0 where downloadstate=1");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   948
	iSqlBuffer.Format(KSqlStatement2);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   949
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   950
	rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, &st,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   951
			(const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   952
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   953
	if (rc == SQLITE_OK)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   954
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   955
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   956
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   957
		}
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
	}
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
void CShowEngine::DBRemoveDownload(TUint aUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   962
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   963
	DP("CShowEngine::DBRemoveDownload");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   964
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   965
	_LIT(KSqlStatement, "delete from downloads where uid=%u");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   966
	iSqlBuffer.Format(KSqlStatement, aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   967
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   968
	sqlite3_stmt *st;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   969
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   970
	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   971
			&st, (const void**) NULL);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   972
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   973
	if (rc == SQLITE_OK)
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
		rc = sqlite3_step(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   976
		sqlite3_finalize(st);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   977
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   978
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   979
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   980
EXPORT_C CShowInfo* CShowEngine::GetNextShowByTrackL(CShowInfo* aShowInfo)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   981
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   982
	CShowInfo* nextShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   983
	RShowInfoArray array;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   984
	DBGetShowsByFeedL(array, aShowInfo->FeedUid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   985
	TUint diff = KMaxTInt;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   986
	for (TInt loop = 0; loop < array.Count(); loop++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   987
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   988
		if (aShowInfo->TrackNo() < array[loop]->TrackNo())
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
			if ((array[loop]->TrackNo() - aShowInfo->TrackNo()) < diff)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   991
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   992
				diff = array[loop]->TrackNo() - aShowInfo->TrackNo();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   993
				nextShow = array[loop];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   994
				}
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
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   997
	array.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   998
	return nextShow;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   999
	}
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
TBool CShowEngine::CompareShowsByUid(const CShowInfo &a, const CShowInfo &b)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1002
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1003
	return a.Uid() == b.Uid();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1004
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1005
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1006
TInt CShowEngine::CompareShowsByDate(const CShowInfo &a, const CShowInfo &b)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1007
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1008
	if (a.PubDate() > b.PubDate())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1009
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1010
		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1011
		return -1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1012
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1013
	else if (a.PubDate() == b.PubDate())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1014
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1015
		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1016
		return 0;
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
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1019
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1020
		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1021
		return 1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1022
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1023
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1024
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1025
TInt CShowEngine::CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1026
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1027
	if (a.TrackNo() < b.TrackNo())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1028
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1029
		return -1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1030
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1031
	else if (a.TrackNo() == b.TrackNo())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1032
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1033
		return 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1034
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1035
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1036
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1037
		return 1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1038
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1039
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1040
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1041
TInt CShowEngine::CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1042
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1043
	if (a.Title() < b.Title())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1044
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1045
		//		DP2("Sorting %S less than %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1046
		return -1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1047
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1048
	else if (a.Title() == b.Title())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1049
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1050
		//		DP2("Sorting %S equal to %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1051
		return 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1052
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1053
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1054
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1055
		//		DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1056
		return 1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1057
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1058
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1059
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1060
EXPORT_C void CShowEngine::DeletePlayedShowsL(RShowInfoArray &aShowInfoArray)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1061
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1062
	for (TInt i = 0; i < aShowInfoArray.Count(); i++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1063
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1064
		if (aShowInfoArray[i]->PlayState() == EPlayed
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1065
				&& aShowInfoArray[i]->FileName().Length() > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1066
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1067
			BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1068
			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
  1069
			DBUpdateShowL(*aShowInfoArray[i]);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1070
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1071
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1072
	}
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
EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles)
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
	RShowInfoArray array;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1077
	DBGetShowsByFeedL(array, aFeedUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1078
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1079
	const TInt count = array.Count();
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
	for (TInt i = count - 1; i >= 0; i--)
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
		if (array[i]->FileName().Length() > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1084
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1085
			if (aDeleteFiles)
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
				BaflUtils::DeleteFile(iPodcastModel.FsSession(), array[i]->FileName());
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
			}
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
	array.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1092
	DBDeleteAllShowsByFeed(aFeedUid);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1095
EXPORT_C void CShowEngine::DeleteOldShowsByFeed(TUint aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1096
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1097
		DBDeleteOldShowsByFeed(aFeedUid);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1100
EXPORT_C void CShowEngine::DeleteShowL(TUint aShowUid, TBool aRemoveFile)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1101
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1102
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1103
	CShowInfo *info = DBGetShowByUidL(aShowUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1104
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1105
	if (info != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1106
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1107
		if (info->FileName().Length() > 0 && aRemoveFile)
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
			BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName());
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
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1112
		info->SetDownloadState(ENotDownloaded);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1113
		DBUpdateShowL(*info);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1114
		delete info;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1115
		}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1118
EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1119
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1120
	DP("CShowEngine::GetShowsByFeed");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1121
	DBGetShowsByFeedL(aShowArray, aFeedUid);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1124
EXPORT_C void CShowEngine::GetAllShowsL(RShowInfoArray &aArray)
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
	DP("CShowEngine::GetAllShows");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1127
	DBGetAllShowsL(aArray);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1130
EXPORT_C void CShowEngine::GetShowsDownloadedL(RShowInfoArray &aArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1131
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1132
	DP("CShowEngine::GetShowsDownloaded");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1133
	DBGetDownloadedShowsL(aArray);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1134
	}
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
EXPORT_C void CShowEngine::GetNewShowsL(RShowInfoArray &aArray)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1137
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1138
	DP("CShowEngine::GetNewShows");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1139
	DBGetNewShowsL(aArray);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1142
EXPORT_C void CShowEngine::GetShowsDownloadingL(RShowInfoArray &aArray)
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
	DP("CShowEngine::GetShowsDownloading");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1145
	DBGetAllDownloadsL(aArray);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1146
	}
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
EXPORT_C TInt CShowEngine::GetNumDownloadingShows()
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
	return (const TInt) DBGetDownloadsCount();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1151
	}
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
EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1154
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1155
	aInfo.SetDownloadState(EQueued);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1156
	DBUpdateShowL(aInfo);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1157
	DBAddDownload(aInfo.Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1158
	DownloadNextShowL();
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1161
void CShowEngine::DownloadNextShowL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1162
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1163
	DP("CShowEngine::DownloadNextShowL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1164
	// Check if we have anything in the download queue
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1165
	const TInt count = DBGetDownloadsCount();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1166
	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
  1167
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1168
	if (count > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1169
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1170
		if (iPodcastModel.SettingsEngine().DownloadSuspended())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1171
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1172
			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
34
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1173
			// Inform the observers
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1174
			NotifyDownloadQueueUpdatedL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1175
			return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1176
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1177
		else if (iShowClient->IsActive())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1178
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1179
			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
34
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1180
			// Inform the observers
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1181
			NotifyDownloadQueueUpdatedL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1182
			return;
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
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1185
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1186
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1187
			// Start the download
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1188
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1189
			CShowInfo *info = DBGetNextDownloadL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1190
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1191
			while(info != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1192
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1193
				TBool getOk = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1194
				DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1195
				info->SetDownloadState(EDownloading);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1196
				info->SetLastError(KErrNone);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1197
				DBUpdateShowL(*info);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1198
				iShowDownloading = info;
34
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1199
				// Inform the observers
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1200
				// important to do this after we change download state
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1201
				NotifyDownloadQueueUpdatedL();
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1202
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1203
				TRAPD(error,getOk = GetShowL(info));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1204
				if (error != KErrNone || !getOk)
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
					info->SetDownloadState(EFailedDownload);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1207
					DBRemoveDownload(info->Uid());
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1208
					DBUpdateShowL(*info);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1209
					info = DBGetNextDownloadL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1210
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1211
					if(info == NULL)
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
						iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1214
						iShowDownloading = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1215
						}
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
				else
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
					break;
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
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1222
			}
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
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1225
		{
34
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1226
		// Inform the observers
a6046405f1aa Fix for download icons not updating correctly
teknolog
parents: 30
diff changeset
  1227
		NotifyDownloadQueueUpdatedL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1228
		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
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
	DP("CShowEngine::DownloadNextShowL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1231
	}
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
void CShowEngine::NotifyDownloadQueueUpdatedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1234
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1235
	const TInt count = iObservers.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1236
	for (TInt i = 0; i < count; i++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1237
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1238
		iObservers[i]->DownloadQueueUpdatedL(1, DBGetDownloadsCount() - 1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1239
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1240
	}
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
void CShowEngine::NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1243
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1244
	const TInt count = iObservers.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1245
	for (TInt i = 0; i < count; i++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1246
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1247
			iObservers[i]->ShowDownloadUpdatedL(aBytesOfCurrentDownload, aBytesTotal);
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
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1250
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1251
void CShowEngine::NotifyShowFinishedL(TInt aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1252
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1253
	const TInt count = iObservers.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1254
		for (TInt i = 0; i < count; i++)
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
				iObservers[i]->ShowDownloadFinishedL(iShowDownloading?iShowDownloading->Uid():0, aError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1257
			}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1260
EXPORT_C void CShowEngine::NotifyShowListUpdatedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1261
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1262
	for (TInt i = 0; i < iObservers.Count(); i++)
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
		iObservers[i]->ShowListUpdatedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1265
		}
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
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1268
void CShowEngine::ReadMetaDataL(CShowInfo& aShowInfo)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1269
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1270
	//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
  1271
	DBUpdateShowL(aShowInfo);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1272
	}
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
void CShowEngine::ReadMetaDataCompleteL()
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
	NotifyShowListUpdatedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1277
	MetaDataReader().SetIgnoreTrackNo(EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1278
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1279
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1280
EXPORT_C void CShowEngine::UpdateShowL(CShowInfo& aInfo)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1281
	{
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 30
diff changeset
  1282
	DBUpdateShowL(aInfo);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1283
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1284
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1285
EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1286
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1287
	return *iMetaDataReader;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1288
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1289
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1290
void CShowEngine::FileError(TUint /*aError*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1291
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1292
	//TODO: Error dialog
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1293
	//StopDownloads();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1294
	iDownloadErrors = KMaxDownloadErrors;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1295
	}