File indexing completed on 2022-11-29 20:01:35

0001 /*
0002     SPDX-FileCopyrightText: 2009 George Kiagiadakis <gkiagia@users.sourceforge.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #ifndef DEBUGGERLAUNCHERS_H
0007 #define DEBUGGERLAUNCHERS_H
0008 
0009 #include <QDBusAbstractAdaptor>
0010 
0011 #include "debugger.h"
0012 #include "debuggermanager.h"
0013 
0014 class DetachedProcessMonitor;
0015 
0016 class AbstractDebuggerLauncher : public QObject
0017 {
0018     Q_OBJECT
0019     Q_PROPERTY(QString name READ name CONSTANT)
0020 public:
0021     explicit AbstractDebuggerLauncher(QObject *parent = nullptr)
0022         : QObject(parent)
0023     {
0024     }
0025     virtual QString name() const = 0;
0026 
0027 public Q_SLOTS:
0028     virtual void start() = 0;
0029 
0030 Q_SIGNALS:
0031     void starting();
0032     void finished();
0033     void invalidated();
0034 };
0035 
0036 class DefaultDebuggerLauncher : public AbstractDebuggerLauncher
0037 {
0038     Q_OBJECT
0039 public:
0040     explicit DefaultDebuggerLauncher(const Debugger &debugger, DebuggerManager *parent = nullptr);
0041     QString name() const override;
0042 
0043 public Q_SLOTS:
0044     void start() override;
0045 
0046 private Q_SLOTS:
0047     void onProcessFinished();
0048 
0049 private:
0050     const Debugger m_debugger;
0051     DetachedProcessMonitor *m_monitor = nullptr;
0052 };
0053 
0054 class DBusInterfaceAdaptor;
0055 
0056 /** This class handles the old drkonqi dbus interface used by kdevelop */
0057 class DBusInterfaceLauncher : public AbstractDebuggerLauncher
0058 {
0059     Q_OBJECT
0060 public:
0061     explicit DBusInterfaceLauncher(const QString &name, qint64 pid, DBusInterfaceAdaptor *parent = nullptr);
0062     QString name() const override;
0063 
0064 public Q_SLOTS:
0065     void start() override;
0066 
0067 private:
0068     QString m_name;
0069     qint64 m_pid;
0070 };
0071 
0072 class DBusInterfaceAdaptor : public QDBusAbstractAdaptor
0073 {
0074     Q_OBJECT
0075     Q_CLASSINFO("D-Bus Interface", "org.kde.drkonqi")
0076 public:
0077     explicit DBusInterfaceAdaptor(DebuggerManager *parent);
0078 
0079 public Q_SLOTS:
0080     int pid();
0081     Q_NOREPLY void registerDebuggingApplication(const QString &name, qint64 pid = 0);
0082     Q_NOREPLY void debuggingFinished(const QString &name);
0083     Q_NOREPLY void debuggerClosed(const QString &name);
0084 
0085 Q_SIGNALS:
0086     void acceptDebuggingApplication(const QString &name);
0087 
0088 private:
0089     QHash<QString, DBusInterfaceLauncher *> m_launchers;
0090 };
0091 
0092 #endif // DEBUGGERLAUNCHERS_H