aboutsummaryrefslogtreecommitdiff
path: root/src/setup
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup')
-rw-r--r--src/setup/gnunet-setup-datacache-config.c137
-rw-r--r--src/setup/gnunet-setup-datacache-plugins.c83
-rw-r--r--src/setup/gnunet-setup-datastore-config.c133
-rw-r--r--src/setup/gnunet-setup-datastore-plugins.c81
-rw-r--r--src/setup/gnunet-setup-hostlist-editing.c72
-rw-r--r--src/setup/gnunet-setup-options.c2580
-rw-r--r--src/setup/gnunet-setup-options.h161
-rw-r--r--src/setup/gnunet-setup-transport-http.c182
-rw-r--r--src/setup/gnunet-setup-transport-https.c182
-rw-r--r--src/setup/gnunet-setup-transport-plugins.c105
-rw-r--r--src/setup/gnunet-setup-transport-tcp.c182
-rw-r--r--src/setup/gnunet-setup-transport-udp.c181
-rw-r--r--src/setup/gnunet-setup-transport.c300
-rw-r--r--src/setup/gnunet-setup.c462
-rw-r--r--src/setup/gnunet-setup.h47
15 files changed, 4888 insertions, 0 deletions
diff --git a/src/setup/gnunet-setup-datacache-config.c b/src/setup/gnunet-setup-datacache-config.c
new file mode 100644
index 00000000..585a786f
--- /dev/null
+++ b/src/setup/gnunet-setup-datacache-config.c
@@ -0,0 +1,137 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-datacache-config.c
23 * @brief test datacache configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_datacache_plugin.h>
28
29/**
30 * Stub implementation of the 'DeleteNotifyCallback' callback.
31 */
32static void
33dnc_dummy (void *cls,
34 const GNUNET_HashCode *key,
35 size_t size)
36{
37 /* do nothing */
38}
39
40
41/**
42 * Test if the configuration works for the given plugin.
43 *
44 * @param name name of the plugin to check
45 * @return GNUNET_OK on success, GNUNET_SYSERR if the config is wrong
46 */
47static int
48test_config (const char *name)
49{
50 struct GNUNET_DATACACHE_PluginEnvironment env =
51 {
52 cfg,
53 "dhtcache",
54 NULL, &dnc_dummy,
55 1024LL
56 };
57 void *ret;
58
59 ret = GNUNET_PLUGIN_load (name, &env);
60 if (NULL == ret)
61 return GNUNET_SYSERR;
62 GNUNET_PLUGIN_unload (name, ret);
63 return GNUNET_OK;
64}
65
66
67static void
68show (const char *name)
69{
70 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder,
71 name)));
72}
73
74
75static void
76hide (const char *name)
77{
78 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
79 name)));
80}
81
82
83void
84GNUNET_setup_datacache_mysql_invalidate_cb ()
85{
86 hide ("GNUNET_setup_datacache_mysql_tab_ok_image");
87 hide ("GNUNET_setup_datacache_mysql_tab_error_image");
88}
89
90
91void
92GNUNET_setup_datacache_postgres_invalidate_cb ()
93{
94 hide ("GNUNET_setup_datacache_postgres_tab_ok_image");
95 hide ("GNUNET_setup_datacache_postgres_tab_error_image");
96}
97
98
99void
100GNUNET_setup_datacache_mysql_tab_test_button_clicked_cb (GtkWidget *widget,
101 gpointer user_data)
102{
103 if (GNUNET_OK ==
104 test_config ("libgnunet_plugin_datacache_mysql"))
105 {
106 show ("GNUNET_setup_datacache_mysql_tab_ok_image");
107 hide ("GNUNET_setup_datacache_mysql_tab_error_image");
108 }
109 else
110 {
111 hide ("GNUNET_setup_datacache_mysql_tab_ok_image");
112 show ("GNUNET_setup_datacache_mysql_tab_error_image");
113 }
114}
115
116
117void
118GNUNET_setup_datacache_postgres_tab_test_button_clicked_cb (GtkWidget *widget,
119 gpointer user_data)
120{
121 if (GNUNET_OK ==
122 test_config ("libgnunet_plugin_datacache_postgres"))
123 {
124 show ("GNUNET_setup_datacache_postgres_tab_ok_image");
125 hide ("GNUNET_setup_datacache_postgres_tab_error_image");
126 }
127 else
128 {
129 hide ("GNUNET_setup_datacache_postgres_tab_ok_image");
130 show ("GNUNET_setup_datacache_postgres_tab_error_image");
131 }
132}
133
134
135
136/* end of gnunet-setup-datacache-config.c */
137
diff --git a/src/setup/gnunet-setup-datacache-plugins.c b/src/setup/gnunet-setup-datacache-plugins.c
new file mode 100644
index 00000000..4e53f6df
--- /dev/null
+++ b/src/setup/gnunet-setup-datacache-plugins.c
@@ -0,0 +1,83 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-datacache-plugins.c
23 * @brief (de)sensitize transport plugin buttons based on plugin availability
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27
28
29/**
30 * Test if the given plugin exists and change the sensitivity
31 * of the widget accordingly.
32 *
33 * @param widget widget to update
34 * @param name name of the plugin to check
35 */
36static void
37test_plugin (GtkWidget *widget,
38 const char *name)
39{
40 if (GNUNET_YES ==
41 GNUNET_PLUGIN_test (name))
42 {
43 gtk_widget_set_sensitive (widget,
44 TRUE);
45 }
46 else
47 {
48 gtk_widget_set_sensitive (widget,
49 FALSE);
50 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
51 FALSE);
52 }
53}
54
55
56
57void
58GNUNET_setup_fs_datacache_sqlite_radiobutton_realize_cb (GtkWidget *widget,
59 gpointer user_data)
60{
61 test_plugin (widget, "libgnunet_plugin_datacache_sqlite");
62}
63
64
65void
66GNUNET_setup_fs_datacache_mysql_radiobutton_realize_cb (GtkWidget *widget,
67 gpointer user_data)
68{
69 test_plugin (widget, "libgnunet_plugin_datacache_mysql");
70}
71
72
73void
74GNUNET_setup_fs_datacache_postgres_radiobutton_realize_cb (GtkWidget *widget,
75 gpointer user_data)
76{
77 test_plugin (widget, "libgnunet_plugin_datacache_postgres");
78}
79
80
81
82/* end of gnunet-setup-transport-plugins.c */
83
diff --git a/src/setup/gnunet-setup-datastore-config.c b/src/setup/gnunet-setup-datastore-config.c
new file mode 100644
index 00000000..ad9c541a
--- /dev/null
+++ b/src/setup/gnunet-setup-datastore-config.c
@@ -0,0 +1,133 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-datastore-config.c
23 * @brief test datastore configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_datastore_plugin.h>
28
29/**
30 * Stub implementation of the 'DiskUtilizationChange' callback.
31 */
32static void
33duc_dummy (void *cls, int delta)
34{
35 /* do nothing */
36}
37
38
39/**
40 * Test if the configuration works for the given plugin.
41 *
42 * @param name name of the plugin to check
43 * @return GNUNET_OK on success, GNUNET_SYSERR if the config is wrong
44 */
45static int
46test_config (const char *name)
47{
48 struct GNUNET_DATASTORE_PluginEnvironment env =
49 {
50 cfg,
51 &duc_dummy, NULL
52 };
53 void *ret;
54
55 ret = GNUNET_PLUGIN_load (name, &env);
56 if (NULL == ret)
57 return GNUNET_SYSERR;
58 GNUNET_PLUGIN_unload (name, ret);
59 return GNUNET_OK;
60}
61
62
63static void
64show (const char *name)
65{
66 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder,
67 name)));
68}
69
70
71static void
72hide (const char *name)
73{
74 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
75 name)));
76}
77
78
79void
80GNUNET_setup_datastore_mysql_invalidate_cb ()
81{
82 hide ("GNUNET_setup_datastore_mysql_tab_ok_image");
83 hide ("GNUNET_setup_datastore_mysql_tab_error_image");
84}
85
86
87void
88GNUNET_setup_datastore_postgres_invalidate_cb ()
89{
90 hide ("GNUNET_setup_datastore_postgres_tab_ok_image");
91 hide ("GNUNET_setup_datastore_postgres_tab_error_image");
92}
93
94
95void
96GNUNET_setup_datastore_mysql_tab_test_button_clicked_cb (GtkWidget *widget,
97 gpointer user_data)
98{
99 if (GNUNET_OK ==
100 test_config ("libgnunet_plugin_datastore_mysql"))
101 {
102 show ("GNUNET_setup_datastore_mysql_tab_ok_image");
103 hide ("GNUNET_setup_datastore_mysql_tab_error_image");
104 }
105 else
106 {
107 hide ("GNUNET_setup_datastore_mysql_tab_ok_image");
108 show ("GNUNET_setup_datastore_mysql_tab_error_image");
109 }
110}
111
112
113void
114GNUNET_setup_datastore_postgres_tab_test_button_clicked_cb (GtkWidget *widget,
115 gpointer user_data)
116{
117 if (GNUNET_OK ==
118 test_config ("libgnunet_plugin_datastore_postgres"))
119 {
120 show ("GNUNET_setup_datastore_postgres_tab_ok_image");
121 hide ("GNUNET_setup_datastore_postgres_tab_error_image");
122 }
123 else
124 {
125 hide ("GNUNET_setup_datastore_postgres_tab_ok_image");
126 show ("GNUNET_setup_datastore_postgres_tab_error_image");
127 }
128}
129
130
131
132/* end of gnunet-setup-datastore-config.c */
133
diff --git a/src/setup/gnunet-setup-datastore-plugins.c b/src/setup/gnunet-setup-datastore-plugins.c
new file mode 100644
index 00000000..e7f448e6
--- /dev/null
+++ b/src/setup/gnunet-setup-datastore-plugins.c
@@ -0,0 +1,81 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-datastore-plugins.c
23 * @brief (de)sensitize datastore plugin buttons based on plugin availability
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27
28/**
29 * Test if the given plugin exists and change the sensitivity
30 * of the widget accordingly.
31 *
32 * @param widget widget to update
33 * @param name name of the plugin to check
34 */
35static void
36test_plugin (GtkWidget *widget,
37 const char *name)
38{
39 if (GNUNET_YES ==
40 GNUNET_PLUGIN_test (name))
41 {
42 gtk_widget_set_sensitive (widget,
43 TRUE);
44 }
45 else
46 {
47 gtk_widget_set_sensitive (widget,
48 FALSE);
49 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
50 FALSE);
51 }
52}
53
54
55void
56GNUNET_setup_fs_datastore_sqlite_radiobutton_realize_cb (GtkWidget *widget,
57 gpointer user_data)
58{
59 test_plugin (widget, "libgnunet_plugin_datastore_sqlite");
60}
61
62
63void
64GNUNET_setup_fs_datastore_mysql_radiobutton_realize_cb (GtkWidget *widget,
65 gpointer user_data)
66{
67 test_plugin (widget, "libgnunet_plugin_datastore_mysql");
68}
69
70
71void
72GNUNET_setup_fs_datastore_postgres_radiobutton_realize_cb (GtkWidget *widget,
73 gpointer user_data)
74{
75 test_plugin (widget, "libgnunet_plugin_datastore_postgres");
76}
77
78
79
80/* end of gnunet-setup-datastore-plugins.c */
81
diff --git a/src/setup/gnunet-setup-hostlist-editing.c b/src/setup/gnunet-setup-hostlist-editing.c
new file mode 100644
index 00000000..471327ca
--- /dev/null
+++ b/src/setup/gnunet-setup-hostlist-editing.c
@@ -0,0 +1,72 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-hostlist-editing.c
23 * @brief allow editing of the hostlist
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27
28/**
29 * Handle editing of text in the GtkListModel. Changes
30 * the new entry to non-editable and creates another
31 * empty entry at the end.
32 *
33 * @param renderer renderer emitting the signal
34 * @param path path identifying the edited cell
35 * @param new_text text that was added
36 * @param user_data not used
37 */
38void
39GNUNET_setup_hostlist_url_cellrenderertext_edited_cb (GtkCellRendererText *renderer,
40 gchar *path,
41 gchar *new_text,
42 gpointer user_data)
43{
44 GtkListStore *ls;
45 GtkTreeIter old;
46 GtkTreeIter iter;
47
48 ls = GTK_LIST_STORE (gtk_builder_get_object (builder,
49 "GNUNET_setup_hostlist_url_liststore"));
50 if (ls == NULL)
51 {
52 GNUNET_break (0);
53 return;
54 }
55 if (TRUE !=
56 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls),
57 &old,
58 path))
59 {
60 GNUNET_break (0);
61 return;
62 }
63
64 gtk_list_store_insert_before (ls, &iter, &old);
65 gtk_list_store_set (ls,
66 &iter,
67 0, new_text,
68 1, FALSE,
69 -1);
70}
71
72/* end of gnunet-setup-hostlist-editing.c */
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c
new file mode 100644
index 00000000..ae2c436e
--- /dev/null
+++ b/src/setup/gnunet-setup-options.c
@@ -0,0 +1,2580 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-options.c
23 * @brief configuration details
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup-options.h"
27#include <gnunet/gnunet_util_lib.h>
28#include <gdk/gdkkeysyms.h>
29
30/**
31 * Regular expression for YES
32 */
33#define REX_YES "^YES$"
34
35/**
36 * Regular expression for NO
37 */
38#define REX_NO "^NO$"
39
40
41/**
42 * Initialize a toggle button based on an options 'yes/no' value.
43 *
44 * @param cls closure
45 * @param section section with the value
46 * @param option option name
47 * @param value value as a string
48 * @param widget widget to initialize
49 * @param cfg configuration handle
50 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
51 */
52static int
53load_yes_no (const void *cls,
54 const char *section,
55 const char *option,
56 const char *value,
57 GObject *widget,
58 const struct GNUNET_CONFIGURATION_Handle *cfg)
59{
60 GtkToggleButton *button;
61
62 button = GTK_TOGGLE_BUTTON (widget);
63 if (button == NULL)
64 return GNUNET_SYSERR;
65 gtk_toggle_button_set_active (button,
66 (0 == strcasecmp (value, "YES")) ? TRUE : FALSE);
67 return GNUNET_OK;
68}
69
70
71/**
72 * Set a yes/no option based on a toggle button.
73 *
74 * @param cls closure
75 * @param section section with the value
76 * @param option option name
77 * @param widget widget to initialize
78 * @param cfg configuration handle to update
79 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
80 */
81static int
82save_yes_no (const void *cls,
83 const char *section,
84 const char *option,
85 GObject *widget,
86 struct GNUNET_CONFIGURATION_Handle *cfg)
87{
88 GtkToggleButton *button;
89 gboolean mode;
90
91 button = GTK_TOGGLE_BUTTON (widget);
92 if (button == NULL)
93 return GNUNET_SYSERR;
94 mode = gtk_toggle_button_get_active (button);
95 GNUNET_CONFIGURATION_set_value_string (cfg,
96 section, option,
97 mode == TRUE ? "YES" : "NO");
98 return GNUNET_OK;
99}
100
101
102/**
103 * Initialize a GtkFileChooser based on a filename option.
104 *
105 * @param cls closure
106 * @param section section with the value
107 * @param option option name
108 * @param value value as a string
109 * @param widget widget to initialize
110 * @param cfg configuration handle
111 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
112 */
113static int
114load_filename (const void *cls,
115 const char *section,
116 const char *option,
117 const char *value,
118 GObject *widget,
119 const struct GNUNET_CONFIGURATION_Handle *cfg)
120{
121 GtkFileChooser *chooser;
122
123 chooser = GTK_FILE_CHOOSER (widget);
124 if (chooser == NULL)
125 return GNUNET_SYSERR;
126 gtk_file_chooser_set_filename (chooser,
127 value);
128 return GNUNET_OK;
129}
130
131
132/**
133 * Set filename option based on a file chooser.
134 *
135 * @param cls closure
136 * @param section section with the value
137 * @param option option name
138 * @param widget widget to initialize
139 * @param cfg configuration handle to update
140 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
141 */
142static int
143save_filename (const void *cls,
144 const char *section,
145 const char *option,
146 GObject *widget,
147 struct GNUNET_CONFIGURATION_Handle *cfg)
148{
149 GtkFileChooser *chooser;
150 gchar *fn;
151
152 chooser = GTK_FILE_CHOOSER (widget);
153 if (chooser == NULL)
154 return GNUNET_SYSERR;
155 fn = gtk_file_chooser_get_filename (chooser);
156 if (fn == NULL)
157 fn = g_strdup ("");
158 GNUNET_CONFIGURATION_set_value_string (cfg,
159 section, option,
160 fn);
161 g_free (fn);
162 return GNUNET_OK;
163}
164
165
166/**
167 * Initialize a GtkEntry based on a text option.
168 *
169 * @param cls closure
170 * @param section section with the value
171 * @param option option name
172 * @param value value as a string
173 * @param widget widget to initialize
174 * @param cfg configuration handle
175 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
176 */
177static int
178load_text (const void *cls,
179 const char *section,
180 const char *option,
181 const char *value,
182 GObject *widget,
183 const struct GNUNET_CONFIGURATION_Handle *cfg)
184{
185 GtkEntry *entry;
186
187 entry = GTK_ENTRY (widget);
188 if (entry == NULL)
189 return GNUNET_SYSERR;
190 gtk_entry_set_text (entry,
191 value);
192 return GNUNET_OK;
193}
194
195
196/**
197 * Set text option based on a GtkEntry.
198 *
199 * @param cls closure
200 * @param section section with the value
201 * @param option option name
202 * @param widget widget to initialize
203 * @param cfg configuration handle to update
204 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
205 */
206static int
207save_text (const void *cls,
208 const char *section,
209 const char *option,
210 GObject *widget,
211 struct GNUNET_CONFIGURATION_Handle *cfg)
212{
213 GtkEntry *entry;
214 const gchar *txt;
215
216 entry = GTK_ENTRY (widget);
217 if (entry == NULL)
218 return GNUNET_SYSERR;
219 txt = gtk_entry_get_text (entry);
220 GNUNET_CONFIGURATION_set_value_string (cfg,
221 section, option,
222 txt);
223 return GNUNET_OK;
224}
225
226
227#if 0
228/**
229 * Initialize a GtkComboBox based on a text option.
230 *
231 * @param cls closure
232 * @param section section with the value
233 * @param option option name
234 * @param value value as a string
235 * @param widget widget to initialize
236 * @param cfg configuration handle
237 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
238 */
239static int
240load_combo_text (const void *cls,
241 const char *section,
242 const char *option,
243 const char *value,
244 GObject *widget,
245 const struct GNUNET_CONFIGURATION_Handle *cfg)
246{
247 GtkComboBoxText *cb;
248
249 cb = GTK_COMBO_BOX_TEXT (widget);
250 if (NULL == cb)
251 return GNUNET_SYSERR;
252 gtk_combo_box_text_append_text (cb, value);
253 return GNUNET_OK;
254}
255
256
257/**
258 * Set text option based on a GtkComboBox.
259 *
260 * @param cls closure
261 * @param section section with the value
262 * @param option option name
263 * @param widget widget to initialize
264 * @param cfg configuration handle to update
265 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
266 */
267static int
268save_combo_text (const void *cls,
269 const char *section,
270 const char *option,
271 GObject *widget,
272 struct GNUNET_CONFIGURATION_Handle *cfg)
273{
274 GtkComboBox *cb;
275 gchar *c;
276
277 cb = GTK_COMBO_BOX (widget);
278 if (NULL == cb)
279 return GNUNET_SYSERR;
280 c = gtk_combo_box_get_active_text (cb);
281 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, c);
282 g_free (c);
283 return GNUNET_OK;
284}
285#endif
286
287
288/**
289 * Initialize a GtkSpinButton based on a numeric option.
290 *
291 * @param cls closure
292 * @param section section with the value
293 * @param option option name
294 * @param value value as a string
295 * @param widget widget to initialize
296 * @param cfg configuration handle
297 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
298 */
299static int
300load_number (const void *cls,
301 const char *section,
302 const char *option,
303 const char *value,
304 GObject *widget,
305 const struct GNUNET_CONFIGURATION_Handle *cfg)
306{
307 GtkSpinButton *spin;
308 unsigned int number;
309
310 spin = GTK_SPIN_BUTTON (widget);
311 if (spin == NULL)
312 return GNUNET_SYSERR;
313 if (1 != sscanf (value, "%u", &number))
314 return GNUNET_SYSERR;
315 gtk_spin_button_set_value (spin,
316 number);
317 return GNUNET_OK;
318}
319
320
321/**
322 * Set numeric option based on a spin button.
323 *
324 * @param cls closure
325 * @param section section with the value
326 * @param option option name
327 * @param widget widget to initialize
328 * @param cfg configuration handle to update
329 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
330 */
331static int
332save_number (const void *cls,
333 const char *section,
334 const char *option,
335 GObject *widget,
336 struct GNUNET_CONFIGURATION_Handle *cfg)
337{
338 GtkSpinButton *spin;
339
340 spin = GTK_SPIN_BUTTON (widget);
341 if (spin == NULL)
342 return GNUNET_SYSERR;
343 GNUNET_CONFIGURATION_set_value_number (cfg,
344 section, option,
345 gtk_spin_button_get_value_as_int (spin));
346 return GNUNET_OK;
347}
348
349
350/**
351 * Initialize a toggle button based on the existence of a word
352 * in an option value.
353 *
354 * @param cls word to test for (conat char *)
355 * @param section section with the value
356 * @param option option name
357 * @param value value as a string
358 * @param widget widget to initialize
359 * @param cfg configuration handle
360 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
361 */
362static int
363load_option_list (const void *cls,
364 const char *section,
365 const char *option,
366 const char *value,
367 GObject *widget,
368 const struct GNUNET_CONFIGURATION_Handle *cfg)
369{
370 const char *word = cls;
371 char *t;
372 char *w;
373 GtkToggleButton *button;
374 int found;
375
376 button = GTK_TOGGLE_BUTTON (widget);
377 if (button == NULL)
378 return GNUNET_SYSERR;
379 found = GNUNET_NO;
380 t = GNUNET_strdup (value);
381 w = strtok (t, " ");
382 while (w != NULL)
383 {
384 if (0 == strcmp (w, word))
385 {
386 found = GNUNET_YES;
387 break;
388 }
389 w = strtok (NULL, " ");
390 }
391 GNUNET_free (t);
392 gtk_toggle_button_set_active (button,
393 found);
394 return GNUNET_OK;
395}
396
397
398/**
399 * Add or remove a word from a sentence based on a toggle button's yes/no value.
400 *
401 * @param cls word to add or remove for (conat char *)
402 * @param section section with the value
403 * @param option option name
404 * @param widget widget to initialize
405 * @param cfg configuration handle to update
406 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
407 */
408static int
409save_option_list (const void *cls,
410 const char *section,
411 const char *option,
412 GObject *widget,
413 struct GNUNET_CONFIGURATION_Handle *cfg)
414{
415 const char *word = cls;
416 GtkToggleButton *button;
417 gboolean mode;
418
419 button = GTK_TOGGLE_BUTTON (widget);
420 if (button == NULL)
421 return GNUNET_SYSERR;
422 mode = gtk_toggle_button_get_active (button);
423 if (mode == TRUE)
424 GNUNET_CONFIGURATION_append_value_filename (cfg,
425 section,
426 option,
427 word);
428 else
429 GNUNET_CONFIGURATION_remove_value_filename (cfg,
430 section,
431 option,
432 word);
433 return GNUNET_OK;
434}
435
436
437/**
438 * User pressed a key in a sensitive tree view with a list store.
439 * Check if it was the 'delete' key and if so remove the selected
440 * row.
441 *
442 * @param tv tree view emitting the signal
443 * @param event key stroke data
444 * @param user_data not used
445 * @return TRUE to stop other handlers from being invoked
446 */
447gboolean
448GNUNET_setup_treeview_key_press_event_cb (GtkTreeView *tv,
449 GdkEventKey *event,
450 gpointer user_data)
451{
452 GtkListStore *ls;
453 GtkTreeModel *tm;
454 GtkTreeSelection *sel;
455 GtkTreeIter iter;
456 gboolean editable;
457
458 if ( (event->type != GDK_KEY_PRESS) ||
459 (event->state != 0) ||
460 (event->keyval != GDK_Delete) )
461 return FALSE;
462 ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv));
463 if (ls == NULL)
464 {
465 GNUNET_break (0);
466 return FALSE;
467 }
468 sel = gtk_tree_view_get_selection (tv);
469 if (TRUE !=
470 gtk_tree_selection_get_selected (sel,
471 &tm,
472 &iter))
473 return FALSE;
474 gtk_tree_model_get (tm, &iter, 1, &editable, -1);
475 if (TRUE == editable)
476 return FALSE; /* likely currently editing... */
477 gtk_list_store_remove (ls, &iter);
478 gtk_tree_model_get_iter_first (tm, &iter);
479 gtk_tree_selection_select_iter (sel, &iter);
480 return FALSE;
481}
482
483
484/**
485 * Initialize a GtkListStore by tokenizing the value into strings.
486 *
487 * @param cls closure (unused)
488 * @param section section with the value
489 * @param option option name
490 * @param value value as a string
491 * @param widget widget to initialize
492 * @param cfg configuration handle
493 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
494 */
495static int
496load_string_list_store (const void *cls,
497 const char *section,
498 const char *option,
499 const char *value,
500 GObject *widget,
501 const struct GNUNET_CONFIGURATION_Handle *cfg)
502{
503 char *t;
504 char *w;
505 GtkListStore *ls;
506 GtkTreeIter iter;
507
508 ls = GTK_LIST_STORE (widget);
509 if (ls == NULL)
510 return GNUNET_SYSERR;
511 t = GNUNET_strdup (value);
512 w = strtok (t, " ");
513 while (w != NULL)
514 {
515 gtk_list_store_insert_with_values (ls,
516 &iter,
517 G_MAXINT,
518 0, w,
519 1, FALSE,
520 -1);
521 w = strtok (NULL, " ");
522 }
523 GNUNET_free (t);
524 gtk_list_store_insert_with_values (ls,
525 &iter,
526 G_MAXINT,
527 0, "",
528 1, TRUE,
529 -1);
530 return GNUNET_OK;
531}
532
533
534/**
535 * The GtkCellRenderer has emmited the 'edited' signal.
536 *
537 *
538 * @param cls closure (unused)
539 * @param section section with the value (NULL)
540 * @param option option name (NULL)
541 * @param widget the cell renderer
542 * @param cfg configuration handle to update
543 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
544 */
545static int
546save_string_list_store (const void *cls,
547 const char *section,
548 const char *option,
549 GObject *widget,
550 struct GNUNET_CONFIGURATION_Handle *cfg)
551{
552 GtkTreeModel *tm;
553 GtkTreeIter iter;
554 char *value;
555 char *n;
556 gchar *val;
557
558 tm = GTK_TREE_MODEL (widget);
559 if (tm == NULL)
560 return GNUNET_SYSERR;
561 value = NULL;
562 if (TRUE == gtk_tree_model_get_iter_first (tm, &iter))
563 {
564 do
565 {
566 gtk_tree_model_get (tm,
567 &iter,
568 0, &val,
569 -1);
570 if (value == NULL)
571 {
572 value = GNUNET_strdup (val);
573 }
574 else
575 {
576 GNUNET_asprintf (&n,
577 "%s %s",
578 value,
579 val);
580 GNUNET_free (value);
581 value = n;
582 }
583 g_free (val);
584 }
585 while (TRUE == gtk_tree_model_iter_next (tm, &iter));
586 }
587 if (value == NULL)
588 value = GNUNET_strdup ("");
589 GNUNET_CONFIGURATION_set_value_string (cfg,
590 section,
591 option,
592 value);
593 GNUNET_free (value);
594 return GNUNET_OK;
595}
596
597
598/**
599 * Check if the section represents a DNS entry and then update the
600 * GtkListStore accordingly.
601 *
602 * @param cls the list store to modify
603 * @param section name of the section
604 */
605static void
606add_dns_entry_to_list_store (void *cls, const char *section)
607{
608 GtkListStore *ls = cls;
609 GtkTreeIter iter;
610 char *sld;
611 char *hostname;
612 char *hostport;
613 char *redirect;
614 char *cpy;
615 gboolean udp;
616
617 if (NULL == section)
618 {
619 gtk_list_store_insert_with_values (ls,
620 &iter,
621 G_MAXINT,
622 0, "",
623 1, (guint) 80,
624 2, (guint) 8080,
625 3, "localhost",
626 4, "tcp",
627 -1);
628 return;
629 }
630
631 if ( (8 > strlen (section)) ||
632 (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) )
633 return;
634 sld = GNUNET_strdup (section);
635 sld[strlen (section) - 8] = '\0';
636 udp = FALSE;
637 do
638 {
639 if (GNUNET_OK ==
640 GNUNET_CONFIGURATION_get_value_string (cfg, section,
641 (TRUE == udp)
642 ? "UDP_REDIRECTS"
643 : "TCP_REDIRECTS",
644 &cpy))
645 {
646 for (redirect = strtok (cpy, " "); redirect != NULL;
647 redirect = strtok (NULL, " "))
648 {
649 if (NULL == (hostname = strstr (redirect, ":")))
650 {
651 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
652 _("Option `%s' is not formatted correctly!\n"),
653 redirect);
654 continue;
655 }
656 hostname[0] = '\0';
657 hostname++;
658 if (NULL == (hostport = strstr (hostname, ":")))
659 {
660 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
661 _("Option `%s' is not formatted correctly!\n"),
662 redirect);
663 continue;
664 }
665 hostport[0] = '\0';
666 hostport++;
667
668 int local_port = atoi (redirect);
669 if (!((local_port > 0) && (local_port < 65536)))
670 {
671 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
672 _("`%s' is not a valid port number!\n"),
673 redirect);
674 continue;
675 }
676 int host_port = atoi (hostport);
677 if (!((host_port > 0) && (host_port < 65536)))
678 {
679 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
680 _("`%s' is not a valid port number!\n"),
681 hostport);
682 continue;
683 }
684 gtk_list_store_insert_with_values (ls,
685 &iter,
686 0,
687 0, sld,
688 1, (guint) local_port,
689 2, (guint) host_port,
690 3, hostname,
691 4, (TRUE == udp) ? "udp" : "tcp",
692 -1);
693 }
694 GNUNET_free (cpy);
695 }
696 udp = !udp;
697 }
698 while (udp != FALSE);
699 GNUNET_free (sld);
700}
701
702
703/**
704 * Initialize the GtkListModel with the VPN's DNS service specification.
705 *
706 * @param cls NULL
707 * @param section section with the value (NULL)
708 * @param option option name (NULL)
709 * @param value value as a string (NULL)
710 * @param widget widget to initialize (the GtkTreeView)
711 * @param cfg configuration handle
712 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
713 */
714static int
715load_vpn_dns_configuration (const void *cls,
716 const char *section,
717 const char *option,
718 const char *value,
719 GObject *widget,
720 const struct GNUNET_CONFIGURATION_Handle *cfg)
721{
722 GtkTreeView *tv;
723 GtkListStore *ls;
724
725 tv = GTK_TREE_VIEW (widget);
726 if (tv == NULL)
727 {
728 GNUNET_break (0);
729 return GNUNET_SYSERR;
730 }
731 ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv));
732 GNUNET_CONFIGURATION_iterate_sections (cfg,
733 &add_dns_entry_to_list_store,
734 ls);
735 /* finally, add empty entry */
736 add_dns_entry_to_list_store (ls, NULL);
737 return GNUNET_OK;
738}
739
740
741/**
742 * Records we use to build DNS information lists.
743 */
744struct DnsInfo
745{
746 struct DnsInfo *next;
747 char *section;
748 char *altnames;
749 char *tcpred;
750 char *udpred;
751 unsigned long long ttl;
752};
753
754
755/**
756 * Function called for each section in the configuration.
757 * Gather existing ttl, section names and altnames.
758 *
759 * @param cls 'struct DnsInfo**' to create
760 * @param section name of a section in the configuration
761 */
762static void
763collect_dns_sections (void *cls,
764 const char *section)
765{
766 struct DnsInfo **base = cls;
767 struct DnsInfo *pos;
768
769 if ( (8 > strlen (section)) ||
770 (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) )
771 return;
772 pos = GNUNET_malloc (sizeof (struct DnsInfo));
773 pos->section = GNUNET_strdup (section);
774 if (GNUNET_OK !=
775 GNUNET_CONFIGURATION_get_value_number (cfg, section, "TTL", &pos->ttl))
776 pos->ttl = 3600000;
777 if (GNUNET_OK !=
778 GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES", &pos->altnames))
779 pos->altnames = NULL;
780 pos->tcpred = GNUNET_strdup ("");
781 pos->udpred = GNUNET_strdup ("");
782 pos->next = *base;
783 *base = pos;
784}
785
786
787/**
788 * Function called for each section in the configuration.
789 * Removes those ending in '.gnunet.'.
790 *
791 * @param cls unused
792 * @param section name of a section in the configuration
793 */
794static void
795remove_dns_sections (void *cls,
796 const char *section)
797{
798 if ( (8 > strlen (section)) ||
799 (0 != strcmp (".gnunet.", section + ((strlen (section) - 8)))) )
800 return;
801 GNUNET_CONFIGURATION_remove_section (cfg, section);
802}
803
804
805/**
806 * Given the list store and the data in it, update the
807 * configuration file accordingly.
808 *
809 * @param tm model to use
810 */
811static void
812update_vpn_dns_configuration (GtkTreeModel *tm)
813{
814 GtkTreeIter iter;
815 gchar *hostname;
816 guint srcport;
817 guint targetport;
818 gchar *targethost;
819 gchar *tcpudp;
820 char *tmp;
821 struct DnsInfo *head;
822 struct DnsInfo *pos;
823
824 head = NULL;
825 GNUNET_CONFIGURATION_iterate_sections (cfg,
826 &collect_dns_sections,
827 &head);
828 if (TRUE ==
829 gtk_tree_model_get_iter_first (tm, &iter))
830 do
831 {
832 gtk_tree_model_get (tm, &iter,
833 0, &hostname,
834 1, &srcport,
835 2, &targetport,
836 3, &targethost,
837 4, &tcpudp,
838 -1);
839 if (0 != strlen (hostname))
840 {
841 pos = head;
842 GNUNET_asprintf (&tmp,
843 "%s.gnunet.",
844 hostname);
845 while ( (NULL != pos) &&
846 (0 != strcasecmp (tmp, pos->section)) )
847 pos = pos->next;
848 if (pos == NULL)
849 {
850 pos = GNUNET_malloc (sizeof (struct DnsInfo));
851 pos->section = tmp;
852 pos->ttl = 3600000;
853 pos->altnames = NULL;
854 pos->tcpred = GNUNET_strdup ("");
855 pos->udpred = GNUNET_strdup ("");
856 pos->next = head;
857 head = pos;
858 }
859 else
860 {
861 GNUNET_free (tmp);
862 }
863
864 GNUNET_asprintf (&tmp,
865 "%u:%s:%u %s",
866 srcport,
867 targethost,
868 targetport,
869 (0 == strcasecmp ("tcp", tcpudp)) ? pos->tcpred : pos->udpred);
870 if (0 == strcasecmp ("tcp", tcpudp))
871 {
872 GNUNET_free (pos->tcpred);
873 pos->tcpred = tmp;
874 }
875 else
876 {
877 GNUNET_free (pos->udpred);
878 pos->udpred = tmp;
879 }
880 }
881 g_free (tcpudp);
882 g_free (hostname);
883 g_free (targethost);
884 }
885 while (TRUE == gtk_tree_model_iter_next (tm, &iter));
886 GNUNET_CONFIGURATION_iterate_sections (cfg,
887 &remove_dns_sections,
888 NULL);
889 while (NULL != head)
890 {
891 pos = head;
892 head = pos->next;
893 if (pos->altnames != NULL)
894 GNUNET_CONFIGURATION_set_value_string (cfg,
895 pos->section,
896 "ALTERNATIVE_NAMES",
897 pos->altnames);
898 if (strlen (pos->udpred) > 0)
899 GNUNET_CONFIGURATION_set_value_string (cfg,
900 pos->section,
901 "UDP_REDIRECTS",
902 pos->udpred);
903 if (strlen (pos->tcpred) > 0)
904 GNUNET_CONFIGURATION_set_value_string (cfg,
905 pos->section,
906 "TCP_REDIRECTS",
907 pos->tcpred);
908 GNUNET_CONFIGURATION_set_value_number (cfg,
909 pos->section,
910 "TTL",
911 pos->ttl);
912 GNUNET_free_non_null (pos->altnames);
913 GNUNET_free (pos->tcpred);
914 GNUNET_free (pos->udpred);
915 GNUNET_free (pos->section);
916 GNUNET_free (pos);
917 }
918}
919
920
921/**
922 * The user has edited the DNS name of a service we're offering.
923 * Update the GtkTreeModel (at the given path) and update the
924 * respective service entry in the configuration file. Finally,
925 * if the edited path is for a "fresh" entry, create another empty
926 * one at the bottom. If the hostname was set to empty, remove
927 * the entire entry from the configuration and the model.
928 *
929 * @param renderer GtkCellRendererText that changed
930 * @param path GtkTreePath identifying where in the Model the change is
931 * @param new_text the new text that was stored in the line
932 * @param user_data NULL
933 */
934static void
935save_vpn_dns_service_dnsname (GtkCellRendererText *renderer,
936 gchar *path,
937 gchar *new_text,
938 gpointer user_data)
939{
940 GtkTreeModel *tm;
941 GtkListStore *ls;
942 GtkTreeIter iter;
943 gchar *old;
944
945 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
946 "vpn_dns_config_liststore"));
947 if (NULL == tm)
948 {
949 GNUNET_break (0);
950 return;
951 }
952 ls = GTK_LIST_STORE (tm);
953 if (NULL == ls)
954 {
955 GNUNET_break (0);
956 return;
957 }
958 if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path))
959 {
960 GNUNET_break (0);
961 return;
962 }
963 gtk_tree_model_get (tm, &iter,
964 0, &old,
965 -1);
966 if ( (0 != strlen (old)) &&
967 (0 == strlen (new_text)) )
968 {
969 /* deletion */
970 gtk_list_store_remove (ls, &iter);
971 g_free (old);
972 return;
973 }
974 /* update model */
975 gtk_list_store_set (ls, &iter,
976 0, new_text,
977 -1);
978 /* update configuration */
979 update_vpn_dns_configuration (tm);
980 if ( (0 == strlen (old)) &&
981 (0 != strlen (new_text)) )
982 {
983 /* need another empty entry at the end for future expansion */
984 add_dns_entry_to_list_store (GTK_LIST_STORE (tm), NULL);
985 }
986 g_free (old);
987}
988
989
990/**
991 * Initialize the GtkListModel with the VPN's DNS service specification.
992 *
993 * @param cls NULL
994 * @param section section with the value (NULL)
995 * @param option option name (NULL)
996 * @param widget widget to initialize (the GtkTreeView)
997 * @param cfg configuration handle
998 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
999 */
1000static int
1001vpn_dns_service_dnsname_install_edited_handler (const void *cls,
1002 const char *section,
1003 const char *option,
1004 GObject *widget,
1005 struct GNUNET_CONFIGURATION_Handle *cfg)
1006{
1007 static int once;
1008 GtkCellRendererText *rt;
1009
1010 rt = GTK_CELL_RENDERER_TEXT(widget);
1011 if (NULL == rt)
1012 return GNUNET_SYSERR;
1013 if (0 != once++)
1014 return GNUNET_OK;
1015 g_signal_connect (rt,
1016 "edited",
1017 G_CALLBACK (&save_vpn_dns_service_dnsname),
1018 NULL);
1019 return GNUNET_OK;
1020}
1021
1022
1023/**
1024 * The user has edited the DNS name of a service we're offering.
1025 * Update the GtkTreeModel (at the given path) and update the
1026 * respective service entry in the configuration file. Finally,
1027 * if the edited path is for a "fresh" entry, create another empty
1028 * one at the bottom. If the hostname was set to empty, remove
1029 * the entire entry from the configuration and the model.
1030 *
1031 * @param renderer GtkCellRendererText that changed
1032 * @param path GtkTreePath identifying where in the Model the change is
1033 * @param new_text the new text that was stored in the line
1034 * @param user_data NULL
1035 */
1036static void
1037save_vpn_dns_service_tcpudp (GtkCellRendererText *renderer,
1038 gchar *path,
1039 gchar *new_text,
1040 gpointer user_data)
1041{
1042 GtkTreeModel *tm;
1043 GtkListStore *ls;
1044 GtkTreeIter iter;
1045
1046 if ( (0 != strcasecmp ("tcp", new_text)) &&
1047 (0 != strcasecmp ("udp", new_text)) )
1048 {
1049 /* FIXME: warn... */
1050 return;
1051 }
1052 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
1053 "vpn_dns_config_liststore"));
1054 if (NULL == tm)
1055 {
1056 GNUNET_break (0);
1057 return;
1058 }
1059 ls = GTK_LIST_STORE (tm);
1060 if (NULL == ls)
1061 {
1062 GNUNET_break (0);
1063 return;
1064 }
1065 if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path))
1066 {
1067 GNUNET_break (0);
1068 return;
1069 }
1070 /* update model */
1071 gtk_list_store_set (ls, &iter,
1072 4, new_text,
1073 -1);
1074 /* update configuration */
1075 update_vpn_dns_configuration (tm);
1076}
1077
1078
1079/**
1080 * Initialize the GtkListModel with the VPN's DNS service specification.
1081 *
1082 * @param cls NULL
1083 * @param section section with the value (NULL)
1084 * @param option option name (NULL)
1085 * @param widget widget to initialize (the GtkTreeView)
1086 * @param cfg configuration handle
1087 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
1088 */
1089static int
1090vpn_dns_service_tcpudp_install_edited_handler (const void *cls,
1091 const char *section,
1092 const char *option,
1093 GObject *widget,
1094 struct GNUNET_CONFIGURATION_Handle *cfg)
1095{
1096 static int once;
1097 GtkCellRendererText *rt;
1098
1099 rt = GTK_CELL_RENDERER_TEXT(widget);
1100 if (NULL == rt)
1101 return GNUNET_SYSERR;
1102 if (0 != once++)
1103 return GNUNET_OK;
1104 g_signal_connect (rt,
1105 "edited",
1106 G_CALLBACK (&save_vpn_dns_service_tcpudp),
1107 NULL);
1108 return GNUNET_OK;
1109}
1110
1111
1112/**
1113 * The user has edited the DNS name of a service we're offering.
1114 * Update the GtkTreeModel (at the given path) and update the
1115 * respective service entry in the configuration file. Finally,
1116 * if the edited path is for a "fresh" entry, create another empty
1117 * one at the bottom. If the hostname was set to empty, remove
1118 * the entire entry from the configuration and the model.
1119 *
1120 * @param renderer GtkCellRendererText that changed
1121 * @param path GtkTreePath identifying where in the Model the change is
1122 * @param new_text the new text that was stored in the line
1123 * @param user_data NULL
1124 */
1125static void
1126save_vpn_dns_service_sourceport (GtkCellRendererText *renderer,
1127 gchar *path,
1128 gchar *new_text,
1129 gpointer user_data)
1130{
1131 GtkTreeModel *tm;
1132 GtkListStore *ls;
1133 GtkTreeIter iter;
1134 int port;
1135
1136 port = atoi (new_text);
1137 if ( (port < 1) || (port > UINT16_MAX) )
1138 {
1139 /* invalid port, FIXME: warn */
1140 return;
1141 }
1142 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
1143 "vpn_dns_config_liststore"));
1144 if (NULL == tm)
1145 {
1146 GNUNET_break (0);
1147 return;
1148 }
1149 ls = GTK_LIST_STORE (tm);
1150 if (NULL == ls)
1151 {
1152 GNUNET_break (0);
1153 return;
1154 }
1155 if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path))
1156 {
1157 GNUNET_break (0);
1158 return;
1159 }
1160 /* update model */
1161 gtk_list_store_set (ls, &iter,
1162 1, (guint) port,
1163 -1);
1164 /* update configuration */
1165 update_vpn_dns_configuration (tm);
1166}
1167
1168
1169/**
1170 * Initialize the GtkListModel with the VPN's DNS service specification.
1171 *
1172 * @param cls NULL
1173 * @param section section with the value (NULL)
1174 * @param option option name (NULL)
1175 * @param widget widget to initialize (the GtkTreeView)
1176 * @param cfg configuration handle
1177 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
1178 */
1179static int
1180vpn_dns_service_sourceport_install_edited_handler (const void *cls,
1181 const char *section,
1182 const char *option,
1183 GObject *widget,
1184 struct GNUNET_CONFIGURATION_Handle *cfg)
1185{
1186 static int once;
1187 GtkCellRendererText *rt;
1188
1189 rt = GTK_CELL_RENDERER_TEXT(widget);
1190 if (NULL == rt)
1191 return GNUNET_SYSERR;
1192 if (0 != once++)
1193 return GNUNET_OK;
1194 g_signal_connect (rt,
1195 "edited",
1196 G_CALLBACK (&save_vpn_dns_service_sourceport),
1197 NULL);
1198 return GNUNET_OK;
1199}
1200
1201
1202/**
1203 * The user has edited the DNS name of a service we're offering.
1204 * Update the GtkTreeModel (at the given path) and update the
1205 * respective service entry in the configuration file. Finally,
1206 * if the edited path is for a "fresh" entry, create another empty
1207 * one at the bottom. If the hostname was set to empty, remove
1208 * the entire entry from the configuration and the model.
1209 *
1210 * @param renderer GtkCellRendererText that changed
1211 * @param path GtkTreePath identifying where in the Model the change is
1212 * @param new_text the new text that was stored in the line
1213 * @param user_data NULL
1214 */
1215static void
1216save_vpn_dns_service_targethostname (GtkCellRendererText *renderer,
1217 gchar *path,
1218 gchar *new_text,
1219 gpointer user_data)
1220{
1221 GtkTreeModel *tm;
1222 GtkListStore *ls;
1223 GtkTreeIter iter;
1224
1225 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
1226 "vpn_dns_config_liststore"));
1227 if (NULL == tm)
1228 {
1229 GNUNET_break (0);
1230 return;
1231 }
1232 ls = GTK_LIST_STORE (tm);
1233 if (NULL == ls)
1234 {
1235 GNUNET_break (0);
1236 return;
1237 }
1238 if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path))
1239 {
1240 GNUNET_break (0);
1241 return;
1242 }
1243 /* update model */
1244 gtk_list_store_set (ls, &iter,
1245 3, new_text,
1246 -1);
1247 /* update configuration */
1248 update_vpn_dns_configuration (tm);
1249}
1250
1251
1252/**
1253 * Initialize the GtkListModel with the VPN's DNS service specification.
1254 *
1255 * @param cls NULL
1256 * @param section section with the value (NULL)
1257 * @param option option name (NULL)
1258 * @param widget widget to initialize (the GtkTreeView)
1259 * @param cfg configuration handle
1260 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
1261 */
1262static int
1263vpn_dns_service_targethostname_install_edited_handler (const void *cls,
1264 const char *section,
1265 const char *option,
1266 GObject *widget,
1267 struct GNUNET_CONFIGURATION_Handle *cfg)
1268{
1269 static int once;
1270 GtkCellRendererText *rt;
1271
1272 rt = GTK_CELL_RENDERER_TEXT(widget);
1273 if (NULL == rt)
1274 return GNUNET_SYSERR;
1275 if (0 != once++)
1276 return GNUNET_OK;
1277 g_signal_connect (rt,
1278 "edited",
1279 G_CALLBACK (&save_vpn_dns_service_targethostname),
1280 NULL);
1281 return GNUNET_OK;
1282}
1283
1284
1285/**
1286 * The user has edited the DNS name of a service we're offering.
1287 * Update the GtkTreeModel (at the given path) and update the
1288 * respective service entry in the configuration file. Finally,
1289 * if the edited path is for a "fresh" entry, create another empty
1290 * one at the bottom. If the hostname was set to empty, remove
1291 * the entire entry from the configuration and the model.
1292 *
1293 * @param renderer GtkCellRendererText that changed
1294 * @param path GtkTreePath identifying where in the Model the change is
1295 * @param new_text the new text that was stored in the line
1296 * @param user_data NULL
1297 */
1298static void
1299save_vpn_dns_service_targetport (GtkCellRendererText *renderer,
1300 gchar *path,
1301 gchar *new_text,
1302 gpointer user_data)
1303{
1304 GtkTreeModel *tm;
1305 GtkListStore *ls;
1306 GtkTreeIter iter;
1307 int port;
1308
1309 port = atoi (new_text);
1310 if ( (port < 1) || (port > UINT16_MAX) )
1311 {
1312 /* invalid port, FIXME: warn */
1313 return;
1314 }
1315 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
1316 "vpn_dns_config_liststore"));
1317 if (NULL == tm)
1318 {
1319 GNUNET_break (0);
1320 return;
1321 }
1322 ls = GTK_LIST_STORE (tm);
1323 if (NULL == ls)
1324 {
1325 GNUNET_break (0);
1326 return;
1327 }
1328 if (TRUE != gtk_tree_model_get_iter_from_string (tm, &iter, path))
1329 {
1330 GNUNET_break (0);
1331 return;
1332 }
1333 /* update model */
1334 gtk_list_store_set (ls, &iter,
1335 2, (guint) port,
1336 -1);
1337 /* update configuration */
1338 update_vpn_dns_configuration (tm);
1339}
1340
1341
1342/**
1343 * Initialize the GtkListModel with the VPN's DNS service specification.
1344 *
1345 * @param cls NULL
1346 * @param section section with the value (NULL)
1347 * @param option option name (NULL)
1348 * @param widget widget to initialize (the GtkTreeView)
1349 * @param cfg configuration handle
1350 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
1351 */
1352static int
1353vpn_dns_service_targetport_install_edited_handler (const void *cls,
1354 const char *section,
1355 const char *option,
1356 GObject *widget,
1357 struct GNUNET_CONFIGURATION_Handle *cfg)
1358{
1359 static int once;
1360 GtkCellRendererText *rt;
1361
1362 rt = GTK_CELL_RENDERER_TEXT(widget);
1363 if (NULL == rt)
1364 return GNUNET_SYSERR;
1365 if (0 != once++)
1366 return GNUNET_OK;
1367 g_signal_connect (rt,
1368 "edited",
1369 G_CALLBACK (&save_vpn_dns_service_targetport),
1370 NULL);
1371 return GNUNET_OK;
1372}
1373
1374
1375/**
1376 * Hide "min connected friends" option if in F2F-only mode.
1377 */
1378static struct GNUNET_SETUP_VisibilitySpecification hide_min_connected_friends[] =
1379{
1380 { "GNUNET_setup_minimum_friends_label", NULL, REX_YES },
1381 { "GNUNET_setup_minimum_friends_spinbutton", NULL, REX_YES },
1382 { NULL, NULL, NULL }
1383};
1384
1385
1386/**
1387 * Hide "hostlist" options if hostlist is not in use.
1388 */
1389static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_options[] =
1390{
1391 { "GNUNET_setup_hostlist_client_enable_checkbutton", "(^| )hostlist($| )", NULL },
1392 { "GNUNET_setup_hostlist_client_learn_checkbutton", "(^| )hostlist($| )", NULL },
1393 { "GNUNET_setup_hostlist_options_hbox", "(^| )hostlist($| )", NULL },
1394 { "GNUNET_setup_hostlist_frame", "(^| )hostlist($| )", NULL },
1395 { NULL, NULL, NULL }
1396};
1397
1398
1399/**
1400 * Hide "exit" options if VPN exit is not in use.
1401 */
1402static struct GNUNET_SETUP_VisibilitySpecification hide_exit_options[] =
1403{
1404 { "GNUNET_setup_vpn_exit_frame", "(^| )exit($| )", NULL },
1405 { "GNUNET_setup_vpn_service_configuration_frame", "(^| )exit($| )", NULL },
1406 { NULL, NULL, NULL }
1407};
1408
1409
1410/**
1411 * Hide "hostlist" server options if hostlist server is not in use.
1412 */
1413static struct GNUNET_SETUP_VisibilitySpecification hide_hostlist_server_options[] =
1414{
1415 { "GNUNET_setup_hostlist_advertise_checkbutton", "(^| )-p($| )", NULL },
1416 { "GNUNET_setup_hostlist_port_label", "(^| )-p($| )", NULL },
1417 { "GNUNET_setup_hostlist_server_port_spin_button", "(^| )-p($| )", NULL },
1418 { NULL, NULL, NULL }
1419};
1420
1421
1422
1423/**
1424 * Hide "fs tab" if FS not active.
1425 */
1426static struct GNUNET_SETUP_VisibilitySpecification hide_fs_tab[] =
1427{
1428 { "GNUNET_setup_fs_main_vbox", "(^| )fs($| )", NULL },
1429 { NULL, NULL, NULL }
1430};
1431
1432
1433
1434/**
1435 * Hide "vpn tab" if VPN not active.
1436 */
1437static struct GNUNET_SETUP_VisibilitySpecification hide_vpn_tab[] =
1438{
1439 { "GNUNET_setup_vpn_vbox", "(^| )vpn($| )", NULL },
1440 { NULL, NULL, NULL }
1441};
1442
1443
1444
1445/**
1446 * Hide "tcp tab" if TCP not active.
1447 */
1448static struct GNUNET_SETUP_VisibilitySpecification hide_tcp_tab[] =
1449{
1450 { "GNUNET_setup_transport_tcp_vbox", "(^| )tcp($| )", NULL },
1451 { NULL, NULL, NULL }
1452};
1453
1454
1455/**
1456 * Hide "udp tab" if UDP not active.
1457 */
1458static struct GNUNET_SETUP_VisibilitySpecification hide_udp_tab[] =
1459{
1460 { "GNUNET_setup_transport_udp_vbox", "(^| )udp($| )", NULL },
1461 { NULL, NULL, NULL }
1462};
1463
1464
1465/**
1466 * Hide "http tab" if HTTP not active.
1467 */
1468static struct GNUNET_SETUP_VisibilitySpecification hide_http_tab[] =
1469{
1470 { "GNUNET_setup_transport_http_vbox", "(^| )http($| )", NULL },
1471 { NULL, NULL, NULL }
1472};
1473
1474
1475/**
1476 * Hide "https tab" if HTTPS not active.
1477 */
1478static struct GNUNET_SETUP_VisibilitySpecification hide_https_tab[] =
1479{
1480 { "GNUNET_setup_transport_https_vbox", "(^| )https($| )", NULL },
1481 { NULL, NULL, NULL }
1482};
1483
1484
1485/**
1486 * Hide "dv tab" if DV not active.
1487 */
1488static struct GNUNET_SETUP_VisibilitySpecification hide_dv_tab[] =
1489{
1490 { "GNUNET_setup_transport_dv_vbox", "(^| )dv($| )", NULL },
1491 { NULL, NULL, NULL }
1492};
1493
1494
1495/**
1496 * Hide "wlan tab" if WLAN not active.
1497 */
1498static struct GNUNET_SETUP_VisibilitySpecification hide_wlan_tab[] =
1499{
1500 { "GNUNET_setup_transport_wlan_vbox", "(^| )wlan($| )", NULL },
1501 { NULL, NULL, NULL }
1502};
1503
1504
1505/**
1506 * Hide "sqlite datastore" tab if sqlite not active.
1507 */
1508static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datastore_tab[] =
1509{
1510 { "GNUNET_setup_fs_datastore_sqlite_label", "^sqlite$", NULL },
1511 { NULL, NULL, NULL }
1512};
1513
1514
1515/**
1516 * Hide "mysql datastore" tab if mysql not active.
1517 */
1518static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datastore_tab[] =
1519{
1520 { "GNUNET_setup_datastore_mysql_vbox", "^mysql$", NULL },
1521 { NULL, NULL, NULL }
1522};
1523
1524
1525/**
1526 * Hide "postgres datastore" tab if postgres not active.
1527 */
1528static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datastore_tab[] =
1529{
1530 { "GNUNET_setup_datastore_postgres_hbox", "^postgres$", NULL },
1531 { NULL, NULL, NULL }
1532};
1533
1534
1535/**
1536 * Hide "sqlite datacache" tab if sqlite not active.
1537 */
1538static struct GNUNET_SETUP_VisibilitySpecification hide_sqlite_datacache_tab[] =
1539{
1540 { "GNUNET_setup_fs_datacache_sqlite_label", "^sqlite$", NULL },
1541 { NULL, NULL, NULL }
1542};
1543
1544
1545/**
1546 * Hide "mysql datacache" tab if mysql not active.
1547 */
1548static struct GNUNET_SETUP_VisibilitySpecification hide_mysql_datacache_tab[] =
1549{
1550 { "GNUNET_setup_datacache_mysql_vbox", "^mysql$", NULL },
1551 { NULL, NULL, NULL }
1552};
1553
1554
1555/**
1556 * Hide "postgres datacache" tab if postgres not active.
1557 */
1558static struct GNUNET_SETUP_VisibilitySpecification hide_postgres_datacache_tab[] =
1559{
1560 { "GNUNET_setup_datacache_postgres_hbox", "^postgres$", NULL },
1561 { NULL, NULL, NULL }
1562};
1563
1564
1565/**
1566 * Hide advertised TCP port if port is zero.
1567 */
1568static struct GNUNET_SETUP_VisibilitySpecification hide_all_tcp_options[] =
1569{
1570 { "GNUNET_setup_transport_tcp_adv_port_hbox", NULL, "^0$" },
1571 { NULL, NULL, NULL }
1572};
1573
1574
1575/**
1576 * Hide NATed peer options.
1577 */
1578static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_options[] =
1579{
1580 { "GNUNET_setup_transport_hole_punched_checkbutton", "^YES$", NULL },
1581 { "GNUNET_setup_transport_upnp_enable_checkbutton", "^YES$", NULL },
1582 { "GNUNET_setup_transport_icmp_server_enable_checkbutton", "^YES$", NULL },
1583 { "GNUNET_setup_transport_external_ip_hbox", "^YES$", NULL },
1584 { NULL, NULL, NULL }
1585};
1586
1587/**
1588 * Hide hole-punched NATed peer options.
1589 */
1590static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_punched_options[] =
1591{
1592 { "GNUNET_setup_transport_upnp_enable_checkbutton", "^NO$", NULL },
1593 { "GNUNET_setup_transport_icmp_server_enable_checkbutton", "^NO$", NULL },
1594 { NULL, NULL, NULL }
1595};
1596
1597
1598/**
1599 * Hide internal IP options.
1600 */
1601static struct GNUNET_SETUP_VisibilitySpecification toggle_internal_ip[] =
1602{
1603 { "GNUNET_setup_transport_internal_ip_hbox", "^YES$", NULL },
1604 { NULL, NULL, NULL }
1605};
1606
1607
1608/**
1609 * Option specification data.
1610 */
1611const struct GNUNET_SETUP_OptionSpecification option_specifications[] =
1612 {
1613
1614 /* GENERAL TAB */
1615
1616 {
1617 "GNUNET_setup_friends_only_checkbutton",
1618 "toggled",
1619 "topology",
1620 "FRIENDS-ONLY",
1621 gettext_noop ("Should GNUnet exclusively connect to friends?"),
1622 "https://gnunet.org/configuration-f2f",
1623 &load_yes_no,
1624 &save_yes_no, NULL,
1625 hide_min_connected_friends
1626 },
1627
1628 {
1629 "GNUNET_setup_friends_filechooserbutton",
1630 "selection-changed",
1631 "topology",
1632 "FRIENDS",
1633 gettext_noop ("Friends file containing the list of friendly peers"),
1634 "https://gnunet.org/configuration-f2f",
1635 &load_filename,
1636 &save_filename, NULL,
1637 NULL
1638 },
1639
1640 {
1641 "GNUNET_setup_minimum_friends_spinbutton",
1642 "value-changed",
1643 "topology",
1644 "MINIMUM-FRIENDS",
1645 gettext_noop ("Minimum number of friendly connections"),
1646 "https://gnunet.org/configuration-f2f",
1647 &load_number,
1648 &save_number, NULL,
1649 NULL
1650 },
1651
1652 {
1653 "GNUNET_setup_general_services_topology_checkbutton",
1654 "toggled",
1655 "arm",
1656 "DEFAULTSERVICES",
1657 gettext_noop ("Topology should always be loaded"),
1658 "https://gnunet.org/configuration-topology",
1659 &load_option_list,
1660 &save_option_list, "topology",
1661 NULL
1662 },
1663
1664 {
1665 "GNUNET_setup_general_services_hostlist_checkbutton",
1666 "toggled",
1667 "arm",
1668 "DEFAULTSERVICES",
1669 gettext_noop ("Should hostlist support be started automatically on startup?"),
1670 "https://gnunet.org/configuration-hostlist",
1671 &load_option_list,
1672 &save_option_list, "hostlist",
1673 hide_hostlist_options
1674 },
1675
1676
1677 {
1678 "GNUNET_setup_general_services_fs_checkbutton",
1679 "toggled",
1680 "arm",
1681 "DEFAULTSERVICES",
1682 gettext_noop ("Should file-sharing be started automatically on startup?"),
1683 "https://gnunet.org/configuration-fs",
1684 &load_option_list,
1685 &save_option_list, "fs",
1686 hide_fs_tab
1687 },
1688
1689 {
1690 "GNUNET_setup_general_services_vpn_checkbutton",
1691 "toggled",
1692 "arm",
1693 "DEFAULTSERVICES",
1694 gettext_noop ("Should the VPN be started automatically on startup?"),
1695 "https://gnunet.org/configuration-vpn",
1696 &load_option_list,
1697 &save_option_list, "vpn",
1698 hide_vpn_tab
1699 },
1700
1701 {
1702 "GNUNET_setup_hostlist_client_enable_checkbutton",
1703 "toggled",
1704 "hostlist",
1705 "OPTIONS",
1706 gettext_noop ("Should GNUnet learn about other peers using hostlists"),
1707 "https://gnunet.org/configuration-hostlist",
1708 &load_option_list,
1709 &save_option_list, "-b",
1710 NULL
1711 },
1712
1713 {
1714 "GNUNET_setup_hostlist_client_learn_checkbutton",
1715 "toggled",
1716 "hostlist",
1717 "OPTIONS",
1718 gettext_noop ("Should GNUnet learn hostlists from other peers"),
1719 "https://gnunet.org/configuration-hostlist",
1720 &load_option_list,
1721 &save_option_list, "-e",
1722 NULL
1723 },
1724
1725 {
1726 "GNUNET_setup_hostlist_offer_hostlist_checkbutton",
1727 "toggled",
1728 "hostlist",
1729 "OPTIONS",
1730 gettext_noop ("Should this peer offer a hostlist to other peers"),
1731 "https://gnunet.org/configuration-hostlist-server",
1732 &load_option_list,
1733 &save_option_list, "-p",
1734 hide_hostlist_server_options
1735 },
1736
1737 {
1738 "GNUNET_setup_hostlist_advertise_checkbutton",
1739 "toggled",
1740 "hostlist",
1741 "OPTIONS",
1742 gettext_noop ("Should this peer advertise its hostlist to other peers"),
1743 "https://gnunet.org/configuration-hostlist-server",
1744 &load_option_list,
1745 &save_option_list, "-a",
1746 NULL
1747 },
1748
1749 {
1750 "GNUNET_setup_hostlist_server_port_spin_button",
1751 "value-changed",
1752 "hostlist",
1753 "HTTPPORT",
1754 gettext_noop ("Port this peers hostlist should be offered on"),
1755 "https://gnunet.org/configuration-hostlist-server",
1756 &load_number,
1757 &save_number, NULL,
1758 NULL
1759 },
1760
1761 {
1762 "GNUNET_setup_hostlist_url_liststore",
1763 "row-changed",
1764 "hostlist",
1765 "SERVERS",
1766 NULL, NULL,
1767 &load_string_list_store,
1768 &save_string_list_store, NULL,
1769 NULL
1770 },
1771
1772 {
1773 "GNUNET_setup_hostlist_url_treeview",
1774 NULL, NULL, NULL, /* FIXME */
1775 gettext_noop ("Known hostlist URLs"),
1776 "https://gnunet.org/configuration-hostlist",
1777 NULL, NULL, NULL, /* FIXME */
1778 NULL
1779 },
1780
1781 {
1782 "GNUNET_setup_bandwidth_out_spinbutton",
1783 "value-changed",
1784 "core",
1785 "TOTAL_QUOTA_OUT",
1786 gettext_noop ("How many bytes per second are we allowed to transmit?"),
1787 "https://gnunet.org/configuration-bandwidth",
1788 &load_number,
1789 &save_number, NULL,
1790 NULL
1791 },
1792
1793 {
1794 "GNUNET_setup_bandwidth_in_spinbutton",
1795 "value-changed",
1796 "core",
1797 "TOTAL_QUOTA_IN",
1798 gettext_noop ("How many bytes per second are we allowed to receive?"),
1799 "https://gnunet.org/configuration-bandwidth",
1800 &load_number,
1801 &save_number, NULL,
1802 NULL
1803 },
1804
1805 /* Transport TAB */
1806
1807 {
1808 "GNUNET_setup_transport_tcp_checkbutton",
1809 "toggled",
1810 "transport",
1811 "PLUGINS",
1812 gettext_noop ("Enable communication via TCP"),
1813 "https://gnunet.org/configuration-tcp",
1814 &load_option_list,
1815 &save_option_list, "tcp",
1816 hide_tcp_tab
1817 },
1818
1819 {
1820 "GNUNET_setup_transport_udp_checkbutton",
1821 "toggled",
1822 "transport",
1823 "PLUGINS",
1824 gettext_noop ("Enable communication via UDP"),
1825 "https://gnunet.org/configuration-udp",
1826 &load_option_list,
1827 &save_option_list, "udp",
1828 hide_udp_tab
1829 },
1830
1831 {
1832 "GNUNET_setup_transport_http_checkbutton",
1833 "toggled",
1834 "transport",
1835 "PLUGINS",
1836 gettext_noop ("Enable communication via HTTP"),
1837 "https://gnunet.org/configuration-http",
1838 &load_option_list,
1839 &save_option_list, "http",
1840 hide_http_tab
1841 },
1842
1843 {
1844 "GNUNET_setup_transport_https_checkbutton",
1845 "toggled",
1846 "transport",
1847 "PLUGINS",
1848 gettext_noop ("Enable communication via HTTPS"),
1849 "https://gnunet.org/configuration-https",
1850 &load_option_list,
1851 &save_option_list, "https",
1852 hide_https_tab
1853 },
1854
1855 {
1856 "GNUNET_setup_transport_dv_checkbutton",
1857 "toggled",
1858 "transport",
1859 "PLUGINS",
1860 gettext_noop ("Enable communication via DV"),
1861 "https://gnunet.org/configuration-dv",
1862 &load_option_list,
1863 &save_option_list, "dv",
1864 hide_dv_tab
1865 },
1866
1867 {
1868 "GNUNET_setup_transport_wlan_checkbutton",
1869 "toggled",
1870 "transport",
1871 "PLUGINS",
1872 gettext_noop ("Enable communication via WLAN"),
1873 "https://gnunet.org/configuration-wlan",
1874 &load_option_list,
1875 &save_option_list, "wlan",
1876 hide_wlan_tab
1877 },
1878
1879 {
1880 "GNUNET_setup_transport_tcp_port_spinbutton",
1881 "value-changed",
1882 "transport-tcp",
1883 "PORT",
1884 gettext_noop ("Port we bind to for TCP"),
1885 "https://gnunet.org/configuration-tcp",
1886 &load_number,
1887 &save_number, NULL,
1888 hide_all_tcp_options
1889 },
1890
1891 {
1892 "GNUNET_setup_transport_tcp_adv_port_spinbutton",
1893 "value-changed",
1894 "transport-tcp",
1895 "ADVERTISED_PORT",
1896 gettext_noop ("Port visible to other peers"),
1897 "https://gnunet.org/configuration-tcp",
1898 &load_number,
1899 &save_number, NULL,
1900 NULL
1901 },
1902
1903 {
1904 "GNUNET_setup_transport_nat_checkbutton",
1905 "toggled",
1906 "nat",
1907 "BEHIND_NAT",
1908 gettext_noop ("Check if this peer is behind a NAT"),
1909 "https://gnunet.org/configuration-nat",
1910 &load_yes_no,
1911 &save_yes_no, NULL,
1912 toggle_nat_options
1913 },
1914
1915 {
1916 "GNUNET_setup_transport_hole_punched_checkbutton",
1917 "toggled",
1918 "nat",
1919 "PUNCHED_NAT",
1920 gettext_noop ("Check if the NAT has been hole-punched manually"),
1921 "https://gnunet.org/configuration-nat",
1922 &load_yes_no,
1923 &save_yes_no, NULL,
1924 toggle_nat_punched_options
1925 },
1926
1927 {
1928 "GNUNET_setup_transport_upnp_enable_checkbutton",
1929 "toggled",
1930 "nat",
1931 "ENABLE_UPNP",
1932 gettext_noop ("Enable NAT traversal with UPnP/PMP"),
1933 "https://gnunet.org/configuration-nat",
1934 &load_yes_no,
1935 &save_yes_no, NULL,
1936 NULL,
1937 },
1938
1939 {
1940 "GNUNET_setup_transport_icmp_server_enable_checkbutton",
1941 "toggled",
1942 "nat",
1943 "ENABLE_ICMP_SERVER",
1944 gettext_noop ("Enable NAT traversal with ICMP as server"),
1945 "https://gnunet.org/configuration-nat",
1946 &load_yes_no,
1947 &save_yes_no, NULL,
1948 NULL,
1949 },
1950
1951 {
1952 "GNUNET_setup_transport_external_ip_address_entry",
1953 "changed",
1954 "nat",
1955 "EXTERNAL_ADDRESS",
1956 gettext_noop ("External (public) IP address of the NAT"),
1957 "https://gnunet.org/configuration-nat",
1958 &load_text,
1959 &save_text, NULL,
1960 NULL
1961 },
1962
1963 {
1964 "GNUNET_setup_transport_icmp_client_enable_checkbutton",
1965 "toggled",
1966 "nat",
1967 "ENABLE_ICMP_CLIENT",
1968 gettext_noop ("Enable NAT traversal with ICMP as client"),
1969 "https://gnunet.org/configuration-nat",
1970 &load_yes_no,
1971 &save_yes_no, NULL,
1972 toggle_internal_ip
1973 },
1974
1975 {
1976 "GNUNET_setup_transport_internal_ip_entry",
1977 "changed",
1978 "nat",
1979 "INTERNAL_ADDRESS",
1980 gettext_noop ("Internal (private) IP address of the NAT"),
1981 "https://gnunet.org/configuration-nat",
1982 &load_text,
1983 &save_text, NULL,
1984 NULL
1985 },
1986
1987 {
1988 "GNUNET_setup_transport_disable_ipv6_checkbutton",
1989 "toggled",
1990 "nat",
1991 "DISABLEV6",
1992 gettext_noop ("Disable IPv6 support"),
1993 "https://gnunet.org/configuration-ipv6",
1994 &load_yes_no,
1995 &save_yes_no, NULL,
1996 NULL,
1997 },
1998
1999 {
2000 "GNUNET_setup_transport_udp_port_spinbutton",
2001 "value-changed",
2002 "transport-udp",
2003 "PORT",
2004 gettext_noop ("Port for inbound UDP packets, use 0 if behind NAT"),
2005 "https://gnunet.org/configuration-udp",
2006 &load_number,
2007 &save_number, NULL,
2008 NULL
2009 },
2010
2011 {
2012 "GNUNET_setup_transport_http_port_spinbutton",
2013 "value-changed",
2014 "transport-http",
2015 "PORT",
2016 gettext_noop ("Port for inbound HTTP connections, use 0 if behind NAT"),
2017 "https://gnunet.org/configuration-http",
2018 &load_number,
2019 &save_number, NULL,
2020 NULL
2021 },
2022
2023 {
2024 "GNUNET_setup_transport_https_port_spinbutton",
2025 "value-changed",
2026 "transport-https",
2027 "PORT",
2028 gettext_noop ("Port for inbound HTTPS connections, use 0 if behind NAT"),
2029 "https://gnunet.org/configuration-https",
2030 &load_number,
2031 &save_number, NULL,
2032 NULL
2033 },
2034
2035 /* FS TAB */
2036
2037 {
2038 "GNUNET_setup_fs_datastore_sqlite_radiobutton",
2039 "toggled",
2040 "datastore",
2041 "DATABASE",
2042 gettext_noop ("Use sqLite to store file-sharing content"),
2043 "https://gnunet.org/configuration-datastore",
2044 &load_option_list /* abuse! */,
2045 &save_option_list /* abuse! */, "sqlite",
2046 hide_sqlite_datastore_tab
2047 },
2048
2049 {
2050 "GNUNET_setup_fs_datastore_mysql_radiobutton",
2051 "toggled",
2052 "datastore",
2053 "DATABASE",
2054 gettext_noop ("Use MySQL to store file-sharing content"),
2055 "https://gnunet.org/configuration-datastore",
2056 &load_option_list /* abuse! */,
2057 &save_option_list /* abuse! */, "mysql",
2058 hide_mysql_datastore_tab
2059 },
2060
2061 {
2062 "GNUNET_setup_fs_datastore_postgres_radiobutton",
2063 "toggled",
2064 "datastore",
2065 "DATABASE",
2066 gettext_noop ("Use Postgres to store file-sharing content"),
2067 "https://gnunet.org/configuration-datastore",
2068 &load_option_list /* abuse! */,
2069 &save_option_list /* abuse! */, "postgres",
2070 hide_postgres_datastore_tab
2071 },
2072
2073 {
2074 "GNUNET_setup_datastore_mysql_database_name_entry",
2075 "changed",
2076 "datastore-mysql",
2077 "DATABASE",
2078 gettext_noop ("Name for the MySQL database"),
2079 "https://gnunet.org/configuration-datastore",
2080 &load_text,
2081 &save_text, NULL,
2082 NULL
2083 },
2084
2085 {
2086 "GNUNET_setup_datastore_mysql_config_file_filechooserbutton",
2087 "selection-changed",
2088 "datastore-mysql",
2089 "CONFIG",
2090 gettext_noop ("Configuration file for MySQL access"),
2091 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html",
2092 &load_filename,
2093 &save_filename, NULL,
2094 NULL
2095 },
2096
2097 {
2098 "GNUNET_setup_datastore_mysql_username_entry",
2099 "changed",
2100 "datastore-mysql",
2101 "USER",
2102 gettext_noop ("Username for MySQL access"),
2103 "https://gnunet.org/configuration-datastore",
2104 &load_text,
2105 &save_text, NULL,
2106 NULL
2107 },
2108
2109 {
2110 "GNUNET_setup_datastore_mysql_password_entry",
2111 "changed",
2112 "datastore-mysql",
2113 "PASSWORD",
2114 gettext_noop ("Password for MySQL access"),
2115 "https://gnunet.org/configuration-datastore",
2116 &load_text,
2117 &save_text, NULL,
2118 NULL
2119 },
2120
2121 {
2122 "GNUNET_setup_datastore_mysql_hostname_entry",
2123 "changed",
2124 "datastore-mysql",
2125 "HOST",
2126 gettext_noop ("Name of host running MySQL database"),
2127 "https://gnunet.org/configuration-datastore",
2128 &load_text,
2129 &save_text, NULL,
2130 NULL
2131 },
2132
2133 {
2134 "GNUNET_setup_datastore_mysql_port_spinbutton",
2135 "value-changed",
2136 "datastore-mysql",
2137 "PORT",
2138 gettext_noop ("Port of MySQL database"),
2139 "https://gnunet.org/configuration-datastore",
2140 &load_number,
2141 &save_number, NULL,
2142 NULL
2143 },
2144
2145 {
2146 "GNUNET_setup_datastore_postgres_config_entry",
2147 "changed",
2148 "datastore-postgres",
2149 "CONFIG",
2150 gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"),
2151 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT",
2152 &load_text,
2153 &save_text, NULL,
2154 NULL
2155 },
2156
2157
2158 {
2159 "GNUNET_setup_fs_migration_from_checkbutton",
2160 "toggled",
2161 "fs",
2162 "CONTENT_PUSHING",
2163 gettext_noop ("Should we try to push our content to other peers?"),
2164 "https://gnunet.org/configuration-fs",
2165 &load_yes_no,
2166 &save_yes_no, NULL,
2167 NULL
2168 },
2169
2170 {
2171 "GNUNET_setup_fs_migration_to_checkbutton",
2172 "toggled",
2173 "fs",
2174 "CONTENT_CACHING",
2175 gettext_noop ("Are we allowed to cache content received from other peers?"),
2176 "https://gnunet.org/configuration-fs",
2177 &load_yes_no,
2178 &save_yes_no, NULL,
2179 NULL
2180 },
2181
2182 {
2183 "GNUNET_setup_fs_datacache_sqlite_radiobutton",
2184 "toggled",
2185 "dhtcache",
2186 "DATABASE",
2187 gettext_noop ("Use sqLite to cache DHT data"),
2188 "https://gnunet.org/configuration-datacache",
2189 &load_option_list /* abuse! */,
2190 &save_option_list /* abuse! */, "sqlite",
2191 hide_sqlite_datacache_tab
2192 },
2193
2194 {
2195 "GNUNET_setup_fs_datacache_mysql_radiobutton",
2196 "toggled",
2197 "dhtcache",
2198 "DATABASE",
2199 gettext_noop ("Use MySQL to cache DHT data"),
2200 "https://gnunet.org/configuration-datacache",
2201 &load_option_list /* abuse! */,
2202 &save_option_list /* abuse! */, "mysql",
2203 hide_mysql_datacache_tab
2204 },
2205
2206 {
2207 "GNUNET_setup_fs_datacache_postgres_radiobutton",
2208 "toggled",
2209 "dhtcache",
2210 "DATABASE",
2211 gettext_noop ("Use Postgres to cache DHT data"),
2212 "https://gnunet.org/configuration-datacache",
2213 &load_option_list /* abuse! */,
2214 &save_option_list /* abuse! */, "postgres",
2215 hide_postgres_datacache_tab
2216 },
2217
2218 {
2219 "GNUNET_setup_datacache_mysql_database_name_entry",
2220 "changed",
2221 "datacache-mysql",
2222 "DATABASE",
2223 gettext_noop ("Name for the MySQL database"),
2224 "https://gnunet.org/configuration-datacache",
2225 &load_text,
2226 &save_text, NULL,
2227 NULL
2228 },
2229
2230 {
2231 "GNUNET_setup_datacache_mysql_config_file_filechooserbutton",
2232 "selection-changed",
2233 "datacache-mysql",
2234 "CONFIG",
2235 gettext_noop ("Configuration file for MySQL access"),
2236 "http://dev.mysql.com/doc/refman/5.5/en/option-files.html",
2237 &load_filename,
2238 &save_filename, NULL,
2239 NULL
2240 },
2241
2242 {
2243 "GNUNET_setup_datacache_mysql_username_entry",
2244 "changed",
2245 "datacache-mysql",
2246 "USER",
2247 gettext_noop ("Username for MySQL access"),
2248 "https://gnunet.org/configuration-datacache",
2249 &load_text,
2250 &save_text, NULL,
2251 NULL
2252 },
2253
2254 {
2255 "GNUNET_setup_datacache_mysql_password_entry",
2256 "changed",
2257 "datacache-mysql",
2258 "PASSWORD",
2259 gettext_noop ("Password for MySQL access"),
2260 "https://gnunet.org/configuration-datacache",
2261 &load_text,
2262 &save_text, NULL,
2263 NULL
2264 },
2265
2266 {
2267 "GNUNET_setup_datacache_mysql_hostname_entry",
2268 "changed",
2269 "datacache-mysql",
2270 "HOST",
2271 gettext_noop ("Name of host running MySQL database"),
2272 "https://gnunet.org/configuration-datacache",
2273 &load_text,
2274 &save_text, NULL,
2275 NULL
2276 },
2277
2278 {
2279 "GNUNET_setup_transport_wlan_interface_entry",
2280 "changed",
2281 "transport-wlan",
2282 "INTERFACE",
2283 gettext_noop ("Name of monitoring interface to use (monX)"),
2284 "https://gnunet.org/configuration-wlan",
2285 &load_text,
2286 &save_text, NULL,
2287 NULL
2288 },
2289
2290 {
2291 "GNUNET_setup_datacache_mysql_port_spinbutton",
2292 "value-changed",
2293 "datacache-mysql",
2294 "PORT",
2295 gettext_noop ("Port of MySQL database"),
2296 "https://gnunet.org/configuration-datacache",
2297 &load_number,
2298 &save_number, NULL,
2299 NULL
2300 },
2301
2302 {
2303 "GNUNET_setup_datacache_postgres_config_entry",
2304 "changed",
2305 "datacache-postgres",
2306 "CONFIG",
2307 gettext_noop ("Configuration for Postgres (passed to PQconnectdb)"),
2308 "http://www.postgresql.org/docs/8.1/static/libpq.html#LIBPQ-CONNECT",
2309 &load_text,
2310 &save_text, NULL,
2311 NULL
2312 },
2313
2314 {
2315 "GNUNET_setup_vpn_master_interface_entry",
2316 "changed",
2317 "vpn",
2318 "IFNAME",
2319 gettext_noop ("Name of the virtual interface the GNUnet VPN should create"),
2320 "https://gnunet.org/configuration-vpn",
2321 &load_text,
2322 &save_text, NULL,
2323 NULL
2324 },
2325
2326 {
2327 "GNUNET_setup_vpn_master_interface_v4_ip_entry",
2328 "changed",
2329 "vpn",
2330 "IPV4ADDR",
2331 gettext_noop ("IPv4 address to use for the VPN interface"),
2332 "https://gnunet.org/configuration-vpn",
2333 &load_text,
2334 &save_text, NULL,
2335 NULL
2336 },
2337
2338 {
2339 "GNUNET_setup_vpn_master_interface_v4_mask_entry",
2340 "changed",
2341 "vpn",
2342 "IPV4MASK",
2343 gettext_noop ("IPv4 network mask to use for the VPN interface"),
2344 "https://gnunet.org/configuration-vpn",
2345 &load_text,
2346 &save_text, NULL,
2347 NULL
2348 },
2349
2350 {
2351 "GNUNET_setup_vpn_master_interface_v6_ip_entry",
2352 "changed",
2353 "vpn",
2354 "IPV6ADDR",
2355 gettext_noop ("IPv6 address to use for the VPN interface"),
2356 "https://gnunet.org/configuration-vpn",
2357 &load_text,
2358 &save_text, NULL,
2359 NULL
2360 },
2361
2362 {
2363 "GNUNET_setup_vpn_master_interface_v6_mask_spinbutton",
2364 "value-changed",
2365 "vpn",
2366 "IPV6MASK",
2367 gettext_noop ("IPv6 network prefix length to use for the VPN interface"),
2368 "https://gnunet.org/configuration-vpn",
2369 &load_number,
2370 &save_number, NULL,
2371 NULL
2372 },
2373
2374 {
2375 "GNUNET_setup_vpn_master_vdns_server_entry",
2376 "changed",
2377 "vpn",
2378 "VIRTDNS",
2379 gettext_noop ("IP address of the virtual DNS server that resolves through GNUnet (use in resolve.conf if you want to resolve through some GNUnet DNS Exit)"),
2380 "https://gnunet.org/configuration-vpn",
2381 &load_text,
2382 &save_text, NULL,
2383 NULL
2384 },
2385
2386 {
2387 "GNUNET_setup_vpn_enable_vpn_exit_checkbutton",
2388 "toggled",
2389 "arm",
2390 "DEFAULTSERVICES",
2391 gettext_noop ("Activate the VPN exit to provide services and/or to enable others to use your Internet connection"),
2392 "https://gnunet.org/configuration-exit",
2393 &load_option_list,
2394 &save_option_list, "exit",
2395 hide_exit_options
2396 },
2397
2398 {
2399 "GNUNET_setup_vpn_enable_dns_exit_checkbutton",
2400 "toggled",
2401 "dns",
2402 "PROVIDE_EXIT",
2403 gettext_noop ("Allow other peers to perform DNS resolutions using your Internet connection"),
2404 "https://gnunet.org/configuration-dns",
2405 &load_yes_no,
2406 &save_yes_no, NULL,
2407 NULL
2408 },
2409
2410 {
2411 "GNUNET_setup_vpn_exit_interface_name_entry",
2412 "changed",
2413 "exit",
2414 "IFNAME",
2415 gettext_noop ("Name of the virtual interface the GNUnet exit service should create for traffic exiting the VPN to the Internet"),
2416 "https://gnunet.org/configuration-exit",
2417 &load_text,
2418 &save_text, NULL,
2419 NULL
2420 },
2421
2422 {
2423 "GNUNET_setup_vpn_exit_interface_v4_ip_entry",
2424 "changed",
2425 "exit",
2426 "IPV4ADDR",
2427 gettext_noop ("IPv4 address to use for the VPN Exit interface"),
2428 "https://gnunet.org/configuration-exit",
2429 &load_text,
2430 &save_text, NULL,
2431 NULL
2432 },
2433
2434 {
2435 "GNUNET_setup_vpn_exit_interface_v4_mask_entry",
2436 "changed",
2437 "exit",
2438 "IPV4MASK",
2439 gettext_noop ("IPv4 network mask to use for the VPN Exit interface"),
2440 "https://gnunet.org/configuration-exit",
2441 &load_text,
2442 &save_text, NULL,
2443 NULL
2444 },
2445
2446 {
2447 "GNUNET_setup_vpn_exit_interface_v6_ip_entry",
2448 "changed",
2449 "exit",
2450 "IPV6ADDR",
2451 gettext_noop ("IPv6 address to use for the VPN Exit interface"),
2452 "https://gnunet.org/configuration-exit",
2453 &load_text,
2454 &save_text, NULL,
2455 NULL
2456 },
2457
2458 {
2459 "GNUNET_setup_vpn_exit_interface_v6_mask_spinbutton",
2460 "value-changed",
2461 "exit",
2462 "IPV6MASK",
2463 gettext_noop ("IPv6 network prefix length to use for the VPN Exit interface"),
2464 "https://gnunet.org/configuration-exit",
2465 &load_number,
2466 &save_number, NULL,
2467 NULL
2468 },
2469
2470
2471 {
2472 "GNUNET_setup_vpn_exit_enable_udp_checkbutton",
2473 "toggled",
2474 "exit",
2475 "ENABLE_UDP",
2476 gettext_noop ("Allow other users to use your Internet connection for UDP traffic (via the Exit interface)"),
2477 "https://gnunet.org/configuration-exit",
2478 &load_yes_no,
2479 &save_yes_no, NULL,
2480 NULL
2481 },
2482
2483 {
2484 "GNUNET_setup_vpn_exit_enable_tcp_checkbutton",
2485 "toggled",
2486 "exit",
2487 "ENABLE_TCP",
2488 gettext_noop ("Allow other users to use your Internet connection for TCP traffic (via the Exit interface)"),
2489 "https://gnunet.org/configuration-exit",
2490 &load_yes_no,
2491 &save_yes_no, NULL,
2492 NULL
2493 },
2494
2495 /* DNS treeview */
2496
2497 {
2498 "GNUNET_setup_vpn_dns_service_treeview",
2499 NULL,
2500 NULL,
2501 NULL,
2502 gettext_noop ("Specification of .gnunet hostnames and services offered by this peer"),
2503 "https://gnunet.org/configuration-dns",
2504 &load_vpn_dns_configuration,
2505 NULL, NULL,
2506 NULL
2507 },
2508
2509 {
2510 "GNUNET_setup_vpn_dns_service_dnsname_cellrenderertext",
2511 "editing-started",
2512 NULL,
2513 NULL,
2514 NULL,
2515 "https://gnunet.org/configuration-dns",
2516 NULL,
2517 &vpn_dns_service_dnsname_install_edited_handler,
2518 NULL,
2519 NULL
2520 },
2521
2522 {
2523 "GNUNET_setup_vpn_dns_service_tcpudp_cellrenderertext",
2524 "editing-started",
2525 NULL,
2526 NULL,
2527 NULL,
2528 "https://gnunet.org/configuration-dns",
2529 NULL,
2530 &vpn_dns_service_tcpudp_install_edited_handler,
2531 NULL,
2532 NULL
2533 },
2534
2535 {
2536 "GNUNET_setup_vpn_dns_service_sourceport_cellrenderertext",
2537 "editing-started",
2538 NULL,
2539 NULL,
2540 NULL,
2541 "https://gnunet.org/configuration-dns",
2542 NULL,
2543 &vpn_dns_service_sourceport_install_edited_handler,
2544 NULL,
2545 NULL
2546 },
2547
2548 {
2549 "GNUNET_setup_vpn_dns_service_targethostname_cellrenderertext",
2550 "editing-started",
2551 NULL,
2552 NULL,
2553 NULL,
2554 "https://gnunet.org/configuration-dns",
2555 NULL,
2556 &vpn_dns_service_targethostname_install_edited_handler,
2557 NULL,
2558 NULL
2559 },
2560
2561 {
2562 "GNUNET_setup_vpn_dns_service_targetport_cellrenderertext",
2563 "editing-started",
2564 NULL,
2565 NULL,
2566 NULL,
2567 "https://gnunet.org/configuration-dns",
2568 NULL,
2569 &vpn_dns_service_targetport_install_edited_handler,
2570 NULL,
2571 NULL
2572 },
2573
2574 /* END of list */
2575
2576 { NULL, NULL, NULL, NULL, NULL,
2577 NULL, NULL, NULL, NULL }
2578 };
2579
2580/* end of gnunet-setup-options.c */
diff --git a/src/setup/gnunet-setup-options.h b/src/setup/gnunet-setup-options.h
new file mode 100644
index 00000000..25cd6507
--- /dev/null
+++ b/src/setup/gnunet-setup-options.h
@@ -0,0 +1,161 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-options.h
23 * @brief configuration details
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SETUP_OPTIONS_H
27#define GNUNET_SETUP_OPTIONS_H
28
29#include "gnunet-setup.h"
30
31
32/**
33 * Function to setup the value on load.
34 *
35 * @param cls closure
36 * @param section section with the value
37 * @param option option name
38 * @param value value as a string
39 * @param widget widget to initialize
40 * @param cfg configuration handle
41 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
42 */
43typedef int (*GNUNET_SETUP_LoadFunction)(const void *cls,
44 const char *section,
45 const char *option,
46 const char *value,
47 GObject *widget,
48 const struct GNUNET_CONFIGURATION_Handle *cfg);
49
50
51/**
52 * Modify the configuration to contain the right value for
53 * the option based on the state of the widget.
54 *
55 * @param cls closure
56 * @param section section with the value
57 * @param option option name
58 * @param widget widget to initialize
59 * @param cfg configuration handle to update
60 * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
61 */
62typedef int (*GNUNET_SETUP_SaveFunction)(const void *cls,
63 const char *section,
64 const char *option,
65 GObject *widget,
66 struct GNUNET_CONFIGURATION_Handle *cfg);
67
68
69/**
70 * Structs of this type specify under which conditions the values of
71 * a particular option impact the visibility (or sensitivity) of some
72 * other widget.
73 */
74struct GNUNET_SETUP_VisibilitySpecification
75{
76 /**
77 * Which widget should be changed?
78 */
79 const char *widget_name;
80
81 /**
82 * If the option value matchis this regex, the widget should be
83 * shown. If NULL, the "hide_value" controls visibility.
84 */
85 const char *show_value;
86
87 /**
88 * If the option value matchis this regex, the widget should be
89 * hidden. If NULL, the "show_value" controls visibility.
90 */
91 const char *hide_value;
92
93};
94
95
96/**
97 * Structs of this type define how widgets relate to GNUnet options
98 * and control visibility and special actions.
99 */
100struct GNUNET_SETUP_OptionSpecification
101{
102 /**
103 * Name of the GTK widget in Glade.
104 */
105 const char *widget_name;
106
107 /**
108 * Name of the signal the widget emits if its state changes.
109 */
110 const char *change_signal;
111
112 /**
113 * Section in the configuration
114 */
115 const char *section;
116
117 /**
118 * Name of the configuration option.
119 */
120 const char *option;
121
122 /**
123 * Help text to display for this option.
124 */
125 const char *help_text;
126
127 /**
128 * Help URL to link to for this option.
129 */
130 const char *help_url;
131
132 /**
133 * Function to call to initialize the widget from the configuration.
134 */
135 GNUNET_SETUP_LoadFunction load_function;
136
137 /**
138 * Function to call set the configuration from the widget.
139 */
140 GNUNET_SETUP_SaveFunction save_function;
141
142 /**
143 * Closure for 'validation_function'.
144 */
145 const void *load_save_cls;
146
147 /**
148 * Visibility changes to apply if this option changes (NULL, or
149 * NULL-terminated).
150 */
151 const struct GNUNET_SETUP_VisibilitySpecification *visibility;
152
153};
154
155
156/**
157 * Option specification data.
158 */
159extern const struct GNUNET_SETUP_OptionSpecification option_specifications[];
160
161#endif
diff --git a/src/setup/gnunet-setup-transport-http.c b/src/setup/gnunet-setup-transport-http.c
new file mode 100644
index 00000000..6021413b
--- /dev/null
+++ b/src/setup/gnunet-setup-transport-http.c
@@ -0,0 +1,182 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport-http.c
23 * @brief support for HTTP configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_resolver_service.h>
28#include <gnunet/gnunet_nat_lib.h>
29
30/**
31 * How long do we wait for the NAT test to report success?
32 */
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
34
35/**
36 * Handle to the active NAT test.
37 */
38static struct GNUNET_NAT_Test *tst;
39
40/**
41 * Task identifier for the timeout.
42 */
43static GNUNET_SCHEDULER_TaskIdentifier tsk;
44
45
46/**
47 * Function called by NAT on success.
48 * Clean up and update GUI (with success).
49 *
50 * @param cls closure (unused)
51 * @param success currently always GNUNET_OK
52 */
53static void
54result_callback (void *cls,
55 int success)
56{
57 int *ok = cls;
58
59 *ok = success;
60 GNUNET_SCHEDULER_cancel (tsk);
61 tsk = GNUNET_SCHEDULER_NO_TASK;
62 GNUNET_NAT_test_stop (tst);
63 tst = NULL;
64}
65
66
67/**
68 * Function called if NAT failed to confirm success.
69 * Clean up and update GUI (with failure).
70 *
71 * @param cls closure (unused)
72 * @param tc scheduler callback
73 */
74static void
75fail_timeout (void *cls,
76 const struct GNUNET_SCHEDULER_TaskContext *tc)
77{
78 int *ok = cls;
79
80 GNUNET_assert (NULL != tst);
81 *ok = GNUNET_NO;
82 tsk = GNUNET_SCHEDULER_NO_TASK;
83 GNUNET_NAT_test_stop (tst);
84 tst = NULL;
85}
86
87
88/**
89 * Main function for the NAT test.
90 *
91 * @param cls the 'int*' for the result
92 * @param tc scheduler context
93 */
94static void
95test (void *cls,
96 const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 int *ok = cls;
99 unsigned long long bnd_port;
100 unsigned long long adv_port;
101
102 GNUNET_assert (NULL != cfg);
103 GNUNET_RESOLVER_connect (cfg);
104 if (GNUNET_OK !=
105 GNUNET_CONFIGURATION_get_value_number (cfg,
106 "transport-http",
107 "PORT",
108 &bnd_port))
109 {
110 GNUNET_break (0);
111 return;
112 }
113 if (GNUNET_OK !=
114 GNUNET_CONFIGURATION_get_value_number (cfg,
115 "transport-http",
116 "ADVERTISED_PORT",
117 &adv_port))
118 adv_port = bnd_port;
119 tst = GNUNET_NAT_test_start (cfg,
120 GNUNET_YES,
121 (uint16_t) bnd_port,
122 (uint16_t) adv_port,
123 &result_callback,
124 ok);
125 if (NULL == tst)
126 {
127 *ok = GNUNET_SYSERR;
128 return;
129 }
130 tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
131 &fail_timeout,
132 ok);
133}
134
135/**
136 * Function called whenever the user wants to test the
137 * HTTP configuration.
138 */
139void
140GNUNET_setup_transport_http_test_button_clicked_cb ()
141{
142 GtkWidget *w;
143 int ok;
144 struct GNUNET_OS_Process *resolver;
145
146 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
147 GNUNET_assert (NULL == tst);
148 w = GTK_WIDGET (gtk_builder_get_object (builder,
149 "GNUNET_setup_transport_http_test_success_image"));
150 gtk_widget_hide (w);
151 resolver = GNUNET_OS_start_process (NULL, NULL,
152 "gnunet-service-resolver",
153 "gnunet-service-resolver", NULL);
154 ok = GNUNET_NO;
155 GNUNET_SCHEDULER_run (&test, &ok);
156 if (NULL != resolver)
157 {
158 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
159 GNUNET_OS_process_close (resolver);
160 }
161 if (GNUNET_YES != ok)
162 {
163 w = GTK_WIDGET (gtk_builder_get_object (builder,
164 "GNUNET_setup_transport_http_test_fail_image"));
165 gtk_widget_show (w);
166 w = GTK_WIDGET (gtk_builder_get_object (builder,
167 "GNUNET_setup_transport_http_test_success_image"));
168 gtk_widget_hide (w);
169 }
170 else
171 {
172 w = GTK_WIDGET (gtk_builder_get_object (builder,
173 "GNUNET_setup_transport_http_test_fail_image"));
174 gtk_widget_hide (w);
175 w = GTK_WIDGET (gtk_builder_get_object (builder,
176 "GNUNET_setup_transport_http_test_success_image"));
177 gtk_widget_show (w);
178 }
179}
180
181
182/* end of gnunet-setup-transport-http.c */
diff --git a/src/setup/gnunet-setup-transport-https.c b/src/setup/gnunet-setup-transport-https.c
new file mode 100644
index 00000000..8d53b1f4
--- /dev/null
+++ b/src/setup/gnunet-setup-transport-https.c
@@ -0,0 +1,182 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport-https.c
23 * @brief support for HTTPS configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_resolver_service.h>
28#include <gnunet/gnunet_nat_lib.h>
29
30/**
31 * How long do we wait for the NAT test to report success?
32 */
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
34
35/**
36 * Handle to the active NAT test.
37 */
38static struct GNUNET_NAT_Test *tst;
39
40/**
41 * Task identifier for the timeout.
42 */
43static GNUNET_SCHEDULER_TaskIdentifier tsk;
44
45
46/**
47 * Function called by NAT on success.
48 * Clean up and update GUI (with success).
49 *
50 * @param cls closure (unused)
51 * @param success currently always GNUNET_OK
52 */
53static void
54result_callback (void *cls,
55 int success)
56{
57 int *ok = cls;
58
59 *ok = success;
60 GNUNET_SCHEDULER_cancel (tsk);
61 tsk = GNUNET_SCHEDULER_NO_TASK;
62 GNUNET_NAT_test_stop (tst);
63 tst = NULL;
64}
65
66
67/**
68 * Function called if NAT failed to confirm success.
69 * Clean up and update GUI (with failure).
70 *
71 * @param cls closure (unused)
72 * @param tc scheduler callback
73 */
74static void
75fail_timeout (void *cls,
76 const struct GNUNET_SCHEDULER_TaskContext *tc)
77{
78 int *ok = cls;
79
80 GNUNET_assert (NULL != tst);
81 *ok = GNUNET_NO;
82 tsk = GNUNET_SCHEDULER_NO_TASK;
83 GNUNET_NAT_test_stop (tst);
84 tst = NULL;
85}
86
87
88/**
89 * Main function for the NAT test.
90 *
91 * @param cls the 'int*' for the result
92 * @param tc scheduler context
93 */
94static void
95test (void *cls,
96 const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 int *ok = cls;
99 unsigned long long bnd_port;
100 unsigned long long adv_port;
101
102 GNUNET_assert (NULL != cfg);
103 GNUNET_RESOLVER_connect (cfg);
104 if (GNUNET_OK !=
105 GNUNET_CONFIGURATION_get_value_number (cfg,
106 "transport-https",
107 "PORT",
108 &bnd_port))
109 {
110 GNUNET_break (0);
111 return;
112 }
113 if (GNUNET_OK !=
114 GNUNET_CONFIGURATION_get_value_number (cfg,
115 "transport-https",
116 "ADVERTISED_PORT",
117 &adv_port))
118 adv_port = bnd_port;
119 tst = GNUNET_NAT_test_start (cfg,
120 GNUNET_YES,
121 (uint16_t) bnd_port,
122 (uint16_t) adv_port,
123 &result_callback,
124 ok);
125 if (NULL == tst)
126 {
127 *ok = GNUNET_SYSERR;
128 return;
129 }
130 tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
131 &fail_timeout,
132 ok);
133}
134
135/**
136 * Function called whenever the user wants to test the
137 * HTTPS configuration.
138 */
139void
140GNUNET_setup_transport_https_test_button_clicked_cb ()
141{
142 GtkWidget *w;
143 int ok;
144 struct GNUNET_OS_Process *resolver;
145
146 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
147 GNUNET_assert (NULL == tst);
148 w = GTK_WIDGET (gtk_builder_get_object (builder,
149 "GNUNET_setup_transport_https_test_success_image"));
150 gtk_widget_hide (w);
151 resolver = GNUNET_OS_start_process (NULL, NULL,
152 "gnunet-service-resolver",
153 "gnunet-service-resolver", NULL);
154 ok = GNUNET_NO;
155 GNUNET_SCHEDULER_run (&test, &ok);
156 if (NULL != resolver)
157 {
158 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
159 GNUNET_OS_process_close (resolver);
160 }
161 if (GNUNET_YES != ok)
162 {
163 w = GTK_WIDGET (gtk_builder_get_object (builder,
164 "GNUNET_setup_transport_https_test_fail_image"));
165 gtk_widget_show (w);
166 w = GTK_WIDGET (gtk_builder_get_object (builder,
167 "GNUNET_setup_transport_https_test_success_image"));
168 gtk_widget_hide (w);
169 }
170 else
171 {
172 w = GTK_WIDGET (gtk_builder_get_object (builder,
173 "GNUNET_setup_transport_https_test_fail_image"));
174 gtk_widget_hide (w);
175 w = GTK_WIDGET (gtk_builder_get_object (builder,
176 "GNUNET_setup_transport_https_test_success_image"));
177 gtk_widget_show (w);
178 }
179}
180
181
182/* end of gnunet-setup-transport-https.c */
diff --git a/src/setup/gnunet-setup-transport-plugins.c b/src/setup/gnunet-setup-transport-plugins.c
new file mode 100644
index 00000000..52fa9dea
--- /dev/null
+++ b/src/setup/gnunet-setup-transport-plugins.c
@@ -0,0 +1,105 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport-plugins.c
23 * @brief (de)sensitize transport plugin buttons based on plugin availability
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27
28
29/**
30 * Test if the given plugin exists and change the sensitivity
31 * of the widget accordingly.
32 *
33 * @param widget widget to update
34 * @param name name of the plugin to check
35 */
36static void
37test_plugin (GtkWidget *widget,
38 const char *name)
39{
40 if (GNUNET_YES ==
41 GNUNET_PLUGIN_test (name))
42 {
43 gtk_widget_set_sensitive (widget,
44 TRUE);
45 }
46 else
47 {
48 gtk_widget_set_sensitive (widget,
49 FALSE);
50 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
51 FALSE);
52 }
53}
54
55
56
57void
58GNUNET_setup_transport_tcp_checkbutton_realize_cb (GtkWidget *widget,
59 gpointer user_data)
60{
61 test_plugin (widget, "libgnunet_plugin_transport_tcp");
62}
63
64
65void
66GNUNET_setup_transport_udp_checkbutton_realize_cb (GtkWidget *widget,
67 gpointer user_data)
68{
69 test_plugin (widget, "libgnunet_plugin_transport_udp");
70}
71
72
73void
74GNUNET_setup_transport_http_checkbutton_realize_cb (GtkWidget *widget,
75 gpointer user_data)
76{
77 test_plugin (widget, "libgnunet_plugin_transport_http");
78}
79
80
81void
82GNUNET_setup_transport_https_checkbutton_realize_cb (GtkWidget *widget,
83 gpointer user_data)
84{
85 test_plugin (widget, "libgnunet_plugin_transport_https");
86}
87
88
89void
90GNUNET_setup_transport_dv_checkbutton_realize_cb (GtkWidget *widget,
91 gpointer user_data)
92{
93 test_plugin (widget, "libgnunet_plugin_transport_dv");
94}
95
96
97void
98GNUNET_setup_transport_wlan_checkbutton_realize_cb (GtkWidget *widget,
99 gpointer user_data)
100{
101 test_plugin (widget, "libgnunet_plugin_transport_wlan");
102}
103
104/* end of gnunet-setup-transport-plugins.c */
105
diff --git a/src/setup/gnunet-setup-transport-tcp.c b/src/setup/gnunet-setup-transport-tcp.c
new file mode 100644
index 00000000..ba592846
--- /dev/null
+++ b/src/setup/gnunet-setup-transport-tcp.c
@@ -0,0 +1,182 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport-tcp.c
23 * @brief support for TCP configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_resolver_service.h>
28#include <gnunet/gnunet_nat_lib.h>
29
30/**
31 * How long do we wait for the NAT test to report success?
32 */
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
34
35/**
36 * Handle to the active NAT test.
37 */
38static struct GNUNET_NAT_Test *tst;
39
40/**
41 * Task identifier for the timeout.
42 */
43static GNUNET_SCHEDULER_TaskIdentifier tsk;
44
45
46/**
47 * Function called by NAT on success.
48 * Clean up and update GUI (with success).
49 *
50 * @param cls closure (unused)
51 * @param success currently always GNUNET_OK
52 */
53static void
54result_callback (void *cls,
55 int success)
56{
57 int *ok = cls;
58
59 *ok = success;
60 GNUNET_SCHEDULER_cancel (tsk);
61 tsk = GNUNET_SCHEDULER_NO_TASK;
62 GNUNET_NAT_test_stop (tst);
63 tst = NULL;
64}
65
66
67/**
68 * Function called if NAT failed to confirm success.
69 * Clean up and update GUI (with failure).
70 *
71 * @param cls closure (unused)
72 * @param tc scheduler callback
73 */
74static void
75fail_timeout (void *cls,
76 const struct GNUNET_SCHEDULER_TaskContext *tc)
77{
78 int *ok = cls;
79
80 GNUNET_assert (NULL != tst);
81 *ok = GNUNET_NO;
82 tsk = GNUNET_SCHEDULER_NO_TASK;
83 GNUNET_NAT_test_stop (tst);
84 tst = NULL;
85}
86
87
88/**
89 * Main function for the NAT test.
90 *
91 * @param cls the 'int*' for the result
92 * @param tc scheduler context
93 */
94static void
95test (void *cls,
96 const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 int *ok = cls;
99 unsigned long long bnd_port;
100 unsigned long long adv_port;
101
102 GNUNET_assert (NULL != cfg);
103 GNUNET_RESOLVER_connect (cfg);
104 if (GNUNET_OK !=
105 GNUNET_CONFIGURATION_get_value_number (cfg,
106 "transport-tcp",
107 "PORT",
108 &bnd_port))
109 {
110 GNUNET_break (0);
111 return;
112 }
113 if (GNUNET_OK !=
114 GNUNET_CONFIGURATION_get_value_number (cfg,
115 "transport-tcp",
116 "ADVERTISED_PORT",
117 &adv_port))
118 adv_port = bnd_port;
119 tst = GNUNET_NAT_test_start (cfg,
120 GNUNET_YES,
121 (uint16_t) bnd_port,
122 (uint16_t) adv_port,
123 &result_callback,
124 ok);
125 if (NULL == tst)
126 {
127 *ok = GNUNET_SYSERR;
128 return;
129 }
130 tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
131 &fail_timeout,
132 ok);
133}
134
135/**
136 * Function called whenever the user wants to test the
137 * TCP configuration.
138 */
139void
140GNUNET_setup_transport_tcp_test_button_clicked_cb ()
141{
142 GtkWidget *w;
143 int ok;
144 struct GNUNET_OS_Process *resolver;
145
146 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
147 GNUNET_assert (NULL == tst);
148 w = GTK_WIDGET (gtk_builder_get_object (builder,
149 "GNUNET_setup_transport_tcp_test_success_image"));
150 gtk_widget_hide (w);
151 resolver = GNUNET_OS_start_process (NULL, NULL,
152 "gnunet-service-resolver",
153 "gnunet-service-resolver", NULL);
154 ok = GNUNET_NO;
155 GNUNET_SCHEDULER_run (&test, &ok);
156 if (NULL != resolver)
157 {
158 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
159 GNUNET_OS_process_close (resolver);
160 }
161 if (GNUNET_YES != ok)
162 {
163 w = GTK_WIDGET (gtk_builder_get_object (builder,
164 "GNUNET_setup_transport_tcp_test_fail_image"));
165 gtk_widget_show (w);
166 w = GTK_WIDGET (gtk_builder_get_object (builder,
167 "GNUNET_setup_transport_tcp_test_success_image"));
168 gtk_widget_hide (w);
169 }
170 else
171 {
172 w = GTK_WIDGET (gtk_builder_get_object (builder,
173 "GNUNET_setup_transport_tcp_test_fail_image"));
174 gtk_widget_hide (w);
175 w = GTK_WIDGET (gtk_builder_get_object (builder,
176 "GNUNET_setup_transport_tcp_test_success_image"));
177 gtk_widget_show (w);
178 }
179}
180
181
182/* end of gnunet-setup-transport-tcp.c */
diff --git a/src/setup/gnunet-setup-transport-udp.c b/src/setup/gnunet-setup-transport-udp.c
new file mode 100644
index 00000000..28aec749
--- /dev/null
+++ b/src/setup/gnunet-setup-transport-udp.c
@@ -0,0 +1,181 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport-udp.c
23 * @brief support for UDP configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_resolver_service.h>
28#include <gnunet/gnunet_nat_lib.h>
29
30/**
31 * How long do we wait for the NAT test to report success?
32 */
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
34
35/**
36 * Handle to the active NAT test.
37 */
38static struct GNUNET_NAT_Test *tst;
39
40/**
41 * Task identifier for the timeout.
42 */
43static GNUNET_SCHEDULER_TaskIdentifier tsk;
44
45
46/**
47 * Function called by NAT on success.
48 * Clean up and update GUI (with success).
49 *
50 * @param cls closure (unused)
51 * @param success currently always GNUNET_OK
52 */
53static void
54result_callback (void *cls,
55 int success)
56{
57 int *ok = cls;
58
59 *ok = success;
60 GNUNET_SCHEDULER_cancel (tsk);
61 tsk = GNUNET_SCHEDULER_NO_TASK;
62 GNUNET_NAT_test_stop (tst);
63 tst = NULL;
64}
65
66
67/**
68 * Function called if NAT failed to confirm success.
69 * Clean up and update GUI (with failure).
70 *
71 * @param cls closure (unused)
72 * @param tc scheduler callback
73 */
74static void
75fail_timeout (void *cls,
76 const struct GNUNET_SCHEDULER_TaskContext *tc)
77{
78 int *ok = cls;
79
80 *ok = GNUNET_NO;
81 tsk = GNUNET_SCHEDULER_NO_TASK;
82 GNUNET_NAT_test_stop (tst);
83 tst = NULL;
84}
85
86
87/**
88 * Main function for the NAT test.
89 *
90 * @param cls the 'int*' for the result
91 * @param tc scheduler context
92 */
93static void
94test (void *cls,
95 const struct GNUNET_SCHEDULER_TaskContext *tc)
96{
97 int *ok = cls;
98 unsigned long long bnd_port;
99 unsigned long long adv_port;
100
101 GNUNET_assert (NULL != cfg);
102 GNUNET_RESOLVER_connect (cfg);
103 if (GNUNET_OK !=
104 GNUNET_CONFIGURATION_get_value_number (cfg,
105 "transport-udp",
106 "PORT",
107 &bnd_port))
108 {
109 GNUNET_break (0);
110 return;
111 }
112 if (GNUNET_OK !=
113 GNUNET_CONFIGURATION_get_value_number (cfg,
114 "transport-udp",
115 "ADVERTISED_PORT",
116 &adv_port))
117 adv_port = bnd_port;
118 tst = GNUNET_NAT_test_start (cfg,
119 GNUNET_NO,
120 (uint16_t) bnd_port,
121 (uint16_t) adv_port,
122 &result_callback,
123 ok);
124 if (NULL == tst)
125 {
126 *ok = GNUNET_SYSERR;
127 return;
128 }
129 tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
130 &fail_timeout,
131 ok);
132}
133
134/**
135 * Function called whenever the user wants to test the
136 * UDP configuration.
137 */
138void
139GNUNET_setup_transport_udp_test_button_clicked_cb ()
140{
141 GtkWidget *w;
142 int ok;
143 struct GNUNET_OS_Process *resolver;
144
145 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
146 GNUNET_assert (NULL == tst);
147 w = GTK_WIDGET (gtk_builder_get_object (builder,
148 "GNUNET_setup_transport_udp_test_success_image"));
149 gtk_widget_hide (w);
150 resolver = GNUNET_OS_start_process (NULL, NULL,
151 "gnunet-service-resolver",
152 "gnunet-service-resolver", NULL);
153 ok = GNUNET_NO;
154 GNUNET_SCHEDULER_run (&test, &ok);
155 if (NULL != resolver)
156 {
157 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
158 GNUNET_OS_process_close (resolver);
159 }
160 if (GNUNET_YES != ok)
161 {
162 w = GTK_WIDGET (gtk_builder_get_object (builder,
163 "GNUNET_setup_transport_udp_test_fail_image"));
164 gtk_widget_show (w);
165 w = GTK_WIDGET (gtk_builder_get_object (builder,
166 "GNUNET_setup_transport_udp_test_success_image"));
167 gtk_widget_hide (w);
168 }
169 else
170 {
171 w = GTK_WIDGET (gtk_builder_get_object (builder,
172 "GNUNET_setup_transport_udp_test_fail_image"));
173 gtk_widget_hide (w);
174 w = GTK_WIDGET (gtk_builder_get_object (builder,
175 "GNUNET_setup_transport_udp_test_success_image"));
176 gtk_widget_show (w);
177 }
178}
179
180
181/* end of gnunet-setup-transport-udp.c */
diff --git a/src/setup/gnunet-setup-transport.c b/src/setup/gnunet-setup-transport.c
new file mode 100644
index 00000000..58a25c15
--- /dev/null
+++ b/src/setup/gnunet-setup-transport.c
@@ -0,0 +1,300 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup-transport.c
23 * @brief support for transport (NAT) configuration
24 * @author Christian Grothoff
25 */
26#include "gnunet-setup.h"
27#include <gnunet/gnunet_util_lib.h>
28#include <gnunet/gnunet_resolver_service.h>
29#include <gnunet/gnunet_nat_lib.h>
30
31/**
32 * How long do we wait for the NAT test to report success?
33 */
34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
35
36/**
37 * Handle to the active NAT test.
38 */
39static struct GNUNET_NAT_Test *tst;
40
41/**
42 * Task identifier for the timeout.
43 */
44static GNUNET_SCHEDULER_TaskIdentifier tsk;
45
46
47/**
48 * Function called by NAT on success.
49 * Clean up and update GUI (with success).
50 *
51 * @param cls closure (unused)
52 * @param success currently always GNUNET_OK
53 */
54static void
55result_callback (void *cls,
56 int success)
57{
58 int *ok = cls;
59
60 *ok = success;
61 GNUNET_SCHEDULER_cancel (tsk);
62 tsk = GNUNET_SCHEDULER_NO_TASK;
63 GNUNET_NAT_test_stop (tst);
64 tst = NULL;
65}
66
67
68/**
69 * Function called if NAT failed to confirm success.
70 * Clean up and update GUI (with failure).
71 *
72 * @param cls closure (unused)
73 * @param tc scheduler callback
74 */
75static void
76fail_timeout (void *cls,
77 const struct GNUNET_SCHEDULER_TaskContext *tc)
78{
79 int *ok = cls;
80
81 GNUNET_assert (NULL != tst);
82 *ok = GNUNET_NO;
83 tsk = GNUNET_SCHEDULER_NO_TASK;
84 GNUNET_NAT_test_stop (tst);
85 tst = NULL;
86}
87
88/**
89 * Main function for the connection reversal test.
90 *
91 * @param cls the 'int*' for the result
92 * @param tc scheduler context
93 */
94static void
95reversal_test (void *cls,
96 const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 int *ok = cls;
99
100 GNUNET_assert (NULL != cfg);
101 GNUNET_RESOLVER_connect (cfg);
102 tst = GNUNET_NAT_test_start (cfg,
103 GNUNET_YES,
104 0, 0,
105 &result_callback,
106 ok);
107 if (NULL == tst)
108 {
109 *ok = GNUNET_SYSERR;
110 return;
111 }
112 tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
113 &fail_timeout,
114 ok);
115}
116
117/**
118 * Test if connection reversal (ICMP method) works.
119 *
120 * @return GNUNET_YES if it works, GNUNET_NO if not.
121 */
122static int
123test_connection_reversal ()
124{
125 int ok;
126 struct GNUNET_OS_Process *resolver;
127
128 resolver = GNUNET_OS_start_process (NULL, NULL,
129 "gnunet-service-resolver",
130 "gnunet-service-resolver", NULL);
131 ok = GNUNET_NO;
132 GNUNET_SCHEDULER_run (&reversal_test, &ok);
133 if (NULL != resolver)
134 {
135 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
136 GNUNET_OS_process_close (resolver);
137 }
138 return ok;
139}
140
141
142/**
143 * Process list of local IP addresses. Find and set the
144 * one of the default interface.
145 *
146 * @param cls closure (not used)
147 * @param name name of the interface (can be NULL for unknown)
148 * @param isDefault is this presumably the default interface
149 * @param addr address of this interface (can be NULL for unknown or unassigned)
150 * @param addrlen length of the address
151 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
152 */
153static int
154nipo (void *cls,
155 const char *name,
156 int isDefault,
157 const struct sockaddr *
158 addr, socklen_t addrlen)
159{
160 const struct sockaddr_in *in;
161 char buf[INET_ADDRSTRLEN];
162 GtkEntry *entry;
163
164 if (! isDefault)
165 return GNUNET_OK;
166 if (addrlen != sizeof (struct sockaddr_in))
167 return GNUNET_OK;
168 in = (const struct sockaddr_in*) addr;
169
170 /* set internal IP address */
171 inet_ntop (AF_INET, &in->sin_addr, buf, sizeof(buf));
172 GNUNET_CONFIGURATION_set_value_string (cfg,
173 "nat",
174 "INTERNAL_ADDRESS",
175 buf);
176 entry = GTK_ENTRY (gtk_builder_get_object (builder,
177 "GNUNET_setup_transport_internal_ip_entry"));
178 if (entry == NULL)
179 {
180 GNUNET_break (0);
181 return GNUNET_SYSERR;
182 }
183 gtk_entry_set_text (entry,
184 buf);
185 /* no need to continue iteration */
186 return GNUNET_SYSERR;
187}
188
189
190/**
191 * User asked for autoconfiguration. Try the full program.
192 */
193void
194GNUNET_setup_transport_autoconfig_button_clicked_cb ()
195{
196 struct in_addr ia;
197 char buf[INET_ADDRSTRLEN];
198 GtkEntry *entry;
199 GtkToggleButton *button;
200 int hns;
201 int hnc;
202 char *tmp;
203
204 /* try to detect external IP */
205 if (GNUNET_OK ==
206 GNUNET_NAT_mini_get_external_ipv4 (&ia))
207 {
208 /* enable 'behind nat' */
209 GNUNET_CONFIGURATION_set_value_string (cfg,
210 "nat",
211 "BEHIND_NAT",
212 "YES");
213 button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
214 "GNUNET_setup_transport_nat_checkbutton"));
215 if (button == NULL)
216 {
217 GNUNET_break (0);
218 return;
219 }
220 gtk_toggle_button_set_active (button,
221 TRUE);
222
223 /* set external IP address */
224 inet_ntop (AF_INET, &ia, buf, sizeof(buf));
225 GNUNET_CONFIGURATION_set_value_string (cfg,
226 "nat",
227 "EXTERNAL_ADDRESS",
228 buf);
229 entry = GTK_ENTRY (gtk_builder_get_object (builder,
230 "GNUNET_setup_transport_external_ip_address_entry"));
231 if (entry == NULL)
232 {
233 GNUNET_break (0);
234 return;
235 }
236 gtk_entry_set_text (entry,
237 buf);
238 }
239
240 /* Try to detect internal IP */
241 GNUNET_OS_network_interfaces_list (&nipo, NULL);
242
243 /* FIXME: do more: test if UPnP works */
244
245 /* test gnunet-helper-nat-server */
246 tmp = NULL;
247 hns = ( (GNUNET_OK ==
248 GNUNET_CONFIGURATION_get_value_string (cfg,
249 "nat",
250 "EXTERNAL_ADDRESS",
251 &tmp)) &&
252 (0 < strlen (tmp)) &&
253 (GNUNET_YES ==
254 GNUNET_CONFIGURATION_get_value_yesno (cfg,
255 "nat",
256 "BEHIND_NAT")) &&
257 (GNUNET_YES ==
258 GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server")) );
259 GNUNET_free_non_null (tmp);
260 if (hns)
261 hns = test_connection_reversal ();
262
263 button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
264 "GNUNET_setup_transport_icmp_server_enable_checkbutton"));
265 if (button == NULL)
266 {
267 GNUNET_break (0);
268 return;
269 }
270 gtk_toggle_button_set_active (button,
271 hns ? TRUE : FALSE);
272
273
274 /* test gnunet-helper-nat-client */
275 tmp = NULL;
276 hnc = ( (GNUNET_OK ==
277 GNUNET_CONFIGURATION_get_value_string (cfg,
278 "nat",
279 "INTERNAL_ADDRESS",
280 &tmp)) &&
281 (0 < strlen (tmp)) &&
282 (GNUNET_YES !=
283 GNUNET_CONFIGURATION_get_value_yesno (cfg,
284 "nat",
285 "BEHIND_NAT")) &&
286 (GNUNET_YES ==
287 GNUNET_OS_check_helper_binary ("gnunet-helper-nat-client")) );
288 GNUNET_free_non_null (tmp);
289 button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
290 "GNUNET_setup_transport_icmp_client_enable_checkbutton"));
291 if (button == NULL)
292 {
293 GNUNET_break (0);
294 return;
295 }
296 gtk_toggle_button_set_active (button,
297 hnc ? TRUE : FALSE);
298}
299
300/* end of gnunet-setup-transport.c */
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c
new file mode 100644
index 00000000..1845c683
--- /dev/null
+++ b/src/setup/gnunet-setup.c
@@ -0,0 +1,462 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup.c
23 * @brief Main function of gnunet-setup
24 * @author Christian Grothoff
25 */
26#if ENABLE_NLS
27#include <locale.h>
28#endif
29#include "gnunet-setup.h"
30#include "gnunet-setup-options.h"
31#include <regex.h>
32
33/**
34 * Builder for the main window (global!)
35 */
36GtkBuilder *builder;
37
38/**
39 * Our configuration (global!)
40 */
41struct GNUNET_CONFIGURATION_Handle *cfg;
42
43
44/**
45 * @brief get the path to a specific GNUnet installation directory or,
46 * with GNUNET_IPK_SELF_PREFIX, the current running apps installation directory
47 * @author Milan
48 * @return a pointer to the dir path (to be freed by the caller)
49 */
50char *
51GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
52
53
54
55/**
56 * Get the name of the directory where all of our package
57 * data is stored ($PREFIX/share/)
58 *
59 * @return name of the data directory
60 */
61const char *
62GNUNET_GTK_get_data_dir ()
63{
64 static char *dd;
65
66 if (dd == NULL)
67 dd = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR);
68 return dd;
69}
70
71
72/**
73 * Create an initialize a new builder based on the
74 * GNUnet-GTK glade file.
75 *
76 * @param filename name of the resource file to load
77 * @return NULL on error
78 */
79GtkBuilder *
80GNUNET_GTK_get_new_builder (const char *filename)
81{
82 char *glade_path;
83 GtkBuilder *ret;
84 GError *error;
85
86 ret = gtk_builder_new ();
87 gtk_builder_set_translation_domain (ret, "gnunet-gtk");
88 GNUNET_asprintf (&glade_path,
89 "%s%s",
90 GNUNET_GTK_get_data_dir (),
91 filename);
92 error = NULL;
93 if (0 == gtk_builder_add_from_file (ret, glade_path, &error))
94 {
95 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
96 _("Failed to load `%s': %s\n"),
97 glade_path,
98 error->message);
99 g_error_free (error);
100 GNUNET_free (glade_path);
101 return NULL;
102 }
103 gtk_builder_connect_signals (ret, NULL);
104 GNUNET_free (glade_path);
105 return ret;
106}
107
108
109
110/**
111 * Initialize GNU gettext for message translation.
112 */
113static void
114setup_nls ()
115{
116#if ENABLE_NLS
117 char *path;
118
119 setlocale (LC_ALL, "");
120 GNUNET_asprintf (&path,
121 "%s/%s/locale/",
122 GNUNET_GTK_get_data_dir (),
123 PACKAGE_NAME);
124 bindtextdomain ("gnunet-setup", path);
125 textdomain ("gnunet-setup");
126 bind_textdomain_codeset ("GNUnet", "UTF-8");
127 bind_textdomain_codeset ("gnunet-setup", "UTF-8");
128 GNUNET_free (path);
129#else
130 fprintf (stderr,
131 "WARNING: gnunet-setup was compiled without i18n support (did CFLAGS contain -Werror?).\n");
132#endif
133}
134
135
136/**
137 * Initialize GTK search path for icons.
138 */
139static void
140set_icon_search_path ()
141{
142 char *buf;
143
144 buf = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_ICONDIR);
145 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), buf);
146 GNUNET_free (buf);
147}
148
149
150static gboolean
151help_click_callback (GtkWidget *widget,
152 GdkEventButton *event,
153 gpointer user_data)
154{
155 const struct GNUNET_SETUP_OptionSpecification *os = user_data;
156 GtkLinkButton *help;
157
158 if (event->type != GDK_BUTTON_PRESS)
159 return FALSE;
160 help = GTK_LINK_BUTTON (gtk_builder_get_object (builder,
161 "GNUNET_setup_help_text"));
162 gtk_link_button_set_uri (help,
163 os->help_url);
164 gtk_button_set_label (GTK_BUTTON (help),
165 os->help_text);
166 return FALSE;
167}
168
169
170/**
171 * Change the visibility of widgets according to the
172 * value and visibility specification given.
173 *
174 * @param os option specification
175 * @param value current value for the given option
176 */
177static void
178update_visibility (const struct GNUNET_SETUP_OptionSpecification *os,
179 const char *value)
180{
181 unsigned int i;
182 const struct GNUNET_SETUP_VisibilitySpecification *vs;
183 GtkWidget *widget;
184 regex_t r;
185
186 if (os->visibility == NULL)
187 return;
188 i = 0;
189 while (os->visibility[i].widget_name != NULL)
190 {
191 vs = &os->visibility[i];
192 widget = GTK_WIDGET (gtk_builder_get_object (builder,
193 vs->widget_name));
194 if (widget == NULL)
195 {
196 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
197 _("Widget `%s' not found\n"),
198 vs->widget_name);
199 }
200 if (NULL != vs->show_value)
201 {
202 if (0 != regcomp (&r, vs->show_value, REG_EXTENDED | REG_ICASE | REG_NOSUB))
203 {
204 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
205 _("Invalid regular expression `%s'\n"),
206 vs->show_value);
207 i++;
208 continue;
209 }
210 if (0 == regexec (&r, value, 0, NULL, 0))
211 gtk_widget_show (widget);
212 else
213 gtk_widget_hide (widget);
214 regfree (&r);
215 }
216 if (NULL != vs->hide_value)
217 {
218 if (0 != regcomp (&r, vs->hide_value, REG_ICASE | REG_NOSUB))
219 {
220 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
221 _("Invalid regular expression `%s'\n"),
222 vs->show_value);
223 i++;
224 continue;
225 }
226 if (0 == regexec (&r, value, 0, NULL, 0))
227 gtk_widget_hide (widget);
228 else
229 gtk_widget_show (widget);
230 regfree (&r);
231 }
232 i++;
233 }
234}
235
236
237/**
238 * Function called whenever a widget changes its state.
239 */
240static void
241widget_state_change_callback (const struct GNUNET_SETUP_OptionSpecification *os)
242{
243 GObject *widget;
244 char *value;
245
246 widget = gtk_builder_get_object (builder,
247 os->widget_name);
248 GNUNET_assert (NULL != os->save_function);
249 if (GNUNET_OK !=
250 os->save_function (os->load_save_cls,
251 os->section,
252 os->option,
253 widget,
254 cfg))
255 {
256 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
257 _("Failed to obtain option value from widget `%s'\n"),
258 os->widget_name);
259 return;
260 }
261 if ( (os->section != NULL) &&
262 (os->option != NULL) )
263 GNUNET_assert (GNUNET_OK ==
264 GNUNET_CONFIGURATION_get_value_string (cfg,
265 os->section,
266 os->option,
267 &value));
268 else
269 value = NULL;
270 update_visibility (os, value);
271 GNUNET_free_non_null (value);
272}
273
274
275int
276main (int argc,
277 char *const *argv)
278{
279 char *cfgName = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE);
280 char *loglev = GNUNET_strdup ("WARNING");
281 struct GNUNET_GETOPT_CommandLineOption options[] = {
282 GNUNET_GETOPT_OPTION_CFG_FILE (&cfgName),
283 GNUNET_GETOPT_OPTION_HELP (gettext_noop ("Setup tool for GNUnet")),
284 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
285 GNUNET_GETOPT_OPTION_VERSION (PACKAGE_VERSION),
286 GNUNET_GETOPT_OPTION_END
287 };
288 gint ret;
289 GtkWidget *main_window;
290 GtkWidget *dialog;
291 GObject *widget;
292 int arg_off;
293 int iret;
294 char *const *argp;
295 char *value;
296 struct GNUNET_CONFIGURATION_Handle *cfgDefault;
297 const struct GNUNET_SETUP_OptionSpecification *os;
298 unsigned int i;
299
300 arg_off = GNUNET_GETOPT_run ("gnunet-setup",
301 options,
302 argc,
303 argv);
304 if (arg_off == GNUNET_SYSERR)
305 {
306 GNUNET_free (loglev);
307 GNUNET_free (cfgName);
308 return 1;
309 }
310 (void) GNUNET_log_setup ("gnunet-setup",
311 loglev,
312 NULL);
313 argp = &argv[arg_off];
314 argc -= arg_off;
315 gtk_init (&argc, (char ***) &argp);
316 set_icon_search_path ();
317 setup_nls ();
318 builder = GNUNET_GTK_get_new_builder ("gnunet-setup.glade");
319 if (builder == NULL)
320 {
321 GNUNET_free (loglev);
322 GNUNET_free (cfgName);
323 return 1;
324 }
325 cfg = GNUNET_CONFIGURATION_create ();
326 (void) GNUNET_CONFIGURATION_load (cfg, cfgName);
327 main_window = GTK_WIDGET (gtk_builder_get_object (builder,
328 "GNUNET_setup_dialog"));
329 /* load options into dialog */
330 i = 0;
331 while (option_specifications[i].widget_name != NULL)
332 {
333 os = &option_specifications[i];
334 widget = gtk_builder_get_object (builder,
335 os->widget_name);
336 if (NULL == widget)
337 {
338 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
339 _("Widget `%s' not found\n"),
340 os->widget_name);
341 i++;
342 continue;
343 }
344 if (os->load_function != NULL)
345 {
346 if ( (NULL == os->section) ||
347 (NULL == os->option) )
348 {
349 if (GNUNET_OK !=
350 os->load_function (os->load_save_cls,
351 NULL, NULL, NULL,
352 widget,
353 cfg))
354 {
355 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
356 _("Failed to initialize widget `%s'\n"),
357 os->widget_name);
358 }
359 }
360 else
361 {
362 if (GNUNET_OK !=
363 GNUNET_CONFIGURATION_get_value_string (cfg,
364 os->section,
365 os->option,
366 &value))
367 {
368 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
369 _("No default value known for option `%s' in section `%s'\n"),
370 os->option,
371 os->section);
372 }
373 else
374 {
375 if (GNUNET_OK !=
376 os->load_function (os->load_save_cls,
377 os->section, os->option,
378 value,
379 widget,
380 cfg))
381 {
382 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
383 _("Failed to initialize widget `%s' with value `%s'\n"),
384 os->widget_name,
385 value);
386 }
387 else
388 {
389 update_visibility (os, value);
390 }
391 GNUNET_free (value);
392 }
393 }
394 }
395 if (os->help_text != NULL)
396 {
397 g_signal_connect (widget,
398 "button-press-event",
399 G_CALLBACK (&help_click_callback),
400 (void*) os);
401 }
402 if (os->change_signal != NULL)
403 {
404 GNUNET_assert (NULL != os->save_function);
405 g_signal_connect_swapped (widget,
406 os->change_signal,
407 G_CALLBACK (&widget_state_change_callback),
408 (void*) os);
409 }
410 i++;
411 }
412
413 RESTART:
414 ret = gtk_dialog_run (GTK_DIALOG (main_window));
415 gtk_widget_hide (main_window);
416 cfgDefault = GNUNET_CONFIGURATION_create ();
417 (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */
418 iret = 0;
419 switch (ret)
420 {
421 case GTK_RESPONSE_CANCEL: /* -6 */
422 /* explicit cancel, do not save! */
423 break;
424 case GTK_RESPONSE_OK: /* save-as, -5 */
425 dialog = gtk_file_chooser_dialog_new (_("Save Configuration File"),
426 NULL,
427 GTK_FILE_CHOOSER_ACTION_SAVE,
428 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
429 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
430 NULL);
431 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), cfgName);
432 if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
433 {
434 gtk_widget_destroy (dialog);
435 goto RESTART;
436 }
437 GNUNET_free (cfgName);
438 cfgName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
439 gtk_widget_destroy (dialog);
440 /* fall through! */
441 case GTK_RESPONSE_DELETE_EVENT: /* window close, -4 */
442 case GTK_RESPONSE_ACCEPT: /* save, -3 */
443 if (GNUNET_OK !=
444 GNUNET_CONFIGURATION_write_diffs (cfgDefault,
445 cfg,
446 cfgName))
447 iret = 1;
448 break;
449 default:
450 GNUNET_break (0);
451 }
452 gtk_widget_destroy (main_window);
453 g_object_unref (G_OBJECT (builder));
454 GNUNET_CONFIGURATION_destroy (cfgDefault);
455 GNUNET_CONFIGURATION_destroy (cfg);
456 GNUNET_free (cfgName);
457 GNUNET_free (loglev);
458 return iret;
459}
460
461
462/* end of gnunet-setup.c */
diff --git a/src/setup/gnunet-setup.h b/src/setup/gnunet-setup.h
new file mode 100644
index 00000000..74b7aba5
--- /dev/null
+++ b/src/setup/gnunet-setup.h
@@ -0,0 +1,47 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gnunet-setup.h
23 * @brief globals
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SETUP_H
27#define GNUNET_SETUP_H
28
29#include "gnunet_gtk.h"
30#include <gnunet/gnunet_directories.h>
31#include <gnunet/gnunet_util_lib.h>
32#include <gladeui/glade.h>
33#include <gtk/gtk.h>
34
35/**
36 * Builder for the main window.
37 */
38extern GtkBuilder *builder;
39
40/**
41 * Our configuration.
42 */
43extern struct GNUNET_CONFIGURATION_Handle *cfg;
44
45
46#endif
47/* end of gnunet-setup.h */