Catch SIGINT signal.
Show pin, connection, disconnection and database messages if verbose logging is disabled.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QSettings>
|
||||
#include <QTextStream>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <vitamtp.h>
|
||||
@@ -59,6 +60,8 @@ void HeadlessManager::refreshDatabase()
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream(stdout) << "Database scan has started" << endl;
|
||||
|
||||
if(!m_db->rescan()) {
|
||||
qDebug("No PS Vita system has been registered");
|
||||
}
|
||||
@@ -128,6 +131,11 @@ void HeadlessManager::start()
|
||||
}
|
||||
}
|
||||
|
||||
void HeadlessManager::receiveMessage(QString message)
|
||||
{
|
||||
QTextStream(stdout) << message << endl;
|
||||
}
|
||||
|
||||
void HeadlessManager::stop()
|
||||
{
|
||||
if(CmaClient::stop() < 0) {
|
||||
|
||||
@@ -70,6 +70,7 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void threadStopped();
|
||||
void receiveMessage(QString message);
|
||||
};
|
||||
|
||||
#endif // HEADLESSMANAGER_H
|
||||
|
||||
@@ -70,12 +70,18 @@ static bool setup_handlers()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sigaction(SIGINT, &term, NULL) != 0) {
|
||||
qCritical("SIGINT signal handle failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(SingleCoreApplication::sendMessage(QObject::tr("An instance of Qcma is already running"))) {
|
||||
if(SingleCoreApplication::sendMessage("Another instance of Qcma tried to start")) {
|
||||
QTextStream(stdout) << "An instance of Qcma is already running" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -137,6 +143,10 @@ int main(int argc, char *argv[])
|
||||
app.setApplicationName("qcma");
|
||||
|
||||
HeadlessManager manager;
|
||||
|
||||
// receive the message from another process
|
||||
QObject::connect(&app, SIGNAL(messageAvailable(QString)), &manager, SLOT(receiveMessage(QString)));
|
||||
|
||||
manager.start();
|
||||
|
||||
return app.exec();
|
||||
|
||||
Reference in New Issue
Block a user