drkonqi: open the crashed application bug report address as is

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-06 23:18:13 +03:00
parent 88db934aa7
commit 91abf9d329
6 changed files with 1 additions and 194 deletions

View file

@ -21,7 +21,6 @@ set(drkonqi_SRCS
drkonqi.cpp drkonqi.cpp
drkonqibackends.cpp drkonqibackends.cpp
detachedprocessmonitor.cpp detachedprocessmonitor.cpp
systeminformation.cpp
crashedapplication.cpp crashedapplication.cpp
debugger.cpp debugger.cpp
debuggerlaunchers.cpp debuggerlaunchers.cpp

View file

@ -54,19 +54,16 @@
#include <KDebug> #include <KDebug>
#include <KLocalizedString> #include <KLocalizedString>
#include "systeminformation.h"
#include "crashedapplication.h" #include "crashedapplication.h"
#include "drkonqibackends.h" #include "drkonqibackends.h"
DrKonqi::DrKonqi() DrKonqi::DrKonqi()
{ {
m_backend = new KCrashBackend(); m_backend = new KCrashBackend();
m_systemInformation = new SystemInformation();
} }
DrKonqi::~DrKonqi() DrKonqi::~DrKonqi()
{ {
delete m_systemInformation;
delete m_backend; delete m_backend;
} }
@ -120,12 +117,6 @@ void DrKonqi::cleanup()
delete instance(); delete instance();
} }
//static
SystemInformation *DrKonqi::systemInformation()
{
return instance()->m_systemInformation;
}
//static //static
DebuggerManager* DrKonqi::debuggerManager() DebuggerManager* DrKonqi::debuggerManager()
{ {

View file

@ -20,7 +20,6 @@
#include <QString> #include <QString>
#include <QWidget> #include <QWidget>
class SystemInformation;
class DebuggerManager; class DebuggerManager;
class CrashedApplication; class CrashedApplication;
class AbstractDrKonqiBackend; class AbstractDrKonqiBackend;
@ -31,7 +30,6 @@ public:
static bool init(); static bool init();
static void cleanup(); static void cleanup();
static SystemInformation *systemInformation();
static DebuggerManager *debuggerManager(); static DebuggerManager *debuggerManager();
static CrashedApplication *crashedApplication(); static CrashedApplication *crashedApplication();
@ -42,7 +40,6 @@ private:
~DrKonqi(); ~DrKonqi();
static DrKonqi *instance(); static DrKonqi *instance();
SystemInformation *m_systemInformation;
AbstractDrKonqiBackend *m_backend; AbstractDrKonqiBackend *m_backend;
}; };

View file

@ -37,7 +37,6 @@
#include "debuggermanager.h" #include "debuggermanager.h"
#include "debuggerlaunchers.h" #include "debuggerlaunchers.h"
#include "drkonqi_globals.h" #include "drkonqi_globals.h"
#include "systeminformation.h"
DrKonqiDialog::DrKonqiDialog(QWidget * parent) : DrKonqiDialog::DrKonqiDialog(QWidget * parent) :
KDialog(parent), KDialog(parent),
@ -234,27 +233,7 @@ void DrKonqiDialog::enableDebugMenu(bool debuggerRunning)
void DrKonqiDialog::startBugReportAssistant() void DrKonqiDialog::startBugReportAssistant()
{ {
const CrashedApplication *crashedApp = DrKonqi::crashedApplication(); const CrashedApplication *crashedApp = DrKonqi::crashedApplication();
QString appReportAddress = crashedApp->bugReportAddress(); KToolInvocation::invokeBrowser(crashedApp->bugReportAddress());
SystemInformation *sysinfo = new SystemInformation(this);
QString backtrace = DrKonqi::debuggerManager()->backtraceGenerator()->parser()->parsedBacktrace();
QString query;
// KDE applications use the email address by default
if (appReportAddress == QLatin1String(KDE_BUG_REPORT_EMAIL)) {
// black magic - report is done in Markdown syntax with new lines preserved
// but invokeBrowser() can call external browser and at this point KDE
// application can not be trused not to crash again (konqueror, rekonq, etc.).
query = QString("%1/new").arg(KDE_BUG_REPORT_URL);
query.append(QString("?title=%1 %2 %3").arg(crashedApp->name(), crashedApp->version(),
crashedApp->signalName()));
query.append(QString("&body=%1\nOS: %2\nRelease: %3\nKDE: %4\nKatie: %5\n%6").arg(
QUrl::toPercentEncoding("## Platform"), sysinfo->system(),
sysinfo->release(), sysinfo->kdeVersion(), sysinfo->qtVersion(),
QUrl::toPercentEncoding("## Backtrace\nPlease, copy-paste it from the DrKonqi window\n")));
} else {
query = QString(appReportAddress);
}
KToolInvocation::invokeBrowser(query);
} }
void DrKonqiDialog::applicationRestarted(bool success) void DrKonqiDialog::applicationRestarted(bool success)

View file

@ -1,113 +0,0 @@
/*******************************************************************
* systeminformation.cpp
* Copyright 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
* Copyright 2009 George Kiagiadakis <gkiagia@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*
******************************************************************/
#include <config-drkonqi.h>
#include "systeminformation.h"
#include <sys/utsname.h>
#include <string.h>
#include <errno.h>
#include <QtCore/QFile>
#include <KDebug>
#include <kdeversion.h>
SystemInformation::SystemInformation(QObject * parent)
: QObject(parent)
{
// NOTE: the relative order is important here
m_system = fetchOSDetailInformation();
m_release = fetchOSReleaseInformation();
}
SystemInformation::~SystemInformation()
{
}
QString SystemInformation::fetchOSDetailInformation() const
{
QString operatingSystem = "unspecified";
struct utsname buf;
if (::uname(&buf) == -1) {
kDebug() << "call to uname failed" << ::strerror(errno);
} else {
operatingSystem = QString::fromLocal8Bit(buf.sysname) + ' '
+ QString::fromLocal8Bit(buf.release) + ' '
+ QString::fromLocal8Bit(buf.machine);
}
return operatingSystem;
}
QString SystemInformation::fetchOSReleaseInformation() const
{
QFile data("/etc/os-release");
if (!data.open(QIODevice::ReadOnly | QIODevice::Text)) {
return QString();
}
QMap<QString,QString> 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('=');
if ( index != -1 ) {
const QString key = line.left(index);
QString value = line.mid(index+1);
value = value.trimmed();
if(value.startsWith("'") or value.startsWith("\"")) {
value.remove(0, 1);
}
if(value.endsWith("'") or value.endsWith("\"")) {
value.chop(1);
}
distroInfos.insert(key, value);
}
}
// the PRETTY_NAME entry should be the most appropriate one,
// but I could be wrong.
return distroInfos.value("PRETTY_NAME", "unspecified");
}
QString SystemInformation::system() const
{
return m_system;
}
QString SystemInformation::release() const
{
return m_release;
}
QString SystemInformation::kdeVersion() const
{
return KDE::versionString();
}
QString SystemInformation::qtVersion() const
{
return qVersion();
}

View file

@ -1,46 +0,0 @@
/*******************************************************************
* systeminformation.h
* Copyright 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
******************************************************************/
#ifndef SYSTEMINFORMATION__H
#define SYSTEMINFORMATION__H
#include <QtCore/QObject>
class SystemInformation: public QObject
{
Q_OBJECT
public:
explicit SystemInformation(QObject * parent = 0);
~SystemInformation();
QString system() const;
QString release() const;
QString kdeVersion() const;
QString qtVersion() const;
private:
QString fetchOSDetailInformation() const;
QString fetchOSReleaseInformation() const;
QString m_system;
QString m_release;
};
#endif