Warning, file /plasma/drkonqi/src/debugpackageinstaller.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /******************************************************************* 0002 * debugpackageinstaller.cpp 0003 * SPDX-FileCopyrightText: 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 * 0007 ******************************************************************/ 0008 0009 #include <config-drkonqi.h> 0010 0011 #include "debugpackageinstaller.h" 0012 0013 #include <KLocalizedString> 0014 #include <KProcess> 0015 #include <QProgressDialog> 0016 #include <QStandardPaths> 0017 0018 #include "crashedapplication.h" 0019 #include "drkonqi.h" 0020 0021 DebugPackageInstaller::DebugPackageInstaller(QObject *parent) 0022 : QObject(parent) 0023 { 0024 m_executablePath = QStandardPaths::findExecutable(QString::fromLatin1(DEBUG_PACKAGE_INSTALLER_NAME)); // defined from CMakeLists.txt 0025 } 0026 0027 bool DebugPackageInstaller::canInstallDebugPackages() const 0028 { 0029 return !m_executablePath.isEmpty(); 0030 } 0031 0032 void DebugPackageInstaller::setMissingLibraries(const QStringList &libraries) 0033 { 0034 m_missingLibraries = libraries; 0035 } 0036 0037 void DebugPackageInstaller::installDebugPackages() 0038 { 0039 Q_ASSERT(canInstallDebugPackages()); 0040 0041 if (!m_installerProcess) { 0042 // Run process 0043 m_installerProcess = new KProcess(this); 0044 connect(m_installerProcess, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished), this, &DebugPackageInstaller::processFinished); 0045 0046 *m_installerProcess << m_executablePath << DrKonqi::crashedApplication()->executable().absoluteFilePath() << m_missingLibraries; 0047 m_installerProcess->start(); 0048 0049 // Show dialog 0050 m_progressDialog = new QProgressDialog(i18nc("@info:progress", 0051 "Requesting installation of missing " 0052 "debug symbols packages..."), 0053 i18n("Cancel"), 0054 0, 0055 0, 0056 qobject_cast<QWidget *>(parent())); 0057 connect(m_progressDialog, &QProgressDialog::canceled, this, &DebugPackageInstaller::progressDialogCanceled); 0058 m_progressDialog->setWindowTitle(i18nc("@title:window", "Missing debug symbols")); 0059 m_progressDialog->show(); 0060 } 0061 } 0062 0063 void DebugPackageInstaller::progressDialogCanceled() 0064 { 0065 m_progressDialog->deleteLater(); 0066 m_progressDialog = nullptr; 0067 0068 if (m_installerProcess) { 0069 if (m_installerProcess->state() == QProcess::Running) { 0070 disconnect(m_installerProcess, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished), this, &DebugPackageInstaller::processFinished); 0071 m_installerProcess->kill(); 0072 disconnect(m_installerProcess, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished), m_installerProcess, &KProcess::deleteLater); 0073 } 0074 m_installerProcess = nullptr; 0075 } 0076 0077 Q_EMIT canceled(); 0078 } 0079 0080 void DebugPackageInstaller::processFinished(int exitCode, QProcess::ExitStatus) 0081 { 0082 switch (exitCode) { 0083 case ResultInstalled: { 0084 Q_EMIT packagesInstalled(); 0085 break; 0086 } 0087 case ResultSymbolsNotFound: { 0088 Q_EMIT error(i18nc("@info", "Could not find debug symbol packages for this application.")); 0089 break; 0090 } 0091 case ResultCanceled: { 0092 Q_EMIT canceled(); 0093 break; 0094 } 0095 case ResultError: 0096 default: { 0097 Q_EMIT error(i18nc("@info", 0098 "An error was encountered during the installation " 0099 "of the debug symbol packages.")); 0100 break; 0101 } 0102 } 0103 0104 m_progressDialog->reject(); 0105 0106 delete m_progressDialog; 0107 m_progressDialog = nullptr; 0108 0109 delete m_installerProcess; 0110 m_installerProcess = nullptr; 0111 }