on xenial help sign in
switch to async DBUS calls
commitf5365cc349d65d08e21177eb5425a52a4ae1d35c authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 12 Jun 2015, 01:45 (11 years ago) parenta2958f0
20 files changed+214−246
plugins/AccountsService/AccountsService.cpp+31−42 plugins/AccountsService/AccountsService.h+4−3 plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+13−11 plugins/AccountsService/AccountsServiceDBusAdaptor.h+3−2 plugins/Lights/Lights.cpp+1−1 plugins/Powerd/Powerd.cpp+33−28 plugins/Powerd/Powerd.h+4−3 plugins/Ubuntu/SystemImage/SystemImage.cpp+7−8 plugins/Ubuntu/SystemImage/SystemImage.h+1−5 plugins/Unity/Connectivity/Connectivity.cpp+5−5 plugins/Unity/Connectivity/Connectivity.h+1 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+1−1 plugins/Unity/DashCommunicator/plugin.cpp+1 plugins/Unity/Launcher/dbusinterface.cpp−4 plugins/Unity/Launcher/dbusinterface.h+1−1 plugins/Unity/Session/dbusunitysessionservice.cpp+47−55 plugins/Unity/Session/dbusunitysessionservice.h+11−8 plugins/Wizard/System.cpp+13−9 tests/plugins/AccountsService/client.cpp+10−20 tests/plugins/Unity/Session/sessionbackendtest.cpp+27−40
plugins/AccountsService/AccountsService.cpp+31−42
@@ -23,10 +23,9 @@
2323#include <QStringList>
2424#include <QDebug>
2525
26−AccountsService::AccountsService(QObject* parent)
27− : QObject(parent),
26+AccountsService::AccountsService(QObject* parent, const QString &user)
27+ : QObject(parent),
2828 m_service(new AccountsServiceDBusAdaptor(this)),
29− m_user(""),
3029 m_demoEdges(false),
3130 m_enableLauncherWhileLocked(false),
3231 m_enableIndicatorsWhileLocked(false),
@@ -36,12 +35,10 @@ AccountsService::AccountsService(QObject* parent)
3635 m_hereEnabled(false),
3736 m_hereLicensePath() // null means not set yet
3837{
39− connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
40− this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
41− connect(m_service, SIGNAL(maybeChanged(const QString &)),
42− this, SLOT(maybeChanged(const QString &)));
38+ connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
39+ connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
4340
44− setUser(qgetenv("USER"));
41+ setUser(!user.isEmpty() ? user : QString::fromUtf8(qgetenv("USER")));
4542}
4643
4744QString AccountsService::user() const
@@ -173,19 +170,18 @@ void AccountsService::updateEnableLauncherWhileLocked(bool async)
173170 connect(watcher, &QDBusPendingCallWatcher::finished,
174171 this, [this](QDBusPendingCallWatcher* watcher) {
175172
176− QDBusPendingReply<QDBusVariant> reply = *watcher;
173+ QDBusPendingReply<QVariant> reply = *watcher;
174+ watcher->deleteLater();
177175 if (reply.isError()) {
178176 qWarning() << "Failed to get 'EnableLauncherWhileLocked' property - " << reply.error().message();
179− watcher->deleteLater();
180177 return;
181178 }
182179
183− auto enableLauncherWhileLocked = reply.value().variant().toBool();
180+ const bool enableLauncherWhileLocked = reply.value().toBool();
184181 if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
185182 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
186183 Q_EMIT enableLauncherWhileLockedChanged();
187184 }
188− watcher->deleteLater();
189185 });
190186 if (!async) {
191187 watcher->waitForFinished();
@@ -203,19 +199,18 @@ void AccountsService::updateEnableIndicatorsWhileLocked(bool async)
203199 connect(watcher, &QDBusPendingCallWatcher::finished,
204200 this, [this](QDBusPendingCallWatcher* watcher) {
205201
206− QDBusPendingReply<QDBusVariant> reply = *watcher;
202+ QDBusPendingReply<QVariant> reply = *watcher;
203+ watcher->deleteLater();
207204 if (reply.isError()) {
208205 qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property - " << reply.error().message();
209− watcher->deleteLater();
210206 return;
211207 }
212208
213− auto enableIndicatorsWhileLocked = reply.value().variant().toBool();
209+ const bool enableIndicatorsWhileLocked = reply.value().toBool();
214210 if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
215211 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
216212 Q_EMIT enableIndicatorsWhileLockedChanged();
217213 }
218− watcher->deleteLater();
219214 });
220215 if (!async) {
221216 watcher->waitForFinished();
@@ -233,19 +228,18 @@ void AccountsService::updateBackgroundFile(bool async)
233228 connect(watcher, &QDBusPendingCallWatcher::finished,
234229 this, [this](QDBusPendingCallWatcher* watcher) {
235230
236− QDBusPendingReply<QDBusVariant> reply = *watcher;
231+ QDBusPendingReply<QVariant> reply = *watcher;
232+ watcher->deleteLater();
237233 if (reply.isError()) {
238234 qWarning() << "Failed to get 'BackgroundFile' property - " << reply.error().message();
239− watcher->deleteLater();
240235 return;
241236 }
242237
243− auto backgroundFile = reply.value().variant().toString();
238+ const QString backgroundFile = reply.value().toString();
244239 if (m_backgroundFile != backgroundFile) {
245240 m_backgroundFile = backgroundFile;
246241 Q_EMIT backgroundFileChanged();
247242 }
248− watcher->deleteLater();
249243 });
250244 if (!async) {
251245 watcher->waitForFinished();
@@ -263,19 +257,18 @@ void AccountsService::updateStatsWelcomeScreen(bool async)
263257 connect(watcher, &QDBusPendingCallWatcher::finished,
264258 this, [this](QDBusPendingCallWatcher* watcher) {
265259
266− QDBusPendingReply<QDBusVariant> reply = *watcher;
260+ QDBusPendingReply<QVariant> reply = *watcher;
261+ watcher->deleteLater();
267262 if (reply.isError()) {
268263 qWarning() << "Failed to get 'StatsWelcomeScreen' property - " << reply.error().message();
269− watcher->deleteLater();
270264 return;
271265 }
272266
273− auto statsWelcomeScreen = reply.value().variant().toBool();
267+ const bool statsWelcomeScreen = reply.value().toBool();
274268 if (m_statsWelcomeScreen != statsWelcomeScreen) {
275269 m_statsWelcomeScreen = statsWelcomeScreen;
276270 Q_EMIT statsWelcomeScreenChanged();
277271 }
278− watcher->deleteLater();
279272 });
280273 if (!async) {
281274 watcher->waitForFinished();
@@ -293,19 +286,18 @@ void AccountsService::updatePasswordDisplayHint(bool async)
293286 connect(watcher, &QDBusPendingCallWatcher::finished,
294287 this, [this](QDBusPendingCallWatcher* watcher) {
295288
296− QDBusPendingReply<QDBusVariant> reply = *watcher;
289+ QDBusPendingReply<QVariant> reply = *watcher;
290+ watcher->deleteLater();
297291 if (reply.isError()) {
298292 qWarning() << "Failed to get 'PasswordDisplayHint' property - " << reply.error().message();
299− watcher->deleteLater();
300293 return;
301294 }
302295
303− PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().variant().toInt();
296+ const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();
304297 if (m_passwordDisplayHint != passwordDisplayHint) {
305298 m_passwordDisplayHint = passwordDisplayHint;
306299 Q_EMIT passwordDisplayHintChanged();
307300 }
308− watcher->deleteLater();
309301 });
310302 if (!async) {
311303 watcher->waitForFinished();
@@ -323,19 +315,18 @@ void AccountsService::updateFailedLogins(bool async)
323315 connect(watcher, &QDBusPendingCallWatcher::finished,
324316 this, [this](QDBusPendingCallWatcher* watcher) {
325317
326− QDBusPendingReply<QDBusVariant> reply = *watcher;
318+ QDBusPendingReply<QVariant> reply = *watcher;
319+ watcher->deleteLater();
327320 if (reply.isError()) {
328321 qWarning() << "Failed to get 'FailedLogins' property - " << reply.error().message();
329− watcher->deleteLater();
330322 return;
331323 }
332324
333− uint failedLogins = reply.value().variant().toUInt();
325+ const uint failedLogins = reply.value().toUInt();
334326 if (m_failedLogins != failedLogins) {
335327 m_failedLogins = failedLogins;
336328 Q_EMIT failedLoginsChanged();
337329 }
338− watcher->deleteLater();
339330 });
340331 if (!async) {
341332 watcher->waitForFinished();
@@ -353,19 +344,18 @@ void AccountsService::updateHereEnabled(bool async)
353344 connect(watcher, &QDBusPendingCallWatcher::finished,
354345 this, [this](QDBusPendingCallWatcher* watcher) {
355346
356− QDBusPendingReply<QDBusVariant> reply = *watcher;
347+ QDBusPendingReply<QVariant> reply = *watcher;
348+ watcher->deleteLater();
357349 if (reply.isError()) {
358350 qWarning() << "Failed to get 'LicenseAccepted' property - " << reply.error().message();
359− watcher->deleteLater();
360351 return;
361352 }
362353
363− auto hereEnabled = reply.value().variant().toBool();
354+ const bool hereEnabled = reply.value().toBool();
364355 if (m_hereEnabled != hereEnabled) {
365356 m_hereEnabled = hereEnabled;
366357 Q_EMIT hereEnabledChanged();
367358 }
368− watcher->deleteLater();
369359 });
370360 if (!async) {
371361 watcher->waitForFinished();
@@ -383,14 +373,14 @@ void AccountsService::updateHereLicensePath(bool async)
383373 connect(watcher, &QDBusPendingCallWatcher::finished,
384374 this, [this](QDBusPendingCallWatcher* watcher) {
385375
386− QDBusPendingReply<QDBusVariant> reply = *watcher;
376+ QDBusPendingReply<QVariant> reply = *watcher;
377+ watcher->deleteLater();
387378 if (reply.isError()) {
388379 qWarning() << "Failed to get 'LicenseBasePath' property - " << reply.error().message();
389− watcher->deleteLater();
390380 return;
391381 }
392382
393− auto hereLicensePath = reply.value().variant().toString();
383+ QString hereLicensePath = reply.value().toString();
394384 if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
395385 hereLicensePath = "";
396386
@@ -398,7 +388,6 @@ void AccountsService::updateHereLicensePath(bool async)
398388 m_hereLicensePath = hereLicensePath;
399389 Q_EMIT hereLicensePathChanged();
400390 }
401− watcher->deleteLater();
402391 });
403392 if (!async) {
404393 watcher->waitForFinished();
@@ -421,7 +410,7 @@ void AccountsService::setFailedLogins(uint failedLogins)
421410 }
422411}
423412
424−void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
413+void AccountsService::onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
425414{
426415 if (m_user != user) {
427416 return;
@@ -459,7 +448,7 @@ void AccountsService::propertiesChanged(const QString &user, const QString &inte
459448 }
460449}
461450
462−void AccountsService::maybeChanged(const QString &user)
451+void AccountsService::onMaybeChanged(const QString &user)
463452{
464453 if (m_user != user) {
465454 return;
plugins/AccountsService/AccountsService.h+4−3
@@ -72,7 +72,8 @@ public:
7272 Numeric,
7373 };
7474
75− explicit AccountsService(QObject *parent = 0);
75+ explicit AccountsService(QObject *parent = 0, const QString & user = QString());
76+ ~AccountsService() = default;
7677
7778 QString user() const;
7879 void setUser(const QString &user);
@@ -103,8 +104,8 @@ Q_SIGNALS:
103104 void hereLicensePathChanged();
104105
105106private Q_SLOTS:
106− void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
107− void maybeChanged(const QString &user);
107+ void onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
108+ void onMaybeChanged(const QString &user);
108109
109110private:
110111 void updateDemoEdges(bool async = true);
plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+13−11
@@ -21,35 +21,35 @@
2121#include <QDBusConnectionInterface>
2222#include <QDBusMessage>
2323#include <QDBusVariant>
24+#include <QDebug>
2425
2526AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
2627 : QObject(parent),
2728 m_accountsManager(nullptr),
28− m_users(),
2929 m_ignoreNextChanged(false)
3030{
3131 QDBusConnection connection = QDBusConnection::SM_BUSNAME();
3232 QDBusConnectionInterface *interface = connection.interface();
3333 interface->startService("org.freedesktop.Accounts");
3434 m_accountsManager = new QDBusInterface("org.freedesktop.Accounts",
35− "/org/freedesktop/Accounts",
36− "org.freedesktop.Accounts",
37− connection, this);
35+ "/org/freedesktop/Accounts",
36+ "org.freedesktop.Accounts",
37+ connection, this);
3838}
3939
4040QVariant AccountsServiceDBusAdaptor::getUserProperty(const QString &user, const QString &interface, const QString &property)
4141{
4242 QDBusInterface *iface = getUserInterface(user);
4343 if (iface != nullptr && iface->isValid()) {
44− QDBusMessage answer = iface->call("Get", interface, property);
45− if (answer.type() == QDBusMessage::ReplyMessage) {
46− return answer.arguments()[0].value<QDBusVariant>().variant();
44+ QDBusReply<QVariant> answer = iface->call("Get", interface, property);
45+ if (answer.isValid()) {
46+ return answer;
4747 }
4848 }
4949 return QVariant();
5050}
5151
52−QDBusPendingReply<QDBusVariant> AccountsServiceDBusAdaptor::getUserPropertyAsync(const QString &user, const QString &interface, const QString &property)
52+QDBusPendingReply<QVariant> AccountsServiceDBusAdaptor::getUserPropertyAsync(const QString &user, const QString &interface, const QString &property)
5353{
5454 QDBusInterface *iface = getUserInterface(user);
5555 if (iface != nullptr && iface->isValid()) {
@@ -116,9 +116,9 @@ QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user
116116{
117117 QDBusInterface *iface = m_users.value(user);
118118 if (iface == nullptr && m_accountsManager->isValid()) {
119− QDBusMessage answer = m_accountsManager->call("FindUserByName", user);
120− if (answer.type() == QDBusMessage::ReplyMessage) {
121− QString path = answer.arguments()[0].value<QDBusObjectPath>().path();
119+ QDBusReply<QDBusObjectPath> answer = m_accountsManager->asyncCall("FindUserByName", user);
120+ if (answer.isValid()) {
121+ const QString path = answer.value().path();
122122
123123 iface = new QDBusInterface("org.freedesktop.Accounts",
124124 path,
@@ -148,6 +148,8 @@ QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user
148148 SLOT(propertiesChangedSlot(QString, QVariantMap, QStringList)));
149149
150150 m_users.insert(user, iface);
151+ } else {
152+ qWarning() << "Couldn't get user interface" << answer.error().name() << answer.error().message();
151153 }
152154 }
153155 return iface;
plugins/AccountsService/AccountsServiceDBusAdaptor.h+3−2
@@ -33,13 +33,14 @@ class AccountsServiceDBusAdaptor: public QObject, public QDBusContext
3333
3434public:
3535 explicit AccountsServiceDBusAdaptor(QObject *parent = 0);
36+ ~AccountsServiceDBusAdaptor() = default;
3637
3738 Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &interface, const QString &property);
38− Q_INVOKABLE QDBusPendingReply<QDBusVariant> getUserPropertyAsync(const QString &user, const QString &interface, const QString &property);
39+ Q_INVOKABLE QDBusPendingReply<QVariant> getUserPropertyAsync(const QString &user, const QString &interface, const QString &property);
3940
4041 template <typename T>
4142 inline T getUserProperty(const QString &user, const QString &interface, const QString &property) {
42− QVariant variant = getUserProperty(user, interface, property);
43+ const QVariant variant = getUserProperty(user, interface, property);
4344 if (variant.isValid() && variant.canConvert<QDBusArgument>()) {
4445 return qdbus_cast<T>(variant.value<QDBusArgument>());
4546 }
plugins/Lights/Lights.cpp+1−1
@@ -71,7 +71,7 @@ void Lights::setColor(const QColor &color)
7171 if (m_color != color) {
7272 m_color = color;
7373 Q_EMIT colorChanged(m_color);
74− // FIXME: update the collor if the light is already on
74+ // FIXME: update the color if the light is already on
7575 }
7676}
7777
plugins/Powerd/Powerd.cpp+33−28
@@ -18,54 +18,49 @@
1818
1919#include "Powerd.h"
2020#include <QDBusPendingCall>
21+#include <QDBusConnection>
2122
22−void autoBrightnessChanged(GSettings *settings, const gchar *key, QDBusInterface *unityScreen)
23+void autoBrightnessChanged(GSettings *settings, const gchar *key, Powerd * instance)
2324{
24− bool value = g_settings_get_boolean(settings, key);
25− unityScreen->asyncCall("userAutobrightnessEnable", QVariant(value));
25+ const bool value = g_settings_get_boolean(settings, key);
26+ instance->performAsyncCall("userAutobrightnessEnable", {value});
2627}
2728
28−void activityTimeoutChanged(GSettings *settings, const gchar *key, QDBusInterface *unityScreen)
29+void activityTimeoutChanged(GSettings *settings, const gchar *key, Powerd * instance)
2930{
30− int value = g_settings_get_uint(settings, key);
31− unityScreen->asyncCall("setInactivityTimeouts", QVariant(value), QVariant(-1));
31+ const int value = g_settings_get_int(settings, key);
32+ instance->performAsyncCall("setInactivityTimeouts", {value, -1});
3233}
3334
34−void dimTimeoutChanged(GSettings *settings, const gchar *key, QDBusInterface *unityScreen)
35+void dimTimeoutChanged(GSettings *settings, const gchar *key, Powerd * instance)
3536{
36− int value = g_settings_get_uint(settings, key);
37− unityScreen->asyncCall("setInactivityTimeouts", QVariant(-1), QVariant(value));
37+ const int value = g_settings_get_int(settings, key);
38+ instance->performAsyncCall("setInactivityTimeouts", {-1, value});
3839}
3940
4041Powerd::Powerd(QObject* parent)
4142 : QObject(parent),
42− unityScreen(nullptr),
4343 cachedStatus(Status::On)
4444{
45− unityScreen = new QDBusInterface("com.canonical.Unity.Screen",
46− "/com/canonical/Unity/Screen",
47− "com.canonical.Unity.Screen",
48− QDBusConnection::SM_BUSNAME(), this);
49−
50− unityScreen->connection().connect("com.canonical.Unity.Screen",
51− "/com/canonical/Unity/Screen",
52− "com.canonical.Unity.Screen",
53− "DisplayPowerStateChange",
54− this,
55− SLOT(handleDisplayPowerStateChange(int, int)));
45+ QDBusConnection::SM_BUSNAME().connect("com.canonical.Unity.Screen",
46+ "/com/canonical/Unity/Screen",
47+ "com.canonical.Unity.Screen",
48+ "DisplayPowerStateChange",
49+ this,
50+ SLOT(handleDisplayPowerStateChange(int, int)));
5651
5752 systemSettings = g_settings_new("com.ubuntu.touch.system");
58− g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), unityScreen);
59− g_signal_connect(systemSettings, "changed::activity-timeout", G_CALLBACK(activityTimeoutChanged), unityScreen);
60− g_signal_connect(systemSettings, "changed::dim-timeout", G_CALLBACK(dimTimeoutChanged), unityScreen);
61− autoBrightnessChanged(systemSettings, "auto-brightness", unityScreen);
62− activityTimeoutChanged(systemSettings, "activity-timeout", unityScreen);
63− dimTimeoutChanged(systemSettings, "dim-timeout", unityScreen);
53+ g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), this);
54+ g_signal_connect(systemSettings, "changed::activity-timeout", G_CALLBACK(activityTimeoutChanged), this);
55+ g_signal_connect(systemSettings, "changed::dim-timeout", G_CALLBACK(dimTimeoutChanged), this);
56+ autoBrightnessChanged(systemSettings, "auto-brightness", this);
57+ activityTimeoutChanged(systemSettings, "activity-timeout", this);
58+ dimTimeoutChanged(systemSettings, "dim-timeout", this);
6459}
6560
6661Powerd::~Powerd()
6762{
68− g_signal_handlers_disconnect_by_data(systemSettings, unityScreen);
63+ g_signal_handlers_disconnect_by_data(systemSettings, this);
6964 g_object_unref(systemSettings);
7065}
7166
@@ -81,3 +76,13 @@ void Powerd::handleDisplayPowerStateChange(int status, int reason)
8176 Q_EMIT statusChanged((DisplayStateChangeReason)reason);
8277 }
8378}
79+
80+void Powerd::performAsyncCall(const QString &method, const QVariantList &args)
81+{
82+ QDBusMessage msg = QDBusMessage::createMethodCall("com.canonical.Unity.Screen",
83+ "/com/canonical/Unity/Screen",
84+ "com.canonical.Unity.Screen",
85+ method);
86+ msg.setArguments(args);
87+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
88+}
plugins/Powerd/Powerd.h+4−3
@@ -21,8 +21,7 @@
2121#define UNITY_POWERD_H
2222
2323#include <gio/gio.h>
24−#include <QtCore/QObject>
25−#include <QtDBus/QDBusInterface>
24+#include <QObject>
2625
2726class Powerd: public QObject
2827{
@@ -30,6 +29,7 @@ class Powerd: public QObject
3029 Q_ENUMS(Status)
3130 Q_ENUMS(DisplayStateChangeReason)
3231 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
32+ Q_DISABLE_COPY(Powerd)
3333
3434public:
3535 enum DisplayStateChangeReason {
@@ -49,6 +49,8 @@ public:
4949
5050 Status status() const;
5151
52+ void performAsyncCall(const QString &method, const QVariantList &args);
53+
5254Q_SIGNALS:
5355 void statusChanged(DisplayStateChangeReason reason);
5456
@@ -56,7 +58,6 @@ private Q_SLOTS:
5658 void handleDisplayPowerStateChange(int status, int reason);
5759
5860private:
59− QDBusInterface *unityScreen;
6061 GSettings *systemSettings;
6162 Status cachedStatus;
6263};
plugins/Ubuntu/SystemImage/SystemImage.cpp+7−8
@@ -16,19 +16,18 @@
1616
1717#include "SystemImage.h"
1818#include <QDBusConnection>
19−#include <QDBusInterface>
19+#include <QDBusPendingCall>
2020
2121SystemImage::SystemImage(QObject *parent)
22− : QObject(parent),
23− m_interface(new QDBusInterface("com.canonical.SystemImage",
24− "/Service",
25− "com.canonical.SystemImage",
26− QDBusConnection::systemBus(),
27− this))
22+ : QObject(parent)
2823{
2924}
3025
3126void SystemImage::factoryReset()
3227{
33− m_interface->call("FactoryReset");
28+ const QDBusMessage msg = QDBusMessage::createMethodCall("com.canonical.SystemImage",
29+ "/Service",
30+ "com.canonical.SystemImage",
31+ "FactoryReset");
32+ QDBusConnection::systemBus().asyncCall(msg);
3433}
plugins/Ubuntu/SystemImage/SystemImage.h+1−5
@@ -19,8 +19,6 @@
1919
2020#include <QObject>
2121
22−class QDBusInterface;
23−
2422class SystemImage : public QObject
2523{
2624 Q_OBJECT
@@ -28,11 +26,9 @@ class SystemImage : public QObject
2826
2927public:
3028 explicit SystemImage(QObject *parent = 0);
29+ ~SystemImage() = default;
3130
3231 Q_INVOKABLE void factoryReset();
33−
34−private:
35− QDBusInterface *m_interface;
3632};
3733
3834#endif // SYSTEMIMAGE_H
plugins/Unity/Connectivity/Connectivity.cpp+5−5
@@ -16,7 +16,6 @@
1616
1717#include "Connectivity.h"
1818#include <QDBusConnection>
19−#include <QDBusInterface>
2019#include <QDBusPendingCall>
2120
2221Connectivity::Connectivity(QObject *parent)
@@ -26,8 +25,9 @@ Connectivity::Connectivity(QObject *parent)
2625
2726void Connectivity::unlockAllModems()
2827{
29− QDBusInterface iface("com.ubuntu.connectivity1",
30− "/com/ubuntu/connectivity1/Private",
31− "com.ubuntu.connectivity1.Private");
32− iface.asyncCall("UnlockAllModems");
28+ const QDBusMessage msg = QDBusMessage::createMethodCall("com.ubuntu.connectivity1",
29+ "/com/ubuntu/connectivity1/Private",
30+ "com.ubuntu.connectivity1.Private",
31+ "UnlockAllModems");
32+ QDBusConnection::sessionBus().asyncCall(msg);
3333}
plugins/Unity/Connectivity/Connectivity.h+1
@@ -26,6 +26,7 @@ class Connectivity : public QObject
2626
2727public:
2828 explicit Connectivity(QObject *parent = 0);
29+ ~Connectivity() = default;
2930
3031 Q_INVOKABLE void unlockAllModems();
3132};
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+1−1
@@ -36,4 +36,4 @@ public Q_SLOTS:
3636
3737};
3838
39−#endif // DBUSUNITYSESSIONSERVICE_H
39+#endif // DBUSDASHCOMMUNICATORSERVICE_H
plugins/Unity/DashCommunicator/plugin.cpp+1
@@ -25,6 +25,7 @@
2525
2626void DashCommunicatorPlugin::registerTypes(const char *uri)
2727{
28+ // @uri Unity.DashCommunicator
2829 Q_ASSERT(uri == QStringLiteral("Unity.DashCommunicator"));
2930 qmlRegisterType<DashCommunicatorService>(uri, 0, 1, "DashCommunicatorService");
3031 qmlRegisterType<DashCommunicator>(uri, 0, 1, "DashCommunicator");
plugins/Unity/Launcher/dbusinterface.cpp−4
@@ -32,10 +32,6 @@ DBusInterface::DBusInterface(LauncherModel *parent):
3232{
3333}
3434
35−DBusInterface::~DBusInterface()
36−{
37−}
38−
3935QString DBusInterface::introspect(const QString &path) const
4036{
4137 /* This case we should just list the nodes */
plugins/Unity/Launcher/dbusinterface.h+1−1
@@ -27,7 +27,7 @@ class DBusInterface: public UnityDBusVirtualObject
2727 Q_OBJECT
2828public:
2929 DBusInterface(LauncherModel *parent);
30− ~DBusInterface();
30+ ~DBusInterface() = default;
3131
3232 // QDBusVirtualObject implementaition
3333 QString introspect (const QString &path) const override;
plugins/Unity/Session/dbusunitysessionservice.cpp+47−55
@@ -18,77 +18,69 @@
1818#include "dbusunitysessionservice.h"
1919
2020// Qt
21−#include <QDBusConnection>
22−#include <QDBusInterface>
21+#include <QDBusPendingCall>
2322
2423DBusUnitySessionService::DBusUnitySessionService()
2524 : UnityDBusObject("/com/canonical/Unity/Session", "com.canonical.Unity")
2625{
2726}
2827
29−DBusUnitySessionService::~DBusUnitySessionService()
30−{
31−}
32−
3328void DBusUnitySessionService::Logout()
3429{
35− Q_EMIT logoutReady();
30+ // TODO ask the apps to quit and then emit the signal
31+ Q_EMIT logoutReady();
3632}
3733
3834void DBusUnitySessionService::EndSession()
3935{
40− QDBusConnection connection = QDBusConnection::sessionBus();
41− QDBusInterface iface1 ("com.ubuntu.Upstart",
42− "/com/ubuntu/Upstart",
43− "com.ubuntu.Upstart0_6",
44− connection);
45−
46− iface1.call("EndSession");
36+ const QDBusMessage msg = QDBusMessage::createMethodCall("com.ubuntu.Upstart",
37+ "/com/ubuntu/Upstart",
38+ "com.ubuntu.Upstart0_6",
39+ "EndSession");
40+ QDBusConnection::sessionBus().asyncCall(msg);
4741}
4842
4943void DBusUnitySessionService::RequestLogout()
5044{
51− Q_EMIT logoutRequested(false);
45+ Q_EMIT logoutRequested(false);
5246}
5347
5448void DBusUnitySessionService::Reboot()
5549{
56− QDBusConnection connection = QDBusConnection::systemBus();
57− QDBusInterface iface1 ("org.freedesktop.login1",
58− "/org/freedesktop/login1",
59− "org.freedesktop.login1.Manager",
60− connection);
61−
62− iface1.call("Reboot", false);
50+ QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.login1",
51+ "/org/freedesktop/login1",
52+ "org.freedesktop.login1.Manager",
53+ "Reboot");
54+ msg << false;
55+ QDBusConnection::systemBus().asyncCall(msg);
6356}
6457
6558void DBusUnitySessionService::RequestReboot()
6659{
67− Q_EMIT rebootRequested(false);
60+ Q_EMIT rebootRequested(false);
6861}
6962
7063void DBusUnitySessionService::Shutdown()
7164{
72− QDBusConnection connection = QDBusConnection::systemBus();
73− QDBusInterface iface1 ("org.freedesktop.login1",
74− "/org/freedesktop/login1",
75− "org.freedesktop.login1.Manager",
76− connection);
77−
78− iface1.call("PowerOff", false);
65+ QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.login1",
66+ "/org/freedesktop/login1",
67+ "org.freedesktop.login1.Manager",
68+ "PowerOff");
69+ msg << false;
70+ QDBusConnection::systemBus().asyncCall(msg);
7971}
8072
8173void DBusUnitySessionService::RequestShutdown()
8274{
83− Q_EMIT shutdownRequested(false);
75+ Q_EMIT shutdownRequested(false);
8476}
8577
8678enum class Action : unsigned
8779{
88− LOGOUT = 0,
89− SHUTDOWN,
90− REBOOT,
91− NONE
80+ LOGOUT = 0,
81+ SHUTDOWN,
82+ REBOOT,
83+ NONE
9284};
9385
9486DBusGnomeSessionManagerWrapper::DBusGnomeSessionManagerWrapper()
@@ -96,38 +88,38 @@ DBusGnomeSessionManagerWrapper::DBusGnomeSessionManagerWrapper()
9688{
9789}
9890
99−DBusGnomeSessionManagerWrapper::~DBusGnomeSessionManagerWrapper()
91+void DBusGnomeSessionManagerWrapper::performAsyncCall(const QString &method)
10092{
93+ const QDBusMessage msg = QDBusMessage::createMethodCall("com.canonical.Unity",
94+ "/com/canonical/Unity/Session",
95+ "com.canonical.Unity.Session",
96+ method);
97+ QDBusConnection::sessionBus().asyncCall(msg);
10198}
10299
103100void DBusGnomeSessionManagerWrapper::Open(const unsigned type, const unsigned arg_1, const unsigned max_wait, const QList<QDBusObjectPath> &inhibitors)
104101{
105− Q_UNUSED(arg_1);
106− Q_UNUSED(max_wait);
107− Q_UNUSED(inhibitors);
108−
109− QDBusConnection connection = QDBusConnection::sessionBus();
110− QDBusInterface iface1 ("com.canonical.Unity",
111− "/com/canonical/Unity/Session",
112− "com.canonical.Unity.Session",
113− connection);
102+ Q_UNUSED(arg_1);
103+ Q_UNUSED(max_wait);
104+ Q_UNUSED(inhibitors);
114105
115− Action action = (Action)type;
106+ const Action action = (Action)type;
116107
117− switch (action)
118− {
108+ switch (action)
109+ {
119110 case Action::LOGOUT:
120− iface1.call("RequestLogout");
121− break;
111+ performAsyncCall("RequestLogout");
112+ break;
122113
123114 case Action::REBOOT:
124− iface1.call("RequestShutdown");
125− break;
115+ performAsyncCall("RequestReboot");
116+ break;
126117
127118 case Action::SHUTDOWN:
128− break;
119+ performAsyncCall("RequestShutdown");
120+ break;
129121
130122 default:
131− break;
132− }
123+ break;
124+ }
133125}
plugins/Unity/Session/dbusunitysessionservice.h+11−8
@@ -38,7 +38,7 @@ class DBusUnitySessionService : public UnityDBusObject
3838
3939public:
4040 DBusUnitySessionService();
41− ~DBusUnitySessionService();
41+ ~DBusUnitySessionService() = default;
4242
4343 // For use in QML. Javascript doesn't accept functions beginning with capital letters
4444 Q_INVOKABLE void logout() { Logout(); }
@@ -90,7 +90,7 @@ public Q_SLOTS:
9090 /**
9191 * Logout the system.
9292 *
93− * This method directly logout the system without user's confirmation.
93+ * This method directly logs out the system without user's confirmation.
9494 * Ordinary applications should avoid calling this method. Please call
9595 * RequestLogout() to ask the user to decide logout or not.
9696 */
@@ -99,7 +99,7 @@ public Q_SLOTS:
9999 /**
100100 * Reboot the system.
101101 *
102− * This method directly reboot the system without user's confirmation.
102+ * This method directly reboots the system without user's confirmation.
103103 * Ordinary applications should avoid calling this method. Please call
104104 * RequestReboot() to ask the user to decide reboot or not.
105105 */
@@ -108,7 +108,7 @@ public Q_SLOTS:
108108 /**
109109 * Shutdown the system.
110110 *
111− * This method directly shutdown the system without user's confirmation.
111+ * This method directly shuts down the system without user's confirmation.
112112 * Ordinary applications should avoid calling this method. Please call
113113 * RequestShutdown() to ask the user to decide shutdown or not.
114114 */
@@ -117,7 +117,7 @@ public Q_SLOTS:
117117 /**
118118 * Issue a logout request.
119119 *
120− * This method emit the logoutRequested signal to the shell with a boolean
120+ * This method emits the logoutRequested signal to the shell with a boolean
121121 * which indicates if there's any inhibitors. The shell should receive
122122 * this signal and display a dialog to ask the user to confirm the logout
123123 * action. If confirmed, shell can call Logout() method to logout.
@@ -127,7 +127,7 @@ public Q_SLOTS:
127127 /**
128128 * Issue a reboot request.
129129 *
130− * This method emit the rebootRequested signal to the shell with a boolean
130+ * This method emist the rebootRequested signal to the shell with a boolean
131131 * which indicates if there's any inhibitors. The shell should receive
132132 * this signal and display a dialog to ask the user to confirm the reboot
133133 * action. If confirmed, shell can call Reboot() method to reboot
@@ -137,7 +137,7 @@ public Q_SLOTS:
137137 /**
138138 * Issue a shutdown request.
139139 *
140− * This method emit the shutdownRequested signal to the shell with a
140+ * This method emits the shutdownRequested signal to the shell with a
141141 * boolean which indicates if there's any inhibitors.
142142 * The shell should receive
143143 * this signal and display a dialog to ask the user to confirm the reboot
@@ -161,9 +161,12 @@ class DBusGnomeSessionManagerWrapper : public UnityDBusObject
161161
162162public:
163163 DBusGnomeSessionManagerWrapper();
164− ~DBusGnomeSessionManagerWrapper();
164+ ~DBusGnomeSessionManagerWrapper() = default;
165165
166166public Q_SLOTS:
167167 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
168+
169+private:
170+ void performAsyncCall(const QString &method);
168171};
169172#endif // DBUSUNITYSESSIONSERVICE_H
plugins/Wizard/System.cpp+13−9
@@ -16,7 +16,9 @@
1616
1717#include "System.h"
1818
19−#include <QDBusInterface>
19+#include <QDBusPendingCall>
20+#include <QDBusMessage>
21+#include <QDBusConnection>
2022#include <QDBusMetaType>
2123#include <QDir>
2224#include <QFile>
@@ -65,21 +67,23 @@ void System::setWizardEnabled(bool enabled)
6567void System::setSessionVariable(const QString &variable, const QString &value)
6668{
6769 // We need to update both upstart's and DBus's environment
68− QProcess::execute(QString("initctl set-env --global %1=%2").arg(variable, value));
69−
70− QDBusInterface iface("org.freedesktop.DBus",
71− "/org/freedesktop/DBus",
72− "org.freedesktop.DBus",
73− QDBusConnection::sessionBus());
70+ QProcess::startDetached(QStringLiteral("initctl set-env --global %1=%2").arg(variable, value));
7471
7572 QMap<QString,QString> valueMap;
7673 valueMap.insert(variable, value);
77− iface.call("UpdateActivationEnvironment", QVariant::fromValue(valueMap));
74+
75+ QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.DBus",
76+ "/org/freedesktop/DBus",
77+ "org.freedesktop.DBus",
78+ "UpdateActivationEnvironment");
79+
80+ msg << QVariant::fromValue(valueMap);
81+ QDBusConnection::sessionBus().asyncCall(msg);
7882}
7983
8084void System::updateSessionLanguage(const QString &locale)
8185{
82− QString language = locale.split(".")[0];
86+ const QString language = locale.split(".")[0];
8387
8488 setSessionVariable("LANGUAGE", language);
8589 setSessionVariable("LANG", locale);
tests/plugins/AccountsService/client.cpp+10−20
@@ -94,8 +94,7 @@ private Q_SLOTS:
9494
9595 void testGetSetService()
9696 {
97− AccountsService session;
98− session.setUser(QTest::currentTestFunction());
97+ AccountsService session(this, QTest::currentTestFunction());
9998
10099 QCOMPARE(session.demoEdges(), false);
101100 session.setDemoEdges(true);
@@ -112,8 +111,7 @@ private Q_SLOTS:
112111
113112 void testAsynchornousChangeForDemoEdges()
114113 {
115− AccountsService session;
116− session.setUser(QTest::currentTestFunction());
114+ AccountsService session(this, QTest::currentTestFunction());
117115
118116 QCOMPARE(session.demoEdges(), false);
119117 ASSERT_DBUS_CALL(m_userInterface->call("Set",
@@ -125,8 +123,7 @@ private Q_SLOTS:
125123
126124 void testAsynchornousChangeForFailedLogins()
127125 {
128− AccountsService session;
129− session.setUser(QTest::currentTestFunction());
126+ AccountsService session(this, QTest::currentTestFunction());
130127
131128 QCOMPARE(session.failedLogins(), (uint)0);
132129 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -138,8 +135,7 @@ private Q_SLOTS:
138135
139136 void testAsynchornousChangeForStatsWelcomeScreen()
140137 {
141− AccountsService session;
142− session.setUser(QTest::currentTestFunction());
138+ AccountsService session(this, QTest::currentTestFunction());
143139
144140 QCOMPARE(session.statsWelcomeScreen(), true);
145141 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -151,8 +147,7 @@ private Q_SLOTS:
151147
152148 void testAsynchornousChangeForStatsEnableLauncherWhileLocked()
153149 {
154− AccountsService session;
155− session.setUser(QTest::currentTestFunction());
150+ AccountsService session(this, QTest::currentTestFunction());
156151
157152 QCOMPARE(session.enableLauncherWhileLocked(), true);
158153 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -164,8 +159,7 @@ private Q_SLOTS:
164159
165160 void testAsynchornousChangeForStatsEnableIndicatorsWhileLocked()
166161 {
167− AccountsService session;
168− session.setUser(QTest::currentTestFunction());
162+ AccountsService session(this, QTest::currentTestFunction());
169163
170164 QCOMPARE(session.enableIndicatorsWhileLocked(), true);
171165 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -177,8 +171,7 @@ private Q_SLOTS:
177171
178172 void testAsynchornousChangeForStatsPasswordDisplayHint()
179173 {
180− AccountsService session;
181− session.setUser(QTest::currentTestFunction());
174+ AccountsService session(this, QTest::currentTestFunction());
182175
183176 QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
184177 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -190,8 +183,7 @@ private Q_SLOTS:
190183
191184 void testAsynchornousChangeForStatsLicenseAccepted()
192185 {
193− AccountsService session;
194− session.setUser(QTest::currentTestFunction());
186+ AccountsService session(this, QTest::currentTestFunction());
195187
196188 QCOMPARE(session.hereEnabled(), false);
197189 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -203,8 +195,7 @@ private Q_SLOTS:
203195
204196 void testAsynchornousChangeForLicenseBasePath()
205197 {
206− AccountsService session;
207− session.setUser(QTest::currentTestFunction());
198+ AccountsService session(this, QTest::currentTestFunction());
208199
209200 QCOMPARE(session.hereLicensePath(), QString());
210201 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
@@ -216,8 +207,7 @@ private Q_SLOTS:
216207
217208 void testAsynchornousChangeForStatsBackgroundFile()
218209 {
219− AccountsService session;
220− session.setUser(QTest::currentTestFunction());
210+ AccountsService session(this, QTest::currentTestFunction());
221211
222212 QCOMPARE(session.backgroundFile(), QString());
223213 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
tests/plugins/Unity/Session/sessionbackendtest.cpp+27−40
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2015 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -15,6 +15,7 @@
1515 *
1616 * Authors:
1717 * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
18+ * Lukáš Tinkl <lukas.tinkl@canonical.com>
1819 */
1920
2021#include <QtTest>
@@ -49,17 +50,22 @@ private Q_SLOTS:
4950
5051 void testUnitySessionLogoutRequested_data() {
5152 QTest::addColumn<QString>("method");
53+ QTest::addColumn<QString>("signal");
5254
53− QTest::newRow("Logout") << "RequestLogout";
55+ QTest::newRow("Logout") << "RequestLogout" << "logoutRequested(bool)";
56+ QTest::newRow("Reboot") << "RequestReboot" << "rebootRequested(bool)";
57+ QTest::newRow("Shutdown") << "RequestShutdown" << "shutdownRequested(bool)";
5458 }
5559
5660 void testUnitySessionLogoutRequested() {
5761 QFETCH(QString, method);
62+ QFETCH(QString, signal);
5863
5964 DBusUnitySessionService dbusUnitySessionService;
6065 QCoreApplication::processEvents(); // to let the service register on DBus
6166
62− QSignalSpy spy(&dbusUnitySessionService, SIGNAL(logoutRequested(bool)));
67+ // .. because QSignalSpy checks the signal signature like this: "if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE)"
68+ QSignalSpy spy(&dbusUnitySessionService, signal.prepend(QSIGNAL_CODE).toLocal8Bit().constData());
6369
6470 QDBusReply<void> reply = dbusUnitySession->call(method);
6571 QCOMPARE(reply.isValid(), true);
@@ -67,51 +73,34 @@ private Q_SLOTS:
6773 QCOMPARE(spy.count(), 1);
6874 }
6975
70− void testGnomeSessionWrapperLogoutRequested() {
71− DBusUnitySessionService dbusUnitySessionService;
72− QCoreApplication::processEvents(); // to let the service register on DBus
73−
74− // Spy on the logoutRequested signal on the /com/canonical/Unity/Session object
75− // as proof we are actually calling the actual method.
76− QSignalSpy spy(&dbusUnitySessionService, SIGNAL(logoutRequested(bool)));
76+ void testGnomeSessionWrapper_data() {
77+ QTest::addColumn<uint>("method");
78+ QTest::addColumn<QString>("signal");
7779
78− DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;
79− QCoreApplication::processEvents(); // to let the service register on DBus
80−
81− QDBusInterface dbusGnomeSessionWrapper ("com.canonical.Unity",
82− "/org/gnome/SessionManager/EndSessionDialog",
83− "org.gnome.SessionManager.EndSessionDialog",
84− QDBusConnection::sessionBus());
85−
86− QCOMPARE(dbusGnomeSessionWrapper.isValid(), true);
87−
88− // Set the QVariant as a QList<QDBusObjectPath> type
89− QDbusList var;
90− QVariant inhibitors;
91− inhibitors.setValue(var);
92−
93− QDBusReply<void> reply = dbusGnomeSessionWrapper.call("Open", (unsigned)Action::LOGOUT, (unsigned)0, (unsigned)0, inhibitors);
94− QCOMPARE(reply.isValid(), true);
95−
96− // Make sure we see the signal being emitted.
97− QCOMPARE(spy.count(), 1);
80+ QTest::newRow("Logout") << (uint)Action::LOGOUT << "logoutRequested(bool)";
81+ QTest::newRow("Shutdown") << (unsigned)Action::SHUTDOWN << "shutdownRequested(bool)";
82+ QTest::newRow("Reboot") << (unsigned)Action::REBOOT << "rebootRequested(bool)";
9883 }
9984
100− void testGnomeSessionWrapperShutdownRequested() {
85+ void testGnomeSessionWrapper() {
86+ QFETCH(uint, method);
87+ QFETCH(QString, signal);
88+
10189 DBusUnitySessionService dbusUnitySessionService;
10290 QCoreApplication::processEvents(); // to let the service register on DBus
10391
104− // Spy on the shutdownRequested signal on the /com/canonical/Unity/Session object
92+ // Spy on the given signal on the /com/canonical/Unity/Session object
10593 // as proof we are actually calling the actual method.
106− QSignalSpy spy(&dbusUnitySessionService, SIGNAL(shutdownRequested(bool)));
94+ // .. because QSignalSpy checks the signal signature like this: "if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE)"
95+ QSignalSpy spy(&dbusUnitySessionService, signal.prepend(QSIGNAL_CODE).toLocal8Bit().constData());
10796
10897 DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;
10998 QCoreApplication::processEvents(); // to let the service register on DBus
11099
111− QDBusInterface dbusGnomeSessionWrapper ("com.canonical.Unity",
112− "/org/gnome/SessionManager/EndSessionDialog",
113− "org.gnome.SessionManager.EndSessionDialog",
114− QDBusConnection::sessionBus());
100+ QDBusInterface dbusGnomeSessionWrapper("com.canonical.Unity",
101+ "/org/gnome/SessionManager/EndSessionDialog",
102+ "org.gnome.SessionManager.EndSessionDialog",
103+ QDBusConnection::sessionBus());
115104
116105 QCOMPARE(dbusGnomeSessionWrapper.isValid(), true);
117106
@@ -120,9 +109,7 @@ private Q_SLOTS:
120109 QVariant inhibitors;
121110 inhibitors.setValue(var);
122111
123− // * Reboot action translates to the shutdown signal due to some weird idiosyncracy
124− // in the indicator-session/Unity interaction. *
125− QDBusReply<void> reply = dbusGnomeSessionWrapper.call("Open", (unsigned)Action::REBOOT, (unsigned)0, (unsigned)0, inhibitors);
112+ QDBusReply<void> reply = dbusGnomeSessionWrapper.call("Open", method, (unsigned)0, (unsigned)0, inhibitors);
126113 QCOMPARE(reply.isValid(), true);
127114
128115 // Make sure we see the signal being emitted.