Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif ()
include(GNUInstallDirs)

set(QT_VERSION_MAJOR 6)
set(DTK_VERSION_MAJOR 6)

macro(install_symlink filepath wantsdir)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/link/${wantsdir}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/lib/systemd/user/${filepath} ${PROJECT_BINARY_DIR}/link/${wantsdir}/${filepath})
Expand Down
5 changes: 5 additions & 0 deletions dbus/types/sessionpathlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

typedef QList<SessionPath> SessionPathList;

inline bool operator !=(const SessionPathList &list1, const SessionPathList &list2)
{
return list1.size() != list2.size() || list1 != list2;
}

Q_DECLARE_METATYPE(SessionPathList)

void registerSessionPathListMetaType();
Expand Down
7 changes: 3 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ Maintainer: Deepin Packages Builder <packages@deepin.com>
Build-Depends:
cmake,
debhelper-compat (= 11),
libdtkcore-dev (>=5.4.14),
libdtkcore5-bin,
libdtk6core-dev,
libdtk6core-bin,
libglib2.0-dev,
libgsettings-qt-dev,
libsecret-1-dev,
libsystemd-dev,
libx11-dev,
libxcursor-dev,
libxfixes-dev,
pkg-config,
qtbase5-dev,
qt6-base-dev,
Standards-Version: 4.1.3
Homepage: https://www.deepin.org

Expand Down
10 changes: 7 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
find_package(DtkTools REQUIRED)
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Tools)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

Expand All @@ -9,13 +13,13 @@ set(CMAKE_CXX_FLAGS "-W -Wall -fPIC -fstack-protector-all -z relro -z noexecstac
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/dbusinterface/)
set(QT_DBUS_INTERFACE_INCLUDE ${PROJECT_BINARY_DIR}/dbusinterface/)

macro(qt5_add_dbus_interface_fix srcs xml class file)
macro(qt_add_dbus_interface_fix srcs xml class file)
execute_process(COMMAND ${DTK_XML2CPP} -c ${class} -p ${PROJECT_BINARY_DIR}/dbusinterface/${file} ${PROJECT_SOURCE_DIR}/dbus/interface/${xml})
list(APPEND ${srcs}
${PROJECT_BINARY_DIR}/dbusinterface/${file}.h
${PROJECT_BINARY_DIR}/dbusinterface/${file}.cpp
)
endmacro(qt5_add_dbus_interface_fix)
endmacro(qt_add_dbus_interface_fix)

# qtdbusextended
set(DBUS_INCLUDE ${PROJECT_SOURCE_DIR}/dbus/)
Expand Down
15 changes: 9 additions & 6 deletions src/dde-session-ctl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5 COMPONENTS Core DBus REQUIRED)
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core DBus)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
qt5_add_dbus_interface(DBUS_SOURCES
qt_add_dbus_interface(DBUS_SOURCES
../../dbus/adaptor/org.deepin.dde.Session1.xml
Session
)

add_executable(dde-session-ctl
main.cpp
${DBUS_SOURCES}
../../dbus/adaptor/org.deepin.dde.Session1.xml
main.cpp
${DBUS_SOURCES}
../../dbus/adaptor/org.deepin.dde.Session1.xml
)
target_link_libraries(dde-session-ctl
Qt${QT_VERSION_MAJOR}::Core
Expand Down
64 changes: 34 additions & 30 deletions src/dde-session/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
#find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5 COMPONENTS Core Concurrent DBus REQUIRED)
find_package(DtkCore REQUIRED)
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Concurrent DBus REQUIRED)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Systemd REQUIRED IMPORTED_TARGET libsystemd)
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
pkg_check_modules(GLIB2 REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO2 REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(XCURSOR REQUIRED IMPORTED_TARGET xcursor)
pkg_check_modules(XFIXES REQUIRED IMPORTED_TARGET xfixes)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)

# dbus adaptor
qt5_add_dbus_adaptor(ADAPTER_SOURCES
qt_add_dbus_adaptor(ADAPTER_SOURCES
../../dbus/adaptor/org.deepin.dde.Session1.xml
impl/session.h
Session)
qt5_add_dbus_adaptor(ADAPTER_SOURCES
Session
)
qt_add_dbus_adaptor(ADAPTER_SOURCES
../../dbus/adaptor/org.deepin.dde.SessionManager1.xml
impl/sessionmanager.h
SessionManager)
qt5_add_dbus_adaptor(ADAPTER_SOURCES
SessionManager
)
qt_add_dbus_adaptor(ADAPTER_SOURCES
../../dbus/adaptor/org.deepin.dde.Inhibitor1.xml
impl/inhibitor.h
Inhibitor)
qt5_add_dbus_adaptor(ADAPTER_SOURCES
Inhibitor
)
qt_add_dbus_adaptor(ADAPTER_SOURCES
../../dbus/adaptor/org.deepin.dde.WMSwitcher1.xml
impl/wmswitcher.h
WMSwitcher)
WMSwitcher
)

# dbus interface
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.PowerManager1.xml PowerManager org_deepin_dde_PowerManager1)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Bluetooth1.xml Bluetooth org_deepin_dde_Bluetooth1)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Daemon1.xml SessionDaemon org_deepin_dde_Daemon1)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.Manager.xml Login1Manager org_freedesktop_login1_Manager)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.Session.xml Login1Session org_freedesktop_login1_Session)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.User.xml Login1User org_freedesktop_login1_User)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.DBus.xml DBus org_freedesktop_DBus)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.systemd1.Manager.xml Systemd1Manager org_freedesktop_systemd1_Manager)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.systemd1.Job.xml Systemd1Job org_freedesktop_systemd1_Job)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Audio1.xml Audio1 org_deepin_dde_Audio1)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Audio1.Sink.xml Sink org_deepin_dde_Audio1_Sink)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.SoundThemePlayer1.xml SoundThemePlayer org_deepin_dde_SoundThemePlayer1)
qt5_add_dbus_interface_fix(INTERFACE_SOURCES com.deepin.wm.xml DeepinWm com_deepin_Wm)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.PowerManager1.xml PowerManager org_deepin_dde_PowerManager1)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Bluetooth1.xml Bluetooth org_deepin_dde_Bluetooth1)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Daemon1.xml SessionDaemon org_deepin_dde_Daemon1)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.Manager.xml Login1Manager org_freedesktop_login1_Manager)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.Session.xml Login1Session org_freedesktop_login1_Session)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.login1.User.xml Login1User org_freedesktop_login1_User)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.DBus.xml DBus org_freedesktop_DBus)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.systemd1.Manager.xml Systemd1Manager org_freedesktop_systemd1_Manager)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.freedesktop.systemd1.Job.xml Systemd1Job org_freedesktop_systemd1_Job)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Audio1.xml Audio1 org_deepin_dde_Audio1)
qt_add_dbus_interface_fix(INTERFACE_SOURCES org.deepin.dde.Audio1.Sink.xml Sink org_deepin_dde_Audio1_Sink)
qt_add_dbus_interface_fix(INTERFACE_SOURCES com.deepin.wm.xml DeepinWm com_deepin_Wm)

file(GLOB_RECURSE DBUS_TYPES ${PROJECT_SOURCE_DIR}/dbus/types/*)

Expand Down Expand Up @@ -74,26 +79,25 @@ add_executable(dde-session
${ADAPTER_SOURCES}
${INTERFACE_SOURCES}
${DBUS_TYPES}
)
)

target_link_libraries(dde-session
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Concurrent
PkgConfig::Systemd
${DtkCore_LIBRARIES}
Dtk${DTK_VERSION_MAJOR}::Core
PkgConfig::GLIB2
PkgConfig::GIO2
PkgConfig::QGSettings
PkgConfig::XCURSOR
PkgConfig::XFIXES
PkgConfig::X11
)
)

target_include_directories(dde-session PUBLIC
../
${QT_DBUS_INTERFACE_INCLUDE}
${DBUS_INCLUDE}
)
)

install(TARGETS dde-session DESTINATION ${CMAKE_INSTALL_BINDIR})
11 changes: 10 additions & 1 deletion src/dde-session/environmentsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ void EnvironmentsManager::init()

void EnvironmentsManager::createGeneralEnvironments()
{
double scaleFactor = Utils::SettingValue("com.deepin.xsettings", QByteArray(), "scale-factor", 1.0).toDouble();
double scaleFactor = 1.0;
QDBusInterface dbusInterface("org.deepin.dde.XSettings1", "/org/deepin/dde/XSettings1",
"org.deepin.dde.XSettings1", QDBusConnection::sessionBus());
if (dbusInterface.isValid()) {
QDBusReply<double> scaleFactorReply = dbusInterface.call("GetScaleFactor");
if (scaleFactorReply.isValid()) {
scaleFactor = scaleFactorReply.value();
}
}

auto envs = QProcessEnvironment::systemEnvironment();
auto keys = envs.keys();

Expand Down
69 changes: 47 additions & 22 deletions src/dde-session/impl/sessionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
#include "utils/dconf.h"
#include "utils/utils.h"
#include "org_deepin_dde_Audio1_Sink.h"
#include "org_deepin_dde_SoundThemePlayer1.h"

#include <QCoreApplication>
#include <QDBusReply>
#include <QDBusObjectPath>
#include <QGSettings>
#include <QStandardPaths>
#include <QJsonDocument>

Expand Down Expand Up @@ -89,6 +87,14 @@ SessionManager::SessionManager(QObject *parent)
if (canPlayEvent("desktop-login")) {
playLoginSound();
}

auto appearanceConfig = DConfig::create("org.deepin.dde.appearance", "org.deepin.dde.appearance", QString(), this);
m_soundTheme = appearanceConfig->value("Sound_Theme", "deepin").toString();
connect(appearanceConfig, &DConfig::valueChanged, this, [this, appearanceConfig] (const QString &key) {
if (key == "Sound_Theme") {
m_soundTheme = appearanceConfig->value("Sound_Theme", "deepin").toString();
}
});
}

SessionManager::~SessionManager()
Expand Down Expand Up @@ -667,15 +673,14 @@ void SessionManager::preparePlayShutdownSound()
{
const QString &soundFile = "/tmp/deepin-shutdown-sound.json";

const QString &soundTheme = Utils::SettingValue(APPEARANCE_SCHEMA, QByteArray(), APPEARANCE_SOUND_THEME_KEY, QString()).toString();
const QString &event = "system-shutdown";
bool canPlay = canPlayEvent(event);
QString device; // TODO

QJsonObject obj;
obj["Event"] = event;
obj["CanPlay"] = canPlay;
obj["Theme"] = soundTheme;
obj["Theme"] = m_soundTheme;
obj["Device"] = device;

QFile file(soundFile);
Expand All @@ -693,15 +698,38 @@ bool SessionManager::canPlayEvent(const QString &event)
return false;
}

if (!Utils::SettingValue(SOUND_EFFECT_SCHEMA, QByteArray(), SOUND_EFFECT_ENABLED_KEY, false).toBool()) {
const QString service = "org.deepin.dde.SoundEffect1";
const QString path = "/org/deepin/dde/SoundEffect1";
const QString interface = "org.freedesktop.DBus.Properties";
const QString methodInterface = "org.deepin.dde.SoundEffect1";

QDBusInterface dbusInterface(service, path, interface, QDBusConnection::sessionBus());
if (!dbusInterface.isValid()) {
return false;
}

if (!Utils::SettingValue(SOUND_EFFECT_SCHEMA, QByteArray(), event, false).toBool()) {
QDBusReply<bool> enabledReply = dbusInterface.call("Get", service, "Enabled");
if (enabledReply.isValid()) {
if (!enabledReply.value()) {
return false;
}
} else {
qWarning() << "Failed to call Get:" << enabledReply.error().message();
return false;
}

return true;
QDBusInterface methodInterfaceObj(service, path, methodInterface, QDBusConnection::sessionBus());
if (!methodInterfaceObj.isValid()) {
return false;
}

QDBusReply<bool> isSoundEnabledReply = methodInterfaceObj.call("IsSoundEnabled", event);
if (isSoundEnabledReply.isValid()) {
return isSoundEnabledReply.value();
}

qWarning() << "Failed to call IsSoundEnabled:" << event << isSoundEnabledReply.error().message();
return false;
}

void SessionManager::playLoginSound()
Expand Down Expand Up @@ -735,14 +763,7 @@ void SessionManager::playLoginSound()
return;

qInfo() << "play system sound: desktop-login";
auto soundTheme = Utils::SettingValue(APPEARANCE_SCHEMA, QByteArray(), APPEARANCE_SOUND_THEME_KEY, QString()).toString();
org::deepin::dde::SoundThemePlayer1 inter("org.deepin.dde.SoundThemePlayer1", "/org/deepin/dde/SoundThemePlayer1", QDBusConnection::systemBus(), this);
QDBusPendingReply<> reply = inter.Play(soundTheme, "desktop-login", QString());
if (reply.isError()) {
qWarning() << "failed to play login sound, error: " << reply.error().name();
} else {
qDebug() << "success to play system sound: desktop-login";
}
playSound("desktop-login");

// 播放后创建文件
QFile file(markFile);
Expand Down Expand Up @@ -776,13 +797,7 @@ void SessionManager::playLogoutSound()
// 始终在注销前退出pulseaudio服务
stopPulseAudioService();

auto soundTheme = Utils::SettingValue(APPEARANCE_SCHEMA, QByteArray(), APPEARANCE_SOUND_THEME_KEY, QString()).toString();
org::deepin::dde::SoundThemePlayer1 inter("org.deepin.dde.SoundThemePlayer1", "/org/deepin/dde/SoundThemePlayer1", QDBusConnection::systemBus(), this);
// TODO device?
QDBusReply<void> reply = inter.Play(soundTheme, "desktop-logout", "");
if (!reply.isValid()) {
qWarning() << "failed to play logout sound, error: " << reply.error().name();
}
playSound("desktop-logout");
}

void SessionManager::setDPMSMode(bool on)
Expand Down Expand Up @@ -880,6 +895,16 @@ void SessionManager::emitCurrentUidChanged(QString uid)
// 这个属性不会变化
}

inline void SessionManager::playSound(const QString &event)
{
QDBusInterface soundPlayerInter("org.deepin.dde.SoundThemePlayer1", "/org/deepin/dde/SoundThemePlayer1",
"org.deepin.dde.SoundThemePlayer1", QDBusConnection::systemBus());
QDBusMessage reply = soundPlayerInter.call("Play", m_soundTheme, event, QString());
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << "Failed to call Play:" << event << reply.errorMessage();
}
}

void SessionManager::handleLoginSessionLocked()
{
qDebug() << "login session locked." << locked();
Expand Down
3 changes: 3 additions & 0 deletions src/dde-session/impl/sessionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public Q_SLOTS:
void emitCurrentSessionPathChanged(QDBusObjectPath);
void emitCurrentUidChanged(QString);

void playSound(const QString &event);

private Q_SLOTS:
void handleLoginSessionLocked();
void handleLoginSessionUnlocked();
Expand All @@ -126,6 +128,7 @@ private Q_SLOTS:
private:
bool m_locked;
QString m_currentUid;
QString m_soundTheme;
int m_stage;
QDBusObjectPath m_currentSessionPath;

Expand Down
3 changes: 3 additions & 0 deletions src/dde-session/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ int main(int argc, char *argv[])
OthersManager().init();
});

#if 0 //TODO has no 'com.deepin.dde.startdde' gsetting
// cpu iowait状态检测
if (Utils::SettingValue("com.deepin.dde.startdde", QByteArray(), "iowait-enabled", false).toBool()) {
QtConcurrent::run([] {
Expand All @@ -140,6 +141,8 @@ int main(int argc, char *argv[])
} else {
qInfo() << "iowait watcher disabled";
}
#endif
qInfo() << "iowait watcher disabled";

QtConcurrent::run([&session](){
qInfo()<< "systemd service pipe thread id: " << QThread::currentThreadId();
Expand Down
Loading
Loading