Akonadi

agentlauncher.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "agentpluginloader.h"
8#include "akonadiagentserver_debug.h"
9
10#include <QApplication>
11#include <QPluginLoader>
12
13int main(int argc, char *argv[])
14{
15 QApplication app(argc, argv);
16 app.setQuitOnLastWindowClosed(false);
17
18 if (app.arguments().size() != 3) { // Expected usage: ./agent_launcher ${plugin_name} ${identifier}
19 qCDebug(AKONADIAGENTSERVER_LOG) << "Invalid usage: expected: ./agent_launcher pluginName agentIdentifier";
20 return 1;
21 }
22
23 const QString agentPluginName = app.arguments().at(1);
24 const QString agentIdentifier = app.arguments().at(2);
25
26 AgentPluginLoader loader;
27 QPluginLoader *factory = loader.load(agentPluginName);
28 if (!factory) {
29 return 1;
30 }
31
32 QObject *instance = nullptr;
33 // clang-format off
34 const bool invokeSucceeded = QMetaObject::invokeMethod(factory->instance(),
35 "createInstance",
37 Q_RETURN_ARG(QObject *, instance),
38 Q_ARG(QString, agentIdentifier));
39 // clang-format on
40 if (invokeSucceeded) {
41 qCDebug(AKONADIAGENTSERVER_LOG) << "Agent instance created in separate process.";
42 } else {
43 qCDebug(AKONADIAGENTSERVER_LOG) << "Agent instance creation in separate process failed";
44 return 2;
45 }
46
47 const int rv = app.exec();
48 delete instance;
49 return rv;
50}
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QObject * instance()
const QChar at(qsizetype position) const const
DirectConnection
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:03:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.