mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
QT doesn't depend on Linux daemon anymore
This commit is contained in:
parent
ff38a3bbfe
commit
70e502e55d
25
Daemon.h
25
Daemon.h
|
@ -3,10 +3,12 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define Daemon i2p::util::DaemonWin32::Instance()
|
||||
#if defined(QT_GUI)
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#else
|
||||
#define Daemon i2p::util::DaemonLinux::Instance()
|
||||
|
||||
#endif
|
||||
|
||||
namespace i2p
|
||||
|
@ -36,7 +38,21 @@ namespace i2p
|
|||
Daemon_Singleton_Private &d;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(QT_GUI_LIB) // check if QT
|
||||
#define Daemon i2p::util::DaemonQT::Instance()
|
||||
class DaemonQT: public i2p::util::Daemon_Singleton
|
||||
{
|
||||
public:
|
||||
|
||||
static DaemonQT& Instance()
|
||||
{
|
||||
static DaemonQT instance;
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#define Daemon i2p::util::DaemonWin32::Instance()
|
||||
class DaemonWin32 : public Daemon_Singleton
|
||||
{
|
||||
public:
|
||||
|
@ -52,6 +68,7 @@ namespace i2p
|
|||
void run ();
|
||||
};
|
||||
#else
|
||||
#define Daemon i2p::util::DaemonLinux::Instance()
|
||||
class DaemonLinux : public Daemon_Singleton
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -74,11 +74,9 @@ namespace i2p
|
|||
}
|
||||
|
||||
// point std{in,out,err} descriptors to /dev/null
|
||||
#ifndef ANDROID
|
||||
stdin = freopen("/dev/null", "r", stdin);
|
||||
stdout = freopen("/dev/null", "w", stdout);
|
||||
stderr = freopen("/dev/null", "w", stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Pidfile
|
||||
|
@ -94,12 +92,7 @@ namespace i2p
|
|||
LogPrint(eLogError, "Daemon: could not create pid file ", pidfile, ": ", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
#ifndef ANDROID
|
||||
if (lockf(pidFH, F_TLOCK, 0) != 0)
|
||||
#else
|
||||
//TODO ANDROID actually need to read man for this, blindly took a solution from <https://forum.qt.io/topic/27872/qtjsondb-build-failed-for-android/2>. -anon5
|
||||
if (fcntl(pidFH, 1, 0) < 0)
|
||||
#endif
|
||||
{
|
||||
LogPrint(eLogError, "Daemon: could not lock pid file ", pidfile, ": ", strerror(errno));
|
||||
return false;
|
||||
|
|
|
@ -365,7 +365,7 @@ namespace http {
|
|||
s << " <a href=\"/?cmd=" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << "\">Stop accepting tunnels</a><br>\r\n";
|
||||
else
|
||||
s << " <a href=\"/?cmd=" << HTTP_COMMAND_START_ACCEPTING_TUNNELS << "\">Start accepting tunnels</a><br>\r\n";
|
||||
#ifndef WIN32
|
||||
#if (!defined(WIN32) && !defined(QT_GUI_LIB))
|
||||
if (Daemon.gracefullShutdownInterval) {
|
||||
s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "\">Cancel gracefull shutdown (";
|
||||
s << Daemon.gracefullShutdownInterval;
|
||||
|
@ -678,12 +678,12 @@ namespace http {
|
|||
i2p::context.SetAcceptsTunnels (false);
|
||||
else if (cmd == HTTP_COMMAND_SHUTDOWN_START) {
|
||||
i2p::context.SetAcceptsTunnels (false);
|
||||
#ifndef WIN32
|
||||
#if (!defined(WIN32) && !defined(QT_GUI_LIB))
|
||||
Daemon.gracefullShutdownInterval = 10*60;
|
||||
#endif
|
||||
} else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL) {
|
||||
i2p::context.SetAcceptsTunnels (true);
|
||||
#ifndef WIN32
|
||||
#if (!defined(WIN32) && !defined(QT_GUI_LIB))
|
||||
Daemon.gracefullShutdownInterval = 0;
|
||||
#endif
|
||||
} else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) {
|
||||
|
|
|
@ -22,8 +22,6 @@ SOURCES += main.cpp\
|
|||
../../BOB.cpp \
|
||||
../../ClientContext.cpp \
|
||||
../../Crypto.cpp \
|
||||
../../DaemonLinux.cpp \
|
||||
../../DaemonWin32.cpp \
|
||||
../../Datagram.cpp \
|
||||
../../Destination.cpp \
|
||||
../../Family.cpp \
|
||||
|
|
|
@ -3,31 +3,20 @@
|
|||
#include <stdlib.h>
|
||||
#include "../../Daemon.h"
|
||||
|
||||
class DaemonQT: public i2p::util::Daemon_Singleton
|
||||
{
|
||||
public:
|
||||
|
||||
static DaemonQT& Instance()
|
||||
{
|
||||
static DaemonQT instance;
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
||||
int ret = -1;
|
||||
if (DaemonQT::Instance ().init(argc, argv))
|
||||
if (Daemon.init(argc, argv))
|
||||
{
|
||||
if (DaemonQT::Instance ().start())
|
||||
if (Daemon.start())
|
||||
{
|
||||
w.show();
|
||||
ret = a.exec();
|
||||
}
|
||||
DaemonQT::Instance ().stop();
|
||||
Daemon.stop();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue