Added Model namespace
This commit is contained in:
@@ -8,10 +8,10 @@ coverArtManager::coverArtManager(const std::string& configPath) : path(configPat
|
||||
{ }
|
||||
|
||||
|
||||
Cover coverArtManager::saveCover(const Song& song, std::string& rootPath, const std::string& stockCoverPath)
|
||||
Model::Cover coverArtManager::saveCover(const Model::Song& song, std::string& rootPath, const std::string& stockCoverPath)
|
||||
{
|
||||
metadata_retriever meta;
|
||||
Cover cov;
|
||||
Model::Cover cov;
|
||||
cov.imagePath = rootPath;
|
||||
cov = meta.update_cover_art(song, cov, stockCoverPath);
|
||||
cov.songTitle = song.title;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::string directory_manager::create_directory_process(Song song, const std::string& root_path)
|
||||
std::string directory_manager::create_directory_process(Model::Song song, const std::string& root_path)
|
||||
{
|
||||
auto curr_path = fs::path(root_path);
|
||||
|
||||
@@ -74,52 +74,6 @@ nlohmann::json directory_manager::pathConfigContent(const std::string& exe_path)
|
||||
return nlohmann::json::parse(contentOfPath(path));
|
||||
}
|
||||
|
||||
/**
|
||||
std::string directory_manager::read_cover_art(const std::string& source)
|
||||
{
|
||||
auto source_path = fs::path(source);
|
||||
|
||||
std::fstream cov(source, std::ios::in | std::ios::binary);
|
||||
|
||||
cov.seekg(0);
|
||||
|
||||
std::stringstream buf;
|
||||
std::copy(std::istreambuf_iterator<char>(cov),
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::ostreambuf_iterator<char>(buf));
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
void directory_manager::copy_stock_to_root(const std::string& target, const std::string& buff)
|
||||
{
|
||||
std::cout<<"starting process"<<std::endl;
|
||||
auto target_path = fs::path(target);
|
||||
if (fs::exists(target_path)) {
|
||||
std::cout<<target_path.string()<<" exists"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout<<target_path.string()<<" does not exist, copying over"<<std::endl;
|
||||
std::fstream cov(target, std::ios::out | std::ios::binary);
|
||||
cov.write(buff.c_str(), buff.size());
|
||||
cov.close();
|
||||
|
||||
std::cout<<"copy finished"<<std::endl;
|
||||
}
|
||||
void directory_manager::copy_song_to_path(const std::string& target, const std::string& source)
|
||||
{
|
||||
std::cout<<"starting process to copy song"<<std::endl;
|
||||
auto target_path = fs::path(target);
|
||||
auto src_path = fs::path(source);
|
||||
|
||||
std::cout<<"copting over to "<<target_path.string()<<std::endl;
|
||||
fs::copy(src_path, target_path);
|
||||
|
||||
fs::remove(source);
|
||||
std::cout<<"copy finished"<<std::endl;
|
||||
}
|
||||
*/
|
||||
void directory_manager::delete_cover_art_file(const std::string& cov_path, const std::string& stock_cover_path)
|
||||
{
|
||||
if (cov_path.compare(stock_cover_path) == 0) {
|
||||
@@ -130,7 +84,7 @@ void directory_manager::delete_cover_art_file(const std::string& cov_path, const
|
||||
fs::remove(cov);
|
||||
}
|
||||
}
|
||||
void directory_manager::delete_directories(Song song, const std::string& root_path)
|
||||
void directory_manager::delete_directories(Model::Song song, const std::string& root_path)
|
||||
{
|
||||
std::cout<<"checking to for empty directories to delete"<<std::endl;
|
||||
const std::string art{root_path + std::string{"/"} + song.artist};
|
||||
@@ -155,7 +109,7 @@ void directory_manager::delete_directories(Song song, const std::string& root_pa
|
||||
|
||||
std::cout<<"deleted empty directory or directories"<<std::endl;
|
||||
}
|
||||
void directory_manager::delete_song(const Song song)
|
||||
void directory_manager::delete_song(const Model::Song song)
|
||||
{
|
||||
std::cout<<"deleting song"<<std::endl;
|
||||
auto song_path = fs::path(song.songPath);
|
||||
|
||||
@@ -19,7 +19,7 @@ song_manager::song_manager(std::string& x_path)
|
||||
{ }
|
||||
|
||||
|
||||
void song_manager::saveSong(Song& song)
|
||||
void song_manager::saveSong(Model::Song& song)
|
||||
{
|
||||
saveSongTemp(song);
|
||||
metadata_retriever meta;
|
||||
@@ -53,7 +53,7 @@ void song_manager::saveSong(Song& song)
|
||||
songRepo.saveRecord(song);
|
||||
}
|
||||
|
||||
void song_manager::deleteSong(Song& song)
|
||||
void song_manager::deleteSong(Model::Song& song)
|
||||
{
|
||||
coverArtRepository covRepo(exe_path);
|
||||
songRepository songRepo(exe_path);
|
||||
@@ -61,7 +61,7 @@ void song_manager::deleteSong(Song& song)
|
||||
song = songRepo.retrieveRecord(song, songFilter::id);
|
||||
songRepo.deleteRecord(song);
|
||||
|
||||
Cover cov;
|
||||
Model::Cover cov;
|
||||
cov.id = song.coverArtId;
|
||||
cov = covRepo.retrieveRecord(cov, coverFilter::id);
|
||||
covRepo.deleteRecord(cov);
|
||||
@@ -81,7 +81,7 @@ void song_manager::deleteSong(Song& song)
|
||||
directory_manager::delete_directories(song, coverArtPath);
|
||||
}
|
||||
|
||||
void song_manager::printSong(const Song& song)
|
||||
void song_manager::printSong(const Model::Song& song)
|
||||
{
|
||||
std::cout << "\n\nsong" << std::endl;
|
||||
std::cout << "title: " << song.title << std::endl;
|
||||
@@ -98,7 +98,7 @@ void song_manager::printSong(const Song& song)
|
||||
}
|
||||
}
|
||||
|
||||
void song_manager::saveSongTemp(Song& song)
|
||||
void song_manager::saveSongTemp(Model::Song& song)
|
||||
{
|
||||
auto config = directory_manager::pathConfigContent(exe_path);
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@ token_manager::token_manager()
|
||||
{
|
||||
}
|
||||
|
||||
loginResult token_manager::retrieve_token()
|
||||
Model::loginResult token_manager::retrieve_token()
|
||||
{
|
||||
loginResult lr;
|
||||
Model::loginResult lr;
|
||||
lr.access_token = "dsfdsf";
|
||||
lr.token_type = "demo";
|
||||
|
||||
return lr;
|
||||
}
|
||||
loginResult token_manager::retrieve_token(std::string_view path)
|
||||
Model::loginResult token_manager::retrieve_token(std::string_view path)
|
||||
{
|
||||
auto cred = parse_auth_credentials(path);
|
||||
|
||||
@@ -50,7 +50,7 @@ loginResult token_manager::retrieve_token(std::string_view path)
|
||||
|
||||
auto post_res = nlohmann::json::parse(r.text);
|
||||
|
||||
loginResult lr;
|
||||
Model::loginResult lr;
|
||||
lr.access_token = post_res["access_token"].get<std::string>();
|
||||
lr.token_type = post_res["token_type"].get<std::string>();
|
||||
lr.expiration = post_res["expires_in"].get<int>();
|
||||
@@ -87,14 +87,14 @@ bool token_manager::is_token_valid(std::string& auth, Scope scope)
|
||||
return false;
|
||||
}
|
||||
|
||||
auth_credentials token_manager::parse_auth_credentials(std::string_view path)
|
||||
Model::auth_credentials token_manager::parse_auth_credentials(std::string_view path)
|
||||
{
|
||||
auto exe_path = directory_manager::configPath(path);
|
||||
exe_path.append("/authcredentials.json");
|
||||
|
||||
auto con = directory_manager::credentialConfigContent(exe_path);
|
||||
|
||||
auth_credentials auth;
|
||||
Model::auth_credentials auth;
|
||||
auth.uri = "https://";
|
||||
auth.uri.append(con["domain"]);
|
||||
auth.api_identifier = con["api_identifier"];
|
||||
|
||||
Reference in New Issue
Block a user