Akonadi

agentthread.cpp
1 /*
2  Copyright (c) 2010 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "agentthread.h"
21 #include "akonadiagentserver_debug.h"
22 
23 #include <QWidget> // Needed for WId
24 
25 #include <shared/akdebug.h>
26 #include <QMetaObject>
27 
28 using namespace Akonadi;
29 
30 AgentThread::AgentThread(const QString &identifier, QObject *factory, QObject *parent)
31  : QThread(parent)
32  , m_identifier(identifier)
33  , m_factory(factory)
34  , m_instance(nullptr)
35 {
36 }
37 
38 void AgentThread::run()
39 {
40  const bool invokeSucceeded = QMetaObject::invokeMethod(m_factory,
41  "createInstance",
42  Qt::DirectConnection,
43  Q_RETURN_ARG(QObject*, m_instance),
44  Q_ARG(QString, m_identifier));
45  if (invokeSucceeded) {
46  qCDebug(AKONADIAGENTSERVER_LOG) << Q_FUNC_INFO << "agent instance created: " << m_instance;
47  } else {
48  qCDebug(AKONADIAGENTSERVER_LOG) << Q_FUNC_INFO << "agent instance creation failed";
49  }
50 
51  exec();
52  delete m_instance;
53  m_instance = nullptr;
54 }
55 
56 void AgentThread::configure(qlonglong windowId)
57 {
58  QMetaObject::invokeMethod(m_instance,
59  "configure",
60  Qt::DirectConnection,
61  Q_ARG(WId, (WId)windowId));
62 }
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
Helper integration between Akonadi and Qt.
AgentThread(const QString &identifier, QObject *factory, QObject *parent=nullptr)
Creates a new agent thread.
Definition: agentthread.cpp:30
int exec()
void configure(qlonglong windowId)
Configures the agent.
Definition: agentthread.cpp:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jun 6 2020 23:09:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.