You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
// SPDX-License-Identifier: BSD-3-Clause
|
|
// Copyright (c) 2014-2021, The Monero Project.
|
|
|
|
#ifndef DAEMONMANAGER_H
|
|
#define DAEMONMANAGER_H
|
|
|
|
#include <memory>
|
|
|
|
#include <QMutex>
|
|
#include <QObject>
|
|
#include <QUrl>
|
|
#include <QProcess>
|
|
#include <QVariantMap>
|
|
#include "FutureScheduler.h"
|
|
|
|
class DaemonManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DaemonManager(QObject *parent = nullptr);
|
|
~DaemonManager() override;
|
|
|
|
bool start(const QStringList &flags, int port);
|
|
void stop();
|
|
|
|
void sendCommandAsync(const QStringList &cmd, std::function<void(QVariantList)> callback) const;
|
|
void exit();
|
|
// QVariantMap validateDataDir(const QString &dataDir) const;
|
|
|
|
void setMonerodPath(const QString &path);
|
|
bool isRunning() const;
|
|
|
|
private:
|
|
bool started();
|
|
bool sendCommand(const QStringList &cmd, QString &message) const;
|
|
bool startWatcher();
|
|
bool stopWatcher();
|
|
|
|
signals:
|
|
void daemonStarted() const;
|
|
void daemonStopped() const;
|
|
void daemonStartFailure(const QString &error) const;
|
|
void daemonConsoleUpdated(QString message) const;
|
|
|
|
public slots:
|
|
void printOutput();
|
|
void printError();
|
|
void stateChanged(QProcess::ProcessState state);
|
|
|
|
private:
|
|
std::unique_ptr<QProcess> m_daemon;
|
|
QMutex m_daemonMutex;
|
|
QString m_monerod;
|
|
|
|
bool m_running = false;
|
|
bool m_started = false;
|
|
bool m_app_exit = false;
|
|
int m_port;
|
|
|
|
mutable FutureScheduler m_scheduler;
|
|
};
|
|
|
|
#endif // DAEMONMANAGER_H
|