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