Removed dbus support.

Added unix signals support.
This commit is contained in:
codestation
2015-03-14 23:55:56 -04:30
parent c162b91b00
commit da6ad50759
17 changed files with 242 additions and 122 deletions

View File

@@ -25,6 +25,7 @@
#include <QLibraryInfo>
#include <QLocale>
#include <QTextCodec>
#include <QTextStream>
#include <QThread>
#include <QTranslator>
@@ -45,9 +46,36 @@ static void noMessageOutput(QtMsgType type, const char *msg)
Q_UNUSED(msg);
}
static bool setup_handlers()
{
struct sigaction hup, term;
hup.sa_handler = ClientManager::hupSignalHandler;
sigemptyset(&hup.sa_mask);
hup.sa_flags = 0;
hup.sa_flags |= SA_RESTART;
if (sigaction(SIGHUP, &hup, NULL) != 0) {
qCritical("SIGHUP signal handle failed");
return false;
}
term.sa_handler = ClientManager::termSignalHandler;
sigemptyset(&term.sa_mask);
term.sa_flags |= SA_RESTART;
if (sigaction(SIGTERM, &term, NULL) != 0) {
qCritical("SIGTERM signal handle failed");
return false;
}
return true;
}
int main(int argc, char *argv[])
{
if(SingleApplication::sendMessage(QObject::tr("A instance of QCMA is already running"))) {
if(SingleApplication::sendMessage(QObject::tr("An instance of Qcma is already running"))) {
return 0;
}
@@ -60,6 +88,8 @@ int main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN);
#endif
setup_handlers();
if(app.arguments().contains("--with-debug")) {
VitaMTP_Set_Logging(VitaMTP_DEBUG);
} else if(app.arguments().contains("--verbose")) {
@@ -77,7 +107,7 @@ int main(int argc, char *argv[])
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
qDebug("Starting QCMA %s", QCMA_VER);
QTextStream(stdout) << "Starting Qcma " << QCMA_VER << endl;
QTranslator translator;
QString locale = QLocale().system().name();