Formatting
This commit is contained in:
@@ -11,33 +11,35 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class ActionManager
|
||||
{
|
||||
public:
|
||||
ActionManager(char**, int);
|
||||
|
||||
Models::IcarusAction retrieveIcarusAction() const;
|
||||
private:
|
||||
constexpr std::array<const char*, 12> supportedFlags() noexcept;
|
||||
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
||||
class ActionManager
|
||||
{
|
||||
public:
|
||||
ActionManager(char**, int);
|
||||
|
||||
bool isNumber(const std::string_view) noexcept;
|
||||
Models::IcarusAction retrieveIcarusAction() const;
|
||||
private:
|
||||
constexpr std::array<const char*, 12> supportedFlags() noexcept;
|
||||
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
||||
|
||||
void initialize();
|
||||
void validateFlags();
|
||||
bool isNumber(const std::string_view) noexcept;
|
||||
|
||||
std::vector<std::string> parsedFlags();
|
||||
void initialize();
|
||||
void validateFlags();
|
||||
|
||||
void printAction() noexcept;
|
||||
void printFlags() noexcept;
|
||||
std::vector<std::string> parsedFlags();
|
||||
|
||||
std::string action;
|
||||
void printAction() noexcept;
|
||||
void printFlags() noexcept;
|
||||
|
||||
std::vector<Models::Flags> flags;
|
||||
std::string action;
|
||||
|
||||
std::vector<Models::Flags> flags;
|
||||
|
||||
char **params;
|
||||
int paramCount;
|
||||
};
|
||||
|
||||
char **params;
|
||||
int paramCount;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,40 +10,42 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class CommitManager
|
||||
|
||||
class CommitManager
|
||||
{
|
||||
public:
|
||||
CommitManager(Models::IcarusAction&);
|
||||
|
||||
void commitAction();
|
||||
|
||||
enum class RetrieveTypes
|
||||
{
|
||||
public:
|
||||
CommitManager(Models::IcarusAction&);
|
||||
|
||||
void commitAction();
|
||||
|
||||
enum class RetrieveTypes
|
||||
{
|
||||
songs
|
||||
};
|
||||
|
||||
private:
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||
|
||||
Models::Token parseToken(Models::API);
|
||||
|
||||
void deleteSong();
|
||||
void downloadSong();
|
||||
void retrieveObjects();
|
||||
void uploadSong();
|
||||
|
||||
enum class ActionValues
|
||||
{
|
||||
deleteAct,
|
||||
downloadAct,
|
||||
retrieveAct,
|
||||
uploadAct
|
||||
};
|
||||
|
||||
Models::IcarusAction icaAction;
|
||||
songs
|
||||
};
|
||||
|
||||
private:
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||
|
||||
Models::Token parseToken(Models::API);
|
||||
|
||||
void deleteSong();
|
||||
void downloadSong();
|
||||
void retrieveObjects();
|
||||
void uploadSong();
|
||||
|
||||
enum class ActionValues
|
||||
{
|
||||
deleteAct,
|
||||
downloadAct,
|
||||
retrieveAct,
|
||||
uploadAct
|
||||
};
|
||||
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,25 +5,27 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(std::string);
|
||||
|
||||
void saveFile(std::string);
|
||||
void modifyFilePath(std::string);
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(std::string);
|
||||
|
||||
char* retrieveFileBuffer() const;
|
||||
int retrieveFileBufferLength() const;
|
||||
private:
|
||||
void readFile();
|
||||
void saveFile(std::string);
|
||||
void modifyFilePath(std::string);
|
||||
|
||||
char* retrieveFileBuffer() const;
|
||||
int retrieveFileBufferLength() const;
|
||||
private:
|
||||
void readFile();
|
||||
|
||||
std::string filePath;
|
||||
char* fileBuffer;
|
||||
bool fileRead;
|
||||
int fileBufferLength;
|
||||
};
|
||||
|
||||
std::string filePath;
|
||||
char* fileBuffer;
|
||||
bool fileRead;
|
||||
int fileBufferLength;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,17 +7,19 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class TokenManager
|
||||
{
|
||||
public:
|
||||
TokenManager(const Models::User&);
|
||||
TokenManager(const Models::User&, Models::API&);
|
||||
|
||||
Models::Token requestToken();
|
||||
private:
|
||||
Models::API api;
|
||||
Models::User user;
|
||||
};
|
||||
class TokenManager
|
||||
{
|
||||
public:
|
||||
TokenManager(const Models::User&);
|
||||
TokenManager(const Models::User&, Models::API&);
|
||||
|
||||
Models::Token requestToken();
|
||||
private:
|
||||
Models::API api;
|
||||
Models::User user;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
UserManager(Models::User);
|
||||
UserManager(const Models::IcarusAction);
|
||||
|
||||
Models::User retrieveUser() const;
|
||||
private:
|
||||
void parseUserFromActions();
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
UserManager(Models::User);
|
||||
UserManager(const Models::IcarusAction);
|
||||
|
||||
Models::User retrieveUser() const;
|
||||
private:
|
||||
void parseUserFromActions();
|
||||
|
||||
Models::User user;
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
|
||||
Models::User user;
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct API
|
||||
{
|
||||
std::string url;
|
||||
std::string endpoint;
|
||||
std::string version;
|
||||
};
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
std::string url;
|
||||
std::string endpoint;
|
||||
std::string version;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct Flags
|
||||
{
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct Flags
|
||||
{
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct IcarusAction
|
||||
{
|
||||
std::string action;
|
||||
std::vector<Flags> flags;
|
||||
};
|
||||
|
||||
struct IcarusAction
|
||||
{
|
||||
std::string action;
|
||||
std::vector<Flags> flags;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+15
-13
@@ -6,19 +6,21 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct Song
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
std::string data;
|
||||
std::string songPath;
|
||||
};
|
||||
|
||||
struct Song
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
std::string data;
|
||||
std::string songPath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct Token
|
||||
{
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
struct Token
|
||||
{
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct UploadForm
|
||||
{
|
||||
std::string url;
|
||||
std::string filePath;
|
||||
};
|
||||
|
||||
struct UploadForm
|
||||
{
|
||||
std::string url;
|
||||
std::string filePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct User
|
||||
{
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
struct User
|
||||
{
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+12
-10
@@ -6,18 +6,20 @@
|
||||
|
||||
namespace Parsers
|
||||
{
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
APIParser(Models::IcarusAction);
|
||||
|
||||
Models::API retrieveAPI() const;
|
||||
private:
|
||||
void parseAPI();
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
APIParser(Models::IcarusAction);
|
||||
|
||||
Models::API retrieveAPI() const;
|
||||
private:
|
||||
void parseAPI();
|
||||
|
||||
Models::API api;
|
||||
Models::IcarusAction icaAct;
|
||||
};
|
||||
|
||||
Models::API api;
|
||||
Models::IcarusAction icaAct;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
Delete(Models::API);
|
||||
|
||||
void deleteSong(const Models::Token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
};
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
Delete(Models::API);
|
||||
|
||||
void deleteSong(const Models::Token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+14
-12
@@ -12,20 +12,22 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
Download();
|
||||
Download(Models::API);
|
||||
Download(std::string);
|
||||
|
||||
void downloadSong(const Models::Token token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
Download();
|
||||
Download(Models::API);
|
||||
Download(std::string);
|
||||
|
||||
void downloadSong(const Models::Token token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
|
||||
std::string downloadFilePath;
|
||||
void saveSong(Models::Song&);
|
||||
};
|
||||
|
||||
std::string downloadFilePath;
|
||||
void saveSong(Models::Song&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
RetrieveRecords();
|
||||
RetrieveRecords(Models::API, Models::Token);
|
||||
|
||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||
private:
|
||||
void fetchSongs();
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
RetrieveRecords();
|
||||
RetrieveRecords(Models::API, Models::Token);
|
||||
|
||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||
private:
|
||||
void fetchSongs();
|
||||
|
||||
Models::API api;
|
||||
Models::Token token;
|
||||
};
|
||||
|
||||
Models::API api;
|
||||
Models::Token token;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,21 +7,23 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
Models::API api;
|
||||
const int OK = 200;
|
||||
const int UNAUTHORIZED = 401;
|
||||
const int NOTFOUND = 404;
|
||||
|
||||
enum class Result
|
||||
{
|
||||
OK = 200,
|
||||
UNAUTHORIZED = 401,
|
||||
NOTFOUND = 404
|
||||
};
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
Models::API api;
|
||||
const int OK = 200;
|
||||
const int UNAUTHORIZED = 401;
|
||||
const int NOTFOUND = 404;
|
||||
|
||||
enum class Result
|
||||
{
|
||||
OK = 200,
|
||||
UNAUTHORIZED = 401,
|
||||
NOTFOUND = 404
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+22
-20
@@ -18,31 +18,33 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Upload
|
||||
{
|
||||
public:
|
||||
Upload();
|
||||
Upload(Models::API);
|
||||
|
||||
Models::Song uploadSong(const Models::Token&, Models::Song&);
|
||||
void uploadSongsFromDirectory(const Models::Token&,
|
||||
const std::string&, const bool, bool);
|
||||
private:
|
||||
Managers::FileManager fMgr;
|
||||
Models::API api;
|
||||
Models::Song song;
|
||||
class Upload
|
||||
{
|
||||
public:
|
||||
Upload();
|
||||
Upload(Models::API);
|
||||
|
||||
std::vector<Models::Song> retrieveAllSongsFromDirectory(const std::string&,
|
||||
bool);
|
||||
Models::Song uploadSong(const Models::Token&, Models::Song&);
|
||||
void uploadSongsFromDirectory(const Models::Token&,
|
||||
const std::string&, const bool, bool);
|
||||
private:
|
||||
Managers::FileManager fMgr;
|
||||
Models::API api;
|
||||
Models::Song song;
|
||||
|
||||
std::string retrieveUrl();
|
||||
std::vector<Models::Song> retrieveAllSongsFromDirectory(const std::string&,
|
||||
bool);
|
||||
|
||||
Models::Song retrieveSongPath(fs::directory_entry&);
|
||||
std::string retrieveUrl();
|
||||
|
||||
Models::Song retrieveSongPath(fs::directory_entry&);
|
||||
|
||||
void printSongDetails();
|
||||
void printSongDetails(std::vector<Models::Song>&);
|
||||
void printJsonData(const nlohmann::json&);
|
||||
};
|
||||
|
||||
void printSongDetails();
|
||||
void printSongDetails(std::vector<Models::Song>&);
|
||||
void printJsonData(const nlohmann::json&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+15
-13
@@ -13,22 +13,24 @@
|
||||
|
||||
namespace UI
|
||||
{
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AboutWindow(QWidget* parent=0);
|
||||
~AboutWindow() = default;
|
||||
|
||||
private:
|
||||
void connections();
|
||||
void setupWindow();
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AboutWindow(QWidget* parent=0);
|
||||
~AboutWindow() = default;
|
||||
|
||||
std::unique_ptr<QLabel> appName;
|
||||
private:
|
||||
void connections();
|
||||
void setupWindow();
|
||||
|
||||
std::unique_ptr<QLabel> appName;
|
||||
|
||||
private slots:
|
||||
void closeWindow();
|
||||
};
|
||||
|
||||
private slots:
|
||||
void closeWindow();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include<QPushButton>
|
||||
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
||||
class CommonWindow
|
||||
{
|
||||
public:
|
||||
@@ -24,4 +27,7 @@ protected:
|
||||
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
|
||||
int windowHeight, windowWidth;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+44
-42
@@ -22,61 +22,63 @@
|
||||
|
||||
namespace UI
|
||||
{
|
||||
class MainWindow: public QMainWindow, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow() = default;
|
||||
private:
|
||||
void configureDownloadSection();
|
||||
void configureUploadSection();
|
||||
void configureWindowDimensions();
|
||||
void configureWindowProperties();
|
||||
void connections();
|
||||
void createMenus();
|
||||
void setupMainWidget();
|
||||
void setupMainWindow();
|
||||
void setupWindowLists();
|
||||
|
||||
class MainWindow: public QMainWindow, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow() = default;
|
||||
private:
|
||||
void configureDownloadSection();
|
||||
void configureUploadSection();
|
||||
void configureWindowDimensions();
|
||||
void configureWindowProperties();
|
||||
void connections();
|
||||
void createMenus();
|
||||
void setupMainWidget();
|
||||
void setupMainWindow();
|
||||
void setupWindowLists();
|
||||
|
||||
|
||||
std::unique_ptr<QStackedWidget> widgetStack;
|
||||
std::unique_ptr<QStackedWidget> widgetStack;
|
||||
|
||||
std::unique_ptr<QVBoxLayout> stackLayout;
|
||||
std::unique_ptr<QVBoxLayout> stackLayout;
|
||||
|
||||
std::unique_ptr<QHBoxLayout> urlPortion;
|
||||
std::unique_ptr<QHBoxLayout> songPathPortion;
|
||||
std::unique_ptr<QHBoxLayout> urlPortion;
|
||||
std::unique_ptr<QHBoxLayout> songPathPortion;
|
||||
|
||||
std::unique_ptr<QWidget> mainWidgetQt;
|
||||
std::unique_ptr<QWidget> uploadSongWidgetQt;
|
||||
std::unique_ptr<QWidget> mainWidgetQt;
|
||||
std::unique_ptr<QWidget> uploadSongWidgetQt;
|
||||
|
||||
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
||||
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
||||
|
||||
std::unique_ptr<QComboBox> windowComboBox;
|
||||
std::unique_ptr<QComboBox> windowComboBox;
|
||||
|
||||
std::unique_ptr<QPushButton> uploadSongQt;
|
||||
std::unique_ptr<QPushButton> uploadSongQt;
|
||||
|
||||
std::unique_ptr<QTextEdit> urlQt;
|
||||
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
||||
std::unique_ptr<QTextEdit> urlQt;
|
||||
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
||||
|
||||
std::unique_ptr<QLabel> urlLabel;
|
||||
std::unique_ptr<QLabel> songPath;
|
||||
std::unique_ptr<QLabel> urlLabel;
|
||||
std::unique_ptr<QLabel> songPath;
|
||||
|
||||
std::unique_ptr<QMenu> fileMenuQt;
|
||||
std::unique_ptr<QMenu> editMenuQt;
|
||||
std::unique_ptr<QMenu> helpMenuQt;
|
||||
std::unique_ptr<QMenu> fileMenuQt;
|
||||
std::unique_ptr<QMenu> editMenuQt;
|
||||
std::unique_ptr<QMenu> helpMenuQt;
|
||||
|
||||
std::unique_ptr<QAction> closeApplicationQt;
|
||||
std::unique_ptr<QAction> aboutApplicationQt;
|
||||
std::unique_ptr<QAction> closeApplicationQt;
|
||||
std::unique_ptr<QAction> aboutApplicationQt;
|
||||
|
||||
std::unique_ptr<AboutWindow> aboutWindow;
|
||||
signals:
|
||||
private slots:
|
||||
void uploadSong();
|
||||
void exitApplication();
|
||||
void displaySoftwareInformation();
|
||||
void setCurrentIndex(int);
|
||||
};
|
||||
|
||||
std::unique_ptr<AboutWindow> aboutWindow;
|
||||
signals:
|
||||
private slots:
|
||||
void uploadSong();
|
||||
void exitApplication();
|
||||
void displaySoftwareInformation();
|
||||
void setCurrentIndex(int);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,17 +6,19 @@
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
class Conversions
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
void initializeValues();
|
||||
class Conversions
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
void initializeValues();
|
||||
|
||||
template <typename T>
|
||||
void printValue(T);
|
||||
private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void printValue(T);
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+107
-106
@@ -16,130 +16,131 @@ using Models::IcarusAction;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
ActionManager::ActionManager(char **param, int paramCount) :
|
||||
params(std::move(param)), paramCount(paramCount)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
#pragma Constructors
|
||||
|
||||
#pragma region Constructors
|
||||
ActionManager::ActionManager(char **param, int paramCount) :
|
||||
params(std::move(param)), paramCount(paramCount)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
IcarusAction ActionManager::retrieveIcarusAction() const
|
||||
{
|
||||
IcarusAction icarusAction;
|
||||
icarusAction.flags = flags;
|
||||
icarusAction.action = action;
|
||||
#pragma region Functions
|
||||
IcarusAction ActionManager::retrieveIcarusAction() const
|
||||
{
|
||||
IcarusAction icarusAction;
|
||||
icarusAction.flags = flags;
|
||||
icarusAction.action = action;
|
||||
|
||||
return icarusAction;
|
||||
}
|
||||
return icarusAction;
|
||||
}
|
||||
|
||||
|
||||
constexpr std::array<const char*, 12> ActionManager::supportedFlags() noexcept
|
||||
{
|
||||
constexpr std::array<const char*, 12> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc"};
|
||||
constexpr std::array<const char*, 12> ActionManager::supportedFlags() noexcept
|
||||
{
|
||||
constexpr std::array<const char*, 12> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc"};
|
||||
|
||||
return allFlags;
|
||||
}
|
||||
return allFlags;
|
||||
}
|
||||
|
||||
|
||||
bool ActionManager::isNumber(string_view val) noexcept
|
||||
{
|
||||
return !val.empty() && std::find_if(val.begin(),
|
||||
val.end(), [](char c)
|
||||
{
|
||||
return !std::isdigit(c);
|
||||
}) == val.end();
|
||||
}
|
||||
|
||||
void ActionManager::initialize()
|
||||
{
|
||||
validateFlags();
|
||||
|
||||
action = std::move(string{params[1]});
|
||||
transform(action.begin(), action.end(),
|
||||
action.begin(), ::tolower);
|
||||
}
|
||||
void ActionManager::validateFlags()
|
||||
{
|
||||
cout<<"Validating flags"<<endl;
|
||||
|
||||
auto flagVals = parsedFlags();
|
||||
|
||||
Flags flg{};
|
||||
|
||||
auto allSupportedFlags = supportedFlags();
|
||||
|
||||
for (auto flag : flagVals)
|
||||
bool ActionManager::isNumber(string_view val) noexcept
|
||||
{
|
||||
return !val.empty() && std::find_if(val.begin(),
|
||||
val.end(), [](char c)
|
||||
{
|
||||
if (flag.compare("-nc") == 0)
|
||||
{
|
||||
flg.flag = flag;
|
||||
flags.push_back(flg);
|
||||
continue;
|
||||
}
|
||||
if (flag.size() > 3 || isNumber(flag))
|
||||
{
|
||||
flg.value = flag;
|
||||
//cout<<"flag value "<<flg.value<<endl;
|
||||
flags.push_back(flg);
|
||||
flg = Flags{};
|
||||
continue;
|
||||
}
|
||||
return !std::isdigit(c);
|
||||
}) == val.end();
|
||||
}
|
||||
|
||||
if (std::any_of(allSupportedFlags.begin(), allSupportedFlags.end(),
|
||||
[&](const char *val)
|
||||
{
|
||||
return !flag.compare(val);
|
||||
}))
|
||||
{
|
||||
//cout<<"flag "<<flag<<endl;
|
||||
flg.flag = flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"Flag is not valid"<<endl;
|
||||
exit(1);
|
||||
}
|
||||
void ActionManager::initialize()
|
||||
{
|
||||
validateFlags();
|
||||
|
||||
action = std::move(string{params[1]});
|
||||
transform(action.begin(), action.end(),
|
||||
action.begin(), ::tolower);
|
||||
}
|
||||
void ActionManager::validateFlags()
|
||||
{
|
||||
cout<<"Validating flags"<<endl;
|
||||
|
||||
auto flagVals = parsedFlags();
|
||||
|
||||
Flags flg{};
|
||||
|
||||
auto allSupportedFlags = supportedFlags();
|
||||
|
||||
for (auto flag : flagVals)
|
||||
{
|
||||
if (flag.compare("-nc") == 0)
|
||||
{
|
||||
flg.flag = flag;
|
||||
flags.push_back(flg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> ActionManager::parsedFlags()
|
||||
{
|
||||
auto parsed = vector<string>();
|
||||
|
||||
for (auto i = 2; i < paramCount; ++i)
|
||||
if (flag.size() > 3 || isNumber(flag))
|
||||
{
|
||||
const std::string flag(std::move(*(params + i)));
|
||||
parsed.push_back(std::move(flag));
|
||||
flg.value = flag;
|
||||
|
||||
flags.push_back(flg);
|
||||
flg = Flags{};
|
||||
continue;
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
#pragma
|
||||
void ActionManager::printAction() noexcept
|
||||
{
|
||||
if (action.empty())
|
||||
if (std::any_of(allSupportedFlags.begin(), allSupportedFlags.end(),
|
||||
[&](const char *val)
|
||||
{
|
||||
return !flag.compare(val);
|
||||
}))
|
||||
{
|
||||
printf("Action is empty\n");
|
||||
flg.flag = flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"Action is "<<action<<endl;
|
||||
cout<<"Flag is not valid"<<endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
void ActionManager::printFlags() noexcept
|
||||
{
|
||||
cout<<"\nPrinting flags..."<<endl;
|
||||
for (auto flag: flags)
|
||||
{
|
||||
cout<<"flag "<<flag.flag<<endl;
|
||||
cout<<"value "<<flag.value<<endl;
|
||||
}
|
||||
}
|
||||
#pragma Testing
|
||||
#pragma Functions
|
||||
}
|
||||
|
||||
vector<string> ActionManager::parsedFlags()
|
||||
{
|
||||
auto parsed = vector<string>();
|
||||
|
||||
for (auto i = 2; i < paramCount; ++i)
|
||||
{
|
||||
const std::string flag(std::move(*(params + i)));
|
||||
parsed.push_back(std::move(flag));
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
#pragma region Testing
|
||||
void ActionManager::printAction() noexcept
|
||||
{
|
||||
if (action.empty())
|
||||
{
|
||||
printf("Action is empty\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"Action is "<<action<<endl;
|
||||
}
|
||||
}
|
||||
void ActionManager::printFlags() noexcept
|
||||
{
|
||||
cout<<"\nPrinting flags..."<<endl;
|
||||
for (auto flag: flags)
|
||||
{
|
||||
cout<<"flag "<<flag.flag<<endl;
|
||||
cout<<"value "<<flag.value<<endl;
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+191
-189
@@ -33,197 +33,199 @@ using Syncers::Upload;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
||||
{ }
|
||||
#pragma Constructors
|
||||
|
||||
#pragma region Constructors
|
||||
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
||||
{ }
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
void CommitManager::commitAction()
|
||||
{
|
||||
auto action = icaAction.action;
|
||||
cout<<"Commiting "<<action<<" action"<<endl;
|
||||
switch (mapActions()[action])
|
||||
{
|
||||
case ActionValues::deleteAct:
|
||||
deleteSong();
|
||||
break;
|
||||
case ActionValues::downloadAct:
|
||||
downloadSong();
|
||||
break;
|
||||
case ActionValues::retrieveAct:
|
||||
retrieveObjects();
|
||||
break;
|
||||
case ActionValues::uploadAct:
|
||||
uploadSong();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, CommitManager::ActionValues>
|
||||
CommitManager::mapActions() noexcept
|
||||
#pragma region Functions
|
||||
void CommitManager::commitAction()
|
||||
{
|
||||
auto action = icaAction.action;
|
||||
cout<<"Commiting "<<action<<" action"<<endl;
|
||||
switch (mapActions()[action])
|
||||
{
|
||||
const std::map<std::string, ActionValues> actions{
|
||||
{"delete", ActionValues::deleteAct},
|
||||
{"download", ActionValues::downloadAct},
|
||||
{"retrieve", ActionValues::retrieveAct},
|
||||
{"upload", ActionValues::uploadAct}
|
||||
};
|
||||
|
||||
return actions;
|
||||
case ActionValues::deleteAct:
|
||||
deleteSong();
|
||||
break;
|
||||
case ActionValues::downloadAct:
|
||||
downloadSong();
|
||||
break;
|
||||
case ActionValues::retrieveAct:
|
||||
retrieveObjects();
|
||||
break;
|
||||
case ActionValues::uploadAct:
|
||||
uploadSong();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Token CommitManager::parseToken(API api)
|
||||
{
|
||||
cout<<"fetching token"<<endl;
|
||||
UserManager usrMgr{icaAction};
|
||||
auto user = usrMgr.retrieveUser();
|
||||
|
||||
TokenManager tk{user, api};
|
||||
|
||||
return tk.requestToken();
|
||||
}
|
||||
|
||||
void CommitManager::deleteSong()
|
||||
{
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song{};
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-D") == 0)
|
||||
{
|
||||
song.id = atoi(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Delete del{api};
|
||||
cout<<"Deleting song..."<<endl;
|
||||
del.deleteSong(token, song);
|
||||
}
|
||||
void CommitManager::downloadSong()
|
||||
{
|
||||
cout<<"Starting downloading process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song{};
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-d") == 0)
|
||||
{
|
||||
song.songPath.assign(arg.value);
|
||||
}
|
||||
if (flag.compare("-b") == 0)
|
||||
{
|
||||
song.id = atoi(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Download dnld{api};
|
||||
cout<<"downloading song"<<endl;
|
||||
dnld.downloadSong(token, song);
|
||||
}
|
||||
void CommitManager::retrieveObjects()
|
||||
{
|
||||
cout<<"Starting retrieve process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
RetrieveTypes retrieveType;
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-rt") == 0)
|
||||
{
|
||||
if (value.compare("songs") == 0)
|
||||
{
|
||||
retrieveType = RetrieveTypes::songs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RetrieveRecords songs{api, token};
|
||||
songs.retrieve(retrieveType);
|
||||
|
||||
}
|
||||
void CommitManager::uploadSong()
|
||||
{
|
||||
auto uploadSingleSong = true;
|
||||
auto recursiveDirectory = false;
|
||||
auto noConfirm = false;
|
||||
string songDirectory;
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song;
|
||||
|
||||
for (auto& arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-s") == 0)
|
||||
{
|
||||
song.songPath.assign(arg.value);
|
||||
}
|
||||
else if (flag.compare("-sd") == 0)
|
||||
{
|
||||
songDirectory = value;
|
||||
uploadSingleSong = false;
|
||||
}
|
||||
else if (flag.compare("-sr") == 0)
|
||||
{
|
||||
songDirectory = value;
|
||||
uploadSingleSong = false;
|
||||
recursiveDirectory = true;
|
||||
}
|
||||
else if (flag.compare("-nc") == 0)
|
||||
{
|
||||
noConfirm = true;
|
||||
}
|
||||
}
|
||||
|
||||
Upload upld{api};
|
||||
if (uploadSingleSong)
|
||||
{
|
||||
cout<<"Uploading song..."<<endl;
|
||||
upld.uploadSong(token, song);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"Uploading songs from " << songDirectory << endl;
|
||||
upld.uploadSongsFromDirectory(token, songDirectory, noConfirm, recursiveDirectory);
|
||||
}
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
|
||||
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, CommitManager::ActionValues>
|
||||
CommitManager::mapActions() noexcept
|
||||
{
|
||||
const std::map<std::string, ActionValues> actions{
|
||||
{"delete", ActionValues::deleteAct},
|
||||
{"download", ActionValues::downloadAct},
|
||||
{"retrieve", ActionValues::retrieveAct},
|
||||
{"upload", ActionValues::uploadAct}
|
||||
};
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
Token CommitManager::parseToken(API api)
|
||||
{
|
||||
cout<<"fetching token"<<endl;
|
||||
UserManager usrMgr{icaAction};
|
||||
auto user = usrMgr.retrieveUser();
|
||||
|
||||
TokenManager tk{user, api};
|
||||
|
||||
return tk.requestToken();
|
||||
}
|
||||
|
||||
void CommitManager::deleteSong()
|
||||
{
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song{};
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-D") == 0)
|
||||
{
|
||||
song.id = atoi(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Delete del{api};
|
||||
cout<<"Deleting song..."<<endl;
|
||||
del.deleteSong(token, song);
|
||||
}
|
||||
void CommitManager::downloadSong()
|
||||
{
|
||||
cout<<"Starting downloading process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song{};
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-d") == 0)
|
||||
{
|
||||
song.songPath.assign(arg.value);
|
||||
}
|
||||
if (flag.compare("-b") == 0)
|
||||
{
|
||||
song.id = atoi(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Download dnld{api};
|
||||
cout<<"downloading song"<<endl;
|
||||
dnld.downloadSong(token, song);
|
||||
}
|
||||
void CommitManager::retrieveObjects()
|
||||
{
|
||||
cout<<"Starting retrieve process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
RetrieveTypes retrieveType;
|
||||
|
||||
for (auto arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-rt") == 0)
|
||||
{
|
||||
if (value.compare("songs") == 0)
|
||||
{
|
||||
retrieveType = RetrieveTypes::songs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RetrieveRecords songs{api, token};
|
||||
songs.retrieve(retrieveType);
|
||||
|
||||
}
|
||||
void CommitManager::uploadSong()
|
||||
{
|
||||
auto uploadSingleSong = true;
|
||||
auto recursiveDirectory = false;
|
||||
auto noConfirm = false;
|
||||
string songDirectory;
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
auto token = parseToken(api);
|
||||
|
||||
Song song;
|
||||
|
||||
for (auto& arg : icaAction.flags)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
auto value = arg.value;
|
||||
|
||||
if (flag.compare("-s") == 0)
|
||||
{
|
||||
song.songPath.assign(arg.value);
|
||||
}
|
||||
else if (flag.compare("-sd") == 0)
|
||||
{
|
||||
songDirectory = value;
|
||||
uploadSingleSong = false;
|
||||
}
|
||||
else if (flag.compare("-sr") == 0)
|
||||
{
|
||||
songDirectory = value;
|
||||
uploadSingleSong = false;
|
||||
recursiveDirectory = true;
|
||||
}
|
||||
else if (flag.compare("-nc") == 0)
|
||||
{
|
||||
noConfirm = true;
|
||||
}
|
||||
}
|
||||
|
||||
Upload upld{api};
|
||||
if (uploadSingleSong)
|
||||
{
|
||||
cout<<"Uploading song..."<<endl;
|
||||
upld.uploadSong(token, song);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"Uploading songs from " << songDirectory << endl;
|
||||
upld.uploadSongsFromDirectory(token, songDirectory, noConfirm, recursiveDirectory);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -11,56 +11,63 @@ using std::string;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
FileManager::FileManager() {}
|
||||
FileManager::FileManager(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
readFile();
|
||||
}
|
||||
|
||||
|
||||
void FileManager::saveFile(string newFilePath)
|
||||
{
|
||||
if (!fileRead)
|
||||
readFile();
|
||||
|
||||
ofstream of{newFilePath, ofstream::binary};
|
||||
of.write(fileBuffer, fileBufferLength);
|
||||
of.close();
|
||||
}
|
||||
|
||||
void FileManager::readFile()
|
||||
{
|
||||
ifstream is{filePath, ifstream::binary};
|
||||
if (is)
|
||||
{
|
||||
is.seekg (0, is.end);
|
||||
fileBufferLength = is.tellg();
|
||||
is.seekg (0, is.beg);
|
||||
|
||||
fileBuffer = new char [fileBufferLength];
|
||||
|
||||
cout<< "Reading "<<fileBufferLength<<" characters... "<<endl;;
|
||||
is.read (fileBuffer,fileBufferLength);
|
||||
|
||||
if (is)
|
||||
cout<<"all characters read successfully.";
|
||||
else
|
||||
cout<<"error: only "<<is.gcount()<<" could be read";
|
||||
cout<<endl;
|
||||
is.close();
|
||||
fileRead = true;
|
||||
}
|
||||
}
|
||||
void FileManager::modifyFilePath(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
}
|
||||
|
||||
char* FileManager::retrieveFileBuffer() const
|
||||
{
|
||||
return fileBuffer;
|
||||
}
|
||||
|
||||
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
||||
#pragma region Constructors
|
||||
FileManager::FileManager() {}
|
||||
FileManager::FileManager(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
readFile();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
void FileManager::saveFile(string newFilePath)
|
||||
{
|
||||
if (!fileRead)
|
||||
readFile();
|
||||
|
||||
ofstream of{newFilePath, ofstream::binary};
|
||||
of.write(fileBuffer, fileBufferLength);
|
||||
of.close();
|
||||
}
|
||||
|
||||
void FileManager::readFile()
|
||||
{
|
||||
ifstream is{filePath, ifstream::binary};
|
||||
if (is)
|
||||
{
|
||||
is.seekg (0, is.end);
|
||||
fileBufferLength = is.tellg();
|
||||
is.seekg (0, is.beg);
|
||||
|
||||
fileBuffer = new char [fileBufferLength];
|
||||
|
||||
cout<< "Reading "<<fileBufferLength<<" characters... "<<endl;;
|
||||
is.read (fileBuffer,fileBufferLength);
|
||||
|
||||
if (is)
|
||||
cout<<"all characters read successfully.";
|
||||
else
|
||||
cout<<"error: only "<<is.gcount()<<" could be read";
|
||||
cout<<endl;
|
||||
is.close();
|
||||
fileRead = true;
|
||||
}
|
||||
}
|
||||
void FileManager::modifyFilePath(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
}
|
||||
|
||||
char* FileManager::retrieveFileBuffer() const
|
||||
{
|
||||
return fileBuffer;
|
||||
}
|
||||
|
||||
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
||||
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -17,44 +17,46 @@ using Models::User;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
TokenManager::TokenManager(const User& user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
TokenManager::TokenManager(const User& user, API& api)
|
||||
{
|
||||
this->user = user;
|
||||
this->api = api;
|
||||
this->api.endpoint = "api/" + api.version
|
||||
+ "/login";
|
||||
}
|
||||
#pragma Constructors
|
||||
|
||||
|
||||
#pragma
|
||||
Token TokenManager::requestToken()
|
||||
{
|
||||
Token token{};
|
||||
json usrObj;
|
||||
|
||||
usrObj["username"] = user.username;
|
||||
usrObj["password"] = user.password;
|
||||
|
||||
cout<<"Sending request for token"<<endl;
|
||||
auto url = api.url + api.endpoint;
|
||||
cout<<url<<endl;
|
||||
auto r = cpr::Post(cpr::Url{url},
|
||||
cpr::Body{usrObj.dump()},
|
||||
cpr::Header{{"Content-Type", "application/json"}});
|
||||
|
||||
json res = json::parse(r.text);
|
||||
token.accessToken = res["token"];
|
||||
token.tokenType = res["token_type"];
|
||||
|
||||
cout<<"status code "<<r.status_code<<endl;
|
||||
|
||||
return token;
|
||||
}
|
||||
#pragma Functions
|
||||
#pragma region Constructors
|
||||
TokenManager::TokenManager(const User& user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
TokenManager::TokenManager(const User& user, API& api)
|
||||
{
|
||||
this->user = user;
|
||||
this->api = api;
|
||||
this->api.endpoint = "api/" + api.version
|
||||
+ "/login";
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
Token TokenManager::requestToken()
|
||||
{
|
||||
Token token{};
|
||||
json usrObj;
|
||||
|
||||
usrObj["username"] = user.username;
|
||||
usrObj["password"] = user.password;
|
||||
|
||||
cout<<"Sending request for token"<<endl;
|
||||
auto url = api.url + api.endpoint;
|
||||
cout<<url<<endl;
|
||||
auto r = cpr::Post(cpr::Url{url},
|
||||
cpr::Body{usrObj.dump()},
|
||||
cpr::Header{{"Content-Type", "application/json"}});
|
||||
|
||||
json res = json::parse(r.text);
|
||||
token.accessToken = res["token"];
|
||||
token.tokenType = res["token_type"];
|
||||
|
||||
cout<<"status code "<<r.status_code<<endl;
|
||||
|
||||
return token;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -12,42 +12,44 @@ using Models::User;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
UserManager::UserManager(User user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
UserManager::UserManager(const IcarusAction icaAct)
|
||||
{
|
||||
this->icaAction = icaAct;
|
||||
this->user = User{};
|
||||
parseUserFromActions();
|
||||
}
|
||||
#pragma Constructors
|
||||
|
||||
#pragma region Constructors
|
||||
UserManager::UserManager(User user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
UserManager::UserManager(const IcarusAction icaAct)
|
||||
{
|
||||
this->icaAction = icaAct;
|
||||
this->user = User{};
|
||||
parseUserFromActions();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
User UserManager::retrieveUser() const
|
||||
{
|
||||
return user;
|
||||
}
|
||||
#pragma region Functions
|
||||
User UserManager::retrieveUser() const
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
void UserManager::parseUserFromActions()
|
||||
{
|
||||
auto args = icaAction.flags;
|
||||
void UserManager::parseUserFromActions()
|
||||
{
|
||||
auto args = icaAction.flags;
|
||||
|
||||
for (auto arg : args)
|
||||
for (auto arg : args)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
if (flag.compare("-u") == 0)
|
||||
{
|
||||
auto flag = arg.flag;
|
||||
if (flag.compare("-u") == 0)
|
||||
{
|
||||
user.username = arg.value;
|
||||
}
|
||||
if (flag.compare("-p") == 0)
|
||||
{
|
||||
user.password = arg.value;
|
||||
}
|
||||
user.username = arg.value;
|
||||
}
|
||||
if (flag.compare("-p") == 0)
|
||||
{
|
||||
user.password = arg.value;
|
||||
}
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+37
-35
@@ -1,6 +1,6 @@
|
||||
#include"Parsers/APIParser.h"
|
||||
#include "Parsers/APIParser.h"
|
||||
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -10,43 +10,45 @@ using Models::IcarusAction;
|
||||
|
||||
namespace Parsers
|
||||
{
|
||||
#pragma
|
||||
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
||||
|
||||
#pragma region Constructors
|
||||
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
||||
{
|
||||
api = API{};
|
||||
parseAPI();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
API APIParser::retrieveAPI() const
|
||||
{
|
||||
return api;
|
||||
}
|
||||
|
||||
void APIParser::parseAPI()
|
||||
{
|
||||
auto flags = icaAct.flags;
|
||||
cout << "Parsing api" << endl;
|
||||
|
||||
for (auto i =0; i < flags.size(); ++i)
|
||||
{
|
||||
api = API{};
|
||||
parseAPI();
|
||||
}
|
||||
#pragma endregion
|
||||
auto arg = flags[i].flag;
|
||||
auto value = flags[i].value;
|
||||
|
||||
|
||||
#pragma
|
||||
API APIParser::retrieveAPI() const
|
||||
{
|
||||
return api;
|
||||
}
|
||||
|
||||
void APIParser::parseAPI()
|
||||
{
|
||||
auto flags = icaAct.flags;
|
||||
cout<<"Parsing api"<<endl;
|
||||
|
||||
for (auto i =0; i < flags.size(); ++i)
|
||||
if (arg.compare("-h") == 0)
|
||||
{
|
||||
auto arg = flags[i].flag;
|
||||
auto value = flags[i].value;
|
||||
|
||||
if (arg.compare("-h") == 0)
|
||||
{
|
||||
api.url = (value[value.size()-1] == '/') ? value : value + "/";
|
||||
break;
|
||||
}
|
||||
|
||||
api.url = (value[value.size()-1] == '/') ? value : value + "/";
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: For now I will hard code
|
||||
// the api version since I am only
|
||||
// on version 1
|
||||
api.version = "v1";
|
||||
}
|
||||
#pragma functions
|
||||
|
||||
// TODO: For now I will hard code
|
||||
// the api version since I am only
|
||||
// on version 1
|
||||
api.version = "v1";
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+48
-46
@@ -1,9 +1,9 @@
|
||||
#include"Syncers/Delete.h"
|
||||
#include "Syncers/Delete.h"
|
||||
|
||||
#include<exception>
|
||||
#include<iostream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
#include<cpr/cpr.h>
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -16,47 +16,49 @@ using Models::Token;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
#pragma
|
||||
Delete::Delete(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
#pragma Constructors
|
||||
|
||||
|
||||
#pragma
|
||||
void Delete::deleteSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto url = retrieveUrl(song);
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Delete(cpr::Url(url),
|
||||
cpr::Header{{"authorization", auth}});
|
||||
|
||||
auto statusCode = r.status_code;
|
||||
|
||||
cout<<"Status code "<<statusCode<<endl;
|
||||
}
|
||||
catch (exception e)
|
||||
{
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
cout<<"Finished"<<endl;
|
||||
}
|
||||
|
||||
string Delete::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
url.append(std::to_string(song.id));
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
#pragma Functions
|
||||
#pragma region Constructors
|
||||
Delete::Delete(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
void Delete::deleteSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto url = retrieveUrl(song);
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Delete(cpr::Url(url),
|
||||
cpr::Header{{"authorization", auth}});
|
||||
|
||||
auto statusCode = r.status_code;
|
||||
|
||||
cout<<"Status code "<<statusCode<<endl;
|
||||
}
|
||||
catch (exception e)
|
||||
{
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
cout<<"Finished"<<endl;
|
||||
}
|
||||
|
||||
string Delete::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
url.append(std::to_string(song.id));
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+76
-74
@@ -1,10 +1,10 @@
|
||||
#include"Syncers/Download.h"
|
||||
#include "Syncers/Download.h"
|
||||
|
||||
#include<exception>
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include<cpr/cpr.h>
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -18,74 +18,76 @@ using Models::Token;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
#pragma
|
||||
Download::Download() { }
|
||||
Download::Download(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
Download::Download(string filePath)
|
||||
{
|
||||
downloadFilePath = filePath;
|
||||
}
|
||||
#pragma Constructors
|
||||
|
||||
|
||||
#pragma
|
||||
void Download::downloadSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = retrieveUrl(song);
|
||||
song.songPath.append("track.mp3");
|
||||
cout<<"song path "<<song.songPath<<endl;
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
|
||||
auto r = cpr::Get(cpr::Url(url),
|
||||
cpr::Header{{"Content-type", "audio/mpeg"},
|
||||
{"Authorization", auth}});
|
||||
|
||||
|
||||
int statusCode = r.status_code;
|
||||
|
||||
if (statusCode == OK) {
|
||||
song.data = r.text;
|
||||
saveSong(song);
|
||||
}
|
||||
|
||||
|
||||
cout<<"finsihed with status code "<<statusCode<<endl;
|
||||
}
|
||||
catch (exception e)
|
||||
{
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
string Download::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
url.append(std::to_string(song.id));
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
void Download::saveSong(Song& song)
|
||||
{
|
||||
cout<<"\nSaving song to: "<<song.songPath<<endl;
|
||||
int bufferLength = song.data.length();
|
||||
const char *data = song.data.c_str();
|
||||
cout<<"buff length "<<bufferLength<<endl;
|
||||
|
||||
ofstream saveSong{song.songPath, std::ios::binary};
|
||||
saveSong.write(data, bufferLength);
|
||||
saveSong.close();
|
||||
}
|
||||
#pragma Functions
|
||||
#pragma region Constructors
|
||||
Download::Download() { }
|
||||
Download::Download(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
Download::Download(string filePath)
|
||||
{
|
||||
downloadFilePath = filePath;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
void Download::downloadSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = retrieveUrl(song);
|
||||
song.songPath.append("track.mp3");
|
||||
cout<<"song path "<<song.songPath<<endl;
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
|
||||
auto r = cpr::Get(cpr::Url(url),
|
||||
cpr::Header{{"Content-type", "audio/mpeg"},
|
||||
{"Authorization", auth}});
|
||||
|
||||
|
||||
int statusCode = r.status_code;
|
||||
|
||||
if (statusCode == OK) {
|
||||
song.data = r.text;
|
||||
saveSong(song);
|
||||
}
|
||||
|
||||
|
||||
cout<<"finsihed with status code "<<statusCode<<endl;
|
||||
}
|
||||
catch (exception e)
|
||||
{
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
string Download::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
url.append(std::to_string(song.id));
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
void Download::saveSong(Song& song)
|
||||
{
|
||||
cout<<"\nSaving song to: "<<song.songPath<<endl;
|
||||
int bufferLength = song.data.length();
|
||||
const char *data = song.data.c_str();
|
||||
cout<<"buff length "<<bufferLength<<endl;
|
||||
|
||||
ofstream saveSong{song.songPath, std::ios::binary};
|
||||
saveSong.write(data, bufferLength);
|
||||
saveSong.close();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -20,43 +20,48 @@ using Utilities::Conversions;
|
||||
namespace Syncers
|
||||
{
|
||||
|
||||
RetrieveRecords::RetrieveRecords() { }
|
||||
RetrieveRecords::RetrieveRecords(API api, Token token)
|
||||
: token(token), api(api) { }
|
||||
#pragma region Constructors
|
||||
RetrieveRecords::RetrieveRecords() { }
|
||||
RetrieveRecords::RetrieveRecords(API api, Token token)
|
||||
: 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:
|
||||
fetchSongs();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void RetrieveRecords::fetchSongs()
|
||||
{
|
||||
cout<<"fetching songs"<<endl;
|
||||
auto url = api.url + "api/" + api.version + "/" + "song";
|
||||
|
||||
auto auth = token.tokenType;
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Get(cpr::Url{url},
|
||||
cpr::Header{{"authorization", auth},
|
||||
});
|
||||
|
||||
if (r.status_code != (int)Result::OK) {
|
||||
cout<<"something went wrong\n";
|
||||
cout<<"status code: "<<r.status_code<<endl;
|
||||
cout<<"message: "<<r.text<<endl;
|
||||
return;
|
||||
}
|
||||
auto songData = nlohmann::json::parse(r.text);
|
||||
|
||||
ofstream writeData{};
|
||||
writeData.open("songs.json");
|
||||
writeData<<songData.dump(4);
|
||||
writeData.close();
|
||||
case CommitManager::RetrieveTypes::songs:
|
||||
fetchSongs();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void RetrieveRecords::fetchSongs()
|
||||
{
|
||||
cout<<"fetching songs"<<endl;
|
||||
auto url = api.url + "api/" + api.version + "/" + "song";
|
||||
|
||||
auto auth = token.tokenType;
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Get(cpr::Url{url},
|
||||
cpr::Header{{"authorization", auth},
|
||||
});
|
||||
|
||||
if (r.status_code != (int)Result::OK) {
|
||||
cout<<"something went wrong\n";
|
||||
cout<<"status code: "<<r.status_code<<endl;
|
||||
cout<<"message: "<<r.text<<endl;
|
||||
return;
|
||||
}
|
||||
auto songData = nlohmann::json::parse(r.text);
|
||||
|
||||
ofstream writeData{};
|
||||
writeData.open("songs.json");
|
||||
writeData<<songData.dump(4);
|
||||
writeData.close();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+158
-153
@@ -24,154 +24,171 @@ using namespace cpr;
|
||||
|
||||
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";
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
Song Upload::uploadSong(const Models::Token& token, Song& song)
|
||||
{
|
||||
try
|
||||
{
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
auto url = retrieveUrl();
|
||||
|
||||
cout<<"url "<<url<<endl;
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Post(cpr::Url{url},
|
||||
cpr::Multipart{{"key", "small value"},
|
||||
{"file", cpr::File{song.songPath}}},
|
||||
cpr::Header{{"authorization", auth}}
|
||||
);
|
||||
|
||||
Song Upload::uploadSong(const Models::Token& token, Song& song)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto url = retrieveUrl();
|
||||
|
||||
cout<<"url "<<url<<endl;
|
||||
string auth{token.tokenType};
|
||||
auth.append(" " + token.accessToken);
|
||||
auto r = cpr::Post(cpr::Url{url},
|
||||
cpr::Multipart{{"key", "small value"},
|
||||
{"file", cpr::File{song.songPath}}},
|
||||
cpr::Header{{"authorization", auth}}
|
||||
);
|
||||
|
||||
cout << "status code: " << r.status_code<< std::endl;
|
||||
cout << r.text << endl;
|
||||
auto result = nlohmann::json::parse(r.text);
|
||||
cout<<"Finished"<<endl;
|
||||
song.id = result["id"].get<int>();
|
||||
song.title = result["title"].get<std::string>();
|
||||
song.artist = result["artist"].get<std::string>();
|
||||
song.album = result["album"].get<std::string>();
|
||||
song.genre = result["genre"].get<std::string>();
|
||||
song.year = result["year"].get<int>();
|
||||
song.duration = result["duration"].get<int>();
|
||||
song.track = result["track"].get<int>();
|
||||
|
||||
return song;
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
cout << "status code: " << r.status_code<< std::endl;
|
||||
cout << r.text << endl;
|
||||
auto result = nlohmann::json::parse(r.text);
|
||||
cout<<"Finished"<<endl;
|
||||
song.id = result["id"].get<int>();
|
||||
song.title = result["title"].get<std::string>();
|
||||
song.artist = result["artist"].get<std::string>();
|
||||
song.album = result["album"].get<std::string>();
|
||||
song.genre = result["genre"].get<std::string>();
|
||||
song.year = result["year"].get<int>();
|
||||
song.duration = result["duration"].get<int>();
|
||||
song.track = result["track"].get<int>();
|
||||
|
||||
return song;
|
||||
}
|
||||
|
||||
void Upload::uploadSongsFromDirectory(const Models::Token& token,
|
||||
const std::string& directory,
|
||||
const bool noConfirm, bool recursive = false)
|
||||
catch (exception& e)
|
||||
{
|
||||
try
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
|
||||
return song;
|
||||
}
|
||||
|
||||
void Upload::uploadSongsFromDirectory(const Models::Token& token,
|
||||
const std::string& directory,
|
||||
const bool noConfirm, bool recursive = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto songs = retrieveAllSongsFromDirectory(directory, recursive);
|
||||
auto confirmUpload = true;
|
||||
|
||||
while (!noConfirm)
|
||||
{
|
||||
auto songs = retrieveAllSongsFromDirectory(directory, recursive);
|
||||
auto confirmUpload = true;
|
||||
auto answer = 'a';
|
||||
cout << "are you sure you want to upload " << songs.size() << " songs? [y/n]";
|
||||
cin >> answer;
|
||||
|
||||
while (!noConfirm)
|
||||
if (answer == 'y' || answer == 'Y')
|
||||
{
|
||||
auto answer = 'a';
|
||||
cout << "are you sure you want to upload " << songs.size() << " songs? [y/n]";
|
||||
cin >> answer;
|
||||
|
||||
if (answer == 'y' || answer == 'Y')
|
||||
{
|
||||
confirmUpload = true;
|
||||
break;
|
||||
}
|
||||
else if (answer == 'n' || answer == 'N')
|
||||
{
|
||||
confirmUpload = false;
|
||||
break;
|
||||
}
|
||||
confirmUpload = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!confirmUpload)
|
||||
else if (answer == 'n' || answer == 'N')
|
||||
{
|
||||
cout << "exiting...\n";
|
||||
std::exit(-1);
|
||||
}
|
||||
|
||||
cout << "uploading songs\n";
|
||||
for (auto& song: songs)
|
||||
{
|
||||
song = uploadSong(token, song);
|
||||
confirmUpload = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (exception& e)
|
||||
|
||||
if (!confirmUpload)
|
||||
{
|
||||
cout<<e.what()<<endl;
|
||||
cout << "exiting...\n";
|
||||
std::exit(-1);
|
||||
}
|
||||
|
||||
cout << "uploading songs\n";
|
||||
for (auto& song: songs)
|
||||
{
|
||||
song = uploadSong(token, song);
|
||||
}
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
cout<<e.what()<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
||||
bool recursive)
|
||||
{
|
||||
std::vector<Song> allSongs;
|
||||
if (recursive)
|
||||
{
|
||||
for (auto p: fs::recursive_directory_iterator(directory))
|
||||
{
|
||||
auto song = retrieveSongPath(p);
|
||||
if (!song.songPath.empty())
|
||||
allSongs.push_back(song);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto p: fs::directory_iterator(directory))
|
||||
{
|
||||
auto song = retrieveSongPath(p);
|
||||
if (!song.songPath.empty())
|
||||
allSongs.push_back(song);
|
||||
}
|
||||
}
|
||||
|
||||
return allSongs;
|
||||
}
|
||||
|
||||
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
||||
bool recursive)
|
||||
|
||||
string Upload::retrieveUrl()
|
||||
{
|
||||
const string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint};
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
||||
{
|
||||
constexpr auto mp3Ext = ".mp3";
|
||||
Song song;
|
||||
if (fs::is_regular_file(dirEntry.path()))
|
||||
{
|
||||
std::vector<Song> allSongs;
|
||||
if (recursive)
|
||||
const auto ext = dirEntry.path().extension().string();
|
||||
if (ext.compare(mp3Ext) == 0)
|
||||
{
|
||||
for (auto p: fs::recursive_directory_iterator(directory))
|
||||
{
|
||||
auto song = retrieveSongPath(p);
|
||||
if (!song.songPath.empty())
|
||||
allSongs.push_back(song);
|
||||
}
|
||||
cout << "found mp3 file" << endl;
|
||||
song.songPath = dirEntry.path().string();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto p: fs::directory_iterator(directory))
|
||||
{
|
||||
auto song = retrieveSongPath(p);
|
||||
if (!song.songPath.empty())
|
||||
allSongs.push_back(song);
|
||||
}
|
||||
}
|
||||
|
||||
return allSongs;
|
||||
}
|
||||
|
||||
|
||||
string Upload::retrieveUrl()
|
||||
{
|
||||
const string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint};
|
||||
|
||||
return url;
|
||||
}
|
||||
return song;
|
||||
}
|
||||
|
||||
|
||||
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
||||
{
|
||||
constexpr auto mp3Ext = ".mp3";
|
||||
Song song;
|
||||
if (fs::is_regular_file(dirEntry.path()))
|
||||
{
|
||||
const auto ext = dirEntry.path().extension().string();
|
||||
if (ext.compare(mp3Ext) == 0)
|
||||
{
|
||||
cout << "found mp3 file" << endl;
|
||||
song.songPath = dirEntry.path().string();
|
||||
}
|
||||
}
|
||||
|
||||
return song;
|
||||
}
|
||||
|
||||
|
||||
#pragma
|
||||
void Upload::printSongDetails()
|
||||
#pragma region Testing
|
||||
void Upload::printSongDetails()
|
||||
{
|
||||
cout<<"Song details: "<<endl;
|
||||
cout<<"Id: "<<song.id<<endl;
|
||||
cout<<"Title: "<<song.title<<endl;
|
||||
cout<<"Artist: "<<song.artist<<endl;
|
||||
cout<<"Album: "<<song.album<<endl;
|
||||
cout<<"Genre: "<<song.genre<<endl;
|
||||
cout<<"Year: "<<song.year<<endl;
|
||||
cout<<"Duration: "<<song.duration<<endl;
|
||||
}
|
||||
void Upload::printSongDetails(std::vector<Song>& songs)
|
||||
{
|
||||
for (auto& song: songs)
|
||||
{
|
||||
cout<<"Song details: "<<endl;
|
||||
cout<<"Id: "<<song.id<<endl;
|
||||
@@ -181,36 +198,24 @@ namespace Syncers
|
||||
cout<<"Genre: "<<song.genre<<endl;
|
||||
cout<<"Year: "<<song.year<<endl;
|
||||
cout<<"Duration: "<<song.duration<<endl;
|
||||
cout<<"Path: "<<song.songPath<<endl;
|
||||
}
|
||||
void Upload::printSongDetails(std::vector<Song>& songs)
|
||||
{
|
||||
for (auto& song: songs)
|
||||
{
|
||||
cout<<"Song details: "<<endl;
|
||||
cout<<"Id: "<<song.id<<endl;
|
||||
cout<<"Title: "<<song.title<<endl;
|
||||
cout<<"Artist: "<<song.artist<<endl;
|
||||
cout<<"Album: "<<song.album<<endl;
|
||||
cout<<"Genre: "<<song.genre<<endl;
|
||||
cout<<"Year: "<<song.year<<endl;
|
||||
cout<<"Duration: "<<song.duration<<endl;
|
||||
cout<<"Path: "<<song.songPath<<endl;
|
||||
}
|
||||
}
|
||||
void Upload::printJsonData(const json& obj)
|
||||
{
|
||||
cout<<endl<<endl<<"JSon data: "<<endl;
|
||||
cout<<"id: "<<obj["id"]<<endl;
|
||||
cout<<"title: "<<obj["title"]<<endl;
|
||||
cout<<"artist: "<<obj["artist"]<<endl;
|
||||
cout<<"album: "<<obj["album"]<<endl;
|
||||
cout<<"genre: "<<obj["genre"]<<endl;
|
||||
cout<<"year: "<<obj["year"]<<endl;
|
||||
cout<<"duration: "<<obj["duration"]<<endl;
|
||||
cout<<"song_data: "<<obj["song_data"]<<endl;
|
||||
|
||||
cout<<endl<<endl;;
|
||||
}
|
||||
#pragma Testing
|
||||
#pragma Functions
|
||||
}
|
||||
void Upload::printJsonData(const json& obj)
|
||||
{
|
||||
cout<<endl<<endl<<"JSon data: "<<endl;
|
||||
cout<<"id: "<<obj["id"]<<endl;
|
||||
cout<<"title: "<<obj["title"]<<endl;
|
||||
cout<<"artist: "<<obj["artist"]<<endl;
|
||||
cout<<"album: "<<obj["album"]<<endl;
|
||||
cout<<"genre: "<<obj["genre"]<<endl;
|
||||
cout<<"year: "<<obj["year"]<<endl;
|
||||
cout<<"duration: "<<obj["duration"]<<endl;
|
||||
cout<<"song_data: "<<obj["song_data"]<<endl;
|
||||
|
||||
cout<<endl<<endl;;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+46
-41
@@ -1,47 +1,52 @@
|
||||
#include"UI/AboutWindow.h"
|
||||
#include "UI/AboutWindow.h"
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
setupWindow();
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::setupWindow()
|
||||
{
|
||||
windowWidth = 250;
|
||||
windowHeight = 300;
|
||||
|
||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
|
||||
appName = unique_ptr<QLabel>{new QLabel(tr("IcarusDownloadManager"))};
|
||||
actionButtonQt = unique_ptr<QPushButton>{new QPushButton(tr("Close"))};
|
||||
|
||||
mainLayoutQt->addWidget(appName.get());
|
||||
mainLayoutQt->addWidget(actionButtonQt.get());
|
||||
|
||||
|
||||
setFixedWidth(windowWidth);
|
||||
setFixedHeight(windowHeight);
|
||||
|
||||
setLayout(mainLayoutQt.get());
|
||||
|
||||
setWindowTitle("About");
|
||||
|
||||
connections();
|
||||
}
|
||||
void AboutWindow::connections()
|
||||
{
|
||||
QObject::connect(actionButtonQt.get(), SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::closeWindow()
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
#pragma region Constructors
|
||||
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
setupWindow();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
void AboutWindow::setupWindow()
|
||||
{
|
||||
windowWidth = 250;
|
||||
windowHeight = 300;
|
||||
|
||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
|
||||
appName = unique_ptr<QLabel>{new QLabel(tr("IcarusDownloadManager"))};
|
||||
actionButtonQt = unique_ptr<QPushButton>{new QPushButton(tr("Close"))};
|
||||
|
||||
mainLayoutQt->addWidget(appName.get());
|
||||
mainLayoutQt->addWidget(actionButtonQt.get());
|
||||
|
||||
|
||||
setFixedWidth(windowWidth);
|
||||
setFixedHeight(windowHeight);
|
||||
|
||||
setLayout(mainLayoutQt.get());
|
||||
|
||||
setWindowTitle("About");
|
||||
|
||||
connections();
|
||||
}
|
||||
void AboutWindow::connections()
|
||||
{
|
||||
QObject::connect(actionButtonQt.get(), SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::closeWindow()
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+165
-159
@@ -1,11 +1,11 @@
|
||||
#include"UI/MainWindow.h"
|
||||
#include "UI/MainWindow.h"
|
||||
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include"Models/UploadForm.h"
|
||||
#include"Syncers/Upload.h"
|
||||
#include"Utilities/Conversions.h"
|
||||
#include "Models/UploadForm.h"
|
||||
#include "Syncers/Upload.h"
|
||||
#include "Utilities/Conversions.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -17,158 +17,164 @@ using Syncers::Upload;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
setupMainWindow();
|
||||
aboutWindow = unique_ptr<AboutWindow>{new AboutWindow};
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::configureDownloadSection()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureUploadSection()
|
||||
{
|
||||
uploadSongQt = unique_ptr<QPushButton>{new QPushButton(tr("Upload"))};
|
||||
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
|
||||
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
|
||||
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
|
||||
|
||||
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
|
||||
urlPortion.get()->addWidget(urlLabel.get());
|
||||
urlPortion.get()->addWidget(urlQt.get());
|
||||
|
||||
songPathPortion->addWidget(songPath.get());
|
||||
songPathPortion->addWidget(sourceFilePathQt.get());
|
||||
|
||||
subLayoutOneQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
||||
subLayoutOneQt->addLayout(songPathPortion.get());
|
||||
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
||||
}
|
||||
void MainWindow::configureWindowDimensions()
|
||||
{
|
||||
windowWidth = 450;
|
||||
windowHeight = 450;
|
||||
}
|
||||
void MainWindow::configureWindowProperties()
|
||||
{
|
||||
setWindowTitle("IcarusDownloadManager");
|
||||
setFixedHeight(windowHeight);
|
||||
setFixedWidth(windowWidth);
|
||||
}
|
||||
void MainWindow::connections()
|
||||
{
|
||||
QObject::connect(uploadSongQt.get(), SIGNAL(clicked()), this, SLOT(uploadSong()));
|
||||
QObject::connect(closeApplicationQt.get(), SIGNAL(triggered()), this,
|
||||
SLOT(exitApplication()));
|
||||
QObject::connect(aboutApplicationQt.get(), SIGNAL(triggered()), this,
|
||||
SLOT(displaySoftwareInformation()));
|
||||
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
||||
this, SLOT(setCurrentIndex(int)));
|
||||
}
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||
editMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||
helpMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Help"))};
|
||||
|
||||
closeApplicationQt = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
closeApplicationQt->setText("Exit Application");
|
||||
|
||||
aboutApplicationQt = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
aboutApplicationQt->setText("About");
|
||||
|
||||
fileMenuQt->addAction(closeApplicationQt.get());
|
||||
helpMenuQt->addAction(aboutApplicationQt.get());
|
||||
|
||||
}
|
||||
void MainWindow::setupMainWidget()
|
||||
{
|
||||
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||
|
||||
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
|
||||
setupWindowLists();
|
||||
|
||||
|
||||
stackLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
stackLayout->addWidget(windowComboBox.get());
|
||||
|
||||
uploadSongWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||
uploadSongWidgetQt->setLayout(mainLayoutQt.get());
|
||||
|
||||
stackLayout->addWidget(uploadSongWidgetQt.get());
|
||||
|
||||
mainWidgetQt->setLayout(stackLayout.get());
|
||||
}
|
||||
void MainWindow::setupMainWindow()
|
||||
{
|
||||
configureWindowDimensions();
|
||||
|
||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
widgetStack = unique_ptr<QStackedWidget>{new QStackedWidget};
|
||||
|
||||
configureUploadSection();
|
||||
|
||||
setupMainWidget();
|
||||
|
||||
widgetStack->addWidget(mainWidgetQt.get());
|
||||
|
||||
MainDockWidgetQt = unique_ptr<QDockWidget>{new QDockWidget};
|
||||
MainDockWidgetQt.get()->setWindowTitle(tr("Music Manager"));
|
||||
MainDockWidgetQt->setWidget(widgetStack.get());
|
||||
MainDockWidgetQt.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
|
||||
setCentralWidget(MainDockWidgetQt.get());
|
||||
|
||||
createMenus();
|
||||
|
||||
configureWindowProperties();
|
||||
|
||||
connections();
|
||||
}
|
||||
void MainWindow::setupWindowLists()
|
||||
{
|
||||
windowComboBox->addItem(tr("Upload song"));
|
||||
windowComboBox->addItem(tr("Download song"));
|
||||
windowComboBox->addItem(tr("Display all songs"));
|
||||
windowComboBox->addItem(tr("Display songs"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::exitApplication()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
void MainWindow::displaySoftwareInformation()
|
||||
{
|
||||
aboutWindow->show();
|
||||
}
|
||||
void MainWindow::setCurrentIndex(int index)
|
||||
{
|
||||
cout<<"index "<<index<<endl;
|
||||
QString qText = windowComboBox->itemText(index);
|
||||
auto cnvert = Utilities::Conversions(qText);
|
||||
auto convertedStr = cnvert.convertQStringToString();
|
||||
cout<<"item text"<<endl;
|
||||
}
|
||||
void MainWindow::uploadSong()
|
||||
{
|
||||
uploadSongQt->setEnabled(false);
|
||||
|
||||
string url = urlQt->toPlainText().toUtf8().constData();
|
||||
string filePath = sourceFilePathQt->toPlainText().toUtf8().constData();
|
||||
cout<<"URL endpoint: "<<url<<endl;
|
||||
cout<<"Music file path: "<<filePath<<endl;
|
||||
UploadForm formData{url, filePath};
|
||||
|
||||
Upload upld{formData};
|
||||
upld.uploadSong();
|
||||
|
||||
uploadSongQt->setEnabled(true);
|
||||
}
|
||||
#pragma region Constructors
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
setupMainWindow();
|
||||
aboutWindow = unique_ptr<AboutWindow>{new AboutWindow};
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
void MainWindow::configureDownloadSection()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureUploadSection()
|
||||
{
|
||||
uploadSongQt = unique_ptr<QPushButton>{new QPushButton(tr("Upload"))};
|
||||
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
|
||||
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
|
||||
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
|
||||
|
||||
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
|
||||
urlPortion.get()->addWidget(urlLabel.get());
|
||||
urlPortion.get()->addWidget(urlQt.get());
|
||||
|
||||
songPathPortion->addWidget(songPath.get());
|
||||
songPathPortion->addWidget(sourceFilePathQt.get());
|
||||
|
||||
subLayoutOneQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
||||
subLayoutOneQt->addLayout(songPathPortion.get());
|
||||
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
||||
}
|
||||
void MainWindow::configureWindowDimensions()
|
||||
{
|
||||
windowWidth = 450;
|
||||
windowHeight = 450;
|
||||
}
|
||||
void MainWindow::configureWindowProperties()
|
||||
{
|
||||
setWindowTitle("IcarusDownloadManager");
|
||||
setFixedHeight(windowHeight);
|
||||
setFixedWidth(windowWidth);
|
||||
}
|
||||
void MainWindow::connections()
|
||||
{
|
||||
QObject::connect(uploadSongQt.get(), SIGNAL(clicked()), this, SLOT(uploadSong()));
|
||||
QObject::connect(closeApplicationQt.get(), SIGNAL(triggered()), this,
|
||||
SLOT(exitApplication()));
|
||||
QObject::connect(aboutApplicationQt.get(), SIGNAL(triggered()), this,
|
||||
SLOT(displaySoftwareInformation()));
|
||||
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
||||
this, SLOT(setCurrentIndex(int)));
|
||||
}
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||
editMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||
helpMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Help"))};
|
||||
|
||||
closeApplicationQt = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
closeApplicationQt->setText("Exit Application");
|
||||
|
||||
aboutApplicationQt = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
aboutApplicationQt->setText("About");
|
||||
|
||||
fileMenuQt->addAction(closeApplicationQt.get());
|
||||
helpMenuQt->addAction(aboutApplicationQt.get());
|
||||
|
||||
}
|
||||
void MainWindow::setupMainWidget()
|
||||
{
|
||||
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||
|
||||
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
|
||||
setupWindowLists();
|
||||
|
||||
|
||||
stackLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
stackLayout->addWidget(windowComboBox.get());
|
||||
|
||||
uploadSongWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||
uploadSongWidgetQt->setLayout(mainLayoutQt.get());
|
||||
|
||||
stackLayout->addWidget(uploadSongWidgetQt.get());
|
||||
|
||||
mainWidgetQt->setLayout(stackLayout.get());
|
||||
}
|
||||
void MainWindow::setupMainWindow()
|
||||
{
|
||||
configureWindowDimensions();
|
||||
|
||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
widgetStack = unique_ptr<QStackedWidget>{new QStackedWidget};
|
||||
|
||||
configureUploadSection();
|
||||
|
||||
setupMainWidget();
|
||||
|
||||
widgetStack->addWidget(mainWidgetQt.get());
|
||||
|
||||
MainDockWidgetQt = unique_ptr<QDockWidget>{new QDockWidget};
|
||||
MainDockWidgetQt.get()->setWindowTitle(tr("Music Manager"));
|
||||
MainDockWidgetQt->setWidget(widgetStack.get());
|
||||
MainDockWidgetQt.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
|
||||
setCentralWidget(MainDockWidgetQt.get());
|
||||
|
||||
createMenus();
|
||||
|
||||
configureWindowProperties();
|
||||
|
||||
connections();
|
||||
}
|
||||
void MainWindow::setupWindowLists()
|
||||
{
|
||||
windowComboBox->addItem(tr("Upload song"));
|
||||
windowComboBox->addItem(tr("Download song"));
|
||||
windowComboBox->addItem(tr("Display all songs"));
|
||||
windowComboBox->addItem(tr("Display songs"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::exitApplication()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
void MainWindow::displaySoftwareInformation()
|
||||
{
|
||||
aboutWindow->show();
|
||||
}
|
||||
void MainWindow::setCurrentIndex(int index)
|
||||
{
|
||||
cout<<"index "<<index<<endl;
|
||||
QString qText = windowComboBox->itemText(index);
|
||||
auto cnvert = Utilities::Conversions(qText);
|
||||
auto convertedStr = cnvert.convertQStringToString();
|
||||
cout<<"item text"<<endl;
|
||||
}
|
||||
void MainWindow::uploadSong()
|
||||
{
|
||||
uploadSongQt->setEnabled(false);
|
||||
|
||||
string url = urlQt->toPlainText().toUtf8().constData();
|
||||
string filePath = sourceFilePathQt->toPlainText().toUtf8().constData();
|
||||
cout<<"URL endpoint: "<<url<<endl;
|
||||
cout<<"Music file path: "<<filePath<<endl;
|
||||
UploadForm formData{url, filePath};
|
||||
|
||||
Upload upld{formData};
|
||||
upld.uploadSong();
|
||||
|
||||
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::unique_ptr;
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
Conversions::Conversions()
|
||||
{
|
||||
initializeValues();
|
||||
}
|
||||
|
||||
void Conversions::initializeValues()
|
||||
{
|
||||
}
|
||||
template <typename T>
|
||||
void Conversions::printValue(T val)
|
||||
{
|
||||
std::cout<<"going to print value"<<std::endl;
|
||||
std::cout<<val<<std::endl;
|
||||
}
|
||||
Conversions::Conversions()
|
||||
{
|
||||
initializeValues();
|
||||
}
|
||||
|
||||
void Conversions::initializeValues()
|
||||
{
|
||||
}
|
||||
template <typename T>
|
||||
void Conversions::printValue(T val)
|
||||
{
|
||||
std::cout<<"going to print value"<<std::endl;
|
||||
std::cout<<val<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user