author | Sebastian Brannstrom <sebastianb@symbian.org> |
Thu, 21 Oct 2010 21:36:03 +0100 | |
branch | 3rded |
changeset 262 | 81bb9210fd4c |
parent 191 | a452d138726a |
child 343 | 9c56bf585696 |
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 FEEDENGINE_H_ |
|
20 |
#define FEEDENGINE_H_ |
|
21 |
||
22 |
#include "HttpClientObserver.h" |
|
23 |
#include "HttpClient.h" |
|
24 |
#include "FeedParser.h" |
|
25 |
#include "FeedInfo.h" |
|
26 |
#include "ShowInfo.h" |
|
27 |
#include <e32cmn.h> |
|
28 |
#include "Constants.h" |
|
29 |
#include "FeedEngineObserver.h" |
|
30 |
#include "FeedTimer.h" |
|
176
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
83
diff
changeset
|
31 |
#include "sqlite3.h" |
191
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
32 |
#include <centralrepository.h> |
2 | 33 |
|
34 |
class CPodcastModel; |
|
35 |
class COpmlParser; |
|
36 |
||
37 |
_LIT(KOpmlFeed, " <outline title=\"%S\" description=\"%S\" xmlUrl=\"%S\" htmlUrl=\"%S\"/>"); |
|
38 |
_LIT(KOpmlHeader, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<opml version=\"1.1\" xmlns:podcastSearch=\"http://digitalpodcast.com/podcastsearchservice/output_specs.html\">\n<head>\n <title>Podcast Feed List</title>\n</head>\n<body>\n <outline>"); |
|
39 |
_LIT(KOpmlFooter, " </outline>\n</body>\n</opml>"); |
|
40 |
||
41 |
_LIT(KSearchUrl, "http://www.digitalpodcast.com/podcastsearchservice/v2b/search/?appid=SymbianPodcatcher&keywords=%S&format=rssopml&sort=rel&searchsource=all&contentfilter=noadult&start=0&results=20"); |
|
42 |
_LIT(KSearchResultsFileName, "searchresults.opml"); |
|
43 |
||
44 |
const TInt KMaxUidBufLen = 20; |
|
45 |
const TInt KMaxTitleLength = 512; |
|
46 |
const TInt KMaxDescriptionLength = 1024; |
|
47 |
const TInt KMaxURLLength = 512; |
|
48 |
const TInt KMaxLineLength = 4096; |
|
49 |
const TInt KMaxSearchString = 30; |
|
50 |
||
51 |
enum TClientState { |
|
52 |
EIdle, |
|
53 |
EUpdatingFeed, |
|
54 |
EUpdatingImage, |
|
55 |
ESearching |
|
56 |
}; |
|
57 |
||
191
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
58 |
|
2 | 59 |
class CFeedEngine : public CBase, public MHttpClientObserver, public MFeedParserObserver |
60 |
{ |
|
61 |
public: |
|
62 |
static CFeedEngine* NewL(CPodcastModel& aPodcastModel); |
|
63 |
virtual ~CFeedEngine(); |
|
64 |
||
65 |
public: |
|
66 |
IMPORT_C TBool AddFeedL(const CFeedInfo& item); |
|
67 |
IMPORT_C void ImportFeedsL(const TDesC& aFile); |
|
68 |
IMPORT_C TBool ExportFeedsL(TFileName& aFile); |
|
69 |
IMPORT_C void RemoveFeedL(TUint aUid); |
|
70 |
IMPORT_C TBool UpdateFeedL(TUint aFeedUid); |
|
71 |
IMPORT_C void UpdateAllFeedsL(TBool aAutoUpdate = EFalse); |
|
72 |
IMPORT_C void CancelUpdateAllFeeds(); |
|
73 |
IMPORT_C const RFeedInfoArray& GetSortedFeeds(); |
|
74 |
IMPORT_C CFeedInfo* GetFeedInfoByUid(TUint aFeedUid); |
|
60 | 75 |
IMPORT_C void GetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed); |
2 | 76 |
|
77 |
IMPORT_C void AddObserver(MFeedEngineObserver *observer); |
|
78 |
IMPORT_C void RemoveObserver(MFeedEngineObserver *observer); |
|
79 |
||
80 |
void RunFeedTimer(); |
|
81 |
||
60 | 82 |
IMPORT_C void UpdateFeedInfoL(CFeedInfo *aItem); |
2 | 83 |
/** |
84 |
* Returns the current internal state of the feed engine4 |
|
85 |
*/ |
|
86 |
IMPORT_C TClientState ClientState(); |
|
87 |
||
88 |
/** |
|
89 |
* Returns the current updating client UID if clientstate is != ENotUpdateing |
|
90 |
* @return TUint |
|
91 |
*/ |
|
92 |
IMPORT_C TUint ActiveClientUid(); |
|
93 |
||
94 |
IMPORT_C void SearchForFeedL(TDesC& aSearchString); |
|
95 |
IMPORT_C void AddSearchResultL(CFeedInfo *item); |
|
96 |
IMPORT_C const RFeedInfoArray& GetSearchResults(); |
|
97 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
7
diff
changeset
|
98 |
IMPORT_C void OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded); |
60 | 99 |
void NotifyFeedUpdateComplete(TInt aFeedUid, TInt aError); |
191
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
100 |
|
2 | 101 |
protected: |
102 |
||
103 |
static TInt CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b); |
|
104 |
||
105 |
private: |
|
106 |
void ConstructL(); |
|
107 |
CFeedEngine(CPodcastModel& aPodcastModel); |
|
108 |
||
109 |
// from HttpClientObserver |
|
110 |
void Connected(CHttpClient* aClient); |
|
111 |
void Disconnected(CHttpClient* aClient); |
|
112 |
void Progress(CHttpClient* aHttpClient, TInt aBytes, TInt aTotalBytes); |
|
113 |
void DownloadInfo(CHttpClient* aClient, TInt aSize); |
|
114 |
void CompleteL(CHttpClient* aClient, TInt aError); |
|
115 |
void FileError(TUint /*aError*/) { } |
|
116 |
// from FeedParser |
|
117 |
void NewShowL(CShowInfo& aItem); |
|
118 |
void ParsingCompleteL(CFeedInfo *aItem); |
|
119 |
||
120 |
void GetFeedImageL(CFeedInfo *aFeedInfo); |
|
121 |
||
122 |
void UpdateNextFeedL(); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
7
diff
changeset
|
123 |
void NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded); |
2 | 124 |
|
125 |
||
126 |
private: |
|
127 |
void DBLoadFeedsL(); |
|
60 | 128 |
void DBRemoveFeedL(TUint aUid); |
129 |
void DBAddFeedL(const CFeedInfo& aTtem); |
|
2 | 130 |
CFeedInfo* DBGetFeedInfoByUidL(TUint aFeedUid); |
60 | 131 |
TUint DBGetFeedCountL(); |
132 |
void DBUpdateFeedL(const CFeedInfo& aItem); |
|
133 |
void DBGetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed); |
|
2 | 134 |
|
135 |
||
136 |
private: |
|
137 |
CHttpClient* iFeedClient; |
|
138 |
TClientState iClientState; |
|
139 |
CFeedTimer iFeedTimer; |
|
140 |
||
141 |
CPodcastModel& iPodcastModel; |
|
142 |
||
143 |
// RSS parser |
|
144 |
CFeedParser* iParser; |
|
145 |
||
146 |
// the list of feeds |
|
147 |
RFeedInfoArray iSortedFeeds; |
|
148 |
||
149 |
CFeedInfo *iActiveFeed; |
|
150 |
TFileName iUpdatingFeedFileName; |
|
151 |
TFileName iSearchResultsFileName; |
|
60 | 152 |
RArray<TUint> iFeedsUpdating; |
2 | 153 |
|
154 |
// observers that will receive callbacks, not owning |
|
155 |
RArray<MFeedEngineObserver*> iObservers; |
|
156 |
||
83
daef3a71bac5
Attempted fix for bug 2434; added KErrInUse leaves if update called when engine is in use
teknolog
parents:
65
diff
changeset
|
157 |
// new feeds only add one show to download list when auto downloading |
daef3a71bac5
Attempted fix for bug 2434; added KErrInUse leaves if update called when engine is in use
teknolog
parents:
65
diff
changeset
|
158 |
TBool newFeed; |
daef3a71bac5
Attempted fix for bug 2434; added KErrInUse leaves if update called when engine is in use
teknolog
parents:
65
diff
changeset
|
159 |
TUint showsAdded; |
2 | 160 |
|
191
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
161 |
// offline mode detection |
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
162 |
CRepository* iRepository; |
a452d138726a
Merged Jakl's fix for 2716
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
163 |
|
2 | 164 |
sqlite3& iDB; |
165 |
||
166 |
TBuf<KDefaultSQLDataBufferLength> iSqlBuffer; |
|
167 |
||
168 |
COpmlParser* iOpmlParser; |
|
169 |
RFeedInfoArray iSearchResults; |
|
170 |
TBool iAutoUpdatedInitiator; |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
7
diff
changeset
|
171 |
TBool iCancelRequested; |
2 | 172 |
}; |
173 |
#endif /*FEEDENGINE_H_*/ |
|
174 |