~aacid/unity8/fix_testDash

« back to all changes in this revision

Viewing changes to plugins/AccountsService/AccountsService.cpp

  • Committer: CI Train Bot
  • Author(s): Michael Terry
  • Date: 2014-12-04 20:54:46 UTC
  • mfrom: (1432.3.19 wizard-plugin)
  • Revision ID: ci-train-bot@canonical.com-20141204205446-pbuftf6d5yt854oj
Convert the welcome wizard from a separate executable into a qml plugin (with a small C++ plugin for support).

- This changes the path for adding customized wizard pages (drops system-settings namespacing).  I checked with cwayne, that support isn't being used yet.  So that's safe to adjust while we're here.

- I did not change the path for the 'has the wizard run yet' marker, since that is being used in the wild.  But I added a comment as to why we're using the phrase "ubuntu-system-settings" in that filename.

- I fleshed out unity8's support for changing the language on the fly, since that's now done in-process.  I believe I caught all cases (anything that used a qml binding to i18n worked automatically, just had to catch the cases that were pulling from outside sources like infographics).

- If an incoming call happens during the wizard, we just bail out of it and the edge demo. I'm not sure what the ideal behavior is, but this is at least reasonable. There's nothing in the wizard that *needs* to be done.

- Making the wizard a plugin lets us drop the gap between the end of the wizard and the start of the shell.  Yay! 
Approved by: Andrea Cimitan

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "AccountsService.h"
20
20
#include "AccountsServiceDBusAdaptor.h"
21
21
 
 
22
#include <QFile>
22
23
#include <QStringList>
23
24
 
24
25
AccountsService::AccountsService(QObject* parent)
25
26
  : QObject(parent),
26
27
    m_service(new AccountsServiceDBusAdaptor(this)),
27
 
    m_user(qgetenv("USER")),
 
28
    m_user(""),
28
29
    m_demoEdges(false),
29
30
    m_enableLauncherWhileLocked(false),
30
31
    m_enableIndicatorsWhileLocked(false),
31
32
    m_statsWelcomeScreen(false),
32
33
    m_passwordDisplayHint(Keyboard),
33
 
    m_failedLogins(0)
 
34
    m_failedLogins(0),
 
35
    m_hereEnabled(false),
 
36
    m_hereLicensePath() // null means not set yet
34
37
{
35
38
    connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
36
39
            this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
37
40
    connect(m_service, SIGNAL(maybeChanged(const QString &)),
38
41
            this, SLOT(maybeChanged(const QString &)));
 
42
 
 
43
    setUser(qgetenv("USER"));
39
44
}
40
45
 
41
46
QString AccountsService::user() const
45
50
 
46
51
void AccountsService::setUser(const QString &user)
47
52
{
 
53
    if (user.isEmpty() || m_user == user)
 
54
        return;
 
55
 
48
56
    m_user = user;
49
57
    Q_EMIT userChanged();
50
58
 
55
63
    updateStatsWelcomeScreen();
56
64
    updatePasswordDisplayHint();
57
65
    updateFailedLogins();
 
66
    updateHereEnabled();
 
67
    updateHereLicensePath();
58
68
}
59
69
 
60
70
bool AccountsService::demoEdges() const
93
103
    return m_passwordDisplayHint;
94
104
}
95
105
 
 
106
bool AccountsService::hereEnabled() const
 
107
{
 
108
    return m_hereEnabled;
 
109
}
 
110
 
 
111
void AccountsService::setHereEnabled(bool enabled)
 
112
{
 
113
    m_service->setUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted", enabled);
 
114
}
 
115
 
 
116
QString AccountsService::hereLicensePath() const
 
117
{
 
118
    return m_hereLicensePath;
 
119
}
 
120
 
 
121
bool AccountsService::hereLicensePathValid() const
 
122
{
 
123
    return !m_hereLicensePath.isNull();
 
124
}
 
125
 
96
126
void AccountsService::updateDemoEdges()
97
127
{
98
128
    auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
156
186
    }
157
187
}
158
188
 
 
189
void AccountsService::updateHereEnabled()
 
190
{
 
191
    bool hereEnabled = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted").toBool();
 
192
    if (m_hereEnabled != hereEnabled) {
 
193
        m_hereEnabled = hereEnabled;
 
194
        Q_EMIT hereEnabledChanged();
 
195
    }
 
196
}
 
197
 
 
198
void AccountsService::updateHereLicensePath()
 
199
{
 
200
    QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
 
201
 
 
202
    if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
 
203
        hereLicensePath = "";
 
204
 
 
205
    if (m_hereLicensePath.isNull() || m_hereLicensePath != hereLicensePath) {
 
206
        m_hereLicensePath = hereLicensePath;
 
207
        Q_EMIT hereLicensePathChanged();
 
208
    }
 
209
}
 
210
 
159
211
uint AccountsService::failedLogins() const
160
212
{
161
213
    return m_failedLogins;
195
247
        if (changed.contains("EnableIndicatorsWhileLocked")) {
196
248
            updateEnableIndicatorsWhileLocked();
197
249
        }
 
250
    } else if (interface == "com.ubuntu.location.providers.here.AccountsService") {
 
251
        if (changed.contains("LicenseAccepted")) {
 
252
            updateHereEnabled();
 
253
        }
 
254
        if (changed.contains("LicenseBasePath")) {
 
255
            updateHereLicensePath();
 
256
        }
198
257
    }
199
258
}
200
259