From 0029eac42230a46660067037e323275ce185262c Mon Sep 17 00:00:00 2001 From: Bytecoin Developer Date: Mon, 28 May 2018 21:39:03 +0300 Subject: [PATCH] Add the batch of release v3.1.1 commits --- ReleaseNotes.md | 5 ++ src/application.cpp | 36 ++++++++++++- src/application.h | 7 +++ src/bytecoin-gui.pro | 8 +-- src/mainwindow.cpp | 11 ++++ src/mainwindow.h | 1 + src/mainwindow.ui | 124 ++++++++++++++++++++++++++----------------- src/version.h | 8 ++- src/walletd.cpp | 22 ++++++-- src/walletd.h | 2 +- 10 files changed, 162 insertions(+), 62 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index ee2402c..3117e1f 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,10 @@ ## Release Notes +### v3.1.1 + +- Added ability to notify the user about the new version of the app available. +- Updated the Bytecoin daemons. + ### v3.1.0 - Increment the major version to conform with the daemon versioning. diff --git a/src/application.cpp b/src/application.cpp index fb3e389..0fea211 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -30,9 +30,13 @@ #include "checkproofdialog.h" #include "walletdparamsdialog.h" #include "questiondialog.h" +#include "filedownloader.h" +#include "version.h" namespace WalletGUI { +const char VERSION_DATA_URL[] = "https://raw.githubusercontent.com/bcndev/bytecoin-gui/master/LatestStableVersion.txt?1"; // use ?1 trick to force reload and bypass cache + WalletApplication::WalletApplication(int& argc, char** argv) : QApplication(argc, argv) , m_systemTrayIcon(new QSystemTrayIcon(this)) @@ -41,16 +45,21 @@ WalletApplication::WalletApplication(int& argc, char** argv) , addressBookManager_(nullptr) , walletd_(nullptr) , walletModel_(new WalletModel(this)) + , downloader_(new FileDownloader(this)) , crashDialog_(new CrashDialog()) , m_isAboutToQuit(false) { setApplicationName("bytecoin"); // do not change becasuse it also changes data directory under Mac and Win setApplicationDisplayName(tr("Bytecoin Wallet")); - setApplicationVersion("2.0.0"); + setApplicationVersion(VERSION); setQuitOnLastWindowClosed(false); QLocale::setDefault(QLocale::c()); loadFonts(); + checkForUpdateTimer_.setInterval(12*60*60*1000); // 12 hours + connect(&checkForUpdateTimer_, &QTimer::timeout, this, &WalletApplication::checkForUpdate); + checkForUpdateTimer_.start(); + connect(this, &WalletApplication::createWalletdSignal, this, &WalletApplication::createWalletd, Qt::QueuedConnection); } @@ -130,11 +139,16 @@ bool WalletApplication::init() connect(this, &WalletApplication::builtinRunSignal, m_mainWindow, &MainWindow::builtinRun); connect(this, &WalletApplication::aboutToQuit, this, &WalletApplication::prepareToQuit); + connect(downloader_, &FileDownloader::downloaded, this, &WalletApplication::updateReceived); + connect(this, &WalletApplication::updateIsReadySignal, m_mainWindow, &MainWindow::updateIsReady); + if(isFirstRun) firstRun(); else // createWalletd(); emit createWalletdSignal(QPrivateSignal{}); + + checkForUpdate(); return true; } @@ -558,4 +572,24 @@ void WalletApplication::exportKeys() emit exportKeysSignal(m_mainWindow, QPrivateSignal{}); } +void WalletApplication::checkForUpdate() +{ + downloader_->download(QUrl::fromUserInput(VERSION_DATA_URL)); +} + +void WalletApplication::updateReceived() +{ + const QString newVersionStr = downloader_->downloadedData(); + const QString currentVersionStr = VERSION; + bool ok = false; + const int newVersion = QString(newVersionStr).remove('.').toInt(&ok); + if (!ok) + return; + ok = false; + const int currentVersion = QString(currentVersionStr).remove('.').toInt(&ok); + Q_ASSERT(ok); + if (newVersion > currentVersion) + emit updateIsReadySignal(newVersionStr); +} + } diff --git a/src/application.h b/src/application.h index da19afc..36837eb 100644 --- a/src/application.h +++ b/src/application.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "rpcapi.h" #include "walletd.h" @@ -25,6 +26,7 @@ class AddressBookManager; class CrashDialog; class MainWindow; +class FileDownloader; class WalletApplication: public QApplication { @@ -46,6 +48,8 @@ class WalletApplication: public QApplication AddressBookManager* addressBookManager_; RemoteWalletd* walletd_; WalletModel* walletModel_; + FileDownloader* downloader_; + QTimer checkForUpdateTimer_; QScopedPointer crashDialog_; bool m_isAboutToQuit; @@ -68,6 +72,7 @@ class WalletApplication: public QApplication void createWalletdSignal(QPrivateSignal); void exportViewOnlyKeysSignal(QWidget* parent/*, const QString& exportPath*/, QPrivateSignal); void exportKeysSignal(QWidget* parent, QPrivateSignal); + void updateIsReadySignal(const QString& newVersion); public slots: void createTx(const RpcApi::CreateTransaction::Request& req); @@ -103,6 +108,8 @@ private slots: void requestPasswordWithConfirmation(); void requestPasswordForExport(QProcess* walletd, QString* pass); void requestWalletdAuth(QAuthenticator* authenticator); + void checkForUpdate(); + void updateReceived(); #ifdef Q_OS_MAC private: diff --git a/src/bytecoin-gui.pro b/src/bytecoin-gui.pro index 6047039..e1ec4a0 100644 --- a/src/bytecoin-gui.pro +++ b/src/bytecoin-gui.pro @@ -15,7 +15,7 @@ TEMPLATE = app macx: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11 macx: ICON = images/bytecoin.icns win32: RC_ICONS = images/bytecoin.ico -win32: VERSION = 3.18.5.21 +win32: VERSION = 3.18.5.24 #QMAKE_CXXFLAGS += -fno-omit-frame-pointer -fsanitize=address,undefined #LIBS += -lasan -lubsan @@ -100,7 +100,8 @@ SOURCES += main.cpp\ createproofdialog.cpp \ checkproofdialog.cpp \ walletdparamsdialog.cpp \ - exportkeydialog.cpp + exportkeydialog.cpp \ + filedownloader.cpp HEADERS += mainwindow.h \ signalhandler.h \ @@ -161,7 +162,8 @@ HEADERS += mainwindow.h \ checkproofdialog.h \ walletdparamsdialog.h \ exportkeydialog.h \ - version.h + version.h \ + filedownloader.h FORMS += mainwindow.ui \ overviewframe.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 16c6426..d705611 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -70,6 +70,9 @@ MainWindow::MainWindow( { m_ui->setupUi(this); + m_ui->m_updateLabel->setText(""); + m_ui->m_updateLabel->hide(); + m_ui->m_viewOnlyLabel->setText(""); setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, this->size(), qApp->desktop()->availableGeometry())); setWindowIcon(QIcon(":images/bytecoin_lin")); clearTitle(); @@ -459,4 +462,12 @@ void MainWindow::exportKeys() emit exportKeysSignal(); } +void MainWindow::updateIsReady(const QString& newVersion) +{ + m_ui->m_updateLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + m_ui->m_updateLabel->setOpenExternalLinks(true); + m_ui->m_updateLabel->setText(QString("New version %1 of Bytecoin wallet is available.").arg(QString("%1").arg(newVersion))); + m_ui->m_updateLabel->show(); +} + } diff --git a/src/mainwindow.h b/src/mainwindow.h index fed430d..92c6477 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -67,6 +67,7 @@ class MainWindow : public QMainWindow Q_SLOT void importKeys(); Q_SLOT void exportViewOnlyKeys(); Q_SLOT void exportKeys(); + Q_SLOT void updateIsReady(const QString& newVersion); protected: void changeEvent(QEvent* event) override; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7856809..73a5303 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -151,24 +151,64 @@ 0 - - - - Qt::Vertical - - - QSizePolicy::Maximum - - - - 20 - 40 - - - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ArrowCursor + + + New version %1 of Bytecoin wallet is available! + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 40 + + + + @@ -191,46 +231,33 @@ - + (View Only) + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 40 + + + + - - - - Qt::Vertical - - - QSizePolicy::Maximum - - - - 20 - 40 - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 34 - 20 - - - + @@ -337,9 +364,6 @@ - - - diff --git a/src/version.h b/src/version.h index 63d3515..0b27755 100644 --- a/src/version.h +++ b/src/version.h @@ -1,8 +1,12 @@ #ifndef VERSION_H #define VERSION_H -constexpr char VERSION[] = "3.1.0"; +namespace WalletGUI { + +constexpr char VERSION[] = "3.1.1"; constexpr char VERSION_SUFFIX[] = "stable"; -constexpr char REVISION[] = "20180521"; +constexpr char REVISION[] = "20180524"; + +} #endif // VERSION_H diff --git a/src/walletd.cpp b/src/walletd.cpp index edf31a3..6f99f60 100644 --- a/src/walletd.cpp +++ b/src/walletd.cpp @@ -20,7 +20,7 @@ namespace { constexpr int RERUN_TIMER_MSEC = 3000; -constexpr int STATUS_TIMER_MSEC = 4000; +constexpr int STATUS_TIMER_MSEC = 15000; constexpr int WAITING_TIMEOUT_MSEC = 10000; template @@ -150,9 +150,9 @@ RemoteWalletd::RemoteWalletd(const QString& endPoint, QObject* parent) rerunTimer_.setSingleShot(true); rerunTimer_.setInterval(RERUN_TIMER_MSEC); rerunTimer_.setSingleShot(false); - statusTimer_.setInterval(STATUS_TIMER_MSEC); +// statusTimer_.setInterval(STATUS_TIMER_MSEC); connect(&rerunTimer_, &QTimer::timeout, this, &RemoteWalletd::rerun); - connect(&statusTimer_, &QTimer::timeout, this, &RemoteWalletd::sendGetStatus); +// connect(&statusTimer_, &QTimer::timeout, this, &RemoteWalletd::sendGetStatus); } /*virtual*/ @@ -195,7 +195,7 @@ void RemoteWalletd::run() this, &RemoteWalletd::errorOccurred, [this]() { - statusTimer_.start(); +// statusTimer_.start(); jsonClient_->sendGetStatus(RpcApi::GetStatus::Request{}); }); @@ -211,7 +211,7 @@ void RemoteWalletd::run() void RemoteWalletd::stop() { rerunTimer_.stop(); - statusTimer_.stop(); +// statusTimer_.stop(); setState(State::STOPPED); } @@ -220,6 +220,18 @@ void RemoteWalletd::statusReceived(const RpcApi::Status& status) if (state_ != State::STOPPED) setState(State::CONNECTED); emit statusReceivedSignal(status); + if (state_ == State::CONNECTED) + { + + jsonClient_->sendGetStatus(RpcApi::GetStatus::Request{ + status.top_block_hash, + status.transaction_pool_version, + status.outgoing_peer_count, + status.incoming_peer_count, + status.lower_level_error}); + + jsonClient_->sendGetBalance(RpcApi::GetBalance::Request{QString{}, -1}); + } } void RemoteWalletd::transfersReceived(const RpcApi::Transfers& history) diff --git a/src/walletd.h b/src/walletd.h index 8126caa..fb09d3f 100644 --- a/src/walletd.h +++ b/src/walletd.h @@ -79,7 +79,7 @@ class RemoteWalletd : public QObject // int rerunTimerId_; // int statusTimerId_; QTimer rerunTimer_; - QTimer statusTimer_; +// QTimer statusTimer_; void setState(State state); // void startRerunTimer();