on xenial help sign in
Cache auth user so we don't send change emission more than once; fixes CI test
ebd7b5bMichael Terry
plugins/LightDM/Greeter.cpp+13−4
@@ -83,7 +83,16 @@ bool Greeter::isAuthenticated() const
83QString Greeter::authenticationUser() const
83QString Greeter::authenticationUser() const
84{
84{
85 Q_D(const Greeter);
85 Q_D(const Greeter);
86+ return d->cachedAuthUser;
87+}
88+
89+void Greeter::checkAuthenticationUser()
90+{
91+ Q_D(Greeter);
92+ if (d->cachedAuthUser != d->m_greeter->authenticationUser()) {
86− return d->m_greeter->authenticationUser();
93+ d->cachedAuthUser = d->m_greeter->authenticationUser();
94+ Q_EMIT authenticationUserChanged();
95+ }
87}
96}
88
97
89QString Greeter::defaultSessionHint() const
98QString Greeter::defaultSessionHint() const
@@ -144,7 +153,7 @@ void Greeter::authenticate(const QString &username)
144 }
153 }
145
154
146 Q_EMIT isAuthenticatedChanged();
155 Q_EMIT isAuthenticatedChanged();
147− Q_EMIT authenticationUserChanged();
156+ checkAuthenticationUser();
148}
157}
149
158
150void Greeter::respond(const QString &response)
159void Greeter::respond(const QString &response)
@@ -164,7 +173,7 @@ void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptTyp
164 Q_D(Greeter);
173 Q_D(Greeter);
165 d->wasPrompted = true;
174 d->wasPrompted = true;
166
175
167− Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
176+ checkAuthenticationUser(); // may have changed in liblightdm
168
177
169 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
178 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
170
179
@@ -185,7 +194,7 @@ void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptTyp
185
194
186void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
195void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
187{
196{
188− Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
197+ checkAuthenticationUser(); // may have changed in liblightdm
189 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
198 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
190}
199}
191
200
plugins/LightDM/Greeter.h+1
@@ -85,4 +85,5 @@ private Q_SLOTS:
85 void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
85 void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
86 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
86 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
87 void authenticationCompleteFilter();
87 void authenticationCompleteFilter();
88+ void checkAuthenticationUser();
88};
89};
plugins/LightDM/GreeterPrivate.h+8−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015-2017 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -14,10 +14,13 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef UNITY_GREETER_PRIVATE_H
17+#pragma once
18−#define UNITY_GREETER_PRIVATE_H
19
18
19+#include <QObject>
20+
20−#include <QLightDM/Greeter>
21+namespace QLightDM {
22+ class Greeter;
23+}
21
24
22class GreeterPrivate
25class GreeterPrivate
23{
26{
@@ -28,6 +31,7 @@ public:
28 bool m_active;
31 bool m_active;
29 bool wasPrompted;
32 bool wasPrompted;
30 bool promptless;
33 bool promptless;
34+ QString cachedAuthUser;
31
35
32protected:
36protected:
33 Greeter * const q_ptr;
37 Greeter * const q_ptr;
@@ -35,5 +39,3 @@ protected:
35private:
39private:
36 Q_DECLARE_PUBLIC(Greeter)
40 Q_DECLARE_PUBLIC(Greeter)
37};
41};
38−
39−#endif // UNITY_GREETER_PRIVATE_H