Mania++
 All Classes Functions Variables Pages
VersionChecker.h
1 #ifndef VERSIONCHECKER_H_
2 #define VERSIONCHECKER_H_
3 
4 #include <curl/curl.h>
5 #include "json.hpp"
6 
7 #include "Config/Version.h"
8 #include "../Utils/Logging.h"
9 #include "../Utils/VersionCompare.h"
10 
11 using json = nlohmann::json;
12 
13 //* GitVersion
17 struct GitVersion
18 {
19  std::string Repository;
20  std::string Tag;
21  std::string Name;
22  std::string Commit;
23  bool PreRelease;
24 };
25 
26 //* VersionChecker
31 {
32 public:
39  bool CheckForUpdates(std::string repository, std::string currentVersion);
40 
41 private:
50  static size_t receiveData(void* contents, size_t size, size_t nmemb, std::string* tags);
51 
58  void retrieveData(std::string url, std::string* data);
59 
65  std::vector<GitVersion> retrieveVersions(std::string repository);
66 
72  std::vector<GitVersion> decodeVersions(std::string response);
73 
79  void retrieveRelease(GitVersion* version);
80 
87  void decodeRelease(GitVersion* version, std::string response);
88 };
89 
90 #endif // VERSIONCHECKER_H_
bool PreRelease
Is pre-release?.
Definition: VersionChecker.h:23
bool CheckForUpdates(std::string repository, std::string currentVersion)
Returns whether there are updates available.
Definition: VersionChecker.cpp:3
Checks Mania++ version (and possibly plugin versions).
Definition: VersionChecker.h:30
void retrieveData(std::string url, std::string *data)
Retrieves data via cURL.
Definition: VersionChecker.cpp:96
void decodeRelease(GitVersion *version, std::string response)
Decodes the JSON response with release and inputs info into version struct.
Definition: VersionChecker.cpp:157
std::string Tag
Tag version.
Definition: VersionChecker.h:20
std::vector< GitVersion > retrieveVersions(std::string repository)
Retrieves versions (tags) of repository.
Definition: VersionChecker.cpp:120
static size_t receiveData(void *contents, size_t size, size_t nmemb, std::string *tags)
Receives data from cURL input.
Definition: VersionChecker.cpp:78
std::vector< GitVersion > decodeVersions(std::string response)
Decodes the JSON response with versions (tags) of repository.
Definition: VersionChecker.cpp:128
void retrieveRelease(GitVersion *version)
Retrieves release information.
Definition: VersionChecker.cpp:149
std::string Repository
Name of the GitHub repository.
Definition: VersionChecker.h:19
Contains information about a Git release (version).
Definition: VersionChecker.h:17
std::string Commit
SHA commit.
Definition: VersionChecker.h:22
std::string Name
Tag name (description).
Definition: VersionChecker.h:21