2022-05-15 12:10:42 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
|
|
|
*
|
|
|
|
* Author: weizhixiang <weizhixiang@uniontech.com>
|
|
|
|
*
|
|
|
|
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STARTMANAGER_H
|
|
|
|
#define STARTMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
class AppLaunchContext;
|
|
|
|
class StartManagerDBusHandler;
|
|
|
|
class DesktopInfo;
|
|
|
|
class QProcess;
|
|
|
|
class QFileSystemWatcher;
|
2022-05-19 13:13:55 +08:00
|
|
|
class ApplicationManager;
|
2022-05-15 12:10:42 +08:00
|
|
|
|
|
|
|
class StartManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit StartManager(QObject *parent = nullptr);
|
|
|
|
|
2022-11-23 14:36:04 +08:00
|
|
|
bool addAutostart(const QString &desktop);
|
|
|
|
bool removeAutostart(const QString &desktop);
|
2022-05-15 12:10:42 +08:00
|
|
|
QStringList autostartList();
|
2022-11-23 14:36:04 +08:00
|
|
|
bool isAutostart(const QString &desktop);
|
2022-05-15 12:10:42 +08:00
|
|
|
bool isMemSufficient();
|
2022-12-06 11:18:45 +08:00
|
|
|
bool launchApp(const QString &desktopFile);
|
|
|
|
bool launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
|
|
|
bool launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp);
|
|
|
|
bool launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
|
|
|
bool runCommand(QString exe, QStringList args);
|
|
|
|
bool runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
2022-05-15 12:10:42 +08:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2022-11-23 14:36:04 +08:00
|
|
|
void autostartChanged(const QString &status, const QString &fileName);
|
2022-05-15 12:10:42 +08:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void onAutoStartupPathChange(const QString &dirPath);
|
|
|
|
|
|
|
|
private:
|
2022-11-23 14:36:04 +08:00
|
|
|
bool setAutostart(const QString &fileName, const bool value);
|
2022-11-04 14:22:45 +08:00
|
|
|
bool doLaunchAppWithOptions(const QString &desktopFile);
|
2022-05-15 12:10:42 +08:00
|
|
|
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
|
|
|
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
|
|
|
|
bool doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
|
|
|
void waitCmd(DesktopInfo *info, QProcess *process, QString cmdName);
|
|
|
|
bool shouldUseProxy(QString appId);
|
|
|
|
bool shouldDisableScaling(QString appId);
|
|
|
|
void loadSysMemLimitConfig();
|
|
|
|
QStringList getDefaultTerminal();
|
|
|
|
void listenAutostartFileEvents();
|
|
|
|
void startAutostartProgram();
|
|
|
|
QStringList getAutostartList();
|
2022-11-24 17:29:29 +08:00
|
|
|
QMap<QString, QString> getDesktopToAutostartMap();
|
|
|
|
void setIsDBusCalled(const bool state);
|
|
|
|
bool isDBusCalled() const;
|
2022-05-15 12:10:42 +08:00
|
|
|
|
|
|
|
uint64_t minMemAvail;
|
|
|
|
uint64_t maxSwapUsed;
|
|
|
|
StartManagerDBusHandler *dbusHandler;
|
2022-11-23 14:36:04 +08:00
|
|
|
QStringList m_autostartFiles;
|
2022-11-24 17:29:29 +08:00
|
|
|
QMap<QString, QString> m_desktopDirToAutostartDirMap; // Desktop全路径和自启动目录
|
|
|
|
QFileSystemWatcher *m_autostartFileWatcher;
|
|
|
|
bool m_isDBusCalled;
|
2022-05-15 12:10:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STARTMANAGER_H
|