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"
116
+ − 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);
109
+ − 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
102
+ − 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
+ − 96
IMPORT_C void OpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded);
93
bbf5c5204844
We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
diff
changeset
+ − 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
+ − 120
void NotifyOpmlParsingCompleteL(TInt aError, TUint aNumFeedsAdded);
2
+ − 121
+ − 122
+ − 123
private:
+ − 124
void DBLoadFeedsL();
109
+ − 125
void DBRemoveFeedL(TUint aUid);
+ − 126
void DBAddFeedL(const CFeedInfo& aTtem);
2
+ − 127
CFeedInfo* DBGetFeedInfoByUidL(TUint aFeedUid);
109
+ − 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;
102
+ − 149
RArray<TUint> iFeedsUpdating;
2
+ − 150
+ − 151
// observers that will receive callbacks, not owning
+ − 152
RArray<MFeedEngineObserver*> iObservers;
+ − 153
+ − 154
TBool iCatchupMode;
+ − 155
TUint iCatchupCounter;
+ − 156
+ − 157
sqlite3& iDB;
+ − 158
+ − 159
TBuf<KDefaultSQLDataBufferLength> iSqlBuffer;
+ − 160
+ − 161
COpmlParser* iOpmlParser;
+ − 162
RFeedInfoArray iSearchResults;
+ − 163
TBool iAutoUpdatedInitiator;
32
+ − 164
TBool iCancelRequested;
2
+ − 165
};
+ − 166
#endif /*FEEDENGINE_H_*/
+ − 167