Skip to content

Commit

Permalink
refactor: daemon refactor
Browse files Browse the repository at this point in the history
install diskencrypt dbus plugin to deepin-service-manager

Log: daemon process refactor
  • Loading branch information
Lighto-Ku authored and Johnson-zs committed Sep 5, 2024
1 parent 35ac7ea commit 8518957
Show file tree
Hide file tree
Showing 29 changed files with 3,265 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later

# ignore files
Files: src/*.json src/*.xml src/*.policy src/*/pinyin.dict src/*.js src/*.ini src/*.qss src/*.theme src/*/templates/* src/*.psd src/*/com.deepin.filemanager.daemon.conf src/dfm-base/qrc/configure/*.cpp
Files: src/*.json src/*.xml src/*.policy src/*/pinyin.dict src/*.js src/*.ini src/*.qss src/*.theme src/*/templates/* src/*.psd src/*/com.deepin.filemanager.daemon.conf src/dfm-base/qrc/configure/*.cpp src/*/*.service src/*/*.conf
Copyright: None
License: CC0-1.0

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ endif(NOT CMAKE_BUILD_TYPE)
message("Build type:"${CMAKE_BUILD_TYPE})

#Indentify the version
if (${DEEPIN_OS_VERSION} MATCHES "23")
if (${DEEPIN_OS_VERSION} MATCHES "^(23|25)$")
add_definitions(-DCOMPILE_ON_V23)
set(COMPLIE_ON_V23 TRUE)
message("COMPILE ON v23")
message("COMPILE ON v2X")
else()
add_definitions(-DCOMPILE_ON_V20)
set(COMPLIE_ON_V20 TRUE)
Expand Down
45 changes: 45 additions & 0 deletions assets/polkit/policy/org.deepin.filemanager.diskencrypt.policy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor />
<vendor_url />
<action id="org.deepin.Filemanager.DiskEncrypt.Encrypt">
<description>Disk encryption</description>
<message>Authentication is required to encrypt the disk</message>
<message xml:lang="zh_CN">加密磁盘需要认证</message>
<message xml:lang="zh_HK">加密磁片需要認證</message>
<message xml:lang="zh_TW">加密磁片需要認證</message>
<icon_name>folder</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
<action id="org.deepin.Filemanager.DiskEncrypt.Decrypt">
<description>Disk encryption</description>
<message>Authentication is required to decrypt the disk</message>
<message xml:lang="zh_CN">取消加密磁盘需要认证</message>
<message xml:lang="zh_HK">取消加密磁片需要認證</message>
<message xml:lang="zh_TW">取消加密磁片需要認證</message>
<icon_name>folder</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
<action id="org.deepin.Filemanager.DiskEncrypt.ChangePassphrase">
<description>Disk encryption</description>
<message>Authentication is required to change the passphrase of disk</message>
<message xml:lang="zh_CN">修改磁盘密码需要认证</message>
<icon_name>folder</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
</policyconfig>
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Build-Depends:
libdfm-mount-dev,
libdfm-io-dev,
dde-file-manager-dev,
libcryptsetup-dev (>= 2:2.3.7),
libdmr-dev,
libcryptsetup-dev (>= 2:2.3.7)
Standards-Version: 4.1.3
Section: libs
Homepage: http://www.deepin.org
Expand Down
7 changes: 5 additions & 2 deletions debian/dfmplugin-disk-encrypt.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ usr/share/dde-file-manager/translations/disk-encrypt*.qm

usr/lib/*/dde-file-manager/plugins/filemanager-edge/libdfmplugin_disk_encrypt.so*
usr/lib/*/dde-file-manager/plugins/filemanager-edge/libdfmplugin_encrypt_manager.so
usr/lib/*/dde-file-manager/plugins/daemon-edge/libdaemonplugin-file-encrypt.so*
usr/bin/deepin-diskencrypt-service

usr/share/dsg/configs/org.deepin.dde.file-manager/org.deepin.dde.file-manager.diskencrypt.json

usr/share/polkit-1/actions/com.deepin.filemanager.daemon.diskencrypt.policy
usr/share/deepin-service-manager/other/deepin-diskencrypt-service.json
usr/share/dbus-1/system.d/org.deepin.filemanager.diskencrypt.conf
usr/share/dbus-1/system-services/org.deepin.Filemanager.DiskEncrypt.service
usr/share/polkit-1/actions/org.deepin.filemanager.diskencrypt.policy
etc/polkit-1/localauthority/10-vendor.d/99-dde-file-manager-encrypt.pkla
4 changes: 0 additions & 4 deletions debian/dfmplugin-disk-encrypt.postinst

This file was deleted.

2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add_subdirectory(dde-file-manager-daemon)
add_subdirectory(dde-desktop)
# add_subdirectory(common)
add_subdirectory(demo)

add_subdirectory(service)
6 changes: 5 additions & 1 deletion src/dde-desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
add_subdirectory(ddplugin-videowallpaper)
option(OPT_ENABLE_VIDEOWALLPAPER OFF)

if (OPT_ENABLE_VIDEOWALLPAPER)
add_subdirectory(ddplugin-videowallpaper)
endif()
4 changes: 3 additions & 1 deletion src/dde-file-manager-daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
add_subdirectory(daemonplugin-file-encrypt)
if (COMPLIE_ON_V20)
add_subdirectory(daemonplugin-file-encrypt)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ enum TPMModuleEncType {
kUseTpmAndPrcAndPin
};

inline constexpr char kDaemonBusName[] { "com.deepin.filemanager.daemon" };
inline constexpr char kDaemonBusPath[] { "/com/deepin/filemanager/daemon/DiskEncrypt" };
inline constexpr char kDaemonBusIface[] { "com.deepin.filemanager.daemon.DiskEncrypt" };
inline constexpr char kDaemonBusName[] { "org.deepin.Filemanager" };
inline constexpr char kDaemonBusPath[] { "/org/deepin/Filemanager/DiskEncrypt" };
inline constexpr char kDaemonBusIface[] { "org.deepin.Filemanager.DiskEncrypt" };

inline constexpr char kMenuPluginName[] { "dfmplugin_menu" };
inline constexpr char kComputerMenuSceneName[] { "ComputerMenu" };
Expand Down
3 changes: 3 additions & 0 deletions src/service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (COMPLIE_ON_V23)
add_subdirectory(diskencrypt)
endif()
74 changes: 74 additions & 0 deletions src/service/diskencrypt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.0)

set(BIN_NAME "deepin-diskencrypt-service")
project(${BIN_NAME})

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 REQUIRED COMPONENTS Core Concurrent DBus)
find_package(deepin-qdbus-service REQUIRED)
find_package(dfm-framework REQUIRED)
find_package(dfm-mount REQUIRED)
find_package(dfm-base REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CryptSetup REQUIRED libcryptsetup)

add_definitions(-DSERVICE_CONFIG_DIR="${CMAKE_INSTALL_PREFIX}/share/deepin-service-manager/")

# generate dbus xml and adaptor
# DBus: DiskEncryptDBus
# qt5_generate_dbus_interface(
# diskencryptdbus.h
# diskencryptdbus.xml
# OPTIONS -M -S
#)
qt5_add_dbus_adaptor(ADAPTER_SRC
diskencryptdbus.xml
diskencryptdbus.h
DiskEncryptDBus)

file(GLOB_RECURSE SRC
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)

add_executable(${BIN_NAME}
${SRC}
${ADAPTER_SRC}
)

target_link_libraries(${BIN_NAME} PRIVATE
Qt5::Core
Qt5::Concurrent
Qt5::DBus
${CryptSetup_LIBRARIES}
${dfm-framework_LIBRARIES}
${dfm-mount_LIBRARIES}
${dfm-base_LIBRARIES}
${deepin-qdbus-service_LIBRARIES}
)

target_include_directories(${BIN_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}
${dfm-framework_INCLUDE_DIRS}
${CryptSetup_INCLUDE_DIRS}
${dfm-mount_INCLUDE_DIRS}
${deepin-qdbus-service_INCLUDE_DIR}
)

install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${PROJECT_NAME}.json DESTINATION share/deepin-service-manager/other/)
install(FILES org.deepin.filemanager.diskencrypt.conf DESTINATION share/dbus-1/system.d/)
install(FILES org.deepin.Filemanager.DiskEncrypt.service DESTINATION share/dbus-1/system-services/)

set(PolicyDir "${CMAKE_INSTALL_PREFIX}/share/polkit-1/actions")
install(FILES ${CMAKE_SOURCE_DIR}/assets/polkit/policy/org.deepin.filemanager.diskencrypt.policy
DESTINATION ${PolicyDir})
install(FILES ${CMAKE_SOURCE_DIR}/assets/polkit/rules/99-dde-file-manager-encrypt.pkla
DESTINATION /etc/polkit-1/localauthority/10-vendor.d)
10 changes: 10 additions & 0 deletions src/service/diskencrypt/deepin-diskencrypt-service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "org.deepin.Filemanager.DiskEncrypt",
"policyStartType": "OnDemand",
"idleTime": 10,
"policy": [
{
"path": "/org/deepin/Filemanager/DiskEncrypt"
}
]
}
46 changes: 46 additions & 0 deletions src/service/diskencrypt/diskencrypt_global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DAEMONPLUGIN_FILE_ENCRYPT_GLOBAL_H
#define DAEMONPLUGIN_FILE_ENCRYPT_GLOBAL_H

#include "globaltypesdefine.h"

#include <QtCore/qglobal.h>
#include <QString>
#include <QDebug>

#if defined(DAEMONPLUGIN_FILE_ENCRYPT_LIBRARY)
# define DAEMONPLUGIN_FILE_ENCRYPT_EXPORT Q_DECL_EXPORT
#else
# define DAEMONPLUGIN_FILE_ENCRYPT_EXPORT Q_DECL_IMPORT
#endif

#define FILE_ENCRYPT_NS daemonplugin_file_encrypt
#define FILE_ENCRYPT_BEGIN_NS namespace FILE_ENCRYPT_NS {
#define FILE_ENCRYPT_END_NS }
#define FILE_ENCRYPT_USE_NS using namespace FILE_ENCRYPT_NS;

FILE_ENCRYPT_BEGIN_NS

struct EncryptParams
{
QString device;
QString passphrase;
QString cipher;
QString recoveryPath;
QString tpmToken;

bool isValid() const
{
return !(device.isEmpty()
&& passphrase.isEmpty()
&& cipher.isEmpty());
}
};

inline constexpr char kDecryptHeaderPrefix[] { "dm_header_decrypt_" };

FILE_ENCRYPT_END_NS
#endif // DAEMONPLUGIN_FILE_ENCRYPT_GLOBAL_H
Loading

0 comments on commit 8518957

Please sign in to comment.