Changed C++ standard to C++17 and will implement functionality to retrieve songs, albums, artists, genres, cover art, and year records in json. Will add explicit versioning too

This commit is contained in:
kdeng00
2019-07-30 22:08:55 -04:00
parent 63bee45f95
commit 24a111e8e9
54 changed files with 1334 additions and 1331 deletions
+43
View File
@@ -0,0 +1,43 @@
#ifndef ACTIONMANAGER_H_
#define ACTIONMANAGER_H_
#include<string>
#include<vector>
#include"Models/Flags.h"
#include"Models/IcarusAction.h"
namespace Managers
{
class ActionManager
{
public:
ActionManager(char**);
Models::IcarusAction retrieveIcarusAction() const;
std::vector<Models::Flags> retrieveFlags() const;
std::string retrieveAction() const;
private:
bool isNumber(std::string);
void initialize();
void initializeSupportedActions();
void initializeSupportedFlags();
void validateAction();
void validateFlags();
std::vector<std::string> parsedFlags();
void printAction();
void printFlags(std::vector<std::string>);
void printFlags();
std::string action;
std::vector<std::string> supportedActions;
std::vector<std::string> supportedFlags;
std::vector<Models::Flags> flags;
char **params;
};
}
#endif
+40
View File
@@ -0,0 +1,40 @@
#ifndef COMMITMANAGER_H_
#define COMMITMANAGER_H_
#include<map>
#include<string>
#include"Models/API.h"
#include"Models/Token.h"
#include"Models/IcarusAction.h"
namespace Managers
{
class CommitManager
{
public:
CommitManager(Models::IcarusAction);
void commitAction();
private:
Models::Token parseToken(Models::API);
void initializeMapActions();
void deleteSong();
void downloadSong();
void uploadSong();
enum ActionValues
{
deleteAct,
downloadAct,
retrieveAct,
uploadAct
};
std::map<std::string, ActionValues> mapActions;
Models::IcarusAction icaAction;
};
}
#endif
+29
View File
@@ -0,0 +1,29 @@
#ifndef FILEMANAGER_H_
#define FILEMANAGER_H_
#include<string>
namespace Managers
{
class FileManager
{
public:
FileManager();
FileManager(std::string);
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;
};
}
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef TOKENMANAGER_H_
#define TOKENMANAGER_H_
#include"Models/API.h"
#include"Models/Token.h"
#include"Models/User.h"
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;
};
}
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef USERMANAGER_H_
#define USERMANAGER_H_
#include<iostream>
#include"Models/IcarusAction.h"
#include"Models/User.h"
namespace Managers
{
class UserManager
{
public:
UserManager(Models::User);
UserManager(const Models::IcarusAction);
Models::User retrieveUser() const;
private:
void parseUserFromActions();
Models::User user;
Models::IcarusAction icaAction;
};
}
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef API_H_
#define API_H_
#include<string>
namespace Models
{
struct API
{
std::string url;
std::string endpoint;
std::string version;
};
}
#endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef FLAGS_H_
#define FLAGS_H_
#include<string>
namespace Models
{
struct Flags
{
std::string flag;
std::string value;
};
}
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef ICARUSACTION_H_
#define ICARUSACTION_H_
#include<string>
#include<vector>
#include"Flags.h"
namespace Models
{
struct IcarusAction
{
std::string action;
std::vector<Flags> flags;
};
}
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef SONG_H_
#define SONG_H_
#include<string>
namespace Models
{
struct Song
{
int id;
std::string title;
std::string artist;
std::string album;
std::string genre;
int year;
int duration;
char *songData;
std::string data;
std::string songPath;
};
}
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef TOKEN_H_
#define TOKEN_H_
#include<string>
namespace Models
{
struct Token
{
std::string accessToken;
std::string tokenType;
int expiration;
};
}
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef UPLOADFORM_H_
#define UPLOADFORM_H_
#include<string>
namespace Models
{
struct UploadForm
{
std::string url;
std::string filePath;
};
}
#endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef USER_H_
#define USER_H_
#include<string>
namespace Models
{
struct User
{
std::string username;
std::string password;
};
}
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef APIPARSER_H_
#define APIPARSER_H_
#include"Models/API.h"
#include"Models/IcarusAction.h"
namespace Parsers
{
class APIParser
{
public:
APIParser(Models::IcarusAction);
Models::API retrieveAPI() const;
private:
void parseAPI();
Models::API api;
Models::IcarusAction icaAct;
};
}
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef DELETE_H_
#define DELETE_H_
#include"Models/API.h"
#include"Models/Song.h"
#include"Models/Token.h"
#include"SyncerBase.h"
namespace Syncers
{
class Delete : SyncerBase
{
public:
Delete(Models::API);
void deleteSong(const Models::Token, Models::Song);
private:
std::string retrieveUrl(Models::Song);
};
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef DOWNLOAD_H_
#define DOWNLOAD_H_
#include<iostream>
#include<string>
#include"Models/API.h"
#include"Models/Song.h"
#include"Models/Token.h"
#include"SyncerBase.h"
namespace Syncers
{
class Download : SyncerBase
{
public:
Download();
Download(Models::API);
Download(std::string);
void downloadSong(int);
void downloadSong(const Models::Token token, Models::Song);
private:
std::string retrieveUrl(Models::Song);
std::string downloadFilePath;
void saveSong(Models::Song*);
};
}
#endif
+20
View File
@@ -0,0 +1,20 @@
#ifndef SYNCERBASE_H_
#define SYNCERBASE_H_
#include<string>
#include"Models/API.h"
namespace Syncers
{
class SyncerBase
{
protected:
Models::API api;
const int OK = 200;
const int UNAUTHORIZED = 401;
const int NOTFOUND = 404;
};
}
#endif
+47
View File
@@ -0,0 +1,47 @@
#ifndef UPLOAD_H_
#define UPLOAD_H_
#include<string>
#include<nlohmann/json.hpp>
#include"Managers/FileManager.h"
#include"Models/API.h"
#include"Models/Song.h"
#include"Models/Token.h"
#include"Models/UploadForm.h"
namespace Syncers
{
class Upload
{
public:
Upload();
Upload(std::string);
Upload(Models::API);
Upload(Models::UploadForm);
void uploadSong();
void uploadSong(const Models::Token, Models::Song);
private:
Managers::FileManager fMgr;
Models::API api;
Models::Song song;
std::string apiUrl{""}; // Not being used
std::string apiEndPoint{""}; // Not being used
std::string songPath; // Not being used
std::string url; // Not being used
int port{9349}; // Not being used
std::string retrieveUrl();
void configureSongDemo();
void printSongDetails();
void printJsonData(nlohmann::json);
nlohmann::json serializeObject(); // Not being used
};
}
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef ABOUTWINDOW_H_
#define ABOUTWINDOW_H_
#include<memory>
#include<QDialog>
#include<QDockWidget>
#include<QLabel>
#include<QPushButton>
#include<QWidget>
#include"UI/CommonWindow.h"
namespace UI
{
class AboutWindow: public QDialog, public CommonWindow
{
Q_OBJECT
public:
AboutWindow(QWidget* parent=0);
~AboutWindow() = default;
private:
void connections();
void setupWindow();
std::unique_ptr<QLabel> appName;
private slots:
void closeWindow();
};
}
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef COMMONWINDOW_H_
#define COMMONWINDOW_H_
#include<memory>
#include<QDialog>
#include<QHBoxLayout>
#include<QVBoxLayout>
#include<QComboBox>
#include<QPushButton>
class CommonWindow
{
public:
CommonWindow() = default;
~CommonWindow() = default;
protected:
virtual void connections()=0;
std::unique_ptr<QComboBox> selectionBoxQt;
std::unique_ptr<QPushButton> actionButtonQt;
std::unique_ptr<QVBoxLayout> mainLayoutQt;
std::unique_ptr<QVBoxLayout> subLayoutOneQt;
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
int windowHeight, windowWidth;
};
#endif
+82
View File
@@ -0,0 +1,82 @@
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
#include<iostream>
#include<memory>
#include<QAction>
#include<QComboBox>
#include<QDialog>
#include<QDockWidget>
#include<QLabel>
#include<QMenu>
#include<QMenuBar>
#include<QMainWindow>
#include<QPushButton>
#include<QStackedWidget>
#include<QTextEdit>
#include<QWidget>
#include"UI/CommonWindow.h"
#include"UI/AboutWindow.h"
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();
std::unique_ptr<QStackedWidget> widgetStack;
std::unique_ptr<QVBoxLayout> stackLayout;
std::unique_ptr<QHBoxLayout> urlPortion;
std::unique_ptr<QHBoxLayout> songPathPortion;
std::unique_ptr<QWidget> mainWidgetQt;
std::unique_ptr<QWidget> uploadSongWidgetQt;
std::unique_ptr<QDockWidget> MainDockWidgetQt;
std::unique_ptr<QComboBox> windowComboBox;
std::unique_ptr<QPushButton> uploadSongQt;
std::unique_ptr<QTextEdit> urlQt;
std::unique_ptr<QTextEdit> sourceFilePathQt;
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<QAction> closeApplicationQt;
std::unique_ptr<QAction> aboutApplicationQt;
std::unique_ptr<AboutWindow> aboutWindow;
signals:
private slots:
void uploadSong();
void exitApplication();
void displaySoftwareInformation();
void setCurrentIndex(int);
};
}
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef CONVERSIONS_H_
#define CONVERSIONS_H_
#include<memory>
#include<string>
namespace Utilities
{
class Conversions
{
public:
Conversions();
void initializeValues();
template <typename T>
void printValue(T);
private:
};
}
#endif