2016-11-05 09:47:17 +00:00
|
|
|
#ifndef DAEMONMANAGER_H
|
|
|
|
#define DAEMONMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
class DaemonManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-11-26 23:16:09 +00:00
|
|
|
static DaemonManager * instance(const QStringList *args);
|
2016-11-05 09:47:17 +00:00
|
|
|
|
2017-02-23 18:47:58 +00:00
|
|
|
Q_INVOKABLE bool start(const QString &flags, bool testnet);
|
|
|
|
Q_INVOKABLE bool stop(bool testnet);
|
2016-11-05 09:47:17 +00:00
|
|
|
|
|
|
|
// return true if daemon process is started
|
2017-02-23 18:47:58 +00:00
|
|
|
Q_INVOKABLE bool running(bool testnet) const;
|
|
|
|
// Send daemon command from qml and prints output in console window.
|
|
|
|
Q_INVOKABLE bool sendCommand(const QString &cmd, bool testnet) const;
|
2017-02-25 13:57:39 +00:00
|
|
|
Q_INVOKABLE void exit();
|
2016-11-05 09:47:17 +00:00
|
|
|
|
2017-02-23 18:47:58 +00:00
|
|
|
private:
|
2017-02-25 13:57:39 +00:00
|
|
|
|
2017-02-23 18:47:58 +00:00
|
|
|
bool sendCommand(const QString &cmd, bool testnet, QString &message) const;
|
2017-02-25 13:57:39 +00:00
|
|
|
bool startWatcher(bool testnet) const;
|
|
|
|
bool stopWatcher(bool testnet) const;
|
2016-11-05 09:47:17 +00:00
|
|
|
signals:
|
2017-02-23 18:47:58 +00:00
|
|
|
void daemonStarted() const;
|
|
|
|
void daemonStopped() const;
|
2017-02-25 19:25:16 +00:00
|
|
|
void daemonStartFailure() const;
|
2017-02-23 18:47:58 +00:00
|
|
|
void daemonConsoleUpdated(QString message) const;
|
2016-11-05 09:47:17 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void printOutput();
|
|
|
|
void printError();
|
2016-11-26 10:54:06 +00:00
|
|
|
void stateChanged(QProcess::ProcessState state);
|
2016-11-05 09:47:17 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit DaemonManager(QObject *parent = 0);
|
|
|
|
static DaemonManager * m_instance;
|
2016-11-26 23:16:09 +00:00
|
|
|
static QStringList m_clArgs;
|
2016-11-05 09:47:17 +00:00
|
|
|
QProcess *m_daemon;
|
2016-11-07 12:10:10 +00:00
|
|
|
bool initialized = false;
|
2017-01-22 22:04:46 +00:00
|
|
|
QString m_monerod;
|
|
|
|
bool m_has_daemon = true;
|
2017-02-25 13:57:39 +00:00
|
|
|
bool m_app_exit = false;
|
2016-11-05 09:47:17 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DAEMONMANAGER_H
|