Unity 8
Greeter.cpp
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  */
18 
19 
20 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21  * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
22  * COUNTERPART IN tests/mocks/Lightdm/liblightdm
23  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
24 
25 
26 #include "Greeter.h"
27 #include "GreeterPrivate.h"
28 #include <QtCore/QCoreApplication>
29 #include <QTimer>
30 
31 namespace QLightDM
32 {
33 
34 Greeter::Greeter(QObject *parent)
35  : QObject(parent),
36  d_ptr(new GreeterPrivate(this))
37 {
38 }
39 
40 Greeter::~Greeter()
41 {
42 }
43 
44 QString Greeter::authenticationUser() const
45 {
46  Q_D(const Greeter);
47  return d->authenticationUser;
48 }
49 
50 bool Greeter::hasGuestAccountHint() const
51 {
52  return false;
53 }
54 
55 QString Greeter::getHint(const QString &name) const
56 {
57  Q_UNUSED(name)
58  return QLatin1String("");
59 }
60 
61 QString Greeter::defaultSessionHint() const
62 {
63  return QStringLiteral("ubuntu");
64 }
65 
66 bool Greeter::hideUsersHint() const
67 {
68  return false;
69 }
70 
71 bool Greeter::showManualLoginHint() const
72 {
73  return false;
74 }
75 
76 bool Greeter::showRemoteLoginHint() const
77 {
78  return false;
79 }
80 
81 QString Greeter::selectUserHint() const
82 {
83  return QLatin1String("");
84 }
85 
86 bool Greeter::selectGuestHint() const
87 {
88  return false;
89 }
90 
91 QString Greeter::autologinUserHint() const
92 {
93  return QLatin1String("");
94 }
95 
96 bool Greeter::autologinGuestHint() const
97 {
98  return false;
99 }
100 
101 int Greeter::autologinTimeoutHint() const
102 {
103  return 0;
104 }
105 
106 bool Greeter::inAuthentication() const
107 {
108  return false;
109 }
110 
111 QString Greeter::hostname() const
112 {
113  return QStringLiteral("hostname1");
114 }
115 
116 bool Greeter::isAuthenticated() const
117 {
118  Q_D(const Greeter);
119  return d->authenticated;
120 }
121 
122 bool Greeter::connectSync()
123 {
124  return true;
125 }
126 
127 void Greeter::authenticate(const QString &username)
128 {
129  Q_D(Greeter);
130 
131  d->authenticated = false;
132  d->authenticationUser = username;
133  d->handleAuthenticate();
134 }
135 
136 void Greeter::authenticateAsGuest()
137 {}
138 
139 void Greeter::authenticateAutologin()
140 {}
141 
142 void Greeter::authenticateRemote(const QString &session, const QString &username)
143 {
144  Q_UNUSED(session)
145  Q_UNUSED(username)
146 }
147 
148 void Greeter::cancelAuthentication()
149 {
150  Q_D(Greeter);
151  d->cancelAuthentication();
152 }
153 
154 void Greeter::setLanguage (const QString &language)
155 {
156  Q_UNUSED(language)
157 }
158 
159 bool Greeter::startSessionSync(const QString &session)
160 {
161  Q_UNUSED(session)
162  return true;
163 }
164 
165 void Greeter::respond(const QString &response)
166 {
167  Q_D(Greeter);
168 
169  d->handleRespond(response);
170 }
171 
172 void Greeter::sendAuthenticationComplete()
173 {
174  if (qEnvironmentVariableIsEmpty("UNITY_TESTING")) {
175  // simulate PAM's delay
176  QTimer::singleShot(1000, this, &Greeter::authenticationComplete);
177  } else {
178  Q_EMIT authenticationComplete();
179  }
180 }
181 
182 }