diff --git a/src/api/model.h b/src/api/model.h index 3820d6e..71b13a7 100755 --- a/src/api/model.h +++ b/src/api/model.h @@ -1,9 +1,9 @@ //------------------------------------------------------------------ -// MiinifluxModel.h +// model.h // // Author: JuanJakobo // Date: 23.04.2021 -// Description: +// Description: global model //------------------------------------------------------------------- #ifndef MODEL @@ -15,4 +15,4 @@ struct Entry { std::string id; }; -#endif \ No newline at end of file +#endif diff --git a/src/api/pocket.h b/src/api/pocket.h index ed1cbba..0df7a9a 100755 --- a/src/api/pocket.h +++ b/src/api/pocket.h @@ -3,7 +3,7 @@ // // Author: JuanJakobo // Date: 22.04.2021 -// Description: +// Description: Interface to the pocket API // //------------------------------------------------------------------- @@ -32,20 +32,19 @@ class Pocket { public: /** - * creatas a new Miniflux object containing the url and token to access the api - * + * Creates a new pocket object containing token to access the api + * */ Pocket(); /** * Retrieve a Users Pocket Data * - * @return vetor of PocketItems that has been received + * @return vector of PocketItems that has been received */ std::vector getItems(); /** - * * Gets the text and images, creates an html out of it and stores the path inside the item * * @param item for that the text shall be downloaded @@ -53,16 +52,18 @@ class Pocket void getText(PocketItem *item); /** - * * Modify a Users Pocket Data - * @param + * + * @param action that shall be performed + * @param ids the ids that shall be modified */ void sendItems(PocketAction action, const std::vector &ids); /** + * Modify a single item * - * Modify a Users Pocket Data - * @param + * @param action that shall be performed + * @param id the id that shall be modified */ void sendItem(PocketAction action, const std::string &id); @@ -70,10 +71,42 @@ class Pocket private: std::string _accessToken; + /** + * Opens the login dialog + */ void loginDialog(); + + /** + * Get the code to start the login process + * + * @return the code that has been received + */ std::string getCode(); - std::string getAccessToken(const std::string &code); + + /** + * Receives the AccessToken and the username and stores these + * + * @param the code that has been received from the net + */ + void getAccessToken(const std::string &code); + + /** + * Determines the action from the enum + * + * @param receivces the action enum + * + * @returns the action as string + */ std::string determineAction(PocketAction action); + + /** + * Accesses the Pocketapi and returns the result as a json + * + * @param apiEndpoint the endpoint that shall be accessed + * @param data the post data + * + * @return the result as a json + */ nlohmann::json post(const std::string &apiEndpoint, const std::string &data); }; diff --git a/src/api/pocketModel.h b/src/api/pocketModel.h index 078af01..3171b2e 100755 --- a/src/api/pocketModel.h +++ b/src/api/pocketModel.h @@ -23,7 +23,8 @@ enum IStatus enum IsDownloaded { NOTDOWNLOADED, - DOWNLOADED + DOWNLOADED, + INVALID }; struct PocketItem : Entry diff --git a/src/api/sqliteConnector.h b/src/api/sqliteConnector.h index 9aaddd2..a1d19b8 100755 --- a/src/api/sqliteConnector.h +++ b/src/api/sqliteConnector.h @@ -3,7 +3,7 @@ // // Author: JuanJakobo // Date: 18.07.2021 -// Description: +// Description: Interface to store itms in a sqlite db // //------------------------------------------------------------------- @@ -27,8 +27,10 @@ class SqliteConnector { public: /** - * - */ + * Creates a new database object + * + * @param DBpath the path where the database is placed + */ SqliteConnector(const std::string &DBpath); /** @@ -64,6 +66,11 @@ class SqliteConnector std::string _dbpath; sqlite3 *_db; + /** + * Opens the DB and creates the table if necessary + * + * @return true if was sucessfull + */ bool open(); }; diff --git a/src/handler/contextMenu.cpp b/src/handler/contextMenu.cpp index bbacc71..df26d19 100755 --- a/src/handler/contextMenu.cpp +++ b/src/handler/contextMenu.cpp @@ -7,6 +7,7 @@ //------------------------------------------------------------------- #include "contextMenu.h" +#include "inkview.h" #include @@ -19,6 +20,7 @@ ContextMenu::~ContextMenu() free(_menu); free(_star); free(_download); + free(_archive); } int ContextMenu::createMenu(int y, const iv_menuhandler &handler, const PocketItem &item) diff --git a/src/handler/contextMenu.h b/src/handler/contextMenu.h index d8b9843..f60af96 100755 --- a/src/handler/contextMenu.h +++ b/src/handler/contextMenu.h @@ -22,14 +22,13 @@ class ContextMenu ~ContextMenu(); /** - * Shows the menu on the screen, lets the user choose menu options and then redirects the handler to the caller - * - * @param y y-coordinate of the item - * @param handler which action does the menu buttons start - * @param comments show if comments are available - * @param starred hide option if is already starred - * @return int returns if the event was handled - */ + * Shows the menu on the screen, lets the user choose menu options and then redirects the handler to the caller + * + * @param y y-coordinate of the item + * @param handler which action does the menu buttons start + * @param item that shall be handled + * @return int returns if the event was handled + */ int createMenu(int y, const iv_menuhandler &handler, const PocketItem &item); diff --git a/src/handler/eventHandler.h b/src/handler/eventHandler.h index a1fdb73..b8a3bcd 100755 --- a/src/handler/eventHandler.h +++ b/src/handler/eventHandler.h @@ -1,7 +1,7 @@ //------------------------------------------------------------------ // eventHandler.h // -// Author: JuanJakob +// Author: JuanJakobo // Date: 22.04.2021 // Description: Handles all events and directs them //------------------------------------------------------------------- @@ -41,20 +41,20 @@ class EventHandler { public: /** - * Defines fonds, sets global Event Handler and starts new content - */ + * Defines fonds, sets global Event Handler and starts new content + */ EventHandler(); ~EventHandler(); /** - * Handles events and redirects them - * - * @param type event type - * @param par1 first argument of the event - * @param par2 second argument of the event - * @return int returns if the event was handled - */ + * Handles events and redirects them + * + * @param type event type + * @param par1 first argument of the event + * @param par2 second argument of the event + * @return int returns if the event was handled + */ int eventDistributor(const int type, const int par1, const int par2); private: @@ -68,65 +68,72 @@ class EventHandler Views _currentView; int _pocketViewShownPage = 1; - void loginDialog(); - /** - * Function needed to call C function, redirects to real function - * - * @param index int of the menu that is set - */ + * Function needed to call C function, redirects to real function + * + * @param index int of the menu that is set + */ static void mainMenuHandlerStatic(const int index); /** - * Handles menu events and redirects them - * - * @param index int of the menu that is set - */ + * Handles menu events and redirects them + * + * @param index int of the menu that is set + */ void mainMenuHandler(const int index); /** - * Function needed to call C function, redirects to real function - * - * @param index int of the menu that is set - */ + * Function needed to call C function, redirects to real function + * + * @param index int of the menu that is set + */ static void contextMenuHandlerStatic(const int index); /** - * Handlescontext menu events and redirects them - * - * @param index int of the menu that is set - */ - + * Handles context menu events and redirects them + * + * @param index int of the menu that is set + */ void contextMenuHandler(const int index); /** - * Handles pointer Events - * - * @param type event type - * @param par1 first argument of the event - * @param par2 second argument of the event - * @return int returns if the event was handled - */ + * Handles pointer Events + * + * @param type event type + * @param par1 first argument of the event + * @param par2 second argument of the event + * @return int returns if the event was handled + */ int pointerHandler(const int type, const int par1, const int par2); /** - * Handles key Events - * - * @param type event type - * @param par1 first argument of the event (is the key) - * @param par2 second argument of the event - * @return int returns if the event was handled - */ + * Handles key Events + * + * @param type event type + * @param par1 first argument of the event (is the key) + * @param par2 second argument of the event + * @return int returns if the event was handled + */ int keyHandler(const int type, const int par1, const int par2); + /** + * Draws pocket items to a screen + * + * @param vector of the pocketItems that shall be drawn + * + * @return true if the items could be drawn an the item size is bigger than 0 + */ bool drawPocketItems(const std::vector &pocketItems); /** - * + * * Draws the pocket items to an ListView - * + * + * @param status the status of the items + * @param favorited if the favorited should be drawn + * */ void filterAndDrawPocket(IStatus status, bool favorited); diff --git a/src/handler/mainMenu.h b/src/handler/mainMenu.h index fe788be..657d5d8 100755 --- a/src/handler/mainMenu.h +++ b/src/handler/mainMenu.h @@ -17,10 +17,10 @@ class MainMenu { public: /** - * Defines fonds, sets global Event Handler and starts new content - * - * @param name name of the application - */ + * Defines fonds, sets global Event Handler and starts new content + * + * @param name name of the application + */ MainMenu(const std::string &name); ~MainMenu(); @@ -29,11 +29,11 @@ class MainMenu irect *getMenuButtonRect() { return &_menuButtonRect; }; /** - * Shows the menu on the screen, lets the user choose menu options and then redirects the handler to the caller - * - * @param mainView if true mainView will be shown - * @return int returns if the event was handled - */ + * Shows the menu on the screen, lets the user choose menu options and then redirects the handler to the caller + * + * @param mainView if true mainView will be shown + * @return int returns if the event was handled + */ int createMenu(bool mainView, const iv_menuhandler &handler); private: diff --git a/src/main.cpp b/src/main.cpp index e3c4990..2cc3ddc 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,7 +13,7 @@ EventHandler *events = nullptr; /** * Handles events and redirects them -* +* * @param type event type * @param par1 first argument of the event * @param par2 second argument of the event diff --git a/src/ui/listView.cpp b/src/ui/listView.cpp index 082b41b..4735706 100755 --- a/src/ui/listView.cpp +++ b/src/ui/listView.cpp @@ -22,7 +22,7 @@ ListView::ListView(const irect *contentRect, int page) : _contentRect(contentRec _footerHeight = _contentRect->h / 15; _footerFontHeight = 0.3 * _footerHeight; - _entryFontHeight = 30; + _entryFontHeight = 30; _footerFont = OpenFont("LiberationMono", _footerFontHeight, 1); _entryFont = OpenFont("LiberationMono", _entryFontHeight, 1); @@ -146,4 +146,4 @@ void ListView::actualizePage(int pageToShow) drawFooter(); PartialUpdate(_contentRect->x, _contentRect->y, _contentRect->w, _contentRect->h); } -} \ No newline at end of file +} diff --git a/src/ui/listView.h b/src/ui/listView.h index 263f65d..2e94351 100755 --- a/src/ui/listView.h +++ b/src/ui/listView.h @@ -9,7 +9,6 @@ #ifndef LISTVIEW #define LISTVIEW -#include "inkview.h" #include "listViewEntry.h" #include "model.h" @@ -20,8 +19,8 @@ class ListView { public: /** - * Displays a list view - * + * Displays a list view + * * @param ContentRect area of the screen where the list view is placed * @param Items items that shall be shown in the listview */ @@ -29,54 +28,77 @@ class ListView virtual ~ListView(); + //TODO is the usage of the pointer okay? + /** + * returns the clicked entry + * + * @return Entry that has been clicked is returned + */ virtual Entry *getCurrentEntry() = 0; - + + /** + * get the entry with the id + * + * @params entryID + * + * @return Entry that has been clicked + */ virtual Entry *getEntry(int entryID) = 0; + /** + * returns the number of the currently displayed page + * + * @return the number of the page + */ int getShownPage(){return _shownPage;}; /** - * Navigates to the next page - */ + * Navigates to the next page + */ void nextPage() { this->actualizePage(_shownPage + 1); }; /** - * Navigates to the prev page - */ + * Navigates to the prev page + */ void prevPage() { this->actualizePage(_shownPage - 1); }; /** - * Navigates to first page - */ + * Navigates to first page + */ void firstPage() { this->actualizePage(1); }; /** - * Draws an single entry to the screen - */ + * Redraws the currently selected entry to the screen + */ void reDrawCurrentEntry(); /** - * inverts the color of the currently selected entry - */ + * Inverts the color of the currently selected entry + */ void invertCurrentEntryColor(); /** - * Checkes if the listview has been clicked and either changes the page or returns item ID - * - * @param x x-coordinate - * @param y y-coordinate - * @return true if was clicked - */ + * Checkes if the listview has been clicked and either changes the page or returns item ID + * + * @param x x-coordinate + * @param y y-coordinate + * @return true if was clicked + */ bool checkIfEntryClicked(int x, int y); + /** + * Returns the current Entry Iterator + * + * @return the current Entry Iterator + */ int getCurrentEntryItertator() const {return _selectedEntry;}; /** - * Clears the screen and draws entries and footer - * - */ + * Clears the screen and draws entries and footer + * + */ void draw(); - + protected: int _footerHeight; int _footerFontHeight; @@ -97,27 +119,27 @@ class ListView /** - * Iterates through the items and sends them to the listViewEntry Class for drawing - */ + * Iterates through the items and sends them to the listViewEntry Class for drawing + */ void drawEntries(); /** - * Draws the footer including a page changer - */ + * Draws the footer including a page changer + */ void drawFooter(); /** - * updates an entry - * - * @param entryID the id of the item that shall be inverted - */ + * Updates an entry + * + * @param entryID the id of the item that shall be inverted + */ void updateEntry(int entryID); /** - * Navigates to the selected page - * - * @param pageToShow page that shall be shown - */ + * Navigates to the selected page + * + * @param pageToShow page that shall be shown + */ void actualizePage(int pageToShow); }; #endif diff --git a/src/ui/listViewEntry.h b/src/ui/listViewEntry.h index e25aed2..5ebbb8c 100755 --- a/src/ui/listViewEntry.h +++ b/src/ui/listViewEntry.h @@ -16,11 +16,11 @@ class ListViewEntry { public: /** - * Creates an ListViewEntry - * - * @param Page site of the listView the Entry is shown - * @param Rect area of the screen the item is positioned - */ + * Creates an ListViewEntry + * + * @param Page site of the listView the Entry is shown + * @param Rect area of the screen the item is positioned + */ ListViewEntry(int page, const irect &position); virtual ~ListViewEntry(){}; @@ -29,14 +29,14 @@ class ListViewEntry int getPage() const { return _page; } /** - * draws the listViewEntry to the screen - * + * Draws the listViewEntry to the screen + * * @param entryFont font for the entry itself * @param entryFontBold bold font for the header - * @param fontHeight height of the font + * @param fontHeight height of the font */ virtual void draw(const ifont *entryFont, const ifont *entryFontBold, int fontHeight) = 0; - + virtual Entry* get() = 0; protected: diff --git a/src/ui/pocketView.h b/src/ui/pocketView.h index 0f9ebd7..e266c84 100755 --- a/src/ui/pocketView.h +++ b/src/ui/pocketView.h @@ -20,14 +20,19 @@ class PocketView final : public ListView { public: /** - * Displays a list view - * - * @param ContentRect area of the screen where the list view is placed - * @param Items items that shall be shown in the listview - * @param page page that is shown, default is 1 - */ + * Displays a list view + * + * @param ContentRect area of the screen where the list view is placed + * @param Items items that shall be shown in the listview + * @param page page that is shown, default is 1 + */ PocketView(const irect *contentRect, const std::vector &pocketItems, int page = 1); + /** + * Gets the current page and returns the itemIds till the page + * + * @return a vector containing the itemIds + */ std::vector getEntriesTillPage(); PocketItem *getCurrentEntry() { return getEntry(_selectedEntry); }; diff --git a/src/ui/pocketViewEntry.h b/src/ui/pocketViewEntry.h index 2d77dde..aee86b8 100755 --- a/src/ui/pocketViewEntry.h +++ b/src/ui/pocketViewEntry.h @@ -16,21 +16,21 @@ class PocketViewEntry : public ListViewEntry { public: /** - * Creates an pocketViewEntry - * - * @param Page site of the listView the Entry is shown - * @param Rect area of the screen the item is positioned - * @param entry entry that shall be drawn - */ + * Creates an pocketViewEntry + * + * @param Page site of the listView the Entry is shown + * @param Rect area of the screen the item is positioned + * @param entry entry that shall be drawn + */ PocketViewEntry(int page, const irect &position, const PocketItem &entry); /** - * draws the pocketViewEntry to the screen - * - * @param entryFont font for the entry itself - * @param entryFontBold bold font for the header - * @param fontHeight height of the font - */ + * draws the pocketViewEntry to the screen + * + * @param entryFont font for the entry itself + * @param entryFontBold bold font for the header + * @param fontHeight height of the font + */ void draw(const ifont *entryFont, const ifont *entryFontBold, int fontHeight) override; PocketItem *get() override { return &_entry; }; diff --git a/src/util/log.cpp b/src/util/log.cpp index 169f239..15a4733 100755 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -8,6 +8,7 @@ #include "log.h" #include "eventHandler.h" +#include "inkview.h" #include #include diff --git a/src/util/log.h b/src/util/log.h index 991b968..0b532d2 100755 --- a/src/util/log.h +++ b/src/util/log.h @@ -9,8 +9,6 @@ #ifndef LOG #define LOG -#include "inkview.h" - #include class Log @@ -18,14 +16,14 @@ class Log public: /** * Writes a error log entry to the log file - * + * * @param text that shall be written to the log */ static void writeErrorLog(const std::string &text); /** * Writes a info log entry to the log file - * + * * @param text that shall be written to the log */ static void writeInfoLog(const std::string &text); @@ -35,7 +33,7 @@ class Log /** * Writes a log entry to the log file - * + * * @param text that shall be written to the log */ static void writeLog(const std::string &text); diff --git a/src/util/util.cpp b/src/util/util.cpp index b773465..0ebab81 100755 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -8,7 +8,6 @@ #include "util.h" #include "inkview.h" #include "eventHandler.h" - #include "log.h" #include @@ -137,6 +136,7 @@ string Util::clearString(string title) return title; } +//TODO use epub? string Util::createHtml(string title, string content) { diff --git a/src/util/util.h b/src/util/util.h index 0533f66..622be88 100755 --- a/src/util/util.h +++ b/src/util/util.h @@ -9,8 +9,6 @@ #ifndef UTIL #define UTIL -#include "inkview.h" - #include enum Action @@ -37,30 +35,68 @@ class Util static size_t writeData(void *ptr, size_t size, size_t nmemb, FILE *stream); /** - * Checks if a network connection can be established + * Checks if a network connection can be established and + * + * @throws error that the network connection could not be established * */ static void connectToNetwork(); /** - * Reads an string from the config file + * Enables the access to the config file * - * @action - * @param name name of the config that shall be read - * @param value value that shall be written to the config + * @param actions taht shall be performed + * @param name of the config that shall be read + * @param value that shall be written to the config * * @return string that has been found in the config file */ static std::string accessConfig(const Action &action, const std::string &name, const std::string &value = std::string()); + + /** + * Gets the data fom a URL (for example to download a picture) + * + * @param url the url where the data should be downlaoded from + * + * @throws error if the html file cannot be downloaded + * + * @return string the data that have been received from the URL + */ static std::string getData(const std::string &url); + /** + * Removes chars that are forbidden in an path + * + * @param string that has to be changed + * @return string that has been adjusted + */ static std::string clearString(std::string title); + /** + * Creates an html file, downloades the pictures and saves it to path + * + * @param title the name the html should be saved + * @param content the html content + * + * @return path where the html file is saved to + */ static std::string createHtml(std::string title, std::string content); + /** + * Decode an html file and transform html tags + * + * @param data a reference to the data that shall be decoded + */ static void decodeHTML(std::string &data); + /** + * Replace for a string all data with an other string + * + * @param data the complete text + * @param replace text that should be replaced + * @param by text by that the text should be replaced + */ static void replaceAll(std::string &data, const std::string &replace, const std::string &by); private: