Change in kio[master]: KIO: provide own daemon (kiod) to run multiple services (mod...
David Faure (Code Review)
noreply at kde.org
Fri Jan 23 20:45:58 UTC 2015
David Faure has uploaded a new change for review.
https://gerrit.vesnicky.cesnet.cz/r/343
Change subject: KIO: provide own daemon (kiod) to run multiple services (modules).
......................................................................
KIO: provide own daemon (kiod) to run multiple services (modules).
Based on the kded idea, but without the KSycoca dependency,
the kdeinit dependency, the dir watching for kbuildsycoca,
the workspace startup phases etc. Makes KIO more independent.
The modules still inherit KDEDModule, they are just hosted by another
daemon.
In kiod, the modules are only loaded on demand via DBus calls,
and must use json.
Followup commits will convert kcookiejar, kpasswdserver, proxyscout,
and favicons.
Change-Id: I85417d324125c4ba7e80761b9c0bd0e9296a1b6c
---
M src/CMakeLists.txt
M src/core/ksslcertificatemanager.cpp
A src/kiod/CMakeLists.txt
A src/kiod/kiod_main.cpp
A src/kiod/org.kde.kiod5.service.in
M src/kssld/CMakeLists.txt
M src/kssld/kssld.cpp
M src/kssld/kssld.desktop
8 files changed, 153 insertions(+), 22 deletions(-)
git pull ssh://gerrit.vesnicky.cesnet.cz:29418/kio refs/changes/43/343/1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6405e5c..a1d644d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,8 +1,9 @@
add_subdirectory(core)
-# KIOCore-only libs
+# KIOCore-only executables
add_subdirectory(kntlm)
add_subdirectory(ioslaves)
+add_subdirectory(kiod)
add_subdirectory(kssld)
add_subdirectory(kioslave)
diff --git a/src/core/ksslcertificatemanager.cpp b/src/core/ksslcertificatemanager.cpp
index 76198eb..7dca155 100644
--- a/src/core/ksslcertificatemanager.cpp
+++ b/src/core/ksslcertificatemanager.cpp
@@ -196,7 +196,7 @@
KSslCertificateManagerPrivate::KSslCertificateManagerPrivate()
: config(QString::fromLatin1("ksslcertificatemanager"), KConfig::SimpleConfig),
- iface(new org::kde::KSSLDInterface(QString::fromLatin1("org.kde.kded5"),
+ iface(new org::kde::KSSLDInterface(QString::fromLatin1("org.kde.kssld5"),
QString::fromLatin1("/modules/kssld"),
QDBusConnection::sessionBus())),
isCertListLoaded(false),
diff --git a/src/kiod/CMakeLists.txt b/src/kiod/CMakeLists.txt
new file mode 100644
index 0000000..1ef3a25
--- /dev/null
+++ b/src/kiod/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(kiod_SRCS kiod_main.cpp)
+
+add_executable(kiod5 ${kiod_SRCS})
+
+target_link_libraries(kiod5
+ KF5::KIOCore # ksslcertificatemanager
+ KF5::DBusAddons # kdedmodule
+ KF5::CoreAddons # kpluginfactory
+ Qt5::Network
+ Qt5::DBus
+)
+
+install(TARGETS kiod5 DESTINATION ${KF5_LIBEXEC_INSTALL_DIR})
+
+configure_file(org.kde.kiod5.service.in
+ ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kiod5.service)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kiod5.service
+ DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
+
diff --git a/src/kiod/kiod_main.cpp b/src/kiod/kiod_main.cpp
new file mode 100644
index 0000000..474b04e
--- /dev/null
+++ b/src/kiod/kiod_main.cpp
@@ -0,0 +1,118 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2015 David Faure <faure at kde.org>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2 of the License or (at
+ your option) version 3 or, at the discretion of KDE e.V. (which shall
+ act as a proxy as in section 14 of the GPLv3), any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <QCoreApplication>
+#include <QHash>
+#include <QDBusMessage>
+#include <QDBusConnectionInterface>
+
+#include <KDBusService>
+#include <KDEDModule>
+#include <KPluginLoader>
+#include <KPluginFactory>
+#include <KPluginMetaData>
+
+#include <QLoggingCategory>
+Q_DECLARE_LOGGING_CATEGORY(KIOD_CATEGORY);
+Q_LOGGING_CATEGORY(KIOD_CATEGORY, "kf5.kiod");
+
+class KIOD
+{
+public:
+ KDEDModule *loadModule(const QString &name);
+
+private:
+ QHash<QString, KDEDModule *> m_modules;
+};
+
+KDEDModule *KIOD::loadModule(const QString &name)
+{
+ // Make sure this method is only called with valid module names.
+ Q_ASSERT(name.indexOf('/') == -1);
+
+ KDEDModule *module = m_modules.value(name, 0);
+ if (module) {
+ return module;
+ }
+
+ KPluginLoader loader("kf5/kiod/" + name);
+ KPluginFactory *factory = loader.factory();
+ if (factory) {
+ module = factory->create<KDEDModule>();
+ }
+ if (!module) {
+ qWarning() << "Error loading plugin:" << loader.errorString();
+ return module;
+ }
+ module->setModuleName(name); // makes it register to DBus
+ m_modules.insert(name, module);
+
+ return module;
+}
+
+Q_GLOBAL_STATIC(KIOD, self);
+
+// on-demand module loading
+// this function is called by the D-Bus message processing function before
+// calls are delivered to objects
+void messageFilter(const QDBusMessage &message)
+{
+ const QString name = KDEDModule::moduleForMessage(message);
+ if (name.isEmpty()) {
+ return;
+ }
+
+ KDEDModule *module = self()->loadModule(name);
+ if (!module) {
+ qCWarning(KIOD_CATEGORY) << "Failed to load module for" << name;
+ }
+ Q_UNUSED(module);
+}
+
+extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*)(const QDBusMessage&));
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ app.setApplicationName("kiod5");
+ app.setOrganizationDomain("kde.org");
+ KDBusService service(KDBusService::Unique);
+
+ QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
+ // Also register as all the names we should respond to (org.kde.kssld, org.kde.kcookiejar, etc.)
+ // so that the calling code is independent from the physical "location" of the service.
+ const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins("kf5/kiod");
+ qDebug() << plugins.count();
+ foreach (const KPluginMetaData &metaData, plugins) {
+ const QString serviceName = metaData.rawData().value("X-KDE-DBus-ServiceName").toString();
+ if (serviceName.isEmpty()) {
+ qWarning(KIOD_CATEGORY) << "No X-KDE-DBus-ServiceName found in" << metaData.fileName();
+ continue;
+ }
+ if (!bus->registerService(serviceName)) {
+ qWarning(KIOD_CATEGORY) << "Couldn't register name" << serviceName << "with DBUS - another process owns it already!";
+ }
+ }
+
+ qDBusAddSpyHook(messageFilter);
+
+ return app.exec();
+}
+
diff --git a/src/kiod/org.kde.kiod5.service.in b/src/kiod/org.kde.kiod5.service.in
new file mode 100644
index 0000000..0332c54
--- /dev/null
+++ b/src/kiod/org.kde.kiod5.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.kde.kiod5
+Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/kf5/kiod5
+
diff --git a/src/kssld/CMakeLists.txt b/src/kssld/CMakeLists.txt
index 040570f..bf6970c 100644
--- a/src/kssld/CMakeLists.txt
+++ b/src/kssld/CMakeLists.txt
@@ -1,14 +1,11 @@
-########### next target ###############
+########### kssld kiod module ###############
-set(kded_kssld_SRCS kssld.cpp )
+set(kssld_SRCS kssld.cpp )
-add_library(kded_kssld MODULE ${kded_kssld_SRCS})
-set_target_properties(kded_kssld PROPERTIES
- OUTPUT_NAME kssld
-)
+add_library(kssld MODULE ${kssld_SRCS})
-target_link_libraries(kded_kssld
+target_link_libraries(kssld
PUBLIC
KF5::KIOCore # ksslcertificatemanager
KF5::DBusAddons # kdedmodule
@@ -18,12 +15,7 @@
Qt5::DBus
)
-install(TARGETS kded_kssld DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kded )
+kcoreaddons_desktop_to_json(kssld kssld.desktop)
-########### install files ###############
-
-install( FILES kssld.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kded )
-
-
-
+install(TARGETS kssld DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kiod )
diff --git a/src/kssld/kssld.cpp b/src/kssld/kssld.cpp
index e3e503a..46669b6 100644
--- a/src/kssld/kssld.cpp
+++ b/src/kssld/kssld.cpp
@@ -33,8 +33,7 @@
#include <kpluginfactory.h>
#include <kpluginloader.h>
-K_PLUGIN_FACTORY(KSSLDFactory, registerPlugin<KSSLD>();)
-//KDECORE_EXPORT void *__kde_do_unload; // TODO re-add support for this?
+K_PLUGIN_FACTORY_WITH_JSON(KSSLDFactory, "kssld.json", registerPlugin<KSSLD>();)
class KSSLDPrivate
{
diff --git a/src/kssld/kssld.desktop b/src/kssld/kssld.desktop
index 4adb798..d8852fb 100644
--- a/src/kssld/kssld.desktop
+++ b/src/kssld/kssld.desktop
@@ -1,10 +1,8 @@
[Desktop Entry]
Type=Service
+X-KDE-DBus-ServiceName=org.kde.kssld5
X-KDE-ServiceTypes=KDEDModule
-X-KDE-Library=kf5/kded/kssld
-X-KDE-DBus-ModuleName=kssld
-X-KDE-Kded-autoload=false
-X-KDE-Kded-load-on-demand=true
+X-KDE-Library=kf5/kiod/kssld
Name=SSL Certificate Policy
Name[ar]=سياسة شهادات SSL
Name[ca]=Política pels certificats SSL
--
To view, visit https://gerrit.vesnicky.cesnet.cz/r/343
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I85417d324125c4ba7e80761b9c0bd0e9296a1b6c
Gerrit-PatchSet: 1
Gerrit-Project: kio
Gerrit-Branch: master
Gerrit-Owner: David Faure <faure at kde.org>
Gerrit-Reviewer: Alex Merry <alex.merry at kde.org>
Gerrit-Reviewer: Sysadmin Testing Account <null at kde.org>
More information about the Kde-frameworks-devel
mailing list