Hello, yet another rather big patch for KAuth which follows last one. This one is based on yet another suggestion by pino. Basically this patch does the following:
- Add a fake helper backend - Compile statically into kdecore both fake backends (the added overhead is extremely trivial) - When loading backends, if no backends are found fall back to the fake ones instead of asserting. Also, if this is due to an installation problem, spit out a kWarning() CMake side, this also adds some more logic to choose the helper backend. This is also in preparation for an eventual Windows backend, which would require a different helper backend as well. Also, this change prevents KDE4Macros from making the assumption that the DBus helper backend is always compiled. While I was at it, I also removed compilation of the policy-gen tool when the fake backend is chosen at build time, as it's no longer needed. Please tell me if it's ok to commit and backport. P.S.: Needless to say that the two patches together have been tested and work fine on a completely fresh environment. P.P.S.: I finally subscribed to the list. -- ------------------- Dario Freddi KDE Developer GPG Key Signature: 511A9A3B
Index: auth/ConfigureChecks.cmake
===================================================================
--- auth/ConfigureChecks.cmake (revisione 1090005)
+++ auth/ConfigureChecks.cmake (copia locale)
@@ -136,14 +136,8 @@
set (KAUTH_COMPILING_FAKE_BACKEND TRUE)
message(STATUS "Building Fake KAuth backend")
- message("WARNING: KAuth will be built with Fake backend. The library will not work properly unless compiled with
+ message("WARNING: No valid KAuth backends will be built. The library will not work properly unless compiled with
a working backend")
-
- set(KAUTH_BACKEND_SRCS ${KAUTH_BACKEND_SRCS}
- auth/backends/fake/FakeBackend.cpp
- )
-
- set(KAUTH_BACKEND_LIBS ${QT_QTCORE_LIBRARY})
endif()
# KAuth policy generator executable source probing
@@ -161,37 +155,63 @@
elseif(KDE4_AUTH_BACKEND_NAME STREQUAL "POLKITQT-1")
set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
auth/backends/polkit-1/kauth-policy-gen-polkit1.cpp )
-else()
- set(KAUTH_POLICY_GEN_SRCS ${KAUTH_POLICY_GEN_SRCS}
- auth/backends/fake/kauth-policy-gen-polkit.cpp )
endif()
-# Helper backend
-# No selection, we have D-Bus only
+########################
+# Helper backend probing
-set (KAUTH_COMPILING_DBUS_HELPER_BACKEND TRUE)
+set(KDE4_AUTH_HELPER_BACKEND_NAME "" CACHE STRING "Specifies the KAuth helper backend to build. Current available options are
+ DBus, Fake. Not setting this variable will build the most appropriate backend for your system")
-qt4_add_dbus_adaptor(kauth_dbus_adaptor_SRCS
- auth/backends/dbus/org.kde.auth.xml
- auth/backends/dbus/DBusHelperProxy.h
- KAuth::DBusHelperProxy)
+set(KAUTH_HELPER_BACKEND ${KDE4_AUTH_HELPER_BACKEND_NAME})
-set(KAUTH_HELPER_BACKEND_SRCS
- auth/backends/dbus/DBusHelperProxy.cpp
- ${kauth_dbus_adaptor_SRCS}
-)
+if(NOT KAUTH_HELPER_BACKEND)
+ # No checks needed, just set the dbus backend
+ set(KAUTH_HELPER_BACKEND "DBus")
+ string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
+ set (KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
+else(NOT KAUTH_HELPER_BACKEND)
+ # No checks needed here either
+ string(TOUPPER ${KAUTH_HELPER_BACKEND} KAUTH_HELPER_BACKEND_UPPER)
+ set (KAUTH_HELPER_BACKEND ${KAUTH_HELPER_BACKEND_UPPER})
+endif(NOT KAUTH_HELPER_BACKEND)
-set(KAUTH_HELPER_BACKEND_LIBS kdecore)
+set(KDE4_AUTH_HELPER_BACKEND_NAME ${KAUTH_HELPER_BACKEND} CACHE STRING "Specifies the KAuth helper backend to build. Current
+ available options are DBus, Fake. Not setting this variable will
+ build the most appropriate backend for your system" FORCE)
-# Install some files as well
-install( FILES auth/backends/dbus/org.kde.auth.conf
- DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d )
+# Add the correct libraries/files depending on the backend
+if(KDE4_AUTH_HELPER_BACKEND_NAME STREQUAL "DBUS")
+ set (KAUTH_COMPILING_DBUS_HELPER_BACKEND TRUE)
-install( FILES auth/backends/dbus/dbus_policy.stub
- auth/backends/dbus/dbus_service.stub
- DESTINATION ${DATA_INSTALL_DIR}/kauth COMPONENT Devel)
+ qt4_add_dbus_adaptor(kauth_dbus_adaptor_SRCS
+ auth/backends/dbus/org.kde.auth.xml
+ auth/backends/dbus/DBusHelperProxy.h
+ KAuth::DBusHelperProxy)
-# Set the various directories
+ set(KAUTH_HELPER_BACKEND_SRCS
+ auth/backends/dbus/DBusHelperProxy.cpp
+ ${kauth_dbus_adaptor_SRCS}
+ )
+
+ set(KAUTH_HELPER_BACKEND_LIBS kdecore)
+
+ # Install some files as well
+ install( FILES auth/backends/dbus/org.kde.auth.conf
+ DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d )
+
+ install( FILES auth/backends/dbus/dbus_policy.stub
+ auth/backends/dbus/dbus_service.stub
+ DESTINATION ${DATA_INSTALL_DIR}/kauth COMPONENT Devel)
+elseif(KDE4_AUTH_HELPER_BACKEND_NAME STREQUAL "FAKE")
+ set (KAUTH_COMPILING_FAKE_HELPER_BACKEND TRUE)
+
+ message("WARNING: No valid KAuth helper backends will be built. The library will not work properly unless compiled with
+ a working backend")
+endif()
+
+
+# Set directories for plugins
set(KAUTH_HELPER_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/helper" CACHE STRING "Where KAuth's helper plugin will be installed")
set(KAUTH_BACKEND_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/backend" CACHE STRING "Where KAuth's backend plugin will be installed")
#set(KAUTH_OTHER_PLUGIN_DIR "${QT_PLUGINS_DIR}/kauth/plugins")
Index: auth/BackendsManager.cpp
===================================================================
--- auth/BackendsManager.cpp (revisione 1090005)
+++ auth/BackendsManager.cpp (copia locale)
@@ -21,8 +21,13 @@
#include "BackendsConfig.h"
+// Include fake backends
+#include "backends/fake/FakeBackend.h"
+#include "backends/fakehelper/FakeHelperProxy.h"
+
#include <QPluginLoader>
#include <QDir>
+#include <kdebug.h>
namespace KAuth
{
@@ -91,8 +96,24 @@
}
}
- Q_ASSERT_X(auth, __FUNCTION__, "No AuthBackend found.");
- Q_ASSERT_X(helper, __FUNCTION__, "No HelperBackend found.");
+ if (!auth) {
+ // Load the fake auth backend then
+ auth = new FakeBackend;
+#ifndef KAUTH_COMPILING_FAKE_BACKEND
+ // Spit a fat warning
+ kWarning() << "WARNING: KAuth was compiled with a working backend, but was unable to load it! Check your installation!";
+#endif
+ }
+
+ if (!helper) {
+ // Load the fake helper backend then
+ helper = new FakeHelperProxy;
+#ifndef KAUTH_COMPILING_FAKE_BACKEND
+ // Spit a fat warning
+ kWarning() << "WARNING: KAuth was compiled with a working helper backend, but was unable to load it! "
+ "Check your installation!";
+#endif
+ }
}
AuthBackend *BackendsManager::authBackend()
Index: auth/BackendsConfig.h.cmake
===================================================================
--- auth/BackendsConfig.h.cmake (revisione 1090005)
+++ auth/BackendsConfig.h.cmake (copia locale)
@@ -3,6 +3,7 @@
#cmakedefine KAUTH_COMPILING_POLKITQT1_BACKEND 1
#cmakedefine KAUTH_COMPILING_FAKE_BACKEND 1
#cmakedefine KAUTH_COMPILING_DBUS_HELPER_BACKEND 1
+#cmakedefine KAUTH_COMPILING_FAKE_HELPER_BACKEND 1
#define KAUTH_BACKEND_PLUGIN_DIR "${KAUTH_BACKEND_PLUGIN_DIR}"
#define KAUTH_HELPER_PLUGIN_DIR "${KAUTH_HELPER_PLUGIN_DIR}"
#define KAUTH_OTHER_PLUGIN_DIR "${KAUTH_OTHER_PLUGIN_DIR}"
Index: auth/backends/fake/FakeBackend.cpp
===================================================================
--- auth/backends/fake/FakeBackend.cpp (revisione 1090005)
+++ auth/backends/fake/FakeBackend.cpp (copia locale)
@@ -19,10 +19,6 @@
#include "FakeBackend.h"
-#include <QtCore/qplugin.h>
-
-#include <syslog.h>
-
namespace KAuth
{
@@ -61,5 +57,3 @@
}
} // namespace Auth
-
-Q_EXPORT_PLUGIN2(kauth_backend, KAuth::FakeBackend)
Index: auth/backends/fakehelper/FakeHelperProxy.cpp
===================================================================
--- auth/backends/fakehelper/FakeHelperProxy.cpp (revisione 0)
+++ auth/backends/fakehelper/FakeHelperProxy.cpp (revisione 0)
@@ -0,0 +1,88 @@
+/*
+* Copyright (C) 2010 Dario Freddi <[email protected]>
+*
+* This program 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.1 of the License, or
+* (at your option) any later version.
+*
+* This program 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 General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
+*/
+
+#include "FakeHelperProxy.h"
+
+namespace KAuth {
+
+FakeHelperProxy::FakeHelperProxy()
+ : HelperProxy()
+{
+
+}
+
+FakeHelperProxy::~FakeHelperProxy()
+{
+
+}
+
+void FakeHelperProxy::sendProgressStep(const QVariantMap& step)
+{
+ Q_UNUSED(step)
+}
+
+void FakeHelperProxy::sendProgressStep(int step)
+{
+ Q_UNUSED(step)
+}
+
+void FakeHelperProxy::sendDebugMessage(int level, const char* msg)
+{
+ Q_UNUSED(level)
+ Q_UNUSED(msg)
+}
+
+bool FakeHelperProxy::hasToStopAction()
+{
+ return false;
+}
+
+void FakeHelperProxy::setHelperResponder(QObject* o)
+{
+ Q_UNUSED(o)
+}
+
+bool FakeHelperProxy::initHelper(const QString& name)
+{
+ Q_UNUSED(name)
+ return false;
+}
+
+void FakeHelperProxy::stopAction(const QString& action, const QString& helperID)
+{
+ Q_UNUSED(action)
+ Q_UNUSED(helperID)
+}
+
+KAuth::ActionReply FakeHelperProxy::executeAction(const QString& action, const QString& helperID, const QVariantMap& arguments)
+{
+ Q_UNUSED(action)
+ Q_UNUSED(helperID)
+ Q_UNUSED(arguments)
+ return KAuth::ActionReply::NoSuchActionReply;
+}
+
+bool FakeHelperProxy::executeActions(const QList< QPair< QString, QVariantMap > >& list, const QString& helperID)
+{
+ Q_UNUSED(list)
+ Q_UNUSED(helperID)
+ return false;
+}
+
+}
Index: auth/backends/fakehelper/FakeHelperProxy.h
===================================================================
--- auth/backends/fakehelper/FakeHelperProxy.h (revisione 0)
+++ auth/backends/fakehelper/FakeHelperProxy.h (revisione 0)
@@ -0,0 +1,49 @@
+/*
+* Copyright (C) 2010 Dario Freddi <[email protected]>
+*
+* This program 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.1 of the License, or
+* (at your option) any later version.
+*
+* This program 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 General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
+*/
+
+#ifndef FAKEHELPERPROXY_H
+#define FAKEHELPERPROXY_H
+
+#include "HelperProxy.h"
+
+namespace KAuth {
+
+class FakeHelperProxy : public HelperProxy
+{
+ Q_OBJECT
+ Q_INTERFACES(KAuth::HelperProxy)
+
+ public:
+ FakeHelperProxy();
+ virtual ~FakeHelperProxy();
+
+ virtual void sendProgressStep(const QVariantMap& step);
+ virtual void sendProgressStep(int step);
+ virtual void sendDebugMessage(int level, const char* msg);
+ virtual bool hasToStopAction();
+ virtual void setHelperResponder(QObject* o);
+ virtual bool initHelper(const QString& name);
+ virtual void stopAction(const QString& action, const QString& helperID);
+ virtual ActionReply executeAction(const QString& action, const QString& helperID, const QVariantMap& arguments);
+ virtual bool executeActions(const QList< QPair< QString, QVariantMap > >& list, const QString& helperID);
+};
+
+}
+
+#endif // FAKEHELPERPROXY_H
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revisione 1090005)
+++ CMakeLists.txt (copia locale)
@@ -186,6 +186,8 @@
auth/BackendsManager.cpp
auth/HelperProxy.cpp
auth/kauthhelpersupport.cpp
+ auth/backends/fake/FakeBackend.cpp
+ auth/backends/fakehelper/FakeHelperProxy.cpp
services/kfoldermimetype.cpp
services/kmimetypefactory.cpp
services/kmimemagicrule.cpp
@@ -331,14 +333,18 @@
# KAuth policy generator executable
-# KAUTH_POLICY_GEN_SRCS has been generated from auth/ConfigureChecks.cmake
-kde4_add_executable(kauth-policy-gen NOGUI ${KAUTH_POLICY_GEN_SRCS})
+# Compile only if fake backend has not been selected
-# KAUTH_POLICY_GEN_LIBRARIES has been generated from auth/ConfigureChecks.cmake
-target_link_libraries( kauth-policy-gen ${KAUTH_POLICY_GEN_LIBRARIES} )
+if (NOT KDE4_AUTH_BACKEND_NAME STREQUAL "FAKE")
+ # KAUTH_POLICY_GEN_SRCS has been generated from auth/ConfigureChecks.cmake
+ kde4_add_executable(kauth-policy-gen NOGUI ${KAUTH_POLICY_GEN_SRCS})
-install( TARGETS kauth-policy-gen EXPORT kdelibsToolsTargets DESTINATION ${LIBEXEC_INSTALL_DIR})
+ # KAUTH_POLICY_GEN_LIBRARIES has been generated from auth/ConfigureChecks.cmake
+ target_link_libraries( kauth-policy-gen ${KAUTH_POLICY_GEN_LIBRARIES} )
+ install( TARGETS kauth-policy-gen EXPORT kdelibsToolsTargets DESTINATION ${LIBEXEC_INSTALL_DIR})
+endif (NOT KDE4_AUTH_BACKEND_NAME STREQUAL "FAKE")
+
########### next target ###############
# KAuth backend plugin
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-buildsystem mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-buildsystem
