on xenial help sign in
Copy original lightdm files
commitd36e3f88914233fd84909b9fc738aeb3479d1abf authorJosh Arenson <joshua.arenson@canonical.com> dateWed 26 Aug 2015, 19:29 (11 years ago) parentde29e22
14 files changed+972
plugins/LightDM/CMakeLists.txt+35 plugins/LightDM/DBusGreeter.cpp+49 plugins/LightDM/DBusGreeter.h+52 plugins/LightDM/DBusGreeterList.cpp+56 plugins/LightDM/DBusGreeterList.h+57 plugins/LightDM/FullLightDM.qmltypes+251 plugins/LightDM/Greeter.cpp+139 plugins/LightDM/Greeter.h+82 plugins/LightDM/GreeterPrivate.h+39 plugins/LightDM/UsersModel.cpp+70 plugins/LightDM/UsersModel.h+37 plugins/LightDM/plugin.cpp+69 plugins/LightDM/plugin.h+33 plugins/LightDM/qmldir+3
plugins/LightDM/CMakeLists.txtnew file+35
@@ -0,0 +1,35 @@
1+pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
2+pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-3)
3+
4+include_directories(
5+ ${CMAKE_CURRENT_SOURCE_DIR}
6+ ${CMAKE_CURRENT_BINARY_DIR}
7+ ${CMAKE_SOURCE_DIR}/plugins/Utils
8+ ${LIBLIGHTDM_INCLUDE_DIRS}
9+ ${libunity8-private_SOURCE_DIR}
10+ ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
11+)
12+
13+set(QMLPLUGIN_SRC
14+ ../Utils/unitysortfilterproxymodelqml.cpp
15+ DBusGreeter.cpp
16+ DBusGreeterList.cpp
17+ Greeter.cpp
18+ plugin.cpp
19+ UsersModel.cpp
20+ )
21+
22+add_library(FullLightDM-qml MODULE
23+ ${QMLPLUGIN_SRC}
24+ )
25+
26+target_link_libraries(FullLightDM-qml
27+ unity8-private
28+ lightdm-qt5-3
29+ ${LIBLIGHTDM_LDFLAGS}
30+ ${LIBUSERMETRICSOUTPUT_LDFLAGS}
31+ )
32+
33+qt5_use_modules(FullLightDM-qml DBus Gui Qml)
34+
35+add_unity8_plugin(FullLightDM 0.1 FullLightDM TARGETS FullLightDM-qml)
plugins/LightDM/DBusGreeter.cppnew file+49
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (C) 2014, 2015 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+
17+#include "DBusGreeter.h"
18+#include "Greeter.h"
19+
20+#include <QDBusMessage>
21+#include <QStringList>
22+
23+DBusGreeter::DBusGreeter(Greeter *greeter, const QString &path)
24+ : UnityDBusObject(path, "com.canonical.UnityGreeter", true, greeter),
25+ m_greeter(greeter)
26+{
27+ connect(m_greeter, SIGNAL(isActiveChanged()), this, SLOT(isActiveChangedHandler()));
28+}
29+
30+bool DBusGreeter::isActive() const
31+{
32+ return m_greeter->isActive();
33+}
34+
35+void DBusGreeter::ShowGreeter()
36+{
37+ Q_EMIT m_greeter->showGreeter();
38+}
39+
40+void DBusGreeter::HideGreeter()
41+{
42+ Q_EMIT m_greeter->hideGreeter();
43+}
44+
45+void DBusGreeter::isActiveChangedHandler()
46+{
47+ notifyPropertyChanged("IsActive", isActive());
48+ Q_EMIT isActiveChanged();
49+}
plugins/LightDM/DBusGreeter.hnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#ifndef UNITY_DBUSGREETER_H
18+#define UNITY_DBUSGREETER_H
19+
20+#include "unitydbusobject.h"
21+#include <QDBusConnection>
22+
23+class Greeter;
24+
25+/** This is an internal class used to talk with the indicators.
26+ */
27+
28+class DBusGreeter : public UnityDBusObject
29+{
30+ Q_OBJECT
31+ Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter")
32+
33+ Q_PROPERTY(bool IsActive READ isActive NOTIFY isActiveChanged) // since 14.10
34+
35+public:
36+ explicit DBusGreeter(Greeter *greeter, const QString &path);
37+
38+ bool isActive() const;
39+ Q_SCRIPTABLE void ShowGreeter(); // temporary, until we split the greeter again
40+ Q_SCRIPTABLE void HideGreeter(); // temporary, until we split the greeter again
41+
42+Q_SIGNALS:
43+ void isActiveChanged();
44+
45+private Q_SLOTS:
46+ void isActiveChangedHandler();
47+
48+private:
49+ Greeter *m_greeter;
50+};
51+
52+#endif
plugins/LightDM/DBusGreeterList.cppnew file+56
@@ -0,0 +1,56 @@
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+
17+#include "DBusGreeterList.h"
18+#include "Greeter.h"
19+
20+#include <QDBusMessage>
21+#include <QStringList>
22+
23+DBusGreeterList::DBusGreeterList(Greeter *greeter, const QString &path)
24+ : UnityDBusObject(path, "com.canonical.UnityGreeter", true, greeter),
25+ m_greeter(greeter)
26+{
27+ connect(m_greeter, SIGNAL(authenticationUserChanged(const QString &)), this, SLOT(authenticationUserChangedHandler(const QString &)));
28+ connect(m_greeter, SIGNAL(promptlessChanged()), this, SLOT(promptlessChangedHandler()));
29+}
30+
31+QString DBusGreeterList::GetActiveEntry() const
32+{
33+ return m_greeter->authenticationUser();
34+}
35+
36+void DBusGreeterList::SetActiveEntry(const QString &entry)
37+{
38+ Q_EMIT m_greeter->requestAuthenticationUser(entry);
39+}
40+
41+bool DBusGreeterList::entryIsLocked() const
42+{
43+ return !m_greeter->promptless();
44+}
45+
46+void DBusGreeterList::authenticationUserChangedHandler(const QString &user)
47+{
48+ notifyPropertyChanged("ActiveEntry", user);
49+ Q_EMIT EntrySelected(user);
50+}
51+
52+void DBusGreeterList::promptlessChangedHandler()
53+{
54+ notifyPropertyChanged("EntryIsLocked", entryIsLocked());
55+ Q_EMIT entryIsLockedChanged();
56+}
plugins/LightDM/DBusGreeterList.hnew file+57
@@ -0,0 +1,57 @@
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+
17+#ifndef UNITY_DBUSGREETERLIST_H
18+#define UNITY_DBUSGREETERLIST_H
19+
20+#include "unitydbusobject.h"
21+#include <QDBusConnection>
22+
23+class Greeter;
24+
25+/** This is an internal class used to talk with the indicators.
26+ */
27+
28+class DBusGreeterList : public UnityDBusObject
29+{
30+ Q_OBJECT
31+ Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter.List")
32+
33+ Q_PROPERTY(QString ActiveEntry READ GetActiveEntry WRITE SetActiveEntry NOTIFY EntrySelected) // since 14.04
34+ Q_PROPERTY(bool EntryIsLocked READ entryIsLocked NOTIFY entryIsLockedChanged) // since 14.04
35+
36+public:
37+ explicit DBusGreeterList(Greeter *greeter, const QString &path);
38+
39+ Q_SCRIPTABLE void SetActiveEntry(const QString &entry); // since 13.04
40+ Q_SCRIPTABLE QString GetActiveEntry() const; // since 13.10
41+
42+ bool entryIsLocked() const;
43+
44+Q_SIGNALS:
45+ Q_SCRIPTABLE void EntrySelected(const QString &entry); // since 13.10
46+
47+ void entryIsLockedChanged();
48+
49+private Q_SLOTS:
50+ void authenticationUserChangedHandler(const QString &user);
51+ void promptlessChangedHandler();
52+
53+private:
54+ Greeter *m_greeter;
55+};
56+
57+#endif
plugins/LightDM/FullLightDM.qmltypesnew file+251
@@ -0,0 +1,251 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable LightDM 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "Greeter"
12+ prototype: "QObject"
13+ exports: ["LightDM/Greeter 0.1"]
14+ isCreatable: false
15+ isSingleton: true
16+ exportMetaObjectRevisions: [0]
17+ Property { name: "active"; type: "bool" }
18+ Property { name: "authenticated"; type: "bool"; isReadonly: true }
19+ Property { name: "authenticationUser"; type: "string"; isReadonly: true }
20+ Property { name: "promptless"; type: "bool"; isReadonly: true }
21+ Signal {
22+ name: "showMessage"
23+ Parameter { name: "text"; type: "string" }
24+ Parameter { name: "isError"; type: "bool" }
25+ }
26+ Signal {
27+ name: "showPrompt"
28+ Parameter { name: "text"; type: "string" }
29+ Parameter { name: "isSecret"; type: "bool" }
30+ Parameter { name: "isDefaultPrompt"; type: "bool" }
31+ }
32+ Signal { name: "authenticationComplete" }
33+ Signal {
34+ name: "authenticationUserChanged"
35+ Parameter { name: "user"; type: "string" }
36+ }
37+ Signal { name: "isActiveChanged" }
38+ Signal { name: "isAuthenticatedChanged" }
39+ Signal { name: "showGreeter" }
40+ Signal { name: "hideGreeter" }
41+ Signal {
42+ name: "requestAuthenticationUser"
43+ Parameter { name: "user"; type: "string" }
44+ }
45+ Method {
46+ name: "authenticate"
47+ Parameter { name: "username"; type: "string" }
48+ }
49+ Method { name: "authenticate" }
50+ Method {
51+ name: "respond"
52+ Parameter { name: "response"; type: "string" }
53+ }
54+ Method {
55+ name: "startSessionSync"
56+ type: "bool"
57+ Parameter { name: "session"; type: "string" }
58+ }
59+ Method { name: "startSessionSync"; type: "bool" }
60+ Method {
61+ name: "setIsActive"
62+ Parameter { name: "isActive"; type: "bool" }
63+ }
64+ }
65+ Component {
66+ name: "QAbstractProxyModel"
67+ prototype: "QAbstractItemModel"
68+ Property { name: "sourceModel"; type: "QAbstractItemModel"; isPointer: true }
69+ }
70+ Component {
71+ name: "QLightDM::UsersModel"
72+ prototype: "QAbstractListModel"
73+ exports: ["LightDM/UserRoles 0.1"]
74+ isCreatable: false
75+ exportMetaObjectRevisions: [0]
76+ Enum {
77+ name: "UserModelRoles"
78+ values: {
79+ "NameRole": 256,
80+ "RealNameRole": 257,
81+ "LoggedInRole": 258,
82+ "BackgroundRole": 259,
83+ "SessionRole": 260,
84+ "HasMessagesRole": 261,
85+ "ImagePathRole": 262,
86+ "BackgroundPathRole": 263
87+ }
88+ }
89+ }
90+ Component {
91+ name: "QSortFilterProxyModel"
92+ prototype: "QAbstractProxyModel"
93+ Property { name: "filterRegExp"; type: "QRegExp" }
94+ Property { name: "filterKeyColumn"; type: "int" }
95+ Property { name: "dynamicSortFilter"; type: "bool" }
96+ Property { name: "filterCaseSensitivity"; type: "Qt::CaseSensitivity" }
97+ Property { name: "sortCaseSensitivity"; type: "Qt::CaseSensitivity" }
98+ Property { name: "isSortLocaleAware"; type: "bool" }
99+ Property { name: "sortRole"; type: "int" }
100+ Property { name: "filterRole"; type: "int" }
101+ Method {
102+ name: "setFilterRegExp"
103+ Parameter { name: "pattern"; type: "string" }
104+ }
105+ Method {
106+ name: "setFilterWildcard"
107+ Parameter { name: "pattern"; type: "string" }
108+ }
109+ Method {
110+ name: "setFilterFixedString"
111+ Parameter { name: "pattern"; type: "string" }
112+ }
113+ Method { name: "clear" }
114+ Method { name: "invalidate" }
115+ }
116+ Component {
117+ name: "UnitySortFilterProxyModelQML"
118+ prototype: "QSortFilterProxyModel"
119+ Property { name: "model"; type: "QAbstractItemModel"; isPointer: true }
120+ Property { name: "totalCount"; type: "int"; isReadonly: true }
121+ Property { name: "count"; type: "int"; isReadonly: true }
122+ Property { name: "invertMatch"; type: "bool" }
123+ Signal {
124+ name: "invertMatchChanged"
125+ Parameter { type: "bool" }
126+ }
127+ Method {
128+ name: "get"
129+ type: "QVariantMap"
130+ Parameter { name: "row"; type: "int" }
131+ }
132+ Method {
133+ name: "data"
134+ type: "QVariant"
135+ Parameter { name: "row"; type: "int" }
136+ Parameter { name: "role"; type: "int" }
137+ }
138+ Method { name: "count"; type: "int" }
139+ Method {
140+ name: "findFirst"
141+ type: "int"
142+ Parameter { name: "role"; type: "int" }
143+ Parameter { name: "value"; type: "QVariant" }
144+ }
145+ Method {
146+ name: "mapRowToSource"
147+ type: "int"
148+ Parameter { name: "row"; type: "int" }
149+ }
150+ Method {
151+ name: "mapFromSource"
152+ type: "int"
153+ Parameter { name: "row"; type: "int" }
154+ }
155+ Method {
156+ name: "mapToSource"
157+ type: "int"
158+ Parameter { name: "row"; type: "int" }
159+ }
160+ }
161+ Component {
162+ name: "UserMetricsOutput::ColorTheme"
163+ prototype: "QObject"
164+ Property { name: "start"; type: "QColor"; isReadonly: true }
165+ Property { name: "main"; type: "QColor"; isReadonly: true }
166+ Property { name: "end"; type: "QColor"; isReadonly: true }
167+ Signal {
168+ name: "startChanged"
169+ Parameter { name: "color"; type: "QColor" }
170+ }
171+ Signal {
172+ name: "mainChanged"
173+ Parameter { name: "color"; type: "QColor" }
174+ }
175+ Signal {
176+ name: "endChanged"
177+ Parameter { name: "color"; type: "QColor" }
178+ }
179+ }
180+ Component {
181+ name: "UserMetricsOutput::UserMetrics"
182+ prototype: "QObject"
183+ exports: ["LightDM/Infographic 0.1"]
184+ isCreatable: false
185+ isSingleton: true
186+ exportMetaObjectRevisions: [0]
187+ Property { name: "label"; type: "string"; isReadonly: true }
188+ Property { name: "username"; type: "string" }
189+ Property {
190+ name: "firstColor"
191+ type: "UserMetricsOutput::ColorTheme"
192+ isReadonly: true
193+ isPointer: true
194+ }
195+ Property {
196+ name: "secondColor"
197+ type: "UserMetricsOutput::ColorTheme"
198+ isReadonly: true
199+ isPointer: true
200+ }
201+ Property { name: "firstMonth"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true }
202+ Property { name: "secondMonth"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true }
203+ Property { name: "currentDay"; type: "int"; isReadonly: true }
204+ Signal {
205+ name: "labelChanged"
206+ Parameter { name: "label"; type: "string" }
207+ }
208+ Signal {
209+ name: "usernameChanged"
210+ Parameter { name: "username"; type: "string" }
211+ }
212+ Signal {
213+ name: "firstColorChanged"
214+ Parameter { name: "color"; type: "ColorTheme"; isPointer: true }
215+ }
216+ Signal {
217+ name: "firstMonthChanged"
218+ Parameter { name: "firstMonth"; type: "QAbstractItemModel"; isPointer: true }
219+ }
220+ Signal {
221+ name: "currentDayChanged"
222+ Parameter { name: "currentDay"; type: "int" }
223+ }
224+ Signal {
225+ name: "secondColorChanged"
226+ Parameter { name: "color"; type: "ColorTheme"; isPointer: true }
227+ }
228+ Signal {
229+ name: "secondMonthChanged"
230+ Parameter { name: "secondMonth"; type: "QAbstractItemModel"; isPointer: true }
231+ }
232+ Signal { name: "nextDataSource" }
233+ Signal { name: "readyForDataChange" }
234+ Signal { name: "dataAboutToAppear" }
235+ Signal { name: "dataAppeared" }
236+ Signal { name: "dataAboutToChange" }
237+ Signal { name: "dataChanged" }
238+ Signal { name: "dataAboutToDisappear" }
239+ Signal { name: "dataDisappeared" }
240+ Method { name: "nextDataSourceSlot" }
241+ Method { name: "readyForDataChangeSlot" }
242+ }
243+ Component {
244+ name: "UsersModel"
245+ prototype: "UnitySortFilterProxyModelQML"
246+ exports: ["LightDM/Users 0.1"]
247+ isCreatable: false
248+ isSingleton: true
249+ exportMetaObjectRevisions: [0]
250+ }
251+}
plugins/LightDM/Greeter.cppnew file+139
@@ -0,0 +1,139 @@
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+#include "Greeter.h"
20+#include "GreeterPrivate.h"
21+#include <libintl.h>
22+#include <QDebug>
23+
24+GreeterPrivate::GreeterPrivate(Greeter* parent)
25+ : m_greeter(new QLightDM::Greeter(parent)),
26+ m_active(false),
27+ wasPrompted(false),
28+ promptless(false),
29+ q_ptr(parent)
30+{
31+}
32+
33+Greeter::Greeter(QObject* parent)
34+ : QObject(parent),
35+ d_ptr(new GreeterPrivate(this))
36+{
37+ Q_D(Greeter);
38+
39+ connect(d->m_greeter, &QLightDM::Greeter::showMessage,
40+ this, &Greeter::showMessageFilter);
41+ connect(d->m_greeter, &QLightDM::Greeter::showPrompt,
42+ this, &Greeter::showPromptFilter);
43+ connect(d->m_greeter, &QLightDM::Greeter::authenticationComplete,
44+ this, &Greeter::authenticationCompleteFilter);
45+
46+ d->m_greeter->connectSync();
47+}
48+
49+bool Greeter::isActive() const
50+{
51+ Q_D(const Greeter);
52+ return d->m_active;
53+}
54+
55+void Greeter::setIsActive(bool active)
56+{
57+ Q_D(Greeter);
58+ if (d->m_active != active) {
59+ d->m_active = active;
60+ Q_EMIT isActiveChanged();
61+ }
62+}
63+
64+bool Greeter::isAuthenticated() const
65+{
66+ Q_D(const Greeter);
67+ return d->m_greeter->isAuthenticated();
68+}
69+
70+QString Greeter::authenticationUser() const
71+{
72+ Q_D(const Greeter);
73+ return d->m_greeter->authenticationUser();
74+}
75+
76+bool Greeter::promptless() const
77+{
78+ Q_D(const Greeter);
79+ return d->promptless;
80+}
81+
82+void Greeter::authenticate(const QString &username)
83+{
84+ Q_D(Greeter);
85+ d->wasPrompted = false;
86+ if (d->promptless) {
87+ d->promptless = false;
88+ Q_EMIT promptlessChanged();
89+ }
90+
91+ d->m_greeter->authenticate(username);
92+ Q_EMIT isAuthenticatedChanged();
93+ Q_EMIT authenticationUserChanged(username);
94+}
95+
96+void Greeter::respond(const QString &response)
97+{
98+ Q_D(Greeter);
99+ d->m_greeter->respond(response);
100+}
101+
102+bool Greeter::startSessionSync(const QString &session)
103+{
104+ Q_D(Greeter);
105+ return d->m_greeter->startSessionSync(session);
106+}
107+
108+void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
109+{
110+ Q_D(Greeter);
111+ d->wasPrompted = true;
112+
113+ bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
114+
115+ // Strip prompt of any colons at the end
116+ QString trimmedText = text.trimmed();
117+ if (trimmedText.endsWith(":") || trimmedText.endsWith(":")) {
118+ trimmedText.chop(1);
119+ }
120+
121+ Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
122+}
123+
124+void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
125+{
126+ Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
127+}
128+
129+void Greeter::authenticationCompleteFilter()
130+{
131+ Q_D(Greeter);
132+ if (!d->wasPrompted) {
133+ d->promptless = true;
134+ Q_EMIT promptlessChanged();
135+ }
136+
137+ Q_EMIT isAuthenticatedChanged();
138+ Q_EMIT authenticationComplete();
139+}
plugins/LightDM/Greeter.hnew file+82
@@ -0,0 +1,82 @@
1+/*
2+ * Copyright (C) 2012,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+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+/* This class is a really tiny filter around QLightDM::Greeter. There are some
20+ operations that we want to edit a bit for the benefit of Qml. Specifically,
21+ we want to chop colons off of any password prompts. But there may be more
22+ such edits in the future, and by inserting ourselves here, we have more
23+ control. */
24+
25+#ifndef UNITY_GREETER_H
26+#define UNITY_GREETER_H
27+
28+#include <QLightDM/Greeter>
29+#include <QtCore/QObject>
30+
31+class GreeterPrivate;
32+
33+class Greeter : public QObject
34+{
35+ Q_OBJECT
36+
37+ Q_PROPERTY(bool active READ isActive WRITE setIsActive NOTIFY isActiveChanged)
38+ Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
39+ Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
40+ Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41+
42+public:
43+ explicit Greeter(QObject* parent=0);
44+
45+ bool isActive() const;
46+ bool isAuthenticated() const;
47+ QString authenticationUser() const;
48+ bool promptless() const;
49+
50+public Q_SLOTS:
51+ void authenticate(const QString &username=QString());
52+ void respond(const QString &response);
53+ bool startSessionSync(const QString &session=QString());
54+ void setIsActive(bool isActive);
55+
56+Q_SIGNALS:
57+ void showMessage(const QString &text, bool isError);
58+ void showPrompt(const QString &text, bool isSecret, bool isDefaultPrompt);
59+ void authenticationComplete();
60+ void authenticationUserChanged(const QString &user);
61+ void isActiveChanged();
62+ void isAuthenticatedChanged();
63+ void promptlessChanged();
64+ void showGreeter();
65+ void hideGreeter();
66+
67+ // This signal is emitted by external agents like indicators, and the UI
68+ // should switch to this user if possible.
69+ void requestAuthenticationUser(const QString &user);
70+
71+protected:
72+ GreeterPrivate * const d_ptr;
73+
74+ Q_DECLARE_PRIVATE(Greeter)
75+
76+private Q_SLOTS:
77+ void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
78+ void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
79+ void authenticationCompleteFilter();
80+};
81+
82+#endif
plugins/LightDM/GreeterPrivate.hnew file+39
@@ -0,0 +1,39 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#ifndef UNITY_GREETER_PRIVATE_H
18+#define UNITY_GREETER_PRIVATE_H
19+
20+#include <QLightDM/Greeter>
21+
22+class GreeterPrivate
23+{
24+public:
25+ explicit GreeterPrivate(Greeter *parent);
26+
27+ QLightDM::Greeter *m_greeter;
28+ bool m_active;
29+ bool wasPrompted;
30+ bool promptless;
31+
32+protected:
33+ Greeter * const q_ptr;
34+
35+private:
36+ Q_DECLARE_PUBLIC(Greeter)
37+};
38+
39+#endif // UNITY_GREETER_PRIVATE_H
plugins/LightDM/UsersModel.cppnew file+70
@@ -0,0 +1,70 @@
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+#include "UsersModel.h"
20+#include <QLightDM/UsersModel>
21+#include <QtCore/QSortFilterProxyModel>
22+
23+// First, we define an internal class that wraps LightDM's UsersModel. This
24+// class will modify some of the data coming from LightDM. For example, we
25+// modify any empty Real Names into just normal Names.
26+// (We can't modify the data directly in UsersModel below because it won't sort
27+// using the modified data.)
28+class MangleModel : public QSortFilterProxyModel
29+{
30+ Q_OBJECT
31+
32+public:
33+ explicit MangleModel(QObject* parent=0);
34+
35+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
36+};
37+
38+MangleModel::MangleModel(QObject* parent)
39+ : QSortFilterProxyModel(parent)
40+{
41+ setSourceModel(new QLightDM::UsersModel(this));
42+}
43+
44+QVariant MangleModel::data(const QModelIndex &index, int role) const
45+{
46+ QVariant data = QSortFilterProxyModel::data(index, role);
47+
48+ // If user's real name is empty, switch to unix name
49+ if (role == QLightDM::UsersModel::RealNameRole && data.toString().isEmpty()) {
50+ data = QSortFilterProxyModel::data(index, QLightDM::UsersModel::NameRole);
51+ } else if (role == QLightDM::UsersModel::BackgroundPathRole && data.toString().startsWith('#')) {
52+ data = "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='" + data.toString() + "'/></svg>";
53+ }
54+
55+ return data;
56+}
57+
58+// **** Now we continue with actual UsersModel class ****
59+
60+UsersModel::UsersModel(QObject* parent)
61+ : UnitySortFilterProxyModelQML(parent)
62+{
63+ setModel(new MangleModel(this));
64+ setSortCaseSensitivity(Qt::CaseInsensitive);
65+ setSortLocaleAware(true);
66+ setSortRole(QLightDM::UsersModel::RealNameRole);
67+ sort(0);
68+}
69+
70+#include "UsersModel.moc"
plugins/LightDM/UsersModel.hnew file+37
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (C) 2012,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+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+/* This class is a really tiny filter around QLightDM::UsersModel. There are
20+ some operations that we want to edit a bit for the benefit of Qml.
21+ Specifically, we want to sort users according to realName. */
22+
23+#ifndef UNITY_USERSMODEL_H
24+#define UNITY_USERSMODEL_H
25+
26+#include <unitysortfilterproxymodelqml.h>
27+#include <QtCore/QObject>
28+
29+class UsersModel : public UnitySortFilterProxyModelQML
30+{
31+ Q_OBJECT
32+
33+public:
34+ explicit UsersModel(QObject* parent=0);
35+};
36+
37+#endif
plugins/LightDM/plugin.cppnew file+69
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (C) 2012,2013,2015 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+ */
17+
18+#include "plugin.h"
19+#include "DBusGreeter.h"
20+#include "DBusGreeterList.h"
21+#include "Greeter.h"
22+#include "UsersModel.h"
23+#include <libusermetricsoutput/ColorTheme.h>
24+#include <libusermetricsoutput/UserMetrics.h>
25+#include <QLightDM/UsersModel>
26+
27+#include <QAbstractItemModel>
28+#include <QDBusConnection>
29+#include <QtQml/qqml.h>
30+
31+static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
32+{
33+ Q_UNUSED(engine)
34+ Q_UNUSED(scriptEngine)
35+
36+ Greeter *greeter = new Greeter();
37+ new DBusGreeter(greeter, "/");
38+ new DBusGreeterList(greeter, "/list");
39+
40+ return greeter;
41+}
42+
43+static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
44+{
45+ Q_UNUSED(engine)
46+ Q_UNUSED(scriptEngine)
47+ return new UsersModel();
48+}
49+
50+static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
51+{
52+ Q_UNUSED(engine)
53+ Q_UNUSED(scriptEngine)
54+ return UserMetricsOutput::UserMetrics::getInstance();
55+}
56+
57+void FullLightDMPlugin::registerTypes(const char *uri)
58+{
59+ qmlRegisterType<QAbstractItemModel>();
60+ qmlRegisterType<UserMetricsOutput::ColorTheme>();
61+
62+ Q_ASSERT(uri == QLatin1String("FullLightDM"));
63+ qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
64+ qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
65+ qmlRegisterSingletonType<QLightDM::Greeter>(uri, 0, 1, "Greeter", greeter_provider);
66+ qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
67+ qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
68+ qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
69+}
plugins/LightDM/plugin.hnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2012,2013,2015 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+ */
17+
18+#ifndef FULL_LIGHTDM_PLUGIN_H
19+#define FULL_LIGHTDM_PLUGIN_H
20+
21+#include <QtQml/QQmlEngine>
22+#include <QtQml/QQmlExtensionPlugin>
23+
24+class FullLightDMPlugin : public QQmlExtensionPlugin
25+{
26+ Q_OBJECT
27+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28+
29+public:
30+ void registerTypes(const char *uri) override;
31+};
32+
33+#endif /* FULL_LIGHTDM_PLUGIN_H */
plugins/LightDM/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module FullLightDM
2+plugin FullLightDM-qml
3+typeinfo FullLightDM.qmltypes