| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Sat, 23 Oct 2010 18:22:27 +0100 | |
| branch | RCL_3 | 
| changeset 282 | cf3842290671 | 
| parent 162 | d15654dbe9b8 | 
| child 300 | 5902e8f443e2 | 
| 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" | |
| 109 | 25 | #include "podcastutils.h" | 
| 114 | 26 | #include "Podcatcher.pan" | 
| 2 | 27 | |
| 28 | #include <cmdestination.h> | |
| 29 | #include <cmmanager.h> | |
| 30 | #include <bautils.h> | |
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 31 | #include <aknserverapp.h> // MAknServerAppExitObserver | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 32 | #include <DocumentHandler.h> | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 33 | |
| 2 | 34 | |
| 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; | |
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
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); | |
| 126 | 82 | |
| 93 
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
 Lars Persson <lars.persson@embeddev.se> parents: 
91diff
changeset | 83 | iImageHandler = CImageHandler::NewL(FsSession(), *this); | 
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 84 | iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()); | 
| 126 | 85 | |
| 86 | TRAPD(err,iCmManager.OpenL()); | |
| 87 | 	DP1("iCmManager.OpenL(),err=%d;", err);
 | |
| 2 | 88 | |
| 126 | 89 | if (err == KErrNone) | 
| 90 | 		{
 | |
| 91 | UpdateIAPListL(); | |
| 92 | UpdateSNAPListL(); | |
| 93 | } | |
| 2 | 94 | |
| 95 | iSettingsEngine = CSettingsEngine::NewL(*this); | |
| 96 | iConnectionEngine = CConnectionEngine::NewL(*this); | |
| 97 | ||
| 126 | 98 | TRAP(err, OpenDBL()); | 
| 109 | 99 | |
| 100 | if (err != KErrNone) | |
| 101 | 		{
 | |
| 102 | ResetDB(); | |
| 103 | ||
| 104 | TRAP(err, OpenDBL()); | |
| 105 | ||
| 106 | if (err != KErrNone) | |
| 107 | 			{
 | |
| 282 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 108 | 			DP1("err=%d", err);
 | 
| 114 | 109 | Panic(EPodcatcherPanicDB); | 
| 109 | 110 | } | 
| 111 | ||
| 112 | } | |
| 113 | ||
| 2 | 114 | iFeedEngine = CFeedEngine::NewL(*this); | 
| 115 | iShowEngine = CShowEngine::NewL(*this); | |
| 116 | ||
| 117 | 	DP("CPodcastModel::ConstructL END");
 | |
| 118 | } | |
| 119 | ||
| 120 | ||
| 121 | ||
| 122 | EXPORT_C void CPodcastModel::UpdateIAPListL() | |
| 123 | 	{
 | |
| 124 | iIapNameArray->Reset(); | |
| 125 | iIapIdArray.Reset(); | |
| 126 | ||
| 127 | CCommsDbTableView* table = iCommDB->OpenTableLC (TPtrC (IAP)); | |
| 128 | TInt ret = table->GotoFirstRecord (); | |
| 129 | TPodcastIAPItem IAPItem; | |
| 130 | TBuf <KCommsDbSvrMaxFieldLength> bufName; | |
| 131 | while (ret == KErrNone) // There was a first record | |
| 132 | 		{
 | |
| 133 | table->ReadUintL(TPtrC(COMMDB_ID), IAPItem.iIapId); | |
| 134 | table->ReadTextL (TPtrC(COMMDB_NAME), bufName); | |
| 135 | table->ReadTextL (TPtrC(IAP_BEARER_TYPE), IAPItem.iBearerType); | |
| 136 | table->ReadTextL (TPtrC(IAP_SERVICE_TYPE), IAPItem.iServiceType); | |
| 137 | ||
| 138 | iIapIdArray.Append(IAPItem); | |
| 139 | iIapNameArray->AppendL(bufName); | |
| 140 | ret = table->GotoNextRecord(); | |
| 141 | } | |
| 142 | CleanupStack::PopAndDestroy(); // Close table | |
| 143 | } | |
| 144 | ||
| 145 | EXPORT_C void CPodcastModel::UpdateSNAPListL() | |
| 146 | {
 | |
| 147 | 	DP("CPodcastModel::UpdateSNAPListL BEGIN");
 | |
| 148 | iSNAPNameArray->Reset(); | |
| 149 | iSNAPIdArray.Reset(); | |
| 150 | ||
| 151 | RCmDestination destination; | |
| 152 | TPodcastIAPItem IAPItem; | |
| 153 | ||
| 154 | RArray<TUint32> destArray; | |
| 155 | CleanupClosePushL(destArray); | |
| 156 | iCmManager.AllDestinationsL(destArray); | |
| 157 | ||
| 158 | TInt cnt = destArray.Count(); | |
| 159 | 	DP1("destArray.Count==%d", cnt);
 | |
| 160 | for(TInt loop = 0;loop<cnt;loop++) | |
| 161 | 		{
 | |
| 162 | destination = iCmManager.DestinationL (destArray[loop]); | |
| 163 | CleanupClosePushL(destination); | |
| 164 | if(!destination.IsHidden()) | |
| 165 | 			{
 | |
| 166 | IAPItem.iIapId = destArray[loop]; | |
| 167 | HBufC* name = destination.NameLC(); | |
| 168 | 			DP1(" destination.NameLC==%S", name);
 | |
| 169 | iSNAPNameArray->AppendL(*name); | |
| 170 | CleanupStack::PopAndDestroy(name); | |
| 171 | iSNAPIdArray.Append(IAPItem); | |
| 172 | } | |
| 173 | CleanupStack::PopAndDestroy();//close destination | |
| 174 | } | |
| 175 | CleanupStack::PopAndDestroy();// close destArray | |
| 176 | ||
| 177 | 	DP("CPodcastModel::UpdateSNAPListL END");
 | |
| 178 | } | |
| 179 | ||
| 180 | EXPORT_C CDesCArrayFlat* CPodcastModel::IAPNames() | |
| 181 | {
 | |
| 182 | return iIapNameArray; | |
| 183 | } | |
| 184 | ||
| 185 | EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::IAPIds() | |
| 186 | {
 | |
| 187 | return iIapIdArray; | |
| 188 | } | |
| 189 | ||
| 190 | EXPORT_C CDesCArrayFlat* CPodcastModel::SNAPNames() | |
| 191 | {
 | |
| 192 | return iSNAPNameArray; | |
| 193 | } | |
| 194 | ||
| 195 | EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::SNAPIds() | |
| 196 | {
 | |
| 197 | return iSNAPIdArray; | |
| 198 | } | |
| 199 | ||
| 200 | ||
| 201 | RFs& CPodcastModel::FsSession() | |
| 202 | 	{
 | |
| 203 | return iFsSession; | |
| 204 | } | |
| 205 | ||
| 206 | EXPORT_C void CPodcastModel::SetPlayingPodcast(CShowInfo* aPodcast) | |
| 207 | {
 | |
| 208 | iPlayingPodcast = aPodcast; | |
| 209 | } | |
| 210 | ||
| 211 | EXPORT_C CShowInfo* CPodcastModel::PlayingPodcast() | |
| 212 | {
 | |
| 213 | return iPlayingPodcast; | |
| 214 | } | |
| 215 | ||
| 216 | EXPORT_C CFeedEngine& CPodcastModel::FeedEngine() | |
| 217 | {
 | |
| 218 | return *iFeedEngine; | |
| 219 | } | |
| 220 | ||
| 221 | EXPORT_C CShowEngine& CPodcastModel::ShowEngine() | |
| 222 | {
 | |
| 223 | return *iShowEngine; | |
| 224 | } | |
| 225 | ||
| 226 | EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine() | |
| 227 | {
 | |
| 228 | return *iSettingsEngine; | |
| 229 | } | |
| 230 | ||
| 231 | EXPORT_C CConnectionEngine& CPodcastModel::ConnectionEngine() | |
| 232 | {
 | |
| 233 | return *iConnectionEngine; | |
| 234 | } | |
| 235 | ||
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 236 | EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool /* aPlayOnInit */) | 
| 2 | 237 | 	{
 | 
| 134 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 238 | 	DP("CPodcastModel::PlayPausePodcastL BEGIN");
 | 
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 239 | TRAPD(err, LaunchFileEmbeddedL(aPodcast->FileName())); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 240 | |
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 241 | if (err == KErrNone) | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 242 | 		{
 | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 243 | aPodcast->SetPlayState(EPlayed); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 244 | iShowEngine->UpdateShowL(*aPodcast); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 245 | } | 
| 134 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 246 | else | 
| 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 247 | 		{
 | 
| 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 248 | User::Leave(err); | 
| 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 249 | } | 
| 
46baf9a7cadd
Fix for KErrCorrupted bug in ShowEngine; Capabilities added to allow interaction with music player and MPXCollection
 teknolog parents: 
133diff
changeset | 250 | 	DP("CPodcastModel::PlayPausePodcastL END");
 | 
| 2 | 251 | } | 
| 252 | ||
| 253 | EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo() | |
| 254 | {
 | |
| 255 | return iActiveFeed; | |
| 256 | } | |
| 257 | ||
| 258 | EXPORT_C void CPodcastModel::SetActiveFeedInfo(CFeedInfo* aFeedInfo) | |
| 259 | {
 | |
| 260 | iActiveFeed = aFeedInfo; | |
| 261 | } | |
| 262 | ||
| 263 | EXPORT_C RShowInfoArray& CPodcastModel::ActiveShowList() | |
| 264 | {
 | |
| 265 | return iActiveShowList; | |
| 266 | } | |
| 267 | ||
| 268 | void CPodcastModel::SetActiveShowList(RShowInfoArray& aShowArray) | |
| 269 | {
 | |
| 270 | iActiveShowList.ResetAndDestroy(); | |
| 271 | TInt cnt = aShowArray.Count(); | |
| 272 | ||
| 273 | for(TInt loop = 0;loop < cnt; loop++) | |
| 274 | 	{
 | |
| 275 | iActiveShowList.Append(aShowArray[loop]); | |
| 276 | } | |
| 277 | } | |
| 278 | ||
| 116 | 279 | EXPORT_C void CPodcastModel::DropDB() | 
| 109 | 280 | 	{
 | 
| 281 | if (iDB != NULL) | |
| 282 | 		{
 | |
| 283 | sqlite3_close(iDB); | |
| 284 | iDB = NULL; | |
| 285 | } | |
| 286 | ||
| 287 | TFileName dbFileName; | |
| 288 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | |
| 289 | dbFileName.Append(KDBFileName); | |
| 290 | ||
| 291 | // remove the old DB file | |
| 292 | if (BaflUtils::FileExists(iFsSession, dbFileName)) | |
| 293 | 		{
 | |
| 294 | BaflUtils::DeleteFile(iFsSession, dbFileName); | |
| 295 | } | |
| 110 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 296 | } | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 297 | |
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 298 | void CPodcastModel::ResetDB() | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 299 | 	{
 | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 300 | 	DP("CPodcastModel::ResetDB BEGIN");
 | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 301 | |
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 302 | DropDB(); | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 303 | |
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 304 | TFileName dbFileName; | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 305 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 306 | dbFileName.Append(KDBFileName); | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 307 | |
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 308 | // remove the old DB file | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 309 | if (BaflUtils::FileExists(iFsSession, dbFileName)) | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 310 | 		{
 | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 311 | BaflUtils::DeleteFile(iFsSession, dbFileName); | 
| 
403412eb5292
Added "Reset database" option in settings. Further robustness fixes for Feeds.
 teknolog parents: 
109diff
changeset | 312 | } | 
| 109 | 313 | |
| 282 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 314 | #ifdef ENABLE_MPX_INTEGRATION | 
| 109 | 315 | // copy template to new DB | 
| 316 | TFileName dbTemplate; | |
| 162 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 317 | TFileName temp; | 
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 318 | 	dbTemplate.Copy(_L("z:"));
 | 
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 319 | temp.Copy(iSettingsEngine->PrivatePath()); | 
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 320 | dbTemplate.Append(temp); | 
| 109 | 321 | dbTemplate.Append(KDBTemplateFileName); | 
| 282 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 322 | # else | 
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 323 | // copy template to new DB | 
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 324 | TFileName dbTemplate; | 
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 325 | dbTemplate.Copy(iSettingsEngine->PrivatePath()); | 
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 326 | dbTemplate.Append(KDBTemplateFileName); | 
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 327 | #endif | 
| 162 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 328 | |
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 329 | 	DP1("Copy template DB from: %S", &dbTemplate);
 | 
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 330 | 	DP1("Copy template DB to: %S", &dbFileName);
 | 
| 
d15654dbe9b8
Fix for bug 3169 - Podcatching failing to open due to missing DB
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
134diff
changeset | 331 | |
| 109 | 332 | BaflUtils::CopyFile(iFsSession, dbTemplate,dbFileName); | 
| 333 | iIsFirstStartup = ETrue; | |
| 334 | 	DP("CPodcastModel::ResetDB END");
 | |
| 335 | } | |
| 336 | ||
| 337 | ||
| 338 | void CPodcastModel::OpenDBL() | |
| 339 | 	{
 | |
| 340 | 	DP("CPodcastModel::OpenDBL BEGIN");
 | |
| 341 | ||
| 342 | if (iDB != NULL) | |
| 343 | 		{
 | |
| 344 | sqlite3_close(iDB); | |
| 345 | iDB = NULL; | |
| 346 | } | |
| 347 | ||
| 348 | TFileName dbFileName; | |
| 349 | dbFileName.Copy(iSettingsEngine->PrivatePath()); | |
| 350 | dbFileName.Append(KDBFileName); | |
| 282 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 351 | |
| 
cf3842290671
Fix for startup bug in Symbian 3 version; new SIS v 1.00.6
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
162diff
changeset | 352 | 	DP1("dbFileName=%S", &dbFileName);
 | 
| 109 | 353 | if (!BaflUtils::FileExists(iFsSession, dbFileName)) | 
| 354 | 		{
 | |
| 355 | User::Leave(KErrNotFound); | |
| 356 | } | |
| 357 | ||
| 358 | 	if (iDB == NULL) {	
 | |
| 359 | // open DB | |
| 360 | TBuf8<KMaxFileName> filename8; | |
| 361 | filename8.Copy(dbFileName); | |
| 362 | int rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); | |
| 363 | 		if(rc != SQLITE_OK){
 | |
| 364 | User::Leave(KErrCorrupt); | |
| 365 | } | |
| 366 | ||
| 367 | // do a test query | |
| 368 | sqlite3_stmt *st; | |
| 369 | rc = sqlite3_prepare_v2(iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); | |
| 370 | if( rc==SQLITE_OK ) | |
| 371 | 			{
 | |
| 372 | Cleanup_sqlite3_finalize_PushL(st); | |
| 373 | rc = sqlite3_step(st); | |
| 374 | ||
| 375 | if (rc != SQLITE_ROW) | |
| 376 | 				{
 | |
| 377 | User::Leave(KErrCorrupt); | |
| 378 | } | |
| 379 | CleanupStack::PopAndDestroy(); // st | |
| 380 | } | |
| 381 | else | |
| 382 | 			{
 | |
| 383 | User::Leave(KErrCorrupt); | |
| 384 | } | |
| 385 | } | |
| 386 | ||
| 387 | 	DP("CPodcastModel::OpenDBL END");	
 | |
| 388 | } | |
| 389 | ||
| 2 | 390 | sqlite3* CPodcastModel::DB() | 
| 391 | {
 | |
| 392 | return iDB; | |
| 393 | } | |
| 394 | ||
| 395 | void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) | |
| 396 | 	{
 | |
| 397 | TBool useProxy = EFalse; | |
| 398 | HBufC* serverName = NULL; | |
| 399 | TUint32 port = 0; | |
| 400 | ||
| 401 | TRAPD(err,GetProxyInformationForConnectionL(useProxy, serverName, port)); | |
| 402 | if (err == KErrNone && useProxy) | |
| 403 | 		{
 | |
| 404 | CleanupStack::PushL(serverName); | |
| 405 | TBuf8<128> proxyAddr; | |
| 406 | proxyAddr.Append(*serverName); | |
| 407 | 		proxyAddr.Append(':');
 | |
| 408 | proxyAddr.AppendNum(port); | |
| 409 | ||
| 410 | RStringF prxAddr = aSession.StringPool().OpenFStringL(proxyAddr); | |
| 411 | CleanupClosePushL(prxAddr); | |
| 412 | THTTPHdrVal prxUsage(aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); | |
| 413 | ||
| 414 | aSession.ConnectionInfo().SetPropertyL( | |
| 415 | aSession.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), | |
| 416 | aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); | |
| 417 | ||
| 418 | aSession.ConnectionInfo().SetPropertyL(aSession.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), prxAddr); | |
| 419 | ||
| 420 | CleanupStack::PopAndDestroy(&prxAddr); | |
| 421 | CleanupStack::PopAndDestroy(serverName); | |
| 422 | } | |
| 423 | } | |
| 424 | ||
| 425 | ||
| 426 | void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort) | |
| 427 | 	{
 | |
| 428 | TInt iapId = GetIapId(); | |
| 429 | CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId); | |
| 430 | ||
| 431 | TUint32 iapService; | |
| 432 | HBufC* iapServiceType; | |
| 433 | table->ReadUintL(TPtrC(IAP_SERVICE), iapService); | |
| 434 | iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE)); | |
| 435 | ||
| 436 | CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType); | |
| 437 | TInt err = proxyTableView->GotoFirstRecord(); | |
| 438 | if( err != KErrNone) | |
| 439 | 		{
 | |
| 440 | User::Leave(KErrNotFound); | |
| 441 | } | |
| 442 | ||
| 443 | proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed); | |
| 444 | if(aIsUsed) | |
| 445 | 		{
 | |
| 446 | HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); | |
| 447 | proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort); | |
| 448 | aProxyServerName = serverName->AllocL(); | |
| 449 | CleanupStack::PopAndDestroy(serverName); | |
| 450 | } | |
| 451 | ||
| 452 | CleanupStack::PopAndDestroy(proxyTableView); | |
| 453 | CleanupStack::PopAndDestroy(iapServiceType); | |
| 454 | CleanupStack::PopAndDestroy(table); | |
| 455 | } | |
| 456 | ||
| 457 | TInt CPodcastModel::GetIapId() | |
| 458 | 	{
 | |
| 459 | _LIT(KSetting, "IAP\\Id"); | |
| 460 | TUint32 iapId = 0; | |
| 461 | iConnectionEngine->Connection().GetIntSetting(KSetting, iapId); | |
| 462 | return iapId; | |
| 463 | } | |
| 464 | ||
| 8 | 465 | EXPORT_C void CPodcastModel::GetShowsDownloadingL() | 
| 2 | 466 | 	{
 | 
| 467 | iActiveShowList.ResetAndDestroy(); | |
| 8 | 468 | iShowEngine->GetShowsDownloadingL(iActiveShowList); | 
| 2 | 469 | } | 
| 470 | ||
| 8 | 471 | EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid) | 
| 2 | 472 | 	{
 | 
| 473 | iActiveShowList.ResetAndDestroy(); | |
| 126 | 474 | iShowEngine->DeleteOldShowsByFeedL(aFeedUid); | 
| 118 
b03018fb3418
Added method that checks for deleted downloaded files and updates DB accordingly
 teknolog parents: 
116diff
changeset | 475 | iShowEngine->CheckForDeletedShows(aFeedUid); | 
| 8 | 476 | iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); | 
| 2 | 477 | } | 
| 478 | ||
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
8diff
changeset | 479 | EXPORT_C void CPodcastModel::MarkSelectionPlayedL() | 
| 2 | 480 | 	{
 | 
| 481 | 	for (int i=0;i<iActiveShowList.Count();i++) {
 | |
| 482 | 		if(iActiveShowList[i]->PlayState() != EPlayed) {
 | |
| 483 | iActiveShowList[i]->SetPlayState(EPlayed); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
8diff
changeset | 484 | iShowEngine->UpdateShowL(*iActiveShowList[i]); | 
| 2 | 485 | } | 
| 486 | } | |
| 487 | } | |
| 488 | ||
| 489 | TInt CPodcastModel::FindActiveShowByUid(TUint aUid) | |
| 490 | 	{
 | |
| 491 | 	for (int i=0;i<iActiveShowList.Count();i++) {
 | |
| 492 | 		if (iActiveShowList[i]->Uid() == aUid) {
 | |
| 493 | return i; | |
| 494 | } | |
| 495 | } | |
| 496 | ||
| 497 | return KErrNotFound; | |
| 498 | } | |
| 499 | ||
| 500 | EXPORT_C TBool CPodcastModel::IsFirstStartup() | |
| 501 | 	{
 | |
| 502 | return iIsFirstStartup; | |
| 503 | } | |
| 504 | ||
| 505 | ||
| 93 
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
 Lars Persson <lars.persson@embeddev.se> parents: 
91diff
changeset | 506 | void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/, CPodcastModel& /*aPodcastModel*/) | 
| 2 | 507 | 	{
 | 
| 508 | ||
| 509 | } | |
| 510 | ||
| 511 | EXPORT_C CImageHandler& CPodcastModel::ImageHandler() | |
| 512 | 	{
 | |
| 513 | return *iImageHandler; | |
| 514 | } | |
| 133 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 515 | |
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 516 | void CPodcastModel::LaunchFileEmbeddedL(const TDesC& aFilename) | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 517 |     {
 | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 518 | //Set the exit observer so HandleServerAppExit will be called | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 519 | iDocHandler->SetExitObserver(this); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 520 | |
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 521 | TDataType emptyDataType = TDataType(); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 522 | //Open a file embedded | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 523 | iDocHandler->OpenFileEmbeddedL(aFilename, emptyDataType); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 524 | } | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 525 | |
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 526 | void CPodcastModel::HandleServerAppExit(TInt aReason) | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 527 |     {
 | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 528 | //Handle closing the handler application | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 529 | MAknServerAppExitObserver::HandleServerAppExit(aReason); | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 530 | } | 
| 
5f9e7e14eb11
Merged playback functionality from FCL Symbian1 branch
 teknolog parents: 
126diff
changeset | 531 |