ukui-session-manager-4.0.0.1/ 0000755 0001750 0001750 00000000000 14565543367 014362 5 ustar feng feng ukui-session-manager-4.0.0.1/CMakeLists.txt 0000644 0001750 0001750 00000003372 14553704175 017120 0 ustar feng feng cmake_minimum_required(VERSION 3.1.0)
project(ukui-session-manager)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Handle the Qt rcc code generator automatically.
set(CMAKE_AUTORCC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 11)
include(GNUInstallDirs)
# Enable funcion names and line numbers even for release builds
add_definitions("-DQT_MESSAGELOGCONTEXT")
# Find the QtWidgets library
find_package(Qt5 COMPONENTS Widgets Core Multimedia X11Extras REQUIRED)
find_package(Qt5LinguistTools)
find_package(KF5IdleTime)
find_package(Qt5DBus)
find_package(KF5CoreAddons)
find_package(KF5Config)
find_package(KF5WindowSystem)
# For debug: cmake -DCMAKE_BUILD_TYPE=debug
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
# i18n
set(UKUI_TRANSLATIONS_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ukui/translations)
add_definitions(
-DUKUI_TRANSLATIONS_DIR="${UKUI_TRANSLATIONS_DIR}"
)
if (NOT DEFINED UPDATE_TRANSLATIONS)
set(UPDATE_TRANSLATIONS "No")
endif()
# To create a new ts file: lupdate -recursive . -target-language en_US -ts translations/en_US.ts -no-ui-lines
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
# cmake -DUPDATE_TRANSLATIONS=yes
if (UPDATE_TRANSLATIONS)
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
endif()
add_custom_target(translations ALL DEPENDS ${QM_FILES})
install(FILES ${QM_FILES} DESTINATION ${UKUI_TRANSLATIONS_DIR}/${PROJECT_NAME})
add_subdirectory(ukui-session)
add_subdirectory(tools)
add_subdirectory(ukuismserver)
add_subdirectory(data)
ukui-session-manager-4.0.0.1/translations/ 0000755 0001750 0001750 00000000000 14553704175 017074 5 ustar feng feng ukui-session-manager-4.0.0.1/translations/bo_CN.ts 0000644 0001750 0001750 00000033204 14553704175 020426 0 ustar feng feng
MainWindow
Logout
ད་ལྟ་རྩིས་ཐེམ་ནས་བསུབ་པ།
Reboot
བསྐྱར་སློང་།
Lock Screen
བརྙན་ཡོལ་ཟྭ་རྒྱག།(_L)
cancel
ལེན་པ།
Hebernate
ངལ་གསོ།
Switch User
སྤྱོད་མཁན་བརྗེ་རེས།
confirm
གཏན་འཁེལ།
Suspend
འགེལ་འཇོག
Shut Down
སྒོ་རྒྱག་པ།
Form
རྣམ་པ།
Hibernate
ཧིན་རྡུ་ཉི་ཞི་ཡ།
<html><head/><body><p><br/></p></body></html>
<html> <head/> <body> <p> <br/> </p> </body> </html>
QApplication
(user),yhkylin-backup-tools is performing a system backup or restore.
(བཀོལ་མི།)ཆིས་ལིན་གྲབས་ཉར་སླར་གསོ་ཡོ་ཆས་ཀྱིས་གྲབས་ཉར་རམ་སླར་གསོ་བྱེད་སྒང་རེད།
(user),ukui-control-center is performing a system update or package installation.
(བཀོལ་མི།)ཚོད་འཛིན་ངོས་པང་གིས་བརྒྱུད་ཁོངས་རིམ་སྤོར་རམ་མཉེན་ཆས་ནང་འཇུག་བྱེད་སྒང་རེད།
For system security,Reboot、Shutdown、Logout and Hibernate are temporarily unavailable.
བརྒྱུད་ཁོངས་བདེ་འཇགས་ལ་དམིགས་ཏེ་སྒོ་བསྐྱར་འབྱེད་དང་སྒོ་གཏན་པ། ཐོ་གསུབ་པ། ངལ་གསོ་བྱེད་པ་སོགས་ཀྱི་བྱེད་ནུས་གནས་སྐབས་རིང་བཀོལ་མི་ཐུབ།
Multiple users are logged in at the same time.Are you sure you want to close this system?
བཀོལ་མི་མང་པོ་དུས་མཉམ་དུ་ཐོ་ཞུགས་རྣམ་པར་གནས་འདུག་པས། བརྒྱུད་ཁོངས་སྒོ་གཏན་ནམ།
For system security,Reboot、Shutdown and Hibernate are temporarily unavailable.
བརྒྱུད་ཁོངས་བདེ་འཇགས་ལ་དམིགས་ཏེ་སྒོ་བསྐྱར་འབྱེད་དང་སྒོ་གཏན་པ། ཐོ་གསུབ་པ། ངལ་གསོ་བྱེད་པ་སོགས་ཀྱི་བྱེད་ནུས་གནས་སྐབས་རིང་བཀོལ་མི་ཐུབ།
UKUI session tools, show the shutdown dialog without any arguments.
UKUIཚོགས་འདུའི་ཡོ་བྱད་ལ་རྩོད་གླེང་ཅི་ཡང་མེད་པར་ལས་མཚམས་འཇོག་པའི་གླེང་མོལ་མངོན་པར་བྱས་ཡོད།
Switch the user of this computer.
རྩིས་འཁོར་འདིའི་སྤྱོད་མཁན་བརྗེ་རེས་བྱེད་དགོས།
Hibernate this computer.
གློག་ཀླད་འདི་ལ་ཧི་པི་ཝེ་སི་ཡོད།
Suspend this computer.
གློག་ཀླད་འདི་གནས་སྐབས་མཚམས་འཇོག་ཏུ་
Logout this computer.
རྩིས་འཁོར་འདི་ཐོ་འགོད་བྱེད་དགོས།
Restart this computer.
རྩིས་འཁོར་འདི་བསྐྱར་དུ་འགོ་བརྩམས།
Shutdown this computer.
གློག་ཀླད་འདི་སྒོ་རྒྱག་དགོས།
Switch User
གློག་སྒོ་འབྱེད་པའི་སྤྱོད་མཁན
Hibernate
ཧིན་རྡུ་ཉི་ཞི་ཡ།
Suspend
གནས་སྐབས་མཚམས་འཇོག་
Logout
ཐོ་འགོད་བྱེད་པ།
Reboot
བསྐྱར་དུ་འཁོར་བ།
Shut Down
ལས་མཚམས་འཇོག
Lock Screen
སྒོ་ལྕགས་ཀྱི་བརྙན་ཤེལ།
cancel
ཕྱིར་འཐེན།
confirm
ངོས་འཛིན་བྱས་པ།
UKUI Session Manager
UKUIཚོགས་འདུའི་སྤྱི་གཉེར་བ།
system-monitor
མ་ལག་ལྟ་ཞིབ་ཚད་ལེན
Log Out
ཐོ་འགོད་བྱེད་པ།
Restart
བསྐྱར་དུ་འཁོར་བ།
QObject
Still to do!
ལག་བསྟར་བྱེད་པ།
some applications are running and they dont want you to do this.
བྱ་རིམ་རེ་འགའ་འཁོར་སྐྱོད་བྱེད་སྒང་ཡིན་པར་མ་ཟད། དེས་བྱ་བ་འདི་མི་བསྒྲུབ་པའི་རེ་འདོན་བྱ་བཞིག་འདུག
System update or package installation in progress,this function is temporarily unavailable.
བརྒྱུད་ཁོངས་རིམ་སྤོར་རམ་མཉེན་ཆས་ནང་འཇུག་བྱེད་སྒང་ཡིན་པས། བྱེད་ནུས་འདི་གནས་སྐབས་རིང་བཀོལ་མི་ཐུབ།
System backup or restore in progress,this function is temporarily unavailable.
བརྒྱུད་ཁོངས་གྲབས་ཉར་རམ་སླར་གསོ་བྱེད་སྒང་ཡིན་པས། བྱེད་ནུས་འདི་གནས་སྐབས་རིང་བཀོལ་མི་ཐུབ།
cancel
ལེན་པ།
notice
གསལ་བརྡ།
confirm
གཏན་འཁེལ།
give up
བློས་གཏང་བ།
Multiple users are logged in at the same time.Are you sure you want to close this system?
བཀོལ་མི་མང་པོ་དུས་མཉམ་དུ་ཐོ་ཞུགས་རྣམ་པར་གནས་འདུག་པས། བརྒྱུད་ཁོངས་སྒོ་གཏན་ནམ།
OK
འགྲིགས།
The following program is running to prevent the system from hibernate!
གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་ལ་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན།
The following program is running to prevent the system from suspend!
གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གནས་སྐབས་མཚམས་འཇོག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན།
The following program is running to prevent the system from logout!
གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གིས་ཐོ་འགོད་བྱེད་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན།
The following program is running to prevent the system from reboot!
གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་བསྐྱར་དུ་འབྱུང་བར་སྔོན་འགོག་བྱེད་ཆེད་ཡིན།
The following program is running to prevent the system from shutting down!
གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གི་སྒོ་རྒྱག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན།
Still Hibernate
སྔར་བཞིན་ཧིན་རྡུ་ཉི་ཞི་ཡ།
Still Suspend
སྔར་བཞིན་གནས་སྐབས་མཚམས་འཇོག
Still Reboot
སྔར་བཞིན་བསྐྱར་དུ་བྱུང་བ་རེད།
Still Shutdown
སྔར་བཞིན་ལས་མཚམས་བཞག་པ
Cancel
ཕྱིར་འཐེན།
some applications are running and they don't want you to do this.
རེ་འདུན་ཞུ་ཡིག་ཁ་ཤས་འཁོར་སྐྱོད་བྱེད་བཞིན་ཡོད་པས་ཁོ་ཚོས་ཁྱེད་ཚོར་འདི་ལྟར་བྱེད་དུ་འཇུག་མི་འདོད།
ukui-session-manager-4.0.0.1/translations/zh_CN.ts 0000644 0001750 0001750 00000030277 14553704175 020456 0 ustar feng feng
MainWindow
Switch User
切换用户
Hibernate
休眠
Suspend
睡眠
Logout
注销
Reboot
重启
Shut Down
关机
Lock Screen
锁屏
cancel
取消
confirm
确认
QApplication
UKUI session tools, show the shutdown dialog without any arguments.
Switch the user of this computer.
Hibernate this computer.
Suspend this computer.
Logout this computer.
Restart this computer.
Shutdown this computer.
system-monitor
系统监视器
Switch User
切换用户
Hibernate
休眠
Suspend
睡眠
Logout
注销
Reboot
重启
Log Out
注销
Restart
重启
Shut Down
关机
Lock Screen
锁屏
Multiple users are logged in at the same time.Are you sure you want to close this system?
同时有多个用户处于登录状态,你确定要退出系统吗?
cancel
取消
confirm
确认
(user),ukui-control-center is performing a system update or package installation.
(用户),系统正在进行升级或软件包安装/卸载相关操作。
(user),yhkylin-backup-tools is performing a system backup or restore.
(用户),备份还原工具正在进行备份或还原。
For system security,Reboot、Shutdown、Logout and Hibernate are temporarily unavailable.
为了系统安全,重启、关机、注销和休眠功能暂时不可用。
For system security,Reboot、Shutdown and Hibernate are temporarily unavailable.
为了系统安全,重启、关机和休眠功能暂时不可用。
UKUI Session Manager
QObject
is block system
阻止系统
into sleep for reason
休眠,因为
is block system
阻止系统
into sleep for reason
睡眠,因为
Are you sure
你确定
you want to get system into sleep?
要让系统进入休眠吗?
Are you sure you want to get system into sleep?
你确定要让系统进入睡眠吗?
cancel
取消
confirm
确认
is block system into reboot for reason
阻止系统重启,因为
is block system into shutdown for reason
阻止系统关机,因为
Are you sure you want to reboot?
你确定要重启系统吗?
Are you sure you want to shutdown?
你确定要退出系统吗?
Multiple users are logged in at the same time.Are you sure you want to close this system?
同时有多个用户处于登录状态,你确定要退出系统吗?
System update or package installation in progress,this function is temporarily unavailable.
正在进行升级或安装/卸载(相关操作),这个功能暂时不可用。
System backup or restore in progress,this function is temporarily unavailable.
正在进行系统备份或还原,这个功能暂时不可用。
OK
确定
The following program is running to prevent the system from hibernate!
以下程序阻止休眠,您可以点击“取消”然后关闭这些程序。
The following program is running to prevent the system from suspend!
以下程序阻止睡眠,您可以点击“取消”然后关闭这些程序。
The following program is running to prevent the system from logout!
以下程序阻止注销,您可以点击“取消”然后关闭这些程序。
The following program is running to prevent the system from reboot!
以下程序阻止重启,您可以点击“取消”然后关闭这些程序。
The following program is running to prevent the system from shutting down!
以下程序阻止关机,您可以点击“取消”然后关闭这些程序。
Still Hibernate
休眠
Still Suspend
睡眠
Still Reboot
重启
Still Shutdown
关机
Cancel
取消
some applications are running and they don't want you to do this.
一些程序正在运行,而且它不希望你继续该操作。
Still to do!
仍然执行!
give up
放弃
ukui-session-manager-4.0.0.1/translations/tr.ts 0000644 0001750 0001750 00000006071 14277116241 020067 0 ustar feng feng
MainWindow
Form
Switch User
Kullanıcı Değiştir
Hebernate
Hazırda Beklet
Suspend
Askıya Al
Logout
Çıkış
Reboot
Yeniden Başlat
Shut Down
Kapat
Lock Screen
Ekranı Kilitle
QApplication
UKUI session tools, show the shutdown dialog without any arguments.
UKUI oturum araçları, herhangi bir argüman olmadan kapatma iletişim kutusunu gösterir.
Switch the user of this computer.
Bu bilgisayardaki kullanıcıyı değiştir.
Hibernate this computer.
Bu bilgisayarı hazırda beklet.
Suspend this computer.
Bu bilgisayarı askıya al.
Logout this computer.
Bu bilgisayardan çık.
Restart this computer.
Bu bilgisayarı yeniden başlat.
Shutdown this computer.
Bu bilgisayarı kapat.
ukui-session-manager-4.0.0.1/translations/bo.ts 0000644 0001750 0001750 00000004337 14277116241 020045 0 ustar feng feng
MainWindow
Form
Suspend
Switch User
Log Out
Restart
Power Off
QApplication
UKUI session tools, show the shutdown dialog without any arguments.
Logout this computer.
Shutdown this computer.
Switch the user of this computer.
Restart this computer.
ukui-session-manager-4.0.0.1/ukui-session/ 0000755 0001750 0001750 00000000000 14567236155 017014 5 ustar feng feng ukui-session-manager-4.0.0.1/ukui-session/modulemanager.h 0000644 0001750 0001750 00000007516 14553704753 022015 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
* 2010-2016 LXQt team.
*
* 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 2, or (at your option)
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA.
**/
#ifndef MODULEMANAGER_H
#define MODULEMANAGER_H
#include "ukuimodule.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class XdgDesktopFile;
class IdleWatcher;
typedef QMap ModulesMap;
typedef QMapIterator ModulesMapIterator;
class ModuleManager : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
ModuleManager(QObject* parent = nullptr);
~ModuleManager() override;
void startProcess(const QString& name, bool detach);
void stopProcess(const QString& name);
bool startProcess(const QString &name, const QStringList &args);
void startup();
void dostartwm();
void startupfinished(const QString& appName ,const QString& string);
// Qt5 users native event filter
bool nativeEventFilter(const QByteArray &eventType, void* message, long* result) override;
static void insertStartupList(QString &&str);
static bool isProgramStarted(const QString &&str);
void ChkScreenLockStartup();
void setIsShutingDown(bool value);
bool getIsShutingDown() const;
private:
bool startModuleTimer(QTimer *timer,int i);
void playBootMusic(bool arg);
void startProcess(const XdgDesktopFile &file, bool required);
void constructStartupList();
bool autoRestart(const XdgDesktopFile &file);
bool openAppWithAppManager(const XdgDesktopFile &file);
public slots:
void startCompsite();
void logout(bool doExit);
void timerUpdate();
void timeup();
void weakup(bool arg);
//void stateChanged(QMediaPlayer::State state);
void onServiceStatusChanged(const QString &name,
const QString &oldOwner,
const QString &newOwner);
void onSLStartupModeChanged(bool isStartup);
private slots:
void restartModules(int exitCode, QProcess::ExitStatus exitStatus);
Q_SIGNALS:
void moduleStateChanged(QString moduleName, bool state);
void finished();
void usdfinished();
void wmfinished();
void panelfinished();
void desktopfinished();
private:
QTimer *tusd = new QTimer();
QTimer *twm = new QTimer();
QTimer *tpanel = new QTimer();
QTimer *tdesktop = new QTimer();
bool isPanelStarted = false;
bool isDesktopStarted = false;
bool isWMStarted = false;
bool isCompsiteStarted = false;
bool isScreenLockStartup = false;
bool isWayland = false;
bool wmFound = false;
bool isDirectInstall = false;
bool isShutingDown = false;
static std::map m_startupMap;
ModulesMap mNameMap;
XdgDesktopFileList mInitialization;
XdgDesktopFile mWindowManager;
XdgDesktopFile mPanel;
XdgDesktopFile mFileManager;
XdgDesktopFileList mDesktop;
XdgDesktopFileList mApplication;
XdgDesktopFileList mForceApplication;
XdgDesktopFileList m_userAutoStartApp;
};
#endif // MODULEMANAGER_H
ukui-session-manager-4.0.0.1/ukui-session/idleadbusdaptor.h 0000644 0001750 0001750 00000002755 14553704753 022343 0 ustar feng feng /* BEGIN_COMMON_COPYRIGHT_HEADER
*
* Copyright: 2023, KylinSoft Co., Ltd.
* Copyright: 2012 Razor team
*
* Authors:
* Christian Surlykke
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef IDLEDBUSADAPTOR_H
#define IDLEDBUSADAPTOR_H
#include
#include "idlewatcher.h"
class IdleDBusAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.Presence")
public:
IdleDBusAdaptor(IdleWatcher *mIdleWatch) : QDBusAbstractAdaptor(mIdleWatch)
{
connect(mIdleWatch, &IdleWatcher::StatusChanged, this , &IdleDBusAdaptor::StatusChanged);
}
Q_SIGNALS:
void StatusChanged(uint status);
private:
IdleWatcher *mIdleWatch;
};
#endif // IDLEDBUSADAPTOR_H
ukui-session-manager-4.0.0.1/ukui-session/usminhibit.h 0000644 0001750 0001750 00000005051 14553704753 021340 0 ustar feng feng /*****************************************************************
ukuismserver - the UKUI session management server
Copyright 2000 Matthias Ettrich
Copyright 2023, KylinSoft Co., Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
#ifndef USMINHIBIT_H
#define USMINHIBIT_H
#include "ukuilockinfo.h"
#include
#include
#include
class inhibit{
public:
inhibit(QString app_id, quint32 toplevel_xid, QString reason, quint32 flags ,quint32 cookie ,QString inhibitorName);
~inhibit();
QString app_id;
quint32 toplevel_xid;
QString reason;
quint32 flags;
quint32 cookie;
QString inhibitorName;
};
class usminhibit : public QObject
{
Q_OBJECT
public:
enum InhibitorFlag{
GSM_INHIBITOR_FLAG_LOGOUT = 1 << 0,
GSM_INHIBITOR_FLAG_SWITCH_USER = 1 << 1,
GSM_INHIBITOR_FLAG_SUSPEND = 1 << 2,
GSM_INHIBITOR_FLAG_IDLE = 1 << 3
};
usminhibit();
~usminhibit();
QStringList getInhibitor();
quint32 addInhibit(QString app_id, quint32 toplevel_xid, QString reason, quint32 flags);
uint unInhibit(quint32 cookie);
uint generateCookie();
bool isInhibited(quint32 flags);
public:
QHash hash;
int inhibitor_serial;
int inhibit_logout_num;
int inhibit_switchuser_num;
int inhibit_suspend_num;
int inhibit_idle_num;
private:
//QDBusInterface dbus;
uint get_next_inhibitor_serial();
Q_SIGNALS:
void inhibitAdd();
void inhibitRemove();
};
#endif // USMINHIBIT_H
ukui-session-manager-4.0.0.1/ukui-session/xdgautostart.h 0000644 0001750 0001750 00000004657 14553704753 021731 0 ustar feng feng /* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* Copyright: 2012 Razor team
* Copyright: 2023, KylinSoft Co., Ltd.
*
* Authors:
* Alexander Sokoloff
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef QTXDG_XDGAUTOSTART_H
#define QTXDG_XDGAUTOSTART_H
#include "xdgmacros.h"
#include "xdgdesktopfile.h"
#include
/*! @brief The XdgAutoStart class implements the "Desktop Application Autostart Specification"
* from freedesktop.org.
* This specification defines a method for automatically starting applications during the startup
* of a desktop environment and after mounting a removable medium.
* Now we impliment only startup.
*
* @sa http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html
*/
class QTXDG_API XdgAutoStart
{
public:
/*! Returns a list of XdgDesktopFile objects for all the .desktop files in the Autostart directories
When the .desktop file has the Hidden key set to true, the .desktop file must be ignored. But you
can change this behavior by setting excludeHidden to false. */
static XdgDesktopFileList desktopFileList(bool excludeHidden=true);
/*! Returns a list of XdgDesktopFile objects for .desktop files in the specified Autostart directories
When the .desktop file has the Hidden key set to true, the .desktop file must be ignored. But you
can change this behavior by setting excludeHidden to false. */
static XdgDesktopFileList desktopFileList(QStringList dirs, bool excludeHidden=true);
/// For XdgDesktopFile returns the file path of the same name in users personal autostart directory.
static QString localPath(const XdgDesktopFile& file);
};
#endif // XDGAUTOSTART_H
ukui-session-manager-4.0.0.1/ukui-session/sessiondbusadaptor.h 0000644 0001750 0001750 00000012140 14553704753 023076 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
* 2010-2016 LXQt team.
*
* 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 2, or (at your option)
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA.
**/
#ifndef SESSIONDBUSADAPTOR_H
#define SESSIONDBUSADAPTOR_H
#include "../tools/ukuipower.h"
#include "../tools/powerprovider.h"
#include "modulemanager.h"
#include "usminhibit.h"
#include "sessionmanagercontext.h"
#include
#include
class SessionDBusAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager")
public:
SessionDBusAdaptor(SessionManagerDBusContext *context)
:QDBusAbstractAdaptor(context)
{
connect(parent(), &SessionManagerDBusContext::moduleStateChanged, this, &SessionDBusAdaptor::moduleStateChanged);
connect(parent(), &SessionManagerDBusContext::inhibitadded, this, &SessionDBusAdaptor::inhibitadded);
connect(parent(), &SessionManagerDBusContext::inhibitremove, this, &SessionDBusAdaptor::inhibitremove);
connect(parent(), &SessionManagerDBusContext::StartLogout, this, &SessionDBusAdaptor::StartLogout);
connect(parent(), &SessionManagerDBusContext::PrepareForSwitchuser, this, &SessionDBusAdaptor::PrepareForSwitchuser);
connect(parent(), &SessionManagerDBusContext::PrepareForPhase2, this, &SessionDBusAdaptor::PrepareForPhase2);
}
virtual ~SessionDBusAdaptor(){}
inline SessionManagerDBusContext *parent() const
{
return static_cast(QObject::parent());
}
Q_SIGNALS:
void moduleStateChanged(QString moduleName, bool state);
void inhibitadded(quint32 flags);
void inhibitremove(quint32 flags);
void StartLogout();
void PrepareForSwitchuser();
void PrepareForPhase2();
public slots:
void startupfinished(const QString &appName ,const QString &string)
{
return parent()->startupfinished(appName, string);
}
bool canSwitch()
{
return parent()->canSwitch();
}
bool canHibernate()
{
return parent()->canHibernate();
}
bool canSuspend()
{
return parent()->canSuspend();
}
bool canLockscreen()
{
return parent()->canLockscreen();
}
bool canLogout()
{
return parent()->canLogout();
}
bool canReboot()
{
return parent()->canReboot();
}
bool canPowerOff()
{
return parent()->canPowerOff();
}
Q_NOREPLY void switchUser()
{
return parent()->switchUser();
}
Q_NOREPLY void hibernate()
{
return parent()->hibernate();
}
Q_NOREPLY void suspend()
{
return parent()->suspend();
}
Q_NOREPLY void logout()
{
return parent()->logout();
}
Q_NOREPLY void reboot()
{
return parent()->reboot();
}
Q_NOREPLY void powerOff()
{
return parent()->powerOff();
}
Q_NOREPLY void startModule(const QString& name)
{
return parent()->startModule(name);
}
Q_NOREPLY void stopModule(const QString& name)
{
return parent()->stopModule(name);
}
bool startApp(const QString &name, const QStringList &args)
{
return parent()->startApp(name, args);
}
uint Inhibit(QString app_id, quint32 toplevel_xid, QString reason, quint32 flags)
{
return parent()->Inhibit(app_id,toplevel_xid, reason, flags);
}
Q_NOREPLY void Uninhibit(uint cookie)
{
return parent()->Uninhibit(cookie);
}
QStringList GetInhibitors()
{
return parent()->GetInhibitors();
}
QVector ListInhibitor(QString type)
{
return parent()->ListInhibitor(type);
}
bool IsSessionRunning(){
return parent()->IsSessionRunning();
}
QString GetSessionName()
{
return parent()->GetSessionName();
}
bool IsInhibited(quint32 flags)
{
return parent()->IsInhibited(flags);
}
Q_NOREPLY void setSessionEnv(const QString &key, const QString &value)
{
return parent()->setSessionEnv(key, value);
}
Q_NOREPLY void emitStartLogout()
{
return parent()->emitStartLogout();
}
Q_NOREPLY void emitPrepareForSwitchuser()
{
return parent()->emitPrepareForSwitchuser();
}
Q_NOREPLY void emitPrepareForPhase2()
{
return parent()->emitPrepareForPhase2();
}
Q_NOREPLY void simulateUserActivity(){
return parent()->simulateUserActivity();
}
};
#endif // SESSIONDBUSADAPTOR_H
ukui-session-manager-4.0.0.1/ukui-session/CMakeLists.txt 0000644 0001750 0001750 00000003170 14553704753 021554 0 ustar feng feng # Populate a CMake variable with the sources
set(ukui-session_SRCS
main.cpp
sessionapplication.cpp
modulemanager.cpp
ukuimodule.cpp
idlewatcher.cpp
sessiondbusadaptor.h
idlewatcher.cpp
idlewatcher.h
idleadbusdaptor.h
xdgautostart.cpp
xdgautostart.h
xdgdesktopfile.cpp
xdgdesktopfile.h
xdgdirs.cpp
xdgdirs.h
xdgmacros.h
usminhibit.cpp
usminhibit.h
../tools/ukuipower.cpp
../tools/powerprovider.cpp
ukuisessiondebug.cpp
ukuisessiondebug.h
sessionmanagercontext.h
sessionmanagercontext.cpp
ukuilockinfo.cpp
)
#find_package(QT5XDG )
find_package(PkgConfig)
pkg_search_module(GSETTINGS_QT REQUIRED gsettings-qt)
include_directories(${GSETTINGS_QT_INCLUDES})
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GIO2 REQUIRED gio-2.0)
pkg_search_module(X11 REQUIRED x11)
pkg_check_modules(KDKINFO kysdk-sysinfo)
if (KDKINFO_FOUND)
ADD_DEFINITIONS(-DKDKINFO_FOUND="true")
endif()
include_directories(${X11_INCLUDES})
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${GIO2_INCLUDE_DIRS})
include_directories(${KDKINFO_INCLUDE_DIRS})
link_directories(${KDKINFO_LIBRARY_DIRS})
add_executable(ukui-session ${ukui-session_SRCS})
target_link_libraries(ukui-session
Qt5::Widgets
Qt5::Core
Qt5::DBus
Qt5::Multimedia
KF5::IdleTime
KF5::CoreAddons
KF5::ConfigCore
KF5::ConfigGui
KF5::WindowSystem
-lSM -lICE
${GSETTINGS_QT_LIBRARIES} ${X11_LIBRARIES}
${GLIB2_LIBRARIES}
${GIO2_LIBRARIES}
${KDKINFO_LIBRARIES})
#${GSETTINGS_QT_LIBRARIES}
install(TARGETS ukui-session DESTINATION bin)
ukui-session-manager-4.0.0.1/ukui-session/org.ukui.KWin.Session.xml 0000644 0001750 0001750 00000000735 14553704175 023574 0 ustar feng feng
ukui-session-manager-4.0.0.1/ukui-session/ukuimodule.cpp 0000644 0001750 0001750 00000004224 14553704753 021704 0 ustar feng feng /* BEGIN_COMMON_COPYRIGHT_HEADER
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "ukuimodule.h"
#include
#include
#include
UkuiModule::UkuiModule(const XdgDesktopFile& file, QObject* parent) : QProcess(parent)
, file(file)
, fileName(QFileInfo(file.fileName()).fileName())
, mIsTerminating(false)
{
restartNum = 0;
QProcess::setProcessChannelMode(QProcess::ForwardedChannels);
connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), SLOT(updateState(QProcess::ProcessState)));
}
void UkuiModule::startUKUIModule()
{
mIsTerminating = false;
QStringList args = file.expandExecString();
QString command = args.takeFirst();
qDebug() << "Start ukui module: " << command << "args: " << args;
QProcess::start(command, args);
ModuleManager::insertStartupList(std::move(command));
}
void UkuiModule::terminate()
{
mIsTerminating = true;
QProcess::terminate();
}
bool UkuiModule::isTerminating()
{
return mIsTerminating;
}
void UkuiModule::updateState(QProcess::ProcessState newState)
{
if (newState != QProcess::Starting)
emit moduleStateChanged(fileName, (newState == QProcess::Running));
}
ukui-session-manager-4.0.0.1/ukui-session/xdgdesktopfile.h 0000644 0001750 0001750 00000031527 14553704753 022210 0 ustar feng feng /* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* Copyright: 2010-2011 Razor team
* Copyright: 2023, KylinSoft Co., Ltd.
*
* Authors:
* Alexander Sokoloff
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef QTXDG_XDGDESKTOPFILE_H
#define QTXDG_XDGDESKTOPFILE_H
#include "xdgmacros.h"
#include
#include
#include
#include
#include
#include
class XdgDesktopFileData;
/**
\brief Desktop files handling.
XdgDesktopFile class gives the interface for reading the values from the XDG .desktop file.
The interface of this class is similar on QSettings. XdgDesktopFile objects can be passed
around by value since the XdgDesktopFile class uses implicit data sharing.
The Desktop Entry Specification defines 3 types of desktop entries: Application, Link and
Directory. The format of .desktop file is described on
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
Note that not all methods in this class make sense for all types of desktop files.
\author Alexander Sokoloff
*/
class QTXDG_API XdgDesktopFile
{
public:
/*! The Desktop Entry Specification defines 3 types of desktop entries: Application, Link and
Directory. File type is determined by the "Type" tag. */
enum Type
{
UnknownType, //! Unknown desktop file type. Maybe is invalid.
ApplicationType, //! The file describes application.
LinkType, //! The file describes URL.
DirectoryType //! The file describes directory settings.
};
//! Constructs an empty XdgDesktopFile
XdgDesktopFile();
/*! Constructs a copy of other.
This operation takes constant time, because XdgDesktopFile is implicitly shared. This makes
returning a XdgDesktopFile from a function very fast. If a shared instance is modified,
it will be copied (copy-on-write), and that takes linear time. */
XdgDesktopFile(const XdgDesktopFile& other);
/*! Constructs a new basic DesktopFile. If type is:
- ApplicationType, "value" should be the Exec value;
- LinkType, "value" should be the URL;
- DirectoryType, "value" should be omitted */
XdgDesktopFile(XdgDesktopFile::Type type, const QString& name, const QString& value = QString());
//! Destroys the object.
virtual ~XdgDesktopFile();
//! Assigns other to this DesktopFile and returns a reference to this DesktopFile.
XdgDesktopFile& operator=(const XdgDesktopFile& other);
//! Returns true if both files contain the identical key-value pairs
bool operator==(const XdgDesktopFile &other) const;
//! Returns false if both files contain the identical key-value pairs
inline bool operator!=(const XdgDesktopFile &other) const
{
return !operator==(other);
}
//! Loads an DesktopFile from the file with the given fileName.
virtual bool load(const QString& fileName);
//! Saves the DesktopFile to the file with the given fileName. Returns true if successful; otherwise returns false.
virtual bool save(const QString &fileName) const;
/*! This is an overloaded function.
This function writes a DesktopFile to the given device. */
virtual bool save(QIODevice *device) const;
/*! Returns the value for key. If the key doesn't exist, returns defaultValue.
If no default value is specified, a default QVariant is returned. */
QVariant value(const QString& key, const QVariant& defaultValue = QVariant()) const;
/*! Returns the localized value for key. In the desktop file keys may be postfixed by [LOCALE]. If the
localized value doesn't exist, returns non lokalized value. If non localized value doesn't exist, returns defaultValue.
LOCALE must be of the form lang_COUNTRY.ENCODING@MODIFIER, where _COUNTRY, .ENCODING, and @MODIFIER may be omitted.
If no default value is specified, a default QVariant is returned. */
QVariant localizedValue(const QString& key, const QVariant& defaultValue = QVariant()) const;
//! Sets the value of setting key to value. If the key already exists, the previous value is overwritten.
void setValue(const QString &key, const QVariant &value);
/*! Sets the value of setting key to value. If a localized version of the key already exists, the previous value is
overwritten. Otherwise, it overwrites the the un-localized version. */
void setLocalizedValue(const QString &key, const QVariant &value);
//! Removes the entry with the specified key, if it exists.
void removeEntry(const QString& key);
//! Returns the entry Categories. It supports X-Categories extensions.
QStringList categories() const;
//! Returns list of values in entry Actions.
QStringList actions() const;
//! Returns true if there exists a setting called key; returns false otherwise.
bool contains(const QString& key) const;
//! Returns true if the XdgDesktopFile is valid; otherwise returns false.
bool isValid() const;
/*! Returns the file name of the desktop file.
* Returns QString() if the file wasn't found when load was called. */
QString fileName() const;
// //! Returns an icon specified in this file.
// QIcon const icon(const QIcon& fallback = QIcon()) const;
// //! Returns an icon for application action \param action.
// QIcon const actionIcon(const QString & action, const QIcon& fallback = QIcon()) const;
// //! Returns an icon name specified in this file.
// QString const iconName() const;
// //! Returns an icon name for application action \param action.
// QString const actionIconName(const QString & action) const;
//! Returns an list of mimetypes specified in this file.
/*! @return Returns a list of the "MimeType=" entries.
* If the file doens't contain the MimeType entry, an empty QStringList is
* returned. Empty values are removed from the returned list.
*/
QStringList mimeTypes() const;
//! This function is provided for convenience. It's equivalent to calling localizedValue("Name").toString().
QString name() const { return localizedValue(QLatin1String("Name")).toString(); }
//! Returns an (localized) name for application action \param action.
QString actionName(const QString & action) const;
//! This function is provided for convenience. It's equivalent to calling localizedValue("Comment").toString().
QString comment() const { return localizedValue(QLatin1String("Comment")).toString(); }
/*! Returns the desktop file type.
@see XdgDesktopFile::Type */
Type type() const;
/*! For file with Application type. Starts the program with the optional urls in a new process, and detaches from it.
Returns true on success; otherwise returns false.
@par urls - A list of files or URLS. Each file is passed as a separate argument to the executable program.
For file with Link type. Opens URL in the associated application. Parametr urls is not used.
For file with Directory type, do nothing. */
bool startDetached(const QStringList& urls) const;
//! This function is provided for convenience. It's equivalent to calling startDetached(QStringList(url)).
bool startDetached(const QString& url = QString()) const;
/*! For file with Application type. Activates action defined by the \param action. Action is activated
* either with the [Desktop Action %s]/Exec or by the D-Bus if the [Desktop Entry]/DBusActivatable is set.
* \note Starting is done the same way as \sa startDetached()
*
* \return true on success; otherwise returns false.
* \param urls - A list of files or URLS. Each file is passed as a separate argument to the executable program.
*
* For file with Link type, do nothing.
*
* For file with Directory type, do nothing.
*/
bool actionActivate(const QString & action, const QStringList & urls) const;
/*! A Exec value consists of an executable program optionally followed by one or more arguments.
This function expands this arguments and returns command line string parts.
Note this method make sense only for Application type.
@par urls - A list of files or URLS. Each file is passed as a separate argument to the result string program.*/
QStringList expandExecString(const QStringList& urls = QStringList()) const;
/*! Returns the URL for the Link desktop file; otherwise an empty string is returned. */
QString url() const;
/*! Computes the desktop file ID. It is the identifier of an installed
* desktop entry file.
* @par fileName - The desktop file complete name.
* @par checkFileExists If true and the file doesn't exist the computed ID
* will be an empty QString(). Defaults to true.
* @return The computed ID. Returns an empty QString() if it's impossible to
* compute the ID. Reference:
* https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id
*/
static QString id(const QString &fileName, bool checkFileExists = true);
/*! The desktop entry specification defines a number of fields to control
the visibility of the application menu. Thisfunction checks whether
to display a this application or not.
@par environment - User supplied desktop environment name. If not
supplied the desktop will be detected reading the
XDG_CURRENT_DESKTOP environment variable. If not set, "UNKNOWN"
will be used as the desktop name. All operations envolving the
desktop environment name are case insensitive.
*/
bool isShown(const QString &environment = QString()) const;
/*! This fuction returns true if the desktop file is applicable to the
current environment.
@par excludeHidden - if set to true (default), files with
"Hidden=true" will be considered "not applicable". Setting this
to false is be useful when the user wants to enable/disable items
and wants to see those that are Hidden
@par environment - User supplied desktop environment name. If not
supplied the desktop will be detected reading the
XDG_CURRENT_DESKTOP environment variable. If not set, "UNKNOWN"
will be used as the desktop name. All operations envolving the
desktop environment name are case insensitive.
*/
bool isSuitable(bool excludeHidden = true, const QString &environment = QString()) const;
protected:
virtual QString prefix() const { return QLatin1String("Desktop Entry"); }
virtual bool check() const { return true; }
private:
/*! Returns the localized version of the key if the Desktop File already contains a localized version of it.
If not, returns the same key back */
QString localizedKey(const QString& key) const;
QSharedDataPointer d;
};
/// Synonym for QList
typedef QList XdgDesktopFileList;
class QTXDG_API XdgDesktopFileCache
{
public:
static XdgDesktopFile* getFile(const QString& fileName);
static QList getAllFiles();
static QList getApps(const QString & mimeType);
static XdgDesktopFile* getDefaultApp(const QString& mimeType);
static QSettings::Format desktopFileSettingsFormat();
/*! Return all desktop apps that have category for their Categories key
* Note that, according to xdg's spec, for non-standard categories "X-"
* is added to the beginning of the category's name. This method takes care
* of both cases.
* See http://standards.freedesktop.org/menu-spec/menu-spec-latest.html#desktop-entry-extensions
*/
static QList getAppsOfCategory(const QString &category);
private:
static XdgDesktopFileCache & instance();
static XdgDesktopFile* load(const QString & fileName);
XdgDesktopFileCache();
~XdgDesktopFileCache();
void initialize();
void initialize(const QString & dirName);
bool m_IsInitialized;
QHash > m_defaultAppsCache;
QHash m_fileCache;
};
#endif // QTXDG_XDGDESKTOPFILE_H
ukui-session-manager-4.0.0.1/ukui-session/sessionmanagercontext.h 0000644 0001750 0001750 00000006605 14553704753 023616 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
* 2014 Hong Jen Yee (PCMan) .
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef SESSIONINHIBITCONTEXT_H
#define SESSIONINHIBITCONTEXT_H
#include "../tools/ukuipower.h"
#include "../tools/powerprovider.h"
#include "modulemanager.h"
#include "usminhibit.h"
#include "ukuilockinfo.h"
#include
#include
#include
#include
#include
#ifdef signals
#undef signals
#endif
class SessionDBusAdaptor;
class SessionManagerDBusContext : public QObject, protected QDBusContext
{
Q_OBJECT
public:
SessionManagerDBusContext(ModuleManager *manager,QObject *object = nullptr);
~SessionManagerDBusContext() override;
Q_SIGNALS:
void moduleStateChanged(QString moduleName, bool state);
void inhibitadded(quint32 flags);
void inhibitremove(quint32 flags);
void StartLogout();
void PrepareForSwitchuser();
void PrepareForPhase2();
public Q_SLOTS:
Q_NOREPLY void startupfinished(const QString& appName ,const QString& string);
bool canLogout();
bool canSwitch();
bool canLockscreen();
bool canHibernate();
bool canSuspend();
bool canReboot();
bool canPowerOff();
Q_NOREPLY void switchUser();
Q_NOREPLY void hibernate();
Q_NOREPLY void suspend();
Q_NOREPLY void logout();
Q_NOREPLY void reboot();
Q_NOREPLY void powerOff();
Q_NOREPLY void startModule(const QString& name);
Q_NOREPLY void stopModule(const QString& name);
bool startApp(const QString &name, const QStringList &args);
uint Inhibit(QString app_id, quint32 toplevel_xid, QString reason, quint32 flags);
Q_NOREPLY void Uninhibit(uint cookie);
QStringList GetInhibitors();
QVector ListInhibitor(QString type);
bool IsSessionRunning();
QString GetSessionName();
bool IsInhibited(quint32 flags);
Q_NOREPLY void setSessionEnv(const QString &key, const QString &value);
Q_NOREPLY void emitStartLogout();
Q_NOREPLY void emitPrepareForSwitchuser();
Q_NOREPLY void emitPrepareForPhase2();
Q_NOREPLY void simulateUserActivity();
void on_serviceUnregistered(const QString &serviceName);
private:
void logoutComplete();
void rebootComplete();
void shutdownComplete();
QStringList listFileList();
void execPro(QStringList proList);
private:
ModuleManager *mManager;
usminhibit *minhibit;
PowerProvider *m_systemdProvider;
PowerProvider *m_ukuiProvider;
QHash> m_hashInhibitionServices;
QDBusServiceWatcher *m_serviceWatcher = nullptr;
};
#endif // SESSIONINHIBITCONTEXT_H
ukui-session-manager-4.0.0.1/ukui-session/ukuimodule.h 0000644 0001750 0001750 00000002727 14553704753 021357 0 ustar feng feng /* BEGIN_COMMON_COPYRIGHT_HEADER
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef UKUIMODULE_H
#define UKUIMODULE_H
#include
#include "xdgautostart.h"
#include "xdgdesktopfile.h"
#include "xdgdirs.h"
class UkuiModule : public QProcess
{
Q_OBJECT
public:
UkuiModule(const XdgDesktopFile& file, QObject *parent = nullptr);
void startUKUIModule();
void terminate();
bool isTerminating();
int restartNum;
const XdgDesktopFile file;
const QString fileName;
Q_SIGNALS:
void moduleStateChanged(QString name, bool state);
private slots:
void updateState(QProcess::ProcessState newState);
private:
bool mIsTerminating;
};
#endif // UKUIMODULE_H
ukui-session-manager-4.0.0.1/ukui-session/modulemanager.cpp 0000644 0001750 0001750 00000063232 14553704753 022345 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
* 2010-2016 LXQt team.
*
* 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 2, or (at your option)
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA.
**/
#include "modulemanager.h"
#include "ukuimodule.h"
#include "idlewatcher.h"
#include "ukuisessiondebug.h"
#include "xdgautostart.h"
#include "xdgdesktopfile.h"
#include "xdgdirs.h"
#include
#include
#include
#include
#include
#include
#include
// #include
#include
#include
#include
#include
#include
/* qt会将glib里的signals成员识别为宏,所以取消该宏
* 后面如果用到signals时,使用Q_SIGNALS代替即可
**/
#ifdef signals
#undef signals
#endif
#define SESSION_REQUIRED_COMPONENTS "org.ukui.session.required-components"
#define SESSION_REQUIRED_COMPONENTS_PATH "/org/ukui/desktop/session/required-components/"
#define SSWND_DBUS_SERVICE "org.ukui.ScreenSaverWnd"
#define SSWND_DBUS_PATH "/"
#define SSWND_DBUS_INTERFACE "org.ukui.ScreenSaverWnd"
#define FD_DBUS_SERVICE "org.freedesktop.DBus"
#define FD_DBUS_PATH "/org/freedesktop/DBus"
#define FD_DBUS_INTERFACE "org.freedesktop.DBus"
std::map ModuleManager::m_startupMap = {};
void ModuleManager::playBootMusic(bool arg)
{
if( arg ) return;
//set default value of whether boot-music is opened
bool play_music = true;
if (QGSettings::isSchemaInstalled("org.ukui.session")) {
QGSettings *gset = new QGSettings("org.ukui.session", "/org/ukui/desktop/session/", this);
if (gset == NULL) {
qDebug() << "QGSettings init error";
delete gset;
return;
}
QString xdg_session_type = qgetenv("XDG_SESSION_TYPE");
if (arg) {
play_music = gset->get("startup-music").toBool();
if (play_music) {
if (xdg_session_type == "wayland") {
//非华为机器没有声音放大器,默认不设置音量大小
QProcess::startDetached("paplay /usr/share/ukui/ukui-session-manager/startup.wav");
} else {
QProcess::startDetached("aplay /usr/share/ukui/ukui-session-manager/startup.wav");
}
}
} else {
play_music = gset->get("weakup-music").toBool();
if (play_music) {
if (xdg_session_type == "wayland") {
QProcess::startDetached("paplay /usr/share/ukui/ukui-session-manager/weakup.wav");
} else {
QProcess::startDetached("aplay /usr/share/ukui/ukui-session-manager/weakup.wav");
}
}
}
}
}
//睡眠转休眠判断
bool isSuspendToHibernate()
{
QString path = "/sys/power/wakeup_reason";
if (!QFile::exists(path)) {
return false;
}
QFile wakeup_reason_file(path);
wakeup_reason_file.open(QIODevice::ReadOnly | QIODevice::Text);
QString wakeupReason = wakeup_reason_file.readAll().simplified();
wakeup_reason_file.close();
if (QString::compare(wakeupReason,"0xaa") == 0) {
qDebug()<< "Suspend to Hibernate, wakeup_reason is "<get("windowmanager").toString() + ".desktop";
panel = gs->get("panel").toString() + ".desktop";
file_manager = gs->get("filemanager").toString() + ".desktop";
wm_notfound = gs->get("windowmanager").toString();
} else {
//gsetting安装失败,或无法获取,设置默认值
qDebug() << "从gsettings 中或取值失败,设置默认值";
window_manager = "ukwm.desktop";
panel = "ukui-panel.desktop";
file_manager = "peony-qt-desktop.desktop";
}
QString xdg_session_type = qgetenv("XDG_SESSION_TYPE");
if (xdg_session_type == "wayland") {
isWayland = true;
}
QStringList desktop_paths;
desktop_paths << "/usr/share/applications";
desktop_paths << "/etc/xdg/autostart";
bool panel_found = false;
bool fm_found = false;
bool wm_found = false;
//const auto files = XdgAutoStart::desktopFileList(desktop_paths, false);
for (const QString &dirName : const_cast(desktop_paths)) {
QDir dir(dirName);
if (!dir.exists()) continue;
const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files | QDir::Readable);
for (const QFileInfo &fi : files) {
if (fi.fileName() == panel) {
mPanel.load(fi.absoluteFilePath());
panel_found = true;
qDebug() << "panel has been found";
}
if (fi.fileName() == file_manager) {
mFileManager.load(fi.absoluteFilePath());
fm_found = true;
qDebug() << "filemanager has been found";
}
if (fi.fileName() == window_manager) {
mWindowManager.load(fi.absoluteFilePath());
wm_found = true;
qDebug() << "windowmanager has been found";
}
if (fm_found && panel_found && wm_found)
break;
}
}
if (!panel_found || !fm_found || !wm_found) isDirectInstall = true;
if (isDirectInstall) {
wmFound = wm_found;
}
if (wm_found == false) {
QFileInfo check_ukwm("/usr/share/applications/ukwm.desktop");
QFileInfo check_ukuikwin("/usr/share/applications/ukui-kwin.desktop");
if (check_ukwm.exists()) {
window_manager = "ukwm.desktop";
mWindowManager.load("/usr/share/applications/ukwm.desktop");
} else if (check_ukuikwin.exists()) {
window_manager = "ukui-kwin.desktop";
mWindowManager.load("/usr/share/applications/ukui-kwin.desktop");
}
wm_found = true;
}
//配置文件所给的窗口管理器找不到.desktop文件时,将所给QString设为可执行命令,创建一个desktop文件赋给mWindowManager
// if (wm_found == false) {
// mWindowManager = XdgDesktopFile(XdgDesktopFile::ApplicationType,"window-manager", wm_notfound);
// qDebug() << "windowmanager has been created";
// }
QString desktop_phase = "X-UKUI-Autostart-Phase";
QString desktop_type = "Type";
//设置excludeHidden为true,判断所有desktop文件的Hidden值,若为true,则将其从自启列表中去掉
const XdgDesktopFileList all_file_list = XdgAutoStart::desktopFileList(true);
for (XdgDesktopFileList::const_iterator i = all_file_list.constBegin(); i != all_file_list.constEnd(); ++i) {
QString filePath = i->fileName();
QString filename = QFileInfo(filePath).fileName();
if (filename == panel || filename == file_manager || filename == window_manager) {
continue;
}
const XdgDesktopFile file = *i;
if (i->contains(desktop_phase)) {
QStringList s1 = file.value(desktop_phase).toString().split(QLatin1Char(';'));
if (s1.contains("Initialization")) {
mInitialization << file;
} else if (s1.contains("Desktop")) {
mDesktop << file;
} else if (s1.contains("Application")) {
//用户设置的自启应用要单独判断,有可能会存在问题,但暂时想不到更好的判断方法
if (filePath.contains(".config/autostart")) {
m_userAutoStartApp << file;
} else {
mApplication << file;
}
}
} else if (i->contains(desktop_type)) {
QStringList s2 = file.value(desktop_type).toString().split(QLatin1Char(';'));
if (s2.contains("Application")) {
if (filePath.contains(".config/autostart")) {
m_userAutoStartApp << file;
} else {
mApplication << file;
}
}
}
}
QStringList force_app_paths;
force_app_paths << "/usr/share/ukui/applications";
const XdgDesktopFileList force_file_list = XdgAutoStart::desktopFileList(force_app_paths, true);
for (XdgDesktopFileList::const_iterator i = force_file_list.constBegin(); i != force_file_list.constEnd(); ++i) {
qDebug() << (*i).fileName();
mForceApplication << *i;
}
}
/* Startup Phare:
* Initialization
* WindowManager
* Panel
* FileManager
* Desktop
* Application
*
*/
bool ModuleManager::startModuleTimer(QTimer *timer, int i)
{
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(timeup()));
timer->start(i * 1000);
return true;
}
void ModuleManager::startupfinished(const QString &appName, const QString &string)
{
qDebug() << "moudle :" + appName + " startup finished, and it want to say " + string;
if (appName == "ukui-settings-daemon") {
tusd->stop();
emit usdfinished();
return;
}
if (appName == "ukui-kwin") {
twm->stop();
isWMStarted = true;
emit wmfinished();
return;
}
if (appName == "ukui-panel") {
tpanel->stop();
isPanelStarted = true;
emit panelfinished();
return;
}
if (appName == "peony-qt-desktop") {
tdesktop->stop();
isDesktopStarted = true;
emit desktopfinished();
return;
}
}
void ModuleManager::timeup()
{
QTimer *time_out = qobject_cast(sender());
if (time_out == tusd) {
qDebug() << "usd超时";
emit usdfinished();
return;
}
if (time_out == twm) {
qDebug() <<"wm超时";
isWMStarted = true;
emit wmfinished();
return;
}
if (time_out == tpanel) {
qDebug() << "panel超时";
isPanelStarted = true;
emit panelfinished();
return;
}
if (time_out == tdesktop) {
qDebug() << "peony-qt-desktop超时";
isDesktopStarted = true;
emit desktopfinished();
return;
}
}
void ModuleManager::startCompsite()
{
if (isWayland) return;
qDebug() << "Enter:: startCompsite";
if (!isPanelStarted || !isDesktopStarted || !isWMStarted) return;// || !isWMStarted
if (isCompsiteStarted) return;
isCompsiteStarted = true;
timerUpdate();
/* //按kwin要求,kwin现在启动后自动开混成
// start composite
QDBusInterface dbus("org.ukui.KWin", "/Compositor", "org.ukui.kwin.Compositing", QDBusConnection::sessionBus());
if (!dbus.isValid()) {
qWarning() << "dbusCall: QDBusInterface is invalid ; kwin do not exit!";
timerUpdate();
} else {
qDebug() << "Start composite";
dbus.call("resume");
timerUpdate();
}*/
}
void ModuleManager::startup()
{
//直接安装进入的流程
const QFile file_installer("/etc/xdg/autostart/kylin-os-installer.desktop");
if (file_installer.exists() && isDirectInstall) {
if (wmFound) {
isPanelStarted = true;
isDesktopStarted = true;
connect(this, &ModuleManager::wmfinished, [=](){ startCompsite(); });
// startProcess(mWindowManager, true);
startModuleTimer(twm, 18);
} else {
timerUpdate();
}
return;
}
if (isWayland) {
startProcess("hwaudioservice", true);
}
if (!isWayland) {
connect(this, &ModuleManager::panelfinished, [=](){ startCompsite(); });
connect(this, &ModuleManager::wmfinished, [=](){ startCompsite(); });
connect(this, &ModuleManager::desktopfinished, [=](){ startCompsite(); });
// dostartwm();
} else {
QTimer::singleShot(500, this, SLOT(timerUpdate()));
}
qDebug() << "Start Initialization app: ";
for (XdgDesktopFileList::const_iterator i = mInitialization.constBegin(); i != mInitialization.constEnd(); ++i) {
startProcess(*i, true);
}
startModuleTimer(twm,3);
startProcess(mPanel, true);
startModuleTimer(tpanel,5);
startProcess(mFileManager, true);
startModuleTimer(tdesktop,5);
if (!isWayland) {
qDebug() << "Start desktop: ";
for (XdgDesktopFileList::const_iterator i = mDesktop.constBegin(); i != mDesktop.constEnd(); ++i) {
startProcess(*i, true);
}
}
}
void ModuleManager::dostartwm()
{
qDebug() << "Start window manager: " << mWindowManager.name();
if (mWindowManager.name() == "UKUI-KWin") {
startProcess(mWindowManager, true);
startModuleTimer(twm, 18);
} else {
startProcess(mWindowManager, true);
isWMStarted = true;
}
}
void ModuleManager::timerUpdate()
{
QTimer::singleShot(500, this, [&](){
emit finished();
});
if (isWayland) {
qDebug() << "Start desktop: ";
for (XdgDesktopFileList::const_iterator i = mDesktop.constBegin(); i != mDesktop.constEnd(); ++i) {
startProcess(*i, true);
}
}
qDebug() << "Start application: ";
QFile file_nm("/etc/xdg/autostart/kylin-nm.desktop");
QFile file_sogou("/usr/bin/sogouImeService");
for (XdgDesktopFileList::const_iterator i = mApplication.constBegin(); i != mApplication.constEnd(); ++i) {
qDebug() << i->fileName();
if (i->fileName() == "/etc/xdg/autostart/nm-applet.desktop" && file_nm.exists()) {
qDebug() << "the kylin-nm exist so the nm-applet will not start";
continue;
}
if (i->fileName() == "/etc/xdg/autostart/fcitx-qimpanel-autostart.desktop" && file_sogou.exists()) {
qDebug() << "the sogouImeService exist so the fcitx-ui-qimpanel will not start";
continue;
}
startProcess(*i, false);
}
qDebug() << "Start force application: ";
for (XdgDesktopFileList::const_iterator i = mForceApplication.constBegin(); i != mForceApplication.constEnd(); ++i) {
startProcess(*i, true);
}
//启动用户自定义的开机自启应用
for (XdgDesktopFileList::const_iterator i = m_userAutoStartApp.constBegin(); i != m_userAutoStartApp.constEnd(); ++i) {
qDebug() << "start user's autostart application " << i->fileName();
openAppWithAppManager(*i);
}
if (QGSettings::isSchemaInstalled("org.ukui.session")) {
QGSettings *gset = new QGSettings("org.ukui.session", "/org/ukui/desktop/session/", this);
bool restoreSession = gset->get("restore-session").toBool();
if (restoreSession) {
//此处设置800ms延迟的原因是,当程序运行到这里时,已经启动了很多应用,根据测试,所有这些应用启动完并且完成与xmspserver的通信一般就需要800ms,如果这里不等待800ms,
//然后直接调用xsmpserver的restoreSession接口,则xsmpserver的主循环会被用来启动那些待恢复的应用,从而无暇顾及其他应用的信号请求,造成阻塞,影响整个启动流程
//之前觉得把xsmpserver分离出去可以解决这个问题,现在看来还是不行,因为ukuismserver还是要跟ukui-session交互并且判断是否该应用是否已经已经启动过,真正要解决这个
//问题,还是要把启动阶段划分好,在restoreSession阶段保证就不会有别的应用干扰。
QTimer::singleShot(800, [](){
//调用ukuismserver恢复会话的接口
qDebug(UKUI_SESSION) << "began restore session";
QDBusInterface ukuismserverFace("org.ukui.ukuismserver",
"/UKUISMServer",
"org.ukui.ukuismserver",
QDBusConnection::sessionBus());
if (!ukuismserverFace.isValid()) {
qDebug() << "ukuisminterface not valid";
return;
}
ukuismserverFace.call(QDBus::CallMode::NoBlock, "restoreSession");
});
}
}
}
void ModuleManager::startProcess(const XdgDesktopFile &file, bool required)
{
QStringList args = file.expandExecString();
if (args.isEmpty()) {
qWarning() << "Wrong desktop file: " << file.fileName();
return;
}
QString name = QFileInfo(file.fileName()).fileName();
if (!mNameMap.contains(name)) {
UkuiModule *proc = new UkuiModule(file, this);
connect(proc, &UkuiModule::moduleStateChanged, this, &ModuleManager::moduleStateChanged);
proc->startUKUIModule();
mNameMap[name] = proc;
if (required || autoRestart(file)) {
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(restartModules(int, QProcess::ExitStatus)));
}
}
}
void ModuleManager::startProcess(const QString& name, bool required)
{
QString desktop_name = name + ".desktop";
QStringList desktop_paths;
desktop_paths << "/usr/share/applications";
const auto files = XdgAutoStart::desktopFileList(desktop_paths, false);
for (const XdgDesktopFile& file : files) {
if (QFileInfo(file.fileName()).fileName() == desktop_name) {
startProcess(file, required);
return;
}
}
}
void ModuleManager::stopProcess(const QString& name)
{
if (mNameMap.contains(name)) {
mNameMap[name]->terminate();
}
}
bool ModuleManager::startProcess(const QString &name, const QStringList &args)
{
if (isProgramStarted(std::move(name))) {
return false;
}
//这个接口供外部应用通过session打开应用使用,需要使用那个进程非正常死亡再拉起机制吗?
QProcess *proc = new QProcess(this);
proc->start(name, args);
proc->closeReadChannel(QProcess::StandardOutput);
proc->closeReadChannel(QProcess::StandardError);
m_startupMap[std::forward(name)] = 1;
return true;
}
bool ModuleManager::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
if (eventType != "xcb_generic_event_t") // We only want to handle XCB events
return false;
return false;
}
void ModuleManager::insertStartupList(QString &&str)
{
if (!str.isEmpty()) {
m_startupMap[std::forward(str)] = 1;
}
}
bool ModuleManager::isProgramStarted(const QString &&str)
{
//需要对str做处理,取出可执行程序名,str一般是一个完整的二进制路径,所以既需要判断二进制路径也要判断二进制名
QString appName = str.mid(str.lastIndexOf(QDir::separator()) + 1);
auto itFullPath = m_startupMap.find(str);
auto itName = m_startupMap.find(appName);
qDebug() << "judge if start before " << appName << " " << str;
if (itFullPath != m_startupMap.end() || itName != m_startupMap.end()) {
qDebug() << str << "has start up before";
return true;
}
return false;
}
bool ModuleManager::autoRestart(const XdgDesktopFile &file)
{
QString auto_restart = "X-UKUI-AutoRestart";
return file.value(auto_restart).toBool();
}
bool ModuleManager::openAppWithAppManager(const XdgDesktopFile &file)
{
QDBusInterface face("com.kylin.AppManager",
"/com/kylin/AppManager",
"com.kylin.AppManager",
QDBusConnection::sessionBus());
if (!face.isValid()) {
qCDebug(UKUI_SESSION()) << "AppManager interface not valid";
return false;
}
QString name = file.fileName();
QVariant desktopFilePath(name);
QDBusReply reply = face.call("LaunchApp", desktopFilePath);
if (reply.isValid()) {
return reply.value();
}
return true;
}
void ModuleManager::restartModules(int /*exitCode*/, QProcess::ExitStatus exitStatus)
{
if (isShutingDown) {
qDebug() << "Logout phase, don't Restart";
return;
}
UkuiModule *proc = qobject_cast(sender());
if (nullptr == proc) {
qWarning() << "Got an invalid (null) module to restart, Ignoring it";
return;
}
//需要做出修改
if (proc->restartNum > 10) {
mNameMap.remove(proc->fileName);
disconnect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), nullptr, nullptr);
proc->deleteLater();
return;
}
if (!proc->isTerminating()) {
//根据退出码来判断程序是否属于异常退出。
QString procName = proc->file.name();
if (proc->exitCode() == 0) {
qDebug() << "Process" << procName << "(" << proc << ") exited correctly. " << "With the exitcode = " << proc->exitCode() << ",exitStatus = " << exitStatus;
} else {
qDebug() << "Process" << procName << "(" << proc << ") has to be restarted. " << "With the exitcode = " << proc->exitCode() << ",exitStatus = " << exitStatus;
proc->startUKUIModule();
proc->restartNum++;
return;
}
}
mNameMap.remove(proc->fileName);
proc->deleteLater();
}
bool ModuleManager::getIsShutingDown() const
{
return isShutingDown;
}
void ModuleManager::setIsShutingDown(bool value)
{
isShutingDown = value;
}
void ModuleManager::logout(bool doExit)
{
// /org/freedesktop/login1/session/self 和 /org/freedesktop/login1/session/auto
//有什么区别
QDBusInterface face("org.freedesktop.login1",\
"/org/freedesktop/login1/session/self",\
"org.freedesktop.login1.Session",\
QDBusConnection::systemBus());
if (doExit) {
face.call("Terminate");
exit(0);
}
}
void ModuleManager::ChkScreenLockStartup()
{
QDBusInterface *iface = new QDBusInterface(SSWND_DBUS_SERVICE,
SSWND_DBUS_PATH,
SSWND_DBUS_INTERFACE,
QDBusConnection::sessionBus(),
this);
if (iface && iface->isValid()) {
QDBusReply reply = iface->call("IsStartupMode");
if (reply.isValid()) {
qDebug()<<"ScreenLockStartup:"<