diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-10-14 17:50:54 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-10-14 17:50:54 -0500 |
| commit | 897d879dad7443550be832f62e199291487453de (patch) | |
| tree | 5503f9ccb4444c92442a2a88716e11b02e10593a /src/daemon/DaemonManager.cpp | |
| parent | e6458b58ef34a74aa45d48d54ac7b659a2400c8c (diff) | |
| parent | 32257c8fab83cab89811111284cdca8bf5e9dbac (diff) | |
| download | monzero-gui-897d879dad7443550be832f62e199291487453de.tar.gz monzero-gui-897d879dad7443550be832f62e199291487453de.tar.xz monzero-gui-897d879dad7443550be832f62e199291487453de.zip | |
Merge pull request #2398
32257c8 DaemonManager: implement async sendCommand (xiphon)
Diffstat (limited to 'src/daemon/DaemonManager.cpp')
| -rw-r--r-- | src/daemon/DaemonManager.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 0d311535..baabffb4 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -150,7 +150,7 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const bool DaemonManager::stop(NetworkType::Type nettype) { QString message; - sendCommand("exit", nettype, message); + sendCommand({"exit"}, nettype, message); qDebug() << message; // Start stop watcher - Will kill if not shutting down @@ -240,7 +240,7 @@ void DaemonManager::printError() bool DaemonManager::running(NetworkType::Type nettype) const { QString status; - sendCommand("sync_info", nettype, status); + sendCommand({"sync_info"}, nettype, status); qDebug() << status; return status.contains("Height:"); } @@ -257,17 +257,10 @@ void DaemonManager::runningAsync(NetworkType::Type nettype, const QJSValue& call }, callback); } -bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype) const -{ - QString message; - return sendCommand(cmd, nettype, message); -} - -bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype, QString &message) const +bool DaemonManager::sendCommand(const QStringList &cmd, NetworkType::Type nettype, QString &message) const { QProcess p; - QStringList external_cmd; - external_cmd << cmd; + QStringList external_cmd(cmd); // Add network type flag if needed if (nettype == NetworkType::TESTNET) @@ -286,6 +279,14 @@ bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype, Q return started; } +void DaemonManager::sendCommandAsync(const QStringList &cmd, NetworkType::Type nettype, const QJSValue& callback) const +{ + m_scheduler.run([this, cmd, nettype] { + QString message; + return QJSValueList({sendCommand(cmd, nettype, message)}); + }, callback); +} + void DaemonManager::exit() { qDebug("DaemonManager: exit()"); |
