Akonadi

agentlauncher.cpp
1 /*
2  Copyright (c) 2010 Bertjan Broeksema <[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 "agentpluginloader.h"
21 #include "akonadiagentserver_debug.h"
22 
23 #include <QApplication>
24 
25 int main(int argc, char *argv[])
26 {
27  QApplication app(argc, argv);
28  app.setQuitOnLastWindowClosed(false);
29 
30  if (app.arguments().size() != 3) { // Expected usage: ./agent_launcher ${plugin_name} ${identifier}
31  qCDebug(AKONADIAGENTSERVER_LOG) << "Invalid usage: expected: ./agent_launcher pluginName agentIdentifier";
32  return 1;
33  }
34 
35  const QString agentPluginName = app.arguments().at(1);
36  const QString agentIdentifier = app.arguments().at(2);
37 
38  AgentPluginLoader loader;
39  QPluginLoader *factory = loader.load(agentPluginName);
40  if (!factory) {
41  return 1;
42  }
43 
44  QObject *instance = nullptr;
45  const bool invokeSucceeded = QMetaObject::invokeMethod(factory->instance(),
46  "createInstance",
47  Qt::DirectConnection,
48  Q_RETURN_ARG(QObject*, instance),
49  Q_ARG(QString, agentIdentifier));
50  if (invokeSucceeded) {
51  qCDebug(AKONADIAGENTSERVER_LOG) << "Agent instance created in separate process.";
52  } else {
53  qCDebug(AKONADIAGENTSERVER_LOG) << "Agent instance creation in separate process failed";
54  return 2;
55  }
56 
57  const int rv = app.exec();
58  delete instance;
59  return rv;
60 }
QObject * instance()
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.