From b4eb489b001fb23382fe2725f747b1d94abacd76 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Mon, 7 Nov 2016 18:08:09 +0100 Subject: [PATCH] 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;