]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - liblightdm-qt/greeter.cpp
Load all users only when really needed
[sojka/lightdm.git] / liblightdm-qt / greeter.cpp
index 7db5c2cc93fad8f63f51108765d8720970a60c2a..d535a02222153752947a740243ac454a6a04dde9 100644 (file)
@@ -5,9 +5,8 @@
  *
  * This library is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version. See http://www.gnu.org/copyleft/lgpl.html the full text of the
- * license.
+ * Software Foundation; either version 2 or version 3 of the License.
+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
  */
 
 
@@ -29,12 +28,14 @@ public:
     LightDMGreeter *ldmGreeter;
 protected:
     Greeter* q_ptr;
-    
+
     static void cb_showPrompt(LightDMGreeter *greeter, const gchar *text, LightDMPromptType type, gpointer data);
     static void cb_showMessage(LightDMGreeter *greeter, const gchar *text, LightDMMessageType type, gpointer data);
     static void cb_authenticationComplete(LightDMGreeter *greeter, gpointer data);
     static void cb_autoLoginExpired(LightDMGreeter *greeter, gpointer data);
-    
+    static void cb_idle(LightDMGreeter *greeter, gpointer data);
+    static void cb_reset(LightDMGreeter *greeter, gpointer data);
+
 private:
     Q_DECLARE_PUBLIC(Greeter)
 };
@@ -42,25 +43,28 @@ private:
 GreeterPrivate::GreeterPrivate(Greeter *parent) :
     q_ptr(parent)
 {
+#if !defined(GLIB_VERSION_2_36)
     g_type_init();
+#endif
     ldmGreeter = lightdm_greeter_new();
-    
-    g_signal_connect (ldmGreeter, "show-prompt", G_CALLBACK (cb_showPrompt), this);
-    g_signal_connect (ldmGreeter, "show-message", G_CALLBACK (cb_showMessage), this);
-    g_signal_connect (ldmGreeter, "authentication-complete", G_CALLBACK (cb_authenticationComplete), this);
-    g_signal_connect (ldmGreeter, "autologin-timer-expired", G_CALLBACK (cb_autoLoginExpired), this);
+
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT, G_CALLBACK (cb_showPrompt), this);
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE, G_CALLBACK (cb_showMessage), this);
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE, G_CALLBACK (cb_authenticationComplete), this);
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_AUTOLOGIN_TIMER_EXPIRED, G_CALLBACK (cb_autoLoginExpired), this);
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_IDLE, G_CALLBACK (cb_idle), this);
+    g_signal_connect (ldmGreeter, LIGHTDM_GREETER_SIGNAL_RESET, G_CALLBACK (cb_reset), this);
 }
 
 void GreeterPrivate::cb_showPrompt(LightDMGreeter *greeter, const gchar *text, LightDMPromptType type, gpointer data)
 {
     Q_UNUSED(greeter);
-    
+
     GreeterPrivate *that = static_cast<GreeterPrivate*>(data);
-    QString message = QString::fromLocal8Bit(text);
-    
-    //FIXME prompt type
+    QString message = QString::fromUtf8(text);
 
-    Q_EMIT that->q_func()->showPrompt(message, Greeter::PromptTypeSecret);
+    Q_EMIT that->q_func()->showPrompt(message, type == LIGHTDM_PROMPT_TYPE_QUESTION ?
+                                               Greeter::PromptTypeQuestion : Greeter::PromptTypeSecret);
 }
 
 void GreeterPrivate::cb_showMessage(LightDMGreeter *greeter, const gchar *text, LightDMMessageType type, gpointer data)
@@ -68,11 +72,10 @@ void GreeterPrivate::cb_showMessage(LightDMGreeter *greeter, const gchar *text,
     Q_UNUSED(greeter);
 
     GreeterPrivate *that = static_cast<GreeterPrivate*>(data);
-    QString message = QString::fromLocal8Bit(text);
+    QString message = QString::fromUtf8(text);
 
-    //FIXME prompt type
-
-    Q_EMIT that->q_func()->showMessage(message, Greeter::MessageTypeInfo);
+    Q_EMIT that->q_func()->showMessage(message, type == LIGHTDM_MESSAGE_TYPE_INFO ?
+                                                Greeter::MessageTypeInfo : Greeter::MessageTypeError);
 }
 
 void GreeterPrivate::cb_authenticationComplete(LightDMGreeter *greeter, gpointer data)
@@ -89,6 +92,20 @@ void GreeterPrivate::cb_autoLoginExpired(LightDMGreeter *greeter, gpointer data)
     Q_EMIT that->q_func()->autologinTimerExpired();
 }
 
+void GreeterPrivate::cb_idle(LightDMGreeter *greeter, gpointer data)
+{
+    Q_UNUSED(greeter);
+    GreeterPrivate *that = static_cast<GreeterPrivate*>(data);
+    Q_EMIT that->q_func()->idle();
+}
+
+void GreeterPrivate::cb_reset(LightDMGreeter *greeter, gpointer data)
+{
+    Q_UNUSED(greeter);
+    GreeterPrivate *that = static_cast<GreeterPrivate*>(data);
+    Q_EMIT that->q_func()->reset();
+}
+
 Greeter::Greeter(QObject *parent) :
     QObject(parent),
     d_ptr(new GreeterPrivate(this))
@@ -101,35 +118,58 @@ Greeter::~Greeter()
 }
 
 
+bool Greeter::connectToDaemonSync()
+{
+    Q_D(Greeter);
+    return lightdm_greeter_connect_to_daemon_sync(d->ldmGreeter, NULL);
+}
+
 bool Greeter::connectSync()
 {
     Q_D(Greeter);
-    return lightdm_greeter_connect_sync(d->ldmGreeter, NULL);
+    return lightdm_greeter_connect_to_daemon_sync(d->ldmGreeter, NULL);
 }
 
 void Greeter::authenticate(const QString &username)
 {
     Q_D(Greeter);
-    lightdm_greeter_authenticate(d->ldmGreeter, username.toLocal8Bit().data());
+    lightdm_greeter_authenticate(d->ldmGreeter, username.toLocal8Bit().data(), NULL);
 }
 
 void Greeter::authenticateAsGuest()
 {
     Q_D(Greeter);
-    lightdm_greeter_authenticate_as_guest(d->ldmGreeter);
-    
+    lightdm_greeter_authenticate_as_guest(d->ldmGreeter, NULL);
+}
+
+void Greeter::authenticateAutologin()
+{
+    Q_D(Greeter);
+    lightdm_greeter_authenticate_autologin(d->ldmGreeter, NULL);
+}
+
+void Greeter::authenticateRemote(const QString &session, const QString &username)
+{
+    Q_D(Greeter);
+    lightdm_greeter_authenticate_remote(d->ldmGreeter, session.toLocal8Bit().data(), username.toLocal8Bit().data(), NULL);
 }
 
 void Greeter::respond(const QString &response)
 {
     Q_D(Greeter);
-    lightdm_greeter_respond(d->ldmGreeter, response.toLocal8Bit().data());
+    lightdm_greeter_respond(d->ldmGreeter, response.toLocal8Bit().data(), NULL);
 }
 
 void Greeter::cancelAuthentication()
 {
     Q_D(Greeter);
-    lightdm_greeter_cancel_authentication(d->ldmGreeter);
+    lightdm_greeter_cancel_authentication(d->ldmGreeter, NULL);
+}
+
+void Greeter::cancelAutologin()
+{
+    Q_D(Greeter);
+    lightdm_greeter_cancel_autologin(d->ldmGreeter);
 }
 
 bool Greeter::inAuthentication() const
@@ -147,13 +187,19 @@ bool Greeter::isAuthenticated() const
 QString Greeter::authenticationUser() const
 {
     Q_D(const Greeter);
-    return QString::fromLocal8Bit(lightdm_greeter_get_authentication_user(d->ldmGreeter));
+    return QString::fromUtf8(lightdm_greeter_get_authentication_user(d->ldmGreeter));
 }
 
 void Greeter::setLanguage (const QString &language)
 {
     Q_D(Greeter);
-    lightdm_greeter_set_language(d->ldmGreeter, language.toLocal8Bit().constData());
+    lightdm_greeter_set_language(d->ldmGreeter, language.toLocal8Bit().constData(), NULL);
+}
+
+void Greeter::setResettable (bool resettable)
+{
+    Q_D(Greeter);
+    lightdm_greeter_set_resettable(d->ldmGreeter, resettable);
 }
 
 bool Greeter::startSessionSync(const QString &session)
@@ -162,6 +208,12 @@ bool Greeter::startSessionSync(const QString &session)
     return lightdm_greeter_start_session_sync(d->ldmGreeter, session.toLocal8Bit().constData(), NULL);
 }
 
+QString Greeter::ensureSharedDataDirSync(const QString &username)
+{
+    Q_D(Greeter);
+    return QString::fromUtf8(lightdm_greeter_ensure_shared_data_dir_sync(d->ldmGreeter, username.toLocal8Bit().constData(), NULL));
+}
+
 
 QString Greeter::getHint(const QString &name) const
 {
@@ -172,7 +224,7 @@ QString Greeter::getHint(const QString &name) const
 QString Greeter::defaultSessionHint() const
 {
     Q_D(const Greeter);
-    return QString::fromLocal8Bit(lightdm_greeter_get_default_session_hint(d->ldmGreeter));
+    return QString::fromUtf8(lightdm_greeter_get_default_session_hint(d->ldmGreeter));
 }
 
 bool Greeter::hideUsersHint() const
@@ -181,6 +233,24 @@ bool Greeter::hideUsersHint() const
     return lightdm_greeter_get_hide_users_hint(d->ldmGreeter);
 }
 
+bool Greeter::showManualLoginHint() const
+{
+    Q_D(const Greeter);
+    return lightdm_greeter_get_show_manual_login_hint(d->ldmGreeter);
+}
+
+bool Greeter::showRemoteLoginHint() const
+{
+    Q_D(const Greeter);
+    return lightdm_greeter_get_show_remote_login_hint(d->ldmGreeter);
+}
+
+bool Greeter::lockHint() const
+{
+    Q_D(const Greeter);
+    return lightdm_greeter_get_lock_hint(d->ldmGreeter);
+}
+
 bool Greeter::hasGuestAccountHint() const
 {
     Q_D(const Greeter);
@@ -190,7 +260,7 @@ bool Greeter::hasGuestAccountHint() const
 QString Greeter::selectUserHint() const
 {
     Q_D(const Greeter);
-    return QString::fromLocal8Bit(lightdm_greeter_get_select_user_hint(d->ldmGreeter));
+    return QString::fromUtf8(lightdm_greeter_get_select_user_hint(d->ldmGreeter));
 }
 
 bool Greeter::selectGuestHint() const
@@ -202,7 +272,7 @@ bool Greeter::selectGuestHint() const
 QString Greeter::autologinUserHint() const
 {
     Q_D(const Greeter);
-    return QString::fromLocal8Bit(lightdm_greeter_get_autologin_user_hint(d->ldmGreeter));
+    return QString::fromUtf8(lightdm_greeter_get_autologin_user_hint(d->ldmGreeter));
 }
 
 bool Greeter::autologinGuestHint() const
@@ -217,4 +287,13 @@ int Greeter::autologinTimeoutHint() const
     return lightdm_greeter_get_autologin_timeout_hint(d->ldmGreeter);
 }
 
-#include "greeter_moc.cpp"
+QString Greeter::hostname() const
+{
+    return QString::fromUtf8(lightdm_get_hostname());
+}
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include "greeter_moc5.cpp"
+#else
+#include "greeter_moc4.cpp"
+#endif