~lightdm-team/lightdm/1.4

« back to all changes in this revision

Viewing changes to greeters/ldm-webkit-greeter.c

  • Committer: robert.ancell at canonical
  • Date: 2011-02-12 00:49:20 UTC
  • Revision ID: robert.ancell@canonical.com-20110212004920-iqo8q7u0g5w2l5hc
Move Webkit greeter into separate module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2010 Robert Ancell.
3
 
 * Author: Robert Ancell <robert.ancell@canonical.com>
4
 
 *
5
 
 * This program is free software: you can redistribute it and/or modify it under
6
 
 * the terms of the GNU General Public License as published by the Free Software
7
 
 * Foundation, either version 3 of the License, or (at your option) any later
8
 
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
9
 
 * license.
10
 
 */
11
 
 
12
 
#include <stdlib.h>
13
 
#include <gtk/gtk.h>
14
 
#include <webkit/webkit.h>
15
 
#include <JavaScriptCore/JavaScript.h>
16
 
#include <glib/gi18n.h>
17
 
 
18
 
#include "greeter.h"
19
 
 
20
 
static JSClassRef gettext_class, ldm_greeter_class, ldm_user_class, ldm_language_class, ldm_layout_class, ldm_session_class;
21
 
 
22
 
static GtkWidget *window;
23
 
 
24
 
static void
25
 
show_prompt_cb (LdmGreeter *greeter, const gchar *text, WebKitWebView *view)
26
 
{
27
 
    gchar *command;
28
 
 
29
 
    command = g_strdup_printf ("show_prompt('%s')", text); // FIXME: Escape text
30
 
    webkit_web_view_execute_script (view, command);
31
 
    g_free (command);
32
 
}
33
 
 
34
 
static void
35
 
show_message_cb (LdmGreeter *greeter, const gchar *text, WebKitWebView *view)
36
 
{
37
 
    gchar *command;
38
 
 
39
 
    command = g_strdup_printf ("show_message('%s')", text); // FIXME: Escape text
40
 
    webkit_web_view_execute_script (view, command);
41
 
    g_free (command);
42
 
}
43
 
 
44
 
static void
45
 
authentication_complete_cb (LdmGreeter *greeter, WebKitWebView *view)
46
 
{
47
 
    webkit_web_view_execute_script (view, "authentication_complete()");
48
 
}
49
 
 
50
 
static void
51
 
timed_login_cb (LdmGreeter *greeter, const gchar *username, WebKitWebView *view)
52
 
{
53
 
    gchar *command;
54
 
 
55
 
    command = g_strdup_printf ("timed_login('%s')", username); // FIXME: Escape text
56
 
    webkit_web_view_execute_script (view, command);
57
 
    g_free (command);
58
 
}
59
 
 
60
 
static gboolean
61
 
fade_timer_cb (gpointer data)
62
 
{
63
 
    gdouble opacity;
64
 
 
65
 
    opacity = gtk_window_get_opacity (GTK_WINDOW (window));
66
 
    opacity -= 0.1;
67
 
    if (opacity <= 0)
68
 
    {
69
 
        gtk_main_quit ();
70
 
        return FALSE;
71
 
    }
72
 
    gtk_window_set_opacity (GTK_WINDOW (window), opacity);
73
 
 
74
 
    return TRUE;
75
 
}
76
 
 
77
 
static void
78
 
quit_cb (LdmGreeter *greeter, const gchar *username)
79
 
{
80
 
    /* Fade out the greeter */
81
 
    g_timeout_add (40, (GSourceFunc) fade_timer_cb, NULL);
82
 
}
83
 
 
84
 
static JSValueRef
85
 
get_user_name_cb (JSContextRef context,
86
 
                  JSObjectRef thisObject,
87
 
                  JSStringRef propertyName,
88
 
                  JSValueRef *exception)
89
 
{
90
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
91
 
    JSStringRef string;
92
 
 
93
 
    string = JSStringCreateWithUTF8CString (ldm_user_get_name (user));
94
 
    return JSValueMakeString (context, string);
95
 
}
96
 
 
97
 
static JSValueRef
98
 
get_user_real_name_cb (JSContextRef context,
99
 
                       JSObjectRef thisObject,
100
 
                       JSStringRef propertyName,
101
 
                       JSValueRef *exception)
102
 
{
103
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
104
 
    JSStringRef string;
105
 
 
106
 
    string = JSStringCreateWithUTF8CString (ldm_user_get_real_name (user));
107
 
    return JSValueMakeString (context, string);
108
 
}
109
 
 
110
 
static JSValueRef
111
 
get_user_display_name_cb (JSContextRef context,
112
 
                          JSObjectRef thisObject,
113
 
                          JSStringRef propertyName,
114
 
                          JSValueRef *exception)
115
 
{
116
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
117
 
    JSStringRef string;
118
 
 
119
 
    string = JSStringCreateWithUTF8CString (ldm_user_get_display_name (user));
120
 
    return JSValueMakeString (context, string);
121
 
}
122
 
 
123
 
static JSValueRef
124
 
get_user_image_cb (JSContextRef context,
125
 
                   JSObjectRef thisObject,
126
 
                   JSStringRef propertyName,
127
 
                   JSValueRef *exception)
128
 
{
129
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
130
 
    JSStringRef string;
131
 
 
132
 
    string = JSStringCreateWithUTF8CString (ldm_user_get_image (user));
133
 
    return JSValueMakeString (context, string);
134
 
}
135
 
 
136
 
static JSValueRef
137
 
get_user_language_cb (JSContextRef context,
138
 
                      JSObjectRef thisObject,
139
 
                      JSStringRef propertyName,
140
 
                      JSValueRef *exception)
141
 
{
142
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
143
 
    const gchar *language = ldm_user_get_language (user);
144
 
    JSStringRef string;
145
 
 
146
 
    if (!language)
147
 
        return JSValueMakeNull (context);
148
 
 
149
 
    string = JSStringCreateWithUTF8CString (language);
150
 
    return JSValueMakeString (context, string);
151
 
}
152
 
 
153
 
static JSValueRef
154
 
get_user_layout_cb (JSContextRef context,
155
 
                    JSObjectRef thisObject,
156
 
                    JSStringRef propertyName,
157
 
                    JSValueRef *exception)
158
 
{
159
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
160
 
    const gchar *layout = ldm_user_get_layout (user);
161
 
    JSStringRef string;
162
 
 
163
 
    if (!layout)
164
 
        return JSValueMakeNull (context);
165
 
 
166
 
    string = JSStringCreateWithUTF8CString (layout);
167
 
    return JSValueMakeString (context, string);
168
 
}
169
 
 
170
 
static JSValueRef
171
 
get_user_session_cb (JSContextRef context,
172
 
                     JSObjectRef thisObject,
173
 
                     JSStringRef propertyName,
174
 
                     JSValueRef *exception)
175
 
{
176
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
177
 
    const gchar *session = ldm_user_get_session (user);
178
 
    JSStringRef string;
179
 
 
180
 
    if (!session)
181
 
        return JSValueMakeNull (context);
182
 
 
183
 
    string = JSStringCreateWithUTF8CString (session);
184
 
    return JSValueMakeString (context, string);
185
 
}
186
 
 
187
 
static JSValueRef
188
 
get_user_logged_in_cb (JSContextRef context,
189
 
                       JSObjectRef thisObject,
190
 
                       JSStringRef propertyName,
191
 
                       JSValueRef *exception)
192
 
{
193
 
    LdmUser *user = JSObjectGetPrivate (thisObject);
194
 
    return JSValueMakeBoolean (context, ldm_user_get_logged_in (user));
195
 
}
196
 
 
197
 
static JSValueRef
198
 
get_language_code_cb (JSContextRef context,
199
 
                      JSObjectRef thisObject,
200
 
                      JSStringRef propertyName,
201
 
                      JSValueRef *exception)
202
 
{
203
 
    LdmLanguage *language = JSObjectGetPrivate (thisObject);
204
 
    JSStringRef string;
205
 
 
206
 
    string = JSStringCreateWithUTF8CString (ldm_language_get_code (language));
207
 
    return JSValueMakeString (context, string);
208
 
}
209
 
 
210
 
static JSValueRef
211
 
get_language_name_cb (JSContextRef context,
212
 
                      JSObjectRef thisObject,
213
 
                      JSStringRef propertyName,
214
 
                      JSValueRef *exception)
215
 
{
216
 
    LdmLanguage *language = JSObjectGetPrivate (thisObject);
217
 
    JSStringRef string;
218
 
 
219
 
    string = JSStringCreateWithUTF8CString (ldm_language_get_name (language));
220
 
    return JSValueMakeString (context, string);
221
 
}
222
 
 
223
 
static JSValueRef
224
 
get_language_territory_cb (JSContextRef context,
225
 
                           JSObjectRef thisObject,
226
 
                           JSStringRef propertyName,
227
 
                           JSValueRef *exception)
228
 
{
229
 
    LdmLanguage *language = JSObjectGetPrivate (thisObject);
230
 
    JSStringRef string;
231
 
 
232
 
    string = JSStringCreateWithUTF8CString (ldm_language_get_territory (language));
233
 
    return JSValueMakeString (context, string);
234
 
}
235
 
 
236
 
static JSValueRef
237
 
get_layout_name_cb (JSContextRef context,
238
 
                    JSObjectRef thisObject,
239
 
                    JSStringRef propertyName,
240
 
                    JSValueRef *exception)
241
 
{
242
 
    LdmLayout *layout = JSObjectGetPrivate (thisObject);
243
 
    JSStringRef string;
244
 
 
245
 
    string = JSStringCreateWithUTF8CString (ldm_layout_get_name (layout));
246
 
    return JSValueMakeString (context, string);
247
 
}
248
 
 
249
 
static JSValueRef
250
 
get_layout_short_description_cb (JSContextRef context,
251
 
                                 JSObjectRef thisObject,
252
 
                                 JSStringRef propertyName,
253
 
                                 JSValueRef *exception)
254
 
{
255
 
    LdmLayout *layout = JSObjectGetPrivate (thisObject);
256
 
    JSStringRef string;
257
 
 
258
 
    string = JSStringCreateWithUTF8CString (ldm_layout_get_short_description (layout));
259
 
    return JSValueMakeString (context, string);
260
 
}
261
 
 
262
 
static JSValueRef
263
 
get_layout_description_cb (JSContextRef context,
264
 
                           JSObjectRef thisObject,
265
 
                           JSStringRef propertyName,
266
 
                           JSValueRef *exception)
267
 
{
268
 
    LdmLayout *layout = JSObjectGetPrivate (thisObject);
269
 
    JSStringRef string;
270
 
 
271
 
    string = JSStringCreateWithUTF8CString (ldm_layout_get_description (layout));
272
 
    return JSValueMakeString (context, string);
273
 
}
274
 
 
275
 
static JSValueRef
276
 
get_session_key_cb (JSContextRef context,
277
 
                    JSObjectRef thisObject,
278
 
                    JSStringRef propertyName,
279
 
                    JSValueRef *exception)
280
 
{
281
 
    LdmSession *session = JSObjectGetPrivate (thisObject);
282
 
    JSStringRef string;
283
 
 
284
 
    string = JSStringCreateWithUTF8CString (ldm_session_get_key (session));
285
 
    return JSValueMakeString (context, string);
286
 
 
287
 
}
288
 
static JSValueRef
289
 
get_session_name_cb (JSContextRef context,
290
 
                     JSObjectRef thisObject,
291
 
                     JSStringRef propertyName,
292
 
                     JSValueRef *exception)
293
 
{
294
 
    LdmSession *session = JSObjectGetPrivate (thisObject);
295
 
    JSStringRef string;
296
 
 
297
 
    string = JSStringCreateWithUTF8CString (ldm_session_get_name (session));
298
 
    return JSValueMakeString (context, string);
299
 
}
300
 
 
301
 
static JSValueRef
302
 
get_session_comment_cb (JSContextRef context,
303
 
                        JSObjectRef thisObject,
304
 
                        JSStringRef propertyName,
305
 
                        JSValueRef *exception)
306
 
{
307
 
    LdmSession *session = JSObjectGetPrivate (thisObject);
308
 
    JSStringRef string;
309
 
 
310
 
    string = JSStringCreateWithUTF8CString (ldm_session_get_comment (session));
311
 
    return JSValueMakeString (context, string);
312
 
}
313
 
 
314
 
static JSValueRef
315
 
get_hostname_cb (JSContextRef context,
316
 
                 JSObjectRef thisObject,
317
 
                 JSStringRef propertyName,
318
 
                 JSValueRef *exception)
319
 
{
320
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
321
 
    JSStringRef string;
322
 
 
323
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_hostname (greeter));
324
 
 
325
 
    return JSValueMakeString (context, string);
326
 
}
327
 
 
328
 
static JSValueRef
329
 
get_num_users_cb (JSContextRef context,
330
 
                  JSObjectRef thisObject,
331
 
                  JSStringRef propertyName,
332
 
                  JSValueRef *exception)
333
 
{
334
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
335
 
    gint num_users;
336
 
 
337
 
    num_users = ldm_greeter_get_num_users (greeter);
338
 
    return JSValueMakeNumber (context, num_users);
339
 
}
340
 
 
341
 
static JSValueRef
342
 
get_users_cb (JSContextRef context,
343
 
              JSObjectRef thisObject,
344
 
              JSStringRef propertyName,
345
 
              JSValueRef *exception)
346
 
{
347
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
348
 
    JSObjectRef array;
349
 
    const GList *users, *link;
350
 
    guint i, n_users = 0;
351
 
    JSValueRef *args;
352
 
 
353
 
    users = ldm_greeter_get_users (greeter);
354
 
    n_users = g_list_length ((GList *)users);
355
 
    args = g_malloc (sizeof (JSValueRef) * (n_users + 1));
356
 
    for (i = 0, link = users; link; i++, link = link->next)
357
 
    {
358
 
        LdmUser *user = link->data;
359
 
        g_object_ref (user);
360
 
        args[i] = JSObjectMake (context, ldm_user_class, user);
361
 
    }
362
 
 
363
 
    array = JSObjectMakeArray (context, n_users, args, NULL);
364
 
    g_free (args);
365
 
    return array;
366
 
}
367
 
 
368
 
static JSValueRef
369
 
get_languages_cb (JSContextRef context,
370
 
                  JSObjectRef thisObject,
371
 
                  JSStringRef propertyName,
372
 
                  JSValueRef *exception)
373
 
{
374
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
375
 
    JSObjectRef array;
376
 
    const GList *languages, *link;
377
 
    guint i, n_languages = 0;
378
 
    JSValueRef *args;
379
 
 
380
 
    languages = ldm_greeter_get_languages (greeter);
381
 
    n_languages = g_list_length ((GList *)languages);
382
 
    args = g_malloc (sizeof (JSValueRef) * (n_languages + 1));
383
 
    for (i = 0, link = languages; link; i++, link = link->next)
384
 
    {
385
 
        LdmLanguage *language = link->data;
386
 
        g_object_ref (language);
387
 
        args[i] = JSObjectMake (context, ldm_language_class, language);
388
 
    }
389
 
 
390
 
    array = JSObjectMakeArray (context, n_languages, args, NULL);
391
 
    g_free (args);
392
 
    return array;
393
 
}
394
 
 
395
 
static JSValueRef
396
 
get_default_language_cb (JSContextRef context,
397
 
                         JSObjectRef thisObject,
398
 
                         JSStringRef propertyName,
399
 
                         JSValueRef *exception)
400
 
{
401
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
402
 
    JSStringRef string;
403
 
 
404
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_default_language (greeter));
405
 
 
406
 
    return JSValueMakeString (context, string);
407
 
}
408
 
 
409
 
static JSValueRef
410
 
get_default_layout_cb (JSContextRef context,
411
 
                       JSObjectRef thisObject,
412
 
                       JSStringRef propertyName,
413
 
                       JSValueRef *exception)
414
 
{
415
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
416
 
    JSStringRef string;
417
 
 
418
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_default_layout (greeter));
419
 
 
420
 
    return JSValueMakeString (context, string);
421
 
}
422
 
 
423
 
static JSValueRef
424
 
get_layouts_cb (JSContextRef context,
425
 
                JSObjectRef thisObject,
426
 
                JSStringRef propertyName,
427
 
                JSValueRef *exception)
428
 
{
429
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
430
 
    JSObjectRef array;
431
 
    const GList *layouts, *link;
432
 
    guint i, n_layouts = 0;
433
 
    JSValueRef *args;
434
 
 
435
 
    layouts = ldm_greeter_get_layouts (greeter);
436
 
    n_layouts = g_list_length ((GList *)layouts);
437
 
    args = g_malloc (sizeof (JSValueRef) * (n_layouts + 1));
438
 
    for (i = 0, link = layouts; link; i++, link = link->next)
439
 
    {
440
 
        LdmLayout *layout = link->data;
441
 
        g_object_ref (layout);
442
 
        args[i] = JSObjectMake (context, ldm_layout_class, layout);
443
 
    }
444
 
 
445
 
    array = JSObjectMakeArray (context, n_layouts, args, NULL);
446
 
    g_free (args);
447
 
    return array;
448
 
}
449
 
 
450
 
static JSValueRef
451
 
get_layout_cb (JSContextRef context,
452
 
               JSObjectRef thisObject,
453
 
               JSStringRef propertyName,
454
 
               JSValueRef *exception)
455
 
{
456
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
457
 
    JSStringRef string;
458
 
 
459
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_layout (greeter));
460
 
 
461
 
    return JSValueMakeString (context, string);
462
 
}
463
 
 
464
 
static bool
465
 
set_layout_cb (JSContextRef context,
466
 
               JSObjectRef thisObject,
467
 
               JSStringRef propertyName,
468
 
               JSValueRef value,
469
 
               JSValueRef *exception)
470
 
{
471
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
472
 
    JSStringRef layout_arg;
473
 
    char layout[1024];
474
 
 
475
 
    // FIXME: Throw exception
476
 
    if (JSValueGetType (context, value) != kJSTypeString)
477
 
        return false;
478
 
 
479
 
    layout_arg = JSValueToStringCopy (context, value, NULL);
480
 
    JSStringGetUTF8CString (layout_arg, layout, 1024);
481
 
    JSStringRelease (layout_arg);
482
 
 
483
 
    ldm_greeter_set_layout (greeter, layout);
484
 
 
485
 
    return true;
486
 
}
487
 
 
488
 
static JSValueRef
489
 
get_sessions_cb (JSContextRef context,
490
 
                 JSObjectRef thisObject,
491
 
                 JSStringRef propertyName,
492
 
                 JSValueRef *exception)
493
 
{
494
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
495
 
    JSObjectRef array;
496
 
    const GList *sessions, *link;
497
 
    guint i, n_sessions = 0;
498
 
    JSValueRef *args;
499
 
 
500
 
    sessions = ldm_greeter_get_sessions (greeter);
501
 
    n_sessions = g_list_length ((GList *)sessions);
502
 
    args = g_malloc (sizeof (JSValueRef) * (n_sessions + 1));
503
 
    for (i = 0, link = sessions; link; i++, link = link->next)
504
 
    {
505
 
        LdmSession *session = link->data;
506
 
        g_object_ref (session);
507
 
        args[i] = JSObjectMake (context, ldm_session_class, session);
508
 
    }
509
 
 
510
 
    array = JSObjectMakeArray (context, n_sessions, args, NULL);
511
 
    g_free (args);
512
 
    return array;
513
 
}
514
 
 
515
 
static JSValueRef
516
 
get_default_session_cb (JSContextRef context,
517
 
                        JSObjectRef thisObject,
518
 
                        JSStringRef propertyName,
519
 
                        JSValueRef *exception)
520
 
{
521
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
522
 
    JSStringRef string;
523
 
 
524
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_default_session (greeter));
525
 
 
526
 
    return JSValueMakeString (context, string);
527
 
}
528
 
 
529
 
static JSValueRef
530
 
get_timed_login_user_cb (JSContextRef context,
531
 
                         JSObjectRef thisObject,
532
 
                         JSStringRef propertyName,
533
 
                         JSValueRef *exception)
534
 
{
535
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
536
 
    JSStringRef string;
537
 
 
538
 
    string = JSStringCreateWithUTF8CString (ldm_greeter_get_timed_login_user (greeter));
539
 
 
540
 
    return JSValueMakeString (context, string);
541
 
}
542
 
 
543
 
static JSValueRef
544
 
get_timed_login_delay_cb (JSContextRef context,
545
 
                          JSObjectRef thisObject,
546
 
                          JSStringRef propertyName,
547
 
                          JSValueRef *exception)
548
 
{
549
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
550
 
    gint delay;
551
 
 
552
 
    delay = ldm_greeter_get_timed_login_delay (greeter);
553
 
    return JSValueMakeNumber (context, delay);
554
 
}
555
 
 
556
 
static JSValueRef
557
 
get_string_property_cb (JSContextRef context,
558
 
                        JSObjectRef function,
559
 
                        JSObjectRef thisObject,
560
 
                        size_t argumentCount,
561
 
                        const JSValueRef arguments[],
562
 
                        JSValueRef *exception)
563
 
{
564
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
565
 
    JSStringRef name_arg;
566
 
    char name[1024];
567
 
    gchar *value;
568
 
    JSStringRef string;
569
 
 
570
 
    // FIXME: Throw exception
571
 
    if (argumentCount != 1)
572
 
        return JSValueMakeNull (context);
573
 
 
574
 
    name_arg = JSValueToStringCopy (context, arguments[0], NULL);
575
 
    JSStringGetUTF8CString (name_arg, name, 1024);
576
 
    JSStringRelease (name_arg);
577
 
 
578
 
    value = ldm_greeter_get_string_property (greeter, name);
579
 
 
580
 
    if (!value)
581
 
        return JSValueMakeNull (context);
582
 
 
583
 
    string = JSStringCreateWithUTF8CString (value);
584
 
    g_free (value);
585
 
    return JSValueMakeString (context, string);
586
 
}
587
 
 
588
 
static JSValueRef
589
 
get_integer_property_cb (JSContextRef context,
590
 
                         JSObjectRef function,
591
 
                         JSObjectRef thisObject,
592
 
                         size_t argumentCount,
593
 
                         const JSValueRef arguments[],
594
 
                         JSValueRef *exception)
595
 
{
596
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
597
 
    JSStringRef name_arg;
598
 
    char name[1024];
599
 
 
600
 
    // FIXME: Throw exception
601
 
    if (argumentCount != 1)
602
 
        return JSValueMakeNull (context);
603
 
 
604
 
    name_arg = JSValueToStringCopy (context, arguments[0], NULL);
605
 
    JSStringGetUTF8CString (name_arg, name, 1024);
606
 
    JSStringRelease (name_arg);
607
 
 
608
 
    return JSValueMakeNumber (context, ldm_greeter_get_integer_property (greeter, name));
609
 
}
610
 
 
611
 
static JSValueRef
612
 
get_boolean_property_cb (JSContextRef context,
613
 
                         JSObjectRef function,
614
 
                         JSObjectRef thisObject,
615
 
                         size_t argumentCount,
616
 
                         const JSValueRef arguments[],
617
 
                         JSValueRef *exception)
618
 
{
619
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
620
 
    JSStringRef name_arg;
621
 
    char name[1024];
622
 
 
623
 
    // FIXME: Throw exception
624
 
    if (argumentCount != 1)
625
 
        return JSValueMakeNull (context);
626
 
 
627
 
    name_arg = JSValueToStringCopy (context, arguments[0], NULL);
628
 
    JSStringGetUTF8CString (name_arg, name, 1024);
629
 
    JSStringRelease (name_arg);
630
 
 
631
 
    return JSValueMakeBoolean (context, ldm_greeter_get_boolean_property (greeter, name));
632
 
}
633
 
 
634
 
static JSValueRef
635
 
cancel_timed_login_cb (JSContextRef context,
636
 
                       JSObjectRef function,
637
 
                       JSObjectRef thisObject,
638
 
                       size_t argumentCount,
639
 
                       const JSValueRef arguments[],
640
 
                       JSValueRef *exception)
641
 
{
642
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
643
 
 
644
 
    // FIXME: Throw exception
645
 
    if (argumentCount != 0)
646
 
        return JSValueMakeNull (context);
647
 
 
648
 
    ldm_greeter_cancel_timed_login (greeter);
649
 
    return JSValueMakeNull (context);
650
 
}
651
 
 
652
 
static JSValueRef
653
 
start_authentication_cb (JSContextRef context,
654
 
                         JSObjectRef function,
655
 
                         JSObjectRef thisObject,
656
 
                         size_t argumentCount,
657
 
                         const JSValueRef arguments[],
658
 
                         JSValueRef *exception)
659
 
{
660
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
661
 
    JSStringRef name_arg;
662
 
    char name[1024];
663
 
 
664
 
    // FIXME: Throw exception
665
 
    if (!(argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString))
666
 
        return JSValueMakeNull (context);
667
 
 
668
 
    name_arg = JSValueToStringCopy (context, arguments[0], NULL);
669
 
    JSStringGetUTF8CString (name_arg, name, 1024);
670
 
    JSStringRelease (name_arg);
671
 
 
672
 
    ldm_greeter_start_authentication (greeter, name);
673
 
    return JSValueMakeNull (context);
674
 
}
675
 
 
676
 
static JSValueRef
677
 
provide_secret_cb (JSContextRef context,
678
 
                   JSObjectRef function,
679
 
                   JSObjectRef thisObject,
680
 
                   size_t argumentCount,
681
 
                   const JSValueRef arguments[],
682
 
                   JSValueRef *exception)
683
 
{
684
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
685
 
    JSStringRef secret_arg;
686
 
    char secret[1024];
687
 
 
688
 
    // FIXME: Throw exception
689
 
    if (!(argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString))
690
 
        return JSValueMakeNull (context);
691
 
 
692
 
    secret_arg = JSValueToStringCopy (context, arguments[0], NULL);
693
 
    JSStringGetUTF8CString (secret_arg, secret, 1024);
694
 
    JSStringRelease (secret_arg);
695
 
 
696
 
    ldm_greeter_provide_secret (greeter, secret);
697
 
    return JSValueMakeNull (context);
698
 
}
699
 
 
700
 
static JSValueRef
701
 
cancel_authentication_cb (JSContextRef context,
702
 
                          JSObjectRef function,
703
 
                          JSObjectRef thisObject,
704
 
                          size_t argumentCount,
705
 
                          const JSValueRef arguments[],
706
 
                          JSValueRef *exception)
707
 
{
708
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
709
 
 
710
 
    // FIXME: Throw exception
711
 
    if (argumentCount != 0)
712
 
        return JSValueMakeNull (context);
713
 
 
714
 
    ldm_greeter_cancel_authentication (greeter);
715
 
    return JSValueMakeNull (context);
716
 
}
717
 
 
718
 
static JSValueRef
719
 
get_authentication_user_cb (JSContextRef context,
720
 
                            JSObjectRef thisObject,
721
 
                            JSStringRef propertyName,
722
 
                            JSValueRef *exception)
723
 
{
724
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
725
 
    return JSValueMakeString (context, JSStringCreateWithUTF8CString (ldm_greeter_get_authentication_user (greeter)));
726
 
}
727
 
 
728
 
static JSValueRef
729
 
get_is_authenticated_cb (JSContextRef context,
730
 
                         JSObjectRef thisObject,
731
 
                         JSStringRef propertyName,
732
 
                         JSValueRef *exception)
733
 
{
734
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
735
 
    return JSValueMakeBoolean (context, ldm_greeter_get_is_authenticated (greeter));
736
 
}
737
 
 
738
 
static JSValueRef
739
 
get_can_suspend_cb (JSContextRef context,
740
 
                    JSObjectRef thisObject,
741
 
                    JSStringRef propertyName,
742
 
                    JSValueRef *exception)
743
 
{
744
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
745
 
    return JSValueMakeBoolean (context, ldm_greeter_get_can_suspend (greeter));
746
 
}
747
 
 
748
 
static JSValueRef
749
 
suspend_cb (JSContextRef context,
750
 
            JSObjectRef function,
751
 
            JSObjectRef thisObject,
752
 
            size_t argumentCount,
753
 
            const JSValueRef arguments[],
754
 
            JSValueRef *exception)
755
 
{
756
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
757
 
 
758
 
    // FIXME: Throw exception
759
 
    if (argumentCount != 0)
760
 
        return JSValueMakeNull (context);
761
 
 
762
 
    ldm_greeter_suspend (greeter);
763
 
    return JSValueMakeNull (context);
764
 
}
765
 
 
766
 
static JSValueRef
767
 
get_can_hibernate_cb (JSContextRef context,
768
 
                      JSObjectRef thisObject,
769
 
                      JSStringRef propertyName,
770
 
                      JSValueRef *exception)
771
 
{
772
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
773
 
    return JSValueMakeBoolean (context, ldm_greeter_get_can_hibernate (greeter));
774
 
}
775
 
 
776
 
static JSValueRef
777
 
hibernate_cb (JSContextRef context,
778
 
              JSObjectRef function,
779
 
              JSObjectRef thisObject,
780
 
              size_t argumentCount,
781
 
              const JSValueRef arguments[],
782
 
              JSValueRef *exception)
783
 
{
784
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
785
 
 
786
 
    // FIXME: Throw exception
787
 
    if (argumentCount != 0)
788
 
        return JSValueMakeNull (context);
789
 
 
790
 
    ldm_greeter_hibernate (greeter);
791
 
    return JSValueMakeNull (context);
792
 
}
793
 
 
794
 
static JSValueRef
795
 
get_can_restart_cb (JSContextRef context,
796
 
                    JSObjectRef thisObject,
797
 
                    JSStringRef propertyName,
798
 
                    JSValueRef *exception)
799
 
{
800
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
801
 
    return JSValueMakeBoolean (context, ldm_greeter_get_can_restart (greeter));
802
 
}
803
 
 
804
 
static JSValueRef
805
 
restart_cb (JSContextRef context,
806
 
            JSObjectRef function,
807
 
            JSObjectRef thisObject,
808
 
            size_t argumentCount,
809
 
            const JSValueRef arguments[],
810
 
            JSValueRef *exception)
811
 
{
812
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
813
 
 
814
 
    // FIXME: Throw exception
815
 
    if (argumentCount != 0)
816
 
        return JSValueMakeNull (context);
817
 
 
818
 
    ldm_greeter_restart (greeter);
819
 
    return JSValueMakeNull (context);
820
 
}
821
 
 
822
 
static JSValueRef
823
 
get_can_shutdown_cb (JSContextRef context,
824
 
                     JSObjectRef thisObject,
825
 
                     JSStringRef propertyName,
826
 
                     JSValueRef *exception)
827
 
{
828
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
829
 
    return JSValueMakeBoolean (context, ldm_greeter_get_can_shutdown (greeter));
830
 
}
831
 
 
832
 
static JSValueRef
833
 
shutdown_cb (JSContextRef context,
834
 
             JSObjectRef function,
835
 
             JSObjectRef thisObject,
836
 
             size_t argumentCount,
837
 
             const JSValueRef arguments[],
838
 
             JSValueRef *exception)
839
 
{
840
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
841
 
 
842
 
    // FIXME: Throw exception
843
 
    if (argumentCount != 0)
844
 
        return JSValueMakeNull (context);
845
 
 
846
 
    ldm_greeter_shutdown (greeter);
847
 
    return JSValueMakeNull (context);
848
 
}
849
 
 
850
 
static JSValueRef
851
 
login_cb (JSContextRef context,
852
 
          JSObjectRef function,
853
 
          JSObjectRef thisObject,
854
 
          size_t argumentCount,
855
 
          const JSValueRef arguments[],
856
 
          JSValueRef *exception)
857
 
{
858
 
    LdmGreeter *greeter = JSObjectGetPrivate (thisObject);
859
 
    JSStringRef arg;
860
 
    char username[1024], *session = NULL, *language = NULL;
861
 
 
862
 
    // FIXME: Throw exception
863
 
    if (argumentCount < 1 || argumentCount > 3)
864
 
        return JSValueMakeNull (context);
865
 
 
866
 
    arg = JSValueToStringCopy (context, arguments[0], NULL);
867
 
    JSStringGetUTF8CString (arg, username, 1024);
868
 
    JSStringRelease (arg);
869
 
 
870
 
    if (argumentCount > 1)
871
 
    {
872
 
        arg = JSValueToStringCopy (context, arguments[1], NULL);
873
 
        session = g_malloc (sizeof (char) * 1024);
874
 
        JSStringGetUTF8CString (arg, session, 1024);
875
 
        JSStringRelease (arg);
876
 
    }
877
 
 
878
 
    if (argumentCount > 2)
879
 
    {
880
 
        arg = JSValueToStringCopy (context, arguments[1], NULL);
881
 
        language = g_malloc (sizeof (char) * 1024);
882
 
        JSStringGetUTF8CString (arg, language, 1024);
883
 
        JSStringRelease (arg);
884
 
    }
885
 
 
886
 
    ldm_greeter_login (greeter, username, session, language);
887
 
    g_free (session);
888
 
    g_free (language);
889
 
 
890
 
    return JSValueMakeNull (context);
891
 
}
892
 
 
893
 
static JSValueRef
894
 
gettext_cb (JSContextRef context,
895
 
            JSObjectRef function,
896
 
            JSObjectRef thisObject,
897
 
            size_t argumentCount,
898
 
            const JSValueRef arguments[],
899
 
            JSValueRef *exception)
900
 
{
901
 
    JSStringRef string_arg, result;
902
 
    char string[1024];
903
 
 
904
 
    // FIXME: Throw exception
905
 
    if (argumentCount != 1)
906
 
        return JSValueMakeNull (context);
907
 
 
908
 
    string_arg = JSValueToStringCopy (context, arguments[0], NULL);
909
 
    JSStringGetUTF8CString (string_arg, string, 1024);
910
 
    JSStringRelease (string_arg);
911
 
 
912
 
    result = JSStringCreateWithUTF8CString (gettext (string));
913
 
    return JSValueMakeString (context, result);
914
 
}
915
 
 
916
 
static JSValueRef
917
 
ngettext_cb (JSContextRef context,
918
 
             JSObjectRef function,
919
 
             JSObjectRef thisObject,
920
 
             size_t argumentCount,
921
 
             const JSValueRef arguments[],
922
 
             JSValueRef *exception)
923
 
{
924
 
    JSStringRef string_arg, plural_string_arg, result;
925
 
    char string[1024], plural_string[1024];
926
 
    unsigned int n;
927
 
 
928
 
    // FIXME: Throw exception
929
 
    if (argumentCount != 3)
930
 
        return JSValueMakeNull (context);
931
 
 
932
 
    string_arg = JSValueToStringCopy (context, arguments[0], NULL);
933
 
    JSStringGetUTF8CString (string_arg, string, 1024);
934
 
    JSStringRelease (string_arg);
935
 
 
936
 
    plural_string_arg = JSValueToStringCopy (context, arguments[1], NULL);
937
 
    JSStringGetUTF8CString (plural_string_arg, string, 1024);
938
 
    JSStringRelease (plural_string_arg);
939
 
 
940
 
    n = JSValueToNumber (context, arguments[2], NULL);
941
 
 
942
 
    result = JSStringCreateWithUTF8CString (ngettext (string, plural_string, n));
943
 
    return JSValueMakeString (context, result);
944
 
}
945
 
 
946
 
static const JSStaticValue ldm_user_values[] =
947
 
{
948
 
    { "name", get_user_name_cb, NULL, kJSPropertyAttributeReadOnly },
949
 
    { "real_name", get_user_real_name_cb, NULL, kJSPropertyAttributeReadOnly },
950
 
    { "display_name", get_user_display_name_cb, NULL, kJSPropertyAttributeReadOnly },
951
 
    { "image", get_user_image_cb, NULL, kJSPropertyAttributeReadOnly },
952
 
    { "language", get_user_language_cb, NULL, kJSPropertyAttributeReadOnly },
953
 
    { "layout", get_user_layout_cb, NULL, kJSPropertyAttributeReadOnly },
954
 
    { "session", get_user_session_cb, NULL, kJSPropertyAttributeReadOnly },
955
 
    { "logged_in", get_user_logged_in_cb, NULL, kJSPropertyAttributeReadOnly },
956
 
    { NULL, NULL, NULL, 0 }
957
 
};
958
 
 
959
 
static const JSStaticValue ldm_language_values[] =
960
 
{
961
 
    { "code", get_language_code_cb, NULL, kJSPropertyAttributeReadOnly },
962
 
    { "name", get_language_name_cb, NULL, kJSPropertyAttributeReadOnly },
963
 
    { "territory", get_language_territory_cb, NULL, kJSPropertyAttributeReadOnly },
964
 
    { NULL, NULL, NULL, 0 }
965
 
};
966
 
 
967
 
static const JSStaticValue ldm_layout_values[] =
968
 
{
969
 
    { "name", get_layout_name_cb, NULL, kJSPropertyAttributeReadOnly },
970
 
    { "short_description", get_layout_short_description_cb, NULL, kJSPropertyAttributeReadOnly },
971
 
    { "description", get_layout_description_cb, NULL, kJSPropertyAttributeReadOnly },
972
 
    { NULL, NULL, NULL, 0 }
973
 
};
974
 
 
975
 
static const JSStaticValue ldm_session_values[] =
976
 
{
977
 
    { "key", get_session_key_cb, NULL, kJSPropertyAttributeReadOnly },
978
 
    { "name", get_session_name_cb, NULL, kJSPropertyAttributeReadOnly },
979
 
    { "comment", get_session_comment_cb, NULL, kJSPropertyAttributeReadOnly },
980
 
    { NULL, NULL, NULL, 0 }
981
 
};
982
 
 
983
 
static const JSStaticValue ldm_greeter_values[] =
984
 
{
985
 
    { "hostname", get_hostname_cb, NULL, kJSPropertyAttributeReadOnly },
986
 
    { "users", get_users_cb, NULL, kJSPropertyAttributeReadOnly },
987
 
    { "default_language", get_default_language_cb, NULL, kJSPropertyAttributeReadOnly },
988
 
    { "languages", get_languages_cb, NULL, kJSPropertyAttributeReadOnly },
989
 
    { "default_layout", get_default_layout_cb, NULL, kJSPropertyAttributeReadOnly },
990
 
    { "layouts", get_layouts_cb, NULL, kJSPropertyAttributeReadOnly },
991
 
    { "layout", get_layout_cb, set_layout_cb, kJSPropertyAttributeReadOnly },
992
 
    { "sessions", get_sessions_cb, NULL, kJSPropertyAttributeReadOnly },
993
 
    { "num_users", get_num_users_cb, NULL, kJSPropertyAttributeReadOnly },
994
 
    { "default_session", get_default_session_cb, NULL, kJSPropertyAttributeNone },
995
 
    { "timed_login_user", get_timed_login_user_cb, NULL, kJSPropertyAttributeReadOnly },
996
 
    { "timed_login_delay", get_timed_login_delay_cb, NULL, kJSPropertyAttributeReadOnly },
997
 
    { "authentication_user", get_authentication_user_cb, NULL, kJSPropertyAttributeReadOnly },
998
 
    { "is_authenticated", get_is_authenticated_cb, NULL, kJSPropertyAttributeReadOnly },
999
 
    { "can_suspend", get_can_suspend_cb, NULL, kJSPropertyAttributeReadOnly },
1000
 
    { "can_hibernate", get_can_hibernate_cb, NULL, kJSPropertyAttributeReadOnly },
1001
 
    { "can_restart", get_can_restart_cb, NULL, kJSPropertyAttributeReadOnly },
1002
 
    { "can_shutdown", get_can_shutdown_cb, NULL, kJSPropertyAttributeReadOnly },
1003
 
    { NULL, NULL, NULL, 0 }
1004
 
};
1005
 
 
1006
 
static const JSStaticFunction ldm_greeter_functions[] =
1007
 
{
1008
 
    { "get_string_property", get_string_property_cb, kJSPropertyAttributeReadOnly },
1009
 
    { "get_integer_property", get_integer_property_cb, kJSPropertyAttributeReadOnly },
1010
 
    { "get_boolean_property", get_boolean_property_cb, kJSPropertyAttributeReadOnly },
1011
 
    { "cancel_timed_login", cancel_timed_login_cb, kJSPropertyAttributeReadOnly },
1012
 
    { "start_authentication", start_authentication_cb, kJSPropertyAttributeReadOnly },
1013
 
    { "provide_secret", provide_secret_cb, kJSPropertyAttributeReadOnly },
1014
 
    { "cancel_authentication", cancel_authentication_cb, kJSPropertyAttributeReadOnly },
1015
 
    { "suspend", suspend_cb, kJSPropertyAttributeReadOnly },
1016
 
    { "hibernate", hibernate_cb, kJSPropertyAttributeReadOnly },
1017
 
    { "restart", restart_cb, kJSPropertyAttributeReadOnly },
1018
 
    { "shutdown", shutdown_cb, kJSPropertyAttributeReadOnly },
1019
 
    { "login", login_cb, kJSPropertyAttributeReadOnly },
1020
 
    { NULL, NULL, 0 }
1021
 
};
1022
 
 
1023
 
static const JSStaticFunction gettext_functions[] =
1024
 
{
1025
 
    { "gettext", gettext_cb, kJSPropertyAttributeReadOnly },
1026
 
    { "ngettext", ngettext_cb, kJSPropertyAttributeReadOnly },
1027
 
    { NULL, NULL, 0 }
1028
 
};
1029
 
 
1030
 
static const JSClassDefinition ldm_user_definition =
1031
 
{
1032
 
    0,                     /* Version */
1033
 
    kJSClassAttributeNone, /* Attributes */
1034
 
    "LdmUser",             /* Class name */
1035
 
    NULL,                  /* Parent class */
1036
 
    ldm_user_values,       /* Static values */
1037
 
};
1038
 
 
1039
 
static const JSClassDefinition ldm_language_definition =
1040
 
{
1041
 
    0,                     /* Version */
1042
 
    kJSClassAttributeNone, /* Attributes */
1043
 
    "LdmLanguage",         /* Class name */
1044
 
    NULL,                  /* Parent class */
1045
 
    ldm_language_values,   /* Static values */
1046
 
};
1047
 
 
1048
 
static const JSClassDefinition ldm_layout_definition =
1049
 
{
1050
 
    0,                     /* Version */
1051
 
    kJSClassAttributeNone, /* Attributes */
1052
 
    "LdmLayout",           /* Class name */
1053
 
    NULL,                  /* Parent class */
1054
 
    ldm_layout_values,     /* Static values */
1055
 
};
1056
 
 
1057
 
static const JSClassDefinition ldm_session_definition =
1058
 
{
1059
 
    0,                     /* Version */
1060
 
    kJSClassAttributeNone, /* Attributes */
1061
 
    "LdmSession",          /* Class name */
1062
 
    NULL,                  /* Parent class */
1063
 
    ldm_session_values,    /* Static values */
1064
 
};
1065
 
 
1066
 
static const JSClassDefinition ldm_greeter_definition =
1067
 
{
1068
 
    0,                     /* Version */
1069
 
    kJSClassAttributeNone, /* Attributes */
1070
 
    "LdmGreeter",          /* Class name */
1071
 
    NULL,                  /* Parent class */
1072
 
    ldm_greeter_values,    /* Static values */
1073
 
    ldm_greeter_functions, /* Static functions */
1074
 
};
1075
 
 
1076
 
static const JSClassDefinition gettext_definition =
1077
 
{
1078
 
    0,                     /* Version */
1079
 
    kJSClassAttributeNone, /* Attributes */
1080
 
    "GettextClass",        /* Class name */
1081
 
    NULL,                  /* Parent class */
1082
 
    NULL,
1083
 
    gettext_functions,     /* Static functions */
1084
 
};
1085
 
 
1086
 
static void
1087
 
window_object_cleared_cb (WebKitWebView  *web_view,
1088
 
                          WebKitWebFrame *frame,
1089
 
                          JSGlobalContextRef context,
1090
 
                          JSObjectRef window_object,
1091
 
                          LdmGreeter *greeter)
1092
 
{
1093
 
    JSObjectRef gettext_object, ldm_greeter_object;
1094
 
 
1095
 
    gettext_class = JSClassCreate (&gettext_definition);
1096
 
    ldm_greeter_class = JSClassCreate (&ldm_greeter_definition);
1097
 
    ldm_user_class = JSClassCreate (&ldm_user_definition);
1098
 
    ldm_language_class = JSClassCreate (&ldm_language_definition);
1099
 
    ldm_layout_class = JSClassCreate (&ldm_layout_definition);
1100
 
    ldm_session_class = JSClassCreate (&ldm_session_definition);
1101
 
 
1102
 
    gettext_object = JSObjectMake (context, gettext_class, NULL);
1103
 
    JSObjectSetProperty (context,
1104
 
                         JSContextGetGlobalObject (context),
1105
 
                         JSStringCreateWithUTF8CString ("gettext"),
1106
 
                         gettext_object, kJSPropertyAttributeNone, NULL);
1107
 
 
1108
 
    ldm_greeter_object = JSObjectMake (context, ldm_greeter_class, greeter);
1109
 
    JSObjectSetProperty (context,
1110
 
                         JSContextGetGlobalObject (context),
1111
 
                         JSStringCreateWithUTF8CString ("lightdm"),
1112
 
                         ldm_greeter_object, kJSPropertyAttributeNone, NULL);
1113
 
}
1114
 
 
1115
 
static void
1116
 
sigterm_cb (int signum)
1117
 
{
1118
 
    exit (0);
1119
 
}
1120
 
 
1121
 
int
1122
 
main(int argc, char **argv)
1123
 
{
1124
 
    LdmGreeter *greeter;
1125
 
    GdkDisplay *display;
1126
 
    GdkScreen *screen;
1127
 
    gint screen_width, screen_height;
1128
 
    GtkWidget *web_view;
1129
 
    gchar *url;
1130
 
 
1131
 
    signal (SIGTERM, sigterm_cb);
1132
 
 
1133
 
    gtk_init (&argc, &argv);
1134
 
 
1135
 
    if (argc != 2) {
1136
 
        g_printerr ("Usage: %s <url>\n", argv[0]);
1137
 
        return 1;
1138
 
    }
1139
 
    url = argv[1];
1140
 
 
1141
 
    greeter = ldm_greeter_new ();
1142
 
 
1143
 
    display = gdk_display_get_default ();
1144
 
    screen = gdk_display_get_default_screen (display);
1145
 
    screen_width = gdk_screen_get_width (screen);
1146
 
    screen_height = gdk_screen_get_height (screen);
1147
 
 
1148
 
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1149
 
    gtk_window_set_default_size (GTK_WINDOW (window), screen_width, screen_height);
1150
 
    gtk_window_fullscreen (GTK_WINDOW (window));
1151
 
 
1152
 
    web_view = webkit_web_view_new ();
1153
 
    g_signal_connect (G_OBJECT (web_view), "window-object-cleared", G_CALLBACK (window_object_cleared_cb), greeter);
1154
 
    gtk_container_add (GTK_CONTAINER (window), web_view);
1155
 
 
1156
 
    g_signal_connect (G_OBJECT (greeter), "show-prompt", G_CALLBACK (show_prompt_cb), web_view);
1157
 
    g_signal_connect (G_OBJECT (greeter), "show-message", G_CALLBACK (show_message_cb), web_view);
1158
 
    g_signal_connect (G_OBJECT (greeter), "show-error", G_CALLBACK (show_message_cb), web_view);
1159
 
    g_signal_connect (G_OBJECT (greeter), "authentication-complete", G_CALLBACK (authentication_complete_cb), web_view);
1160
 
    g_signal_connect (G_OBJECT (greeter), "timed-login", G_CALLBACK (timed_login_cb), web_view);
1161
 
    g_signal_connect (G_OBJECT (greeter), "quit", G_CALLBACK (quit_cb), web_view);
1162
 
 
1163
 
    webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), url);
1164
 
    ldm_greeter_connect (greeter);
1165
 
 
1166
 
    gtk_widget_show_all (window);
1167
 
 
1168
 
    gtk_main ();
1169
 
 
1170
 
    return 0;
1171
 
}