on xenial help sign in
Add desktop files and ability to dymanicaly load lightdm
356dba8Josh Arenson
CMakeLists.txt+1
@@ -108,6 +108,7 @@ set(SHELL_APP unity8)
108set(DASH_APP unity8-dash)
108set(DASH_APP unity8-dash)
109set(SCOPE_TOOL unity-scope-tool)
109set(SCOPE_TOOL unity-scope-tool)
110set(INDICATORS_CLIENT_APP indicators-client)
110set(INDICATORS_CLIENT_APP indicators-client)
111+set(LIGHTDM_GREETER_APP lightdm-unity8-greeter)
111set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
112set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
112
113
113include_directories(
114include_directories(
data/CMakeLists.txt+6
@@ -2,6 +2,7 @@
2configure_file(${SHELL_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop @ONLY)
2configure_file(${SHELL_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop @ONLY)
3configure_file(${DASH_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${DASH_APP}.desktop @ONLY)
3configure_file(${DASH_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${DASH_APP}.desktop @ONLY)
4configure_file(${INDICATORS_CLIENT_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${INDICATORS_CLIENT_APP}.desktop @ONLY)
4configure_file(${INDICATORS_CLIENT_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${INDICATORS_CLIENT_APP}.desktop @ONLY)
5+configure_file(${LIGHTDM_GREETER_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${LIGHTDM_GREETER_APP}.desktop @ONLY)
5
6
6# install desktop files
7# install desktop files
7install(FILES
8install(FILES
@@ -11,5 +12,10 @@ install(FILES
11 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
12 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
12 )
13 )
13
14
15+install(FILES
16+ ${CMAKE_CURRENT_BINARY_DIR}/${LIGHTDM_GREETER_APP}.desktop
17+ DESTINATION ${CMAKE_INSTALL_DATADIR}/xgreeters
18+ )
19+
14install(FILES com.canonical.Unity8.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
20install(FILES com.canonical.Unity8.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
15install(FILES unity8-dash.url-dispatcher DESTINATION ${CMAKE_INSTALL_DATADIR}/url-dispatcher/urls)
21install(FILES unity8-dash.url-dispatcher DESTINATION ${CMAKE_INSTALL_DATADIR}/url-dispatcher/urls)
data/lightdm-unity8-greeter.desktop.innew file+9
@@ -0,0 +1,9 @@
1+[Desktop Entry]
2+Type=Application
3+Name=LightDM Unity 8 Greeter
4+Comment=The converged Unity shell's LightDM Greeter
5+Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8 --mode=greeter
6+Terminal=false
7+Icon=
8+NoDisplay=true
9+X-Ubuntu-Touch=true
debian/unity8.install+1
@@ -5,6 +5,7 @@ usr/bin/unity8
5usr/bin/unity8-dash
5usr/bin/unity8-dash
6usr/share/applications/unity8-dash.desktop
6usr/share/applications/unity8-dash.desktop
7usr/share/applications/unity8.desktop
7usr/share/applications/unity8.desktop
8+usr/share/xgreeters/lightdm-unity8-greeter.desktop
8usr/share/unity8/Greeter
9usr/share/unity8/Greeter
9usr/share/unity8/Launcher
10usr/share/unity8/Launcher
10usr/share/unity8/Panel
11usr/share/unity8/Panel
plugins/FullLightDM/DBusGreeter.cppnew file+49
@@ -0,0 +1,49 @@
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+#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+ return Q_EMIT m_greeter->showGreeter();
38+}
39+
40+void DBusGreeter::HideGreeter()
41+{
42+ return Q_EMIT m_greeter->hideGreeter();
43+}
44+
45+void DBusGreeter::isActiveChangedHandler()
46+{
47+ notifyPropertyChanged("IsActive", isActive());
48+ Q_EMIT isActiveChanged();
49+}
plugins/FullLightDM/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/FullLightDM/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/FullLightDM/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/FullLightDM/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/FullLightDM/Greeter.cppnew file+140
@@ -0,0 +1,140 @@
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 <lightdm.h>
22+#include <libintl.h>
23+#include <QDebug>
24+
25+GreeterPrivate::GreeterPrivate(Greeter* parent)
26+ : m_greeter(new QLightDM::Greeter(parent)),
27+ m_active(false),
28+ wasPrompted(false),
29+ promptless(false),
30+ q_ptr(parent)
31+{
32+}
33+
34+Greeter::Greeter(QObject* parent)
35+ : QObject(parent),
36+ d_ptr(new GreeterPrivate(this))
37+{
38+ Q_D(Greeter);
39+
40+ connect(d->m_greeter, SIGNAL(showMessage(QString, QLightDM::Greeter::MessageType)),
41+ this, SLOT(showMessageFilter(QString, QLightDM::Greeter::MessageType)));
42+ connect(d->m_greeter, SIGNAL(showPrompt(QString, QLightDM::Greeter::PromptType)),
43+ this, SLOT(showPromptFilter(QString, QLightDM::Greeter::PromptType)));
44+ connect(d->m_greeter, SIGNAL(authenticationComplete()),
45+ this, SLOT(authenticationCompleteFilter()));
46+
47+ d->m_greeter->connectSync();
48+}
49+
50+bool Greeter::isActive() const
51+{
52+ Q_D(const Greeter);
53+ return d->m_active;
54+}
55+
56+void Greeter::setIsActive(bool active)
57+{
58+ Q_D(Greeter);
59+ if (d->m_active != active) {
60+ d->m_active = active;
61+ Q_EMIT isActiveChanged();
62+ }
63+}
64+
65+bool Greeter::isAuthenticated() const
66+{
67+ Q_D(const Greeter);
68+ return d->m_greeter->isAuthenticated();
69+}
70+
71+QString Greeter::authenticationUser() const
72+{
73+ Q_D(const Greeter);
74+ return d->m_greeter->authenticationUser();
75+}
76+
77+bool Greeter::promptless() const
78+{
79+ Q_D(const Greeter);
80+ return d->promptless;
81+}
82+
83+void Greeter::authenticate(const QString &username)
84+{
85+ Q_D(Greeter);
86+ d->wasPrompted = false;
87+ if (d->promptless) {
88+ d->promptless = false;
89+ Q_EMIT promptlessChanged();
90+ }
91+
92+ d->m_greeter->authenticate(username);
93+ Q_EMIT isAuthenticatedChanged();
94+ Q_EMIT authenticationUserChanged(username);
95+}
96+
97+void Greeter::respond(const QString &response)
98+{
99+ Q_D(Greeter);
100+ d->m_greeter->respond(response);
101+}
102+
103+bool Greeter::startSessionSync(const QString &session)
104+{
105+ Q_D(Greeter);
106+ return d->m_greeter->startSessionSync(session);
107+}
108+
109+void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type)
110+{
111+ Q_D(Greeter);
112+ d->wasPrompted = true;
113+
114+ bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
115+
116+ // Strip prompt of any colons at the end
117+ QString trimmedText = text.trimmed();
118+ if (trimmedText.endsWith(":") || trimmedText.endsWith(":")) {
119+ trimmedText.chop(1);
120+ }
121+
122+ Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt);
123+}
124+
125+void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
126+{
127+ Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
128+}
129+
130+void Greeter::authenticationCompleteFilter()
131+{
132+ Q_D(Greeter);
133+ if (!d->wasPrompted) {
134+ d->promptless = true;
135+ Q_EMIT promptlessChanged();
136+ }
137+
138+ Q_EMIT isAuthenticatedChanged();
139+ Q_EMIT authenticationComplete();
140+}
plugins/FullLightDM/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/FullLightDM/GreeterPrivate.cppnew file+305
@@ -0,0 +1,305 @@
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 <QFuture>
22+#include <QFutureInterface>
23+#include <QFutureWatcher>
24+#include <QQueue>
25+#include <QtConcurrent>
26+#include <QVector>
27+#include <security/pam_appl.h>
28+
29+namespace QLightDM
30+{
31+
32+class GreeterImpl : public QObject
33+{
34+ Q_OBJECT
35+
36+ struct AppData
37+ {
38+ GreeterImpl *impl;
39+ pam_handle *handle;
40+ };
41+
42+ typedef QFutureInterface<QString> ResponseFuture;
43+
44+public:
45+ explicit GreeterImpl(Greeter *parent, GreeterPrivate *greeterPrivate)
46+ : QObject(parent),
47+ greeter(parent),
48+ greeterPrivate(greeterPrivate),
49+ pamHandle(nullptr)
50+ {
51+ qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture");
52+
53+ connect(&futureWatcher, SIGNAL(finished()),
54+ this, SLOT(finishPam()));
55+ connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)),
56+ this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
57+ // This next connect is how we pass ResponseFutures between threads
58+ connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
59+ this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
60+ Qt::BlockingQueuedConnection);
61+ }
62+
63+ ~GreeterImpl()
64+ {
65+ cancelPam();
66+ }
67+
68+ void start(QString username)
69+ {
70+ // Clear out any existing PAM interactions first
71+ cancelPam();
72+ if (pamHandle != nullptr) {
73+ // While we were cancelling pam above, we processed Qt events.
74+ // Which may have allowed someone to call start() on us again.
75+ // In which case, we'll bail on our current start() call.
76+ // This isn't racy because it's all in the same thread.
77+ return;
78+ }
79+
80+ AppData *appData = new AppData();
81+ appData->impl = this;
82+
83+ // Now actually start a new conversation with PAM
84+ pam_conv conversation;
85+ conversation.conv = converseWithPam;
86+ conversation.appdata_ptr = static_cast<void*>(appData);
87+
88+ if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) {
89+ appData->handle = pamHandle;
90+ futureWatcher.setFuture(QtConcurrent::mapped(QList<pam_handle*>() << pamHandle, authenticateWithPam));
91+ } else {
92+ delete appData;
93+ greeterPrivate->authenticated = false;
94+ Q_EMIT greeter->showMessage("Internal error: could not start PAM authentication", QLightDM::Greeter::MessageTypeError);
95+ Q_EMIT greeter->authenticationComplete();
96+ }
97+ }
98+
99+ static int authenticateWithPam(pam_handle* const& pamHandle)
100+ {
101+ int pamStatus = pam_authenticate(pamHandle, 0);
102+ if (pamStatus == PAM_SUCCESS) {
103+ pamStatus = pam_acct_mgmt(pamHandle, 0);
104+ }
105+ if (pamStatus == PAM_NEW_AUTHTOK_REQD) {
106+ pamStatus = pam_chauthtok(pamHandle, PAM_CHANGE_EXPIRED_AUTHTOK);
107+ }
108+ if (pamStatus == PAM_SUCCESS) {
109+ pam_setcred(pamHandle, PAM_REINITIALIZE_CRED);
110+ }
111+ return pamStatus;
112+ }
113+
114+ static int converseWithPam(int num_msg, const pam_message** msg,
115+ pam_response** resp, void* appdata_ptr)
116+ {
117+ if (num_msg <= 0)
118+ return PAM_CONV_ERR;
119+
120+ auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response)));
121+ if (!tmp_response)
122+ return PAM_CONV_ERR;
123+
124+ AppData *appData = static_cast<AppData*>(appdata_ptr);
125+ GreeterImpl *impl = appData->impl;
126+ pam_handle *handle = appData->handle;
127+
128+ int count;
129+ QVector<ResponseFuture> responses;
130+
131+ for (count = 0; count < num_msg; ++count)
132+ {
133+ switch (msg[count]->msg_style)
134+ {
135+ case PAM_PROMPT_ECHO_ON:
136+ {
137+ QString message(msg[count]->msg);
138+ responses.append(ResponseFuture());
139+ responses.last().reportStarted();
140+ Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeQuestion, responses.last());
141+ break;
142+ }
143+ case PAM_PROMPT_ECHO_OFF:
144+ {
145+ QString message(msg[count]->msg);
146+ responses.append(ResponseFuture());
147+ responses.last().reportStarted();
148+ Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeSecret, responses.last());
149+ break;
150+ }
151+ case PAM_TEXT_INFO:
152+ {
153+ QString message(msg[count]->msg);
154+ Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeInfo);
155+ break;
156+ }
157+ default:
158+ {
159+ QString message(msg[count]->msg);
160+ Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeError);
161+ break;
162+ }
163+ }
164+ }
165+
166+ int i = 0;
167+ bool raise_error = false;
168+
169+ for (auto &response : responses)
170+ {
171+ pam_response* resp_item = &tmp_response[i++];
172+ resp_item->resp_retcode = 0;
173+ resp_item->resp = strdup(response.future().result().toUtf8());
174+
175+ if (!resp_item->resp)
176+ {
177+ raise_error = true;
178+ break;
179+ }
180+ }
181+
182+ delete appData;
183+
184+ if (raise_error)
185+ {
186+ for (int i = 0; i < count; ++i)
187+ free(tmp_response[i].resp);
188+
189+ free(tmp_response);
190+ return PAM_CONV_ERR;
191+ }
192+ else
193+ {
194+ *resp = tmp_response;
195+ return PAM_SUCCESS;
196+ }
197+ }
198+
199+public Q_SLOTS:
200+ bool respond(QString response)
201+ {
202+ if (!futures.isEmpty()) {
203+ futures.dequeue().reportFinished(&response);
204+ return true;
205+ } else {
206+ return false;
207+ }
208+ }
209+
210+Q_SIGNALS:
211+ void showMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type);
212+ void showPrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture response);
213+
214+private Q_SLOTS:
215+ void finishPam()
216+ {
217+ if (pamHandle == nullptr) {
218+ return;
219+ }
220+
221+ int pamStatus = futureWatcher.result();
222+
223+ pam_end(pamHandle, pamStatus);
224+ pamHandle = nullptr;
225+
226+ greeterPrivate->authenticated = (pamStatus == PAM_SUCCESS);
227+ Q_EMIT greeter->authenticationComplete();
228+ }
229+
230+ void handleMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type)
231+ {
232+ if (handle != pamHandle)
233+ return;
234+
235+ Q_EMIT greeter->showMessage(text, type);
236+ }
237+
238+ void handlePrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture future)
239+ {
240+ if (handle != pamHandle) {
241+ future.reportResult(QString());
242+ future.reportFinished();
243+ return;
244+ }
245+
246+ futures.enqueue(future);
247+ Q_EMIT greeter->showPrompt(text, type);
248+ }
249+
250+private:
251+ void cancelPam()
252+ {
253+ if (pamHandle != nullptr) {
254+ QFuture<int> pamFuture = futureWatcher.future();
255+ pam_handle *handle = pamHandle;
256+ pamHandle = nullptr; // to disable normal finishPam() handling
257+ pamFuture.cancel();
258+
259+ // Note the empty loop, we just want to clear the futures queue.
260+ // Any further prompts from the pam thread will be immediately
261+ // responded to/dismissed in handlePrompt().
262+ while (respond(QString()));
263+
264+ // Now let signal/slot handling happen so the thread can finish
265+ while (!pamFuture.isFinished()) {
266+ QCoreApplication::processEvents();
267+ }
268+
269+ pam_end(handle, PAM_CONV_ERR);
270+ }
271+ }
272+
273+ Greeter *greeter;
274+ GreeterPrivate *greeterPrivate;
275+ pam_handle* pamHandle;
276+ QFutureWatcher<int> futureWatcher;
277+ QQueue<ResponseFuture> futures;
278+};
279+
280+GreeterPrivate::GreeterPrivate(Greeter* parent)
281+ : authenticated(false),
282+ authenticationUser(),
283+ m_impl(new GreeterImpl(parent, this)),
284+ q_ptr(parent)
285+{
286+}
287+
288+GreeterPrivate::~GreeterPrivate()
289+{
290+ delete m_impl;
291+}
292+
293+void GreeterPrivate::handleAuthenticate()
294+{
295+ m_impl->start(authenticationUser);
296+}
297+
298+void GreeterPrivate::handleRespond(const QString &response)
299+{
300+ m_impl->respond(response);
301+}
302+
303+}
304+
305+#include "GreeterPrivate.moc"
plugins/FullLightDM/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/FullLightDM/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/FullLightDM/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
qml/Greeter/LightDM.qml+2−1
@@ -30,7 +30,8 @@ Loader {
30 property var userRoles: d.valid ? loader.item.userRoles : null
30 property var userRoles: d.valid ? loader.item.userRoles : null
31
31
32 // TODO: Conditionally load RealLightDMImpl if shellMode dictates it
32 // TODO: Conditionally load RealLightDMImpl if shellMode dictates it
33+ source: shellMode === "greeter" ?
33− source: "./FullLightDMImpl.qml"
34+ "./FullLightDMImpl.qml" : "./IntegratedLightDMImpl.qml"
34
35
35 QtObject {
36 QtObject {
36 id: d
37 id: d