From 4cdc258b152e54766bdb8c26ceee4b5ddf4bb9b6 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 5 Nov 2016 10:47:17 +0100 Subject: [PATCH 01/43] WalletManager: basic functionality --- src/daemon/DaemonManager.cpp | 87 ++++++++++++++++++++++++++++++++++++ src/daemon/DaemonManager.h | 41 +++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/daemon/DaemonManager.cpp create mode 100644 src/daemon/DaemonManager.h diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp new file mode 100644 index 00000000..30ae06cd --- /dev/null +++ b/src/daemon/DaemonManager.cpp @@ -0,0 +1,87 @@ +#include "DaemonManager.h" +#include +#include +#include +#include +#include +#include +#include +#include + +DaemonManager * DaemonManager::m_instance = nullptr; + +DaemonManager *DaemonManager::instance() +{ + if (!m_instance) { + m_instance = new DaemonManager; + } + + return m_instance; +} + +bool DaemonManager::start() +{ + QString program = QApplication::applicationDirPath() + "/monerod"; + qDebug() << "starting monerod " + program; + QStringList arguments; + + m_daemon = new QProcess(); + + connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput())); + connect (m_daemon, SIGNAL(readyReadStandardError()), this, SLOT(printError())); + + + m_daemon->start(program); + bool started = m_daemon->waitForStarted(); + + if(!started){ + qDebug() << "Daemon start error: " + m_daemon->errorString(); + } + + return started; +} + +bool DaemonManager::stop() +{ + return true; +} + +void DaemonManager::printOutput() +{ + QByteArray byteArray = m_daemon->readAllStandardOutput(); + QStringList strLines = QString(byteArray).split("\n"); + + foreach (QString line, strLines){ + // dConsole.append(line+"\n"); + qDebug() << "Daemon: " + line; + } +} + +void DaemonManager::printError() +{ + QByteArray byteArray = m_daemon->readAllStandardError(); + QStringList strLines = QString(byteArray).split("\n"); + + foreach (QString line, strLines){ + // dConsole.append(line+"\n"); + qDebug() << "Daemon ERROR: " + line; + } +} + +bool DaemonManager::running() const +{ + return m_daemon && m_daemon->state() > QProcess::NotRunning; +} + +QString DaemonManager::console() const +{ + return dConsole; +} + + +DaemonManager::DaemonManager(QObject *parent) + : QObject(parent) +{ + +} + diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h new file mode 100644 index 00000000..669f9119 --- /dev/null +++ b/src/daemon/DaemonManager.h @@ -0,0 +1,41 @@ +#ifndef DAEMONMANAGER_H +#define DAEMONMANAGER_H + +#include +#include +#include + +class DaemonManager : public QObject +{ + Q_OBJECT + +public: + + static DaemonManager * instance(); + + Q_INVOKABLE bool start(); + Q_INVOKABLE bool stop(); + Q_INVOKABLE QString console() const; + + // return true if daemon process is started + Q_INVOKABLE bool running() const; + +signals: + + void daemonStarted(const QProcess &d); + void daemonStopped(); + +public slots: + void printOutput(); + void printError(); + +private: + + explicit DaemonManager(QObject *parent = 0); + static DaemonManager * m_instance; + QProcess *m_daemon; + QString dConsole; + +}; + +#endif // DAEMONMANAGER_H From 9fbfbc4b2a36f1056bfb0f204afcc490180c4f83 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:06:41 +0100 Subject: [PATCH 02/43] daemonManager: embed as context property --- main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.cpp b/main.cpp index fe42cb61..1853ab71 100644 --- a/main.cpp +++ b/main.cpp @@ -44,6 +44,7 @@ #include "TransactionHistory.h" #include "model/TransactionHistoryModel.h" #include "model/TransactionHistorySortFilterModel.h" +#include "daemon/DaemonManager.h" int main(int argc, char *argv[]) @@ -88,6 +89,8 @@ int main(int argc, char *argv[]) qmlRegisterUncreatableType("moneroComponents.TransactionInfo", 1, 0, "TransactionInfo", "TransactionHistory can't be instantiated directly"); + qmlRegisterUncreatableType("moneroComponents.DaemonManager", 1, 0, "DaemonManager", + "DaemonManager can't be instantiated directly"); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); @@ -105,6 +108,8 @@ int main(int argc, char *argv[]) engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider()); + engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance()); + // export to QML monero accounts root directory // wizard is talking about where // to save the wallet file (.keys, .bin), they have to be user-accessible for From 1c6884e886f5f548428a1ce33798c66ac8f0675e Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 5 Nov 2016 10:54:11 +0100 Subject: [PATCH 03/43] Show daemon manager dialog if daemon isnt started --- components/DaemonManagerDialog.qml | 119 +++++++++++++++++++++++++++++ main.qml | 16 ++++ 2 files changed, 135 insertions(+) create mode 100644 components/DaemonManagerDialog.qml diff --git a/components/DaemonManagerDialog.qml b/components/DaemonManagerDialog.qml new file mode 100644 index 00000000..a0787fb5 --- /dev/null +++ b/components/DaemonManagerDialog.qml @@ -0,0 +1,119 @@ +// Copyright (c) 2014-2015, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import QtQuick 2.0 +import QtQuick.Controls 1.4 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Window 2.0 + +import "../components" as MoneroComponents + +Window { + id: root + modality: Qt.ApplicationModal + flags: Qt.Window | Qt.FramelessWindowHint + + signal rejected() + + function open() { + show() + } + + // TODO: implement without hardcoding sizes + width: 480 + height: 200 + + ColumnLayout { + id: mainLayout + spacing: 10 + anchors { fill: parent; margins: 35 } + + ColumnLayout { + id: column + //anchors {fill: parent; margins: 16 } + Layout.alignment: Qt.AlignHCenter + + Label { + text: qsTr("Daemon doesn't appear to be running") + Layout.alignment: Qt.AlignHCenter + Layout.columnSpan: 2 + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 24 + font.family: "Arial" + color: "#555555" + } + + } + + RowLayout { + id: buttons + spacing: 60 + Layout.alignment: Qt.AlignHCenter + + MoneroComponents.StandardButton { + id: okButton + width: 120 + fontSize: 14 + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + text: qsTr("Start daemon") + KeyNavigation.tab: cancelButton + onClicked: { + daemonManager.start(); + root.accepted() + root.close() + } + } + + MoneroComponents.StandardButton { + id: cancelButton + width: 120 + fontSize: 14 + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + text: qsTr("Cancel") + + onClicked: { + root.rejected() + root.close() + } + } + } + } + +} + + + diff --git a/main.qml b/main.qml index 5f28e415..af027f5e 100644 --- a/main.qml +++ b/main.qml @@ -318,6 +318,18 @@ ApplicationWindow { } + + + // daemonManager.daemonConsole(); + // console.log("Daemon runnnig: ",daemonManager.running()); + + if(!daemonManager.running()){ + daemonManagerDialog.open(); + } + + + + onWalletUpdate(); } @@ -721,6 +733,10 @@ ApplicationWindow { } + DaemonManagerDialog { + id: daemonManagerDialog + + } ProcessingSplash { id: splash From 82c39e09bf237cc825252a45a9dd2ce3f1a63fc8 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:08:39 +0100 Subject: [PATCH 04/43] WalletManager: include dependencies --- monero-core.pro | 6 ++++-- qml.qrc | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/monero-core.pro b/monero-core.pro index 5e47d732..249a65f5 100644 --- a/monero-core.pro +++ b/monero-core.pro @@ -30,7 +30,8 @@ HEADERS += \ src/model/TransactionHistorySortFilterModel.h \ src/QR-Code-generator/BitBuffer.hpp \ src/QR-Code-generator/QrCode.hpp \ - src/QR-Code-generator/QrSegment.hpp + src/QR-Code-generator/QrSegment.hpp \ + src/daemon/DaemonManager.h SOURCES += main.cpp \ @@ -49,7 +50,8 @@ SOURCES += main.cpp \ src/model/TransactionHistorySortFilterModel.cpp \ src/QR-Code-generator/BitBuffer.cpp \ src/QR-Code-generator/QrCode.cpp \ - src/QR-Code-generator/QrSegment.cpp + src/QR-Code-generator/QrSegment.cpp \ + src/daemon/DaemonManager.cpp lupdate_only { SOURCES = *.qml \ diff --git a/qml.qrc b/qml.qrc index 17873589..93938e96 100644 --- a/qml.qrc +++ b/qml.qrc @@ -120,5 +120,6 @@ components/DaemonProgress.qml components/StandardDialog.qml pages/Sign.qml + components/DaemonManagerDialog.qml From 277512475715a353e81a217a751655ec6fd4c943 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 5 Nov 2016 11:00:29 +0100 Subject: [PATCH 05/43] small error in daemon manager dialog --- components/DaemonManagerDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DaemonManagerDialog.qml b/components/DaemonManagerDialog.qml index a0787fb5..23f2e9e5 100644 --- a/components/DaemonManagerDialog.qml +++ b/components/DaemonManagerDialog.qml @@ -90,8 +90,8 @@ Window { KeyNavigation.tab: cancelButton onClicked: { daemonManager.start(); - root.accepted() root.close() + // root.accepted() } } From ae977af2ec10f7cdb24d17479a354d7b5b47a493 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 5 Nov 2016 11:08:35 +0100 Subject: [PATCH 06/43] settings: add daemon manager --- pages/Settings.qml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pages/Settings.qml b/pages/Settings.qml index e144cccc..9fc76df6 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -37,7 +37,6 @@ import "../components" import moneroComponents.Clipboard 1.0 Rectangle { - property var daemonAddress color: "#F0EEEE" @@ -272,6 +271,44 @@ Rectangle { } } + RowLayout { + Label { + id: manageDaemonLabel + color: "#4A4949" + text: qsTr("Manage daemon") + translationManager.emptyString + fontSize: 16 + } + + StandardButton { + visible: true + id: startDaemonButton + width: 110 + text: qsTr("Start daemon") + translationManager.emptyString + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + onClicked: { + daemonManager.start(); + } + } + + StandardButton { + visible: false + id: stopDaemonButton + width: 110 + text: qsTr("Stop daemon") + translationManager.emptyString + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + onClicked: { + + //daemonManager.stop(); + } + } + } + } From 86772bee5221d68862a5471dca6b2ee4227599e2 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 19 Nov 2016 15:05:53 +0100 Subject: [PATCH 07/43] added standardDialog component --- components/StandardDialog.qml | 1 + qml.qrc | 1 + 2 files changed, 2 insertions(+) diff --git a/components/StandardDialog.qml b/components/StandardDialog.qml index 0e081ae5..8c7a05d3 100644 --- a/components/StandardDialog.qml +++ b/components/StandardDialog.qml @@ -119,6 +119,7 @@ Window { releasedColor: "#FF6C3C" pressedColor: "#FF4304" text: qsTr("Cancel") + KeyNavigation.tab: passwordInput onClicked: { root.rejected() root.close() diff --git a/qml.qrc b/qml.qrc index 93938e96..c1aa0ece 100644 --- a/qml.qrc +++ b/qml.qrc @@ -121,5 +121,6 @@ components/StandardDialog.qml pages/Sign.qml components/DaemonManagerDialog.qml + components/StandardDialog.qml From de635cb24f8943192dab2fab9e8541277e65df2c Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 19 Nov 2016 15:07:49 +0100 Subject: [PATCH 08/43] pw dialog: close popup before continue --- components/PasswordDialog.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml index 7d1a5bd6..7b19c517 100644 --- a/components/PasswordDialog.qml +++ b/components/PasswordDialog.qml @@ -143,8 +143,8 @@ Window { text: qsTr("Cancel") KeyNavigation.tab: passwordInput onClicked: { - root.rejected() root.close() + root.rejected() } } MoneroComponents.StandardButton { @@ -158,8 +158,8 @@ Window { text: qsTr("Ok") KeyNavigation.tab: cancelButton onClicked: { - root.accepted() root.close() + root.accepted() } } } From 48471f3407b8263f66254a39d693604de8894a38 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:09:32 +0100 Subject: [PATCH 09/43] onDaemonStarted/stopped signals/slots --- main.qml | 31 ++++++++++++++++++------------- src/daemon/DaemonManager.cpp | 11 +++++++++++ src/daemon/DaemonManager.h | 3 +-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/main.qml b/main.qml index af027f5e..e9a36684 100644 --- a/main.qml +++ b/main.qml @@ -59,6 +59,7 @@ ApplicationWindow { property int restoreHeight:0 property bool daemonSynced: false property int maxWindowHeight: (Screen.height < 900)? 720 : 800; + property bool daemonRunning: false // true if wallet ever synchronized property bool walletInitialized : false @@ -292,6 +293,10 @@ ApplicationWindow { // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) + // If wallet isnt connected and no daemon is running - Ask + if(!currentWallet.connected && !daemonManager.running() && !walletInitialized){ + daemonManagerDialog.open(); + } // Refresh is succesfull if blockchain height > 1 if (currentWallet.blockChainHeight() > 1){ @@ -317,22 +322,19 @@ ApplicationWindow { walletInitialized = true } - - - - // daemonManager.daemonConsole(); - // console.log("Daemon runnnig: ",daemonManager.running()); - - if(!daemonManager.running()){ - daemonManagerDialog.open(); - } - - - - onWalletUpdate(); } + function onDaemonStarted(){ + console.log("daemon started"); + daemonRunning = true; + } + function onDaemonStopped(){ + console.log("daemon stopped"); + daemonRunning = false; + } + + function onWalletNewBlock(blockHeight) { if (splash.visible) { var currHeight = blockHeight @@ -645,6 +647,9 @@ ApplicationWindow { walletManager.walletOpened.connect(onWalletOpened); walletManager.walletClosed.connect(onWalletClosed); + daemonManager.daemonStarted.connect(onDaemonStarted); + daemonManager.daemonStopped.connect(onDaemonStopped); + if(!walletsFound()) { rootItem.state = "wizard" } else { diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 30ae06cd..a637d281 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -36,6 +36,8 @@ bool DaemonManager::start() if(!started){ qDebug() << "Daemon start error: " + m_daemon->errorString(); + } else { + emit daemonStarted(); } return started; @@ -43,6 +45,15 @@ bool DaemonManager::start() bool DaemonManager::stop() { + if(m_daemon){ + qDebug() << "stopping daemon"; + m_daemon->terminate(); + // Wait until stopped. Max 30 seconds + bool stopped = m_daemon->waitForFinished(30000); + if(stopped) emit daemonStopped(); + return stopped; + } + return true; } diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 669f9119..b4170047 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -21,8 +21,7 @@ public: Q_INVOKABLE bool running() const; signals: - - void daemonStarted(const QProcess &d); + void daemonStarted(); void daemonStopped(); public slots: From 4e7de8c140f52ed158eb0c93fbbe2aecf1c926e2 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:10:59 +0100 Subject: [PATCH 10/43] proper daemon shutdown on app exit --- main.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.qml b/main.qml index e9a36684..1bb88a5e 100644 --- a/main.qml +++ b/main.qml @@ -1058,5 +1058,7 @@ ApplicationWindow { walletManager.closeWallet(currentWallet); currentWallet = undefined } + // Stop daemon + daemonManager.stop(); } } From 482bd30c0066c78b0ce69d375b2831193a395475 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sun, 6 Nov 2016 23:34:07 +0100 Subject: [PATCH 11/43] settings: enable/disable daemon start/stop buttons --- pages/Settings.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pages/Settings.qml b/pages/Settings.qml index 9fc76df6..8a946fdf 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -281,6 +281,7 @@ Rectangle { StandardButton { visible: true + enabled: !appWindow.daemonRunning id: startDaemonButton width: 110 text: qsTr("Start daemon") + translationManager.emptyString @@ -294,7 +295,8 @@ Rectangle { } StandardButton { - visible: false + visible: true + enabled: appWindow.daemonRunning id: stopDaemonButton width: 110 text: qsTr("Stop daemon") + translationManager.emptyString @@ -303,8 +305,7 @@ Rectangle { releasedColor: "#FF6C3C" pressedColor: "#FF4304" onClicked: { - - //daemonManager.stop(); + daemonManager.stop(); } } } From d4657804cd35b7d25dca67aa16c3eeb35140eb44 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sun, 6 Nov 2016 23:35:16 +0100 Subject: [PATCH 12/43] resized standard dialog --- components/StandardDialog.qml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/StandardDialog.qml b/components/StandardDialog.qml index 8c7a05d3..8f7e0e8d 100644 --- a/components/StandardDialog.qml +++ b/components/StandardDialog.qml @@ -40,9 +40,11 @@ Window { modality: Qt.ApplicationModal flags: Qt.Window | Qt.FramelessWindowHint property alias title: dialogTitle.text - property alias content: dialogContent.text + property alias text: dialogContent.text + property alias content: root.text property alias cancelVisible: cancelButton.visible property alias okVisible: okButton.visible + property var icon // same signals as Dialog has signal accepted() @@ -54,8 +56,8 @@ Window { } // TODO: implement without hardcoding sizes - width: 600 - height: 480 + width: 800 + height: 580 ColumnLayout { id: mainLayout @@ -80,6 +82,8 @@ Window { RowLayout { TextArea { id : dialogContent + width: 750 + height: 480 Layout.fillWidth: true font.family: "Arial" textFormat: TextEdit.AutoText From 5a110f410f0405b0783b7e0700add0a5e7164f1a Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Sat, 19 Nov 2016 15:15:11 +0100 Subject: [PATCH 13/43] replace message dialog with custom dialog --- main.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.qml b/main.qml index 1bb88a5e..78e3ccac 100644 --- a/main.qml +++ b/main.qml @@ -685,11 +685,11 @@ ApplicationWindow { // TODO: replace with customized popups // Information dialog - MessageDialog { + StandardDialog { // dynamically change onclose handler property var onCloseCallback id: informationPopup - standardButtons: StandardButton.Ok + cancelVisible: false onAccepted: { if (onCloseCallback) { onCloseCallback() @@ -698,10 +698,10 @@ ApplicationWindow { } // Confrirmation aka question dialog - MessageDialog { + StandardDialog { id: transactionConfirmationPopup - standardButtons: StandardButton.Ok + StandardButton.Cancel onAccepted: { + close(); handleTransactionConfirmed() } } From 5da9f8fbe4f2221bb6ec7ce08140c17ef0754b18 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 11:09:31 +0100 Subject: [PATCH 14/43] standardDialog: close window before continue --- components/StandardDialog.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/StandardDialog.qml b/components/StandardDialog.qml index 8f7e0e8d..f93a22ea 100644 --- a/components/StandardDialog.qml +++ b/components/StandardDialog.qml @@ -109,8 +109,9 @@ Window { text: qsTr("Ok") KeyNavigation.tab: cancelButton onClicked: { - root.accepted() root.close() + root.accepted() + } } @@ -125,8 +126,8 @@ Window { text: qsTr("Cancel") KeyNavigation.tab: passwordInput onClicked: { - root.rejected() root.close() + root.rejected() } } } From 3df9e44849cfd0e086d33b79d4dacd03b99a5583 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 11:55:11 +0100 Subject: [PATCH 15/43] DaemonManager: windows support --- src/daemon/DaemonManager.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index a637d281..80d7c8a4 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -21,17 +21,33 @@ DaemonManager *DaemonManager::instance() bool DaemonManager::start() { - QString program = QApplication::applicationDirPath() + "/monerod"; - qDebug() << "starting monerod " + program; + + // + QString process; +#ifdef Q_OS_WIN + process = QApplication::applicationDirPath() + "/monerod.exe"; +#elif defined(Q_OS_UNIX) + process = QApplication::applicationDirPath() + "/monerod"; +#endif + + if(process.length() == 0) { + qDebug() << "no daemon binary defined for current platform"; + return false; + } + + qDebug() << "starting monerod " + process; + + // TODO: forward CLI arguments QStringList arguments; m_daemon = new QProcess(); + // Connect output slots connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput())); connect (m_daemon, SIGNAL(readyReadStandardError()), this, SLOT(printError())); - m_daemon->start(program); + m_daemon->start(process); bool started = m_daemon->waitForStarted(); if(!started){ @@ -48,8 +64,8 @@ bool DaemonManager::stop() if(m_daemon){ qDebug() << "stopping daemon"; m_daemon->terminate(); - // Wait until stopped. Max 30 seconds - bool stopped = m_daemon->waitForFinished(30000); + // Wait until stopped. Max 10 seconds + bool stopped = m_daemon->waitForFinished(10000); if(stopped) emit daemonStopped(); return stopped; } From 3a431543fab567d42f5981d82687c1c9a9244f68 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 13:10:10 +0100 Subject: [PATCH 16/43] DaemonManager: added console updated signals --- src/daemon/DaemonManager.cpp | 17 +++++++++++++---- src/daemon/DaemonManager.h | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 80d7c8a4..1fdfcd52 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -41,6 +41,7 @@ bool DaemonManager::start() QStringList arguments; m_daemon = new QProcess(); + initialized = true; // Connect output slots connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput())); @@ -61,7 +62,7 @@ bool DaemonManager::start() bool DaemonManager::stop() { - if(m_daemon){ + if(initialized){ qDebug() << "stopping daemon"; m_daemon->terminate(); // Wait until stopped. Max 10 seconds @@ -80,7 +81,8 @@ void DaemonManager::printOutput() foreach (QString line, strLines){ // dConsole.append(line+"\n"); - qDebug() << "Daemon: " + line; + emit daemonConsoleUpdated(line); + // qDebug() << "Daemon: " + line; } } @@ -91,13 +93,20 @@ void DaemonManager::printError() foreach (QString line, strLines){ // dConsole.append(line+"\n"); - qDebug() << "Daemon ERROR: " + line; + emit daemonConsoleUpdated(line); + // qDebug() << "Daemon ERROR: " + line; } } bool DaemonManager::running() const { - return m_daemon && m_daemon->state() > QProcess::NotRunning; + if(initialized){ + qDebug() << m_daemon->state(); + qDebug() << QProcess::NotRunning; + + return m_daemon->state() > QProcess::NotRunning; + } + return false; } QString DaemonManager::console() const diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index b4170047..4dfc77a1 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -23,6 +23,7 @@ public: signals: void daemonStarted(); void daemonStopped(); + void daemonConsoleUpdated(QString message); public slots: void printOutput(); @@ -34,6 +35,7 @@ private: static DaemonManager * m_instance; QProcess *m_daemon; QString dConsole; + bool initialized = false; }; From 5855700007a1675916440944dbf8d03d4ac886f2 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 14:54:49 +0100 Subject: [PATCH 17/43] daemonManagerDialog: added starting signal --- components/DaemonManagerDialog.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/DaemonManagerDialog.qml b/components/DaemonManagerDialog.qml index 23f2e9e5..f93cbb9a 100644 --- a/components/DaemonManagerDialog.qml +++ b/components/DaemonManagerDialog.qml @@ -41,6 +41,7 @@ Window { flags: Qt.Window | Qt.FramelessWindowHint signal rejected() + signal started(); function open() { show() @@ -91,7 +92,7 @@ Window { onClicked: { daemonManager.start(); root.close() - // root.accepted() + root.started() } } @@ -106,8 +107,8 @@ Window { text: qsTr("Cancel") onClicked: { - root.rejected() root.close() + root.rejected() } } } From b4f29b291c96378115bf3a3883858246dc2e73d5 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 14:56:05 +0100 Subject: [PATCH 18/43] StandardDialog: changed default sizes --- components/StandardDialog.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/StandardDialog.qml b/components/StandardDialog.qml index f93a22ea..39ef1660 100644 --- a/components/StandardDialog.qml +++ b/components/StandardDialog.qml @@ -44,6 +44,7 @@ Window { property alias content: root.text property alias cancelVisible: cancelButton.visible property alias okVisible: okButton.visible + property alias textArea: dialogContent property var icon // same signals as Dialog has @@ -56,8 +57,8 @@ Window { } // TODO: implement without hardcoding sizes - width: 800 - height: 580 + width: 480 + height: 280 ColumnLayout { id: mainLayout @@ -82,9 +83,8 @@ Window { RowLayout { TextArea { id : dialogContent - width: 750 - height: 480 Layout.fillWidth: true + Layout.fillHeight: true font.family: "Arial" textFormat: TextEdit.AutoText readOnly: true From b53ef00b3611998148a91c0ffc97460ff0a0b54e Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 14:58:06 +0100 Subject: [PATCH 19/43] history tx details: resized popup --- components/HistoryTable.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/components/HistoryTable.qml b/components/HistoryTable.qml index 5f4584c7..0c9e9b60 100644 --- a/components/HistoryTable.qml +++ b/components/HistoryTable.qml @@ -69,6 +69,7 @@ ListView { StandardDialog { id: detailsPopup + width:600 cancelVisible: false okVisible: true } From 14a5bd5dcc036a985a71e775a6d72cd5e703d322 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 14:59:00 +0100 Subject: [PATCH 20/43] settings: added daemon console --- pages/Settings.qml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pages/Settings.qml b/pages/Settings.qml index 8a946fdf..eba450d7 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -308,17 +308,57 @@ Rectangle { daemonManager.stop(); } } + + StandardButton { + visible: true + // enabled: appWindow.daemonRunning + id: daemonConsolePopupButton + width: 110 + text: qsTr("Show concole") + translationManager.emptyString + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + onClicked: { + daemonConsolePopup.open(); + } + } + } } + // Daemon console + StandardDialog { + id: daemonConsolePopup + height:800 + width:800 + cancelVisible: false + title: qsTr("Daemon console") + onAccepted: { + close(); + } + } + // fires on every page load function onPageCompleted() { console.log("Settings page loaded"); initSettings(); } + // fires only once + Component.onCompleted: { + daemonManager.daemonConsoleUpdated.connect(onDaemonConsoleUpdated) + } + + function onDaemonConsoleUpdated(message){ + // Update daemon console + daemonConsolePopup.textArea.append(message) + } + + + } From 7840dab9cc03730ceaf7bfdc0b93674bc6489de6 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 15:00:14 +0100 Subject: [PATCH 21/43] DaemonManager: console debug output --- src/daemon/DaemonManager.cpp | 12 ++---------- src/daemon/DaemonManager.h | 2 -- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 1fdfcd52..aa87f1c6 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -80,9 +80,8 @@ void DaemonManager::printOutput() QStringList strLines = QString(byteArray).split("\n"); foreach (QString line, strLines){ - // dConsole.append(line+"\n"); emit daemonConsoleUpdated(line); - // qDebug() << "Daemon: " + line; + qDebug() << "Daemon: " + line; } } @@ -92,9 +91,8 @@ void DaemonManager::printError() QStringList strLines = QString(byteArray).split("\n"); foreach (QString line, strLines){ - // dConsole.append(line+"\n"); emit daemonConsoleUpdated(line); - // qDebug() << "Daemon ERROR: " + line; + qDebug() << "Daemon ERROR: " + line; } } @@ -109,12 +107,6 @@ bool DaemonManager::running() const return false; } -QString DaemonManager::console() const -{ - return dConsole; -} - - DaemonManager::DaemonManager(QObject *parent) : QObject(parent) { diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 4dfc77a1..4ee5214e 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -15,7 +15,6 @@ public: Q_INVOKABLE bool start(); Q_INVOKABLE bool stop(); - Q_INVOKABLE QString console() const; // return true if daemon process is started Q_INVOKABLE bool running() const; @@ -34,7 +33,6 @@ private: explicit DaemonManager(QObject *parent = 0); static DaemonManager * m_instance; QProcess *m_daemon; - QString dConsole; bool initialized = false; }; From 752ff2616f466750b6d406e831daa51dd2288f00 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:12:07 +0100 Subject: [PATCH 22/43] forward command line arguments to DaemonManager --- main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 1853ab71..570916ea 100644 --- a/main.cpp +++ b/main.cpp @@ -51,8 +51,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - qDebug() << "app startd"; - app.setApplicationName("monero-core"); app.setOrganizationDomain("getmonero.org"); app.setOrganizationName("The Monero Project"); @@ -108,7 +106,7 @@ int main(int argc, char *argv[]) engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider()); - engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance()); + engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance(QCoreApplication::arguments())); // export to QML monero accounts root directory // wizard is talking about where From b4eb489b001fb23382fe2725f747b1d94abacd76 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 18:08:09 +0100 Subject: [PATCH 23/43] DaemonManager: forward command line arguments to monerod --- src/daemon/DaemonManager.cpp | 20 +++++++++++++++----- src/daemon/DaemonManager.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index aa87f1c6..122aec5e 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -9,11 +9,15 @@ #include DaemonManager * DaemonManager::m_instance = nullptr; +QStringList DaemonManager::clArgs; -DaemonManager *DaemonManager::instance() +DaemonManager *DaemonManager::instance(QStringList args) { if (!m_instance) { m_instance = new DaemonManager; + // store command line arguments for later use + clArgs = args; + clArgs.removeFirst(); } return m_instance; @@ -35,10 +39,16 @@ bool DaemonManager::start() return false; } - qDebug() << "starting monerod " + process; - // TODO: forward CLI arguments + // prepare command line arguments and pass to monerod QStringList arguments; + foreach (const QString &str, clArgs) { + qDebug() << QString(" [%1] ").arg(str); + arguments << str; + } + + qDebug() << "starting monerod " + process; + qDebug() << "With command line arguments " << arguments; m_daemon = new QProcess(); initialized = true; @@ -47,8 +57,8 @@ bool DaemonManager::start() connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput())); connect (m_daemon, SIGNAL(readyReadStandardError()), this, SLOT(printError())); - - m_daemon->start(process); + // Start monerod + m_daemon->start(process,arguments); bool started = m_daemon->waitForStarted(); if(!started){ diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 4ee5214e..6beb14ed 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -11,7 +11,7 @@ class DaemonManager : public QObject public: - static DaemonManager * instance(); + static DaemonManager * instance(QStringList args); Q_INVOKABLE bool start(); Q_INVOKABLE bool stop(); @@ -32,6 +32,7 @@ private: explicit DaemonManager(QObject *parent = 0); static DaemonManager * m_instance; + static QStringList clArgs; QProcess *m_daemon; bool initialized = false; From 065b0601020643c4c1ba7b50582256273f2c27f8 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 18:09:47 +0100 Subject: [PATCH 24/43] main: debug messages --- main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.cpp b/main.cpp index 570916ea..21ab9da5 100644 --- a/main.cpp +++ b/main.cpp @@ -51,6 +51,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + qDebug() << "app startd"; + app.setApplicationName("monero-core"); app.setOrganizationDomain("getmonero.org"); app.setOrganizationName("The Monero Project"); From 7876957b484580fcf3d3d9224e6b7f3b165025f4 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 23:06:18 +0100 Subject: [PATCH 25/43] DaemonManager::closing() --- src/daemon/DaemonManager.cpp | 5 +++++ src/daemon/DaemonManager.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 122aec5e..293c600b 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -123,3 +123,8 @@ DaemonManager::DaemonManager(QObject *parent) } +void DaemonManager::closing() +{ + qDebug() << __FUNCTION__; + stop(); +} diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 6beb14ed..5c1234d6 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -27,6 +27,7 @@ signals: public slots: void printOutput(); void printError(); + void closing(); private: From 8dfa79ec58898a1b9522d1f2e86a73aab346319f Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:14:52 +0100 Subject: [PATCH 26/43] Shutdown daemon and close wallet properly on app exit --- main.cpp | 8 ++++++++ main.qml | 15 ++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 21ab9da5..ebae384f 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "clipboardAdapter.h" #include "filter.h" #include "oscursor.h" @@ -110,6 +111,13 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance(QCoreApplication::arguments())); + DaemonManager * daemonManager = DaemonManager::instance(QCoreApplication::arguments()); + QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing())); + engine.rootContext()->setContextProperty("daemonManager", daemonManager); + + +>>>>>>> cc05e1a... Shutdown daemon and close wallet properly on app exit + // export to QML monero accounts root directory // wizard is talking about where // to save the wallet file (.keys, .bin), they have to be user-accessible for diff --git a/main.qml b/main.qml index 78e3ccac..f51ffded 100644 --- a/main.qml +++ b/main.qml @@ -1053,12 +1053,13 @@ ApplicationWindow { } } onClosing: { - // Close and save to disk on app close - if (currentWallet != undefined) { - walletManager.closeWallet(currentWallet); - currentWallet = undefined - } - // Stop daemon - daemonManager.stop(); + // Make sure wallet is closed before app exit (~Wallet() isn't always invoked) + // Daemon shutdown is handled with signal/slot in main.cpp + if (currentWallet != undefined) { + walletManager.closeWallet(currentWallet); + currentWallet = undefined + } + // Stop daemon + daemonManager.stop(); } } From 8361dda994b35803fbfc5bfdced262c4f6f30be2 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:17:38 +0100 Subject: [PATCH 27/43] resolve rebase conflict --- main.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/main.cpp b/main.cpp index ebae384f..4bc71a53 100644 --- a/main.cpp +++ b/main.cpp @@ -115,9 +115,6 @@ int main(int argc, char *argv[]) QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing())); engine.rootContext()->setContextProperty("daemonManager", daemonManager); - ->>>>>>> cc05e1a... Shutdown daemon and close wallet properly on app exit - // export to QML monero accounts root directory // wizard is talking about where // to save the wallet file (.keys, .bin), they have to be user-accessible for From bb881d9aef71a7aac6d41f71f802206e86a2e864 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 11:31:27 +0100 Subject: [PATCH 28/43] show processingSplash when starting/stopping daemon --- main.qml | 9 +++++++++ pages/Settings.qml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/main.qml b/main.qml index f51ffded..e464fcb7 100644 --- a/main.qml +++ b/main.qml @@ -325,6 +325,15 @@ ApplicationWindow { onWalletUpdate(); } + function startDaemon(){ + appWindow.showProcessingSplash(qsTr("Waiting for daemon to start...")) + daemonManager.start(); + } + function stopDaemon(){ + appWindow.showProcessingSplash(qsTr("Waiting for daemon to stop...")) + daemonManager.stop(); + } + function onDaemonStarted(){ console.log("daemon started"); daemonRunning = true; diff --git a/pages/Settings.qml b/pages/Settings.qml index eba450d7..9b6e618c 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -290,7 +290,7 @@ Rectangle { releasedColor: "#FF6C3C" pressedColor: "#FF4304" onClicked: { - daemonManager.start(); + appWindow.startDaemon() } } @@ -305,7 +305,7 @@ Rectangle { releasedColor: "#FF6C3C" pressedColor: "#FF4304" onClicked: { - daemonManager.stop(); + appWindow.stopDaemon() } } From 760e01b50c38cfeff4b80bf8129cc51559a2a6e5 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 11:41:27 +0100 Subject: [PATCH 29/43] daemonManagerDialog: show processdialog when starting --- components/DaemonManagerDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DaemonManagerDialog.qml b/components/DaemonManagerDialog.qml index f93cbb9a..da3cf582 100644 --- a/components/DaemonManagerDialog.qml +++ b/components/DaemonManagerDialog.qml @@ -90,8 +90,8 @@ Window { text: qsTr("Start daemon") KeyNavigation.tab: cancelButton onClicked: { - daemonManager.start(); root.close() + appWindow.startDaemon(); root.started() } } From 8d19a03b6801272552e2157623c320d51f6aaad5 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 11:54:06 +0100 Subject: [PATCH 30/43] DaemonManager: add stateChanged() --- src/daemon/DaemonManager.cpp | 21 +++++++++++++++------ src/daemon/DaemonManager.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 293c600b..3769302a 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -61,6 +61,9 @@ bool DaemonManager::start() m_daemon->start(process,arguments); bool started = m_daemon->waitForStarted(); + // add state changed listener + connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState))); + if(!started){ qDebug() << "Daemon start error: " + m_daemon->errorString(); } else { @@ -74,16 +77,22 @@ bool DaemonManager::stop() { if(initialized){ qDebug() << "stopping daemon"; - m_daemon->terminate(); - // Wait until stopped. Max 10 seconds - bool stopped = m_daemon->waitForFinished(10000); - if(stopped) emit daemonStopped(); - return stopped; + // we can't use QProcess::terminate() on windows console process + // write exit command to stdin + m_daemon->write("exit\n"); } return true; } +void DaemonManager::stateChanged(QProcess::ProcessState state) +{ + qDebug() << "STATE CHANGED: " << state; + if(state == QProcess::NotRunning) { + emit daemonStopped(); + } +} + void DaemonManager::printOutput() { QByteArray byteArray = m_daemon->readAllStandardOutput(); @@ -111,7 +120,7 @@ bool DaemonManager::running() const if(initialized){ qDebug() << m_daemon->state(); qDebug() << QProcess::NotRunning; - + // m_daemon->write("status\n"); return m_daemon->state() > QProcess::NotRunning; } return false; diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 5c1234d6..1c4ae8ad 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -28,6 +28,7 @@ public slots: void printOutput(); void printError(); void closing(); + void stateChanged(QProcess::ProcessState state); private: From dd01f59a9c99a5aeea988218c57ca3f97f0fe785 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 13:15:25 +0100 Subject: [PATCH 31/43] hide daemon sync progress after disconnecting wallet --- components/DaemonProgress.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/DaemonProgress.qml b/components/DaemonProgress.qml index 1ed533e3..846c03d3 100644 --- a/components/DaemonProgress.qml +++ b/components/DaemonProgress.qml @@ -27,6 +27,7 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import QtQuick 2.0 +import moneroComponents.Wallet 1.0 Item { id: item @@ -46,7 +47,7 @@ Item { // TODO: lower daemon block height cache, ttl and refresh interval? - item.visible = (currentBlock < targetBlock) + item.visible = (currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (currentBlock < targetBlock) } } From f62bb687dfbb0c84492091de3c734800c3ea9886 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 13:16:36 +0100 Subject: [PATCH 32/43] daemonManagerDialog: use new ConnectionStatus enum --- main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.qml b/main.qml index e464fcb7..d0c77338 100644 --- a/main.qml +++ b/main.qml @@ -294,7 +294,7 @@ ApplicationWindow { daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) // If wallet isnt connected and no daemon is running - Ask - if(!currentWallet.connected && !daemonManager.running() && !walletInitialized){ + if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){ daemonManagerDialog.open(); } From d9f4ab45e2bfba2baf3d454d659f1776b5ea69a9 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 13:41:34 +0100 Subject: [PATCH 33/43] daemonManager: wait for daemon stop on app close --- src/daemon/DaemonManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 3769302a..b84a0fa2 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -136,4 +136,8 @@ void DaemonManager::closing() { qDebug() << __FUNCTION__; stop(); + // Wait for daemon to stop before exiting (max 10 secs) + if(initialized){ + m_daemon->waitForFinished(10000); + } } From 18b7a6788659bd39c0241b29be5cedc2762037b2 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 15:34:56 +0100 Subject: [PATCH 34/43] Wallet: add connectionStatusChanged signal --- src/libwalletqt/Wallet.cpp | 11 +++++++++-- src/libwalletqt/Wallet.h | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 9170073d..608bbd0f 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -87,9 +87,15 @@ Wallet::Status Wallet::status() const return static_cast(m_walletImpl->status()); } -Wallet::ConnectionStatus Wallet::connected() const +Wallet::ConnectionStatus Wallet::connected() { - return static_cast(m_walletImpl->connected()); + qDebug("Checking wallet connection status"); + ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); + if(newStatus != m_connectionStatus) { + m_connectionStatus = newStatus; + emit connectionStatusChanged(); + } + return newStatus; } bool Wallet::synchronized() const @@ -422,6 +428,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) { m_history = new TransactionHistory(m_walletImpl->history(), this); m_walletImpl->setListener(new WalletListenerImpl(this)); + m_connectionStatus = Wallet::ConnectionStatus_Disconnected; } Wallet::~Wallet() diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 14308ce5..f9cf8792 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -63,7 +63,7 @@ public: Status status() const; //! returns whether the wallet is connected, and version status - ConnectionStatus connected() const; + ConnectionStatus connected(); //! returns true if wallet was ever synchronized bool synchronized() const; @@ -196,6 +196,8 @@ signals: // emitted when transaction is created async void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount); + void connectionStatusChanged(); + private: Wallet(QObject * parent = nullptr); Wallet(Bitmonero::Wallet *w, QObject * parent = 0); @@ -217,6 +219,7 @@ private: mutable QTime m_daemonBlockChainTargetHeightTime; mutable quint64 m_daemonBlockChainTargetHeight; int m_daemonBlockChainTargetHeightTtl; + ConnectionStatus m_connectionStatus; }; From 76e6ae8b6f8392871011639be214fe03346e23e4 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 15:35:45 +0100 Subject: [PATCH 35/43] remove reference to old pw-dialog --- components/StandardDialog.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/components/StandardDialog.qml b/components/StandardDialog.qml index 39ef1660..03c64a64 100644 --- a/components/StandardDialog.qml +++ b/components/StandardDialog.qml @@ -124,7 +124,6 @@ Window { releasedColor: "#FF6C3C" pressedColor: "#FF4304" text: qsTr("Cancel") - KeyNavigation.tab: passwordInput onClicked: { root.close() root.rejected() From 93a8200e4afe78907b8a84d88e2dfe643cd40ae7 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 15:47:25 +0100 Subject: [PATCH 36/43] Transfer: new connectionStatus handling + show status msg --- MiddlePanel.qml | 16 ++++------- pages/Transfer.qml | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/MiddlePanel.qml b/MiddlePanel.qml index e14255a5..16cc9492 100644 --- a/MiddlePanel.qml +++ b/MiddlePanel.qml @@ -32,6 +32,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import QtGraphicalEffects 1.0 +import moneroComponents.Wallet 1.0 import "./pages" @@ -56,9 +57,6 @@ Rectangle { signal generatePaymentIdInvoked() signal checkPaymentClicked(string address, string txid, string txkey); - // Disable transfer page if daemon isnt fully synced - enabled: (currentView !== transferView || appWindow.daemonSynced) - color: "#F0EEEE" onCurrentViewChanged: { @@ -72,6 +70,10 @@ Rectangle { } } + function updateStatus(){ + transferView.updateStatus(); + } + // XXX: just for memo, to be removed // states: [ @@ -292,14 +294,6 @@ Rectangle { color: "#DBDBDB" } - Rectangle { - id:desaturate - color:"black" - anchors.fill: parent - opacity: 0.1 - visible: (root.enabled)? 0 : 1; - } - /* connect "payment" click */ Connections { diff --git a/pages/Transfer.qml b/pages/Transfer.qml index d2bfc213..7ef534a2 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -29,6 +29,7 @@ import QtQuick 2.0 import moneroComponents.PendingTransaction 1.0 import "../components" +import moneroComponents.Wallet 1.0 Rectangle { @@ -331,4 +332,69 @@ Rectangle { } } + + Rectangle { + id:desaturate + color:"black" + anchors.fill: parent + opacity: 0.1 + visible: (root.enabled)? 0 : 1; + } + + Rectangle { + x: root.width/2 - width/2 + y: root.height/2 - height/2 + height:statusText.paintedHeight + 50 + width:statusText.paintedWidth + 40 + visible: statusText.text != "" + opacity: 0.9 + + Text { + id: statusText + anchors.fill:parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + Component.onCompleted: { + //Disable password page until enabled by updateStatus + root.enabled = false + } + + // fires on every page load + function onPageCompleted() { + console.log("transfer page loaded") + updateStatus(); + } + + //TODO: Add daemon sync status + //TODO: enable send page when we're connected and daemon is synced + + function updateStatus() { + console.log("updated transfer page status") + if(typeof currentWallet === "undefined") { + statusText.text = qsTr("Wallet is not connected to daemon.") + return; + } + + switch (currentWallet.connected) { + case Wallet.ConnectionStatus_Disconnected: + statusText.text = qsTr("Wallet is not connected to daemon.") + break + case Wallet.ConnectionStatus_WrongVersion: + statusText.text = qsTr("Connected daemon is not compatible with GUI. \n" + + "Please upgrade or connect to another daemon") + break + default: + if(!appWindow.daemonSynced){ + statusText.text = qsTr("Waiting on daemon synchronization to finish") + } else { + // everything OK, enable transfer page + root.enabled = true; + statusText.text = ""; + } + + } + } } From 36a6b89b540020957eb59e1b57bf6186e180afcb Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 15:50:04 +0100 Subject: [PATCH 37/43] connect onWalletConnectionStatusChanged() --- main.qml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.qml b/main.qml index d0c77338..97b9934d 100644 --- a/main.qml +++ b/main.qml @@ -213,6 +213,7 @@ ApplicationWindow { currentWallet.moneySpent.disconnect(onWalletMoneySent) currentWallet.moneyReceived.disconnect(onWalletMoneyReceived) currentWallet.transactionCreated.disconnect(onTransactionCreated) + currentWallet.connectionStatusChanged.disconnect(onWalletConnectionStatusChanged) currentWallet.refreshed.connect(onWalletRefresh) currentWallet.updated.connect(onWalletUpdate) @@ -220,6 +221,7 @@ ApplicationWindow { currentWallet.moneySpent.connect(onWalletMoneySent) currentWallet.moneyReceived.connect(onWalletMoneyReceived) currentWallet.transactionCreated.connect(onTransactionCreated) + currentWallet.connectionStatusChanged.connect(onWalletConnectionStatusChanged) console.log("initializing with daemon address: ", persistentSettings.daemon_address) @@ -233,6 +235,11 @@ ApplicationWindow { return wallet_path; } + function onWalletConnectionStatusChanged(){ + console.log("Wallet connection status changed") + middlePanel.updateStatus(); + } + function onWalletOpened(wallet) { console.log(">>> wallet opened: " + wallet) if (wallet.status !== Wallet.Status_Ok) { From 3f8e05d7a4891623bd34c62d82959eab80d079db Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 16:31:27 +0100 Subject: [PATCH 38/43] Wallet: Cache connection status query --- src/libwalletqt/Wallet.cpp | 23 ++++++++++++++++++----- src/libwalletqt/Wallet.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 608bbd0f..201d5293 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -15,6 +15,7 @@ namespace { static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10; static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 60; + static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5; } class WalletListenerImpl : public Bitmonero::WalletListener @@ -90,12 +91,19 @@ Wallet::Status Wallet::status() const Wallet::ConnectionStatus Wallet::connected() { qDebug("Checking wallet connection status"); - ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); - if(newStatus != m_connectionStatus) { - m_connectionStatus = newStatus; - emit connectionStatusChanged(); + + // cache connection status + if(m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){ + qDebug("connectionStatus query"); + ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); + if(newStatus != m_connectionStatus) { + m_connectionStatus = newStatus; + emit connectionStatusChanged(); + } + m_connectionStatusTime.restart(); } - return newStatus; + + return m_connectionStatus; } bool Wallet::synchronized() const @@ -425,10 +433,15 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) , m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS) , m_daemonBlockChainTargetHeight(0) , m_daemonBlockChainTargetHeightTtl(DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS) + , m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS) { m_history = new TransactionHistory(m_walletImpl->history(), this); m_walletImpl->setListener(new WalletListenerImpl(this)); m_connectionStatus = Wallet::ConnectionStatus_Disconnected; + // start cache timers + m_connectionStatusTime.restart(); + m_daemonBlockChainHeightTime.restart(); + m_daemonBlockChainTargetHeightTime.restart(); } Wallet::~Wallet() diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index f9cf8792..6eddd8bd 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -220,6 +220,8 @@ private: mutable quint64 m_daemonBlockChainTargetHeight; int m_daemonBlockChainTargetHeightTtl; ConnectionStatus m_connectionStatus; + int m_connectionStatusTtl; + mutable QTime m_connectionStatusTime; }; From c7232e1fe67becb456afadf2b6fe89d59a08b5a0 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 17:01:29 +0100 Subject: [PATCH 39/43] set wallet connection status before querying sync status --- main.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.qml b/main.qml index 97b9934d..895b255d 100644 --- a/main.qml +++ b/main.qml @@ -288,17 +288,17 @@ ApplicationWindow { hideProcessingSplash() } + // Daemon connected + leftPanel.networkStatus.connected = currentWallet.connected + // Check daemon status var dCurrentBlock = currentWallet.daemonBlockChainHeight(); var dTargetBlock = currentWallet.daemonBlockChainTargetHeight(); - leftPanel.daemonProgress.updateProgress(dCurrentBlock,dTargetBlock); - - // Daemon connected - leftPanel.networkStatus.connected = currentWallet.connected // Daemon fully synced // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) + leftPanel.daemonProgress.updateProgress(dCurrentBlock,dTargetBlock); // If wallet isnt connected and no daemon is running - Ask if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){ @@ -336,6 +336,7 @@ ApplicationWindow { appWindow.showProcessingSplash(qsTr("Waiting for daemon to start...")) daemonManager.start(); } + function stopDaemon(){ appWindow.showProcessingSplash(qsTr("Waiting for daemon to stop...")) daemonManager.stop(); From 0e8cd146dbc425579e48e04629803dfa7d02d3c6 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 17:01:59 +0100 Subject: [PATCH 40/43] Wallet: add m_initialized --- src/libwalletqt/Wallet.cpp | 7 +++---- src/libwalletqt/Wallet.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 201d5293..c1c1b8e8 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -90,11 +90,9 @@ Wallet::Status Wallet::status() const Wallet::ConnectionStatus Wallet::connected() { - qDebug("Checking wallet connection status"); - // cache connection status - if(m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){ - qDebug("connectionStatus query"); + if(!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){ + m_initialized = true; ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); if(newStatus != m_connectionStatus) { m_connectionStatus = newStatus; @@ -442,6 +440,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) m_connectionStatusTime.restart(); m_daemonBlockChainHeightTime.restart(); m_daemonBlockChainTargetHeightTime.restart(); + m_initialized = false; } Wallet::~Wallet() diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 6eddd8bd..8b1d7525 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -222,6 +222,7 @@ private: ConnectionStatus m_connectionStatus; int m_connectionStatusTtl; mutable QTime m_connectionStatusTime; + bool m_initialized; }; From 0ae3d677507ce4e2872d8fa5faca17419673e4b8 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sat, 26 Nov 2016 19:30:53 +0100 Subject: [PATCH 41/43] daemon console -> log + adjusted height --- pages/Settings.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/Settings.qml b/pages/Settings.qml index 9b6e618c..432653fa 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -314,7 +314,7 @@ Rectangle { // enabled: appWindow.daemonRunning id: daemonConsolePopupButton width: 110 - text: qsTr("Show concole") + translationManager.emptyString + text: qsTr("Show log") + translationManager.emptyString shadowReleasedColor: "#FF4304" shadowPressedColor: "#B32D00" releasedColor: "#FF6C3C" @@ -331,10 +331,10 @@ Rectangle { // Daemon console StandardDialog { id: daemonConsolePopup - height:800 + height:500 width:800 cancelVisible: false - title: qsTr("Daemon console") + title: qsTr("Daemon log") onAccepted: { close(); } From 01549a3040da4c4e6931654ab91017283f0552a7 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sun, 27 Nov 2016 00:16:09 +0100 Subject: [PATCH 42/43] walletManager: coding conventions Signed-off-by: Jaquee --- main.cpp | 6 ++---- src/daemon/DaemonManager.cpp | 27 +++++++++++++-------------- src/daemon/DaemonManager.h | 4 ++-- src/libwalletqt/Wallet.cpp | 6 +++--- src/libwalletqt/Wallet.h | 8 ++++---- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/main.cpp b/main.cpp index 4bc71a53..e9ea5a56 100644 --- a/main.cpp +++ b/main.cpp @@ -108,10 +108,8 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance()); engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider()); - - engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance(QCoreApplication::arguments())); - - DaemonManager * daemonManager = DaemonManager::instance(QCoreApplication::arguments()); + const QStringList arguments = QCoreApplication::arguments(); + DaemonManager * daemonManager = DaemonManager::instance(&arguments); QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing())); engine.rootContext()->setContextProperty("daemonManager", daemonManager); diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index b84a0fa2..185cde1e 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -9,15 +9,15 @@ #include DaemonManager * DaemonManager::m_instance = nullptr; -QStringList DaemonManager::clArgs; +QStringList DaemonManager::m_clArgs; -DaemonManager *DaemonManager::instance(QStringList args) +DaemonManager *DaemonManager::instance(const QStringList *args) { if (!m_instance) { m_instance = new DaemonManager; // store command line arguments for later use - clArgs = args; - clArgs.removeFirst(); + m_clArgs = *args; + m_clArgs.removeFirst(); } return m_instance; @@ -25,7 +25,6 @@ DaemonManager *DaemonManager::instance(QStringList args) bool DaemonManager::start() { - // QString process; #ifdef Q_OS_WIN @@ -34,7 +33,7 @@ bool DaemonManager::start() process = QApplication::applicationDirPath() + "/monerod"; #endif - if(process.length() == 0) { + if (process.length() == 0) { qDebug() << "no daemon binary defined for current platform"; return false; } @@ -42,7 +41,7 @@ bool DaemonManager::start() // prepare command line arguments and pass to monerod QStringList arguments; - foreach (const QString &str, clArgs) { + foreach (const QString &str, m_clArgs) { qDebug() << QString(" [%1] ").arg(str); arguments << str; } @@ -64,7 +63,7 @@ bool DaemonManager::start() // add state changed listener connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState))); - if(!started){ + if (!started) { qDebug() << "Daemon start error: " + m_daemon->errorString(); } else { emit daemonStarted(); @@ -75,7 +74,7 @@ bool DaemonManager::start() bool DaemonManager::stop() { - if(initialized){ + if (initialized) { qDebug() << "stopping daemon"; // we can't use QProcess::terminate() on windows console process // write exit command to stdin @@ -88,7 +87,7 @@ bool DaemonManager::stop() void DaemonManager::stateChanged(QProcess::ProcessState state) { qDebug() << "STATE CHANGED: " << state; - if(state == QProcess::NotRunning) { + if (state == QProcess::NotRunning) { emit daemonStopped(); } } @@ -98,7 +97,7 @@ void DaemonManager::printOutput() QByteArray byteArray = m_daemon->readAllStandardOutput(); QStringList strLines = QString(byteArray).split("\n"); - foreach (QString line, strLines){ + foreach (QString line, strLines) { emit daemonConsoleUpdated(line); qDebug() << "Daemon: " + line; } @@ -109,7 +108,7 @@ void DaemonManager::printError() QByteArray byteArray = m_daemon->readAllStandardError(); QStringList strLines = QString(byteArray).split("\n"); - foreach (QString line, strLines){ + foreach (QString line, strLines) { emit daemonConsoleUpdated(line); qDebug() << "Daemon ERROR: " + line; } @@ -117,7 +116,7 @@ void DaemonManager::printError() bool DaemonManager::running() const { - if(initialized){ + if (initialized) { qDebug() << m_daemon->state(); qDebug() << QProcess::NotRunning; // m_daemon->write("status\n"); @@ -137,7 +136,7 @@ void DaemonManager::closing() qDebug() << __FUNCTION__; stop(); // Wait for daemon to stop before exiting (max 10 secs) - if(initialized){ + if (initialized) { m_daemon->waitForFinished(10000); } } diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 1c4ae8ad..8f425fd5 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -11,7 +11,7 @@ class DaemonManager : public QObject public: - static DaemonManager * instance(QStringList args); + static DaemonManager * instance(const QStringList *args); Q_INVOKABLE bool start(); Q_INVOKABLE bool stop(); @@ -34,7 +34,7 @@ private: explicit DaemonManager(QObject *parent = 0); static DaemonManager * m_instance; - static QStringList clArgs; + static QStringList m_clArgs; QProcess *m_daemon; bool initialized = false; diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index c1c1b8e8..bc72cc1a 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -88,13 +88,13 @@ Wallet::Status Wallet::status() const return static_cast(m_walletImpl->status()); } -Wallet::ConnectionStatus Wallet::connected() +Wallet::ConnectionStatus Wallet::connected() const { // cache connection status - if(!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){ + if (!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl) { m_initialized = true; ConnectionStatus newStatus = static_cast(m_walletImpl->connected()); - if(newStatus != m_connectionStatus) { + if (newStatus != m_connectionStatus) { m_connectionStatus = newStatus; emit connectionStatusChanged(); } diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 8b1d7525..3289bb37 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -63,7 +63,7 @@ public: Status status() const; //! returns whether the wallet is connected, and version status - ConnectionStatus connected(); + ConnectionStatus connected() const; //! returns true if wallet was ever synchronized bool synchronized() const; @@ -196,7 +196,7 @@ signals: // emitted when transaction is created async void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount); - void connectionStatusChanged(); + void connectionStatusChanged() const; private: Wallet(QObject * parent = nullptr); @@ -219,10 +219,10 @@ private: mutable QTime m_daemonBlockChainTargetHeightTime; mutable quint64 m_daemonBlockChainTargetHeight; int m_daemonBlockChainTargetHeightTtl; - ConnectionStatus m_connectionStatus; + mutable ConnectionStatus m_connectionStatus; int m_connectionStatusTtl; mutable QTime m_connectionStatusTime; - bool m_initialized; + mutable bool m_initialized; }; From 3752ec7899d19a2202574f25e113e5bb900496e3 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sun, 27 Nov 2016 13:35:27 +0100 Subject: [PATCH 43/43] send page: check daemon status after every refresh --- main.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/main.qml b/main.qml index 895b255d..b3b3b678 100644 --- a/main.qml +++ b/main.qml @@ -299,6 +299,7 @@ ApplicationWindow { // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) leftPanel.daemonProgress.updateProgress(dCurrentBlock,dTargetBlock); + middlePanel.updateStatus(); // If wallet isnt connected and no daemon is running - Ask if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){