mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
checkUpates: installer support (Win), use GUI buildTag and version
This commit is contained in:
parent
585fb2810d
commit
9b98e0a2f5
5 changed files with 86 additions and 5 deletions
21
main.qml
21
main.qml
|
@ -45,6 +45,7 @@ import "pages/merchant" as MoneroMerchant
|
|||
import "wizard"
|
||||
import "js/Utils.js" as Utils
|
||||
import "js/Windows.js" as Windows
|
||||
import "version.js" as Version
|
||||
|
||||
ApplicationWindow {
|
||||
id: appWindow
|
||||
|
@ -1988,8 +1989,26 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
function getBuildTag() {
|
||||
if (isMac) {
|
||||
return "mac-x64";
|
||||
}
|
||||
if (isWindows) {
|
||||
return oshelper.installed ? "install-win-x64" : "win-x64";
|
||||
}
|
||||
if (isLinux) {
|
||||
return "linux-x64";
|
||||
}
|
||||
return "source";
|
||||
}
|
||||
|
||||
function checkUpdates() {
|
||||
walletManager.checkUpdatesAsync("monero-gui", "gui")
|
||||
const version = Version.GUI_VERSION.match(/\d+\.\d+\.\d+\.\d+/);
|
||||
if (version) {
|
||||
walletManager.checkUpdatesAsync("monero-gui", "gui", getBuildTag(), version[0]);
|
||||
} else {
|
||||
console.error("failed to parse version number", Version.GUI_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -463,10 +463,18 @@ bool WalletManager::saveQrCode(const QString &code, const QString &path) const
|
|||
return QRCodeImageProvider::genQrImage(code, &size).scaled(size.expandedTo(QSize(240, 240)), Qt::KeepAspectRatio).save(path, "PNG", 100);
|
||||
}
|
||||
|
||||
void WalletManager::checkUpdatesAsync(const QString &software, const QString &subdir)
|
||||
void WalletManager::checkUpdatesAsync(
|
||||
const QString &software,
|
||||
const QString &subdir,
|
||||
const QString &buildTag,
|
||||
const QString &version)
|
||||
{
|
||||
m_scheduler.run([this, software, subdir] {
|
||||
const auto updateInfo = Monero::WalletManager::checkUpdates(software.toStdString(), subdir.toStdString());
|
||||
m_scheduler.run([this, software, subdir, buildTag, version] {
|
||||
const auto updateInfo = Monero::WalletManager::checkUpdates(
|
||||
software.toStdString(),
|
||||
subdir.toStdString(),
|
||||
buildTag.toStdString().c_str(),
|
||||
version.toStdString().c_str());
|
||||
if (!std::get<0>(updateInfo))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -175,7 +175,11 @@ public:
|
|||
Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error) const;
|
||||
Q_INVOKABLE QVariantMap parse_uri_to_object(const QString &uri) const;
|
||||
Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const;
|
||||
Q_INVOKABLE void checkUpdatesAsync(const QString &software, const QString &subdir);
|
||||
Q_INVOKABLE void checkUpdatesAsync(
|
||||
const QString &software,
|
||||
const QString &subdir,
|
||||
const QString &buildTag,
|
||||
const QString &version);
|
||||
Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const;
|
||||
|
||||
// clear/rename wallet cache
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "oshelper.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryFile>
|
||||
|
@ -164,3 +165,47 @@ QString OSHelper::temporaryPath() const
|
|||
{
|
||||
return QDir::tempPath();
|
||||
}
|
||||
|
||||
bool OSHelper::installed() const
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
static constexpr const wchar_t installKey[] =
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Monero GUI Wallet_is1";
|
||||
static constexpr const wchar_t installValue[] = L"InstallLocation";
|
||||
|
||||
DWORD size;
|
||||
LSTATUS status =
|
||||
::RegGetValueW(HKEY_LOCAL_MACHINE, installKey, installValue, RRF_RT_REG_SZ, nullptr, nullptr, &size);
|
||||
if (status == ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
qCritical() << "RegGetValueW failed (get size)" << status;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::wstring installLocation;
|
||||
installLocation.resize(size / sizeof(std::wstring::value_type));
|
||||
size = installLocation.size() * sizeof(std::wstring::value_type);
|
||||
status = ::RegGetValueW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
installKey,
|
||||
installValue,
|
||||
RRF_RT_REG_SZ,
|
||||
nullptr,
|
||||
&installLocation[0],
|
||||
&size);
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
qCritical() << "RegGetValueW Failed (read)" << status;
|
||||
return false;
|
||||
}
|
||||
|
||||
const QDir installDir(QString(reinterpret_cast<const QChar *>(&installLocation[0])));
|
||||
return installDir == QDir(QCoreApplication::applicationDirPath());
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
class OSHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool installed READ installed CONSTANT);
|
||||
|
||||
public:
|
||||
explicit OSHelper(QObject *parent = 0);
|
||||
|
||||
|
@ -47,6 +49,9 @@ public:
|
|||
Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const;
|
||||
Q_INVOKABLE bool isCapsLock() const;
|
||||
|
||||
private:
|
||||
bool installed() const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in a new issue