47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "misc/DataBuffer.h"
|
|
|
|
#include <ctime>
|
|
|
|
#define TD_VERSION "alpha-0.0.1"
|
|
|
|
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
|