2022-12-03 06:47:32 +02:00
|
|
|
/* This file is part of the KDE libraries
|
|
|
|
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License version 2, as published by the Free Software Foundation.
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
2015-10-14 22:38:09 +03:00
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
#ifndef KLAUNCHER_ADAPTOR_H
|
|
|
|
#define KLAUNCHER_ADAPTOR_H
|
|
|
|
|
|
|
|
#include "kstartupinfo.h"
|
2023-08-19 19:25:01 +03:00
|
|
|
#include "kservice.h"
|
2022-12-03 06:47:32 +02:00
|
|
|
|
|
|
|
#include <QDBusAbstractAdaptor>
|
|
|
|
#include <QProcess>
|
2023-08-19 19:25:01 +03:00
|
|
|
#include <QTimer>
|
2022-12-03 06:47:32 +02:00
|
|
|
|
2022-12-10 09:01:48 +02:00
|
|
|
// #define KLAUNCHER_DEBUG
|
|
|
|
|
2023-08-19 19:25:01 +03:00
|
|
|
class KLauncherProcess : public QProcess
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit KLauncherProcess(QObject *parent);
|
2024-05-11 02:15:42 +03:00
|
|
|
~KLauncherProcess();
|
2023-08-19 19:25:01 +03:00
|
|
|
|
2024-05-11 02:15:42 +03:00
|
|
|
void setupStartup(const QString &appexe, const KService::Ptr kservice, const qint64 timeout,
|
|
|
|
const bool temp, const QStringList &args);
|
2023-08-19 19:25:01 +03:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void slotProcessStateChanged(QProcess::ProcessState state);
|
|
|
|
void slotStartupRemoved(const KStartupInfoId &id, const KStartupInfoData &data);
|
|
|
|
void slotStartupTimeout();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(KLauncherProcess);
|
|
|
|
|
|
|
|
void sendSIStart(const qint64 timeout);
|
|
|
|
void sendSIChange();
|
|
|
|
void sendSIFinish();
|
|
|
|
|
|
|
|
KStartupInfo* m_kstartupinfo;
|
|
|
|
QTimer* m_startuptimer;
|
|
|
|
KStartupInfoId m_kstartupinfoid;
|
|
|
|
KStartupInfoData m_kstartupinfodata;
|
2024-05-11 02:15:42 +03:00
|
|
|
bool m_temp;
|
|
|
|
QStringList m_args;
|
2023-08-19 19:25:01 +03:00
|
|
|
};
|
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
// Adaptor class for interface org.kde.KLauncher
|
2014-11-13 01:04:59 +02:00
|
|
|
class KLauncherAdaptor: public QDBusAbstractAdaptor
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.KLauncher")
|
|
|
|
public:
|
|
|
|
KLauncherAdaptor(QObject *parent);
|
2022-12-03 06:47:32 +02:00
|
|
|
~KLauncherAdaptor();
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-12-10 08:53:45 +02:00
|
|
|
public:
|
|
|
|
public Q_SLOTS:
|
2024-05-09 00:55:08 +03:00
|
|
|
// used by plasma-desktop
|
2022-12-10 08:53:45 +02:00
|
|
|
void autoStart(int phase);
|
|
|
|
|
2024-05-09 00:55:08 +03:00
|
|
|
// used by plasma-desktop and klauncher itself
|
2024-05-12 05:02:58 +03:00
|
|
|
void exec_blind(const QString &name, const QStringList &args);
|
2023-06-29 00:16:32 +03:00
|
|
|
void cleanup();
|
2022-12-10 08:53:45 +02:00
|
|
|
|
|
|
|
// used by KToolInvocation
|
|
|
|
void setLaunchEnv(const QString &name, const QString &value);
|
2024-05-11 02:15:42 +03:00
|
|
|
bool start_program(const QString &app, const QStringList &args, const QStringList &envs,
|
|
|
|
quint64 window, bool temp);
|
|
|
|
bool start_program_with_workdir(const QString &app, const QStringList &args,
|
|
|
|
const QStringList &envs, quint64 window, bool temp,
|
|
|
|
const QString &workdir);
|
|
|
|
bool start_service_by_storage_id(const QString &serviceName, const QStringList &urls,
|
|
|
|
const QStringList &envs, quint64 window, bool temp);
|
|
|
|
bool start_service_by_url(const QString &url, const QStringList &envs, quint64 window,
|
|
|
|
bool temp);
|
2022-12-03 06:47:32 +02:00
|
|
|
|
2022-12-10 09:01:48 +02:00
|
|
|
// for debugging
|
|
|
|
#ifdef KLAUNCHER_DEBUG
|
|
|
|
QStringList environment() const;
|
|
|
|
#endif
|
|
|
|
|
2022-12-10 08:53:45 +02:00
|
|
|
Q_SIGNALS:
|
2014-11-13 01:04:59 +02:00
|
|
|
void autoStart0Done();
|
|
|
|
void autoStart1Done();
|
|
|
|
void autoStart2Done();
|
2022-12-03 06:47:32 +02:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void slotProcessFinished(int exitcode);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString findExe(const QString &app) const;
|
2024-05-11 02:15:42 +03:00
|
|
|
bool startProgram(const QString &app, const QStringList &args, const QStringList &envs,
|
|
|
|
const quint64 window, const bool temp, const QString &workdir, qint64 &pid,
|
|
|
|
const qint64 timeout, const KService::Ptr kservice = KService::Ptr(nullptr));
|
2022-12-03 06:47:32 +02:00
|
|
|
|
2022-12-05 00:39:08 +02:00
|
|
|
QProcessEnvironment m_environment;
|
2023-08-19 01:16:26 +03:00
|
|
|
qint64 m_startuptimeout;
|
2023-08-19 19:25:01 +03:00
|
|
|
QList<KLauncherProcess*> m_processes;
|
2022-12-03 06:47:32 +02:00
|
|
|
QStringList m_autostart;
|
2014-11-13 01:04:59 +02:00
|
|
|
};
|
|
|
|
|
2022-12-03 06:47:32 +02:00
|
|
|
#endif // KLAUNCHER_ADAPTOR_H
|