on 551c708 help sign in
unity8/tests/mocks/LightDM/demo/GreeterPrivate.cpp
68 lines 2.0 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
19#include "../Greeter.h"
20#include "../GreeterPrivate.h"
21#include <QtCore/QDir>
22#include <QtCore/QSettings>
24namespace QLightDM
27GreeterPrivate::GreeterPrivate(Greeter* parent)
28 : authenticated(false),
29 authenticationUser(),
30 q_ptr(parent)
34void GreeterPrivate::handleAuthenticate()
36 Q_Q(Greeter);
38 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
39 QVariant password = settings.value("password", "none");
41 if (password == "pin") {
42 Q_EMIT q->showPrompt("PIN", Greeter::PromptTypeSecret);
43 } else if (password == "keyboard") {
44 Q_EMIT q->showPrompt("Password", Greeter::PromptTypeSecret);
45 } else {
46 authenticated = true;
47 Q_EMIT q->authenticationComplete();
48 }
51void GreeterPrivate::handleRespond(const QString &response)
53 Q_Q(Greeter);
55 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
56 QVariant password = settings.value("password", "none");
58 QString passwordValue;
59 if (password == "pin") {
60 passwordValue = settings.value("passwordValue", "1234").toString();
61 } else {
62 passwordValue = settings.value("passwordValue", "password").toString();
63 }
64 authenticated = (response == passwordValue);
65 Q_EMIT q->authenticationComplete();