Add automatic updating

This commit is contained in:
Jaidyn Ann 2021-01-12 19:08:42 -06:00
parent 17d45ae9ec
commit 313e40d9bb
6 changed files with 28 additions and 46 deletions

View File

@ -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

View File

@ -5,6 +5,7 @@
#include "App.h"
#include <MessageRunner.h>
#include <StorageKit.h>
#include <String.h>
@ -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();
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);
}

View File

@ -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;

View File

@ -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/");
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)
updateInterval = storage.GetFloat("updateInterval", .5);
outDir = BString(storage.GetString("outDir", "/boot/home/feeds/"));
if (cacheDir == NULL)
cacheDir = BString(storage.GetString("cacheDir",
"/boot/home/config/cache/Pogger/"));
delete file;
}
@ -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());

View File

@ -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;

View File

@ -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();