From a58c4a9f5c0dd66c130da2b068971358949d7bb8 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 16 Aug 2020 23:22:15 -0500 Subject: [PATCH] Refactor; add BApp --- Makefile | 3 +- src/{Pogger.h => App.cpp} | 61 ++++++++++++++++++++++++------ src/App.h | 26 +++++++++++++ src/{Pogger.cpp => Invocation.cpp} | 22 +---------- src/Invocation.h | 14 +++++++ 5 files changed, 94 insertions(+), 32 deletions(-) rename src/{Pogger.h => App.cpp} (74%) create mode 100644 src/App.h rename src/{Pogger.cpp => Invocation.cpp} (89%) create mode 100644 src/Invocation.h diff --git a/Makefile b/Makefile index 586eb2e..e2f521c 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ SRCS = \ src/Mimetypes.cpp, \ src/Config.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 # used. diff --git a/src/Pogger.h b/src/App.cpp similarity index 74% rename from src/Pogger.h rename to src/App.cpp index d51af15..b7eb354 100644 --- a/src/Pogger.h +++ b/src/App.cpp @@ -1,20 +1,60 @@ #include +#include +#include +#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; const char* configPath = "/boot/home/config/settings/Pogger/"; - -// ---------------------------------------------------------------------------- - - BString usageMsg = "Usage: %app% [-hvDus] [-tT datetime] [-cCO path] \n" " %app% [-hvs] [-tTcCO] ( | | )\n" @@ -54,4 +94,3 @@ BString usageMsg = " 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" ; - diff --git a/src/App.h b/src/App.h new file mode 100644 index 0000000..d7720d0 --- /dev/null +++ b/src/App.h @@ -0,0 +1,26 @@ +#ifndef APPP_H +#define APPP_H + +#include +#include + + +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 diff --git a/src/Pogger.cpp b/src/Invocation.cpp similarity index 89% rename from src/Pogger.cpp rename to src/Invocation.cpp index 39d1564..bf2f7fd 100644 --- a/src/Pogger.cpp +++ b/src/Invocation.cpp @@ -8,26 +8,8 @@ #include "Mimetypes.h" #include "Config.h" #include "Util.h" -#include "Pogger.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; -} - -// ---------------------------------------------------------------------------- +#include "App.h" +#include "Invocation.h" int usage ( ) diff --git a/src/Invocation.h b/src/Invocation.h new file mode 100644 index 0000000..9ad2ee4 --- /dev/null +++ b/src/Invocation.h @@ -0,0 +1,14 @@ +#ifndef INVOCATION_H +#define INVOCATION_H + +#include + +int usage ( ); +int invocation ( int, char**, Config** ); +void freeargInvocation ( int, char**, int, Config** ); +bool processItem ( void* ); +bool processFeed ( void* ); + +// ---------------------------------------------------------------------------- + +#endif