View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001782 | gnunet-gtk | gnunet-setup | public | 2011-09-18 22:54 | 2012-02-28 11:06 |
| Reporter | Christian Grothoff | Assigned To | vminko | ||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | open | ||
| Product Version | 0.9.0 | ||||
| Target Version | 0.9.2 | Fixed in Version | 0.9.2 | ||
| Summary | 0001782: gnunet-setup always permits optional options of gnunet-hostlist-daemon | ||||
| Description | If GNUnet was compiled without MHD, offering a hostlist and/or advertising one's hostlist are not options gnunet-hostlist-daemon would support. gnunet-setup does not detect this and allows the user to select those options anyway. As a result, an "invalid" configuration is generated which then causes gnunet-daemon-hostlist to exit with an error message on startup (just to be re-started repeatedly by ARM). | ||||
| Tags | No tags attached. | ||||
| Attached Files | gnunet-bug1782-fix.patch (8,616 bytes)
Index: src/setup/gnunet-setup-hostlist-server.c
===================================================================
--- src/setup/gnunet-setup-hostlist-server.c (revision 0)
+++ src/setup/gnunet-setup-hostlist-server.c (revision 0)
@@ -0,0 +1,205 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/gnunet-setup-hostlist-server.c
+ * @brief (de)sensitize UI elements related to hostlist server configuration
+ * based on the build configuration of the hostlist daemon
+ * @author Christian Grothoff
+ */
+#include "gnunet-setup.h"
+#include <gnunet/gnunet_util_lib.h>
+
+
+/**
+ * Timeout for hostlist daemon to print help information
+ */
+#define CMD_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
+
+
+/**
+ * Function called to report the result of testing the hostlist daemon.
+ *
+ * @param cls closure
+ * @param result GNUNET_YES if the hostlist daemon has an integrated hostlist
+ * server, GNUNET_NO otherwise
+ */
+typedef void (*TestHostlistDaemonCallback) (void *cls,
+ int result);
+
+
+/**
+ * Context for running hostlist daemon and processing its output.
+ */
+struct CommandContext
+{
+ /**
+ * Handle to the command.
+ */
+ struct GNUNET_OS_CommandHandle *cmd;
+
+ /**
+ * Where to pass the result.
+ */
+ TestHostlistDaemonCallback callback;
+
+ /**
+ * Closure for the callback.
+ */
+ void *callback_cls;
+
+ /**
+ * GNUNET_YES if the target argument was found, GNUNET_NO otherwise.
+ */
+ int found;
+
+};
+
+
+void
+set_checkbutton_status (void *cls,
+ int result)
+{
+ GtkWidget * widget = cls;
+ GtkToggleButton *button;
+
+ if (GNUNET_YES != result)
+ {
+ gtk_widget_set_sensitive (widget, FALSE);
+ button = GTK_TOGGLE_BUTTON (widget);
+ if (button == NULL)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ /* also deactivate the checkbutton since this option could be enabled
+ by editing the config file manually */
+ gtk_toggle_button_set_active (button, FALSE);
+ }
+}
+
+
+void
+set_spinbutton_status (void *cls,
+ int result)
+{
+ GtkWidget * widget = cls;
+
+ if (GNUNET_YES != result)
+ gtk_widget_set_sensitive (widget, FALSE);
+}
+
+
+/**
+ * Process the output from the 'gnunet-daemon-hostlist -h' command
+ * to find out whether the hostlist daemon can provide a hostlist server.
+ *
+ * @param cls the 'struct CommandContext'
+ * @param line line of output, NULL at the end
+ */
+static void
+process_hostlist_daemon_output (void *cls, const char *line)
+{
+ struct CommandContext *ctx = cls;
+ char *t;
+ char *w;
+
+ if (NULL == line)
+ {
+ ctx->callback (ctx->callback_cls, ctx->found);
+ GNUNET_OS_command_stop (ctx->cmd);
+ GNUNET_free (ctx);
+ return;
+ }
+
+ t = GNUNET_strdup (line);
+ w = strtok (t, " ");
+ while (w != NULL)
+ {
+ if (0 == strcmp (w, "--provide-hostlist"))
+ {
+ ctx->found = GNUNET_YES;
+ break;
+ }
+ w = strtok (NULL, " ");
+ }
+ GNUNET_free (t);
+}
+
+
+/**
+ * Run 'gnunet-daemon-hostlist -h'. Output of this command will let us
+ * know whether the hostlist daemon can provide a hostlist server.
+ *
+ * @param callback function to call with the result
+ * @param cls closure for the callback
+ */
+static void
+test_hostlist_daemon (TestHostlistDaemonCallback callback,
+ void *cls)
+{
+ struct CommandContext *ctx;
+
+ ctx = GNUNET_malloc (sizeof (struct CommandContext));
+ ctx->callback = callback;
+ ctx->callback_cls = cls;
+ ctx->found = GNUNET_NO;
+ ctx->cmd = GNUNET_OS_command_run (&process_hostlist_daemon_output,
+ ctx,
+ CMD_TIMEOUT,
+ "gnunet-daemon-hostlist",
+ "gnunet-daemon-hostlist",
+ "-h",
+ NULL);
+ if (NULL == ctx->cmd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Could not determine whether the hostlist daemon has"
+ " an integrated hostlist server!\n"));
+ GNUNET_free (ctx);
+ }
+}
+
+
+void
+GNUNET_setup_hostlist_offer_hostlist_checkbutton_realize_cb (GtkWidget * widget,
+ gpointer user_data)
+{
+ test_hostlist_daemon (&set_checkbutton_status, widget);
+}
+
+
+void
+GNUNET_setup_hostlist_advertise_checkbutton_realize_cb (GtkWidget * widget,
+ gpointer user_data)
+{
+ test_hostlist_daemon (&set_checkbutton_status, widget);
+}
+
+
+void
+GNUNET_setup_hostlist_server_port_spin_button_realize_cb (GtkWidget * widget,
+ gpointer user_data)
+{
+ test_hostlist_daemon (&set_spinbutton_status, widget);
+}
+
+
+/* end of gnunet-setup-hostlist-server.c */
Index: src/setup/Makefile.am
===================================================================
--- src/setup/Makefile.am (revision 19098)
+++ src/setup/Makefile.am (working copy)
@@ -27,7 +27,8 @@
gnunet-setup-datastore-config.c \
gnunet-setup-datacache-plugins.c \
gnunet-setup-datacache-config.c \
- gnunet-setup-hostlist-editing.c
+ gnunet-setup-hostlist-editing.c \
+ gnunet-setup-hostlist-server.c
gnunet_setup_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ \
@@ -35,4 +36,4 @@
-lgnunetutil -lgnunetnat \
$(INTLLIBS)
gnunet_setup_LDFLAGS = \
- -export-dynamic
\ No newline at end of file
+ -export-dynamic
Index: contrib/gnunet_setup_gtk_main_window.glade
===================================================================
--- contrib/gnunet_setup_gtk_main_window.glade (revision 19098)
+++ contrib/gnunet_setup_gtk_main_window.glade (working copy)
@@ -421,6 +421,7 @@
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
+ <signal name="realize" handler="GNUNET_setup_hostlist_offer_hostlist_checkbutton_realize_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -437,6 +438,7 @@
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
+ <signal name="realize" handler="GNUNET_setup_hostlist_advertise_checkbutton_realize_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -473,6 +475,7 @@
<property name="secondary_icon_sensitive">True</property>
<property name="adjustment">GNUNET_setup_hostlist_server_port_adjustment</property>
<property name="numeric">True</property>
+ <signal name="realize" handler="GNUNET_setup_hostlist_server_port_spin_button_realize_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
| ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-09-18 22:54 | Christian Grothoff | New Issue | |
| 2011-09-18 22:54 | Christian Grothoff | Status | new => assigned |
| 2011-09-18 22:54 | Christian Grothoff | Assigned To | => Christian Grothoff |
| 2011-11-04 11:17 | Christian Grothoff | Priority | normal => low |
| 2011-12-01 10:02 | Christian Grothoff | Priority | low => high |
| 2011-12-01 10:02 | Christian Grothoff | Target Version | => 0.9.1 |
| 2011-12-11 12:32 | Christian Grothoff | Priority | high => normal |
| 2011-12-11 12:32 | Christian Grothoff | Status | assigned => confirmed |
| 2011-12-11 12:32 | Christian Grothoff | Target Version | 0.9.1 => |
| 2011-12-11 12:34 | Christian Grothoff | Assigned To | Christian Grothoff => |
| 2012-01-12 04:12 | vminko | File Added: gnunet-bug1782-fix.patch | |
| 2012-01-12 04:12 | vminko | Note Added: 0005258 | |
| 2012-01-12 09:35 | Christian Grothoff | Note Added: 0005259 | |
| 2012-01-12 09:35 | Christian Grothoff | Assigned To | => vminko |
| 2012-01-12 09:35 | Christian Grothoff | Status | confirmed => assigned |
| 2012-01-12 09:36 | Christian Grothoff | Status | assigned => resolved |
| 2012-01-12 09:36 | Christian Grothoff | Product Version | => 0.9.0 |
| 2012-01-12 09:36 | Christian Grothoff | Fixed in Version | => 0.9.2 |
| 2012-01-12 09:36 | Christian Grothoff | Target Version | => 0.9.2 |
| 2012-02-28 11:06 | Christian Grothoff | Status | resolved => closed |