refactor: movd Updater

This commit is contained in:
2021-11-30 18:07:25 +01:00
parent f91ab4bc83
commit 0c1824e40b
4 changed files with 5 additions and 4 deletions

46
include/updater/Updater.h Normal file
View File

@@ -0,0 +1,46 @@
#pragma once
#include "misc/DataBuffer.h"
#include <ctime>
#define TD_VERSION "alpha-0.0.2"
namespace td {
namespace utils {
class Updater {
private:
float m_Progress;
bool m_DownloadComplete;
bool m_FileWrited;
bool m_CancelDownload;
DataBuffer m_FileBuffer;
std::string m_LastVersion;
public:
Updater() : m_Progress(0), m_DownloadComplete(false), m_FileWrited(false), m_CancelDownload(false) {}
bool checkUpdate();
void downloadUpdate();
void cancelDownload() { m_CancelDownload = true; m_Progress = 0.0f; m_DownloadComplete = false; }
bool writeFile();
void clearCache() { m_FileBuffer.Clear(); }
float getDownloadProgress() { return m_Progress; }
bool isDownloadComplete() { return m_DownloadComplete; }
bool isFileWrited() { return m_FileWrited; }
static std::string getLocalFilePath();
static void removeOldFile();
static std::string getCurrentVersion() { return TD_VERSION; }
std::string getLastVersion() { return m_LastVersion; }
bool canUpdate();
private:
std::string getDownloadFileURL();
};
} // namespace utils
} // namespace td