New constructors; make Feeds' minDate and maxDate local
This commit is contained in:
parent
956d7786af
commit
69e1a3085c
|
@ -4,16 +4,22 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "AtomFeed.h"
|
#include "AtomFeed.h"
|
||||||
|
|
||||||
AtomFeed::AtomFeed ( BString path, Config* cfg )
|
AtomFeed::AtomFeed ( )
|
||||||
{
|
{
|
||||||
title = BString("Untitled Feed");
|
title = BString("Untitled Feed");
|
||||||
description = BString("");
|
description = BString("");
|
||||||
homeUrl = BString("");
|
homeUrl = BString("");
|
||||||
xmlUrl = BString("");
|
xmlUrl = BString("");
|
||||||
filePath = path;
|
filePath = BString("");
|
||||||
outputDir = cfg->outDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtomFeed::AtomFeed ( Feed* feed ) : AtomFeed::AtomFeed()
|
||||||
|
{ filePath = feed->filePath; }
|
||||||
|
AtomFeed::AtomFeed ( Feed* feed, Config* cfg ) : AtomFeed::AtomFeed( feed )
|
||||||
|
{ outputDir = cfg->outDir; }
|
||||||
|
AtomFeed::AtomFeed ( Config* cfg ) : AtomFeed::AtomFeed( )
|
||||||
|
{ outputDir = cfg->outDir; }
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -27,9 +33,9 @@ AtomFeed::Parse ( Config* cfg )
|
||||||
BDateTime attrLastDate = BDateTime();
|
BDateTime attrLastDate = BDateTime();
|
||||||
|
|
||||||
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
||||||
if ( tt_lastDate > 0 && cfg->minDate == NULL && cfg->updateFeeds == true ) {
|
if ( tt_lastDate > 0 && cfg->updateFeeds == true ) {
|
||||||
attrLastDate.SetTime_t( tt_lastDate );
|
attrLastDate.SetTime_t( tt_lastDate );
|
||||||
cfg->minDate = attrLastDate;
|
minDate = attrLastDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement* xfeed = xml.FirstChildElement("feed");
|
tinyxml2::XMLElement* xfeed = xml.FirstChildElement("feed");
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
|
|
||||||
class AtomFeed: public Feed {
|
class AtomFeed: public Feed {
|
||||||
public:
|
public:
|
||||||
AtomFeed ( BString, Config* );
|
AtomFeed ( );
|
||||||
|
AtomFeed ( Feed*, Config* );
|
||||||
|
AtomFeed ( Feed* );
|
||||||
|
AtomFeed ( Config* );
|
||||||
|
|
||||||
void Parse ( Config* );
|
void Parse ( Config* );
|
||||||
void RootParse ( Config*, tinyxml2::XMLElement* );
|
void RootParse ( Config*, tinyxml2::XMLElement* );
|
||||||
|
|
|
@ -9,6 +9,15 @@ Config::Config () {
|
||||||
updateFeeds = false;
|
updateFeeds = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config::Config ( Config* cfg ) {
|
||||||
|
verbose = cfg->verbose;
|
||||||
|
daemon = cfg->daemon;
|
||||||
|
will_save = cfg->will_save;
|
||||||
|
updateFeeds = cfg->updateFeeds;
|
||||||
|
minDate = cfg->minDate;
|
||||||
|
maxDate = cfg->maxDate;
|
||||||
|
}
|
||||||
|
|
||||||
// !! handle file status
|
// !! handle file status
|
||||||
void
|
void
|
||||||
Config::Load ()
|
Config::Load ()
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public:
|
public:
|
||||||
|
Config ( );
|
||||||
|
Config ( Config* );
|
||||||
|
|
||||||
bool verbose;
|
bool verbose;
|
||||||
bool daemon;
|
bool daemon;
|
||||||
BString outDir;
|
BString outDir;
|
||||||
|
@ -21,8 +24,6 @@ public:
|
||||||
|
|
||||||
bool updateFeeds;
|
bool updateFeeds;
|
||||||
|
|
||||||
Config ( );
|
|
||||||
|
|
||||||
void Load ( );
|
void Load ( );
|
||||||
void Save ( );
|
void Save ( );
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,7 +113,8 @@ Feed::xmlCountSiblings ( tinyxml2::XMLElement* xsibling, const char* sibling_nam
|
||||||
bool
|
bool
|
||||||
Feed::AddEntry ( Config* cfg, Entry* newEntry )
|
Feed::AddEntry ( Config* cfg, Entry* newEntry )
|
||||||
{
|
{
|
||||||
if ( !withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) )
|
if ( !withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) ||
|
||||||
|
!withinDateRange( minDate, newEntry->date, maxDate ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( cfg->verbose == true )
|
if ( cfg->verbose == true )
|
||||||
|
|
|
@ -18,6 +18,8 @@ public:
|
||||||
BString description;
|
BString description;
|
||||||
BDateTime date;
|
BDateTime date;
|
||||||
BDateTime lastDate;
|
BDateTime lastDate;
|
||||||
|
BDateTime minDate;
|
||||||
|
BDateTime maxDate;
|
||||||
BString homeUrl;
|
BString homeUrl;
|
||||||
BString xmlUrl;
|
BString xmlUrl;
|
||||||
BString filePath;
|
BString filePath;
|
||||||
|
|
|
@ -149,15 +149,18 @@ processFeed ( void* feedArg )
|
||||||
Feed* testFeed = new Feed( *(feedStr), main_cfg );
|
Feed* testFeed = new Feed( *(feedStr), main_cfg );
|
||||||
BList entries;
|
BList entries;
|
||||||
|
|
||||||
|
if ( testFeed->updated == false && main_cfg->updateFeeds == true )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( testFeed->IsAtom() ) {
|
if ( testFeed->IsAtom() ) {
|
||||||
AtomFeed* feed = (AtomFeed*)malloc( sizeof(AtomFeed) );
|
AtomFeed* feed = (AtomFeed*)malloc( sizeof(AtomFeed) );
|
||||||
feed = new AtomFeed( testFeed->filePath, main_cfg );
|
feed = new AtomFeed( testFeed, main_cfg );
|
||||||
feed->Parse(main_cfg);
|
feed->Parse(main_cfg);
|
||||||
entries = feed->entries;
|
entries = feed->entries;
|
||||||
}
|
}
|
||||||
if ( testFeed->IsRss() ) {
|
if ( testFeed->IsRss() ) {
|
||||||
RssFeed* feed = (RssFeed*)malloc( sizeof(RssFeed) );
|
RssFeed* feed = (RssFeed*)malloc( sizeof(RssFeed) );
|
||||||
feed = new RssFeed( testFeed->filePath, main_cfg );
|
feed = new RssFeed( testFeed, main_cfg );
|
||||||
feed->Parse(main_cfg);
|
feed->Parse(main_cfg);
|
||||||
entries = feed->entries;
|
entries = feed->entries;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,22 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "RssFeed.h"
|
#include "RssFeed.h"
|
||||||
|
|
||||||
RssFeed::RssFeed ( BString path, Config* cfg )
|
RssFeed::RssFeed ( )
|
||||||
{
|
{
|
||||||
title = BString("Untitled Feed");
|
title = BString("Untitled Feed");
|
||||||
description = BString("");
|
description = BString("");
|
||||||
homeUrl = BString("");
|
homeUrl = BString("");
|
||||||
xmlUrl = BString("");
|
xmlUrl = BString("");
|
||||||
filePath = path;
|
|
||||||
outputDir = cfg->outDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RssFeed::RssFeed ( Feed* feed ) : RssFeed::RssFeed()
|
||||||
|
{ filePath = feed->filePath; }
|
||||||
|
RssFeed::RssFeed ( Feed* feed, Config* cfg ) : RssFeed::RssFeed( feed )
|
||||||
|
{ outputDir = cfg->outDir; }
|
||||||
|
RssFeed::RssFeed ( Config* cfg ) : RssFeed::RssFeed( )
|
||||||
|
{ outputDir = cfg->outDir; }
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -27,9 +33,9 @@ RssFeed::Parse ( Config* cfg )
|
||||||
|
|
||||||
|
|
||||||
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
feedFile->ReadAttr( "LastDate", B_TIME_TYPE, 0, &tt_lastDate, sizeof(time_t) );
|
||||||
if ( tt_lastDate > 0 && cfg->minDate == NULL && cfg->updateFeeds == true ) {
|
if ( tt_lastDate > 0 && cfg->updateFeeds == true ) {
|
||||||
attrLastDate.SetTime_t( tt_lastDate );
|
attrLastDate.SetTime_t( tt_lastDate );
|
||||||
cfg->minDate = attrLastDate;
|
minDate = attrLastDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml.LoadFile( filePath.String() );
|
xml.LoadFile( filePath.String() );
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
|
|
||||||
class RssFeed: public Feed {
|
class RssFeed: public Feed {
|
||||||
public:
|
public:
|
||||||
RssFeed ( BString, Config* );
|
RssFeed ( );
|
||||||
|
RssFeed ( Feed*, Config* );
|
||||||
|
RssFeed ( Feed* );
|
||||||
|
RssFeed ( Config* );
|
||||||
|
|
||||||
void Parse ( Config* );
|
void Parse ( Config* );
|
||||||
void RootParse ( Config*, tinyxml2::XMLElement* );
|
void RootParse ( Config*, tinyxml2::XMLElement* );
|
||||||
|
|
Ŝarĝante…
Reference in New Issue