mirror of
https://github.com/PurpleI2P/i2pd-qt.git
synced 2025-03-12 13:21:51 +00:00
Dissect DaemonQT.* into the app launcher and daemon controller
This commit is contained in:
parent
7688d2093c
commit
af1d09d0b1
@ -38,7 +38,8 @@ CONFIG(release, debug|release) {
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
src/DaemonQT.cpp \
|
||||
src/launcher/i2pd_qt_launcher.cpp \
|
||||
src/controller/i2pd_daemon_controller.cpp \
|
||||
src/MutexWrapperLock.cpp \
|
||||
src/mainwindow.cpp \
|
||||
src/ClientTunnelPane.cpp \
|
||||
@ -67,7 +68,8 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
src/ConcurrentHolder.h \
|
||||
src/DaemonQT.h \
|
||||
src/launcher/i2pd_qt_launcher.h \
|
||||
src/controller/i2pd_daemon_controller.h \
|
||||
src/MutexWrapperLock.h \
|
||||
src/mainwindow.h \
|
||||
src/ClientTunnelPane.h \
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "DaemonQT.h"
|
||||
#include "controller/i2pd_daemon_controller.h"
|
||||
#include "Daemon.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
@ -11,12 +11,8 @@
|
||||
#include <QMutexLocker>
|
||||
#include <QThread>
|
||||
|
||||
//#define DEBUG_WITH_DEFAULT_LOGGING (1)
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace i2p {
|
||||
namespace qt {
|
||||
Worker::Worker (DaemonQTImpl& daemon):
|
||||
m_Daemon (daemon)
|
||||
{
|
||||
@ -146,50 +142,6 @@ namespace qt
|
||||
m_RunningChangedCallback();
|
||||
}
|
||||
}
|
||||
|
||||
int RunQT (int argc, char* argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
int result;
|
||||
|
||||
{
|
||||
std::shared_ptr<std::iostream> logstreamptr=
|
||||
#ifdef DEBUG_WITH_DEFAULT_LOGGING
|
||||
nullptr
|
||||
#else
|
||||
std::make_shared<std::stringstream>()
|
||||
#endif
|
||||
;
|
||||
//TODO move daemon init deinit to a bg thread
|
||||
DaemonQTImpl daemon;
|
||||
if(logstreamptr) (*logstreamptr) << "Initialising the daemon..." << std::endl;
|
||||
bool daemonInitSuccess = daemon.init(argc, argv, logstreamptr);
|
||||
if(!daemonInitSuccess)
|
||||
{
|
||||
QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||
return 1;
|
||||
}
|
||||
LogPrint(eLogDebug, "Initialised, creating the main window...");
|
||||
MainWindow w(logstreamptr);
|
||||
LogPrint(eLogDebug, "Before main window.show()...");
|
||||
w.show ();
|
||||
|
||||
{
|
||||
i2p::qt::Controller daemonQtController(daemon);
|
||||
w.setI2PController(&daemonQtController);
|
||||
LogPrint(eLogDebug, "Starting the daemon...");
|
||||
emit daemonQtController.startDaemon();
|
||||
//daemon.start ();
|
||||
LogPrint(eLogDebug, "Starting GUI event loop...");
|
||||
result = app.exec();
|
||||
//daemon.stop ();
|
||||
}
|
||||
}
|
||||
|
||||
//QMessageBox::information(&w, "Debug", "demon stopped");
|
||||
LogPrint(eLogDebug, "Exiting the application");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef DAEMONQT_H
|
||||
#define DAEMONQT_H
|
||||
#ifndef I2PD_DAEMON_CONTROLLER_H
|
||||
#define I2PD_DAEMON_CONTROLLER_H
|
||||
|
||||
#include <memory>
|
||||
#include <QObject>
|
||||
@ -85,4 +85,4 @@ namespace qt
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DAEMONQT_H
|
||||
#endif // I2PD_DAEMON_CONTROLLER_H
|
65
src/launcher/i2pd_qt_launcher.cpp
Normal file
65
src/launcher/i2pd_qt_launcher.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
#include <memory>
|
||||
|
||||
#include "launcher/i2pd_qt_launcher.h"
|
||||
#include "controller/i2pd_daemon_controller.h"
|
||||
#include "Daemon.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QMutexLocker>
|
||||
#include <QThread>
|
||||
|
||||
//#define DEBUG_WITH_DEFAULT_LOGGING (1)
|
||||
|
||||
namespace i2p {
|
||||
namespace qt {
|
||||
|
||||
//TODO rework for clean MVC
|
||||
int RunQT (int argc, char* argv[]) {
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
int result;
|
||||
|
||||
{
|
||||
std::shared_ptr<std::iostream> logstreamptr =
|
||||
#ifdef DEBUG_WITH_DEFAULT_LOGGING
|
||||
nullptr
|
||||
#else
|
||||
std::make_shared<std::stringstream>()
|
||||
#endif
|
||||
;
|
||||
//TODO move daemon init deinit to a bg thread
|
||||
DaemonQTImpl daemon;
|
||||
if (logstreamptr) (*logstreamptr) << "Initialising the daemon..." << std::endl;
|
||||
bool daemonInitSuccess = daemon.init(argc, argv, logstreamptr);
|
||||
if (!daemonInitSuccess) {
|
||||
QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||
return 1;
|
||||
}
|
||||
LogPrint(eLogDebug, "Initialised, creating the main window...");
|
||||
MainWindow w(logstreamptr);
|
||||
LogPrint(eLogDebug, "Before main window.show()...");
|
||||
w.show ();
|
||||
|
||||
{
|
||||
i2p::qt::Controller daemonQtController(daemon);
|
||||
w.setI2PController(&daemonQtController);
|
||||
LogPrint(eLogDebug, "Starting the daemon...");
|
||||
emit daemonQtController.startDaemon();
|
||||
//daemon.start ();
|
||||
LogPrint(eLogDebug, "Starting GUI event loop...");
|
||||
result = app.exec();
|
||||
//daemon.stop ();
|
||||
}
|
||||
}
|
||||
|
||||
//QMessageBox::information(&w, "Debug", "demon stopped");
|
||||
LogPrint(eLogDebug, "Exiting the application");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
10
src/launcher/i2pd_qt_launcher.h
Normal file
10
src/launcher/i2pd_qt_launcher.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef I2PD_QT_LAUNCHER_H
|
||||
#define I2PD_QT_LAUNCHER_H
|
||||
|
||||
namespace i2p {
|
||||
namespace qt {
|
||||
int RunQT (int argc, char* argv[]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // I2PD_QT_LAUNCHER_H
|
@ -33,7 +33,8 @@
|
||||
# include <QtDebug>
|
||||
#endif
|
||||
|
||||
#include "DaemonQT.h"
|
||||
#include "controller/i2pd_daemon_controller.h"
|
||||
|
||||
#include "SignatureTypeComboboxFactory.h"
|
||||
|
||||
#include "logviewermanager.h"
|
||||
|
@ -56,7 +56,8 @@
|
||||
|
||||
#include "TunnelsPageUpdateListener.h"
|
||||
|
||||
#include "DaemonQT.h"
|
||||
#include "controller/i2pd_daemon_controller.h"
|
||||
|
||||
#include "SignatureTypeComboboxFactory.h"
|
||||
#include "pagewithbackbutton.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user