diff options
Diffstat (limited to 'tests/src/test-qt-greeter.cpp')
-rw-r--r-- | tests/src/test-qt-greeter.cpp | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/tests/src/test-qt-greeter.cpp b/tests/src/test-qt-greeter.cpp index 68ab1674..9a34567c 100644 --- a/tests/src/test-qt-greeter.cpp +++ b/tests/src/test-qt-greeter.cpp @@ -3,7 +3,6 @@ #include <stdio.h> #include <signal.h> #include <glib-object.h> -#include <xcb/xcb.h> #include <QLightDM/Greeter> #include <QtCore/QSettings> #include <QtCore/QDebug> @@ -12,6 +11,7 @@ #include "test-qt-greeter.h" #include "status.h" +static gchar *greeter_id; static QCoreApplication *app = NULL; static QSettings *config = NULL; static TestGreeter *greeter = NULL; @@ -26,33 +26,33 @@ TestGreeter::TestGreeter () void TestGreeter::showMessage (QString text, QLightDM::Greeter::MessageType type) { - status_notify ("GREETER %s SHOW-MESSAGE TEXT=\"%s\"", getenv ("DISPLAY"), text.toAscii ().constData ()); + status_notify ("%s SHOW-MESSAGE TEXT=\"%s\"", greeter_id, text.toAscii ().constData ()); } void TestGreeter::showPrompt (QString text, QLightDM::Greeter::PromptType type) { - status_notify ("GREETER %s SHOW-PROMPT TEXT=\"%s\"", getenv ("DISPLAY"), text.toAscii ().constData ()); + status_notify ("%s SHOW-PROMPT TEXT=\"%s\"", greeter_id, text.toAscii ().constData ()); } void TestGreeter::authenticationComplete () { if (authenticationUser () != "") - status_notify ("GREETER %s AUTHENTICATION-COMPLETE USERNAME=%s AUTHENTICATED=%s", - getenv ("DISPLAY"), + status_notify ("%s AUTHENTICATION-COMPLETE USERNAME=%s AUTHENTICATED=%s", + greeter_id, authenticationUser ().toAscii ().constData (), isAuthenticated () ? "TRUE" : "FALSE"); else - status_notify ("GREETER %s AUTHENTICATION-COMPLETE AUTHENTICATED=%s", getenv ("DISPLAY"), isAuthenticated () ? "TRUE" : "FALSE"); + status_notify ("%s AUTHENTICATION-COMPLETE AUTHENTICATED=%s", greeter_id, isAuthenticated () ? "TRUE" : "FALSE"); } void TestGreeter::autologinTimerExpired () { - status_notify ("GREETER %s AUTOLOGIN-TIMER-EXPIRED", getenv ("DISPLAY")); + status_notify ("%s AUTOLOGIN-TIMER-EXPIRED", greeter_id); } static void signal_cb (int signum) { - status_notify ("GREETER %s TERMINATE SIGNAL=%d", getenv ("DISPLAY"), signum); + status_notify ("%s TERMINATE SIGNAL=%d", greeter_id, signum); _exit (EXIT_SUCCESS); } @@ -67,32 +67,32 @@ request_cb (const gchar *request) return; } - r = g_strdup_printf ("GREETER %s AUTHENTICATE", getenv ("DISPLAY")); + r = g_strdup_printf ("%s AUTHENTICATE", greeter_id); if (strcmp (request, r) == 0) greeter->authenticate (); g_free (r); - r = g_strdup_printf ("GREETER %s AUTHENTICATE USERNAME=", getenv ("DISPLAY")); + r = g_strdup_printf ("%s AUTHENTICATE USERNAME=", greeter_id); if (g_str_has_prefix (request, r)) greeter->authenticate (request + strlen (r)); g_free (r); - r = g_strdup_printf ("GREETER %s AUTHENTICATE-GUEST", getenv ("DISPLAY")); + r = g_strdup_printf ("%s AUTHENTICATE-GUEST", greeter_id); if (strcmp (request, r) == 0) greeter->authenticateAsGuest (); g_free (r); - r = g_strdup_printf ("GREETER %s AUTHENTICATE-AUTOLOGIN", getenv ("DISPLAY")); + r = g_strdup_printf ("%s AUTHENTICATE-AUTOLOGIN", greeter_id); if (strcmp (request, r) == 0) greeter->authenticateAutologin (); g_free (r); - r = g_strdup_printf ("GREETER %s AUTHENTICATE-REMOTE SESSION=", getenv ("DISPLAY")); + r = g_strdup_printf ("%s AUTHENTICATE-REMOTE SESSION=", greeter_id); if (g_str_has_prefix (request, r)) greeter->authenticateRemote (request + strlen (r), NULL); g_free (r); - r = g_strdup_printf ("GREETER %s RESPOND TEXT=\"", getenv ("DISPLAY")); + r = g_strdup_printf ("%s RESPOND TEXT=\"", greeter_id); if (g_str_has_prefix (request, r)) { gchar *text = g_strdup (request + strlen (r)); @@ -102,19 +102,19 @@ request_cb (const gchar *request) } g_free (r); - r = g_strdup_printf ("GREETER %s START-SESSION", getenv ("DISPLAY")); + r = g_strdup_printf ("%s START-SESSION", greeter_id); if (strcmp (request, r) == 0) { if (!greeter->startSessionSync ()) - status_notify ("GREETER %s SESSION-FAILED", getenv ("DISPLAY")); + status_notify ("%s SESSION-FAILED", greeter_id); } g_free (r); - r = g_strdup_printf ("GREETER %s START-SESSION SESSION=", getenv ("DISPLAY")); + r = g_strdup_printf ("%s START-SESSION SESSION=", greeter_id); if (g_str_has_prefix (request, r)) { if (!greeter->startSessionSync (request + strlen (r))) - status_notify ("GREETER %s SESSION-FAILED", getenv ("DISPLAY")); + status_notify ("%s SESSION-FAILED", greeter_id); } g_free (r); } @@ -122,10 +122,20 @@ request_cb (const gchar *request) int main(int argc, char *argv[]) { + gchar *display; + #if !defined(GLIB_VERSION_2_36) g_type_init (); #endif + display = getenv ("DISPLAY"); + if (display == NULL) + greeter_id = g_strdup ("GREETER-?"); + else if (display[0] == ':') + greeter_id = g_strdup_printf ("GREETER-X-%s", display + 1); + else + greeter_id = g_strdup_printf ("GREETER-X-%s", display); + status_connect (request_cb); app = new QCoreApplication (argc, argv); @@ -133,7 +143,7 @@ main(int argc, char *argv[]) signal (SIGINT, signal_cb); signal (SIGTERM, signal_cb); - status_notify ("GREETER %s START", getenv ("DISPLAY")); + status_notify ("%s START", greeter_id); config = new QSettings (g_build_filename (getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), QSettings::IniFormat); @@ -141,27 +151,27 @@ main(int argc, char *argv[]) if (xcb_connection_has_error (connection)) { - status_notify ("GREETER %s FAIL-CONNECT-XSERVER", getenv ("DISPLAY")); + status_notify ("%s FAIL-CONNECT-XSERVER", greeter_id); return EXIT_FAILURE; } - status_notify ("GREETER %s CONNECT-XSERVER", getenv ("DISPLAY")); + status_notify ("%s CONNECT-XSERVER", greeter_id); greeter = new TestGreeter(); - status_notify ("GREETER %s CONNECT-TO-DAEMON", getenv ("DISPLAY")); + status_notify ("%s CONNECT-TO-DAEMON", greeter_id); if (!greeter->connectSync()) { - status_notify ("GREETER %s FAIL-CONNECT-DAEMON", getenv ("DISPLAY")); + status_notify ("%s FAIL-CONNECT-DAEMON", greeter_id); return EXIT_FAILURE; } - status_notify ("GREETER %s CONNECTED-TO-DAEMON", getenv ("DISPLAY")); + status_notify ("%s CONNECTED-TO-DAEMON", greeter_id); if (greeter->selectUserHint() != "") - status_notify ("GREETER %s SELECT-USER-HINT USERNAME=%s", getenv ("DISPLAY"), greeter->selectUserHint ().toAscii ().constData ()); + status_notify ("%s SELECT-USER-HINT USERNAME=%s", greeter_id, greeter->selectUserHint ().toAscii ().constData ()); if (greeter->lockHint()) - status_notify ("GREETER %s LOCK-HINT", getenv ("DISPLAY")); + status_notify ("%s LOCK-HINT", greeter_id); return app->exec(); } |