Commit 92e16a83 authored by Volker Krause's avatar Volker Krause
Browse files

Remove usage of KDBusConnectionPool

Summary:
As per T12722 this is no longer needed, QDBusConnection now behaves
correctly in a multi-threaded scenario.

This doesn't remove all traces of KDBusAddons yet, the remaining bits
need the users of Akonadi CMake macros to be ported first.

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D27510
parent d8f8cb56
......@@ -28,7 +28,7 @@ macro(add_akonadi_test _source)
get_filename_component(_name ${_source} NAME_WE)
ecm_add_test(TEST_NAME ${_name} ${_test})
set_tests_properties(${_name} PROPERTIES ENVIRONMENT "QT_HASH_SEED=1;QT_NO_CPU_FEATURE=sse4.2")
target_link_libraries(${_name} akonaditestfake Qt5::Test KF5::AkonadiPrivate KF5::DBusAddons KF5::I18n)
target_link_libraries(${_name} akonaditestfake Qt5::Test KF5::AkonadiPrivate KF5::I18n)
endmacro()
# convenience macro to add akonadi qtestlib unit-tests
......@@ -41,7 +41,7 @@ macro(add_akonadi_test_widgets _source)
get_filename_component(_name ${_source} NAME_WE)
ecm_add_test(TEST_NAME ${_name} ${_test})
set_tests_properties(${_name} PROPERTIES ENVIRONMENT "QT_HASH_SEED=1;QT_NO_CPU_FEATURE=sse4.2")
target_link_libraries(${_name} akonaditestfake Qt5::Test KF5::AkonadiWidgets KF5::AkonadiPrivate KF5::DBusAddons)
target_link_libraries(${_name} akonaditestfake Qt5::Test KF5::AkonadiWidgets KF5::AkonadiPrivate)
endmacro()
......@@ -72,7 +72,6 @@ target_link_libraries(akonaditestfake
Qt5::Test
Qt5::Widgets
Qt5::Network
KF5::DBusAddons
KF5::AkonadiPrivate
akonadi_shared
)
......@@ -82,7 +81,7 @@ add_executable(akonadi-firstrun
firstrunner.cpp
${CMAKE_BINARY_DIR}/src/core/akonadicore_debug.cpp
)
target_link_libraries( akonadi-firstrun Qt5::Test Qt5::Core KF5::AkonadiCore KF5::AkonadiPrivate KF5::DBusAddons KF5::ConfigCore Qt5::Widgets)
target_link_libraries( akonadi-firstrun Qt5::Test Qt5::Core KF5::AkonadiCore KF5::AkonadiPrivate KF5::ConfigCore Qt5::Widgets)
# qtestlib unit tests
add_akonadi_test(imapparsertest.cpp)
......
......@@ -21,14 +21,13 @@
#define AKONADI_TEST_UTILS_H
#include "collectionpathresolver.h"
#include "kdbusconnectionpool.h"
#include "servermanager.h"
#include "qtest_akonadi.h"
#include "monitor.h"
#include "collectionfetchscope.h"
#include "itemfetchscope.h"
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusReply>
......@@ -56,7 +55,7 @@ bool restartAkonadiServer()
QDBusInterface testrunnerIface(testrunnerServiceName(),
QStringLiteral("/"),
QStringLiteral("org.kde.Akonadi.Testrunner"),
KDBusConnectionPool::threadConnection());
QDBusConnection::sessionBus());
if (!testrunnerIface.isValid()) {
qWarning() << "Unable to get a dbus interface to the testrunner!";
}
......@@ -83,7 +82,7 @@ bool trackAkonadiProcess(bool track)
QDBusInterface testrunnerIface(testrunnerServiceName(),
QStringLiteral("/"),
QStringLiteral("org.kde.Akonadi.Testrunner"),
KDBusConnectionPool::threadConnection());
QDBusConnection::sessionBus());
if (!testrunnerIface.isValid()) {
qWarning() << "Unable to get a dbus interface to the testrunner!";
}
......
......@@ -17,8 +17,6 @@
02110-1301, USA.
*/
#include "KDBusConnectionPool"
#include <qtest_akonadi.h>
#include <servermanager.h>
......@@ -43,7 +41,7 @@ private Q_SLOTS:
void testDBus()
{
QVERIFY(KDBusConnectionPool::threadConnection().isConnected());
QVERIFY(QDBusConnection::sessionBus().isConnected());
}
void testAkonadiServer()
......@@ -53,11 +51,11 @@ private Q_SLOTS:
void testResources()
{
QVERIFY(KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(
QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(
ServerManager::agentServiceName(ServerManager::Resource, QStringLiteral("akonadi_knut_resource_0"))));
QVERIFY(KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(
QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(
ServerManager::agentServiceName(ServerManager::Resource, QStringLiteral("akonadi_knut_resource_1"))));
QVERIFY(KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(
QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(
ServerManager::agentServiceName(ServerManager::Resource, QStringLiteral("akonadi_knut_resource_2"))));
}
};
......
......@@ -33,7 +33,6 @@ target_link_libraries(akonadi_knut_resource
KF5::AkonadiCore
KF5::KIOCore
KF5::AkonadiAgentBase
KF5::DBusAddons
Qt5::Xml
KF5::I18n
)
......
......@@ -29,7 +29,7 @@
#include <agentfactory.h>
#include <changerecorder.h>
#include <collection.h>
#include <KDBusConnectionPool>
#include <QDBusConnection>
#include <item.h>
#include <itemfetchscope.h>
#include <tagcreatejob.h>
......@@ -54,7 +54,7 @@ KnutResource::KnutResource(const QString &id)
changeRecorder()->fetchCollection(true);
new SettingsAdaptor(mSettings);
KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/Settings"),
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"),
mSettings, QDBusConnection::ExportAdaptors);
connect(this, &KnutResource::reloadConfiguration, this, &KnutResource::load);
connect(mWatcher, &QFileSystemWatcher::fileChanged, this, &KnutResource::load);
......
......@@ -63,7 +63,6 @@ PUBLIC
PRIVATE
KF5::AkonadiPrivate
KF5::AkonadiWidgets
KF5::DBusAddons
KF5::I18n
Qt5::Network
akonadi_shared
......
......@@ -28,7 +28,6 @@
#include "agentmanager.h"
#include "changerecorder.h"
#include "controladaptor.h"
#include "KDBusConnectionPool"
#include "itemfetchjob.h"
#include "monitor_p.h"
#include "servermanager_p.h"
......@@ -379,12 +378,12 @@ void AgentBasePrivate::init()
mTracer = new org::freedesktop::Akonadi::Tracer(ServerManager::serviceName(ServerManager::Server),
QStringLiteral("/tracing"),
KDBusConnectionPool::threadConnection(), q);
QDBusConnection::sessionBus(), q);
new Akonadi__ControlAdaptor(q);
new Akonadi__StatusAdaptor(q);
if (!KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/"), q, QDBusConnection::ExportAdaptors)) {
Q_EMIT q->error(i18n("Unable to register object at dbus: %1", KDBusConnectionPool::threadConnection().lastError().message()));
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), q, QDBusConnection::ExportAdaptors)) {
Q_EMIT q->error(i18n("Unable to register object at dbus: %1", QDBusConnection::sessionBus().lastError().message()));
}
mSettings = new QSettings(ServerManager::agentConfigFilePath(mId), QSettings::IniFormat);
......@@ -461,13 +460,13 @@ void AgentBasePrivate::delayedInit()
Q_Q(AgentBase);
const QString serviceId = ServerManager::agentServiceName(ServerManager::Agent, mId);
if (!KDBusConnectionPool::threadConnection().registerService(serviceId)) {
if (!QDBusConnection::sessionBus().registerService(serviceId)) {
qCCritical(AKONADIAGENTBASE_LOG) << "Unable to register service" << serviceId << "at dbus:"
<< KDBusConnectionPool::threadConnection().lastError().message();
<< QDBusConnection::sessionBus().lastError().message();
}
q->setOnlineInternal(mDesiredOnlineState);
KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/Debug"), this, QDBusConnection::ExportScriptableSlots);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Debug"), this, QDBusConnection::ExportScriptableSlots);
}
void AgentBasePrivate::setProgramName()
......@@ -1112,7 +1111,7 @@ void AgentBase::configure(qlonglong windowId)
WId AgentBase::winIdForDialogs() const
{
const bool registered = KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.akonaditray"));
const bool registered = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.akonaditray"));
if (!registered) {
return 0;
}
......
......@@ -77,7 +77,7 @@ class Item;
* most notably AgentBase::config(). Additionally,
* one cannot use QDBusConnection::sessionBus() with dbus < 1.4, because of a
* multithreading bug in libdbus. Instead one should use
* KDBusConnectionPool::threadConnection() which works around this problem.
* QDBusConnection::sessionBus() which works around this problem.
*
* @author Till Adam <adam@kde.org>, Volker Krause <vkrause@kde.org>
*/
......
......@@ -21,7 +21,7 @@
#include "akonadiagentbase_debug.h"
#include "agentsearchinterface_p.h"
#include "collection.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "searchresultjob_p.h"
#include "searchadaptor.h"
#include "collectionfetchjob.h"
......@@ -36,7 +36,7 @@ AgentSearchInterfacePrivate::AgentSearchInterfacePrivate(AgentSearchInterface *q
: q(qq)
{
new Akonadi__SearchAdaptor(this);
KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/Search"),
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Search"),
this, QDBusConnection::ExportAdaptors);
QTimer::singleShot(0, this, &AgentSearchInterfacePrivate::delayedInit);
......
......@@ -20,7 +20,7 @@
#include "preprocessorbase_p.h"
#include "preprocessorbase.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "preprocessoradaptor.h"
#include "servermanager.h"
......@@ -38,17 +38,17 @@ PreprocessorBasePrivate::PreprocessorBasePrivate(PreprocessorBase *parent)
new Akonadi__PreprocessorAdaptor(this);
if (!KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/Preprocessor"), this, QDBusConnection::ExportAdaptors)) {
Q_EMIT q->error(i18n("Unable to register object at dbus: %1", KDBusConnectionPool::threadConnection().lastError().message()));
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/Preprocessor"), this, QDBusConnection::ExportAdaptors)) {
Q_EMIT q->error(i18n("Unable to register object at dbus: %1", QDBusConnection::sessionBus().lastError().message()));
}
}
void PreprocessorBasePrivate::delayedInit()
{
if (!KDBusConnectionPool::threadConnection().registerService(ServerManager::agentServiceName(ServerManager::Preprocessor, mId))) {
if (!QDBusConnection::sessionBus().registerService(ServerManager::agentServiceName(ServerManager::Preprocessor, mId))) {
qCCritical(AKONADIAGENTBASE_LOG) << "Unable to register service at D-Bus: "
<< KDBusConnectionPool::threadConnection().lastError().message();
<< QDBusConnection::sessionBus().lastError().message();
}
AgentBasePrivate::delayedInit();
}
......
......@@ -25,7 +25,7 @@
#include "resourceadaptor.h"
#include "collectiondeletejob.h"
#include "collectionsync_p.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "itemsync.h"
#include "akonadifull-version.h"
#include "tagsync.h"
......@@ -103,9 +103,9 @@ public:
void delayedInit() override {
const QString serviceId = ServerManager::agentServiceName(ServerManager::Resource, mId);
if (!KDBusConnectionPool::threadConnection().registerService(serviceId))
if (!QDBusConnection::sessionBus().registerService(serviceId))
{
QString reason = KDBusConnectionPool::threadConnection().lastError().message();
QString reason = QDBusConnection::sessionBus().lastError().message();
if (reason.isEmpty()) {
reason = QStringLiteral("this service is probably running already.");
}
......
......@@ -19,7 +19,7 @@
#include "resourcescheduler_p.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "recursivemover_p.h"
#include "akonadiagentbase_debug.h"
......@@ -528,11 +528,11 @@ void ResourceScheduler::signalTaskToTracker(const Task &task, const QByteArray &
// if there's a job tracer running, tell it about the new job
if (!s_resourcetracker) {
const QString suffix = Akonadi::Instance::identifier().isEmpty() ? QString() : QLatin1Char('-') + Akonadi::Instance::identifier();
if (KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(QStringLiteral("org.kde.akonadiconsole") + suffix)) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.akonadiconsole") + suffix)) {
s_resourcetracker = new QDBusInterface(QLatin1String("org.kde.akonadiconsole") + suffix,
QStringLiteral("/resourcesJobtracker"),
QStringLiteral("org.freedesktop.Akonadi.JobTracker"),
KDBusConnectionPool::threadConnection(), nullptr);
QDBusConnection::sessionBus(), nullptr);
}
}
......@@ -576,7 +576,7 @@ void ResourceScheduler::Task::sendDBusReplies(const QString &errorMsg)
} else {
qCCritical(AKONADIAGENTBASE_LOG) << "Got unexpected member:" << methodName;
}
KDBusConnectionPool::threadConnection().send(reply);
QDBusConnection::sessionBus().send(reply);
}
}
......
......@@ -20,7 +20,7 @@
#include "transportresourcebase.h"
#include "transportresourcebase_p.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "transportadaptor.h"
#include "itemfetchjob.h"
......@@ -35,7 +35,7 @@ TransportResourceBasePrivate::TransportResourceBasePrivate(TransportResourceBase
, q(qq)
{
new Akonadi__TransportAdaptor(this);
KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/Transport"),
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Transport"),
this, QDBusConnection::ExportAdaptors);
}
......
......@@ -305,7 +305,6 @@ PRIVATE
Qt5::Network
Qt5::Widgets
KF5::AkonadiPrivate
KF5::DBusAddons
KF5::I18n
KF5::IconThemes
KF5::ConfigCore
......
......@@ -26,7 +26,7 @@
#include <QPluginLoader>
#include <QDir>
#include <KDBusConnectionPool>
#include <QDBusConnection>
namespace Akonadi {
class Q_DECL_HIDDEN AgentConfigurationManager::Private {
......@@ -66,7 +66,7 @@ AgentConfigurationManager::~AgentConfigurationManager()
bool AgentConfigurationManager::registerInstanceConfiguration(const QString &instance)
{
const auto serviceName = d->serviceName(instance);
QDBusConnection conn = KDBusConnectionPool::threadConnection();
QDBusConnection conn = QDBusConnection::sessionBus();
if (conn.interface()->isServiceRegistered(serviceName)) {
qCDebug(AKONADICORE_LOG) << "Service " << serviceName << " is already registered";
return false;
......@@ -78,13 +78,13 @@ bool AgentConfigurationManager::registerInstanceConfiguration(const QString &ins
void AgentConfigurationManager::unregisterInstanceConfiguration(const QString &instance)
{
const auto serviceName = d->serviceName(instance);
KDBusConnectionPool::threadConnection().unregisterService(serviceName);
QDBusConnection::sessionBus().unregisterService(serviceName);
}
bool AgentConfigurationManager::isInstanceRegistered(const QString &instance) const
{
const auto serviceName = d->serviceName(instance);
return KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(serviceName);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName);
}
QString AgentConfigurationManager::findConfigPlugin(const QString &type) const
......
......@@ -22,7 +22,7 @@
#include "agenttype_p.h"
#include "agentinstance_p.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "servermanager.h"
#include "collection.h"
......@@ -30,7 +30,6 @@
#include <QDBusServiceWatcher>
#include <QWidget>
#include <kdbusconnectionpool.h>
using namespace Akonadi;
using namespace AkRanges;
......@@ -318,7 +317,7 @@ void AgentManagerPrivate::createDBusInterface()
mManager = new org::freedesktop::Akonadi::AgentManager(ServerManager::serviceName(ServerManager::Control),
QStringLiteral("/AgentManager"),
KDBusConnectionPool::threadConnection(), mParent);
QDBusConnection::sessionBus(), mParent);
QObject::connect(mManager, SIGNAL(agentTypeAdded(QString)),
mParent, SLOT(agentTypeAdded(QString)));
......@@ -360,7 +359,7 @@ AgentManager::AgentManager()
d->createDBusInterface();
d->mServiceWatcher = std::make_unique<QDBusServiceWatcher>(
ServerManager::serviceName(ServerManager::Control), KDBusConnectionPool::threadConnection(),
ServerManager::serviceName(ServerManager::Control), QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration);
connect(d->mServiceWatcher.get(), &QDBusServiceWatcher::serviceRegistered,
this, [this]() {
......
......@@ -18,7 +18,7 @@
*/
#include "firstrun_p.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "servermanager.h"
#include "agentinstance.h"
......@@ -55,7 +55,7 @@ Firstrun::Firstrun(QObject *parent)
deleteLater();
return;
}
if (KDBusConnectionPool::threadConnection().registerService(QLatin1String(FIRSTRUN_DBUSLOCK))) {
if (QDBusConnection::sessionBus().registerService(QLatin1String(FIRSTRUN_DBUSLOCK))) {
findPendingDefaults();
qCDebug(AKONADICORE_LOG) << "D-Bus lock acquired, pending defaults:" << mPendingDefaults;
setupNext();
......@@ -68,7 +68,7 @@ Firstrun::Firstrun(QObject *parent)
Firstrun::~Firstrun()
{
if (qApp) {
KDBusConnectionPool::threadConnection().unregisterService(QLatin1String(FIRSTRUN_DBUSLOCK));
QDBusConnection::sessionBus().unregisterService(QLatin1String(FIRSTRUN_DBUSLOCK));
}
delete mConfig;
qCDebug(AKONADICORE_LOG) << "done";
......@@ -154,7 +154,7 @@ void Firstrun::instanceCreated(KJob *job)
const auto service = ServerManager::agentServiceName(ServerManager::Agent, instance.identifier());
QDBusInterface *iface = new QDBusInterface(service, QStringLiteral("/Settings"), QString(),
KDBusConnectionPool::threadConnection(), this);
QDBusConnection::sessionBus(), this);
if (!iface->isValid()) {
qCCritical(AKONADICORE_LOG) << "Unable to obtain the KConfigXT D-Bus interface of " << instance.identifier();
setupNext();
......
......@@ -23,7 +23,7 @@
#include "agentmanager.h"
#include "agentmanager_p.h"
#include "controlinterface.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "kjobprivatebase_p.h"
#include "servermanager.h"
......@@ -77,7 +77,7 @@ public:
{
org::freedesktop::Akonadi::Agent::Control *agentControlIface =
new org::freedesktop::Akonadi::Agent::Control(ServerManager::agentServiceName(ServerManager::Agent, agentInstance.identifier()),
QStringLiteral("/"), KDBusConnectionPool::threadConnection(), q);
QStringLiteral("/"), QDBusConnection::sessionBus(), q);
if (!agentControlIface || !agentControlIface->isValid()) {
delete agentControlIface;
......
......@@ -16,7 +16,7 @@
*/
#include "collectionattributessynchronizationjob.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include "kjobprivatebase_p.h"
#include "servermanager.h"
#include "akonadicore_debug.h"
......@@ -98,7 +98,7 @@ void CollectionAttributesSynchronizationJobPrivate::doStart()
interface = new QDBusInterface(ServerManager::agentServiceName(ServerManager::Resource, instance.identifier()),
QStringLiteral("/"),
QStringLiteral("org.freedesktop.Akonadi.Resource"),
KDBusConnectionPool::threadConnection(), this);
QDBusConnection::sessionBus(), this);
connect(interface, SIGNAL(attributesSynchronized(qlonglong)), q, SLOT(slotSynchronized(qlonglong)));
if (interface->isValid()) {
......
......@@ -22,7 +22,7 @@
#include "job.h"
#include "job_p.h"
#include "akonadicore_debug.h"
#include "KDBusConnectionPool"
#include <QDBusConnection>
#include <QTime>
#include "private/protocol_p.h"
#include "private/instance_p.h"
......@@ -121,11 +121,11 @@ void JobPrivate::publishJob()
s_lastTime.start();
}
const QString suffix = Akonadi::Instance::identifier().isEmpty() ? QString() : QLatin1Char('-') + Akonadi::Instance::identifier();
if (KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(QStringLiteral("org.kde.akonadiconsole") + suffix)) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.akonadiconsole") + suffix)) {
s_jobtracker = new QDBusInterface(QLatin1String("org.kde.akonadiconsole") + suffix,
QStringLiteral("/jobtracker"),
QStringLiteral("org.freedesktop.Akonadi.JobTracker"),
KDBusConnectionPool::threadConnection(), nullptr);
QDBusConnection::sessionBus(), nullptr);
mSession->d->publishOtherJobs(q);
} else {
s_lastTime.restart();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment