File indexing completed on 2024-11-10 07:57:22
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2020-2022 Harald Sitter <sitter@kde.org> 0003 0004 #pragma once 0005 0006 #include <QFileInfo> 0007 #include <QObject> 0008 0009 #include <automaticcoredumpexcavator.h> 0010 0011 class Coredump; 0012 class Patient : public QObject 0013 { 0014 Q_OBJECT 0015 0016 QString m_origCoreFilename; 0017 QFileInfo m_coreFileInfo; 0018 0019 #define MEMBER_PROPERTY(type, name) \ 0020 Q_PROPERTY(type name MEMBER m_##name NOTIFY changed) \ 0021 type m_##name 0022 0023 // NB: these all share the same changed signal but its only ever emitted once. 0024 // They are effectively CONSTANT, but not really because they change during construction. 0025 MEMBER_PROPERTY(int, signal) = -1; 0026 MEMBER_PROPERTY(QString, appName); 0027 MEMBER_PROPERTY(pid_t, pid) = 0; 0028 MEMBER_PROPERTY(time_t, timestamp) = 0; 0029 #undef MEMBER_PROPERTY 0030 Q_PROPERTY(bool canDebug READ canDebug NOTIFY changed) 0031 Q_PROPERTY(QString dateTime READ dateTime NOTIFY changed) 0032 Q_PROPERTY(QString iconName READ iconName CONSTANT) 0033 public: 0034 explicit Patient(const Coredump &dump); 0035 0036 QStringList coredumpctlArguments(const QString &command) const; 0037 0038 bool canDebug(); 0039 Q_INVOKABLE void debug(); 0040 QString dateTime() const; 0041 QString iconName() const; 0042 0043 Q_SIGNALS: 0044 void changed(); 0045 0046 private Q_SLOTS: 0047 void launchDebugger(); 0048 0049 private: 0050 const QByteArray m_coredumpExe; 0051 const QByteArray m_coredumpCom; 0052 QString m_iconName; 0053 std::unique_ptr<AutomaticCoredumpExcavator> m_excavator; 0054 }; 0055 0056 Q_DECLARE_METATYPE(time_t) 0057 Q_DECLARE_METATYPE(pid_t)