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"
|
2021-01-09 16:53:39 -06:00
|
|
|
#include "FeedController.h"
|
2020-12-30 22:07:54 -06:00
|
|
|
#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();
|
|
|
|
feedMimeType();
|
|
|
|
|
2020-11-16 20:32:58 -06:00
|
|
|
app->cfg = new Config;
|
|
|
|
app->cfg->Load();
|
2020-08-16 23:22:15 -05:00
|
|
|
|
2021-01-11 11:41:46 -06:00
|
|
|
app->Run();
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 22:07:54 -06:00
|
|
|
App::App() : BApplication("application/x-vnd.Pogger")
|
2020-08-16 23:22:15 -05:00
|
|
|
{
|
2021-01-09 16:53:39 -06:00
|
|
|
fMainWindow = new MainWindow();
|
|
|
|
fFeedController = new FeedController();
|
|
|
|
fMainWindow->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
App::MessageReceived(BMessage* msg)
|
|
|
|
{
|
|
|
|
switch (msg->what)
|
|
|
|
{
|
|
|
|
case kEnqueueFeed:
|
|
|
|
{
|
|
|
|
fFeedController->MessageReceived(msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kClearQueue:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kQueueProgress:
|
|
|
|
{
|
|
|
|
fMainWindow->MessageReceived(msg);
|
|
|
|
}
|
|
|
|
case kDownloadComplete:
|
|
|
|
{
|
|
|
|
fFeedController->MessageReceived(msg);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
// BApplication::MessageReceived(msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 23:22:15 -05:00
|
|
|
}
|
2020-07-03 19:13:41 -05:00
|
|
|
|
2020-07-07 20:17:52 -05:00
|
|
|
|
2021-01-11 11:41:46 -06:00
|
|
|
void
|
|
|
|
App::ArgvReceived(int32 argc, char** argv)
|
|
|
|
{
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
Feed* newFeed = new Feed(argv[i]);
|
|
|
|
|
|
|
|
BMessage* enqueue = new BMessage(kEnqueueFeed);
|
|
|
|
enqueue->AddData("feeds", B_RAW_TYPE, (void*)newFeed, sizeof(Feed));
|
|
|
|
|
|
|
|
MessageReceived(enqueue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-16 23:22:15 -05:00
|
|
|
const char* configPath = "/boot/home/config/settings/Pogger/";
|
2021-01-11 11:41:46 -06:00
|
|
|
|
|
|
|
|