Akonadi

agentlauncher.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Bertjan Broeksema <[email protected]>
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 
13 int 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 }
DirectConnection
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)
const QChar at(int position) const const
QObject * instance()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.