Browse Source

macOS update testing

tobtoht 1 month ago
parent
commit
9af9c651ac
Signed by: tobtoht GPG Key ID: 1CADD27F41F45C3C
  1. 2
      CMakeLists.txt
  2. 2
      monero
  3. 11
      src/MainWindow.cpp
  4. 1
      src/MainWindow.h
  5. 76
      src/dialog/UpdateDialog.cpp
  6. 10
      src/utils/Utils.cpp
  7. 1
      src/utils/Utils.h

2
CMakeLists.txt

@ -32,7 +32,7 @@ if(DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
set(MONERO_HEAD "eba8ce661ce289df99f507225dbb1aaf58125e85")
set(MONERO_HEAD "bdd284b35d2e2c9c6ac733b4bc5ce8bd3b1162dd")
set(BUILD_GUI_DEPS ON)
option(ARCH "Target architecture" "x86-64")
set(BUILD_64 ON)

2
monero

@ -1 +1 @@
Subproject commit d4257af2e7503fc6dc09fc704606230d353a0a02
Subproject commit bdd284b35d2e2c9c6ac733b4bc5ce8bd3b1162dd

11
src/MainWindow.cpp

@ -87,6 +87,8 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
#ifdef DONATE_BEG
this->donationNag();
#endif
this->testUpdate("1.0.0", "haha", "7a971cf5ef7c3d8bf87035fa75571bbac7e3282c3d97c48a4c90562d61d566bb", "whatever");
}
void MainWindow::initStatusBar() {
@ -1326,6 +1328,15 @@ void MainWindow::onShowUpdateCheck(const QString &version, const QString &binary
updateDialog.exec();
}
void MainWindow::testUpdate(const QString &version, const QString &binaryFilename, const QString &hash,
const QString &signer) {
QString downloadUrl = QString("http://127.0.0.1:9999/feather-beta-9-mac.zip");
UpdateDialog updateDialog{this, version, downloadUrl, hash, signer};
connect(&updateDialog, &UpdateDialog::restartWallet, m_windowManager, &WindowManager::restartApplication);
updateDialog.exec();
}
void MainWindow::onUpdatesAvailable(const QJsonObject &updates) {
QString featherVersionStr{FEATHER_VERSION};

1
src/MainWindow.h

@ -133,6 +133,7 @@ private slots:
void onTorConnectionStateChanged(bool connected);
void onCheckUpdatesComplete(const QString &version, const QString &binaryFilename, const QString &hash, const QString &signer);
void onShowUpdateCheck(const QString &version, const QString &binaryFilename, const QString &hash, const QString &signer);
void testUpdate(const QString &version, const QString &binaryFilename, const QString &hash, const QString &signer);
void onSignedHashesReceived(QNetworkReply *reply, const QString &platformTag, const QString &version);
void onShowDonationNag();
void onInitiateTransaction();

76
src/dialog/UpdateDialog.cpp

@ -50,7 +50,7 @@ void UpdateDialog::onDownloadClicked() {
ui->btn_download->hide();
ui->progressBar->show();
UtilsNetworking network{getNetworkTor()};
UtilsNetworking network{getNetworkClearnet()};
m_reply = network.get(m_downloadUrl);
connect(m_reply, &QNetworkReply::downloadProgress, this, &UpdateDialog::onDownloadProgress);
@ -77,23 +77,23 @@ void UpdateDialog::onDownloadFinished() {
std::string responseStr = response.toStdString();
try {
const QByteArray calculatedHash = AsyncTask::runAndWaitForFuture([this, responseStr]{
return Updater().getHash(&responseStr[0], responseStr.size());
});
const QByteArray signedHash = QByteArray::fromHex(m_hash.toUtf8());
if (signedHash != calculatedHash) {
this->onDownloadError("Error: Hash sum mismatch.");
return;
}
}
catch (const std::exception &e)
{
this->onDownloadError(QString("Error: Unable to calculate sha256sum: %1").arg(e.what()));
return;
}
// try {
// const QByteArray calculatedHash = AsyncTask::runAndWaitForFuture([this, responseStr]{
// return Updater().getHash(&responseStr[0], responseStr.size());
// });
//
// const QByteArray signedHash = QByteArray::fromHex(m_hash.toUtf8());
//
// if (signedHash != calculatedHash) {
// this->onDownloadError("Error: Hash sum mismatch.");
// return;
// }
// }
// catch (const std::exception &e)
// {
// this->onDownloadError(QString("Error: Unable to calculate sha256sum: %1").arg(e.what()));
// return;
// }
this->setStatus("Download finished and verified.", true);
@ -117,6 +117,37 @@ void UpdateDialog::onInstallUpdate() {
ui->btn_installUpdate->hide();
this->setStatus("Unzipping archive...");
//#ifdef Q_OS_MACOS
// TODO: not going to bother using libzip for .apps on macOS
QDir appDir(Utils::applicationPath());
QString appName = QString("feather-%1").arg(m_version);
QString zipName = QString("%1.zip").arg(appName);
QString fPath = appDir.filePath(zipName);
QFile f(fPath);
if (!f.open(QIODevice::WriteOnly))
{
this->onInstallError(QString("Error: Could not write to application path: %1").arg(fPath));
return;
}
if (static_cast<size_t>(f.write(&m_updateZipArchive[0], m_updateZipArchive.size()) != m_updateZipArchive.size())) {
this->onInstallError("Error: Unable to write file");
return;
}
QProcess unzip;
unzip.start("/usr/bin/unzip", {"-n", zipName});
unzip.waitForFinished();
m_updatePath = QString("%1/Contents/MacOS/feather").arg(appDir.filePath(appName));
this->setStatus("Installation successful. Do you want to restart Feather now?");
ui->btn_restart->show();
return;
//#endif
zip_error_t err;
zip_error_init(&err);
@ -172,14 +203,7 @@ void UpdateDialog::onInstallUpdate() {
zip_fclose(zf);
zip_close(zip_archive);
QString applicationPath = qgetenv("APPIMAGE");
if (!applicationPath.isEmpty()) {
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
} else {
applicationPath = QCoreApplication::applicationDirPath();
}
QDir applicationDir(applicationPath);
QDir applicationDir(Utils::applicationPath());
QString filePath = applicationDir.filePath(name);
m_updatePath = filePath;

10
src/utils/Utils.cpp

@ -126,6 +126,16 @@ QString defaultWalletDir() {
#endif
}
QString applicationPath() {
QString applicationPath = qgetenv("APPIMAGE");
if (!applicationPath.isEmpty()) {
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
} else {
applicationPath = QCoreApplication::applicationDirPath();
}
return applicationPath;
}
bool validateJSON(const QByteArray &blob) {
QJsonDocument doc = QJsonDocument::fromJson(blob);
QString jsonString = doc.toJson(QJsonDocument::Indented);

1
src/utils/Utils.h

@ -23,6 +23,7 @@ namespace Utils
bool dirExists(const QString &path);
QString defaultWalletDir();
QString applicationPath();
bool validateJSON(const QByteArray &blob);
bool readJsonFile(QIODevice &device, QSettings::SettingsMap &map);

Loading…
Cancel
Save