45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "td/misc/DataBuffer.h"
|
|
|
|
#define TD_VERSION "alpha-0.3.0"
|
|
|
|
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
|