Akonadi

agentthread.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "agentthread.h"
8#include "akonadiagentserver_debug.h"
9
10#include "shared/akdebug.h"
11#include <QMetaObject>
12
13using namespace Akonadi;
14
15AgentThread::AgentThread(const QString &identifier, QObject *factory, QObject *parent)
16 : QThread(parent)
17 , m_identifier(identifier)
18 , m_factory(factory)
19{
20}
21
22void AgentThread::run()
23{
24 // // clang-format off
25 const bool invokeSucceeded =
26 QMetaObject::invokeMethod(m_factory, "createInstance", Qt::DirectConnection, Q_RETURN_ARG(QObject *, m_instance), Q_ARG(QString, m_identifier));
27 // clang-format on
28 if (invokeSucceeded) {
29 qCDebug(AKONADIAGENTSERVER_LOG) << Q_FUNC_INFO << "agent instance created: " << m_instance;
30 } else {
31 qCDebug(AKONADIAGENTSERVER_LOG) << Q_FUNC_INFO << "agent instance creation failed";
32 }
33
34 exec();
35 delete m_instance;
36 m_instance = nullptr;
37}
38
39void AgentThread::configure(qlonglong windowId)
40{
41 QMetaObject::invokeMethod(m_instance, "configure", Qt::DirectConnection, Q_ARG(quintptr, (quintptr)windowId));
42}
43
44#include "moc_agentthread.cpp"
AgentThread(const QString &identifier, QObject *factory, QObject *parent=nullptr)
Creates a new agent thread.
void configure(qlonglong windowId)
Configures the agent.
Helper integration between Akonadi and Qt.
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
T qobject_cast(QObject *object)
DirectConnection
int exec()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.