Refactor; add BApp

This commit is contained in:
Jaidyn Ann 2020-08-16 23:22:15 -05:00
parent b5f0d5bab8
commit a58c4a9f5c
5 changed files with 94 additions and 32 deletions

View File

@ -37,7 +37,8 @@ SRCS = \
src/Mimetypes.cpp, \ src/Mimetypes.cpp, \
src/Config.cpp, \ src/Config.cpp, \
src/Util.cpp, \ src/Util.cpp, \
src/Pogger.cpp src/App.cpp, \
src/Invocation.cpp \
# Specify the resource definition files to use. Full or relative paths can be # Specify the resource definition files to use. Full or relative paths can be
# used. # used.

View File

@ -1,20 +1,60 @@
#include <StorageKit.h> #include <StorageKit.h>
#include <String.h>
#include <getopt.h>
#include "AtomFeed.h"
#include "RssFeed.h"
#include "Feed.h"
#include "Entry.h"
#include "Mimetypes.h"
#include "Config.h"
#include "Util.h"
#include "App.h"
#include "Invocation.h"
int
main ( int argc, char** argv )
{
App* app = new App();
usageMsg.ReplaceAll("%app%", "Pogger");
feedMimeType();
main_cfg = new Config;
main_cfg->Load();
if ( argc == 0 )
app->Run();
else
cliStart( argc, argv );
if ( main_cfg->will_save == true )
main_cfg->Save();
return 0;
}
// -------------------------------------
void
cliStart ( int argc, char** argv )
{
invocation( argc, argv, &main_cfg );
main_cfg->targetFeeds.DoForEach( &processFeed );
}
App::App ( )
: BApplication("application/x-vnd.Pogger")
{
}
int main ( int, char** );
int usage ( );
int invocation ( int, char**, Config** );
void freeargInvocation ( int, char**, int, Config** );
bool processItem ( void* );
bool processFeed ( void* );
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Config* main_cfg; Config* main_cfg;
const char* configPath = "/boot/home/config/settings/Pogger/"; const char* configPath = "/boot/home/config/settings/Pogger/";
// ----------------------------------------------------------------------------
BString usageMsg = BString usageMsg =
"Usage: %app% [-hvDus] [-tT datetime] [-cCO path] \n" "Usage: %app% [-hvDus] [-tT datetime] [-cCO path] \n"
" %app% [-hvs] [-tTcCO] ( <text/xml file> | <META:url file> | <url> )\n" " %app% [-hvs] [-tTcCO] ( <text/xml file> | <META:url file> | <url> )\n"
@ -54,4 +94,3 @@ BString usageMsg =
" isn't implemented at all. As such, -D -u and -C are non-functional.\n" " isn't implemented at all. As such, -D -u and -C are non-functional.\n"
" But it sure can turn an XML feed into files! Lol.\n" " But it sure can turn an XML feed into files! Lol.\n"
; ;

26
src/App.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef APPP_H
#define APPP_H
#include <SupportDefs.h>
#include <Application.h>
class App : public BApplication
{
public:
App(void);
};
// ----------------------------------------------------------------------------
int main ( int, char** );
void cliStart ( int, char** );
// ----------------------------------------------------------------------------
extern Config* main_cfg;
extern const char* configPath;
extern BString usageMsg;
#endif

View File

@ -8,26 +8,8 @@
#include "Mimetypes.h" #include "Mimetypes.h"
#include "Config.h" #include "Config.h"
#include "Util.h" #include "Util.h"
#include "Pogger.h" #include "App.h"
#include "Invocation.h"
int
main ( int argc, char** argv )
{
main_cfg = new Config;
usageMsg.ReplaceAll("%app%", "Pogger");
feedMimeType();
invocation( argc, argv, &main_cfg );
main_cfg->Load();
main_cfg->targetFeeds.DoForEach( &processFeed );
if ( main_cfg->will_save == true )
main_cfg->Save();
return 0;
}
// ----------------------------------------------------------------------------
int int
usage ( ) usage ( )

14
src/Invocation.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef INVOCATION_H
#define INVOCATION_H
#include <StorageKit.h>
int usage ( );
int invocation ( int, char**, Config** );
void freeargInvocation ( int, char**, int, Config** );
bool processItem ( void* );
bool processFeed ( void* );
// ----------------------------------------------------------------------------
#endif