Beispiel #1
0
LightDMSession*
find_session_by_key(const gchar *key)
{
    LightDMSession *ret = NULL;
    guint i;

    if (sessions == NULL) {
        sessions = lightdm_get_sessions ();
    }

    for (i = 0; i < g_list_length (sessions); i++) {
        LightDMSession *session = (LightDMSession *)g_list_nth_data(sessions,
                                                                    i);

        if (session != NULL) {
            gchar *session_key = g_strdup(lightdm_session_get_key(session));
            if (g_strcmp0 (key, session_key) == 0) {
                ret = session;
            } else {
                continue;
            }
            g_free (session_key);

        } else {
            continue;
        }
    }

    return ret;
}
Beispiel #2
0
JS_EXPORT_API
JSObjectRef greeter_get_sessions ()
{
    JSObjectRef array = json_array_create ();

    guint i;

    if (sessions == NULL) {
        sessions = lightdm_get_sessions ();
    }

    for (i = 0; i < g_list_length (sessions); ++i) {
        gchar *key = NULL;
        LightDMSession *session = (LightDMSession *)g_list_nth_data(sessions,
                                                                    i);

        key = g_strdup (lightdm_session_get_key (session));
        json_array_insert(array, i, jsvalue_from_cstr(get_global_context(),
                                                      g_strdup(key)));

        g_free (key);
    }

    return array;
}
Beispiel #3
0
JS_EXPORT_API
gchar* greeter_get_default_session ()
{
    gchar *key = NULL;

    extern LightDMGreeter *greeter;
    guint i;

    gchar* session_name = g_strdup(
        lightdm_greeter_get_default_session_hint(greeter));
    if (session_name != NULL) {
        if (sessions == NULL) {
            sessions = lightdm_get_sessions ();
        }

        for (i = 0; i < g_list_length (sessions); ++i) {
            LightDMSession *session = (LightDMSession *)g_list_nth_data(
                sessions, i);
            gchar *name = g_strdup (lightdm_session_get_name (session));

            if (g_strcmp0 (session_name, name) == 0) {
                key = g_strdup (lightdm_session_get_key (session));
                g_free (name);
                break;

            } else {
                g_free (name);
                continue;
            }
        }
    }
    g_free (session_name);

    return key;
}
static JSValueRef
get_session_key_cb(JSContextRef context,
				   JSObjectRef thisObject,
				   JSStringRef propertyName,
				   JSValueRef *exception) {
	return string_or_null(context, lightdm_session_get_key(SESSION));
}