Commit 3358faa8 authored by Volker Krause's avatar Volker Krause
Browse files

Make use of Bugzilla products specified by the crashed application

KAboutData::productName already existed for this, we just weren't using
it for DrKonqi yet.

See also frameworks/kcrash!16.
parent 3c48c539
......@@ -31,6 +31,17 @@ ProductMapping::ProductMapping(const CrashedApplication *crashedApp, BugzillaMan
m_bugzillaVersionString = QStringLiteral("unspecified");
m_relatedBugzillaProducts = QStringList() << m_bugzillaProduct;
if (!crashedApp->productName().isEmpty()) {
const auto l = crashedApp->productName().split(QLatin1Char('/'), Qt::SkipEmptyParts);
if (l.size() == 2) {
m_bugzillaProduct = l[0];
m_bugzillaComponent = l[1];
} else {
m_bugzillaProduct = crashedApp->productName();
}
m_hasExternallyProvidedProductName = true;
}
map(crashedApp->fakeExecutableBaseName());
// Get valid versions
......@@ -52,6 +63,10 @@ void ProductMapping::mapUsingInternalFile(const QString &appName)
KConfig mappingsFile(QString::fromLatin1("mappings"), KConfig::NoGlobals, QStandardPaths::AppDataLocation);
const KConfigGroup mappings = mappingsFile.group("Mappings");
if (mappings.hasKey(appName)) {
if (m_hasExternallyProvidedProductName) {
qCWarning(DRKONQI_LOG) << "Mapping found despite product information being provided by the application. Consider removing the mapping entry"
<< appName;
}
QString mappingString = mappings.readEntry(appName);
if (!mappingString.isEmpty()) {
QStringList list = mappingString.split(QLatin1Char('|'), Qt::SkipEmptyParts);
......
......@@ -61,6 +61,7 @@ private:
bool m_bugzillaProductDisabled;
bool m_bugzillaVersionDisabled;
bool m_hasExternallyProvidedProductName = false;
QMetaObject::Connection m_productInfoErrorConnection;
};
......
......@@ -29,6 +29,7 @@ CrashedApplication::CrashedApplication(int pid,
const QString &version,
const BugReportAddress &reportAddress,
const QString &name,
const QString &productName,
const QDateTime &datetime,
bool restarted,
bool hasDeletedFiles,
......@@ -43,6 +44,7 @@ CrashedApplication::CrashedApplication(int pid,
, m_fakeBaseName(fakeBaseName)
, m_version(version)
, m_reportAddress(reportAddress)
, m_productName(productName)
, m_restarted(restarted)
, m_thread(thread)
, m_datetime(datetime)
......@@ -82,6 +84,11 @@ BugReportAddress CrashedApplication::bugReportAddress() const
return m_reportAddress;
}
QString CrashedApplication::productName() const
{
return m_productName;
}
int CrashedApplication::pid() const
{
return m_pid;
......
......@@ -25,6 +25,7 @@ public:
const QString &version,
const BugReportAddress &reportAddress,
const QString &name = QString(),
const QString &productName = QString(),
const QDateTime &datetime = QDateTime::currentDateTime(),
bool restarted = false,
bool hasDeletedFiles = false,
......@@ -53,6 +54,9 @@ public:
/** Returns the address where the bug report for this application should go */
BugReportAddress bugReportAddress() const;
/** Bugzialla product name, if the crashed application has explicitly specified that. */
QString productName() const;
/** Returns the pid of the crashed program */
int pid() const;
......@@ -85,6 +89,7 @@ protected:
QString m_fakeBaseName;
QString m_version;
BugReportAddress m_reportAddress;
QString m_productName;
bool m_restarted;
int m_thread;
QDateTime m_datetime;
......
......@@ -265,6 +265,11 @@ void DrKonqi::setProgramName(const QString &programName)
instance()->m_programName = programName;
}
void DrKonqi::setProductName(const QString &productName)
{
instance()->m_productName = productName;
}
void DrKonqi::setPid(int pid)
{
instance()->m_pid = pid;
......@@ -330,6 +335,11 @@ const QString &DrKonqi::programName()
return instance()->m_programName;
}
const QString &DrKonqi::productName()
{
return instance()->m_productName;
}
int DrKonqi::pid()
{
return instance()->m_pid;
......
......@@ -32,6 +32,7 @@ public:
static void setAppVersion(const QString &appVersion);
static void setBugAddress(const QString &bugAddress);
static void setProgramName(const QString &programName);
static void setProductName(const QString &productName);
static void setPid(int pid);
static void setKdeinit(bool kdeinit);
static void setSafer(bool safer);
......@@ -46,6 +47,7 @@ public:
static const QString &appVersion();
static const QString &bugAddress();
static const QString &programName();
static const QString &productName();
static int pid();
static bool isKdeinit();
static bool isSafer();
......@@ -70,6 +72,7 @@ private:
QString m_appVersion;
QString m_bugAddress;
QString m_programName;
QString m_productName;
int m_pid;
bool m_kdeinit;
bool m_safer;
......
......@@ -159,6 +159,7 @@ CrashedApplication *KCrashBackend::constructCrashedApplication()
DrKonqi::appVersion(),
BugReportAddress(DrKonqi::bugAddress()),
DrKonqi::programName(),
DrKonqi::productName(),
QDateTime::currentDateTime(),
DrKonqi::isRestarted(),
hasDeletedFiles,
......
......@@ -122,6 +122,7 @@ int main(int argc, char *argv[])
const QCommandLineOption appVersionOption(QStringLiteral("appversion"), i18nc("@info:shell", "The <version> of the program"), QStringLiteral("version"));
const QCommandLineOption bugAddressOption(QStringLiteral("bugaddress"), i18nc("@info:shell", "The bug <address> to use"), QStringLiteral("address"));
const QCommandLineOption programNameOption(QStringLiteral("programname"), i18nc("@info:shell", "Translated <name> of the program"), QStringLiteral("name"));
const QCommandLineOption productNameOption(QStringLiteral("productname"), i18nc("@info:shell", "Bugzilla product name"), QStringLiteral("name"));
const QCommandLineOption pidOption(QStringLiteral("pid"), i18nc("@info:shell", "The <PID> of the program"), QStringLiteral("pid"));
const QCommandLineOption startupIdOption(QStringLiteral("startupid"), i18nc("@info:shell", "Startup <ID> of the program"), QStringLiteral("id"));
const QCommandLineOption kdeinitOption(QStringLiteral("kdeinit"), i18nc("@info:shell", "The program was started by kdeinit"));
......@@ -140,6 +141,7 @@ int main(int argc, char *argv[])
appVersionOption,
bugAddressOption,
programNameOption,
productNameOption,
pidOption,
startupIdOption,
kdeinitOption,
......@@ -176,6 +178,7 @@ int main(int argc, char *argv[])
DrKonqi::setAppVersion(parser.value(appVersionOption));
DrKonqi::setBugAddress(parser.value(bugAddressOption));
DrKonqi::setProgramName(parser.value(programNameOption));
DrKonqi::setProductName(parser.value(productNameOption));
DrKonqi::setPid(parser.value(pidOption).toInt());
DrKonqi::setKdeinit(parser.isSet(kdeinitOption));
DrKonqi::setSafer(parser.isSet(saferOption));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment