Slight refactoring

This commit is contained in:
Jaidyn Ann 2020-08-14 14:00:07 -05:00
parent 69e1a3085c
commit b5f0d5bab8
4 changed files with 23 additions and 20 deletions

View File

@ -25,25 +25,19 @@ AtomFeed::AtomFeed ( Config* cfg ) : AtomFeed::AtomFeed( )
void
AtomFeed::Parse ( Config* cfg )
{
BFile* feedFile = new BFile( filePath.String(), B_READ_ONLY );
entries = BList();
tinyxml2::XMLDocument xml;
xml.LoadFile( filePath.String() );
time_t tt_lastDate = 0;
BDateTime attrLastDate = BDateTime();
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
if ( tt_lastDate > 0 && cfg->updateFeeds == true ) {
attrLastDate.SetTime_t( tt_lastDate );
minDate = attrLastDate;
}
Feed::Parse( cfg );
tinyxml2::XMLElement* xfeed = xml.FirstChildElement("feed");
RootParse( cfg, xfeed );
ParseEntries( cfg, xfeed );
tt_lastDate = lastDate.Time_t();
BFile* feedFile = new BFile( filePath.String(), B_READ_WRITE );
time_t tt_lastDate = lastDate.Time_t();
feedFile->WriteAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
}

View File

@ -24,6 +24,22 @@ Feed::Feed ( )
// ----------------------------------------------------------------------------
void
Feed::Parse ( Config* cfg )
{
BFile* feedFile = new BFile( filePath.String(), B_READ_ONLY );
time_t tt_lastDate = 0;
BDateTime attrLastDate = BDateTime();
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
if ( tt_lastDate > 0 && cfg->updateFeeds == true ) {
attrLastDate.SetTime_t( tt_lastDate );
minDate = attrLastDate;
}
}
// -------------------------------------
BString
Feed::GetCachePath ( BString givenPath, Config* cfg )
{

View File

@ -27,7 +27,7 @@ public:
BList entries;
bool updated;
void Parse ( Config* );
virtual void Parse ( Config* );
bool AddEntry ( Config*, Entry* );
bool SetTitle ( const char* );

View File

@ -25,18 +25,10 @@ RssFeed::RssFeed ( Config* cfg ) : RssFeed::RssFeed( )
void
RssFeed::Parse ( Config* cfg )
{
BFile* feedFile = new BFile( filePath.String(), B_READ_ONLY );
tinyxml2::XMLDocument xml;
entries = BList();
time_t tt_lastDate = 0;
BDateTime attrLastDate = BDateTime();
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
if ( tt_lastDate > 0 && cfg->updateFeeds == true ) {
attrLastDate.SetTime_t( tt_lastDate );
minDate = attrLastDate;
}
Feed::Parse( cfg );
xml.LoadFile( filePath.String() );
tinyxml2::XMLElement* xchan = xml.FirstChildElement("rss")->FirstChildElement("channel");
@ -44,7 +36,8 @@ RssFeed::Parse ( Config* cfg )
RootParse( cfg, xchan );
ParseEntries( cfg, xchan );
tt_lastDate = lastDate.Time_t();
time_t tt_lastDate = lastDate.Time_t();
BFile* feedFile = new BFile( filePath.String(), B_READ_ONLY );
feedFile->WriteAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
}