File indexing completed on 2024-04-21 16:12:17

0001 /*
0002     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003     SPDX-FileCopyrightText: 2019-2022 Harald Sitter <sitter@kde.org>
0004 */
0005 
0006 #pragma once
0007 
0008 #include <QObject>
0009 #include <QSocketNotifier>
0010 
0011 #include <systemd/sd-journal.h>
0012 
0013 #include "memory.h"
0014 
0015 class Coredump;
0016 class CoredumpWatcher : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit CoredumpWatcher(std::unique_ptr<sd_journal> context_, QString bootId_, const QString &instance_, QObject *parent = nullptr);
0021 
0022     void start();
0023 
0024 Q_SIGNALS:
0025     void finished();
0026     void error(const QString &msg);
0027     void newDump(const Coredump &dump);
0028     /// Emitted when the current iteration has reached the log end. Roughly meaning that it has loaded all past entries.
0029     void atLogEnd();
0030 
0031 private:
0032     void processLog();
0033     void errnoError(const QString &msg, int err);
0034 
0035     const std::unique_ptr<sd_journal> context = nullptr;
0036     std::unique_ptr<QSocketNotifier> notifier = nullptr;
0037     const QString bootId;
0038     const QString instance;
0039     const QString instanceFilter; // systemd-coredump@%1 instance name
0040 };