summaryrefslogtreecommitdiff
path: root/liblightdm-qt
diff options
context:
space:
mode:
authorIain Lane <iain.lane@canonical.com>2013-04-16 17:37:08 +0100
committerIain Lane <iain.lane@canonical.com>2013-04-16 17:37:08 +0100
commitcf0cb47d745d47ba178c0e461c796a83785f58a0 (patch)
treef9ae7049b53d3498649f7859ea8ac0d59f0fcd21 /liblightdm-qt
parent7f7951f5a77352a6aaddf09e876ae46b462b39c2 (diff)
downloadlightdm-cf0cb47d745d47ba178c0e461c796a83785f58a0.tar.gz
Merge trunk
There may still be some tests that need to be reworked
Diffstat (limited to 'liblightdm-qt')
-rw-r--r--liblightdm-qt/Makefile.am33
-rw-r--r--liblightdm-qt/QLightDM/greeter.h28
-rw-r--r--liblightdm-qt/QLightDM/power.h10
-rw-r--r--liblightdm-qt/QLightDM/sessionsmodel.h4
-rw-r--r--liblightdm-qt/QLightDM/usersmodel.h4
-rw-r--r--liblightdm-qt/liblightdm-qt-3.pc.in (renamed from liblightdm-qt/liblightdm-qt-2.pc.in)0
-rw-r--r--liblightdm-qt/liblightdm-qt5-3.pc.in (renamed from liblightdm-qt/liblightdm-qt5-2.pc.in)0
-rw-r--r--liblightdm-qt/power.cpp59
8 files changed, 84 insertions, 54 deletions
diff --git a/liblightdm-qt/Makefile.am b/liblightdm-qt/Makefile.am
index d16cf966..7969458b 100644
--- a/liblightdm-qt/Makefile.am
+++ b/liblightdm-qt/Makefile.am
@@ -7,21 +7,22 @@
common_libadd = \
-L$(top_builddir)/liblightdm-gobject \
-llightdm-gobject-1
-liblightdm_qt_2_la_LIBADD = \
+liblightdm_qt_3_la_LIBADD = \
$(LIBLIGHTDM_QT4_LIBS) \
$(common_libadd)
-liblightdm_qt5_2_la_LIBADD = \
+liblightdm_qt5_3_la_LIBADD = \
$(LIBLIGHTDM_QT5_LIBS) \
$(common_libadd)
common_cflags = \
-I$(top_srcdir)/liblightdm-gobject \
$(LIBLIGHTDM_GOBJECT_CFLAGS) \
+ -DQT_NO_KEYWORDS \
-DXSESSIONS_DIR=\"$(datadir)/xsessions\"
-liblightdm_qt_2_la_CXXFLAGS = \
+liblightdm_qt_3_la_CXXFLAGS = \
$(LIBLIGHTDM_QT4_CFLAGS) \
$(common_cflags)
-liblightdm_qt5_2_la_CXXFLAGS = \
+liblightdm_qt5_3_la_CXXFLAGS = \
-fPIC \
-DQT_DISABLE_DEPRECATED_BEFORE="QT_VERSION_CHECK(4, 0, 0)" \
$(LIBLIGHTDM_QT5_CFLAGS) \
@@ -37,20 +38,20 @@ common_headers = \
QLightDM/sessionsmodel.h \
QLightDM/usersmodel.h
-liblightdm_qt_2includedir=$(includedir)/lightdm-qt-2/QLightDM
-liblightdm_qt5_2includedir=$(includedir)/lightdm-qt5-2/QLightDM
+liblightdm_qt_3includedir=$(includedir)/lightdm-qt-3/QLightDM
+liblightdm_qt5_3includedir=$(includedir)/lightdm-qt5-3/QLightDM
common_sources = \
greeter.cpp \
power.cpp \
sessionsmodel.cpp \
usersmodel.cpp
-liblightdm_qt_2_la_SOURCES = \
+liblightdm_qt_3_la_SOURCES = \
$(common_sources) \
- $(liblightdm_qt_2include_HEADERS)
-liblightdm_qt5_2_la_SOURCES = \
+ $(liblightdm_qt_3include_HEADERS)
+liblightdm_qt5_3_la_SOURCES = \
$(common_sources) \
- $(liblightdm_qt5_2include_HEADERS)
+ $(liblightdm_qt5_3include_HEADERS)
pkgconfigdir = $(libdir)/pkgconfig
@@ -66,15 +67,15 @@ BUILT_SOURCES =
pkgconfig_DATA =
if COMPILE_LIBLIGHTDM_QT4
-lib_LTLIBRARIES += liblightdm-qt-2.la
-liblightdm_qt_2include_HEADERS = $(common_headers)
+lib_LTLIBRARIES += liblightdm-qt-3.la
+liblightdm_qt_3include_HEADERS = $(common_headers)
BUILT_SOURCES += $(common_sources:.cpp=_moc4.cpp)
-pkgconfig_DATA += liblightdm-qt-2.pc
+pkgconfig_DATA += liblightdm-qt-3.pc
endif
if COMPILE_LIBLIGHTDM_QT5
-lib_LTLIBRARIES += liblightdm-qt5-2.la
-liblightdm_qt5_2include_HEADERS = $(common_headers)
+lib_LTLIBRARIES += liblightdm-qt5-3.la
+liblightdm_qt5_3include_HEADERS = $(common_headers)
BUILT_SOURCES += $(common_sources:.cpp=_moc5.cpp)
-pkgconfig_DATA += liblightdm-qt5-2.pc
+pkgconfig_DATA += liblightdm-qt5-3.pc
endif
diff --git a/liblightdm-qt/QLightDM/greeter.h b/liblightdm-qt/QLightDM/greeter.h
index 602c09c4..787485f4 100644
--- a/liblightdm-qt/QLightDM/greeter.h
+++ b/liblightdm-qt/QLightDM/greeter.h
@@ -24,19 +24,19 @@ class Q_DECL_EXPORT Greeter : public QObject
{
Q_OBJECT
- Q_PROPERTY(bool authenticated READ isAuthenticated ); //NOTFIY authenticationComplete
- Q_PROPERTY(QString authenticationUser READ authenticationUser );
- Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT);
- Q_PROPERTY(QString selectUser READ selectUserHint CONSTANT);
- Q_PROPERTY(bool selectGuest READ selectGuestHint CONSTANT);
-
- Q_PROPERTY(QString hostname READ hostname CONSTANT);
- Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT);
- Q_PROPERTY(bool locked READ lockHint CONSTANT);
+ Q_PROPERTY(bool authenticated READ isAuthenticated ) //NOTFIY authenticationComplete
+ Q_PROPERTY(QString authenticationUser READ authenticationUser )
+ Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT)
+ Q_PROPERTY(QString selectUser READ selectUserHint CONSTANT)
+ Q_PROPERTY(bool selectGuest READ selectGuestHint CONSTANT)
+
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
+ Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT)
+ Q_PROPERTY(bool locked READ lockHint CONSTANT)
- Q_PROPERTY(QString hostname READ hostname CONSTANT);
+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
- Q_ENUMS(PromptType MessageType);
+ Q_ENUMS(PromptType MessageType)
public:
enum PromptType {
@@ -70,7 +70,7 @@ public:
QString authenticationUser() const;
QString hostname() const;
-public slots:
+public Q_SLOTS:
bool connectSync();
void authenticate(const QString &username=QString());
void authenticateAsGuest();
@@ -81,7 +81,7 @@ public slots:
void setLanguage (const QString &language);
bool startSessionSync(const QString &session=QString());
-signals:
+Q_SIGNALS:
void showMessage(QString text, QLightDM::Greeter::MessageType type);
void showPrompt(QString text, QLightDM::Greeter::PromptType type);
void authenticationComplete();
@@ -92,6 +92,6 @@ private:
Q_DECLARE_PRIVATE(Greeter)
};
-};
+}
#endif // QLIGHTDM_GREETER_H
diff --git a/liblightdm-qt/QLightDM/power.h b/liblightdm-qt/QLightDM/power.h
index 86eb2b2e..44d9e2c4 100644
--- a/liblightdm-qt/QLightDM/power.h
+++ b/liblightdm-qt/QLightDM/power.h
@@ -34,16 +34,16 @@ namespace QLightDM
bool canRestart();
public Q_SLOTS:
- void suspend();
- void hibernate();
- void shutdown();
- void restart();
+ bool suspend();
+ bool hibernate();
+ bool shutdown();
+ bool restart();
private:
class PowerInterfacePrivate;
PowerInterfacePrivate * const d;
};
-};
+}
#endif // QLIGHTDM_POWER_H
diff --git a/liblightdm-qt/QLightDM/sessionsmodel.h b/liblightdm-qt/QLightDM/sessionsmodel.h
index 79564cf3..77c81fb2 100644
--- a/liblightdm-qt/QLightDM/sessionsmodel.h
+++ b/liblightdm-qt/QLightDM/sessionsmodel.h
@@ -20,7 +20,7 @@ namespace QLightDM {
{
Q_OBJECT
- Q_ENUMS(SessionModelRoles SessionType);
+ Q_ENUMS(SessionModelRoles SessionType)
public:
enum SessionModelRoles {
@@ -48,6 +48,6 @@ namespace QLightDM {
private:
Q_DECLARE_PRIVATE(SessionsModel)
};
-};
+}
#endif // QLIGHTDM_SESSION_H
diff --git a/liblightdm-qt/QLightDM/usersmodel.h b/liblightdm-qt/QLightDM/usersmodel.h
index 72f8f601..d803c41c 100644
--- a/liblightdm-qt/QLightDM/usersmodel.h
+++ b/liblightdm-qt/QLightDM/usersmodel.h
@@ -24,7 +24,7 @@ class Q_DECL_EXPORT UsersModel : public QAbstractListModel
{
Q_OBJECT
- Q_ENUMS(UserModelRoles);
+ Q_ENUMS(UserModelRoles)
public:
explicit UsersModel(QObject *parent = 0);
@@ -52,6 +52,6 @@ private:
};
-};
+}
#endif // QLIGHTDM_USER_H
diff --git a/liblightdm-qt/liblightdm-qt-2.pc.in b/liblightdm-qt/liblightdm-qt-3.pc.in
index 1217afd9..1217afd9 100644
--- a/liblightdm-qt/liblightdm-qt-2.pc.in
+++ b/liblightdm-qt/liblightdm-qt-3.pc.in
diff --git a/liblightdm-qt/liblightdm-qt5-2.pc.in b/liblightdm-qt/liblightdm-qt5-3.pc.in
index bebeb5f8..bebeb5f8 100644
--- a/liblightdm-qt/liblightdm-qt5-2.pc.in
+++ b/liblightdm-qt/liblightdm-qt5-3.pc.in
diff --git a/liblightdm-qt/power.cpp b/liblightdm-qt/power.cpp
index 3df5cbd5..47bd5a05 100644
--- a/liblightdm-qt/power.cpp
+++ b/liblightdm-qt/power.cpp
@@ -15,6 +15,7 @@
#include <QtCore/QVariant>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
+#include <QDebug>
#include "config.h"
@@ -26,11 +27,13 @@ public:
PowerInterfacePrivate();
QScopedPointer<QDBusInterface> powerManagementInterface;
QScopedPointer<QDBusInterface> consoleKitInterface;
+ QScopedPointer<QDBusInterface> login1Interface;
};
PowerInterface::PowerInterfacePrivate::PowerInterfacePrivate() :
powerManagementInterface(new QDBusInterface("org.freedesktop.UPower","/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus())),
- consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus()))
+ consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus())),
+ login1Interface(new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()))
{
}
@@ -57,9 +60,10 @@ bool PowerInterface::canSuspend()
}
}
-void PowerInterface::suspend()
+bool PowerInterface::suspend()
{
- d->powerManagementInterface->call("Suspend");
+ QDBusReply<void> reply = d->powerManagementInterface->call("Suspend");
+ return reply.isValid ();
}
bool PowerInterface::canHibernate()
@@ -73,41 +77,66 @@ bool PowerInterface::canHibernate()
}
}
-void PowerInterface::hibernate()
+bool PowerInterface::hibernate()
{
- d->powerManagementInterface->call("Hibernate");
+ QDBusReply<void> reply = d->powerManagementInterface->call("Hibernate");
+ return reply.isValid ();
}
bool PowerInterface::canShutdown()
{
+ if (d->login1Interface->isValid()) {
+ QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff");
+ if (reply1.isValid()) {
+ return reply1.value() == "yes";
+ }
+ }
+ qWarning() << d->login1Interface->lastError();
+
QDBusReply<bool> reply = d->consoleKitInterface->call("CanStop");
if (reply.isValid()) {
return reply.value();
}
- else {
- return false;
- }
+
+ return false;
}
-void PowerInterface::shutdown()
+bool PowerInterface::shutdown()
{
- d->consoleKitInterface->call("Stop");
+ QDBusReply<void> reply;
+ if (d->login1Interface->isValid())
+ reply = d->login1Interface->call("PowerOff", false);
+ else
+ reply = d->consoleKitInterface->call("Stop");
+ return reply.isValid();
}
bool PowerInterface::canRestart()
{
+ if (d->login1Interface->isValid()) {
+ QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot");
+ if (reply1.isValid()) {
+ return reply1.value() == "yes";
+ }
+ }
+ qWarning() << d->login1Interface->lastError();
+
QDBusReply<bool> reply = d->consoleKitInterface->call("CanRestart");
if (reply.isValid()) {
return reply.value();
}
- else {
- return false;
- }
+
+ return false;
}
-void PowerInterface::restart()
+bool PowerInterface::restart()
{
- d->consoleKitInterface->call("Restart");
+ QDBusReply<void> reply;
+ if (d->login1Interface->isValid())
+ reply = d->login1Interface->call("Reboot", false);
+ else
+ reply = d->consoleKitInterface->call("Restart");
+ return reply.isValid();
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)