Tidied up code, going to put up the coding convention later on

This commit is contained in:
amazing-username
2019-09-04 15:41:43 +00:00
parent dd995269df
commit d4e9b8c71f
73 changed files with 1334 additions and 1368 deletions
@@ -8,10 +8,10 @@
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/web/server/HttpConnectionHandler.hpp"
namespace Component
namespace component
{
class appComponent
class AppComponent
{
public:
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
@@ -9,35 +9,36 @@
#include "oatpp/core/macro/component.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "dto/loginResultDto.hpp"
#include "managers/token_manager.h"
#include "dto/LoginResultDto.hpp"
#include "manager/TokenManager.h"
#include "model/Models.h"
namespace Controller
namespace controller
{
class loginController : public oatpp::web::server::api::ApiController
class LoginController : public oatpp::web::server::api::ApiController
{
public:
loginController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
LoginController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
: oatpp::web::server::api::ApiController(objectMapper), exe_path(p)
{ }
loginController(const Model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
LoginController(const model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
:oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf)
{ }
#include OATPP_CODEGEN_BEGIN(ApiController)
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(Dto::userDto::ObjectWrapper, usr)) {
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(dto::UserDto::ObjectWrapper, usr)) {
OATPP_LOGI("icarus", "logging in");
Manager::token_manager tok;
auto token = tok.retrieve_token(m_bConf);
manager::TokenManager tok;
auto token = tok.retrieveToken(m_bConf);
auto logRes = Dto::loginResultDto::createShared();
auto logRes = dto::LoginResultDto::createShared();
logRes->id = 0; // TODO: change this later on to something meaningful
logRes->username = usr->username->c_str();
logRes->token = token.access_token.c_str();
logRes->token_type = token.token_type.c_str();
logRes->token = token.accessToken.c_str();
logRes->token_type = token.tokenType.c_str();
logRes->expiration = token.expiration;
logRes->message = "Successful";
@@ -47,7 +48,7 @@ namespace Controller
#include OATPP_CODEGEN_END(ApiController)
private:
std::string exe_path;
Model::BinaryPath m_bConf;
model::BinaryPath m_bConf;
};
}
#endif
@@ -17,26 +17,26 @@
#include "oatpp/web/mime/multipart/Reader.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "database/songRepository.h"
#include "dto/songDto.hpp"
#include "managers/song_manager.h"
#include "managers/token_manager.h"
#include "models/models.h"
#include "types/scopes.h"
#include "types/songFilter.h"
#include "database/SongRepository.h"
#include "dto/SongDto.hpp"
#include "manager/SongManager.h"
#include "manager/TokenManager.h"
#include "model/Models.h"
#include "type/Scopes.h"
#include "type/SongFilter.h"
namespace fs = std::filesystem;
namespace Controller
namespace controller
{
class songController : public oatpp::web::server::api::ApiController
class SongController : public oatpp::web::server::api::ApiController
{
public:
songController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
SongController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
{ }
songController(const Model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
SongController(const model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf)
{ }
@@ -52,8 +52,8 @@ namespace Controller
auto auth = authHeader->std_str();
Manager::token_manager tok;
OATPP_ASSERT_HTTP(tok.is_token_valid(auth, Type::Scope::upload), Status::CODE_403, "Not allowed");
manager::TokenManager tok;
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::upload), Status::CODE_403, "Not allowed");
auto mp = std::make_shared<oatpp::web::mime::multipart::Multipart>(request->getHeaders());
@@ -72,11 +72,11 @@ namespace Controller
std::vector<unsigned char> data(buff.get(), buff.get() + buffSize);
Model::Song sng;
model::Song sng;
sng.data = std::move(data);
Manager::song_manager s_mgr(m_bConf);
s_mgr.saveSong(sng);
manager::SongManager songMgr(m_bConf);
songMgr.saveSong(sng);
return createResponse(Status::CODE_200, "OK");
}
@@ -86,13 +86,13 @@ namespace Controller
REQUEST(std::shared_ptr<IncomingRequest>, request))
{
std::cout << "starting process of retrieving songs" << std::endl;
Database::songRepository songRepo(m_bConf);
database::SongRepository songRepo(m_bConf);
auto songsDb = songRepo.retrieveRecords();
auto songs = oatpp::data::mapping::type::List<Dto::songDto::ObjectWrapper>::createShared();
auto songs = oatpp::data::mapping::type::List<dto::SongDto::ObjectWrapper>::createShared();
std::cout << "creating object to send" << std::endl;
for (auto& songDb : songsDb) {
auto song = Dto::songDto::createShared();
auto song = dto::SongDto::createShared();
song->id = songDb.id;
song->title = songDb.title.c_str();
song->artist = songDb.artist.c_str();
@@ -113,16 +113,16 @@ namespace Controller
ENDPOINT("GET", "/api/v1/song/{id}", songRecord,
PATH(Int32, id)) {
Database::songRepository songRepo(m_bConf);
Model::Song songDb;
database::SongRepository songRepo(m_bConf);
model::Song songDb;
songDb.id = id;
OATPP_ASSERT_HTTP(songRepo.doesSongExist(songDb, Type::songFilter::id) , Status::CODE_403, "song does not exist");
OATPP_ASSERT_HTTP(songRepo.doesSongExist(songDb, type::SongFilter::id) , Status::CODE_403, "song does not exist");
std::cout << "song exists" << std::endl;
songDb = songRepo.retrieveRecord(songDb, Type::songFilter::id);
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
auto song = Dto::songDto::createShared();
auto song = dto::SongDto::createShared();
song->id = songDb.id;
song->title = songDb.title.c_str();
song->artist = songDb.artist.c_str();
@@ -139,10 +139,10 @@ namespace Controller
ENDPOINT("GET", "/api/v1/song/data/{id}", downloadSong,
PATH(Int32, id)) {
Database::songRepository songRepo(m_bConf);
Model::Song songDb;
database::SongRepository songRepo(m_bConf);
model::Song songDb;
songDb.id = id;
songDb = songRepo.retrieveRecord(songDb, Type::songFilter::id);
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
std::ifstream fl(songDb.songPath.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
fl.seekg(0);
@@ -165,10 +165,10 @@ namespace Controller
ENDPOINT("DELETE", "api/v1/song/data/{id}", songDelete, PATH(Int32, id)) {
Model::Song song;
model::Song song;
song.id = id;
Manager::song_manager sngMgr(m_bConf);
manager::SongManager sngMgr(m_bConf);
sngMgr.deleteSong(song);
return createResponse(Status::CODE_200, "OK");
@@ -179,7 +179,7 @@ namespace Controller
#include OATPP_CODEGEN_END(ApiController)
private:
std::string m_exe_path;
Model::BinaryPath m_bConf;
model::BinaryPath m_bConf;
const long m_dataSize = std::numeric_limits<long long int>::max();
};
}
+34
View File
@@ -0,0 +1,34 @@
#ifndef ALBUMREPOSITORY_H_
#define ALBUMREPOSITORY_H_
#include <vector>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/AlbumFilter.h"
namespace database
{
class AlbumRepository : public BaseRepository
{
public:
AlbumRepository(const model::BinaryPath&);
std::vector<model::Album> retrieveRecords();
model::Album retrieveRecord(model::Album&, type::AlbumFilter);
bool doesAlbumExists(const model::Album&, type::AlbumFilter);
void saveAlbum(const model::Album&);
private:
std::vector<model::Album> parseRecords(MYSQL_RES*);
// TODO: after parseRecord(MYSQL_STMT*) is implemented remove
// parseRecord(MYSQL_RES*)
model::Album parseRecord(MYSQL_RES*);
model::Album parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef ARTISTREPOSITORY_H_
#define ARTISTREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/ArtistFilter.h"
namespace database
{
class ArtistRepository : public BaseRepository
{
public:
ArtistRepository(const model::BinaryPath&);
model::Artist retrieveRecord(model::Artist&, type::ArtistFilter);
bool doesArtistExist(const model::Artist&, type::ArtistFilter);
void saveRecord(const model::Artist&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Artist parseRecord(MYSQL_RES*);
model::Artist parseRecord(MYSQL_STMT*);
};
}
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef BASE_REPOSITORY_H_
#define BASE_REPOSITORY_H_
#include <string>
#include <mysql/mysql.h>
#include "model/Models.h"
namespace database
{
class BaseRepository
{
public:
BaseRepository();
BaseRepository(const std::string&);
BaseRepository(const model::BinaryPath&);
protected:
MYSQL* setupMysqlConnection();
MYSQL* setupMysqlConnection(model::DatabaseConnection);
MYSQL_RES* performMysqlQuery(MYSQL*, const std::string&);
model::DatabaseConnection details;
private:
void intitalizeDetails();
void initializeDetails(const model::BinaryPath&);
std::string path;
model::BinaryPath m_binConf;
};
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef COVERARTREPOSITORY_H_
#define COVERARTREPOSITORY_H_
#include <mysql/mysql.h>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/CoverFilter.h"
namespace database
{
class CoverArtRepository : public BaseRepository
{
public:
CoverArtRepository(const std::string&);
CoverArtRepository(const model::BinaryPath&);
model::Cover retrieveRecord(model::Cover&, type::CoverFilter);
bool doesCoverArtExist(const model::Cover&, type::CoverFilter);
void deleteRecord(const model::Cover&);
void saveRecord(const model::Cover&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Cover parseRecord(MYSQL_RES*);
model::Cover parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef GENREREPOSITORY_H_
#define GENREREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/GenreFilter.h"
namespace database
{
class GenreRepository : public BaseRepository
{
public:
GenreRepository(const model::BinaryPath&);
model::Genre retrieveRecord(model::Genre&, type::GenreFilter);
bool doesGenreExist(const model::Genre&, type::GenreFilter);
void saveRecord(const model::Genre&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Genre parseRecord(MYSQL_RES*);
model::Genre parseRecord(MYSQL_STMT*);
};
}
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef SONGREPOSITORY_H_
#define SONGREPOSITORY_H_
#include <memory>
#include <vector>
#include <mysql/mysql.h>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/SongFilter.h"
namespace database
{
class SongRepository : public BaseRepository
{
public:
SongRepository(const std::string&);
SongRepository(const model::BinaryPath&);
std::vector<model::Song> retrieveRecords();
bool doesSongExist(const model::Song&, type::SongFilter);
model::Song retrieveRecord(model::Song&, type::SongFilter);
void deleteRecord(const model::Song&);
void saveRecord(const model::Song&);
private:
std::vector<model::Song> parseRecords(MYSQL_RES*); // TODO: to be removed
std::vector<model::Song> parseRecords(MYSQL_STMT*);
model::Song parseRecord(MYSQL_RES*); // TODO: to be removed
model::Song parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef YEARREPOSITORY_H_
#define YEARREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/YearFilter.h"
namespace database
{
class YearRepository : public BaseRepository
{
public:
YearRepository(const model::BinaryPath&);
model::Year retrieveRecord(model::Year&, type::YearFilter);
bool doesYearExist(const model::Year&, type::YearFilter);
void saveRecord(const model::Year&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Year parseRecord(MYSQL_RES*);
model::Year parseRecord(MYSQL_STMT*);
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef ALBUMREPOSITORY_H_
#define ALBUMREPOSITORY_H_
#include <vector>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/albumFilter.h"
namespace Database
{
class albumRepository : public base_repository
{
public:
albumRepository(const Model::BinaryPath&);
std::vector<Model::Album> retrieveRecords();
Model::Album retrieveRecord(Model::Album&, Type::albumFilter);
bool doesAlbumExists(const Model::Album&, Type::albumFilter);
void saveAlbum(const Model::Album&);
private:
std::vector<Model::Album> parseRecords(MYSQL_RES*);
// TODO: after parseRecord(MYSQL_STMT*) is implemented remove
// parseRecord(MYSQL_RES*)
Model::Album parseRecord(MYSQL_RES*);
Model::Album parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef ARTISTREPOSITORY_H_
#define ARTISTREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/artistFilter.h"
namespace Database
{
class artistRepository : public base_repository
{
public:
artistRepository(const Model::BinaryPath&);
Model::Artist retrieveRecord(Model::Artist&, Type::artistFilter);
bool doesArtistExist(const Model::Artist&, Type::artistFilter);
void saveRecord(const Model::Artist&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Artist parseRecord(MYSQL_RES*);
Model::Artist parseRecord(MYSQL_STMT*);
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef BASE_REPOSITORY_H_
#define BASE_REPOSITORY_H_
#include <string>
#include <mysql/mysql.h>
#include "models/models.h"
namespace Database
{
class base_repository
{
public:
base_repository();
base_repository(const std::string&);
base_repository(const Model::BinaryPath&);
protected:
MYSQL* setup_mysql_connection();
MYSQL* setup_mysql_connection(Model::database_connection);
MYSQL_RES* perform_mysql_query(MYSQL*, const std::string&);
Model::database_connection details;
private:
void intitalizeDetails();
void initializeDetails(const Model::BinaryPath&);
std::string path;
Model::BinaryPath m_binConf;
};
}
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef COVERARTREPOSITORY_H_
#define COVERARTREPOSITORY_H_
#include <mysql/mysql.h>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/coverFilter.h"
namespace Database
{
class coverArtRepository : public base_repository
{
public:
coverArtRepository(const std::string&);
coverArtRepository(const Model::BinaryPath&);
Model::Cover retrieveRecord(Model::Cover&, Type::coverFilter);
bool doesCoverArtExist(const Model::Cover&, Type::coverFilter);
void deleteRecord(const Model::Cover&);
void saveRecord(const Model::Cover&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Cover parseRecord(MYSQL_RES*);
Model::Cover parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef GENREREPOSITORY_H_
#define GENREREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/genreFilter.h"
namespace Database
{
class genreRepository : public base_repository
{
public:
genreRepository(const Model::BinaryPath&);
Model::Genre retrieveRecord(Model::Genre&, Type::genreFilter);
bool doesGenreExist(const Model::Genre&, Type::genreFilter);
void saveRecord(const Model::Genre&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Genre parseRecord(MYSQL_RES*);
Model::Genre parseRecord(MYSQL_STMT*);
};
}
#endif
-38
View File
@@ -1,38 +0,0 @@
#ifndef SONGREPOSITORY_H_
#define SONGREPOSITORY_H_
#include <memory>
#include <vector>
#include <mysql/mysql.h>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/songFilter.h"
namespace Database
{
class songRepository : public base_repository
{
public:
songRepository(const std::string&);
songRepository(const Model::BinaryPath&);
std::vector<Model::Song> retrieveRecords();
bool doesSongExist(const Model::Song&, Type::songFilter);
Model::Song retrieveRecord(Model::Song&, Type::songFilter);
void deleteRecord(const Model::Song&);
void saveRecord(const Model::Song&);
private:
std::vector<Model::Song> parseRecords(MYSQL_RES*); // TODO: to be removed
std::vector<Model::Song> parseRecords(MYSQL_STMT*);
Model::Song parseRecord(MYSQL_RES*); // TODO: to be removed
Model::Song parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef YEARREPOSITORY_H_
#define YEARREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/yearFilter.h"
namespace Database
{
class yearRepository : public base_repository
{
public:
yearRepository(const Model::BinaryPath&);
Model::Year retrieveRecord(Model::Year&, Type::yearFilter);
bool doesYearExist(const Model::Year&, Type::yearFilter);
void saveRecord(const Model::Year&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Year parseRecord(MYSQL_RES*);
Model::Year parseRecord(MYSQL_STMT*);
};
}
#endif
@@ -4,13 +4,13 @@
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace Dto
namespace dto
{
#include OATPP_CODEGEN_BEGIN(DTO)
class loginResultDto : public oatpp::data::mapping::type::Object
class LoginResultDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(loginResultDto, Object)
DTO_INIT(LoginResultDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, username);
@@ -20,9 +20,9 @@ namespace Dto
DTO_FIELD(String, message);
};
class userDto : public oatpp::data::mapping::type::Object
class UserDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(userDto, Object)
DTO_INIT(UserDto, Object)
DTO_FIELD(String, username);
DTO_FIELD(String, password);
@@ -4,13 +4,13 @@
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace Dto
namespace dto
{
#include OATPP_CODEGEN_BEGIN(DTO)
class songDto : public oatpp::data::mapping::type::Object
class SongDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(songDto, Object)
DTO_INIT(SongDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, title);
+22
View File
@@ -0,0 +1,22 @@
#ifndef ALBUMMANAGER_H_
#define ALBUMMANAGER_H_
#include "model/Models.h"
namespace manager
{
class AlbumManager
{
public:
AlbumManager(const model::BinaryPath&);
model::Album retrieveAlbum(model::Album&);
model::Album saveAlbum(const model::Song&);
static void printAlbum(const model::Album&);
private:
model::BinaryPath m_bConf;
};
}
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef ARTISTMANAGER_H_
#define ARTISTMANAGER_H_
#include "model/Models.h"
namespace manager
{
class ArtistManager
{
public:
ArtistManager(const model::BinaryPath&);
model::Artist retrieveArtist(model::Artist&);
model::Artist saveArtist(const model::Song&);
static void printArtist(const model::Artist&);
private:
model::BinaryPath m_bConf;
};
}
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef COVERARTMANAGER_H_
#define COVERARTMANAGER_H_
#include <string>
#include "model/Models.h"
namespace manager
{
class CoverArtManager
{
public:
CoverArtManager(const std::string&);
CoverArtManager(const model::BinaryPath& bConf);
model::Cover saveCover(const model::Song&, std::string&, const std::string&);
private:
model::BinaryPath m_bConf;
std::string path;
};
}
#endif
+33
View File
@@ -0,0 +1,33 @@
#ifndef DIRECTORY_MANAGER_H_
#define DIRECTORY_MANAGER_H_
#include <string>
#include <string_view>
#include <nlohmann/json.hpp>
#include "model/Models.h"
namespace manager
{
class DirectoryManager
{
public:
static std::string createDirectoryProcess(model::Song, const std::string&);
static std::string configPath(std::string_view);
static std::string configPath(const model::BinaryPath&);
static std::string contentOfPath(const std::string&);
static nlohmann::json credentialConfigContent(const model::BinaryPath&);
static nlohmann::json databaseConfigContent(const model::BinaryPath&);
static nlohmann::json pathConfigContent(const model::BinaryPath&);
void deleteCoverArtFile(const std::string&, const std::string&);
static void deleteDirectories(model::Song, const std::string&);
private:
void deleteSong(const model::Song);
};
}
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef GENREMANAGER_H_
#define GENREMANAGER_H_
#include "model/Models.h"
namespace manager
{
class GenreManager
{
public:
GenreManager(const model::BinaryPath&);
model::Genre retrieveGenre(model::Genre&);
model::Genre saveGenre(const model::Song&);
static void printGenre(const model::Genre&);
private:
model::BinaryPath m_bConf;
};
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef SONGMANAGER_H_
#define SONGMANAGER_H_
#include <iostream>
#include <string>
#include <nlohmann/json.hpp>
#include "model/Models.h"
namespace manager
{
class SongManager
{
public:
SongManager(std::string&);
SongManager(const model::BinaryPath&);
void saveSong(model::Song&);
void deleteSong(model::Song&);
static void printSong(const model::Song&);
private:
void saveSongTemp(model::Song&);
void saveMisc(model::Song&);
model::BinaryPath m_bConf;
std::string exe_path;
};
}
#endif
+37
View File
@@ -0,0 +1,37 @@
#ifndef TOKEN_MANAGER_H_
#define TOKEN_MANAGER_H_
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <jwt-cpp/jwt.h>
#include "model/Models.h"
#include "type/Scopes.h"
namespace manager
{
class TokenManager
{
public:
TokenManager();
model::LoginResult retrieveToken();
model::LoginResult retrieveToken(std::string_view);
model::LoginResult retrieveToken(const model::BinaryPath&);
bool isTokenValid(std::string&, type::Scope);
private:
model::AuthCredentials parseAuthCredentials(std::string_view);
model::AuthCredentials parseAuthCredentials(const model::BinaryPath&);
std::vector<std::string> extractScopes(const jwt::decoded_jwt&&);
std::pair<bool, std::vector<std::string>> fetchAuthHeader(const std::string&);
bool tokenSupportsScope(const std::vector<std::string>, const std::string&&);
};
}
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef YEARMANAGER_H_
#define YEARMANAGER_H_
#include "model/Models.h"
namespace manager
{
class YearManager
{
public:
YearManager(const model::BinaryPath&);
model::Year retrieveYear(model::Year&);
model::Year saveYear(const model::Song&);
static void printYear(const model::Year&);
private:
model::BinaryPath m_bConf;
};
}
#endif
-22
View File
@@ -1,22 +0,0 @@
#ifndef ALBUMMANAGER_H_
#define ALBUMMANAGER_H_
#include "models/models.h"
namespace Manager
{
class albumManager
{
public:
albumManager(const Model::BinaryPath&);
Model::Album retrieveAlbum(Model::Album&);
Model::Album saveAlbum(const Model::Song&);
static void printAlbum(const Model::Album&);
private:
Model::BinaryPath m_bConf;
};
}
#endif
-22
View File
@@ -1,22 +0,0 @@
#ifndef ARTISTMANAGER_H_
#define ARTISTMANAGER_H_
#include "models/models.h"
namespace Manager
{
class artistManager
{
public:
artistManager(const Model::BinaryPath&);
Model::Artist retrieveArtist(Model::Artist&);
Model::Artist saveArtist(const Model::Song&);
static void printArtist(const Model::Artist&);
private:
Model::BinaryPath m_bConf;
};
}
#endif
-23
View File
@@ -1,23 +0,0 @@
#ifndef COVERARTMANAGER_H_
#define COVERARTMANAGER_H_
#include <string>
#include "models/models.h"
namespace Manager
{
class coverArtManager
{
public:
coverArtManager(const std::string&);
coverArtManager(const Model::BinaryPath& bConf);
Model::Cover saveCover(const Model::Song&, std::string&, const std::string&);
private:
Model::BinaryPath m_bConf;
std::string path;
};
}
#endif
-36
View File
@@ -1,36 +0,0 @@
#ifndef DIRECTORY_MANAGER_H_
#define DIRECTORY_MANAGER_H_
#include <string>
#include <string_view>
#include <nlohmann/json.hpp>
#include "models/models.h"
namespace Manager
{
class directory_manager
{
public:
static std::string create_directory_process(Model::Song, const std::string&);
static std::string configPath(std::string_view);
static std::string configPath(const Model::BinaryPath&);
static std::string contentOfPath(const std::string&);
//static nlohmann::json credentialConfigContent(const std::string&);
static nlohmann::json credentialConfigContent(const Model::BinaryPath&);
//static nlohmann::json databaseConfigContent(const std::string&);
static nlohmann::json databaseConfigContent(const Model::BinaryPath&);
//static nlohmann::json pathConfigContent(const std::string&);
static nlohmann::json pathConfigContent(const Model::BinaryPath&);
void delete_cover_art_file(const std::string&, const std::string&);
static void delete_directories(Model::Song, const std::string&);
private:
void delete_song(const Model::Song);
};
}
#endif
-22
View File
@@ -1,22 +0,0 @@
#ifndef GENREMANAGER_H_
#define GENREMANAGER_H_
#include "models/models.h"
namespace Manager
{
class genreManager
{
public:
genreManager(const Model::BinaryPath&);
Model::Genre retrieveGenre(Model::Genre&);
Model::Genre saveGenre(const Model::Song&);
static void printGenre(const Model::Genre&);
private:
Model::BinaryPath m_bConf;
};
}
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef SONGMANAGER_H_
#define SONGMANAGER_H_
#include <iostream>
#include <string>
#include <nlohmann/json.hpp>
#include "models/models.h"
namespace Manager
{
class song_manager
{
public:
song_manager(std::string&);
song_manager(const Model::BinaryPath&);
void saveSong(Model::Song&);
void deleteSong(Model::Song&);
static void printSong(const Model::Song&);
private:
void saveSongTemp(Model::Song&);
void saveMisc(Model::Song&);
Model::BinaryPath m_bConf;
std::string exe_path;
};
}
#endif
-37
View File
@@ -1,37 +0,0 @@
#ifndef TOKEN_MANAGER_H_
#define TOKEN_MANAGER_H_
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <jwt-cpp/jwt.h>
#include "models/models.h"
#include "types/scopes.h"
namespace Manager
{
class token_manager
{
public:
token_manager();
Model::loginResult retrieve_token();
Model::loginResult retrieve_token(std::string_view);
Model::loginResult retrieve_token(const Model::BinaryPath&);
bool is_token_valid(std::string&, Type::Scope);
private:
Model::auth_credentials parse_auth_credentials(std::string_view);
Model::auth_credentials parse_auth_credentials(const Model::BinaryPath&);
std::vector<std::string> extract_scopes(const jwt::decoded_jwt&&);
std::pair<bool, std::vector<std::string>> fetch_auth_header(const std::string&);
bool token_supports_scope(const std::vector<std::string>, const std::string&&);
};
}
#endif
-22
View File
@@ -1,22 +0,0 @@
#ifndef YEARMANAGER_H_
#define YEARMANAGER_H_
#include "models/models.h"
namespace Manager
{
class yearManager
{
public:
yearManager(const Model::BinaryPath&);
Model::Year retrieveYear(Model::Year&);
Model::Year saveYear(const Model::Song&);
static void printYear(const Model::Year&);
private:
Model::BinaryPath m_bConf;
};
}
#endif
@@ -4,7 +4,7 @@
#include <string>
#include <vector>
namespace Model
namespace model
{
struct Song
{
@@ -62,27 +62,27 @@ namespace Model
std::vector<unsigned char> data;
};
struct loginResult
struct LoginResult
{
int user_id;
int userId;
std::string username;
std::string access_token;
std::string token_type;
std::string accessToken;
std::string tokenType;
std::string message;
int expiration;
};
struct auth_credentials
struct AuthCredentials
{
std::string domain;
std::string api_identifier;
std::string client_id;
std::string client_secret;
std::string apiIdentifier;
std::string clientId;
std::string clientSecret;
std::string uri;
std::string endpoint;
};
struct database_connection
struct DatabaseConnection
{
std::string server;
std::string username;
@@ -1,9 +1,9 @@
#ifndef ALBUMFILTER_H_
#define ALBUMFILTER_H_
namespace Type
namespace type
{
enum class albumFilter
enum class AlbumFilter
{
id = 0,
title,
@@ -1,9 +1,9 @@
#ifndef ARTISTFILTER_H_
#define ARTISTFILTER_H_
namespace Type
namespace type
{
enum class artistFilter
enum class ArtistFilter
{
id = 0,
artist
@@ -1,9 +1,9 @@
#ifndef COVERFILTER_H_
#define COVERFILTER_H_
namespace Type
namespace type
{
enum class coverFilter
enum class CoverFilter
{
id = 0,
songTitle,
@@ -1,9 +1,9 @@
#ifndef GENREFILTER_H_
#define GENREFILTER_H_
namespace Type
namespace type
{
enum class genreFilter
enum class GenreFilter
{
id = 0,
category
@@ -1,7 +1,7 @@
#ifndef SCOPES_H_
#define SCOPES_H_
namespace Type
namespace type
{
enum class Scope
{
@@ -1,9 +1,9 @@
#ifndef SONGFILTER_H_
#define SONGFILTER_H_
namespace Type
namespace type
{
enum class songFilter
enum class SongFilter
{
id = 0,
title,
@@ -1,9 +1,9 @@
#ifndef YEARFILTER_H_
#define YEARFILTER_H_
namespace Type
namespace type
{
enum class yearFilter
enum class YearFilter
{
id = 0,
year
-22
View File
@@ -1,22 +0,0 @@
#ifndef METADATA_RETRIEVER_H_
#define METADATA_RETRIEVER_H_
#include <iostream>
#include <string>
#include "models/models.h"
namespace Utility
{
class metadata_retriever
{
public:
Model::Song retrieve_metadata(std::string&);
Model::Cover update_cover_art(const Model::Song&, Model::Cover& cov, const std::string&);
void update_metadata(Model::Song updated_song, const Model::Song old_song);
private:
};
}
#endif
@@ -13,12 +13,12 @@
#include <tpropertymap.h>
#include <id3v2tag.h>
namespace Utility
namespace utility
{
class imageFile : public TagLib::File
class ImageFile : public TagLib::File
{
public:
imageFile(const char *file);
ImageFile(const char *file);
TagLib::ByteVector data();
+22
View File
@@ -0,0 +1,22 @@
#ifndef METADATA_RETRIEVER_H_
#define METADATA_RETRIEVER_H_
#include <iostream>
#include <string>
#include "model/Models.h"
namespace utility
{
class MetadataRetriever
{
public:
model::Song retrieveMetadata(std::string&);
model::Cover updateCoverArt(const model::Song&, model::Cover&, const std::string&);
void updateMetadata(model::Song&, const model::Song&);
private:
};
}
#endif