From 44d9aaf10b9ee9edfa061c6c0d5c55c2ee316348 Mon Sep 17 00:00:00 2001 From: tsic404 Date: Mon, 13 May 2024 13:46:40 +0800 Subject: [PATCH 1/2] feat: remove uos-ai plugin when uos ai uninstalled log: as title --- .../dock/tray/plugins/uos-ai/CMakeLists.txt | 13 +++++- .../dbus/org.desktopspec.ObjectManager1.xml | 20 +++++++++ .../dock/tray/plugins/uos-ai/dbus/types/am.h | 20 +++++++++ .../dock/tray/plugins/uos-ai/uosaiplugin.cpp | 41 ++++++++++++++++++- 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 panels/dock/tray/plugins/uos-ai/dbus/org.desktopspec.ObjectManager1.xml create mode 100644 panels/dock/tray/plugins/uos-ai/dbus/types/am.h diff --git a/panels/dock/tray/plugins/uos-ai/CMakeLists.txt b/panels/dock/tray/plugins/uos-ai/CMakeLists.txt index 97055d885..e2f63a50b 100644 --- a/panels/dock/tray/plugins/uos-ai/CMakeLists.txt +++ b/panels/dock/tray/plugins/uos-ai/CMakeLists.txt @@ -11,8 +11,19 @@ find_package(Qt6 REQUIRED COMPONENTS Svg DBus Widgets) find_package(Dtk6Widget REQUIRED) find_package(Dtk6Gui REQUIRED) +set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/dbus/org.desktopspec.ObjectManager1.xml + PROPERTIES INCLUDE dbus/types/am.h + CLASSNAME ObjectManager +) + +qt_add_dbus_interfaces( + DBUS_INTERFACES + ${CMAKE_CURRENT_SOURCE_DIR}/dbus/org.desktopspec.ObjectManager1.xml +) + add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN") -add_library(${PLUGIN_NAME} SHARED ${SRCS} plugin-tray.qrc) +add_library(${PLUGIN_NAME} SHARED ${SRCS} ${DBUS_INTERFACES} plugin-tray.qrc) set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../quick-trays) target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ../../interfaces diff --git a/panels/dock/tray/plugins/uos-ai/dbus/org.desktopspec.ObjectManager1.xml b/panels/dock/tray/plugins/uos-ai/dbus/org.desktopspec.ObjectManager1.xml new file mode 100644 index 000000000..9c5884245 --- /dev/null +++ b/panels/dock/tray/plugins/uos-ai/dbus/org.desktopspec.ObjectManager1.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/panels/dock/tray/plugins/uos-ai/dbus/types/am.h b/panels/dock/tray/plugins/uos-ai/dbus/types/am.h new file mode 100644 index 000000000..969737bc4 --- /dev/null +++ b/panels/dock/tray/plugins/uos-ai/dbus/types/am.h @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +// from am global.h +#include +#include +#include + +using ObjectInterfaceMap = QMap; +using ObjectMap = QMap; +using QStringMap = QMap; +using PropMap = QMap; + +Q_DECLARE_METATYPE(ObjectInterfaceMap) +Q_DECLARE_METATYPE(ObjectMap) +Q_DECLARE_METATYPE(QStringMap) +Q_DECLARE_METATYPE(PropMap) diff --git a/panels/dock/tray/plugins/uos-ai/uosaiplugin.cpp b/panels/dock/tray/plugins/uos-ai/uosaiplugin.cpp index 5ad9cf7ab..135de566c 100644 --- a/panels/dock/tray/plugins/uos-ai/uosaiplugin.cpp +++ b/panels/dock/tray/plugins/uos-ai/uosaiplugin.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "uosaiplugin.h" +#include "objectmanager1interface.h" #include #include @@ -17,6 +18,10 @@ using namespace uos_ai; #define QUICK_ITEM_KEY QStringLiteral("quick_item_key") #define PLUGIN_STATE_KEY "enable" +static const QString AM_DBUS_PATH = "org.desktopspec.ApplicationManager1"; +static const QString UOS_AI_AM_PATH = "/org/desktopspec/ApplicationManager1/uos_2dai_2dassistant"; +static ObjectManager desktopobjectManager(AM_DBUS_PATH, "/org/desktopspec/ApplicationManager1", QDBusConnection::sessionBus()); + UosAiPlugin::UosAiPlugin(QObject *parent) : QObject(parent) , m_tipsLabel(new QLabel) @@ -32,6 +37,40 @@ UosAiPlugin::UosAiPlugin(QObject *parent) changeTheme(); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &UosAiPlugin::changeTheme); + const auto reply = desktopobjectManager.GetManagedObjects(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *call){ + QDBusPendingReply reply = *call; + if (reply.isError()) { + call->deleteLater(); + return; + } + + const auto objects = reply.value(); + for (auto iter = objects.cbegin(); iter != objects.cend(); ++iter) { + const auto &objPath = iter.key(); + if (objPath.path() == UOS_AI_AM_PATH) { + m_pluginLoaded = true; + break; + } + } + call->deleteLater(); + }); + watcher->waitForFinished(); + + connect(&desktopobjectManager, &ObjectManager::InterfacesRemoved, this, [this] (const QDBusObjectPath& path, const QStringList& interfaces) { + if (path.path() == UOS_AI_AM_PATH) { + m_pluginLoaded = false; + pluginStateSwitched(); + } + }); + + connect(&desktopobjectManager, &ObjectManager::InterfacesAdded, this, [this] (const QDBusObjectPath& path, const ObjectInterfaceMap& info) { + if (path.path() == UOS_AI_AM_PATH) { + m_pluginLoaded = true; + pluginStateSwitched(); + } + }); #ifdef USE_DOCK_API_V2 QDBusConnection::sessionBus().connect("com.deepin.copilot", "/com/deepin/copilot", "com.deepin.copilot", "windowVisibleChanged", this, SLOT(onUosAiVisibleChanged(bool))); QDBusConnection::sessionBus().connect("com.deepin.copilot", "/com/deepin/copilot", "com.deepin.copilot", "windowActiveChanged", this, SLOT(onUosAiVisibleChanged(bool))); @@ -139,7 +178,7 @@ void UosAiPlugin::pluginStateSwitched() bool UosAiPlugin::pluginIsDisable() { - return !m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool(); + return !(m_pluginLoaded && m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool()); } #ifdef USE_V23_DOCK From 266f26ff21ba5329eaa8af6b1a031cd0a089af83 Mon Sep 17 00:00:00 2001 From: tsic404 Date: Mon, 13 May 2024 14:09:39 +0800 Subject: [PATCH 2/2] chore: release version 0.0.19 log: as title --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 9a3ab2074..50c15873b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dde-shell (0.0.19) unstable; urgency=medium + + * feat: remove uos-ai plugin when uos ai uninstalled + + -- tsic404 Mon, 13 May 2024 14:09:19 +0800 + dde-shell (0.0.18) unstable; urgency=medium * feat: add tray dci icons(Issue: https://github.com/linuxdeepin/developer-center/issues/8082)