diff -Nru ukui-service-manager-0.1.0/debian/changelog ukui-service-manager-0.1.0/debian/changelog --- ukui-service-manager-0.1.0/debian/changelog 2024-12-21 11:20:41.000000000 +0800 +++ ukui-service-manager-0.1.0/debian/changelog 2025-03-27 15:03:37.000000000 +0800 @@ -1,3 +1,9 @@ +ukui-service-manager (0.1.0-ok2~0327) huanghe; urgency=medium + + * 添加子服务配置和注册选项配置规则 + + -- Yue Lan <lanyue@kylinos.cn> Thu, 27 Mar 2025 15:03:37 +0800 + ukui-service-manager (0.1.0-ok1~1221) huanghe; urgency=medium * fix #311181 diff -Nru ukui-service-manager-0.1.0/debian/patches/0004-registeroptions.patch ukui-service-manager-0.1.0/debian/patches/0004-registeroptions.patch --- ukui-service-manager-0.1.0/debian/patches/0004-registeroptions.patch 1970-01-01 08:00:00.000000000 +0800 +++ ukui-service-manager-0.1.0/debian/patches/0004-registeroptions.patch 2025-03-27 15:03:37.000000000 +0800 @@ -0,0 +1,233 @@ +From: Yue-Lan <lanyue@kylinos.cn> +Date: Tue, 25 Mar 2025 10:23:55 +0800 +Subject: =?utf-8?b?5L+u5aSN5a2Q5pyN5YqhcmVnaXN0ZXJvcHRpb25z6Kej5p6Q6ZSZ6K+v?= + =?utf-8?b?6Zeu6aKY?= + +--- + service-plugin-demo/demoservice2.cpp | 4 +- + service-plugin-demo/service-plugin-demo.json | 17 ++++++- + src/libukuiservice/serviceregister.cpp | 1 + + .../sessionservicelauncher.cpp | 56 +++++++++++++++++++-- + src/ukui-system-service/systemservicelauncher.cpp | 57 ++++++++++++++++++++-- + 5 files changed, 125 insertions(+), 10 deletions(-) + +diff --git a/service-plugin-demo/demoservice2.cpp b/service-plugin-demo/demoservice2.cpp +index cb20c5a..008d3dc 100644 +--- a/service-plugin-demo/demoservice2.cpp ++++ b/service-plugin-demo/demoservice2.cpp +@@ -1,9 +1,11 @@ + #include "demoservice2.h" ++#include <QVariant> + + DemoService2::DemoService2(QObject *parent) + : UKUI::ServiceObject{parent} + { +- ++ setProperty("demo2sub", QVariant::fromValue(this)); ++ setProperty("demo2sub2", QVariant::fromValue(this)); + } + + void DemoService2::test2() +diff --git a/service-plugin-demo/service-plugin-demo.json b/service-plugin-demo/service-plugin-demo.json +index 19d929f..2f1b89f 100644 +--- a/service-plugin-demo/service-plugin-demo.json ++++ b/service-plugin-demo/service-plugin-demo.json +@@ -12,7 +12,22 @@ + "path" : "/org/ukui/service", + "interface" : "org.ukui.service.demo2", + "resident" : true, +- "namespace" : "Default" ++ "namespace" : "Default", ++ "registeroptions" : "0x01", ++ "subservices" : [ ++ { ++ "serviceobjectname" : "demo2sub", ++ "path" : "/org/ukui/service/demo2", ++ "interface" : "org.ukui.service.demo2sub", ++ "registeroptions" : "0x01" ++ }, ++ { ++ "serviceobjectname" : "demo2sub2", ++ "path" : "/org/ukui/service/demo2other", ++ "interface" : "org.ukui.service.demo2subother", ++ "registeroptions" : "0x01" ++ } ++ ] + } + ] + } +diff --git a/src/libukuiservice/serviceregister.cpp b/src/libukuiservice/serviceregister.cpp +index b65d8e9..83d60d6 100644 +--- a/src/libukuiservice/serviceregister.cpp ++++ b/src/libukuiservice/serviceregister.cpp +@@ -30,6 +30,7 @@ bool ServiceRegister::registerServiceByPlugin(const QString &pluginPath) + l.setFileName(pluginPath); + + if (!l.load()) { ++ qWarning() << l.errorString(); + return false; + } + +diff --git a/src/ukui-session-service/sessionservicelauncher.cpp b/src/ukui-session-service/sessionservicelauncher.cpp +index 631c9e1..1f99b64 100644 +--- a/src/ukui-session-service/sessionservicelauncher.cpp ++++ b/src/ukui-session-service/sessionservicelauncher.cpp +@@ -57,6 +57,12 @@ bool SessionServiceLauncher::launchServices(const QString &pluginPath, const QSt + + QString servicePath = serviceObject["path"].toString(); + QString serviceInterface = serviceObject["interface"].toString(); ++ QString serviceRegisterOptions = serviceObject["registeroptions"].toString(); ++ bool useCustomServiceRegisterOptions = false; ++ if (!serviceRegisterOptions.isEmpty()) { ++ useCustomServiceRegisterOptions = true; ++ qDebug() << serviceName << "has customRegisterOptions" << serviceRegisterOptions; ++ } + qDebug() << jsonObj; + + Q_ASSERT(!serviceName.isEmpty()); +@@ -80,10 +86,19 @@ bool SessionServiceLauncher::launchServices(const QString &pluginPath, const QSt + + qDebug() << serviceConnection.lastError(); + +- bool objectRegistered = serviceConnection.registerObject(servicePath, serviceInterface, service, +- QDBusConnection::ExportAllSlots| +- QDBusConnection::ExportAllSignals| +- QDBusConnection::ExportAllProperties); ++ QDBusConnection::RegisterOptions options; ++ if (useCustomServiceRegisterOptions) { ++ bool ok = false; ++ options = QDBusConnection::RegisterOption(serviceRegisterOptions.toInt(&ok, 16)); ++ if (!ok) { ++ options = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ } else { ++ qDebug() << serviceName << "use custom register options" << options; ++ } ++ } else { ++ options = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ } ++ bool objectRegistered = serviceConnection.registerObject(servicePath, serviceInterface, service, options); + //Q_ASSERT(objectRegistered); + if (!objectRegistered) { + if (calledFromDBus()) { +@@ -92,6 +107,39 @@ bool SessionServiceLauncher::launchServices(const QString &pluginPath, const QSt + } + } + ++ // 加载服务插件声明的子服务 ++ // TODO: 添加子服务信息到管控相关流程中 ++ if (!serviceObject["subservices"].isNull()) { ++ auto subservices = serviceObject["subservices"].toArray(); ++ for (auto subserviceValue : subservices) { ++ if (subserviceValue.isObject()) { ++ auto subservice = subserviceValue.toObject(); ++ auto subservicename = subservice["serviceobjectname"].toString(); ++ auto subservicepath = subservice["path"].toString(); ++ auto subserviceinterface = subservice["interface"].toString(); ++ auto subserviceoptions = subservice["registeroptions"].toString(); ++ auto subserviceRegisterOptions = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ if (!subserviceoptions.isNull()) { ++ bool ok = false; ++ auto tmp = QDBusConnection::RegisterOption(subserviceoptions.toInt(&ok, 16)); ++ if (ok) { ++ subserviceRegisterOptions = tmp; ++ } ++ } ++ ++ // 从serviceobject实例中查找子服务,TODO:实现子服务的管控能力 ++ auto subserviceobject = qvariant_cast<QObject *>(service->property(subservicename.toLocal8Bit().constData())); ++ if (subserviceobject) { ++ qDebug() << serviceName << "has sub service" << subservicename << subservicepath << subserviceinterface << subserviceRegisterOptions; ++ bool subserviceRegisted = serviceConnection.registerObject(subservicepath, subserviceinterface, subserviceobject, subserviceRegisterOptions); ++ if (!subserviceRegisted) { ++ qWarning() << "failed to register" << subservicename << serviceConnection.lastError(); ++ } ++ } ++ } ++ } ++ } ++ + if (!serviceRigistered || !objectRegistered) + successed = false; + +diff --git a/src/ukui-system-service/systemservicelauncher.cpp b/src/ukui-system-service/systemservicelauncher.cpp +index 4c28023..b80f071 100644 +--- a/src/ukui-system-service/systemservicelauncher.cpp ++++ b/src/ukui-system-service/systemservicelauncher.cpp +@@ -57,6 +57,12 @@ bool SystemServiceLauncher::launchServices(const QString &pluginPath, const QStr + + QString servicePath = serviceObject["path"].toString(); + QString serviceInterface = serviceObject["interface"].toString(); ++ QString serviceRegisterOptions = serviceObject["registeroptions"].toString(); ++ bool useCustomServiceRegisterOptions = false; ++ if (!serviceRegisterOptions.isEmpty()) { ++ useCustomServiceRegisterOptions = true; ++ qDebug() << serviceName << "has customRegisterOptions" << serviceRegisterOptions; ++ } + qDebug() << jsonObj; + + Q_ASSERT(!serviceName.isEmpty()); +@@ -80,10 +86,20 @@ bool SystemServiceLauncher::launchServices(const QString &pluginPath, const QStr + + qDebug() << serviceConnection.lastError(); + +- bool objectRegistered = serviceConnection.registerObject(servicePath, serviceInterface, service, +- QDBusConnection::ExportAllSlots| +- QDBusConnection::ExportAllSignals| +- QDBusConnection::ExportAllProperties); ++ QDBusConnection::RegisterOptions options; ++ if (useCustomServiceRegisterOptions) { ++ bool ok = false; ++ options = QDBusConnection::RegisterOption(serviceRegisterOptions.toInt(&ok, 16)); ++ if (!ok) { ++ options = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ } else { ++ qDebug() << serviceName << "use custom register options" << options; ++ } ++ } else { ++ options = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ } ++ bool objectRegistered = serviceConnection.registerObject(servicePath, serviceInterface, service, options); ++ + // Q_ASSERT(objectRegistered); + if (!objectRegistered) { + if (calledFromDBus()) { +@@ -92,6 +108,39 @@ bool SystemServiceLauncher::launchServices(const QString &pluginPath, const QStr + } + } + ++ // 加载服务插件声明的子服务 ++ // TODO: 添加子服务信息到管控相关流程中 ++ if (!serviceObject["subservices"].isNull()) { ++ auto subservices = serviceObject["subservices"].toArray(); ++ for (auto subserviceValue : subservices) { ++ if (subserviceValue.isObject()) { ++ auto subservice = subserviceValue.toObject(); ++ auto subservicename = subservice["serviceobjectname"].toString(); ++ auto subservicepath = subservice["path"].toString(); ++ auto subserviceinterface = subservice["interface"].toString(); ++ auto subserviceoptions = subservice["registeroptions"].toString(); ++ auto subserviceRegisterOptions = QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals|QDBusConnection::ExportAllProperties; ++ if (!subserviceoptions.isNull()) { ++ bool ok = false; ++ auto tmp = QDBusConnection::RegisterOption(subserviceoptions.toInt(&ok, 16)); ++ if (ok) { ++ subserviceRegisterOptions = tmp; ++ } ++ } ++ ++ // 从serviceobject实例中查找子服务,TODO:实现子服务的管控能力 ++ auto subserviceobject = qvariant_cast<QObject *>(service->property(subservicename.toLocal8Bit().constData())); ++ if (subserviceobject) { ++ qDebug() << serviceName << "has sub service" << subservicename << subservicepath << subserviceinterface << subserviceRegisterOptions; ++ bool subserviceRegisted = serviceConnection.registerObject(subservicepath, subserviceinterface, subserviceobject, subserviceRegisterOptions); ++ if (!subserviceRegisted) { ++ qWarning() << "failed to register" << subservicename << serviceConnection.lastError(); ++ } ++ } ++ } ++ } ++ } ++ + if (!serviceRigistered || !objectRegistered) + successed = false; + diff -Nru ukui-service-manager-0.1.0/debian/patches/series ukui-service-manager-0.1.0/debian/patches/series --- ukui-service-manager-0.1.0/debian/patches/series 2024-12-21 11:20:41.000000000 +0800 +++ ukui-service-manager-0.1.0/debian/patches/series 2025-03-27 15:03:37.000000000 +0800 @@ -1,3 +1,4 @@ 0001-update-changelog.patch 0002-update-changelog.patch 0003-update-changelog.patch +0004-registeroptions.patch