Added Model namespace
This commit is contained in:
@@ -14,11 +14,11 @@ public:
|
||||
base_repository(const std::string&);
|
||||
protected:
|
||||
MYSQL* setup_mysql_connection();
|
||||
MYSQL* setup_mysql_connection(database_connection);
|
||||
MYSQL* setup_mysql_connection(Model::database_connection);
|
||||
|
||||
MYSQL_RES* perform_mysql_query(MYSQL*, const std::string&);
|
||||
|
||||
database_connection details;
|
||||
Model::database_connection details;
|
||||
private:
|
||||
void intitalizeDetails();
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ class coverArtRepository : public base_repository
|
||||
public:
|
||||
coverArtRepository(const std::string&);
|
||||
|
||||
Cover retrieveRecord(Cover&, coverFilter);
|
||||
Model::Cover retrieveRecord(Model::Cover&, coverFilter);
|
||||
|
||||
void deleteRecord(const Cover&);
|
||||
void saveRecord(const Cover&);
|
||||
void deleteRecord(const Model::Cover&);
|
||||
void saveRecord(const Model::Cover&);
|
||||
private:
|
||||
Cover parseRecord(MYSQL_RES*);
|
||||
Model::Cover parseRecord(MYSQL_RES*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,16 +15,16 @@ class songRepository : public base_repository
|
||||
public:
|
||||
songRepository(const std::string&);
|
||||
|
||||
std::vector<Song> retrieveRecords();
|
||||
std::vector<Model::Song> retrieveRecords();
|
||||
|
||||
Song retrieveRecord(Song&, songFilter);
|
||||
Model::Song retrieveRecord(Model::Song&, songFilter);
|
||||
|
||||
void deleteRecord(const Song&);
|
||||
void saveRecord(const Song&);
|
||||
void deleteRecord(const Model::Song&);
|
||||
void saveRecord(const Model::Song&);
|
||||
private:
|
||||
std::vector<Song> parseRecords(MYSQL_RES*);
|
||||
std::vector<Model::Song> parseRecords(MYSQL_RES*);
|
||||
|
||||
Song parseRecord(MYSQL_RES*);
|
||||
Model::Song parseRecord(MYSQL_RES*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@ class coverArtManager
|
||||
public:
|
||||
coverArtManager(const std::string&);
|
||||
|
||||
Cover saveCover(const Song&, std::string&, const std::string&);
|
||||
Model::Cover saveCover(const Model::Song&, std::string&, const std::string&);
|
||||
private:
|
||||
std::string path;
|
||||
};
|
||||
|
||||
@@ -12,24 +12,19 @@ class directory_manager
|
||||
{
|
||||
public:
|
||||
|
||||
static std::string create_directory_process(Song, const std::string&);
|
||||
static std::string create_directory_process(Model::Song, const std::string&);
|
||||
static std::string configPath(std::string_view);
|
||||
static std::string contentOfPath(std::string_view);
|
||||
|
||||
static nlohmann::json credentialConfigContent(const std::string&);
|
||||
static nlohmann::json databaseConfigContent(const std::string&);
|
||||
static nlohmann::json pathConfigContent(const std::string&);
|
||||
// Return Cover instead
|
||||
//std::string read_cover_art(const std::string&);
|
||||
|
||||
|
||||
//void copy_stock_to_root(const std::string&, const std::string&);
|
||||
//void copy_song_to_path(const std::string&, const std::string&);
|
||||
void delete_cover_art_file(const std::string&, const std::string&);
|
||||
static void delete_directories(Song, const std::string&);
|
||||
static void delete_directories(Model::Song, const std::string&);
|
||||
|
||||
private:
|
||||
void delete_song(const Song);
|
||||
void delete_song(const Model::Song);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,12 +13,12 @@ class song_manager
|
||||
public:
|
||||
song_manager(std::string&);
|
||||
|
||||
void saveSong(Song&);
|
||||
void deleteSong(Song&);
|
||||
void saveSong(Model::Song&);
|
||||
void deleteSong(Model::Song&);
|
||||
|
||||
static void printSong(const Song&);
|
||||
static void printSong(const Model::Song&);
|
||||
private:
|
||||
void saveSongTemp(Song&);
|
||||
void saveSongTemp(Model::Song&);
|
||||
|
||||
std::string exe_path;
|
||||
};
|
||||
|
||||
@@ -16,12 +16,12 @@ class token_manager
|
||||
public:
|
||||
token_manager();
|
||||
|
||||
loginResult retrieve_token();
|
||||
loginResult retrieve_token(std::string_view);
|
||||
Model::loginResult retrieve_token();
|
||||
Model::loginResult retrieve_token(std::string_view);
|
||||
|
||||
bool is_token_valid(std::string&, Scope);
|
||||
private:
|
||||
auth_credentials parse_auth_credentials(std::string_view);
|
||||
Model::auth_credentials parse_auth_credentials(std::string_view);
|
||||
|
||||
std::vector<std::string> extract_scopes(const jwt::decoded_jwt&&);
|
||||
std::pair<bool, std::vector<std::string>> fetch_auth_header(const std::string&);
|
||||
|
||||
+66
-65
@@ -4,77 +4,78 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Song
|
||||
namespace Model
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
};
|
||||
struct Song
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
};
|
||||
|
||||
struct Cover
|
||||
{
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
struct Album
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
int year;
|
||||
std::vector<Song> songs;
|
||||
};
|
||||
|
||||
struct LoginRes
|
||||
{
|
||||
int UserId;
|
||||
char Username[1024];
|
||||
char Token[1024];
|
||||
char TokenType[1024];
|
||||
char Message[1024];
|
||||
int Expiration;
|
||||
};
|
||||
struct Cover
|
||||
{
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct loginResult
|
||||
{
|
||||
int user_id;
|
||||
std::string username;
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
struct LoginRes
|
||||
{
|
||||
int UserId;
|
||||
char Username[1024];
|
||||
char Token[1024];
|
||||
char TokenType[1024];
|
||||
char Message[1024];
|
||||
int Expiration;
|
||||
};
|
||||
|
||||
struct auth_credentials
|
||||
{
|
||||
std::string domain;
|
||||
std::string api_identifier;
|
||||
std::string client_id;
|
||||
std::string client_secret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
struct loginResult
|
||||
{
|
||||
int user_id;
|
||||
std::string username;
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
struct database_connection
|
||||
{
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
struct auth_credentials
|
||||
{
|
||||
std::string domain;
|
||||
std::string api_identifier;
|
||||
std::string client_id;
|
||||
std::string client_secret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
|
||||
struct TokenReq
|
||||
{
|
||||
char ClientId[1024];
|
||||
char ClientSecret[1024];
|
||||
char Audience[1024];
|
||||
char GrantType[1024];
|
||||
char URI[1024];
|
||||
char Endpoint[1024];
|
||||
};
|
||||
struct database_connection
|
||||
{
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,45 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
//#include <taglib/attachedpictureframe.h>
|
||||
#include <attachedpictureframe.h>
|
||||
//#include <taglib/mpegfile.h>
|
||||
//#include <mpegfile.h>
|
||||
//#include <taglib/tag.h>
|
||||
#include <tag.h>
|
||||
//#include <taglib/tfile.h>
|
||||
#include <tfile.h>
|
||||
//#include <taglib/tfilestream.h>
|
||||
#include <tfilestream.h>
|
||||
//#include <taglib/fileref.h>
|
||||
#include <fileref.h>
|
||||
//#include <taglib/tbytevector.h>
|
||||
#include <tbytevector.h>
|
||||
//#include <taglib/tbytevectorstream.h>
|
||||
#include <tbytevectorstream.h>
|
||||
//#include <taglib/tpropertymap.h>
|
||||
#include <tpropertymap.h>
|
||||
//#include <taglib/id3v2tag.h>
|
||||
#include <id3v2tag.h>
|
||||
|
||||
class imageFile : public TagLib::File
|
||||
{
|
||||
public:
|
||||
imageFile(const char *file);
|
||||
/**
|
||||
imageFile(const char *file) : TagLib::File(file)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
TagLib::ByteVector data();
|
||||
/**
|
||||
TagLib::ByteVector data()
|
||||
{
|
||||
return readBlock(length());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private:
|
||||
virtual TagLib::Tag *tag() const { return 0; }
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
class metadata_retriever
|
||||
{
|
||||
public:
|
||||
Song retrieve_metadata(std::string&);
|
||||
Cover update_cover_art(const Song&, Cover& cov, const std::string&);
|
||||
Model::Song retrieve_metadata(std::string&);
|
||||
Model::Cover update_cover_art(const Model::Song&, Model::Cover& cov, const std::string&);
|
||||
|
||||
void update_metadata(Song updated_song, const Song old_song);
|
||||
void update_metadata(Model::Song updated_song, const Model::Song old_song);
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user