diff --git a/CMakeLists.txt b/CMakeLists.txt index 805202ff..64090dee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,83 +1,82 @@ cmake_minimum_required(VERSION 3.0) project(drkonqi) set(PROJECT_VERSION "5.15.80") set(PROJECT_VERSION_MAJOR 5) set(QT_MIN_VERSION "5.11.0") set(KF5_MIN_VERSION "5.54.0") find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) include(ECMMarkAsTest) include(CheckFunctionExists) include(FeatureSummary) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Widgets Test DBus Concurrent) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n CoreAddons Service ConfigWidgets JobWidgets KIO Crash Completion XmlRpcClient WidgetsAddons Wallet Notifications IdleTime) if(APPLE) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS WindowSystem) endif() find_package(Qt5X11Extras ${QT_MIN_VERSION} CONFIG) set_package_properties(Qt5X11Extras PROPERTIES TYPE RECOMMENDED PURPOSE "Recommended for better integration on X11.") if (MINGW) find_package(ZLIB REQUIRED) find_library(INTL_LIBRARY NAMES intl) find_library(IBERTY_LIBRARY NAMES iberty) find_library(BFD_LIBRARY NAMES bfd) if (IBERTY_LIBRARY) set(iberty_FOUND 1) else() set(msg "iberty") endif() if (BFD_LIBRARY) set(bfd_FOUND 1) else() set(msg "${msg} bfd") endif() if (INTL_LIBRARY) set(intl_FOUND 1) else() set(msg "${msg} intl") endif() if (msg) message(FATAL_ERROR "could not find ${msg}") endif() add_library(intl SHARED IMPORTED) set_target_properties(intl PROPERTIES IMPORTED_IMPLIB ${INTL_LIBRARY} ) add_library(iberty STATIC IMPORTED) set_target_properties(iberty PROPERTIES IMPORTED_LOCATION ${IBERTY_LIBRARY} ) add_library(bfd STATIC IMPORTED) set_target_properties(bfd PROPERTIES IMPORTED_LOCATION ${BFD_LIBRARY} # bfd header requires this to be defined INTERFACE_COMPILE_DEFINITIONS "PACKAGE;PACKAGE_VERSION" ) find_path(BFD_INCLUDE_DIR bfd.h) include_directories(${BFD_INCLUDE_DIR}) endif() include_directories("${CMAKE_CURRENT_BINARY_DIR}") -configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_subdirectory(src) install( FILES drkonqi.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/config-X11.h.cmake b/config-X11.h.cmake deleted file mode 100644 index 2f779a2b..00000000 --- a/config-X11.h.cmake +++ /dev/null @@ -1,2 +0,0 @@ -#cmakedefine01 Qt5X11Extras_FOUND -#define HAVE_X11 Qt5X11Extras_FOUND diff --git a/src/config-drkonqi.h.cmake b/src/config-drkonqi.h.cmake index c850353e..19a2bad2 100644 --- a/src/config-drkonqi.h.cmake +++ b/src/config-drkonqi.h.cmake @@ -1,8 +1,8 @@ -#cmakedefine HAVE_STRSIGNAL 1 -#cmakedefine HAVE_UNAME 1 -#cmakedefine HAVE_X11 1 -#define HAVE_XMLRPCCLIENT 1 +#cmakedefine01 HAVE_STRSIGNAL +#cmakedefine01 HAVE_UNAME +#cmakedefine01 HAVE_X11 +#cmakedefine01 HAVE_XMLRPCCLIENT #define DEBUG_PACKAGE_INSTALLER_NAME "@DEBUG_PACKAGE_INSTALLER_NAME@" #define PROJECT_VERSION "@PROJECT_VERSION@" diff --git a/src/crashedapplication.cpp b/src/crashedapplication.cpp index 71668fdc..aabeaf52 100644 --- a/src/crashedapplication.cpp +++ b/src/crashedapplication.cpp @@ -1,186 +1,186 @@ /* Copyright (C) 2009 George Kiagiadakis This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include "crashedapplication.h" -#if defined(HAVE_STRSIGNAL) && defined(Q_OS_UNIX) +#if HAVE_STRSIGNAL && defined(Q_OS_UNIX) # include # include # include #else # if defined(Q_OS_UNIX) # include # else # include # endif #endif #include CrashedApplication::CrashedApplication(QObject *parent) : QObject(parent), m_restarted(false) { } CrashedApplication::~CrashedApplication() { } QString CrashedApplication::name() const { return m_name.isEmpty() ? fakeExecutableBaseName() : m_name; } QFileInfo CrashedApplication::executable() const { return m_executable; } QString CrashedApplication::fakeExecutableBaseName() const { if (!m_fakeBaseName.isEmpty()) { return m_fakeBaseName; } else { return m_executable.baseName(); } } QString CrashedApplication::version() const { return m_version; } BugReportAddress CrashedApplication::bugReportAddress() const { return m_reportAddress; } int CrashedApplication::pid() const { return m_pid; } int CrashedApplication::signalNumber() const { return m_signalNumber; } QString CrashedApplication::signalName() const { -#if defined(HAVE_STRSIGNAL) && defined(Q_OS_UNIX) +#if HAVE_STRSIGNAL && defined(Q_OS_UNIX) const char * oldLocale = std::setlocale(LC_MESSAGES, nullptr); char * savedLocale; if (oldLocale) { savedLocale = strdup(oldLocale); } else { savedLocale = nullptr; } std::setlocale(LC_MESSAGES, "C"); const char *name = strsignal(m_signalNumber); std::setlocale(LC_MESSAGES, savedLocale); std::free(savedLocale); return QString::fromLocal8Bit(name ? name : "Unknown"); #else switch (m_signalNumber) { # if defined(Q_OS_UNIX) case SIGILL: return QLatin1String("SIGILL"); case SIGABRT: return QLatin1String("SIGABRT"); case SIGFPE: return QLatin1String("SIGFPE"); case SIGSEGV: return QLatin1String("SIGSEGV"); case SIGBUS: return QLatin1String("SIGBUS"); # else case EXCEPTION_ACCESS_VIOLATION: return QLatin1String("EXCEPTION_ACCESS_VIOLATION"); case EXCEPTION_DATATYPE_MISALIGNMENT: return QLatin1String("EXCEPTION_DATATYPE_MISALIGNMENT"); case EXCEPTION_BREAKPOINT: return QLatin1String("EXCEPTION_BREAKPOINT"); case EXCEPTION_SINGLE_STEP: return QLatin1String("EXCEPTION_SINGLE_STEP"); case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: return QLatin1String("EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); case EXCEPTION_FLT_DENORMAL_OPERAND: return QLatin1String("EXCEPTION_FLT_DENORMAL_OPERAND"); case EXCEPTION_FLT_DIVIDE_BY_ZERO: return QLatin1String("EXCEPTION_FLT_DIVIDE_BY_ZERO"); case EXCEPTION_FLT_INEXACT_RESULT: return QLatin1String("EXCEPTION_FLT_INEXACT_RESULT"); case EXCEPTION_FLT_INVALID_OPERATION: return QLatin1String("EXCEPTION_FLT_INVALID_OPERATION"); case EXCEPTION_FLT_OVERFLOW: return QLatin1String("EXCEPTION_FLT_OVERFLOW"); case EXCEPTION_FLT_STACK_CHECK: return QLatin1String("EXCEPTION_FLT_STACK_CHECK"); case EXCEPTION_FLT_UNDERFLOW: return QLatin1String("EXCEPTION_FLT_UNDERFLOW"); case EXCEPTION_INT_DIVIDE_BY_ZERO: return QLatin1String("EXCEPTION_INT_DIVIDE_BY_ZERO"); case EXCEPTION_INT_OVERFLOW: return QLatin1String("EXCEPTION_INT_OVERFLOW"); case EXCEPTION_PRIV_INSTRUCTION: return QLatin1String("EXCEPTION_PRIV_INSTRUCTION"); case EXCEPTION_IN_PAGE_ERROR: return QLatin1String("EXCEPTION_IN_PAGE_ERROR"); case EXCEPTION_ILLEGAL_INSTRUCTION: return QLatin1String("EXCEPTION_ILLEGAL_INSTRUCTION"); case EXCEPTION_NONCONTINUABLE_EXCEPTION: return QLatin1String("EXCEPTION_NONCONTINUABLE_EXCEPTION"); case EXCEPTION_STACK_OVERFLOW: return QLatin1String("EXCEPTION_STACK_OVERFLOW"); case EXCEPTION_INVALID_DISPOSITION: return QLatin1String("EXCEPTION_INVALID_DISPOSITION"); # endif default: return QLatin1String("Unknown"); } #endif } bool CrashedApplication::hasBeenRestarted() const { return m_restarted; } int CrashedApplication::thread() const { return m_thread; } const QDateTime& CrashedApplication::datetime() const { return m_datetime; } void CrashedApplication::restart() { if (m_restarted) { return; } int ret = -1; //start the application via kdeinit, as it needs to have a pristine environment and //KProcess::startDetached() can't start a new process with custom environment variables. if (!m_fakeBaseName.isEmpty()) { // if m_fakeBaseName is set, this means m_executable is the path to kdeinit4 // so we need to use the fakeBaseName to restart the app ret = KToolInvocation::kdeinitExec(m_fakeBaseName); } else { ret = KToolInvocation::kdeinitExec(m_executable.absoluteFilePath()); } const bool success = (ret == 0); m_restarted = success; emit restarted(success); } QString getSuggestedKCrashFilename(const CrashedApplication* app) { QString filename = app->fakeExecutableBaseName() + QLatin1Char('-') + app->datetime().toString(QStringLiteral("yyyyMMdd-hhmmss")) + QStringLiteral(".kcrash.txt"); if (filename.contains(QLatin1Char('/'))) { filename = filename.mid(filename.lastIndexOf(QLatin1Char('/')) + 1); } return filename; } diff --git a/src/main.cpp b/src/main.cpp index 532b273f..894b3fab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,184 +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 +#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; } diff --git a/src/systeminformation.cpp b/src/systeminformation.cpp index 4ca450fa..5903fb92 100644 --- a/src/systeminformation.cpp +++ b/src/systeminformation.cpp @@ -1,303 +1,303 @@ /******************************************************************* * systeminformation.cpp * Copyright 2009 Dario Andres Rodriguez * Copyright 2009 George Kiagiadakis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ******************************************************************/ #include #include "systeminformation.h" -#ifdef HAVE_UNAME +#if HAVE_UNAME # include # include #endif #include #include #include "drkonqi_debug.h" #include #include #include #include #include #include static const QString OS_UNSPECIFIED = QStringLiteral("unspecified"); static const QString PLATFORM_UNSPECIFIED = QStringLiteral("unspecified"); SystemInformation::SystemInformation(QObject * parent) : QObject(parent) , m_bugzillaOperatingSystem(OS_UNSPECIFIED) , m_bugzillaPlatform(PLATFORM_UNSPECIFIED) { // NOTE: the relative order is important here m_bugzillaOperatingSystem = fetchOSBasicInformation(); m_operatingSystem = fetchOSDetailInformation(); tryToSetBugzillaPlatform(); KConfigGroup config(KSharedConfig::openConfig(), "SystemInformation"); m_compiledSources = config.readEntry("CompiledSources", false); } SystemInformation::~SystemInformation() { KConfigGroup config(KSharedConfig::openConfig(), "SystemInformation"); config.writeEntry("CompiledSources", m_compiledSources); config.sync(); } void SystemInformation::tryToSetBugzillaPlatform() { QString platform = PLATFORM_UNSPECIFIED; // first, try to guess bugzilla platfrom from the internal OS information // this should work for BSDs, solaris and windows. platform = guessBugzillaPlatform(m_bugzillaOperatingSystem); // if the internal information is not enough, refer to external information if (platform == PLATFORM_UNSPECIFIED) { tryToSetBugzillaPlatformFromExternalInfo(); } else { setBugzillaPlatform(platform); } } void SystemInformation::tryToSetBugzillaPlatformFromExternalInfo() { //Run lsb_release async QString lsb_release = QStandardPaths::findExecutable(QLatin1String("lsb_release")); if ( !lsb_release.isEmpty() ) { qCDebug(DRKONQI_LOG) << "found lsb_release"; KProcess *process = new KProcess(); process->setOutputChannelMode(KProcess::OnlyStdoutChannel); process->setEnv(QStringLiteral("LC_ALL"), QStringLiteral("C")); *process << lsb_release << QStringLiteral("-sd"); connect(process, static_cast(&KProcess::finished), this, &SystemInformation::lsbReleaseFinished); process->start(); } else { // when lsb_release is unavailable, turn to /etc/os-release const QString& osReleaseInfo = fetchOSReleaseInformation(); const QString& platform = guessBugzillaPlatform(osReleaseInfo); setBugzillaPlatform(platform); } } void SystemInformation::lsbReleaseFinished() { KProcess *process = qobject_cast(sender()); Q_ASSERT(process); m_lsbRelease = QString::fromLocal8Bit(process->readAllStandardOutput().trimmed()); process->deleteLater(); //Guess distro string QString platform = guessBugzillaPlatform(m_lsbRelease); // if lsb_release doesn't work well, turn to the /etc/os-release file if (platform == PLATFORM_UNSPECIFIED) { const QString& osReleaseInfo = fetchOSReleaseInformation(); platform = guessBugzillaPlatform(osReleaseInfo); } setBugzillaPlatform(platform); } //this function maps the distribution information to an "Hardware Platform" . //value that is accepted by bugs.kde.org. If the values change on the server . //side, they need to be updated here as well . QString SystemInformation::guessBugzillaPlatform(const QString& distroInfo) const { if ( distroInfo.contains(QStringLiteral("suse"),Qt::CaseInsensitive) ) { return (QLatin1String("openSUSE RPMs")); } else if ( distroInfo.contains(QStringLiteral("mint"),Qt::CaseInsensitive) ) { return (QLatin1String("Mint (Ubuntu Based)")); } else if ( distroInfo.contains(QStringLiteral("lmde"),Qt::CaseInsensitive) ) { return (QLatin1String("Mint (Debian Based)")); } else if ( distroInfo.contains(QStringLiteral("ubuntu"),Qt::CaseInsensitive) ) { return (QLatin1String("Ubuntu Packages")); } else if ( distroInfo.contains(QStringLiteral("fedora"),Qt::CaseInsensitive) ) { return (QLatin1String("Fedora RPMs")); } else if ( distroInfo.contains(QStringLiteral("redhat"),Qt::CaseInsensitive) ) { return (QLatin1String("RedHat RPMs")); } else if ( distroInfo.contains(QStringLiteral("gentoo"),Qt::CaseInsensitive) ) { return (QLatin1String("Gentoo Packages")); } else if ( distroInfo.contains(QStringLiteral("mandriva"),Qt::CaseInsensitive) ) { return (QLatin1String("Mandriva RPMs")); } else if ( distroInfo.contains(QStringLiteral("mageia"),Qt::CaseInsensitive) ) { return (QLatin1String("Mageia RPMs")); } else if ( distroInfo.contains(QStringLiteral("slack"),Qt::CaseInsensitive) ) { return (QLatin1String("Slackware Packages")); } else if ( distroInfo.contains(QStringLiteral("pclinuxos"),Qt::CaseInsensitive) ) { return (QLatin1String("PCLinuxOS")); } else if ( distroInfo.contains(QStringLiteral("pardus"),Qt::CaseInsensitive) ) { return (QLatin1String("Pardus Packages")); } else if ( distroInfo.contains(QStringLiteral("freebsd"),Qt::CaseInsensitive) ) { return (QLatin1String("FreeBSD Ports")); } else if ( distroInfo.contains(QStringLiteral("netbsd"),Qt::CaseInsensitive) ) { return (QLatin1String("NetBSD pkgsrc")); } else if ( distroInfo.contains(QStringLiteral("openbsd"),Qt::CaseInsensitive) ) { return (QLatin1String("OpenBSD Packages")); } else if ( distroInfo.contains(QStringLiteral("solaris"),Qt::CaseInsensitive) ) { return (QLatin1String("Solaris Packages")); } else if ( distroInfo.contains(QStringLiteral("chakra"),Qt::CaseInsensitive) ) { return (QLatin1String("Chakra")); } else if ( distroInfo.contains(QStringLiteral("ms windows"),Qt::CaseInsensitive) ) { return (QLatin1String("MS Windows")); } else if ( distroInfo.contains(QStringLiteral("arch"),Qt::CaseInsensitive) ) { return (QLatin1String("Archlinux Packages")); } else if ( distroInfo.contains(QStringLiteral("debian"),Qt::CaseInsensitive) ) { if ( distroInfo.contains(QStringLiteral("unstable"),Qt::CaseInsensitive) ) { return (QLatin1String("Debian unstable")); } else if ( distroInfo.contains(QStringLiteral("testing"),Qt::CaseInsensitive) ) { return (QLatin1String("Debian testing")); } else { return (QLatin1String("Debian stable")); } } else { return PLATFORM_UNSPECIFIED; } } //this function maps the operating system to an OS value that is accepted by bugs.kde.org. //if the values change on the server side, they need to be updated here as well. QString SystemInformation::fetchOSBasicInformation() const { //krazy:excludeall=cpp //Get the base OS string (bugzillaOS) #if defined(Q_OS_LINUX) return QLatin1String("Linux"); #elif defined(Q_OS_FREEBSD) return QLatin1String("FreeBSD"); #elif defined(Q_OS_NETBSD) return QLatin1String("NetBSD"); #elif defined(Q_OS_OPENBSD) return QLatin1String("OpenBSD"); #elif defined(Q_OS_AIX) return QLatin1String("AIX"); #elif defined(Q_OS_HPUX) return QLatin1String("HP-UX"); #elif defined(Q_OS_IRIX) return QLatin1String("IRIX"); #elif defined(Q_OS_OSF) return QLatin1String("Tru64"); #elif defined(Q_OS_SOLARIS) return QLatin1String("Solaris"); #elif defined(Q_OS_CYGWIN) return QLatin1String("Cygwin"); #elif defined(Q_OS_DARWIN) return QLatin1String("OS X"); #elif defined(Q_OS_WIN32) return QLatin1String("MS Windows"); #else return OS_UNSPECIFIED; #endif } QString SystemInformation::fetchOSDetailInformation() const { //Get complete OS string (and fallback to base string) QString operatingSystem = m_bugzillaOperatingSystem; -#ifdef HAVE_UNAME +#if HAVE_UNAME struct utsname buf; if (uname(&buf) == -1) { qCDebug(DRKONQI_LOG) << "call to uname failed" << errno; } else { operatingSystem = QString::fromLocal8Bit(buf.sysname) + QLatin1Char(' ') + QString::fromLocal8Bit(buf.release) + QLatin1Char(' ') + QString::fromLocal8Bit(buf.machine); } #endif return operatingSystem; } QString SystemInformation::fetchOSReleaseInformation() const { QFile data(QStringLiteral("/etc/os-release")); if (!data.open(QIODevice::ReadOnly | QIODevice::Text)) { return QString(); } QMap distroInfos; QTextStream in(&data); while (!in.atEnd()) { const QString line = in.readLine(); // its format is one simple NAME=VALUE per line // don't use QString.split() here since its value might contain '='' const int index = line.indexOf(QLatin1Char('=')); if ( index != -1 ) { const QString key = line.left(index); const QString value = line.mid(index+1); distroInfos.insert(key, value); } } // the PRETTY_NAME entry should be the most appropriate one, // but I could be wrong. const QString prettyName = distroInfos.value(QStringLiteral("PRETTY_NAME"), QStringLiteral("Linux")); return prettyName; } QString SystemInformation::operatingSystem() const { return m_operatingSystem; } QString SystemInformation::bugzillaOperatingSystem() const { return m_bugzillaOperatingSystem; } QString SystemInformation::bugzillaPlatform() const { return m_bugzillaPlatform; } void SystemInformation::setBugzillaPlatform(const QString & platform) { m_bugzillaPlatform = platform; } QString SystemInformation::lsbRelease() const { return m_lsbRelease; } bool SystemInformation::compiledSources() const { return m_compiledSources; } void SystemInformation::setCompiledSources(bool compiled) { m_compiledSources = compiled; } QString SystemInformation::qtVersion() const { return QString::fromLatin1(qVersion()); } QString SystemInformation::frameworksVersion() const { return KCoreAddons::versionString(); }