~dandrader/unity8/miral

« back to all changes in this revision

Viewing changes to plugins/Wizard/System.cpp

  • Committer: CI Train Bot
  • Author(s): Lukáš Tinkl
  • Date: 2015-07-17 15:53:14 UTC
  • mfrom: (1799.2.4 asyncDbusCalls)
  • Revision ID: ci-train-bot@canonical.com-20150717155314-o1i9eesjp8v9vfet
Avoid sync DBUS calls
Approved by: Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include "System.h"
18
18
 
19
 
#include <QDBusInterface>
 
19
#include <QDBusPendingCall>
 
20
#include <QDBusMessage>
 
21
#include <QDBusConnection>
20
22
#include <QDBusMetaType>
21
23
#include <QDir>
22
24
#include <QFile>
65
67
void System::setSessionVariable(const QString &variable, const QString &value)
66
68
{
67
69
    // 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));
74
71
 
75
72
    QMap<QString,QString> valueMap;
76
73
    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);
78
82
}
79
83
 
80
84
void System::updateSessionLanguage(const QString &locale)
81
85
{
82
 
    QString language = locale.split(".")[0];
 
86
    const QString language = locale.split(".")[0];
83
87
 
84
88
    setSessionVariable("LANGUAGE", language);
85
89
    setSessionVariable("LANG", locale);