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