aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-06 15:26:06 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-06 15:26:06 +0000
commit3b0e481b024aba22e863a81b72a454d021946ced (patch)
tree2358085eb1428f77ab1128473097342bcaea2db6
parentc5e30dfdc388ead86a587f5b6ae6b08a3a29a50b (diff)
downloadgnunet-gtk-3b0e481b024aba22e863a81b72a454d021946ced.tar.gz
gnunet-gtk-3b0e481b024aba22e863a81b72a454d021946ced.zip
-implementing updated namestore plugin code for new GNS2DNS records (#3093)
-rw-r--r--contrib/gnunet_namestore_edit_gns2dns.glade200
-rw-r--r--src/namestore/plugin_gtk_namestore_gns2dns.c60
2 files changed, 174 insertions, 86 deletions
diff --git a/contrib/gnunet_namestore_edit_gns2dns.glade b/contrib/gnunet_namestore_edit_gns2dns.glade
index 9cc58132..624807cc 100644
--- a/contrib/gnunet_namestore_edit_gns2dns.glade
+++ b/contrib/gnunet_namestore_edit_gns2dns.glade
@@ -46,67 +46,6 @@
46 <property name="visible">True</property> 46 <property name="visible">True</property>
47 <property name="can_focus">False</property> 47 <property name="can_focus">False</property>
48 <property name="spacing">2</property> 48 <property name="spacing">2</property>
49 <child internal-child="action_area">
50 <object class="GtkHButtonBox" id="edit_dialog_action_area">
51 <property name="visible">True</property>
52 <property name="can_focus">False</property>
53 <property name="layout_style">end</property>
54 <child>
55 <object class="GtkButton" id="edit_dialog_cancel_button">
56 <property name="label">gtk-cancel</property>
57 <property name="use_action_appearance">False</property>
58 <property name="visible">True</property>
59 <property name="can_focus">True</property>
60 <property name="receives_default">True</property>
61 <property name="use_stock">True</property>
62 </object>
63 <packing>
64 <property name="expand">False</property>
65 <property name="fill">False</property>
66 <property name="position">0</property>
67 </packing>
68 </child>
69 <child>
70 <object class="GtkButton" id="edit_dialog_delete_button">
71 <property name="label">gtk-delete</property>
72 <property name="use_action_appearance">False</property>
73 <property name="visible">True</property>
74 <property name="can_focus">True</property>
75 <property name="receives_default">True</property>
76 <property name="use_stock">True</property>
77 </object>
78 <packing>
79 <property name="expand">False</property>
80 <property name="fill">False</property>
81 <property name="position">1</property>
82 </packing>
83 </child>
84 <child>
85 <object class="GtkButton" id="edit_dialog_save_button">
86 <property name="label">gtk-save</property>
87 <property name="use_action_appearance">False</property>
88 <property name="visible">True</property>
89 <property name="can_focus">True</property>
90 <property name="can_default">True</property>
91 <property name="has_default">True</property>
92 <property name="receives_default">True</property>
93 <property name="tooltip_text" translatable="yes">Store the updated record in the database. If the record is public, GNUnet will begin to publish the record to the world, limiting your ability to change it later (based on the selected expiration values).</property>
94 <property name="use_stock">True</property>
95 </object>
96 <packing>
97 <property name="expand">False</property>
98 <property name="fill">False</property>
99 <property name="position">2</property>
100 </packing>
101 </child>
102 </object>
103 <packing>
104 <property name="expand">False</property>
105 <property name="fill">True</property>
106 <property name="pack_type">end</property>
107 <property name="position">0</property>
108 </packing>
109 </child>
110 <child> 49 <child>
111 <object class="GtkFrame" id="edit_dialog_name_frame"> 50 <object class="GtkFrame" id="edit_dialog_name_frame">
112 <property name="visible">True</property> 51 <property name="visible">True</property>
@@ -126,6 +65,7 @@
126 <object class="GtkEntry" id="edit_dialog_name_entry"> 65 <object class="GtkEntry" id="edit_dialog_name_entry">
127 <property name="visible">True</property> 66 <property name="visible">True</property>
128 <property name="sensitive">False</property> 67 <property name="sensitive">False</property>
68 <property name="can_focus">False</property>
129 <property name="tooltip_text" translatable="yes">Name of the record in the zone.</property> 69 <property name="tooltip_text" translatable="yes">Name of the record in the zone.</property>
130 <property name="max_length">63</property> 70 <property name="max_length">63</property>
131 <property name="invisible_char">●</property> 71 <property name="invisible_char">●</property>
@@ -189,38 +129,97 @@
189 <packing> 129 <packing>
190 <property name="expand">False</property> 130 <property name="expand">False</property>
191 <property name="fill">False</property> 131 <property name="fill">False</property>
132 <property name="position">0</property>
133 </packing>
134 </child>
135 <child>
136 <object class="GtkFrame" id="edit_dialog_gns2dns_ns_frame">
137 <property name="visible">True</property>
138 <property name="can_focus">False</property>
139 <property name="label_xalign">0</property>
140 <property name="shadow_type">none</property>
141 <child>
142 <object class="GtkAlignment" id="edit_dialog_gns2dns_ns_alignment">
143 <property name="visible">True</property>
144 <property name="can_focus">False</property>
145 <property name="top_padding">4</property>
146 <property name="left_padding">12</property>
147 <child>
148 <object class="GtkVBox" id="edit_dialog_gns2dns_ns_vbox">
149 <property name="visible">True</property>
150 <property name="can_focus">False</property>
151 <child>
152 <object class="GtkEntry" id="edit_dialog_gns2dns_ns_entry">
153 <property name="visible">True</property>
154 <property name="can_focus">True</property>
155 <property name="tooltip_text" translatable="yes">Enter the name of the DNS domain that this label delegates to. Resolution will continue under the given target domain, asking the DNS server specified below.</property>
156 <property name="max_length">253</property>
157 <property name="invisible_char">●</property>
158 <property name="invisible_char_set">True</property>
159 <property name="primary_icon_activatable">False</property>
160 <property name="secondary_icon_activatable">False</property>
161 <property name="primary_icon_sensitive">True</property>
162 <property name="secondary_icon_sensitive">True</property>
163 <signal name="changed" handler="GNS_edit_dialog_gns2dns_ns_entry_changed_cb" swapped="no"/>
164 </object>
165 <packing>
166 <property name="expand">False</property>
167 <property name="fill">False</property>
168 <property name="position">0</property>
169 </packing>
170 </child>
171 </object>
172 </child>
173 </object>
174 </child>
175 <child type="label">
176 <object class="GtkLabel" id="edit_dialog_gns2dns_ns_label">
177 <property name="visible">True</property>
178 <property name="can_focus">False</property>
179 <property name="label" translatable="yes">&lt;b&gt;Name of the target DNS domain&lt;/b&gt;</property>
180 <property name="use_markup">True</property>
181 </object>
182 </child>
183 </object>
184 <packing>
185 <property name="expand">False</property>
186 <property name="fill">False</property>
187 <property name="padding">5</property>
192 <property name="position">1</property> 188 <property name="position">1</property>
193 </packing> 189 </packing>
194 </child> 190 </child>
195 <child> 191 <child>
196 <object class="GtkFrame" id="edit_dialog_gns2dns_frame"> 192 <object class="GtkFrame" id="edit_dialog_gns2dns_ip_frame">
197 <property name="visible">True</property> 193 <property name="visible">True</property>
198 <property name="can_focus">False</property> 194 <property name="can_focus">False</property>
199 <property name="label_xalign">0</property> 195 <property name="label_xalign">0</property>
200 <property name="shadow_type">none</property> 196 <property name="shadow_type">none</property>
201 <child> 197 <child>
202 <object class="GtkAlignment" id="edit_dialog_gns2dns_alignment"> 198 <object class="GtkAlignment" id="edit_dialog_gns2dns_ip_alignment">
203 <property name="visible">True</property> 199 <property name="visible">True</property>
204 <property name="can_focus">False</property> 200 <property name="can_focus">False</property>
205 <property name="top_padding">4</property> 201 <property name="top_padding">4</property>
206 <property name="left_padding">12</property> 202 <property name="left_padding">12</property>
207 <child> 203 <child>
208 <object class="GtkVBox" id="edit_dialog_gns2dns_vbox"> 204 <object class="GtkVBox" id="edit_dialog_gns2dns_ip_vbox">
209 <property name="visible">True</property> 205 <property name="visible">True</property>
210 <property name="can_focus">False</property> 206 <property name="can_focus">False</property>
211 <child> 207 <child>
212 <object class="GtkEntry" id="edit_dialog_gns2dns_entry"> 208 <object class="GtkEntry" id="edit_dialog_gns2dns_ip_entry">
213 <property name="visible">True</property> 209 <property name="visible">True</property>
214 <property name="can_focus">True</property> 210 <property name="can_focus">True</property>
215 <property name="has_focus">True</property> 211 <property name="has_focus">True</property>
216 <property name="tooltip_text" translatable="yes">Enter the name of the DNS nameserver for the subzone.</property> 212 <property name="tooltip_text" translatable="yes">Enter the name of the DNS nameserver for the subzone.
213The specified name can be a GNS name, an IPv4 or IPv6 address or even a DNS name.
214If you want to specify multiple IPv4 addresses, you should specify a GNS label in the current zone (i.e. glue.+) and then add the IP addresses under that glue label.
215</property>
217 <property name="max_length">253</property> 216 <property name="max_length">253</property>
218 <property name="invisible_char">●</property> 217 <property name="invisible_char">●</property>
219 <property name="primary_icon_activatable">False</property> 218 <property name="primary_icon_activatable">False</property>
220 <property name="secondary_icon_activatable">False</property> 219 <property name="secondary_icon_activatable">False</property>
221 <property name="primary_icon_sensitive">True</property> 220 <property name="primary_icon_sensitive">True</property>
222 <property name="secondary_icon_sensitive">True</property> 221 <property name="secondary_icon_sensitive">True</property>
223 <signal name="changed" handler="GNS_edit_dialog_gns2dns_entry_changed_cb" swapped="no"/> 222 <signal name="changed" handler="GNS_edit_dialog_gns2dns_ip_entry_changed_cb" swapped="no"/>
224 </object> 223 </object>
225 <packing> 224 <packing>
226 <property name="expand">False</property> 225 <property name="expand">False</property>
@@ -233,7 +232,7 @@
233 </object> 232 </object>
234 </child> 233 </child>
235 <child type="label"> 234 <child type="label">
236 <object class="GtkLabel" id="edit_dialog_gns2dns_label"> 235 <object class="GtkLabel" id="edit_dialog_gns2dns_ip_abel">
237 <property name="visible">True</property> 236 <property name="visible">True</property>
238 <property name="can_focus">False</property> 237 <property name="can_focus">False</property>
239 <property name="label" translatable="yes">&lt;b&gt;Name of the authoritative name server for the given name&lt;/b&gt;</property> 238 <property name="label" translatable="yes">&lt;b&gt;Name of the authoritative name server for the given name&lt;/b&gt;</property>
@@ -266,7 +265,6 @@
266 <child> 265 <child>
267 <object class="GtkCheckButton" id="edit_dialog_options_public_checkbutton"> 266 <object class="GtkCheckButton" id="edit_dialog_options_public_checkbutton">
268 <property name="label" translatable="yes">Record is public (visible to other users)</property> 267 <property name="label" translatable="yes">Record is public (visible to other users)</property>
269 <property name="use_action_appearance">False</property>
270 <property name="visible">True</property> 268 <property name="visible">True</property>
271 <property name="can_focus">True</property> 269 <property name="can_focus">True</property>
272 <property name="receives_default">False</property> 270 <property name="receives_default">False</property>
@@ -282,7 +280,6 @@
282 <child> 280 <child>
283 <object class="GtkCheckButton" id="edit_dialog_options_shadow_checkbutton"> 281 <object class="GtkCheckButton" id="edit_dialog_options_shadow_checkbutton">
284 <property name="label" translatable="yes">Record is a shadow record (valid after other records expire)</property> 282 <property name="label" translatable="yes">Record is a shadow record (valid after other records expire)</property>
285 <property name="use_action_appearance">False</property>
286 <property name="visible">True</property> 283 <property name="visible">True</property>
287 <property name="can_focus">True</property> 284 <property name="can_focus">True</property>
288 <property name="receives_default">False</property> 285 <property name="receives_default">False</property>
@@ -339,7 +336,6 @@
339 <child> 336 <child>
340 <object class="GtkRadioButton" id="edit_dialog_expiration_relative_radiobutton"> 337 <object class="GtkRadioButton" id="edit_dialog_expiration_relative_radiobutton">
341 <property name="label" translatable="yes">Relative</property> 338 <property name="label" translatable="yes">Relative</property>
342 <property name="use_action_appearance">False</property>
343 <property name="visible">True</property> 339 <property name="visible">True</property>
344 <property name="can_focus">True</property> 340 <property name="can_focus">True</property>
345 <property name="receives_default">False</property> 341 <property name="receives_default">False</property>
@@ -357,7 +353,6 @@
357 <child> 353 <child>
358 <object class="GtkRadioButton" id="edit_dialog_expiration_absolute_radiobutton"> 354 <object class="GtkRadioButton" id="edit_dialog_expiration_absolute_radiobutton">
359 <property name="label" translatable="yes">Absolute</property> 355 <property name="label" translatable="yes">Absolute</property>
360 <property name="use_action_appearance">False</property>
361 <property name="visible">True</property> 356 <property name="visible">True</property>
362 <property name="can_focus">True</property> 357 <property name="can_focus">True</property>
363 <property name="receives_default">False</property> 358 <property name="receives_default">False</property>
@@ -376,7 +371,6 @@
376 <child> 371 <child>
377 <object class="GtkRadioButton" id="edit_dialog_expiration_never_radiobutton"> 372 <object class="GtkRadioButton" id="edit_dialog_expiration_never_radiobutton">
378 <property name="label" translatable="yes">Never</property> 373 <property name="label" translatable="yes">Never</property>
379 <property name="use_action_appearance">False</property>
380 <property name="visible">True</property> 374 <property name="visible">True</property>
381 <property name="can_focus">True</property> 375 <property name="can_focus">True</property>
382 <property name="receives_default">False</property> 376 <property name="receives_default">False</property>
@@ -557,7 +551,65 @@
557 <packing> 551 <packing>
558 <property name="expand">True</property> 552 <property name="expand">True</property>
559 <property name="fill">True</property> 553 <property name="fill">True</property>
560 <property name="position">4</property> 554 <property name="position">5</property>
555 </packing>
556 </child>
557 <child internal-child="action_area">
558 <object class="GtkHButtonBox" id="edit_dialog_action_area">
559 <property name="visible">True</property>
560 <property name="can_focus">False</property>
561 <property name="layout_style">end</property>
562 <child>
563 <object class="GtkButton" id="edit_dialog_cancel_button">
564 <property name="label">gtk-cancel</property>
565 <property name="visible">True</property>
566 <property name="can_focus">True</property>
567 <property name="receives_default">True</property>
568 <property name="use_stock">True</property>
569 </object>
570 <packing>
571 <property name="expand">False</property>
572 <property name="fill">False</property>
573 <property name="position">0</property>
574 </packing>
575 </child>
576 <child>
577 <object class="GtkButton" id="edit_dialog_delete_button">
578 <property name="label">gtk-delete</property>
579 <property name="visible">True</property>
580 <property name="can_focus">True</property>
581 <property name="receives_default">True</property>
582 <property name="use_stock">True</property>
583 </object>
584 <packing>
585 <property name="expand">False</property>
586 <property name="fill">False</property>
587 <property name="position">1</property>
588 </packing>
589 </child>
590 <child>
591 <object class="GtkButton" id="edit_dialog_save_button">
592 <property name="label">gtk-save</property>
593 <property name="visible">True</property>
594 <property name="can_focus">True</property>
595 <property name="can_default">True</property>
596 <property name="has_default">True</property>
597 <property name="receives_default">True</property>
598 <property name="tooltip_text" translatable="yes">Store the updated record in the database. If the record is public, GNUnet will begin to publish the record to the world, limiting your ability to change it later (based on the selected expiration values).</property>
599 <property name="use_stock">True</property>
600 </object>
601 <packing>
602 <property name="expand">False</property>
603 <property name="fill">False</property>
604 <property name="position">2</property>
605 </packing>
606 </child>
607 </object>
608 <packing>
609 <property name="expand">False</property>
610 <property name="fill">True</property>
611 <property name="pack_type">end</property>
612 <property name="position">5</property>
561 </packing> 613 </packing>
562 </child> 614 </child>
563 </object> 615 </object>
diff --git a/src/namestore/plugin_gtk_namestore_gns2dns.c b/src/namestore/plugin_gtk_namestore_gns2dns.c
index 16ac03fb..d5da783c 100644
--- a/src/namestore/plugin_gtk_namestore_gns2dns.c
+++ b/src/namestore/plugin_gtk_namestore_gns2dns.c
@@ -56,12 +56,31 @@ GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry,
56 */ 56 */
57static void 57static void
58gns2dns_load (void *cls, 58gns2dns_load (void *cls,
59 gchar *n_value, 59 gchar *n_value,
60 GtkBuilder *builder) 60 GtkBuilder *builder)
61{ 61{
62 char *cpy;
63 char *at;
64
65 cpy = GNUNET_strdup (n_value);
66 at = strchr (cpy, '@');
67 if (NULL == at)
68 {
69 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
70 _("Unable to parse GNS2DNS record `%s'\n"),
71 n_value);
72 GNUNET_free (cpy);
73 return;
74 }
75 *at = '\0';
76 at++;
62 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, 77 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder,
63 "edit_dialog_gns2dns_entry")), 78 "edit_dialog_gns2dns_ns_entry")),
64 n_value); 79 cpy);
80 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder,
81 "edit_dialog_gns2dns_ip_entry")),
82 at);
83 GNUNET_free (cpy);
65} 84}
66 85
67 86
@@ -75,15 +94,24 @@ gns2dns_load (void *cls,
75 */ 94 */
76static gchar * 95static gchar *
77gns2dns_store (void *cls, 96gns2dns_store (void *cls,
78 GtkBuilder *builder) 97 GtkBuilder *builder)
79{ 98{
80 GtkEntry *entry; 99 GtkEntry *entry;
81 const gchar *value; 100 const gchar *ns_value;
101 const gchar *ip_value;
102 char *ret;
82 103
83 entry = GTK_ENTRY (gtk_builder_get_object (builder, 104 entry = GTK_ENTRY (gtk_builder_get_object (builder,
84 "edit_dialog_gns2dns_entry")); 105 "edit_dialog_gns2dns_ns_entry"));
85 value = gtk_entry_get_text (entry); 106 ns_value = gtk_entry_get_text (entry);
86 return g_strdup (value); 107 entry = GTK_ENTRY (gtk_builder_get_object (builder,
108 "edit_dialog_gns2dns_ip_entry"));
109 ip_value = gtk_entry_get_text (entry);
110 GNUNET_asprintf (&ret,
111 "%s@%s",
112 ns_value,
113 ip_value);
114 return ret;
87} 115}
88 116
89 117
@@ -100,13 +128,19 @@ gns2dns_store (void *cls,
100 */ 128 */
101static int 129static int
102gns2dns_validate (void *cls, 130gns2dns_validate (void *cls,
103 GtkBuilder *builder) 131 GtkBuilder *builder)
104{ 132{
105 GtkEditable *entry; 133 GtkEditable *entry;
106 const gchar *preedit; 134 const gchar *preedit;
107 135
108 entry = GTK_EDITABLE (gtk_builder_get_object (builder, 136 entry = GTK_EDITABLE (gtk_builder_get_object (builder,
109 "edit_dialog_gns2dns_entry")), 137 "edit_dialog_gns2dns_ns_entry")),
138 preedit = gtk_editable_get_chars (entry, 0, -1);
139 if ( (NULL == preedit) ||
140 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
141 return GNUNET_SYSERR;
142 entry = GTK_EDITABLE (gtk_builder_get_object (builder,
143 "edit_dialog_gns2dns_ip_entry")),
110 preedit = gtk_editable_get_chars (entry, 0, -1); 144 preedit = gtk_editable_get_chars (entry, 0, -1);
111 if ( (NULL == preedit) || 145 if ( (NULL == preedit) ||
112 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) 146 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
@@ -127,7 +161,9 @@ libgnunet_plugin_gtk_namestore_gns2dns_init (void *cls)
127 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 161 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
128 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 162 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
129 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = { 163 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
130 { "GNS_edit_dialog_gns2dns_entry_changed_cb", 164 { "GNS_edit_dialog_gns2dns_ip_entry_changed_cb",
165 G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) },
166 { "GNS_edit_dialog_gns2dns_ns_entry_changed_cb",
131 G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) }, 167 G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) },
132 { NULL, NULL } 168 { NULL, NULL }
133 }; 169 };