Change in kio[master]: kssld: compile as standalone daemon, and use that when kded ...

David Faure (Code Review) noreply at kde.org
Wed Jan 14 14:33:00 UTC 2015


David Faure has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/323

Change subject: kssld: compile as standalone daemon, and use that when kded isn't available.
......................................................................

kssld: compile as standalone daemon, and use that when kded isn't available.

Both kded and kssld can be autostarted, so the way we found out which
one to use, is simply "is kded5 on $PATH". On reduced systems without kded5,
we start kssld instead.

CHANGELOG: kssld now also exists as a standalone daemon, for systems without kded5.

Change-Id: I2e8a1b470359e9396986d4d378aebd85c1103da8
---
M src/core/ksslcertificatemanager.cpp
M src/kssld/CMakeLists.txt
M src/kssld/kssld.h
A src/kssld/kssld_main.cpp
A src/kssld/org.kde.kssld5.service.in
5 files changed, 79 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/kio refs/changes/23/323/1

diff --git a/src/core/ksslcertificatemanager.cpp b/src/core/ksslcertificatemanager.cpp
index 76198eb..93908cc 100644
--- a/src/core/ksslcertificatemanager.cpp
+++ b/src/core/ksslcertificatemanager.cpp
@@ -196,12 +196,23 @@
 
 KSslCertificateManagerPrivate::KSslCertificateManagerPrivate()
     : config(QString::fromLatin1("ksslcertificatemanager"), KConfig::SimpleConfig),
-      iface(new org::kde::KSSLDInterface(QString::fromLatin1("org.kde.kded5"),
-                                         QString::fromLatin1("/modules/kssld"),
-                                         QDBusConnection::sessionBus())),
       isCertListLoaded(false),
       userCertDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QString::fromLatin1("/kssl/userCaCertificates/"))
 {
+    static int s_kdedAvailable = -1; // -1 didn't look yet, 0 no, 1 yes
+    if (s_kdedAvailable < 0) {
+        s_kdedAvailable = QStandardPaths::findExecutable("kded5").isEmpty() ? 0 : 1;
+    }
+    if (s_kdedAvailable == 1) {
+      iface = new org::kde::KSSLDInterface(QString::fromLatin1("org.kde.kded5"),
+                                         QString::fromLatin1("/modules/kssld"),
+                                         QDBusConnection::sessionBus());
+    } else {
+      iface = new org::kde::KSSLDInterface(QString::fromLatin1("org.kde.kssld5"),
+                                         QString::fromLatin1("/modules/kssld"),
+                                         QDBusConnection::sessionBus());
+    }
+
     // set Qt's set to empty; this is protected by the lock in K_GLOBAL_STATIC.
     QSslSocket::setDefaultCaCertificates(QList<QSslCertificate>());
 }
@@ -428,14 +439,6 @@
 KSslCertificateManager::KSslCertificateManager()
     : d(new KSslCertificateManagerPrivate())
 {
-    // Make sure kded is running
-    QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
-    if (!bus->isServiceRegistered(QLatin1String("org.kde.kded5"))) {
-        QDBusReply<void> reply = bus->startService(QLatin1String("org.kde.kded5"));
-        if (!reply.isValid()) {
-            qWarning() << "Couldn't start kded5 from org.kde.kded5.service:" << reply.error();
-        }
-    }
 }
 
 KSslCertificateManager::~KSslCertificateManager()
diff --git a/src/kssld/CMakeLists.txt b/src/kssld/CMakeLists.txt
index 040570f..8f51de0 100644
--- a/src/kssld/CMakeLists.txt
+++ b/src/kssld/CMakeLists.txt
@@ -1,5 +1,5 @@
 
-########### next target ###############
+########### kssld as a kded module ###############
 
 set(kded_kssld_SRCS kssld.cpp )
 
@@ -20,6 +20,29 @@
 
 install(TARGETS kded_kssld  DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kded )
 
+########### kssld as a standalone daemon ###########
+
+set(kssld_SRCS kssld.cpp kssld_main.cpp)
+
+add_executable(kssld5 ${kssld_SRCS})
+
+target_link_libraries(kssld5
+PUBLIC
+   KF5::KIOCore     # ksslcertificatemanager
+   KF5::DBusAddons # kdedmodule
+PRIVATE
+   KF5::CoreAddons  # kpluginfactory
+   Qt5::Network
+   Qt5::DBus
+)
+
+install(TARGETS kssld5 DESTINATION ${KF5_LIBEXEC_INSTALL_DIR})
+
+configure_file(org.kde.kssld5.service.in
+   ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kssld5.service)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kssld5.service
+   DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
+
 ########### install files ###############
 
 install( FILES kssld.desktop  DESTINATION  ${KDE_INSTALL_KSERVICES5DIR}/kded )
diff --git a/src/kssld/kssld.h b/src/kssld/kssld.h
index d9f315b..b69974f 100644
--- a/src/kssld/kssld.h
+++ b/src/kssld/kssld.h
@@ -35,7 +35,7 @@
 {
     Q_OBJECT
 public:
-    KSSLD(QObject *parent, const QVariantList &);
+    KSSLD(QObject *parent = 0, const QVariantList & = QVariantList());
     ~KSSLD();
 
     void setRule(const KSslCertificateRule &rule);
diff --git a/src/kssld/kssld_main.cpp b/src/kssld/kssld_main.cpp
new file mode 100644
index 0000000..29282bb
--- /dev/null
+++ b/src/kssld/kssld_main.cpp
@@ -0,0 +1,36 @@
+/* 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 <KDBusService>
+#include "kssld.h"
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+    app.setApplicationName("kssld5");
+    app.setOrganizationDomain("kde.org");
+    KDBusService service(KDBusService::Unique);
+
+    KSSLD ssld;
+    ssld.setModuleName("kssld");
+    return app.exec();
+}
+
diff --git a/src/kssld/org.kde.kssld5.service.in b/src/kssld/org.kde.kssld5.service.in
new file mode 100644
index 0000000..55705fe
--- /dev/null
+++ b/src/kssld/org.kde.kssld5.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.kde.kssld5
+Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/kf5/kssld5
+

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/323
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e8a1b470359e9396986d4d378aebd85c1103da8
Gerrit-PatchSet: 1
Gerrit-Project: kio
Gerrit-Branch: master
Gerrit-Owner: David Faure <faure at kde.org>
Gerrit-Reviewer: Sysadmin Testing Account <null at kde.org>


More information about the Kde-frameworks-devel mailing list