File indexing completed on 2023-09-24 09:32:07

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 <QObject>
0007 
0008 class Coredump;
0009 class Patient : public QObject
0010 {
0011     Q_OBJECT
0012 
0013 #define MEMBER_PROPERTY(type, name)                                                                                                                            \
0014     Q_PROPERTY(type name MEMBER m_##name NOTIFY changed)                                                                                                       \
0015     type m_##name
0016 
0017     // NB: these all share the same changed signal but its only ever emitted once.
0018     // They are effectively CONSTANT, but not really because they change during construction.
0019     MEMBER_PROPERTY(int, signal) = -1;
0020     MEMBER_PROPERTY(QString, appName);
0021     MEMBER_PROPERTY(pid_t, pid) = 0;
0022     MEMBER_PROPERTY(bool, canDebug) = false;
0023     MEMBER_PROPERTY(time_t, timestamp) = 0;
0024 #undef MEMBER_PROPERTY
0025     Q_PROPERTY(QString dateTime READ dateTime NOTIFY changed)
0026     Q_PROPERTY(QString iconName READ iconName CONSTANT)
0027 public:
0028     explicit Patient(const Coredump &dump);
0029 
0030     QStringList coredumpctlArguments(const QString &command) const;
0031 
0032     Q_INVOKABLE void debug() const;
0033     QString dateTime() const;
0034     QString iconName() const;
0035 
0036 Q_SIGNALS:
0037     void changed();
0038 
0039 private:
0040     const QByteArray m_coredumpExe;
0041     const QByteArray m_coredumpCom;
0042     QString m_iconName;
0043 };
0044 
0045 Q_DECLARE_METATYPE(time_t)
0046 Q_DECLARE_METATYPE(pid_t)