## Greeter Interface Greeter Interface — Make a connection to the LightDM daemon and authenticate users |

## Synopsis

    #include <lightdm.h>

    void                (*show_message)                     (LightDMGreeter *greeter,
                                                             const gchar *text,
                                                             LightDMMessageType type);
    void                (*show_prompt)                      (LightDMGreeter *greeter,
                                                             const gchar *text,
                                                             LightDMPromptType type);
    void                (*authentication_complete)          (LightDMGreeter *greeter);
    void                (*autologin_timer_expired)          (LightDMGreeter *greeter);
    enum                LightDMMessageType;
    enum                LightDMPromptType;
    LightDMGreeter *    lightdm_greeter_new                 (void);
    gboolean            lightdm_greeter_connect_sync        (LightDMGreeter *greeter,
                                                             GError **error);
    const gchar *       lightdm_greeter_get_default_session_hint
                                                            (LightDMGreeter *greeter);
    const gchar *       lightdm_greeter_get_hint            (LightDMGreeter *greeter,
                                                             const gchar *name);
    gboolean            lightdm_greeter_get_has_guest_account_hint
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_get_hide_users_hint (LightDMGreeter *greeter);
    const gchar *       lightdm_greeter_get_select_user_hint
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_get_select_guest_hint
                                                            (LightDMGreeter *greeter);
    const gchar *       lightdm_greeter_get_autologin_user_hint
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_get_autologin_guest_hint
                                                            (LightDMGreeter *greeter);
    gint                lightdm_greeter_get_autologin_timeout_hint
                                                            (LightDMGreeter *greeter);
    void                lightdm_greeter_cancel_autologin    (LightDMGreeter *greeter);
    void                lightdm_greeter_authenticate        (LightDMGreeter *greeter,
                                                             const gchar *username);
    void                lightdm_greeter_authenticate_as_guest
                                                            (LightDMGreeter *greeter);
    void                lightdm_greeter_respond             (LightDMGreeter *greeter,
                                                             const gchar *response);
    void                lightdm_greeter_cancel_authentication
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_get_in_authentication
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_get_is_authenticated
                                                            (LightDMGreeter *greeter);
    const gchar *       lightdm_greeter_get_authentication_user
                                                            (LightDMGreeter *greeter);
    gboolean            lightdm_greeter_start_session_sync  (LightDMGreeter *greeter,
                                                             const gchar *session,
                                                             GError **error);

## Description

LightDMGreeter is an object that manages the connection to the LightDM server and provides common greeter functionality.

Example 1. Example Greeter

    int main ()
    {
        GMainLoop *main_loop;
        LightDMGreeter *greeter
        main_loop = g_main_loop_new ();
        greeter = lightdm_greeter_new ();
        g_object_connect (greeter, "show-prompt", G_CALLBACK (show_prompt_cb), NULL);
        g_object_connect (greeter, "authentication-complete", G_CALLBACK (authentication_complete_cb), NULL);
        // Connect to LightDM daemon
        if (!lightdm_greeter_connect_sync (greeter, NULL))
            return EXIT_FAILURE;
        // Start authentication
        lightdm_greeter_authenticate (greeter, NULL);
        g_main_loop_run (main_loop);
        return EXIT_SUCCESS;
    }
    static void show_prompt_cb (LightDMGreeter *greeter, const char *text, LightDMPromptType type)
    {
        // Show the user the message and prompt for some response
        gchar *secret = prompt_user (text, type);
        // Give the result to the user
        lightdm_greeter_respond (greeter, response);
    }
    static void authentication_complete_cb (LightDMGreeter *greeter)
    {
        // Start the session
        if (!lightdm_greeter_get_is_authenticated (greeter) ||
            !lightdm_greeter_start_session_sync (greeter, NULL))
        {
            // Failed authentication, try again
            lightdm_greeter_authenticate (greeter, NULL);
        }
    }

## Details

### show_message ()

    void                (*show_message)                     (LightDMGreeter *greeter,
                                                             const gchar *text,
                                                             LightDMMessageType type);

### show_prompt ()

    void                (*show_prompt)                      (LightDMGreeter *greeter,
                                                             const gchar *text,
                                                             LightDMPromptType type);

### authentication_complete ()

    void                (*authentication_complete)          (LightDMGreeter *greeter);

### autologin_timer_expired ()

    void                (*autologin_timer_expired)          (LightDMGreeter *greeter);

### enum LightDMMessageType

    typedef enum {
        LIGHTDM_MESSAGE_TYPE_INFO,
        LIGHTDM_MESSAGE_TYPE_ERROR
    } LightDMMessageType;

`LIGHTDM_MESSAGE_TYPE_INFO` | Informational message.
`LIGHTDM_MESSAGE_TYPE_ERROR` | Error message.

### enum LightDMPromptType

    typedef enum {
        LIGHTDM_PROMPT_TYPE_QUESTION,
        LIGHTDM_PROMPT_TYPE_SECRET
    } LightDMPromptType;

`LIGHTDM_PROMPT_TYPE_QUESTION` | Prompt is a question. The information can be shown as it is entered.
`LIGHTDM_PROMPT_TYPE_SECRET` | Prompt is for secret information. The entered information should be obscured so it can't be publically visible.

### lightdm_greeter_new ()

    LightDMGreeter *    lightdm_greeter_new                 (void);

Create a new greeter.

Returns : | the new LightDMGreeter

### lightdm_greeter_connect_sync ()

    gboolean            lightdm_greeter_connect_sync        (LightDMGreeter *greeter,
                                                             GError **error);

Connects the greeter to the display manager. Will block until connected.

`greeter` : | The greeter to connect
`error` : | return location for a GError, or `NULL`
Returns : | TRUE if successfully connected

### lightdm_greeter_get_default_session_hint ()

    const gchar *       lightdm_greeter_get_default_session_hint
                                                            (LightDMGreeter *greeter);

Get the default session to use.

`greeter` : | A LightDMGreeter
Returns : | The session name

### lightdm_greeter_get_hint ()

    const gchar *       lightdm_greeter_get_hint            (LightDMGreeter *greeter,
                                                             const gchar *name);

Get a hint.

`greeter` : | A LightDMGreeter
`name` : | The hint name to query.
Returns : | The value for this hint or NULL if not set.

### lightdm_greeter_get_has_guest_account_hint ()

    gboolean            lightdm_greeter_get_has_guest_account_hint
                                                            (LightDMGreeter *greeter);

Check if guest sessions are supported.

`greeter` : | A LightDMGreeter
Returns : | TRUE if guest sessions are supported.

### lightdm_greeter_get_hide_users_hint ()

    gboolean            lightdm_greeter_get_hide_users_hint (LightDMGreeter *greeter);

Check if user accounts should be shown. If this is TRUE then the list of accounts should be taken from LightDMUserList and displayed in the greeter for the user to choose from. Note that this list can be empty and it is recommended you show a method for the user to enter a username manually.

If this option is shown the greeter should only allow these users to be chosen for login unless the manual login hint is set.

`greeter` : | A LightDMGreeter
Returns : | TRUE if the available users should not be shown.

### lightdm_greeter_get_select_user_hint ()

    const gchar *       lightdm_greeter_get_select_user_hint
                                                            (LightDMGreeter *greeter);

Get the user to select by default.

`greeter` : | A LightDMGreeter
Returns : | A username

### lightdm_greeter_get_select_guest_hint ()

    gboolean            lightdm_greeter_get_select_guest_hint
                                                            (LightDMGreeter *greeter);

Check if the guest account should be selected by default.

`greeter` : | A LightDMGreeter
Returns : | TRUE if the guest account should be selected by default.

### lightdm_greeter_get_autologin_user_hint ()

    const gchar *       lightdm_greeter_get_autologin_user_hint
                                                            (LightDMGreeter *greeter);

Get the user account to automatically logg into when the timer expires.

`greeter` : | A LightDMGreeter
Returns : | The user account to automatically log into.

### lightdm_greeter_get_autologin_guest_hint ()

    gboolean            lightdm_greeter_get_autologin_guest_hint
                                                            (LightDMGreeter *greeter);

Check if the guest account should be automatically logged into when the timer expires.

`greeter` : | A LightDMGreeter
Returns : | TRUE if the guest account should be automatically logged into.

### lightdm_greeter_get_autologin_timeout_hint ()

    gint                lightdm_greeter_get_autologin_timeout_hint
                                                            (LightDMGreeter *greeter);

Get the number of seconds to wait before automaitcally logging in.

`greeter` : | A LightDMGreeter
Returns : | The number of seconds to wait before automatically logging in or 0 for no timeout.

### lightdm_greeter_cancel_autologin ()

    void                lightdm_greeter_cancel_autologin    (LightDMGreeter *greeter);

Cancel the automatic login.

`greeter` : | A LightDMGreeter

### lightdm_greeter_authenticate ()

    void                lightdm_greeter_authenticate        (LightDMGreeter *greeter,
                                                             const gchar *username);

Starts the authentication procedure for a user.

`greeter` : | A LightDMGreeter
`username` : | A username or NULL to prompt for a username. [allow-none]

### lightdm_greeter_authenticate_as_guest ()

    void                lightdm_greeter_authenticate_as_guest
                                                            (LightDMGreeter *greeter);

Starts the authentication procedure for the guest user.

`greeter` : | A LightDMGreeter

### lightdm_greeter_respond ()

    void                lightdm_greeter_respond             (LightDMGreeter *greeter,
                                                             const gchar *response);

Provide response to a prompt. May be one in a series.

`greeter` : | A LightDMGreeter
`response` : | Response to a prompt

### lightdm_greeter_cancel_authentication ()

    void                lightdm_greeter_cancel_authentication
                                                            (LightDMGreeter *greeter);

Cancel the current user authentication.

`greeter` : | A LightDMGreeter

### lightdm_greeter_get_in_authentication ()

    gboolean            lightdm_greeter_get_in_authentication
                                                            (LightDMGreeter *greeter);

Checks if the greeter is in the process of authenticating.

`greeter` : | A LightDMGreeter
Returns : | TRUE if the greeter is authenticating a user.

### lightdm_greeter_get_is_authenticated ()

    gboolean            lightdm_greeter_get_is_authenticated
                                                            (LightDMGreeter *greeter);

Checks if the greeter has successfully authenticated.

`greeter` : | A LightDMGreeter
Returns : | TRUE if the greeter is authenticated for login.

### lightdm_greeter_get_authentication_user ()

    const gchar *       lightdm_greeter_get_authentication_user
                                                            (LightDMGreeter *greeter);

Get the user that is being authenticated.

`greeter` : | A LightDMGreeter
Returns : | The username of the authentication user being authenticated or NULL if no authentication in progress.

### lightdm_greeter_start_session_sync ()

    gboolean            lightdm_greeter_start_session_sync  (LightDMGreeter *greeter,
                                                             const gchar *session,
                                                             GError **error);

Start a session for the authenticated user.

`greeter` : | A LightDMGreeter
`session` : | The session to log into or NULL to use the default. [allow-none]
`error` : | return location for a GError, or `NULL`
Returns : | TRUE if the session was started.