2023-02-18 11:42:19 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//
|
|
|
|
// EmulationStation Desktop Edition
|
|
|
|
// ApplicationUpdater.h
|
|
|
|
//
|
|
|
|
// Checks for application updates.
|
2023-07-03 16:06:47 +00:00
|
|
|
// Used in conjunction with GuiApplicationUpdater.
|
2023-02-18 11:42:19 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ES_APP_APPLICATION_UPDATER_H
|
|
|
|
#define ES_APP_APPLICATION_UPDATER_H
|
|
|
|
|
|
|
|
#include "AsyncHandle.h"
|
|
|
|
#include "HttpReq.h"
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class ApplicationUpdater : public AsyncHandle
|
|
|
|
{
|
|
|
|
public:
|
2023-02-26 11:50:30 +00:00
|
|
|
virtual ~ApplicationUpdater();
|
|
|
|
static ApplicationUpdater& getInstance();
|
2023-02-18 11:42:19 +00:00
|
|
|
|
|
|
|
void checkForUpdates();
|
|
|
|
void updaterThread();
|
|
|
|
bool downloadFile();
|
2023-02-18 12:20:36 +00:00
|
|
|
void update();
|
2023-02-18 11:42:19 +00:00
|
|
|
void parseFile();
|
|
|
|
void compareVersions();
|
2023-02-26 11:50:30 +00:00
|
|
|
bool getResults();
|
2023-02-18 11:42:19 +00:00
|
|
|
|
|
|
|
struct Package {
|
|
|
|
std::string name;
|
2023-07-03 15:46:56 +00:00
|
|
|
std::string version;
|
2023-02-18 11:42:19 +00:00
|
|
|
std::string filename;
|
|
|
|
std::string url;
|
|
|
|
std::string md5;
|
|
|
|
std::string message;
|
|
|
|
};
|
|
|
|
|
2023-02-26 11:50:30 +00:00
|
|
|
const std::string& getResultsString() { return mResults; }
|
|
|
|
const Package& getPackageInfo() { return mPackage; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
ApplicationUpdater();
|
|
|
|
|
2023-02-18 11:42:19 +00:00
|
|
|
struct Release {
|
|
|
|
std::string releaseType;
|
|
|
|
std::string version;
|
|
|
|
std::string releaseNum;
|
|
|
|
std::string date;
|
|
|
|
std::vector<Package> packages;
|
|
|
|
};
|
|
|
|
|
2023-02-26 11:50:30 +00:00
|
|
|
enum class PackageType {
|
|
|
|
WINDOWS_PORTABLE,
|
|
|
|
WINDOWS_INSTALLER,
|
|
|
|
MACOS_APPLE,
|
|
|
|
MACOS_INTEL,
|
|
|
|
LINUX_APPIMAGE,
|
|
|
|
LINUX_STEAM_DECK_APPIMAGE,
|
|
|
|
UNKNOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
PackageType mPackageType;
|
|
|
|
Package mPackage;
|
2023-02-18 11:42:19 +00:00
|
|
|
std::string mUrl;
|
|
|
|
std::string mResults;
|
2023-02-18 19:36:30 +00:00
|
|
|
std::string mLogInfo;
|
|
|
|
std::string mLogWarning;
|
|
|
|
std::string mLogError;
|
2023-02-18 11:42:19 +00:00
|
|
|
unsigned int mTimer;
|
|
|
|
unsigned int mMaxTime;
|
|
|
|
std::atomic<bool> mAbortDownload;
|
2023-02-18 19:36:30 +00:00
|
|
|
std::atomic<bool> mApplicationShutdown;
|
2023-02-18 11:42:19 +00:00
|
|
|
bool mCheckedForUpdate;
|
2023-02-26 11:50:30 +00:00
|
|
|
bool mNewVersion;
|
2023-02-18 11:42:19 +00:00
|
|
|
|
|
|
|
std::unique_ptr<std::thread> mThread;
|
|
|
|
std::unique_ptr<HttpReq> mRequest;
|
|
|
|
AsyncHandleStatus mStatus;
|
|
|
|
|
|
|
|
Release mStableRelease;
|
|
|
|
Release mPrerelease;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_APPLICATION_UPDATER_H
|