| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Tue, 16 Nov 2010 09:35:25 +0000 | |
| branch | symbian1 | 
| changeset 360 | e2fa17cfc987 | 
| parent 349 | 4538abb763e4 | 
| permissions | -rw-r--r-- | 
| 2 | 1 | /* | 
| 2 | * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB | |
| 3 | * | |
| 4 | * All rights reserved. | |
| 5 | * This component and the accompanying materials are made available | |
| 6 | * under the terms of the License "Eclipse Public License v1.0" | |
| 7 | * which accompanies this distribution, and is available | |
| 8 | * at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
| 9 | * | |
| 10 | * Initial Contributors: | |
| 11 | * EmbedDev AB - initial contribution. | |
| 12 | * | |
| 13 | * Contributors: | |
| 14 | * | |
| 15 | * Description: | |
| 16 | * | |
| 17 | */ | |
| 18 | ||
| 19 | #include <commdb.h> | |
| 20 | #include "PodcastModel.h" | |
| 21 | #include "FeedEngine.h" | |
| 22 | #include "SettingsEngine.h" | |
| 23 | #include "ShowEngine.h" | |
| 24 | #include "connectionengine.h" | |
| 60 | 25 | #include "podcastutils.h" | 
| 26 | #include "Podcatcher.pan" | |
| 2 | 27 | |
| 28 | #include <cmdestination.h> | |
| 29 | #include <cmmanager.h> | |
| 30 | #include <bautils.h> | |
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 31 | #include <aknserverapp.h> // MAknServerAppExitObserver | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 32 | #include <DocumentHandler.h> | 
| 2 | 33 | |
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 34 | |
| 2 | 35 | const TInt KDefaultGranu = 5; | 
| 36 | _LIT(KDBFileName, "podcatcher.sqlite"); | |
| 37 | _LIT(KDBTemplateFileName, "podcatcher.sqlite.template"); | |
| 38 | ||
| 39 | EXPORT_C CPodcastModel* CPodcastModel::NewL() | |
| 40 | {
 | |
| 41 | CPodcastModel* self = new (ELeave) CPodcastModel; | |
| 42 | CleanupStack::PushL(self); | |
| 43 | self->ConstructL(); | |
| 44 | CleanupStack::Pop(self); | |
| 45 | return self; | |
| 46 | } | |
| 47 | ||
| 48 | CPodcastModel::~CPodcastModel() | |
| 49 | {
 | |
| 50 | ||
| 51 | delete iFeedEngine; | |
| 52 | delete iSettingsEngine; | |
| 53 | delete iShowEngine; | |
| 54 | ||
| 55 | delete iIapNameArray; | |
| 56 | iIapIdArray.Close(); | |
| 57 | ||
| 58 | delete iSNAPNameArray; | |
| 59 | iSNAPIdArray.Close(); | |
| 60 | delete iCommDB; | |
| 61 | sqlite3_close(iDB); | |
| 62 | iFsSession.Close(); | |
| 63 | iActiveShowList.ResetAndDestroy(); | |
| 64 | iActiveShowList.Close(); | |
| 65 | delete iConnectionEngine; | |
| 66 | iCmManager.Close(); | |
| 67 | delete iImageHandler; | |
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 68 | delete iDocHandler; | 
| 2 | 69 | } | 
| 70 | ||
| 71 | CPodcastModel::CPodcastModel() | |
| 72 | {	
 | |
| 73 | } | |
| 74 | ||
| 75 | void CPodcastModel::ConstructL() | |
| 76 | {
 | |
| 77 | 	DP("CPodcastModel::ConstructL BEGIN");
 | |
| 78 | User::LeaveIfError(iFsSession.Connect()); | |
| 79 | iCommDB = CCommsDatabase::NewL (EDatabaseTypeUnspecified); | |
| 80 | iIapNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); | |
| 81 | iSNAPNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); | |
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 82 | |
| 60 | 83 | iImageHandler = CImageHandler::NewL(FsSession(), *this); | 
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 84 | iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()); | 
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 85 | |
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 86 | TRAPD(err,iCmManager.OpenL()); | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 87 | 	DP1("iCmManager.OpenL(),err=%d;", err);
 | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 88 | |
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 89 | if (err == KErrNone) | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 90 | 		{
 | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 91 | UpdateIAPListL(); | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 92 | UpdateSNAPListL(); | 
| 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 93 | } | 
| 2 | 94 | |
| 95 | iSettingsEngine = CSettingsEngine::NewL(*this); | |
| 96 | iConnectionEngine = CConnectionEngine::NewL(*this); | |
| 97 | ||
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 98 | TRAP(err, OpenDBL()); | 
| 60 | 99 | |
| 100 | if (err != KErrNone) | |
| 101 | 		{
 | |
| 102 | ResetDB(); | |
| 103 | ||
| 104 | TRAP(err, OpenDBL()); | |
| 105 | ||
| 106 | if (err != KErrNone) | |
| 107 | 			{
 | |
| 108 | Panic(EPodcatcherPanicDB); | |
| 109 | } | |
| 110 | ||
| 111 | } | |
| 112 | ||
| 2 | 113 | iFeedEngine = CFeedEngine::NewL(*this); | 
| 114 | iShowEngine = CShowEngine::NewL(*this); | |
| 115 | ||
| 116 | 	DP("CPodcastModel::ConstructL END");
 | |
| 117 | } | |
| 118 | ||
| 119 | ||
| 120 | ||
| 121 | EXPORT_C void CPodcastModel::UpdateIAPListL() | |
| 122 | 	{
 | |
| 123 | iIapNameArray->Reset(); | |
| 124 | iIapIdArray.Reset(); | |
| 125 | ||
| 126 | CCommsDbTableView* table = iCommDB->OpenTableLC (TPtrC (IAP)); | |
| 127 | TInt ret = table->GotoFirstRecord (); | |
| 128 | TPodcastIAPItem IAPItem; | |
| 129 | TBuf <KCommsDbSvrMaxFieldLength> bufName; | |
| 130 | while (ret == KErrNone) // There was a first record | |
| 131 | 		{
 | |
| 132 | table->ReadUintL(TPtrC(COMMDB_ID), IAPItem.iIapId); | |
| 133 | table->ReadTextL (TPtrC(COMMDB_NAME), bufName); | |
| 134 | table->ReadTextL (TPtrC(IAP_BEARER_TYPE), IAPItem.iBearerType); | |
| 135 | table->ReadTextL (TPtrC(IAP_SERVICE_TYPE), IAPItem.iServiceType); | |
| 136 | ||
| 137 | iIapIdArray.Append(IAPItem); | |
| 138 | iIapNameArray->AppendL(bufName); | |
| 139 | ret = table->GotoNextRecord(); | |
| 140 | } | |
| 141 | CleanupStack::PopAndDestroy(); // Close table | |
| 142 | } | |
| 143 | ||
| 144 | EXPORT_C void CPodcastModel::UpdateSNAPListL() | |
| 145 | {
 | |
| 146 | 	DP("CPodcastModel::UpdateSNAPListL BEGIN");
 | |
| 147 | iSNAPNameArray->Reset(); | |
| 148 | iSNAPIdArray.Reset(); | |
| 149 | ||
| 150 | RCmDestination destination; | |
| 151 | TPodcastIAPItem IAPItem; | |
| 152 | ||
| 153 | RArray<TUint32> destArray; | |
| 154 | CleanupClosePushL(destArray); | |
| 155 | iCmManager.AllDestinationsL(destArray); | |
| 156 | ||
| 157 | TInt cnt = destArray.Count(); | |
| 158 | 	DP1("destArray.Count==%d", cnt);
 | |
| 159 | for(TInt loop = 0;loop<cnt;loop++) | |
| 160 | 		{
 | |
| 161 | destination = iCmManager.DestinationL (destArray[loop]); | |
| 162 | CleanupClosePushL(destination); | |
| 163 | if(!destination.IsHidden()) | |
| 164 | 			{
 | |
| 165 | IAPItem.iIapId = destArray[loop]; | |
| 166 | HBufC* name = destination.NameLC(); | |
| 167 | 			DP1(" destination.NameLC==%S", name);
 | |
| 168 | iSNAPNameArray->AppendL(*name); | |
| 169 | CleanupStack::PopAndDestroy(name); | |
| 170 | iSNAPIdArray.Append(IAPItem); | |
| 171 | } | |
| 172 | CleanupStack::PopAndDestroy();//close destination | |
| 173 | } | |
| 174 | CleanupStack::PopAndDestroy();// close destArray | |
| 175 | ||
| 176 | 	DP("CPodcastModel::UpdateSNAPListL END");
 | |
| 177 | } | |
| 178 | ||
| 179 | EXPORT_C CDesCArrayFlat* CPodcastModel::IAPNames() | |
| 180 | {
 | |
| 181 | return iIapNameArray; | |
| 182 | } | |
| 183 | ||
| 184 | EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::IAPIds() | |
| 185 | {
 | |
| 186 | return iIapIdArray; | |
| 187 | } | |
| 188 | ||
| 189 | EXPORT_C CDesCArrayFlat* CPodcastModel::SNAPNames() | |
| 190 | {
 | |
| 191 | return iSNAPNameArray; | |
| 192 | } | |
| 193 | ||
| 194 | EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::SNAPIds() | |
| 195 | {
 | |
| 196 | return iSNAPIdArray; | |
| 197 | } | |
| 198 | ||
| 199 | ||
| 200 | RFs& CPodcastModel::FsSession() | |
| 201 | 	{
 | |
| 202 | return iFsSession; | |
| 203 | } | |
| 204 | ||
| 205 | EXPORT_C void CPodcastModel::SetPlayingPodcast(CShowInfo* aPodcast) | |
| 206 | {
 | |
| 207 | iPlayingPodcast = aPodcast; | |
| 208 | } | |
| 209 | ||
| 210 | EXPORT_C CShowInfo* CPodcastModel::PlayingPodcast() | |
| 211 | {
 | |
| 212 | return iPlayingPodcast; | |
| 213 | } | |
| 214 | ||
| 215 | EXPORT_C CFeedEngine& CPodcastModel::FeedEngine() | |
| 216 | {
 | |
| 217 | return *iFeedEngine; | |
| 218 | } | |
| 219 | ||
| 220 | EXPORT_C CShowEngine& CPodcastModel::ShowEngine() | |
| 221 | {
 | |
| 222 | return *iShowEngine; | |
| 223 | } | |
| 224 | ||
| 225 | EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine() | |
| 226 | {
 | |
| 227 | return *iSettingsEngine; | |
| 228 | } | |
| 229 | ||
| 230 | EXPORT_C CConnectionEngine& CPodcastModel::ConnectionEngine() | |
| 231 | {
 | |
| 232 | return *iConnectionEngine; | |
| 233 | } | |
| 234 | ||
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 235 | EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool /* aPlayOnInit */) | 
| 2 | 236 | 	{
 | 
| 136 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 237 | 	DP("CPodcastModel::PlayPausePodcastL BEGIN");
 | 
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 238 | TRAPD(err, LaunchFileEmbeddedL(aPodcast->FileName())); | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 239 | |
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 240 | if (err == KErrNone) | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 241 | 		{
 | 
| 349 
4538abb763e4
Added auto delete feature
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
348diff
changeset | 242 | iShowEngine->PostPlayHandling(aPodcast); | 
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 243 | } | 
| 136 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 244 | else | 
| 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 245 | 		{
 | 
| 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 246 | User::Leave(err); | 
| 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 247 | } | 
| 
cee38af14bcf
Merged show playback error handling from S^3 branch
 teknolog parents: 
90diff
changeset | 248 | 	DP("CPodcastModel::PlayPausePodcastL END");
 | 
| 2 | 249 | } | 
| 250 | ||
| 251 | EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo() | |
| 252 | {
 | |
| 253 | return iActiveFeed; | |
| 254 | } | |
| 255 | ||
| 256 | EXPORT_C void CPodcastModel::SetActiveFeedInfo(CFeedInfo* aFeedInfo) | |
| 257 | {
 | |
| 258 | iActiveFeed = aFeedInfo; | |
| 259 | } | |
| 260 | ||
| 261 | EXPORT_C RShowInfoArray& CPodcastModel::ActiveShowList() | |
| 262 | {
 | |
| 263 | return iActiveShowList; | |
| 264 | } | |
| 265 | ||
| 266 | void CPodcastModel::SetActiveShowList(RShowInfoArray& aShowArray) | |
| 267 | {
 | |
| 268 | iActiveShowList.ResetAndDestroy(); | |
| 269 | TInt cnt = aShowArray.Count(); | |
| 270 | ||
| 271 | for(TInt loop = 0;loop < cnt; loop++) | |
| 272 | 	{
 | |
| 273 | iActiveShowList.Append(aShowArray[loop]); | |
| 274 | } | |
| 275 | } | |
| 276 | ||
| 60 | 277 | EXPORT_C void CPodcastModel::DropDB() | 
| 278 | 	{
 | |
| 279 | if (iDB != NULL) | |
| 280 | 		{
 | |
| 281 | sqlite3_close(iDB); | |
| 282 | iDB = NULL; | |
| 283 | } | |
| 284 | ||
| 285 | TFileName dbFileName; | |
| 286 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | |
| 287 | dbFileName.Append(KDBFileName); | |
| 288 | ||
| 289 | // remove the old DB file | |
| 290 | if (BaflUtils::FileExists(iFsSession, dbFileName)) | |
| 291 | 		{
 | |
| 292 | BaflUtils::DeleteFile(iFsSession, dbFileName); | |
| 293 | } | |
| 294 | } | |
| 295 | ||
| 296 | void CPodcastModel::ResetDB() | |
| 297 | 	{
 | |
| 298 | 	DP("CPodcastModel::ResetDB BEGIN");
 | |
| 299 | ||
| 300 | DropDB(); | |
| 301 | ||
| 302 | TFileName dbFileName; | |
| 303 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | |
| 304 | dbFileName.Append(KDBFileName); | |
| 305 | ||
| 306 | // remove the old DB file | |
| 307 | if (BaflUtils::FileExists(iFsSession, dbFileName)) | |
| 308 | 		{
 | |
| 309 | BaflUtils::DeleteFile(iFsSession, dbFileName); | |
| 310 | } | |
| 311 | ||
| 312 | // copy template to new DB | |
| 313 | TFileName dbTemplate; | |
| 314 | dbTemplate.Copy(iSettingsEngine->PrivatePath()); | |
| 315 | dbTemplate.Append(KDBTemplateFileName); | |
| 316 | ||
| 336 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 317 | 	DP1("Copy template DB from: %S", &dbTemplate);
 | 
| 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 318 | 	DP1("Copy template DB to: %S", &dbFileName);
 | 
| 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 319 | |
| 60 | 320 | BaflUtils::CopyFile(iFsSession, dbTemplate,dbFileName); | 
| 336 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 321 | |
| 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 322 | // important to set this file to not be read only if copying from Z: | 
| 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 323 | iFsSession.SetAtt(dbFileName, 0, KEntryAttReadOnly); | 
| 
3d6c1417e8bd
Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
211diff
changeset | 324 | |
| 60 | 325 | iIsFirstStartup = ETrue; | 
| 326 | 	DP("CPodcastModel::ResetDB END");
 | |
| 327 | } | |
| 328 | ||
| 329 | ||
| 330 | void CPodcastModel::OpenDBL() | |
| 331 | 	{
 | |
| 332 | 	DP("CPodcastModel::OpenDBL BEGIN");
 | |
| 333 | ||
| 334 | if (iDB != NULL) | |
| 335 | 		{
 | |
| 336 | sqlite3_close(iDB); | |
| 337 | iDB = NULL; | |
| 338 | } | |
| 339 | ||
| 340 | TFileName dbFileName; | |
| 341 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | |
| 342 | dbFileName.Append(KDBFileName); | |
| 343 | ||
| 344 | if (!BaflUtils::FileExists(iFsSession, dbFileName)) | |
| 345 | 		{
 | |
| 346 | User::Leave(KErrNotFound); | |
| 347 | } | |
| 348 | ||
| 349 | 	if (iDB == NULL) {	
 | |
| 350 | // open DB | |
| 351 | TBuf8<KMaxFileName> filename8; | |
| 352 | filename8.Copy(dbFileName); | |
| 353 | int rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); | |
| 354 | 		if(rc != SQLITE_OK){
 | |
| 355 | User::Leave(KErrCorrupt); | |
| 356 | } | |
| 357 | ||
| 358 | // do a test query | |
| 359 | sqlite3_stmt *st; | |
| 360 | rc = sqlite3_prepare_v2(iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); | |
| 361 | if( rc==SQLITE_OK ) | |
| 362 | 			{
 | |
| 363 | Cleanup_sqlite3_finalize_PushL(st); | |
| 364 | rc = sqlite3_step(st); | |
| 365 | ||
| 366 | if (rc != SQLITE_ROW) | |
| 367 | 				{
 | |
| 368 | User::Leave(KErrCorrupt); | |
| 369 | } | |
| 370 | CleanupStack::PopAndDestroy(); // st | |
| 371 | } | |
| 372 | else | |
| 373 | 			{
 | |
| 374 | User::Leave(KErrCorrupt); | |
| 375 | } | |
| 376 | } | |
| 377 | ||
| 378 | 	DP("CPodcastModel::OpenDBL END");	
 | |
| 379 | } | |
| 380 | ||
| 2 | 381 | sqlite3* CPodcastModel::DB() | 
| 382 | {
 | |
| 383 | return iDB; | |
| 384 | } | |
| 385 | ||
| 386 | void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) | |
| 387 | 	{
 | |
| 388 | TBool useProxy = EFalse; | |
| 389 | HBufC* serverName = NULL; | |
| 390 | TUint32 port = 0; | |
| 391 | ||
| 392 | TRAPD(err,GetProxyInformationForConnectionL(useProxy, serverName, port)); | |
| 393 | if (err == KErrNone && useProxy) | |
| 394 | 		{
 | |
| 395 | CleanupStack::PushL(serverName); | |
| 396 | TBuf8<128> proxyAddr; | |
| 397 | proxyAddr.Append(*serverName); | |
| 398 | 		proxyAddr.Append(':');
 | |
| 399 | proxyAddr.AppendNum(port); | |
| 400 | ||
| 401 | RStringF prxAddr = aSession.StringPool().OpenFStringL(proxyAddr); | |
| 402 | CleanupClosePushL(prxAddr); | |
| 403 | THTTPHdrVal prxUsage(aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); | |
| 404 | ||
| 405 | aSession.ConnectionInfo().SetPropertyL( | |
| 406 | aSession.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), | |
| 407 | aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); | |
| 408 | ||
| 409 | aSession.ConnectionInfo().SetPropertyL(aSession.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), prxAddr); | |
| 410 | ||
| 411 | CleanupStack::PopAndDestroy(&prxAddr); | |
| 412 | CleanupStack::PopAndDestroy(serverName); | |
| 413 | } | |
| 414 | } | |
| 415 | ||
| 416 | ||
| 417 | void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort) | |
| 418 | 	{
 | |
| 419 | TInt iapId = GetIapId(); | |
| 420 | CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId); | |
| 421 | ||
| 422 | TUint32 iapService; | |
| 423 | HBufC* iapServiceType; | |
| 424 | table->ReadUintL(TPtrC(IAP_SERVICE), iapService); | |
| 425 | iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE)); | |
| 426 | ||
| 427 | CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType); | |
| 428 | TInt err = proxyTableView->GotoFirstRecord(); | |
| 429 | if( err != KErrNone) | |
| 430 | 		{
 | |
| 431 | User::Leave(KErrNotFound); | |
| 432 | } | |
| 433 | ||
| 434 | proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed); | |
| 435 | if(aIsUsed) | |
| 436 | 		{
 | |
| 437 | HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); | |
| 438 | proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort); | |
| 439 | aProxyServerName = serverName->AllocL(); | |
| 440 | CleanupStack::PopAndDestroy(serverName); | |
| 441 | } | |
| 442 | ||
| 443 | CleanupStack::PopAndDestroy(proxyTableView); | |
| 444 | CleanupStack::PopAndDestroy(iapServiceType); | |
| 445 | CleanupStack::PopAndDestroy(table); | |
| 446 | } | |
| 447 | ||
| 448 | TInt CPodcastModel::GetIapId() | |
| 449 | 	{
 | |
| 450 | _LIT(KSetting, "IAP\\Id"); | |
| 451 | TUint32 iapId = 0; | |
| 452 | iConnectionEngine->Connection().GetIntSetting(KSetting, iapId); | |
| 453 | return iapId; | |
| 454 | } | |
| 455 | ||
| 8 | 456 | EXPORT_C void CPodcastModel::GetShowsDownloadingL() | 
| 2 | 457 | 	{
 | 
| 458 | iActiveShowList.ResetAndDestroy(); | |
| 8 | 459 | iShowEngine->GetShowsDownloadingL(iActiveShowList); | 
| 2 | 460 | } | 
| 461 | ||
| 8 | 462 | EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid) | 
| 2 | 463 | 	{
 | 
| 464 | iActiveShowList.ResetAndDestroy(); | |
| 88 
f4b512d870e8
Moved call to DeleteOldShowsByFeedL to when a feed is listed. This prevents a race condition which likely caused
 teknolog parents: 
67diff
changeset | 465 | iShowEngine->DeleteOldShowsByFeedL(aFeedUid); | 
| 60 | 466 | iShowEngine->CheckForDeletedShows(aFeedUid); | 
| 8 | 467 | iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); | 
| 2 | 468 | } | 
| 469 | ||
| 347 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 470 | EXPORT_C void CPodcastModel::GetNewShowsL() | 
| 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 471 | 	{
 | 
| 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 472 | iActiveShowList.ResetAndDestroy(); | 
| 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 473 | iShowEngine->GetNewShowsL(iActiveShowList); | 
| 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 474 | } | 
| 
b8d687bb7ca1
Experimenting with adding a new view to list all new shows
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
336diff
changeset | 475 | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
8diff
changeset | 476 | EXPORT_C void CPodcastModel::MarkSelectionPlayedL() | 
| 2 | 477 | 	{
 | 
| 478 | 	for (int i=0;i<iActiveShowList.Count();i++) {
 | |
| 479 | 		if(iActiveShowList[i]->PlayState() != EPlayed) {
 | |
| 360 
e2fa17cfc987
Fix so mark all old also triggers auto delete
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
349diff
changeset | 480 | ShowEngine().PostPlayHandling(iActiveShowList[i]); | 
| 2 | 481 | } | 
| 482 | } | |
| 483 | } | |
| 484 | ||
| 485 | TInt CPodcastModel::FindActiveShowByUid(TUint aUid) | |
| 486 | 	{
 | |
| 487 | 	for (int i=0;i<iActiveShowList.Count();i++) {
 | |
| 488 | 		if (iActiveShowList[i]->Uid() == aUid) {
 | |
| 489 | return i; | |
| 490 | } | |
| 491 | } | |
| 492 | ||
| 493 | return KErrNotFound; | |
| 494 | } | |
| 495 | ||
| 496 | EXPORT_C TBool CPodcastModel::IsFirstStartup() | |
| 497 | 	{
 | |
| 498 | return iIsFirstStartup; | |
| 499 | } | |
| 500 | ||
| 501 | ||
| 60 | 502 | void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/, CPodcastModel& /*aPodcastModel*/) | 
| 2 | 503 | 	{
 | 
| 504 | ||
| 505 | } | |
| 506 | ||
| 507 | EXPORT_C CImageHandler& CPodcastModel::ImageHandler() | |
| 508 | 	{
 | |
| 509 | return *iImageHandler; | |
| 510 | } | |
| 90 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 511 | |
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 512 | void CPodcastModel::LaunchFileEmbeddedL(const TDesC& aFilename) | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 513 |     {
 | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 514 | //Set the exit observer so HandleServerAppExit will be called | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 515 | iDocHandler->SetExitObserver(this); | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 516 | |
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 517 | TDataType emptyDataType = TDataType(); | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 518 | //Open a file embedded | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 519 | iDocHandler->OpenFileEmbeddedL(aFilename, emptyDataType); | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 520 | } | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 521 | |
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 522 | void CPodcastModel::HandleServerAppExit(TInt aReason) | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 523 |     {
 | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 524 | //Handle closing the handler application | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 525 | MAknServerAppExitObserver::HandleServerAppExit(aReason); | 
| 
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
 teknolog parents: 
88diff
changeset | 526 | } | 
| 164 
000f9fc147b2
Catch up with default branch; New v 27 SIS
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
148diff
changeset | 527 |