mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Add a new method that return version numbers
This commit is contained in:
parent
c87c242098
commit
7a20bb4deb
2 changed files with 22 additions and 14 deletions
|
@ -25,13 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifdef HAS_LIBCURL
|
#ifdef HAS_LIBCURL
|
||||||
|
|
||||||
#include <curl/curl.h>
|
# include <curl/curl.h>
|
||||||
|
|
||||||
//#include <httplib.h>
|
//#include <httplib.h>
|
||||||
#include "../qcommon/json.hpp"
|
# include "../qcommon/json.hpp"
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#include <chrono>
|
# include <chrono>
|
||||||
|
|
||||||
UpdateChecker updateChecker;
|
UpdateChecker updateChecker;
|
||||||
|
|
||||||
|
@ -168,6 +168,19 @@ bool UpdateChecker::CheckNewVersion() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UpdateChecker::CheckNewVersion(int& major, int& minor, int& patch) const
|
||||||
|
{
|
||||||
|
if (!CheckNewVersion()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
major = lastMajor;
|
||||||
|
minor = lastMinor;
|
||||||
|
patch = lastPatch;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool UpdateChecker::ParseVersionNumber(const char *value, int& major, int& minor, int& patch) const
|
bool UpdateChecker::ParseVersionNumber(const char *value, int& major, int& minor, int& patch) const
|
||||||
{
|
{
|
||||||
const char *p = value;
|
const char *p = value;
|
||||||
|
@ -239,10 +252,10 @@ void UpdateChecker::DoRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json data;
|
nlohmann::json data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = nlohmann::json::parse(responseString);
|
data = nlohmann::json::parse(responseString);
|
||||||
} catch(const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,16 +293,10 @@ void UpdateChecker::RequestThread()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void Sys_UpdateChecker_Init()
|
void Sys_UpdateChecker_Init() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sys_UpdateChecker_Process()
|
void Sys_UpdateChecker_Process() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sys_UpdateChecker_Shutdown()
|
void Sys_UpdateChecker_Shutdown() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
bool CheckNewVersion() const;
|
bool CheckNewVersion() const;
|
||||||
|
bool CheckNewVersion(int& major, int& minor, int& patch) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShutdownClient();
|
void ShutdownClient();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue