diff --git a/TODO.txt b/TODO.txt index ef0fb2e..46306d9 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,8 +1,4 @@ * Add subscriptions - * Feed files in ~/config/settings/Pogger/subscriptions/ - * Default column layout, somehow? - * Use these Feed files as the cache files - * ~/config/cache/Pogger should be used only by random URL argvs * Adding/editing from GUI * Do this for file refs when Feeds, too * Revamp configuration @@ -14,17 +10,18 @@ * Show progress * With progress bar * With indicator in the feeds list -* Timed updating +* Configurations * Remove unnecessary `new`-- make sure to delete everything * Check if arg is a file or not (treat appropriately) * No hardcoded paths +* Default column layouts for ~/feeds and ~/config/settings/Pogger/Subscriptions * Show in desktray * Make archivable * Get menu working -* Add proper scripting support +* Proper scripting support * Multiple downloads at once? * Array of thread_ids for multiple DL threads? * In which case, it'd probably make sense to only spin them up as necessary, and kill when everything's done. * That'd require a proper queue system, instead of just - sending data to the download thread lol + spamming data to the download thread lol diff --git a/src/App.cpp b/src/App.cpp index 660f564..07040d3 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -5,6 +5,7 @@ #include "App.h" +#include #include #include @@ -24,26 +25,28 @@ int main(int argc, char** argv) { - App* app = new App(); installMimeTypes(); - app->cfg = new Config; - app->cfg->Load(); - + App* app = new App(); app->Run(); - - if ( app->cfg->will_save == true ) - app->cfg->Save(); - + app->cfg->Save(); return 0; } App::App() : BApplication("application/x-vnd.Pogger") { + cfg = new Config; + cfg->Load(); + fMainWindow = new MainWindow(); fFeedController = new FeedController(); fMainWindow->Show(); + + BMessage* updateMessage = new BMessage(kUpdateSubscribed); + MessageReceived(updateMessage); + fUpdateRunner = new BMessageRunner(this, updateMessage, + cfg->updateInterval); } diff --git a/src/App.h b/src/App.h index af25957..ecdb489 100644 --- a/src/App.h +++ b/src/App.h @@ -11,6 +11,7 @@ class BMessage; +class BMessageRunner; class Config; class FeedController; class MainWindow; @@ -26,6 +27,7 @@ public: Config* cfg; MainWindow* fMainWindow; + BMessageRunner* fUpdateRunner; private: FeedController* fFeedController; diff --git a/src/Config.cpp b/src/Config.cpp index 96c47f4..5f800fe 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -11,20 +11,11 @@ Config::Config() { - verbose = false; - daemon = true; - will_save = false; - updateFeeds = false; + Load(); } Config::Config(Config* cfg) { - verbose = cfg->verbose; - daemon = cfg->daemon; - will_save = cfg->will_save; - updateFeeds = cfg->updateFeeds; - minDate = cfg->minDate; - maxDate = cfg->maxDate; } @@ -32,23 +23,20 @@ Config::Config(Config* cfg) { void Config::Load() { - if (configDir == NULL) - configDir = BString("/boot/home/config/settings/Pogger/"); + configDir = BString("/boot/home/config/settings/Pogger/"); BString filename = BString(configDir); filename.Append("settings"); - BFile* file = new BFile(filename.String(), B_READ_ONLY); - status_t result = file->InitCheck(); + BFile file(filename.String(), B_READ_ONLY); + status_t result = file.InitCheck(); BMessage storage; - storage.Unflatten(file); + storage.Unflatten(&file); - if (outDir == NULL) - outDir = BString(storage.GetString("outDir", "/boot/home/feeds/")); - if (cacheDir == NULL) - cacheDir = BString(storage.GetString("cacheDir", - "/boot/home/config/cache/Pogger/")); - delete file; + updateInterval = storage.GetFloat("updateInterval", .5); + outDir = BString(storage.GetString("outDir", "/boot/home/feeds/")); + cacheDir = BString(storage.GetString("cacheDir", + "/boot/home/config/cache/Pogger/")); } @@ -75,6 +63,7 @@ Config::Save () | B_ERASE_FILE); status_t result = file->InitCheck(); + storage.AddFloat("updateInterval", updateInterval); storage.AddString("outDir", outDir.String()); storage.AddString("cacheDir", cacheDir.String()); diff --git a/src/Config.h b/src/Config.h index dbf2392..51cd686 100644 --- a/src/Config.h +++ b/src/Config.h @@ -22,11 +22,8 @@ public: bool verbose; bool daemon; BString outDir; - BList targetFeeds; // strings of files or urls - - BDateTime minDate; - BDateTime maxDate; + int64 updateInterval; BString configDir; BString cacheDir; bool will_save; diff --git a/src/FeedController.cpp b/src/FeedController.cpp index 2dadd1c..c7e4e00 100644 --- a/src/FeedController.cpp +++ b/src/FeedController.cpp @@ -128,9 +128,6 @@ FeedController::_ParseLoop(void* ignored) BDirectory outDir = BDirectory(((App*)be_app)->cfg->outDir); if (feedBuffer->IsAtom()) { - printf("Parsing Atom feed from %s...\n", - feedBuffer->GetXmlUrl().UrlString().String()); - AtomFeed* feed = (AtomFeed*)malloc(sizeof(AtomFeed)); feed = new AtomFeed(feedBuffer); feed->Parse(); @@ -138,9 +135,6 @@ FeedController::_ParseLoop(void* ignored) delete(feed); } else if (feedBuffer->IsRss()) { - printf("Parsing RSS feed from %s...\n", - feedBuffer->GetXmlUrl().UrlString().String()); - RssFeed* feed = (RssFeed*)malloc(sizeof(RssFeed)); feed = new RssFeed(feedBuffer); feed->Parse();