aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-09 17:33:03 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-09 17:33:03 +0000
commitcf67709d29f38f66d76f997aab5140116b57d715 (patch)
tree95058c2f6cb6db3accaf4af35c312276e28f3f0d
parent474f9794b40f029e45e61cbfa2dd8a781a811ae1 (diff)
downloadgnunet-gtk-cf67709d29f38f66d76f997aab5140116b57d715.tar.gz
gnunet-gtk-cf67709d29f38f66d76f997aab5140116b57d715.zip
vminko: fixing 1734: adding code to detect duplicate port usage
-rw-r--r--AUTHORS2
-rw-r--r--src/setup/gnunet-setup-options.c270
-rw-r--r--src/setup/gnunet-setup-options.h21
-rw-r--r--src/setup/gnunet-setup.c4
4 files changed, 295 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index c01034ea..020506da 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,7 +8,7 @@ Nils Durner <durner@gnunet.org>
8Nicklas Larsson <whybill@gmail.com> 8Nicklas Larsson <whybill@gmail.com>
9Milan Bouchet-Valat <nalimilan@club.fr> 9Milan Bouchet-Valat <nalimilan@club.fr>
10Igor Wronsky <iwronsky@users.sourceforge.net> 10Igor Wronsky <iwronsky@users.sourceforge.net>
11 11Vitaly Minko <vitaly.minko@gmail.com>
12 12
13Images and other content from: 13Images and other content from:
14Jakub 'jimmac' Steiner <jimmac@ximian.org> 14Jakub 'jimmac' Steiner <jimmac@ximian.org>
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c
index 077f363b..7cbe5eea 100644
--- a/src/setup/gnunet-setup-options.c
+++ b/src/setup/gnunet-setup-options.c
@@ -38,6 +38,36 @@
38 */ 38 */
39#define REX_NO "^NO$" 39#define REX_NO "^NO$"
40 40
41/**
42 * Color for marking invalid input
43 */
44#define INVALID_INPUT_COLOR "red"
45
46
47/**
48 * Structs of this type specify connection between widgets storing
49 * port numbers and widgets controlling status of respective transport.
50 */
51struct PortSpecification
52{
53 /**
54 * Name of the GtkSpinButton storing the port value.
55 */
56 const char *spinbutton_name;
57
58 /**
59 * Name of the GtkCheckButton controlling whether the respective
60 * transport/daemon is enabled.
61 */
62 const char *checkbutton_name;
63
64 /**
65 * Name of the transport/daemon which owns this port.
66 */
67 const char *owner_name;
68
69};
70
41 71
42/** 72/**
43 * Initialize a toggle button based on an options 'yes/no' value. 73 * Initialize a toggle button based on an options 'yes/no' value.
@@ -312,6 +342,159 @@ save_number (const void *cls, const char *section, const char *option,
312 342
313 343
314/** 344/**
345 * NULL-terminated list of port specifications, which should be checked
346 * for collisions.
347 */
348static struct PortSpecification port_specifications[] = {
349 {
350 "GNUNET_setup_hostlist_server_port_spin_button",
351 "GNUNET_setup_hostlist_offer_hostlist_checkbutton",
352 gettext_noop ("the hostlist server"),},
353 {
354 "GNUNET_setup_transport_tcp_port_spinbutton",
355 "GNUNET_setup_transport_tcp_checkbutton",
356 gettext_noop ("the TCP transport plugin"),},
357 {
358 "GNUNET_setup_transport_http_port_spinbutton",
359 "GNUNET_setup_transport_http_checkbutton",
360 gettext_noop ("the HTTP transport plugin"),},
361 {
362 "GNUNET_setup_transport_https_port_spinbutton",
363 "GNUNET_setup_transport_https_checkbutton",
364 gettext_noop ("the HTTPS transport plugin"),},
365 {NULL, NULL}
366};
367
368
369/**
370 * Find spinbutton associated with a port specification.
371 *
372 * @param i index of the respective port specification
373 * @return spinbutton or NULL in case of an error or if respecitve transport is disabled
374 */
375static GtkSpinButton *
376get_port_spinbutton (unsigned int i)
377{
378 const char *sb_name;
379 const char *cb_name;
380 GtkWidget *widget;
381 GtkToggleButton *checkbt;
382 GtkSpinButton *spinbt;
383 gboolean mode;
384
385 if (port_specifications[i].spinbutton_name == NULL ||
386 port_specifications[i].checkbutton_name == NULL)
387 return NULL;
388 cb_name = port_specifications[i].checkbutton_name;
389 widget = GTK_WIDGET (GNUNET_SETUP_get_object (cb_name));
390 if (widget == NULL)
391 {
392 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"),
393 cb_name);
394 return NULL;
395 }
396 checkbt = GTK_TOGGLE_BUTTON (widget);
397 if (checkbt == NULL)
398 {
399 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
400 _("Specified widget `%s' is not a checkbutton\n"),
401 cb_name);
402 return NULL;
403 }
404 mode = gtk_toggle_button_get_active (checkbt);
405 if (TRUE != mode)
406 return NULL;
407
408 sb_name = port_specifications[i].spinbutton_name;
409 widget = GTK_WIDGET (GNUNET_SETUP_get_object (sb_name));
410 if (widget == NULL)
411 {
412 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"),
413 sb_name);
414 return NULL;
415 }
416 spinbt = GTK_SPIN_BUTTON (widget);
417 if (spinbt == NULL)
418 {
419 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
420 _("Specified widget `%s' is not a spinbutton\n"),
421 sb_name);
422 return NULL;
423 }
424 return spinbt;
425}
426
427
428/**
429 * Check port numbers for collisions and highlight conflicting ports, if any.
430 *
431 * @param cls closure (unused)
432 * @param widget widget whose state was changed (unused)
433 */
434static void
435highlight_port_collisions (const void *cls,
436 GObject *widget)
437{
438 unsigned int i;
439 unsigned int j;
440 unsigned int port;
441 GtkSpinButton *spinbt_i;
442 GtkSpinButton *spinbt_j;
443 GdkColor color;
444 GdkColor *pcolor;
445 int found;
446 char *tooltip;
447
448 gdk_color_parse (INVALID_INPUT_COLOR, &color);
449 for (i = 0;
450 port_specifications[i].spinbutton_name != NULL;
451 i++)
452 {
453 spinbt_i = get_port_spinbutton (i);
454 if (spinbt_i == NULL)
455 continue;
456 else
457 port = gtk_spin_button_get_value_as_int (spinbt_i);
458
459 found = GNUNET_NO;
460 for (j = 0;
461 port_specifications[j].spinbutton_name != NULL;
462 j++)
463 {
464 if (i == j) continue;
465 spinbt_j = get_port_spinbutton (j);
466 if (spinbt_j == NULL)
467 continue;
468 if (port == gtk_spin_button_get_value_as_int (spinbt_j))
469 {
470 found = GNUNET_YES;
471 break;
472 }
473 }
474 if (GNUNET_YES == found)
475 {
476 pcolor = &color;
477 GNUNET_asprintf (&tooltip, _("This port is already occupied by %s."),
478 port_specifications[j].owner_name);
479 }
480 else
481 {
482 pcolor = NULL;
483 tooltip = GNUNET_strdup ("");
484 }
485 gtk_widget_modify_text (GTK_WIDGET (spinbt_i),
486 GTK_STATE_NORMAL, pcolor);
487 gtk_widget_modify_text (GTK_WIDGET (spinbt_i),
488 GTK_STATE_ACTIVE, pcolor);
489 gtk_widget_modify_text (GTK_WIDGET (spinbt_i),
490 GTK_STATE_SELECTED, pcolor);
491 gtk_widget_set_tooltip_text (GTK_WIDGET (spinbt_i), tooltip);
492 GNUNET_free (tooltip);
493 }
494}
495
496
497/**
315 * Initialize a toggle button based on the existence of a word 498 * Initialize a toggle button based on the existence of a word
316 * in an option value. 499 * in an option value.
317 * 500 *
@@ -1465,6 +1648,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1465 "https://gnunet.org/configuration-f2f", 1648 "https://gnunet.org/configuration-f2f",
1466 &load_yes_no, 1649 &load_yes_no,
1467 &save_yes_no, NULL, 1650 &save_yes_no, NULL,
1651 NULL, NULL,
1468 hide_min_connected_friends}, 1652 hide_min_connected_friends},
1469 1653
1470 { 1654 {
@@ -1476,6 +1660,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1476 "https://gnunet.org/configuration-f2f", 1660 "https://gnunet.org/configuration-f2f",
1477 &load_filename, 1661 &load_filename,
1478 &save_filename, NULL, 1662 &save_filename, NULL,
1663 NULL, NULL,
1479 NULL}, 1664 NULL},
1480 1665
1481 { 1666 {
@@ -1487,6 +1672,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1487 "https://gnunet.org/configuration-f2f", 1672 "https://gnunet.org/configuration-f2f",
1488 &load_number, 1673 &load_number,
1489 &save_number, NULL, 1674 &save_number, NULL,
1675 NULL, NULL,
1490 NULL}, 1676 NULL},
1491 1677
1492 { 1678 {
@@ -1498,6 +1684,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1498 "https://gnunet.org/configuration-topology", 1684 "https://gnunet.org/configuration-topology",
1499 &load_option_list, 1685 &load_option_list,
1500 &save_option_list, "topology", 1686 &save_option_list, "topology",
1687 NULL, NULL,
1501 NULL}, 1688 NULL},
1502 1689
1503 { 1690 {
@@ -1510,6 +1697,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1510 "https://gnunet.org/configuration-hostlist", 1697 "https://gnunet.org/configuration-hostlist",
1511 &load_option_list, 1698 &load_option_list,
1512 &save_option_list, "hostlist", 1699 &save_option_list, "hostlist",
1700 NULL, NULL,
1513 hide_hostlist_options}, 1701 hide_hostlist_options},
1514 1702
1515 1703
@@ -1522,6 +1710,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1522 "https://gnunet.org/configuration-fs", 1710 "https://gnunet.org/configuration-fs",
1523 &load_option_list, 1711 &load_option_list,
1524 &save_option_list, "fs", 1712 &save_option_list, "fs",
1713 NULL, NULL,
1525 hide_fs_tab}, 1714 hide_fs_tab},
1526 1715
1527 { 1716 {
@@ -1533,6 +1722,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1533 "https://gnunet.org/configuration-vpn", 1722 "https://gnunet.org/configuration-vpn",
1534 &load_option_list, 1723 &load_option_list,
1535 &save_option_list, "vpn", 1724 &save_option_list, "vpn",
1725 NULL, NULL,
1536 hide_vpn_tab}, 1726 hide_vpn_tab},
1537 1727
1538 { 1728 {
@@ -1544,6 +1734,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1544 "https://gnunet.org/configuration-hostlist", 1734 "https://gnunet.org/configuration-hostlist",
1545 &load_option_list, 1735 &load_option_list,
1546 &save_option_list, "-b", 1736 &save_option_list, "-b",
1737 NULL, NULL,
1547 NULL}, 1738 NULL},
1548 1739
1549 { 1740 {
@@ -1555,6 +1746,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1555 "https://gnunet.org/configuration-hostlist", 1746 "https://gnunet.org/configuration-hostlist",
1556 &load_option_list, 1747 &load_option_list,
1557 &save_option_list, "-e", 1748 &save_option_list, "-e",
1749 NULL, NULL,
1558 NULL}, 1750 NULL},
1559 1751
1560 { 1752 {
@@ -1566,6 +1758,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1566 "https://gnunet.org/configuration-hostlist-server", 1758 "https://gnunet.org/configuration-hostlist-server",
1567 &load_option_list, 1759 &load_option_list,
1568 &save_option_list, "-p", 1760 &save_option_list, "-p",
1761 &highlight_port_collisions, NULL,
1569 hide_hostlist_server_options}, 1762 hide_hostlist_server_options},
1570 1763
1571 { 1764 {
@@ -1577,6 +1770,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1577 "https://gnunet.org/configuration-hostlist-server", 1770 "https://gnunet.org/configuration-hostlist-server",
1578 &load_option_list, 1771 &load_option_list,
1579 &save_option_list, "-a", 1772 &save_option_list, "-a",
1773 NULL, NULL,
1580 NULL}, 1774 NULL},
1581 1775
1582 { 1776 {
@@ -1588,6 +1782,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1588 "https://gnunet.org/configuration-hostlist-server", 1782 "https://gnunet.org/configuration-hostlist-server",
1589 &load_number, 1783 &load_number,
1590 &save_number, NULL, 1784 &save_number, NULL,
1785 &highlight_port_collisions, NULL,
1591 NULL}, 1786 NULL},
1592 1787
1593 { 1788 {
@@ -1598,6 +1793,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1598 NULL, NULL, 1793 NULL, NULL,
1599 &load_string_list_store, 1794 &load_string_list_store,
1600 &save_string_list_store, NULL, 1795 &save_string_list_store, NULL,
1796 NULL, NULL,
1601 NULL}, 1797 NULL},
1602 1798
1603 { 1799 {
@@ -1606,6 +1802,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1606 gettext_noop ("Known hostlist URLs"), 1802 gettext_noop ("Known hostlist URLs"),
1607 "https://gnunet.org/configuration-hostlist", 1803 "https://gnunet.org/configuration-hostlist",
1608 NULL, NULL, NULL, /* FIXME */ 1804 NULL, NULL, NULL, /* FIXME */
1805 NULL, NULL,
1609 NULL}, 1806 NULL},
1610 1807
1611 { 1808 {
@@ -1617,6 +1814,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1617 "https://gnunet.org/configuration-bandwidth", 1814 "https://gnunet.org/configuration-bandwidth",
1618 &load_number, 1815 &load_number,
1619 &save_number, NULL, 1816 &save_number, NULL,
1817 NULL, NULL,
1620 NULL}, 1818 NULL},
1621 1819
1622 { 1820 {
@@ -1628,6 +1826,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1628 "https://gnunet.org/configuration-bandwidth", 1826 "https://gnunet.org/configuration-bandwidth",
1629 &load_number, 1827 &load_number,
1630 &save_number, NULL, 1828 &save_number, NULL,
1829 NULL, NULL,
1631 NULL}, 1830 NULL},
1632 1831
1633 /* Transport TAB */ 1832 /* Transport TAB */
@@ -1641,6 +1840,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1641 "https://gnunet.org/configuration-tcp", 1840 "https://gnunet.org/configuration-tcp",
1642 &load_option_list, 1841 &load_option_list,
1643 &save_option_list, "tcp", 1842 &save_option_list, "tcp",
1843 &highlight_port_collisions, NULL,
1644 hide_tcp_tab}, 1844 hide_tcp_tab},
1645 1845
1646 { 1846 {
@@ -1652,6 +1852,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1652 "https://gnunet.org/configuration-udp", 1852 "https://gnunet.org/configuration-udp",
1653 &load_option_list, 1853 &load_option_list,
1654 &save_option_list, "udp", 1854 &save_option_list, "udp",
1855 NULL, NULL,
1655 hide_udp_tab}, 1856 hide_udp_tab},
1656 1857
1657 { 1858 {
@@ -1663,6 +1864,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1663 "https://gnunet.org/configuration-http", 1864 "https://gnunet.org/configuration-http",
1664 &load_option_list, 1865 &load_option_list,
1665 &save_option_list, "http", 1866 &save_option_list, "http",
1867 &highlight_port_collisions, NULL,
1666 hide_http_tab}, 1868 hide_http_tab},
1667 1869
1668 { 1870 {
@@ -1674,6 +1876,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1674 "https://gnunet.org/configuration-https", 1876 "https://gnunet.org/configuration-https",
1675 &load_option_list, 1877 &load_option_list,
1676 &save_option_list, "https", 1878 &save_option_list, "https",
1879 &highlight_port_collisions, NULL,
1677 hide_https_tab}, 1880 hide_https_tab},
1678 1881
1679 { 1882 {
@@ -1685,6 +1888,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1685 "https://gnunet.org/configuration-dv", 1888 "https://gnunet.org/configuration-dv",
1686 &load_option_list, 1889 &load_option_list,
1687 &save_option_list, "dv", 1890 &save_option_list, "dv",
1891 NULL, NULL,
1688 hide_dv_tab}, 1892 hide_dv_tab},
1689 1893
1690 { 1894 {
@@ -1696,6 +1900,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1696 "https://gnunet.org/configuration-wlan", 1900 "https://gnunet.org/configuration-wlan",
1697 &load_option_list, 1901 &load_option_list,
1698 &save_option_list, "wlan", 1902 &save_option_list, "wlan",
1903 NULL, NULL,
1699 hide_wlan_tab}, 1904 hide_wlan_tab},
1700 1905
1701 { 1906 {
@@ -1707,6 +1912,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1707 "https://gnunet.org/configuration-tcp", 1912 "https://gnunet.org/configuration-tcp",
1708 &load_number, 1913 &load_number,
1709 &save_number, NULL, 1914 &save_number, NULL,
1915 &highlight_port_collisions, NULL,
1710 hide_all_tcp_options}, 1916 hide_all_tcp_options},
1711 1917
1712 { 1918 {
@@ -1718,6 +1924,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1718 "https://gnunet.org/configuration-tcp", 1924 "https://gnunet.org/configuration-tcp",
1719 &load_number, 1925 &load_number,
1720 &save_number, NULL, 1926 &save_number, NULL,
1927 NULL, NULL,
1721 NULL}, 1928 NULL},
1722 1929
1723 { 1930 {
@@ -1729,6 +1936,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1729 "https://gnunet.org/configuration-nat", 1936 "https://gnunet.org/configuration-nat",
1730 &load_yes_no, 1937 &load_yes_no,
1731 &save_yes_no, NULL, 1938 &save_yes_no, NULL,
1939 NULL, NULL,
1732 toggle_nat_options}, 1940 toggle_nat_options},
1733 1941
1734 { 1942 {
@@ -1740,6 +1948,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1740 "https://gnunet.org/configuration-nat", 1948 "https://gnunet.org/configuration-nat",
1741 &load_yes_no, 1949 &load_yes_no,
1742 &save_yes_no, NULL, 1950 &save_yes_no, NULL,
1951 NULL, NULL,
1743 toggle_nat_punched_options}, 1952 toggle_nat_punched_options},
1744 1953
1745 { 1954 {
@@ -1751,6 +1960,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1751 "https://gnunet.org/configuration-nat", 1960 "https://gnunet.org/configuration-nat",
1752 &load_yes_no, 1961 &load_yes_no,
1753 &save_yes_no, NULL, 1962 &save_yes_no, NULL,
1963 NULL, NULL,
1754 NULL, 1964 NULL,
1755 }, 1965 },
1756 1966
@@ -1763,6 +1973,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1763 "https://gnunet.org/configuration-nat", 1973 "https://gnunet.org/configuration-nat",
1764 &load_yes_no, 1974 &load_yes_no,
1765 &save_yes_no, NULL, 1975 &save_yes_no, NULL,
1976 NULL, NULL,
1766 NULL, 1977 NULL,
1767 }, 1978 },
1768 1979
@@ -1775,6 +1986,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1775 "https://gnunet.org/configuration-nat", 1986 "https://gnunet.org/configuration-nat",
1776 &load_text, 1987 &load_text,
1777 &save_text, NULL, 1988 &save_text, NULL,
1989 NULL, NULL,
1778 NULL}, 1990 NULL},
1779 1991
1780 { 1992 {
@@ -1786,6 +1998,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1786 "https://gnunet.org/configuration-nat", 1998 "https://gnunet.org/configuration-nat",
1787 &load_yes_no, 1999 &load_yes_no,
1788 &save_yes_no, NULL, 2000 &save_yes_no, NULL,
2001 NULL, NULL,
1789 toggle_internal_ip}, 2002 toggle_internal_ip},
1790 2003
1791 { 2004 {
@@ -1797,6 +2010,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1797 "https://gnunet.org/configuration-nat", 2010 "https://gnunet.org/configuration-nat",
1798 &load_text, 2011 &load_text,
1799 &save_text, NULL, 2012 &save_text, NULL,
2013 NULL, NULL,
1800 NULL}, 2014 NULL},
1801 2015
1802 { 2016 {
@@ -1808,6 +2022,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1808 "https://gnunet.org/configuration-ipv6", 2022 "https://gnunet.org/configuration-ipv6",
1809 &load_yes_no, 2023 &load_yes_no,
1810 &save_yes_no, NULL, 2024 &save_yes_no, NULL,
2025 NULL, NULL,
1811 NULL, 2026 NULL,
1812 }, 2027 },
1813 2028
@@ -1820,6 +2035,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1820 "https://gnunet.org/configuration-udp", 2035 "https://gnunet.org/configuration-udp",
1821 &load_number, 2036 &load_number,
1822 &save_number, NULL, 2037 &save_number, NULL,
2038 NULL, NULL,
1823 NULL}, 2039 NULL},
1824 2040
1825 { 2041 {
@@ -1831,6 +2047,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1831 "https://gnunet.org/configuration-http", 2047 "https://gnunet.org/configuration-http",
1832 &load_number, 2048 &load_number,
1833 &save_number, NULL, 2049 &save_number, NULL,
2050 &highlight_port_collisions, NULL,
1834 NULL}, 2051 NULL},
1835 2052
1836 { 2053 {
@@ -1842,6 +2059,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1842 "https://gnunet.org/configuration-https", 2059 "https://gnunet.org/configuration-https",
1843 &load_number, 2060 &load_number,
1844 &save_number, NULL, 2061 &save_number, NULL,
2062 &highlight_port_collisions, NULL,
1845 NULL}, 2063 NULL},
1846 2064
1847 /* FS TAB */ 2065 /* FS TAB */
@@ -1855,6 +2073,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1855 "https://gnunet.org/configuration-datastore", 2073 "https://gnunet.org/configuration-datastore",
1856 &load_option_list /* abuse! */ , 2074 &load_option_list /* abuse! */ ,
1857 &save_option_list /* abuse! */ , "sqlite", 2075 &save_option_list /* abuse! */ , "sqlite",
2076 NULL, NULL,
1858 hide_sqlite_datastore_tab}, 2077 hide_sqlite_datastore_tab},
1859 2078
1860 { 2079 {
@@ -1866,6 +2085,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1866 "https://gnunet.org/configuration-datastore", 2085 "https://gnunet.org/configuration-datastore",
1867 &load_option_list /* abuse! */ , 2086 &load_option_list /* abuse! */ ,
1868 &save_option_list /* abuse! */ , "mysql", 2087 &save_option_list /* abuse! */ , "mysql",
2088 NULL, NULL,
1869 hide_mysql_datastore_tab}, 2089 hide_mysql_datastore_tab},
1870 2090
1871 { 2091 {
@@ -1877,6 +2097,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1877 "https://gnunet.org/configuration-datastore", 2097 "https://gnunet.org/configuration-datastore",
1878 &load_option_list /* abuse! */ , 2098 &load_option_list /* abuse! */ ,
1879 &save_option_list /* abuse! */ , "postgres", 2099 &save_option_list /* abuse! */ , "postgres",
2100 NULL, NULL,
1880 hide_postgres_datastore_tab}, 2101 hide_postgres_datastore_tab},
1881 2102
1882 { 2103 {
@@ -1888,6 +2109,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1888 "https://gnunet.org/configuration-datastore", 2109 "https://gnunet.org/configuration-datastore",
1889 &load_text, 2110 &load_text,
1890 &save_text, NULL, 2111 &save_text, NULL,
2112 NULL, NULL,
1891 NULL}, 2113 NULL},
1892 2114
1893 { 2115 {
@@ -1899,6 +2121,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1899 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", 2121 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html",
1900 &load_filename, 2122 &load_filename,
1901 &save_filename, NULL, 2123 &save_filename, NULL,
2124 NULL, NULL,
1902 NULL}, 2125 NULL},
1903 2126
1904 { 2127 {
@@ -1910,6 +2133,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1910 "https://gnunet.org/configuration-datastore", 2133 "https://gnunet.org/configuration-datastore",
1911 &load_text, 2134 &load_text,
1912 &save_text, NULL, 2135 &save_text, NULL,
2136 NULL, NULL,
1913 NULL}, 2137 NULL},
1914 2138
1915 { 2139 {
@@ -1921,6 +2145,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1921 "https://gnunet.org/configuration-datastore", 2145 "https://gnunet.org/configuration-datastore",
1922 &load_text, 2146 &load_text,
1923 &save_text, NULL, 2147 &save_text, NULL,
2148 NULL, NULL,
1924 NULL}, 2149 NULL},
1925 2150
1926 { 2151 {
@@ -1932,6 +2157,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1932 "https://gnunet.org/configuration-datastore", 2157 "https://gnunet.org/configuration-datastore",
1933 &load_text, 2158 &load_text,
1934 &save_text, NULL, 2159 &save_text, NULL,
2160 NULL, NULL,
1935 NULL}, 2161 NULL},
1936 2162
1937 { 2163 {
@@ -1943,6 +2169,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1943 "https://gnunet.org/configuration-datastore", 2169 "https://gnunet.org/configuration-datastore",
1944 &load_number, 2170 &load_number,
1945 &save_number, NULL, 2171 &save_number, NULL,
2172 NULL, NULL,
1946 NULL}, 2173 NULL},
1947 2174
1948 { 2175 {
@@ -1954,6 +2181,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1954 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", 2181 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT",
1955 &load_text, 2182 &load_text,
1956 &save_text, NULL, 2183 &save_text, NULL,
2184 NULL, NULL,
1957 NULL}, 2185 NULL},
1958 2186
1959 2187
@@ -1966,6 +2194,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1966 "https://gnunet.org/configuration-fs", 2194 "https://gnunet.org/configuration-fs",
1967 &load_yes_no, 2195 &load_yes_no,
1968 &save_yes_no, NULL, 2196 &save_yes_no, NULL,
2197 NULL, NULL,
1969 NULL}, 2198 NULL},
1970 2199
1971 { 2200 {
@@ -1977,6 +2206,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1977 "https://gnunet.org/configuration-fs", 2206 "https://gnunet.org/configuration-fs",
1978 &load_yes_no, 2207 &load_yes_no,
1979 &save_yes_no, NULL, 2208 &save_yes_no, NULL,
2209 NULL, NULL,
1980 NULL}, 2210 NULL},
1981 2211
1982 { 2212 {
@@ -1988,6 +2218,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1988 "https://gnunet.org/configuration-datacache", 2218 "https://gnunet.org/configuration-datacache",
1989 &load_option_list /* abuse! */ , 2219 &load_option_list /* abuse! */ ,
1990 &save_option_list /* abuse! */ , "sqlite", 2220 &save_option_list /* abuse! */ , "sqlite",
2221 NULL, NULL,
1991 hide_sqlite_datacache_tab}, 2222 hide_sqlite_datacache_tab},
1992 2223
1993 { 2224 {
@@ -1999,6 +2230,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1999 "https://gnunet.org/configuration-datacache", 2230 "https://gnunet.org/configuration-datacache",
2000 &load_option_list /* abuse! */ , 2231 &load_option_list /* abuse! */ ,
2001 &save_option_list /* abuse! */ , "mysql", 2232 &save_option_list /* abuse! */ , "mysql",
2233 NULL, NULL,
2002 hide_mysql_datacache_tab}, 2234 hide_mysql_datacache_tab},
2003 2235
2004 { 2236 {
@@ -2010,6 +2242,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2010 "https://gnunet.org/configuration-datacache", 2242 "https://gnunet.org/configuration-datacache",
2011 &load_option_list /* abuse! */ , 2243 &load_option_list /* abuse! */ ,
2012 &save_option_list /* abuse! */ , "postgres", 2244 &save_option_list /* abuse! */ , "postgres",
2245 NULL, NULL,
2013 hide_postgres_datacache_tab}, 2246 hide_postgres_datacache_tab},
2014 2247
2015 { 2248 {
@@ -2021,6 +2254,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2021 "https://gnunet.org/configuration-datacache", 2254 "https://gnunet.org/configuration-datacache",
2022 &load_text, 2255 &load_text,
2023 &save_text, NULL, 2256 &save_text, NULL,
2257 NULL, NULL,
2024 NULL}, 2258 NULL},
2025 2259
2026 { 2260 {
@@ -2032,6 +2266,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2032 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html", 2266 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html",
2033 &load_filename, 2267 &load_filename,
2034 &save_filename, NULL, 2268 &save_filename, NULL,
2269 NULL, NULL,
2035 NULL}, 2270 NULL},
2036 2271
2037 { 2272 {
@@ -2043,6 +2278,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2043 "https://gnunet.org/configuration-datacache", 2278 "https://gnunet.org/configuration-datacache",
2044 &load_text, 2279 &load_text,
2045 &save_text, NULL, 2280 &save_text, NULL,
2281 NULL, NULL,
2046 NULL}, 2282 NULL},
2047 2283
2048 { 2284 {
@@ -2054,6 +2290,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2054 "https://gnunet.org/configuration-datacache", 2290 "https://gnunet.org/configuration-datacache",
2055 &load_text, 2291 &load_text,
2056 &save_text, NULL, 2292 &save_text, NULL,
2293 NULL, NULL,
2057 NULL}, 2294 NULL},
2058 2295
2059 { 2296 {
@@ -2065,6 +2302,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2065 "https://gnunet.org/configuration-datacache", 2302 "https://gnunet.org/configuration-datacache",
2066 &load_text, 2303 &load_text,
2067 &save_text, NULL, 2304 &save_text, NULL,
2305 NULL, NULL,
2068 NULL}, 2306 NULL},
2069 2307
2070 { 2308 {
@@ -2076,6 +2314,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2076 "https://gnunet.org/configuration-wlan", 2314 "https://gnunet.org/configuration-wlan",
2077 &load_text, 2315 &load_text,
2078 &save_text, NULL, 2316 &save_text, NULL,
2317 NULL, NULL,
2079 NULL}, 2318 NULL},
2080 2319
2081 { 2320 {
@@ -2087,6 +2326,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2087 "https://gnunet.org/configuration-datacache", 2326 "https://gnunet.org/configuration-datacache",
2088 &load_number, 2327 &load_number,
2089 &save_number, NULL, 2328 &save_number, NULL,
2329 NULL, NULL,
2090 NULL}, 2330 NULL},
2091 2331
2092 { 2332 {
@@ -2098,6 +2338,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2098 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT", 2338 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT",
2099 &load_text, 2339 &load_text,
2100 &save_text, NULL, 2340 &save_text, NULL,
2341 NULL, NULL,
2101 NULL}, 2342 NULL},
2102 2343
2103 { 2344 {
@@ -2109,6 +2350,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2109 "https://gnunet.org/configuration-vpn", 2350 "https://gnunet.org/configuration-vpn",
2110 &load_text, 2351 &load_text,
2111 &save_text, NULL, 2352 &save_text, NULL,
2353 NULL, NULL,
2112 NULL}, 2354 NULL},
2113 2355
2114 { 2356 {
@@ -2120,6 +2362,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2120 "https://gnunet.org/configuration-vpn", 2362 "https://gnunet.org/configuration-vpn",
2121 &load_text, 2363 &load_text,
2122 &save_text, NULL, 2364 &save_text, NULL,
2365 NULL, NULL,
2123 NULL}, 2366 NULL},
2124 2367
2125 { 2368 {
@@ -2131,6 +2374,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2131 "https://gnunet.org/configuration-vpn", 2374 "https://gnunet.org/configuration-vpn",
2132 &load_text, 2375 &load_text,
2133 &save_text, NULL, 2376 &save_text, NULL,
2377 NULL, NULL,
2134 NULL}, 2378 NULL},
2135 2379
2136 { 2380 {
@@ -2142,6 +2386,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2142 "https://gnunet.org/configuration-vpn", 2386 "https://gnunet.org/configuration-vpn",
2143 &load_text, 2387 &load_text,
2144 &save_text, NULL, 2388 &save_text, NULL,
2389 NULL, NULL,
2145 NULL}, 2390 NULL},
2146 2391
2147 { 2392 {
@@ -2153,6 +2398,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2153 "https://gnunet.org/configuration-vpn", 2398 "https://gnunet.org/configuration-vpn",
2154 &load_number, 2399 &load_number,
2155 &save_number, NULL, 2400 &save_number, NULL,
2401 NULL, NULL,
2156 NULL}, 2402 NULL},
2157 2403
2158 { 2404 {
@@ -2165,6 +2411,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2165 "https://gnunet.org/configuration-vpn", 2411 "https://gnunet.org/configuration-vpn",
2166 &load_text, 2412 &load_text,
2167 &save_text, NULL, 2413 &save_text, NULL,
2414 NULL, NULL,
2168 NULL}, 2415 NULL},
2169 2416
2170 { 2417 {
@@ -2177,6 +2424,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2177 "https://gnunet.org/configuration-exit", 2424 "https://gnunet.org/configuration-exit",
2178 &load_option_list, 2425 &load_option_list,
2179 &save_option_list, "exit", 2426 &save_option_list, "exit",
2427 NULL, NULL,
2180 hide_exit_options}, 2428 hide_exit_options},
2181 2429
2182 { 2430 {
@@ -2189,6 +2437,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2189 "https://gnunet.org/configuration-dns", 2437 "https://gnunet.org/configuration-dns",
2190 &load_yes_no, 2438 &load_yes_no,
2191 &save_yes_no, NULL, 2439 &save_yes_no, NULL,
2440 NULL, NULL,
2192 NULL}, 2441 NULL},
2193 2442
2194 { 2443 {
@@ -2201,6 +2450,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2201 "https://gnunet.org/configuration-exit", 2450 "https://gnunet.org/configuration-exit",
2202 &load_text, 2451 &load_text,
2203 &save_text, NULL, 2452 &save_text, NULL,
2453 NULL, NULL,
2204 NULL}, 2454 NULL},
2205 2455
2206 { 2456 {
@@ -2212,6 +2462,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2212 "https://gnunet.org/configuration-exit", 2462 "https://gnunet.org/configuration-exit",
2213 &load_text, 2463 &load_text,
2214 &save_text, NULL, 2464 &save_text, NULL,
2465 NULL, NULL,
2215 NULL}, 2466 NULL},
2216 2467
2217 { 2468 {
@@ -2223,6 +2474,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2223 "https://gnunet.org/configuration-exit", 2474 "https://gnunet.org/configuration-exit",
2224 &load_text, 2475 &load_text,
2225 &save_text, NULL, 2476 &save_text, NULL,
2477 NULL, NULL,
2226 NULL}, 2478 NULL},
2227 2479
2228 { 2480 {
@@ -2234,6 +2486,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2234 "https://gnunet.org/configuration-exit", 2486 "https://gnunet.org/configuration-exit",
2235 &load_text, 2487 &load_text,
2236 &save_text, NULL, 2488 &save_text, NULL,
2489 NULL, NULL,
2237 NULL}, 2490 NULL},
2238 2491
2239 { 2492 {
@@ -2246,6 +2499,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2246 "https://gnunet.org/configuration-exit", 2499 "https://gnunet.org/configuration-exit",
2247 &load_number, 2500 &load_number,
2248 &save_number, NULL, 2501 &save_number, NULL,
2502 NULL, NULL,
2249 NULL}, 2503 NULL},
2250 2504
2251 2505
@@ -2259,6 +2513,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2259 "https://gnunet.org/configuration-exit", 2513 "https://gnunet.org/configuration-exit",
2260 &load_yes_no, 2514 &load_yes_no,
2261 &save_yes_no, NULL, 2515 &save_yes_no, NULL,
2516 NULL, NULL,
2262 NULL}, 2517 NULL},
2263 2518
2264 { 2519 {
@@ -2271,6 +2526,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2271 "https://gnunet.org/configuration-exit", 2526 "https://gnunet.org/configuration-exit",
2272 &load_yes_no, 2527 &load_yes_no,
2273 &save_yes_no, NULL, 2528 &save_yes_no, NULL,
2529 NULL, NULL,
2274 NULL}, 2530 NULL},
2275 2531
2276 /* DNS treeview */ 2532 /* DNS treeview */
@@ -2285,6 +2541,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2285 "https://gnunet.org/configuration-dns", 2541 "https://gnunet.org/configuration-dns",
2286 &load_vpn_dns_configuration, 2542 &load_vpn_dns_configuration,
2287 NULL, NULL, 2543 NULL, NULL,
2544 NULL, NULL,
2288 NULL}, 2545 NULL},
2289 2546
2290 { 2547 {
@@ -2297,6 +2554,8 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2297 NULL, 2554 NULL,
2298 &vpn_dns_service_dnsname_install_edited_handler, 2555 &vpn_dns_service_dnsname_install_edited_handler,
2299 NULL, 2556 NULL,
2557 NULL,
2558 NULL,
2300 NULL}, 2559 NULL},
2301 2560
2302 { 2561 {
@@ -2309,6 +2568,8 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2309 NULL, 2568 NULL,
2310 &vpn_dns_service_tcpudp_install_edited_handler, 2569 &vpn_dns_service_tcpudp_install_edited_handler,
2311 NULL, 2570 NULL,
2571 NULL,
2572 NULL,
2312 NULL}, 2573 NULL},
2313 2574
2314 { 2575 {
@@ -2321,6 +2582,8 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2321 NULL, 2582 NULL,
2322 &vpn_dns_service_sourceport_install_edited_handler, 2583 &vpn_dns_service_sourceport_install_edited_handler,
2323 NULL, 2584 NULL,
2585 NULL,
2586 NULL,
2324 NULL}, 2587 NULL},
2325 2588
2326 { 2589 {
@@ -2333,6 +2596,8 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2333 NULL, 2596 NULL,
2334 &vpn_dns_service_targethostname_install_edited_handler, 2597 &vpn_dns_service_targethostname_install_edited_handler,
2335 NULL, 2598 NULL,
2599 NULL,
2600 NULL,
2336 NULL}, 2601 NULL},
2337 2602
2338 { 2603 {
@@ -2345,12 +2610,15 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
2345 NULL, 2610 NULL,
2346 &vpn_dns_service_targetport_install_edited_handler, 2611 &vpn_dns_service_targetport_install_edited_handler,
2347 NULL, 2612 NULL,
2613 NULL,
2614 NULL,
2348 NULL}, 2615 NULL},
2349 2616
2350 /* END of list */ 2617 /* END of list */
2351 2618
2352 {NULL, NULL, NULL, NULL, NULL, 2619 {NULL, NULL, NULL, NULL, NULL,
2353 NULL, NULL, NULL, NULL} 2620 NULL, NULL, NULL, NULL, NULL,
2621 NULL}
2354}; 2622};
2355 2623
2356/* end of gnunet-setup-options.c */ 2624/* end of gnunet-setup-options.c */
diff --git a/src/setup/gnunet-setup-options.h b/src/setup/gnunet-setup-options.h
index 31727d30..c1dbf44b 100644
--- a/src/setup/gnunet-setup-options.h
+++ b/src/setup/gnunet-setup-options.h
@@ -65,6 +65,17 @@ typedef int (*GNUNET_SETUP_SaveFunction) (const void *cls, const char *section,
65 65
66 66
67/** 67/**
68 * Function called each time the widget changes its state to validate
69 * its value.
70 *
71 * @param cls closure
72 * @param widget widget whose state was changed
73 */
74typedef void (*GNUNET_SETUP_InputValidationFunction) (const void *cls,
75 GObject *widget);
76
77
78/**
68 * Structs of this type specify under which conditions the values of 79 * Structs of this type specify under which conditions the values of
69 * a particular option impact the visibility (or sensitivity) of some 80 * a particular option impact the visibility (or sensitivity) of some
70 * other widget. 81 * other widget.
@@ -143,6 +154,16 @@ struct GNUNET_SETUP_OptionSpecification
143 const void *load_save_cls; 154 const void *load_save_cls;
144 155
145 /** 156 /**
157 * Function to call to validate the value of the widget.
158 */
159 GNUNET_SETUP_InputValidationFunction input_validation_function;
160
161 /**
162 * Closure for 'input_validation_function'.
163 */
164 const void *input_validation_function_cls;
165
166 /**
146 * Visibility changes to apply if this option changes (NULL, or 167 * Visibility changes to apply if this option changes (NULL, or
147 * NULL-terminated). 168 * NULL-terminated).
148 */ 169 */
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c
index 52534812..19eda81e 100644
--- a/src/setup/gnunet-setup.c
+++ b/src/setup/gnunet-setup.c
@@ -171,6 +171,8 @@ widget_state_change_callback (const struct GNUNET_SETUP_OptionSpecification *os)
171 os->widget_name); 171 os->widget_name);
172 return; 172 return;
173 } 173 }
174 if (NULL != os->input_validation_function)
175 os->input_validation_function (os->input_validation_function_cls, widget);
174 if ((os->section != NULL) && (os->option != NULL)) 176 if ((os->section != NULL) && (os->option != NULL))
175 GNUNET_assert (GNUNET_OK == 177 GNUNET_assert (GNUNET_OK ==
176 GNUNET_CONFIGURATION_get_value_string (cfg, os->section, 178 GNUNET_CONFIGURATION_get_value_string (cfg, os->section,
@@ -246,6 +248,8 @@ load_options ()
246 } 248 }
247 } 249 }
248 } 250 }
251 if (NULL != os->input_validation_function)
252 os->input_validation_function (os->input_validation_function_cls, widget);
249 if (os->help_text != NULL) 253 if (os->help_text != NULL)
250 { 254 {
251 g_signal_connect (widget, "button-press-event", 255 g_signal_connect (widget, "button-press-event",