|
|
75a7a3 |
From d32365ddb729e94f7ebf650ef526f7f5319dfe4c Mon Sep 17 00:00:00 2001
|
|
|
75a7a3 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
75a7a3 |
Date: Fri, 31 Mar 2017 15:40:21 -0400
|
|
|
75a7a3 |
Subject: [PATCH 13/13] chooser: filter out duplicate hostnames
|
|
|
75a7a3 |
|
|
|
75a7a3 |
One host may report itself on multiple interfaces.
|
|
|
75a7a3 |
GDM only supports based on hostname not interface,
|
|
|
75a7a3 |
so that leads duplicate entries in the list.
|
|
|
75a7a3 |
|
|
|
75a7a3 |
This commit filters out the dupes.
|
|
|
75a7a3 |
---
|
|
|
75a7a3 |
chooser/gdm-host-chooser-widget.c | 34 +++++++++++++++++++++++++++++++++-
|
|
|
75a7a3 |
1 file changed, 33 insertions(+), 1 deletion(-)
|
|
|
75a7a3 |
|
|
|
75a7a3 |
diff --git a/chooser/gdm-host-chooser-widget.c b/chooser/gdm-host-chooser-widget.c
|
|
|
75a7a3 |
index f8aabf3e..e2507900 100644
|
|
|
75a7a3 |
--- a/chooser/gdm-host-chooser-widget.c
|
|
|
75a7a3 |
+++ b/chooser/gdm-host-chooser-widget.c
|
|
|
75a7a3 |
@@ -92,70 +92,102 @@ static void gdm_host_chooser_widget_finalize (GObject *
|
|
|
75a7a3 |
|
|
|
75a7a3 |
G_DEFINE_TYPE (GdmHostChooserWidget, gdm_host_chooser_widget, GTK_TYPE_VBOX)
|
|
|
75a7a3 |
|
|
|
75a7a3 |
#define GDM_XDMCP_PROTOCOL_VERSION 1001
|
|
|
75a7a3 |
#define SCAN_TIMEOUT 30
|
|
|
75a7a3 |
#define PING_TIMEOUT 2
|
|
|
75a7a3 |
#define PING_TRIES 3
|
|
|
75a7a3 |
|
|
|
75a7a3 |
enum {
|
|
|
75a7a3 |
CHOOSER_LIST_ICON_COLUMN = 0,
|
|
|
75a7a3 |
CHOOSER_LIST_LABEL_COLUMN,
|
|
|
75a7a3 |
CHOOSER_LIST_HOST_COLUMN
|
|
|
75a7a3 |
};
|
|
|
75a7a3 |
|
|
|
75a7a3 |
static void
|
|
|
75a7a3 |
chooser_host_add (GdmHostChooserWidget *widget,
|
|
|
75a7a3 |
GdmChooserHost *host)
|
|
|
75a7a3 |
{
|
|
|
75a7a3 |
widget->priv->chooser_hosts = g_slist_prepend (widget->priv->chooser_hosts, host);
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
|
|
|
75a7a3 |
#if 0
|
|
|
75a7a3 |
static void
|
|
|
75a7a3 |
chooser_host_remove (GdmHostChooserWidget *widget,
|
|
|
75a7a3 |
GdmChooserHost *host)
|
|
|
75a7a3 |
{
|
|
|
75a7a3 |
widget->priv->chooser_hosts = g_slist_remove (widget->priv->chooser_hosts, host);
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
#endif
|
|
|
75a7a3 |
|
|
|
75a7a3 |
+static gboolean
|
|
|
75a7a3 |
+address_hostnames_equal (GdmAddress *address,
|
|
|
75a7a3 |
+ GdmAddress *other_address)
|
|
|
75a7a3 |
+{
|
|
|
75a7a3 |
+ char *hostname, *other_hostname;
|
|
|
75a7a3 |
+ gboolean are_equal;
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ if (gdm_address_equal (address, other_address)) {
|
|
|
75a7a3 |
+ return TRUE;
|
|
|
75a7a3 |
+ }
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ if (!gdm_address_get_hostname (address, &hostname)) {
|
|
|
75a7a3 |
+ gdm_address_get_numeric_info (address, &hostname, NULL);
|
|
|
75a7a3 |
+ }
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ if (!gdm_address_get_hostname (other_address, &other_hostname)) {
|
|
|
75a7a3 |
+ gdm_address_get_numeric_info (other_address, &other_hostname, NULL);
|
|
|
75a7a3 |
+ }
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ are_equal = g_strcmp0 (hostname, other_hostname) == 0;
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ g_free (hostname);
|
|
|
75a7a3 |
+ g_free (other_hostname);
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ return are_equal;
|
|
|
75a7a3 |
+}
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
static GdmChooserHost *
|
|
|
75a7a3 |
find_known_host (GdmHostChooserWidget *widget,
|
|
|
75a7a3 |
GdmAddress *address)
|
|
|
75a7a3 |
{
|
|
|
75a7a3 |
GSList *li;
|
|
|
75a7a3 |
GdmChooserHost *host;
|
|
|
75a7a3 |
|
|
|
75a7a3 |
for (li = widget->priv->chooser_hosts; li != NULL; li = li->next) {
|
|
|
75a7a3 |
+ GdmAddress *other_address;
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
host = li->data;
|
|
|
75a7a3 |
- if (gdm_address_equal (gdm_chooser_host_get_address (host), address)) {
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ other_address = gdm_chooser_host_get_address (host);
|
|
|
75a7a3 |
+
|
|
|
75a7a3 |
+ if (address_hostnames_equal (address, other_address)) {
|
|
|
75a7a3 |
goto out;
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
|
|
|
75a7a3 |
host = NULL;
|
|
|
75a7a3 |
out:
|
|
|
75a7a3 |
|
|
|
75a7a3 |
return host;
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
|
|
|
75a7a3 |
static void
|
|
|
75a7a3 |
browser_add_host (GdmHostChooserWidget *widget,
|
|
|
75a7a3 |
GdmChooserHost *host)
|
|
|
75a7a3 |
{
|
|
|
75a7a3 |
char *hostname;
|
|
|
75a7a3 |
char *name;
|
|
|
75a7a3 |
char *desc;
|
|
|
75a7a3 |
char *label;
|
|
|
75a7a3 |
GtkTreeModel *model;
|
|
|
75a7a3 |
GtkTreeIter iter;
|
|
|
75a7a3 |
gboolean res;
|
|
|
75a7a3 |
|
|
|
75a7a3 |
GtkTreeSelection *selection;
|
|
|
75a7a3 |
|
|
|
75a7a3 |
g_assert (host != NULL);
|
|
|
75a7a3 |
|
|
|
75a7a3 |
if (! gdm_chooser_host_get_willing (host)) {
|
|
|
75a7a3 |
gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
|
|
|
75a7a3 |
return;
|
|
|
75a7a3 |
}
|
|
|
75a7a3 |
--
|
|
|
75a7a3 |
2.12.0
|
|
|
75a7a3 |
|