| author | Sebastian Brannstrom <sebastianb@symbian.org> | 
| Fri, 22 Oct 2010 14:28:27 +0100 | |
| branch | symbian1 | 
| changeset 266 | ff6cd24e77e2 | 
| parent 148 | e3f9b65d6910 | 
| child 176 | 1c8b56cb6409 | 
| child 336 | 3d6c1417e8bd | 
| 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" | |
| 60 | 30 | #include <sqlite3.h> | 
| 2 | 31 | |
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 32 | struct TDownload | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 33 | 	{
 | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 34 | TUint iIndex; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 35 | TUint iUid; | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 36 | }; | 
| 147 | 37 | |
| 130 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 38 | typedef enum TShowFilter | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 39 | 	{
 | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 40 | EAllShows, | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 41 | ENewShows, | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 42 | EDownloadedShows, | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 43 | ENewAndDownloadedShows | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 44 | }; | 
| 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 45 | |
| 2 | 46 | class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver | 
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 47 | 	{
 | 
| 2 | 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); | |
| 60 | 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 | ||
| 60 | 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); | |
| 60 | 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 | ||
| 60 | 87 | IMPORT_C void CheckForDeletedShows(TUint aFeedUid); | 
| 2 | 88 | IMPORT_C CMetaDataReader& MetaDataReader(); | 
| 130 
92572a695a1d
Added new experimental feature to show only new and downloaded shows; Updated SIS files
 teknolog parents: 
65diff
changeset | 89 | IMPORT_C void SetShowFilter(TShowFilter aFilter); | 
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 90 | IMPORT_C void MoveDownloadUpL(TUint aUid); | 
| 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 91 | IMPORT_C void MoveDownloadDownL(TUint aUid); | 
| 2 | 92 | |
| 93 | private: | |
| 94 | // from HttpClientObserver, dont have to be public | |
| 95 | void Connected(CHttpClient* aClient); | |
| 96 | void Disconnected(CHttpClient* aClient); | |
| 97 | void CompleteL(CHttpClient* aClient, TInt aError); | |
| 98 | void Progress(CHttpClient* aHttpClient, int aBytes, int aTotalBytes); | |
| 99 | void DownloadInfo(CHttpClient* aClient, int aSize); | |
| 100 | void FileError(TUint aError); | |
| 101 | // from MetaDataReaderObserver | |
| 35 
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
 Brendan Donegan <brendand@symbian.org> parents: 
2diff
changeset | 102 | void ReadMetaDataL(CShowInfo& aShowInfo); | 
| 2 | 103 | void ReadMetaDataCompleteL(); | 
| 104 | ||
| 105 | private: | |
| 106 | CShowEngine(CPodcastModel& aPodcastModel); | |
| 107 | void ConstructL(); | |
| 108 | ||
| 60 | 109 | void GetShowL(CShowInfo *info); | 
| 2 | 110 | |
| 111 | void NotifyDownloadQueueUpdatedL(); | |
| 112 | void NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal); | |
| 113 | void NotifyShowFinishedL(TInt aError); | |
| 114 | void DownloadNextShowL(); | |
| 115 | ||
| 116 | static TInt CompareShowsByDate(const CShowInfo &a, const CShowInfo &b); | |
| 117 | static TBool CompareShowsByUid(const CShowInfo &a, const CShowInfo &b); | |
| 118 | static TInt CompareShowsByTitle(const CShowInfo &a, const CShowInfo &b); | |
| 119 | static TInt CompareShowsByTrackNo(const CShowInfo &a, const CShowInfo &b); | |
| 120 | ||
| 121 | void AddShowToMpxCollection(CShowInfo &aShowInfo); | |
| 122 | ||
| 123 | private: | |
| 124 | // DB methods | |
| 125 | CShowInfo* DBGetShowByUidL(TUint aUid); | |
| 126 | void DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo); | |
| 60 | 127 | void DBAddShowL(const CShowInfo& aItem); | 
| 128 | void DBUpdateShowL(CShowInfo& aItem); | |
| 2 | 129 | void DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid); | 
| 130 | void DBGetAllShowsL(RShowInfoArray& aShowArray); | |
| 131 | void DBGetNewShowsL(RShowInfoArray& aShowArray); | |
| 132 | void DBGetDownloadedShowsL(RShowInfoArray& aShowArray); | |
| 60 | 133 | void DBDeleteAllShowsByFeedL(TUint aFeedUid); | 
| 134 | void DBDeleteOldShowsByFeedL(TUint aFeedUid); | |
| 135 | void DBDeleteShowL(TUint aUid); | |
| 136 | void DBRemoveAllDownloadsL(); | |
| 137 | void DBRemoveDownloadL(TUint aUid); | |
| 2 | 138 | void DBGetAllDownloadsL(RShowInfoArray& aShowArray); | 
| 60 | 139 | TUint DBGetDownloadsCountL(); | 
| 140 | void DBAddDownloadL(TUint aUid); | |
| 2 | 141 | CShowInfo* DBGetNextDownloadL(); | 
| 145 
cc0182a5da39
Fix for Bug 2604 and bulk of the work towards implementing Bug 2737
 Brendan Donegan <brendand@symbian.org> parents: 
65diff
changeset | 142 | void DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL); | 
| 2 | 143 | |
| 144 | private: | |
| 145 | CHttpClient* iShowClient; | |
| 146 | ||
| 147 | CPodcastModel& iPodcastModel; | |
| 148 | ||
| 149 | // observers that will receive callbacks | |
| 147 | 150 | RArray<MShowEngineObserver*> iObservers; | 
| 2 | 151 | |
| 152 | // The show we are currently downloading | |
| 153 | CShowInfo* iShowDownloading; | |
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 154 | TUint iDownloadErrors; | 
| 2 | 155 | |
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 156 | CMetaDataReader* iMetaDataReader; | 
| 2 | 157 | |
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 158 | RApaLsSession iApaSession; | 
| 2 | 159 | TBuf8<512> iRecogBuffer; | 
| 160 | ||
| 161 | sqlite3& iDB; | |
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 162 | TBuf<KDefaultSQLDataBufferLength> iSqlBuffer; | 
| 147 | 163 | TShowFilter iShowFilter; | 
| 148 
e3f9b65d6910
Cleanup from the merge
 Brendan Donegan <brendand@symbian.org> parents: 
147diff
changeset | 164 | }; | 
| 2 | 165 | |
| 166 | #endif /*SHOWENGINE_H_*/ | |
| 167 |