Merge branch 'master' into support_new_upload_endpoint
This commit is contained in:
@@ -12,78 +12,80 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class ActionManager
|
||||
|
||||
|
||||
|
||||
class ActionManager
|
||||
{
|
||||
public:
|
||||
ActionManager(char**, int);
|
||||
|
||||
Models::IcarusAction retrieveIcarusAction() const;
|
||||
private:
|
||||
constexpr std::array<const char*, 16> supportedFlags() noexcept
|
||||
{
|
||||
public:
|
||||
ActionManager(char**, int);
|
||||
constexpr std::array<const char*, 16> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc",
|
||||
"-m", "-ca", "-smca", "-t"};
|
||||
|
||||
Models::IcarusAction retrieveIcarusAction() const;
|
||||
private:
|
||||
constexpr std::array<const char*, 16> supportedFlags() noexcept
|
||||
return allFlags;
|
||||
}
|
||||
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
||||
|
||||
void initialize();
|
||||
void validateFlags();
|
||||
// Checks to see if the flag is valid
|
||||
template<typename Str>
|
||||
bool isValidFlag(const Str flag)
|
||||
{
|
||||
const auto flags = supportedFlags();
|
||||
const auto i = std::find_if(flags.begin(), flags.end(), [&](const Str &f)
|
||||
{
|
||||
constexpr std::array<const char*, 16> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc",
|
||||
"-m", "-ca", "-smca", "-t"};
|
||||
return f.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
|
||||
return allFlags;
|
||||
}
|
||||
constexpr std::array<const char*, 4> supportedActions() noexcept;
|
||||
auto result = i != flags.end() ? true : false;
|
||||
|
||||
void initialize();
|
||||
void validateFlags();
|
||||
// Checks to see if the flag is valid
|
||||
template<typename Str>
|
||||
bool isValidFlag(const Str flag)
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Str>
|
||||
bool doesFlagHaveValue(const Str flag)
|
||||
{
|
||||
const auto flags = parsedFlags();
|
||||
auto i = std::find_if(flags.begin(), flags.end(), [&](const Str &f)
|
||||
{
|
||||
const auto flags = supportedFlags();
|
||||
const auto i = std::find_if(flags.begin(), flags.end(), [&](const Str &f)
|
||||
{
|
||||
return f.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
return f.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
|
||||
auto result = i != flags.end() ? true : false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Str>
|
||||
bool doesFlagHaveValue(const Str flag)
|
||||
if (i != flags.end())
|
||||
{
|
||||
const auto flags = parsedFlags();
|
||||
auto i = std::find_if(flags.begin(), flags.end(), [&](const Str &f)
|
||||
if (++i != flags.end() && !isValidFlag<Str>(*i))
|
||||
{
|
||||
return f.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
|
||||
if (i != flags.end())
|
||||
{
|
||||
if (++i != flags.end() && !isValidFlag<Str>(*i))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> parsedFlags();
|
||||
void printAction() noexcept;
|
||||
void printFlags() noexcept;
|
||||
|
||||
void printAction() noexcept;
|
||||
void printFlags() noexcept;
|
||||
std::string action;
|
||||
|
||||
std::vector<Models::Flags> flags;
|
||||
|
||||
std::string action;
|
||||
|
||||
std::vector<Models::Flags> flags;
|
||||
char **params;
|
||||
int paramCount;
|
||||
};
|
||||
|
||||
char **params;
|
||||
int paramCount;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+187
-185
@@ -14,197 +14,199 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class CommitManager
|
||||
|
||||
class CommitManager
|
||||
{
|
||||
public:
|
||||
CommitManager(Models::IcarusAction&);
|
||||
|
||||
void commitAction();
|
||||
|
||||
|
||||
enum class RetrieveTypes
|
||||
{
|
||||
songs
|
||||
};
|
||||
|
||||
// Used for parsing songs from the metadata file
|
||||
class Album
|
||||
{
|
||||
public:
|
||||
CommitManager(Models::IcarusAction&);
|
||||
Album() = default;
|
||||
|
||||
void commitAction();
|
||||
|
||||
enum class RetrieveTypes
|
||||
{
|
||||
songs
|
||||
};
|
||||
|
||||
// Used for parsing songs from the metadata file
|
||||
class Album
|
||||
{
|
||||
public:
|
||||
Album() = default;
|
||||
|
||||
void printInfo();
|
||||
|
||||
|
||||
std::string album;
|
||||
std::string albumArtist;
|
||||
std::string genre;
|
||||
int year;
|
||||
int trackCount;
|
||||
int discCount;
|
||||
std::vector<Models::Song> songs;
|
||||
};
|
||||
|
||||
private:
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||
|
||||
Models::Token parseToken(Models::API);
|
||||
|
||||
void deleteSong();
|
||||
void downloadSong();
|
||||
void retrieveObjects();
|
||||
void uploadSong();
|
||||
// Uploads a single song. The song is constructed from a metadata file that contains
|
||||
// information about the album the song is from. Also, the cover art of the song must
|
||||
// be present.
|
||||
//
|
||||
// Expects
|
||||
// * Song - mp3 file path
|
||||
// * TrackID - track number to chose from when retrieving metadata. "1" and "1:1" are similar
|
||||
// * Metadata - Source file containing metadata of the song
|
||||
// * Cover art - path to image cover art
|
||||
void uploadSongWithMetadata();
|
||||
|
||||
// Expects the song path, trackID, metadata file path, and cover path
|
||||
void singTargetUpload(const std::string &songPath, const std::string &trackID,
|
||||
const std::string &metaPath, const std::string &coverPath);
|
||||
// Expects the source directory that contains songs, a metadata file, and cover image
|
||||
// Disc and Track is retrieved from the filename if the filename conforms to a standard.
|
||||
// If not, then the disc and track will default to 1
|
||||
//
|
||||
// Standards
|
||||
// * track01.mp3 - Disc 1, Track 1
|
||||
// * track05d02.mp3 - Disc 2, Track 5
|
||||
void multiTargetUpload(const std::string &sourcePath);
|
||||
|
||||
// Standards
|
||||
// * track01.mp3 - Disc 1, Track 1
|
||||
// * track05d02.mp3 - Disc 2, Track 5
|
||||
template<typename Song, typename Str>
|
||||
void initializeDiscAndTrack(Song &song)
|
||||
{
|
||||
auto disc = 1;
|
||||
auto track = 1;
|
||||
// If 1 go with first standard, if 2 go with the second, if 0 then will default to 1 for disc and track
|
||||
auto mode = 0;
|
||||
const Str &songPath = song.songPath;
|
||||
|
||||
auto trd = song.songPath.find("trackd");
|
||||
auto tr = song.songPath.find("track");
|
||||
|
||||
if (tr != Str::npos)
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
|
||||
if (trd != Str::npos)
|
||||
{
|
||||
mode = 2;
|
||||
}
|
||||
|
||||
auto dl = [](char c, char t){ return c == t; };
|
||||
auto d = Utilities::Checks::itemIterInContainer<char, Str>(songPath, 'd', dl);
|
||||
auto k = Utilities::Checks::itemIterInContainer<char, Str>(songPath, 'k', dl);
|
||||
auto dot = Utilities::Checks::itemIterInContainer<char, Str>(songPath, '.', dl);
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (k != songPath.end() && dot != songPath.end())
|
||||
{
|
||||
auto tStr = std::string(++k, dot);
|
||||
std::cout << "TStr: " << tStr<<"\n";
|
||||
|
||||
if (Utilities::Checks::isNumber(tStr))
|
||||
{
|
||||
track = std::atoi(tStr.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (k != songPath.end() && dot != songPath.end() && d != songPath.end())
|
||||
{
|
||||
auto tStr = std::string(++k, d);
|
||||
auto dStr = std::string(++d, dot);
|
||||
std::cout<<"DStr: "<<dStr<<" TStr: " << tStr<<"\n";
|
||||
|
||||
if (Utilities::Checks::isNumber(tStr))
|
||||
{
|
||||
track = std::atoi(tStr.c_str());
|
||||
}
|
||||
else if (Utilities::Checks::isNumber(dStr))
|
||||
{
|
||||
disc = std::atoi(dStr.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
void printInfo();
|
||||
|
||||
|
||||
song.disc = disc;
|
||||
song.track = track;
|
||||
}
|
||||
|
||||
template<typename Song, typename Str>
|
||||
void parseDiscAndTrack(Song &song, const Str &trackID)
|
||||
{
|
||||
auto sep = [](char c, char t) { return c == t; };
|
||||
auto separator = Utilities::Checks::itemIterInContainer<char, Str>(trackID, ':', sep);
|
||||
|
||||
if (separator != trackID.end())
|
||||
{
|
||||
auto dStr = Str(trackID.begin(), separator);
|
||||
auto tStr = Str(++separator, trackID.end());
|
||||
|
||||
song.disc = std::atoi(dStr.c_str());
|
||||
song.track = std::atoi(tStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto isNumber = Utilities::Checks::isNumber(trackID);
|
||||
if (isNumber)
|
||||
{
|
||||
song.track = std::atoi(trackID.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Checks for the no confirm flag. Used when uploading songs from a directory
|
||||
bool checkForNoConfirm()
|
||||
{
|
||||
for (const auto &arg: this->icaAction.flags)
|
||||
{
|
||||
if (arg.flag.compare("-nc") == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Album retrieveMetadata(const std::string_view path);
|
||||
std::string retrieveFileContent(const std::string_view path);
|
||||
|
||||
enum class ActionValues
|
||||
{
|
||||
deleteAct,
|
||||
downloadAct,
|
||||
retrieveAct,
|
||||
uploadAct,
|
||||
UPLOAD_SONG_WITH_METADATA // Uploads the song with metadata, including cover art
|
||||
};
|
||||
|
||||
|
||||
Models::IcarusAction icaAction;
|
||||
std::string album;
|
||||
std::string albumArtist;
|
||||
std::string genre;
|
||||
int year;
|
||||
int trackCount;
|
||||
int discCount;
|
||||
std::vector<Models::Song> songs;
|
||||
};
|
||||
|
||||
private:
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||
|
||||
void deleteSong();
|
||||
void downloadSong();
|
||||
void retrieveObjects();
|
||||
void uploadSong();
|
||||
// Uploads a single song. The song is constructed from a metadata file that contains
|
||||
// information about the album the song is from. Also, the cover art of the song must
|
||||
// be present.
|
||||
//
|
||||
// Expects
|
||||
// * Song - mp3 file path
|
||||
// * TrackID - track number to chose from when retrieving metadata. "1" and "1:1" are similar
|
||||
// * Metadata - Source file containing metadata of the song
|
||||
// * Cover art - path to image cover art
|
||||
void uploadSongWithMetadata();
|
||||
|
||||
// Expects the song path, trackID, metadata file path, and cover path
|
||||
void singTargetUpload(const std::string &songPath, const std::string &trackID,
|
||||
const std::string &metaPath, const std::string &coverPath);
|
||||
// Expects the source directory that contains songs, a metadata file, and cover image
|
||||
// Disc and Track is retrieved from the filename if the filename conforms to a standard.
|
||||
// If not, then the disc and track will default to 1
|
||||
//
|
||||
// Standards
|
||||
// * track01.mp3 - Disc 1, Track 1
|
||||
// * track05d02.mp3 - Disc 2, Track 5
|
||||
void multiTargetUpload(const std::string &sourcePath);
|
||||
|
||||
// Standards
|
||||
// * track01.mp3 - Disc 1, Track 1
|
||||
// * track05d02.mp3 - Disc 2, Track 5
|
||||
template<typename Song, typename Str>
|
||||
void initializeDiscAndTrack(Song &song)
|
||||
{
|
||||
auto disc = 1;
|
||||
auto track = 1;
|
||||
// If 1 go with first standard, if 2 go with the second, if 0 then will default to 1 for disc and track
|
||||
auto mode = 0;
|
||||
const Str &songPath = song.songPath;
|
||||
|
||||
auto trd = song.songPath.find("trackd");
|
||||
auto tr = song.songPath.find("track");
|
||||
|
||||
if (tr != Str::npos)
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
|
||||
if (trd != Str::npos)
|
||||
{
|
||||
mode = 2;
|
||||
}
|
||||
|
||||
auto dl = [](char c, char t){ return c == t; };
|
||||
auto d = Utilities::Checks::itemIterInContainer<char, Str>(songPath, 'd', dl);
|
||||
auto k = Utilities::Checks::itemIterInContainer<char, Str>(songPath, 'k', dl);
|
||||
auto dot = Utilities::Checks::itemIterInContainer<char, Str>(songPath, '.', dl);
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (k != songPath.end() && dot != songPath.end())
|
||||
{
|
||||
auto tStr = std::string(++k, dot);
|
||||
std::cout << "TStr: " << tStr<<"\n";
|
||||
|
||||
if (Utilities::Checks::isNumber(tStr))
|
||||
{
|
||||
track = std::atoi(tStr.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (k != songPath.end() && dot != songPath.end() && d != songPath.end())
|
||||
{
|
||||
auto tStr = std::string(++k, d);
|
||||
auto dStr = std::string(++d, dot);
|
||||
std::cout<<"DStr: "<<dStr<<" TStr: " << tStr<<"\n";
|
||||
|
||||
if (Utilities::Checks::isNumber(tStr))
|
||||
{
|
||||
track = std::atoi(tStr.c_str());
|
||||
}
|
||||
else if (Utilities::Checks::isNumber(dStr))
|
||||
{
|
||||
disc = std::atoi(dStr.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
song.disc = disc;
|
||||
song.track = track;
|
||||
}
|
||||
|
||||
template<typename Song, typename Str>
|
||||
void parseDiscAndTrack(Song &song, const Str &trackID)
|
||||
{
|
||||
auto sep = [](char c, char t) { return c == t; };
|
||||
auto separator = Utilities::Checks::itemIterInContainer<char, Str>(trackID, ':', sep);
|
||||
|
||||
if (separator != trackID.end())
|
||||
{
|
||||
auto dStr = Str(trackID.begin(), separator);
|
||||
auto tStr = Str(++separator, trackID.end());
|
||||
|
||||
song.disc = std::atoi(dStr.c_str());
|
||||
song.track = std::atoi(tStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto isNumber = Utilities::Checks::isNumber(trackID);
|
||||
if (isNumber)
|
||||
{
|
||||
song.track = std::atoi(trackID.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Checks for the no confirm flag. Used when uploading songs from a directory
|
||||
bool checkForNoConfirm()
|
||||
{
|
||||
for (const auto &arg: this->icaAction.flags)
|
||||
{
|
||||
if (arg.flag.compare("-nc") == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Album retrieveMetadata(const std::string_view path);
|
||||
std::string retrieveFileContent(const std::string_view path);
|
||||
|
||||
enum class ActionValues
|
||||
{
|
||||
deleteAct,
|
||||
downloadAct,
|
||||
retrieveAct,
|
||||
uploadAct,
|
||||
UPLOAD_SONG_WITH_METADATA // Uploads the song with metadata, including cover art
|
||||
};
|
||||
|
||||
|
||||
Models::IcarusAction icaAction;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,25 +5,27 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(std::string);
|
||||
|
||||
void saveFile(std::string);
|
||||
void modifyFilePath(std::string);
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(std::string);
|
||||
|
||||
char* retrieveFileBuffer() const;
|
||||
int retrieveFileBufferLength() const;
|
||||
private:
|
||||
void readFile();
|
||||
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;
|
||||
};
|
||||
|
||||
std::string filePath;
|
||||
char* fileBuffer;
|
||||
bool fileRead;
|
||||
int fileBufferLength;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,17 +7,19 @@
|
||||
|
||||
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;
|
||||
};
|
||||
class TokenManager
|
||||
{
|
||||
public:
|
||||
TokenManager(const Models::User&);
|
||||
TokenManager(const Models::User&, Models::API&);
|
||||
|
||||
Models::Token requestToken();
|
||||
private:
|
||||
Models::API api;
|
||||
Models::User user;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
UserManager(Models::User);
|
||||
UserManager(const Models::IcarusAction);
|
||||
|
||||
Models::User retrieveUser() const;
|
||||
private:
|
||||
void parseUserFromActions();
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
UserManager(Models::User);
|
||||
UserManager(const Models::IcarusAction);
|
||||
|
||||
Models::User retrieveUser() const;
|
||||
private:
|
||||
void parseUserFromActions();
|
||||
|
||||
Models::User user;
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
|
||||
Models::User user;
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct API
|
||||
{
|
||||
std::string url;
|
||||
std::string endpoint;
|
||||
std::string version;
|
||||
};
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
std::string url;
|
||||
std::string endpoint;
|
||||
std::string version;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+15
-6
@@ -5,12 +5,21 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
|
||||
struct Flags
|
||||
{
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,41 +11,43 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class IcarusAction
|
||||
|
||||
class IcarusAction
|
||||
{
|
||||
public:
|
||||
std::string retrieveFlagValue(const std::string_view flag)
|
||||
{
|
||||
public:
|
||||
std::string retrieveFlagValue(const std::string_view flag)
|
||||
std::string value;
|
||||
|
||||
const auto fg = std::find_if(flags.begin(), flags.end(), [&](Flags f)
|
||||
{
|
||||
std::string value;
|
||||
return f.flag.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
|
||||
const auto fg = std::find_if(flags.begin(), flags.end(), [&](Flags f)
|
||||
{
|
||||
return f.flag.compare(flag) == 0 ? true : false;
|
||||
});
|
||||
|
||||
if (fg != flags.end())
|
||||
{
|
||||
value.assign(fg->value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
void print_action_and_flags() noexcept
|
||||
if (fg != flags.end())
|
||||
{
|
||||
std::cout<<"Action: "<<this->action<<"\n";
|
||||
std::cout<<"Flag count: "<<this->flags.size()<<"\n";
|
||||
|
||||
for (const auto &flag : this->flags)
|
||||
{
|
||||
std::cout<<"flag "<<flag.flag<<" value "<<flag.value<<"\n";
|
||||
}
|
||||
|
||||
std::cout<<"\n";
|
||||
value.assign(fg->value);
|
||||
}
|
||||
|
||||
std::string action;
|
||||
std::vector<Flags> flags;
|
||||
};
|
||||
return value;
|
||||
}
|
||||
void print_action_and_flags() noexcept
|
||||
{
|
||||
std::cout<<"Action: "<<this->action<<"\n";
|
||||
std::cout<<"Flag count: "<<this->flags.size()<<"\n";
|
||||
|
||||
for (const auto &flag : this->flags)
|
||||
{
|
||||
std::cout<<"flag "<<flag.flag<<" value "<<flag.value<<"\n";
|
||||
}
|
||||
|
||||
std::cout<<"\n";
|
||||
}
|
||||
|
||||
std::string action;
|
||||
std::vector<Flags> flags;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+31
-29
@@ -7,40 +7,42 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class Song
|
||||
|
||||
class Song
|
||||
{
|
||||
public:
|
||||
Song() = default;
|
||||
|
||||
void printInfo()
|
||||
{
|
||||
public:
|
||||
Song() = default;
|
||||
std::cout<<"Title: "<<this->title<<"\n";
|
||||
std::cout<<"\n";
|
||||
}
|
||||
|
||||
void printInfo()
|
||||
{
|
||||
std::cout<<"Title: "<<this->title<<"\n";
|
||||
std::cout<<"\n";
|
||||
}
|
||||
std::string toMetadataJson();
|
||||
|
||||
std::string toMetadataJson();
|
||||
|
||||
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string data;
|
||||
std::string songPath;
|
||||
};
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string data;
|
||||
std::string songPath;
|
||||
};
|
||||
|
||||
class CoverArt
|
||||
{
|
||||
public:
|
||||
int id;
|
||||
std::string title;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
class CoverArt
|
||||
{
|
||||
public:
|
||||
int id;
|
||||
std::string title;
|
||||
std::string path;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct Token
|
||||
{
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
struct Token
|
||||
{
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct UploadForm
|
||||
{
|
||||
std::string url;
|
||||
std::string filePath;
|
||||
};
|
||||
|
||||
struct UploadForm
|
||||
{
|
||||
std::string url;
|
||||
std::string filePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct User
|
||||
{
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
struct User
|
||||
{
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+12
-10
@@ -6,18 +6,20 @@
|
||||
|
||||
namespace Parsers
|
||||
{
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
APIParser(Models::IcarusAction);
|
||||
|
||||
Models::API retrieveAPI() const;
|
||||
private:
|
||||
void parseAPI();
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
APIParser(Models::IcarusAction);
|
||||
|
||||
Models::API retrieveAPI() const;
|
||||
private:
|
||||
void parseAPI();
|
||||
|
||||
Models::API api;
|
||||
Models::IcarusAction icaAct;
|
||||
};
|
||||
|
||||
Models::API api;
|
||||
Models::IcarusAction icaAct;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
Delete(Models::API);
|
||||
|
||||
void deleteSong(const Models::Token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
};
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
Delete(Models::API);
|
||||
|
||||
void deleteSong(const Models::Token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+14
-12
@@ -12,20 +12,22 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
Download();
|
||||
Download(Models::API);
|
||||
Download(std::string);
|
||||
|
||||
void downloadSong(const Models::Token token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
Download();
|
||||
Download(Models::API);
|
||||
Download(std::string);
|
||||
|
||||
void downloadSong(const Models::Token token, Models::Song);
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
|
||||
std::string downloadFilePath;
|
||||
void saveSong(Models::Song&);
|
||||
};
|
||||
|
||||
std::string downloadFilePath;
|
||||
void saveSong(Models::Song&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
RetrieveRecords();
|
||||
RetrieveRecords(Models::API, Models::Token);
|
||||
|
||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||
private:
|
||||
void fetchSongs();
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
RetrieveRecords();
|
||||
RetrieveRecords(Models::API, Models::Token);
|
||||
|
||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||
private:
|
||||
void fetchSongs();
|
||||
|
||||
Models::API api;
|
||||
Models::Token token;
|
||||
};
|
||||
|
||||
Models::API api;
|
||||
Models::Token token;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,21 +7,23 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
Models::API api;
|
||||
const int OK = 200;
|
||||
const int UNAUTHORIZED = 401;
|
||||
const int NOTFOUND = 404;
|
||||
|
||||
enum class Result
|
||||
{
|
||||
OK = 200,
|
||||
UNAUTHORIZED = 401,
|
||||
NOTFOUND = 404
|
||||
};
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
Models::API api;
|
||||
const int OK = 200;
|
||||
const int UNAUTHORIZED = 401;
|
||||
const int NOTFOUND = 404;
|
||||
|
||||
enum class Result
|
||||
{
|
||||
OK = 200,
|
||||
UNAUTHORIZED = 401,
|
||||
NOTFOUND = 404
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+24
-22
@@ -19,34 +19,36 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Upload
|
||||
|
||||
class Upload
|
||||
{
|
||||
public:
|
||||
Upload(Models::API api, Models::Token token) : m_token(token), api(api)
|
||||
{
|
||||
public:
|
||||
Upload(Models::API api, Models::Token token) : m_token(token), api(api)
|
||||
{
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
|
||||
Models::Song uploadSong(Models::Song&);
|
||||
void uploadSongsFromDirectory(const std::string&, const bool, bool);
|
||||
void uploadSongWithMetadata(Managers::CommitManager::Album&, Models::Song&, Models::CoverArt&);
|
||||
private:
|
||||
Managers::FileManager fMgr;
|
||||
Models::API api;
|
||||
Models::Song song;
|
||||
Models::Token m_token;
|
||||
Models::Song uploadSong(Models::Song&);
|
||||
void uploadSongsFromDirectory(const std::string&, const bool, bool);
|
||||
void uploadSongWithMetadata(Managers::CommitManager::Album&, Models::Song&, Models::CoverArt&);
|
||||
private:
|
||||
Managers::FileManager fMgr;
|
||||
Models::API api;
|
||||
Models::Song song;
|
||||
Models::Token m_token;
|
||||
|
||||
std::vector<Models::Song> retrieveAllSongsFromDirectory(const std::string&,
|
||||
bool);
|
||||
std::vector<Models::Song> retrieveAllSongsFromDirectory(const std::string&,
|
||||
bool);
|
||||
|
||||
std::string retrieveUrl();
|
||||
std::string retrieveUrl();
|
||||
|
||||
Models::Song retrieveSongPath(fs::directory_entry&);
|
||||
Models::Song retrieveSongPath(fs::directory_entry&);
|
||||
|
||||
void printSongDetails();
|
||||
void printSongDetails(std::vector<Models::Song>&);
|
||||
void printJsonData(const nlohmann::json&);
|
||||
};
|
||||
|
||||
void printSongDetails();
|
||||
void printSongDetails(std::vector<Models::Song>&);
|
||||
void printJsonData(const nlohmann::json&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+15
-13
@@ -13,22 +13,24 @@
|
||||
|
||||
namespace UI
|
||||
{
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AboutWindow(QWidget* parent=0);
|
||||
~AboutWindow() = default;
|
||||
|
||||
private:
|
||||
void connections();
|
||||
void setupWindow();
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AboutWindow(QWidget* parent=0);
|
||||
~AboutWindow() = default;
|
||||
|
||||
std::unique_ptr<QLabel> appName;
|
||||
private:
|
||||
void connections();
|
||||
void setupWindow();
|
||||
|
||||
std::unique_ptr<QLabel> appName;
|
||||
|
||||
private slots:
|
||||
void closeWindow();
|
||||
};
|
||||
|
||||
private slots:
|
||||
void closeWindow();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include<QPushButton>
|
||||
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
||||
class CommonWindow
|
||||
{
|
||||
public:
|
||||
@@ -24,4 +27,7 @@ protected:
|
||||
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
|
||||
int windowHeight, windowWidth;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+45
-43
@@ -22,61 +22,63 @@
|
||||
|
||||
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();
|
||||
|
||||
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<QStackedWidget> widgetStack;
|
||||
|
||||
std::unique_ptr<QVBoxLayout> stackLayout;
|
||||
std::unique_ptr<QVBoxLayout> stackLayout;
|
||||
|
||||
std::unique_ptr<QHBoxLayout> urlPortion;
|
||||
std::unique_ptr<QHBoxLayout> songPathPortion;
|
||||
std::unique_ptr<QHBoxLayout> urlPortion;
|
||||
std::unique_ptr<QHBoxLayout> songPathPortion;
|
||||
|
||||
std::unique_ptr<QWidget> mainWidgetQt;
|
||||
std::unique_ptr<QWidget> uploadSongWidgetQt;
|
||||
std::unique_ptr<QWidget> mainWidgetQt;
|
||||
std::unique_ptr<QWidget> uploadSongWidgetQt;
|
||||
|
||||
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
||||
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
||||
|
||||
std::unique_ptr<QComboBox> windowComboBox;
|
||||
|
||||
std::unique_ptr<QPushButton> uploadSongQt;
|
||||
std::unique_ptr<QComboBox> windowComboBox;
|
||||
|
||||
std::unique_ptr<QPushButton> uploadSongQt;
|
||||
|
||||
std::unique_ptr<QTextEdit> urlQt;
|
||||
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
||||
std::unique_ptr<QTextEdit> urlQt;
|
||||
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
||||
|
||||
std::unique_ptr<QLabel> urlLabel;
|
||||
std::unique_ptr<QLabel> songPath;
|
||||
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<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<QAction> closeApplicationQt;
|
||||
std::unique_ptr<QAction> aboutApplicationQt;
|
||||
|
||||
std::unique_ptr<AboutWindow> aboutWindow;
|
||||
signals:
|
||||
private slots:
|
||||
void uploadSong();
|
||||
void exitApplication();
|
||||
void displaySoftwareInformation();
|
||||
void setCurrentIndex(int);
|
||||
};
|
||||
|
||||
std::unique_ptr<AboutWindow> aboutWindow;
|
||||
signals:
|
||||
private slots:
|
||||
void uploadSong();
|
||||
void exitApplication();
|
||||
void displaySoftwareInformation();
|
||||
void setCurrentIndex(int);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,26 +6,24 @@
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
class Conversions
|
||||
|
||||
class Conversions
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
static void toLowerChar(char &c)
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
|
||||
static void toLowerChar(char &c)
|
||||
if (std::isalpha(c))
|
||||
{
|
||||
if (std::isalpha(c))
|
||||
{
|
||||
c = std::tolower(c);
|
||||
}
|
||||
c = std::tolower(c);
|
||||
}
|
||||
}
|
||||
|
||||
void initializeValues();
|
||||
void initializeValues();
|
||||
private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void printValue(T);
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user