185
187
gdm_chooser_host_dispose (GdmChooserHost *host)
190
if (host->picture != NULL)
191
g_object_unref (G_OBJECT (host->picture));
192
host->picture = NULL;
192
if (host->picture != NULL)
193
g_object_unref (G_OBJECT (host->picture));
194
host->picture = NULL;
201
static GdmChooserHost *
203
static GdmChooserHost *
202
204
gdm_chooser_host_alloc (const char *hostname,
203
205
const char *description,
206
208
gboolean willing)
208
GdmChooserHost *host;
213
host = g_new0 (GdmChooserHost, 1);
214
host->name = g_strdup (hostname);
215
host->desc = g_strdup (description);
216
host->willing = willing;
210
GdmChooserHost *host;
215
host = g_new0 (GdmChooserHost, 1);
216
host->name = g_strdup (hostname);
217
host->desc = g_strdup (description);
218
host->willing = willing;
217
220
#ifdef ENABLE_IPV6
218
if (family == AF_INET6)
219
memcpy (&host->ia6, (struct in6_addr *)ia, sizeof (struct in6_addr));
221
if (family == AF_INET6)
222
memcpy (&host->ia6, (struct in6_addr *)ia, sizeof (struct in6_addr));
222
memcpy (&host->ia, (struct in_addr *)ia, sizeof (struct in_addr));
224
host->addrtype = family;
225
chooser_hosts = g_list_prepend (chooser_hosts, host);
230
hostimgdir = gdm_config_get_string (GDM_KEY_HOST_IMAGE_DIR);
231
hostimg = g_strconcat (hostimgdir, "/", hostname, NULL);
232
if (g_access (hostimg, R_OK) != 0) {
234
hostimg = g_strconcat (hostimgdir, "/", hostname, ".png", NULL);
237
if (g_access (hostimg, R_OK) == 0 &&
238
(img = gdk_pixbuf_new_from_file (hostimg, NULL)) != NULL) {
239
gint w, h, maxw, maxh;
241
w = gdk_pixbuf_get_width (img);
242
h = gdk_pixbuf_get_height (img);
244
maxw = gdm_config_get_int (GDM_KEY_MAX_ICON_WIDTH);
245
maxh = gdm_config_get_int (GDM_KEY_MAX_ICON_HEIGHT);
247
if (w > h && w > maxw) {
248
h = h * ((gfloat) maxw / w);
250
} else if (h > maxh) {
251
w = w * ((gfloat) maxh / h);
256
if (w != gdk_pixbuf_get_width (img) ||
257
h != gdk_pixbuf_get_height (img))
258
host->picture = gdk_pixbuf_scale_simple (img, w, h,
259
GDK_INTERP_BILINEAR);
261
host->picture = g_object_ref (G_OBJECT (img));
263
g_object_unref (G_OBJECT (img));
264
} else if (defhostimg != NULL) {
265
host->picture = (GdkPixbuf *)g_object_ref (G_OBJECT (defhostimg));
225
memcpy (&host->ia, (struct in_addr *)ia, sizeof (struct in_addr));
227
host->addrtype = family;
228
chooser_hosts = g_list_prepend (chooser_hosts, host);
233
hostimgdir = gdm_config_get_string (GDM_KEY_HOST_IMAGE_DIR);
234
hostimg = g_strconcat (hostimgdir, "/", hostname, NULL);
235
if (g_access (hostimg, R_OK) != 0) {
237
hostimg = g_strconcat (hostimgdir, "/", hostname, ".png", NULL);
240
if (g_access (hostimg, R_OK) == 0 &&
241
(img = gdk_pixbuf_new_from_file (hostimg, NULL)) != NULL) {
242
gint w, h, maxw, maxh;
244
w = gdk_pixbuf_get_width (img);
245
h = gdk_pixbuf_get_height (img);
247
maxw = gdm_config_get_int (GDM_KEY_MAX_ICON_WIDTH);
248
maxh = gdm_config_get_int (GDM_KEY_MAX_ICON_HEIGHT);
250
if (w > h && w > maxw) {
251
h = h * ((gfloat) maxw / w);
253
} else if (h > maxh) {
254
w = w * ((gfloat) maxh / h);
259
if (w != gdk_pixbuf_get_width (img) ||
260
h != gdk_pixbuf_get_height (img))
261
host->picture = gdk_pixbuf_scale_simple (img, w, h,
262
GDK_INTERP_BILINEAR);
264
host->picture = g_object_ref (G_OBJECT (img));
266
g_object_unref (G_OBJECT (img));
267
} else if (defhostimg != NULL) {
268
host->picture = (GdkPixbuf *)g_object_ref (G_OBJECT (defhostimg));
274
277
gdm_chooser_browser_add_host (GdmChooserHost *host)
276
gboolean add_this_host = FALSE;
279
gboolean add_this_host = FALSE;
279
GtkTreeIter iter = {0};
282
GtkTreeIter iter = {0};
283
286
#ifdef ENABLE_IPV6
284
if (host->addrtype == AF_INET6) { /* IPv6 address */
285
static char buffer6[INET6_ADDRSTRLEN];
287
if (host->addrtype == AF_INET6) { /* IPv6 address */
288
static char buffer6[INET6_ADDRSTRLEN];
287
addr = inet_ntop (AF_INET6, host->ia6.s6_addr, buffer6, INET6_ADDRSTRLEN);
289
else /* IPv4 address */
290
addr = inet_ntop (AF_INET6, host->ia6.s6_addr, buffer6, INET6_ADDRSTRLEN);
292
else /* IPv4 address */
292
addr = inet_ntoa (host->ia);
295
name = g_markup_escape_text (host->name, -1);
296
desc = g_markup_escape_text (host->desc, -1);
298
if (strcmp (addr, host->name) == 0)
299
label = g_strdup_printf ("<b>%s</b>\n%s",
303
label = g_strdup_printf ("<b>%s</b> (%s)\n%s",
311
gtk_list_store_append (GTK_LIST_STORE (browser_model), &iter);
312
gtk_list_store_set (GTK_LIST_STORE (browser_model), &iter,
313
CHOOSER_LIST_ICON_COLUMN, host->picture,
314
CHOOSER_LIST_LABEL_COLUMN, label,
315
CHOOSER_LIST_HOST_COLUMN, host,
295
addr = inet_ntoa (host->ia);
298
name = g_markup_escape_text (host->name, -1);
299
desc = g_markup_escape_text (host->desc, -1);
301
if (strcmp (addr, host->name) == 0)
302
label = g_strdup_printf ("<b>%s</b>\n%s",
306
label = g_strdup_printf ("<b>%s</b> (%s)\n%s",
314
gtk_list_store_append (GTK_LIST_STORE (browser_model), &iter);
315
gtk_list_store_set (GTK_LIST_STORE (browser_model), &iter,
316
CHOOSER_LIST_ICON_COLUMN, host->picture,
317
CHOOSER_LIST_LABEL_COLUMN, label,
318
CHOOSER_LIST_HOST_COLUMN, host,
319
322
#ifdef ENABLE_IPV6
320
if (added6_addr != NULL && memcmp (&host->ia6, added6_addr,
321
sizeof (struct in6_addr)) == 0) {
323
add_this_host = TRUE;
323
if (added6_addr != NULL && memcmp (&host->ia6, added6_addr,
324
sizeof (struct in6_addr)) == 0) {
326
add_this_host = TRUE;
326
if (added_addr != NULL &&
327
memcmp (&host->ia, added_addr,
328
sizeof (struct in_addr)) == 0) {
330
add_this_host = TRUE;
329
if (added_addr != NULL &&
330
memcmp (&host->ia, added_addr,
331
sizeof (struct in_addr)) == 0) {
333
add_this_host = TRUE;
334
GtkTreeSelection *selection;
335
GtkTreePath *path = gtk_tree_model_get_path (browser_model, &iter);
336
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser));
337
gtk_tree_selection_select_iter (selection, &iter);
338
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (browser),
341
gtk_tree_path_free (path);
342
gtk_widget_grab_focus (manage);
346
if (add_check_handler > 0)
347
g_source_remove (add_check_handler);
348
add_check_handler = 0;
337
GtkTreeSelection *selection;
338
GtkTreePath *path = gtk_tree_model_get_path (browser_model, &iter);
339
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser));
340
gtk_tree_selection_select_iter (selection, &iter);
341
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (browser),
344
gtk_tree_path_free (path);
345
gtk_widget_grab_focus (manage);
349
if (add_check_handler > 0)
350
g_source_remove (add_check_handler);
351
add_check_handler = 0;
351
gtk_widget_set_sensitive (GTK_WIDGET (browser), TRUE);
354
gtk_widget_set_sensitive (GTK_WIDGET (browser), TRUE);
354
357
static GdmChooserHost *
434
hig_dialog_new (GtkWindow *parent,
435
GtkDialogFlags flags,
437
GtkButtonsType buttons,
438
const gchar *primary_message,
439
const gchar *secondary_message)
443
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
444
GTK_DIALOG_DESTROY_WITH_PARENT,
447
"%s", primary_message);
449
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
450
"%s", secondary_message);
452
gtk_window_set_title (GTK_WINDOW (dialog), "");
453
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
454
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
431
460
gdm_chooser_decode_packet (GIOChannel *source,
432
461
GIOCondition condition,
435
464
#ifdef ENABLE_IPV6
436
char hbuf[NI_MAXHOST];
437
struct sockaddr_in6 clnt6_sa;
439
struct sockaddr_in clnt_sa;
441
static XdmcpBuffer buf;
444
gchar *hostname = NULL;
445
gchar *status = NULL;
446
ARRAY8 auth = {0}, host = {0}, stat = {0};
449
gboolean host_not_willing = FALSE;
451
if ( ! (condition & G_IO_IN))
465
char hbuf[NI_MAXHOST];
466
struct sockaddr_in6 clnt6_sa;
468
struct sockaddr_in clnt_sa;
470
static XdmcpBuffer buf;
473
gchar *hostname = NULL;
474
gchar *status = NULL;
475
ARRAY8 auth = {0}, host = {0}, stat = {0};
478
gboolean host_not_willing = FALSE;
483
/* apparently Hurd doesn't have PIPE_BUF */
484
pipe_buf = fpathconf (1 /*stdout*/, _PC_PIPE_BUF);
485
/* could return -1 if no limit */
488
if ( ! (condition & G_IO_IN))
454
491
#ifdef ENABLE_IPV6
456
sa_len = sizeof (struct sockaddr_in6);
457
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt6_sa, &sa_len))
493
sa_len = sizeof (struct sockaddr_in6);
494
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt6_sa, &sa_len))
462
sa_len = sizeof (struct sockaddr_in);
463
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt_sa, &sa_len))
499
sa_len = sizeof (struct sockaddr_in);
500
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt_sa, &sa_len))
467
if (! XdmcpReadHeader (&buf, &header))
504
if (! XdmcpReadHeader (&buf, &header))
470
if (header.version != XDM_PROTOCOL_VERSION)
473
if (header.opcode == WILLING) {
474
if (! XdmcpReadARRAY8 (&buf, &auth))
477
if (! XdmcpReadARRAY8 (&buf, &host))
480
if (! XdmcpReadARRAY8 (&buf, &stat))
483
status = g_strndup ((char *) stat.data, MIN (stat.length, 256));
484
} else if (header.opcode == UNWILLING) {
485
/* immaterial, will not be shown */
507
if (header.version != XDM_PROTOCOL_VERSION)
510
if (header.opcode == WILLING) {
511
if (! XdmcpReadARRAY8 (&buf, &auth))
514
if (! XdmcpReadARRAY8 (&buf, &host))
517
if (! XdmcpReadARRAY8 (&buf, &stat))
520
status = g_strndup ((char *) stat.data, MIN (stat.length, 256));
521
} else if (header.opcode == UNWILLING) {
522
/* immaterial, will not be shown */
490
527
#ifdef ENABLE_IPV6
491
/*Since, IPv4 addresses will get extracted as V4 mapped IPv6 address*/
494
IN6_IS_ADDR_V4MAPPED (&(clnt6_sa.sin6_addr))) {
495
memset (&clnt_sa, 0, sizeof (clnt_sa));
496
memcpy (&(clnt_sa.sin_addr), &(clnt6_sa.sin6_addr.s6_addr[12]), 4);
497
clnt_sa.sin_family = AF_INET;
498
clnt_sa.sin_port = clnt6_sa.sin6_port;
499
clnt6_sa.sin6_family = AF_INET;
503
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
504
if ( ! is_loopback_addr ((gchar *) &clnt6_sa.sin6_addr, AF_INET6)) {
505
clnt6_sa.sin6_scope_id = 0;
507
getnameinfo ((struct sockaddr *)&clnt6_sa, sizeof (struct sockaddr_in6), hbuf, sizeof (hbuf), NULL, 0, 0);
511
if (strlen (hostname)+1 > PIPE_BUF)
513
hostname = g_strdup (hostname);
516
hostname = g_new0 (char, 1024);
518
if (gethostname (hostname, 1023) != 0) {
528
/*Since, IPv4 addresses will get extracted as V4 mapped IPv6 address*/
531
IN6_IS_ADDR_V4MAPPED (&(clnt6_sa.sin6_addr))) {
532
memset (&clnt_sa, 0, sizeof (clnt_sa));
533
memcpy (&(clnt_sa.sin_addr), &(clnt6_sa.sin6_addr.s6_addr[12]), 4);
534
clnt_sa.sin_family = AF_INET;
535
clnt_sa.sin_port = clnt6_sa.sin6_port;
536
clnt6_sa.sin6_family = AF_INET;
540
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
541
if ( ! is_loopback_addr ((gchar *) &clnt6_sa.sin6_addr, AF_INET6)) {
542
clnt6_sa.sin6_scope_id = 0;
544
getnameinfo ((struct sockaddr *)&clnt6_sa, sizeof (struct sockaddr_in6), hbuf, sizeof (hbuf), NULL, 0, 0);
548
if (strlen (hostname) + 1 > pipe_buf)
550
hostname = g_strdup (hostname);
553
hostname = g_new0 (char, 1024);
555
if (gethostname (hostname, 1023) != 0) {
560
gh = gdm_host_known ((char *)&clnt6_sa.sin6_addr, AF_INET6);
565
if ( !is_loopback_addr ((char *)&clnt_sa.sin_addr, AF_INET)) {
566
he = gethostbyaddr ((gchar *) &clnt_sa.sin_addr,
567
sizeof (struct in_addr),
570
hostname = (he && he->h_name) ? he->h_name : inet_ntoa (clnt_sa.sin_addr);
571
if (strlen (hostname) + 1 > pipe_buf)
574
hostname = g_strdup (hostname);
576
hostname = g_new0 (char, 1024);
577
if (gethostname (hostname, 1023) != 0) {
584
/* We can't pipe hostnames larger than this */
585
if (pipe_buf > 0 && strlen (hostname)+1 > pipe_buf) {
519
586
g_free (hostname);
523
gh = gdm_host_known ((char *)&clnt6_sa.sin6_addr, AF_INET6);
528
if ( !is_loopback_addr ((char *)&clnt_sa.sin_addr, AF_INET)) {
529
he = gethostbyaddr ((gchar *) &clnt_sa.sin_addr,
530
sizeof (struct in_addr),
533
hostname = (he && he->h_name) ? he->h_name : inet_ntoa (clnt_sa.sin_addr);
534
if (strlen (hostname)+1 > PIPE_BUF)
537
hostname = g_strdup (hostname);
539
hostname = g_new0 (char, 1024);
540
if (gethostname (hostname, 1023) != 0) {
550
/* apparently Hurd doesn't have PIPE_BUF */
551
pipe_buf = fpathconf (1 /*stdout*/, _PC_PIPE_BUF);
552
/* could return -1 if no limit */
555
/* We can't pipe hostnames larger than this */
556
if (pipe_buf > 0 && strlen (hostname)+1 > pipe_buf) {
562
if (have_ipv6 && ((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
563
gh = gdm_host_known ((char *)&clnt6_sa.sin6_addr, AF_INET6);
565
gh = gdm_chooser_host_alloc (hostname, status, (char *)&clnt6_sa.sin6_addr, AF_INET6, header.opcode == WILLING);
566
gdm_chooser_browser_add_host (gh);
571
gh = gdm_host_known ((char *)&clnt_sa.sin_addr, AF_INET);
573
gh = gdm_chooser_host_alloc (hostname, status, (char *)&clnt_sa.sin_addr, AF_INET, header.opcode == WILLING);
574
gdm_chooser_browser_add_host (gh);
578
/* server changed it's mind */
579
if (header.opcode == WILLING &&
582
gdm_chooser_browser_add_host (gh);
584
/* hmmm what about the other change, just ignore
585
for now, it's kind of confusing to just remove
590
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6 &&
592
added6_addr != NULL &&
593
memcmp (&gh->ia6, added6_addr, sizeof (struct in6_addr)) == 0) {
596
host_not_willing = TRUE;
600
if (clnt_sa.sin_family == AF_INET &&
602
added_addr != NULL &&
603
memcmp (&gh->ia, added_addr, sizeof (struct in_addr)) == 0) {
606
host_not_willing = TRUE;
609
if (host_not_willing) {
613
if (add_check_handler > 0)
614
g_source_remove (add_check_handler);
615
add_check_handler = 0;
617
msg = g_strdup_printf (_("The host \"%s\" is not willing "
618
"to support a login session right now. "
619
"Please try again later."),
622
dialog = ve_hig_dialog_new
623
(GTK_WINDOW (chooser) /* parent */,
624
GTK_DIALOG_MODAL /* flags */,
627
_("Cannot connect to remote server"),
632
if (RUNNING_UNDER_GDM)
633
gdm_wm_center_window (GTK_WINDOW (dialog));
635
gdm_wm_no_login_focus_push ();
636
gtk_dialog_run (GTK_DIALOG (dialog));
637
gtk_widget_destroy (dialog);
638
gdm_wm_no_login_focus_pop ();
591
if (have_ipv6 && ((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
592
gh = gdm_host_known ((char *)&clnt6_sa.sin6_addr, AF_INET6);
594
gh = gdm_chooser_host_alloc (hostname, status, (char *)&clnt6_sa.sin6_addr, AF_INET6, header.opcode == WILLING);
595
gdm_chooser_browser_add_host (gh);
600
gh = gdm_host_known ((char *)&clnt_sa.sin_addr, AF_INET);
602
gh = gdm_chooser_host_alloc (hostname, status, (char *)&clnt_sa.sin_addr, AF_INET, header.opcode == WILLING);
603
gdm_chooser_browser_add_host (gh);
607
/* server changed it's mind */
608
if (header.opcode == WILLING &&
611
gdm_chooser_browser_add_host (gh);
613
/* hmmm what about the other change, just ignore
614
for now, it's kind of confusing to just remove
619
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6 &&
621
added6_addr != NULL &&
622
memcmp (&gh->ia6, added6_addr, sizeof (struct in6_addr)) == 0) {
625
host_not_willing = TRUE;
629
if (clnt_sa.sin_family == AF_INET &&
631
added_addr != NULL &&
632
memcmp (&gh->ia, added_addr, sizeof (struct in_addr)) == 0) {
635
host_not_willing = TRUE;
638
if (host_not_willing) {
642
if (add_check_handler > 0)
643
g_source_remove (add_check_handler);
644
add_check_handler = 0;
646
msg = g_strdup_printf (_("The host \"%s\" is not willing "
647
"to support a login session right now. "
648
"Please try again later."),
651
dialog = hig_dialog_new (GTK_WINDOW (chooser) /* parent */,
652
GTK_DIALOG_MODAL /* flags */,
655
_("Cannot connect to remote server"),
660
if (RUNNING_UNDER_GDM)
661
gdm_wm_center_window (GTK_WINDOW (dialog));
663
gdm_wm_no_login_focus_push ();
664
gtk_dialog_run (GTK_DIALOG (dialog));
665
gtk_widget_destroy (dialog);
666
gdm_wm_no_login_focus_pop ();
647
if (header.opcode == WILLING) {
648
XdmcpDisposeARRAY8 (&auth);
649
XdmcpDisposeARRAY8 (&host);
650
XdmcpDisposeARRAY8 (&stat);
675
if (header.opcode == WILLING) {
676
XdmcpDisposeARRAY8 (&auth);
677
XdmcpDisposeARRAY8 (&host);
678
XdmcpDisposeARRAY8 (&stat);
751
779
if (ioctl (sock, SIOCGIFCONF, &ifc) >= 0)
752
780
ifr = ifc.ifc_req;
753
num = ifc.ifc_len / sizeof (struct ifreq); /* No of interfaces */
754
for (i = 0 ; i < num ; i++) {
781
num = ifc.ifc_len / sizeof (struct ifreq); /* No of interfaces */
782
for (i = 0 ; i < num ; i++) {
758
memset (&ifreq, 0, sizeof (ifreq));
759
strncpy (ifreq.ifr_name, ifr[i].ifr_name, sizeof (ifreq.ifr_name));
760
ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
786
memset (&ifreq, 0, sizeof (ifreq));
787
strncpy (ifreq.ifr_name, ifr[i].ifr_name, sizeof (ifreq.ifr_name));
788
ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
762
if (ioctl (sock, SIOCGIFFLAGS, &ifreq) < 0)
763
gdm_common_error ("Could not get interface flags for %s\n", ifr[i].ifr_name);
764
ifindex = if_nametoindex (ifr[i].ifr_name);
790
if (ioctl (sock, SIOCGIFFLAGS, &ifreq) < 0)
791
gdm_common_error ("Could not get interface flags for %s\n", ifr[i].ifr_name);
792
ifindex = if_nametoindex (ifr[i].ifr_name);
766
if ((!(ifreq.ifr_flags & IFF_UP) || (!(ifreq.ifr_flags & IFF_MULTICAST))) || (ifindex == 0 )) {
794
if ((!(ifreq.ifr_flags & IFF_UP) || (!(ifreq.ifr_flags & IFF_MULTICAST))) || (ifindex == 0 )) {
767
795
/* Not a valid interface or Not up */
771
sin6 = g_new0 (struct sockaddr_in6, 1);
772
sin6->sin6_family = AF_INET6;
773
sin6->sin6_port = htons (XDM_UDP_PORT);
774
sin6->sin6_scope_id = ifindex;
775
inet_pton (AF_INET6, gdm_config_get_string (GDM_KEY_MULTICAST_ADDR),
778
/* bcaddr is also serving for multicast address for IPv6 */
779
bcaddr = g_slist_append (bcaddr, sin6);
799
sin6 = g_new0 (struct sockaddr_in6, 1);
800
sin6->sin6_family = AF_INET6;
801
sin6->sin6_port = htons (XDM_UDP_PORT);
802
sin6->sin6_scope_id = ifindex;
803
inet_pton (AF_INET6, gdm_config_get_string (GDM_KEY_MULTICAST_ADDR),
806
/* bcaddr is also serving for multicast address for IPv6 */
807
bcaddr = g_slist_append (bcaddr, sin6);
804
832
do_ping (gboolean full)
806
struct sockaddr_in sock;
808
GSList *ql = queryaddr;
811
struct sockaddr_in6 sock6;
813
memset (&sock6, 0, sizeof (sock6));
814
sock6.sin6_family = AF_INET6;
815
sock6.sin6_port = htons (XDM_UDP_PORT);
818
sock.sin_family = AF_INET;
819
sock.sin_port = htons (XDM_UDP_PORT);
822
ia = (struct sockaddr *) bl->data;
824
if (have_ipv6) { /* Convert the IPv4 broadcast address to v4 mapped v6 address.*/
825
if (ia->sa_family == AF_INET) {
829
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (((struct sockaddr_in *)(ia))->sin_addr));
830
inet_pton (AF_INET6, tmpaddr, &in6);
831
memcpy (sock6.sin6_addr.s6_addr, in6.s6_addr, sizeof (struct in6_addr));
832
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
835
else if (ia->sa_family == AF_INET6) {
836
memcpy (sock6.sin6_addr.s6_addr, ((struct sockaddr_in6 *)ia)->sin6_addr.s6_addr, sizeof (struct in6_addr));
837
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
843
if (ia->sa_family == AF_INET) {
844
sock.sin_addr.s_addr = ((struct sockaddr_in *)ia)->sin_addr.s_addr;
845
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock, (int)sizeof (struct sockaddr_in));
852
ia = (struct sockaddr *) ql->data;
856
if (ia->sa_family == AF_INET) {
860
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (((struct sockaddr_in *)(ia))->sin_addr));
861
inet_pton (AF_INET6, tmpaddr, &in6);
863
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in6 *)ia)->sin6_addr, AF_INET6)) {
864
memcpy (sock6.sin6_addr.s6_addr, in6.s6_addr, sizeof (struct in6_addr));
865
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
869
if (ia->sa_family == AF_INET6) {
870
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in6 *)ia)->sin6_addr, AF_INET6)) {
871
memcpy (&sock6.sin6_addr, &((struct sockaddr_in6 *)ia)->sin6_addr, sizeof (struct in6_addr));
872
XdmcpFlush (sockfd, &querybuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
879
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in *)ia)->sin_addr, AF_INET)) {
880
sock.sin_addr.s_addr = ((struct sockaddr_in *)ia)->sin_addr.s_addr;
881
XdmcpFlush (sockfd, &querybuf, (XdmcpNetaddr) &sock, (int)sizeof (struct sockaddr_in));
834
struct sockaddr_in sock;
836
GSList *ql = queryaddr;
839
struct sockaddr_in6 sock6;
841
memset (&sock6, 0, sizeof (sock6));
842
sock6.sin6_family = AF_INET6;
843
sock6.sin6_port = htons (XDM_UDP_PORT);
846
sock.sin_family = AF_INET;
847
sock.sin_port = htons (XDM_UDP_PORT);
850
ia = (struct sockaddr *) bl->data;
852
if (have_ipv6) { /* Convert the IPv4 broadcast address to v4 mapped v6 address.*/
853
if (ia->sa_family == AF_INET) {
857
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (((struct sockaddr_in *)(ia))->sin_addr));
858
inet_pton (AF_INET6, tmpaddr, &in6);
859
memcpy (sock6.sin6_addr.s6_addr, in6.s6_addr, sizeof (struct in6_addr));
860
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
863
else if (ia->sa_family == AF_INET6) {
864
memcpy (sock6.sin6_addr.s6_addr, ((struct sockaddr_in6 *)ia)->sin6_addr.s6_addr, sizeof (struct in6_addr));
865
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
871
if (ia->sa_family == AF_INET) {
872
sock.sin_addr.s_addr = ((struct sockaddr_in *)ia)->sin_addr.s_addr;
873
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock, (int)sizeof (struct sockaddr_in));
880
ia = (struct sockaddr *) ql->data;
884
if (ia->sa_family == AF_INET) {
888
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (((struct sockaddr_in *)(ia))->sin_addr));
889
inet_pton (AF_INET6, tmpaddr, &in6);
891
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in6 *)ia)->sin6_addr, AF_INET6)) {
892
memcpy (sock6.sin6_addr.s6_addr, in6.s6_addr, sizeof (struct in6_addr));
893
XdmcpFlush (sockfd, &bcbuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
897
if (ia->sa_family == AF_INET6) {
898
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in6 *)ia)->sin6_addr, AF_INET6)) {
899
memcpy (&sock6.sin6_addr, &((struct sockaddr_in6 *)ia)->sin6_addr, sizeof (struct in6_addr));
900
XdmcpFlush (sockfd, &querybuf, (XdmcpNetaddr) &sock6, (int) sizeof (struct sockaddr_in6));
907
if (full || ! gdm_host_known ((char *)&((struct sockaddr_in *)ia)->sin_addr, AF_INET)) {
908
sock.sin_addr.s_addr = ((struct sockaddr_in *)ia)->sin_addr.s_addr;
909
XdmcpFlush (sockfd, &querybuf, (XdmcpNetaddr) &sock, (int)sizeof (struct sockaddr_in));
901
929
gdm_chooser_xdmcp_discover (void)
903
GList *hl = chooser_hosts;
931
GList *hl = chooser_hosts;
907
935
#ifdef ENABLE_IPV6
911
if (add_check_handler > 0)
912
g_source_remove (add_check_handler);
913
add_check_handler = 0;
915
gtk_widget_set_sensitive (GTK_WIDGET (manage), FALSE);
916
gtk_widget_set_sensitive (GTK_WIDGET (rescan), FALSE);
917
gtk_list_store_clear (GTK_LIST_STORE (browser_model));
918
gtk_widget_set_sensitive (GTK_WIDGET (browser), FALSE);
919
gtk_label_set_label (GTK_LABEL (status_label),
920
_(scanning_message));
923
gdm_chooser_host_dispose ((GdmChooserHost *) hl->data);
927
g_list_free (chooser_hosts);
928
chooser_hosts = NULL;
932
if (scan_time_handler > 0)
933
g_source_remove (scan_time_handler);
934
scan_time_handler = g_timeout_add (gdm_config_get_int (GDM_KEY_SCAN_TIME) * 1000,
935
chooser_scan_time_update, NULL);
937
/* Note we already used up one try */
938
ping_tries = PING_TRIES - 1;
939
if (ping_try_handler > 0)
940
g_source_remove (ping_try_handler);
941
ping_try_handler = g_timeout_add (PING_TIMEOUT, ping_try, NULL);
939
if (add_check_handler > 0)
940
g_source_remove (add_check_handler);
941
add_check_handler = 0;
943
gtk_widget_set_sensitive (GTK_WIDGET (manage), FALSE);
944
gtk_widget_set_sensitive (GTK_WIDGET (rescan), FALSE);
945
gtk_list_store_clear (GTK_LIST_STORE (browser_model));
946
gtk_widget_set_sensitive (GTK_WIDGET (browser), FALSE);
947
gtk_label_set_label (GTK_LABEL (status_label),
948
_(scanning_message));
951
gdm_chooser_host_dispose ((GdmChooserHost *) hl->data);
955
g_list_free (chooser_hosts);
956
chooser_hosts = NULL;
960
if (scan_time_handler > 0)
961
g_source_remove (scan_time_handler);
962
scan_time_handler = g_timeout_add (gdm_config_get_int (GDM_KEY_SCAN_TIME) * 1000,
963
chooser_scan_time_update, NULL);
965
/* Note we already used up one try */
966
ping_tries = PING_TRIES - 1;
967
if (ping_try_handler > 0)
968
g_source_remove (ping_try_handler);
969
ping_try_handler = g_timeout_add (PING_TIMEOUT, ping_try, NULL);
944
972
#ifndef ishexdigit
1018
if ((strlen (name) == 8) && (from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0)) {
1019
queryaddr = g_slist_append (queryaddr, qa);
1024
used_addr = AF_INET;
1028
if (inet_pton (AF_INET6, name, &qa6->sin6_addr) > 0) {
1029
queryaddr = g_slist_append (queryaddr, qa6);
1032
used_addr = AF_INET6;
1036
if ((qa->sin_addr.s_addr = inet_addr (name)) != -1) {
1037
queryaddr = g_slist_append (queryaddr, qa);
1042
used_addr = AF_INET;
1046
if (getaddrinfo (name, NULL, &hints, &result) == 0) {
1047
for (res = result; res; res = res->ai_next) {
1048
if (res && res->ai_family == AF_INET6) {
1049
memmove (qa6, res->ai_addr, res->ai_addrlen);
1046
if ((strlen (name) == 8) && (from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0)) {
1047
queryaddr = g_slist_append (queryaddr, qa);
1052
used_addr = AF_INET;
1056
if (inet_pton (AF_INET6, name, &qa6->sin6_addr) > 0) {
1050
1057
queryaddr = g_slist_append (queryaddr, qa6);
1053
1060
used_addr = AF_INET6;
1055
if (res && res->ai_family == AF_INET) {
1056
memmove (qa, res->ai_addr, res->ai_addrlen);
1057
queryaddr = g_slist_append (queryaddr, qa);
1060
used_addr = AF_INET;
1065
if ((hostent = gethostbyname (name)) != NULL
1066
&& hostent->h_addrtype == AF_INET
1067
&& hostent->h_length == 4) {
1068
qa->sin_family = AF_INET;
1069
memmove (&qa->sin_addr, hostent->h_addr, 4);
1070
queryaddr = g_slist_append (queryaddr, qa);
1075
used_addr = AF_INET;
1077
continue; /* not a valid address */
1064
if ((qa->sin_addr.s_addr = inet_addr (name)) != -1) {
1065
queryaddr = g_slist_append (queryaddr, qa);
1070
used_addr = AF_INET;
1074
if (getaddrinfo (name, NULL, &hints, &result) == 0) {
1075
for (res = result; res; res = res->ai_next) {
1076
if (res && res->ai_family == AF_INET6) {
1077
memmove (qa6, res->ai_addr, res->ai_addrlen);
1078
queryaddr = g_slist_append (queryaddr, qa6);
1081
used_addr = AF_INET6;
1083
if (res && res->ai_family == AF_INET) {
1084
memmove (qa, res->ai_addr, res->ai_addrlen);
1085
queryaddr = g_slist_append (queryaddr, qa);
1088
used_addr = AF_INET;
1093
if ((hostent = gethostbyname (name)) != NULL
1094
&& hostent->h_addrtype == AF_INET
1095
&& hostent->h_length == 4) {
1096
qa->sin_family = AF_INET;
1097
memmove (&qa->sin_addr, hostent->h_addr, 4);
1098
queryaddr = g_slist_append (queryaddr, qa);
1103
used_addr = AF_INET;
1105
continue; /* not a valid address */
1081
1109
if (bcaddr == NULL &&
1087
1115
gdm_chooser_xdmcp_init (char **hosts)
1089
static XdmcpHeader header;
1117
static XdmcpHeader header;
1092
/* Open socket for communication */
1120
/* Open socket for communication */
1093
1121
#ifdef ENABLE_IPV6
1094
if ((sockfd = socket (AF_INET6, SOCK_DGRAM, 0)) == -1)
1122
if ((sockfd = socket (AF_INET6, SOCK_DGRAM, 0)) == -1)
1100
if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) == -1) {
1101
gdm_common_fail_exit ("Could not create socket!");
1105
if (setsockopt (sockfd, SOL_SOCKET, SO_BROADCAST,
1106
(char *) &sockopts, sizeof (sockopts)) < 0) {
1107
gdm_common_fail_exit ("Could not set socket options!");
1110
/* Assemble XDMCP BROADCAST_QUERY packet in static buffer */
1111
header.opcode = (CARD16) BROADCAST_QUERY;
1113
header.version = XDM_PROTOCOL_VERSION;
1114
XdmcpWriteHeader (&bcbuf, &header);
1115
XdmcpWriteARRAY8 (&bcbuf, &authlist.authentication);
1117
/* Assemble XDMCP QUERY packet in static buffer */
1118
header.opcode = (CARD16) QUERY;
1120
header.version = XDM_PROTOCOL_VERSION;
1121
XdmcpWriteHeader (&querybuf, &header);
1122
XdmcpWriteARRAY8 (&querybuf, &authlist.authentication);
1124
gdm_chooser_add_hosts (hosts);
1126
channel = g_io_channel_unix_new (sockfd);
1127
g_io_channel_set_encoding (channel, NULL, NULL);
1128
g_io_channel_set_buffered (channel, FALSE);
1129
g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
1130
G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
1131
gdm_chooser_decode_packet,
1132
GINT_TO_POINTER (sockfd), NULL);
1133
g_io_channel_unref (channel);
1135
gdm_chooser_xdmcp_discover ();
1128
if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) == -1) {
1129
gdm_common_fail_exit ("Could not create socket!");
1133
if (setsockopt (sockfd, SOL_SOCKET, SO_BROADCAST,
1134
(char *) &sockopts, sizeof (sockopts)) < 0) {
1135
gdm_common_fail_exit ("Could not set socket options!");
1138
/* Assemble XDMCP BROADCAST_QUERY packet in static buffer */
1139
header.opcode = (CARD16) BROADCAST_QUERY;
1141
header.version = XDM_PROTOCOL_VERSION;
1142
XdmcpWriteHeader (&bcbuf, &header);
1143
XdmcpWriteARRAY8 (&bcbuf, &authlist.authentication);
1145
/* Assemble XDMCP QUERY packet in static buffer */
1146
header.opcode = (CARD16) QUERY;
1148
header.version = XDM_PROTOCOL_VERSION;
1149
XdmcpWriteHeader (&querybuf, &header);
1150
XdmcpWriteARRAY8 (&querybuf, &authlist.authentication);
1152
gdm_chooser_add_hosts (hosts);
1154
channel = g_io_channel_unix_new (sockfd);
1155
g_io_channel_set_encoding (channel, NULL, NULL);
1156
g_io_channel_set_buffered (channel, FALSE);
1157
g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
1158
G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
1159
gdm_chooser_decode_packet,
1160
GINT_TO_POINTER (sockfd), NULL);
1161
g_io_channel_unref (channel);
1163
gdm_chooser_xdmcp_discover ();
1139
1167
gdm_chooser_choose_host (const char *hostname)
1142
1170
#ifndef ENABLE_IPV6
1143
struct hostent *hentry;
1146
printf ("\n%s\n", curhost->name);
1148
if (xdm_address != NULL) {
1151
struct sockaddr_in6 in6_addr;
1152
struct addrinfo hints, *result;
1154
struct sockaddr_in in_addr;
1156
char client_addr[32];
1160
long family, port, addr;
1162
if (strlen (xdm_address) > 64 ||
1163
from_hex (xdm_address, xdm_addr, strlen (xdm_address)) != 0) {
1164
gdm_common_fail_exit ("gdm_chooser_chooser_host: Invalid xdm address.");
1167
family = (xdm_addr[0] << 8) | xdm_addr[1];
1168
port = (xdm_addr[2] << 8) | xdm_addr[3];
1171
if (family == AF_INET6) {
1172
memset (&in6_addr, 0, sizeof (in6_addr));
1174
in6_addr.sin6_port = htons (port);
1175
in6_addr.sin6_family = AF_INET6;
1177
memcpy (&in6_addr.sin6_addr, &xdm_address[4], 16);
1179
if ((fd = socket (PF_INET6, SOCK_STREAM, 0)) == -1) {
1180
gdm_common_fail_exit ("gdm_chooser_choose_host: Could not create response socket.");
1183
if (connect (fd, (struct sockaddr *) &in6_addr,
1184
sizeof (in6_addr)) == -1) {
1186
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not connect to xdm.");
1191
addr = (xdm_addr[4] << 24) | (xdm_addr[5] << 16) |
1192
(xdm_addr[6] << 8) | xdm_addr[7];
1194
in_addr.sin_family = AF_INET;
1195
in_addr.sin_port = htons (port);
1196
in_addr.sin_addr.s_addr = htonl (addr);
1198
if ((fd = socket (PF_INET, SOCK_STREAM, 0)) == -1) {
1199
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not create response socket.");
1202
if (connect (fd, (struct sockaddr *) &in_addr,
1203
sizeof (in_addr)) == -1) {
1205
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not connect to xdm.");
1209
buffer.data = (BYTE *) buf;
1210
buffer.size = sizeof (buf);
1214
if (strlen (client_address) > 64 || from_hex (client_address,
1215
client_addr, strlen (client_address)) != 0) {
1217
gdm_common_fail_exit ("gdm_chooser_chooser_host: Invalid client address.");
1220
tmparr.data = (BYTE *) client_addr;
1221
tmparr.length = strlen (client_address) / 2;
1223
XdmcpWriteARRAY8 (&buffer, &tmparr);
1224
XdmcpWriteCARD16 (&buffer, (CARD16) connection_type);
1228
memset (&hints, 0, sizeof (hints));
1229
hints.ai_socktype = SOCK_STREAM;
1231
status = getaddrinfo (hostname, NULL, &hints, &result);
1234
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not get host entry for %s",
1238
if (result->ai_family == AF_INET6)
1240
if (result->ai_family == AF_INET)
1242
tmparr.data = (BYTE *) result->ai_addr;
1171
struct hostent *hentry;
1174
printf ("\n%s\n", curhost->name);
1176
if (xdm_address != NULL) {
1179
struct sockaddr_in6 in6_addr;
1180
struct addrinfo hints, *result;
1182
struct sockaddr_in in_addr;
1184
char client_addr[32];
1188
long family, port, addr;
1190
if (strlen (xdm_address) > 64 ||
1191
from_hex (xdm_address, xdm_addr, strlen (xdm_address)) != 0) {
1192
gdm_common_fail_exit ("gdm_chooser_chooser_host: Invalid xdm address.");
1195
family = (xdm_addr[0] << 8) | xdm_addr[1];
1196
port = (xdm_addr[2] << 8) | xdm_addr[3];
1199
if (family == AF_INET6) {
1200
memset (&in6_addr, 0, sizeof (in6_addr));
1202
in6_addr.sin6_port = htons (port);
1203
in6_addr.sin6_family = AF_INET6;
1205
memcpy (&in6_addr.sin6_addr, &xdm_address[4], 16);
1207
if ((fd = socket (PF_INET6, SOCK_STREAM, 0)) == -1) {
1208
gdm_common_fail_exit ("gdm_chooser_choose_host: Could not create response socket.");
1211
if (connect (fd, (struct sockaddr *) &in6_addr,
1212
sizeof (in6_addr)) == -1) {
1214
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not connect to xdm.");
1219
addr = (xdm_addr[4] << 24) | (xdm_addr[5] << 16) |
1220
(xdm_addr[6] << 8) | xdm_addr[7];
1222
in_addr.sin_family = AF_INET;
1223
in_addr.sin_port = htons (port);
1224
in_addr.sin_addr.s_addr = htonl (addr);
1226
if ((fd = socket (PF_INET, SOCK_STREAM, 0)) == -1) {
1227
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not create response socket.");
1230
if (connect (fd, (struct sockaddr *) &in_addr,
1231
sizeof (in_addr)) == -1) {
1233
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not connect to xdm.");
1237
buffer.data = (BYTE *) buf;
1238
buffer.size = sizeof (buf);
1242
if (strlen (client_address) > 64 || from_hex (client_address,
1243
client_addr, strlen (client_address)) != 0) {
1245
gdm_common_fail_exit ("gdm_chooser_chooser_host: Invalid client address.");
1248
tmparr.data = (BYTE *) client_addr;
1249
tmparr.length = strlen (client_address) / 2;
1251
XdmcpWriteARRAY8 (&buffer, &tmparr);
1252
XdmcpWriteCARD16 (&buffer, (CARD16) connection_type);
1256
memset (&hints, 0, sizeof (hints));
1257
hints.ai_socktype = SOCK_STREAM;
1259
status = getaddrinfo (hostname, NULL, &hints, &result);
1262
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not get host entry for %s",
1266
if (result->ai_family == AF_INET6)
1268
if (result->ai_family == AF_INET)
1270
tmparr.data = (BYTE *) result->ai_addr;
1244
hentry = gethostbyname (hostname);
1247
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not get host entry for %s",
1251
tmparr.data = (BYTE *) hentry->h_addr_list[0]; /* XXX */
1272
hentry = gethostbyname (hostname);
1275
gdm_common_fail_exit ("gdm_chooser_chooser_host: Could not get host entry for %s",
1279
tmparr.data = (BYTE *) hentry->h_addr_list[0]; /* XXX */
1255
XdmcpWriteARRAY8 (&buffer, &tmparr);
1256
write (fd, (char *) buffer.data, buffer.pointer);
1283
XdmcpWriteARRAY8 (&buffer, &tmparr);
1284
write (fd, (char *) buffer.data, buffer.pointer);
1261
1289
static gboolean
1342
if (strlen (name) == 8 &&
1343
from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0) {
1348
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (qa->sin_addr));
1349
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
1355
if (have_ipv6 && inet_pton (AF_INET6, name, &qa6->sin6_addr) > 0) ;
1358
if (inet_aton (name, &(qa->sin_addr))) {
1363
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (qa->sin_addr));
1364
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
1370
if (getaddrinfo (name, NULL, &hints, &result) == 0) {
1371
if (result->ai_family == AF_INET6) {
1372
memcpy (qa6, (struct sockaddr_in6 *)result->ai_addr, result->ai_addrlen);
1374
else if (result->ai_family == AF_INET) {
1369
if (strlen (name) == 8 &&
1370
from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0) {
1375
1372
if (have_ipv6) {
1378
sprintf (tmpaddr, "::ffff:%s",
1379
inet_ntoa (((struct sockaddr_in *)result->ai_addr)->sin_addr));
1375
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (qa->sin_addr));
1380
1376
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
1386
if ((hostent = gethostbyname (name)) != NULL &&
1387
hostent->h_addrtype == AF_INET && hostent->h_length == 4) {
1388
memmove (&qa->sin_addr, hostent->h_addr, 4);
1393
msg = g_strdup_printf (_("Cannot find the host \"%s\". "
1394
"Perhaps you have mistyped it."),
1397
dialog = ve_hig_dialog_new
1398
(GTK_WINDOW (chooser) /* parent */,
1399
GTK_DIALOG_MODAL /* flags */,
1402
_("Cannot find host"),
1407
if (RUNNING_UNDER_GDM)
1408
gdm_wm_center_window (GTK_WINDOW (dialog));
1410
gdm_wm_no_login_focus_push ();
1411
gtk_dialog_run (GTK_DIALOG (dialog));
1412
gtk_widget_destroy (dialog);
1413
gdm_wm_no_login_focus_pop ();
1418
return; /* not a valid address */
1382
if (have_ipv6 && inet_pton (AF_INET6, name, &qa6->sin6_addr) > 0) ;
1385
if (inet_aton (name, &(qa->sin_addr))) {
1390
sprintf (tmpaddr, "::ffff:%s", inet_ntoa (qa->sin_addr));
1391
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
1397
if (getaddrinfo (name, NULL, &hints, &result) == 0) {
1398
if (result->ai_family == AF_INET6) {
1399
memcpy (qa6, (struct sockaddr_in6 *)result->ai_addr, result->ai_addrlen);
1401
else if (result->ai_family == AF_INET) {
1405
sprintf (tmpaddr, "::ffff:%s",
1406
inet_ntoa (((struct sockaddr_in *)result->ai_addr)->sin_addr));
1407
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
1413
if ((hostent = gethostbyname (name)) != NULL &&
1414
hostent->h_addrtype == AF_INET && hostent->h_length == 4) {
1415
memmove (&qa->sin_addr, hostent->h_addr, 4);
1420
msg = g_strdup_printf (_("Cannot find the host \"%s\". "
1421
"Perhaps you have mistyped it."),
1424
dialog = hig_dialog_new (GTK_WINDOW (chooser) /* parent */,
1425
GTK_DIALOG_MODAL /* flags */,
1428
_("Cannot find host"),
1432
if (RUNNING_UNDER_GDM)
1433
gdm_wm_center_window (GTK_WINDOW (dialog));
1435
gdm_wm_no_login_focus_push ();
1436
gtk_dialog_run (GTK_DIALOG (dialog));
1437
gtk_widget_destroy (dialog);
1438
gdm_wm_no_login_focus_pop ();
1443
return; /* not a valid address */
1421
1446
#ifdef ENABLE_IPV6
1422
1447
if (have_ipv6) {
1634
glade_helper_add_glade_directory (GDM_GLADE_DIR);
1635
glade_helper_search_gnome_dirs (FALSE);
1638
if (RUNNING_UNDER_GDM) {
1639
const char *theme_name;
1641
if ( ! ve_string_empty (gdm_config_get_string (GDM_KEY_GTKRC)))
1642
gtk_rc_parse (gdm_config_get_string (GDM_KEY_GTKRC));
1644
theme_name = g_getenv ("GDM_GTK_THEME");
1645
if (ve_string_empty (theme_name))
1646
theme_name = gdm_config_get_string (GDM_KEY_GTK_THEME);
1648
if ( ! ve_string_empty (theme_name)) {
1649
gdm_set_theme (theme_name);
1653
defaulthosticon = gdm_config_get_string (GDM_KEY_DEFAULT_HOST_IMG);
1655
/* Load default host image */
1656
if (g_access (defaulthosticon, R_OK) != 0) {
1657
gdm_common_error ("Could not open default host icon: %s", defaulthosticon);
1659
defhostimg = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
1660
FALSE /* has_alpha */,
1661
8 /* bits_per_sample */,
1665
defhostimg = gdk_pixbuf_new_from_file (defaulthosticon, NULL);
1669
chooser_app = glade_helper_load ("gdmchooser.glade",
1657
if (RUNNING_UNDER_GDM) {
1658
const char *theme_name;
1660
if ( ! ve_string_empty (gdm_config_get_string (GDM_KEY_GTKRC)))
1661
gtk_rc_parse (gdm_config_get_string (GDM_KEY_GTKRC));
1663
theme_name = g_getenv ("GDM_GTK_THEME");
1664
if (ve_string_empty (theme_name))
1665
theme_name = gdm_config_get_string (GDM_KEY_GTK_THEME);
1667
if ( ! ve_string_empty (theme_name)) {
1668
gdm_set_theme (theme_name);
1672
defaulthosticon = gdm_config_get_string (GDM_KEY_DEFAULT_HOST_IMG);
1674
/* Load default host image */
1675
if (g_access (defaulthosticon, R_OK) != 0) {
1676
gdm_common_error ("Could not open default host icon: %s", defaulthosticon);
1678
defhostimg = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
1679
FALSE /* has_alpha */,
1680
8 /* bits_per_sample */,
1684
defhostimg = gdk_pixbuf_new_from_file (defaulthosticon, NULL);
1688
chooser_app = glade_xml_new (GDM_GLADE_DIR "/gdmchooser.glade",
1670
1689
"gdmchooser_main",
1672
FALSE /* dump_on_destroy */);
1673
glade_xml_signal_autoconnect (chooser_app);
1675
chooser = glade_helper_get (chooser_app, "gdmchooser_main",
1677
manage = glade_helper_get (chooser_app, "connect_button",
1679
rescan = glade_helper_get (chooser_app, "rescan_button",
1681
cancel = glade_helper_get (chooser_app, "quit_button",
1683
status_label = glade_helper_get (chooser_app, "status_label",
1685
add_entry = glade_helper_get (chooser_app, "add_entry",
1687
add_button = glade_helper_get (chooser_app, "add_button",
1690
browser = glade_helper_get (chooser_app, "chooser_iconlist",
1691
GTK_TYPE_TREE_VIEW);
1693
gtk_dialog_set_has_separator (GTK_DIALOG (chooser), FALSE);
1695
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (browser), TRUE);
1697
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser));
1698
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1700
g_signal_connect (selection, "changed",
1701
G_CALLBACK (host_selected),
1703
g_signal_connect (browser, "row_activated",
1704
G_CALLBACK (row_activated),
1707
browser_model = (GtkTreeModel *)gtk_list_store_new (3,
1711
gtk_tree_view_set_model (GTK_TREE_VIEW (browser), browser_model);
1712
column = gtk_tree_view_column_new_with_attributes
1714
gtk_cell_renderer_pixbuf_new (),
1715
"pixbuf", CHOOSER_LIST_ICON_COLUMN,
1717
gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column);
1719
column = gtk_tree_view_column_new_with_attributes
1721
gtk_cell_renderer_text_new (),
1722
"markup", CHOOSER_LIST_LABEL_COLUMN,
1724
gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column);
1726
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser_model),
1727
CHOOSER_LIST_LABEL_COLUMN,
1728
GTK_SORT_ASCENDING);
1731
if ( ! gdm_config_get_bool (GDM_KEY_ALLOW_ADD)) {
1732
GtkWidget *w = glade_helper_get (chooser_app, "add_hbox",
1734
gtk_widget_hide (w);
1737
gtk_window_get_size (GTK_WINDOW (chooser),
1739
if (RUNNING_UNDER_GDM) {
1740
if (width > gdm_wm_screen.width)
1741
width = gdm_wm_screen.width;
1742
if (height > gdm_wm_screen.height)
1743
height = gdm_wm_screen.height;
1745
if (width > gdk_screen_width ())
1746
width = gdk_screen_width ();
1747
if (height > gdk_screen_height ())
1748
height = gdk_screen_height ();
1750
gtk_widget_set_size_request (GTK_WIDGET (chooser),
1752
gtk_window_set_default_size (GTK_WINDOW (chooser),
1754
gtk_window_resize (GTK_WINDOW (chooser),
1758
/* cursor blinking is evil on remote displays, don't do it forever */
1759
gdm_common_setup_blinking ();
1760
gdm_common_setup_blinking_entry (add_entry);
1762
if (RUNNING_UNDER_GDM) {
1763
gtk_widget_show_now (chooser);
1764
gdm_wm_center_window (GTK_WINDOW (chooser));
1691
glade_xml_signal_autoconnect (chooser_app);
1692
chooser = glade_xml_get_widget (chooser_app, "gdmchooser_main");
1693
manage = glade_xml_get_widget (chooser_app, "connect_button");
1694
rescan = glade_xml_get_widget (chooser_app, "rescan_button");
1695
cancel = glade_xml_get_widget (chooser_app, "quit_button");
1696
status_label = glade_xml_get_widget (chooser_app, "status_label");
1697
add_entry = glade_xml_get_widget (chooser_app, "add_entry");
1698
add_button = glade_xml_get_widget (chooser_app, "add_button");
1699
browser = glade_xml_get_widget (chooser_app, "chooser_iconlist");
1701
gtk_dialog_set_has_separator (GTK_DIALOG (chooser), FALSE);
1703
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (browser), TRUE);
1705
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser));
1706
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1708
g_signal_connect (selection, "changed",
1709
G_CALLBACK (host_selected),
1711
g_signal_connect (browser, "row_activated",
1712
G_CALLBACK (row_activated),
1715
browser_model = (GtkTreeModel *)gtk_list_store_new (3,
1719
gtk_tree_view_set_model (GTK_TREE_VIEW (browser), browser_model);
1720
column = gtk_tree_view_column_new_with_attributes ("Icon",
1721
gtk_cell_renderer_pixbuf_new (),
1722
"pixbuf", CHOOSER_LIST_ICON_COLUMN,
1724
gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column);
1726
column = gtk_tree_view_column_new_with_attributes ("Hostname",
1727
gtk_cell_renderer_text_new (),
1728
"markup", CHOOSER_LIST_LABEL_COLUMN,
1730
gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column);
1732
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser_model),
1733
CHOOSER_LIST_LABEL_COLUMN,
1734
GTK_SORT_ASCENDING);
1737
if ( ! gdm_config_get_bool (GDM_KEY_ALLOW_ADD)) {
1738
GtkWidget *w = glade_xml_get_widget (chooser_app, "add_hbox");
1739
gtk_widget_hide (w);
1742
gtk_window_get_size (GTK_WINDOW (chooser),
1744
if (RUNNING_UNDER_GDM) {
1745
if (width > gdm_wm_screen.width)
1746
width = gdm_wm_screen.width;
1747
if (height > gdm_wm_screen.height)
1748
height = gdm_wm_screen.height;
1750
if (width > gdk_screen_width ())
1751
width = gdk_screen_width ();
1752
if (height > gdk_screen_height ())
1753
height = gdk_screen_height ();
1755
gtk_widget_set_size_request (GTK_WIDGET (chooser),
1757
gtk_window_set_default_size (GTK_WINDOW (chooser),
1759
gtk_window_resize (GTK_WINDOW (chooser),
1763
/* cursor blinking is evil on remote displays, don't do it forever */
1764
gdm_common_setup_blinking ();
1765
gdm_common_setup_blinking_entry (add_entry);
1767
if (RUNNING_UNDER_GDM) {
1768
gtk_widget_show_now (chooser);
1769
gdm_wm_center_window (GTK_WINDOW (chooser));
1860
1862
gdm_chooser_signals_init (void)
1862
struct sigaction hup;
1863
struct sigaction term;
1866
ve_signal_add (SIGHUP, gdm_reread_config, NULL);
1868
hup.sa_handler = ve_signal_notify;
1870
sigemptyset (&hup.sa_mask);
1871
sigaddset (&hup.sa_mask, SIGCHLD);
1873
term.sa_handler = gdm_chooser_cancel;
1875
sigemptyset (&term.sa_mask);
1877
if (sigaction (SIGHUP, &hup, NULL) < 0) {
1878
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1879
"gdm_signals_init", "HUP", strerror (errno));
1882
if (sigaction (SIGINT, &term, NULL) < 0) {
1883
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1884
"gdm_signals_init", "INT", strerror (errno));
1887
if (sigaction (SIGTERM, &term, NULL) < 0) {
1888
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1889
"gdm_signals_init", "TERM", strerror (errno));
1893
sigdelset (&mask, SIGTERM);
1894
sigdelset (&mask, SIGHUP);
1895
sigdelset (&mask, SIGINT);
1864
struct sigaction hup;
1865
struct sigaction term;
1868
ve_signal_add (SIGHUP, gdm_reread_config, NULL);
1870
hup.sa_handler = ve_signal_notify;
1872
sigemptyset (&hup.sa_mask);
1873
sigaddset (&hup.sa_mask, SIGCHLD);
1875
term.sa_handler = gdm_chooser_cancel;
1877
sigemptyset (&term.sa_mask);
1879
if (sigaction (SIGHUP, &hup, NULL) < 0) {
1880
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1881
"gdm_signals_init", "HUP", strerror (errno));
1884
if (sigaction (SIGINT, &term, NULL) < 0) {
1885
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1886
"gdm_signals_init", "INT", strerror (errno));
1889
if (sigaction (SIGTERM, &term, NULL) < 0) {
1890
gdm_common_fail_exit ("%s: Error setting up %s signal handler: %s",
1891
"gdm_signals_init", "TERM", strerror (errno));
1895
sigdelset (&mask, SIGTERM);
1896
sigdelset (&mask, SIGHUP);
1897
sigdelset (&mask, SIGINT);
1897
if (sigprocmask (SIG_SETMASK, &mask, NULL) == -1)
1898
gdm_common_fail_exit ("Could not set signal mask!");
1899
if (sigprocmask (SIG_SETMASK, &mask, NULL) == -1)
1900
gdm_common_fail_exit ("Could not set signal mask!");
1901
1903
GOptionEntry chooser_options [] = {
1902
{ "xdmaddress", '\0', 0, G_OPTION_ARG_STRING, &xdm_address,
1904
{ "xdmaddress", '\0', 0, G_OPTION_ARG_STRING, &xdm_address,
1903
1905
N_("Socket for xdm communication"), N_("SOCKET") },
1904
{ "clientaddress", '\0', 0, G_OPTION_ARG_STRING, &client_address,
1906
{ "clientaddress", '\0', 0, G_OPTION_ARG_STRING, &client_address,
1905
1907
N_("Client address to return in response to xdm"), N_("ADDRESS") },
1906
{ "connectionType", '\0', 0, G_OPTION_ARG_INT, &connection_type,
1908
{ "connectionType", '\0', 0, G_OPTION_ARG_INT, &connection_type,
1907
1909
N_("Connection type to return in response to xdm"), N_("TYPE") },
1908
{ G_OPTION_REMAINING, NULL, 0, G_OPTION_ARG_STRING_ARRAY, &chooser_hosts,
1910
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &chooser_hosts,
1913
1915
static gboolean
1914
1916
gdm_event (GSignalInvocationHint *ihint,
1941
1943
main (int argc, char *argv[])
1944
gchar **hosts_opt = NULL;
1945
GOptionContext *ctx;
1946
const char *gdm_version;
1950
stored_argv = g_new0 (char *, argc + 1);
1951
for (i = 0; i < argc; i++)
1952
stored_argv[i] = g_strdup (argv[i]);
1953
stored_argv[i] = NULL;
1956
if (g_getenv ("RUNNING_UNDER_GDM") != NULL)
1957
RUNNING_UNDER_GDM = TRUE;
1959
gdm_common_openlog ("gdmchooser", LOG_PID, LOG_DAEMON);
1961
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
1962
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1963
textdomain (GETTEXT_PACKAGE);
1965
gtk_init (&argc, &argv);
1967
ctx = g_option_context_new (_("- gdm login chooser"));
1968
g_option_context_add_main_entries(ctx, chooser_options, _("main options"));
1969
g_option_context_parse(ctx, &argc, &argv, NULL);
1970
g_option_context_free(ctx);
1974
/* Read all configuration at once, so the values get cached */
1977
GdmHosts = g_strdup (gdm_config_get_string (GDM_KEY_HOSTS));
1979
/* if broadcasting, then append BROADCAST to hosts */
1980
if (gdm_config_get_bool (GDM_KEY_BROADCAST)) {
1982
if (ve_string_empty (GdmHosts)) {
1985
tmp = g_strconcat (GdmHosts, ",BROADCAST", NULL);
1946
gchar **hosts_opt = NULL;
1947
GOptionContext *ctx;
1948
const char *gdm_version;
1952
stored_argv = g_new0 (char *, argc + 1);
1953
for (i = 0; i < argc; i++)
1954
stored_argv[i] = g_strdup (argv[i]);
1955
stored_argv[i] = NULL;
1958
if (g_getenv ("RUNNING_UNDER_GDM") != NULL)
1959
RUNNING_UNDER_GDM = TRUE;
1961
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
1962
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1963
textdomain (GETTEXT_PACKAGE);
1966
* gdm_common_atspi_launch () needs gdk initialized.
1967
* We cannot start gtk before the registry is running
1968
* because the atk-bridge will crash.
1970
gdk_init (&argc, &argv);
1971
gdm_common_atspi_launch ();
1973
gtk_init (&argc, &argv);
1975
ctx = g_option_context_new (_("- gdm login chooser"));
1976
g_option_context_add_main_entries(ctx, chooser_options, _("main options"));
1977
g_option_context_parse(ctx, &argc, &argv, NULL);
1978
g_option_context_free(ctx);
1982
gdm_common_log_init ();
1983
gdm_common_log_set_debug (gdm_config_get_bool (GDM_KEY_DEBUG));
1985
gdm_common_setup_builtin_icons ();
1987
/* Read all configuration at once, so the values get cached */
1990
GdmHosts = g_strdup (gdm_config_get_string (GDM_KEY_HOSTS));
1992
/* if broadcasting, then append BROADCAST to hosts */
1993
if (gdm_config_get_bool (GDM_KEY_BROADCAST)) {
1995
if (ve_string_empty (GdmHosts)) {
1998
tmp = g_strconcat (GdmHosts, ",BROADCAST", NULL);
1991
2004
#ifdef ENABLE_IPV6
1992
if (gdm_config_get_bool (GDM_KEY_MULTICAST)) {
1994
if (ve_string_empty (GdmHosts)) {
1997
tmp = g_strconcat (GdmHosts, ",MULTICAST", NULL);
2005
if (gdm_config_get_bool (GDM_KEY_MULTICAST)) {
2007
if (ve_string_empty (GdmHosts)) {
2010
tmp = g_strconcat (GdmHosts, ",MULTICAST", NULL);
2004
if (RUNNING_UNDER_GDM)
2005
gdm_wm_screen_init (gdm_config_get_int (GDM_KEY_XINERAMA_SCREEN));
2007
gdm_version = g_getenv ("GDM_VERSION");
2009
/* Load the background as early as possible so GDM does not leave */
2010
/* the background unfilled. The cursor should be a watch already */
2011
/* but just in case */
2012
if (RUNNING_UNDER_GDM) {
2013
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
2014
gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
2016
gdm_common_setup_cursor (GDK_WATCH);
2019
if (RUNNING_UNDER_GDM &&
2020
gdm_version != NULL &&
2021
strcmp (gdm_version, VERSION) != 0) {
2027
gdm_wm_focus_new_windows (TRUE);
2029
msg = g_strdup_printf (_("The chooser version (%s) does not match the daemon "
2031
"You have probably just upgraded GDM. "
2032
"Please restart the GDM daemon or the computer."),
2033
VERSION, gdm_version);
2035
dialog = ve_hig_dialog_new (NULL /* parent */,
2036
GTK_DIALOG_MODAL /* flags */,
2039
_("Cannot run chooser"),
2043
gtk_widget_show_all (dialog);
2044
gdm_wm_center_window (GTK_WINDOW (dialog));
2046
gdm_common_setup_cursor (GDK_LEFT_PTR);
2048
gtk_dialog_run (GTK_DIALOG (dialog));
2050
return EXIT_SUCCESS;
2017
if (RUNNING_UNDER_GDM)
2018
gdm_wm_screen_init (gdm_config_get_int (GDM_KEY_XINERAMA_SCREEN));
2020
gdm_version = g_getenv ("GDM_VERSION");
2022
/* Load the background as early as possible so GDM does not leave */
2023
/* the background unfilled. The cursor should be a watch already */
2024
/* but just in case */
2025
if (RUNNING_UNDER_GDM) {
2026
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
2027
gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
2029
gdm_common_setup_cursor (GDK_WATCH);
2032
if (RUNNING_UNDER_GDM &&
2033
gdm_version != NULL &&
2034
strcmp (gdm_version, VERSION) != 0) {
2040
gdm_wm_focus_new_windows (TRUE);
2042
msg = g_strdup_printf (_("The chooser version (%s) does not match the daemon "
2044
"You have probably just upgraded GDM. "
2045
"Please restart the GDM daemon or the computer."),
2046
VERSION, gdm_version);
2048
dialog = hig_dialog_new (NULL /* parent */,
2049
GTK_DIALOG_MODAL /* flags */,
2052
_("Cannot run chooser"),
2056
gtk_widget_show_all (dialog);
2057
gdm_wm_center_window (GTK_WINDOW (dialog));
2059
gdm_common_setup_cursor (GDK_LEFT_PTR);
2061
gtk_dialog_run (GTK_DIALOG (dialog));
2063
return EXIT_SUCCESS;
2053
gtk_window_set_default_icon_from_file (DATADIR"/pixmaps/gdm-xnest.png", NULL);
2055
gdm_chooser_gui_init ();
2056
gdm_chooser_signals_init ();
2058
/* when no hosts on the command line, take them from the config */
2059
if (hosts_opt == NULL ||
2060
hosts_opt[0] == NULL) {
2062
hosts_opt = g_strsplit (GdmHosts, ",", -1);
2063
for (i = 0; hosts_opt != NULL && hosts_opt[i] != NULL; i++) {
2064
g_strstrip (hosts_opt[i]);
2067
gdm_chooser_xdmcp_init (hosts_opt);
2068
g_strfreev (chooser_hosts);
2070
sid = g_signal_lookup ("event",
2072
g_signal_add_emission_hook (sid,
2076
NULL /* destroy_notify */);
2078
gtk_widget_queue_resize (chooser);
2079
gtk_widget_show_now (chooser);
2081
if (RUNNING_UNDER_GDM)
2082
gdm_wm_center_window (GTK_WINDOW (chooser));
2084
if (RUNNING_UNDER_GDM &&
2085
/* can it ever happen that it'd be NULL here ??? */
2086
chooser->window != NULL) {
2087
gdm_wm_init (GDK_WINDOW_XWINDOW (chooser->window));
2089
/* Run the focus, note that this will work no matter what
2090
* since gdm_wm_init will set the display to the gdk one
2092
gdm_wm_focus_window (GDK_WINDOW_XWINDOW (chooser->window));
2095
if (gdm_config_get_bool (GDM_KEY_ALLOW_ADD))
2096
gtk_widget_grab_focus (add_entry);
2098
gdm_chooser_add_entry_changed ();
2100
if (RUNNING_UNDER_GDM) {
2101
gdm_wm_restore_wm_order ();
2102
gdm_common_setup_cursor (GDK_LEFT_PTR);
2107
exit (EXIT_SUCCESS);
2066
gtk_window_set_default_icon_name ("gdm-xnest");
2068
gdm_chooser_gui_init ();
2069
gdm_chooser_signals_init ();
2071
/* when no hosts on the command line, take them from the config */
2072
if (hosts_opt == NULL ||
2073
hosts_opt[0] == NULL) {
2075
hosts_opt = g_strsplit (GdmHosts, ",", -1);
2076
for (i = 0; hosts_opt != NULL && hosts_opt[i] != NULL; i++) {
2077
g_strstrip (hosts_opt[i]);
2080
gdm_chooser_xdmcp_init (hosts_opt);
2081
g_strfreev (hosts_opt);
2083
sid = g_signal_lookup ("event",
2085
g_signal_add_emission_hook (sid,
2089
NULL /* destroy_notify */);
2091
gtk_widget_queue_resize (chooser);
2092
gtk_widget_show_now (chooser);
2094
if (RUNNING_UNDER_GDM)
2095
gdm_wm_center_window (GTK_WINDOW (chooser));
2097
if (RUNNING_UNDER_GDM &&
2098
/* can it ever happen that it'd be NULL here ??? */
2099
chooser->window != NULL) {
2100
gdm_wm_init (GDK_WINDOW_XWINDOW (chooser->window));
2102
/* Run the focus, note that this will work no matter what
2103
* since gdm_wm_init will set the display to the gdk one
2105
gdm_wm_focus_window (GDK_WINDOW_XWINDOW (chooser->window));
2108
if (gdm_config_get_bool (GDM_KEY_ALLOW_ADD))
2109
gtk_widget_grab_focus (add_entry);
2111
gdm_chooser_add_entry_changed ();
2113
if (RUNNING_UNDER_GDM) {
2114
gdm_wm_restore_wm_order ();
2115
gdm_common_setup_cursor (GDK_LEFT_PTR);
2120
exit (EXIT_SUCCESS);