summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore8
-rw-r--r--Makefile.am2
-rw-r--r--NEWS1
-rw-r--r--configure.ac10
-rw-r--r--libldmgreeter-gobject/libldmgreeter-gobject-0.pc.in6
-rw-r--r--libldmgreeter-qt/Makefile.am37
-rw-r--r--libldmgreeter-qt/consolekitinterface.cpp26
-rw-r--r--libldmgreeter-qt/consolekitinterface.h64
-rw-r--r--libldmgreeter-qt/displayinterface.cpp26
-rw-r--r--libldmgreeter-qt/displayinterface.h107
-rw-r--r--libldmgreeter-qt/ldmauthrequest.cpp77
-rw-r--r--libldmgreeter-qt/ldmauthrequest.h35
-rw-r--r--libldmgreeter-qt/ldmgreeter.cpp258
-rw-r--r--libldmgreeter-qt/ldmgreeter.h78
-rw-r--r--libldmgreeter-qt/ldmlanguage.cpp51
-rw-r--r--libldmgreeter-qt/ldmlanguage.h22
-rw-r--r--libldmgreeter-qt/ldmsession.cpp50
-rw-r--r--libldmgreeter-qt/ldmsession.h25
-rw-r--r--libldmgreeter-qt/ldmuser.cpp100
-rw-r--r--libldmgreeter-qt/ldmuser.h44
-rw-r--r--libldmgreeter-qt/libldmgreeter-qt-0.pc.in13
-rw-r--r--libldmgreeter-qt/powermanagementinterface.cpp26
-rw-r--r--libldmgreeter-qt/powermanagementinterface.h73
-rw-r--r--libldmgreeter-qt/usermanagerinterface.cpp26
-rw-r--r--libldmgreeter-qt/usermanagerinterface.h69
25 files changed, 1226 insertions, 8 deletions
diff --git a/.bzrignore b/.bzrignore
index 5e79b5fa..6b8d5702 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -25,16 +25,16 @@ Makefile.in.in
./omf.make
./xmldocs.make
doc/html
-doc/ldmgreeter.*
+doc/ldmgreeter-gobject.*
doc/*.stamp
doc/tmpl
doc/*.txt
doc/xml
greeters/ldm-gtk-greeter
greeters/ldm-webkit-greeter
-libldmgreeter/*.gir
-libldmgreeter/*.typelib
-libldmgreeter/libldmgreeter-0.pc
+libldmgreeter-gobject/*.gir
+libldmgreeter-gobject/*.typelib
+libldmgreeter-gobject/libldmgreeter-gobject-0.pc
po/POTFILES
po/stamp-it
src/display-glue.h
diff --git a/Makefile.am b/Makefile.am
index 81743407..ac988c7b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libldmgreeter-gobject data greeters po src themes doc
+SUBDIRS = libldmgreeter-gobject libldmgreeter-qt data greeters po src themes doc
DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc
diff --git a/NEWS b/NEWS
index d096d1da..9d29195e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Overview of changes in lightdm 0.2.1
* Use "lightdm" as default PAM service and make it configurable
* Rename libldmgreeter to libldmgreeter-gobject
+ * Add libldmgreeter-qt (David Edmundson)
Overview of changes in lightdm 0.2.0
diff --git a/configure.ac b/configure.ac
index b78e17cd..79bde0c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,7 @@ AC_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE
LT_INIT
AM_PROG_CC_C_O
+AC_PROG_CXX
AC_PROG_LIBTOOL
AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
@@ -39,6 +40,12 @@ PKG_CHECK_MODULES(LIBLDMGREETER_GOBJECT, [
x11
])
+PKG_CHECK_MODULES(LIBLDMGREETER_QT, [
+ QtCore
+ QtGui
+], have_qt=yes, have_qt=no)
+AM_CONDITIONAL(HAVE_QT, test $have_qt = yes)
+
PKG_CHECK_MODULES(LIGHTDM_GTK_GREETER, [
gtk+-2.0
dbus-glib-1
@@ -215,6 +222,8 @@ doc/Makefile
greeters/Makefile
libldmgreeter-gobject/libldmgreeter-gobject-0.pc
libldmgreeter-gobject/Makefile
+libldmgreeter-qt/libldmgreeter-qt-0.pc
+libldmgreeter-qt/Makefile
po/Makefile.in
src/Makefile
themes/Makefile
@@ -244,6 +253,7 @@ echo "
Theme: $GREETER_THEME
Greeters:
+ libldmgreeter-qt: $have_qt
GTK+: $have_gtk
Webkit: $have_webkit
"
diff --git a/libldmgreeter-gobject/libldmgreeter-gobject-0.pc.in b/libldmgreeter-gobject/libldmgreeter-gobject-0.pc.in
index b9573bde..139f675c 100644
--- a/libldmgreeter-gobject/libldmgreeter-gobject-0.pc.in
+++ b/libldmgreeter-gobject/libldmgreeter-gobject-0.pc.in
@@ -5,9 +5,9 @@ includedir=@includedir@
themedir=@THEME_DIR@
-Name: libldmgreeter
+Name: libldmgreeter-gobject
Description: LightDM greeter library
Version: @VERSION@
Requires: glib-2.0 dbus-glib-1 libxklavier
-Libs: -L${libdir} -lldmgreeter
-Cflags: -I${includedir}/lightdm-0
+Libs: -L${libdir} -lldmgreeter-gobject
+Cflags: -I${includedir}/lightdm-gobject-0
diff --git a/libldmgreeter-qt/Makefile.am b/libldmgreeter-qt/Makefile.am
new file mode 100644
index 00000000..44b48fa4
--- /dev/null
+++ b/libldmgreeter-qt/Makefile.am
@@ -0,0 +1,37 @@
+if HAVE_QT
+lib_LTLIBRARIES = libldmgreeter-qt.la
+endif
+
+libldmgreeter_qtinclude_HEADERS = \
+ consolekitinterface.h \
+ displayinterface.h \
+ ldmauthrequest.h \
+ ldmgreeter.h \
+ ldmlanguage.h \
+ ldmsession.h \
+ ldmuser.h \
+ powermanagementinterface.h \
+ usermanagerinterface.h
+libldmgreeter_qtincludedir=$(includedir)/lightdm-qt-0/lightdm
+
+libldmgreeter_qt_la_LIBADD = $(LIBLDMGREETER_QT_LIBS)
+libldmgreeter_qt_la_CXXFLAGS = $(LIBLDMGREETER_QT_CFLAGS) \
+ -DXSESSIONS_DIR=\"$(XSESSIONS_DIR)\"
+
+libldmgreeter_qt_la_SOURCES= \
+ consolekitinterface.cpp \
+ displayinterface.cpp \
+ ldmauthrequest.cpp \
+ ldmgreeter.cpp \
+ ldmlanguage.cpp \
+ ldmsession.cpp \
+ ldmuser.cpp \
+ powermanagementinterface.cpp \
+ usermanagerinterface.cpp
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libldmgreeter-qt-0.pc
+
+DISTCLEANFILES = \
+ Makefile.in \
+ $(pkgconfig_DATA)
diff --git a/libldmgreeter-qt/consolekitinterface.cpp b/libldmgreeter-qt/consolekitinterface.cpp
new file mode 100644
index 00000000..a35d0e7b
--- /dev/null
+++ b/libldmgreeter-qt/consolekitinterface.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp /usr/share/./dbus-1/interfaces/org.freedesktop.PowerManagement.xml -c PowerManagement -p powermanagement
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "consolekitinterface.h"
+
+/*
+ * Implementation of interface class ConsoleKit
+ */
+
+ConsoleKitInterface::ConsoleKitInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+ConsoleKitInterface::~ConsoleKitInterface()
+{
+}
+
diff --git a/libldmgreeter-qt/consolekitinterface.h b/libldmgreeter-qt/consolekitinterface.h
new file mode 100644
index 00000000..0cc91a22
--- /dev/null
+++ b/libldmgreeter-qt/consolekitinterface.h
@@ -0,0 +1,64 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp /usr/share/./dbus-1/interfaces/org.freedesktop.PowerManagement.xml -c PowerManagement -p powermanagement
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef CONSOLEKIT_H_1289511259
+#define CONSOLEKIT_H_1289511259
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.freedesktop.ConsoleKit
+ */
+class ConsoleKitInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.ConsoleKit"; }
+
+public:
+ ConsoleKitInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~ConsoleKitInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<bool> canStop()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("CanStop"), argumentList);
+ }
+
+ inline QDBusPendingReply<bool> canRestart()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("CanRestart"), argumentList);
+ }
+
+ inline QDBusPendingReply<> stop()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("Stop"), argumentList);
+ }
+
+ inline QDBusPendingReply<> restart()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("Restart"), argumentList);
+ }
+
+};
+#endif
diff --git a/libldmgreeter-qt/displayinterface.cpp b/libldmgreeter-qt/displayinterface.cpp
new file mode 100644
index 00000000..9ae3668f
--- /dev/null
+++ b/libldmgreeter-qt/displayinterface.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp display.xml -c DisplayInterface -p displayinterface
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "displayinterface.h"
+
+/*
+ * Implementation of interface class DisplayInterface
+ */
+
+DisplayInterface::DisplayInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+DisplayInterface::~DisplayInterface()
+{
+}
+
diff --git a/libldmgreeter-qt/displayinterface.h b/libldmgreeter-qt/displayinterface.h
new file mode 100644
index 00000000..40dfe237
--- /dev/null
+++ b/libldmgreeter-qt/displayinterface.h
@@ -0,0 +1,107 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp display.xml -c DisplayInterface -p displayinterface
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an edited auto-generated file.
+ */
+
+#ifndef DISPLAYINTERFACE_H_1289588967
+#define DISPLAYINTERFACE_H_1289588967
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+
+#include "ldmauthrequest.h"
+
+/*
+ * Proxy class for interface org.lightdm.LightDisplayManager.Greeter
+ */
+class DisplayInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.lightdm.LightDisplayManager.Greeter"; }
+
+public:
+ DisplayInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~DisplayInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QString, QString, QString, QString, QString, int> connect()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("Connect"), argumentList);
+ }
+
+ inline QDBusReply<QString> connect(QString &language, QString &layout, QString &session, QString &username, int &delay)
+ {
+ QList<QVariant> argumentList;
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("Connect"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 6) {
+ language = reply.arguments().at(1).toString();
+ language = qdbus_cast<QString>(reply.arguments().at(1));
+ layout = qdbus_cast<QString>(reply.arguments().at(2));
+ session = qdbus_cast<QString>(reply.arguments().at(3));
+ username = qdbus_cast<QString>(reply.arguments().at(4));
+ delay = qdbus_cast<int>(reply.arguments().at(5));
+ }
+ return reply;
+ }
+
+ inline QDBusPendingReply<int, QList<LdmAuthRequest> > continueAuthentication(const QStringList &secrets)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(secrets);
+ return asyncCallWithArgumentList(QLatin1String("ContinueAuthentication"), argumentList);
+ }
+ inline QDBusReply<int> continueAuthentication(const QStringList &secrets, QList<LdmAuthRequest> &requests)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(secrets);
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("ContinueAuthentication"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
+ requests = qdbus_cast<QList<LdmAuthRequest> >(reply.arguments().at(1));
+ }
+ return reply;
+ }
+
+ inline QDBusPendingReply<> login(const QString &username, const QString &session, const QString &language)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(username) << qVariantFromValue(session) << qVariantFromValue(language);
+ return asyncCallWithArgumentList(QLatin1String("Login"), argumentList);
+ }
+
+ inline QDBusPendingReply<int, QList<LdmAuthRequest> > startAuthentication(const QString &username)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(username);
+ return asyncCallWithArgumentList(QLatin1String("StartAuthentication"), argumentList);
+ }
+ inline QDBusReply<int> startAuthentication(const QString &username, QList<LdmAuthRequest> &requests)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(username);
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("StartAuthentication"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
+ requests = qdbus_cast<QList<LdmAuthRequest> >(reply.arguments().at(1));
+ }
+ return reply;
+ }
+
+Q_SIGNALS: // SIGNALS
+ void quitGreeter();
+};
+
+#endif
diff --git a/libldmgreeter-qt/ldmauthrequest.cpp b/libldmgreeter-qt/ldmauthrequest.cpp
new file mode 100644
index 00000000..07dec8a1
--- /dev/null
+++ b/libldmgreeter-qt/ldmauthrequest.cpp
@@ -0,0 +1,77 @@
+#include "ldmauthrequest.h"
+#include <QtDBus/QDBusArgument>
+#include <QList>
+#include <QDebug>
+
+
+
+class LdmAuthRequestPrivate
+{
+public:
+ //rename when I find out what the hell these contain
+ int messageType;
+ QString message;
+};
+
+LdmAuthRequest::LdmAuthRequest()
+ :d(new LdmAuthRequestPrivate)
+{
+}
+
+
+LdmAuthRequest::LdmAuthRequest(const int messageType, const QString& message)
+ :d(new LdmAuthRequestPrivate)
+{
+ d->messageType = messageType;
+ d->message = message;
+}
+
+LdmAuthRequest::LdmAuthRequest(const LdmAuthRequest &other)
+ :d(new LdmAuthRequestPrivate(*other.d))
+{
+
+}
+
+LdmAuthRequest::~LdmAuthRequest()
+{
+ delete d;
+}
+
+LdmAuthRequest& LdmAuthRequest::operator =(const LdmAuthRequest &other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+
+int LdmAuthRequest::messageType() const
+{
+ return d->messageType;
+}
+
+QString LdmAuthRequest::message() const
+{
+ return d->message;
+}
+
+
+QDBusArgument &operator<<(QDBusArgument &argument, const LdmAuthRequest &request)
+{
+ argument.beginStructure();
+ argument << request.messageType() << request.message();
+ argument.endStructure();
+
+ return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, LdmAuthRequest &request)
+{
+ int messageType;
+ QString message;
+ argument.beginStructure();
+ argument >> messageType >> message;
+ argument.endStructure();
+
+ request = LdmAuthRequest(messageType, message);
+ return argument;
+}
diff --git a/libldmgreeter-qt/ldmauthrequest.h b/libldmgreeter-qt/ldmauthrequest.h
new file mode 100644
index 00000000..ca1e840a
--- /dev/null
+++ b/libldmgreeter-qt/ldmauthrequest.h
@@ -0,0 +1,35 @@
+#ifndef LDMAUTHREQUEST_H
+#define LDMAUTHREQUEST_H
+
+#include <QString>
+#include <QtDBus/QtDBus>
+
+class LdmAuthRequestPrivate;
+
+//FIXME this is never public facing, remove Ldm prefix - make sure it's not exported.
+class LdmAuthRequest
+{
+public:
+ explicit LdmAuthRequest();
+ LdmAuthRequest(const int messageType, const QString& message);
+ LdmAuthRequest(const LdmAuthRequest& other);
+ ~LdmAuthRequest();
+
+ LdmAuthRequest &operator=(const LdmAuthRequest& other);
+
+ int messageType() const;
+ QString message() const;
+
+
+// LdmAuthRequest &operator=(const LdmAuthRequest user);
+private:
+ LdmAuthRequestPrivate* d;
+};
+
+QDBusArgument &operator<<(QDBusArgument &argument, const LdmAuthRequest &request);
+const QDBusArgument &operator>>(const QDBusArgument &argument, LdmAuthRequest &request);
+
+Q_DECLARE_METATYPE(LdmAuthRequest);
+Q_DECLARE_METATYPE(QList<LdmAuthRequest>);
+
+#endif // LDMAUTHREQUEST_H
diff --git a/libldmgreeter-qt/ldmgreeter.cpp b/libldmgreeter-qt/ldmgreeter.cpp
new file mode 100644
index 00000000..a52ee4e4
--- /dev/null
+++ b/libldmgreeter-qt/ldmgreeter.cpp
@@ -0,0 +1,258 @@
+#include "ldmgreeter.h"
+
+#include "powermanagementinterface.h"
+#include "displayinterface.h"
+#include "usermanagerinterface.h"
+#include "consolekitinterface.h"
+#include "ldmuser.h"
+#include "ldmsession.h"
+
+#include <QtNetwork/QHostInfo> //needed for localHostName
+#include <QDebug>
+#include <QtDBus/QDBusReply>
+#include <QtDBus/QDBusPendingReply>
+#include <QtGui/QApplication>
+#include <QtGui/QDesktopWidget>
+
+class LdmGreeterPrivate
+{
+public:
+ QString language;
+ QString layout;
+ QString session;
+ QString username;
+ QString themeName; //TODO turn into a KConfig
+ int delay;
+
+ QString currentlyAuthenticatingUser;
+
+ PowerManagementInterface* powerManagement;
+ DisplayInterface* display;
+ UserManagerInterface* userManager;
+ ConsoleKitInterface* consoleKit;
+};
+
+
+
+LdmGreeter::LdmGreeter() :
+ QWidget(0),
+ d(new LdmGreeterPrivate)
+{
+ QRect screen = QApplication::desktop()->rect();
+ this->setGeometry(screen);
+
+ qDBusRegisterMetaType<LdmUser>();
+ qDBusRegisterMetaType<QList<LdmUser> >();
+
+ qDBusRegisterMetaType<LdmAuthRequest>();
+ qDBusRegisterMetaType<QList<LdmAuthRequest> >();
+
+ d->powerManagement = new PowerManagementInterface("org.freedesktop.PowerManagement","/org/freedesktop/PowerManagement", QDBusConnection::sessionBus(), this);
+ d->display = new DisplayInterface("org.lightdm.LightDisplayManager", "/org/lightdm/LightDisplayManager/Display0", QDBusConnection::sessionBus(), this);
+ d->userManager = new UserManagerInterface("org.lightdm.LightDisplayManager", "/org/lightdm/LightDisplayManager/Users", QDBusConnection::sessionBus(), this);
+ d->consoleKit = new ConsoleKitInterface("org.freedesktop.ConsoleKit","/org/freedesktop/ConsoleKit/Manager", QDBusConnection::systemBus(), this );
+
+ //FIXME use the pendingReply, it's a much nicer API.
+ QDBusReply<QString> connectResult = d->display->connect(d->language, d->layout, d->session, d->username, d->delay);
+ connect(d->display, SIGNAL(quitGreeter()), SIGNAL(quit()));
+
+
+ if(!connectResult.isValid())
+ {
+ qDebug() << connectResult.error().name();
+ }
+ else
+ {
+ d->themeName = connectResult;
+ //TODO create a kconfig from this path name - or not. Keep this lib Qt only?
+ }
+}
+
+LdmGreeter::~LdmGreeter()
+{
+ delete d;
+}
+
+
+
+QString LdmGreeter::hostname()
+{
+ return QHostInfo::localHostName();
+}
+
+QString LdmGreeter::defaultLanguage()
+{
+ return d->language;
+}
+
+QString LdmGreeter::defaultLayout()
+{
+ return d->layout;
+}
+
+QString LdmGreeter::defaultSession()
+{
+ return d->session;
+}
+
+QString LdmGreeter::defaultUsername()
+{
+ return d->username;
+}
+
+
+QList<LdmUser> LdmGreeter::users()
+{
+ QDBusPendingReply<QList<LdmUser> > users = d->userManager->GetUsers();
+ users.waitForFinished();
+ if (users.isValid())
+ {
+ return users.value();
+ }
+ else
+ {
+ qDebug() << users.error().name();
+ qDebug() << users.error().message();
+ return QList<LdmUser>();
+ }
+}
+
+QList<LdmSession> LdmGreeter::sessions()
+{
+ QList<LdmSession> sessions;
+ //FIXME don't hardcode this!
+ //FIXME I'm not happy with this bodgy finding .desktop files, and strcat situtation.
+ QDir sessionDir("/usr/share/xsessions");
+ sessionDir.setNameFilters(QStringList() << "*.desktop");
+ foreach(QString sessionFileName, sessionDir.entryList())
+ {
+ QSettings sessionData(QString("/usr/share/xsessions/").append(sessionFileName), QSettings::IniFormat);
+ sessionData.beginGroup("Desktop Entry");
+ sessionFileName.chop(8);// chop(8) removes '.desktop'
+ QString name = sessionData.value("Name").toString();
+ QString comment = sessionData.value("Comment").toString();
+ LdmSession session(sessionFileName, name, comment);
+
+ sessions.append(session);
+ }
+ return sessions;
+}
+
+
+void LdmGreeter::startAuthentication(QString username)
+{
+ d->currentlyAuthenticatingUser = username;
+ QDBusPendingReply<int, QList<LdmAuthRequest> > reply = d->display->startAuthentication(username);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onAuthFinished(QDBusPendingCallWatcher*)));
+}
+
+void LdmGreeter::provideSecret(QString secret)
+{
+ QDBusPendingReply<int, QList<LdmAuthRequest> > reply = d->display->continueAuthentication(QStringList() << secret);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onAuthFinished(QDBusPendingCallWatcher*)));
+}
+
+void LdmGreeter::login(QString username, QString session, QString language)
+{
+ d->display->login(username, session, language);
+}
+
+
+bool LdmGreeter::canSuspend()
+{
+ QDBusPendingReply<bool> reply = d->powerManagement->canSuspend();
+ reply.waitForFinished();
+ return reply.value();
+}
+
+void LdmGreeter::suspend()
+{
+ d->powerManagement->suspend();
+}
+
+bool LdmGreeter::canHibernate()
+{
+ QDBusPendingReply<bool> reply = d->powerManagement->canHibernate();
+ reply.waitForFinished();
+ return reply.value();
+}
+
+void LdmGreeter::hibernate()
+{
+ d->powerManagement->hibernate();
+}
+
+bool LdmGreeter::canShutdown()
+{
+ QDBusPendingReply<bool> reply = d->consoleKit->canStop();
+ reply.waitForFinished();
+ return reply.value();
+}
+
+
+void LdmGreeter::shutdown()
+{
+ d->consoleKit->stop();
+}
+
+bool LdmGreeter::canRestart()
+{
+ QDBusPendingReply<bool> reply = d->consoleKit->canRestart();
+ reply.waitForFinished();
+ return reply.value();
+}
+
+void LdmGreeter::restart()
+{
+ d->consoleKit->restart();
+}
+
+
+void LdmGreeter::onAuthFinished(QDBusPendingCallWatcher *call)
+{
+ QDBusPendingReply<int, QList<LdmAuthRequest> > reply = *call;
+ if(reply.isValid())
+ {
+ QList<LdmAuthRequest> requests = reply.argumentAt<1>();
+
+ if (requests.size() == 0) //if there are no requests
+ {
+ int returnValue = reply.argumentAt<0>();
+ if (returnValue == 0) //Magic number..FIXME
+ {
+ emit authenticationComplete(true);
+ }
+ else
+ {
+ emit authenticationComplete(false);
+ }
+ }
+ else
+ {
+ foreach(LdmAuthRequest request, requests)
+ {
+ switch(request.messageType())
+ {
+ //FIXME create an enum use that (or include PAM libs)
+ case 0:
+ case 1:
+ emit showPrompt(request.message());
+ break;
+ case 2:
+ emit showMessage(request.message());
+ break;
+ case 3:
+ emit showError(request.message());
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ qDebug() << reply.error().name();
+ qDebug() << reply.error().message();
+ }
+}
diff --git a/libldmgreeter-qt/ldmgreeter.h b/libldmgreeter-qt/ldmgreeter.h
new file mode 100644
index 00000000..6929ec89
--- /dev/null
+++ b/libldmgreeter-qt/ldmgreeter.h
@@ -0,0 +1,78 @@
+#ifndef LDMGREETER_H
+#define LDMGREETER_H
+
+#include <QWidget>
+
+class PowerManagementInterface;
+class DisplayInterface;
+class UserManagerInterface;
+
+class LdmGreeterPrivate;
+class LdmUser;
+class LdmSession;
+class LdmAuthRequest;
+class QDBusPendingCallWatcher;
+
+//TODO
+// all accessors need to be marked const.
+// need to pass by reference where applicable.
+// fix FIXME about authentication.
+// decide async start - provide ready() signal(like Tp-Qt4)?
+// quit is a rubbish name for a signal, it sounds too much like a slot.
+// maybe modify defaultLayout to return the layout?(same for sesion) - or the modelIndex?
+// document all the public methods.
+
+class Q_DECL_EXPORT LdmGreeter : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit LdmGreeter();
+ ~LdmGreeter();
+
+ /** The hostname of the machine*/
+ QString hostname();
+ QString defaultLanguage();
+ QString defaultLayout();
+ QString defaultSession();
+ QString defaultUsername();
+
+ QList<LdmUser> users();
+
+ QList<LdmSession> sessions();
+
+ //FIXME this is inconsistent - need to decide whether lib remembers username, or client needs to keep passing it.
+ void startAuthentication(QString username);
+ void provideSecret(QString secret);
+ void login(QString username, QString session, QString language);
+
+ //FIXME should probably mess about with Q_PROPERTY
+ bool canSuspend();
+ void suspend();
+ bool canHibernate();
+ void hibernate();
+ bool canShutdown();
+ void shutdown();
+ bool canRestart();
+ void restart();
+
+ //FIXME replace these signals with pure virtual
+ //virtual blah() = 0;
+
+signals:
+ void showPrompt(QString prompt);
+ void showMessage(QString message);
+ void showError(QString message);
+ void authenticationComplete(bool success);
+ void timedLogin(QString username);
+ void quit();
+
+public slots:
+
+private slots:
+ void onAuthFinished(QDBusPendingCallWatcher*);
+
+private:
+ LdmGreeterPrivate* d;
+};
+
+#endif // GREETER_H
diff --git a/libldmgreeter-qt/ldmlanguage.cpp b/libldmgreeter-qt/ldmlanguage.cpp
new file mode 100644
index 00000000..8d294a84
--- /dev/null
+++ b/libldmgreeter-qt/ldmlanguage.cpp
@@ -0,0 +1,51 @@
+#include "ldmlanguage.h"
+
+class LdmLanguagePrivate
+{
+public:
+ QString code;
+ QString name;
+ QString territory;
+};
+
+LdmLanguage::LdmLanguage(QString &code, QString &name, QString &territory)
+ : d(new LdmLanguagePrivate)
+{
+ d->code = code;
+ d->name = name;
+ d->territory = territory;
+}
+
+LdmLanguage::LdmLanguage(const LdmLanguage &other)
+ :d(new LdmLanguagePrivate(*other.d))
+{
+}
+
+LdmLanguage::~LdmLanguage()
+{
+ delete d;
+}
+
+LdmLanguage& LdmLanguage::operator=(const LdmLanguage& other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+
+QString LdmLanguage::code() const
+{
+ return d->code;
+}
+
+QString LdmLanguage::name() const
+{
+ return d->name;
+}
+
+QString LdmLanguage::territory() const
+{
+ return d->territory;
+}
+
+
diff --git a/libldmgreeter-qt/ldmlanguage.h b/libldmgreeter-qt/ldmlanguage.h
new file mode 100644
index 00000000..04f1f2c4
--- /dev/null
+++ b/libldmgreeter-qt/ldmlanguage.h
@@ -0,0 +1,22 @@
+#ifndef LDMLANGUAGE_H
+#define LDMLANGUAGE_H
+#include <QString>
+
+class LdmLanguagePrivate;
+
+class LdmLanguage
+{
+public:
+ LdmLanguage(QString &code, QString &name, QString &territory);
+ ~LdmLanguage();
+ LdmLanguage(const LdmLanguage& other);
+ LdmLanguage &operator=(const LdmLanguage& other);
+
+ QString code() const;
+ QString name() const;
+ QString territory() const;
+private:
+ LdmLanguagePrivate* d;
+};
+
+#endif // LDMLANGUAGE_H
diff --git a/libldmgreeter-qt/ldmsession.cpp b/libldmgreeter-qt/ldmsession.cpp
new file mode 100644
index 00000000..ca7d2d3f
--- /dev/null
+++ b/libldmgreeter-qt/ldmsession.cpp
@@ -0,0 +1,50 @@
+#include "ldmsession.h"
+
+#include <QDebug>
+
+class LdmSessionPrivate
+{
+public:
+ QString key;
+ QString name;
+ QString comment;
+};
+
+LdmSession::LdmSession(const QString &key, const QString &name, const QString &comment)
+ : d(new LdmSessionPrivate)
+{
+ d->key = key;
+ d->name = name;
+ d->comment = comment;
+}
+
+LdmSession::LdmSession(const LdmSession &other)
+ :d(new LdmSessionPrivate(*other.d))
+{
+}
+
+LdmSession& LdmSession::operator=(const LdmSession& other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+LdmSession::~LdmSession()
+{
+ delete d;
+}
+
+QString LdmSession::key() const
+{
+ return d->key;
+}
+
+QString LdmSession::name() const
+{
+ return d->name;
+}
+
+QString LdmSession::comment() const
+{
+ return d->comment;
+}
diff --git a/libldmgreeter-qt/ldmsession.h b/libldmgreeter-qt/ldmsession.h
new file mode 100644
index 00000000..25900d6b
--- /dev/null
+++ b/libldmgreeter-qt/ldmsession.h
@@ -0,0 +1,25 @@
+#ifndef LDMSESSION_H
+#define LDMSESSION_H
+
+#include <QString>
+
+class LdmSessionPrivate;
+
+class Q_DECL_EXPORT LdmSession
+{
+public:
+ LdmSession(const QString& key, const QString &name, const QString &comment);
+ LdmSession(const LdmSession& other);
+ ~LdmSession();
+ LdmSession &operator=(const LdmSession& other);
+
+ QString key() const;
+ QString name() const;
+ QString comment() const;
+
+private:
+ LdmSessionPrivate *d;
+
+};
+
+#endif // LDMSESSION_H
diff --git a/libldmgreeter-qt/ldmuser.cpp b/libldmgreeter-qt/ldmuser.cpp
new file mode 100644
index 00000000..04bbdbad
--- /dev/null
+++ b/libldmgreeter-qt/ldmuser.cpp
@@ -0,0 +1,100 @@
+#include "ldmuser.h"
+
+class LdmUserPrivate
+{
+public:
+ QString name;
+ QString realName;
+ QString image;
+ bool isLoggedIn;
+};
+
+LdmUser::LdmUser():
+ d(new LdmUserPrivate)
+{
+}
+
+LdmUser::LdmUser(const QString& name, const QString& realName, const QString& image, const bool loggedIn) :
+ d(new LdmUserPrivate)
+{
+ d->name = name;
+ d->realName = realName;
+ d->image = image;
+ d->isLoggedIn = loggedIn;
+}
+
+LdmUser::LdmUser(const LdmUser &other)
+ :d(new LdmUserPrivate(*other.d))
+{
+}
+
+LdmUser::~LdmUser()
+{
+ delete d;
+}
+
+
+LdmUser& LdmUser::operator=(const LdmUser& other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+QString LdmUser::displayName() const
+{
+ if (!d->realName.isEmpty())
+ {
+ return d->realName;
+ }
+ else
+ {
+ return d->name;
+ }
+}
+
+QString LdmUser::name() const
+{
+ return d->name;
+}
+
+QString LdmUser::realName() const
+{
+ return d->realName;
+}
+
+QString LdmUser::image() const
+{
+ return d->image;
+}
+
+bool LdmUser::isLoggedIn() const
+{
+ return d->isLoggedIn;
+}
+
+
+//don't actually need this I never send an LdmUser across DBUS...
+QDBusArgument &operator<<(QDBusArgument &argument, const LdmUser &user)
+{
+ argument.beginStructure();
+ argument << user.name() << user.realName() << user.image() << user.isLoggedIn();
+ argument.endStructure();
+ return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, LdmUser &user)
+{
+ QString name;
+ QString realName;
+ QString image;
+ bool loggedIn;
+
+ argument.beginStructure();
+ argument >> name >> realName >> image >> loggedIn;
+ argument.endStructure();
+
+ user = LdmUser(name, realName, image, loggedIn);
+
+ return argument;
+}
+
diff --git a/libldmgreeter-qt/ldmuser.h b/libldmgreeter-qt/ldmuser.h
new file mode 100644
index 00000000..1cae5a2b
--- /dev/null
+++ b/libldmgreeter-qt/ldmuser.h
@@ -0,0 +1,44 @@
+#ifndef LDMUSER_H
+#define LDMUSER_H
+
+#include <QString>
+#include <QtDBus/QtDBus>
+
+class LdmUserPrivate;
+
+//public facing User class
+class Q_DECL_EXPORT LdmUser
+{
+public:
+ explicit LdmUser();
+ LdmUser(const QString& name, const QString& realName, const QString& image, const bool loggedIn);
+ LdmUser(const LdmUser& other);
+ ~LdmUser();
+ LdmUser &operator=(const LdmUser& other);
+
+ /** The name to display (the real name if available, otherwise use the username */
+ QString displayName() const;
+
+ /** The username of the user*/
+ QString name() const;
+ /** The user's real name, use this for displaying*/
+ QString realName() const;
+
+ /** Returns the path to an avatar of this user*/
+ QString image() const;
+
+ /** Returns true if this user is already logged in on another session*/
+ bool isLoggedIn() const;
+
+// LdmUser &operator=(const LdmUser user);
+private:
+ LdmUserPrivate* d;
+};
+
+QDBusArgument &operator<<(QDBusArgument &argument, const LdmUser &request);
+const QDBusArgument &operator>>(const QDBusArgument &argument, LdmUser &request);
+
+Q_DECLARE_METATYPE(LdmUser);
+Q_DECLARE_METATYPE(QList<LdmUser>);
+
+#endif // LDMUSER_H
diff --git a/libldmgreeter-qt/libldmgreeter-qt-0.pc.in b/libldmgreeter-qt/libldmgreeter-qt-0.pc.in
new file mode 100644
index 00000000..11c7c050
--- /dev/null
+++ b/libldmgreeter-qt/libldmgreeter-qt-0.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+themedir=@THEME_DIR@
+
+Name: libldmgreeter-qt
+Description: LightDM greeter library
+Version: @VERSION@
+Requires: QtCore QtGui
+Libs: -L${libdir} -lldmgreeter-qt
+Cflags: -I${includedir}/lightdm-qt-0
diff --git a/libldmgreeter-qt/powermanagementinterface.cpp b/libldmgreeter-qt/powermanagementinterface.cpp
new file mode 100644
index 00000000..51885b60
--- /dev/null
+++ b/libldmgreeter-qt/powermanagementinterface.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp /usr/share/./dbus-1/interfaces/org.freedesktop.PowerManagement.xml -c PowerManagement -p powermanagement
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "powermanagementinterface.h"
+
+/*
+ * Implementation of interface class PowerManagement
+ */
+
+PowerManagementInterface::PowerManagementInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+PowerManagementInterface::~PowerManagementInterface()
+{
+}
+
diff --git a/libldmgreeter-qt/powermanagementinterface.h b/libldmgreeter-qt/powermanagementinterface.h
new file mode 100644
index 00000000..f7db84d8
--- /dev/null
+++ b/libldmgreeter-qt/powermanagementinterface.h
@@ -0,0 +1,73 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp /usr/share/./dbus-1/interfaces/org.freedesktop.PowerManagement.xml -c PowerManagement -p powermanagement
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef POWERMANAGEMENT_H_1289511259
+#define POWERMANAGEMENT_H_1289511259
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.freedesktop.PowerManagement
+ */
+class PowerManagementInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.PowerManagement"; }
+
+public:
+ PowerManagementInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~PowerManagementInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<bool> canHibernate()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("CanHibernate"), argumentList);
+ }
+
+ inline QDBusPendingReply<bool> canSuspend()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("CanSuspend"), argumentList);
+ }
+
+ inline QDBusPendingReply<> hibernate()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("Hibernate"), argumentList);
+ }
+
+ inline QDBusPendingReply<> suspend()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("Suspend"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void canHibernateChanged(bool can_hibernate);
+ void canSuspendChanged(bool can_suspend);
+};
+
+namespace org {
+ namespace freedesktop {
+ typedef ::PowerManagementInterface PowerManagement;
+ }
+}
+#endif
diff --git a/libldmgreeter-qt/usermanagerinterface.cpp b/libldmgreeter-qt/usermanagerinterface.cpp
new file mode 100644
index 00000000..5d721998
--- /dev/null
+++ b/libldmgreeter-qt/usermanagerinterface.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp user-manager.xml -c UserManagerInterface -p usermanagernterface
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "usermanagerinterface.h"
+
+/*
+ * Implementation of interface class UserManagerInterface
+ */
+
+UserManagerInterface::UserManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+UserManagerInterface::~UserManagerInterface()
+{
+}
+
diff --git a/libldmgreeter-qt/usermanagerinterface.h b/libldmgreeter-qt/usermanagerinterface.h
new file mode 100644
index 00000000..35d1283e
--- /dev/null
+++ b/libldmgreeter-qt/usermanagerinterface.h
@@ -0,0 +1,69 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp user-manager.xml -c UserManagerInterface -p usermanagernterface
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef USERMANAGERNTERFACE_H_1289589108
+#define USERMANAGERNTERFACE_H_1289589108
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+#include "ldmuser.h"
+
+/*
+ * Proxy class for interface org.lightdm.LightDisplayManager.Users
+ */
+class UserManagerInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.lightdm.LightDisplayManager.Users"; }
+
+public:
+ UserManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~UserManagerInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QString, QString, QString> GetUserDefaults(const QString &username)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(username);
+ return asyncCallWithArgumentList(QLatin1String("GetUserDefaults"), argumentList);
+ }
+ inline QDBusReply<QString> GetUserDefaults(const QString &username, QString &layout, QString &session)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(username);
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("GetUserDefaults"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 3) {
+ layout = qdbus_cast<QString>(reply.arguments().at(1));
+ session = qdbus_cast<QString>(reply.arguments().at(2));
+ }
+ return reply;
+ }
+
+ inline QDBusPendingReply<QList<LdmUser> > GetUsers()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetUsers"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+
+#endif