diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ffca948..5769a191 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,132 +1,130 @@ include (CheckFunctionExists) check_function_exists("strsignal" HAVE_STRSIGNAL) check_function_exists("uname" HAVE_UNAME) if (NOT DEBUG_PACKAGE_INSTALLER_NAME) set (DEBUG_PACKAGE_INSTALLER_NAME "installdbgsymbols.sh") endif () configure_file (config-drkonqi.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-drkonqi.h ) add_subdirectory( data ) add_subdirectory( parser ) if ( WIN32 ) find_package(KDEWin REQUIRED) # for finding drkonqi_debug.h include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_subdirectory( kdbgwin ) endif () set(drkonqi_SRCS main.cpp drkonqidialog.cpp statuswidget.cpp aboutbugreportingdialog.cpp backtraceratingwidget.cpp backtracewidget.cpp backtracegenerator.cpp drkonqi.cpp drkonqibackends.cpp detachedprocessmonitor.cpp debugpackageinstaller.cpp systeminformation.cpp crashedapplication.cpp debugger.cpp debuggerlaunchers.cpp ptracer.cpp debuggermanager.cpp applicationdetailsexamples.cpp gdbhighlighter.cpp statusnotifier.cpp ) ki18n_wrap_ui(drkonqi_SRCS ui/maindialog.ui ui/backtracewidget.ui ) # if BACKTRACE_PARSER_DEBUG is enabled, it will show both the # parsed and the unparsed backtrace in the backtrace widget. # Comment this out for release. #add_definitions(-DBACKTRACE_PARSER_DEBUG) set(drkonqi_SRCS ${drkonqi_SRCS} bugzillaintegration/bugzillalib.cpp bugzillaintegration/reportassistantdialog.cpp bugzillaintegration/reportassistantpage.cpp bugzillaintegration/reportassistantpages_base.cpp bugzillaintegration/reportassistantpages_bugzilla.cpp bugzillaintegration/reportassistantpages_bugzilla_duplicates.cpp bugzillaintegration/reportinterface.cpp bugzillaintegration/productmapping.cpp bugzillaintegration/parsebugbacktraces.cpp # Requires kxmlrpcclient bugzillaintegration/duplicatefinderjob.cpp ) ki18n_wrap_ui(drkonqi_SRCS bugzillaintegration/ui/assistantpage_introduction.ui bugzillaintegration/ui/assistantpage_bugawareness.ui bugzillaintegration/ui/assistantpage_conclusions.ui bugzillaintegration/ui/assistantpage_conclusions_dialog.ui bugzillaintegration/ui/assistantpage_bugzilla_login.ui bugzillaintegration/ui/assistantpage_bugzilla_duplicates.ui bugzillaintegration/ui/assistantpage_bugzilla_duplicates_dialog.ui bugzillaintegration/ui/assistantpage_bugzilla_duplicates_dialog_confirmation.ui bugzillaintegration/ui/assistantpage_bugzilla_information.ui bugzillaintegration/ui/assistantpage_bugzilla_preview.ui bugzillaintegration/ui/assistantpage_bugzilla_send.ui ) ecm_qt_declare_logging_category(drkonqi_SRCS HEADER drkonqi_debug.h IDENTIFIER DRKONQI_LOG CATEGORY_NAME org.kde.drkonqi) add_executable(drkonqi ${drkonqi_SRCS}) ecm_mark_nongui_executable(drkonqi) -target_compile_definitions(drkonqi PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") - target_link_libraries(drkonqi KF5::I18n KF5::CoreAddons KF5::Service KF5::ConfigWidgets KF5::JobWidgets KF5::KIOCore KF5::Crash KF5::Completion Qt5::DBus KF5::XmlRpcClient KF5::WidgetsAddons KF5::Wallet KF5::Notifications # for status notifier KF5::IdleTime # hide status notifier only if user saw it drkonqi_backtrace_parser ) if (${Qt5X11Extras_FOUND}) target_link_libraries(drkonqi Qt5::X11Extras ) endif() if (APPLE) target_link_libraries(drkonqi KF5::WindowSystem ) endif() if (WIN32) target_link_libraries(drkonqi kdewin) endif() install(TARGETS drkonqi DESTINATION ${KDE_INSTALL_LIBEXECDIR}) configure_file(org.kde.drkonqi.desktop.cmake ${CMAKE_BINARY_DIR}/src/org.kde.drkonqi.desktop) install(PROGRAMS ${CMAKE_BINARY_DIR}/src/org.kde.drkonqi.desktop DESTINATION ${KDE_INSTALL_APPDIR}) # Only go into tests once we have a drkonqi target so the tests can reference # it. add_subdirectory( tests ) diff --git a/src/config-drkonqi.h.cmake b/src/config-drkonqi.h.cmake index 94b876de..c850353e 100644 --- a/src/config-drkonqi.h.cmake +++ b/src/config-drkonqi.h.cmake @@ -1,6 +1,8 @@ #cmakedefine HAVE_STRSIGNAL 1 #cmakedefine HAVE_UNAME 1 #cmakedefine HAVE_X11 1 #define HAVE_XMLRPCCLIENT 1 #define DEBUG_PACKAGE_INSTALLER_NAME "@DEBUG_PACKAGE_INSTALLER_NAME@" + +#define PROJECT_VERSION "@PROJECT_VERSION@" diff --git a/src/main.cpp b/src/main.cpp index 7c87ec5d..532b273f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,183 +1,184 @@ /***************************************************************** * drkonqi - The KDE Crash Handler * * Copyright (C) 2000-2003 Hans Petter Bieker * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************/ #include #include #include #include #include #include #include #if HAVE_X11 #include #endif #ifdef Q_OS_MACOS #include #endif +#include "config-drkonqi.h" #include "drkonqi.h" #include "drkonqidialog.h" #include "statusnotifier.h" static const char version[] = PROJECT_VERSION; static const char description[] = I18N_NOOP("The KDE Crash Handler gives the user feedback " "if a program has crashed."); int main(int argc, char* argv[]) { #ifndef Q_OS_WIN //krazy:exclude=cpp // Drop privs. setgid(getgid()); if (setuid(getuid()) < 0 && geteuid() != getuid()) { exit(255); } #endif QApplication qa(argc, argv); qa.setAttribute(Qt::AA_UseHighDpiPixmaps, true); KLocalizedString::setApplicationDomain("drkonqi5"); QCoreApplication::setApplicationName(QStringLiteral("drkonqi")); QCoreApplication::setApplicationVersion(QString::fromLatin1(version)); QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); // Prevent KApplication from setting the crash handler. We will set it later... setenv("KDE_DEBUG", "true", 1); // Session management is not needed, do not even connect in order to survive longer than ksmserver. unsetenv("SESSION_MANAGER"); KAboutData aboutData(QStringLiteral("drkonqi"), i18n("The KDE Crash Handler"), QString::fromLatin1(version), i18n(description), KAboutLicense::GPL, i18n("(C) 2000-2018, The DrKonqi Authors")); aboutData.addAuthor(i18nc("@info:credit","Hans Petter Bieker"), QString(), QStringLiteral("bieker@kde.org")); aboutData.addAuthor(i18nc("@info:credit","Dario Andres Rodriguez"), QString(), QStringLiteral("andresbajotierra@gmail.com")); aboutData.addAuthor(i18nc("@info:credit","George Kiagiadakis"), QString(), QStringLiteral("gkiagia@users.sourceforge.net")); aboutData.addAuthor(i18nc("@info:credit","A. L. Spehr"), QString(), QStringLiteral("spehr@kde.org")); qa.setWindowIcon(QIcon::fromTheme(QStringLiteral("tools-report-bug"), qa.windowIcon())); qa.setDesktopFileName(QStringLiteral("org.kde.drkonqi")); QCommandLineParser parser; aboutData.setupCommandLine(&parser); QCommandLineOption signalOption(QStringLiteral("signal"), i18nc("@info:shell","The signal that was caught"), QStringLiteral("number")); QCommandLineOption appNameOption(QStringLiteral("appname"), i18nc("@info:shell"," of the program"), QStringLiteral("name")); QCommandLineOption appPathOption(QStringLiteral("apppath"), i18nc("@info:shell"," to the executable"), QStringLiteral("path")); QCommandLineOption appVersionOption(QStringLiteral("appversion"), i18nc("@info:shell","The of the program"), QStringLiteral("version")); QCommandLineOption bugAddressOption(QStringLiteral("bugaddress"), i18nc("@info:shell","The bug
to use"), QStringLiteral("address")); QCommandLineOption programNameOption(QStringLiteral("programname"), i18nc("@info:shell","Translated of the program"), QStringLiteral("name")); QCommandLineOption pidOption(QStringLiteral("pid"), i18nc("@info:shell","The of the program"), QStringLiteral("pid")); QCommandLineOption startupIdOption(QStringLiteral("startupid"), i18nc("@info:shell","Startup of the program"), QStringLiteral("id")); QCommandLineOption kdeinitOption(QStringLiteral("kdeinit"), i18nc("@info:shell","The program was started by kdeinit")); QCommandLineOption saferOption(QStringLiteral("safer"), i18nc("@info:shell","Disable arbitrary disk access")); QCommandLineOption restartedOption(QStringLiteral("restarted"), i18nc("@info:shell","The program has already been restarted")); QCommandLineOption keepRunningOption(QStringLiteral("keeprunning"), i18nc("@info:shell","Keep the program running and generate " "the backtrace at startup")); QCommandLineOption threadOption(QStringLiteral("thread"), i18nc("@info:shell","The of the failing thread"), QStringLiteral("threadid")); QCommandLineOption dialogOption(QStringLiteral("dialog"), i18nc("@info:shell","Do not show a notification but launch the debug dialog directly")); parser.addOption(signalOption); parser.addOption(appNameOption); parser.addOption(appPathOption); parser.addOption(appVersionOption); parser.addOption(bugAddressOption); parser.addOption(programNameOption); parser.addOption(pidOption); parser.addOption(startupIdOption); parser.addOption(kdeinitOption); parser.addOption(saferOption); parser.addOption(restartedOption); parser.addOption(keepRunningOption); parser.addOption(threadOption); parser.addOption(dialogOption); parser.process(qa); aboutData.processCommandLine(&parser); DrKonqi::setSignal(parser.value(signalOption).toInt()); DrKonqi::setAppName(parser.value(appNameOption)); DrKonqi::setAppPath(parser.value(appPathOption)); DrKonqi::setAppVersion(parser.value(appVersionOption)); DrKonqi::setBugAddress(parser.value(bugAddressOption)); DrKonqi::setProgramName(parser.value(programNameOption)); DrKonqi::setPid(parser.value(pidOption).toInt()); DrKonqi::setKdeinit(parser.isSet(kdeinitOption)); DrKonqi::setSafer(parser.isSet(saferOption)); DrKonqi::setRestarted(parser.isSet(restartedOption)); DrKonqi::setKeepRunning(parser.isSet(keepRunningOption)); DrKonqi::setThread(parser.value(threadOption).toInt()); auto forceDialog = parser.isSet(dialogOption); #if HAVE_X11 const QString startupId = parser.value(startupIdOption); if (!startupId.isEmpty()) { QX11Info::setNextStartupId(startupId.toUtf8()); } #endif if (!DrKonqi::init()) { return 1; } qa.setQuitOnLastWindowClosed(false); auto openDrKonqiDialog = [&qa]{ DrKonqiDialog *w = new DrKonqiDialog(); QObject::connect(w, &DrKonqiDialog::rejected, &qa, &QApplication::quit); w->show(); #ifdef Q_OS_MACOS KWindowSystem::forceActiveWindow(w->winId()); #endif }; bool restarted = parser.isSet(restartedOption); // if no notification service is running (eg. shell crashed, or other desktop environment) // and we didn't auto-restart the app, open DrKonqi dialog instead of showing an SNI // and emitting a desktop notification if (forceDialog || (!restarted && !StatusNotifier::notificationServiceRegistered())) { openDrKonqiDialog(); } else { StatusNotifier *statusNotifier = new StatusNotifier(); if (!restarted) { statusNotifier->notify(); } QObject::connect(statusNotifier, &StatusNotifier::expired, &qa, &QApplication::quit); QObject::connect(statusNotifier, &StatusNotifier::activated, openDrKonqiDialog); } int ret = qa.exec(); DrKonqi::cleanup(); return ret; }