2017-06-06 16:48:30 +01:00
|
|
|
/*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2017-06-06 16:48:30 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2017-06-06 16:48:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DBUSHELPERS_H
|
|
|
|
#define DBUSHELPERS_H
|
|
|
|
|
|
|
|
#include <QDBusPendingReply>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Q_REQUIRED_RESULT T blockOnReply(QDBusPendingReply<T> reply)
|
|
|
|
{
|
|
|
|
reply.waitForFinished();
|
|
|
|
if (reply.isError()) {
|
|
|
|
QTextStream(stderr) << i18n("error: ") << reply.error().message() << endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return reply.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
void blockOnReply(QDBusPendingReply<void> reply)
|
|
|
|
{
|
|
|
|
reply.waitForFinished();
|
|
|
|
if (reply.isError()) {
|
|
|
|
QTextStream(stderr) << i18n("error: ") << reply.error().message() << endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|