Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
extend documentation and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanJakobo committed Feb 9, 2022
1 parent 6495ecc commit e066a41
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 158 deletions.
6 changes: 3 additions & 3 deletions src/api/model.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//------------------------------------------------------------------
// MiinifluxModel.h
// model.h
//
// Author: JuanJakobo
// Date: 23.04.2021
// Description:
// Description: global model
//-------------------------------------------------------------------

#ifndef MODEL
Expand All @@ -15,4 +15,4 @@ struct Entry
{
std::string id;
};
#endif
#endif
53 changes: 43 additions & 10 deletions src/api/pocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Author: JuanJakobo
// Date: 22.04.2021
// Description:
// Description: Interface to the pocket API
//
//-------------------------------------------------------------------

Expand Down Expand Up @@ -32,48 +32,81 @@ 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<PocketItem> 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
*/
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<std::string> &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);


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);

};
Expand Down
3 changes: 2 additions & 1 deletion src/api/pocketModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum IStatus
enum IsDownloaded
{
NOTDOWNLOADED,
DOWNLOADED
DOWNLOADED,
INVALID
};

struct PocketItem : Entry
Expand Down
13 changes: 10 additions & 3 deletions src/api/sqliteConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Author: JuanJakobo
// Date: 18.07.2021
// Description:
// Description: Interface to store itms in a sqlite db
//
//-------------------------------------------------------------------

Expand All @@ -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);

/**
Expand Down Expand Up @@ -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();
};

Expand Down
2 changes: 2 additions & 0 deletions src/handler/contextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//-------------------------------------------------------------------

#include "contextMenu.h"
#include "inkview.h"

#include <string>

Expand All @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions src/handler/contextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
97 changes: 52 additions & 45 deletions src/handler/eventHandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------
// eventHandler.h
//
// Author: JuanJakob
// Author: JuanJakobo
// Date: 22.04.2021
// Description: Handles all events and directs them
//-------------------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand All @@ -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<PocketItem> &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);

Expand Down
18 changes: 9 additions & 9 deletions src/handler/mainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e066a41

Please sign in to comment.