feat: add app-update-notifier
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
ebe218b70e
commit
94db47a015
@ -24,7 +24,7 @@ Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
# DBus API
|
||||
Files: api/dbus/*.xml
|
||||
Files: api/dbus/*.xml apps/app-update-notifier/api/dbus/*.xml
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
|
@ -21,6 +21,7 @@ find_package(Qt6 REQUIRED COMPONENTS Core DBus Concurrent)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(APP_LAUNCH_HELPER_BIN app-launch-helper)
|
||||
set(APP_UPDATE_NOTIFIER_BIN app-update-notifier)
|
||||
|
||||
if(DDE_AM_USE_DEBUG_DBUS_NAME)
|
||||
add_compile_definitions(-DDDE_AM_USE_DEBUG_DBUS_NAME)
|
||||
|
@ -1,3 +1,3 @@
|
||||
add_subdirectory(dde-application-manager)
|
||||
add_subdirectory(app-launch-helper)
|
||||
|
||||
add_subdirectory(app-update-notifier)
|
||||
|
2
apps/app-update-notifier/CMakeLists.txt
Normal file
2
apps/app-update-notifier/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(misc)
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "https://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.desktopspec.ApplicationUpdateNotifier1">
|
||||
<signal name="ApplicationUpdated">
|
||||
<annotation
|
||||
name="org.freedesktop.DBus.Description"
|
||||
value="This signal will emit when application's
|
||||
infomations need to update."
|
||||
/>
|
||||
</signal>
|
||||
</interface>
|
||||
</node>
|
32
apps/app-update-notifier/misc/CMakeLists.txt
Normal file
32
apps/app-update-notifier/misc/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
include(GNUInstallDirs)
|
||||
|
||||
configure_file(
|
||||
systemd/system/org.desktopspec.ApplicationUpdateNotifier1.service.in
|
||||
systemd/system/org.desktopspec.ApplicationUpdateNotifier1.service
|
||||
@ONLY
|
||||
)
|
||||
|
||||
set(SYSTEMD_SYSTEM_FILE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/systemd/system/org.desktopspec.ApplicationUpdateNotifier1.service
|
||||
)
|
||||
|
||||
install(FILES ${SYSTEMD_SYSTEM_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system/)
|
||||
|
||||
configure_file(
|
||||
dbus/org.desktopspec.ApplicationUpdateNotifier1.service.in
|
||||
dbus/org.desktopspec.ApplicationUpdateNotifier1.service
|
||||
@ONLY
|
||||
)
|
||||
|
||||
set(DBUS_APPLICATION_UPDATE_NOTIFIER_SERVICE_FILE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dbus/org.desktopspec.ApplicationUpdateNotifier1.service
|
||||
)
|
||||
|
||||
install(FILES ${DBUS_APPLICATION_UPDATE_NOTIFIER_SERVICE_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/service)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_LIST_DIR}/dbus/org.desktopspec.ApplicationUpdateNotifier1.conf
|
||||
DESTINATION /usr/share/dbus-1/system.d)
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
-->
|
||||
<!-- -*- XML -*- -->
|
||||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<!-- Only root can own the service -->
|
||||
<policy user="root">
|
||||
<allow own="org.desktopspec.ApplicationUpdateNotifier1"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<allow send_destination="org.desktopspec.ApplicationUpdateNotifier1"/>
|
||||
<allow receive_sender="org.desktopspec.ApplicationUpdateNotifier1"/>
|
||||
</policy>
|
||||
<!-- Only allow @LINGLONG_USERNAME@ to invoke methods on the interfaces -->
|
||||
<policy user="root">
|
||||
<allow send_destination="org.desktopspec.ApplicationUpdateNotifier1"/>
|
||||
</policy>
|
||||
</busconfig>
|
@ -0,0 +1,9 @@
|
||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
[D-BUS Service]
|
||||
Name=org.desktopspec.ApplicationUpdateNotifier1
|
||||
Exec=@CMAKE_INSTALL_FULL_BINDIR@/app-update-notifier
|
||||
User=root
|
||||
SystemdService=org.desktopspec.ApplicationUpdateNotifier1
|
@ -0,0 +1,13 @@
|
||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
[Unit]
|
||||
Description=Notify by signal when Application changed by package manager.
|
||||
|
||||
[Service]
|
||||
Type=dbus
|
||||
User=root
|
||||
Group=root
|
||||
BusName=org.desktopspec.ApplicationUpdateNotifier1
|
||||
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/app-update-notifier
|
14
apps/app-update-notifier/src/CMakeLists.txt
Normal file
14
apps/app-update-notifier/src/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
add_subdirectory(dbus)
|
||||
|
||||
add_executable(${APP_UPDATE_NOTIFIER_BIN} main.cpp)
|
||||
|
||||
target_link_libraries(${APP_UPDATE_NOTIFIER_BIN} PRIVATE
|
||||
app_update_notifier_static
|
||||
)
|
||||
|
||||
target_include_directories(${APP_UPDATE_NOTIFIER_BIN} PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/src
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS ${APP_UPDATE_NOTIFIER_BIN} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager/)
|
20
apps/app-update-notifier/src/dbus/CMakeLists.txt
Normal file
20
apps/app-update-notifier/src/dbus/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
file(GLOB_RECURSE app_update_notifier_static_SOURCE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
||||
)
|
||||
|
||||
qt_add_dbus_adaptor(app_update_notifier_static_SOURCE ${CMAKE_CURRENT_LIST_DIR}/../../api/dbus/org.desktopspec.ApplicationUpdateNotifier1.xml dbus/applicationupdatenotifier1service.h ApplicationUpdateNotifier1Service)
|
||||
|
||||
add_library(app_update_notifier_static STATIC ${app_update_notifier_static_SOURCE})
|
||||
|
||||
target_link_libraries(
|
||||
app_update_notifier_static PUBLIC
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::DBus
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
app_update_notifier_static PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR}/..
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dbus/applicationupdatenotifier1adaptor.h"
|
||||
|
||||
ApplicationUpdateNotifier1Service::ApplicationUpdateNotifier1Service()
|
||||
{
|
||||
new ApplicationUpdateNotifier1Adaptor{this};
|
||||
auto conn = QDBusConnection::systemBus();
|
||||
if (!conn.registerService(NotifierServiceName)) {
|
||||
qFatal("%s", conn.lastError().message().toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
if (!conn.registerObject(NotifierObjectPath, NotifierInterfaceName, this, QDBusConnection::ExportAdaptors)) {
|
||||
qFatal("%s", conn.lastError().message().toLocal8Bit().constData());
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#ifndef APPLICATIONUPDATENOTIFIER1SERVICE_H
|
||||
#define APPLICATIONUPDATENOTIFIER1SERVICE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
constexpr auto NotifierServiceName = "org.desktopspec.ApplicationUpdateNotifier1";
|
||||
constexpr auto NotifierObjectPath = "/org/desktopspec/ApplicationUpdateNotifier1";
|
||||
constexpr auto NotifierInterfaceName = "org.desktopspec.ApplicationUpdateNotifier1";
|
||||
|
||||
class ApplicationUpdateNotifier1Service : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ApplicationUpdateNotifier1Service();
|
||||
~ApplicationUpdateNotifier1Service() override = default;
|
||||
Q_SIGNALS:
|
||||
void ApplicationUpdated();
|
||||
};
|
||||
|
||||
#endif
|
12
apps/app-update-notifier/src/main.cpp
Normal file
12
apps/app-update-notifier/src/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "dbus/applicationupdatenotifier1service.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
ApplicationUpdateNotifier1Service service;
|
||||
emit service.ApplicationUpdated();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user