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 true;
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 true;
74 }
75 
76 bool Greeter::showRemoteLoginHint() const
77 {
78  return true;
79 }
80 
81 bool Greeter::lockHint () const
82 {
83  return false;
84 }
85 
86 QString Greeter::selectUserHint() const
87 {
88  return QLatin1String("");
89 }
90 
91 bool Greeter::selectGuestHint() const
92 {
93  return false;
94 }
95 
96 QString Greeter::autologinUserHint() const
97 {
98  return QLatin1String("");
99 }
100 
101 bool Greeter::autologinGuestHint() const
102 {
103  return false;
104 }
105 
106 int Greeter::autologinTimeoutHint() const
107 {
108  return 0;
109 }
110 
111 bool Greeter::inAuthentication() const
112 {
113  return false;
114 }
115 
116 QString Greeter::hostname() const
117 {
118  return QStringLiteral("hostname1");
119 }
120 
121 bool Greeter::isAuthenticated() const
122 {
123  Q_D(const Greeter);
124  return d->authenticated;
125 }
126 
127 bool Greeter::connectSync()
128 {
129  return true;
130 }
131 
132 void Greeter::authenticate(const QString &username)
133 {
134  Q_D(Greeter);
135 
136  d->authenticated = false;
137  d->authenticationUser = username;
138  d->handleAuthenticate();
139 }
140 
141 void Greeter::authenticateAsGuest()
142 {}
143 
144 void Greeter::authenticateAutologin()
145 {}
146 
147 void Greeter::authenticateRemote(const QString &session, const QString &username)
148 {
149  Q_UNUSED(session)
150  Q_UNUSED(username)
151 }
152 
153 void Greeter::cancelAuthentication()
154 {}
155 
156 void Greeter::setLanguage (const QString &language)
157 {
158  Q_UNUSED(language)
159 }
160 
161 bool Greeter::startSessionSync(const QString &session)
162 {
163  Q_UNUSED(session)
164  return true;
165 }
166 
167 void Greeter::respond(const QString &response)
168 {
169  Q_D(Greeter);
170 
171  d->handleRespond(response);
172 }
173 
174 void Greeter::sendAuthenticationComplete()
175 {
176  if (qgetenv("UNITY_TESTING").isEmpty()) {
177  // simulate PAM's delay
178  QTimer::singleShot(1000, this, &Greeter::authenticationComplete);
179  } else {
180  Q_EMIT authenticationComplete();
181  }
182 }
183 
184 }