feat: add app-update-notifier
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
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;
|
||||
}
|
Reference in New Issue
Block a user