Back to index

lightdm  1.3.2
Functions | Variables
test-qt-greeter.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <glib-object.h>
#include <xcb/xcb.h>
#include <QLightDM/Greeter>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QtCore/QCoreApplication>
#include "test-qt-greeter.h"
#include "status.h"

Go to the source code of this file.

Functions

static void signal_cb (int signum)
static void request_cb (const gchar *request)
int main (int argc, char *argv[])

Variables

static QSettings * config = NULL
static TestGreetergreeter = NULL

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 99 of file test-qt-greeter.cpp.

{
    g_type_init ();

    status_connect (request_cb);

    QCoreApplication app(argc, argv);

    signal (SIGINT, signal_cb);
    signal (SIGTERM, signal_cb);

    status_notify ("GREETER %s START", getenv ("DISPLAY"));

    config = new QSettings (g_build_filename (getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), QSettings::IniFormat);

    xcb_connection_t *connection = xcb_connect (NULL, NULL);

    if (xcb_connection_has_error (connection))
    {
        status_notify ("GREETER %s FAIL-CONNECT-XSERVER", getenv ("DISPLAY"));
        return EXIT_FAILURE;
    }

    status_notify ("GREETER %s CONNECT-XSERVER", getenv ("DISPLAY"));

    greeter = new TestGreeter();
  
    status_notify ("GREETER %s CONNECT-TO-DAEMON", getenv ("DISPLAY"));
    if (!greeter->connectSync())
    {
        status_notify ("GREETER %s FAIL-CONNECT-DAEMON", getenv ("DISPLAY"));
        return EXIT_FAILURE;
    }

    status_notify ("GREETER %s CONNECTED-TO-DAEMON", getenv ("DISPLAY"));

    if (greeter->selectUserHint() != "")
        status_notify ("GREETER %s SELECT-USER-HINT USERNAME=%s", getenv ("DISPLAY"), greeter->selectUserHint ().toAscii ().constData ());
    if (greeter->lockHint())
        status_notify ("GREETER %s LOCK-HINT", getenv ("DISPLAY"));

    return app.exec();
}

Here is the call graph for this function:

static void request_cb ( const gchar *  request) [static]

Definition at line 52 of file test-qt-greeter.cpp.

{
    gchar *r;
  
    r = g_strdup_printf ("GREETER %s AUTHENTICATE", getenv ("DISPLAY"));
    if (strcmp (request, r) == 0)
        greeter->authenticate ();
    g_free (r);

    r = g_strdup_printf ("GREETER %s AUTHENTICATE USERNAME=", getenv ("DISPLAY"));
    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"));
    if (strcmp (request, r) == 0)
        greeter->authenticateAsGuest ();
    g_free (r);

    r = g_strdup_printf ("GREETER %s RESPOND TEXT=\"", getenv ("DISPLAY"));
    if (g_str_has_prefix (request, r))
    {
        gchar *text = g_strdup (request + strlen (r));
        text[strlen (text) - 1] = '\0';
        greeter->respond (text);
        g_free (text);
    }
    g_free (r);

    r = g_strdup_printf ("GREETER %s START-SESSION", getenv ("DISPLAY"));
    if (strcmp (request, r) == 0)
    {
        if (!greeter->startSessionSync ())
            status_notify ("GREETER %s SESSION-FAILED", getenv ("DISPLAY"));
    }
    g_free (r);

    r = g_strdup_printf ("GREETER %s START-SESSION SESSION=", getenv ("DISPLAY"));
    if (g_str_has_prefix (request, r))
    {
        if (!greeter->startSessionSync (request + strlen (r)))
            status_notify ("GREETER %s SESSION-FAILED", getenv ("DISPLAY"));
    }
    g_free (r);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void signal_cb ( int  signum) [static]

Definition at line 45 of file test-qt-greeter.cpp.

{
    status_notify ("GREETER %s TERMINATE SIGNAL=%d", getenv ("DISPLAY"), signum);
    exit (EXIT_SUCCESS);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

QSettings* config = NULL [static]

Definition at line 14 of file test-qt-greeter.cpp.

TestGreeter* greeter = NULL [static]

Definition at line 15 of file test-qt-greeter.cpp.