mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Merge pull request #10307 from AdmiralCurtiss/config-port-autoupdate
Config: Port AutoUpdate settings to new config system.
This commit is contained in:
commit
1112b2a19e
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "AudioCommon/AudioCommon.h"
|
#include "AudioCommon/AudioCommon.h"
|
||||||
#include "Common/Config/Config.h"
|
#include "Common/Config/Config.h"
|
||||||
|
#include "Common/Version.h"
|
||||||
#include "Core/Config/DefaultLocale.h"
|
#include "Core/Config/DefaultLocale.h"
|
||||||
#include "Core/HW/EXI/EXI_Device.h"
|
#include "Core/HW/EXI/EXI_Device.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
@ -252,4 +253,11 @@ const Info<bool> MAIN_GAMELIST_COLUMN_TAGS{{System::Main, "GameList", "ColumnTag
|
|||||||
|
|
||||||
const Info<bool> MAIN_FIFOPLAYER_LOOP_REPLAY{{System::Main, "FifoPlayer", "LoopReplay"}, true};
|
const Info<bool> MAIN_FIFOPLAYER_LOOP_REPLAY{{System::Main, "FifoPlayer", "LoopReplay"}, true};
|
||||||
|
|
||||||
|
// Main.AutoUpdate
|
||||||
|
|
||||||
|
const Info<std::string> MAIN_AUTOUPDATE_UPDATE_TRACK{{System::Main, "AutoUpdate", "UpdateTrack"},
|
||||||
|
Common::scm_update_track_str};
|
||||||
|
const Info<std::string> MAIN_AUTOUPDATE_HASH_OVERRIDE{{System::Main, "AutoUpdate", "HashOverride"},
|
||||||
|
""};
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
|
@ -215,4 +215,9 @@ extern const Info<bool> MAIN_GAMELIST_COLUMN_TAGS;
|
|||||||
|
|
||||||
extern const Info<bool> MAIN_FIFOPLAYER_LOOP_REPLAY;
|
extern const Info<bool> MAIN_FIFOPLAYER_LOOP_REPLAY;
|
||||||
|
|
||||||
|
// Main.AutoUpdate
|
||||||
|
|
||||||
|
extern const Info<std::string> MAIN_AUTOUPDATE_UPDATE_TRACK;
|
||||||
|
extern const Info<std::string> MAIN_AUTOUPDATE_HASH_OVERRIDE;
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
|
@ -27,7 +27,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||||||
{
|
{
|
||||||
for (const std::string_view section :
|
for (const std::string_view section :
|
||||||
{"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons",
|
{"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons",
|
||||||
"DSP", "GameList", "FifoPlayer"})
|
"DSP", "GameList", "FifoPlayer", "AutoUpdate"})
|
||||||
{
|
{
|
||||||
if (config_location.section == section)
|
if (config_location.section == section)
|
||||||
return true;
|
return true;
|
||||||
|
@ -95,7 +95,6 @@ void SConfig::SaveSettings()
|
|||||||
SaveInputSettings(ini);
|
SaveInputSettings(ini);
|
||||||
SaveBluetoothPassthroughSettings(ini);
|
SaveBluetoothPassthroughSettings(ini);
|
||||||
SaveUSBPassthroughSettings(ini);
|
SaveUSBPassthroughSettings(ini);
|
||||||
SaveAutoUpdateSettings(ini);
|
|
||||||
SaveJitDebugSettings(ini);
|
SaveJitDebugSettings(ini);
|
||||||
|
|
||||||
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||||
@ -244,14 +243,6 @@ void SConfig::SaveUSBPassthroughSettings(IniFile& ini)
|
|||||||
section->Set("Devices", devices_string);
|
section->Set("Devices", devices_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConfig::SaveAutoUpdateSettings(IniFile& ini)
|
|
||||||
{
|
|
||||||
IniFile::Section* section = ini.GetOrCreateSection("AutoUpdate");
|
|
||||||
|
|
||||||
section->Set("UpdateTrack", m_auto_update_track);
|
|
||||||
section->Set("HashOverride", m_auto_update_hash_override);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SConfig::SaveJitDebugSettings(IniFile& ini)
|
void SConfig::SaveJitDebugSettings(IniFile& ini)
|
||||||
{
|
{
|
||||||
IniFile::Section* section = ini.GetOrCreateSection("Debug");
|
IniFile::Section* section = ini.GetOrCreateSection("Debug");
|
||||||
@ -283,7 +274,6 @@ void SConfig::LoadSettings()
|
|||||||
LoadInputSettings(ini);
|
LoadInputSettings(ini);
|
||||||
LoadBluetoothPassthroughSettings(ini);
|
LoadBluetoothPassthroughSettings(ini);
|
||||||
LoadUSBPassthroughSettings(ini);
|
LoadUSBPassthroughSettings(ini);
|
||||||
LoadAutoUpdateSettings(ini);
|
|
||||||
LoadJitDebugSettings(ini);
|
LoadJitDebugSettings(ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,14 +432,6 @@ void SConfig::LoadUSBPassthroughSettings(IniFile& ini)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConfig::LoadAutoUpdateSettings(IniFile& ini)
|
|
||||||
{
|
|
||||||
IniFile::Section* section = ini.GetOrCreateSection("AutoUpdate");
|
|
||||||
|
|
||||||
section->Get("UpdateTrack", &m_auto_update_track, Common::scm_update_track_str);
|
|
||||||
section->Get("HashOverride", &m_auto_update_hash_override, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
void SConfig::LoadJitDebugSettings(IniFile& ini)
|
void SConfig::LoadJitDebugSettings(IniFile& ini)
|
||||||
{
|
{
|
||||||
IniFile::Section* section = ini.GetOrCreateSection("Debug");
|
IniFile::Section* section = ini.GetOrCreateSection("Debug");
|
||||||
|
@ -241,10 +241,6 @@ struct SConfig
|
|||||||
bool m_AdapterRumble[4];
|
bool m_AdapterRumble[4];
|
||||||
bool m_AdapterKonga[4];
|
bool m_AdapterKonga[4];
|
||||||
|
|
||||||
// Auto-update settings
|
|
||||||
std::string m_auto_update_track;
|
|
||||||
std::string m_auto_update_hash_override;
|
|
||||||
|
|
||||||
SConfig(const SConfig&) = delete;
|
SConfig(const SConfig&) = delete;
|
||||||
SConfig& operator=(const SConfig&) = delete;
|
SConfig& operator=(const SConfig&) = delete;
|
||||||
SConfig(SConfig&&) = delete;
|
SConfig(SConfig&&) = delete;
|
||||||
@ -272,7 +268,6 @@ private:
|
|||||||
void SaveMovieSettings(IniFile& ini);
|
void SaveMovieSettings(IniFile& ini);
|
||||||
void SaveBluetoothPassthroughSettings(IniFile& ini);
|
void SaveBluetoothPassthroughSettings(IniFile& ini);
|
||||||
void SaveUSBPassthroughSettings(IniFile& ini);
|
void SaveUSBPassthroughSettings(IniFile& ini);
|
||||||
void SaveAutoUpdateSettings(IniFile& ini);
|
|
||||||
void SaveJitDebugSettings(IniFile& ini);
|
void SaveJitDebugSettings(IniFile& ini);
|
||||||
|
|
||||||
void LoadGeneralSettings(IniFile& ini);
|
void LoadGeneralSettings(IniFile& ini);
|
||||||
@ -282,7 +277,6 @@ private:
|
|||||||
void LoadMovieSettings(IniFile& ini);
|
void LoadMovieSettings(IniFile& ini);
|
||||||
void LoadBluetoothPassthroughSettings(IniFile& ini);
|
void LoadBluetoothPassthroughSettings(IniFile& ini);
|
||||||
void LoadUSBPassthroughSettings(IniFile& ini);
|
void LoadUSBPassthroughSettings(IniFile& ini);
|
||||||
void LoadAutoUpdateSettings(IniFile& ini);
|
|
||||||
void LoadJitDebugSettings(IniFile& ini);
|
void LoadJitDebugSettings(IniFile& ini);
|
||||||
|
|
||||||
void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
|
void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
|
||||||
|
@ -254,7 +254,7 @@ void DolphinAnalytics::MakeBaseBuilder()
|
|||||||
builder.AddData("version-dist", Common::scm_distributor_str);
|
builder.AddData("version-dist", Common::scm_distributor_str);
|
||||||
|
|
||||||
// Auto-Update information.
|
// Auto-Update information.
|
||||||
builder.AddData("update-track", SConfig::GetInstance().m_auto_update_track);
|
builder.AddData("update-track", Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK));
|
||||||
|
|
||||||
// CPU information.
|
// CPU information.
|
||||||
builder.AddData("cpu-summary", cpu_info.Summarize());
|
builder.AddData("cpu-summary", cpu_info.Summarize());
|
||||||
|
@ -286,7 +286,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||||||
|
|
||||||
if (!Settings::Instance().IsBatchModeEnabled())
|
if (!Settings::Instance().IsBatchModeEnabled())
|
||||||
{
|
{
|
||||||
auto* updater = new Updater(&win);
|
auto* updater = new Updater(&win, Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK),
|
||||||
|
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
|
||||||
updater->start();
|
updater->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,12 +548,8 @@ void MenuBar::AddOptionsMenu()
|
|||||||
|
|
||||||
void MenuBar::InstallUpdateManually()
|
void MenuBar::InstallUpdateManually()
|
||||||
{
|
{
|
||||||
auto& track = SConfig::GetInstance().m_auto_update_track;
|
auto* updater =
|
||||||
auto previous_value = track;
|
new Updater(this->parentWidget(), "dev", Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
|
||||||
|
|
||||||
track = "dev";
|
|
||||||
|
|
||||||
auto* updater = new Updater(this->parentWidget());
|
|
||||||
|
|
||||||
if (!updater->CheckForUpdate())
|
if (!updater->CheckForUpdate())
|
||||||
{
|
{
|
||||||
@ -561,8 +557,6 @@ void MenuBar::InstallUpdateManually()
|
|||||||
this, tr("Update"),
|
this, tr("Update"),
|
||||||
tr("You are running the latest version available on this update track."));
|
tr("You are running the latest version available on this update track."));
|
||||||
}
|
}
|
||||||
|
|
||||||
track = previous_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddHelpMenu()
|
void MenuBar::AddHelpMenu()
|
||||||
|
@ -614,14 +614,14 @@ void Settings::SetAutoUpdateTrack(const QString& mode)
|
|||||||
if (mode == GetAutoUpdateTrack())
|
if (mode == GetAutoUpdateTrack())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SConfig::GetInstance().m_auto_update_track = mode.toStdString();
|
Config::SetBase(Config::MAIN_AUTOUPDATE_UPDATE_TRACK, mode.toStdString());
|
||||||
|
|
||||||
emit AutoUpdateTrackChanged(mode);
|
emit AutoUpdateTrackChanged(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::GetAutoUpdateTrack() const
|
QString Settings::GetAutoUpdateTrack() const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(SConfig::GetInstance().m_auto_update_track);
|
return QString::fromStdString(Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::SetFallbackRegion(const DiscIO::Region& region)
|
void Settings::SetFallbackRegion(const DiscIO::Region& region)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "DolphinQt/Updater.h"
|
#include "DolphinQt/Updater.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
@ -18,20 +20,22 @@
|
|||||||
|
|
||||||
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
||||||
|
|
||||||
Updater::Updater(QWidget* parent) : m_parent(parent)
|
Updater::Updater(QWidget* parent, std::string update_track, std::string hash_override)
|
||||||
|
: m_parent(parent), m_update_track(std::move(update_track)),
|
||||||
|
m_hash_override(std::move(hash_override))
|
||||||
{
|
{
|
||||||
connect(this, &QThread::finished, this, &QObject::deleteLater);
|
connect(this, &QThread::finished, this, &QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::run()
|
void Updater::run()
|
||||||
{
|
{
|
||||||
AutoUpdateChecker::CheckForUpdate();
|
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Updater::CheckForUpdate()
|
bool Updater::CheckForUpdate()
|
||||||
{
|
{
|
||||||
m_update_available = false;
|
m_update_available = false;
|
||||||
AutoUpdateChecker::CheckForUpdate();
|
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override);
|
||||||
|
|
||||||
return m_update_available;
|
return m_update_available;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include "UICommon/AutoUpdate.h"
|
#include "UICommon/AutoUpdate.h"
|
||||||
@ -15,7 +17,7 @@ class Updater : public QThread, public AutoUpdateChecker
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Updater(QWidget* parent);
|
explicit Updater(QWidget* parent, std::string update_track, std::string hash_override);
|
||||||
|
|
||||||
void run() override;
|
void run() override;
|
||||||
void OnUpdateAvailable(const NewVersionInformation& info) override;
|
void OnUpdateAvailable(const NewVersionInformation& info) override;
|
||||||
@ -23,5 +25,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* m_parent;
|
QWidget* m_parent;
|
||||||
|
std::string m_update_track;
|
||||||
|
std::string m_hash_override;
|
||||||
bool m_update_available = false;
|
bool m_update_available = false;
|
||||||
};
|
};
|
||||||
|
@ -3,16 +3,17 @@
|
|||||||
|
|
||||||
#include "UICommon/AutoUpdate.h"
|
#include "UICommon/AutoUpdate.h"
|
||||||
|
|
||||||
#include <picojson.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include <picojson.h>
|
||||||
|
|
||||||
#include "Common/CommonPaths.h"
|
#include "Common/CommonPaths.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/HttpRequest.h"
|
#include "Common/HttpRequest.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/Version.h"
|
#include "Common/Version.h"
|
||||||
#include "Core/ConfigManager.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -149,22 +150,20 @@ static std::string GetPlatformID()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdateChecker::CheckForUpdate()
|
void AutoUpdateChecker::CheckForUpdate(std::string_view update_track,
|
||||||
|
std::string_view hash_override)
|
||||||
{
|
{
|
||||||
// Don't bother checking if updates are not supported or not enabled.
|
// Don't bother checking if updates are not supported or not enabled.
|
||||||
if (!SystemSupportsAutoUpdates() || SConfig::GetInstance().m_auto_update_track.empty())
|
if (!SystemSupportsAutoUpdates() || update_track.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef OS_SUPPORTS_UPDATER
|
#ifdef OS_SUPPORTS_UPDATER
|
||||||
CleanupFromPreviousUpdate();
|
CleanupFromPreviousUpdate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string version_hash = SConfig::GetInstance().m_auto_update_hash_override.empty() ?
|
std::string_view version_hash = hash_override.empty() ? Common::scm_rev_git_str : hash_override;
|
||||||
Common::scm_rev_git_str :
|
std::string url = fmt::format("https://dolphin-emu.org/update/check/v1/{}/{}/{}", update_track,
|
||||||
SConfig::GetInstance().m_auto_update_hash_override;
|
version_hash, GetPlatformID());
|
||||||
std::string url = "https://dolphin-emu.org/update/check/v1/" +
|
|
||||||
SConfig::GetInstance().m_auto_update_track + "/" + version_hash + "/" +
|
|
||||||
GetPlatformID();
|
|
||||||
|
|
||||||
Common::HttpRequest req{std::chrono::seconds{10}};
|
Common::HttpRequest req{std::chrono::seconds{10}};
|
||||||
auto resp = req.Get(url);
|
auto resp = req.Get(url);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ class AutoUpdateChecker
|
|||||||
public:
|
public:
|
||||||
// Initiates a check for updates in the background. Calls the OnUpdateAvailable callback if an
|
// Initiates a check for updates in the background. Calls the OnUpdateAvailable callback if an
|
||||||
// update is available, does "nothing" otherwise.
|
// update is available, does "nothing" otherwise.
|
||||||
void CheckForUpdate();
|
void CheckForUpdate(std::string_view update_track, std::string_view hash_override);
|
||||||
|
|
||||||
static bool SystemSupportsAutoUpdates();
|
static bool SystemSupportsAutoUpdates();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user