Factoring
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#ifndef BASE_REPOSITORY_H_
|
||||
#define BASE_REPOSITORY_H_
|
||||
|
||||
#include<string>
|
||||
#include <string>
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
#include "models.h"
|
||||
#include "models/models.h"
|
||||
|
||||
class base_repository
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#include "models.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string create_directory_process(Song, const char*);
|
||||
std::string read_cover_art(const char*);
|
||||
|
||||
bool delete_song(Song*);
|
||||
|
||||
void copy_stock_to_root(const char*, const std::string);
|
||||
void copy_song_to_path(const char*, const char*);
|
||||
void delete_cover_art_file(const std::string);
|
||||
void delete_directories(Song, const char*);
|
||||
void delete_song(Song);
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef DIRECTORY_MANAGER_H_
|
||||
#define DIRECTORY_MANAGER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "models/models.h"
|
||||
|
||||
class directory_manager
|
||||
{
|
||||
public:
|
||||
|
||||
std::string create_directory_process(Song, 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&);
|
||||
void delete_directories(Song, const std::string&);
|
||||
|
||||
private:
|
||||
void delete_song(const Song);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "models.h"
|
||||
#include "models/models.h"
|
||||
|
||||
class song_manager
|
||||
{
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "models.h"
|
||||
#include <jwt-cpp/jwt.h>
|
||||
|
||||
#include "models/models.h"
|
||||
#include "types/scopes.h"
|
||||
|
||||
class token_manager
|
||||
@@ -18,6 +22,11 @@ public:
|
||||
bool is_token_valid(std::string&, Scope);
|
||||
private:
|
||||
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&);
|
||||
|
||||
bool token_supports_scope(const std::vector<std::string>, const std::string&&);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "models.h"
|
||||
+13
-11
@@ -6,22 +6,24 @@
|
||||
|
||||
struct Song
|
||||
{
|
||||
int Id;
|
||||
char Title[1024];
|
||||
char Artist[1024];
|
||||
char Album[1024];
|
||||
char Genre[1024];
|
||||
int Year;
|
||||
int Duration;
|
||||
char SongPath[1024];
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct Cover
|
||||
{
|
||||
int Id;
|
||||
char SongTitle[1024];
|
||||
char ImagePath[1024];
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Currently not being used but it should
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct LoginRes
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef MODELS_H_
|
||||
#define MODELS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Song
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct Cover
|
||||
{
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct LoginRes
|
||||
{
|
||||
int UserId;
|
||||
char Username[1024];
|
||||
char Token[1024];
|
||||
char TokenType[1024];
|
||||
char Message[1024];
|
||||
int Expiration;
|
||||
};
|
||||
|
||||
struct loginResult
|
||||
{
|
||||
int user_id;
|
||||
std::string username;
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string message;
|
||||
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 database_connection
|
||||
{
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
|
||||
struct TokenReq
|
||||
{
|
||||
char ClientId[1024];
|
||||
char ClientSecret[1024];
|
||||
char Audience[1024];
|
||||
char GrantType[1024];
|
||||
char URI[1024];
|
||||
char Endpoint[1024];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef METADATA_RETRIEVER_H_
|
||||
#define METADATA_RETRIEVER_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "models/models.h"
|
||||
|
||||
class metadata_retriever
|
||||
{
|
||||
public:
|
||||
Song retrieve_metadata(std::string&);
|
||||
Cover update_cover_art(Cover, const Song, const std::string&);
|
||||
|
||||
void update_metadata(Song updated_song, const Song old_song);
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user