mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
fixed build errors
This commit is contained in:
parent
8130487b18
commit
f76c04b7a6
5 changed files with 69 additions and 148 deletions
|
@ -265,13 +265,5 @@ namespace i2p
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonQT::init(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
m_Impl = std::make_shared<DaemonQTImpl> (argc, argv);
|
|
||||||
#endif
|
|
||||||
return Daemon_Singleton::init(argc, argv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
Daemon.h
10
Daemon.h
|
@ -33,9 +33,6 @@ namespace i2p
|
||||||
|
|
||||||
#if defined(QT_GUI_LIB) // check if QT
|
#if defined(QT_GUI_LIB) // check if QT
|
||||||
#define Daemon i2p::util::DaemonQT::Instance()
|
#define Daemon i2p::util::DaemonQT::Instance()
|
||||||
#if 0
|
|
||||||
class DaemonQTImpl;
|
|
||||||
#endif
|
|
||||||
class DaemonQT: public i2p::util::Daemon_Singleton
|
class DaemonQT: public i2p::util::Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -47,13 +44,6 @@ namespace i2p
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init(int argc, char* argv[]);
|
bool init(int argc, char* argv[]);
|
||||||
#if 0
|
|
||||||
void run ();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::shared_ptr<DaemonQTImpl> m_Impl;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
|
|
6
i2pd.cpp
6
i2pd.cpp
|
@ -17,7 +17,7 @@ int main( int argc, char* argv[] )
|
||||||
//QMessageBox::information(0,"Debug","runGUI completed");
|
//QMessageBox::information(0,"Debug","runGUI completed");
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qDebug("Initialising the daemon...");
|
qDebug("Initialising the daemon...");
|
||||||
bool daemonInitSuccess = i2p::util::DaemonQt::DaemonQTImpl::init(argc, argv);
|
bool daemonInitSuccess = i2p::qt::DaemonQTImpl::init(argc, argv);
|
||||||
if(!daemonInitSuccess) {
|
if(!daemonInitSuccess) {
|
||||||
QMessageBox::critical(0, "Error", "Daemon init failed");
|
QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -28,14 +28,14 @@ int main( int argc, char* argv[] )
|
||||||
w.show ();
|
w.show ();
|
||||||
int result;
|
int result;
|
||||||
{
|
{
|
||||||
i2p::util::DaemonQt::Controller daemonQtController;
|
i2p::qt::Controller daemonQtController;
|
||||||
qDebug("Starting the daemon...");
|
qDebug("Starting the daemon...");
|
||||||
emit daemonQtController.startDaemon();
|
emit daemonQtController.startDaemon();
|
||||||
qDebug("Starting gui event loop...");
|
qDebug("Starting gui event loop...");
|
||||||
result = app.exec();
|
result = app.exec();
|
||||||
//QMessageBox::information(&w, "Debug", "exec finished");
|
//QMessageBox::information(&w, "Debug", "exec finished");
|
||||||
}
|
}
|
||||||
i2p::util::DaemonQt::DaemonQTImpl::deinit();
|
i2p::qt::DaemonQTImpl::deinit();
|
||||||
//QMessageBox::information(&w, "Debug", "demon stopped");
|
//QMessageBox::information(&w, "Debug", "demon stopped");
|
||||||
//exit(result); //return from main() causes intermittent sigsegv bugs in some Androids. exit() is a workaround for this
|
//exit(result); //return from main() causes intermittent sigsegv bugs in some Androids. exit() is a workaround for this
|
||||||
qDebug("Exiting the application");
|
qDebug("Exiting the application");
|
||||||
|
|
|
@ -7,139 +7,81 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
namespace DaemonQt
|
bool DaemonQT::init(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
return Daemon_Singleton::init(argc, argv);
|
||||||
void Worker::startDaemon() {
|
}
|
||||||
qDebug("Performing daemon start...");
|
|
||||||
DaemonQTImpl::start();
|
|
||||||
qDebug("Daemon started.");
|
|
||||||
emit resultReady();
|
|
||||||
}
|
|
||||||
void Worker::restartDaemon() {
|
|
||||||
qDebug("Performing daemon restart...");
|
|
||||||
DaemonQTImpl::restart();
|
|
||||||
qDebug("Daemon restarted.");
|
|
||||||
emit resultReady();
|
|
||||||
}
|
|
||||||
void Worker::stopDaemon() {
|
|
||||||
qDebug("Performing daemon stop...");
|
|
||||||
DaemonQTImpl::stop();
|
|
||||||
qDebug("Daemon stopped.");
|
|
||||||
emit resultReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller::Controller() {
|
|
||||||
Worker *worker = new Worker;
|
|
||||||
worker->moveToThread(&workerThread);
|
|
||||||
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
|
||||||
connect(this, &Controller::startDaemon, worker, &Worker::startDaemon);
|
|
||||||
connect(this, &Controller::stopDaemon, worker, &Worker::stopDaemon);
|
|
||||||
connect(this, &Controller::restartDaemon, worker, &Worker::restartDaemon);
|
|
||||||
connect(worker, &Worker::resultReady, this, &Controller::handleResults);
|
|
||||||
workerThread.start();
|
|
||||||
}
|
|
||||||
Controller::~Controller() {
|
|
||||||
qDebug("Closing and waiting for daemon worker thread...");
|
|
||||||
workerThread.quit();
|
|
||||||
workerThread.wait();
|
|
||||||
qDebug("Waiting for daemon worker thread finished.");
|
|
||||||
if(i2p::util::DaemonQt::DaemonQTImpl::isRunning()) {
|
|
||||||
qDebug("Stopping the daemon...");
|
|
||||||
i2p::util::DaemonQt::DaemonQTImpl::stop();
|
|
||||||
qDebug("Stopped the daemon.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static DaemonQTImpl::runningChangedCallback DaemonQTImpl_runningChanged;
|
|
||||||
static bool DaemonQTImpl_running;
|
|
||||||
static QMutex* mutex;
|
|
||||||
|
|
||||||
bool DaemonQTImpl::init(int argc, char* argv[]){mutex=new QMutex(QMutex::Recursive);setRunningCallback(0);DaemonQTImpl_running=false;return Daemon.init(argc,argv);}
|
|
||||||
void DaemonQTImpl::deinit(){delete mutex;}
|
|
||||||
void DaemonQTImpl::start(){QMutexLocker locker(mutex);setRunning(true);Daemon.start();}
|
|
||||||
void DaemonQTImpl::stop(){QMutexLocker locker(mutex);Daemon.stop();setRunning(false);}
|
|
||||||
void DaemonQTImpl::restart(){QMutexLocker locker(mutex);stop();start();}
|
|
||||||
|
|
||||||
void DaemonQTImpl::setRunningCallback(runningChangedCallback cb){DaemonQTImpl_runningChanged=cb;}
|
|
||||||
bool DaemonQTImpl::isRunning(){return DaemonQTImpl_running;}
|
|
||||||
void DaemonQTImpl::setRunning(bool newValue){
|
|
||||||
bool oldValue = DaemonQTImpl_running;
|
|
||||||
if(oldValue!=newValue) {
|
|
||||||
DaemonQTImpl_running = newValue;
|
|
||||||
if(DaemonQTImpl_runningChanged!=0)DaemonQTImpl_runningChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include <memory>
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include <QApplication>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "../../Daemon.h"
|
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace util
|
namespace qt
|
||||||
{
|
{
|
||||||
class DaemonQTImpl: public std::enable_shared_from_this<DaemonQTImpl>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
DaemonQTImpl (int argc, char* argv[]):
|
void Worker::startDaemon() {
|
||||||
m_App (argc, argv)
|
qDebug("Performing daemon start...");
|
||||||
{
|
DaemonQTImpl::start();
|
||||||
}
|
qDebug("Daemon started.");
|
||||||
|
emit resultReady();
|
||||||
void Run ()
|
}
|
||||||
{
|
void Worker::restartDaemon() {
|
||||||
MainWindow w(m_App);
|
qDebug("Performing daemon restart...");
|
||||||
w.show ();
|
DaemonQTImpl::restart();
|
||||||
m_App.exec();
|
qDebug("Daemon restarted.");
|
||||||
}
|
emit resultReady();
|
||||||
|
}
|
||||||
private:
|
void Worker::stopDaemon() {
|
||||||
|
qDebug("Performing daemon stop...");
|
||||||
void StartDaemon ()
|
DaemonQTImpl::stop();
|
||||||
{
|
qDebug("Daemon stopped.");
|
||||||
Daemon.start ();
|
emit resultReady();
|
||||||
}
|
|
||||||
|
|
||||||
void StopDaemon ()
|
|
||||||
{
|
|
||||||
Daemon.stop ();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsRunning () const
|
|
||||||
{
|
|
||||||
return Daemon.running;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
QApplication m_App;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool DaemonQT::init(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
m_Impl = std::make_shared<DaemonQTImpl> (argc, argv);
|
|
||||||
return Daemon_Singleton::init(argc, argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonQT::run ()
|
Controller::Controller() {
|
||||||
{
|
Worker *worker = new Worker;
|
||||||
if (m_Impl)
|
worker->moveToThread(&workerThread);
|
||||||
{
|
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
||||||
m_Impl->Run ();
|
connect(this, &Controller::startDaemon, worker, &Worker::startDaemon);
|
||||||
m_Impl = nullptr;
|
connect(this, &Controller::stopDaemon, worker, &Worker::stopDaemon);
|
||||||
|
connect(this, &Controller::restartDaemon, worker, &Worker::restartDaemon);
|
||||||
|
connect(worker, &Worker::resultReady, this, &Controller::handleResults);
|
||||||
|
workerThread.start();
|
||||||
|
}
|
||||||
|
Controller::~Controller() {
|
||||||
|
qDebug("Closing and waiting for daemon worker thread...");
|
||||||
|
workerThread.quit();
|
||||||
|
workerThread.wait();
|
||||||
|
qDebug("Waiting for daemon worker thread finished.");
|
||||||
|
if(DaemonQTImpl::isRunning()) {
|
||||||
|
qDebug("Stopping the daemon...");
|
||||||
|
DaemonQTImpl::stop();
|
||||||
|
qDebug("Stopped the daemon.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static DaemonQTImpl::runningChangedCallback DaemonQTImpl_runningChanged;
|
||||||
|
static bool DaemonQTImpl_running;
|
||||||
|
static QMutex* mutex;
|
||||||
|
|
||||||
|
bool DaemonQTImpl::init(int argc, char* argv[]){mutex=new QMutex(QMutex::Recursive);setRunningCallback(0);DaemonQTImpl_running=false;return Daemon.init(argc,argv);}
|
||||||
|
void DaemonQTImpl::deinit(){delete mutex;}
|
||||||
|
void DaemonQTImpl::start(){QMutexLocker locker(mutex);setRunning(true);Daemon.start();}
|
||||||
|
void DaemonQTImpl::stop(){QMutexLocker locker(mutex);Daemon.stop();setRunning(false);}
|
||||||
|
void DaemonQTImpl::restart(){QMutexLocker locker(mutex);stop();start();}
|
||||||
|
|
||||||
|
void DaemonQTImpl::setRunningCallback(runningChangedCallback cb){DaemonQTImpl_runningChanged=cb;}
|
||||||
|
bool DaemonQTImpl::isRunning(){return DaemonQTImpl_running;}
|
||||||
|
void DaemonQTImpl::setRunning(bool newValue){
|
||||||
|
bool oldValue = DaemonQTImpl_running;
|
||||||
|
if(oldValue!=newValue) {
|
||||||
|
DaemonQTImpl_running = newValue;
|
||||||
|
if(DaemonQTImpl_runningChanged!=0)DaemonQTImpl_runningChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace util
|
namespace qt
|
||||||
{
|
|
||||||
namespace DaemonQt
|
|
||||||
{
|
{
|
||||||
class Worker : public QObject
|
class Worker : public QObject
|
||||||
{
|
{
|
||||||
|
@ -61,6 +59,5 @@ namespace DaemonQt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DAEMONQT_H
|
#endif // DAEMONQT_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue