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