[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 6 | /// @author Marek Kurdej <firstname.surname@utc.fr>
|
---|
| 7 | /// @date March, 2013
|
---|
| 8 | /// @version $Id$
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 |
|
---|
[184] | 11 | #include <csignal>
|
---|
[89] | 12 | #include <Pacpus/kernel/Log.h>
|
---|
| 13 | #include <Pacpus/kernel/PacpusApplication.h>
|
---|
[162] | 14 | #include <Pacpus/kernel/PacpusException.h>
|
---|
[165] | 15 | #include <sstream>
|
---|
| 16 | #include <string>
|
---|
[89] | 17 |
|
---|
| 18 | using namespace pacpus;
|
---|
| 19 |
|
---|
| 20 | DECLARE_STATIC_LOGGER("pacpus.core.PacpusApplication");
|
---|
| 21 |
|
---|
| 22 | PacpusApplication::PacpusApplication(int & argc, char ** argv
|
---|
| 23 | #ifndef Q_QDOC
|
---|
| 24 | , int _internal
|
---|
| 25 | #endif
|
---|
| 26 | )
|
---|
| 27 | : QApplication(argc, argv, _internal)
|
---|
| 28 | {
|
---|
[165] | 29 | //installSignalHandler();
|
---|
[89] | 30 | }
|
---|
| 31 |
|
---|
| 32 | //PacpusApplication::PacpusApplication(int & argc, char ** argv, bool GUIenabled
|
---|
| 33 | //#ifndef Q_QDOC
|
---|
| 34 | // , int _internal
|
---|
| 35 | //#endif
|
---|
| 36 | // )
|
---|
| 37 | // : QApplication(argc, argv, GUIenabled, _internal)
|
---|
| 38 | //{
|
---|
| 39 | //}
|
---|
| 40 |
|
---|
| 41 | //PacpusApplication::PacpusApplication(int & argc, char ** argv, Type type
|
---|
| 42 | //#ifndef Q_QDOC
|
---|
| 43 | // , int _internal
|
---|
| 44 | //#endif
|
---|
| 45 | // )
|
---|
| 46 | // : QApplication(argc, argv, type, _internal)
|
---|
| 47 | //{
|
---|
| 48 | //}
|
---|
| 49 |
|
---|
| 50 | #if defined(Q_WS_X11)
|
---|
| 51 | PacpusApplication::PacpusApplication(Display * display, Qt::HANDLE visual, Qt::HANDLE colormap
|
---|
| 52 | #ifndef Q_QDOC
|
---|
| 53 | , int _internal
|
---|
| 54 | #endif
|
---|
| 55 | )
|
---|
| 56 | : QApplication(display, visual, colormap, _internal)
|
---|
| 57 | {
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | PacpusApplication::PacpusApplication(Display * display, int & argc, char ** argv, Qt::HANDLE visual , Qt::HANDLE colormap
|
---|
| 61 | #ifndef Q_QDOC
|
---|
| 62 | , int _internal
|
---|
| 63 | #endif
|
---|
| 64 | )
|
---|
| 65 | : QApplication(display, argc, argv, visual, colormap, _internal)
|
---|
| 66 | {
|
---|
| 67 | }
|
---|
| 68 | #endif
|
---|
| 69 |
|
---|
| 70 | #if defined(Q_OS_SYMBIAN)
|
---|
| 71 | PacpusApplication::PacpusApplication(QApplication::QS60MainApplicationFactory factory, int & argc, char ** argv
|
---|
| 72 | #ifndef Q_QDOC
|
---|
| 73 | , int _internal
|
---|
| 74 | #endif
|
---|
| 75 | )
|
---|
| 76 | : QApplication(factory, argc, argv, _internal)
|
---|
| 77 | {
|
---|
| 78 | }
|
---|
| 79 | #endif
|
---|
| 80 |
|
---|
| 81 | PacpusApplication::~PacpusApplication()
|
---|
| 82 | {
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | bool PacpusApplication::notify(QObject * receiver, QEvent * ev)
|
---|
| 86 | {
|
---|
| 87 | try {
|
---|
| 88 | return QApplication::notify(receiver, ev);
|
---|
[162] | 89 | } catch(PacpusException & e) {
|
---|
[141] | 90 | (void) e; // unused
|
---|
[162] | 91 | LOG_ERROR("PacpusException thrown:" << e.what());
|
---|
[89] | 92 | } catch(std::exception & e) {
|
---|
[141] | 93 | (void) e; // unused
|
---|
[89] | 94 | LOG_ERROR("std::exception thrown:" << e.what());
|
---|
| 95 | }
|
---|
| 96 | return false;
|
---|
| 97 | }
|
---|
[165] | 98 |
|
---|
[184] | 99 | void signalHandler(int signal);
|
---|
| 100 |
|
---|
| 101 | void PacpusApplication::installSignalHandler()
|
---|
| 102 | {
|
---|
| 103 | LOG_INFO("installing signal handler...");
|
---|
| 104 |
|
---|
| 105 | typedef void (*SignalHandlerType)(int);
|
---|
| 106 |
|
---|
| 107 | //std::signal(SIGABRT, &signalHandler);
|
---|
| 108 | //std::signal(SIGFPE, &signalHandler);
|
---|
| 109 | //std::signal(SIGILL, &signalHandler);
|
---|
| 110 | std::signal(SIGINT, &signalHandler); // interrupt (CTRL-C)
|
---|
| 111 | //std::signal(SIGSEGV, &signalHandler);
|
---|
| 112 | //std::signal(SIGTERM, &signalHandler);
|
---|
| 113 |
|
---|
| 114 | LOG_INFO("successfully installed signal handler");
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | void signalHandler(int signal)
|
---|
| 118 | {
|
---|
| 119 | LOG_FATAL("signal received: sig = " << signal);
|
---|
| 120 | std::stringstream errorMessage;
|
---|
| 121 | errorMessage << "received signal number " << signal;
|
---|
| 122 | throw PacpusException(errorMessage.str());
|
---|
| 123 | }
|
---|