File indexing completed on 2024-05-19 05:39:09
0001 /* 0002 ksmserver - the KDE session management server 0003 0004 SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org> 0005 0006 SPDX-License-Identifier: MIT 0007 */ 0008 0009 #pragma once 0010 0011 #include <KJob> 0012 #include <QEventLoopLocker> 0013 #include <QObject> 0014 #include <QProcessEnvironment> 0015 0016 #include "autostart.h" 0017 0018 class Startup : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 Startup(QObject *parent); 0023 void upAndRunning(const QString &msg); 0024 void finishStartup(); 0025 0026 static Startup *self() 0027 { 0028 Q_ASSERT(s_self); 0029 return s_self; 0030 } 0031 0032 bool startDetached(QProcess *process); 0033 0034 public Q_SLOTS: 0035 // alternatively we could drop this and have a rule that we /always/ launch everything through klauncher 0036 // need resolution from frameworks discussion on kdeinit 0037 void updateLaunchEnv(const QString &key, const QString &value); 0038 0039 private: 0040 void autoStart(int phase); 0041 0042 QList<QProcess *> m_processes; 0043 std::unique_ptr<QEventLoopLocker> m_lock; 0044 static Startup *s_self; 0045 }; 0046 0047 class SleepJob : public KJob 0048 { 0049 Q_OBJECT 0050 public: 0051 SleepJob(); 0052 void start() override; 0053 }; 0054 0055 class KCMInitJob : public KJob 0056 { 0057 Q_OBJECT 0058 public: 0059 KCMInitJob(); 0060 void start() override; 0061 }; 0062 0063 class AutoStartAppsJob : public KJob 0064 { 0065 Q_OBJECT 0066 public: 0067 AutoStartAppsJob(const AutoStart &autoStart, int phase); 0068 void start() override; 0069 0070 private: 0071 AutoStart m_autoStart; 0072 }; 0073 0074 /** 0075 * Launches a process, and waits for the process to start 0076 */ 0077 class StartProcessJob : public KJob 0078 { 0079 Q_OBJECT 0080 public: 0081 StartProcessJob(const QString &process, const QStringList &args, const QProcessEnvironment &additionalEnv = QProcessEnvironment()); 0082 void start() override; 0083 0084 private: 0085 QProcess *m_process; 0086 }; 0087 0088 /** 0089 * Launches a process, and waits for the service to appear on the session bus 0090 */ 0091 class StartServiceJob : public KJob 0092 { 0093 Q_OBJECT 0094 public: 0095 StartServiceJob(const QString &process, 0096 const QStringList &args, 0097 const QString &serviceId, 0098 const QProcessEnvironment &additionalEnv = QProcessEnvironment()); 0099 void start() override; 0100 0101 private: 0102 QProcess *m_process; 0103 const QString m_serviceId; 0104 const QProcessEnvironment m_additionalEnv; 0105 }; 0106 0107 class RestoreSessionJob : public KJob 0108 { 0109 Q_OBJECT 0110 public: 0111 RestoreSessionJob(); 0112 void start() override; 0113 0114 private: 0115 };