| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Thu, 22 Jul 2010 10:22:58 +0100 | |
| changeset 200 | 79076725bab9 | 
| parent 151 | 17da6d3a5a4b | 
| child 202 | e1dedb07817d | 
| 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 | #ifndef SHOWENGINE_H_ | |
| 20 | #define SHOWENGINE_H_ | |
| 21 | ||
| 22 | #include <e32base.h> | |
| 23 | #include <APGCLI.H> | |
| 24 | #include "constants.h" | |
| 25 | #include "ShowInfo.h" | |
| 26 | #include "PodcastModel.h" | |
| 27 | #include "HttpClient.h" | |
| 28 | #include "ShowEngineObserver.h" | |
| 29 | #include "MetaDataReader.h" | |
| 116 | 30 | #include <sqlite3.h> | 
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 31 | #ifdef ENABLE_MPX_INTEGRATION | 
| 126 | 32 | #include "mpxcollectionhelper.h" | 
| 33 | #include "mpxcollectionhelperobserver.h" | |
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 34 | #endif | 
| 2 | 35 | |
| 151 | 36 | struct TDownload | 
| 37 | 	{
 | |
| 38 | TUint iIndex; | |
| 39 | TUint iUid; | |
| 40 | }; | |
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 41 | #ifdef ENABLE_MPX_INTEGRATION | 
| 126 | 42 | class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver, | 
| 43 | public MMPXCollectionHelperObserver | |
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 44 | #else | 
| 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 45 | class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver | 
| 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 46 | #endif | 
| 2 | 47 | {
 | 
| 48 | public: | |
| 49 | IMPORT_C static CShowEngine* NewL(CPodcastModel& aPodcastModel); | |
| 50 | IMPORT_C virtual ~CShowEngine(); | |
| 51 | ||
| 52 | public: | |
| 53 | IMPORT_C void AddDownloadL(CShowInfo& info); | |
| 111 | 54 | IMPORT_C void RemoveDownloadL(TUint aUid); | 
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
2diff
changeset | 55 | IMPORT_C void RemoveAllDownloadsL(); | 
| 2 | 56 | |
| 57 | IMPORT_C void SuspendDownloads(); | |
| 58 | IMPORT_C void ResumeDownloadsL(); | |
| 59 | ||
| 60 | IMPORT_C TInt GetNumDownloadingShows(); | |
| 61 | IMPORT_C CShowInfo* ShowDownloading(); | |
| 62 | IMPORT_C CShowInfo* GetShowByUidL(TUint aShowUid); | |
| 63 | IMPORT_C CShowInfo* GetNextShowByTrackL(CShowInfo* aShowInfo); | |
| 64 | ||
| 65 | // show access methods | |
| 66 | IMPORT_C void GetAllShowsL(RShowInfoArray &aArray); | |
| 67 | IMPORT_C void GetShowsByFeedL(RShowInfoArray &aArray, TUint aFeedUid); | |
| 68 | IMPORT_C void GetShowsDownloadedL(RShowInfoArray &aArray); | |
| 69 | IMPORT_C void GetNewShowsL(RShowInfoArray &aArray); | |
| 70 | IMPORT_C void GetShowsDownloadingL(RShowInfoArray &aArray); | |
| 71 | IMPORT_C CShowInfo* DBGetShowByFileNameL(TFileName aFileName); | |
| 72 | ||
| 111 | 73 | IMPORT_C void AddShowL(const CShowInfo& item); | 
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
2diff
changeset | 74 | IMPORT_C void DeletePlayedShowsL(RShowInfoArray &aShowInfoArray); | 
| 2 | 75 | IMPORT_C void DeleteAllShowsByFeedL(TUint aFeedUid,TBool aDeleteFiles=ETrue); | 
| 76 | IMPORT_C void DeleteShowL(TUint aShowUid, TBool aRemoveFile=ETrue); | |
| 111 | 77 | IMPORT_C void DeleteOldShowsByFeedL(TUint aFeedUid); | 
| 2 | 78 | |
| 79 | IMPORT_C void AddObserver(MShowEngineObserver *observer); | |
| 80 | IMPORT_C void RemoveObserver(MShowEngineObserver *observer); | |
| 81 | ||
| 82 | IMPORT_C void NotifyShowListUpdatedL(); | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
2diff
changeset | 83 | IMPORT_C void UpdateShowL(CShowInfo& aInfo); | 
| 2 | 84 | |
| 85 | IMPORT_C void GetMimeType(const TDesC& aFileName, TDes& aMimeType); | |
| 86 | ||
| 118 
b03018fb3418
Added method that checks for deleted downloaded files and updates DB accordingly
 teknolog parents: 
116diff
changeset | 87 | IMPORT_C void CheckForDeletedShows(TUint aFeedUid); | 
| 2 | 88 | IMPORT_C CMetaDataReader& MetaDataReader(); | 
| 151 | 89 | IMPORT_C void MoveDownloadUpL(TUint aUid); | 
| 90 | IMPORT_C void MoveDownloadDownL(TUint aUid); | |
| 2 | 91 | |
| 92 | private: | |
| 93 | // from HttpClientObserver, dont have to be public | |
| 94 | void Connected(CHttpClient* aClient); | |
| 95 | void Disconnected(CHttpClient* aClient); | |
| 96 | void CompleteL(CHttpClient* aClient, TInt aError); | |
| 97 | void Progress(CHttpClient* aHttpClient, int aBytes, int aTotalBytes); | |
| 98 | void DownloadInfo(CHttpClient* aClient, int aSize); | |
| 99 | void FileError(TUint aError); | |
| 100 | // from MetaDataReaderObserver | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
2diff
changeset | 101 | void ReadMetaDataL(CShowInfo& aShowInfo); | 
| 2 | 102 | void ReadMetaDataCompleteL(); | 
| 126 | 103 | // from MMPXCollectionHelperObserver | 
| 104 |     void HandleAddFileCompleteL( TInt /*aErr*/ ) {}  
 | |
| 105 | ||
| 2 | 106 | private: | 
| 107 | CShowEngine(CPodcastModel& aPodcastModel); | |
| 108 | void ConstructL(); | |
| 109 | ||
| 111 | 110 | void GetShowL(CShowInfo *info); | 
| 2 | 111 | |
| 112 | void NotifyDownloadQueueUpdatedL(); | |
| 113 | void NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal); | |
| 114 | void NotifyShowFinishedL(TInt aError); | |
| 115 | void DownloadNextShowL(); | |
| 116 | ||
| 117 | static TInt CompareShowsByDate(const CShowInfo &a, const CShowInfo &b); | |
| 118 | static TBool CompareShowsByUid(const CShowInfo &a, const CShowInfo &b); | |
| 119 | static TInt CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b); | |
| 120 | static TInt CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b); | |
| 121 | ||
| 122 | void AddShowToMpxCollection(CShowInfo &aShowInfo); | |
| 123 | ||
| 124 | private: | |
| 125 | // DB methods | |
| 126 | CShowInfo* DBGetShowByUidL(TUint aUid); | |
| 127 | void DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo); | |
| 111 | 128 | void DBAddShowL(const CShowInfo& aItem); | 
| 129 | void DBUpdateShowL(CShowInfo& aItem); | |
| 2 | 130 | void DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid); | 
| 131 | void DBGetAllShowsL(RShowInfoArray& aShowArray); | |
| 132 | void DBGetNewShowsL(RShowInfoArray& aShowArray); | |
| 133 | void DBGetDownloadedShowsL(RShowInfoArray& aShowArray); | |
| 111 | 134 | void DBDeleteAllShowsByFeedL(TUint aFeedUid); | 
| 135 | void DBDeleteOldShowsByFeedL(TUint aFeedUid); | |
| 136 | void DBDeleteShowL(TUint aUid); | |
| 137 | void DBRemoveAllDownloadsL(); | |
| 138 | void DBRemoveDownloadL(TUint aUid); | |
| 2 | 139 | void DBGetAllDownloadsL(RShowInfoArray& aShowArray); | 
| 111 | 140 | TUint DBGetDownloadsCountL(); | 
| 141 | void DBAddDownloadL(TUint aUid); | |
| 2 | 142 | CShowInfo* DBGetNextDownloadL(); | 
| 151 | 143 | void DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL); | 
| 2 | 144 | |
| 145 | private: | |
| 146 | CHttpClient* iShowClient; | |
| 147 | ||
| 148 | CPodcastModel& iPodcastModel; | |
| 149 | ||
| 150 | // observers that will receive callbacks | |
| 151 | RArray<MShowEngineObserver*> iObservers; | |
| 152 | ||
| 153 | // The show we are currently downloading | |
| 154 | CShowInfo* iShowDownloading; | |
| 155 | TUint iDownloadErrors; | |
| 156 | ||
| 157 | CMetaDataReader* iMetaDataReader; | |
| 158 | ||
| 159 | RApaLsSession iApaSession; | |
| 160 | TBuf8<512> iRecogBuffer; | |
| 161 | ||
| 162 | sqlite3& iDB; | |
| 163 | TBuf<KDefaultSQLDataBufferLength> iSqlBuffer; | |
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 164 | #ifdef ENABLE_MPX_INTEGRATION | 
| 126 | 165 | MMPXCollectionHelper* iCollectionHelper; | 
| 200 
79076725bab9
Added #define to enable/disable MPX integration, since it requires capabilities that can't be granted when self signed
 Sebastian Brannstrom <sebastianb@symbian.org> parents: 
151diff
changeset | 166 | #endif | 
| 2 | 167 | }; | 
| 168 | ||
| 169 | #endif /*SHOWENGINE_H_*/ | |
| 170 |