2016-06-15 19:20:31 +03:00
|
|
|
#include <memory>
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "../../Daemon.h"
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
2016-06-15 21:43:29 +03:00
|
|
|
class DaemonQTImpl: public std::enable_shared_from_this<DaemonQTImpl>
|
2016-06-15 19:20:31 +03:00
|
|
|
{
|
2016-06-15 21:43:29 +03:00
|
|
|
public:
|
2016-06-15 19:20:31 +03:00
|
|
|
|
2016-06-15 21:43:29 +03:00
|
|
|
DaemonQTImpl (int argc, char* argv[]):
|
|
|
|
m_App (argc, argv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Run ()
|
|
|
|
{
|
|
|
|
MainWindow w;
|
|
|
|
w.show ();
|
|
|
|
m_App.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-06-15 19:20:31 +03:00
|
|
|
|
2016-06-15 21:43:29 +03:00
|
|
|
void StartDaemon ()
|
|
|
|
{
|
|
|
|
Daemon.start ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopDaemon ()
|
|
|
|
{
|
|
|
|
Daemon.stop ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRunning () const
|
|
|
|
{
|
|
|
|
return Daemon.running;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QApplication m_App;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool DaemonQT::init(int argc, char* argv[])
|
2016-06-15 19:20:31 +03:00
|
|
|
{
|
2016-06-15 21:43:29 +03:00
|
|
|
m_Impl = std::make_shared<DaemonQTImpl> (argc, argv);
|
|
|
|
return Daemon_Singleton::init(argc, argv);
|
2016-06-15 19:20:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DaemonQT::run ()
|
|
|
|
{
|
2016-06-15 21:43:29 +03:00
|
|
|
if (m_Impl)
|
|
|
|
{
|
|
|
|
m_Impl->Run ();
|
|
|
|
m_Impl = nullptr;
|
|
|
|
}
|
2016-06-15 19:20:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|