From cf0cb47d745d47ba178c0e461c796a83785f58a0 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Tue, 16 Apr 2013 17:37:08 +0100 Subject: Merge trunk There may still be some tests that need to be reworked --- liblightdm-qt/Makefile.am | 33 ++++++++++--------- liblightdm-qt/QLightDM/greeter.h | 28 ++++++++-------- liblightdm-qt/QLightDM/power.h | 10 +++--- liblightdm-qt/QLightDM/sessionsmodel.h | 4 +-- liblightdm-qt/QLightDM/usersmodel.h | 4 +-- liblightdm-qt/liblightdm-qt-2.pc.in | 11 ------- liblightdm-qt/liblightdm-qt-3.pc.in | 11 +++++++ liblightdm-qt/liblightdm-qt5-2.pc.in | 11 ------- liblightdm-qt/liblightdm-qt5-3.pc.in | 11 +++++++ liblightdm-qt/power.cpp | 59 +++++++++++++++++++++++++--------- 10 files changed, 106 insertions(+), 76 deletions(-) delete mode 100644 liblightdm-qt/liblightdm-qt-2.pc.in create mode 100644 liblightdm-qt/liblightdm-qt-3.pc.in delete mode 100644 liblightdm-qt/liblightdm-qt5-2.pc.in create mode 100644 liblightdm-qt/liblightdm-qt5-3.pc.in (limited to 'liblightdm-qt') 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-2.pc.in deleted file mode 100644 index 1217afd9..00000000 --- a/liblightdm-qt/liblightdm-qt-2.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: liblightdm-qt -Description: LightDM Qt4 client library -Version: @VERSION@ -Requires: QtCore QtGui -Libs: -L${libdir} -llightdm-qt-2 -Cflags: -I${includedir}/lightdm-qt-2 diff --git a/liblightdm-qt/liblightdm-qt-3.pc.in b/liblightdm-qt/liblightdm-qt-3.pc.in new file mode 100644 index 00000000..1217afd9 --- /dev/null +++ b/liblightdm-qt/liblightdm-qt-3.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: liblightdm-qt +Description: LightDM Qt4 client library +Version: @VERSION@ +Requires: QtCore QtGui +Libs: -L${libdir} -llightdm-qt-2 +Cflags: -I${includedir}/lightdm-qt-2 diff --git a/liblightdm-qt/liblightdm-qt5-2.pc.in b/liblightdm-qt/liblightdm-qt5-2.pc.in deleted file mode 100644 index bebeb5f8..00000000 --- a/liblightdm-qt/liblightdm-qt5-2.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: liblightdm-qt5 -Description: LightDM Qt5 client library -Version: @VERSION@ -Requires: Qt5Core Qt5Gui -Libs: -L${libdir} -llightdm-qt5-2 -Cflags: -I${includedir}/lightdm-qt5-2 diff --git a/liblightdm-qt/liblightdm-qt5-3.pc.in b/liblightdm-qt/liblightdm-qt5-3.pc.in new file mode 100644 index 00000000..bebeb5f8 --- /dev/null +++ b/liblightdm-qt/liblightdm-qt5-3.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: liblightdm-qt5 +Description: LightDM Qt5 client library +Version: @VERSION@ +Requires: Qt5Core Qt5Gui +Libs: -L${libdir} -llightdm-qt5-2 +Cflags: -I${includedir}/lightdm-qt5-2 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 #include #include +#include #include "config.h" @@ -26,11 +27,13 @@ public: PowerInterfacePrivate(); QScopedPointer powerManagementInterface; QScopedPointer consoleKitInterface; + QScopedPointer 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 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 reply = d->powerManagementInterface->call("Hibernate"); + return reply.isValid (); } bool PowerInterface::canShutdown() { + if (d->login1Interface->isValid()) { + QDBusReply reply1 = d->login1Interface->call("CanPowerOff"); + if (reply1.isValid()) { + return reply1.value() == "yes"; + } + } + qWarning() << d->login1Interface->lastError(); + QDBusReply 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 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 reply1 = d->login1Interface->call("CanReboot"); + if (reply1.isValid()) { + return reply1.value() == "yes"; + } + } + qWarning() << d->login1Interface->lastError(); + QDBusReply 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 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) -- cgit v1.2.1