aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/plugin_gtk_namestore_soa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/plugin_gtk_namestore_soa.c')
-rw-r--r--src/namestore/plugin_gtk_namestore_soa.c139
1 files changed, 135 insertions, 4 deletions
diff --git a/src/namestore/plugin_gtk_namestore_soa.c b/src/namestore/plugin_gtk_namestore_soa.c
index 20cc3920..bb4b61cf 100644
--- a/src/namestore/plugin_gtk_namestore_soa.c
+++ b/src/namestore/plugin_gtk_namestore_soa.c
@@ -28,6 +28,40 @@
28 28
29 29
30/** 30/**
31 * The user has edited the SOA record value. Enable/disable 'save'
32 * button depending on the validity of the value.
33 *
34 * @param entry editing widget
35 * @param user_data the plugin environment
36 */
37void
38GNS_edit_dialog_soa_contact_email_entry_changed_cb (GtkEditable *entry,
39 gpointer user_data)
40{
41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data;
42
43 env->check_validity (env->cls);
44}
45
46
47/**
48 * The user has edited the SOA record value. Enable/disable 'save'
49 * button depending on the validity of the value.
50 *
51 * @param entry editing widget
52 * @param user_data the plugin environment
53 */
54void
55GNS_edit_dialog_soa_source_host_entry_changed_cb (GtkEditable *entry,
56 gpointer user_data)
57{
58 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data;
59
60 env->check_validity (env->cls);
61}
62
63
64/**
31 * Function that will be called to initialize the builder's 65 * Function that will be called to initialize the builder's
32 * widgets from the existing record (if there is one). 66 * widgets from the existing record (if there is one).
33 * The `n_value` is the existing value of the record as a string. 67 * The `n_value` is the existing value of the record as a string.
@@ -41,7 +75,51 @@ soa_load (void *cls,
41 gchar *n_value, 75 gchar *n_value,
42 GtkBuilder *builder) 76 GtkBuilder *builder)
43{ 77{
44 GNUNET_break (0); 78 char soa_rname[253 + 1];
79 char soa_mname[253 + 1];
80 unsigned int soa_serial;
81 unsigned int soa_refresh;
82 unsigned int soa_retry;
83 unsigned int soa_expire;
84 unsigned int soa_min;
85
86 if (7 != SSCANF (n_value,
87 "rname=%253s mname=%253s %u,%u,%u,%u,%u",
88 soa_rname,
89 soa_mname,
90 &soa_serial,
91 &soa_refresh,
92 &soa_retry,
93 &soa_expire,
94 &soa_min))
95 {
96 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
97 _("Unable to parse SOA record `%s'\n"),
98 n_value);
99 return;
100 }
101 /* set SOA record */
102 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder,
103 "edit_dialog_soa_source_host_entry")),
104 soa_rname);
105 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder,
106 "edit_dialog_soa_contact_email_entry")),
107 soa_mname);
108 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
109 "edit_dialog_soa_serial_number_spinbutton")),
110 soa_serial);
111 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
112 "edit_dialog_soa_refresh_time_spinbutton")),
113 soa_refresh);
114 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
115 "edit_dialog_soa_retry_time_spinbutton")),
116 soa_retry);
117 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
118 "edit_dialog_soa_expire_time_spinbutton")),
119 soa_expire);
120 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
121 "edit_dialog_soa_minimum_ttl_spinbutton")),
122 soa_min);
45} 123}
46 124
47 125
@@ -57,8 +135,41 @@ static gchar *
57soa_store (void *cls, 135soa_store (void *cls,
58 GtkBuilder *builder) 136 GtkBuilder *builder)
59{ 137{
60 GNUNET_break (0); 138 GtkEntry *entry;
61 return NULL; 139 const gchar *source_host;
140 const gchar *contact_email;
141 unsigned int soa_serial;
142 unsigned int soa_refresh;
143 unsigned int soa_retry;
144 unsigned int soa_expire;
145 unsigned int soa_min;
146 char *result;
147
148 entry = GTK_ENTRY (gtk_builder_get_object (builder,
149 "edit_dialog_soa_source_host_entry"));
150 source_host = gtk_entry_get_text (entry);
151 entry = GTK_ENTRY (gtk_builder_get_object (builder,
152 "edit_dialog_soa_contact_email_entry"));
153 contact_email = gtk_entry_get_text (entry);
154 soa_serial = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
155 "edit_dialog_soa_serial_number_spinbutton")));
156 soa_refresh = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
157 "edit_dialog_soa_refresh_time_spinbutton")));
158 soa_retry = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
159 "edit_dialog_soa_retry_time_spinbutton")));
160 soa_expire = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
161 "edit_dialog_soa_expire_time_spinbutton")));
162 soa_min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
163 "edit_dialog_soa_minimum_ttl_spinbutton")));
164 GNUNET_asprintf (&result,
165 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
166 source_host, contact_email,
167 soa_serial,
168 soa_refresh,
169 soa_retry,
170 soa_expire,
171 soa_min);
172 return result;
62} 173}
63 174
64 175
@@ -77,7 +188,27 @@ static int
77soa_validate (void *cls, 188soa_validate (void *cls,
78 GtkBuilder *builder) 189 GtkBuilder *builder)
79{ 190{
80 GNUNET_break (0); 191 GtkEditable *entry;
192 const gchar *preedit;
193
194 entry = GTK_EDITABLE (gtk_builder_get_object (builder,
195 "edit_dialog_soa_source_host_entry")),
196 preedit = gtk_editable_get_chars (entry, 0, -1);
197 if ( (NULL == preedit) ||
198 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
199 return GNUNET_SYSERR;
200 /* check for '@' in the e-mail --- required format uses "." instead! */
201 entry = GTK_EDITABLE (gtk_builder_get_object (builder,
202 "edit_dialog_soa_contact_email_entry")),
203 preedit = gtk_editable_get_chars (entry, 0, -1);
204 /* E-mail is specified in the RFC also as a 'domain-name', hence
205 we check above that it follows those conventions as well; the '@'
206 is a common mistake, and while it should be illegal despite IDN,
207 it feels better to check explicitly. */
208 if ( (NULL == preedit) ||
209 (NULL != strstr (preedit, "@")) ||
210 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
211 return GNUNET_SYSERR;
81 return GNUNET_OK; 212 return GNUNET_OK;
82} 213}
83 214