From 9693b5238b76e6348413d68fa8c6ffc8c64fc12f Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Wed, 8 Aug 2007 16:58:27 +0000 Subject: [PATCH] Implemented a signal handler to graceful shutdown Quassel when SIGTERM or SIGINT (Ctrl+C) are received. Should be portable (it's ISO C at least), but if not, just comment out the few lines in main.cpp and tell me. --- src/common/main.cpp | 13 +++++++++++++ src/qtgui/coreconnectdlg.cpp | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/common/main.cpp b/src/common/main.cpp index fea9d2cc..86d874b5 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "settings.h" +#include #if defined BUILD_CORE #include @@ -45,7 +46,19 @@ #error "Something is wrong - you need to #define a build mode!" #endif +#include + +//! Signal handler for graceful shutdown. +void handle_signal(int sig) { + qWarning(QString("Caught signal %1 - exiting.").arg(sig).toAscii()); + QCoreApplication::quit(); +} + int main(int argc, char **argv) { + // We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel. + signal(SIGTERM, handle_signal); + signal(SIGINT, handle_signal); + qRegisterMetaType("Message"); qRegisterMetaType("BufferId"); qRegisterMetaTypeStreamOperators("Message"); diff --git a/src/qtgui/coreconnectdlg.cpp b/src/qtgui/coreconnectdlg.cpp index 3b3bb249..d845f00d 100644 --- a/src/qtgui/coreconnectdlg.cpp +++ b/src/qtgui/coreconnectdlg.cpp @@ -46,6 +46,8 @@ CoreConnectDlg::CoreConnectDlg(QWidget *parent, bool /*doAutoConnect*/) : QDialo connect(ui.hostEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputValid())); connect(ui.userEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputValid())); connect(ui.internalCore, SIGNAL(toggled(bool)), this, SLOT(checkInputValid())); + connect(ui.internalCore, SIGNAL(toggled(bool)), ui.hostEdit, SLOT(setDisabled(bool))); + connect(ui.internalCore, SIGNAL(toggled(bool)), ui.port, SLOT(setDisabled(bool))); connect(ui.accountList, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(accountChanged(const QString &))); connect(ui.autoConnect, SIGNAL(clicked(bool)), this, SLOT(autoConnectToggled(bool))); @@ -59,7 +61,7 @@ CoreConnectDlg::CoreConnectDlg(QWidget *parent, bool /*doAutoConnect*/) : QDialo curacc = s.lastAccount(); if(!ui.accountList->count()) { //if(doAutoConnect) reject(); - /* + setAccountEditEnabled(false); QString newacc = QInputDialog::getText(this, tr("Create Account"), tr( "In order to connect to a Quassel Core, you need to create an account.
" @@ -71,7 +73,7 @@ CoreConnectDlg::CoreConnectDlg(QWidget *parent, bool /*doAutoConnect*/) : QDialo ui.internalCore->setChecked(false); setAccountEditEnabled(true); } - */ + /* // FIXME We create a default account here that just connects to the internal core curacc = "Default"; ui.accountList->addItem("Default"); @@ -84,7 +86,7 @@ CoreConnectDlg::CoreConnectDlg(QWidget *parent, bool /*doAutoConnect*/) : QDialo ui.accountList->setCurrentIndex(0); ui.autoConnect->setChecked(true); autoConnectToggled(true); - + */ } else { if(!curacc.isEmpty()) { //if(doAutoConnect) { qDebug() << "auto"; -- 2.20.1