2016-06-17 13:49:49 +00:00
|
|
|
#ifndef ANDROID
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include "Daemon.h"
|
|
|
|
#else
|
|
|
|
# include "qt/i2pd_qt/i2pd_qt_gui.h"
|
|
|
|
# include <QMessageBox>
|
|
|
|
# include <QApplication>
|
|
|
|
# include "DaemonQT.h"
|
|
|
|
# include "mainwindow.h"
|
|
|
|
# include <QThread>
|
|
|
|
#endif
|
2014-02-05 00:28:18 +00:00
|
|
|
|
2014-01-30 00:56:48 +00:00
|
|
|
int main( int argc, char* argv[] )
|
2013-12-10 13:05:42 +00:00
|
|
|
{
|
2016-06-17 13:49:49 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
//int result = runGUI(argc, argv);
|
|
|
|
//QMessageBox::information(0,"Debug","runGUI completed");
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
qDebug("Initialising the daemon...");
|
2016-06-17 14:26:51 +00:00
|
|
|
bool daemonInitSuccess = i2p::qt::DaemonQTImpl::init(argc, argv);
|
2016-06-17 13:49:49 +00:00
|
|
|
if(!daemonInitSuccess) {
|
|
|
|
QMessageBox::critical(0, "Error", "Daemon init failed");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
qDebug("Initialised, creating the main window...");
|
|
|
|
MainWindow w;
|
|
|
|
qDebug("Before main window.show()...");
|
|
|
|
w.show ();
|
|
|
|
int result;
|
|
|
|
{
|
2016-06-17 14:26:51 +00:00
|
|
|
i2p::qt::Controller daemonQtController;
|
2016-06-17 13:49:49 +00:00
|
|
|
qDebug("Starting the daemon...");
|
|
|
|
emit daemonQtController.startDaemon();
|
|
|
|
qDebug("Starting gui event loop...");
|
|
|
|
result = app.exec();
|
|
|
|
//QMessageBox::information(&w, "Debug", "exec finished");
|
|
|
|
}
|
2016-06-17 14:26:51 +00:00
|
|
|
i2p::qt::DaemonQTImpl::deinit();
|
2016-06-17 13:49:49 +00:00
|
|
|
//QMessageBox::information(&w, "Debug", "demon stopped");
|
|
|
|
//exit(result); //return from main() causes intermittent sigsegv bugs in some Androids. exit() is a workaround for this
|
|
|
|
qDebug("Exiting the application");
|
|
|
|
return result;
|
|
|
|
#else
|
|
|
|
if (Daemon.init(argc, argv))
|
2016-03-10 06:12:46 +00:00
|
|
|
{
|
|
|
|
if (Daemon.start())
|
|
|
|
Daemon.run ();
|
|
|
|
Daemon.stop();
|
|
|
|
}
|
2014-12-10 17:10:07 +00:00
|
|
|
return EXIT_SUCCESS;
|
2016-06-17 13:49:49 +00:00
|
|
|
#endif
|
2013-12-10 13:05:42 +00:00
|
|
|
}
|
2015-11-03 14:15:49 +00:00
|
|
|
|
2016-03-10 06:12:46 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
int CALLBACK WinMain(
|
|
|
|
_In_ HINSTANCE hInstance,
|
|
|
|
_In_ HINSTANCE hPrevInstance,
|
|
|
|
_In_ LPSTR lpCmdLine,
|
|
|
|
_In_ int nCmdShow
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return main(__argc, __argv);
|
|
|
|
}
|
|
|
|
#endif
|