author | Sebastian Brannstrom <sebastianb@symbian.org> |
Wed, 14 Jul 2010 14:53:21 +0100 | |
branch | 3rded |
changeset 179 | a14b0d78eda1 |
parent 176 | 1c8b56cb6409 |
child 191 | a452d138726a |
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" |
2 | 32 |
|
33 |
class CPodcastModel; |
|
34 |
class COpmlParser; |
|
35 |
||
36 |
_LIT(KOpmlFeed, " <outline title=\"%S\" description=\"%S\" xmlUrl=\"%S\" htmlUrl=\"%S\"/>"); |
|
37 |
_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>"); |
|
38 |
_LIT(KOpmlFooter, " </outline>\n</body>\n</opml>"); |
|
39 |
||
40 |
_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"); |
|
41 |
_LIT(KSearchResultsFileName, "searchresults.opml"); |
|
42 |
||
43 |
const TInt KMaxUidBufLen = 20; |
|
44 |
const TInt KMaxTitleLength = 512; |
|
45 |
const TInt KMaxDescriptionLength = 1024; |
|
46 |
const TInt KMaxURLLength = 512; |
|
47 |
const TInt KMaxLineLength = 4096; |
|
48 |
const TInt KMaxSearchString = 30; |
|
49 |
||
50 |
enum TClientState { |
|
51 |
EIdle, |
|
52 |
EUpdatingFeed, |
|
53 |
EUpdatingImage, |
|
54 |
ESearching |
|
55 |
}; |
|
56 |
||
57 |
class CFeedEngine : public CBase, public MHttpClientObserver, public MFeedParserObserver |
|
58 |
{ |
|
59 |
public: |
|
60 |
static CFeedEngine* NewL(CPodcastModel& aPodcastModel); |
|
61 |
virtual ~CFeedEngine(); |
|
62 |
||
63 |
public: |
|
64 |
IMPORT_C TBool AddFeedL(const CFeedInfo& item); |
|
65 |
IMPORT_C void ImportFeedsL(const TDesC& aFile); |
|
66 |
IMPORT_C TBool ExportFeedsL(TFileName& aFile); |
|
67 |
IMPORT_C void RemoveFeedL(TUint aUid); |
|
68 |
IMPORT_C TBool UpdateFeedL(TUint aFeedUid); |
|
69 |
IMPORT_C void UpdateAllFeedsL(TBool aAutoUpdate = EFalse); |
|
70 |
IMPORT_C void CancelUpdateAllFeeds(); |
|
71 |
IMPORT_C const RFeedInfoArray& GetSortedFeeds(); |
|
72 |
IMPORT_C CFeedInfo* GetFeedInfoByUid(TUint aFeedUid); |
|
60 | 73 |
IMPORT_C void GetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed); |
2 | 74 |
|
75 |
IMPORT_C void AddObserver(MFeedEngineObserver *observer); |
|
76 |
IMPORT_C void RemoveObserver(MFeedEngineObserver *observer); |
|
77 |
||
78 |
void RunFeedTimer(); |
|
79 |
||
60 | 80 |
IMPORT_C void UpdateFeedInfoL(CFeedInfo *aItem); |
2 | 81 |
/** |
82 |
* Returns the current internal state of the feed engine4 |
|
83 |
*/ |
|
84 |
IMPORT_C TClientState ClientState(); |
|
85 |
||
86 |
/** |
|
87 |
* Returns the current updating client UID if clientstate is != ENotUpdateing |
|
88 |
* @return TUint |
|
89 |
*/ |
|
90 |
IMPORT_C TUint ActiveClientUid(); |
|
91 |
||
92 |
IMPORT_C void SearchForFeedL(TDesC& aSearchString); |
|
93 |
IMPORT_C void AddSearchResultL(CFeedInfo *item); |
|
94 |
IMPORT_C const RFeedInfoArray& GetSearchResults(); |
|
95 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
7
diff
changeset
|
96 |
IMPORT_C void OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded); |
60 | 97 |
void NotifyFeedUpdateComplete(TInt aFeedUid, TInt aError); |
2 | 98 |
protected: |
99 |
||
100 |
static TInt CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b); |
|
101 |
||
102 |
private: |
|
103 |
void ConstructL(); |
|
104 |
CFeedEngine(CPodcastModel& aPodcastModel); |
|
105 |
||
106 |
// from HttpClientObserver |
|
107 |
void Connected(CHttpClient* aClient); |
|
108 |
void Disconnected(CHttpClient* aClient); |
|
109 |
void Progress(CHttpClient* aHttpClient, TInt aBytes, TInt aTotalBytes); |
|
110 |
void DownloadInfo(CHttpClient* aClient, TInt aSize); |
|
111 |
void CompleteL(CHttpClient* aClient, TInt aError); |
|
112 |
void FileError(TUint /*aError*/) { } |
|
113 |
// from FeedParser |
|
114 |
void NewShowL(CShowInfo& aItem); |
|
115 |
void ParsingCompleteL(CFeedInfo *aItem); |
|
116 |
||
117 |
void GetFeedImageL(CFeedInfo *aFeedInfo); |
|
118 |
||
119 |
void UpdateNextFeedL(); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
7
diff
changeset
|
120 |
void NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded); |
2 | 121 |
|
122 |
||
123 |
private: |
|
124 |
void DBLoadFeedsL(); |
|
60 | 125 |
void DBRemoveFeedL(TUint aUid); |
126 |
void DBAddFeedL(const CFeedInfo& aTtem); |
|
2 | 127 |
CFeedInfo* DBGetFeedInfoByUidL(TUint aFeedUid); |
60 | 128 |
TUint DBGetFeedCountL(); |
129 |
void DBUpdateFeedL(const CFeedInfo& aItem); |
|
130 |
void DBGetStatsByFeedL(TUint aFeedUid, TUint &aNumShows, TUint &aNumUnplayed); |
|
2 | 131 |
|
132 |
||
133 |
private: |
|
134 |
CHttpClient* iFeedClient; |
|
135 |
TClientState iClientState; |
|
136 |
CFeedTimer iFeedTimer; |
|
137 |
||
138 |
CPodcastModel& iPodcastModel; |
|
139 |
||
140 |
// RSS parser |
|
141 |
CFeedParser* iParser; |
|
142 |
||
143 |
// the list of feeds |
|
144 |
RFeedInfoArray iSortedFeeds; |
|
145 |
||
146 |
CFeedInfo *iActiveFeed; |
|
147 |
TFileName iUpdatingFeedFileName; |
|
148 |
TFileName iSearchResultsFileName; |
|
60 | 149 |
RArray<TUint> iFeedsUpdating; |
2 | 150 |
|
151 |
// observers that will receive callbacks, not owning |
|
152 |
RArray<MFeedEngineObserver*> iObservers; |
|
153 |
||
83
daef3a71bac5
Attempted fix for bug 2434; added KErrInUse leaves if update called when engine is in use
teknolog
parents:
65
diff
changeset
|
154 |
// 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
|
155 |
TBool newFeed; |
daef3a71bac5
Attempted fix for bug 2434; added KErrInUse leaves if update called when engine is in use
teknolog
parents:
65
diff
changeset
|
156 |
TUint showsAdded; |
2 | 157 |
|
158 |
sqlite3& iDB; |
|
159 |
||
160 |
TBuf<KDefaultSQLDataBufferLength> iSqlBuffer; |
|
161 |
||
162 |
COpmlParser* iOpmlParser; |
|
163 |
RFeedInfoArray iSearchResults; |
|
164 |
TBool iAutoUpdatedInitiator; |
|
32
26a3f2dfba08
Fix for bug where we always load the feed icon a large number of times
teknolog
parents:
7
diff
changeset
|
165 |
TBool iCancelRequested; |
2 | 166 |
}; |
167 |
#endif /*FEEDENGINE_H_*/ |
|
168 |