engine/src/PodcastModel.cpp
author teknolog
Thu, 25 Feb 2010 21:08:38 +0000
changeset 15 93d9f66bf50b
parent 8 aab3aa4acdd6
child 32 26a3f2dfba08
child 35 66c5303f3610
permissions -rw-r--r--
Cleaning description better for second line in search results
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 <commdb.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include "PodcastModel.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include "FeedEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include "SoundEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "SettingsEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include "ShowEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include "connectionengine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
#include <cmdestination.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
#include <cmmanager.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
#include <bautils.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
const TInt KDefaultGranu = 5;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
_LIT(KDBFileName, "podcatcher.sqlite");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
_LIT(KDBTemplateFileName, "podcatcher.sqlite.template");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
EXPORT_C CPodcastModel* CPodcastModel::NewL()
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
	CPodcastModel* self = new (ELeave) CPodcastModel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
	CleanupStack::PushL(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
	self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
	CleanupStack::Pop(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
	return self;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
CPodcastModel::~CPodcastModel()
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
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	delete iFeedEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	delete iSoundEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	delete iSettingsEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	delete iShowEngine;
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
	delete iIapNameArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	iIapIdArray.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	delete iSNAPNameArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
	iSNAPIdArray.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
	delete iCommDB;	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
	sqlite3_close(iDB);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
	iFsSession.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
	iActiveShowList.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
	iActiveShowList.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	delete iConnectionEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
	iCmManager.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
	delete iImageHandler;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
CPodcastModel::CPodcastModel()
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
void CPodcastModel::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	DP("CPodcastModel::ConstructL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	User::LeaveIfError(iFsSession.Connect());
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
	iCommDB = CCommsDatabase::NewL (EDatabaseTypeUnspecified);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	//iCommDB ->ShowHiddenRecords(); // magic
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	iIapNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	iSNAPNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	iCmManager.OpenL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	iImageHandler = CImageHandler::NewL(FsSession());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	UpdateIAPListL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	UpdateSNAPListL();
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
	iSettingsEngine = CSettingsEngine::NewL(*this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	iConnectionEngine = CConnectionEngine::NewL(*this);	
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
	iFeedEngine = CFeedEngine::NewL(*this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	iShowEngine = CShowEngine::NewL(*this);
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
	iSoundEngine = CSoundEngine::NewL(*this);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	DP("CPodcastModel::ConstructL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
EXPORT_C void CPodcastModel::UpdateIAPListL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	iIapNameArray->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	iIapIdArray.Reset();	   
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	CCommsDbTableView* table = iCommDB->OpenTableLC (TPtrC (IAP)); 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
	TInt ret = table->GotoFirstRecord ();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
	TPodcastIAPItem IAPItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	TBuf <KCommsDbSvrMaxFieldLength> bufName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	while (ret == KErrNone) // There was a first record
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
		table->ReadUintL(TPtrC(COMMDB_ID), IAPItem.iIapId);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
		table->ReadTextL (TPtrC(COMMDB_NAME), bufName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
		table->ReadTextL (TPtrC(IAP_BEARER_TYPE), IAPItem.iBearerType);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
		table->ReadTextL (TPtrC(IAP_SERVICE_TYPE), IAPItem.iServiceType);
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
		iIapIdArray.Append(IAPItem);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
		iIapNameArray->AppendL(bufName); 		 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
		ret = table->GotoNextRecord();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
	CleanupStack::PopAndDestroy(); // Close table
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
	}
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
EXPORT_C void CPodcastModel::UpdateSNAPListL()
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
	DP("CPodcastModel::UpdateSNAPListL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
	iSNAPNameArray->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
	iSNAPIdArray.Reset();
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
	RCmDestination destination;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
	TPodcastIAPItem IAPItem;
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
	RArray<TUint32> destArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
	CleanupClosePushL(destArray);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
	iCmManager.AllDestinationsL(destArray);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
	TInt cnt = destArray.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
	DP1("destArray.Count==%d", cnt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
	for(TInt loop = 0;loop<cnt;loop++)
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
		destination = iCmManager.DestinationL (destArray[loop]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
		CleanupClosePushL(destination);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
		if(!destination.IsHidden())
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
			IAPItem.iIapId = destArray[loop];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
			HBufC* name = destination.NameLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
			DP1(" destination.NameLC==%S", name);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
			iSNAPNameArray->AppendL(*name);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
			CleanupStack::PopAndDestroy(name);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
			iSNAPIdArray.Append(IAPItem);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
		CleanupStack::PopAndDestroy();//close destination
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
	CleanupStack::PopAndDestroy();// close destArray
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
	DP("CPodcastModel::UpdateSNAPListL END");
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
EXPORT_C CDesCArrayFlat* CPodcastModel::IAPNames()
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
	return iIapNameArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
}
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
EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::IAPIds()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
	return iIapIdArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
EXPORT_C CDesCArrayFlat* CPodcastModel::SNAPNames()
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 iSNAPNameArray;
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
EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::SNAPIds()
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
	return iSNAPIdArray;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
RFs& CPodcastModel::FsSession()
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
	return iFsSession;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
	}
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
EXPORT_C void CPodcastModel::SetPlayingPodcast(CShowInfo* aPodcast)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
	iPlayingPodcast = aPodcast;
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
EXPORT_C CShowInfo* CPodcastModel::PlayingPodcast()
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
	return iPlayingPodcast;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
EXPORT_C CFeedEngine& CPodcastModel::FeedEngine()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
	return *iFeedEngine;
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
EXPORT_C CShowEngine& CPodcastModel::ShowEngine()
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
	return *iShowEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
EXPORT_C CSoundEngine& CPodcastModel::SoundEngine()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
	return *iSoundEngine;
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
EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
	return *iSettingsEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
EXPORT_C CConnectionEngine& CPodcastModel::ConnectionEngine()
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
	return *iConnectionEngine;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool aPlayOnInit) 
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
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
	// special treatment if this podcast is already active
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
	if (iPlayingPodcast->Uid() == aPodcast->Uid() && SoundEngine().State() > ESoundEngineOpening ) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
		if (aPodcast->PlayState() == EPlaying) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
			SoundEngine().Pause();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
			aPodcast->SetPosition(iSoundEngine->Position());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
			aPodcast->SetPlayState(EPlayed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
			aPodcast->SetPlayState(EPlayed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
		} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
			iSoundEngine->Play();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
		// switching file, so save position
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
		iSoundEngine->Pause();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
		if (iPlayingPodcast != NULL) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
			iPlayingPodcast->SetPosition(iSoundEngine->Position());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
		iSoundEngine->Stop(EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
		// we play video podcasts through the external player
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
		if(aPodcast != NULL && aPodcast->ShowType() != EVideoPodcast) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
			DP1("Starting: %S", &(aPodcast->FileName()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
			TRAPD( error, iSoundEngine->OpenFileL(aPodcast->FileName(), aPlayOnInit) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
			if (error != KErrNone) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
				DP1("Error: %d", error);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
			} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
				iSoundEngine->SetPosition(aPodcast->Position().Int64() / 1000000);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
		iPlayingPodcast = aPodcast;		
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
}
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
EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo()
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
	return iActiveFeed;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
EXPORT_C void CPodcastModel::SetActiveFeedInfo(CFeedInfo* aFeedInfo)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
	iActiveFeed = aFeedInfo;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
EXPORT_C RShowInfoArray& CPodcastModel::ActiveShowList()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
	return iActiveShowList;
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 CPodcastModel::SetActiveShowList(RShowInfoArray& aShowArray)
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
	iActiveShowList.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
	TInt cnt = aShowArray.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
	for(TInt loop = 0;loop < cnt; loop++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
		iActiveShowList.Append(aShowArray[loop]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
sqlite3* CPodcastModel::DB()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
	if (iDB == NULL) {		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
		TFileName dbFileName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
		iFsSession.PrivatePath(dbFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
		dbFileName.Append(KDBFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
		DP1("DB is at %S", &dbFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
		if (!BaflUtils::FileExists(iFsSession, dbFileName)) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
			TFileName dbTemplate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   290
			iFsSession.PrivatePath(dbTemplate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
			dbTemplate.Append(KDBTemplateFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
			DP1("No DB found, copying template from %S", &dbTemplate);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
			BaflUtils::CopyFile(iFsSession, dbTemplate,dbFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
			iIsFirstStartup = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
		}
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
		TBuf8<KMaxFileName> filename8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   298
		filename8.Copy(dbFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   299
		int rc = rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
		if( rc != SQLITE_OK){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   301
			DP("Error loading DB");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
			User::Panic(_L("Podcatcher"), 10);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
	return iDB;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   310
void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   311
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   312
	TBool useProxy = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
	HBufC* serverName = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
	TUint32 port = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   316
	TRAPD(err,GetProxyInformationForConnectionL(useProxy, serverName, port));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
	if (err == KErrNone && useProxy)
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
		CleanupStack::PushL(serverName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
		TBuf8<128> proxyAddr;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
		proxyAddr.Append(*serverName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
		proxyAddr.Append(':');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   323
		proxyAddr.AppendNum(port);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   324
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   325
		RStringF prxAddr = aSession.StringPool().OpenFStringL(proxyAddr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   326
		CleanupClosePushL(prxAddr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   327
		THTTPHdrVal prxUsage(aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
		aSession.ConnectionInfo().SetPropertyL(
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
						aSession.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
						aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
		aSession.ConnectionInfo().SetPropertyL(aSession.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), prxAddr); 
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
		CleanupStack::PopAndDestroy(&prxAddr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
		CleanupStack::PopAndDestroy(serverName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   337
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   338
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   339
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   340
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   341
void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
	TInt iapId = GetIapId();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   344
	CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
	TUint32 iapService;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
	HBufC* iapServiceType;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
	table->ReadUintL(TPtrC(IAP_SERVICE), iapService);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
	iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE));
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
	CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   352
	TInt err = proxyTableView->GotoFirstRecord();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
	if( err != KErrNone)
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
		User::Leave(KErrNotFound);	
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
	proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   359
	if(aIsUsed)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
		HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
		proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
		aProxyServerName = serverName->AllocL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
		CleanupStack::PopAndDestroy(serverName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   366
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   367
	CleanupStack::PopAndDestroy(proxyTableView);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   368
	CleanupStack::PopAndDestroy(iapServiceType);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
	CleanupStack::PopAndDestroy(table);
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
	
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
TInt CPodcastModel::GetIapId()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   374
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
	_LIT(KSetting, "IAP\\Id");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
	TUint32 iapId = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
	iConnectionEngine->Connection().GetIntSetting(KSetting, iapId);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
	return iapId;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   381
EXPORT_C void CPodcastModel::GetAllShowsL()
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   382
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
	iActiveShowList.ResetAndDestroy();
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   384
	iShowEngine->GetAllShowsL(iActiveShowList);
2
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
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   387
EXPORT_C void CPodcastModel::GetNewShowsL()
2
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
	iActiveShowList.ResetAndDestroy();
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   390
	iShowEngine->GetNewShowsL(iActiveShowList);	
2
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
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   393
EXPORT_C void CPodcastModel::GetShowsDownloadedL()
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   394
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   395
	iActiveShowList.ResetAndDestroy();
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   396
	iShowEngine->GetShowsDownloadedL(iActiveShowList);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   397
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   398
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   399
EXPORT_C void CPodcastModel::GetShowsDownloadingL()
2
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
	iActiveShowList.ResetAndDestroy();
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   402
	iShowEngine->GetShowsDownloadingL(iActiveShowList);
2
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
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   405
EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   406
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   407
	iActiveShowList.ResetAndDestroy();
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 2
diff changeset
   408
	iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid);
2
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   411
EXPORT_C void CPodcastModel::MarkSelectionPlayed()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   412
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   413
	for (int i=0;i<iActiveShowList.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   414
		if(iActiveShowList[i]->PlayState() != EPlayed) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   415
			iActiveShowList[i]->SetPlayState(EPlayed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   416
			iShowEngine->UpdateShow(*iActiveShowList[i]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   417
		}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   421
TInt CPodcastModel::FindActiveShowByUid(TUint aUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   422
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   423
	for (int i=0;i<iActiveShowList.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   424
		if (iActiveShowList[i]->Uid() == aUid) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
			return i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
		}
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
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
	return KErrNotFound;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   432
EXPORT_C TBool CPodcastModel::IsFirstStartup()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   433
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   434
	return iIsFirstStartup;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   435
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   436
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   443
EXPORT_C CImageHandler& CPodcastModel::ImageHandler()
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
	return *iImageHandler;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
	}