2
* Copyright (C) 2013 Canonical, Ltd.
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
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Michael Terry <michael.terry@canonical.com>
19
#include "../Greeter.h"
20
#include "../GreeterPrivate.h"
25
GreeterPrivate::GreeterPrivate(Greeter* parent)
26
: authenticated(false),
33
void GreeterPrivate::handleAuthenticate()
37
// Send out any messages we need to
38
if (authenticationUser == "info-prompt")
39
Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
40
else if (authenticationUser == "wide-info-prompt")
41
Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo);
42
else if (authenticationUser == "html-info-prompt")
43
Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo);
44
else if (authenticationUser == "long-info-prompt")
45
Q_EMIT q->showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo);
46
else if (authenticationUser == "multi-info-prompt") {
47
Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
48
Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError);
49
Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo);
52
// OK, now actually do the prompt
53
if (authenticationUser == "no-password") {
55
Q_EMIT q->authenticationComplete();
56
} else if (authenticationUser == "auth-error") {
57
authenticated = false;
58
Q_EMIT q->authenticationComplete();
59
} else if (authenticationUser == "different-prompt") {
60
Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret);
62
Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
66
void GreeterPrivate::handleRespond(const QString &response)
70
if (authenticationUser == "no-response")
72
else if (authenticationUser == "two-factor") {
74
if (response == "password") {
76
Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion);
78
authenticated = false;
79
Q_EMIT q->authenticationComplete();
82
authenticated = (response == "otp");
83
Q_EMIT q->authenticationComplete();
88
authenticated = (response == "password");
89
Q_EMIT q->authenticationComplete();