Formatting
This commit is contained in:
@@ -11,13 +11,14 @@
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
class ActionManager
|
|
||||||
{
|
class ActionManager
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
ActionManager(char**, int);
|
ActionManager(char**, int);
|
||||||
|
|
||||||
Models::IcarusAction retrieveIcarusAction() const;
|
Models::IcarusAction retrieveIcarusAction() const;
|
||||||
private:
|
private:
|
||||||
constexpr std::array<const char*, 12> supportedFlags() noexcept;
|
constexpr std::array<const char*, 12> supportedFlags() noexcept;
|
||||||
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
||||||
|
|
||||||
@@ -37,7 +38,8 @@ namespace Managers
|
|||||||
|
|
||||||
char **params;
|
char **params;
|
||||||
int paramCount;
|
int paramCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,9 +10,10 @@
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
class CommitManager
|
|
||||||
{
|
class CommitManager
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
CommitManager(Models::IcarusAction&);
|
CommitManager(Models::IcarusAction&);
|
||||||
|
|
||||||
void commitAction();
|
void commitAction();
|
||||||
@@ -22,7 +23,7 @@ namespace Managers
|
|||||||
songs
|
songs
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class ActionValues;
|
enum class ActionValues;
|
||||||
|
|
||||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||||
@@ -43,7 +44,8 @@ namespace Managers
|
|||||||
};
|
};
|
||||||
|
|
||||||
Models::IcarusAction icaAction;
|
Models::IcarusAction icaAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
class FileManager
|
|
||||||
{
|
class FileManager
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
FileManager();
|
FileManager();
|
||||||
FileManager(std::string);
|
FileManager(std::string);
|
||||||
|
|
||||||
@@ -16,14 +17,15 @@ namespace Managers
|
|||||||
|
|
||||||
char* retrieveFileBuffer() const;
|
char* retrieveFileBuffer() const;
|
||||||
int retrieveFileBufferLength() const;
|
int retrieveFileBufferLength() const;
|
||||||
private:
|
private:
|
||||||
void readFile();
|
void readFile();
|
||||||
|
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
char* fileBuffer;
|
char* fileBuffer;
|
||||||
bool fileRead;
|
bool fileRead;
|
||||||
int fileBufferLength;
|
int fileBufferLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,17 +7,19 @@
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
class TokenManager
|
|
||||||
{
|
class TokenManager
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
TokenManager(const Models::User&);
|
TokenManager(const Models::User&);
|
||||||
TokenManager(const Models::User&, Models::API&);
|
TokenManager(const Models::User&, Models::API&);
|
||||||
|
|
||||||
Models::Token requestToken();
|
Models::Token requestToken();
|
||||||
private:
|
private:
|
||||||
Models::API api;
|
Models::API api;
|
||||||
Models::User user;
|
Models::User user;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,19 +8,21 @@
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
class UserManager
|
|
||||||
{
|
class UserManager
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
UserManager(Models::User);
|
UserManager(Models::User);
|
||||||
UserManager(const Models::IcarusAction);
|
UserManager(const Models::IcarusAction);
|
||||||
|
|
||||||
Models::User retrieveUser() const;
|
Models::User retrieveUser() const;
|
||||||
private:
|
private:
|
||||||
void parseUserFromActions();
|
void parseUserFromActions();
|
||||||
|
|
||||||
Models::User user;
|
Models::User user;
|
||||||
Models::IcarusAction icaAction;
|
Models::IcarusAction icaAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,12 +5,15 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct API
|
|
||||||
{
|
class API
|
||||||
|
{
|
||||||
|
public:
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string endpoint;
|
std::string endpoint;
|
||||||
std::string version;
|
std::string version;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct Flags
|
|
||||||
{
|
struct Flags
|
||||||
|
{
|
||||||
std::string flag;
|
std::string flag;
|
||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct IcarusAction
|
|
||||||
{
|
struct IcarusAction
|
||||||
|
{
|
||||||
std::string action;
|
std::string action;
|
||||||
std::vector<Flags> flags;
|
std::vector<Flags> flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct Song
|
|
||||||
{
|
struct Song
|
||||||
|
{
|
||||||
int id;
|
int id;
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string artist;
|
std::string artist;
|
||||||
@@ -18,7 +19,8 @@ namespace Models
|
|||||||
int track;
|
int track;
|
||||||
std::string data;
|
std::string data;
|
||||||
std::string songPath;
|
std::string songPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct Token
|
|
||||||
{
|
struct Token
|
||||||
|
{
|
||||||
std::string accessToken;
|
std::string accessToken;
|
||||||
std::string tokenType;
|
std::string tokenType;
|
||||||
int expiration;
|
int expiration;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,11 +6,13 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct UploadForm
|
|
||||||
{
|
struct UploadForm
|
||||||
|
{
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
namespace Models
|
namespace Models
|
||||||
{
|
{
|
||||||
struct User
|
|
||||||
{
|
struct User
|
||||||
|
{
|
||||||
std::string username;
|
std::string username;
|
||||||
std::string password;
|
std::string password;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,18 +6,20 @@
|
|||||||
|
|
||||||
namespace Parsers
|
namespace Parsers
|
||||||
{
|
{
|
||||||
class APIParser
|
|
||||||
{
|
class APIParser
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
APIParser(Models::IcarusAction);
|
APIParser(Models::IcarusAction);
|
||||||
|
|
||||||
Models::API retrieveAPI() const;
|
Models::API retrieveAPI() const;
|
||||||
private:
|
private:
|
||||||
void parseAPI();
|
void parseAPI();
|
||||||
|
|
||||||
Models::API api;
|
Models::API api;
|
||||||
Models::IcarusAction icaAct;
|
Models::IcarusAction icaAct;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,15 +9,17 @@
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
class Delete : SyncerBase
|
|
||||||
{
|
class Delete : SyncerBase
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
Delete(Models::API);
|
Delete(Models::API);
|
||||||
|
|
||||||
void deleteSong(const Models::Token, Models::Song);
|
void deleteSong(const Models::Token, Models::Song);
|
||||||
private:
|
private:
|
||||||
std::string retrieveUrl(Models::Song);
|
std::string retrieveUrl(Models::Song);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,20 +12,22 @@
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
class Download : SyncerBase
|
|
||||||
{
|
class Download : SyncerBase
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
Download();
|
Download();
|
||||||
Download(Models::API);
|
Download(Models::API);
|
||||||
Download(std::string);
|
Download(std::string);
|
||||||
|
|
||||||
void downloadSong(const Models::Token token, Models::Song);
|
void downloadSong(const Models::Token token, Models::Song);
|
||||||
private:
|
private:
|
||||||
std::string retrieveUrl(Models::Song);
|
std::string retrieveUrl(Models::Song);
|
||||||
|
|
||||||
std::string downloadFilePath;
|
std::string downloadFilePath;
|
||||||
void saveSong(Models::Song&);
|
void saveSong(Models::Song&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,19 +8,21 @@
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
class RetrieveRecords: public SyncerBase
|
|
||||||
{
|
class RetrieveRecords: public SyncerBase
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
RetrieveRecords();
|
RetrieveRecords();
|
||||||
RetrieveRecords(Models::API, Models::Token);
|
RetrieveRecords(Models::API, Models::Token);
|
||||||
|
|
||||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||||
private:
|
private:
|
||||||
void fetchSongs();
|
void fetchSongs();
|
||||||
|
|
||||||
Models::API api;
|
Models::API api;
|
||||||
Models::Token token;
|
Models::Token token;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
class SyncerBase
|
|
||||||
{
|
class SyncerBase
|
||||||
protected:
|
{
|
||||||
|
protected:
|
||||||
Models::API api;
|
Models::API api;
|
||||||
const int OK = 200;
|
const int OK = 200;
|
||||||
const int UNAUTHORIZED = 401;
|
const int UNAUTHORIZED = 401;
|
||||||
@@ -21,7 +22,8 @@ namespace Syncers
|
|||||||
UNAUTHORIZED = 401,
|
UNAUTHORIZED = 401,
|
||||||
NOTFOUND = 404
|
NOTFOUND = 404
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,16 +18,17 @@ namespace fs = std::filesystem;
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
class Upload
|
|
||||||
{
|
class Upload
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
Upload();
|
Upload();
|
||||||
Upload(Models::API);
|
Upload(Models::API);
|
||||||
|
|
||||||
Models::Song uploadSong(const Models::Token&, Models::Song&);
|
Models::Song uploadSong(const Models::Token&, Models::Song&);
|
||||||
void uploadSongsFromDirectory(const Models::Token&,
|
void uploadSongsFromDirectory(const Models::Token&,
|
||||||
const std::string&, const bool, bool);
|
const std::string&, const bool, bool);
|
||||||
private:
|
private:
|
||||||
Managers::FileManager fMgr;
|
Managers::FileManager fMgr;
|
||||||
Models::API api;
|
Models::API api;
|
||||||
Models::Song song;
|
Models::Song song;
|
||||||
@@ -42,7 +43,8 @@ namespace Syncers
|
|||||||
void printSongDetails();
|
void printSongDetails();
|
||||||
void printSongDetails(std::vector<Models::Song>&);
|
void printSongDetails(std::vector<Models::Song>&);
|
||||||
void printJsonData(const nlohmann::json&);
|
void printJsonData(const nlohmann::json&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,22 +13,24 @@
|
|||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
class AboutWindow: public QDialog, public CommonWindow
|
|
||||||
{
|
class AboutWindow: public QDialog, public CommonWindow
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AboutWindow(QWidget* parent=0);
|
AboutWindow(QWidget* parent=0);
|
||||||
~AboutWindow() = default;
|
~AboutWindow() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connections();
|
void connections();
|
||||||
void setupWindow();
|
void setupWindow();
|
||||||
|
|
||||||
std::unique_ptr<QLabel> appName;
|
std::unique_ptr<QLabel> appName;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
|
||||||
class CommonWindow
|
class CommonWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -24,4 +27,7 @@ protected:
|
|||||||
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
|
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
|
||||||
int windowHeight, windowWidth;
|
int windowHeight, windowWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,13 +22,14 @@
|
|||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
class MainWindow: public QMainWindow, public CommonWindow
|
|
||||||
{
|
class MainWindow: public QMainWindow, public CommonWindow
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
~MainWindow() = default;
|
~MainWindow() = default;
|
||||||
private:
|
private:
|
||||||
void configureDownloadSection();
|
void configureDownloadSection();
|
||||||
void configureUploadSection();
|
void configureUploadSection();
|
||||||
void configureWindowDimensions();
|
void configureWindowDimensions();
|
||||||
@@ -70,13 +71,14 @@ namespace UI
|
|||||||
std::unique_ptr<QAction> aboutApplicationQt;
|
std::unique_ptr<QAction> aboutApplicationQt;
|
||||||
|
|
||||||
std::unique_ptr<AboutWindow> aboutWindow;
|
std::unique_ptr<AboutWindow> aboutWindow;
|
||||||
signals:
|
signals:
|
||||||
private slots:
|
private slots:
|
||||||
void uploadSong();
|
void uploadSong();
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
void displaySoftwareInformation();
|
void displaySoftwareInformation();
|
||||||
void setCurrentIndex(int);
|
void setCurrentIndex(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,17 +6,19 @@
|
|||||||
|
|
||||||
namespace Utilities
|
namespace Utilities
|
||||||
{
|
{
|
||||||
class Conversions
|
|
||||||
{
|
class Conversions
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
Conversions();
|
Conversions();
|
||||||
|
|
||||||
void initializeValues();
|
void initializeValues();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void printValue(T);
|
void printValue(T);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,54 +16,55 @@ using Models::IcarusAction;
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
ActionManager::ActionManager(char **param, int paramCount) :
|
#pragma region Constructors
|
||||||
|
ActionManager::ActionManager(char **param, int paramCount) :
|
||||||
params(std::move(param)), paramCount(paramCount)
|
params(std::move(param)), paramCount(paramCount)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
IcarusAction ActionManager::retrieveIcarusAction() const
|
IcarusAction ActionManager::retrieveIcarusAction() const
|
||||||
{
|
{
|
||||||
IcarusAction icarusAction;
|
IcarusAction icarusAction;
|
||||||
icarusAction.flags = flags;
|
icarusAction.flags = flags;
|
||||||
icarusAction.action = action;
|
icarusAction.action = action;
|
||||||
|
|
||||||
return icarusAction;
|
return icarusAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constexpr std::array<const char*, 12> ActionManager::supportedFlags() noexcept
|
constexpr std::array<const char*, 12> ActionManager::supportedFlags() noexcept
|
||||||
{
|
{
|
||||||
constexpr std::array<const char*, 12> allFlags{"-u", "-p", "-t", "-h", "-s",
|
constexpr std::array<const char*, 12> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||||
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc"};
|
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc"};
|
||||||
|
|
||||||
return allFlags;
|
return allFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ActionManager::isNumber(string_view val) noexcept
|
bool ActionManager::isNumber(string_view val) noexcept
|
||||||
{
|
{
|
||||||
return !val.empty() && std::find_if(val.begin(),
|
return !val.empty() && std::find_if(val.begin(),
|
||||||
val.end(), [](char c)
|
val.end(), [](char c)
|
||||||
{
|
{
|
||||||
return !std::isdigit(c);
|
return !std::isdigit(c);
|
||||||
}) == val.end();
|
}) == val.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManager::initialize()
|
void ActionManager::initialize()
|
||||||
{
|
{
|
||||||
validateFlags();
|
validateFlags();
|
||||||
|
|
||||||
action = std::move(string{params[1]});
|
action = std::move(string{params[1]});
|
||||||
transform(action.begin(), action.end(),
|
transform(action.begin(), action.end(),
|
||||||
action.begin(), ::tolower);
|
action.begin(), ::tolower);
|
||||||
}
|
}
|
||||||
void ActionManager::validateFlags()
|
void ActionManager::validateFlags()
|
||||||
{
|
{
|
||||||
cout<<"Validating flags"<<endl;
|
cout<<"Validating flags"<<endl;
|
||||||
|
|
||||||
auto flagVals = parsedFlags();
|
auto flagVals = parsedFlags();
|
||||||
@@ -83,7 +84,7 @@ namespace Managers
|
|||||||
if (flag.size() > 3 || isNumber(flag))
|
if (flag.size() > 3 || isNumber(flag))
|
||||||
{
|
{
|
||||||
flg.value = flag;
|
flg.value = flag;
|
||||||
//cout<<"flag value "<<flg.value<<endl;
|
|
||||||
flags.push_back(flg);
|
flags.push_back(flg);
|
||||||
flg = Flags{};
|
flg = Flags{};
|
||||||
continue;
|
continue;
|
||||||
@@ -95,7 +96,6 @@ namespace Managers
|
|||||||
return !flag.compare(val);
|
return !flag.compare(val);
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
//cout<<"flag "<<flag<<endl;
|
|
||||||
flg.flag = flag;
|
flg.flag = flag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -104,10 +104,10 @@ namespace Managers
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> ActionManager::parsedFlags()
|
vector<string> ActionManager::parsedFlags()
|
||||||
{
|
{
|
||||||
auto parsed = vector<string>();
|
auto parsed = vector<string>();
|
||||||
|
|
||||||
for (auto i = 2; i < paramCount; ++i)
|
for (auto i = 2; i < paramCount; ++i)
|
||||||
@@ -117,11 +117,11 @@ namespace Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma
|
#pragma region Testing
|
||||||
void ActionManager::printAction() noexcept
|
void ActionManager::printAction() noexcept
|
||||||
{
|
{
|
||||||
if (action.empty())
|
if (action.empty())
|
||||||
{
|
{
|
||||||
printf("Action is empty\n");
|
printf("Action is empty\n");
|
||||||
@@ -130,16 +130,17 @@ namespace Managers
|
|||||||
{
|
{
|
||||||
cout<<"Action is "<<action<<endl;
|
cout<<"Action is "<<action<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ActionManager::printFlags() noexcept
|
void ActionManager::printFlags() noexcept
|
||||||
{
|
{
|
||||||
cout<<"\nPrinting flags..."<<endl;
|
cout<<"\nPrinting flags..."<<endl;
|
||||||
for (auto flag: flags)
|
for (auto flag: flags)
|
||||||
{
|
{
|
||||||
cout<<"flag "<<flag.flag<<endl;
|
cout<<"flag "<<flag.flag<<endl;
|
||||||
cout<<"value "<<flag.value<<endl;
|
cout<<"value "<<flag.value<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma Testing
|
#pragma endregion
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,16 @@ using Syncers::Upload;
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
#pragma region Constructors
|
||||||
{ }
|
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
||||||
#pragma Constructors
|
{ }
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
void CommitManager::commitAction()
|
void CommitManager::commitAction()
|
||||||
{
|
{
|
||||||
auto action = icaAction.action;
|
auto action = icaAction.action;
|
||||||
cout<<"Commiting "<<action<<" action"<<endl;
|
cout<<"Commiting "<<action<<" action"<<endl;
|
||||||
switch (mapActions()[action])
|
switch (mapActions()[action])
|
||||||
@@ -61,14 +62,14 @@ namespace Managers
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum class ActionValues;
|
enum class ActionValues;
|
||||||
|
|
||||||
std::map<std::string, CommitManager::ActionValues>
|
std::map<std::string, CommitManager::ActionValues>
|
||||||
CommitManager::mapActions() noexcept
|
CommitManager::mapActions() noexcept
|
||||||
{
|
{
|
||||||
const std::map<std::string, ActionValues> actions{
|
const std::map<std::string, ActionValues> actions{
|
||||||
{"delete", ActionValues::deleteAct},
|
{"delete", ActionValues::deleteAct},
|
||||||
{"download", ActionValues::downloadAct},
|
{"download", ActionValues::downloadAct},
|
||||||
@@ -77,11 +78,11 @@ namespace Managers
|
|||||||
};
|
};
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Token CommitManager::parseToken(API api)
|
Token CommitManager::parseToken(API api)
|
||||||
{
|
{
|
||||||
cout<<"fetching token"<<endl;
|
cout<<"fetching token"<<endl;
|
||||||
UserManager usrMgr{icaAction};
|
UserManager usrMgr{icaAction};
|
||||||
auto user = usrMgr.retrieveUser();
|
auto user = usrMgr.retrieveUser();
|
||||||
@@ -89,10 +90,10 @@ namespace Managers
|
|||||||
TokenManager tk{user, api};
|
TokenManager tk{user, api};
|
||||||
|
|
||||||
return tk.requestToken();
|
return tk.requestToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommitManager::deleteSong()
|
void CommitManager::deleteSong()
|
||||||
{
|
{
|
||||||
APIParser apiPrs{icaAction};
|
APIParser apiPrs{icaAction};
|
||||||
auto api = apiPrs.retrieveAPI();
|
auto api = apiPrs.retrieveAPI();
|
||||||
|
|
||||||
@@ -114,9 +115,9 @@ namespace Managers
|
|||||||
Delete del{api};
|
Delete del{api};
|
||||||
cout<<"Deleting song..."<<endl;
|
cout<<"Deleting song..."<<endl;
|
||||||
del.deleteSong(token, song);
|
del.deleteSong(token, song);
|
||||||
}
|
}
|
||||||
void CommitManager::downloadSong()
|
void CommitManager::downloadSong()
|
||||||
{
|
{
|
||||||
cout<<"Starting downloading process..."<<endl;
|
cout<<"Starting downloading process..."<<endl;
|
||||||
|
|
||||||
APIParser apiPrs{icaAction};
|
APIParser apiPrs{icaAction};
|
||||||
@@ -144,9 +145,9 @@ namespace Managers
|
|||||||
Download dnld{api};
|
Download dnld{api};
|
||||||
cout<<"downloading song"<<endl;
|
cout<<"downloading song"<<endl;
|
||||||
dnld.downloadSong(token, song);
|
dnld.downloadSong(token, song);
|
||||||
}
|
}
|
||||||
void CommitManager::retrieveObjects()
|
void CommitManager::retrieveObjects()
|
||||||
{
|
{
|
||||||
cout<<"Starting retrieve process..."<<endl;
|
cout<<"Starting retrieve process..."<<endl;
|
||||||
|
|
||||||
APIParser apiPrs{icaAction};
|
APIParser apiPrs{icaAction};
|
||||||
@@ -173,9 +174,9 @@ namespace Managers
|
|||||||
RetrieveRecords songs{api, token};
|
RetrieveRecords songs{api, token};
|
||||||
songs.retrieve(retrieveType);
|
songs.retrieve(retrieveType);
|
||||||
|
|
||||||
}
|
}
|
||||||
void CommitManager::uploadSong()
|
void CommitManager::uploadSong()
|
||||||
{
|
{
|
||||||
auto uploadSingleSong = true;
|
auto uploadSingleSong = true;
|
||||||
auto recursiveDirectory = false;
|
auto recursiveDirectory = false;
|
||||||
auto noConfirm = false;
|
auto noConfirm = false;
|
||||||
@@ -224,6 +225,7 @@ namespace Managers
|
|||||||
cout<<"Uploading songs from " << songDirectory << endl;
|
cout<<"Uploading songs from " << songDirectory << endl;
|
||||||
upld.uploadSongsFromDirectory(token, songDirectory, noConfirm, recursiveDirectory);
|
upld.uploadSongsFromDirectory(token, songDirectory, noConfirm, recursiveDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,26 +11,30 @@ using std::string;
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
FileManager::FileManager() {}
|
|
||||||
FileManager::FileManager(string filePath)
|
#pragma region Constructors
|
||||||
{
|
FileManager::FileManager() {}
|
||||||
|
FileManager::FileManager(string filePath)
|
||||||
|
{
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
readFile();
|
readFile();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
void FileManager::saveFile(string newFilePath)
|
#pragma region Functions
|
||||||
{
|
void FileManager::saveFile(string newFilePath)
|
||||||
|
{
|
||||||
if (!fileRead)
|
if (!fileRead)
|
||||||
readFile();
|
readFile();
|
||||||
|
|
||||||
ofstream of{newFilePath, ofstream::binary};
|
ofstream of{newFilePath, ofstream::binary};
|
||||||
of.write(fileBuffer, fileBufferLength);
|
of.write(fileBuffer, fileBufferLength);
|
||||||
of.close();
|
of.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::readFile()
|
void FileManager::readFile()
|
||||||
{
|
{
|
||||||
ifstream is{filePath, ifstream::binary};
|
ifstream is{filePath, ifstream::binary};
|
||||||
if (is)
|
if (is)
|
||||||
{
|
{
|
||||||
@@ -51,16 +55,19 @@ namespace Managers
|
|||||||
is.close();
|
is.close();
|
||||||
fileRead = true;
|
fileRead = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void FileManager::modifyFilePath(string filePath)
|
void FileManager::modifyFilePath(string filePath)
|
||||||
{
|
{
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* FileManager::retrieveFileBuffer() const
|
char* FileManager::retrieveFileBuffer() const
|
||||||
{
|
{
|
||||||
return fileBuffer;
|
return fileBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,24 +17,25 @@ using Models::User;
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
TokenManager::TokenManager(const User& user)
|
#pragma region Constructors
|
||||||
{
|
TokenManager::TokenManager(const User& user)
|
||||||
|
{
|
||||||
this->user = user;
|
this->user = user;
|
||||||
}
|
}
|
||||||
TokenManager::TokenManager(const User& user, API& api)
|
TokenManager::TokenManager(const User& user, API& api)
|
||||||
{
|
{
|
||||||
this->user = user;
|
this->user = user;
|
||||||
this->api = api;
|
this->api = api;
|
||||||
this->api.endpoint = "api/" + api.version
|
this->api.endpoint = "api/" + api.version
|
||||||
+ "/login";
|
+ "/login";
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
Token TokenManager::requestToken()
|
Token TokenManager::requestToken()
|
||||||
{
|
{
|
||||||
Token token{};
|
Token token{};
|
||||||
json usrObj;
|
json usrObj;
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ namespace Managers
|
|||||||
cout<<"status code "<<r.status_code<<endl;
|
cout<<"status code "<<r.status_code<<endl;
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,29 @@ using Models::User;
|
|||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
UserManager::UserManager(User user)
|
#pragma region Constructors
|
||||||
{
|
UserManager::UserManager(User user)
|
||||||
|
{
|
||||||
this->user = user;
|
this->user = user;
|
||||||
}
|
}
|
||||||
UserManager::UserManager(const IcarusAction icaAct)
|
UserManager::UserManager(const IcarusAction icaAct)
|
||||||
{
|
{
|
||||||
this->icaAction = icaAct;
|
this->icaAction = icaAct;
|
||||||
this->user = User{};
|
this->user = User{};
|
||||||
parseUserFromActions();
|
parseUserFromActions();
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
User UserManager::retrieveUser() const
|
User UserManager::retrieveUser() const
|
||||||
{
|
{
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserManager::parseUserFromActions()
|
void UserManager::parseUserFromActions()
|
||||||
{
|
{
|
||||||
auto args = icaAction.flags;
|
auto args = icaAction.flags;
|
||||||
|
|
||||||
for (auto arg : args)
|
for (auto arg : args)
|
||||||
@@ -48,6 +49,7 @@ namespace Managers
|
|||||||
user.password = arg.value;
|
user.password = arg.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-16
@@ -1,6 +1,6 @@
|
|||||||
#include"Parsers/APIParser.h"
|
#include "Parsers/APIParser.h"
|
||||||
|
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@@ -10,25 +10,26 @@ using Models::IcarusAction;
|
|||||||
|
|
||||||
namespace Parsers
|
namespace Parsers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
#pragma region Constructors
|
||||||
{
|
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
||||||
|
{
|
||||||
api = API{};
|
api = API{};
|
||||||
parseAPI();
|
parseAPI();
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
API APIParser::retrieveAPI() const
|
API APIParser::retrieveAPI() const
|
||||||
{
|
{
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIParser::parseAPI()
|
void APIParser::parseAPI()
|
||||||
{
|
{
|
||||||
auto flags = icaAct.flags;
|
auto flags = icaAct.flags;
|
||||||
cout<<"Parsing api"<<endl;
|
cout << "Parsing api" << endl;
|
||||||
|
|
||||||
for (auto i =0; i < flags.size(); ++i)
|
for (auto i =0; i < flags.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,7 @@ namespace Parsers
|
|||||||
// the api version since I am only
|
// the api version since I am only
|
||||||
// on version 1
|
// on version 1
|
||||||
api.version = "v1";
|
api.version = "v1";
|
||||||
}
|
}
|
||||||
#pragma functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-17
@@ -1,9 +1,9 @@
|
|||||||
#include"Syncers/Delete.h"
|
#include "Syncers/Delete.h"
|
||||||
|
|
||||||
#include<exception>
|
#include <exception>
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include<cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@@ -16,18 +16,19 @@ using Models::Token;
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
Delete::Delete(API api)
|
#pragma region Constructors
|
||||||
{
|
Delete::Delete(API api)
|
||||||
|
{
|
||||||
this->api = api;
|
this->api = api;
|
||||||
this->api.endpoint = "song/data";
|
this->api.endpoint = "song/data";
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
void Delete::deleteSong(const Token token, Song song)
|
void Delete::deleteSong(const Token token, Song song)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto url = retrieveUrl(song);
|
auto url = retrieveUrl(song);
|
||||||
@@ -46,10 +47,10 @@ namespace Syncers
|
|||||||
cout<<msg<<endl;
|
cout<<msg<<endl;
|
||||||
}
|
}
|
||||||
cout<<"Finished"<<endl;
|
cout<<"Finished"<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Delete::retrieveUrl(Song song)
|
string Delete::retrieveUrl(Song song)
|
||||||
{
|
{
|
||||||
string url{api.url + "api/" + api.version + "/" +
|
string url{api.url + "api/" + api.version + "/" +
|
||||||
api.endpoint + "/"};
|
api.endpoint + "/"};
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ namespace Syncers
|
|||||||
cout<<"url "<<url<<endl;
|
cout<<"url "<<url<<endl;
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-25
@@ -1,10 +1,10 @@
|
|||||||
#include"Syncers/Download.h"
|
#include "Syncers/Download.h"
|
||||||
|
|
||||||
#include<exception>
|
#include <exception>
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
#include<fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include<cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@@ -18,23 +18,24 @@ using Models::Token;
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
#pragma
|
|
||||||
Download::Download() { }
|
#pragma region Constructors
|
||||||
Download::Download(API api)
|
Download::Download() { }
|
||||||
{
|
Download::Download(API api)
|
||||||
|
{
|
||||||
this->api = api;
|
this->api = api;
|
||||||
this->api.endpoint = "song/data";
|
this->api.endpoint = "song/data";
|
||||||
}
|
}
|
||||||
Download::Download(string filePath)
|
Download::Download(string filePath)
|
||||||
{
|
{
|
||||||
downloadFilePath = filePath;
|
downloadFilePath = filePath;
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Functions
|
||||||
void Download::downloadSong(const Token token, Song song)
|
void Download::downloadSong(const Token token, Song song)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string url = retrieveUrl(song);
|
string url = retrieveUrl(song);
|
||||||
@@ -63,10 +64,10 @@ namespace Syncers
|
|||||||
auto msg = e.what();
|
auto msg = e.what();
|
||||||
cout<<msg<<endl;
|
cout<<msg<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string Download::retrieveUrl(Song song)
|
string Download::retrieveUrl(Song song)
|
||||||
{
|
{
|
||||||
string url{api.url + "api/" + api.version + "/" +
|
string url{api.url + "api/" + api.version + "/" +
|
||||||
api.endpoint + "/"};
|
api.endpoint + "/"};
|
||||||
|
|
||||||
@@ -74,10 +75,10 @@ namespace Syncers
|
|||||||
cout<<"url "<<url<<endl;
|
cout<<"url "<<url<<endl;
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Download::saveSong(Song& song)
|
void Download::saveSong(Song& song)
|
||||||
{
|
{
|
||||||
cout<<"\nSaving song to: "<<song.songPath<<endl;
|
cout<<"\nSaving song to: "<<song.songPath<<endl;
|
||||||
int bufferLength = song.data.length();
|
int bufferLength = song.data.length();
|
||||||
const char *data = song.data.c_str();
|
const char *data = song.data.c_str();
|
||||||
@@ -86,6 +87,7 @@ namespace Syncers
|
|||||||
ofstream saveSong{song.songPath, std::ios::binary};
|
ofstream saveSong{song.songPath, std::ios::binary};
|
||||||
saveSong.write(data, bufferLength);
|
saveSong.write(data, bufferLength);
|
||||||
saveSong.close();
|
saveSong.close();
|
||||||
}
|
}
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,15 @@ using Utilities::Conversions;
|
|||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
|
|
||||||
RetrieveRecords::RetrieveRecords() { }
|
#pragma region Constructors
|
||||||
RetrieveRecords::RetrieveRecords(API api, Token token)
|
RetrieveRecords::RetrieveRecords() { }
|
||||||
|
RetrieveRecords::RetrieveRecords(API api, Token token)
|
||||||
: token(token), api(api) { }
|
: token(token), api(api) { }
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
void RetrieveRecords::retrieve(CommitManager::RetrieveTypes type)
|
#pragma region Functions
|
||||||
{
|
void RetrieveRecords::retrieve(CommitManager::RetrieveTypes type)
|
||||||
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CommitManager::RetrieveTypes::songs:
|
case CommitManager::RetrieveTypes::songs:
|
||||||
@@ -34,9 +37,9 @@ namespace Syncers
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RetrieveRecords::fetchSongs()
|
void RetrieveRecords::fetchSongs()
|
||||||
{
|
{
|
||||||
cout<<"fetching songs"<<endl;
|
cout<<"fetching songs"<<endl;
|
||||||
auto url = api.url + "api/" + api.version + "/" + "song";
|
auto url = api.url + "api/" + api.version + "/" + "song";
|
||||||
|
|
||||||
@@ -58,5 +61,7 @@ namespace Syncers
|
|||||||
writeData.open("songs.json");
|
writeData.open("songs.json");
|
||||||
writeData<<songData.dump(4);
|
writeData<<songData.dump(4);
|
||||||
writeData.close();
|
writeData.close();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-31
@@ -24,15 +24,19 @@ using namespace cpr;
|
|||||||
|
|
||||||
namespace Syncers
|
namespace Syncers
|
||||||
{
|
{
|
||||||
Upload::Upload() { }
|
|
||||||
Upload::Upload(API api) : api(api)
|
#pragma region Constructors
|
||||||
{
|
Upload::Upload() { }
|
||||||
|
Upload::Upload(API api) : api(api)
|
||||||
|
{
|
||||||
this->api.endpoint = "song/data";
|
this->api.endpoint = "song/data";
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
Song Upload::uploadSong(const Models::Token& token, Song& song)
|
#pragma region Functions
|
||||||
{
|
Song Upload::uploadSong(const Models::Token& token, Song& song)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto url = retrieveUrl();
|
auto url = retrieveUrl();
|
||||||
@@ -68,12 +72,12 @@ namespace Syncers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Upload::uploadSongsFromDirectory(const Models::Token& token,
|
void Upload::uploadSongsFromDirectory(const Models::Token& token,
|
||||||
const std::string& directory,
|
const std::string& directory,
|
||||||
const bool noConfirm, bool recursive = false)
|
const bool noConfirm, bool recursive = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto songs = retrieveAllSongsFromDirectory(directory, recursive);
|
auto songs = retrieveAllSongsFromDirectory(directory, recursive);
|
||||||
@@ -113,12 +117,12 @@ namespace Syncers
|
|||||||
{
|
{
|
||||||
cout<<e.what()<<endl;
|
cout<<e.what()<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
||||||
bool recursive)
|
bool recursive)
|
||||||
{
|
{
|
||||||
std::vector<Song> allSongs;
|
std::vector<Song> allSongs;
|
||||||
if (recursive)
|
if (recursive)
|
||||||
{
|
{
|
||||||
@@ -140,20 +144,20 @@ namespace Syncers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return allSongs;
|
return allSongs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string Upload::retrieveUrl()
|
string Upload::retrieveUrl()
|
||||||
{
|
{
|
||||||
const string url{api.url + "api/" + api.version + "/" +
|
const string url{api.url + "api/" + api.version + "/" +
|
||||||
api.endpoint};
|
api.endpoint};
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
||||||
{
|
{
|
||||||
constexpr auto mp3Ext = ".mp3";
|
constexpr auto mp3Ext = ".mp3";
|
||||||
Song song;
|
Song song;
|
||||||
if (fs::is_regular_file(dirEntry.path()))
|
if (fs::is_regular_file(dirEntry.path()))
|
||||||
@@ -167,12 +171,12 @@ namespace Syncers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma
|
#pragma region Testing
|
||||||
void Upload::printSongDetails()
|
void Upload::printSongDetails()
|
||||||
{
|
{
|
||||||
cout<<"Song details: "<<endl;
|
cout<<"Song details: "<<endl;
|
||||||
cout<<"Id: "<<song.id<<endl;
|
cout<<"Id: "<<song.id<<endl;
|
||||||
cout<<"Title: "<<song.title<<endl;
|
cout<<"Title: "<<song.title<<endl;
|
||||||
@@ -181,9 +185,9 @@ namespace Syncers
|
|||||||
cout<<"Genre: "<<song.genre<<endl;
|
cout<<"Genre: "<<song.genre<<endl;
|
||||||
cout<<"Year: "<<song.year<<endl;
|
cout<<"Year: "<<song.year<<endl;
|
||||||
cout<<"Duration: "<<song.duration<<endl;
|
cout<<"Duration: "<<song.duration<<endl;
|
||||||
}
|
}
|
||||||
void Upload::printSongDetails(std::vector<Song>& songs)
|
void Upload::printSongDetails(std::vector<Song>& songs)
|
||||||
{
|
{
|
||||||
for (auto& song: songs)
|
for (auto& song: songs)
|
||||||
{
|
{
|
||||||
cout<<"Song details: "<<endl;
|
cout<<"Song details: "<<endl;
|
||||||
@@ -196,9 +200,9 @@ namespace Syncers
|
|||||||
cout<<"Duration: "<<song.duration<<endl;
|
cout<<"Duration: "<<song.duration<<endl;
|
||||||
cout<<"Path: "<<song.songPath<<endl;
|
cout<<"Path: "<<song.songPath<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Upload::printJsonData(const json& obj)
|
void Upload::printJsonData(const json& obj)
|
||||||
{
|
{
|
||||||
cout<<endl<<endl<<"JSon data: "<<endl;
|
cout<<endl<<endl<<"JSon data: "<<endl;
|
||||||
cout<<"id: "<<obj["id"]<<endl;
|
cout<<"id: "<<obj["id"]<<endl;
|
||||||
cout<<"title: "<<obj["title"]<<endl;
|
cout<<"title: "<<obj["title"]<<endl;
|
||||||
@@ -210,7 +214,8 @@ namespace Syncers
|
|||||||
cout<<"song_data: "<<obj["song_data"]<<endl;
|
cout<<"song_data: "<<obj["song_data"]<<endl;
|
||||||
|
|
||||||
cout<<endl<<endl;;
|
cout<<endl<<endl;;
|
||||||
}
|
}
|
||||||
#pragma Testing
|
#pragma endregion
|
||||||
#pragma Functions
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-16
@@ -1,17 +1,20 @@
|
|||||||
#include"UI/AboutWindow.h"
|
#include "UI/AboutWindow.h"
|
||||||
|
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
#pragma region Constructors
|
||||||
{
|
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
||||||
|
{
|
||||||
setupWindow();
|
setupWindow();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
void AboutWindow::setupWindow()
|
#pragma region Functions
|
||||||
{
|
void AboutWindow::setupWindow()
|
||||||
|
{
|
||||||
windowWidth = 250;
|
windowWidth = 250;
|
||||||
windowHeight = 300;
|
windowHeight = 300;
|
||||||
|
|
||||||
@@ -32,16 +35,18 @@ namespace UI
|
|||||||
setWindowTitle("About");
|
setWindowTitle("About");
|
||||||
|
|
||||||
connections();
|
connections();
|
||||||
}
|
}
|
||||||
void AboutWindow::connections()
|
void AboutWindow::connections()
|
||||||
{
|
{
|
||||||
QObject::connect(actionButtonQt.get(), SIGNAL(clicked()), this,
|
QObject::connect(actionButtonQt.get(), SIGNAL(clicked()), this,
|
||||||
SLOT(closeWindow()));
|
SLOT(closeWindow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AboutWindow::closeWindow()
|
void AboutWindow::closeWindow()
|
||||||
{
|
{
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-48
@@ -1,11 +1,11 @@
|
|||||||
#include"UI/MainWindow.h"
|
#include "UI/MainWindow.h"
|
||||||
|
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
#include<string>
|
#include <string>
|
||||||
|
|
||||||
#include"Models/UploadForm.h"
|
#include "Models/UploadForm.h"
|
||||||
#include"Syncers/Upload.h"
|
#include "Syncers/Upload.h"
|
||||||
#include"Utilities/Conversions.h"
|
#include "Utilities/Conversions.h"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@@ -17,18 +17,22 @@ using Syncers::Upload;
|
|||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
MainWindow::MainWindow()
|
|
||||||
{
|
#pragma region Constructors
|
||||||
|
MainWindow::MainWindow()
|
||||||
|
{
|
||||||
setupMainWindow();
|
setupMainWindow();
|
||||||
aboutWindow = unique_ptr<AboutWindow>{new AboutWindow};
|
aboutWindow = unique_ptr<AboutWindow>{new AboutWindow};
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::configureDownloadSection()
|
#pragma region Functions
|
||||||
{
|
void MainWindow::configureDownloadSection()
|
||||||
}
|
{
|
||||||
void MainWindow::configureUploadSection()
|
}
|
||||||
{
|
void MainWindow::configureUploadSection()
|
||||||
|
{
|
||||||
uploadSongQt = unique_ptr<QPushButton>{new QPushButton(tr("Upload"))};
|
uploadSongQt = unique_ptr<QPushButton>{new QPushButton(tr("Upload"))};
|
||||||
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||||
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||||
@@ -49,20 +53,20 @@ namespace UI
|
|||||||
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
||||||
subLayoutOneQt->addLayout(songPathPortion.get());
|
subLayoutOneQt->addLayout(songPathPortion.get());
|
||||||
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
||||||
}
|
}
|
||||||
void MainWindow::configureWindowDimensions()
|
void MainWindow::configureWindowDimensions()
|
||||||
{
|
{
|
||||||
windowWidth = 450;
|
windowWidth = 450;
|
||||||
windowHeight = 450;
|
windowHeight = 450;
|
||||||
}
|
}
|
||||||
void MainWindow::configureWindowProperties()
|
void MainWindow::configureWindowProperties()
|
||||||
{
|
{
|
||||||
setWindowTitle("IcarusDownloadManager");
|
setWindowTitle("IcarusDownloadManager");
|
||||||
setFixedHeight(windowHeight);
|
setFixedHeight(windowHeight);
|
||||||
setFixedWidth(windowWidth);
|
setFixedWidth(windowWidth);
|
||||||
}
|
}
|
||||||
void MainWindow::connections()
|
void MainWindow::connections()
|
||||||
{
|
{
|
||||||
QObject::connect(uploadSongQt.get(), SIGNAL(clicked()), this, SLOT(uploadSong()));
|
QObject::connect(uploadSongQt.get(), SIGNAL(clicked()), this, SLOT(uploadSong()));
|
||||||
QObject::connect(closeApplicationQt.get(), SIGNAL(triggered()), this,
|
QObject::connect(closeApplicationQt.get(), SIGNAL(triggered()), this,
|
||||||
SLOT(exitApplication()));
|
SLOT(exitApplication()));
|
||||||
@@ -70,9 +74,9 @@ namespace UI
|
|||||||
SLOT(displaySoftwareInformation()));
|
SLOT(displaySoftwareInformation()));
|
||||||
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
||||||
this, SLOT(setCurrentIndex(int)));
|
this, SLOT(setCurrentIndex(int)));
|
||||||
}
|
}
|
||||||
void MainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
fileMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
fileMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||||
editMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
editMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||||
helpMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Help"))};
|
helpMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Help"))};
|
||||||
@@ -86,9 +90,9 @@ namespace UI
|
|||||||
fileMenuQt->addAction(closeApplicationQt.get());
|
fileMenuQt->addAction(closeApplicationQt.get());
|
||||||
helpMenuQt->addAction(aboutApplicationQt.get());
|
helpMenuQt->addAction(aboutApplicationQt.get());
|
||||||
|
|
||||||
}
|
}
|
||||||
void MainWindow::setupMainWidget()
|
void MainWindow::setupMainWidget()
|
||||||
{
|
{
|
||||||
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||||
|
|
||||||
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
|
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
|
||||||
@@ -104,9 +108,9 @@ namespace UI
|
|||||||
stackLayout->addWidget(uploadSongWidgetQt.get());
|
stackLayout->addWidget(uploadSongWidgetQt.get());
|
||||||
|
|
||||||
mainWidgetQt->setLayout(stackLayout.get());
|
mainWidgetQt->setLayout(stackLayout.get());
|
||||||
}
|
}
|
||||||
void MainWindow::setupMainWindow()
|
void MainWindow::setupMainWindow()
|
||||||
{
|
{
|
||||||
configureWindowDimensions();
|
configureWindowDimensions();
|
||||||
|
|
||||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
@@ -130,34 +134,34 @@ namespace UI
|
|||||||
configureWindowProperties();
|
configureWindowProperties();
|
||||||
|
|
||||||
connections();
|
connections();
|
||||||
}
|
}
|
||||||
void MainWindow::setupWindowLists()
|
void MainWindow::setupWindowLists()
|
||||||
{
|
{
|
||||||
windowComboBox->addItem(tr("Upload song"));
|
windowComboBox->addItem(tr("Upload song"));
|
||||||
windowComboBox->addItem(tr("Download song"));
|
windowComboBox->addItem(tr("Download song"));
|
||||||
windowComboBox->addItem(tr("Display all songs"));
|
windowComboBox->addItem(tr("Display all songs"));
|
||||||
windowComboBox->addItem(tr("Display songs"));
|
windowComboBox->addItem(tr("Display songs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::exitApplication()
|
void MainWindow::exitApplication()
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
void MainWindow::displaySoftwareInformation()
|
void MainWindow::displaySoftwareInformation()
|
||||||
{
|
{
|
||||||
aboutWindow->show();
|
aboutWindow->show();
|
||||||
}
|
}
|
||||||
void MainWindow::setCurrentIndex(int index)
|
void MainWindow::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
cout<<"index "<<index<<endl;
|
cout<<"index "<<index<<endl;
|
||||||
QString qText = windowComboBox->itemText(index);
|
QString qText = windowComboBox->itemText(index);
|
||||||
auto cnvert = Utilities::Conversions(qText);
|
auto cnvert = Utilities::Conversions(qText);
|
||||||
auto convertedStr = cnvert.convertQStringToString();
|
auto convertedStr = cnvert.convertQStringToString();
|
||||||
cout<<"item text"<<endl;
|
cout<<"item text"<<endl;
|
||||||
}
|
}
|
||||||
void MainWindow::uploadSong()
|
void MainWindow::uploadSong()
|
||||||
{
|
{
|
||||||
uploadSongQt->setEnabled(false);
|
uploadSongQt->setEnabled(false);
|
||||||
|
|
||||||
string url = urlQt->toPlainText().toUtf8().constData();
|
string url = urlQt->toPlainText().toUtf8().constData();
|
||||||
@@ -170,5 +174,7 @@ namespace UI
|
|||||||
upld.uploadSong();
|
upld.uploadSong();
|
||||||
|
|
||||||
uploadSongQt->setEnabled(true);
|
uploadSongQt->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
#include"Utilities/Conversions.h"
|
#include "Utilities/Conversions.h"
|
||||||
|
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
namespace Utilities
|
namespace Utilities
|
||||||
{
|
{
|
||||||
Conversions::Conversions()
|
|
||||||
{
|
|
||||||
initializeValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Conversions::initializeValues()
|
Conversions::Conversions()
|
||||||
{
|
{
|
||||||
}
|
initializeValues();
|
||||||
template <typename T>
|
}
|
||||||
void Conversions::printValue(T val)
|
|
||||||
{
|
void Conversions::initializeValues()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
void Conversions::printValue(T val)
|
||||||
|
{
|
||||||
std::cout<<"going to print value"<<std::endl;
|
std::cout<<"going to print value"<<std::endl;
|
||||||
std::cout<<val<<std::endl;
|
std::cout<<val<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user