clean up header files

pull/23/head
JuanJakobo 2021-06-01 09:08:39 +02:00
parent 2823b5410d
commit 7c7164ea0c
9 changed files with 62 additions and 75 deletions

View File

@ -16,7 +16,7 @@
#include <memory> #include <memory>
const string LOG_PATH = "/mnt/ext1/system/config/nextcloud"; const std::string LOG_PATH = "/mnt/ext1/system/config/nextcloud";
class EventHandler class EventHandler
{ {
@ -42,7 +42,7 @@ private:
std::unique_ptr<LoginView> _loginView; std::unique_ptr<LoginView> _loginView;
MenuHandler _menu = MenuHandler("Nextcloud"); MenuHandler _menu = MenuHandler("Nextcloud");
Nextcloud _nextcloud = Nextcloud(); Nextcloud _nextcloud = Nextcloud();
string _tempPath; std::string _tempPath;
/** /**
* Function needed to call C function, redirects to real function * Function needed to call C function, redirects to real function

View File

@ -11,8 +11,6 @@
#include <string> #include <string>
using std::string;
class MenuHandler class MenuHandler
{ {
public: public:
@ -21,7 +19,7 @@ public:
* *
* @param name name of the application * @param name name of the application
*/ */
MenuHandler(const string &name); MenuHandler(const std::string &name);
~MenuHandler(); ~MenuHandler();

View File

@ -17,9 +17,6 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
using std::string;
using std::vector;
class ListView class ListView
{ {
public: public:
@ -29,7 +26,7 @@ public:
* @param ContentRect area of the screen where the list view is placed * @param ContentRect area of the screen where the list view is placed
* @param Items items that shall be shown in the listview * @param Items items that shall be shown in the listview
*/ */
ListView(const irect *contentRect, const vector<Item> &items); ListView(const irect *contentRect, const std::vector<Item> &items);
~ListView(); ~ListView();
@ -39,7 +36,7 @@ public:
* @param headerText the text that shall be displayed in the header * @param headerText the text that shall be displayed in the header
* *
*/ */
void drawHeader(string headerText); void drawHeader(std::string headerText);
/** /**
* Draws the footer including a page changer * Draws the footer including a page changer
@ -81,8 +78,8 @@ private:
int _footerFontHeight; int _footerFontHeight;
int _entryFontHeight; int _entryFontHeight;
const irect *_contentRect; const irect *_contentRect;
std::unique_ptr<const vector<Item>> _items; std::unique_ptr<const std::vector<Item>> _items;
vector<ListViewEntry> _entries; std::vector<ListViewEntry> _entries;
ifont *_headerFont; ifont *_headerFont;
ifont *_footerFont; ifont *_footerFont;
ifont *_entryFont; ifont *_entryFont;

View File

@ -13,8 +13,6 @@
#include <string> #include <string>
using std::string;
enum KeyboardTarget enum KeyboardTarget
{ {
IURL, IURL,
@ -45,9 +43,9 @@ public:
*/ */
int logginClicked(int x, int y); int logginClicked(int x, int y);
string getUsername() { return _username; }; std::string getUsername() { return _username; };
string getPassword() { return _password; }; std::string getPassword() { return _password; };
string getURL() { return _url; }; std::string getURL() { return _url; };
private: private:
static LoginView *_loginViewStatic; static LoginView *_loginViewStatic;
@ -59,10 +57,10 @@ private:
irect _usernameButton; irect _usernameButton;
irect _passwordButton; irect _passwordButton;
KeyboardTarget _target; KeyboardTarget _target;
string _username; std::string _username;
string _password; std::string _password;
string _url; std::string _url;
string _temp; std::string _temp;
/** /**
* Functions needed to call C function, handles the keyboard * Functions needed to call C function, handles the keyboard

View File

@ -13,8 +13,6 @@
#include <string> #include <string>
using std::string;
enum Itemtype enum Itemtype
{ {
IFILE, IFILE,
@ -37,7 +35,7 @@ public:
* *
* @param xmlItem result of the nextcloud request * @param xmlItem result of the nextcloud request
*/ */
Item(const string &xmlItem); Item(const std::string &xmlItem);
/** /**
* Creates a new item by receiving localPath from the pocketbook * Creates a new item by receiving localPath from the pocketbook
@ -46,7 +44,7 @@ public:
* @param state state of the file * @param state state of the file
* @param type type of the item (folder/file) * @param type type of the item (folder/file)
*/ */
Item(const string &localPath, FileState state, Itemtype type); Item(const std::string &localPath, FileState state, Itemtype type);
/** /**
* Tries to open the item by checking the file format and then executes the fitting action * Tries to open the item by checking the file format and then executes the fitting action
@ -55,36 +53,36 @@ public:
bool removeFile(); bool removeFile();
void setPath(const string &path) { _path = path; }; void setPath(const std::string &path) { _path = path; };
string getPath() const { return _path; }; std::string getPath() const { return _path; };
string getLocalPath() const { return _localPath; }; std::string getLocalPath() const { return _localPath; };
Itemtype getType() const { return _type; }; Itemtype getType() const { return _type; };
void setTitle(const string &title) { _title = title; }; void setTitle(const std::string &title) { _title = title; };
string getTitle() const { return _title; }; std::string getTitle() const { return _title; };
void setState(FileState state) { _state = state; }; void setState(FileState state) { _state = state; };
FileState getState() const { return _state; }; FileState getState() const { return _state; };
string getLastEditDate() const { return _lastEditDate; }; std::string getLastEditDate() const { return _lastEditDate; };
void setLastEditDate(const string &date) { _lastEditDate = date; }; void setLastEditDate(const std::string &date) { _lastEditDate = date; };
double getSize() const { return _size; }; double getSize() const { return _size; };
string getSizeString() const; std::string getSizeString() const;
string getFiletype() const { return _fileType; }; std::string getFiletype() const { return _fileType; };
private: private:
string _path; std::string _path;
string _title; std::string _title;
string _localPath; std::string _localPath;
FileState _state{FileState::ICLOUD}; FileState _state{FileState::ICLOUD};
Itemtype _type; Itemtype _type;
string _lastEditDate{"Error"}; std::string _lastEditDate{"Error"};
double _size; double _size;
string _fileType; std::string _fileType;
/** /**
* Converts the size to an easier readble format * Converts the size to an easier readble format

View File

@ -12,7 +12,7 @@
#include <string> #include <string>
#include <fstream> #include <fstream>
void Log::writeLog(const string &text) void Log::writeLog(const std::string &text)
{ {
std::ofstream log(LOG_PATH + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out); std::ofstream log(LOG_PATH + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out);

View File

@ -13,8 +13,6 @@
#include <string> #include <string>
using std::string;
class Log class Log
{ {
public: public:
@ -23,7 +21,7 @@ public:
* *
* @param text that shall be written to the log * @param text that shall be written to the log
*/ */
static void writeLog(const string &text); static void writeLog(const std::string &text);
private: private:
Log() {} Log() {}

View File

@ -20,6 +20,7 @@
using std::ifstream; using std::ifstream;
using std::ofstream; using std::ofstream;
using std::string; using std::string;
using std::vector;
Nextcloud::Nextcloud() Nextcloud::Nextcloud()
{ {

View File

@ -17,29 +17,26 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
using std::string; const std::string NEXTCLOUD_PATH = "/mnt/ext1/system/config/nextcloud";
using std::vector; const std::string NEXTCLOUD_CONFIG_PATH = NEXTCLOUD_PATH + "/nextcloud.cfg";
const std::string NEXTCLOUD_FILE_PATH = "/mnt/ext1/nextcloud";
const string NEXTCLOUD_PATH = "/mnt/ext1/system/config/nextcloud"; const std::string NEXTCLOUD_ROOT_PATH = "/remote.php/dav/files/";
const string NEXTCLOUD_CONFIG_PATH = NEXTCLOUD_PATH + "/nextcloud.cfg"; const std::string NEXTCLOUD_STRUCTURE_EXTENSION = ".structure";
const string NEXTCLOUD_FILE_PATH = "/mnt/ext1/nextcloud"; const std::string NEXTCLOUD_END_PATH = "/nextcloud";
const string NEXTCLOUD_ROOT_PATH = "/remote.php/dav/files/";
const string NEXTCLOUD_STRUCTURE_EXTENSION = ".structure";
const string NEXTCLOUD_END_PATH = "/nextcloud";
class Nextcloud class Nextcloud
{ {
public: public:
explicit Nextcloud(); explicit Nextcloud();
void setURL(const string &Url); void setURL(const std::string &Url);
void setUsername(const string &Username); void setUsername(const std::string &Username);
void setUUID(const string &UUID); void setUUID(const std::string &UUID);
void setPassword(const string &Pass); void setPassword(const std::string &Pass);
void setStartFolder(const string &Path); void setStartFolder(const std::string &Path);
bool setItems(const vector<Item> &tempItems); bool setItems(const std::vector<Item> &tempItems);
const vector<Item> &getItems() const { return _items; }; const std::vector<Item> &getItems() const { return _items; };
bool isLoggedIn() const { return _loggedIn; }; bool isLoggedIn() const { return _loggedIn; };
bool isWorkOffline() const { return _workOffline; }; bool isWorkOffline() const { return _workOffline; };
void switchWorkOffline() { _workOffline = !_workOffline; }; void switchWorkOffline() { _workOffline = !_workOffline; };
@ -58,7 +55,7 @@ public:
* @param Pass the pass of the Nextcloud instance * @param Pass the pass of the Nextcloud instance
* @return true - login succeeded, false - login failed * @return true - login succeeded, false - login failed
*/ */
bool login(const string &Url, const string &Username, const string &Pass); bool login(const std::string &Url, const std::string &Username, const std::string &Pass);
/** /**
* Deletes the config files and deletes are temp files * Deletes the config files and deletes are temp files
@ -71,14 +68,14 @@ public:
* @param tempItems set of items where the item is in * @param tempItems set of items where the item is in
* @param itemID id of the item * @param itemID id of the item
*/ */
void downloadItem(vector<Item> &tempItems, int itemID); void downloadItem(std::vector<Item> &tempItems, int itemID);
/** /**
* Downloads a certain folder from the Nextcloud and saves it locally * Downloads a certain folder from the Nextcloud and saves it locally
* @param tempItems set of items where the item is in * @param tempItems set of items where the item is in
* @param itemID id of the item * @param itemID id of the item
*/ */
void downloadFolder(vector<Item> &tempItems, int itemId); void downloadFolder(std::vector<Item> &tempItems, int itemId);
/** /**
* Checks the network connection and starts the download of the certain itemId * Checks the network connection and starts the download of the certain itemId
@ -101,7 +98,7 @@ public:
* @param pathUrl URL to get the dataStructure of * @param pathUrl URL to get the dataStructure of
* @return vector of items * @return vector of items
*/ */
vector<Item> getDataStructure(string &pathUrl); std::vector<Item> getDataStructure(std::string &pathUrl);
/** /**
* formats the pathUrl to a local path * formats the pathUrl to a local path
@ -109,7 +106,7 @@ public:
* @param path online path * @param path online path
* @return local path * @return local path
*/ */
static string getLocalPath(string path); static std::string getLocalPath(std::string path);
/** /**
* checks the local storage checks if the items are locally available * checks the local storage checks if the items are locally available
@ -117,12 +114,12 @@ public:
* @param tempItems items that shall be compared * @param tempItems items that shall be compared
* @param localPath path that has to be checked * @param localPath path that has to be checked
*/ */
void getLocalFileStructure(vector<Item> &tempItems, const string &localPath); void getLocalFileStructure(std::vector<Item> &tempItems, const std::string &localPath);
private: private:
vector<Item> _items; std::vector<Item> _items;
bool _loggedIn{false}; bool _loggedIn{false};
string _url; std::string _url;
bool _workOffline{false}; bool _workOffline{false};
/** /**
@ -133,13 +130,13 @@ private:
* @param Pass the pass of the Nextcloud instance * @param Pass the pass of the Nextcloud instance
* @return vector of Items * @return vector of Items
*/ */
vector<Item> getDataStructure(const string &pathUrl, const string &Username, const string &Pass); std::vector<Item> getDataStructure(const std::string &pathUrl, const std::string &Username, const std::string &Pass);
string getUrl(); std::string getUrl();
string getUsername(); std::string getUsername();
string getUUID(); std::string getUUID();
string getPassword(); std::string getPassword();
string getStartFolder(); std::string getStartFolder();
/** /**
* Handles the end of the game dialog and lets the user * Handles the end of the game dialog and lets the user
@ -156,14 +153,14 @@ private:
* @param xml xml formatted result from curl call * @param xml xml formatted result from curl call
* @return vector<Item> the items that have been read from the xml * @return vector<Item> the items that have been read from the xml
*/ */
vector<Item> readInXML(string xml); std::vector<Item> readInXML(std::string xml);
/** /**
* Checks if a .structure file exists and if that is the case return a vector of items * Checks if a .structure file exists and if that is the case return a vector of items
* @param pathUrl path that shall be checked * @param pathUrl path that shall be checked
* @return return the items for the structure if available offline * @return return the items for the structure if available offline
*/ */
vector<Item> getOfflineStructure(const string &pathUrl); std::vector<Item> getOfflineStructure(const std::string &pathUrl);
}; };
#endif #endif