Commit c029ae2b authored by Nicolas Fella's avatar Nicolas Fella Committed by Nicolas Fella

add --replace option to kdeconnectd

parent a67a99a7
Pipeline #3531 failed with stage
in 9 minutes and 23 seconds
......@@ -22,6 +22,10 @@
#include <QNetworkAccessManager>
#include <QTimer>
#include <QLoggingCategory>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QDBusMessage>
#include <QDBusConnection>
#include <KAboutData>
#include <KDBusService>
......@@ -106,6 +110,21 @@ int main(int argc, char* argv[])
app.setQuitOnLastWindowClosed(false);
app.setDesktopFileName(QStringLiteral("org.kde.kdeconnect.daemon"));
QCommandLineParser parser;
QCommandLineOption replaceOption({QStringLiteral("replace")}, i18n("Replace an existing instance"));
parser.addOption(replaceOption);
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
if (parser.isSet(replaceOption)) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnectd"),
QStringLiteral("/MainApplication"),
QStringLiteral("org.qtproject.Qt.QCoreApplication"),
QStringLiteral("quit"));
QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits
}
KDBusService dbusService(KDBusService::Unique);
DesktopDaemon daemon;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment