i2pd/qt/i2pd_qt/DaemonQT.h

82 lines
1.4 KiB
C
Raw Normal View History

#ifndef DAEMONQT_H
#define DAEMONQT_H
#include <QObject>
#include <QThread>
2016-06-17 18:25:28 +03:00
#include <QMutex>
namespace i2p
{
2016-06-17 17:26:51 +03:00
namespace qt
{
class DaemonQTImpl
{
public:
2016-06-17 18:25:28 +03:00
DaemonQTImpl ();
~DaemonQTImpl ();
typedef void (*runningChangedCallback)();
/**
* @brief init
* @param argc
* @param argv
* @return success
*/
2016-06-17 18:25:28 +03:00
bool init(int argc, char* argv[]);
void start();
void stop();
void restart();
void setRunningCallback(runningChangedCallback cb);
bool isRunning();
private:
2016-06-17 18:25:28 +03:00
void setRunning(bool running);
private:
QMutex* mutex;
bool m_IsRunning;
runningChangedCallback m_RunningChangedCallback;
};
2016-06-17 18:25:28 +03:00
class Worker : public QObject
{
Q_OBJECT
public:
Worker (DaemonQTImpl& daemon);
private:
DaemonQTImpl& m_Daemon;
public slots:
void startDaemon();
void restartDaemon();
void stopDaemon();
signals:
void resultReady();
};
class Controller : public QObject
{
Q_OBJECT
QThread workerThread;
public:
2016-06-17 18:25:28 +03:00
Controller(DaemonQTImpl& daemon);
~Controller();
2016-06-17 18:25:28 +03:00
private:
DaemonQTImpl& m_Daemon;
public slots:
void handleResults(){}
signals:
void startDaemon();
void stopDaemon();
void restartDaemon();
};
}
}
#endif // DAEMONQT_H