1
/* $Id: xfsm-dns.c 4771 2005-01-12 15:25:24Z benny $ */
3
* Copyright (c) 2004 Benedikt Meurer <benny@xfce.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
* Parts of this file where taken from gnome-session/main.c, which
22
* was written by Tom Tromey.
29
#ifdef HAVE_SYS_TYPES_H
30
#include <sys/types.h>
32
#ifdef HAVE_SYS_SOCKET_H
33
#include <sys/socket.h>
35
#ifdef HAVE_SYS_UTSNAME_H
36
#include <sys/utsname.h>
54
#include <libxfcegui4/libxfcegui4.h>
56
#include <libxfsm/xfsm-util.h>
58
#include <xfce4-session/xfsm-global.h>
62
queryhostname (gchar *buffer, gsize length, gboolean readable)
64
#ifdef HAVE_GETHOSTNAME
65
if (gethostname (buffer, length) == 0)
68
struct utsname utsname;
69
if (uname (&utsname) == 0)
71
g_strlcpy (buffer, utsname.nodename, length);
77
g_strlcpy (buffer, _("(Unknown)"), length);
87
#ifdef HAVE_GETADDRINFO
88
struct addrinfo *result = NULL;
89
struct addrinfo hints;
94
hostname = queryhostname (buffer, 256, FALSE);
98
#ifdef HAVE_GETADDRINFO
99
bzero (&hints, sizeof (hints));
100
hints.ai_socktype = SOCK_STREAM;
101
hints.ai_flags = AI_CANONNAME;
103
if (getaddrinfo (hostname, NULL, &hints, &result) != 0)
106
if (g_ascii_strncasecmp (result->ai_canonname, hostname, 0) != 0)
109
#ifdef HAVE_GETHOSTBYNAME
110
if (gethostbyname (hostname) == NULL)
129
xfsm_dns_check (void)
131
GtkWidget *msgbox = NULL;
135
while (!check_for_dns ())
139
queryhostname (hostname, 256, TRUE);
141
msgbox = gtk_message_dialog_new (NULL, 0,
144
_("Could not look up internet address for %s.\n"
145
"This will prevent Xfce from operating correctly.\n"
146
"It may be possible to correct the problem by adding\n"
147
"%s to the file /etc/hosts on your system."),
150
gtk_dialog_add_buttons (GTK_DIALOG (msgbox),
151
_("Continue anyway"), RESPONSE_LOG_IN,
152
_("Try again"), RESPONSE_TRY_AGAIN,
155
xfsm_window_add_border (GTK_WINDOW (msgbox));
156
xfce_gtk_window_center_on_monitor_with_pointer (GTK_WINDOW (msgbox));
159
gtk_dialog_set_default_response (GTK_DIALOG (msgbox), RESPONSE_TRY_AGAIN);
161
response = xfsm_splash_screen_run (splash_screen, msgbox);
162
if (response != RESPONSE_TRY_AGAIN)
165
gtk_widget_hide (msgbox);
169
gtk_widget_destroy (msgbox);