2020-12-30 22:07:54 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "App.h"
|
|
|
|
|
2020-07-03 19:13:41 -05:00
|
|
|
#include <StorageKit.h>
|
2020-08-16 23:22:15 -05:00
|
|
|
#include <String.h>
|
2020-12-30 22:07:54 -06:00
|
|
|
|
2020-08-16 23:22:15 -05:00
|
|
|
#include <getopt.h>
|
2020-12-30 22:07:54 -06:00
|
|
|
|
2020-08-16 23:22:15 -05:00
|
|
|
#include "AtomFeed.h"
|
2020-12-30 22:07:54 -06:00
|
|
|
#include "Config.h"
|
2020-08-16 23:22:15 -05:00
|
|
|
#include "Entry.h"
|
2020-12-30 22:07:54 -06:00
|
|
|
#include "Feed.h"
|
|
|
|
#include "Invocation.h"
|
|
|
|
#include "MainWindow.h"
|
2020-08-16 23:22:15 -05:00
|
|
|
#include "Mimetypes.h"
|
2020-12-30 22:07:54 -06:00
|
|
|
#include "RssFeed.h"
|
2020-08-16 23:22:15 -05:00
|
|
|
#include "Util.h"
|
2020-07-03 19:13:41 -05:00
|
|
|
|
|
|
|
|
2020-08-16 23:22:15 -05:00
|
|
|
int
|
2020-12-30 22:07:54 -06:00
|
|
|
main(int argc, char** argv)
|
2020-08-16 23:22:15 -05:00
|
|
|
{
|
|
|
|
App* app = new App();
|
|
|
|
usageMsg.ReplaceAll("%app%", "Pogger");
|
|
|
|
feedMimeType();
|
|
|
|
|
2020-11-16 20:32:58 -06:00
|
|
|
app->cfg = new Config;
|
|
|
|
app->cfg->Load();
|
2020-08-16 23:22:15 -05:00
|
|
|
|
|
|
|
|
2020-12-30 22:07:54 -06:00
|
|
|
if (argc == 1)
|
2020-08-16 23:22:15 -05:00
|
|
|
app->Run();
|
|
|
|
else
|
2020-12-30 22:07:54 -06:00
|
|
|
cliStart(argc, argv);
|
2020-08-16 23:22:15 -05:00
|
|
|
|
|
|
|
|
2020-11-16 20:32:58 -06:00
|
|
|
if ( app->cfg->will_save == true )
|
|
|
|
app->cfg->Save();
|
2020-08-16 23:22:15 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2020-12-30 22:07:54 -06:00
|
|
|
cliStart(int argc, char** argv)
|
2020-08-16 23:22:15 -05:00
|
|
|
{
|
2020-12-30 22:07:54 -06:00
|
|
|
invocation(argc, argv);
|
|
|
|
((App*)be_app)->cfg->targetFeeds.DoForEach(&processFeed);
|
2020-08-16 23:22:15 -05:00
|
|
|
}
|
|
|
|
|
2020-12-30 22:07:54 -06:00
|
|
|
|
|
|
|
App::App() : BApplication("application/x-vnd.Pogger")
|
2020-08-16 23:22:15 -05:00
|
|
|
{
|
2020-12-30 21:13:12 -06:00
|
|
|
MainWindow* mainWin = new MainWindow();
|
|
|
|
mainWin->Show();
|
2020-08-16 23:22:15 -05:00
|
|
|
}
|
2020-07-03 19:13:41 -05:00
|
|
|
|
2020-07-07 20:17:52 -05:00
|
|
|
|
2020-08-16 23:22:15 -05:00
|
|
|
const char* configPath = "/boot/home/config/settings/Pogger/";
|
2020-07-03 19:13:41 -05:00
|
|
|
BString usageMsg =
|
2020-08-02 03:29:56 -05:00
|
|
|
"Usage: %app% [-hvDus] [-tT datetime] [-cCO path] \n"
|
|
|
|
" %app% [-hvs] [-tTcCO] ( <text/xml file> | <META:url file> | <url> )\n"
|
2020-07-03 19:13:41 -05:00
|
|
|
"\n"
|
|
|
|
"%app%, a RSS and Atom feed parser/daemon.\n"
|
|
|
|
"\n"
|
|
|
|
"Options:\n"
|
|
|
|
" -h, --help - Print this usage info.\n"
|
|
|
|
" -v, --verbose - Print verbose (debug) info.\n"
|
|
|
|
" -O, --output - Output dir for item files. (Default: ~/feeds/)\n"
|
|
|
|
" -t, --before - Only return items published before this datetime.\n"
|
|
|
|
" -T, --after - Only return items published after this datetime.\n"
|
2020-07-07 20:17:52 -05:00
|
|
|
" -c, --config - Path to config dir. (Default: ~/config/settings/Pogger/)\n"
|
|
|
|
" -C, --cache - Path to cache. (Default: ~/config/cache/Pogger/)\n"
|
|
|
|
" -s, --save - Save the args of `-m`, `-C`, and `-O` to config.\n"
|
|
|
|
" -u, --update - Update all feeds, but don't start daemon.\n"
|
2020-07-03 19:13:41 -05:00
|
|
|
" -D, --foreground - Run in the foreground, do not daemonize.\n"
|
2020-07-07 20:17:52 -05:00
|
|
|
" `-u` and `-D` only apply when running without file/url arg.\n"
|
2020-07-03 19:13:41 -05:00
|
|
|
"\n"
|
|
|
|
"When invoked without a file or URL, will search for any new feed items\n"
|
|
|
|
"published since last check by by any 'feed file' placed in the config\n"
|
|
|
|
"directory (default: ~/config/settings/Rifen/feeds/) and create their\n"
|
|
|
|
"corresponding files.\n"
|
|
|
|
"\n"
|
|
|
|
"When invoked with a file or URL, will create files from items contained\n"
|
|
|
|
"within the given file or URL.\n"
|
|
|
|
"\n"
|
|
|
|
"'Feed files' are files with a 'META:url' attribute containing the\n"
|
|
|
|
"corresponding URL to the feed's XML.\n"
|
|
|
|
"\n"
|
|
|
|
"Both -t and -T use the ISO 8601 format for specifying datetimes:\n"
|
|
|
|
" YYYY-MM-DDTHH:MM:SS - 2020-01-01T07:07:07\n"
|
2020-07-04 04:44:54 -05:00
|
|
|
"\n"
|
|
|
|
"NOTE: This message doesn't reflect reality. This is more of a spec of\n"
|
2020-07-07 17:42:12 -05:00
|
|
|
" what I hope this program will be. As of now, running %app%\n"
|
|
|
|
" without a file/url free-argument is invalid, as the daemon\n"
|
2020-07-07 20:17:52 -05:00
|
|
|
" isn't implemented at all. As such, -D -u and -C are non-functional.\n"
|
2020-07-04 04:44:54 -05:00
|
|
|
" But it sure can turn an XML feed into files! Lol.\n"
|
2020-07-03 19:13:41 -05:00
|
|
|
;
|